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

Commit 14d8f3d9 authored by Michal Brzezinski's avatar Michal Brzezinski
Browse files

Adding extra logging for tiles distribution across pages

There are a few things:
- adding generic methods in QSLogger to be able to log simple messages without adding extra methods to it
- moving all logging in PagedTileLayout to using QSLogger
- for every case when we force tiles redistribution, we log reason why it is happening
- adding temp logs for when tiles are not redistributed but maybe they should be
- logging when split shade state has changed in QSPanelControllerBase

Bug: 255208946
Test: just adding logging
Change-Id: Ie0b165edbf1f79dfff78c55646e513d37cea67a3
parent 8b8aa7d6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ public class LogModule {
    @SysUISingleton
    @QSLog
    public static LogBuffer provideQuickSettingsLogBuffer(LogBufferFactory factory) {
        return factory.create("QSLog", 500 /* maxSize */, false /* systrace */);
        return factory.create("QSLog", 700 /* maxSize */, false /* systrace */);
    }

    /** Provides a logging buffer for {@link com.android.systemui.broadcast.BroadcastDispatcher} */
+32 −26
Original line number Diff line number Diff line
@@ -11,7 +11,6 @@ import android.content.Context;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -31,6 +30,7 @@ import com.android.systemui.R;
import com.android.systemui.plugins.qs.QSTile;
import com.android.systemui.qs.QSPanel.QSTileLayout;
import com.android.systemui.qs.QSPanelControllerBase.TileRecord;
import com.android.systemui.qs.logging.QSLogger;

import java.util.ArrayList;
import java.util.List;
@@ -38,11 +38,9 @@ import java.util.Set;

public class PagedTileLayout extends ViewPager implements QSTileLayout {

    private static final boolean DEBUG = false;
    private static final String CURRENT_PAGE = "current_page";
    private static final int NO_PAGE = -1;

    private static final String TAG = "PagedTileLayout";
    private static final int REVEAL_SCROLL_DURATION_MILLIS = 750;
    private static final float BOUNCE_ANIMATION_TENSION = 1.3f;
    private static final long BOUNCE_ANIMATION_DURATION = 450L;
@@ -55,6 +53,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
    private final ArrayList<TileRecord> mTiles = new ArrayList<>();
    private final ArrayList<TileLayout> mPages = new ArrayList<>();

    private QSLogger mLogger;
    @Nullable
    private PageIndicator mPageIndicator;
    private float mPageIndicatorPosition;
@@ -146,9 +145,15 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
        }
        if (mLayoutOrientation != newConfig.orientation) {
            mLayoutOrientation = newConfig.orientation;
            mDistributeTiles = true;
            forceTilesRedistribution("orientation changed to " + mLayoutOrientation);
            setCurrentItem(0, false);
            mPageToRestore = 0;
        } else {
            // logging in case we missed redistribution because orientation was not changed
            // while configuration changed, can be removed after b/255208946 is fixed
            mLogger.d(
                    "Orientation didn't change, tiles might be not redistributed, new config",
                    newConfig);
        }
    }

@@ -226,7 +231,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
            // Keep on drawing until the animation has finished.
            postInvalidateOnAnimation();
        } catch (NullPointerException e) {
            Log.e(TAG, "FakeDragBy called before begin", e);
            mLogger.logException("FakeDragBy called before begin", e);
            // If we were trying to fake drag, it means we just added a new tile to the last
            // page, so animate there.
            final int lastPageNumber = mPages.size() - 1;
@@ -246,7 +251,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
            super.endFakeDrag();
        } catch (NullPointerException e) {
            // Not sure what's going on. Let's log it
            Log.e(TAG, "endFakeDrag called without velocityTracker", e);
            mLogger.logException("endFakeDrag called without velocityTracker", e);
        }
    }

@@ -304,14 +309,14 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
    @Override
    public void addTile(TileRecord tile) {
        mTiles.add(tile);
        mDistributeTiles = true;
        forceTilesRedistribution("adding new tile");
        requestLayout();
    }

    @Override
    public void removeTile(TileRecord tile) {
        if (mTiles.remove(tile)) {
            mDistributeTiles = true;
            forceTilesRedistribution("removing tile");
            requestLayout();
        }
    }
@@ -367,19 +372,11 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
        final int tilesPerPageCount = mPages.get(0).maxTiles();
        int index = 0;
        final int totalTilesCount = mTiles.size();
        if (DEBUG) {
            Log.d(TAG, "Distributing tiles: "
                    + "[tilesPerPageCount=" + tilesPerPageCount + "]"
                    + "[totalTilesCount=" + totalTilesCount + "]"
            );
        }
        mLogger.logTileDistributionInProgress(tilesPerPageCount, totalTilesCount);
        for (int i = 0; i < totalTilesCount; i++) {
            TileRecord tile = mTiles.get(i);
            if (mPages.get(index).mRecords.size() == tilesPerPageCount) index++;
            if (DEBUG) {
                Log.d(TAG, "Adding " + tile.tile.getClass().getSimpleName() + " to "
                        + index);
            }
            mLogger.logTileDistributed(tile.tile.getClass().getSimpleName(), index);
            mPages.get(index).addTile(tile);
        }
    }
@@ -394,11 +391,11 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
            return;
        }
        while (mPages.size() < numPages) {
            if (DEBUG) Log.d(TAG, "Adding page");
            mLogger.d("Adding new page");
            mPages.add(createTileLayout());
        }
        while (mPages.size() > numPages) {
            if (DEBUG) Log.d(TAG, "Removing page");
            mLogger.d("Removing page");
            mPages.remove(mPages.size() - 1);
        }
        mPageIndicator.setNumPages(mPages.size());
@@ -417,8 +414,12 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
            changed |= mPages.get(i).updateResources();
        }
        if (changed) {
            mDistributeTiles = true;
            forceTilesRedistribution("resources in pages changed");
            requestLayout();
        } else {
            // logging in case we missed redistribution because number of column in updateResources
            // was not changed, can be removed after b/255208946 is fixed
            mLogger.d("resource in pages didn't change, tiles might be not redistributed");
        }
        return changed;
    }
@@ -430,7 +431,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
        for (int i = 0; i < mPages.size(); i++) {
            if (mPages.get(i).setMinRows(minRows)) {
                changed = true;
                mDistributeTiles = true;
                forceTilesRedistribution("minRows changed in page");
            }
        }
        return changed;
@@ -443,7 +444,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
        for (int i = 0; i < mPages.size(); i++) {
            if (mPages.get(i).setMaxColumns(maxColumns)) {
                changed = true;
                mDistributeTiles = true;
                forceTilesRedistribution("maxColumns in pages changed");
            }
        }
        return changed;
@@ -710,14 +711,14 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
    private final PagerAdapter mAdapter = new PagerAdapter() {
        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
            if (DEBUG) Log.d(TAG, "Destantiating " + position);
            mLogger.d("Destantiating page at", position);
            container.removeView((View) object);
            updateListening();
        }

        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            if (DEBUG) Log.d(TAG, "Instantiating " + position);
            mLogger.d("Instantiating page at", position);
            if (isLayoutRtl()) {
                position = mPages.size() - 1 - position;
            }
@@ -745,10 +746,15 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
     * Force all tiles to be redistributed across pages.
     * Should be called when one of the following changes: rows, columns, number of tiles.
     */
    public void forceTilesRedistribution() {
    public void forceTilesRedistribution(String reason) {
        mLogger.d("forcing tile redistribution across pages, reason", reason);
        mDistributeTiles = true;
    }

    public void setLogger(QSLogger qsLogger) {
        mLogger = qsLogger;
    }

    public interface PageListener {
        int INVALID_PAGE = -1;

+7 −1
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import com.android.internal.logging.UiEventLogger;
import com.android.internal.widget.RemeasuringLinearLayout;
import com.android.systemui.R;
import com.android.systemui.plugins.qs.QSTile;
import com.android.systemui.qs.logging.QSLogger;
import com.android.systemui.settings.brightness.BrightnessSliderController;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerService.Tunable;
@@ -106,6 +107,7 @@ public class QSPanel extends LinearLayout implements Tunable {
    private ViewGroup mMediaHostView;
    private boolean mShouldMoveMediaOnExpansion = true;
    private boolean mUsingCombinedHeaders = false;
    private QSLogger mQsLogger;

    public QSPanel(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -122,7 +124,8 @@ public class QSPanel extends LinearLayout implements Tunable {

    }

    void initialize() {
    void initialize(QSLogger qsLogger) {
        mQsLogger = qsLogger;
        mTileLayout = getOrCreateTileLayout();

        if (mUsingMediaPlayer) {
@@ -206,6 +209,7 @@ public class QSPanel extends LinearLayout implements Tunable {
        if (mTileLayout == null) {
            mTileLayout = (QSTileLayout) LayoutInflater.from(mContext)
                    .inflate(R.layout.qs_paged_tile_layout, this, false);
            mTileLayout.setLogger(mQsLogger);
            mTileLayout.setSquishinessFraction(mSquishinessFraction);
        }
        return mTileLayout;
@@ -735,6 +739,8 @@ public class QSPanel extends LinearLayout implements Tunable {
        default void setExpansion(float expansion, float proposedTranslation) {}

        int getNumVisibleTiles();

        default void setLogger(QSLogger qsLogger) { }
    }

    interface OnConfigurationChangedListener {
+4 −4
Original line number Diff line number Diff line
@@ -122,9 +122,8 @@ public class QSPanelController extends QSPanelControllerBase<QSPanel> {
        }
        switchTileLayout(true);
        mBrightnessMirrorHandler.onQsPanelAttached();

        ((PagedTileLayout) mView.getOrCreateTileLayout())
                .setOnTouchListener(mTileLayoutTouchListener);
        PagedTileLayout pagedTileLayout= ((PagedTileLayout) mView.getOrCreateTileLayout());
        pagedTileLayout.setOnTouchListener(mTileLayoutTouchListener);
    }

    @Override
@@ -150,7 +149,8 @@ public class QSPanelController extends QSPanelControllerBase<QSPanel> {

    @Override
    protected void onSplitShadeChanged() {
        ((PagedTileLayout) mView.getOrCreateTileLayout()).forceTilesRedistribution();
        ((PagedTileLayout) mView.getOrCreateTileLayout())
                .forceTilesRedistribution("Split shade state changed");
    }

    /** */
+3 −2
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr
    protected final MediaHost mMediaHost;
    protected final MetricsLogger mMetricsLogger;
    private final UiEventLogger mUiEventLogger;
    private final QSLogger mQSLogger;
    protected final QSLogger mQSLogger;
    private final DumpManager mDumpManager;
    protected final ArrayList<TileRecord> mRecords = new ArrayList<>();
    protected boolean mShouldUseSplitNotificationShade;
@@ -152,7 +152,7 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr

    @Override
    protected void onInit() {
        mView.initialize();
        mView.initialize(mQSLogger);
        mQSLogger.logAllTilesChangeListening(mView.isListening(), mView.getDumpableTag(), "");
    }

@@ -430,6 +430,7 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr
            pw.println("  horizontal layout: " + mUsingHorizontalLayout);
            pw.println("  last orientation: " + mLastOrientation);
        }
        pw.println("  mShouldUseSplitNotificationShade: " + mShouldUseSplitNotificationShade);
    }

    public QSPanel.QSTileLayout getTileLayout() {
Loading