• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

frameworks/base


Commit MetaInfo

修订版d37eb96212c6fe4819c66bd0a1e0a2f9f7501602 (tree)
时间2020-03-13 05:34:26
作者Riddle Hsu <riddlehsu@goog...>
CommiterAnis Assi

Log Message

RESTRICT AUTOMERGE Use consistent calling uid and package in navigateUpTo

Originally, if the caller of navigateUpTo is alive, even the calling
uid is set to the caller who launched the existing destination activity,
the uid from caller process has higher priority to replace the given
calling uid. So this change doesn't modify the existing behavior if
the caller process is valid. Besides, the case of delivering new intent
uses the source record as calling identity too, so the case of starting
new activity should be consistent.

Also forbid attaching null application thread to avoid unexpected state
in process record.

Bug: 144285917
Test: bit FrameworksServicesTests:com.android.server.am.ActivityStackTests
Change-Id: I60732f430256d37cb926d08d093581f051c4afed
(cherry picked from commit 0d7e27af30e39fbb6dcafedc854daa639074e5cc)

更改概述

差异

--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -6917,7 +6917,7 @@ public class ActivityManagerService extends IActivityManager.Stub
69176917 }
69186918 }
69196919
6920- private final boolean attachApplicationLocked(IApplicationThread thread,
6920+ private boolean attachApplicationLocked(@NonNull IApplicationThread thread,
69216921 int pid) {
69226922
69236923 // Find the application record that is being attached... either via
@@ -7222,6 +7222,9 @@ public class ActivityManagerService extends IActivityManager.Stub
72227222
72237223 @Override
72247224 public final void attachApplication(IApplicationThread thread) {
7225+ if (thread == null) {
7226+ throw new SecurityException("Invalid application interface");
7227+ }
72257228 synchronized (this) {
72267229 int callingPid = Binder.getCallingPid();
72277230 final long origId = Binder.clearCallingIdentity();
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -3961,6 +3961,11 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
39613961
39623962 final boolean navigateUpToLocked(ActivityRecord srec, Intent destIntent, int resultCode,
39633963 Intent resultData) {
3964+ if (srec.app == null || srec.app.thread == null) {
3965+ // Nothing to do if the caller is not attached, because this method should be called
3966+ // from an alive activity.
3967+ return false;
3968+ }
39643969 final TaskRecord task = srec.getTask();
39653970 final ArrayList<ActivityRecord> activities = task.mActivities;
39663971 final int start = activities.indexOf(srec);
@@ -4012,22 +4017,22 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
40124017 }
40134018
40144019 if (parent != null && foundParentInTask) {
4020+ final int callingUid = srec.info.applicationInfo.uid;
40154021 final int parentLaunchMode = parent.info.launchMode;
40164022 final int destIntentFlags = destIntent.getFlags();
40174023 if (parentLaunchMode == ActivityInfo.LAUNCH_SINGLE_INSTANCE ||
40184024 parentLaunchMode == ActivityInfo.LAUNCH_SINGLE_TASK ||
40194025 parentLaunchMode == ActivityInfo.LAUNCH_SINGLE_TOP ||
40204026 (destIntentFlags & Intent.FLAG_ACTIVITY_CLEAR_TOP) != 0) {
4021- parent.deliverNewIntentLocked(srec.info.applicationInfo.uid, destIntent,
4022- srec.packageName);
4027+ parent.deliverNewIntentLocked(callingUid, destIntent, srec.packageName);
40234028 } else {
40244029 try {
40254030 ActivityInfo aInfo = AppGlobals.getPackageManager().getActivityInfo(
40264031 destIntent.getComponent(), 0, srec.userId);
40274032 int res = mService.mActivityStarter.startActivityLocked(srec.app.thread,
40284033 destIntent, null /*ephemeralIntent*/, null, aInfo, null /*rInfo*/, null,
4029- null, parent.appToken, null, 0, -1, parent.launchedFromUid,
4030- parent.launchedFromPackage, -1, parent.launchedFromUid, 0, null,
4034+ null, parent.appToken, null, 0, -1, callingUid,
4035+ srec.packageName, -1, callingUid, 0, null,
40314036 false, true, null, null, "navigateUpTo");
40324037 foundParentInTask = res == ActivityManager.START_SUCCESS;
40334038 } catch (RemoteException e) {
--- a/services/tests/servicestests/src/com/android/server/am/ActivityStackTests.java
+++ b/services/tests/servicestests/src/com/android/server/am/ActivityStackTests.java
@@ -122,4 +122,17 @@ public class ActivityStackTests extends ActivityTestsBase {
122122 assertEquals(task.getTopActivity(true /* includeOverlays */), taskOverlay);
123123 assertNotNull(result.r);
124124 }
125+
126+ @Test
127+ public void testNavigateUpTo() {
128+ final ActivityManagerService service = createActivityManagerService();
129+ final TaskRecord task = createTask(service, testActivityComponent, TEST_STACK_ID);
130+ final ActivityRecord activityRecord = createActivity(service, testActivityComponent, task);
131+ activityRecord.app = new ProcessRecord(null, activityRecord.appInfo,
132+ activityRecord.processName, activityRecord.getUid());
133+ final ActivityStack testStack = service.mStackSupervisor.getStack(TEST_STACK_ID);
134+ // No-op if the source activity record doesn't have attached process (app.thread == null).
135+ assertFalse(testStack.navigateUpToLocked(activityRecord, activityRecord.intent,
136+ 0 /* resultCode */, null /* resultData */));
137+ }
125138 }