Merge "QSTileHost use overrideableByRestore" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
cb9287697d
@@ -259,6 +259,9 @@
|
|||||||
<!-- Permission to register process observer -->
|
<!-- Permission to register process observer -->
|
||||||
<uses-permission android:name="android.permission.SET_ACTIVITY_WATCHER"/>
|
<uses-permission android:name="android.permission.SET_ACTIVITY_WATCHER"/>
|
||||||
|
|
||||||
|
<!-- Restore settings (used by QS) even if they have been modified -->
|
||||||
|
<uses-permission android:name="android.permission.MODIFY_SETTINGS_OVERRIDEABLE_BY_RESTORE" />
|
||||||
|
|
||||||
<protected-broadcast android:name="com.android.settingslib.action.REGISTER_SLICE_RECEIVER" />
|
<protected-broadcast android:name="com.android.settingslib.action.REGISTER_SLICE_RECEIVER" />
|
||||||
<protected-broadcast android:name="com.android.settingslib.action.UNREGISTER_SLICE_RECEIVER" />
|
<protected-broadcast android:name="com.android.settingslib.action.UNREGISTER_SLICE_RECEIVER" />
|
||||||
<protected-broadcast android:name="com.android.settings.flashlight.action.FLASHLIGHT_CHANGED" />
|
<protected-broadcast android:name="com.android.settings.flashlight.action.FLASHLIGHT_CHANGED" />
|
||||||
|
|||||||
@@ -339,13 +339,18 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, D
|
|||||||
changeTileSpecs(tileSpecs-> !tileSpecs.contains(spec) && tileSpecs.add(spec));
|
changeTileSpecs(tileSpecs-> !tileSpecs.contains(spec) && tileSpecs.add(spec));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void saveTilesToSettings(List<String> tileSpecs) {
|
||||||
|
Settings.Secure.putStringForUser(mContext.getContentResolver(), TILES_SETTING,
|
||||||
|
TextUtils.join(",", tileSpecs), null /* tag */,
|
||||||
|
false /* default */, mCurrentUser, true /* overrideable by restore */);
|
||||||
|
}
|
||||||
|
|
||||||
private void changeTileSpecs(Predicate<List<String>> changeFunction) {
|
private void changeTileSpecs(Predicate<List<String>> changeFunction) {
|
||||||
final String setting = Settings.Secure.getStringForUser(mContext.getContentResolver(),
|
final String setting = Settings.Secure.getStringForUser(mContext.getContentResolver(),
|
||||||
TILES_SETTING, ActivityManager.getCurrentUser());
|
TILES_SETTING, mCurrentUser);
|
||||||
final List<String> tileSpecs = loadTileSpecs(mContext, setting);
|
final List<String> tileSpecs = loadTileSpecs(mContext, setting);
|
||||||
if (changeFunction.test(tileSpecs)) {
|
if (changeFunction.test(tileSpecs)) {
|
||||||
Settings.Secure.putStringForUser(mContext.getContentResolver(), TILES_SETTING,
|
saveTilesToSettings(tileSpecs);
|
||||||
TextUtils.join(",", tileSpecs), ActivityManager.getCurrentUser());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,7 +380,7 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, D
|
|||||||
Intent intent = new Intent().setComponent(component);
|
Intent intent = new Intent().setComponent(component);
|
||||||
TileLifecycleManager lifecycleManager = new TileLifecycleManager(new Handler(),
|
TileLifecycleManager lifecycleManager = new TileLifecycleManager(new Handler(),
|
||||||
mContext, mServices, new Tile(), intent,
|
mContext, mServices, new Tile(), intent,
|
||||||
new UserHandle(ActivityManager.getCurrentUser()),
|
new UserHandle(mCurrentUser),
|
||||||
mBroadcastDispatcher);
|
mBroadcastDispatcher);
|
||||||
lifecycleManager.onStopListening();
|
lifecycleManager.onStopListening();
|
||||||
lifecycleManager.onTileRemoved();
|
lifecycleManager.onTileRemoved();
|
||||||
@@ -384,8 +389,7 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, D
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (DEBUG) Log.d(TAG, "saveCurrentTiles " + newTiles);
|
if (DEBUG) Log.d(TAG, "saveCurrentTiles " + newTiles);
|
||||||
Secure.putStringForUser(getContext().getContentResolver(), QSTileHost.TILES_SETTING,
|
saveTilesToSettings(newTiles);
|
||||||
TextUtils.join(",", newTiles), ActivityManager.getCurrentUser());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public QSTile createTile(String tileSpec) {
|
public QSTile createTile(String tileSpec) {
|
||||||
|
|||||||
Reference in New Issue
Block a user