Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ae69755a authored by Amith Yamasani's avatar Amith Yamasani
Browse files

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
parent 0e5fd21b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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();
    }

    /**
+6 −0
Original line number Diff line number Diff line
@@ -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) {