summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Mak <tonymak@google.com>2016-04-19 10:32:29 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-04-19 10:32:33 +0000
commit882a0802a7f7268750b15adb8747dd3904f935b0 (patch)
treecd77e71e27c1fb6cc7c2beada69d46f90dacbc17
parentbf8207e270b1af908278b7a58c33a3e16d425cac (diff)
parent2c11dc99632354836281cbe3000b911e72a30d14 (diff)
Merge "User action should only stop lock task mode if it is in pinned mode" into nyc-dev
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java43
1 files changed, 25 insertions, 18 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 8653f1ad0000..a60690c5e811 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -9970,19 +9970,25 @@ public final class ActivityManagerService extends ActivityManagerNative
final int callingUid = Binder.getCallingUid();
final int lockTaskUid = lockTask.mLockTaskUid;
- // Ensure the same caller for startLockTaskMode and stopLockTaskMode.
- // It is possible lockTaskMode was started by the system process because
- // android:lockTaskMode is set to a locking value in the application manifest instead of
- // the app calling startLockTaskMode. In this case {@link TaskRecord.mLockTaskUid} will
- // be 0, so we compare the callingUid to the {@link TaskRecord.effectiveUid} instead.
- if (getLockTaskModeState() == ActivityManager.LOCK_TASK_MODE_LOCKED &&
- callingUid != lockTaskUid
- && (lockTaskUid != 0
- || (lockTaskUid == 0 && callingUid != lockTask.effectiveUid))) {
- throw new SecurityException("Invalid uid, expected " + lockTaskUid
- + " callingUid=" + callingUid + " effectiveUid=" + lockTask.effectiveUid);
+ final int lockTaskModeState = mStackSupervisor.getLockTaskModeState();
+ if (lockTaskModeState == ActivityManager.LOCK_TASK_MODE_NONE) {
+ // Done.
+ return;
+ } else {
+ // Ensure the same caller for startLockTaskMode and stopLockTaskMode.
+ // It is possible lockTaskMode was started by the system process because
+ // android:lockTaskMode is set to a locking value in the application manifest
+ // instead of the app calling startLockTaskMode. In this case
+ // {@link TaskRecord.mLockTaskUid} will be 0, so we compare the callingUid to the
+ // {@link TaskRecord.effectiveUid} instead. Also caller with
+ // {@link MANAGE_ACTIVITY_STACKS} can stop any lock task.
+ if (checkCallingPermission(MANAGE_ACTIVITY_STACKS) != PERMISSION_GRANTED
+ && callingUid != lockTaskUid
+ && (lockTaskUid != 0 || callingUid != lockTask.effectiveUid)) {
+ throw new SecurityException("Invalid uid, expected " + lockTaskUid
+ + " callingUid=" + callingUid + " effectiveUid=" + lockTask.effectiveUid);
+ }
}
-
long ident = Binder.clearCallingIdentity();
try {
Log.d(TAG, "stopLockTaskMode");
@@ -9996,15 +10002,16 @@ public final class ActivityManagerService extends ActivityManagerNative
}
}
+ /**
+ * This API should be called by SystemUI only when user perform certain action to dismiss
+ * lock task mode. We should only dismiss pinned lock task mode in this case.
+ */
@Override
public void stopSystemLockTaskMode() throws RemoteException {
- enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "stopSystemLockTaskMode");
- // This makes inner call to look as if it was initiated by system.
- long ident = Binder.clearCallingIdentity();
- try {
+ if (mStackSupervisor.getLockTaskModeState() == ActivityManager.LOCK_TASK_MODE_PINNED) {
stopLockTaskMode();
- } finally {
- Binder.restoreCallingIdentity(ident);
+ } else {
+ mStackSupervisor.showLockTaskToast();
}
}