Skip to content

Commit 198a030

Browse files
committed
Fix the seesaw behavior on the status panels.
The code in onMeasure that attempts to accommodate changing child boundaries (i.e. an expanding/collapsing notification) was locking the window size to the child measurement, even though another window was trying to seesaw it closed. We now only activate the rubberband behavior when the size of the children changes, not on each onMeasure(). Lots of other small fixes to the panel expansion logic, too, including ensuring that the expanded fraction doesn't jump to 1.0f when the panel content hasn't been laid out yet (causing the entire screen to become dim for a second thanks to PhoneStatusBarView.panelExpansionChanged). This change also restores the ability of Binder clients (such as accessibility systems) to expand and collapse the status bar. Bug: 7008196 Bug: 6995518 Bug: 6628429 Change-Id: Ib0244a27aef2b4dbe19be98f7e039a9d38f1b80e
1 parent d79dd34 commit 198a030

File tree

6 files changed

+90
-33
lines changed

6 files changed

+90
-33
lines changed

packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@
8484

8585
public abstract class BaseStatusBar extends SystemUI implements
8686
CommandQueue.Callbacks {
87-
static final String TAG = "StatusBar";
88-
private static final boolean DEBUG = false;
87+
public static final String TAG = "StatusBar";
88+
public static final boolean DEBUG = false;
8989
public static final boolean MULTIUSER_DEBUG = false;
9090

9191
protected static final int MSG_TOGGLE_RECENTS_PANEL = 1020;
@@ -162,6 +162,9 @@ public void onChange(boolean selfChange) {
162162
private RemoteViews.OnClickHandler mOnClickHandler = new RemoteViews.OnClickHandler() {
163163
@Override
164164
public boolean onClickHandler(View view, PendingIntent pendingIntent, Intent fillInIntent) {
165+
if (DEBUG) {
166+
Slog.v(TAG, "Notification click handler invoked for intent: " + pendingIntent);
167+
}
165168
final boolean isActivity = pendingIntent.isActivity();
166169
if (isActivity) {
167170
try {

packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,23 @@
1010

1111
public class PanelBar extends FrameLayout {
1212
public static final boolean DEBUG = false;
13-
public static final String TAG = PanelView.class.getSimpleName();
13+
public static final String TAG = PanelBar.class.getSimpleName();
1414
public static final void LOG(String fmt, Object... args) {
1515
if (!DEBUG) return;
1616
Slog.v(TAG, String.format(fmt, args));
1717
}
1818

19+
public static final int STATE_CLOSED = 0;
20+
public static final int STATE_OPENING = 1;
21+
public static final int STATE_OPEN = 2;
22+
1923
private PanelHolder mPanelHolder;
2024
private ArrayList<PanelView> mPanels = new ArrayList<PanelView>();
2125
protected PanelView mTouchingPanel;
22-
private static final int STATE_CLOSED = 0;
23-
private static final int STATE_TRANSITIONING = 1;
24-
private static final int STATE_OPEN = 2;
2526
private int mState = STATE_CLOSED;
2627
private boolean mTracking;
2728

28-
private void go(int state) {
29+
public void go(int state) {
2930
LOG("go state: %d -> %d", mState, state);
3031
mState = state;
3132
}
@@ -80,25 +81,32 @@ public boolean onTouchEvent(MotionEvent event) {
8081

8182
// figure out which panel needs to be talked to here
8283
if (event.getAction() == MotionEvent.ACTION_DOWN) {
83-
mTouchingPanel = selectPanelForTouchX(event.getX());
84-
mPanelHolder.setSelectedPanel(mTouchingPanel);
85-
LOG("PanelBar.onTouch: state=%d ACTION_DOWN: panel %s", mState, mTouchingPanel.getName());
86-
if (mState == STATE_CLOSED || mState == STATE_OPEN) {
87-
go(STATE_TRANSITIONING);
88-
onPanelPeeked();
89-
}
84+
final PanelView panel = selectPanelForTouchX(event.getX());
85+
LOG("PanelBar.onTouch: state=%d ACTION_DOWN: panel %s", mState, panel);
86+
startOpeningPanel(panel);
9087
}
9188
final boolean result = mTouchingPanel.getHandle().dispatchTouchEvent(event);
9289
return result;
9390
}
9491

92+
// called from PanelView when self-expanding, too
93+
public void startOpeningPanel(PanelView panel) {
94+
LOG("startOpeningPanel: " + panel);
95+
mTouchingPanel = panel;
96+
mPanelHolder.setSelectedPanel(mTouchingPanel);
97+
}
98+
9599
public void panelExpansionChanged(PanelView panel, float frac) {
96100
boolean fullyClosed = true;
97101
PanelView fullyOpenedPanel = null;
98102
LOG("panelExpansionChanged: start state=%d panel=%s", mState, panel.getName());
99103
for (PanelView pv : mPanels) {
100104
// adjust any other panels that may be partially visible
101105
if (pv.getExpandedHeight() > 0f) {
106+
if (mState == STATE_CLOSED) {
107+
go(STATE_OPENING);
108+
onPanelPeeked();
109+
}
102110
fullyClosed = false;
103111
final float thisFrac = pv.getExpandedFraction();
104112
LOG("panelExpansionChanged: -> %s: f=%.1f", pv.getName(), thisFrac);
@@ -112,7 +120,7 @@ public void panelExpansionChanged(PanelView panel, float frac) {
112120
if (fullyOpenedPanel != null && !mTracking) {
113121
go(STATE_OPEN);
114122
onPanelFullyOpened(fullyOpenedPanel);
115-
} else if (fullyClosed && !mTracking) {
123+
} else if (fullyClosed && !mTracking && mState != STATE_CLOSED) {
116124
go(STATE_CLOSED);
117125
onAllPanelsCollapsed();
118126
}
@@ -122,13 +130,21 @@ public void panelExpansionChanged(PanelView panel, float frac) {
122130
}
123131

124132
public void collapseAllPanels(boolean animate) {
133+
boolean waiting = false;
125134
for (PanelView pv : mPanels) {
126-
if (animate && pv == mTouchingPanel) {
127-
mTouchingPanel.collapse();
135+
if (animate && !pv.isFullyCollapsed()) {
136+
pv.collapse();
137+
waiting = true;
128138
} else {
129139
pv.setExpandedFraction(0); // just in case
130140
}
131141
}
142+
if (!waiting) {
143+
// it's possible that nothing animated, so we replicate the termination
144+
// conditions of panelExpansionChanged here
145+
go(STATE_CLOSED);
146+
onAllPanelsCollapsed();
147+
}
132148
}
133149

134150
public void onPanelPeeked() {

packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import android.view.MotionEvent;
1010
import android.view.VelocityTracker;
1111
import android.view.View;
12+
import android.view.ViewGroup;
1213
import android.widget.FrameLayout;
1314

1415
import com.android.systemui.R;
@@ -18,7 +19,7 @@
1819
import com.android.systemui.statusbar.policy.NetworkController;
1920

2021
public class PanelView extends FrameLayout {
21-
public static final boolean DEBUG = false;
22+
public static final boolean DEBUG = PanelBar.DEBUG;
2223
public static final String TAG = PanelView.class.getSimpleName();
2324
public final void LOG(String fmt, Object... args) {
2425
if (!DEBUG) return;
@@ -298,10 +299,16 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
298299

299300
LOG("onMeasure(%d, %d) -> (%d, %d)",
300301
widthMeasureSpec, heightMeasureSpec, getMeasuredWidth(), getMeasuredHeight());
301-
mFullHeight = getMeasuredHeight();
302-
// if one of our children is getting smaller, we should track that
303-
if (!mTracking && !mRubberbanding && !mTimeAnimator.isStarted() && mExpandedHeight > 0 && mExpandedHeight != mFullHeight) {
304-
mExpandedHeight = mFullHeight;
302+
303+
// Did one of our children change size?
304+
int newHeight = getMeasuredHeight();
305+
if (newHeight != mFullHeight) {
306+
mFullHeight = newHeight;
307+
// If the user isn't actively poking us, let's rubberband to the content
308+
if (!mTracking && !mRubberbanding && !mTimeAnimator.isStarted()
309+
&& mExpandedHeight > 0 && mExpandedHeight != mFullHeight) {
310+
mExpandedHeight = mFullHeight;
311+
}
305312
}
306313
heightMeasureSpec = MeasureSpec.makeMeasureSpec(
307314
(int) mExpandedHeight, MeasureSpec.AT_MOST); // MeasureSpec.getMode(heightMeasureSpec));
@@ -310,6 +317,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
310317

311318

312319
public void setExpandedHeight(float height) {
320+
mTracking = mRubberbanding = false;
313321
post(mStopAnimator);
314322
setExpandedHeightInternal(height);
315323
}
@@ -326,21 +334,26 @@ public void setExpandedHeightInternal(float h) {
326334
// Hmm, full height hasn't been computed yet
327335
}
328336

329-
LOG("setExpansion: height=%.1f fh=%.1f tracking=%s rubber=%s", h, fh, mTracking?"T":"f", mRubberbanding?"T":"f");
330-
331337
if (h < 0) h = 0;
332338
if (!(STRETCH_PAST_CONTENTS && (mTracking || mRubberbanding)) && h > fh) h = fh;
333339
mExpandedHeight = h;
334340

341+
LOG("setExpansion: height=%.1f fh=%.1f tracking=%s rubber=%s", h, fh, mTracking?"T":"f", mRubberbanding?"T":"f");
342+
335343
requestLayout();
336344
// FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams();
337345
// lp.height = (int) mExpandedHeight;
338346
// setLayoutParams(lp);
339347

340-
mExpandedFraction = Math.min(1f, h / fh);
348+
mExpandedFraction = Math.min(1f, (fh == 0) ? 0 : h / fh);
341349
}
342350

343351
private float getFullHeight() {
352+
if (mFullHeight <= 0) {
353+
LOG("Forcing measure() since fullHeight=" + mFullHeight);
354+
measure(MeasureSpec.makeMeasureSpec(LayoutParams.WRAP_CONTENT, MeasureSpec.EXACTLY),
355+
MeasureSpec.makeMeasureSpec(LayoutParams.WRAP_CONTENT, MeasureSpec.EXACTLY));
356+
}
344357
return mFullHeight;
345358
}
346359

@@ -385,8 +398,12 @@ public void collapse() {
385398
}
386399

387400
public void expand() {
388-
if (!isFullyExpanded()) {
401+
if (isFullyCollapsed()) {
402+
mBar.startOpeningPanel(this);
403+
LOG("expand: calling fling(%s, true)", mSelfExpandVelocityPx);
389404
fling (mSelfExpandVelocityPx, /*always=*/ true);
405+
} else if (DEBUG) {
406+
LOG("skipping expansion: is expanded");
390407
}
391408
}
392409
}

packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595

9696
public class PhoneStatusBar extends BaseStatusBar {
9797
static final String TAG = "PhoneStatusBar";
98-
public static final boolean DEBUG = false;
98+
public static final boolean DEBUG = BaseStatusBar.DEBUG;
9999
public static final boolean SPEW = DEBUG;
100100
public static final boolean DUMPTRUCK = true; // extra dumpsys info
101101

@@ -285,9 +285,6 @@ protected PhoneStatusBarView makeStatusBarView() {
285285

286286
mStatusBarWindow = (StatusBarWindowView) View.inflate(context,
287287
R.layout.super_status_bar, null);
288-
if (DEBUG) {
289-
mStatusBarWindow.setBackgroundColor(0x6000FF80);
290-
}
291288
mStatusBarWindow.mService = this;
292289
mStatusBarWindow.setOnTouchListener(new View.OnTouchListener() {
293290
@Override
@@ -1160,7 +1157,7 @@ public void animateCollapse() {
11601157

11611158
public void animateCollapse(int flags) {
11621159
if (SPEW) {
1163-
Slog.d(TAG, "animateCollapse(): "
1160+
Slog.d(TAG, "animateCollapse():"
11641161
+ " mExpandedVisible=" + mExpandedVisible
11651162
+ " mAnimating=" + mAnimating
11661163
+ " mAnimatingReveal=" + mAnimatingReveal
@@ -1203,7 +1200,7 @@ void makeExpandedInvisible() {
12031200
}
12041201

12051202
// Ensure the panel is fully collapsed (just in case; bug 6765842)
1206-
mStatusBarView.collapseAllPanels(/*animate=*/ false);
1203+
// @@@ mStatusBarView.collapseAllPanels(/*animate=*/ false);
12071204

12081205
mExpandedVisible = false;
12091206
mPile.setLayoutTransitionsEnabled(false);

packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import android.os.SystemClock;
2828
import android.util.AttributeSet;
2929
import android.util.Log;
30+
import android.util.Slog;
3031
import android.view.KeyEvent;
3132
import android.view.MotionEvent;
3233
import android.view.View;
@@ -41,6 +42,8 @@
4142

4243
public class PhoneStatusBarView extends PanelBar {
4344
private static final String TAG = "PhoneStatusBarView";
45+
private static final boolean DEBUG = PhoneStatusBar.DEBUG;
46+
4447
PhoneStatusBar mBar;
4548
int mScrimColor;
4649
float mMinFlingGutter;
@@ -152,6 +155,10 @@ public boolean onInterceptTouchEvent(MotionEvent event) {
152155
public void panelExpansionChanged(PanelView pv, float frac) {
153156
super.panelExpansionChanged(pv, frac);
154157

158+
if (DEBUG) {
159+
Slog.v(TAG, "panelExpansionChanged: f=" + frac);
160+
}
161+
155162
if (mFadingPanel == pv
156163
&& mScrimColor != 0 && ActivityManager.isHighEndGfx()) {
157164
// woo, special effects

packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package com.android.systemui.statusbar.phone;
1818

1919
import android.content.Context;
20+
import android.graphics.Canvas;
21+
import android.graphics.Paint;
2022
import android.util.AttributeSet;
2123
import android.util.Log;
2224
import android.view.KeyEvent;
@@ -28,12 +30,14 @@
2830

2931
import com.android.systemui.ExpandHelper;
3032
import com.android.systemui.R;
33+
import com.android.systemui.statusbar.BaseStatusBar;
3134
import com.android.systemui.statusbar.policy.NotificationRowLayout;
3235

3336

3437
public class StatusBarWindowView extends FrameLayout
3538
{
36-
private static final String TAG = "StatusBarWindowView";
39+
public static final String TAG = "StatusBarWindowView";
40+
public static final boolean DEBUG = BaseStatusBar.DEBUG;
3741

3842
private ExpandHelper mExpandHelper;
3943
private NotificationRowLayout latestItems;
@@ -44,6 +48,7 @@ public class StatusBarWindowView extends FrameLayout
4448
public StatusBarWindowView(Context context, AttributeSet attrs) {
4549
super(context, attrs);
4650
setMotionEventSplittingEnabled(false);
51+
setWillNotDraw(!DEBUG);
4752
}
4853

4954
@Override
@@ -101,5 +106,17 @@ public boolean onTouchEvent(MotionEvent ev) {
101106
}
102107
return handled;
103108
}
109+
110+
@Override
111+
public void onDraw(Canvas canvas) {
112+
super.onDraw(canvas);
113+
if (DEBUG) {
114+
Paint pt = new Paint();
115+
pt.setColor(0x80FFFF00);
116+
pt.setStrokeWidth(12.0f);
117+
pt.setStyle(Paint.Style.STROKE);
118+
canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), pt);
119+
}
120+
}
104121
}
105122

0 commit comments

Comments
 (0)