summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Tony Mak <tonymak@google.com> 2016-03-21 12:20:41 +0000
committer Tony Mak <tonymak@google.com> 2016-03-21 14:29:17 +0000
commit8c536f91f1a72f671d41d54b3aeda4d70ee90d49 (patch)
tree6d7f5b19bdc105c48ff62e44f6f3c7907f758ecd
parent47fcbd823cda4f98974dd6c5f1079ebdc4d27245 (diff)
Show work challenge directly when there is no device lock
The trick is to switch to home stack first and then start the activity of the targeted task again to trigger the intercepting code. And back button in the lock screen page brings user to launcher instead of the work app. Change-Id: Ic0305dbcb63fec2a8287b12f3e76e70d4268d423
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java15
-rw-r--r--services/core/java/com/android/server/am/UserController.java5
2 files changed, 19 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index e653d5184e4c..5aac43d910f7 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -11420,7 +11420,20 @@ public final class ActivityManagerService extends ActivityManagerNative
final long ident = Binder.clearCallingIdentity();
try {
final int currentUserId = mUserController.getCurrentUserIdLocked();
- startHomeActivityLocked(currentUserId, "notifyProfileLocked");
+ // Get the focused task before launching launcher.
+ final int taskId = (mFocusedActivity == null)
+ ? -1 : mFocusedActivity.task.taskId;
+ startHomeActivityLocked(currentUserId, "notifyLockedProfile");
+ if (mUserController.isLockScreenDisabled(currentUserId)) {
+ // If there is no device lock, we first go to launcher and then resume the
+ // original task. Work challenge will be shown because we intercepted
+ // startActivityFromRecentsInner and the reason why we switch to home stack
+ // first is to prevent pressing back button brings user back to the work
+ // app.
+ if (taskId != -1) {
+ startActivityFromRecentsInner(taskId, null);
+ }
+ }
} finally {
Binder.restoreCallingIdentity(ident);
}
diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java
index 59c2682bdb0f..5baba524aab4 100644
--- a/services/core/java/com/android/server/am/UserController.java
+++ b/services/core/java/com/android/server/am/UserController.java
@@ -39,6 +39,7 @@ import static com.android.server.am.ActivityManagerService.SYSTEM_USER_UNLOCK_MS
import static com.android.server.am.ActivityManagerService.USER_SWITCH_TIMEOUT_MSG;
import android.annotation.NonNull;
+import android.annotation.UserIdInt;
import android.app.ActivityManager;
import android.app.AppOpsManager;
import android.app.Dialog;
@@ -1340,6 +1341,10 @@ final class UserController {
return km.isDeviceLocked(userId);
}
+ boolean isLockScreenDisabled(@UserIdInt int userId) {
+ return mLockPatternUtils.isLockScreenDisabled(userId);
+ }
+
void dump(PrintWriter pw, boolean dumpAll) {
pw.println(" mStartedUsers:");
for (int i = 0; i < mStartedUsers.size(); i++) {