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
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
|
import android.app.ActivityManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
@@ -278,7 +279,7 @@ public class Utils {
|
|||||||
* Returns true if Monkey is running.
|
* Returns true if Monkey is running.
|
||||||
*/
|
*/
|
||||||
public static boolean isMonkeyRunning() {
|
public static boolean isMonkeyRunning() {
|
||||||
return SystemProperties.getBoolean("ro.monkey", false);
|
return ActivityManager.isUserAMonkey();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -34,6 +34,7 @@ import android.util.Log;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
import com.android.settings.SettingsPreferenceFragment;
|
||||||
|
import com.android.settings.Utils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* USB storage settings.
|
* USB storage settings.
|
||||||
@@ -111,6 +112,11 @@ public class UsbSettings extends SettingsPreferenceFragment {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
|
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
|
// temporary hack - using check boxes as radio buttons
|
||||||
// don't allow unchecking them
|
// don't allow unchecking them
|
||||||
if (preference instanceof CheckBoxPreference) {
|
if (preference instanceof CheckBoxPreference) {
|
||||||
|
Reference in New Issue
Block a user