From 27be1ccfeb899ff4899968a4de3244724a193205 Mon Sep 17 00:00:00 2001 From: Yabin Huang Date: Thu, 3 Jun 2021 19:12:28 -0700 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. Fixes: 182842046 Test: atest CtsAccessibilityServiceTestCases Change-Id: I10405769ba6426c7bbcd31e09e1cd4c99585665b Merged-In: I10405769ba6426c7bbcd31e09e1cd4c99585665b --- .../java/com/android/server/policy/LegacyGlobalActions.java | 5 ++++- 1 file changed, 4 insertions(+), 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 5b48abb3e1f2d..a5969a88008d5 100644 --- a/services/core/java/com/android/server/policy/LegacyGlobalActions.java +++ b/services/core/java/com/android/server/policy/LegacyGlobalActions.java @@ -135,7 +135,10 @@ 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); + // By default CLOSE_SYSTEM_DIALOGS broadcast is sent only for current user, which is user + // 10 on devices with headless system user enabled. + // In order to receive the broadcast, register the broadcast receiver with UserHandle.ALL. + context.registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, filter, null, null); mHasTelephony = context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY);