am 3b4fcbc9: Add ActivityManager#isRunningInTestHarness() public API.
* commit '3b4fcbc9f13bab6a2e9e5c37cc5e18fec7341c04': Add ActivityManager#isRunningInTestHarness() public API.
This commit is contained in:
@@ -24982,6 +24982,17 @@
|
|||||||
<exception name="SecurityException" type="java.lang.SecurityException">
|
<exception name="SecurityException" type="java.lang.SecurityException">
|
||||||
</exception>
|
</exception>
|
||||||
</method>
|
</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"
|
<method name="isUserAMonkey"
|
||||||
return="boolean"
|
return="boolean"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import com.android.internal.telephony.ITelephony;
|
|||||||
import com.android.internal.telephony.TelephonyIntents;
|
import com.android.internal.telephony.TelephonyIntents;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
|
import android.app.ActivityManager;
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
@@ -162,8 +163,6 @@ public class AccountManagerService
|
|||||||
private static AtomicReference<AccountManagerService> sThis =
|
private static AtomicReference<AccountManagerService> sThis =
|
||||||
new AtomicReference<AccountManagerService>();
|
new AtomicReference<AccountManagerService>();
|
||||||
|
|
||||||
private static final boolean isDebuggableMonkeyBuild =
|
|
||||||
SystemProperties.getBoolean("ro.monkey", false);
|
|
||||||
private static final Account[] EMPTY_ACCOUNT_ARRAY = new Account[]{};
|
private static final Account[] EMPTY_ACCOUNT_ARRAY = new Account[]{};
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@@ -1992,12 +1991,12 @@ public class AccountManagerService
|
|||||||
account.name, account.type};
|
account.name, account.type};
|
||||||
final boolean permissionGranted =
|
final boolean permissionGranted =
|
||||||
DatabaseUtils.longForQuery(db, COUNT_OF_MATCHING_GRANTS, args) != 0;
|
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
|
// TODO: Skip this check when running automated tests. Replace this
|
||||||
// with a more general solution.
|
// with a more general solution.
|
||||||
Log.d(TAG, "no credentials permission for usage of " + account + ", "
|
Log.d(TAG, "no credentials permission for usage of " + account + ", "
|
||||||
+ authTokenType + " by uid " + Binder.getCallingUid()
|
+ authTokenType + " by uid " + Binder.getCallingUid()
|
||||||
+ " but ignoring since this is a monkey build");
|
+ " but ignoring since device is in test harness.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return permissionGranted;
|
return permissionGranted;
|
||||||
|
|||||||
@@ -1149,4 +1149,11 @@ public class ActivityManager {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns "true" if device is running in a test harness.
|
||||||
|
*/
|
||||||
|
public static boolean isRunningInTestHarness() {
|
||||||
|
return SystemProperties.getBoolean("ro.test_harness", false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import com.android.internal.widget.SlidingTab;
|
|||||||
import com.android.internal.widget.WaveView;
|
import com.android.internal.widget.WaveView;
|
||||||
import com.android.internal.widget.WaveView.OnTriggerListener;
|
import com.android.internal.widget.WaveView.OnTriggerListener;
|
||||||
|
|
||||||
|
import android.app.ActivityManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
@@ -250,9 +251,9 @@ class LockScreen extends LinearLayout implements KeyguardScreen,
|
|||||||
private boolean shouldEnableMenuKey() {
|
private boolean shouldEnableMenuKey() {
|
||||||
final Resources res = getResources();
|
final Resources res = getResources();
|
||||||
final boolean configDisabled = res.getBoolean(R.bool.config_disableMenuKeyInLockScreen);
|
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();
|
final boolean fileOverride = (new File(ENABLE_MENU_KEY_FILE)).exists();
|
||||||
return !configDisabled || isMonkey || fileOverride;
|
return !configDisabled || isTestHarness || fileOverride;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user