Don't block activity starts in permissive mode.
When activity starts have been enabled via developer options we shouldn't block them. But we still want to show a toast to warn that the start would have been blocked. Scenarios where we were blocking when we shouldn't: - Creating a new task from a background receiver (here the activity is created but not brought to the front). - Starting an activity while app switching protection is in force. - Various cases when starting an activity in a new task or a task that doesn't already have one of our activities in it. Bug: 132919170 Bug: 132919170 Test: manual Test: atest BackgroundActivityLaunchTest Test: atest RootWindowContainerTests Test: atest WmTests:ActivityStarterTests Test: atest CtsWindowManagerDeviceTestCases:ActivityStarterTests Test: atest CtsAppTestCases:.ServiceTest Change-Id: I32d75d04ea93cb4883e93bbe74468755a708ca24
This commit is contained in:
@@ -161,7 +161,7 @@ class ActivityStarter {
|
||||
private ActivityOptions mOptions;
|
||||
|
||||
// If it is true, background activity can only be started in an existing task that contains
|
||||
// an activity with same uid.
|
||||
// an activity with same uid, or if activity starts are enabled in developer options.
|
||||
private boolean mRestrictedBgActivity;
|
||||
|
||||
private int mLaunchMode;
|
||||
@@ -921,7 +921,7 @@ class ActivityStarter {
|
||||
|| stack.getResumedActivity().info.applicationInfo.uid != realCallingUid)) {
|
||||
if (!mService.checkAppSwitchAllowedLocked(callingPid, callingUid,
|
||||
realCallingPid, realCallingUid, "Activity start")) {
|
||||
if (!restrictedBgActivity) {
|
||||
if (!(restrictedBgActivity && handleBackgroundActivityAbort(r))) {
|
||||
mController.addPendingActivityLaunch(new PendingActivityLaunch(r,
|
||||
sourceRecord, startFlags, stack, callerApp));
|
||||
}
|
||||
@@ -1916,7 +1916,7 @@ class ActivityStarter {
|
||||
|
||||
mNoAnimation = (mLaunchFlags & FLAG_ACTIVITY_NO_ANIMATION) != 0;
|
||||
|
||||
if (restrictedBgActivity) {
|
||||
if (mRestrictedBgActivity && !mService.isBackgroundActivityStartsEnabled()) {
|
||||
mAvoidMoveToFront = true;
|
||||
mDoResume = false;
|
||||
}
|
||||
@@ -2380,7 +2380,6 @@ class ActivityStarter {
|
||||
if (handleBackgroundActivityAbort(mStartActivity)) {
|
||||
return START_ABORTED;
|
||||
}
|
||||
return START_ABORTED;
|
||||
}
|
||||
// We only want to allow changing stack in two cases:
|
||||
// 1. If the target task is not the top one. Otherwise we would move the launching task to
|
||||
@@ -2553,17 +2552,15 @@ class ActivityStarter {
|
||||
if (handleBackgroundActivityAbort(mStartActivity)) {
|
||||
return START_ABORTED;
|
||||
}
|
||||
return START_ABORTED;
|
||||
}
|
||||
final TaskRecord task = (prev != null)
|
||||
? prev.getTaskRecord() : mTargetStack.createTaskRecord(
|
||||
mSupervisor.getNextTaskIdForUserLocked(mStartActivity.mUserId), mStartActivity.info,
|
||||
mIntent, null, null, true, mStartActivity, mSourceRecord, mOptions);
|
||||
if (mRestrictedBgActivity && !task.containsAppUid(mCallingUid)) {
|
||||
if (mRestrictedBgActivity && prev != null && !task.containsAppUid(mCallingUid)) {
|
||||
if (handleBackgroundActivityAbort(mStartActivity)) {
|
||||
return START_ABORTED;
|
||||
}
|
||||
return START_ABORTED;
|
||||
}
|
||||
addOrReparentStartingActivity(task, "setTaskToCurrentTopOrCreateNewTask");
|
||||
mTargetStack.positionChildWindowContainerAtTop(task);
|
||||
|
||||
Reference in New Issue
Block a user