Skip to content

Commit ed930e5

Browse files
committed
Fix stuck status bars.
An odd little bit of logic (attempting to defend against the status bar getting stuck on orientation change) was ironically causing it to get stuck if the bar was closed twice in very rapid succession (which can happen if you manage to click the settings button as the panel is about to close). Other tweaks to help defend against this sort of problem in the future: - When the screen goes off, immediately collapse the notification panel (without animation) - When completing panel collapse, force the height of the expanded view to 0 (in case it ended up some other way by this point). - Reduce a weird little glitch when you start animateCollapse() in the middle of a reveal animation. (The panel would jump to full height.) Bug: 6765842 Change-Id: I233467c73e130f64401333319943289cbf3daa56
1 parent 15c15ea commit ed930e5

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

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

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ public class PhoneStatusBar extends BaseStatusBar {
203203

204204
// the tracker view
205205
int mTrackingPosition; // the position of the top of the tracking view.
206-
private boolean mPanelSlightlyVisible;
207206

208207
// ticker
209208
private Ticker mTicker;
@@ -1235,6 +1234,7 @@ public void animateCollapse(int flags, float velocityMultiplier) {
12351234
+ " mExpandedVisible=" + mExpandedVisible
12361235
+ " mExpanded=" + mExpanded
12371236
+ " mAnimating=" + mAnimating
1237+
+ " mAnimatingReveal=" + mAnimatingReveal
12381238
+ " mAnimY=" + mAnimY
12391239
+ " mAnimVel=" + mAnimVel
12401240
+ " flags=" + flags);
@@ -1255,7 +1255,7 @@ public void animateCollapse(int flags, float velocityMultiplier) {
12551255
}
12561256

12571257
int y;
1258-
if (mAnimating) {
1258+
if (mAnimating || mAnimatingReveal) {
12591259
y = (int)mAnimY;
12601260
} else {
12611261
y = getExpandedViewMaxHeight()-1;
@@ -1290,6 +1290,10 @@ void performCollapse() {
12901290
if (!mExpandedVisible) {
12911291
return;
12921292
}
1293+
1294+
// Ensure the panel is fully collapsed (just in case; bug 6765842)
1295+
updateExpandedViewPos(0);
1296+
12931297
mExpandedVisible = false;
12941298
mPile.setLayoutTransitionsEnabled(false);
12951299
if (mNavigationBarView != null)
@@ -2050,9 +2054,14 @@ protected int getExpandedViewMaxHeight() {
20502054
@Override
20512055
protected void updateExpandedViewPos(int expandedPosition) {
20522056
if (SPEW) {
2053-
Slog.d(TAG, "updateExpandedViewPos before expandedPosition=" + expandedPosition
2057+
Slog.d(TAG, "updateExpandedViewPos: expandedPosition=" + expandedPosition
20542058
//+ " mTrackingParams.y=" + ((mTrackingParams == null) ? "?" : mTrackingParams.y)
2059+
+ " mTracking=" + mTracking
20552060
+ " mTrackingPosition=" + mTrackingPosition
2061+
+ " mExpandedVisible=" + mExpandedVisible
2062+
+ " mAnimating=" + mAnimating
2063+
+ " mAnimatingReveal=" + mAnimatingReveal
2064+
+ " mClosing=" + mClosing
20562065
+ " gravity=" + mNotificationPanelGravity);
20572066
}
20582067
int panelh = 0;
@@ -2061,6 +2070,7 @@ protected void updateExpandedViewPos(int expandedPosition) {
20612070
// If the expanded view is not visible, make sure they're still off screen.
20622071
// Maybe the view was resized.
20632072
if (!mExpandedVisible) {
2073+
if (SPEW) Slog.d(TAG, "updateExpandedViewPos: view not visible, bailing");
20642074
updateExpandedInvisiblePosition();
20652075
return;
20662076
}
@@ -2082,13 +2092,21 @@ else if (expandedPosition == EXPANDED_LEAVE_ALONE) {
20822092
}
20832093

20842094
// catch orientation changes and other peculiar cases
2085-
if (panelh > disph || (panelh < disph && !mTracking && !mAnimating)) {
2095+
if (panelh > 0 &&
2096+
((panelh > disph) ||
2097+
(panelh < disph && !mTracking && !mAnimating))) {
2098+
if (SPEW) Slog.d(TAG, "updateExpandedViewPos: orientation change?");
20862099
panelh = disph;
20872100
} else if (panelh < 0) {
20882101
panelh = 0;
20892102
}
20902103

2091-
if (panelh == mTrackingPosition) return;
2104+
if (SPEW) Slog.d(TAG, "updateExpandedViewPos: adjusting size to panelh=" + panelh);
2105+
2106+
if (panelh == mTrackingPosition) {
2107+
if (SPEW) Slog.d(TAG, "updateExpandedViewPos: panelh == mTrackingPosition, bailing");
2108+
return;
2109+
}
20922110

20932111
mTrackingPosition = panelh;
20942112

@@ -2248,8 +2266,7 @@ public void onClick(View v) {
22482266
private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
22492267
public void onReceive(Context context, Intent intent) {
22502268
String action = intent.getAction();
2251-
if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)
2252-
|| Intent.ACTION_SCREEN_OFF.equals(action)) {
2269+
if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {
22532270
int flags = CommandQueue.FLAG_EXCLUDE_NONE;
22542271
if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {
22552272
String reason = intent.getStringExtra("reason");
@@ -2259,6 +2276,10 @@ public void onReceive(Context context, Intent intent) {
22592276
}
22602277
animateCollapse(flags);
22612278
}
2279+
else if (Intent.ACTION_SCREEN_OFF.equals(action)) {
2280+
// no waiting!
2281+
performCollapse();
2282+
}
22622283
else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {
22632284
updateResources();
22642285
repositionNavigationBar();

0 commit comments

Comments
 (0)