From 1f15be80a0a0c10333f02e5938641e36c99a8caf Mon Sep 17 00:00:00 2001 From: William Hester Date: Thu, 16 Apr 2020 14:23:00 -0700 Subject: [PATCH] Ensure ADB is stopped when enabling Test Harness Mode Because adbd may be enabled before TestHarnessModeService activates Test Harness Mode, we need to stop ADB by turning the setting off. For user builds, this is a no-op. For userdebug and eng builds, this stops adbd and restarts it immediately afterwards. This allows the newly-created keys to be loaded when adbd starts up. Change-Id: Ia673d1c18aba2e33d4df901ffe982122da4cb295 Bug: 150721793 (cherry picked from commit e2f1fe31e7f94c26e3c9208d061b11cac1a63655) --- .../android/server/testharness/TestHarnessModeService.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/core/java/com/android/server/testharness/TestHarnessModeService.java b/services/core/java/com/android/server/testharness/TestHarnessModeService.java index c2ecd41e7dbfd..735a9e41a03bb 100644 --- a/services/core/java/com/android/server/testharness/TestHarnessModeService.java +++ b/services/core/java/com/android/server/testharness/TestHarnessModeService.java @@ -161,6 +161,10 @@ public class TestHarnessModeService extends SystemService { private void configureSettings() { ContentResolver cr = getContext().getContentResolver(); + // Stop ADB before we enable it, otherwise on userdebug/eng builds, the keys won't have + // registered with adbd, and it will prompt the user to confirm the keys. + Settings.Global.putInt(cr, Settings.Global.ADB_ENABLED, 0); + // Disable the TTL for ADB keys before enabling ADB Settings.Global.putLong(cr, Settings.Global.ADB_ALLOWED_CONNECTION_TIME, 0); Settings.Global.putInt(cr, Settings.Global.ADB_ENABLED, 1);