Backup system QS tiles DO NOT MERGE
Add QS tiles to the backup list. Non-system tiles will get removed since they won't be installed when restore happens. Change-Id: Iccf6e773384c45bd4d1f10c21aa8af356b3920d2 Bug: 28782938
This commit is contained in:
@@ -6235,6 +6235,12 @@ public final class Settings {
|
||||
public static final String MANAGED_PROFILE_CONTACT_REMOTE_SEARCH =
|
||||
"managed_profile_contact_remote_search";
|
||||
|
||||
/**
|
||||
* Holds comma separated list of ordering of QS tiles.
|
||||
* @hide
|
||||
*/
|
||||
public static final String QS_TILES = "sysui_qs_tiles";
|
||||
|
||||
/**
|
||||
* This are the settings to be backed up.
|
||||
*
|
||||
@@ -6308,7 +6314,8 @@ public final class Settings {
|
||||
PREFERRED_TTY_MODE,
|
||||
ENHANCED_VOICE_PRIVACY_ENABLED,
|
||||
TTY_MODE_ENABLED,
|
||||
INCALL_POWER_BUTTON_BEHAVIOR
|
||||
INCALL_POWER_BUTTON_BEHAVIOR,
|
||||
QS_TILES,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -63,6 +63,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;
|
||||
@@ -123,6 +126,12 @@ public class TileLifecycleManager extends BroadcastReceiver implements
|
||||
}
|
||||
|
||||
public void setBindService(boolean bind) {
|
||||
if (mBound && mUnbindImmediate) {
|
||||
// If we are already bound and expecting to unbind, this means we should stay bound
|
||||
// because something else wants to hold the connection open.
|
||||
mUnbindImmediate = false;
|
||||
return;
|
||||
}
|
||||
mBound = bind;
|
||||
if (bind) {
|
||||
if (mBindTryCount == MAX_BIND_RETRIES) {
|
||||
@@ -399,4 +408,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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,8 +86,15 @@ 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();
|
||||
mStateManager.flushMessagesAndUnbind();
|
||||
}
|
||||
}
|
||||
|
||||
public void setTileChangeListener(TileChangeListener changeListener) {
|
||||
|
||||
@@ -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(component), intent,
|
||||
new UserHandle(ActivityManager.getCurrentUser()));
|
||||
lifecycleManager.onTileAdded();
|
||||
TileLifecycleManager.setTileAdded(mContext, component, false);
|
||||
lifecycleManager.flushMessagesAndUnbind();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user