OSDN Git Service

Assume virtual devices always have USB connection.
authorJeff Sharkey <jsharkey@android.com>
Tue, 27 Jun 2017 01:57:16 +0000 (19:57 -0600)
committerJeff Sharkey <jsharkey@android.com>
Tue, 27 Jun 2017 01:57:19 +0000 (19:57 -0600)
We use the presence of an active USB data connection to suppress
the RescueParty logic.  For example, all physical devices in a test
lab return "true" here to avoid interfering with test results.

Since virtual devices are pretty much only used in test labs, return
true for them too.

Bug: 37347800
Test: builds, boots
Change-Id: Ie79ce57ce67fb78234c1001a593918253a85254d

services/core/java/com/android/server/RescueParty.java

index 3b36c3c..1924a86 100644 (file)
@@ -55,6 +55,7 @@ public class RescueParty {
     private static final String PROP_RESCUE_LEVEL = "sys.rescue_level";
     private static final String PROP_RESCUE_BOOT_COUNT = "sys.rescue_boot_count";
     private static final String PROP_RESCUE_BOOT_START = "sys.rescue_boot_start";
+    private static final String PROP_VIRTUAL_DEVICE = "ro.hardware.virtual_device";
 
     private static final int LEVEL_NONE = 0;
     private static final int LEVEL_RESET_SETTINGS_UNTRUSTED_DEFAULTS = 1;
@@ -336,6 +337,10 @@ public class RescueParty {
      * a good proxy for someone doing local development work.
      */
     private static boolean isUsbActive() {
+        if (SystemProperties.getBoolean(PROP_VIRTUAL_DEVICE, false)) {
+            Slog.v(TAG, "Assuming virtual device is connected over USB");
+            return true;
+        }
         try {
             final String state = FileUtils
                     .readTextFile(new File("/sys/class/android_usb/android0/state"), 128, "");