Merge "Remove main thread ipc call in QuickQSPanel"

This commit is contained in:
Fabian Kozynski
2019-09-16 17:03:39 +00:00
committed by Android (Google) Code Review
4 changed files with 39 additions and 10 deletions

View File

@@ -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();

View File

@@ -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.
*

View File

@@ -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

View File

@@ -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) {