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

Commit 0c3138d6 authored by Daniel Chapin's avatar Daniel Chapin Committed by Android (Google) Code Review
Browse files

Revert "Creates Flags for Letterbox blurred wallpaper background"

This reverts commit 51a5a076.

Reason for revert: Bug: b/300422166 

Change-Id: Ifc0bf0ace53165a8d9b8f13110fd6f92610c82cd
parent 51a5a076
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
package: "com.android.window.flags"

flag {
  name: "letterbox_background_wallpaper_flag"
  namespace: "large_screen_experiences_app_compat"
  description: "Whether the letterbox wallpaper style is enabled by default"
  bug: "297195682"
}
+19 −15
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ import android.util.Slog;

import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.window.flags.FeatureFlags;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -91,6 +90,13 @@ final class LetterboxConfiguration {
            "enable_app_compat_user_aspect_ratio_fullscreen";
    private static final boolean DEFAULT_VALUE_ENABLE_USER_ASPECT_RATIO_FULLSCREEN = true;

    // Whether the letterbox wallpaper style is enabled by default
    private static final String KEY_ENABLE_LETTERBOX_BACKGROUND_WALLPAPER =
            "enable_letterbox_background_wallpaper";

    // TODO(b/290048978): Enable wallpaper as default letterbox background.
    private static final boolean DEFAULT_VALUE_ENABLE_LETTERBOX_BACKGROUND_WALLPAPER = false;

    /**
     * Override of aspect ratio for fixed orientation letterboxing that is set via ADB with
     * set-fixed-orientation-letterbox-aspect-ratio or via {@link
@@ -179,9 +185,6 @@ final class LetterboxConfiguration {
    @NonNull
    private final LetterboxConfigurationPersister mLetterboxConfigurationPersister;

    @NonNull
    private final FeatureFlags mFeatureFlags;

    // Aspect ratio of letterbox for fixed orientation, values <=
    // MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO will be ignored.
    private float mFixedOrientationLetterboxAspectRatio;
@@ -298,8 +301,7 @@ final class LetterboxConfiguration {
    // Flags dynamically updated with {@link android.provider.DeviceConfig}.
    @NonNull private final SynchedDeviceConfig mDeviceConfig;

    LetterboxConfiguration(@NonNull final Context systemUiContext,
                           @NonNull FeatureFlags featureFags) {
    LetterboxConfiguration(@NonNull final Context systemUiContext) {
        this(systemUiContext, new LetterboxConfigurationPersister(
                () -> readLetterboxHorizontalReachabilityPositionFromConfig(
                        systemUiContext, /* forBookMode */ false),
@@ -308,16 +310,14 @@ final class LetterboxConfiguration {
                () -> readLetterboxHorizontalReachabilityPositionFromConfig(
                        systemUiContext, /* forBookMode */ true),
                () -> readLetterboxVerticalReachabilityPositionFromConfig(
                        systemUiContext, /* forTabletopMode */ true)),
                featureFags);
                        systemUiContext, /* forTabletopMode */ true)));
    }

    @VisibleForTesting
    LetterboxConfiguration(@NonNull final Context systemUiContext,
            @NonNull final LetterboxConfigurationPersister letterboxConfigurationPersister,
            @NonNull FeatureFlags featureFags) {
            @NonNull final LetterboxConfigurationPersister letterboxConfigurationPersister) {
        mContext = systemUiContext;
        mFeatureFlags = featureFags;

        mFixedOrientationLetterboxAspectRatio = mContext.getResources().getFloat(
                R.dimen.config_fixedOrientationLetterboxAspectRatio);
        mLetterboxBackgroundType = readLetterboxBackgroundTypeFromConfig(mContext);
@@ -385,6 +385,8 @@ final class LetterboxConfiguration {
                        DEFAULT_VALUE_ENABLE_USER_ASPECT_RATIO_SETTINGS,
                        mContext.getResources().getBoolean(
                                R.bool.config_appCompatUserAppAspectRatioSettingsIsEnabled))
                .addDeviceConfigEntry(KEY_ENABLE_LETTERBOX_BACKGROUND_WALLPAPER,
                        DEFAULT_VALUE_ENABLE_LETTERBOX_BACKGROUND_WALLPAPER, /* enabled */ true)
                .addDeviceConfigEntry(KEY_ENABLE_USER_ASPECT_RATIO_FULLSCREEN,
                        DEFAULT_VALUE_ENABLE_USER_ASPECT_RATIO_FULLSCREEN,
                        mContext.getResources().getBoolean(
@@ -542,7 +544,8 @@ final class LetterboxConfiguration {
    }

    /**
     * Resets letterbox background type value depending on the built time and runtime flags.
     * Resets letterbox background type value depending on the
     * {@link #KEY_ENABLE_LETTERBOX_BACKGROUND_WALLPAPER} built time and runtime flags.
     *
     * <p>If enabled, the letterbox background type value is set toZ
     * {@link #LETTERBOX_BACKGROUND_WALLPAPER}. When disabled the letterbox background type value
@@ -552,11 +555,12 @@ final class LetterboxConfiguration {
        mLetterboxBackgroundTypeOverride = LETTERBOX_BACKGROUND_OVERRIDE_UNSET;
    }

    // Returns LETTERBOX_BACKGROUND_WALLPAPER if the flag is enabled or the value in
    // com.android.internal.R.integer.config_letterboxBackgroundType if the flag is disabled.
    // Returns KEY_ENABLE_LETTERBOX_BACKGROUND_WALLPAPER if the DeviceConfig flag is enabled
    // or the value in com.android.internal.R.integer.config_letterboxBackgroundType if the flag
    // is disabled.
    @LetterboxBackgroundType
    private int getDefaultLetterboxBackgroundType() {
        return mFeatureFlags.letterboxBackgroundWallpaperFlag()
        return mDeviceConfig.getFlagValue(KEY_ENABLE_LETTERBOX_BACKGROUND_WALLPAPER)
                ? LETTERBOX_BACKGROUND_WALLPAPER : mLetterboxBackgroundType;
    }

+2 −3
Original line number Diff line number Diff line
@@ -97,6 +97,7 @@ import static android.view.WindowManagerPolicyConstants.TYPE_LAYER_MULTIPLIER;
import static android.view.displayhash.DisplayHashResultCallback.DISPLAY_HASH_ERROR_MISSING_WINDOW;
import static android.view.displayhash.DisplayHashResultCallback.DISPLAY_HASH_ERROR_NOT_VISIBLE_ON_SCREEN;
import static android.window.WindowProviderService.isWindowProviderService;

import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ADD_REMOVE;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ANIM;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_BOOT;
@@ -333,7 +334,6 @@ import com.android.server.policy.WindowManagerPolicy;
import com.android.server.policy.WindowManagerPolicy.ScreenOffListener;
import com.android.server.power.ShutdownThread;
import com.android.server.utils.PriorityDump;
import com.android.window.flags.FeatureFlagsImpl;

import dalvik.annotation.optimization.NeverCompile;

@@ -1175,8 +1175,7 @@ public class WindowManagerService extends IWindowManager.Stub

        mLetterboxConfiguration = new LetterboxConfiguration(
                // Using SysUI context to have access to Material colors extracted from Wallpaper.
                ActivityThread.currentActivityThread().getSystemUiContext(),
                new FeatureFlagsImpl());
                ActivityThread.currentActivityThread().getSystemUiContext());

        mInputManager = inputManager; // Must be before createDisplayContentLocked.
        mDisplayManagerInternal = LocalServices.getService(DisplayManagerInternal.class);
+3 −45
Original line number Diff line number Diff line
@@ -17,15 +17,14 @@
package com.android.server.wm;

import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_BACKGROUND_SOLID_COLOR;
import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_BACKGROUND_WALLPAPER;

import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_HORIZONTAL_REACHABILITY_POSITION_CENTER;
import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_HORIZONTAL_REACHABILITY_POSITION_LEFT;
import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_HORIZONTAL_REACHABILITY_POSITION_RIGHT;
import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_VERTICAL_REACHABILITY_POSITION_BOTTOM;
import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_VERTICAL_REACHABILITY_POSITION_CENTER;
import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_VERTICAL_REACHABILITY_POSITION_TOP;
import static junit.framework.Assert.assertEquals;

import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
@@ -38,8 +37,6 @@ import android.platform.test.annotations.Presubmit;

import androidx.test.filters.SmallTest;

import com.android.window.flags.FakeFeatureFlagsImpl;

import org.junit.Before;
import org.junit.Test;

@@ -60,16 +57,12 @@ public class LetterboxConfigurationTest {
    private LetterboxConfiguration mLetterboxConfiguration;
    private LetterboxConfigurationPersister mLetterboxConfigurationPersister;

    private MutableFakeFeatureFlagsImpl mMutableFakeFeatureFlags;


    @Before
    public void setUp() throws Exception {
        mContext = getInstrumentation().getTargetContext();
        mMutableFakeFeatureFlags = new MutableFakeFeatureFlagsImpl();
        mLetterboxConfigurationPersister = mock(LetterboxConfigurationPersister.class);
        mLetterboxConfiguration = new LetterboxConfiguration(mContext,
                mLetterboxConfigurationPersister, mMutableFakeFeatureFlags);
                mLetterboxConfigurationPersister);
    }

    @Test
@@ -98,22 +91,6 @@ public class LetterboxConfigurationTest {
        }
    }

    @Test
    public void test_whenFlagEnabled_wallpaperIsDefaultBackground() {
        mMutableFakeFeatureFlags.setLetterboxBackgroundWallpaperFlag(true);
        assertEquals(LETTERBOX_BACKGROUND_WALLPAPER,
                mLetterboxConfiguration.getLetterboxBackgroundType());
        assertEquals(1, mMutableFakeFeatureFlags.getInvocationCount());
    }

    @Test
    public void test_whenFlagDisabled_solidColorIsDefaultBackground() {
        mMutableFakeFeatureFlags.setLetterboxBackgroundWallpaperFlag(false);
        assertEquals(LETTERBOX_BACKGROUND_SOLID_COLOR,
                mLetterboxConfiguration.getLetterboxBackgroundType());
        assertEquals(1, mMutableFakeFeatureFlags.getInvocationCount());
    }

    @Test
    public void test_whenMovedHorizontally_updatePositionAccordingly() {
        // Starting from center
@@ -311,23 +288,4 @@ public class LetterboxConfigurationTest {
                false /* forTabletopMode */,
                LETTERBOX_VERTICAL_REACHABILITY_POSITION_TOP);
    }

    private static class MutableFakeFeatureFlagsImpl extends FakeFeatureFlagsImpl {
        private boolean mLetterboxBackgroundWallpaperFlag;
        private int mInvocationCount;

        public void setLetterboxBackgroundWallpaperFlag(boolean letterboxBackgroundWallpaperFlag) {
            mLetterboxBackgroundWallpaperFlag = letterboxBackgroundWallpaperFlag;
        }

        @Override
        public boolean letterboxBackgroundWallpaperFlag() {
            mInvocationCount++;
            return mLetterboxBackgroundWallpaperFlag;
        }

        int getInvocationCount() {
            return mInvocationCount;
        }
    }
}