From 167804a645ef62ea1dc4d0e30f43082c49bf6c2c Mon Sep 17 00:00:00 2001 From: Jacky Kao Date: Mon, 18 May 2020 16:19:38 +0800 Subject: [PATCH] Bubble's change could notify to A11y framework The virtual display of the activity became private and A11y framework won't track the windows of the private virtual display. Then the change of bubbles using the activityView could not be notified to A11y framework. Due to the bubbles created from system ui, we made the private virtual display created from system ui could track its windows. This is the short term solution, and only phases in rvc-dev branch. We plan to track all private virtual displays as the long term solution at master branch, but need to avoid this issue happened again, b/148760652. Bug: 156685691 Test: a11y CTS & unit tests Change-Id: I7a7e3d6040ce05f5d3769c14d34f906d8042c473 --- .../AccessibilityManagerService.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java index b3867a35dba52..07bb3356aec07 100644 --- a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java +++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java @@ -51,6 +51,7 @@ import android.content.DialogInterface.OnClickListener; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; +import android.content.pm.PackageManagerInternal; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.database.ContentObserver; @@ -2934,11 +2935,19 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub public class AccessibilityDisplayListener implements DisplayManager.DisplayListener { private final DisplayManager mDisplayManager; private final ArrayList mDisplaysList = new ArrayList<>(); + private int mSystemUiUid = 0; AccessibilityDisplayListener(Context context, MainHandler handler) { mDisplayManager = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE); mDisplayManager.registerDisplayListener(this, handler); initializeDisplayList(); + + final PackageManagerInternal pm = + LocalServices.getService(PackageManagerInternal.class); + if (pm != null) { + mSystemUiUid = pm.getPackageUid(pm.getSystemUiServiceComponent().getPackageName(), + PackageManager.MATCH_SYSTEM_ONLY, mCurrentUserId); + } } ArrayList getValidDisplayList() { @@ -3034,8 +3043,13 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub } // Private virtual displays are created by the ap and is not allowed to access by other // aps. We assume we could ignore them. + // The exceptional case is for bubbles. Because the bubbles use the activityView, and + // the virtual display of the activityView is private, so if the owner UID of the + // private virtual display is the one of system ui which creates the virtual display of + // bubbles, then this private virtual display should track the windows. if (display.getType() == Display.TYPE_VIRTUAL - && (display.getFlags() & Display.FLAG_PRIVATE) != 0) { + && (display.getFlags() & Display.FLAG_PRIVATE) != 0 + && display.getOwnerUid() != mSystemUiUid) { return false; } return true;