From fc4f7c948ddb659b7c73dd01f557ecb343744001 Mon Sep 17 00:00:00 2001 From: Jason Chang Date: Fri, 6 Nov 2020 18:38:18 +0800 Subject: [PATCH] Fix change One-handed mode screen size from 50% to 40% but also keep adb command mechanism for UX tuning Provide both config.xml and adb command mechanism. Bug: 169724216 Test: adb shell setprop persist.debug.one_handed_offset_percentage 60 adb shell pidof com.android.systemui |xargs -i adb shell kill -9 {} or adb reboot adb shell setprop persist.debug.one_handed_translate_animation_duration 150 adb shell pidof com.android.systemui |xargs -i adb shell kill -9 {} or adb reboot Test: manual Test: atest WMShellUnitTests Change-Id: I9502cbe8e496f484fdeb8041b5618c47aba0f1d1 --- libs/WindowManager/Shell/res/values/config.xml | 6 ++++++ .../android/wm/shell/onehanded/OneHandedController.java | 8 ++++++-- .../wm/shell/onehanded/OneHandedDisplayAreaOrganizer.java | 6 +++++- .../wm/shell/onehanded/OneHandedTutorialHandler.java | 7 +++++-- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/libs/WindowManager/Shell/res/values/config.xml b/libs/WindowManager/Shell/res/values/config.xml index e99350b264b9d..807e5afae890b 100644 --- a/libs/WindowManager/Shell/res/values/config.xml +++ b/libs/WindowManager/Shell/res/values/config.xml @@ -30,6 +30,12 @@ 250 + + 300 + + + 40% + true diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedController.java index f84936e5f3861..e8c6cb74af0c0 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedController.java @@ -37,6 +37,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; +import com.android.wm.shell.R; import com.android.wm.shell.common.DisplayChangeController; import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.TaskStackListenerCallback; @@ -205,8 +206,11 @@ public class OneHandedController implements OneHanded { mGestureHandler = gestureHandler; mOverlayManager = overlayManager; - mOffSetFraction = SystemProperties.getInt(ONE_HANDED_MODE_OFFSET_PERCENTAGE, 50) - / 100.0f; + final float offsetPercentageConfig = context.getResources().getFraction( + R.fraction.config_one_handed_offset, 1, 1); + final int sysPropPercentageConfig = SystemProperties.getInt( + ONE_HANDED_MODE_OFFSET_PERCENTAGE, Math.round(offsetPercentageConfig * 100.0f)); + mOffSetFraction = sysPropPercentageConfig / 100.0f; mIsOneHandedEnabled = OneHandedSettingsUtil.getSettingsOneHandedModeEnabled( context.getContentResolver()); mIsSwipeToNotificationEnabled = diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedDisplayAreaOrganizer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedDisplayAreaOrganizer.java index bd6c1e096d013..0311030890c41 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedDisplayAreaOrganizer.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedDisplayAreaOrganizer.java @@ -40,6 +40,7 @@ import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import com.android.internal.os.SomeArgs; +import com.android.wm.shell.R; import com.android.wm.shell.common.DisplayController; import java.io.PrintWriter; @@ -156,8 +157,11 @@ public class OneHandedDisplayAreaOrganizer extends DisplayAreaOrganizer { mDisplayController = displayController; mDefaultDisplayBounds.set(getDisplayBounds()); mLastVisualDisplayBounds.set(getDisplayBounds()); + final int animationDurationConfig = context.getResources().getInteger( + R.integer.config_one_handed_translate_animation_duration); mEnterExitAnimationDurationMs = - SystemProperties.getInt(ONE_HANDED_MODE_TRANSLATE_ANIMATION_DURATION, 300); + SystemProperties.getInt(ONE_HANDED_MODE_TRANSLATE_ANIMATION_DURATION, + animationDurationConfig); mSurfaceControlTransactionFactory = SurfaceControl.Transaction::new; mTutorialHandler = tutorialHandler; } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedTutorialHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedTutorialHandler.java index b6b518d69c55b..d65ad62cdbbba 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedTutorialHandler.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedTutorialHandler.java @@ -86,8 +86,11 @@ public class OneHandedTutorialHandler implements OneHandedTransitionCallback { context.getSystemService(Context.ACCESSIBILITY_SERVICE); mTargetViewContainer = new FrameLayout(context); mTargetViewContainer.setClipChildren(false); - mTutorialAreaHeight = Math.round(mDisplaySize.y - * (SystemProperties.getInt(ONE_HANDED_MODE_OFFSET_PERCENTAGE, 50) / 100.0f)); + final float offsetPercentageConfig = context.getResources().getFraction( + R.fraction.config_one_handed_offset, 1, 1); + final int sysPropPercentageConfig = SystemProperties.getInt( + ONE_HANDED_MODE_OFFSET_PERCENTAGE, Math.round(offsetPercentageConfig * 100.0f)); + mTutorialAreaHeight = Math.round(mDisplaySize.y * (sysPropPercentageConfig / 100.0f)); mTutorialView = LayoutInflater.from(context).inflate(R.layout.one_handed_tutorial, null); mTargetViewContainer.addView(mTutorialView); mCanShowTutorial = (Settings.Secure.getInt(mContentResolver,