Revert "[RESTRICT AUTOMERGE]Only allow system and same app to apply relinquishTaskIdentity"
This reverts commit 6898dea5c9.
Reason for revert: b/218243793
Change-Id: Iadc00568b09d0e122eefbe25c0c44820b3c24815
This commit is contained in:
@@ -119,7 +119,6 @@ import android.graphics.Point;
|
|||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.os.Debug;
|
import android.os.Debug;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.Process;
|
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.os.Trace;
|
import android.os.Trace;
|
||||||
@@ -228,11 +227,6 @@ class Task extends WindowContainer<WindowContainer> {
|
|||||||
// Do not move the stack as a part of reparenting
|
// Do not move the stack as a part of reparenting
|
||||||
static final int REPARENT_LEAVE_STACK_IN_PLACE = 2;
|
static final int REPARENT_LEAVE_STACK_IN_PLACE = 2;
|
||||||
|
|
||||||
/**
|
|
||||||
* Used to identify if the activity that is installed from device's system image.
|
|
||||||
*/
|
|
||||||
boolean mIsEffectivelySystemApp;
|
|
||||||
|
|
||||||
String affinity; // The affinity name for this task, or null; may change identity.
|
String affinity; // The affinity name for this task, or null; may change identity.
|
||||||
String rootAffinity; // Initial base affinity, or null; does not change from initial root.
|
String rootAffinity; // Initial base affinity, or null; does not change from initial root.
|
||||||
String mWindowLayoutAffinity; // Launch param affinity of this task or null. Used when saving
|
String mWindowLayoutAffinity; // Launch param affinity of this task or null. Used when saving
|
||||||
@@ -483,24 +477,11 @@ class Task extends WindowContainer<WindowContainer> {
|
|||||||
|
|
||||||
if (r.finishing) return false;
|
if (r.finishing) return false;
|
||||||
|
|
||||||
if (mRoot == null || mRoot.finishing) {
|
// Set this as the candidate root since it isn't finishing.
|
||||||
// Set this as the candidate root since it isn't finishing.
|
|
||||||
mRoot = r;
|
|
||||||
}
|
|
||||||
|
|
||||||
final int uid = mRoot == r ? effectiveUid : r.info.applicationInfo.uid;
|
|
||||||
if (ignoreRelinquishIdentity
|
|
||||||
|| (mRoot.info.flags & FLAG_RELINQUISH_TASK_IDENTITY) == 0
|
|
||||||
|| (mRoot.info.applicationInfo.uid != Process.SYSTEM_UID
|
|
||||||
&& !mRoot.info.applicationInfo.isSystemApp()
|
|
||||||
&& mRoot.info.applicationInfo.uid != uid)) {
|
|
||||||
// No need to relinquish identity, end search.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Relinquish to next activity
|
|
||||||
mRoot = r;
|
mRoot = r;
|
||||||
return false;
|
|
||||||
|
// Only end search if we are ignore relinquishing identity or we are not relinquishing.
|
||||||
|
return ignoreRelinquishIdentity || (r.info.flags & FLAG_RELINQUISH_TASK_IDENTITY) == 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -948,20 +929,10 @@ class Task extends WindowContainer<WindowContainer> {
|
|||||||
* @param info The activity info which could be different from {@code r.info} if set.
|
* @param info The activity info which could be different from {@code r.info} if set.
|
||||||
*/
|
*/
|
||||||
void setIntent(ActivityRecord r, @Nullable Intent intent, @Nullable ActivityInfo info) {
|
void setIntent(ActivityRecord r, @Nullable Intent intent, @Nullable ActivityInfo info) {
|
||||||
boolean updateIdentity = false;
|
mCallingUid = r.launchedFromUid;
|
||||||
if (this.intent == null) {
|
mCallingPackage = r.launchedFromPackage;
|
||||||
updateIdentity = true;
|
mCallingFeatureId = r.launchedFromFeatureId;
|
||||||
} else if (!mNeverRelinquishIdentity) {
|
setIntent(intent != null ? intent : r.intent, info != null ? info : r.info);
|
||||||
final ActivityInfo activityInfo = info != null ? info : r.info;
|
|
||||||
updateIdentity = (effectiveUid == Process.SYSTEM_UID || mIsEffectivelySystemApp
|
|
||||||
|| effectiveUid == activityInfo.applicationInfo.uid);
|
|
||||||
}
|
|
||||||
if (updateIdentity) {
|
|
||||||
mCallingUid = r.launchedFromUid;
|
|
||||||
mCallingPackage = r.launchedFromPackage;
|
|
||||||
mCallingFeatureId = r.launchedFromFeatureId;
|
|
||||||
setIntent(intent != null ? intent : r.intent, info != null ? info : r.info);
|
|
||||||
}
|
|
||||||
setLockTaskAuth(r);
|
setLockTaskAuth(r);
|
||||||
|
|
||||||
final WindowContainer parent = getParent();
|
final WindowContainer parent = getParent();
|
||||||
@@ -977,7 +948,8 @@ class Task extends WindowContainer<WindowContainer> {
|
|||||||
private void setIntent(Intent _intent, ActivityInfo info) {
|
private void setIntent(Intent _intent, ActivityInfo info) {
|
||||||
final boolean isLeaf = isLeafTask();
|
final boolean isLeaf = isLeafTask();
|
||||||
if (intent == null) {
|
if (intent == null) {
|
||||||
mNeverRelinquishIdentity = (info.flags & FLAG_RELINQUISH_TASK_IDENTITY) == 0;
|
mNeverRelinquishIdentity =
|
||||||
|
(info.flags & FLAG_RELINQUISH_TASK_IDENTITY) == 0;
|
||||||
} else if (mNeverRelinquishIdentity && isLeaf) {
|
} else if (mNeverRelinquishIdentity && isLeaf) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -990,7 +962,6 @@ class Task extends WindowContainer<WindowContainer> {
|
|||||||
rootAffinity = affinity;
|
rootAffinity = affinity;
|
||||||
}
|
}
|
||||||
effectiveUid = info.applicationInfo.uid;
|
effectiveUid = info.applicationInfo.uid;
|
||||||
mIsEffectivelySystemApp = info.applicationInfo.isSystemApp();
|
|
||||||
stringName = null;
|
stringName = null;
|
||||||
|
|
||||||
if (info.targetActivity == null) {
|
if (info.targetActivity == null) {
|
||||||
|
|||||||
@@ -616,14 +616,13 @@ public class TaskRecordTests extends ActivityTestsBase {
|
|||||||
// one above as finishing.
|
// one above as finishing.
|
||||||
final ActivityRecord activity0 = task.getBottomMostActivity();
|
final ActivityRecord activity0 = task.getBottomMostActivity();
|
||||||
activity0.info.flags |= FLAG_RELINQUISH_TASK_IDENTITY;
|
activity0.info.flags |= FLAG_RELINQUISH_TASK_IDENTITY;
|
||||||
task.effectiveUid = activity0.getUid();
|
|
||||||
final ActivityRecord activity1 = new ActivityBuilder(mService).setTask(task).build();
|
final ActivityRecord activity1 = new ActivityBuilder(mService).setTask(task).build();
|
||||||
activity1.finishing = true;
|
activity1.finishing = true;
|
||||||
new ActivityBuilder(mService).setTask(task).build();
|
new ActivityBuilder(mService).setTask(task).build();
|
||||||
|
|
||||||
assertEquals("The first non-finishing activity and non-relinquishing task identity "
|
assertEquals("The first non-finishing activity and non-relinquishing task identity "
|
||||||
+ "must be reported.", task.getChildAt(2), task.getRootActivity(
|
+ "must be reported.", task.getChildAt(2), task.getRootActivity(
|
||||||
false /*ignoreRelinquishIdentity*/, true /*setToBottomIfNone*/));
|
false /*ignoreRelinquishIdentity*/, true /*setToBottomIfNone*/));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -651,7 +650,6 @@ public class TaskRecordTests extends ActivityTestsBase {
|
|||||||
// Set relinquishTaskIdentity for all activities in the task
|
// Set relinquishTaskIdentity for all activities in the task
|
||||||
final ActivityRecord activity0 = task.getBottomMostActivity();
|
final ActivityRecord activity0 = task.getBottomMostActivity();
|
||||||
activity0.info.flags |= FLAG_RELINQUISH_TASK_IDENTITY;
|
activity0.info.flags |= FLAG_RELINQUISH_TASK_IDENTITY;
|
||||||
task.effectiveUid = activity0.getUid();
|
|
||||||
final ActivityRecord activity1 = new ActivityBuilder(mService).setTask(task).build();
|
final ActivityRecord activity1 = new ActivityBuilder(mService).setTask(task).build();
|
||||||
activity1.info.flags |= FLAG_RELINQUISH_TASK_IDENTITY;
|
activity1.info.flags |= FLAG_RELINQUISH_TASK_IDENTITY;
|
||||||
|
|
||||||
@@ -804,7 +802,6 @@ public class TaskRecordTests extends ActivityTestsBase {
|
|||||||
// Make the current root activity relinquish task identity
|
// Make the current root activity relinquish task identity
|
||||||
final ActivityRecord activity0 = task.getBottomMostActivity();
|
final ActivityRecord activity0 = task.getBottomMostActivity();
|
||||||
activity0.info.flags |= FLAG_RELINQUISH_TASK_IDENTITY;
|
activity0.info.flags |= FLAG_RELINQUISH_TASK_IDENTITY;
|
||||||
task.effectiveUid = activity0.getUid();
|
|
||||||
// Add an extra activity on top - this will be the new root
|
// Add an extra activity on top - this will be the new root
|
||||||
final ActivityRecord activity1 = new ActivityBuilder(mService).setTask(task).build();
|
final ActivityRecord activity1 = new ActivityBuilder(mService).setTask(task).build();
|
||||||
// Add one more on top
|
// Add one more on top
|
||||||
@@ -899,48 +896,6 @@ public class TaskRecordTests extends ActivityTestsBase {
|
|||||||
verify(task).setIntent(eq(activity0));
|
verify(task).setIntent(eq(activity0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test {@link Task#updateEffectiveIntent()} when activity with relinquishTaskIdentity but
|
|
||||||
* another with different uid. This should make the task use the root activity when updating the
|
|
||||||
* intent.
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testUpdateEffectiveIntent_relinquishingWithDifferentUid() {
|
|
||||||
final ActivityRecord activity0 = new ActivityBuilder(mService)
|
|
||||||
.setActivityFlags(FLAG_RELINQUISH_TASK_IDENTITY).setCreateTask(true).build();
|
|
||||||
final Task task = activity0.getTask();
|
|
||||||
|
|
||||||
// Add an extra activity on top
|
|
||||||
new ActivityBuilder(mService).setUid(11).setTask(task).build();
|
|
||||||
|
|
||||||
spyOn(task);
|
|
||||||
task.updateEffectiveIntent();
|
|
||||||
verify(task).setIntent(eq(activity0));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test {@link Task#updateEffectiveIntent()} with activities set as relinquishTaskIdentity.
|
|
||||||
* This should make the task use the topmost activity when updating the intent.
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testUpdateEffectiveIntent_relinquishingMultipleActivities() {
|
|
||||||
final ActivityRecord activity0 = new ActivityBuilder(mService)
|
|
||||||
.setActivityFlags(FLAG_RELINQUISH_TASK_IDENTITY).setCreateTask(true).build();
|
|
||||||
final Task task = activity0.getTask();
|
|
||||||
task.effectiveUid = activity0.getUid();
|
|
||||||
// Add an extra activity on top
|
|
||||||
final ActivityRecord activity1 = new ActivityBuilder(mService).setTask(task).build();
|
|
||||||
activity1.info.flags |= FLAG_RELINQUISH_TASK_IDENTITY;
|
|
||||||
|
|
||||||
// Add an extra activity on top
|
|
||||||
final ActivityRecord activity2 = new ActivityBuilder(mService).setTask(task).build();
|
|
||||||
|
|
||||||
spyOn(task);
|
|
||||||
task.updateEffectiveIntent();
|
|
||||||
verify(task).setIntent(eq(activity2));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSaveLaunchingStateWhenConfigurationChanged() {
|
public void testSaveLaunchingStateWhenConfigurationChanged() {
|
||||||
LaunchParamsPersister persister = mService.mStackSupervisor.mLaunchParamsPersister;
|
LaunchParamsPersister persister = mService.mStackSupervisor.mLaunchParamsPersister;
|
||||||
|
|||||||
Reference in New Issue
Block a user