Loading services/core/java/com/android/server/adb/AdbDebuggingManager.java +28 −9 Original line number Diff line number Diff line Loading @@ -571,14 +571,7 @@ public class AdbDebuggingManager { static final String MSG_START_ADB_WIFI = "W1"; static final String MSG_STOP_ADB_WIFI = "W0"; @VisibleForTesting @NonNull final AdbKeyStore mAdbKeyStore = new AdbKeyStore( mContext, mTempKeysFile, mUserKeyFile, mTicker, () -> sendPersistKeyStoreMessage()); @Nullable @VisibleForTesting AdbKeyStore mAdbKeyStore; private final AdbDebuggingThread mThread; Loading Loading @@ -612,6 +605,20 @@ public class AdbDebuggingManager { } } /** Initialize the AdbKeyStore so tests can grab mAdbKeyStore immediately. */ @VisibleForTesting void initKeyStore() { if (mAdbKeyStore == null) { mAdbKeyStore = new AdbKeyStore( mContext, mTempKeysFile, mUserKeyFile, mTicker, () -> sendPersistKeyStoreMessage()); } } // Show when at least one device is connected. public void showAdbConnectedNotification(boolean show) { final int id = SystemMessage.NOTE_ADB_WIFI_ACTIVE; Loading Loading @@ -659,6 +666,8 @@ public class AdbDebuggingManager { } public void handleMessage(Message msg) { initKeyStore(); switch (msg.what) { case MESSAGE_ADB_ENABLED -> { if (mAdbUsbEnabled) { Loading Loading @@ -718,6 +727,9 @@ public class AdbDebuggingManager { case MESSAGE_ADB_CLEAR -> { Slog.d(TAG, "Received a request to clear the adb authorizations"); mConnectedKeys.clear(); // If the key store has not yet been instantiated then do so now; this avoids // the unnecessary creation of the key store when adb is not enabled. initKeyStore(); mWifiConnectedKeys.clear(); mAdbKeyStore.deleteKeyStore(); cancelJobToUpdateAdbKeyStore(); Loading Loading @@ -1441,7 +1453,14 @@ public class AdbDebuggingManager { /** Returns the list of paired devices. */ public Map<String, PairDevice> getPairedDevices() { return getPairedDevicesForKeys(mHandler.mAdbKeyStore.getKeys()); AdbKeyStore keystore = new AdbKeyStore( mContext, mTempKeysFile, mUserKeyFile, mTicker, () -> sendPersistKeyStoreMessage()); return getPairedDevicesForKeys(keystore.getKeys()); } private Map<String, PairDevice> getPairedDevicesForKeys(Set<String> keys) { Loading services/tests/servicestests/src/com/android/server/adb/AdbDebuggingManagerTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -118,6 +118,7 @@ public final class AdbDebuggingManagerTest { mHandler = mManager.mHandler; mThread.setHandler(mHandler); mHandler.initKeyStore(); mKeyStore = mHandler.mAdbKeyStore; mOriginalAllowedConnectionTime = mKeyStore.getAllowedConnectionTime(); Loading Loading
services/core/java/com/android/server/adb/AdbDebuggingManager.java +28 −9 Original line number Diff line number Diff line Loading @@ -571,14 +571,7 @@ public class AdbDebuggingManager { static final String MSG_START_ADB_WIFI = "W1"; static final String MSG_STOP_ADB_WIFI = "W0"; @VisibleForTesting @NonNull final AdbKeyStore mAdbKeyStore = new AdbKeyStore( mContext, mTempKeysFile, mUserKeyFile, mTicker, () -> sendPersistKeyStoreMessage()); @Nullable @VisibleForTesting AdbKeyStore mAdbKeyStore; private final AdbDebuggingThread mThread; Loading Loading @@ -612,6 +605,20 @@ public class AdbDebuggingManager { } } /** Initialize the AdbKeyStore so tests can grab mAdbKeyStore immediately. */ @VisibleForTesting void initKeyStore() { if (mAdbKeyStore == null) { mAdbKeyStore = new AdbKeyStore( mContext, mTempKeysFile, mUserKeyFile, mTicker, () -> sendPersistKeyStoreMessage()); } } // Show when at least one device is connected. public void showAdbConnectedNotification(boolean show) { final int id = SystemMessage.NOTE_ADB_WIFI_ACTIVE; Loading Loading @@ -659,6 +666,8 @@ public class AdbDebuggingManager { } public void handleMessage(Message msg) { initKeyStore(); switch (msg.what) { case MESSAGE_ADB_ENABLED -> { if (mAdbUsbEnabled) { Loading Loading @@ -718,6 +727,9 @@ public class AdbDebuggingManager { case MESSAGE_ADB_CLEAR -> { Slog.d(TAG, "Received a request to clear the adb authorizations"); mConnectedKeys.clear(); // If the key store has not yet been instantiated then do so now; this avoids // the unnecessary creation of the key store when adb is not enabled. initKeyStore(); mWifiConnectedKeys.clear(); mAdbKeyStore.deleteKeyStore(); cancelJobToUpdateAdbKeyStore(); Loading Loading @@ -1441,7 +1453,14 @@ public class AdbDebuggingManager { /** Returns the list of paired devices. */ public Map<String, PairDevice> getPairedDevices() { return getPairedDevicesForKeys(mHandler.mAdbKeyStore.getKeys()); AdbKeyStore keystore = new AdbKeyStore( mContext, mTempKeysFile, mUserKeyFile, mTicker, () -> sendPersistKeyStoreMessage()); return getPairedDevicesForKeys(keystore.getKeys()); } private Map<String, PairDevice> getPairedDevicesForKeys(Set<String> keys) { Loading
services/tests/servicestests/src/com/android/server/adb/AdbDebuggingManagerTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -118,6 +118,7 @@ public final class AdbDebuggingManagerTest { mHandler = mManager.mHandler; mThread.setHandler(mHandler); mHandler.initKeyStore(); mKeyStore = mHandler.mAdbKeyStore; mOriginalAllowedConnectionTime = mKeyStore.getAllowedConnectionTime(); Loading