Loading packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java +2 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import android.provider.Settings; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.ArraySet; import android.util.Log; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.app.LocalePicker; Loading Loading @@ -238,6 +239,7 @@ public class SettingsHelper { // If we fail to apply the setting, by definition nothing happened sendBroadcast = false; sendBroadcastSystemUI = false; Log.e(TAG, "Failed to restore setting name: " + name + " + value: " + value, e); } finally { // If this was an element of interest, send the "we just restored it" // broadcast with the historical value now that the new value has Loading packages/SystemUI/src/com/android/systemui/qs/AutoAddTracker.kt +2 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,7 @@ class AutoAddTracker @VisibleForTesting constructor( val tilesToRemove = restoredAutoAdded.filter { it !in restoredTiles } if (tilesToRemove.isNotEmpty()) { Log.d(TAG, "Removing tiles: $tilesToRemove") qsHost.removeTiles(tilesToRemove) } val tiles = synchronized(autoAdded) { Loading Loading @@ -255,6 +256,7 @@ class AutoAddTracker @VisibleForTesting constructor( override fun dump(pw: PrintWriter, args: Array<out String>) { pw.println("Current user: $userId") pw.println("Restored tiles: $restoredTiles") pw.println("Added tiles: $autoAdded") } Loading packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java +9 −4 Original line number Diff line number Diff line Loading @@ -302,7 +302,7 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, P if (tile != null && (!(tile instanceof CustomTile) || ((CustomTile) tile).getUser() == currentUser)) { if (tile.isAvailable()) { if (DEBUG) Log.d(TAG, "Adding " + tile); Log.d(TAG, "Adding " + tile); tile.removeCallbacks(); if (!(tile instanceof CustomTile) && mCurrentUser != currentUser) { tile.userSwitch(currentUser); Loading Loading @@ -421,6 +421,7 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, P // When calling this, you may want to modify mTilesListDirty accordingly. @MainThread private void saveTilesToSettings(List<String> tileSpecs) { Log.d(TAG, "Saving tiles: " + tileSpecs + " for user: " + mCurrentUser); mSecureSettings.putStringForUser(TILES_SETTING, TextUtils.join(",", tileSpecs), null /* tag */, false /* default */, mCurrentUser, true /* overrideable by restore */); Loading Loading @@ -494,7 +495,7 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, P lifecycleManager.flushMessagesAndUnbind(); } } if (DEBUG) Log.d(TAG, "saveCurrentTiles " + newTiles); Log.d(TAG, "saveCurrentTiles " + newTiles); mTilesListDirty = true; saveTilesToSettings(newTiles); } Loading Loading @@ -565,9 +566,9 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, P if (TextUtils.isEmpty(tileList)) { tileList = res.getString(R.string.quick_settings_tiles); if (DEBUG) Log.d(TAG, "Loaded tile specs from default config: " + tileList); Log.d(TAG, "Loaded tile specs from default config: " + tileList); } else { if (DEBUG) Log.d(TAG, "Loaded tile specs from setting: " + tileList); Log.d(TAG, "Loaded tile specs from setting: " + tileList); } final ArrayList<String> tiles = new ArrayList<String>(); boolean addedDefault = false; Loading Loading @@ -613,6 +614,10 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, P @Override public void dump(PrintWriter pw, String[] args) { pw.println("QSTileHost:"); pw.println("tile specs: " + mTileSpecs); pw.println("current user: " + mCurrentUser); pw.println("is dirty: " + mTilesListDirty); pw.println("tiles:"); mTiles.values().stream().filter(obj -> obj instanceof Dumpable) .forEach(o -> ((Dumpable) o).dump(pw, args)); } Loading packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java +14 −5 Original line number Diff line number Diff line Loading @@ -297,11 +297,20 @@ public class QSTileHostTest extends SysuiTestCase { StringWriter w = new StringWriter(); PrintWriter pw = new PrintWriter(w); mQSTileHost.dump(pw, new String[]{}); String output = "QSTileHost:\n" + TestTile1.class.getSimpleName() + ":\n" + " " + MOCK_STATE_STRING + "\n" + TestTile2.class.getSimpleName() + ":\n" + " " + MOCK_STATE_STRING + "\n"; String output = "QSTileHost:" + "\n" + "tile specs: [spec1, spec2]" + "\n" + "current user: 0" + "\n" + "is dirty: false" + "\n" + "tiles:" + "\n" + "TestTile1:" + "\n" + " MockState" + "\n" + "TestTile2:" + "\n" + " MockState" + "\n"; System.out.println(output); System.out.println(w.getBuffer().toString()); assertEquals(output, w.getBuffer().toString()); } Loading Loading
packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java +2 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import android.provider.Settings; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.ArraySet; import android.util.Log; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.app.LocalePicker; Loading Loading @@ -238,6 +239,7 @@ public class SettingsHelper { // If we fail to apply the setting, by definition nothing happened sendBroadcast = false; sendBroadcastSystemUI = false; Log.e(TAG, "Failed to restore setting name: " + name + " + value: " + value, e); } finally { // If this was an element of interest, send the "we just restored it" // broadcast with the historical value now that the new value has Loading
packages/SystemUI/src/com/android/systemui/qs/AutoAddTracker.kt +2 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,7 @@ class AutoAddTracker @VisibleForTesting constructor( val tilesToRemove = restoredAutoAdded.filter { it !in restoredTiles } if (tilesToRemove.isNotEmpty()) { Log.d(TAG, "Removing tiles: $tilesToRemove") qsHost.removeTiles(tilesToRemove) } val tiles = synchronized(autoAdded) { Loading Loading @@ -255,6 +256,7 @@ class AutoAddTracker @VisibleForTesting constructor( override fun dump(pw: PrintWriter, args: Array<out String>) { pw.println("Current user: $userId") pw.println("Restored tiles: $restoredTiles") pw.println("Added tiles: $autoAdded") } Loading
packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java +9 −4 Original line number Diff line number Diff line Loading @@ -302,7 +302,7 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, P if (tile != null && (!(tile instanceof CustomTile) || ((CustomTile) tile).getUser() == currentUser)) { if (tile.isAvailable()) { if (DEBUG) Log.d(TAG, "Adding " + tile); Log.d(TAG, "Adding " + tile); tile.removeCallbacks(); if (!(tile instanceof CustomTile) && mCurrentUser != currentUser) { tile.userSwitch(currentUser); Loading Loading @@ -421,6 +421,7 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, P // When calling this, you may want to modify mTilesListDirty accordingly. @MainThread private void saveTilesToSettings(List<String> tileSpecs) { Log.d(TAG, "Saving tiles: " + tileSpecs + " for user: " + mCurrentUser); mSecureSettings.putStringForUser(TILES_SETTING, TextUtils.join(",", tileSpecs), null /* tag */, false /* default */, mCurrentUser, true /* overrideable by restore */); Loading Loading @@ -494,7 +495,7 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, P lifecycleManager.flushMessagesAndUnbind(); } } if (DEBUG) Log.d(TAG, "saveCurrentTiles " + newTiles); Log.d(TAG, "saveCurrentTiles " + newTiles); mTilesListDirty = true; saveTilesToSettings(newTiles); } Loading Loading @@ -565,9 +566,9 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, P if (TextUtils.isEmpty(tileList)) { tileList = res.getString(R.string.quick_settings_tiles); if (DEBUG) Log.d(TAG, "Loaded tile specs from default config: " + tileList); Log.d(TAG, "Loaded tile specs from default config: " + tileList); } else { if (DEBUG) Log.d(TAG, "Loaded tile specs from setting: " + tileList); Log.d(TAG, "Loaded tile specs from setting: " + tileList); } final ArrayList<String> tiles = new ArrayList<String>(); boolean addedDefault = false; Loading Loading @@ -613,6 +614,10 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, P @Override public void dump(PrintWriter pw, String[] args) { pw.println("QSTileHost:"); pw.println("tile specs: " + mTileSpecs); pw.println("current user: " + mCurrentUser); pw.println("is dirty: " + mTilesListDirty); pw.println("tiles:"); mTiles.values().stream().filter(obj -> obj instanceof Dumpable) .forEach(o -> ((Dumpable) o).dump(pw, args)); } Loading
packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java +14 −5 Original line number Diff line number Diff line Loading @@ -297,11 +297,20 @@ public class QSTileHostTest extends SysuiTestCase { StringWriter w = new StringWriter(); PrintWriter pw = new PrintWriter(w); mQSTileHost.dump(pw, new String[]{}); String output = "QSTileHost:\n" + TestTile1.class.getSimpleName() + ":\n" + " " + MOCK_STATE_STRING + "\n" + TestTile2.class.getSimpleName() + ":\n" + " " + MOCK_STATE_STRING + "\n"; String output = "QSTileHost:" + "\n" + "tile specs: [spec1, spec2]" + "\n" + "current user: 0" + "\n" + "is dirty: false" + "\n" + "tiles:" + "\n" + "TestTile1:" + "\n" + " MockState" + "\n" + "TestTile2:" + "\n" + " MockState" + "\n"; System.out.println(output); System.out.println(w.getBuffer().toString()); assertEquals(output, w.getBuffer().toString()); } Loading