Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 26239fb5 authored by Fabián Kozynski's avatar Fabián Kozynski
Browse files

Send broadcast to the correct user in QS restore

For broadcast sent to SystemUI (QS restore), use the correct user that
is being restored, both for the broadcast and for retrieving the value
before restore.

This is done only for these broadcasts as the consumers are known and
are expecting this. For the general android package case, an audit is
needed to determine that all consumers are expecting it.

Test: manual, on hsum restore
Fixes: 330304534
Change-Id: Iff392afb96ace3ac9e9223400677e91be71d80f1
parent 3116b729
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -186,9 +186,14 @@ public class SettingsHelper {
        sendBroadcast = sBroadcastOnRestore.contains(name);
        sendBroadcastSystemUI = sBroadcastOnRestoreSystemUI.contains(name);

        if (sendBroadcast || sendBroadcastSystemUI) {
        if (sendBroadcast) {
            // TODO: http://b/22388012
            oldValue = table.lookup(cr, name, UserHandle.USER_SYSTEM);
        } else if (sendBroadcastSystemUI) {
            // This is only done for broadcasts sent to system ui as the consumers are known.
            // It would probably be correct to do it for the ones sent to the system, but consumers
            // may be depending on the current behavior.
            oldValue = table.lookup(cr, name, context.getUserId());
        }

        try {
@@ -266,7 +271,7 @@ public class SettingsHelper {
                if (sendBroadcastSystemUI) {
                    intent.setPackage(
                            context.getString(com.android.internal.R.string.config_systemUi));
                    context.sendBroadcastAsUser(intent, UserHandle.SYSTEM, null);
                    context.sendBroadcastAsUser(intent, context.getUser(), null);
                }
            }
        }