summaryrefslogtreecommitdiffstats
path: root/services/java
diff options
context:
space:
mode:
authorSvetoslav Ganov <svetoslavganov@google.com>2013-04-12 17:17:59 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-04-12 17:17:59 -0700
commitdd03b6dcb74ee05921086518e5b7f41e6468eae3 (patch)
treed1f5ec48831b43ceaaa4d5303ad0fbf0870d7304 /services/java
parent640769589b5eb6a4c9a09f8710c3a585320fa075 (diff)
parent26257a09a54cda5e8a0bc5b1edb0a5b401983a3b (diff)
downloadframeworks_base-dd03b6dcb74ee05921086518e5b7f41e6468eae3.zip
frameworks_base-dd03b6dcb74ee05921086518e5b7f41e6468eae3.tar.gz
frameworks_base-dd03b6dcb74ee05921086518e5b7f41e6468eae3.tar.bz2
am 26257a09: Merge "Allow for setting test type as a monkey." into jb-mr2-dev
* commit '26257a09a54cda5e8a0bc5b1edb0a5b401983a3b': Allow for setting test type as a monkey.
Diffstat (limited to 'services/java')
-rw-r--r--services/java/com/android/server/am/ActivityManagerService.java31
1 files changed, 28 insertions, 3 deletions
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 2417cff..bc1df85 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -936,6 +936,12 @@ public final class ActivityManagerService extends ActivityManagerNative
CompatModeDialog mCompatModeDialog;
long mLastMemUsageReportTime = 0;
+ /**
+ * Flag whether the current user is a "monkey", i.e. whether
+ * the UI is driven by a UI automation tool.
+ */
+ private boolean mUserIsMonkey;
+
final Handler mHandler = new Handler() {
//public Handler() {
// if (localLOGV) Slog.v(TAG, "Handler started!");
@@ -7434,11 +7440,27 @@ public final class ActivityManagerService extends ActivityManagerNative
}
}
+ public void setUserIsMonkey(boolean userIsMonkey) {
+ synchronized (this) {
+ synchronized (mPidsSelfLocked) {
+ final int callingPid = Binder.getCallingPid();
+ ProcessRecord precessRecord = mPidsSelfLocked.get(callingPid);
+ if (precessRecord == null) {
+ throw new SecurityException("Unknown process: " + callingPid);
+ }
+ if (precessRecord.instrumentationUiAutomationConnection == null) {
+ throw new SecurityException("Only an instrumentation process "
+ + "with a UiAutomation can call setUserIsMonkey");
+ }
+ }
+ mUserIsMonkey = userIsMonkey;
+ }
+ }
+
public boolean isUserAMonkey() {
- // For now the fact that there is a controller implies
- // we have a monkey.
synchronized (this) {
- return mController != null;
+ // If there is a controller also implies the user is a monkey.
+ return (mUserIsMonkey || mController != null);
}
}
@@ -12435,6 +12457,9 @@ public final class ActivityManagerService extends ActivityManagerNative
} catch (RemoteException re) {
/* ignore */
}
+ // Only a UiAutomation can set this flag and now that
+ // it is finished we make sure it is reset to its default.
+ mUserIsMonkey = false;
}
app.instrumentationWatcher = null;
app.instrumentationUiAutomationConnection = null;