Fix FLAG_ACTIVITY_CLEAR_TOP not working for aliased activities
bug: 26216591
Change-Id: I26528b7613bd8aa80fc7f4d6b64ea7bf639935d3
diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java
index ed26e0c..4879cbfb 100755
--- a/services/core/java/com/android/server/am/ActivityRecord.java
+++ b/services/core/java/com/android/server/am/ActivityRecord.java
@@ -584,13 +584,16 @@
haveState = true;
if (aInfo != null) {
+ // If the class name in the intent doesn't match that of the target, this is
+ // probably an alias. We have to create a new ComponentName object to keep track
+ // of the real activity name, so that FLAG_ACTIVITY_CLEAR_TOP is handled properly.
if (aInfo.targetActivity == null
- || aInfo.launchMode == ActivityInfo.LAUNCH_MULTIPLE
- || aInfo.launchMode == ActivityInfo.LAUNCH_SINGLE_TOP) {
+ || (aInfo.targetActivity.equals(_intent.getComponent().getClassName())
+ && (aInfo.launchMode == ActivityInfo.LAUNCH_MULTIPLE
+ || aInfo.launchMode == ActivityInfo.LAUNCH_SINGLE_TOP))) {
realActivity = _intent.getComponent();
} else {
- realActivity = new ComponentName(aInfo.packageName,
- aInfo.targetActivity);
+ realActivity = new ComponentName(aInfo.packageName, aInfo.targetActivity);
}
taskAffinity = aInfo.taskAffinity;
stateNotNeeded = (aInfo.flags&