From 14d1a545c9b55fd6c23aec53cb2bc8bfc88a8849 Mon Sep 17 00:00:00 2001 From: Artem Radchenko Date: Mon, 1 Mar 2021 12:10:06 +0200 Subject: [PATCH] Fix LegacyGlobalActions broadcast receiver By default CLOSE_SYSTEM_DIALOGS broadcast is sent only for current user. Current user is user 10 on devices with headless system user enabled. LegacyGlobalActions broadcast receiver is registered with system user (user 0), so the broadcast is not received. It is proposed to use registerReceiverAsUser with UserHandle.ALL when registering receiver to be able to receive broadcast. Bug: 181734723 Test: cts-tradefed run cts-dev -m CtsAccessibilityServiceTestCases -t android.accessibilityservice.cts.AccessibilityGlobalActionsTest#testPerformGlobalActionPowerDialog or Manual: 1. Open global actions dialog: adb shell input keyevent --longpress KEYCODE_POWER (automotive implementation uses LegacyGlobalActions implementation by default) 2. Broadcast close system dialogs intent: adb shell am broadcast -a android.intent.action.CLOSE_SYSTEM_DIALOGS Signed-off-by: Artem Radchenko Change-Id: I71c7903ccb3d7f9a95a99014d14da37c61d40f8e --- .../java/com/android/server/policy/LegacyGlobalActions.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/policy/LegacyGlobalActions.java b/services/core/java/com/android/server/policy/LegacyGlobalActions.java index 9c3a394400543..f6c59f184d560 100644 --- a/services/core/java/com/android/server/policy/LegacyGlobalActions.java +++ b/services/core/java/com/android/server/policy/LegacyGlobalActions.java @@ -135,7 +135,7 @@ class LegacyGlobalActions implements DialogInterface.OnDismissListener, DialogIn filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(TelephonyManager.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED); - context.registerReceiver(mBroadcastReceiver, filter); + context.registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, filter, null, null); ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);