Backup system QS tiles

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:
Jason Monk
2016-08-25 15:57:14 -04:00
parent 28cb706ee9
commit baade7573f
4 changed files with 29 additions and 16 deletions

View File

@@ -6310,6 +6310,12 @@ public final class Settings {
public static final String SYSTEM_NAVIGATION_KEYS_ENABLED =
"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,
};
/**

View File

@@ -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();
}
}

View File

@@ -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) {

View File

@@ -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();
}
}