NavBar: Use rotation watcher am: a98b32cea2

am: c5d9eb8ebd

Change-Id: I599c828ade63e93b0d71a3a1b5e96670c7a40ea1
This commit is contained in:
Adrian Roos
2016-08-17 18:18:39 +00:00
committed by android-build-merger
2 changed files with 27 additions and 24 deletions

View File

@@ -54,7 +54,7 @@ import java.io.PrintWriter;
public class NavigationBarView extends LinearLayout {
final static boolean DEBUG = false;
final static String TAG = "PhoneStatusBar/NavigationBarView";
final static String TAG = "StatusBar/NavBarView";
// slippery nav bar when everything is disabled, e.g. during setup
final static boolean SLIPPERY_WHEN_DISABLED = true;
@@ -527,8 +527,8 @@ public class NavigationBarView extends LinearLayout {
updateCurrentView();
}
public boolean needsReorient() {
return mCurrentRotation != mDisplay.getRotation();
public boolean needsReorient(int rotation) {
return mCurrentRotation != rotation;
}
private void updateCurrentView() {
@@ -567,7 +567,7 @@ public class NavigationBarView extends LinearLayout {
setMenuVisibility(mShowMenu, true /* force */);
if (DEBUG) {
Log.d(TAG, "reorient(): rot=" + mDisplay.getRotation());
Log.d(TAG, "reorient(): rot=" + mCurrentRotation);
}
updateTaskSwitchHelper();

View File

@@ -65,7 +65,6 @@ import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.hardware.display.DisplayManager;
import android.inputmethodservice.InputMethodService;
import android.media.AudioAttributes;
import android.media.MediaMetadata;
@@ -100,6 +99,7 @@ import android.util.DisplayMetrics;
import android.util.EventLog;
import android.util.Log;
import android.view.Display;
import android.view.IRotationWatcher;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@@ -207,7 +207,7 @@ import java.util.Map;
public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
DragDownHelper.DragDownCallback, ActivityStarter, OnUnlockMethodChangedListener,
HeadsUpManager.OnHeadsUpChangedListener, DisplayManager.DisplayListener {
HeadsUpManager.OnHeadsUpChangedListener {
static final String TAG = "PhoneStatusBar";
public static final boolean DEBUG = BaseStatusBar.DEBUG;
public static final boolean SPEW = false;
@@ -693,8 +693,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
mUnlockMethodCache.addListener(this);
startKeyguard();
mContext.getSystemService(DisplayManager.class).registerDisplayListener(this, null);
mDozeServiceHost = new DozeServiceHost();
KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mDozeServiceHost);
putComponent(DozeHost.class, mDozeServiceHost);
@@ -1411,6 +1409,27 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
if (DEBUG) Log.v(TAG, "addNavigationBar: about to add " + mNavigationBarView);
if (mNavigationBarView == null) return;
try {
WindowManagerGlobal.getWindowManagerService()
.watchRotation(new IRotationWatcher.Stub() {
@Override
public void onRotationChanged(int rotation) throws RemoteException {
// We need this to be scheduled as early as possible to beat the redrawing of
// window in response to the orientation change.
Message msg = Message.obtain(mHandler, () -> {
if (mNavigationBarView != null
&& mNavigationBarView.needsReorient(rotation)) {
repositionNavigationBar();
}
});
msg.setAsynchronous(true);
mHandler.sendMessageAtFrontOfQueue(msg);
}
});
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
prepareNavigationBarView();
mWindowManager.addView(mNavigationBarView, getNavigationBarLayoutParams());
@@ -3586,22 +3605,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
mNetworkController.onConfigurationChanged();
}
@Override
public void onDisplayAdded(int displayId) {
}
@Override
public void onDisplayRemoved(int displayId) {
}
@Override
public void onDisplayChanged(int displayId) {
if (displayId == Display.DEFAULT_DISPLAY
&& mNavigationBarView != null && mNavigationBarView.needsReorient()) {
repositionNavigationBar();
}
}
@Override
public void userSwitched(int newUserId) {
super.userSwitched(newUserId);