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

Commit f94b1a39 authored by Evan McClain's avatar Evan McClain
Browse files

Set landscape orientation prop



Set sys.orientation.landscape to 1 when in landscape and to 0 when
in portrait orientation for devices that have rotating capacitive
buttons.

Change-Id: I5cf86834d3e09ead515e9de31391904d5aff3107
Signed-off-by: default avatarEvan McClain <aeroevan@gmail.com>
parent 34cb111b
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -798,4 +798,8 @@

    <!-- Name of that key handler class -->
    <string name="config_deviceKeyHandlerClass"></string>

    <!-- Whether to set a system prop (sys.orientation.landscape)
         when rotating for devices that have rotating buttons -->
    <bool name="config_setLandscapeProp">false</bool>
</resources>
+11 −0
Original line number Diff line number Diff line
@@ -303,6 +303,8 @@ public class WindowManagerService extends IWindowManager.Stub

    final boolean mLimitedAlphaCompositing;

    final boolean mSetLandscapeProperty;

    final WindowManagerPolicy mPolicy = PolicyManager.makeNewWindowManager();

    final IActivityManager mActivityManager;
@@ -755,6 +757,8 @@ public class WindowManagerService extends IWindowManager.Stub
        mAllowBootMessages = showBootMsgs;
        mLimitedAlphaCompositing = context.getResources().getBoolean(
                com.android.internal.R.bool.config_sf_limitedAlpha);
        mSetLandscapeProperty = context.getResources().getBoolean(
                com.android.internal.R.bool.config_setLandscapeProp);

        mPowerManager = pm;
        mPowerManager.setPolicy(mPolicy);
@@ -5050,6 +5054,11 @@ public class WindowManagerService extends IWindowManager.Stub
        SystemProperties.set(StrictMode.VISUAL_PROPERTY, value);
    }

    public void setLandscapeProperty(String value) {
        if (!mSetLandscapeProperty) return;
        SystemProperties.set("sys.orientation.landscape", value);
    }

    /**
     * Takes a snapshot of the screen.  In landscape mode this grabs the whole screen.
     * In portrait mode, it grabs the upper region of the screen based on the vertical dimension
@@ -6063,8 +6072,10 @@ public class WindowManagerService extends IWindowManager.Stub
        int orientation = Configuration.ORIENTATION_SQUARE;
        if (dw < dh) {
            orientation = Configuration.ORIENTATION_PORTRAIT;
            setLandscapeProperty("0");
        } else if (dw > dh) {
            orientation = Configuration.ORIENTATION_LANDSCAPE;
            setLandscapeProperty("1");
        }
        config.orientation = orientation;