Add logs for QS tiles
These logs would help understand the restoring process of QS tiles from a bugreport. Test: Manual Bug: 254931931 Change-Id: I9214aea4922accd280c522c19f323636a39533a1
This commit is contained in:
@@ -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;
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
@@ -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 */);
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user