From b96c1eacafdbe5be4690a553696a5841e2797701 Mon Sep 17 00:00:00 2001 From: Ricky Wai Date: Thu, 2 Jun 2016 11:42:16 +0100 Subject: [PATCH] Do not use cached tile specs value in QSTileHost.addTile() As addTile() can be run multiple times before listener receives the update, addTile() should always use the latest updated value from settings but not from the cache value. Bug: 28185436 Change-Id: I8c840343b797b00373a6f40cc5ea125efe68a6e1 --- .../android/systemui/statusbar/phone/QSTileHost.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java index 29b4db1743750..68e5d0b5bdd38 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java @@ -369,13 +369,15 @@ public class QSTileHost implements QSTile.Host, Tunable { } public void addTile(String spec) { - if (mTileSpecs.contains(spec)) { + final String setting = Settings.Secure.getStringForUser(mContext.getContentResolver(), + TILES_SETTING, ActivityManager.getCurrentUser()); + final List tileSpecs = loadTileSpecs(mContext, setting); + if (tileSpecs.contains(spec)) { return; } - ArrayList specs = new ArrayList<>(mTileSpecs); - specs.add(spec); + tileSpecs.add(spec); Settings.Secure.putStringForUser(mContext.getContentResolver(), TILES_SETTING, - TextUtils.join(",", specs), ActivityManager.getCurrentUser()); + TextUtils.join(",", tileSpecs), ActivityManager.getCurrentUser()); } public void addTile(ComponentName tile) {