Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c05cbe2f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "QSTileHost use overrideableByRestore" into rvc-dev am: cb928769

Change-Id: I742fcc125f6a13647f1ce8130da7ebeadbc78b5b
parents f7780af3 cb928769
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -259,6 +259,9 @@
    <!-- Permission to register process observer -->
    <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.UNREGISTER_SLICE_RECEIVER" />
    <protected-broadcast android:name="com.android.settings.flashlight.action.FLASHLIGHT_CHANGED" />
+10 −6
Original line number Diff line number Diff line
@@ -339,13 +339,18 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, D
        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) {
        final String setting = Settings.Secure.getStringForUser(mContext.getContentResolver(),
            TILES_SETTING, ActivityManager.getCurrentUser());
                TILES_SETTING, mCurrentUser);
        final List<String> tileSpecs = loadTileSpecs(mContext, setting);
        if (changeFunction.test(tileSpecs)) {
            Settings.Secure.putStringForUser(mContext.getContentResolver(), TILES_SETTING,
                TextUtils.join(",", tileSpecs), ActivityManager.getCurrentUser());
            saveTilesToSettings(tileSpecs);
        }
    }

@@ -375,7 +380,7 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, D
                Intent intent = new Intent().setComponent(component);
                TileLifecycleManager lifecycleManager = new TileLifecycleManager(new Handler(),
                        mContext, mServices, new Tile(), intent,
                        new UserHandle(ActivityManager.getCurrentUser()),
                        new UserHandle(mCurrentUser),
                        mBroadcastDispatcher);
                lifecycleManager.onStopListening();
                lifecycleManager.onTileRemoved();
@@ -384,8 +389,7 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, D
            }
        }
        if (DEBUG) Log.d(TAG, "saveCurrentTiles " + newTiles);
        Secure.putStringForUser(getContext().getContentResolver(), QSTileHost.TILES_SETTING,
                TextUtils.join(",", newTiles), ActivityManager.getCurrentUser());
        saveTilesToSettings(newTiles);
    }

    public QSTile createTile(String tileSpec) {