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

Commit b1f6ddc3 authored by Mike Digman's avatar Mike Digman Committed by Android (Google) Code Review
Browse files

Merge "Send valid and invalid rotation proposal changes to SysUI"

parents e65bd19f e0777317
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -115,7 +115,7 @@ oneway interface IStatusBar
    /**
     * Notifies the status bar that a new rotation suggestion is available.
     */
    void onProposedRotationChanged(int rotation);
    void onProposedRotationChanged(int rotation, boolean isValid);

    /**
     * Set whether the top app currently hides the statusbar.
+4 −4
Original line number Diff line number Diff line
@@ -144,7 +144,7 @@ public class CommandQueue extends IStatusBar.Stub {
        default void handleShowGlobalActionsMenu() { }
        default void handleShowShutdownUi(boolean isReboot, String reason) { }

        default void onRotationProposal(int rotation) { }
        default void onRotationProposal(int rotation, boolean isValid) { }
    }

    @VisibleForTesting
@@ -462,10 +462,10 @@ public class CommandQueue extends IStatusBar.Stub {
    }

    @Override
    public void onProposedRotationChanged(int rotation) {
    public void onProposedRotationChanged(int rotation, boolean isValid) {
        synchronized (mLock) {
            mHandler.removeMessages(MSG_ROTATION_PROPOSAL);
            mHandler.obtainMessage(MSG_ROTATION_PROPOSAL, rotation, 0,
            mHandler.obtainMessage(MSG_ROTATION_PROPOSAL, rotation, isValid ? 1 : 0,
                    null).sendToTarget();
        }
    }
@@ -668,7 +668,7 @@ public class CommandQueue extends IStatusBar.Stub {
                    break;
                case MSG_ROTATION_PROPOSAL:
                    for (int i = 0; i < mCallbacks.size(); i++) {
                        mCallbacks.get(i).onRotationProposal(msg.arg1);
                        mCallbacks.get(i).onRotationProposal(msg.arg1, msg.arg2 != 0);
                    }
                    break;
            }
+10 −3
Original line number Diff line number Diff line
@@ -335,9 +335,16 @@ public class NavigationBarFragment extends Fragment implements Callbacks {
    }

    @Override
    public void onRotationProposal(final int rotation) {
        // This method will only be called if rotation is valid but will include proposals for the
        // current system rotation
    public void onRotationProposal(final int rotation, boolean isValid) {
        // This method will be called on rotation suggestion changes even if the proposed rotation
        // is not valid for the top app. Use invalid rotation choices as a signal to remove the
        // rotate button if shown.

        if (!isValid) {
            setRotateSuggestionButtonState(false);
            return;
        }

        Handler h = getView().getHandler();
        if (rotation == mWindowManager.getDefaultDisplay().getRotation()) {
            // Use this as a signal to remove any current suggestions
+18 −15
Original line number Diff line number Diff line
@@ -66,7 +66,6 @@ import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW;
import static android.view.WindowManager.LayoutParams.LAST_SYSTEM_WINDOW;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER;
import static android.view.WindowManager.LayoutParams.MATCH_PARENT;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_ACQUIRES_SLEEP_TOKEN;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_DRAW_STATUS_BAR_BACKGROUND;
@@ -163,13 +162,10 @@ import android.app.StatusBarManager;
import android.app.UiModeManager;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.ComponentCallbacks;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
@@ -202,7 +198,6 @@ import android.os.IBinder;
import android.os.IDeviceIdleController;
import android.os.Looper;
import android.os.Message;
import android.os.Messenger;
import android.os.PowerManager;
import android.os.PowerManagerInternal;
import android.os.Process;
@@ -1030,8 +1025,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            public void run() {
                // send interaction hint to improve redraw performance
                mPowerManagerInternal.powerHint(PowerHint.INTERACTION, 0);
                if (showRotationChoice(mCurrentAppOrientation, mRotation)) {
                    sendProposedRotationChangeToStatusBarInternal(mRotation);
                if (isRotationChoiceEnabled()) {
                    final boolean isValid = isValidRotationChoice(mCurrentAppOrientation,
                            mRotation);
                    sendProposedRotationChangeToStatusBarInternal(mRotation, isValid);
                } else {
                    updateRotation(false);
                }
@@ -6193,10 +6190,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    /**
     * Notify the StatusBar that system rotation suggestion has changed.
     */
    private void sendProposedRotationChangeToStatusBarInternal(int rotation) {
    private void sendProposedRotationChangeToStatusBarInternal(int rotation, boolean isValid) {
        StatusBarManagerInternal statusBar = getStatusBarManagerInternal();
        if (statusBar != null) {
            statusBar.onProposedRotationChanged(rotation);
            statusBar.onProposedRotationChanged(rotation, isValid);
        }
    }

@@ -7142,15 +7139,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        mOrientationListener.setCurrentRotation(rotation);
    }

    public boolean showRotationChoice(int orientation, final int preferredRotation) {
    public boolean isRotationChoiceEnabled() {
        // Rotation choice is only shown when the user is in locked mode.
        if (mUserRotationMode != WindowManagerPolicy.USER_ROTATION_LOCKED) return false;

        // We should only show a rotation choice if:
        // 1. The rotation isn't forced by the lid, dock, demo, hdmi, vr, etc mode
        // 2. The user choice won't be ignored due to screen orientation settings
        // We should only enable rotation choice if the rotation isn't forced by the lid, dock,
        // demo, hdmi, vr, etc mode

        // Determine if the rotation currently forced
        // Determine if the rotation is currently forced
        if (mForceDefaultOrientation) {
            return false; // Rotation is forced to default orientation

@@ -7183,7 +7179,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            return false;
        }

        // Determine if the orientation will ignore user choice
        // Rotation isn't forced, enable choice
        return true;
    }

    public boolean isValidRotationChoice(int orientation, final int preferredRotation) {
        // Determine if the given app orientation can be chosen and, if so, if it is compatible
        // with the provided rotation choice

        switch (orientation) {
            case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT:
            case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE:
+1 −1
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ public interface StatusBarManagerInternal {
     *
     * @param rotation rotation suggestion
     */
    void onProposedRotationChanged(int rotation);
    void onProposedRotationChanged(int rotation, boolean isValid);

    public interface GlobalActionsListener {
        /**
Loading