Support blocking screen on multi-display.
- register UXR listener for each physical display;
- non-physical (likely virtual) displays gets UXR for main display;
- if no display has physical address, assume main display is physical;
Bug: 128456985
Test: verified on device with single display; also verified with
multi-display as 2nd home.
Change-Id: I54b45915e1e32f01613d3477c10b2e8c38e4e94e
diff --git a/service/src/com/android/car/SystemActivityMonitoringService.java b/service/src/com/android/car/SystemActivityMonitoringService.java
index 3894337..d192727 100644
--- a/service/src/com/android/car/SystemActivityMonitoringService.java
+++ b/service/src/com/android/car/SystemActivityMonitoringService.java
@@ -15,6 +15,8 @@
*/
package com.android.car;
+import static com.android.car.pm.CarPackageManagerService.BLOCKING_INTENT_EXTRA_DISPLAY_ID;
+
import android.app.ActivityManager;
import android.app.ActivityManager.StackInfo;
import android.app.ActivityOptions;
@@ -104,7 +106,7 @@
private final HandlerThread mMonitorHandlerThread;
private final ActivityMonitorHandler mHandler;
- /** K: stack id, V: top task */
+ /** K: display id, V: top task */
private final SparseArray<TopTaskInfoContainer> mTopTasks = new SparseArray<>();
/** K: uid, V : list of pid */
private final Map<Integer, Set<Integer>> mForegroundUidPids = new ArrayMap<>();
@@ -377,10 +379,14 @@
* block the current task with the provided new activity.
*/
private void handleBlockActivity(TopTaskInfoContainer currentTask, Intent newActivityIntent) {
- // Only block default display.
- ActivityOptions options = ActivityOptions.makeBasic();
- options.setLaunchDisplayId(Display.DEFAULT_DISPLAY);
+ int displayId = newActivityIntent.getIntExtra(BLOCKING_INTENT_EXTRA_DISPLAY_ID,
+ Display.DEFAULT_DISPLAY);
+ if (Log.isLoggable(CarLog.TAG_AM, Log.DEBUG)) {
+ Log.d(CarLog.TAG_AM, "Launching blocking activity on display: " + displayId);
+ }
+ ActivityOptions options = ActivityOptions.makeBasic();
+ options.setLaunchDisplayId(displayId);
mContext.startActivityAsUser(newActivityIntent, options.toBundle(),
new UserHandle(currentTask.stackInfo.userId));
// Now make stack with new activity focused.