diff options
4 files changed, 29 insertions, 16 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 00d9387c6f03..300deea1c873 100755 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -6311,6 +6311,12 @@ public final class Settings { "system_navigation_keys_enabled"; /** + * Holds comma separated list of ordering of QS tiles. + * @hide + */ + public static final String QS_TILES = "sysui_qs_tiles"; + + /** * Whether preloaded APKs have been installed for the user. * @hide */ @@ -6396,7 +6402,8 @@ public final class Settings { NIGHT_DISPLAY_ACTIVATED, CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED, CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, - SYSTEM_NAVIGATION_KEYS_ENABLED + SYSTEM_NAVIGATION_KEYS_ENABLED, + QS_TILES, }; /** diff --git a/packages/SystemUI/src/com/android/systemui/qs/external/TileLifecycleManager.java b/packages/SystemUI/src/com/android/systemui/qs/external/TileLifecycleManager.java index 681005c2d08d..28da69c34e28 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/external/TileLifecycleManager.java +++ b/packages/SystemUI/src/com/android/systemui/qs/external/TileLifecycleManager.java @@ -65,6 +65,9 @@ public class TileLifecycleManager extends BroadcastReceiver implements private static final int MAX_BIND_RETRIES = 5; private static final int BIND_RETRY_DELAY = 1000; + // Shared prefs that hold tile lifecycle info. + private static final String TILES = "tiles_prefs"; + private final Context mContext; private final Handler mHandler; private final Intent mIntent; @@ -406,4 +409,13 @@ public class TileLifecycleManager extends BroadcastReceiver implements public interface TileChangeListener { void onTileChanged(ComponentName tile); } + + public static boolean isTileAdded(Context context, ComponentName component) { + return context.getSharedPreferences(TILES, 0).getBoolean(component.flattenToString(), false); + } + + public static void setTileAdded(Context context, ComponentName component, boolean added) { + context.getSharedPreferences(TILES, 0).edit().putBoolean(component.flattenToString(), + added).commit(); + } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/external/TileServiceManager.java b/packages/SystemUI/src/com/android/systemui/qs/external/TileServiceManager.java index f3e4d607aaaa..8493cc671d3a 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/external/TileServiceManager.java +++ b/packages/SystemUI/src/com/android/systemui/qs/external/TileServiceManager.java @@ -88,8 +88,14 @@ public class TileServiceManager { IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_PACKAGE_REMOVED); filter.addDataScheme("package"); - mServices.getContext().registerReceiverAsUser(mUninstallReceiver, + Context context = mServices.getContext(); + context.registerReceiverAsUser(mUninstallReceiver, new UserHandle(ActivityManager.getCurrentUser()), filter, null, mHandler); + ComponentName component = tileLifecycleManager.getComponent(); + if (!TileLifecycleManager.isTileAdded(context, component)) { + TileLifecycleManager.setTileAdded(context, component, true); + mStateManager.onTileAdded(); + } } public void setTileChangeListener(TileChangeListener changeListener) { 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 10facea1e8f8..da698d8a95d4 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java @@ -86,7 +86,7 @@ public class QSTileHost implements QSTile.Host, Tunable { private static final String TAG = "QSTileHost"; private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); - public static final String TILES_SETTING = "sysui_qs_tiles"; + public static final String TILES_SETTING = Secure.QS_TILES; private final Context mContext; private final PhoneStatusBar mStatusBar; @@ -407,19 +407,7 @@ public class QSTileHost implements QSTile.Host, Tunable { new UserHandle(ActivityManager.getCurrentUser())); lifecycleManager.onStopListening(); lifecycleManager.onTileRemoved(); - lifecycleManager.flushMessagesAndUnbind(); - } - } - for (int i = 0; i < NA; i++) { - String tileSpec = newTiles.get(i); - if (!tileSpec.startsWith(CustomTile.PREFIX)) continue; - if (!previousTiles.contains(tileSpec)) { - ComponentName component = CustomTile.getComponentFromSpec(tileSpec); - Intent intent = new Intent().setComponent(component); - TileLifecycleManager lifecycleManager = new TileLifecycleManager(new Handler(), - mContext, mServices, new Tile(), intent, - new UserHandle(ActivityManager.getCurrentUser())); - lifecycleManager.onTileAdded(); + TileLifecycleManager.setTileAdded(mContext, component, false); lifecycleManager.flushMessagesAndUnbind(); } } |