Loading services/core/java/com/android/server/wm/ActivityStarter.java +5 −1 Original line number Original line Diff line number Diff line Loading @@ -700,11 +700,15 @@ class ActivityStarter { mService.updateConfigurationLocked(mRequest.globalConfig, null, false); mService.updateConfigurationLocked(mRequest.globalConfig, null, false); } } // The original options may have additional info about metrics. The mOptions is not // used here because it may be cleared in setTargetStackIfNeeded. final ActivityOptions originalOptions = mRequest.activityOptions != null ? mRequest.activityOptions.getOriginalOptions() : null; // Notify ActivityMetricsLogger that the activity has launched. // Notify ActivityMetricsLogger that the activity has launched. // ActivityMetricsLogger will then wait for the windows to be drawn and populate // ActivityMetricsLogger will then wait for the windows to be drawn and populate // WaitResult. // WaitResult. mSupervisor.getActivityMetricsLogger().notifyActivityLaunched(launchingState, res, mSupervisor.getActivityMetricsLogger().notifyActivityLaunched(launchingState, res, mLastStartActivityRecord, mOptions); mLastStartActivityRecord, originalOptions); return getExternalResult(mRequest.waitResult == null ? res return getExternalResult(mRequest.waitResult == null ? res : waitForResult(res, mLastStartActivityRecord)); : waitForResult(res, mLastStartActivityRecord)); } } Loading services/core/java/com/android/server/wm/SafeActivityOptions.java +8 −0 Original line number Original line Diff line number Diff line Loading @@ -149,6 +149,14 @@ public class SafeActivityOptions { adapter.setCallingPidUid(callingPid, callingUid); adapter.setCallingPidUid(callingPid, callingUid); } } /** * Gets the original options passed in. It should only be used for logging. DO NOT use it as a * condition in the logic of activity launch. */ ActivityOptions getOriginalOptions() { return mOriginalOptions; } /** /** * @see ActivityOptions#popAppVerificationBundle * @see ActivityOptions#popAppVerificationBundle */ */ Loading services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -63,6 +63,7 @@ import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.notNull; import android.app.ActivityOptions; import android.app.ActivityOptions; import android.app.IApplicationThread; import android.app.IApplicationThread; Loading Loading @@ -800,6 +801,7 @@ public class ActivityStarterTests extends WindowTestsBase { final Task topTask = new TaskBuilder(mSupervisor).setParentTask(topStack).build(); final Task topTask = new TaskBuilder(mSupervisor).setParentTask(topStack).build(); new ActivityBuilder(mAtm).setTask(topTask).build(); new ActivityBuilder(mAtm).setTask(topTask).build(); doReturn(mActivityMetricsLogger).when(mSupervisor).getActivityMetricsLogger(); // Start activity with the same intent as {@code singleTaskActivity} on secondary display. // Start activity with the same intent as {@code singleTaskActivity} on secondary display. final ActivityOptions options = ActivityOptions.makeBasic() final ActivityOptions options = ActivityOptions.makeBasic() .setLaunchDisplayId(secondaryDisplay.mDisplayId); .setLaunchDisplayId(secondaryDisplay.mDisplayId); Loading @@ -813,6 +815,9 @@ public class ActivityStarterTests extends WindowTestsBase { // Ensure secondary display only creates two stacks. // Ensure secondary display only creates two stacks. verify(secondaryTaskContainer, times(2)).createStack(anyInt(), anyInt(), anyBoolean()); verify(secondaryTaskContainer, times(2)).createStack(anyInt(), anyInt(), anyBoolean()); // The metrics logger should receive the same result and non-null options. verify(mActivityMetricsLogger).notifyActivityLaunched(any() /* launchingState */, eq(result), eq(singleTaskActivity), notNull() /* options */); } } @Test @Test Loading Loading
services/core/java/com/android/server/wm/ActivityStarter.java +5 −1 Original line number Original line Diff line number Diff line Loading @@ -700,11 +700,15 @@ class ActivityStarter { mService.updateConfigurationLocked(mRequest.globalConfig, null, false); mService.updateConfigurationLocked(mRequest.globalConfig, null, false); } } // The original options may have additional info about metrics. The mOptions is not // used here because it may be cleared in setTargetStackIfNeeded. final ActivityOptions originalOptions = mRequest.activityOptions != null ? mRequest.activityOptions.getOriginalOptions() : null; // Notify ActivityMetricsLogger that the activity has launched. // Notify ActivityMetricsLogger that the activity has launched. // ActivityMetricsLogger will then wait for the windows to be drawn and populate // ActivityMetricsLogger will then wait for the windows to be drawn and populate // WaitResult. // WaitResult. mSupervisor.getActivityMetricsLogger().notifyActivityLaunched(launchingState, res, mSupervisor.getActivityMetricsLogger().notifyActivityLaunched(launchingState, res, mLastStartActivityRecord, mOptions); mLastStartActivityRecord, originalOptions); return getExternalResult(mRequest.waitResult == null ? res return getExternalResult(mRequest.waitResult == null ? res : waitForResult(res, mLastStartActivityRecord)); : waitForResult(res, mLastStartActivityRecord)); } } Loading
services/core/java/com/android/server/wm/SafeActivityOptions.java +8 −0 Original line number Original line Diff line number Diff line Loading @@ -149,6 +149,14 @@ public class SafeActivityOptions { adapter.setCallingPidUid(callingPid, callingUid); adapter.setCallingPidUid(callingPid, callingUid); } } /** * Gets the original options passed in. It should only be used for logging. DO NOT use it as a * condition in the logic of activity launch. */ ActivityOptions getOriginalOptions() { return mOriginalOptions; } /** /** * @see ActivityOptions#popAppVerificationBundle * @see ActivityOptions#popAppVerificationBundle */ */ Loading
services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -63,6 +63,7 @@ import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.notNull; import android.app.ActivityOptions; import android.app.ActivityOptions; import android.app.IApplicationThread; import android.app.IApplicationThread; Loading Loading @@ -800,6 +801,7 @@ public class ActivityStarterTests extends WindowTestsBase { final Task topTask = new TaskBuilder(mSupervisor).setParentTask(topStack).build(); final Task topTask = new TaskBuilder(mSupervisor).setParentTask(topStack).build(); new ActivityBuilder(mAtm).setTask(topTask).build(); new ActivityBuilder(mAtm).setTask(topTask).build(); doReturn(mActivityMetricsLogger).when(mSupervisor).getActivityMetricsLogger(); // Start activity with the same intent as {@code singleTaskActivity} on secondary display. // Start activity with the same intent as {@code singleTaskActivity} on secondary display. final ActivityOptions options = ActivityOptions.makeBasic() final ActivityOptions options = ActivityOptions.makeBasic() .setLaunchDisplayId(secondaryDisplay.mDisplayId); .setLaunchDisplayId(secondaryDisplay.mDisplayId); Loading @@ -813,6 +815,9 @@ public class ActivityStarterTests extends WindowTestsBase { // Ensure secondary display only creates two stacks. // Ensure secondary display only creates two stacks. verify(secondaryTaskContainer, times(2)).createStack(anyInt(), anyInt(), anyBoolean()); verify(secondaryTaskContainer, times(2)).createStack(anyInt(), anyInt(), anyBoolean()); // The metrics logger should receive the same result and non-null options. verify(mActivityMetricsLogger).notifyActivityLaunched(any() /* launchingState */, eq(result), eq(singleTaskActivity), notNull() /* options */); } } @Test @Test Loading