From efd1c54a400de12b5a73983418ce23ee6a47ab6b Mon Sep 17 00:00:00 2001 From: Akitaka Kimura Date: Tue, 27 Sep 2016 20:06:00 +0900 Subject: [PATCH] Fix Hotspot tile is shown on Guest user Last tiles are cached in QSTileHost and they are re-used for other users. But when the cached tile is added, QSTileHost doesn't check whether it is available or not. So Hotspot tile is shown on Guest user. To fix this issue, QSTileHost should check whether the tile is available when it is added. Bug: 32817349 Test: manual - add Hotspot tile to default tiles and switch to Guest user Change-Id: I96d5876024f6d519bf72a462b5c79dcf41b253f9 --- .../systemui/statusbar/phone/QSTileHost.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 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 fa5777570b5d4..18a7c2fbc5a35 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java @@ -335,16 +335,24 @@ public class QSTileHost implements QSTile.Host, Tunable { QSTile tile = mTiles.get(tileSpec); if (tile != null && (!(tile instanceof CustomTile) || ((CustomTile) tile).getUser() == currentUser)) { - if (DEBUG) Log.d(TAG, "Adding " + tile); - tile.removeCallbacks(); - newTiles.put(tileSpec, tile); + if (tile.isAvailable()) { + if (DEBUG) Log.d(TAG, "Adding " + tile); + tile.removeCallbacks(); + newTiles.put(tileSpec, tile); + } else { + tile.destroy(); + } } else { if (DEBUG) Log.d(TAG, "Creating tile: " + tileSpec); try { tile = createTile(tileSpec); - if (tile != null && tile.isAvailable()) { - tile.setTileSpec(tileSpec); - newTiles.put(tileSpec, tile); + if (tile != null) { + if (tile.isAvailable()) { + tile.setTileSpec(tileSpec); + newTiles.put(tileSpec, tile); + } else { + tile.destroy(); + } } } catch (Throwable t) { Log.w(TAG, "Error creating tile for spec: " + tileSpec, t);