Loading services/core/java/com/android/server/wm/AppTaskImpl.java +1 −1 Original line number Diff line number Diff line Loading @@ -98,7 +98,7 @@ class AppTaskImpl extends IAppTask.Stub { throw new IllegalArgumentException("Unable to find task ID " + mTaskId); } return mService.getRecentTasks().createRecentTaskInfo(task, false /* stripExtras */); false /* stripExtras */, true /* getTasksAllowed */); } finally { Binder.restoreCallingIdentity(origId); } Loading services/core/java/com/android/server/wm/RecentTasks.java +6 −2 Original line number Diff line number Diff line Loading @@ -976,7 +976,7 @@ class RecentTasks { continue; } res.add(createRecentTaskInfo(task, true /* stripExtras */)); res.add(createRecentTaskInfo(task, true /* stripExtras */, getTasksAllowed)); } return res; } Loading Loading @@ -1895,7 +1895,8 @@ class RecentTasks { /** * Creates a new RecentTaskInfo from a Task. */ ActivityManager.RecentTaskInfo createRecentTaskInfo(Task tr, boolean stripExtras) { ActivityManager.RecentTaskInfo createRecentTaskInfo(Task tr, boolean stripExtras, boolean getTasksAllowed) { final ActivityManager.RecentTaskInfo rti = new ActivityManager.RecentTaskInfo(); // If the recent Task is detached, we consider it will be re-attached to the default // TaskDisplayArea because we currently only support recent overview in the default TDA. Loading @@ -1907,6 +1908,9 @@ class RecentTasks { rti.id = rti.isRunning ? rti.taskId : INVALID_TASK_ID; rti.persistentId = rti.taskId; rti.lastSnapshotData.set(tr.mLastTaskSnapshotData); if (!getTasksAllowed) { Task.trimIneffectiveInfo(tr, rti); } // Fill in organized child task info for the task created by organizer. if (tr.mCreatedByOrganizer) { Loading services/core/java/com/android/server/wm/RunningTasks.java +4 −0 Original line number Diff line number Diff line Loading @@ -142,6 +142,10 @@ class RunningTasks { task.fillTaskInfo(rti, !mKeepIntentExtra); // Fill in some deprecated values rti.id = rti.taskId; if (!mAllowed) { Task.trimIneffectiveInfo(task, rti); } return rti; } } services/core/java/com/android/server/wm/Task.java +48 −0 Original line number Diff line number Diff line Loading @@ -3467,6 +3467,54 @@ class Task extends TaskFragment { info.isSleeping = shouldSleepActivities(); } /** * Removes the activity info if the activity belongs to a different uid, which is * different from the app that hosts the task. */ static void trimIneffectiveInfo(Task task, TaskInfo info) { final ActivityRecord baseActivity = task.getActivity(r -> !r.finishing, false /* traverseTopToBottom */); final int baseActivityUid = baseActivity != null ? baseActivity.getUid() : task.effectiveUid; if (info.topActivityInfo != null && task.effectiveUid != info.topActivityInfo.applicationInfo.uid) { // Making a copy to prevent eliminating the info in the original ActivityRecord. info.topActivityInfo = new ActivityInfo(info.topActivityInfo); info.topActivityInfo.applicationInfo = new ApplicationInfo(info.topActivityInfo.applicationInfo); // Strip the sensitive info. info.topActivity = new ComponentName("", ""); info.topActivityInfo.packageName = ""; info.topActivityInfo.taskAffinity = ""; info.topActivityInfo.processName = ""; info.topActivityInfo.name = ""; info.topActivityInfo.parentActivityName = ""; info.topActivityInfo.targetActivity = ""; info.topActivityInfo.splitName = ""; info.topActivityInfo.applicationInfo.className = ""; info.topActivityInfo.applicationInfo.credentialProtectedDataDir = ""; info.topActivityInfo.applicationInfo.dataDir = ""; info.topActivityInfo.applicationInfo.deviceProtectedDataDir = ""; info.topActivityInfo.applicationInfo.manageSpaceActivityName = ""; info.topActivityInfo.applicationInfo.nativeLibraryDir = ""; info.topActivityInfo.applicationInfo.nativeLibraryRootDir = ""; info.topActivityInfo.applicationInfo.processName = ""; info.topActivityInfo.applicationInfo.publicSourceDir = ""; info.topActivityInfo.applicationInfo.scanPublicSourceDir = ""; info.topActivityInfo.applicationInfo.scanSourceDir = ""; info.topActivityInfo.applicationInfo.sourceDir = ""; info.topActivityInfo.applicationInfo.taskAffinity = ""; info.topActivityInfo.applicationInfo.name = ""; info.topActivityInfo.applicationInfo.packageName = ""; } if (task.effectiveUid != baseActivityUid) { info.baseActivity = new ComponentName("", ""); } } @Nullable PictureInPictureParams getPictureInPictureParams() { final Task topTask = getTopMostTask(); if (topTask == null) return null; Loading services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java +23 −5 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; import static android.content.pm.ActivityInfo.LAUNCH_MULTIPLE; import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_INSTANCE; import static android.content.res.Configuration.ORIENTATION_PORTRAIT; import static android.os.Process.NOBODY_UID; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; Loading Loading @@ -1220,20 +1221,35 @@ public class RecentTasksTest extends WindowTestsBase { @Test public void testCreateRecentTaskInfo_detachedTask() { final Task task = createTaskBuilder(".Task").setCreateActivity(true).build(); final Task task = createTaskBuilder(".Task").build(); final ComponentName componentName = getUniqueComponentName(); new ActivityBuilder(mSupervisor.mService) .setTask(task) .setUid(NOBODY_UID) .setComponent(componentName) .build(); final TaskDisplayArea tda = task.getDisplayArea(); assertTrue(task.isAttached()); assertTrue(task.supportsMultiWindow()); RecentTaskInfo info = mRecentTasks.createRecentTaskInfo(task, true); RecentTaskInfo info = mRecentTasks.createRecentTaskInfo(task, true /* stripExtras */, true /* getTasksAllowed */); assertTrue(info.supportsMultiWindow); info = mRecentTasks.createRecentTaskInfo(task, true /* stripExtras */, false /* getTasksAllowed */); assertFalse(info.topActivity.equals(componentName)); assertFalse(info.topActivityInfo.packageName.equals(componentName.getPackageName())); assertFalse(info.baseActivity.equals(componentName)); // The task can be put in split screen even if it is not attached now. task.removeImmediately(); info = mRecentTasks.createRecentTaskInfo(task, true); info = mRecentTasks.createRecentTaskInfo(task, true /* stripExtras */, true /* getTasksAllowed */); assertTrue(info.supportsMultiWindow); Loading @@ -1242,7 +1258,8 @@ public class RecentTasksTest extends WindowTestsBase { doReturn(false).when(tda).supportsNonResizableMultiWindow(); doReturn(false).when(task).isResizeable(); info = mRecentTasks.createRecentTaskInfo(task, true); info = mRecentTasks.createRecentTaskInfo(task, true /* stripExtras */, true /* getTasksAllowed */); assertFalse(info.supportsMultiWindow); Loading @@ -1250,7 +1267,8 @@ public class RecentTasksTest extends WindowTestsBase { // the device supports it. doReturn(true).when(tda).supportsNonResizableMultiWindow(); info = mRecentTasks.createRecentTaskInfo(task, true); info = mRecentTasks.createRecentTaskInfo(task, true /* stripExtras */, true /* getTasksAllowed */); assertTrue(info.supportsMultiWindow); } Loading Loading
services/core/java/com/android/server/wm/AppTaskImpl.java +1 −1 Original line number Diff line number Diff line Loading @@ -98,7 +98,7 @@ class AppTaskImpl extends IAppTask.Stub { throw new IllegalArgumentException("Unable to find task ID " + mTaskId); } return mService.getRecentTasks().createRecentTaskInfo(task, false /* stripExtras */); false /* stripExtras */, true /* getTasksAllowed */); } finally { Binder.restoreCallingIdentity(origId); } Loading
services/core/java/com/android/server/wm/RecentTasks.java +6 −2 Original line number Diff line number Diff line Loading @@ -976,7 +976,7 @@ class RecentTasks { continue; } res.add(createRecentTaskInfo(task, true /* stripExtras */)); res.add(createRecentTaskInfo(task, true /* stripExtras */, getTasksAllowed)); } return res; } Loading Loading @@ -1895,7 +1895,8 @@ class RecentTasks { /** * Creates a new RecentTaskInfo from a Task. */ ActivityManager.RecentTaskInfo createRecentTaskInfo(Task tr, boolean stripExtras) { ActivityManager.RecentTaskInfo createRecentTaskInfo(Task tr, boolean stripExtras, boolean getTasksAllowed) { final ActivityManager.RecentTaskInfo rti = new ActivityManager.RecentTaskInfo(); // If the recent Task is detached, we consider it will be re-attached to the default // TaskDisplayArea because we currently only support recent overview in the default TDA. Loading @@ -1907,6 +1908,9 @@ class RecentTasks { rti.id = rti.isRunning ? rti.taskId : INVALID_TASK_ID; rti.persistentId = rti.taskId; rti.lastSnapshotData.set(tr.mLastTaskSnapshotData); if (!getTasksAllowed) { Task.trimIneffectiveInfo(tr, rti); } // Fill in organized child task info for the task created by organizer. if (tr.mCreatedByOrganizer) { Loading
services/core/java/com/android/server/wm/RunningTasks.java +4 −0 Original line number Diff line number Diff line Loading @@ -142,6 +142,10 @@ class RunningTasks { task.fillTaskInfo(rti, !mKeepIntentExtra); // Fill in some deprecated values rti.id = rti.taskId; if (!mAllowed) { Task.trimIneffectiveInfo(task, rti); } return rti; } }
services/core/java/com/android/server/wm/Task.java +48 −0 Original line number Diff line number Diff line Loading @@ -3467,6 +3467,54 @@ class Task extends TaskFragment { info.isSleeping = shouldSleepActivities(); } /** * Removes the activity info if the activity belongs to a different uid, which is * different from the app that hosts the task. */ static void trimIneffectiveInfo(Task task, TaskInfo info) { final ActivityRecord baseActivity = task.getActivity(r -> !r.finishing, false /* traverseTopToBottom */); final int baseActivityUid = baseActivity != null ? baseActivity.getUid() : task.effectiveUid; if (info.topActivityInfo != null && task.effectiveUid != info.topActivityInfo.applicationInfo.uid) { // Making a copy to prevent eliminating the info in the original ActivityRecord. info.topActivityInfo = new ActivityInfo(info.topActivityInfo); info.topActivityInfo.applicationInfo = new ApplicationInfo(info.topActivityInfo.applicationInfo); // Strip the sensitive info. info.topActivity = new ComponentName("", ""); info.topActivityInfo.packageName = ""; info.topActivityInfo.taskAffinity = ""; info.topActivityInfo.processName = ""; info.topActivityInfo.name = ""; info.topActivityInfo.parentActivityName = ""; info.topActivityInfo.targetActivity = ""; info.topActivityInfo.splitName = ""; info.topActivityInfo.applicationInfo.className = ""; info.topActivityInfo.applicationInfo.credentialProtectedDataDir = ""; info.topActivityInfo.applicationInfo.dataDir = ""; info.topActivityInfo.applicationInfo.deviceProtectedDataDir = ""; info.topActivityInfo.applicationInfo.manageSpaceActivityName = ""; info.topActivityInfo.applicationInfo.nativeLibraryDir = ""; info.topActivityInfo.applicationInfo.nativeLibraryRootDir = ""; info.topActivityInfo.applicationInfo.processName = ""; info.topActivityInfo.applicationInfo.publicSourceDir = ""; info.topActivityInfo.applicationInfo.scanPublicSourceDir = ""; info.topActivityInfo.applicationInfo.scanSourceDir = ""; info.topActivityInfo.applicationInfo.sourceDir = ""; info.topActivityInfo.applicationInfo.taskAffinity = ""; info.topActivityInfo.applicationInfo.name = ""; info.topActivityInfo.applicationInfo.packageName = ""; } if (task.effectiveUid != baseActivityUid) { info.baseActivity = new ComponentName("", ""); } } @Nullable PictureInPictureParams getPictureInPictureParams() { final Task topTask = getTopMostTask(); if (topTask == null) return null; Loading
services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java +23 −5 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; import static android.content.pm.ActivityInfo.LAUNCH_MULTIPLE; import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_INSTANCE; import static android.content.res.Configuration.ORIENTATION_PORTRAIT; import static android.os.Process.NOBODY_UID; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; Loading Loading @@ -1220,20 +1221,35 @@ public class RecentTasksTest extends WindowTestsBase { @Test public void testCreateRecentTaskInfo_detachedTask() { final Task task = createTaskBuilder(".Task").setCreateActivity(true).build(); final Task task = createTaskBuilder(".Task").build(); final ComponentName componentName = getUniqueComponentName(); new ActivityBuilder(mSupervisor.mService) .setTask(task) .setUid(NOBODY_UID) .setComponent(componentName) .build(); final TaskDisplayArea tda = task.getDisplayArea(); assertTrue(task.isAttached()); assertTrue(task.supportsMultiWindow()); RecentTaskInfo info = mRecentTasks.createRecentTaskInfo(task, true); RecentTaskInfo info = mRecentTasks.createRecentTaskInfo(task, true /* stripExtras */, true /* getTasksAllowed */); assertTrue(info.supportsMultiWindow); info = mRecentTasks.createRecentTaskInfo(task, true /* stripExtras */, false /* getTasksAllowed */); assertFalse(info.topActivity.equals(componentName)); assertFalse(info.topActivityInfo.packageName.equals(componentName.getPackageName())); assertFalse(info.baseActivity.equals(componentName)); // The task can be put in split screen even if it is not attached now. task.removeImmediately(); info = mRecentTasks.createRecentTaskInfo(task, true); info = mRecentTasks.createRecentTaskInfo(task, true /* stripExtras */, true /* getTasksAllowed */); assertTrue(info.supportsMultiWindow); Loading @@ -1242,7 +1258,8 @@ public class RecentTasksTest extends WindowTestsBase { doReturn(false).when(tda).supportsNonResizableMultiWindow(); doReturn(false).when(task).isResizeable(); info = mRecentTasks.createRecentTaskInfo(task, true); info = mRecentTasks.createRecentTaskInfo(task, true /* stripExtras */, true /* getTasksAllowed */); assertFalse(info.supportsMultiWindow); Loading @@ -1250,7 +1267,8 @@ public class RecentTasksTest extends WindowTestsBase { // the device supports it. doReturn(true).when(tda).supportsNonResizableMultiWindow(); info = mRecentTasks.createRecentTaskInfo(task, true); info = mRecentTasks.createRecentTaskInfo(task, true /* stripExtras */, true /* getTasksAllowed */); assertTrue(info.supportsMultiWindow); } Loading