Merge "Protect against assumptions of a top focused stack." into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
7afae41a1d
@@ -1469,11 +1469,11 @@ class ActivityStack extends Task {
|
|||||||
|
|
||||||
if (resumeNext) {
|
if (resumeNext) {
|
||||||
final ActivityStack topStack = mRootWindowContainer.getTopDisplayFocusedStack();
|
final ActivityStack topStack = mRootWindowContainer.getTopDisplayFocusedStack();
|
||||||
if (!topStack.shouldSleepOrShutDownActivities()) {
|
if (topStack != null && !topStack.shouldSleepOrShutDownActivities()) {
|
||||||
mRootWindowContainer.resumeFocusedStacksTopActivities(topStack, prev, null);
|
mRootWindowContainer.resumeFocusedStacksTopActivities(topStack, prev, null);
|
||||||
} else {
|
} else {
|
||||||
checkReadyForSleep();
|
checkReadyForSleep();
|
||||||
ActivityRecord top = topStack.topRunningActivity();
|
final ActivityRecord top = topStack != null ? topStack.topRunningActivity() : null;
|
||||||
if (top == null || (prev != null && top != prev)) {
|
if (top == null || (prev != null && top != prev)) {
|
||||||
// If there are no more activities available to run, do resume anyway to start
|
// If there are no more activities available to run, do resume anyway to start
|
||||||
// something. Also if the top activity on the stack is not the just paused
|
// something. Also if the top activity on the stack is not the just paused
|
||||||
|
|||||||
@@ -615,12 +615,15 @@ class ActivityStarter {
|
|||||||
|
|
||||||
int res;
|
int res;
|
||||||
synchronized (mService.mGlobalLock) {
|
synchronized (mService.mGlobalLock) {
|
||||||
final ActivityStack stack = mRootWindowContainer.getTopDisplayFocusedStack();
|
final boolean globalConfigWillChange = mRequest.globalConfig != null
|
||||||
stack.mConfigWillChange = mRequest.globalConfig != null
|
|
||||||
&& mService.getGlobalConfiguration().diff(mRequest.globalConfig) != 0;
|
&& mService.getGlobalConfiguration().diff(mRequest.globalConfig) != 0;
|
||||||
|
final ActivityStack stack = mRootWindowContainer.getTopDisplayFocusedStack();
|
||||||
|
if (stack != null) {
|
||||||
|
stack.mConfigWillChange = globalConfigWillChange;
|
||||||
|
}
|
||||||
if (DEBUG_CONFIGURATION) {
|
if (DEBUG_CONFIGURATION) {
|
||||||
Slog.v(TAG_CONFIGURATION, "Starting activity when config will change = "
|
Slog.v(TAG_CONFIGURATION, "Starting activity when config will change = "
|
||||||
+ stack.mConfigWillChange);
|
+ globalConfigWillChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
final long origId = Binder.clearCallingIdentity();
|
final long origId = Binder.clearCallingIdentity();
|
||||||
@@ -633,7 +636,7 @@ class ActivityStarter {
|
|||||||
|
|
||||||
Binder.restoreCallingIdentity(origId);
|
Binder.restoreCallingIdentity(origId);
|
||||||
|
|
||||||
if (stack.mConfigWillChange) {
|
if (globalConfigWillChange) {
|
||||||
// If the caller also wants to switch to a new configuration, do so now.
|
// If the caller also wants to switch to a new configuration, do so now.
|
||||||
// This allows a clean switch, as we are waiting for the current activity
|
// This allows a clean switch, as we are waiting for the current activity
|
||||||
// to pause (so we will not destroy it), and have not yet started the
|
// to pause (so we will not destroy it), and have not yet started the
|
||||||
@@ -641,7 +644,9 @@ class ActivityStarter {
|
|||||||
mService.mAmInternal.enforceCallingPermission(
|
mService.mAmInternal.enforceCallingPermission(
|
||||||
android.Manifest.permission.CHANGE_CONFIGURATION,
|
android.Manifest.permission.CHANGE_CONFIGURATION,
|
||||||
"updateConfiguration()");
|
"updateConfiguration()");
|
||||||
|
if (stack != null) {
|
||||||
stack.mConfigWillChange = false;
|
stack.mConfigWillChange = false;
|
||||||
|
}
|
||||||
if (DEBUG_CONFIGURATION) {
|
if (DEBUG_CONFIGURATION) {
|
||||||
Slog.v(TAG_CONFIGURATION,
|
Slog.v(TAG_CONFIGURATION,
|
||||||
"Updating to new configuration after starting activity.");
|
"Updating to new configuration after starting activity.");
|
||||||
@@ -1536,10 +1541,12 @@ class ActivityStarter {
|
|||||||
// If the activity being launched is the same as the one currently at the top, then
|
// If the activity being launched is the same as the one currently at the top, then
|
||||||
// we need to check if it should only be launched once.
|
// we need to check if it should only be launched once.
|
||||||
final ActivityStack topStack = mRootWindowContainer.getTopDisplayFocusedStack();
|
final ActivityStack topStack = mRootWindowContainer.getTopDisplayFocusedStack();
|
||||||
|
if (topStack != null) {
|
||||||
startResult = deliverToCurrentTopIfNeeded(topStack);
|
startResult = deliverToCurrentTopIfNeeded(topStack);
|
||||||
if (startResult != START_SUCCESS) {
|
if (startResult != START_SUCCESS) {
|
||||||
return startResult;
|
return startResult;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mTargetStack == null) {
|
if (mTargetStack == null) {
|
||||||
mTargetStack = getLaunchStack(mStartActivity, mLaunchFlags, targetTask, mOptions);
|
mTargetStack = getLaunchStack(mStartActivity, mLaunchFlags, targetTask, mOptions);
|
||||||
@@ -2126,10 +2133,13 @@ class ActivityStarter {
|
|||||||
if ((startFlags & START_FLAG_ONLY_IF_NEEDED) != 0) {
|
if ((startFlags & START_FLAG_ONLY_IF_NEEDED) != 0) {
|
||||||
ActivityRecord checkedCaller = sourceRecord;
|
ActivityRecord checkedCaller = sourceRecord;
|
||||||
if (checkedCaller == null) {
|
if (checkedCaller == null) {
|
||||||
checkedCaller = mRootWindowContainer.getTopDisplayFocusedStack()
|
ActivityStack topFocusedStack = mRootWindowContainer.getTopDisplayFocusedStack();
|
||||||
.topRunningNonDelayedActivityLocked(mNotTop);
|
if (topFocusedStack != null) {
|
||||||
|
checkedCaller = topFocusedStack.topRunningNonDelayedActivityLocked(mNotTop);
|
||||||
}
|
}
|
||||||
if (!checkedCaller.mActivityComponent.equals(r.mActivityComponent)) {
|
}
|
||||||
|
if (checkedCaller == null
|
||||||
|
|| !checkedCaller.mActivityComponent.equals(r.mActivityComponent)) {
|
||||||
// Caller is not the same as launcher, so always needed.
|
// Caller is not the same as launcher, so always needed.
|
||||||
mStartFlags &= ~START_FLAG_ONLY_IF_NEEDED;
|
mStartFlags &= ~START_FLAG_ONLY_IF_NEEDED;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1104,8 +1104,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
// If this is coming from the currently resumed activity, it is
|
// If this is coming from the currently resumed activity, it is
|
||||||
// effectively saying that app switches are allowed at this point.
|
// effectively saying that app switches are allowed at this point.
|
||||||
final ActivityStack stack = getTopDisplayFocusedStack();
|
final ActivityStack stack = getTopDisplayFocusedStack();
|
||||||
if (stack.mResumedActivity != null &&
|
if (stack != null && stack.mResumedActivity != null
|
||||||
stack.mResumedActivity.info.applicationInfo.uid == Binder.getCallingUid()) {
|
&& stack.mResumedActivity.info.applicationInfo.uid == Binder.getCallingUid()) {
|
||||||
mAppSwitchesAllowedTime = 0;
|
mAppSwitchesAllowedTime = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1951,8 +1951,13 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
public boolean isTopActivityImmersive() {
|
public boolean isTopActivityImmersive() {
|
||||||
enforceNotIsolatedCaller("isTopActivityImmersive");
|
enforceNotIsolatedCaller("isTopActivityImmersive");
|
||||||
synchronized (mGlobalLock) {
|
synchronized (mGlobalLock) {
|
||||||
final ActivityRecord r = getTopDisplayFocusedStack().topRunningActivity();
|
final ActivityStack topFocusedStack = getTopDisplayFocusedStack();
|
||||||
return (r != null) ? r.immersive : false;
|
if (topFocusedStack == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final ActivityRecord r = topFocusedStack.topRunningActivity();
|
||||||
|
return r != null && r.immersive;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1981,7 +1986,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
public int getFrontActivityScreenCompatMode() {
|
public int getFrontActivityScreenCompatMode() {
|
||||||
enforceNotIsolatedCaller("getFrontActivityScreenCompatMode");
|
enforceNotIsolatedCaller("getFrontActivityScreenCompatMode");
|
||||||
synchronized (mGlobalLock) {
|
synchronized (mGlobalLock) {
|
||||||
final ActivityRecord r = getTopDisplayFocusedStack().topRunningActivity();
|
final ActivityStack stack = getTopDisplayFocusedStack();
|
||||||
|
final ActivityRecord r = stack != null ? stack.topRunningActivity() : null;
|
||||||
if (r == null) {
|
if (r == null) {
|
||||||
return ActivityManager.COMPAT_MODE_UNKNOWN;
|
return ActivityManager.COMPAT_MODE_UNKNOWN;
|
||||||
}
|
}
|
||||||
@@ -1995,7 +2001,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
"setFrontActivityScreenCompatMode");
|
"setFrontActivityScreenCompatMode");
|
||||||
ApplicationInfo ai;
|
ApplicationInfo ai;
|
||||||
synchronized (mGlobalLock) {
|
synchronized (mGlobalLock) {
|
||||||
final ActivityRecord r = getTopDisplayFocusedStack().topRunningActivity();
|
final ActivityStack stack = getTopDisplayFocusedStack();
|
||||||
|
final ActivityRecord r = stack != null ? stack.topRunningActivity() : null;
|
||||||
if (r == null) {
|
if (r == null) {
|
||||||
Slog.w(TAG, "setFrontActivityScreenCompatMode failed: no top activity");
|
Slog.w(TAG, "setFrontActivityScreenCompatMode failed: no top activity");
|
||||||
return;
|
return;
|
||||||
@@ -2383,7 +2390,10 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
synchronized (mGlobalLock) {
|
synchronized (mGlobalLock) {
|
||||||
final long origId = Binder.clearCallingIdentity();
|
final long origId = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
getTopDisplayFocusedStack().unhandledBackLocked();
|
final ActivityStack topFocusedStack = getTopDisplayFocusedStack();
|
||||||
|
if (topFocusedStack != null) {
|
||||||
|
topFocusedStack.unhandledBackLocked();
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
Binder.restoreCallingIdentity(origId);
|
Binder.restoreCallingIdentity(origId);
|
||||||
}
|
}
|
||||||
@@ -3616,7 +3626,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
"enqueueAssistContext()");
|
"enqueueAssistContext()");
|
||||||
|
|
||||||
synchronized (mGlobalLock) {
|
synchronized (mGlobalLock) {
|
||||||
ActivityRecord activity = getTopDisplayFocusedStack().getTopNonFinishingActivity();
|
final ActivityStack stack = getTopDisplayFocusedStack();
|
||||||
|
ActivityRecord activity = stack != null ? stack.getTopNonFinishingActivity() : null;
|
||||||
if (activity == null) {
|
if (activity == null) {
|
||||||
Slog.w(TAG, "getAssistContextExtras failed: no top activity");
|
Slog.w(TAG, "getAssistContextExtras failed: no top activity");
|
||||||
return null;
|
return null;
|
||||||
@@ -7037,9 +7048,9 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
mRootWindowContainer.dumpDisplayConfigs(pw, " ");
|
mRootWindowContainer.dumpDisplayConfigs(pw, " ");
|
||||||
}
|
}
|
||||||
if (dumpAll) {
|
if (dumpAll) {
|
||||||
if (dumpPackage == null) {
|
final ActivityStack topFocusedStack = getTopDisplayFocusedStack();
|
||||||
pw.println(" mConfigWillChange: "
|
if (dumpPackage == null && topFocusedStack != null) {
|
||||||
+ getTopDisplayFocusedStack().mConfigWillChange);
|
pw.println(" mConfigWillChange: " + topFocusedStack.mConfigWillChange);
|
||||||
}
|
}
|
||||||
if (mCompatModePackages.getPackages().size() > 0) {
|
if (mCompatModePackages.getPackages().size() > 0) {
|
||||||
boolean printed = false;
|
boolean printed = false;
|
||||||
@@ -7120,7 +7131,10 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
synchronized (mGlobalLock) {
|
synchronized (mGlobalLock) {
|
||||||
if (dumpPackage == null) {
|
if (dumpPackage == null) {
|
||||||
getGlobalConfiguration().dumpDebug(proto, GLOBAL_CONFIGURATION);
|
getGlobalConfiguration().dumpDebug(proto, GLOBAL_CONFIGURATION);
|
||||||
proto.write(CONFIG_WILL_CHANGE, getTopDisplayFocusedStack().mConfigWillChange);
|
final ActivityStack topFocusedStack = getTopDisplayFocusedStack();
|
||||||
|
if (topFocusedStack != null) {
|
||||||
|
proto.write(CONFIG_WILL_CHANGE, topFocusedStack.mConfigWillChange);
|
||||||
|
}
|
||||||
writeSleepStateToProto(proto, wakeFullness, testPssMode);
|
writeSleepStateToProto(proto, wakeFullness, testPssMode);
|
||||||
if (mRunningVoice != null) {
|
if (mRunningVoice != null) {
|
||||||
final long vrToken = proto.start(
|
final long vrToken = proto.start(
|
||||||
|
|||||||
@@ -1980,7 +1980,9 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean switchUser(int userId, UserState uss) {
|
boolean switchUser(int userId, UserState uss) {
|
||||||
final int focusStackId = getTopDisplayFocusedStack().getRootTaskId();
|
final ActivityStack topFocusedStack = getTopDisplayFocusedStack();
|
||||||
|
final int focusStackId = topFocusedStack != null
|
||||||
|
? topFocusedStack.getRootTaskId() : INVALID_TASK_ID;
|
||||||
// We dismiss the docked stack whenever we switch users.
|
// We dismiss the docked stack whenever we switch users.
|
||||||
final ActivityStack dockedStack = getDefaultDisplay().getRootSplitScreenPrimaryTask();
|
final ActivityStack dockedStack = getDefaultDisplay().getRootSplitScreenPrimaryTask();
|
||||||
if (dockedStack != null) {
|
if (dockedStack != null) {
|
||||||
@@ -3455,7 +3457,12 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
|
|||||||
ArrayList<ActivityRecord> getDumpActivities(String name, boolean dumpVisibleStacksOnly,
|
ArrayList<ActivityRecord> getDumpActivities(String name, boolean dumpVisibleStacksOnly,
|
||||||
boolean dumpFocusedStackOnly) {
|
boolean dumpFocusedStackOnly) {
|
||||||
if (dumpFocusedStackOnly) {
|
if (dumpFocusedStackOnly) {
|
||||||
return getTopDisplayFocusedStack().getDumpActivitiesLocked(name);
|
final ActivityStack topFocusedStack = getTopDisplayFocusedStack();
|
||||||
|
if (topFocusedStack != null) {
|
||||||
|
return topFocusedStack.getDumpActivitiesLocked(name);
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ArrayList<ActivityRecord> activities = new ArrayList<>();
|
ArrayList<ActivityRecord> activities = new ArrayList<>();
|
||||||
int numDisplays = getChildCount();
|
int numDisplays = getChildCount();
|
||||||
|
|||||||
Reference in New Issue
Block a user