Merge "RESTRICT AUTOMERGE Use consistent calling uid and package in navigateUpTo" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
321b255d93
@@ -7594,7 +7594,7 @@ public class ActivityManagerService extends IActivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GuardedBy("this")
|
@GuardedBy("this")
|
||||||
private final boolean attachApplicationLocked(IApplicationThread thread,
|
private boolean attachApplicationLocked(@NonNull IApplicationThread thread,
|
||||||
int pid, int callingUid, long startSeq) {
|
int pid, int callingUid, long startSeq) {
|
||||||
|
|
||||||
// Find the application record that is being attached... either via
|
// Find the application record that is being attached... either via
|
||||||
@@ -7975,6 +7975,9 @@ public class ActivityManagerService extends IActivityManager.Stub
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void attachApplication(IApplicationThread thread, long startSeq) {
|
public final void attachApplication(IApplicationThread thread, long startSeq) {
|
||||||
|
if (thread == null) {
|
||||||
|
throw new SecurityException("Invalid application interface");
|
||||||
|
}
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
int callingPid = Binder.getCallingPid();
|
int callingPid = Binder.getCallingPid();
|
||||||
final int callingUid = Binder.getCallingUid();
|
final int callingUid = Binder.getCallingUid();
|
||||||
|
|||||||
@@ -3943,6 +3943,11 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
|
|||||||
|
|
||||||
final boolean navigateUpToLocked(ActivityRecord srec, Intent destIntent, int resultCode,
|
final boolean navigateUpToLocked(ActivityRecord srec, Intent destIntent, int resultCode,
|
||||||
Intent resultData) {
|
Intent resultData) {
|
||||||
|
if (srec.app == null || srec.app.thread == null) {
|
||||||
|
// Nothing to do if the caller is not attached, because this method should be called
|
||||||
|
// from an alive activity.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
final TaskRecord task = srec.getTask();
|
final TaskRecord task = srec.getTask();
|
||||||
final ArrayList<ActivityRecord> activities = task.mActivities;
|
final ArrayList<ActivityRecord> activities = task.mActivities;
|
||||||
final int start = activities.indexOf(srec);
|
final int start = activities.indexOf(srec);
|
||||||
@@ -3994,14 +3999,14 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (parent != null && foundParentInTask) {
|
if (parent != null && foundParentInTask) {
|
||||||
|
final int callingUid = srec.info.applicationInfo.uid;
|
||||||
final int parentLaunchMode = parent.info.launchMode;
|
final int parentLaunchMode = parent.info.launchMode;
|
||||||
final int destIntentFlags = destIntent.getFlags();
|
final int destIntentFlags = destIntent.getFlags();
|
||||||
if (parentLaunchMode == ActivityInfo.LAUNCH_SINGLE_INSTANCE ||
|
if (parentLaunchMode == ActivityInfo.LAUNCH_SINGLE_INSTANCE ||
|
||||||
parentLaunchMode == ActivityInfo.LAUNCH_SINGLE_TASK ||
|
parentLaunchMode == ActivityInfo.LAUNCH_SINGLE_TASK ||
|
||||||
parentLaunchMode == ActivityInfo.LAUNCH_SINGLE_TOP ||
|
parentLaunchMode == ActivityInfo.LAUNCH_SINGLE_TOP ||
|
||||||
(destIntentFlags & Intent.FLAG_ACTIVITY_CLEAR_TOP) != 0) {
|
(destIntentFlags & Intent.FLAG_ACTIVITY_CLEAR_TOP) != 0) {
|
||||||
parent.deliverNewIntentLocked(srec.info.applicationInfo.uid, destIntent,
|
parent.deliverNewIntentLocked(callingUid, destIntent, srec.packageName);
|
||||||
srec.packageName);
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
ActivityInfo aInfo = AppGlobals.getPackageManager().getActivityInfo(
|
ActivityInfo aInfo = AppGlobals.getPackageManager().getActivityInfo(
|
||||||
@@ -4014,10 +4019,10 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
|
|||||||
.setActivityInfo(aInfo)
|
.setActivityInfo(aInfo)
|
||||||
.setResultTo(parent.appToken)
|
.setResultTo(parent.appToken)
|
||||||
.setCallingPid(-1)
|
.setCallingPid(-1)
|
||||||
.setCallingUid(parent.launchedFromUid)
|
.setCallingUid(callingUid)
|
||||||
.setCallingPackage(parent.launchedFromPackage)
|
.setCallingPackage(srec.packageName)
|
||||||
.setRealCallingPid(-1)
|
.setRealCallingPid(-1)
|
||||||
.setRealCallingUid(parent.launchedFromUid)
|
.setRealCallingUid(callingUid)
|
||||||
.setComponentSpecified(true)
|
.setComponentSpecified(true)
|
||||||
.execute();
|
.execute();
|
||||||
foundParentInTask = res == ActivityManager.START_SUCCESS;
|
foundParentInTask = res == ActivityManager.START_SUCCESS;
|
||||||
|
|||||||
@@ -606,6 +606,19 @@ public class ActivityStackTests extends ActivityTestsBase {
|
|||||||
assertTrue(listener.changed);
|
assertTrue(listener.changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNavigateUpTo() {
|
||||||
|
final ActivityRecord firstActivity = new ActivityBuilder(mService).setTask(mTask).build();
|
||||||
|
final ActivityRecord secondActivity = new ActivityBuilder(mService).setTask(mTask)
|
||||||
|
.setUid(firstActivity.getUid() + 1).build();
|
||||||
|
secondActivity.app.thread = null;
|
||||||
|
// This should do nothing from a non-attached caller (app.thread == null).
|
||||||
|
assertFalse(mStack.navigateUpToLocked(secondActivity /* source record */,
|
||||||
|
firstActivity.intent /* destIntent */, 0 /* resultCode */, null /* resultData */));
|
||||||
|
assertFalse(secondActivity.finishing);
|
||||||
|
assertFalse(firstActivity.finishing);
|
||||||
|
}
|
||||||
|
|
||||||
private void verifyShouldSleepActivities(boolean focusedStack,
|
private void verifyShouldSleepActivities(boolean focusedStack,
|
||||||
boolean keyguardGoingAway, boolean displaySleeping, boolean expected) {
|
boolean keyguardGoingAway, boolean displaySleeping, boolean expected) {
|
||||||
mSupervisor.mFocusedStack = focusedStack ? mStack : null;
|
mSupervisor.mFocusedStack = focusedStack ? mStack : null;
|
||||||
|
|||||||
@@ -192,6 +192,8 @@ public class ActivityTestsBase {
|
|||||||
aInfo.applicationInfo = new ApplicationInfo();
|
aInfo.applicationInfo = new ApplicationInfo();
|
||||||
aInfo.applicationInfo.packageName = mComponent.getPackageName();
|
aInfo.applicationInfo.packageName = mComponent.getPackageName();
|
||||||
aInfo.applicationInfo.uid = mUid;
|
aInfo.applicationInfo.uid = mUid;
|
||||||
|
aInfo.packageName = mComponent.getPackageName();
|
||||||
|
aInfo.name = mComponent.getClassName();
|
||||||
aInfo.flags |= mActivityFlags;
|
aInfo.flags |= mActivityFlags;
|
||||||
|
|
||||||
final ActivityRecord activity = new ActivityRecord(mService, null /* caller */,
|
final ActivityRecord activity = new ActivityRecord(mService, null /* caller */,
|
||||||
|
|||||||
Reference in New Issue
Block a user