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

Commit ca30f570 authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

Add QSLogs using new loggers

Test: manual using DumpController
Test: atest

Change-Id: Id665ff047d60ddfa5f8f2fe907b7e20f84bd0013
parent 753216eb
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@

package com.android.systemui.plugins.qs;

import android.annotation.NonNull;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.metrics.LogMaker;
@@ -107,6 +108,12 @@ public interface QSTile {
        public int getPadding() {
            return 0;
        }

        @Override
        @NonNull
        public String toString() {
            return "Icon";
        }
    }

    @ProvidesInterface(version = State.VERSION)
+12 −0
Original line number Diff line number Diff line
@@ -61,6 +61,18 @@ public class LogModule {
        return buffer;
    }

    /** Provides a logging buffer for all logs related to Quick Settings. */
    @Provides
    @Singleton
    @QSLog
    public static LogBuffer provideQuickSettingsLogBuffer(
            LogcatEchoTracker bufferFilter,
            DumpController dumpController) {
        LogBuffer buffer = new LogBuffer("QSLog", 500, 10, bufferFilter);
        buffer.attach(dumpController);
        return buffer;
    }

    /** Allows logging buffers to be tweaked via adb on debug builds but not on prod builds. */
    @Provides
    @Singleton
+33 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.log.dagger;

import static java.lang.annotation.RetentionPolicy.RUNTIME;

import com.android.systemui.log.LogBuffer;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;

import javax.inject.Qualifier;

/** A {@link LogBuffer} for QS-related messages. */
@Qualifier
@Documented
@Retention(RUNTIME)
public @interface QSLog {
}
+2 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ import android.content.Context;

import com.android.systemui.plugins.qs.QSTile;
import com.android.systemui.qs.external.TileServices;
import com.android.systemui.qs.logging.QSLogger;

import java.util.Collection;

@@ -27,6 +28,7 @@ public interface QSHost {
    void forceCollapsePanels();
    void openPanels();
    Context getContext();
    QSLogger getQSLogger();
    Collection<QSTile> getTiles();
    void addCallback(Callback callback);
    void removeCallback(Callback callback);
+23 −14
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ import com.android.systemui.plugins.qs.QSTileView;
import com.android.systemui.qs.QSHost.Callback;
import com.android.systemui.qs.customize.QSCustomizer;
import com.android.systemui.qs.external.CustomTile;
import com.android.systemui.qs.logging.QSLogger;
import com.android.systemui.settings.BrightnessController;
import com.android.systemui.settings.ToggleSliderView;
import com.android.systemui.statusbar.policy.BrightnessMirrorController;
@@ -69,6 +70,7 @@ import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

import javax.inject.Inject;
import javax.inject.Named;
@@ -84,6 +86,7 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne

    protected final Context mContext;
    protected final ArrayList<TileRecord> mRecords = new ArrayList<>();
    private String mCachedSpecs = "";
    protected final View mBrightnessView;
    private final H mHandler = new H();
    private final MetricsLogger mMetricsLogger = Dependency.get(MetricsLogger.class);
@@ -101,6 +104,7 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
    private QSDetail.Callback mCallback;
    private BrightnessController mBrightnessController;
    private DumpController mDumpController;
    private final QSLogger mQSLogger;
    protected QSTileHost mHost;

    protected QSSecurityFooter mFooter;
@@ -140,23 +144,17 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
        }
    };

    public QSPanel(Context context) {
        this(context, null);
    }

    public QSPanel(Context context, AttributeSet attrs) {
        this(context, attrs, null);
    }

    public QSPanel(Context context, AttributeSet attrs, DumpController dumpController) {
        this(context, attrs, dumpController, Dependency.get(BroadcastDispatcher.class));
    }

    @Inject
    public QSPanel(@Named(VIEW_CONTEXT) Context context, AttributeSet attrs,
            DumpController dumpController, BroadcastDispatcher broadcastDispatcher) {
    public QSPanel(
            @Named(VIEW_CONTEXT) Context context,
            AttributeSet attrs,
            DumpController dumpController,
            BroadcastDispatcher broadcastDispatcher,
            QSLogger qsLogger
    ) {
        super(context, attrs);
        mContext = context;
        mQSLogger = qsLogger;

        setOrientation(VERTICAL);

@@ -166,6 +164,7 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne

        mTileLayout = (QSTileLayout) LayoutInflater.from(mContext).inflate(
                R.layout.qs_paged_tile_layout, this, false);
        mQSLogger.logAllTilesChangeListening(mListening, getDumpableTag(), mCachedSpecs);
        mTileLayout.setListening(mListening);
        addView((View) mTileLayout);

@@ -521,6 +520,7 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne

    public void setExpanded(boolean expanded) {
        if (mExpanded == expanded) return;
        mQSLogger.logPanelExpanded(expanded, getDumpableTag());
        mExpanded = expanded;
        if (!mExpanded && mTileLayout instanceof PagedTileLayout) {
            ((PagedTileLayout) mTileLayout).setCurrentItem(0, false);
@@ -547,6 +547,7 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
        if (mListening == listening) return;
        mListening = listening;
        if (mTileLayout != null) {
            mQSLogger.logAllTilesChangeListening(listening, getDumpableTag(), mCachedSpecs);
            mTileLayout.setListening(listening);
        }
        if (mListening) {
@@ -554,6 +555,12 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
        }
    }

    private String getTilesSpecs() {
        return mRecords.stream()
                .map(tileRecord ->  tileRecord.tile.getTileSpec())
                .collect(Collectors.joining(","));
    }

    public void setListening(boolean listening, boolean expanded) {
        setListening(listening && expanded);
        getFooter().setListening(listening);
@@ -611,6 +618,7 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
            record.tile.removeCallback(record.callback);
        }
        mRecords.clear();
        mCachedSpecs = "";
        for (QSTile tile : tiles) {
            addTile(tile, collapsedView);
        }
@@ -675,6 +683,7 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
        r.tileView.init(r.tile);
        r.tile.refreshState();
        mRecords.add(r);
        mCachedSpecs = getTilesSpecs();

        if (mTileLayout != null) {
            mTileLayout.addTile(r);
Loading