Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ea45df8f authored by Quarx2k's avatar Quarx2k Committed by Gerrit Code Review
Browse files

Add UsbDebuggingManager and UsbDebuggingActivity to LegacyUsbManager

The UsbDebuggingManager listens to adbd requests and displays a dialog
when the public key authentification fails, for the user to confirm if it
wants to allow USB debugging from the attached host. If the user chooses
to always allow USB debugging, the UsbDebuggingManager writes the public
key to adbd's config file so that the public key authenfication succeeds
next time.

Change-Id: I819b8a0428ba34b68dadeb9fa67c53abb9a85fbc
parent 9f94d8de
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ public class LegacyUsbDeviceManager extends UsbDeviceManager {
    private boolean mUseUsbNotification;
    private boolean mAdbEnabled;
    private boolean mLegacy = false;
    private UsbDebuggingManager mDebuggingManager;

    private class AdbSettingsObserver extends ContentObserver {
        public AdbSettingsObserver() {
@@ -165,6 +166,9 @@ public class LegacyUsbDeviceManager extends UsbDeviceManager {
                Process.THREAD_PRIORITY_BACKGROUND);
        thread.start();
        mHandler = new LegacyUsbHandler(thread.getLooper());
        if ("1".equals(SystemProperties.get("ro.adb.secure"))) {
            mDebuggingManager = new UsbDebuggingManager(context);
        }
    }

    public void setCurrentSettings(UsbSettingsManager settings) {
@@ -552,6 +556,9 @@ public class LegacyUsbDeviceManager extends UsbDeviceManager {
                    if (mCurrentAccessory != null) {
                        getCurrentSettings().accessoryAttached(mCurrentAccessory);
                    }
                    if (mDebuggingManager != null) {
                        mDebuggingManager.setAdbEnabled(mAdbEnabled);
                    }
                    break;
            }
        }
@@ -673,4 +680,25 @@ public class LegacyUsbDeviceManager extends UsbDeviceManager {
            }
        }
    }

    public void allowUsbDebugging(boolean alwaysAllow, String publicKey) {
        if (mDebuggingManager != null) {
            mDebuggingManager.allowUsbDebugging(alwaysAllow, publicKey);
        }
    }

    public void denyUsbDebugging() {
        if (mDebuggingManager != null) {
            mDebuggingManager.denyUsbDebugging();
        }
    }

    public void dump(FileDescriptor fd, PrintWriter pw) {
        if (mHandler != null) {
            mHandler.dump(fd, pw);
        }
        if (mDebuggingManager != null) {
            mDebuggingManager.dump(fd, pw);
        }
    }
}