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
This commit is contained in:
Ricky Wai
2016-06-02 11:42:16 +01:00
parent 98801e9f2b
commit b96c1eacaf

View File

@@ -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<String> tileSpecs = loadTileSpecs(mContext, setting);
if (tileSpecs.contains(spec)) {
return;
}
ArrayList<String> 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) {