Merge "Split predictive back bitmask flags into a few boolean flags." into tm-dev
This commit is contained in:
@@ -51,9 +51,10 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher {
|
|||||||
private IWindowSession mWindowSession;
|
private IWindowSession mWindowSession;
|
||||||
private IWindow mWindow;
|
private IWindow mWindow;
|
||||||
private static final String TAG = "WindowOnBackDispatcher";
|
private static final String TAG = "WindowOnBackDispatcher";
|
||||||
private static final String BACK_PREDICTABILITY_PROP = "persist.debug.back_predictability";
|
private static final boolean ENABLE_PREDICTIVE_BACK = SystemProperties
|
||||||
private static final boolean IS_BACK_PREDICTABILITY_ENABLED = SystemProperties
|
.getInt("persist.wm.debug.predictive_back", 1) != 0;
|
||||||
.getInt(BACK_PREDICTABILITY_PROP, 1) > 0;
|
private static final boolean ALWAYS_ENFORCE_PREDICTIVE_BACK = SystemProperties
|
||||||
|
.getInt("persist.wm.debug.predictive_back_always_enforce", 0) != 0;
|
||||||
|
|
||||||
/** Convenience hashmap to quickly decide if a callback has been added. */
|
/** Convenience hashmap to quickly decide if a callback has been added. */
|
||||||
private final HashMap<OnBackInvokedCallback, Integer> mAllCallbacks = new HashMap<>();
|
private final HashMap<OnBackInvokedCallback, Integer> mAllCallbacks = new HashMap<>();
|
||||||
@@ -254,18 +255,18 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher {
|
|||||||
public static boolean isOnBackInvokedCallbackEnabled(@Nullable Context context) {
|
public static boolean isOnBackInvokedCallbackEnabled(@Nullable Context context) {
|
||||||
// new back is enabled if the feature flag is enabled AND the app does not explicitly
|
// new back is enabled if the feature flag is enabled AND the app does not explicitly
|
||||||
// request legacy back.
|
// request legacy back.
|
||||||
boolean featureFlagEnabled = IS_BACK_PREDICTABILITY_ENABLED;
|
boolean featureFlagEnabled = ENABLE_PREDICTIVE_BACK;
|
||||||
// If the context is null, we assume true and fallback on the two other conditions.
|
// If the context is null, we assume true and fallback on the two other conditions.
|
||||||
boolean appRequestsPredictiveBack =
|
boolean appRequestsPredictiveBack =
|
||||||
context != null && context.getApplicationInfo().isOnBackInvokedCallbackEnabled();
|
context != null && context.getApplicationInfo().isOnBackInvokedCallbackEnabled();
|
||||||
|
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, TextUtils.formatSimple("App: %s featureFlagEnabled=%s "
|
Log.d(TAG, TextUtils.formatSimple("App: %s featureFlagEnabled=%s "
|
||||||
+ "appRequestsPredictiveBack=%s",
|
+ "appRequestsPredictiveBack=%s alwaysEnforce=%s",
|
||||||
context != null ? context.getApplicationInfo().packageName : "null context",
|
context != null ? context.getApplicationInfo().packageName : "null context",
|
||||||
featureFlagEnabled, appRequestsPredictiveBack));
|
featureFlagEnabled, appRequestsPredictiveBack, ALWAYS_ENFORCE_PREDICTIVE_BACK));
|
||||||
}
|
}
|
||||||
|
|
||||||
return featureFlagEnabled && appRequestsPredictiveBack;
|
return featureFlagEnabled && (appRequestsPredictiveBack || ALWAYS_ENFORCE_PREDICTIVE_BACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,18 +48,16 @@ import com.android.wm.shell.common.annotations.ShellMainThread;
|
|||||||
* Controls the window animation run when a user initiates a back gesture.
|
* Controls the window animation run when a user initiates a back gesture.
|
||||||
*/
|
*/
|
||||||
public class BackAnimationController implements RemoteCallable<BackAnimationController> {
|
public class BackAnimationController implements RemoteCallable<BackAnimationController> {
|
||||||
|
|
||||||
private static final String BACK_PREDICTABILITY_PROGRESS_THRESHOLD_PROP =
|
|
||||||
"persist.debug.back_predictability_progress_threshold";
|
|
||||||
// By default, enable new back dispatching without any animations.
|
|
||||||
private static final int BACK_PREDICTABILITY_PROP =
|
|
||||||
SystemProperties.getInt("persist.debug.back_predictability", 1);
|
|
||||||
public static final boolean IS_ENABLED = BACK_PREDICTABILITY_PROP > 0;
|
|
||||||
private static final int PROGRESS_THRESHOLD = SystemProperties
|
|
||||||
.getInt(BACK_PREDICTABILITY_PROGRESS_THRESHOLD_PROP, -1);
|
|
||||||
private static final String TAG = "BackAnimationController";
|
private static final String TAG = "BackAnimationController";
|
||||||
|
private static final String PREDICTIVE_BACK_PROGRESS_THRESHOLD_PROP =
|
||||||
|
"persist.wm.debug.predictive_back_progress_threshold";
|
||||||
|
public static final boolean IS_ENABLED =
|
||||||
|
SystemProperties.getInt("persist.wm.debug.predictive_back", 1) != 0;
|
||||||
|
private static final int PROGRESS_THRESHOLD = SystemProperties
|
||||||
|
.getInt(PREDICTIVE_BACK_PROGRESS_THRESHOLD_PROP, -1);
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
boolean mEnableAnimations = (BACK_PREDICTABILITY_PROP & (1 << 1)) != 0;
|
boolean mEnableAnimations = SystemProperties.getInt(
|
||||||
|
"persist.wm.debug.predictive_back_anim", 0) != 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Location of the initial touch event of the back gesture.
|
* Location of the initial touch event of the back gesture.
|
||||||
|
|||||||
@@ -162,6 +162,17 @@ public class Flags {
|
|||||||
public static final SysPropBooleanFlag WM_ENABLE_SHELL_TRANSITIONS =
|
public static final SysPropBooleanFlag WM_ENABLE_SHELL_TRANSITIONS =
|
||||||
new SysPropBooleanFlag(1100, "persist.wm.debug.shell_transit", false);
|
new SysPropBooleanFlag(1100, "persist.wm.debug.shell_transit", false);
|
||||||
|
|
||||||
|
// 1200 - predictive back
|
||||||
|
@Keep
|
||||||
|
public static final SysPropBooleanFlag WM_ENABLE_PREDICTIVE_BACK = new SysPropBooleanFlag(
|
||||||
|
1200, "persist.wm.debug.predictive_back", true);
|
||||||
|
@Keep
|
||||||
|
public static final SysPropBooleanFlag WM_ENABLE_PREDICTIVE_BACK_ANIM = new SysPropBooleanFlag(
|
||||||
|
1201, "persist.wm.debug.predictive_back_anim", false);
|
||||||
|
@Keep
|
||||||
|
public static final SysPropBooleanFlag WM_ALWAYS_ENFORCE_PREDICTIVE_BACK =
|
||||||
|
new SysPropBooleanFlag(1202, "persist.wm.debug.predictive_back_always_enforce", false);
|
||||||
|
|
||||||
// Pay no attention to the reflection behind the curtain.
|
// Pay no attention to the reflection behind the curtain.
|
||||||
// ========================== Curtain ==========================
|
// ========================== Curtain ==========================
|
||||||
// | |
|
// | |
|
||||||
|
|||||||
@@ -47,12 +47,6 @@ import com.android.server.LocalServices;
|
|||||||
class BackNavigationController {
|
class BackNavigationController {
|
||||||
|
|
||||||
private static final String TAG = "BackNavigationController";
|
private static final String TAG = "BackNavigationController";
|
||||||
// By default, enable new back dispatching without any animations.
|
|
||||||
private static final int BACK_PREDICTABILITY_PROP =
|
|
||||||
SystemProperties.getInt("persist.debug.back_predictability", 1);
|
|
||||||
private static final int ANIMATIONS_MASK = 1 << 1;
|
|
||||||
private static final int SCREENSHOT_MASK = 1 << 2;
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private TaskSnapshotController mTaskSnapshotController;
|
private TaskSnapshotController mTaskSnapshotController;
|
||||||
|
|
||||||
@@ -60,15 +54,15 @@ class BackNavigationController {
|
|||||||
* Returns true if the back predictability feature is enabled
|
* Returns true if the back predictability feature is enabled
|
||||||
*/
|
*/
|
||||||
static boolean isEnabled() {
|
static boolean isEnabled() {
|
||||||
return BACK_PREDICTABILITY_PROP > 0;
|
return SystemProperties.getInt("persist.wm.debug.predictive_back", 1) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isScreenshotEnabled() {
|
static boolean isScreenshotEnabled() {
|
||||||
return (BACK_PREDICTABILITY_PROP & SCREENSHOT_MASK) != 0;
|
return SystemProperties.getInt("persist.wm.debug.predictive_back_screenshot", 0) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isAnimationEnabled() {
|
private static boolean isAnimationEnabled() {
|
||||||
return (BACK_PREDICTABILITY_PROP & ANIMATIONS_MASK) != 0;
|
return SystemProperties.getInt("persist.wm.debug.predictive_back_anim", 0) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user