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
This commit is contained in:
Yabin Huang
2021-06-03 19:12:28 -07:00
parent 3ff294cd82
commit 27be1ccfeb

View File

@@ -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);