Merge "Add listener for "enable_compat_fake_focus"" into tm-qpr-dev am: bcec71f396
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21150126 Change-Id: I3318312c9be340ea793cdf9a7d4ee11dd093db25 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -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.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_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_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 static com.android.server.wm.LetterboxConfigurationDeviceConfig.KEY_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY;
|
||||||
|
|
||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
@@ -42,10 +43,6 @@ final class LetterboxConfiguration {
|
|||||||
|
|
||||||
private static final String TAG = TAG_WITH_CLASS_NAME ? "LetterboxConfiguration" : TAG_ATM;
|
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
|
* 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
|
||||||
@@ -115,12 +112,6 @@ final class LetterboxConfiguration {
|
|||||||
/** Letterboxed app window is aligned to the right side. */
|
/** Letterboxed app window is aligned to the right side. */
|
||||||
static final int LETTERBOX_VERTICAL_REACHABILITY_POSITION_BOTTOM = 2;
|
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;
|
final Context mContext;
|
||||||
|
|
||||||
// Responsible for the persistence of letterbox[Horizontal|Vertical]PositionMultiplier
|
// Responsible for the persistence of letterbox[Horizontal|Vertical]PositionMultiplier
|
||||||
@@ -317,6 +308,9 @@ final class LetterboxConfiguration {
|
|||||||
mDeviceConfig.updateFlagActiveStatus(
|
mDeviceConfig.updateFlagActiveStatus(
|
||||||
/* isActive */ true,
|
/* isActive */ true,
|
||||||
/* key */ KEY_ALLOW_IGNORE_ORIENTATION_REQUEST);
|
/* key */ KEY_ALLOW_IGNORE_ORIENTATION_REQUEST);
|
||||||
|
mDeviceConfig.updateFlagActiveStatus(
|
||||||
|
/* isActive */ mIsCompatFakeFocusEnabled,
|
||||||
|
/* key */ KEY_ENABLE_COMPAT_FAKE_FOCUS);
|
||||||
|
|
||||||
mLetterboxConfigurationPersister = letterboxConfigurationPersister;
|
mLetterboxConfigurationPersister = letterboxConfigurationPersister;
|
||||||
mLetterboxConfigurationPersister.start();
|
mLetterboxConfigurationPersister.start();
|
||||||
@@ -1066,9 +1060,7 @@ final class LetterboxConfiguration {
|
|||||||
|
|
||||||
/** Whether fake sending focus is enabled for unfocused apps in splitscreen */
|
/** Whether fake sending focus is enabled for unfocused apps in splitscreen */
|
||||||
boolean isCompatFakeFocusEnabled() {
|
boolean isCompatFakeFocusEnabled() {
|
||||||
return mIsCompatFakeFocusEnabled
|
return mIsCompatFakeFocusEnabled && mDeviceConfig.getFlag(KEY_ENABLE_COMPAT_FAKE_FOCUS);
|
||||||
&& DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_WINDOW_MANAGER,
|
|
||||||
DEVICE_CONFIG_KEY_ENABLE_COMPAT_FAKE_FOCUS, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ final class LetterboxConfigurationDeviceConfig
|
|||||||
"allow_ignore_orientation_request";
|
"allow_ignore_orientation_request";
|
||||||
private static final boolean DEFAULT_VALUE_ALLOW_IGNORE_ORIENTATION_REQUEST = true;
|
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
|
@VisibleForTesting
|
||||||
static final Map<String, Boolean> sKeyToDefaultValueMap = Map.of(
|
static final Map<String, Boolean> sKeyToDefaultValueMap = Map.of(
|
||||||
KEY_ENABLE_CAMERA_COMPAT_TREATMENT,
|
KEY_ENABLE_CAMERA_COMPAT_TREATMENT,
|
||||||
@@ -52,7 +55,9 @@ final class LetterboxConfigurationDeviceConfig
|
|||||||
KEY_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY,
|
KEY_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY,
|
||||||
DEFAULT_VALUE_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY,
|
DEFAULT_VALUE_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY,
|
||||||
KEY_ALLOW_IGNORE_ORIENTATION_REQUEST,
|
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.
|
// Whether camera compatibility treatment is enabled.
|
||||||
@@ -72,6 +77,11 @@ final class LetterboxConfigurationDeviceConfig
|
|||||||
private boolean mIsAllowIgnoreOrientationRequest =
|
private boolean mIsAllowIgnoreOrientationRequest =
|
||||||
DEFAULT_VALUE_ALLOW_IGNORE_ORIENTATION_REQUEST;
|
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
|
// Set of active device configs that need to be updated in
|
||||||
// DeviceConfig.OnPropertiesChangedListener#onPropertiesChanged.
|
// DeviceConfig.OnPropertiesChangedListener#onPropertiesChanged.
|
||||||
private final ArraySet<String> mActiveDeviceConfigsSet = new ArraySet<>();
|
private final ArraySet<String> mActiveDeviceConfigsSet = new ArraySet<>();
|
||||||
@@ -117,6 +127,8 @@ final class LetterboxConfigurationDeviceConfig
|
|||||||
return mIsDisplayRotationImmersiveAppCompatPolicyEnabled;
|
return mIsDisplayRotationImmersiveAppCompatPolicyEnabled;
|
||||||
case KEY_ALLOW_IGNORE_ORIENTATION_REQUEST:
|
case KEY_ALLOW_IGNORE_ORIENTATION_REQUEST:
|
||||||
return mIsAllowIgnoreOrientationRequest;
|
return mIsAllowIgnoreOrientationRequest;
|
||||||
|
case KEY_ENABLE_COMPAT_FAKE_FOCUS:
|
||||||
|
return mIsCompatFakeFocusAllowed;
|
||||||
default:
|
default:
|
||||||
throw new AssertionError("Unexpected flag name: " + key);
|
throw new AssertionError("Unexpected flag name: " + key);
|
||||||
}
|
}
|
||||||
@@ -140,6 +152,10 @@ final class LetterboxConfigurationDeviceConfig
|
|||||||
mIsAllowIgnoreOrientationRequest =
|
mIsAllowIgnoreOrientationRequest =
|
||||||
getDeviceConfig(key, defaultValue);
|
getDeviceConfig(key, defaultValue);
|
||||||
break;
|
break;
|
||||||
|
case KEY_ENABLE_COMPAT_FAKE_FOCUS:
|
||||||
|
mIsCompatFakeFocusAllowed =
|
||||||
|
getDeviceConfig(key, defaultValue);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new AssertionError("Unexpected flag name: " + key);
|
throw new AssertionError("Unexpected flag name: " + key);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ 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.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_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;
|
||||||
@@ -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_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 org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
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;
|
||||||
@@ -37,7 +34,6 @@ import static org.mockito.Mockito.when;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.platform.test.annotations.Presubmit;
|
import android.platform.test.annotations.Presubmit;
|
||||||
import android.provider.DeviceConfig;
|
|
||||||
|
|
||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
|
|
||||||
@@ -233,34 +229,6 @@ public class LetterboxConfigurationTest {
|
|||||||
LetterboxConfiguration::movePositionForVerticalReachabilityToNextBottomStop);
|
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,
|
private void assertForHorizontalMove(int from, int expected, int expectedTime,
|
||||||
boolean halfFoldPose, BiConsumer<LetterboxConfiguration, Boolean> move) {
|
boolean halfFoldPose, BiConsumer<LetterboxConfiguration, Boolean> move) {
|
||||||
// We are in the current position
|
// We are in the current position
|
||||||
|
|||||||
Reference in New Issue
Block a user