Loading services/core/java/com/android/server/wm/LetterboxConfiguration.java +5 −13 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM; import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.LetterboxConfigurationDeviceConfig.KEY_ALLOW_IGNORE_ORIENTATION_REQUEST; import static com.android.server.wm.LetterboxConfigurationDeviceConfig.KEY_ENABLE_CAMERA_COMPAT_TREATMENT; import static com.android.server.wm.LetterboxConfigurationDeviceConfig.KEY_ENABLE_COMPAT_FAKE_FOCUS; import static com.android.server.wm.LetterboxConfigurationDeviceConfig.KEY_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY; import android.annotation.IntDef; Loading @@ -42,10 +43,6 @@ final class LetterboxConfiguration { private static final String TAG = TAG_WITH_CLASS_NAME ? "LetterboxConfiguration" : TAG_ATM; @VisibleForTesting static final String DEVICE_CONFIG_KEY_ENABLE_COMPAT_FAKE_FOCUS = "enable_compat_fake_focus"; /** * Override of aspect ratio for fixed orientation letterboxing that is set via ADB with * set-fixed-orientation-letterbox-aspect-ratio or via {@link Loading Loading @@ -115,12 +112,6 @@ final class LetterboxConfiguration { /** Letterboxed app window is aligned to the right side. */ static final int LETTERBOX_VERTICAL_REACHABILITY_POSITION_BOTTOM = 2; @VisibleForTesting static final String PROPERTY_COMPAT_FAKE_FOCUS_OPT_IN = "com.android.COMPAT_FAKE_FOCUS_OPT_IN"; @VisibleForTesting static final String PROPERTY_COMPAT_FAKE_FOCUS_OPT_OUT = "com.android.COMPAT_FAKE_FOCUS_OPT_OUT"; final Context mContext; // Responsible for the persistence of letterbox[Horizontal|Vertical]PositionMultiplier Loading Loading @@ -317,6 +308,9 @@ final class LetterboxConfiguration { mDeviceConfig.updateFlagActiveStatus( /* isActive */ true, /* key */ KEY_ALLOW_IGNORE_ORIENTATION_REQUEST); mDeviceConfig.updateFlagActiveStatus( /* isActive */ mIsCompatFakeFocusEnabled, /* key */ KEY_ENABLE_COMPAT_FAKE_FOCUS); mLetterboxConfigurationPersister = letterboxConfigurationPersister; mLetterboxConfigurationPersister.start(); Loading Loading @@ -1066,9 +1060,7 @@ final class LetterboxConfiguration { /** Whether fake sending focus is enabled for unfocused apps in splitscreen */ boolean isCompatFakeFocusEnabled() { return mIsCompatFakeFocusEnabled && DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_WINDOW_MANAGER, DEVICE_CONFIG_KEY_ENABLE_COMPAT_FAKE_FOCUS, true); return mIsCompatFakeFocusEnabled && mDeviceConfig.getFlag(KEY_ENABLE_COMPAT_FAKE_FOCUS); } /** Loading services/core/java/com/android/server/wm/LetterboxConfigurationDeviceConfig.java +17 −1 Original line number Diff line number Diff line Loading @@ -45,6 +45,9 @@ final class LetterboxConfigurationDeviceConfig "allow_ignore_orientation_request"; private static final boolean DEFAULT_VALUE_ALLOW_IGNORE_ORIENTATION_REQUEST = true; static final String KEY_ENABLE_COMPAT_FAKE_FOCUS = "enable_compat_fake_focus"; private static final boolean DEFAULT_VALUE_ENABLE_COMPAT_FAKE_FOCUS = true; @VisibleForTesting static final Map<String, Boolean> sKeyToDefaultValueMap = Map.of( KEY_ENABLE_CAMERA_COMPAT_TREATMENT, Loading @@ -52,7 +55,9 @@ final class LetterboxConfigurationDeviceConfig KEY_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY, DEFAULT_VALUE_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY, KEY_ALLOW_IGNORE_ORIENTATION_REQUEST, DEFAULT_VALUE_ALLOW_IGNORE_ORIENTATION_REQUEST DEFAULT_VALUE_ALLOW_IGNORE_ORIENTATION_REQUEST, KEY_ENABLE_COMPAT_FAKE_FOCUS, DEFAULT_VALUE_ENABLE_COMPAT_FAKE_FOCUS ); // Whether camera compatibility treatment is enabled. Loading @@ -72,6 +77,11 @@ final class LetterboxConfigurationDeviceConfig private boolean mIsAllowIgnoreOrientationRequest = DEFAULT_VALUE_ALLOW_IGNORE_ORIENTATION_REQUEST; // Whether sending compat fake focus for split screen resumed activities is enabled. This is // needed because some game engines wait to get focus before drawing the content of the app // which isn't guaranteed by default in multi-window modes. private boolean mIsCompatFakeFocusAllowed = DEFAULT_VALUE_ENABLE_COMPAT_FAKE_FOCUS; // Set of active device configs that need to be updated in // DeviceConfig.OnPropertiesChangedListener#onPropertiesChanged. private final ArraySet<String> mActiveDeviceConfigsSet = new ArraySet<>(); Loading Loading @@ -117,6 +127,8 @@ final class LetterboxConfigurationDeviceConfig return mIsDisplayRotationImmersiveAppCompatPolicyEnabled; case KEY_ALLOW_IGNORE_ORIENTATION_REQUEST: return mIsAllowIgnoreOrientationRequest; case KEY_ENABLE_COMPAT_FAKE_FOCUS: return mIsCompatFakeFocusAllowed; default: throw new AssertionError("Unexpected flag name: " + key); } Loading @@ -140,6 +152,10 @@ final class LetterboxConfigurationDeviceConfig mIsAllowIgnoreOrientationRequest = getDeviceConfig(key, defaultValue); break; case KEY_ENABLE_COMPAT_FAKE_FOCUS: mIsCompatFakeFocusAllowed = getDeviceConfig(key, defaultValue); break; default: throw new AssertionError("Unexpected flag name: " + key); } Loading services/tests/wmtests/src/com/android/server/wm/LetterboxConfigurationTest.java +0 −32 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.server.wm; import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static com.android.server.wm.LetterboxConfiguration.DEVICE_CONFIG_KEY_ENABLE_COMPAT_FAKE_FOCUS; 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; Loading @@ -26,8 +25,6 @@ import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_VERTICAL_RE 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 org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; Loading @@ -37,7 +34,6 @@ import static org.mockito.Mockito.when; import android.content.Context; import android.platform.test.annotations.Presubmit; import android.provider.DeviceConfig; import androidx.test.filters.SmallTest; Loading Loading @@ -233,34 +229,6 @@ public class LetterboxConfigurationTest { LetterboxConfiguration::movePositionForVerticalReachabilityToNextBottomStop); } @Test public void testIsCompatFakeFocusEnabledOnDevice() { boolean wasFakeFocusEnabled = DeviceConfig .getBoolean(DeviceConfig.NAMESPACE_WINDOW_MANAGER, DEVICE_CONFIG_KEY_ENABLE_COMPAT_FAKE_FOCUS, false); // Set runtime flag to true and build time flag to false DeviceConfig.setProperty(DeviceConfig.NAMESPACE_WINDOW_MANAGER, DEVICE_CONFIG_KEY_ENABLE_COMPAT_FAKE_FOCUS, "true", false); mLetterboxConfiguration.setIsCompatFakeFocusEnabled(false); assertFalse(mLetterboxConfiguration.isCompatFakeFocusEnabled()); // Set runtime flag to false and build time flag to true DeviceConfig.setProperty(DeviceConfig.NAMESPACE_WINDOW_MANAGER, DEVICE_CONFIG_KEY_ENABLE_COMPAT_FAKE_FOCUS, "false", false); mLetterboxConfiguration.setIsCompatFakeFocusEnabled(true); assertFalse(mLetterboxConfiguration.isCompatFakeFocusEnabled()); // Set runtime flag to true so that both are enabled DeviceConfig.setProperty(DeviceConfig.NAMESPACE_WINDOW_MANAGER, DEVICE_CONFIG_KEY_ENABLE_COMPAT_FAKE_FOCUS, "true", false); assertTrue(mLetterboxConfiguration.isCompatFakeFocusEnabled()); DeviceConfig.setProperty(DeviceConfig.NAMESPACE_WINDOW_MANAGER, DEVICE_CONFIG_KEY_ENABLE_COMPAT_FAKE_FOCUS, Boolean.toString(wasFakeFocusEnabled), false); } private void assertForHorizontalMove(int from, int expected, int expectedTime, boolean halfFoldPose, BiConsumer<LetterboxConfiguration, Boolean> move) { // We are in the current position Loading Loading
services/core/java/com/android/server/wm/LetterboxConfiguration.java +5 −13 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM; import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.LetterboxConfigurationDeviceConfig.KEY_ALLOW_IGNORE_ORIENTATION_REQUEST; import static com.android.server.wm.LetterboxConfigurationDeviceConfig.KEY_ENABLE_CAMERA_COMPAT_TREATMENT; import static com.android.server.wm.LetterboxConfigurationDeviceConfig.KEY_ENABLE_COMPAT_FAKE_FOCUS; import static com.android.server.wm.LetterboxConfigurationDeviceConfig.KEY_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY; import android.annotation.IntDef; Loading @@ -42,10 +43,6 @@ final class LetterboxConfiguration { private static final String TAG = TAG_WITH_CLASS_NAME ? "LetterboxConfiguration" : TAG_ATM; @VisibleForTesting static final String DEVICE_CONFIG_KEY_ENABLE_COMPAT_FAKE_FOCUS = "enable_compat_fake_focus"; /** * Override of aspect ratio for fixed orientation letterboxing that is set via ADB with * set-fixed-orientation-letterbox-aspect-ratio or via {@link Loading Loading @@ -115,12 +112,6 @@ final class LetterboxConfiguration { /** Letterboxed app window is aligned to the right side. */ static final int LETTERBOX_VERTICAL_REACHABILITY_POSITION_BOTTOM = 2; @VisibleForTesting static final String PROPERTY_COMPAT_FAKE_FOCUS_OPT_IN = "com.android.COMPAT_FAKE_FOCUS_OPT_IN"; @VisibleForTesting static final String PROPERTY_COMPAT_FAKE_FOCUS_OPT_OUT = "com.android.COMPAT_FAKE_FOCUS_OPT_OUT"; final Context mContext; // Responsible for the persistence of letterbox[Horizontal|Vertical]PositionMultiplier Loading Loading @@ -317,6 +308,9 @@ final class LetterboxConfiguration { mDeviceConfig.updateFlagActiveStatus( /* isActive */ true, /* key */ KEY_ALLOW_IGNORE_ORIENTATION_REQUEST); mDeviceConfig.updateFlagActiveStatus( /* isActive */ mIsCompatFakeFocusEnabled, /* key */ KEY_ENABLE_COMPAT_FAKE_FOCUS); mLetterboxConfigurationPersister = letterboxConfigurationPersister; mLetterboxConfigurationPersister.start(); Loading Loading @@ -1066,9 +1060,7 @@ final class LetterboxConfiguration { /** Whether fake sending focus is enabled for unfocused apps in splitscreen */ boolean isCompatFakeFocusEnabled() { return mIsCompatFakeFocusEnabled && DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_WINDOW_MANAGER, DEVICE_CONFIG_KEY_ENABLE_COMPAT_FAKE_FOCUS, true); return mIsCompatFakeFocusEnabled && mDeviceConfig.getFlag(KEY_ENABLE_COMPAT_FAKE_FOCUS); } /** Loading
services/core/java/com/android/server/wm/LetterboxConfigurationDeviceConfig.java +17 −1 Original line number Diff line number Diff line Loading @@ -45,6 +45,9 @@ final class LetterboxConfigurationDeviceConfig "allow_ignore_orientation_request"; private static final boolean DEFAULT_VALUE_ALLOW_IGNORE_ORIENTATION_REQUEST = true; static final String KEY_ENABLE_COMPAT_FAKE_FOCUS = "enable_compat_fake_focus"; private static final boolean DEFAULT_VALUE_ENABLE_COMPAT_FAKE_FOCUS = true; @VisibleForTesting static final Map<String, Boolean> sKeyToDefaultValueMap = Map.of( KEY_ENABLE_CAMERA_COMPAT_TREATMENT, Loading @@ -52,7 +55,9 @@ final class LetterboxConfigurationDeviceConfig KEY_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY, DEFAULT_VALUE_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY, KEY_ALLOW_IGNORE_ORIENTATION_REQUEST, DEFAULT_VALUE_ALLOW_IGNORE_ORIENTATION_REQUEST DEFAULT_VALUE_ALLOW_IGNORE_ORIENTATION_REQUEST, KEY_ENABLE_COMPAT_FAKE_FOCUS, DEFAULT_VALUE_ENABLE_COMPAT_FAKE_FOCUS ); // Whether camera compatibility treatment is enabled. Loading @@ -72,6 +77,11 @@ final class LetterboxConfigurationDeviceConfig private boolean mIsAllowIgnoreOrientationRequest = DEFAULT_VALUE_ALLOW_IGNORE_ORIENTATION_REQUEST; // Whether sending compat fake focus for split screen resumed activities is enabled. This is // needed because some game engines wait to get focus before drawing the content of the app // which isn't guaranteed by default in multi-window modes. private boolean mIsCompatFakeFocusAllowed = DEFAULT_VALUE_ENABLE_COMPAT_FAKE_FOCUS; // Set of active device configs that need to be updated in // DeviceConfig.OnPropertiesChangedListener#onPropertiesChanged. private final ArraySet<String> mActiveDeviceConfigsSet = new ArraySet<>(); Loading Loading @@ -117,6 +127,8 @@ final class LetterboxConfigurationDeviceConfig return mIsDisplayRotationImmersiveAppCompatPolicyEnabled; case KEY_ALLOW_IGNORE_ORIENTATION_REQUEST: return mIsAllowIgnoreOrientationRequest; case KEY_ENABLE_COMPAT_FAKE_FOCUS: return mIsCompatFakeFocusAllowed; default: throw new AssertionError("Unexpected flag name: " + key); } Loading @@ -140,6 +152,10 @@ final class LetterboxConfigurationDeviceConfig mIsAllowIgnoreOrientationRequest = getDeviceConfig(key, defaultValue); break; case KEY_ENABLE_COMPAT_FAKE_FOCUS: mIsCompatFakeFocusAllowed = getDeviceConfig(key, defaultValue); break; default: throw new AssertionError("Unexpected flag name: " + key); } Loading
services/tests/wmtests/src/com/android/server/wm/LetterboxConfigurationTest.java +0 −32 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.server.wm; import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static com.android.server.wm.LetterboxConfiguration.DEVICE_CONFIG_KEY_ENABLE_COMPAT_FAKE_FOCUS; 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; Loading @@ -26,8 +25,6 @@ import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_VERTICAL_RE 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 org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; Loading @@ -37,7 +34,6 @@ import static org.mockito.Mockito.when; import android.content.Context; import android.platform.test.annotations.Presubmit; import android.provider.DeviceConfig; import androidx.test.filters.SmallTest; Loading Loading @@ -233,34 +229,6 @@ public class LetterboxConfigurationTest { LetterboxConfiguration::movePositionForVerticalReachabilityToNextBottomStop); } @Test public void testIsCompatFakeFocusEnabledOnDevice() { boolean wasFakeFocusEnabled = DeviceConfig .getBoolean(DeviceConfig.NAMESPACE_WINDOW_MANAGER, DEVICE_CONFIG_KEY_ENABLE_COMPAT_FAKE_FOCUS, false); // Set runtime flag to true and build time flag to false DeviceConfig.setProperty(DeviceConfig.NAMESPACE_WINDOW_MANAGER, DEVICE_CONFIG_KEY_ENABLE_COMPAT_FAKE_FOCUS, "true", false); mLetterboxConfiguration.setIsCompatFakeFocusEnabled(false); assertFalse(mLetterboxConfiguration.isCompatFakeFocusEnabled()); // Set runtime flag to false and build time flag to true DeviceConfig.setProperty(DeviceConfig.NAMESPACE_WINDOW_MANAGER, DEVICE_CONFIG_KEY_ENABLE_COMPAT_FAKE_FOCUS, "false", false); mLetterboxConfiguration.setIsCompatFakeFocusEnabled(true); assertFalse(mLetterboxConfiguration.isCompatFakeFocusEnabled()); // Set runtime flag to true so that both are enabled DeviceConfig.setProperty(DeviceConfig.NAMESPACE_WINDOW_MANAGER, DEVICE_CONFIG_KEY_ENABLE_COMPAT_FAKE_FOCUS, "true", false); assertTrue(mLetterboxConfiguration.isCompatFakeFocusEnabled()); DeviceConfig.setProperty(DeviceConfig.NAMESPACE_WINDOW_MANAGER, DEVICE_CONFIG_KEY_ENABLE_COMPAT_FAKE_FOCUS, Boolean.toString(wasFakeFocusEnabled), false); } private void assertForHorizontalMove(int from, int expected, int expectedTime, boolean halfFoldPose, BiConsumer<LetterboxConfiguration, Boolean> move) { // We are in the current position Loading