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

Commit 3b4fcbc9 authored by Brett Chabot's avatar Brett Chabot
Browse files

Add ActivityManager#isRunningInTestHarness() public API.

Replaces use of ro.monkey system property. This new API is controlled by
ro.test_harness.

Bug 3329873

Change-Id: Idb5bbbd9ca691976ef842eec681be34c29915976
parent ac0f347e
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -24982,6 +24982,17 @@
<exception name="SecurityException" type="java.lang.SecurityException">
</exception>
</method>
<method name="isRunningInTestHarness"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="isUserAMonkey"
 return="boolean"
 abstract="false"
+3 −4
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.TelephonyIntents;

import android.Manifest;
import android.app.ActivityManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
@@ -162,8 +163,6 @@ public class AccountManagerService
    private static AtomicReference<AccountManagerService> sThis =
            new AtomicReference<AccountManagerService>();

    private static final boolean isDebuggableMonkeyBuild =
            SystemProperties.getBoolean("ro.monkey", false);
    private static final Account[] EMPTY_ACCOUNT_ARRAY = new Account[]{};

    static {
@@ -1992,12 +1991,12 @@ public class AccountManagerService
                account.name, account.type};
        final boolean permissionGranted =
                DatabaseUtils.longForQuery(db, COUNT_OF_MATCHING_GRANTS, args) != 0;
        if (!permissionGranted && isDebuggableMonkeyBuild) {
        if (!permissionGranted && ActivityManager.isRunningInTestHarness()) {
            // TODO: Skip this check when running automated tests. Replace this
            // with a more general solution.
            Log.d(TAG, "no credentials permission for usage of " + account + ", "
                    + authTokenType + " by uid " + Binder.getCallingUid()
                    + " but ignoring since this is a monkey build");
                    + " but ignoring since device is in test harness.");
            return true;
        }
        return permissionGranted;
+7 −0
Original line number Diff line number Diff line
@@ -1149,4 +1149,11 @@ public class ActivityManager {
        }
        return false;
    }

    /**
     * Returns "true" if device is running in a test harness.
     */
    public static boolean isRunningInTestHarness() {
        return SystemProperties.getBoolean("ro.test_harness", false);
    }
}
+3 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import com.android.internal.widget.SlidingTab;
import com.android.internal.widget.WaveView;
import com.android.internal.widget.WaveView.OnTriggerListener;

import android.app.ActivityManager;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
@@ -250,9 +251,9 @@ class LockScreen extends LinearLayout implements KeyguardScreen,
    private boolean shouldEnableMenuKey() {
        final Resources res = getResources();
        final boolean configDisabled = res.getBoolean(R.bool.config_disableMenuKeyInLockScreen);
        final boolean isMonkey = SystemProperties.getBoolean("ro.monkey", false);
        final boolean isTestHarness = ActivityManager.isRunningInTestHarness();
        final boolean fileOverride = (new File(ENABLE_MENU_KEY_FILE)).exists();
        return !configDisabled || isMonkey || fileOverride;
        return !configDisabled || isTestHarness || fileOverride;
    }

    /**