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

Commit 0e797d00 authored by Michael Bestas's avatar Michael Bestas
Browse files

fixup! Configurable 0, 90, 180 and 270 degree rotation

Remove configstore usage, switch to sysprop

Test: atest CtsStrictJavaPackagesTestCases
Change-Id: I66015d2195b530efee753171db43b7571d0ad975
parent 3445bdbb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -203,7 +203,6 @@ java_library {
        "android.hardware.cas-V1.0-java",
        "android.hardware.cas-V1.1-java",
        "android.hardware.cas-V1.2-java",
        "android.hardware.configstore-V1.1-java",
        "android.hardware.contexthub-V1.0-java",
        "android.hardware.contexthub-V1.1-java",
        "android.hardware.contexthub-V1.2-java",
@@ -248,6 +247,7 @@ java_library {
        "com.android.sysprop.init",
        "com.android.sysprop.localization",
        "PlatformProperties",
        "SurfaceFlingerProperties",
    ],
    sdk_version: "core_platform",
    installable: false,
+14 −27
Original line number Diff line number Diff line
@@ -20,16 +20,14 @@ import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.database.ContentObserver;
import android.hardware.configstore.V1_1.DisplayOrientation;
import android.hardware.configstore.V1_1.ISurfaceFlingerConfigs;
import android.hardware.configstore.V1_1.OptionalDisplayOrientation;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.provider.Settings;
import android.sysprop.SurfaceFlingerProperties;
import android.sysprop.SurfaceFlingerProperties.primary_display_orientation_values;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.IWindowManager;
@@ -38,7 +36,7 @@ import android.view.WindowManagerGlobal;

import com.android.internal.R;

import java.util.NoSuchElementException;
import java.util.Optional;

/**
 * Provides helper functions for configuring the display rotation policy.
@@ -234,33 +232,22 @@ public final class RotationPolicy {
    }

    private static int getNaturalRotationConfig() {
        String primaryDisplayOrientation =
                SystemProperties.get("ro.surface_flinger.primary_display_orientation");
        if (primaryDisplayOrientation == "ORIENTATION_90") {
            return Surface.ROTATION_90;
        }
        if (primaryDisplayOrientation == "ORIENTATION_180") {
            return Surface.ROTATION_180;
        }
        if (primaryDisplayOrientation == "ORIENTATION_270") {
            return Surface.ROTATION_270;
        primary_display_orientation_values orientation =
                primary_display_orientation_values.ORIENTATION_0;
        Optional<primary_display_orientation_values> primaryDisplayOrientation =
                SurfaceFlingerProperties.primary_display_orientation();
        if (primaryDisplayOrientation.isPresent()) {
            orientation = primaryDisplayOrientation.get();
        }

        OptionalDisplayOrientation orientation;

        try {
            orientation =
                    ISurfaceFlingerConfigs.getService().primaryDisplayOrientation();
            switch (orientation.value) {
                case DisplayOrientation.ORIENTATION_90:
        if (orientation == primary_display_orientation_values.ORIENTATION_90) {
            return Surface.ROTATION_90;
                case DisplayOrientation.ORIENTATION_180:
        }
        if (orientation == primary_display_orientation_values.ORIENTATION_180) {
            return Surface.ROTATION_180;
                case DisplayOrientation.ORIENTATION_270:
                    return Surface.ROTATION_270;
        }
        } catch (RemoteException | NoSuchElementException e) {
            // do nothing
        if (orientation == primary_display_orientation_values.ORIENTATION_270) {
            return Surface.ROTATION_270;
        }

        return Surface.ROTATION_0;
+0 −1
Original line number Diff line number Diff line
@@ -173,7 +173,6 @@ java_library_static {
        "netd-client",
        "motorola.hardware.health-V1.0-java",
        "overlayable_policy_aidl-java",
        "SurfaceFlingerProperties",
        "com.android.sysprop.watchdog",
    ],
    javac_shard_size: 50,