From 1fcc8c4c7ee1d8ffbbe5a76dd4859f4addf6d5ea Mon Sep 17 00:00:00 2001 From: Fabian Kozynski Date: Mon, 4 May 2020 13:31:47 -0400 Subject: QSTileHost use overrideableByRestore Starting in this release, settings that were set (after the first time) will not be overriden by restore. This does not work with QSTileHost as there are many things that may override secure sysui_qs_tiles without the user directly taking an action (for example, packages that are uninstalled or updated, may make tiles unavailable), changing the set of current tiles. In the case the restore is delayed, (for example D2D), it'd be good if this setting is restored, regardless of changes that may have happened in the intervening time. Marking all saving of this setting as overrideableByRestore may make some changes to be lost, however it's thought to be the better alternative, because of the following: * It continues the behavior from previous releases, preventing a regression. * If the user is using D2D, we can assume that they expect those tiles to be restored without changes. * If the user is using another restore method and they made changes to the tiles, this will override them, but it's no different than previous behavior. Also, use the cached currentUser. Fixes: 153835600 Test: build Change-Id: Id8f28ff4731556f7ccbee468e06cd3e03324f201 --- packages/SystemUI/AndroidManifest.xml | 3 +++ .../SystemUI/src/com/android/systemui/qs/QSTileHost.java | 16 ++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml index 61b1e30845b3..c4ea2e91dc31 100644 --- a/packages/SystemUI/AndroidManifest.xml +++ b/packages/SystemUI/AndroidManifest.xml @@ -259,6 +259,9 @@ + + + diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java b/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java index 54a928d78a89..4008918e267c 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java @@ -339,13 +339,18 @@ public class QSTileHost implements QSHost, Tunable, PluginListener, D changeTileSpecs(tileSpecs-> !tileSpecs.contains(spec) && tileSpecs.add(spec)); } + private void saveTilesToSettings(List tileSpecs) { + Settings.Secure.putStringForUser(mContext.getContentResolver(), TILES_SETTING, + TextUtils.join(",", tileSpecs), null /* tag */, + false /* default */, mCurrentUser, true /* overrideable by restore */); + } + private void changeTileSpecs(Predicate> changeFunction) { final String setting = Settings.Secure.getStringForUser(mContext.getContentResolver(), - TILES_SETTING, ActivityManager.getCurrentUser()); + TILES_SETTING, mCurrentUser); final List tileSpecs = loadTileSpecs(mContext, setting); if (changeFunction.test(tileSpecs)) { - Settings.Secure.putStringForUser(mContext.getContentResolver(), TILES_SETTING, - TextUtils.join(",", tileSpecs), ActivityManager.getCurrentUser()); + saveTilesToSettings(tileSpecs); } } @@ -375,7 +380,7 @@ public class QSTileHost implements QSHost, Tunable, PluginListener, D Intent intent = new Intent().setComponent(component); TileLifecycleManager lifecycleManager = new TileLifecycleManager(new Handler(), mContext, mServices, new Tile(), intent, - new UserHandle(ActivityManager.getCurrentUser()), + new UserHandle(mCurrentUser), mBroadcastDispatcher); lifecycleManager.onStopListening(); lifecycleManager.onTileRemoved(); @@ -384,8 +389,7 @@ public class QSTileHost implements QSHost, Tunable, PluginListener, D } } if (DEBUG) Log.d(TAG, "saveCurrentTiles " + newTiles); - Secure.putStringForUser(getContext().getContentResolver(), QSTileHost.TILES_SETTING, - TextUtils.join(",", newTiles), ActivityManager.getCurrentUser()); + saveTilesToSettings(newTiles); } public QSTile createTile(String tileSpec) { -- cgit v1.2.3-59-g8ed1b