Loading packages/SystemUI/src/com/android/systemui/controls/controller/ControlsBindingController.kt +1 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ import android.content.ComponentName import android.service.controls.Control import android.service.controls.ControlsProviderService import android.service.controls.actions.ControlAction import com.android.systemui.controls.UserAwareController import com.android.systemui.util.UserAwareController import java.util.function.Consumer /** Loading packages/SystemUI/src/com/android/systemui/controls/controller/ControlsController.kt +1 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ import android.service.controls.Control import android.service.controls.ControlsProviderService import android.service.controls.actions.ControlAction import com.android.systemui.controls.ControlStatus import com.android.systemui.controls.UserAwareController import com.android.systemui.util.UserAwareController import com.android.systemui.controls.management.ControlsFavoritingActivity import com.android.systemui.controls.ui.ControlsUiController import java.util.function.Consumer Loading packages/SystemUI/src/com/android/systemui/controls/management/ControlsListingController.kt +2 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ package com.android.systemui.controls.management import android.content.ComponentName import com.android.systemui.controls.ControlsServiceInfo import com.android.systemui.controls.UserAwareController import com.android.systemui.util.UserAwareController import com.android.systemui.statusbar.policy.CallbackController /** Loading packages/SystemUI/src/com/android/systemui/qs/AutoAddTracker.java +53 −11 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static com.android.systemui.statusbar.phone.AutoTileManager.WORK; import android.content.Context; import android.database.ContentObserver; import android.os.Handler; import android.os.UserHandle; import android.provider.Settings.Secure; import android.text.TextUtils; import android.util.ArraySet; Loading @@ -30,6 +31,7 @@ import android.util.ArraySet; import com.android.internal.annotations.VisibleForTesting; import com.android.systemui.Prefs; import com.android.systemui.Prefs.Key; import com.android.systemui.util.UserAwareController; import java.util.Arrays; import java.util.Collection; Loading @@ -37,7 +39,7 @@ import java.util.Collections; import javax.inject.Inject; public class AutoAddTracker { public class AutoAddTracker implements UserAwareController { private static final String[][] CONVERT_PREFS = { {Key.QS_HOTSPOT_ADDED, HOTSPOT}, Loading @@ -49,20 +51,39 @@ public class AutoAddTracker { private final ArraySet<String> mAutoAdded; private final Context mContext; private int mUserId; @Inject public AutoAddTracker(Context context) { public AutoAddTracker(Context context, int userId) { mContext = context; mUserId = userId; mAutoAdded = new ArraySet<>(getAdded()); // TODO: remove migration code and shared preferences keys after P release if (mUserId == UserHandle.USER_SYSTEM) { for (String[] convertPref : CONVERT_PREFS) { if (Prefs.getBoolean(context, convertPref[0], false)) { setTileAdded(convertPref[1]); Prefs.remove(context, convertPref[0]); } } } mContext.getContentResolver().registerContentObserver( Secure.getUriFor(Secure.QS_AUTO_ADDED_TILES), false, mObserver); Secure.getUriFor(Secure.QS_AUTO_ADDED_TILES), false, mObserver, UserHandle.USER_ALL); } @Override public void changeUser(UserHandle newUser) { if (newUser.getIdentifier() == mUserId) { return; } mUserId = newUser.getIdentifier(); mAutoAdded.clear(); mAutoAdded.addAll(getAdded()); } @Override public int getCurrentUserId() { return mUserId; } public boolean isAdded(String tile) { Loading @@ -86,12 +107,13 @@ public class AutoAddTracker { } private void saveTiles() { Secure.putString(mContext.getContentResolver(), Secure.QS_AUTO_ADDED_TILES, TextUtils.join(",", mAutoAdded)); Secure.putStringForUser(mContext.getContentResolver(), Secure.QS_AUTO_ADDED_TILES, TextUtils.join(",", mAutoAdded), mUserId); } private Collection<String> getAdded() { String current = Secure.getString(mContext.getContentResolver(), Secure.QS_AUTO_ADDED_TILES); String current = Secure.getStringForUser(mContext.getContentResolver(), Secure.QS_AUTO_ADDED_TILES, mUserId); if (current == null) { return Collections.emptyList(); } Loading @@ -102,7 +124,27 @@ public class AutoAddTracker { protected final ContentObserver mObserver = new ContentObserver(new Handler()) { @Override public void onChange(boolean selfChange) { mAutoAdded.clear(); mAutoAdded.addAll(getAdded()); } }; public static class Builder { private final Context mContext; private int mUserId; @Inject public Builder(Context context) { mContext = context; } public Builder setUserId(int userId) { mUserId = userId; return this; } public AutoAddTracker build() { return new AutoAddTracker(mContext, mUserId); } } } packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java +3 −0 Original line number Diff line number Diff line Loading @@ -255,6 +255,9 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, D int currentUser = ActivityManager.getCurrentUser(); if (currentUser != mCurrentUser) { mUserContext = mContext.createContextAsUser(UserHandle.of(currentUser), 0); if (mAutoTiles != null) { mAutoTiles.changeUser(UserHandle.of(currentUser)); } } if (tileSpecs.equals(mTileSpecs) && currentUser == mCurrentUser) return; mTiles.entrySet().stream().filter(tile -> !tileSpecs.contains(tile.getKey())).forEach( Loading Loading
packages/SystemUI/src/com/android/systemui/controls/controller/ControlsBindingController.kt +1 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ import android.content.ComponentName import android.service.controls.Control import android.service.controls.ControlsProviderService import android.service.controls.actions.ControlAction import com.android.systemui.controls.UserAwareController import com.android.systemui.util.UserAwareController import java.util.function.Consumer /** Loading
packages/SystemUI/src/com/android/systemui/controls/controller/ControlsController.kt +1 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ import android.service.controls.Control import android.service.controls.ControlsProviderService import android.service.controls.actions.ControlAction import com.android.systemui.controls.ControlStatus import com.android.systemui.controls.UserAwareController import com.android.systemui.util.UserAwareController import com.android.systemui.controls.management.ControlsFavoritingActivity import com.android.systemui.controls.ui.ControlsUiController import java.util.function.Consumer Loading
packages/SystemUI/src/com/android/systemui/controls/management/ControlsListingController.kt +2 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ package com.android.systemui.controls.management import android.content.ComponentName import com.android.systemui.controls.ControlsServiceInfo import com.android.systemui.controls.UserAwareController import com.android.systemui.util.UserAwareController import com.android.systemui.statusbar.policy.CallbackController /** Loading
packages/SystemUI/src/com/android/systemui/qs/AutoAddTracker.java +53 −11 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static com.android.systemui.statusbar.phone.AutoTileManager.WORK; import android.content.Context; import android.database.ContentObserver; import android.os.Handler; import android.os.UserHandle; import android.provider.Settings.Secure; import android.text.TextUtils; import android.util.ArraySet; Loading @@ -30,6 +31,7 @@ import android.util.ArraySet; import com.android.internal.annotations.VisibleForTesting; import com.android.systemui.Prefs; import com.android.systemui.Prefs.Key; import com.android.systemui.util.UserAwareController; import java.util.Arrays; import java.util.Collection; Loading @@ -37,7 +39,7 @@ import java.util.Collections; import javax.inject.Inject; public class AutoAddTracker { public class AutoAddTracker implements UserAwareController { private static final String[][] CONVERT_PREFS = { {Key.QS_HOTSPOT_ADDED, HOTSPOT}, Loading @@ -49,20 +51,39 @@ public class AutoAddTracker { private final ArraySet<String> mAutoAdded; private final Context mContext; private int mUserId; @Inject public AutoAddTracker(Context context) { public AutoAddTracker(Context context, int userId) { mContext = context; mUserId = userId; mAutoAdded = new ArraySet<>(getAdded()); // TODO: remove migration code and shared preferences keys after P release if (mUserId == UserHandle.USER_SYSTEM) { for (String[] convertPref : CONVERT_PREFS) { if (Prefs.getBoolean(context, convertPref[0], false)) { setTileAdded(convertPref[1]); Prefs.remove(context, convertPref[0]); } } } mContext.getContentResolver().registerContentObserver( Secure.getUriFor(Secure.QS_AUTO_ADDED_TILES), false, mObserver); Secure.getUriFor(Secure.QS_AUTO_ADDED_TILES), false, mObserver, UserHandle.USER_ALL); } @Override public void changeUser(UserHandle newUser) { if (newUser.getIdentifier() == mUserId) { return; } mUserId = newUser.getIdentifier(); mAutoAdded.clear(); mAutoAdded.addAll(getAdded()); } @Override public int getCurrentUserId() { return mUserId; } public boolean isAdded(String tile) { Loading @@ -86,12 +107,13 @@ public class AutoAddTracker { } private void saveTiles() { Secure.putString(mContext.getContentResolver(), Secure.QS_AUTO_ADDED_TILES, TextUtils.join(",", mAutoAdded)); Secure.putStringForUser(mContext.getContentResolver(), Secure.QS_AUTO_ADDED_TILES, TextUtils.join(",", mAutoAdded), mUserId); } private Collection<String> getAdded() { String current = Secure.getString(mContext.getContentResolver(), Secure.QS_AUTO_ADDED_TILES); String current = Secure.getStringForUser(mContext.getContentResolver(), Secure.QS_AUTO_ADDED_TILES, mUserId); if (current == null) { return Collections.emptyList(); } Loading @@ -102,7 +124,27 @@ public class AutoAddTracker { protected final ContentObserver mObserver = new ContentObserver(new Handler()) { @Override public void onChange(boolean selfChange) { mAutoAdded.clear(); mAutoAdded.addAll(getAdded()); } }; public static class Builder { private final Context mContext; private int mUserId; @Inject public Builder(Context context) { mContext = context; } public Builder setUserId(int userId) { mUserId = userId; return this; } public AutoAddTracker build() { return new AutoAddTracker(mContext, mUserId); } } }
packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java +3 −0 Original line number Diff line number Diff line Loading @@ -255,6 +255,9 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, D int currentUser = ActivityManager.getCurrentUser(); if (currentUser != mCurrentUser) { mUserContext = mContext.createContextAsUser(UserHandle.of(currentUser), 0); if (mAutoTiles != null) { mAutoTiles.changeUser(UserHandle.of(currentUser)); } } if (tileSpecs.equals(mTileSpecs) && currentUser == mCurrentUser) return; mTiles.entrySet().stream().filter(tile -> !tileSpecs.contains(tile.getKey())).forEach( Loading