Merge "Enable translucent activities strategy by default" into tm-qpr-dev am: 9649e11962 am: 02538b5d3b

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21141399

Change-Id: I36be2f8f311436c8f16dd2b9b5de3a630ea5dc11
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Massimo Carli
2023-02-22 11:30:00 +00:00
committed by Automerger Merge Worker
2 changed files with 25 additions and 17 deletions

View File

@@ -22,6 +22,7 @@ import static com.android.server.wm.LetterboxConfigurationDeviceConfig.KEY_ALLOW
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_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 static com.android.server.wm.LetterboxConfigurationDeviceConfig.KEY_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY;
import android.annotation.IntDef; import android.annotation.IntDef;
import android.annotation.NonNull; import android.annotation.NonNull;
@@ -296,7 +297,6 @@ final class LetterboxConfiguration {
R.bool.config_isCompatFakeFocusEnabled); R.bool.config_isCompatFakeFocusEnabled);
mIsPolicyForIgnoringRequestedOrientationEnabled = mContext.getResources().getBoolean( mIsPolicyForIgnoringRequestedOrientationEnabled = mContext.getResources().getBoolean(
R.bool.config_letterboxIsPolicyForIgnoringRequestedOrientationEnabled); R.bool.config_letterboxIsPolicyForIgnoringRequestedOrientationEnabled);
mIsDisplayRotationImmersiveAppCompatPolicyEnabled = mContext.getResources().getBoolean( mIsDisplayRotationImmersiveAppCompatPolicyEnabled = mContext.getResources().getBoolean(
R.bool.config_letterboxIsDisplayRotationImmersiveAppCompatPolicyEnabled); R.bool.config_letterboxIsDisplayRotationImmersiveAppCompatPolicyEnabled);
mDeviceConfig.updateFlagActiveStatus( mDeviceConfig.updateFlagActiveStatus(
@@ -311,7 +311,9 @@ final class LetterboxConfiguration {
mDeviceConfig.updateFlagActiveStatus( mDeviceConfig.updateFlagActiveStatus(
/* isActive */ mIsCompatFakeFocusEnabled, /* isActive */ mIsCompatFakeFocusEnabled,
/* key */ KEY_ENABLE_COMPAT_FAKE_FOCUS); /* key */ KEY_ENABLE_COMPAT_FAKE_FOCUS);
mDeviceConfig.updateFlagActiveStatus(
/* isActive */ mTranslucentLetterboxingEnabled,
/* key */ KEY_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY);
mLetterboxConfigurationPersister = letterboxConfigurationPersister; mLetterboxConfigurationPersister = letterboxConfigurationPersister;
mLetterboxConfigurationPersister.start(); mLetterboxConfigurationPersister.start();
} }
@@ -1003,7 +1005,7 @@ final class LetterboxConfiguration {
boolean isTranslucentLetterboxingEnabled() { boolean isTranslucentLetterboxingEnabled() {
return mTranslucentLetterboxingOverrideEnabled || (mTranslucentLetterboxingEnabled return mTranslucentLetterboxingOverrideEnabled || (mTranslucentLetterboxingEnabled
&& isTranslucentLetterboxingAllowed()); && mDeviceConfig.getFlag(KEY_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY));
} }
void setTranslucentLetterboxingEnabled(boolean translucentLetterboxingEnabled) { void setTranslucentLetterboxingEnabled(boolean translucentLetterboxingEnabled) {
@@ -1051,13 +1053,6 @@ final class LetterboxConfiguration {
isDeviceInTabletopMode, nextVerticalPosition); isDeviceInTabletopMode, nextVerticalPosition);
} }
// TODO(b/262378106): Cache a runtime flag and implement
// DeviceConfig.OnPropertiesChangedListener
static boolean isTranslucentLetterboxingAllowed() {
return DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_WINDOW_MANAGER,
"enable_translucent_activity_letterbox", false);
}
/** 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 && mDeviceConfig.getFlag(KEY_ENABLE_COMPAT_FAKE_FOCUS); return mIsCompatFakeFocusEnabled && mDeviceConfig.getFlag(KEY_ENABLE_COMPAT_FAKE_FOCUS);

View File

@@ -48,6 +48,11 @@ final class LetterboxConfigurationDeviceConfig
static final String KEY_ENABLE_COMPAT_FAKE_FOCUS = "enable_compat_fake_focus"; static final String KEY_ENABLE_COMPAT_FAKE_FOCUS = "enable_compat_fake_focus";
private static final boolean DEFAULT_VALUE_ENABLE_COMPAT_FAKE_FOCUS = true; private static final boolean DEFAULT_VALUE_ENABLE_COMPAT_FAKE_FOCUS = true;
static final String KEY_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY =
"enable_letterbox_translucent_activity";
private static final boolean DEFAULT_VALUE_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY = 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,
@@ -57,7 +62,9 @@ final class LetterboxConfigurationDeviceConfig
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, KEY_ENABLE_COMPAT_FAKE_FOCUS,
DEFAULT_VALUE_ENABLE_COMPAT_FAKE_FOCUS DEFAULT_VALUE_ENABLE_COMPAT_FAKE_FOCUS,
KEY_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY,
DEFAULT_VALUE_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY
); );
// Whether camera compatibility treatment is enabled. // Whether camera compatibility treatment is enabled.
@@ -82,6 +89,10 @@ final class LetterboxConfigurationDeviceConfig
// which isn't guaranteed by default in multi-window modes. // which isn't guaranteed by default in multi-window modes.
private boolean mIsCompatFakeFocusAllowed = DEFAULT_VALUE_ENABLE_COMPAT_FAKE_FOCUS; private boolean mIsCompatFakeFocusAllowed = DEFAULT_VALUE_ENABLE_COMPAT_FAKE_FOCUS;
// Whether the letterbox strategy for transparent activities is allowed
private boolean mIsTranslucentLetterboxingAllowed =
DEFAULT_VALUE_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY;
// 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<>();
@@ -129,6 +140,8 @@ final class LetterboxConfigurationDeviceConfig
return mIsAllowIgnoreOrientationRequest; return mIsAllowIgnoreOrientationRequest;
case KEY_ENABLE_COMPAT_FAKE_FOCUS: case KEY_ENABLE_COMPAT_FAKE_FOCUS:
return mIsCompatFakeFocusAllowed; return mIsCompatFakeFocusAllowed;
case KEY_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY:
return mIsTranslucentLetterboxingAllowed;
default: default:
throw new AssertionError("Unexpected flag name: " + key); throw new AssertionError("Unexpected flag name: " + key);
} }
@@ -141,20 +154,20 @@ final class LetterboxConfigurationDeviceConfig
} }
switch (key) { switch (key) {
case KEY_ENABLE_CAMERA_COMPAT_TREATMENT: case KEY_ENABLE_CAMERA_COMPAT_TREATMENT:
mIsCameraCompatTreatmentEnabled = mIsCameraCompatTreatmentEnabled = getDeviceConfig(key, defaultValue);
getDeviceConfig(key, defaultValue);
break; break;
case KEY_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY: case KEY_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY:
mIsDisplayRotationImmersiveAppCompatPolicyEnabled = mIsDisplayRotationImmersiveAppCompatPolicyEnabled =
getDeviceConfig(key, defaultValue); getDeviceConfig(key, defaultValue);
break; break;
case KEY_ALLOW_IGNORE_ORIENTATION_REQUEST: case KEY_ALLOW_IGNORE_ORIENTATION_REQUEST:
mIsAllowIgnoreOrientationRequest = mIsAllowIgnoreOrientationRequest = getDeviceConfig(key, defaultValue);
getDeviceConfig(key, defaultValue);
break; break;
case KEY_ENABLE_COMPAT_FAKE_FOCUS: case KEY_ENABLE_COMPAT_FAKE_FOCUS:
mIsCompatFakeFocusAllowed = mIsCompatFakeFocusAllowed = getDeviceConfig(key, defaultValue);
getDeviceConfig(key, defaultValue); break;
case KEY_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY:
mIsTranslucentLetterboxingAllowed = getDeviceConfig(key, defaultValue);
break; break;
default: default:
throw new AssertionError("Unexpected flag name: " + key); throw new AssertionError("Unexpected flag name: " + key);