summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jorim Jaggi <jjaggi@google.com> 2018-06-01 14:45:24 +0200
committer Jorim Jaggi <jjaggi@google.com> 2018-06-01 16:32:44 +0200
commit9c52ebbf96ba04e07bde962c93f203e81621599b (patch)
tree9fa2327aa5dbc3a921cb52048a7d3d8c8b08033b
parentf225af4f6c7143fcfac837d87c9991ea91e55a5a (diff)
Crashing can not override Keyguard transit
If an app crashes during Keyguard transition, make sure to keep Keyguard transition Test: AppTransitionTests Test: go/wm-smoke Change-Id: I80b80952f93d2b5611754f05a3dc333905cd1c86 Fixes: 80132133
-rw-r--r--core/java/android/view/WindowManager.java3
-rw-r--r--services/core/java/com/android/server/am/ActivityStack.java6
-rw-r--r--services/core/java/com/android/server/wm/AppTransition.java13
-rw-r--r--services/tests/servicestests/src/com/android/server/wm/AppTransitionTests.java24
4 files changed, 37 insertions, 9 deletions
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index 37aca260c937..fc34a25cabc9 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -278,7 +278,8 @@ public interface WindowManager extends ViewManager {
TRANSIT_KEYGUARD_OCCLUDE,
TRANSIT_KEYGUARD_UNOCCLUDE,
TRANSIT_TRANSLUCENT_ACTIVITY_OPEN,
- TRANSIT_TRANSLUCENT_ACTIVITY_CLOSE
+ TRANSIT_TRANSLUCENT_ACTIVITY_CLOSE,
+ TRANSIT_CRASHING_ACTIVITY_CLOSE
})
@Retention(RetentionPolicy.SOURCE)
@interface TransitionType {}
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 748eae951379..bc95192c0a4f 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -3549,8 +3549,8 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
int taskNdx = mTaskHistory.indexOf(finishedTask);
final TaskRecord task = finishedTask;
int activityNdx = task.mActivities.indexOf(r);
- mWindowManager.prepareAppTransition(TRANSIT_CRASHING_ACTIVITY_CLOSE, false /* TODO */,
- 0, true /* forceOverride */);
+ mWindowManager.prepareAppTransition(TRANSIT_CRASHING_ACTIVITY_CLOSE,
+ false /* alwaysKeepCurrent */);
finishActivityLocked(r, Activity.RESULT_CANCELED, null, reason, false);
finishedTask = task;
// Also terminate any activities below it that aren't yet
@@ -5001,7 +5001,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
// Force the destroy to skip right to removal.
r.app = null;
mWindowManager.prepareAppTransition(TRANSIT_CRASHING_ACTIVITY_CLOSE,
- false /* TODO */, 0, true /* forceOverride */);
+ false /* alwaysKeepCurrent */);
finishCurrentActivityLocked(r, FINISH_IMMEDIATELY, false,
"handleAppCrashedLocked");
}
diff --git a/services/core/java/com/android/server/wm/AppTransition.java b/services/core/java/com/android/server/wm/AppTransition.java
index 2f174c2f5170..d73606f3003f 100644
--- a/services/core/java/com/android/server/wm/AppTransition.java
+++ b/services/core/java/com/android/server/wm/AppTransition.java
@@ -2003,8 +2003,11 @@ public class AppTransition implements Dump {
case TRANSIT_TRANSLUCENT_ACTIVITY_CLOSE: {
return "TRANSIT_TRANSLUCENT_ACTIVITY_CLOSE";
}
+ case TRANSIT_CRASHING_ACTIVITY_CLOSE: {
+ return "TRANSIT_CRASHING_ACTIVITY_CLOSE";
+ }
default: {
- return "<UNKNOWN>";
+ return "<UNKNOWN: " + transition + ">";
}
}
}
@@ -2133,15 +2136,17 @@ public class AppTransition implements Dump {
+ " " + this
+ " alwaysKeepCurrent=" + alwaysKeepCurrent
+ " Callers=" + Debug.getCallers(3));
+ final boolean allowSetCrashing = !isKeyguardTransit(mNextAppTransition)
+ && transit == TRANSIT_CRASHING_ACTIVITY_CLOSE;
if (forceOverride || isKeyguardTransit(transit) || !isTransitionSet()
- || mNextAppTransition == TRANSIT_NONE) {
+ || mNextAppTransition == TRANSIT_NONE || allowSetCrashing) {
setAppTransition(transit, flags);
}
// We never want to change from a Keyguard transit to a non-Keyguard transit, as our logic
// relies on the fact that we always execute a Keyguard transition after preparing one. We
// also don't want to change away from a crashing transition.
- else if (!alwaysKeepCurrent && !isKeyguardTransit(transit)
- && transit != TRANSIT_CRASHING_ACTIVITY_CLOSE) {
+ else if (!alwaysKeepCurrent && !isKeyguardTransit(mNextAppTransition)
+ && mNextAppTransition != TRANSIT_CRASHING_ACTIVITY_CLOSE) {
if (transit == TRANSIT_TASK_OPEN && isTransitionEqual(TRANSIT_TASK_CLOSE)) {
// Opening a new task always supersedes a close for the anim.
setAppTransition(transit, flags);
diff --git a/services/tests/servicestests/src/com/android/server/wm/AppTransitionTests.java b/services/tests/servicestests/src/com/android/server/wm/AppTransitionTests.java
index 8e5aec399bb5..be7d781799fa 100644
--- a/services/tests/servicestests/src/com/android/server/wm/AppTransitionTests.java
+++ b/services/tests/servicestests/src/com/android/server/wm/AppTransitionTests.java
@@ -17,6 +17,7 @@
package com.android.server.wm;
import static android.view.WindowManager.TRANSIT_ACTIVITY_OPEN;
+import static android.view.WindowManager.TRANSIT_CRASHING_ACTIVITY_CLOSE;
import static android.view.WindowManager.TRANSIT_KEYGUARD_GOING_AWAY;
import static android.view.WindowManager.TRANSIT_KEYGUARD_UNOCCLUDE;
import static org.junit.Assert.assertEquals;
@@ -35,7 +36,7 @@ import org.junit.runner.RunWith;
/**
* Test class for {@link AppTransition}.
*
- * runtest frameworks-services -c com.android.server.wm.AppTransitionTests
+ * atest AppTransitionTests
*/
@SmallTest
@Presubmit
@@ -60,10 +61,31 @@ public class AppTransitionTests {
}
@Test
+ public void testKeyguardKeep() throws Exception {
+ mWm.prepareAppTransition(TRANSIT_KEYGUARD_GOING_AWAY, false /* alwaysKeepCurrent */);
+ mWm.prepareAppTransition(TRANSIT_ACTIVITY_OPEN, false /* alwaysKeepCurrent */);
+ assertEquals(TRANSIT_KEYGUARD_GOING_AWAY, mWm.mAppTransition.getAppTransition());
+ }
+
+ @Test
public void testForceOverride() throws Exception {
mWm.prepareAppTransition(TRANSIT_KEYGUARD_UNOCCLUDE, false /* alwaysKeepCurrent */);
mWm.prepareAppTransition(TRANSIT_ACTIVITY_OPEN, false /* alwaysKeepCurrent */,
0 /* flags */, true /* forceOverride */);
assertEquals(TRANSIT_ACTIVITY_OPEN, mWm.mAppTransition.getAppTransition());
}
+
+ @Test
+ public void testCrashing() throws Exception {
+ mWm.prepareAppTransition(TRANSIT_ACTIVITY_OPEN, false /* alwaysKeepCurrent */);
+ mWm.prepareAppTransition(TRANSIT_CRASHING_ACTIVITY_CLOSE, false /* alwaysKeepCurrent */);
+ assertEquals(TRANSIT_CRASHING_ACTIVITY_CLOSE, mWm.mAppTransition.getAppTransition());
+ }
+
+ @Test
+ public void testKeepKeyguard_withCrashing() throws Exception {
+ mWm.prepareAppTransition(TRANSIT_KEYGUARD_GOING_AWAY, false /* alwaysKeepCurrent */);
+ mWm.prepareAppTransition(TRANSIT_CRASHING_ACTIVITY_CLOSE, false /* alwaysKeepCurrent */);
+ assertEquals(TRANSIT_KEYGUARD_GOING_AWAY, mWm.mAppTransition.getAppTransition());
+ }
}