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

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

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

parents d633dcc1 38565493
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -21,8 +21,14 @@ import android.graphics.Rect;
import android.util.DisplayMetrics;
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
 *  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 {
    private static final float LARGE_SCREEN_MIN_DPS = 600;
@@ -43,7 +49,15 @@ public class LargeScreenSettings {
        final Rect bounds = windowManager.getCurrentWindowMetrics().getBounds();
        float smallestWidth = dpiFromPx(Math.min(bounds.width(), bounds.height()),
                context.getResources().getConfiguration().densityDpi);
        return smallestWidth >= LARGE_SCREEN_MIN_DPS;
        boolean isLargeScreen = 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) {
+1 −1
Original line number Diff line number Diff line
@@ -979,7 +979,7 @@ public class SettingsBackupAgent extends BackupAgentHelper {

            if (LargeScreenSettings.doNotRestoreIfLargeScreenSetting(key, getBaseContext())) {
                Log.i(TAG, "Skipping restore for setting " + key + " as the target device "
                        + "is a large screen (i.e tablet or foldable in unfolded state)");
                        + "is a large screen (i.e tablet or foldable)");
                if (areAgentMetricsEnabled) {
                    mBackupRestoreEventLogger.logItemsRestoreFailed(
                            settingsKey, /* count= */ 1, ERROR_SKIPPED_DUE_TO_LARGE_SCREEN);