From ae69755aa874dbac77e9874d9716ab891a144193 Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Tue, 27 Sep 2011 11:33:17 -0700 Subject: Disable USB connection type when monkeys are running. Bug: 5375336 Also use the correct API for testing if monkeys are running. (ActivityManager.isUserAMonkey()) Bug: 5375910 Change-Id: I2bf8e061ee5977d521de197d3a92095c1a98218d --- src/com/android/settings/Utils.java | 3 ++- src/com/android/settings/deviceinfo/UsbSettings.java | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src/com') diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java index 90336e2..ac6cb64 100644 --- a/src/com/android/settings/Utils.java +++ b/src/com/android/settings/Utils.java @@ -16,6 +16,7 @@ package com.android.settings; +import android.app.ActivityManager; import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; @@ -278,7 +279,7 @@ public class Utils { * Returns true if Monkey is running. */ public static boolean isMonkeyRunning() { - return SystemProperties.getBoolean("ro.monkey", false); + return ActivityManager.isUserAMonkey(); } /** diff --git a/src/com/android/settings/deviceinfo/UsbSettings.java b/src/com/android/settings/deviceinfo/UsbSettings.java index 538cde7..c8671b9 100644 --- a/src/com/android/settings/deviceinfo/UsbSettings.java +++ b/src/com/android/settings/deviceinfo/UsbSettings.java @@ -34,6 +34,7 @@ import android.util.Log; import com.android.settings.R; import com.android.settings.SettingsPreferenceFragment; +import com.android.settings.Utils; /** * USB storage settings. @@ -111,6 +112,11 @@ public class UsbSettings extends SettingsPreferenceFragment { @Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { + // Don't allow any changes to take effect as the USB host will be disconnected, killing + // the monkeys + if (Utils.isMonkeyRunning()) { + return true; + } // temporary hack - using check boxes as radio buttons // don't allow unchecking them if (preference instanceof CheckBoxPreference) { -- cgit v1.1