Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a5b2457d authored by Android Build Merger (Role)'s avatar Android Build Merger (Role) Committed by Android (Google) Code Review
Browse files

Merge "NavBar: Use rotation watcher am: a98b32ce am: c5d9eb8e" into nyc-mr1-dev-plus-aosp

parents b373c6e3 d966384d
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -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();
+23 −20
Original line number Diff line number Diff line
@@ -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);