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

Commit b5ba0c00 authored by Anton Potapov's avatar Anton Potapov Committed by Automerger Merge Worker
Browse files

Merge "Add logs for QS tiles" into udc-dev am: 34a00ec6

parents 4dc8e307 34a00ec6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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
+2 −0
Original line number Diff line number Diff line
@@ -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")
    }

+9 −4
Original line number Diff line number Diff line
@@ -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));
    }
+14 −5
Original line number Diff line number Diff line
@@ -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());
    }