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

Commit c7749aeb authored by Shivangi Dubey's avatar Shivangi Dubey Committed by Android (Google) Code Review
Browse files

Merge "Revert "Disable B&R for foldables of ACCELEROMETER_ROTATION"" into main

parents d271853a 186ce9e7
Loading
Loading
Loading
Loading
+1 −15
Original line number Original line Diff line number Diff line
@@ -21,14 +21,8 @@ import android.graphics.Rect;
import android.util.DisplayMetrics;
import android.util.DisplayMetrics;
import android.view.WindowManager;
import android.view.WindowManager;


import com.android.internal.R;
import com.android.window.flags.Flags;

/** Settings that should not be restored when target device is a large screen
/** Settings that should not be restored when target device is a large screen
 *  i.e. tablets and foldables in unfolded state
 *  i.e. tablets and foldables in unfolded state
 *
 *  <p>If {@link Flags#FLAG_ENABLE_DEVICE_STATE_AUTO_ROTATE_SETTING_REFACTOR} is enabled, specified
 *  settings will not be restored when target device is a large screen i.e. tablets and foldables
 */
 */
public class LargeScreenSettings {
public class LargeScreenSettings {
    private static final float LARGE_SCREEN_MIN_DPS = 600;
    private static final float LARGE_SCREEN_MIN_DPS = 600;
@@ -49,15 +43,7 @@ public class LargeScreenSettings {
        final Rect bounds = windowManager.getCurrentWindowMetrics().getBounds();
        final Rect bounds = windowManager.getCurrentWindowMetrics().getBounds();
        float smallestWidth = dpiFromPx(Math.min(bounds.width(), bounds.height()),
        float smallestWidth = dpiFromPx(Math.min(bounds.width(), bounds.height()),
                context.getResources().getConfiguration().densityDpi);
                context.getResources().getConfiguration().densityDpi);
        boolean isLargeScreen = smallestWidth >= LARGE_SCREEN_MIN_DPS;
        return smallestWidth >= LARGE_SCREEN_MIN_DPS;
        if (Flags.enableOmitAccelerometerRotationRestore()) {
            isLargeScreen = isLargeScreen || isFoldable(context);
        }
        return isLargeScreen;
    }

    private static boolean isFoldable(Context context) {
        return context.getResources().getIntArray(R.array.config_foldedDeviceStates).length > 0;
    }
    }


    private static float dpiFromPx(float size, int densityDpi) {
    private static float dpiFromPx(float size, int densityDpi) {