Loading core/java/android/window/flags/large_screen_experiences_app_compat.aconfig 0 → 100644 +8 −0 Original line number Original line 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" } services/core/java/com/android/server/wm/LetterboxConfiguration.java +15 −19 Original line number Original line Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.util.Slog; import com.android.internal.R; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; import com.android.window.flags.FeatureFlags; import java.lang.annotation.Retention; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy; Loading Loading @@ -90,13 +91,6 @@ final class LetterboxConfiguration { "enable_app_compat_user_aspect_ratio_fullscreen"; "enable_app_compat_user_aspect_ratio_fullscreen"; private static final boolean DEFAULT_VALUE_ENABLE_USER_ASPECT_RATIO_FULLSCREEN = true; 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 * Override of aspect ratio for fixed orientation letterboxing that is set via ADB with * set-fixed-orientation-letterbox-aspect-ratio or via {@link * set-fixed-orientation-letterbox-aspect-ratio or via {@link Loading Loading @@ -185,6 +179,9 @@ final class LetterboxConfiguration { @NonNull @NonNull private final LetterboxConfigurationPersister mLetterboxConfigurationPersister; private final LetterboxConfigurationPersister mLetterboxConfigurationPersister; @NonNull private final FeatureFlags mFeatureFlags; // Aspect ratio of letterbox for fixed orientation, values <= // Aspect ratio of letterbox for fixed orientation, values <= // MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO will be ignored. // MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO will be ignored. private float mFixedOrientationLetterboxAspectRatio; private float mFixedOrientationLetterboxAspectRatio; Loading Loading @@ -301,7 +298,8 @@ final class LetterboxConfiguration { // Flags dynamically updated with {@link android.provider.DeviceConfig}. // Flags dynamically updated with {@link android.provider.DeviceConfig}. @NonNull private final SynchedDeviceConfig mDeviceConfig; @NonNull private final SynchedDeviceConfig mDeviceConfig; LetterboxConfiguration(@NonNull final Context systemUiContext) { LetterboxConfiguration(@NonNull final Context systemUiContext, @NonNull FeatureFlags featureFags) { this(systemUiContext, new LetterboxConfigurationPersister( this(systemUiContext, new LetterboxConfigurationPersister( () -> readLetterboxHorizontalReachabilityPositionFromConfig( () -> readLetterboxHorizontalReachabilityPositionFromConfig( systemUiContext, /* forBookMode */ false), systemUiContext, /* forBookMode */ false), Loading @@ -310,14 +308,16 @@ final class LetterboxConfiguration { () -> readLetterboxHorizontalReachabilityPositionFromConfig( () -> readLetterboxHorizontalReachabilityPositionFromConfig( systemUiContext, /* forBookMode */ true), systemUiContext, /* forBookMode */ true), () -> readLetterboxVerticalReachabilityPositionFromConfig( () -> readLetterboxVerticalReachabilityPositionFromConfig( systemUiContext, /* forTabletopMode */ true))); systemUiContext, /* forTabletopMode */ true)), featureFags); } } @VisibleForTesting @VisibleForTesting LetterboxConfiguration(@NonNull final Context systemUiContext, LetterboxConfiguration(@NonNull final Context systemUiContext, @NonNull final LetterboxConfigurationPersister letterboxConfigurationPersister) { @NonNull final LetterboxConfigurationPersister letterboxConfigurationPersister, @NonNull FeatureFlags featureFags) { mContext = systemUiContext; mContext = systemUiContext; mFeatureFlags = featureFags; mFixedOrientationLetterboxAspectRatio = mContext.getResources().getFloat( mFixedOrientationLetterboxAspectRatio = mContext.getResources().getFloat( R.dimen.config_fixedOrientationLetterboxAspectRatio); R.dimen.config_fixedOrientationLetterboxAspectRatio); mLetterboxBackgroundType = readLetterboxBackgroundTypeFromConfig(mContext); mLetterboxBackgroundType = readLetterboxBackgroundTypeFromConfig(mContext); Loading Loading @@ -385,8 +385,6 @@ final class LetterboxConfiguration { DEFAULT_VALUE_ENABLE_USER_ASPECT_RATIO_SETTINGS, DEFAULT_VALUE_ENABLE_USER_ASPECT_RATIO_SETTINGS, mContext.getResources().getBoolean( mContext.getResources().getBoolean( R.bool.config_appCompatUserAppAspectRatioSettingsIsEnabled)) 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, .addDeviceConfigEntry(KEY_ENABLE_USER_ASPECT_RATIO_FULLSCREEN, DEFAULT_VALUE_ENABLE_USER_ASPECT_RATIO_FULLSCREEN, DEFAULT_VALUE_ENABLE_USER_ASPECT_RATIO_FULLSCREEN, mContext.getResources().getBoolean( mContext.getResources().getBoolean( Loading Loading @@ -544,8 +542,7 @@ final class LetterboxConfiguration { } } /** /** * Resets letterbox background type value depending on the * Resets letterbox background type value depending on the built time and runtime flags. * {@link #KEY_ENABLE_LETTERBOX_BACKGROUND_WALLPAPER} built time and runtime flags. * * * <p>If enabled, the letterbox background type value is set toZ * <p>If enabled, the letterbox background type value is set toZ * {@link #LETTERBOX_BACKGROUND_WALLPAPER}. When disabled the letterbox background type value * {@link #LETTERBOX_BACKGROUND_WALLPAPER}. When disabled the letterbox background type value Loading @@ -555,12 +552,11 @@ final class LetterboxConfiguration { mLetterboxBackgroundTypeOverride = LETTERBOX_BACKGROUND_OVERRIDE_UNSET; mLetterboxBackgroundTypeOverride = LETTERBOX_BACKGROUND_OVERRIDE_UNSET; } } // Returns KEY_ENABLE_LETTERBOX_BACKGROUND_WALLPAPER if the DeviceConfig flag is enabled // Returns LETTERBOX_BACKGROUND_WALLPAPER if the flag is enabled or the value in // or the value in com.android.internal.R.integer.config_letterboxBackgroundType if the flag // com.android.internal.R.integer.config_letterboxBackgroundType if the flag is disabled. // is disabled. @LetterboxBackgroundType @LetterboxBackgroundType private int getDefaultLetterboxBackgroundType() { private int getDefaultLetterboxBackgroundType() { return mDeviceConfig.getFlagValue(KEY_ENABLE_LETTERBOX_BACKGROUND_WALLPAPER) return mFeatureFlags.letterboxBackgroundWallpaperFlag() ? LETTERBOX_BACKGROUND_WALLPAPER : mLetterboxBackgroundType; ? LETTERBOX_BACKGROUND_WALLPAPER : mLetterboxBackgroundType; } } Loading services/core/java/com/android/server/wm/WindowManagerService.java +3 −2 Original line number Original line Diff line number Diff line Loading @@ -97,7 +97,6 @@ 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_MISSING_WINDOW; import static android.view.displayhash.DisplayHashResultCallback.DISPLAY_HASH_ERROR_NOT_VISIBLE_ON_SCREEN; import static android.view.displayhash.DisplayHashResultCallback.DISPLAY_HASH_ERROR_NOT_VISIBLE_ON_SCREEN; import static android.window.WindowProviderService.isWindowProviderService; 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_ADD_REMOVE; import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ANIM; import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ANIM; import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_BOOT; import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_BOOT; Loading Loading @@ -334,6 +333,7 @@ import com.android.server.policy.WindowManagerPolicy; import com.android.server.policy.WindowManagerPolicy.ScreenOffListener; import com.android.server.policy.WindowManagerPolicy.ScreenOffListener; import com.android.server.power.ShutdownThread; import com.android.server.power.ShutdownThread; import com.android.server.utils.PriorityDump; import com.android.server.utils.PriorityDump; import com.android.window.flags.FeatureFlagsImpl; import dalvik.annotation.optimization.NeverCompile; import dalvik.annotation.optimization.NeverCompile; Loading Loading @@ -1175,7 +1175,8 @@ public class WindowManagerService extends IWindowManager.Stub mLetterboxConfiguration = new LetterboxConfiguration( mLetterboxConfiguration = new LetterboxConfiguration( // Using SysUI context to have access to Material colors extracted from Wallpaper. // Using SysUI context to have access to Material colors extracted from Wallpaper. ActivityThread.currentActivityThread().getSystemUiContext()); ActivityThread.currentActivityThread().getSystemUiContext(), new FeatureFlagsImpl()); mInputManager = inputManager; // Must be before createDisplayContentLocked. mInputManager = inputManager; // Must be before createDisplayContentLocked. mDisplayManagerInternal = LocalServices.getService(DisplayManagerInternal.class); mDisplayManagerInternal = LocalServices.getService(DisplayManagerInternal.class); Loading services/tests/wmtests/src/com/android/server/wm/LetterboxConfigurationTest.java +45 −3 Original line number Original line Diff line number Diff line Loading @@ -17,14 +17,15 @@ package com.android.server.wm; package com.android.server.wm; import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; 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_CENTER; import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_HORIZONTAL_REACHABILITY_POSITION_LEFT; 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_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_BOTTOM; import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_VERTICAL_REACHABILITY_POSITION_CENTER; 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 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.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock; Loading @@ -37,6 +38,8 @@ import android.platform.test.annotations.Presubmit; import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest; import com.android.window.flags.FakeFeatureFlagsImpl; import org.junit.Before; import org.junit.Before; import org.junit.Test; import org.junit.Test; Loading @@ -57,12 +60,16 @@ public class LetterboxConfigurationTest { private LetterboxConfiguration mLetterboxConfiguration; private LetterboxConfiguration mLetterboxConfiguration; private LetterboxConfigurationPersister mLetterboxConfigurationPersister; private LetterboxConfigurationPersister mLetterboxConfigurationPersister; private MutableFakeFeatureFlagsImpl mMutableFakeFeatureFlags; @Before @Before public void setUp() throws Exception { public void setUp() throws Exception { mContext = getInstrumentation().getTargetContext(); mContext = getInstrumentation().getTargetContext(); mMutableFakeFeatureFlags = new MutableFakeFeatureFlagsImpl(); mLetterboxConfigurationPersister = mock(LetterboxConfigurationPersister.class); mLetterboxConfigurationPersister = mock(LetterboxConfigurationPersister.class); mLetterboxConfiguration = new LetterboxConfiguration(mContext, mLetterboxConfiguration = new LetterboxConfiguration(mContext, mLetterboxConfigurationPersister); mLetterboxConfigurationPersister, mMutableFakeFeatureFlags); } } @Test @Test Loading Loading @@ -91,6 +98,22 @@ 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 @Test public void test_whenMovedHorizontally_updatePositionAccordingly() { public void test_whenMovedHorizontally_updatePositionAccordingly() { // Starting from center // Starting from center Loading Loading @@ -288,4 +311,23 @@ public class LetterboxConfigurationTest { false /* forTabletopMode */, false /* forTabletopMode */, LETTERBOX_VERTICAL_REACHABILITY_POSITION_TOP); 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; } } } } Loading
core/java/android/window/flags/large_screen_experiences_app_compat.aconfig 0 → 100644 +8 −0 Original line number Original line 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" }
services/core/java/com/android/server/wm/LetterboxConfiguration.java +15 −19 Original line number Original line Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.util.Slog; import com.android.internal.R; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; import com.android.window.flags.FeatureFlags; import java.lang.annotation.Retention; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy; Loading Loading @@ -90,13 +91,6 @@ final class LetterboxConfiguration { "enable_app_compat_user_aspect_ratio_fullscreen"; "enable_app_compat_user_aspect_ratio_fullscreen"; private static final boolean DEFAULT_VALUE_ENABLE_USER_ASPECT_RATIO_FULLSCREEN = true; 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 * Override of aspect ratio for fixed orientation letterboxing that is set via ADB with * set-fixed-orientation-letterbox-aspect-ratio or via {@link * set-fixed-orientation-letterbox-aspect-ratio or via {@link Loading Loading @@ -185,6 +179,9 @@ final class LetterboxConfiguration { @NonNull @NonNull private final LetterboxConfigurationPersister mLetterboxConfigurationPersister; private final LetterboxConfigurationPersister mLetterboxConfigurationPersister; @NonNull private final FeatureFlags mFeatureFlags; // Aspect ratio of letterbox for fixed orientation, values <= // Aspect ratio of letterbox for fixed orientation, values <= // MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO will be ignored. // MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO will be ignored. private float mFixedOrientationLetterboxAspectRatio; private float mFixedOrientationLetterboxAspectRatio; Loading Loading @@ -301,7 +298,8 @@ final class LetterboxConfiguration { // Flags dynamically updated with {@link android.provider.DeviceConfig}. // Flags dynamically updated with {@link android.provider.DeviceConfig}. @NonNull private final SynchedDeviceConfig mDeviceConfig; @NonNull private final SynchedDeviceConfig mDeviceConfig; LetterboxConfiguration(@NonNull final Context systemUiContext) { LetterboxConfiguration(@NonNull final Context systemUiContext, @NonNull FeatureFlags featureFags) { this(systemUiContext, new LetterboxConfigurationPersister( this(systemUiContext, new LetterboxConfigurationPersister( () -> readLetterboxHorizontalReachabilityPositionFromConfig( () -> readLetterboxHorizontalReachabilityPositionFromConfig( systemUiContext, /* forBookMode */ false), systemUiContext, /* forBookMode */ false), Loading @@ -310,14 +308,16 @@ final class LetterboxConfiguration { () -> readLetterboxHorizontalReachabilityPositionFromConfig( () -> readLetterboxHorizontalReachabilityPositionFromConfig( systemUiContext, /* forBookMode */ true), systemUiContext, /* forBookMode */ true), () -> readLetterboxVerticalReachabilityPositionFromConfig( () -> readLetterboxVerticalReachabilityPositionFromConfig( systemUiContext, /* forTabletopMode */ true))); systemUiContext, /* forTabletopMode */ true)), featureFags); } } @VisibleForTesting @VisibleForTesting LetterboxConfiguration(@NonNull final Context systemUiContext, LetterboxConfiguration(@NonNull final Context systemUiContext, @NonNull final LetterboxConfigurationPersister letterboxConfigurationPersister) { @NonNull final LetterboxConfigurationPersister letterboxConfigurationPersister, @NonNull FeatureFlags featureFags) { mContext = systemUiContext; mContext = systemUiContext; mFeatureFlags = featureFags; mFixedOrientationLetterboxAspectRatio = mContext.getResources().getFloat( mFixedOrientationLetterboxAspectRatio = mContext.getResources().getFloat( R.dimen.config_fixedOrientationLetterboxAspectRatio); R.dimen.config_fixedOrientationLetterboxAspectRatio); mLetterboxBackgroundType = readLetterboxBackgroundTypeFromConfig(mContext); mLetterboxBackgroundType = readLetterboxBackgroundTypeFromConfig(mContext); Loading Loading @@ -385,8 +385,6 @@ final class LetterboxConfiguration { DEFAULT_VALUE_ENABLE_USER_ASPECT_RATIO_SETTINGS, DEFAULT_VALUE_ENABLE_USER_ASPECT_RATIO_SETTINGS, mContext.getResources().getBoolean( mContext.getResources().getBoolean( R.bool.config_appCompatUserAppAspectRatioSettingsIsEnabled)) 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, .addDeviceConfigEntry(KEY_ENABLE_USER_ASPECT_RATIO_FULLSCREEN, DEFAULT_VALUE_ENABLE_USER_ASPECT_RATIO_FULLSCREEN, DEFAULT_VALUE_ENABLE_USER_ASPECT_RATIO_FULLSCREEN, mContext.getResources().getBoolean( mContext.getResources().getBoolean( Loading Loading @@ -544,8 +542,7 @@ final class LetterboxConfiguration { } } /** /** * Resets letterbox background type value depending on the * Resets letterbox background type value depending on the built time and runtime flags. * {@link #KEY_ENABLE_LETTERBOX_BACKGROUND_WALLPAPER} built time and runtime flags. * * * <p>If enabled, the letterbox background type value is set toZ * <p>If enabled, the letterbox background type value is set toZ * {@link #LETTERBOX_BACKGROUND_WALLPAPER}. When disabled the letterbox background type value * {@link #LETTERBOX_BACKGROUND_WALLPAPER}. When disabled the letterbox background type value Loading @@ -555,12 +552,11 @@ final class LetterboxConfiguration { mLetterboxBackgroundTypeOverride = LETTERBOX_BACKGROUND_OVERRIDE_UNSET; mLetterboxBackgroundTypeOverride = LETTERBOX_BACKGROUND_OVERRIDE_UNSET; } } // Returns KEY_ENABLE_LETTERBOX_BACKGROUND_WALLPAPER if the DeviceConfig flag is enabled // Returns LETTERBOX_BACKGROUND_WALLPAPER if the flag is enabled or the value in // or the value in com.android.internal.R.integer.config_letterboxBackgroundType if the flag // com.android.internal.R.integer.config_letterboxBackgroundType if the flag is disabled. // is disabled. @LetterboxBackgroundType @LetterboxBackgroundType private int getDefaultLetterboxBackgroundType() { private int getDefaultLetterboxBackgroundType() { return mDeviceConfig.getFlagValue(KEY_ENABLE_LETTERBOX_BACKGROUND_WALLPAPER) return mFeatureFlags.letterboxBackgroundWallpaperFlag() ? LETTERBOX_BACKGROUND_WALLPAPER : mLetterboxBackgroundType; ? LETTERBOX_BACKGROUND_WALLPAPER : mLetterboxBackgroundType; } } Loading
services/core/java/com/android/server/wm/WindowManagerService.java +3 −2 Original line number Original line Diff line number Diff line Loading @@ -97,7 +97,6 @@ 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_MISSING_WINDOW; import static android.view.displayhash.DisplayHashResultCallback.DISPLAY_HASH_ERROR_NOT_VISIBLE_ON_SCREEN; import static android.view.displayhash.DisplayHashResultCallback.DISPLAY_HASH_ERROR_NOT_VISIBLE_ON_SCREEN; import static android.window.WindowProviderService.isWindowProviderService; 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_ADD_REMOVE; import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ANIM; import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ANIM; import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_BOOT; import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_BOOT; Loading Loading @@ -334,6 +333,7 @@ import com.android.server.policy.WindowManagerPolicy; import com.android.server.policy.WindowManagerPolicy.ScreenOffListener; import com.android.server.policy.WindowManagerPolicy.ScreenOffListener; import com.android.server.power.ShutdownThread; import com.android.server.power.ShutdownThread; import com.android.server.utils.PriorityDump; import com.android.server.utils.PriorityDump; import com.android.window.flags.FeatureFlagsImpl; import dalvik.annotation.optimization.NeverCompile; import dalvik.annotation.optimization.NeverCompile; Loading Loading @@ -1175,7 +1175,8 @@ public class WindowManagerService extends IWindowManager.Stub mLetterboxConfiguration = new LetterboxConfiguration( mLetterboxConfiguration = new LetterboxConfiguration( // Using SysUI context to have access to Material colors extracted from Wallpaper. // Using SysUI context to have access to Material colors extracted from Wallpaper. ActivityThread.currentActivityThread().getSystemUiContext()); ActivityThread.currentActivityThread().getSystemUiContext(), new FeatureFlagsImpl()); mInputManager = inputManager; // Must be before createDisplayContentLocked. mInputManager = inputManager; // Must be before createDisplayContentLocked. mDisplayManagerInternal = LocalServices.getService(DisplayManagerInternal.class); mDisplayManagerInternal = LocalServices.getService(DisplayManagerInternal.class); Loading
services/tests/wmtests/src/com/android/server/wm/LetterboxConfigurationTest.java +45 −3 Original line number Original line Diff line number Diff line Loading @@ -17,14 +17,15 @@ package com.android.server.wm; package com.android.server.wm; import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; 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_CENTER; import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_HORIZONTAL_REACHABILITY_POSITION_LEFT; 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_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_BOTTOM; import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_VERTICAL_REACHABILITY_POSITION_CENTER; 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 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.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock; Loading @@ -37,6 +38,8 @@ import android.platform.test.annotations.Presubmit; import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest; import com.android.window.flags.FakeFeatureFlagsImpl; import org.junit.Before; import org.junit.Before; import org.junit.Test; import org.junit.Test; Loading @@ -57,12 +60,16 @@ public class LetterboxConfigurationTest { private LetterboxConfiguration mLetterboxConfiguration; private LetterboxConfiguration mLetterboxConfiguration; private LetterboxConfigurationPersister mLetterboxConfigurationPersister; private LetterboxConfigurationPersister mLetterboxConfigurationPersister; private MutableFakeFeatureFlagsImpl mMutableFakeFeatureFlags; @Before @Before public void setUp() throws Exception { public void setUp() throws Exception { mContext = getInstrumentation().getTargetContext(); mContext = getInstrumentation().getTargetContext(); mMutableFakeFeatureFlags = new MutableFakeFeatureFlagsImpl(); mLetterboxConfigurationPersister = mock(LetterboxConfigurationPersister.class); mLetterboxConfigurationPersister = mock(LetterboxConfigurationPersister.class); mLetterboxConfiguration = new LetterboxConfiguration(mContext, mLetterboxConfiguration = new LetterboxConfiguration(mContext, mLetterboxConfigurationPersister); mLetterboxConfigurationPersister, mMutableFakeFeatureFlags); } } @Test @Test Loading Loading @@ -91,6 +98,22 @@ 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 @Test public void test_whenMovedHorizontally_updatePositionAccordingly() { public void test_whenMovedHorizontally_updatePositionAccordingly() { // Starting from center // Starting from center Loading Loading @@ -288,4 +311,23 @@ public class LetterboxConfigurationTest { false /* forTabletopMode */, false /* forTabletopMode */, LETTERBOX_VERTICAL_REACHABILITY_POSITION_TOP); 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; } } } }