Skip to content

Commit df89e65

Browse files
author
Dianne Hackborn
committed
Fix how we hide and show the nav bar.
The PhoneWindowManager is now responsible for hiding and showing the nav bar. For hiding, it just moves it off the screen (easy way to get a nice slide animation on and off). At the same time, we use a new WM facility to put up a fake input window to capture all touch events. When a touch event is received, we force the system UI to clear the navigation hiding bit so it will be shown again. This removes a bunch of code from the system UI for hiding and showing the nav bar. Also removes the code calling from userActivity() to the system UI, which was bad. (Also no longer using userActivity() fixes bugs around re-showing the nav bar due to key presses and other wrong things.) Change-Id: I8c3174873b5bcaa36a92322a51e8f7993e88e551
1 parent 25d888b commit df89e65

File tree

14 files changed

+413
-150
lines changed

14 files changed

+413
-150
lines changed

core/java/android/view/WindowManager.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,13 @@ public static class LayoutParams extends ViewGroup.LayoutParams
415415
*/
416416
public static final int TYPE_BOOT_PROGRESS = FIRST_SYSTEM_WINDOW+21;
417417

418+
/**
419+
* Window type: Fake window to consume touch events when the navigation
420+
* bar is hidden.
421+
* @hide
422+
*/
423+
public static final int TYPE_HIDDEN_NAV_CONSUMER = FIRST_SYSTEM_WINDOW+22;
424+
418425
/**
419426
* End of types of system windows.
420427
*/

core/java/android/view/WindowManagerPolicy.java

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import android.graphics.RectF;
2424
import android.os.IBinder;
2525
import android.os.LocalPowerManager;
26+
import android.os.Looper;
2627
import android.view.animation.Animation;
2728

2829
import java.io.FileDescriptor;
@@ -314,6 +315,36 @@ public void computeFrameLw(Rect parentFrame, Rect displayFrame,
314315
public boolean showLw(boolean doAnimation);
315316
}
316317

318+
/**
319+
* Representation of a "fake window" that the policy has added to the
320+
* window manager to consume events.
321+
*/
322+
public interface FakeWindow {
323+
/**
324+
* Remove the fake window from the window manager.
325+
*/
326+
void dismiss();
327+
}
328+
329+
/**
330+
* Interface for calling back in to the window manager that is private
331+
* between it and the policy.
332+
*/
333+
public interface WindowManagerFuncs {
334+
/**
335+
* Ask the window manager to re-evaluate the system UI flags.
336+
*/
337+
public void reevaluateStatusBarVisibility();
338+
339+
/**
340+
* Add a fake window to the window manager. This window sits
341+
* at the top of the other windows and consumes events.
342+
*/
343+
public FakeWindow addFakeWindow(Looper looper, InputHandler inputHandler,
344+
String name, int windowType, int layoutParamsFlags, boolean canReceiveKeys,
345+
boolean hasFocus, boolean touchFullscreen);
346+
}
347+
317348
/**
318349
* Bit mask that is set for all enter transition.
319350
*/
@@ -395,6 +426,7 @@ public void computeFrameLw(Rect parentFrame, Rect displayFrame,
395426
* @param powerManager
396427
*/
397428
public void init(Context context, IWindowManager windowManager,
429+
WindowManagerFuncs windowManagerFuncs,
398430
LocalPowerManager powerManager);
399431

400432
/**
@@ -762,7 +794,7 @@ public void animatingWindowLw(WindowState win,
762794
/**
763795
* A new window has been focused.
764796
*/
765-
public void focusChanged(WindowState lastFocus, WindowState newFocus);
797+
public int focusChangedLw(WindowState lastFocus, WindowState newFocus);
766798

767799
/**
768800
* Called after the screen turns off.
@@ -967,6 +999,14 @@ interface OnKeyguardExitResult {
967999
*/
9681000
public void setUserRotationMode(int mode, int rotation);
9691001

1002+
/**
1003+
* Called when a new system UI visibility is being reported, allowing
1004+
* the policy to adjust what is actually reported.
1005+
* @param visibility The raw visiblity reported by the status bar.
1006+
* @return The new desired visibility.
1007+
*/
1008+
public int adjustSystemUiVisibilityLw(int visibility);
1009+
9701010
/**
9711011
* Print the WindowManagerPolicy's state into the given stream.
9721012
*

core/java/com/android/internal/statusbar/IStatusBar.aidl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ oneway interface IStatusBar
3434
void topAppWindowChanged(boolean menuVisible);
3535
void setImeWindowStatus(in IBinder token, int vis, int backDisposition);
3636
void setHardKeyboardStatus(boolean available, boolean enabled);
37-
void userActivity();
3837
void toggleRecentApps();
3938
}
4039

core/java/com/android/internal/statusbar/IStatusBarService.aidl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,5 @@ interface IStatusBarService
4646
void onNotificationClear(String pkg, String tag, int id);
4747
void setSystemUiVisibility(int vis);
4848
void setHardKeyboardEnabled(boolean enabled);
49-
void userActivity();
5049
void toggleRecentApps();
5150
}

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

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ public class CommandQueue extends IStatusBar.Stub {
6060
private static final int MSG_SHOW_IME_BUTTON = 9 << MSG_SHIFT;
6161
private static final int MSG_SET_HARD_KEYBOARD_STATUS = 10 << MSG_SHIFT;
6262

63-
private static final int MSG_USER_ACTIVITY = 11 << MSG_SHIFT;
64-
private static final int MSG_TOGGLE_RECENT_APPS = 12 << MSG_SHIFT;
63+
private static final int MSG_TOGGLE_RECENT_APPS = 11 << MSG_SHIFT;
6564

6665
private StatusBarIconList mList;
6766
private Callbacks mCallbacks;
@@ -90,7 +89,6 @@ public void updateIcon(String slot, int index, int viewIndex,
9089
public void topAppWindowChanged(boolean visible);
9190
public void setImeWindowStatus(IBinder token, int vis, int backDisposition);
9291
public void setHardKeyboardStatus(boolean available, boolean enabled);
93-
public void userActivity();
9492
public void toggleRecentApps();
9593
}
9694

@@ -191,13 +189,6 @@ public void setHardKeyboardStatus(boolean available, boolean enabled) {
191189
}
192190
}
193191

194-
public void userActivity() {
195-
synchronized (mList) {
196-
mHandler.removeMessages(MSG_USER_ACTIVITY);
197-
mHandler.obtainMessage(MSG_USER_ACTIVITY, 0, 0, null).sendToTarget();
198-
}
199-
}
200-
201192
public void toggleRecentApps() {
202193
synchronized (mList) {
203194
mHandler.removeMessages(MSG_TOGGLE_RECENT_APPS);
@@ -271,9 +262,6 @@ public void handleMessage(Message msg) {
271262
case MSG_SET_HARD_KEYBOARD_STATUS:
272263
mCallbacks.setHardKeyboardStatus(msg.arg1 != 0, msg.arg2 != 0);
273264
break;
274-
case MSG_USER_ACTIVITY:
275-
mCallbacks.userActivity();
276-
break;
277265
case MSG_TOGGLE_RECENT_APPS:
278266
mCallbacks.toggleRecentApps();
279267
break;

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

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,20 @@
1717
package com.android.systemui.statusbar.phone;
1818

1919
import android.animation.Animator;
20-
import android.animation.AnimatorSet;
2120
import android.animation.AnimatorListenerAdapter;
22-
import android.animation.ObjectAnimator;
2321
import android.content.Context;
2422
import android.content.res.Resources;
2523
import android.os.ServiceManager;
2624
import android.util.AttributeSet;
2725
import android.util.Slog;
2826
import android.view.animation.AccelerateInterpolator;
2927
import android.view.Display;
30-
import android.view.KeyEvent;
3128
import android.view.MotionEvent;
3229
import android.view.View;
3330
import android.view.ViewGroup;
3431
import android.view.Surface;
3532
import android.view.WindowManager;
3633
import android.widget.LinearLayout;
37-
import android.content.res.Configuration;
3834

3935
import com.android.internal.statusbar.IStatusBarService;
4036

@@ -54,7 +50,6 @@ public class NavigationBarView extends LinearLayout {
5450
final Display mDisplay;
5551
View mCurrentView = null;
5652
View[] mRotatedViews = new View[4];
57-
AnimatorSet mLastAnimator = null;
5853

5954
int mBarSize;
6055
boolean mVertical;
@@ -204,43 +199,6 @@ public void setHidden(final boolean hide) {
204199

205200
// bring up the lights no matter what
206201
setLowProfile(false);
207-
208-
if (!ANIMATE_HIDE_TRANSITION) {
209-
setVisibility(hide ? View.GONE : View.VISIBLE);
210-
return;
211-
}
212-
213-
float oldAlpha = mCurrentView.getAlpha();
214-
if (DEBUG) {
215-
Slog.d(TAG, "animating alpha: " + oldAlpha + " -> "
216-
+ (!hide ? 1f : 0f));
217-
}
218-
219-
if (mLastAnimator != null && mLastAnimator.isRunning()) mLastAnimator.cancel();
220-
221-
if (!hide) {
222-
setVisibility(View.VISIBLE);
223-
}
224-
225-
// play us off, animatorset
226-
mLastAnimator = new AnimatorSet();
227-
mLastAnimator.playTogether(
228-
ObjectAnimator.ofFloat(mCurrentView, "alpha", hide ? 0f : 1f),
229-
ObjectAnimator.ofFloat(mCurrentView,
230-
mVertical ? "translationX" : "translationY",
231-
hide ? mBarSize : 0)
232-
);
233-
mLastAnimator.setDuration(!hide ? 250 : 1000);
234-
mLastAnimator.addListener(new AnimatorListenerAdapter() {
235-
@Override
236-
public void onAnimationEnd(Animator _a) {
237-
mLastAnimator = null;
238-
if (hide) {
239-
setVisibility(View.GONE);
240-
}
241-
}
242-
});
243-
mLastAnimator.start();
244202
}
245203

246204
public void onFinishInflate() {

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

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,8 @@
3131
import android.content.res.Resources;
3232
import android.content.res.Configuration;
3333
import android.graphics.PixelFormat;
34-
import android.graphics.Point;
3534
import android.graphics.Rect;
3635
import android.graphics.drawable.Drawable;
37-
import android.graphics.drawable.LayerDrawable;
38-
import android.net.Uri;
39-
import android.os.Bundle;
4036
import android.os.IBinder;
4137
import android.os.RemoteException;
4238
import android.os.Handler;
@@ -471,6 +467,7 @@ private WindowManager.LayoutParams getNavigationBarLayoutParams() {
471467
0
472468
| WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING
473469
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
470+
| WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
474471
| WindowManager.LayoutParams.FLAG_SPLIT_TOUCH
475472
| WindowManager.LayoutParams.FLAG_SLIPPERY,
476473
PixelFormat.OPAQUE);
@@ -2028,19 +2025,6 @@ void updateExpandedSize() {
20282025
}
20292026
}
20302027

2031-
// The user is not allowed to get stuck without navigation UI. Upon the slightest user
2032-
// interaction we bring the navigation back.
2033-
public void userActivity() {
2034-
if (0 != (mSystemUiVisibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION)) {
2035-
try {
2036-
mBarService.setSystemUiVisibility(
2037-
mSystemUiVisibility & ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
2038-
} catch (RemoteException ex) {
2039-
// weep softly
2040-
}
2041-
}
2042-
}
2043-
20442028
public void toggleRecentApps() {
20452029
int msg = (mRecentsPanel.getVisibility() == View.GONE)
20462030
? MSG_OPEN_RECENTS_PANEL : MSG_CLOSE_RECENTS_PANEL;

packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,9 +1822,6 @@ public void clearAll() {
18221822
visibilityChanged(false);
18231823
}
18241824

1825-
public void userActivity() {
1826-
}
1827-
18281825
public void toggleRecentApps() {
18291826
int msg = (mRecentsPanel.getVisibility() == View.GONE)
18301827
? MSG_OPEN_RECENTS_PANEL : MSG_CLOSE_RECENTS_PANEL;

0 commit comments

Comments
 (0)