AdbLib
AdbLib copied to clipboard
Re-prompt to allow USB debugging
Please look at my issue.Thank you very much.
Old issure: I am using your adblib, thank you very much for being open source. I met a question and wanted to ask for your help. I use your project on Android, the code as same as your demo, the interface is AdbCrypto.loadAdbKeyPair.However,when I re-open my application, it need to re-prompt to allow USB debugging, but the computer's RSA key as same as last RSA.
@FnAndroid While authenticating ADB at the android end there is a check box in the dialog which asks to remember the computer.. Did you check it ? If that isn't check everytime you connect your phone a new RSA is generated at the android end which does not match the previous RSA stored at the computer.
Yes,I checked it.However,no way.
First of all thank you for open sourcing this helpful library.
I am having the same issue as FnAndroid. Even after clicking on the remind me box it android carries on asking for a debugging confirmation. Interestingly the RSA fingerprint shown is always the same.
This can be solved by creating base64 encoded string without line breaks. Have a look at the code below...
public static AdbBase64 getBase64Impl() {
return new AdbBase64() {
@Override
public String encodeToString(byte[] arg0) {
return android.util.Base64.encodeToString(arg0, android.util.Base64.NO_WRAP);
}
};
}
It works like a charm. Thank you very much!!!
On Mon, 6 Aug 2018 at 14:50, boggyb [email protected] wrote:
This can be solved by creating base64 encoded string without line breaks. Have a look at the code below...
public static AdbBase64 getBase64Impl() { return new AdbBase64() { @Override public String encodeToString(byte[] arg0) { return android.util.Base64.encodeToString(arg0, android.util.Base64.NO_WRAP); } }; }
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/cgutman/AdbLib/issues/6#issuecomment-410831816, or mute the thread https://github.com/notifications/unsubscribe-auth/ASetKkzXPWs40VJ94xfXSS-yI7w4mvyBks5uOJ4dgaJpZM4NjWCR .
Thank you very much amitv87.
@amitv87 @lgianca @tangyong2019
Thanks for ur solution on ADB RePrompt on adblib but I am still facing reprompt. Its reprompting me again when i close and open the application again. Please help.
This is piece of code in my OnCreate Method:
Socket socket = new Socket("192.168.1.4", 5555);
AdbCrypto crypto = AdbCrypto.generateAdbKeyPair(new AdbBase64() { @Override public String encodeToString(byte[] data) { return android.util.Base64.encodeToString(data, android.util.Base64.NO_WRAP); } });
connection = AdbConnection.create(socket, crypto);
connection.connect();
AdbStream stream = connection.open("shell:input keyevent 20");
I don't want the reprompt to occur again if its already connected.
@piyush2cloud Do you also face reprompt issue with USB ADB connections?
Yes @amitv87
The thing is that whenenver my app opens onCreate Method is called and connection.connect() brings the Allow USB Debugging prompt on the Device to connect
Don't want the prompt to come again if already accepted.
@amitv87 This is the piece of code in onCreate()
Socket socket = new Socket("192.168.1.4", 5555);
AdbCrypto crypto = AdbCrypto.generateAdbKeyPair(new AdbBase64() { @OverRide public String encodeToString(byte[] data) { return android.util.Base64.encodeToString(data, android.util.Base64.NO_WRAP); } });
connection = AdbConnection.create(socket, crypto);
connection.connect();
AdbStream stream = connection.open("shell:input keyevent 20");
@piyush2cloud My previous question is not specific to this library but with respect to a physical USB cable. If you do face re-prompt issue with physical USB cable then the problem is with your android device.
@amitv87 I am not using any physical cable.
@piyush2cloud re-prompting is expected behavior in your case. You are using AdbCrypto.generateAdbKeyPair()
in onCreate()
. It creates a new keypair everytime. Instead create keypair once, save both files in a secure place, and then use AdbCrypto.loadAdbKeyPair()
ever afterwards. See sample app.