summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Tony Mak <tonymak@google.com> 2016-03-24 12:23:22 +0000
committer Tony Mak <tonymak@google.com> 2016-03-24 20:39:36 +0000
commit4291c76e8097af550972b51aeda1b0b1dcf4fb5b (patch)
treead49df4d593e48ec683ce892499509874a3c442f
parent482c7da6ab5a95a28ee64cb4a0365b85e8681afb (diff)
Use FLAG_ACTIVITY_TASK_ON_HOME to make sure back button brings user to home
In work challenge, we want to show home when user taps back button. Previously, we do this by launching launcher before showing work challenge. We now use FLAG_ACTIVITY_TASK_ON_HOME instead. Bug: 27826548 Change-Id: I74cca611bf00c6f53b4752f2967a0c729ddf2d61
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java18
-rw-r--r--services/core/java/com/android/server/am/ActivityStartInterceptor.java5
2 files changed, 11 insertions, 12 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index c1ec71c92a2d..95a8988efd4c 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -11422,18 +11422,16 @@ public final class ActivityManagerService extends ActivityManagerNative
try {
final int currentUserId = mUserController.getCurrentUserIdLocked();
// 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);
+ // If there is no device lock, we will show the profile's credential page.
+ // startActivityFromRecentsInner is intercepted and will forward user to it.
+ if (mFocusedActivity != null) {
+ startActivityFromRecentsInner(mFocusedActivity.task.taskId, null);
}
+ } else {
+ // Showing launcher to avoid user entering credential twice.
+ startHomeActivityLocked(currentUserId, "notifyLockedProfile");
}
} finally {
Binder.restoreCallingIdentity(ident);
diff --git a/services/core/java/com/android/server/am/ActivityStartInterceptor.java b/services/core/java/com/android/server/am/ActivityStartInterceptor.java
index 13d90e3f2672..76dfd015ee0b 100644
--- a/services/core/java/com/android/server/am/ActivityStartInterceptor.java
+++ b/services/core/java/com/android/server/am/ActivityStartInterceptor.java
@@ -26,6 +26,7 @@ import static android.content.Intent.EXTRA_PACKAGE_NAME;
import static android.content.Intent.EXTRA_TASK_ID;
import static android.content.Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
+import static android.content.Intent.FLAG_ACTIVITY_TASK_ON_HOME;
import static android.content.pm.ApplicationInfo.FLAG_SUSPENDED;
import android.app.KeyguardManager;
@@ -192,14 +193,14 @@ class ActivityStartInterceptor {
Binder.getCallingUid(), userId, null, null, 0, new Intent[]{ intent },
new String[]{ resolvedType },
FLAG_CANCEL_CURRENT | FLAG_ONE_SHOT | FLAG_IMMUTABLE, null);
- final int flags = intent.getFlags();
final KeyguardManager km = (KeyguardManager) mService.mContext
.getSystemService(KEYGUARD_SERVICE);
final Intent newIntent = km.createConfirmDeviceCredentialIntent(null, null, userId);
if (newIntent == null) {
return null;
}
- newIntent.setFlags(flags | FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
+ newIntent.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS |
+ FLAG_ACTIVITY_TASK_ON_HOME);
newIntent.putExtra(EXTRA_PACKAGE_NAME, aInfo.packageName);
newIntent.putExtra(EXTRA_INTENT, new IntentSender(target));
return newIntent;