AdbLib icon indicating copy to clipboard operation
AdbLib copied to clipboard

Re-prompt to allow USB debugging

Open FnAndroid opened this issue 7 years ago • 13 comments

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 avatar May 23 '17 08:05 FnAndroid

@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.

saiprasad1996 avatar May 25 '17 03:05 saiprasad1996

Yes,I checked it.However,no way.

FnAndroid avatar May 26 '17 03:05 FnAndroid

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.

lgianca avatar Jul 18 '18 23:07 lgianca

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);
    }
  };
}

amitv87 avatar Aug 06 '18 19:08 amitv87

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 .

lgianca avatar Aug 06 '18 20:08 lgianca

Thank you very much amitv87.

tangyong2019 avatar May 28 '19 08:05 tangyong2019

@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 avatar Dec 29 '21 07:12 piyush2cloud

@piyush2cloud Do you also face reprompt issue with USB ADB connections?

amitv87 avatar Dec 29 '21 07:12 amitv87

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.

piyush2cloud avatar Dec 29 '21 07:12 piyush2cloud

@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 avatar Dec 29 '21 08:12 piyush2cloud

@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 avatar Dec 29 '21 09:12 amitv87

@amitv87 I am not using any physical cable.

piyush2cloud avatar Dec 29 '21 09:12 piyush2cloud

@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.

mirfatif avatar Dec 30 '21 02:12 mirfatif