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

Commit c4e19883 authored by Fabian Kozynski's avatar Fabian Kozynski Committed by Android (Google) Code Review
Browse files

Merge "Remove main thread ipc call in QuickQSPanel"

parents b4bf2246 c8d8f05b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -155,7 +155,7 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
        } else if (MOVE_FULL_ROWS.equals(key)) {
            mFullRows = TunerService.parseIntegerSwitch(newValue, true);
        } else if (QuickQSPanel.NUM_QUICK_TILES.equals(key)) {
            mNumQuickTiles = mQuickQsPanel.getNumQuickTiles(mQs.getContext());
            mNumQuickTiles = QuickQSPanel.parseNumTiles(newValue);
            clearAnimationState();
        }
        updateAnimators();
+5 −0
Original line number Diff line number Diff line
@@ -28,6 +28,11 @@ public interface QSFooter {
     */
    void setQSPanel(@Nullable QSPanel panel);

    /**
     * Sets the given {@link QuickQSPanel} to be the one associated with quick settings.
     */
    default void setQQSPanel(@Nullable QuickQSPanel panel) {};

    /**
     * Sets whether or not the footer should be visible.
     *
+8 −1
Original line number Diff line number Diff line
@@ -81,6 +81,7 @@ public class QSFooterImpl extends FrameLayout implements QSFooter,

    private boolean mQsDisabled;
    private QSPanel mQsPanel;
    private QuickQSPanel mQuickQsPanel;

    private boolean mExpanded;

@@ -177,7 +178,8 @@ public class QSFooterImpl extends FrameLayout implements QSFooter,
    }

    private void updateAnimator(int width) {
        int numTiles = QuickQSPanel.getNumQuickTiles(mContext);
        int numTiles = mQuickQsPanel != null ? mQuickQsPanel.getNumQuickTiles()
                : QuickQSPanel.getDefaultMaxTiles();
        int size = mContext.getResources().getDimensionPixelSize(R.dimen.qs_quick_tile_size)
                - mContext.getResources().getDimensionPixelSize(dimen.qs_quick_tile_padding);
        int remaining = (width - numTiles * size) / (numTiles - 1);
@@ -345,6 +347,11 @@ public class QSFooterImpl extends FrameLayout implements QSFooter,
        }
    }

    @Override
    public void setQQSPanel(@Nullable QuickQSPanel panel) {
        mQuickQsPanel = panel;
    }

    @Override
    public void onClick(View v) {
        // Don't do anything until view are unhidden
+25 −8
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.systemui.qs;

import static com.android.systemui.DejankUtils.whitelistIpcs;
import static com.android.systemui.util.InjectionInflationController.VIEW_CONTEXT;

import android.content.Context;
@@ -50,9 +49,10 @@ public class QuickQSPanel extends QSPanel {

    public static final String NUM_QUICK_TILES = "sysui_qqs_count";
    private static final String TAG = "QuickQSPanel";
    // Start it at 6 so a non-zero value can be obtained statically.
    private static int sDefaultMaxTiles = 6;

    private boolean mDisabledByPolicy;
    private static int mDefaultMaxTiles;
    private int mMaxTiles;
    protected QSPanel mFullPanel;

@@ -69,7 +69,7 @@ public class QuickQSPanel extends QSPanel {
            }
            removeView((View) mTileLayout);
        }
        mDefaultMaxTiles = getResources().getInteger(R.integer.quick_qs_panel_max_columns);
        sDefaultMaxTiles = getResources().getInteger(R.integer.quick_qs_panel_max_columns);
        mTileLayout = new HeaderTileLayout(context);
        mTileLayout.setListening(mListening);
        addView((View) mTileLayout, 0 /* Between brightness and footer */);
@@ -155,14 +155,31 @@ public class QuickQSPanel extends QSPanel {
    private final Tunable mNumTiles = new Tunable() {
        @Override
        public void onTuningChanged(String key, String newValue) {
            setMaxTiles(getNumQuickTiles(mContext));
            setMaxTiles(parseNumTiles(newValue));
        }
    };

    public static int getNumQuickTiles(Context context) {
        // TODO(b/140052679)
        return whitelistIpcs(() ->
                Dependency.get(TunerService.class).getValue(NUM_QUICK_TILES, mDefaultMaxTiles));
    public int getNumQuickTiles() {
        return mMaxTiles;
    }

    /**
     * Parses the String setting into the number of tiles. Defaults to {@code mDefaultMaxTiles}
     *
     * @param numTilesValue value of the setting to parse
     * @return parsed value of numTilesValue OR {@code mDefaultMaxTiles} on error
     */
    public static int parseNumTiles(String numTilesValue) {
        try {
            return Integer.parseInt(numTilesValue);
        } catch (NumberFormatException e) {
            // Couldn't read an int from the new setting value. Use default.
            return sDefaultMaxTiles;
        }
    }

    public static int getDefaultMaxTiles() {
        return sDefaultMaxTiles;
    }

    void setDisabledByPolicy(boolean disabled) {