diff options
| author | 2020-09-09 07:36:59 +0000 | |
|---|---|---|
| committer | 2020-09-09 07:36:59 +0000 | |
| commit | fb25108536382d3f2d9dd98fafb9a3ccd0180585 (patch) | |
| tree | 88d0d7ea24cb317f4f61e79a27ecd8067560ee6c | |
| parent | 614423b2c178e30605545b3506c39ff0665ef3e0 (diff) | |
| parent | 1ed148d3e7e2dd6bcef6cdffad24cf233149fe5f (diff) | |
Merge "Migrate OneHanded to WM shell (4/n)"
41 files changed, 289 insertions, 316 deletions
diff --git a/libs/WindowManager/Shell/Android.bp b/libs/WindowManager/Shell/Android.bp index 16b87c43fc58..1591b0616262 100644 --- a/libs/WindowManager/Shell/Android.bp +++ b/libs/WindowManager/Shell/Android.bp @@ -105,6 +105,7 @@ android_library { static_libs: [ "protolog-lib", "WindowManager-Shell-proto", + "androidx.appcompat_appcompat", ], manifest: "AndroidManifest.xml", }
\ No newline at end of file diff --git a/packages/SystemUI/res/drawable-hdpi/one_handed_tutorial.png b/libs/WindowManager/Shell/res/drawable-hdpi/one_handed_tutorial.png Binary files differindex 6c1f1cfdea7c..6c1f1cfdea7c 100644 --- a/packages/SystemUI/res/drawable-hdpi/one_handed_tutorial.png +++ b/libs/WindowManager/Shell/res/drawable-hdpi/one_handed_tutorial.png diff --git a/packages/SystemUI/res/xml/one_handed_tutorial.xml b/libs/WindowManager/Shell/res/layout/one_handed_tutorial.xml index dc54caf0f14a..dc54caf0f14a 100644 --- a/packages/SystemUI/res/xml/one_handed_tutorial.xml +++ b/libs/WindowManager/Shell/res/layout/one_handed_tutorial.xml diff --git a/libs/WindowManager/Shell/res/values/config.xml b/libs/WindowManager/Shell/res/values/config.xml index 39efd0768eaa..63b0f6ffbec3 100644 --- a/libs/WindowManager/Shell/res/values/config.xml +++ b/libs/WindowManager/Shell/res/values/config.xml @@ -29,4 +29,7 @@ <!-- Animation duration when using long press on recents to dock --> <integer name="long_press_dock_anim_duration">250</integer> + + <!-- Allow one handed to enable round corner --> + <bool name="config_one_handed_enable_round_corner">true</bool> </resources> diff --git a/libs/WindowManager/Shell/res/values/dimen.xml b/libs/WindowManager/Shell/res/values/dimen.xml index ce690281b491..7fb641a4b06e 100644 --- a/libs/WindowManager/Shell/res/values/dimen.xml +++ b/libs/WindowManager/Shell/res/values/dimen.xml @@ -62,4 +62,8 @@ <dimen name="docked_divider_handle_width">16dp</dimen> <dimen name="docked_divider_handle_height">2dp</dimen> + + <!-- One-Handed Mode --> + <!-- Threshold for dragging distance to enable one-handed mode --> + <dimen name="gestures_onehanded_drag_threshold">20dp</dimen> </resources> diff --git a/libs/WindowManager/Shell/res/values/strings.xml b/libs/WindowManager/Shell/res/values/strings.xml index cad924771cd3..b6668fbe4872 100644 --- a/libs/WindowManager/Shell/res/values/strings.xml +++ b/libs/WindowManager/Shell/res/values/strings.xml @@ -88,4 +88,9 @@ <string name="accessibility_action_divider_top_30">Top 30%</string> <!-- Accessibility action for moving docked stack divider to make the bottom screen full screen [CHAR LIMIT=NONE] --> <string name="accessibility_action_divider_bottom_full">Bottom full screen</string> + + <!-- One-Handed Tutorial title [CHAR LIMIT=60] --> + <string name="one_handed_tutorial_title">Using one-handed mode</string> + <!-- One-Handed Tutorial description [CHAR LIMIT=NONE] --> + <string name="one_handed_tutorial_description">To exit, swipe up from the bottom of the screen or tap anywhere above the app</string> </resources> diff --git a/packages/SystemUI/src/com/android/systemui/onehanded/OneHanded.java b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHanded.java index b7c6262b07e0..9c78fc5e57b8 100644 --- a/packages/SystemUI/src/com/android/systemui/onehanded/OneHanded.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHanded.java @@ -14,11 +14,11 @@ * limitations under the License. */ -package com.android.systemui.onehanded; +package com.android.wm.shell.onehanded; import androidx.annotation.NonNull; -import com.android.systemui.onehanded.OneHandedGestureHandler.OneHandedGestureEventCallback; +import com.android.wm.shell.onehanded.OneHandedGestureHandler.OneHandedGestureEventCallback; import java.io.PrintWriter; diff --git a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedAnimationCallback.java b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedAnimationCallback.java index 264ace749383..6749f7eec968 100644 --- a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedAnimationCallback.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedAnimationCallback.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.systemui.onehanded; +package com.android.wm.shell.onehanded; import android.view.SurfaceControl; diff --git a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedAnimationController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedAnimationController.java index 9be1b5a35be6..963909621a1b 100644 --- a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedAnimationController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedAnimationController.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.systemui.onehanded; +package com.android.wm.shell.onehanded; import android.animation.Animator; import android.animation.ValueAnimator; diff --git a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedController.java index 90adf838440c..c84b4781d19d 100644 --- a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedController.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.systemui.onehanded; +package com.android.wm.shell.onehanded; import static android.os.UserHandle.USER_CURRENT; import static android.view.Display.DEFAULT_DISPLAY; @@ -35,9 +35,9 @@ import android.util.Log; import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; -import com.android.systemui.onehanded.OneHandedGestureHandler.OneHandedGestureEventCallback; import com.android.wm.shell.common.DisplayChangeController; import com.android.wm.shell.common.DisplayController; +import com.android.wm.shell.onehanded.OneHandedGestureHandler.OneHandedGestureEventCallback; import java.io.PrintWriter; @@ -390,7 +390,7 @@ public class OneHandedController implements OneHanded { } } - @androidx.annotation.VisibleForTesting + @VisibleForTesting private void setEnabledGesturalOverlay(boolean enabled) { try { mOverlayManager.setEnabled(ONE_HANDED_MODE_GESTURAL_OVERLAY, enabled, USER_CURRENT); diff --git a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedDisplayAreaOrganizer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedDisplayAreaOrganizer.java index ec40bad06b71..9954618134e8 100644 --- a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedDisplayAreaOrganizer.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedDisplayAreaOrganizer.java @@ -14,12 +14,12 @@ * limitations under the License. */ -package com.android.systemui.onehanded; +package com.android.wm.shell.onehanded; import static android.view.Display.DEFAULT_DISPLAY; -import static com.android.systemui.onehanded.OneHandedAnimationController.TRANSITION_DIRECTION_EXIT; -import static com.android.systemui.onehanded.OneHandedAnimationController.TRANSITION_DIRECTION_TRIGGER; +import static com.android.wm.shell.onehanded.OneHandedAnimationController.TRANSITION_DIRECTION_EXIT; +import static com.android.wm.shell.onehanded.OneHandedAnimationController.TRANSITION_DIRECTION_TRIGGER; import android.content.Context; import android.graphics.Point; diff --git a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedEvents.java b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedEvents.java index 327ed67d6fc8..79ddd2b11e72 100644 --- a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedEvents.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedEvents.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.systemui.onehanded; +package com.android.wm.shell.onehanded; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.logging.UiEvent; diff --git a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedGestureHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedGestureHandler.java index 4a493ba800ba..3b1e6cbe5ccd 100644 --- a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedGestureHandler.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedGestureHandler.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.systemui.onehanded; +package com.android.wm.shell.onehanded; import static android.view.Display.DEFAULT_DISPLAY; @@ -38,7 +38,7 @@ import android.window.WindowContainerTransaction; import androidx.annotation.VisibleForTesting; -import com.android.systemui.R; +import com.android.wm.shell.R; import com.android.wm.shell.common.DisplayChangeController; import com.android.wm.shell.common.DisplayController; @@ -210,7 +210,7 @@ public class OneHandedGestureHandler implements OneHandedTransitionCallback, displaySize.y); mInputMonitor = InputManager.getInstance().monitorGestureInput( "onehanded-gesture-offset", DEFAULT_DISPLAY); - mInputEventReceiver = new SysUiInputEventReceiver( + mInputEventReceiver = new EventReceiver( mInputMonitor.getInputChannel(), Looper.getMainLooper()); } } @@ -227,8 +227,8 @@ public class OneHandedGestureHandler implements OneHandedTransitionCallback, mRotation = toRotation; } - private class SysUiInputEventReceiver extends InputEventReceiver { - SysUiInputEventReceiver(InputChannel channel, Looper looper) { + private class EventReceiver extends InputEventReceiver { + EventReceiver(InputChannel channel, Looper looper) { super(channel, looper); } diff --git a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedSettingsUtil.java b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedSettingsUtil.java index 0598f32c16d5..4d66f2961a29 100644 --- a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedSettingsUtil.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedSettingsUtil.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.systemui.onehanded; +package com.android.wm.shell.onehanded; import android.annotation.IntDef; import android.content.ContentResolver; @@ -22,8 +22,6 @@ import android.database.ContentObserver; import android.net.Uri; import android.provider.Settings; -import com.android.systemui.dagger.SysUISingleton; - import java.io.PrintWriter; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -31,7 +29,6 @@ import java.lang.annotation.RetentionPolicy; /** * APIs for querying or updating one handed settings . */ -@SysUISingleton public final class OneHandedSettingsUtil { private static final String TAG = "OneHandedSettingsUtil"; diff --git a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedSurfaceTransactionHelper.java b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedSurfaceTransactionHelper.java index bc4a9b49205c..e7010db97d77 100644 --- a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedSurfaceTransactionHelper.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedSurfaceTransactionHelper.java @@ -14,14 +14,14 @@ * limitations under the License. */ -package com.android.systemui.onehanded; +package com.android.wm.shell.onehanded; import android.content.Context; import android.content.res.Resources; import android.graphics.Rect; import android.view.SurfaceControl; -import com.android.systemui.R; +import com.android.wm.shell.R; /** * Abstracts the common operations on {@link SurfaceControl.Transaction} for OneHanded transition. diff --git a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedThread.java b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedThread.java index b7b814a31a1e..24d33ede5d63 100644 --- a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedThread.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedThread.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.systemui.onehanded; +package com.android.wm.shell.onehanded; import android.os.Handler; import android.os.HandlerThread; diff --git a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedTimeoutHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedTimeoutHandler.java index 21329ea1b0e6..9c97cd7db71f 100644 --- a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedTimeoutHandler.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedTimeoutHandler.java @@ -14,9 +14,9 @@ * limitations under the License. */ -package com.android.systemui.onehanded; +package com.android.wm.shell.onehanded; -import static com.android.systemui.onehanded.OneHandedSettingsUtil.ONE_HANDED_TIMEOUT_MEDIUM_IN_SECONDS; +import static com.android.wm.shell.onehanded.OneHandedSettingsUtil.ONE_HANDED_TIMEOUT_MEDIUM_IN_SECONDS; import android.os.Handler; import android.os.Looper; diff --git a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedTouchHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedTouchHandler.java index 3d28a426f4f8..721382d52717 100644 --- a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedTouchHandler.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedTouchHandler.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.systemui.onehanded; +package com.android.wm.shell.onehanded; import static android.view.Display.DEFAULT_DISPLAY; @@ -127,7 +127,7 @@ public class OneHandedTouchHandler implements OneHandedTransitionCallback { if (mIsEnabled) { mInputMonitor = InputManager.getInstance().monitorGestureInput( "onehanded-touch", DEFAULT_DISPLAY); - mInputEventReceiver = new SysUiInputEventReceiver( + mInputEventReceiver = new EventReceiver( mInputMonitor.getInputChannel(), Looper.getMainLooper()); } } @@ -150,8 +150,8 @@ public class OneHandedTouchHandler implements OneHandedTransitionCallback { pw.println(mLastUpdatedBounds); } - private class SysUiInputEventReceiver extends InputEventReceiver { - SysUiInputEventReceiver(InputChannel channel, Looper looper) { + private class EventReceiver extends InputEventReceiver { + EventReceiver(InputChannel channel, Looper looper) { super(channel, looper); } diff --git a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedTransitionCallback.java b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedTransitionCallback.java index 75eb0ebd5c84..3af7c4b71d0a 100644 --- a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedTransitionCallback.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedTransitionCallback.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.systemui.onehanded; +package com.android.wm.shell.onehanded; import android.graphics.Rect; diff --git a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedTutorialHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedTutorialHandler.java index beccf3dbc8de..b15b5154c2a4 100644 --- a/packages/SystemUI/src/com/android/systemui/onehanded/OneHandedTutorialHandler.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedTutorialHandler.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.systemui.onehanded; +package com.android.wm.shell.onehanded; import android.content.ContentResolver; import android.content.Context; @@ -33,7 +33,7 @@ import android.widget.FrameLayout; import androidx.annotation.NonNull; -import com.android.systemui.R; +import com.android.wm.shell.R; import java.io.PrintWriter; @@ -79,7 +79,7 @@ public class OneHandedTutorialHandler implements OneHandedTransitionCallback { mTargetViewContainer.setClipChildren(false); mTutorialAreaHeight = Math.round(mDisplaySize.y * (SystemProperties.getInt(ONE_HANDED_MODE_OFFSET_PERCENTAGE, 50) / 100.0f)); - mTutorialView = LayoutInflater.from(context).inflate(R.xml.one_handed_tutorial, null); + mTutorialView = LayoutInflater.from(context).inflate(R.layout.one_handed_tutorial, null); mTargetViewContainer.addView(mTutorialView); mCanShowTutorial = (Settings.Secure.getInt(mContentResolver, Settings.Secure.ONE_HANDED_TUTORIAL_SHOW_COUNT, 0) >= MAX_TUTORIAL_SHOW_COUNT) diff --git a/libs/WindowManager/Shell/tests/unittest/Android.bp b/libs/WindowManager/Shell/tests/unittest/Android.bp index 692e2fa88fc3..937b00b3a0fd 100644 --- a/libs/WindowManager/Shell/tests/unittest/Android.bp +++ b/libs/WindowManager/Shell/tests/unittest/Android.bp @@ -25,6 +25,7 @@ android_test { "androidx.test.ext.junit", "mockito-target-extended-minus-junit4", "truth-prebuilt", + "testables", ], libs: [ "android.test.mock", diff --git a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedAnimationControllerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/onehanded/OneHandedAnimationControllerTest.java index 7fabf8258198..a8a3a9fd7da2 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedAnimationControllerTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/onehanded/OneHandedAnimationControllerTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.systemui.onehanded; +package com.android.wm.shell.onehanded; import static org.junit.Assert.assertNotNull; diff --git a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedControllerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/onehanded/OneHandedControllerTest.java index e42cf529373e..1ce8b5445b37 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedControllerTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/onehanded/OneHandedControllerTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.systemui.onehanded; +package com.android.wm.shell.onehanded; import static com.google.common.truth.Truth.assertThat; @@ -112,10 +112,21 @@ public class OneHandedControllerTest extends OneHandedTestCase { } @Test + public void testRegisterTransitionCallbackAfterInit() { + verify(mMockDisplayAreaOrganizer).registerTransitionCallback(mMockTouchHandler); + verify(mMockDisplayAreaOrganizer).registerTransitionCallback(mMockGestureHandler); + verify(mMockDisplayAreaOrganizer).registerTransitionCallback(mMockTutorialHandler); + } + + @Test public void testRegisterTransitionCallback() { - verify(mMockDisplayAreaOrganizer, atLeastOnce()).registerTransitionCallback(any()); + OneHandedTransitionCallback callback = new OneHandedTransitionCallback() {}; + mOneHandedController.registerTransitionCallback(callback); + + verify(mMockDisplayAreaOrganizer).registerTransitionCallback(callback); } + @Test public void testStopOneHanded_shouldRemoveTimer() { mOneHandedController.stopOneHanded(); @@ -139,7 +150,7 @@ public class OneHandedControllerTest extends OneHandedTestCase { verify(mMockTouchHandler, atLeastOnce()).onOneHandedEnabled(enabled); } - @Ignore("b/161980408, fix it after migration finished") + @Ignore("b/167943723, refactor it and fix it") @Test public void tesSettingsObserver_updateTapAppToExit() { Settings.Secure.putInt(mContext.getContentResolver(), @@ -148,7 +159,7 @@ public class OneHandedControllerTest extends OneHandedTestCase { verify(mOneHandedController).setTaskChangeToExit(true); } - @Ignore("b/161980408, fix it after migration finished") + @Ignore("b/167943723, refactor it and fix it") @Test public void tesSettingsObserver_updateEnabled() { Settings.Secure.putInt(mContext.getContentResolver(), @@ -157,7 +168,7 @@ public class OneHandedControllerTest extends OneHandedTestCase { verify(mOneHandedController).setOneHandedEnabled(true); } - @Ignore("b/161980408, fix it after migration finished") + @Ignore("b/167943723, refactor it and fix it") @Test public void tesSettingsObserver_updateTimeout() { Settings.Secure.putInt(mContext.getContentResolver(), @@ -168,7 +179,7 @@ public class OneHandedControllerTest extends OneHandedTestCase { OneHandedSettingsUtil.ONE_HANDED_TIMEOUT_MEDIUM_IN_SECONDS); } - @Ignore("b/161980408, fix it after migration finished") + @Ignore("b/167943723, refactor it and fix it") @Test public void tesSettingsObserver_updateSwipeToNotification() { Settings.Secure.putInt(mContext.getContentResolver(), diff --git a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedDisplayAreaOrganizerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/onehanded/OneHandedDisplayAreaOrganizerTest.java index a989cd1f9c40..5ff94b6308ef 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedDisplayAreaOrganizerTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/onehanded/OneHandedDisplayAreaOrganizerTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.systemui.onehanded; +package com.android.wm.shell.onehanded; import static android.view.Display.DEFAULT_DISPLAY; import static android.window.DisplayAreaOrganizer.FEATURE_ONE_HANDED; diff --git a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedEventsTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/onehanded/OneHandedEventsTest.java index 36c1174fcdce..492c34e10ed5 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedEventsTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/onehanded/OneHandedEventsTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.systemui.onehanded; +package com.android.wm.shell.onehanded; import static org.junit.Assert.assertEquals; @@ -22,7 +22,6 @@ import androidx.test.filters.SmallTest; import com.android.internal.logging.UiEventLogger; import com.android.internal.logging.testing.UiEventLoggerFake; -import com.android.systemui.SysuiTestCase; import org.junit.Before; import org.junit.Test; @@ -34,7 +33,7 @@ import java.util.Collection; @RunWith(Parameterized.class) @SmallTest -public class OneHandedEventsTest extends SysuiTestCase { +public class OneHandedEventsTest extends OneHandedTestCase { private UiEventLoggerFake mUiEventLogger; diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/onehanded/OneHandedGestureHandlerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/onehanded/OneHandedGestureHandlerTest.java new file mode 100644 index 000000000000..fb417c8ca5e8 --- /dev/null +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/onehanded/OneHandedGestureHandlerTest.java @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.wm.shell.onehanded; + +import static com.google.common.truth.Truth.assertThat; + +import static org.mockito.ArgumentMatchers.any; + +import android.testing.AndroidTestingRunner; +import android.testing.TestableLooper; + +import androidx.test.filters.SmallTest; + +import com.android.wm.shell.common.DisplayController; + +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +@SmallTest +@RunWith(AndroidTestingRunner.class) +@TestableLooper.RunWithLooper +public class OneHandedGestureHandlerTest extends OneHandedTestCase { + OneHandedTutorialHandler mTutorialHandler; + OneHandedGestureHandler mGestureHandler; + @Mock + DisplayController mMockDisplayController; + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + mTutorialHandler = new OneHandedTutorialHandler(mContext); + mGestureHandler = new OneHandedGestureHandler(mContext, mMockDisplayController); + } + + @Test + public void testSetGestureEventListener() { + OneHandedGestureHandler.OneHandedGestureEventCallback callback = + new OneHandedGestureHandler.OneHandedGestureEventCallback() { + @Override + public void onStart() {} + + @Override + public void onStop() {} + }; + + mGestureHandler.setGestureEventListener(callback); + assertThat(mGestureHandler.mGestureEventCallback).isEqualTo(callback); + } + + @Ignore("b/167943723, refactor it and fix it") + @Test + public void testReceiveNewConfig_whenThreeButtonModeEnabled() { + mGestureHandler.onOneHandedEnabled(true); + mGestureHandler.onThreeButtonModeEnabled(true); + + assertThat(mGestureHandler.mInputMonitor).isNotNull(); + assertThat(mGestureHandler.mInputEventReceiver).isNotNull(); + } + + @Test + public void testOneHandedDisabled_shouldDisposeInputChannel() { + mGestureHandler.onOneHandedEnabled(false); + + assertThat(mGestureHandler.mInputMonitor).isNull(); + assertThat(mGestureHandler.mInputEventReceiver).isNull(); + } + + @Test + public void testChangeNavBarToNon3Button_shouldDisposeInputChannel() { + mGestureHandler.onOneHandedEnabled(true); + mGestureHandler.onThreeButtonModeEnabled(false); + + assertThat(mGestureHandler.mInputMonitor).isNull(); + assertThat(mGestureHandler.mInputEventReceiver).isNull(); + } +} diff --git a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedSettingsUtilTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/onehanded/OneHandedSettingsUtilTest.java index 990eb634e46f..7c11138a47aa 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedSettingsUtilTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/onehanded/OneHandedSettingsUtilTest.java @@ -14,12 +14,12 @@ * limitations under the License. */ -package com.android.systemui.onehanded; +package com.android.wm.shell.onehanded; -import static com.android.systemui.onehanded.OneHandedSettingsUtil.ONE_HANDED_TIMEOUT_LONG_IN_SECONDS; -import static com.android.systemui.onehanded.OneHandedSettingsUtil.ONE_HANDED_TIMEOUT_MEDIUM_IN_SECONDS; -import static com.android.systemui.onehanded.OneHandedSettingsUtil.ONE_HANDED_TIMEOUT_NEVER; -import static com.android.systemui.onehanded.OneHandedSettingsUtil.ONE_HANDED_TIMEOUT_SHORT_IN_SECONDS; +import static com.android.wm.shell.onehanded.OneHandedSettingsUtil.ONE_HANDED_TIMEOUT_LONG_IN_SECONDS; +import static com.android.wm.shell.onehanded.OneHandedSettingsUtil.ONE_HANDED_TIMEOUT_MEDIUM_IN_SECONDS; +import static com.android.wm.shell.onehanded.OneHandedSettingsUtil.ONE_HANDED_TIMEOUT_NEVER; +import static com.android.wm.shell.onehanded.OneHandedSettingsUtil.ONE_HANDED_TIMEOUT_SHORT_IN_SECONDS; import static com.google.common.truth.Truth.assertThat; @@ -59,24 +59,24 @@ public class OneHandedSettingsUtilTest extends OneHandedTestCase { @Test public void testRegisterSecureKeyObserver() { final Uri result = OneHandedSettingsUtil.registerSettingsKeyObserver( - Settings.Secure.ONE_HANDED_MODE_ENABLED, mContentResolver, mContentObserver); + Settings.Secure.TAPS_APP_TO_EXIT, mContentResolver, mContentObserver); assertThat(result).isNotNull(); OneHandedSettingsUtil.registerSettingsKeyObserver( - Settings.Secure.ONE_HANDED_MODE_ENABLED, mContentResolver, mContentObserver); + Settings.Secure.TAPS_APP_TO_EXIT, mContentResolver, mContentObserver); } @Test public void testUnregisterSecureKeyObserver() { OneHandedSettingsUtil.registerSettingsKeyObserver( - Settings.Secure.ONE_HANDED_MODE_ENABLED, mContentResolver, mContentObserver); + Settings.Secure.TAPS_APP_TO_EXIT, mContentResolver, mContentObserver); OneHandedSettingsUtil.unregisterSettingsKeyObserver(mContentResolver, mContentObserver); assertThat(mOnChanged).isFalse(); Settings.Secure.putInt(mContext.getContentResolver(), - Settings.Secure.ONE_HANDED_MODE_ENABLED, 0); + Settings.Secure.TAPS_APP_TO_EXIT, 0); assertThat(mOnChanged).isFalse(); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedTestCase.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/onehanded/OneHandedTestCase.java index f111c4896458..c7ae2a09ad67 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedTestCase.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/onehanded/OneHandedTestCase.java @@ -14,17 +14,21 @@ * limitations under the License. */ -package com.android.systemui.onehanded; +package com.android.wm.shell.onehanded; -import static com.android.systemui.onehanded.OneHandedController.SUPPORT_ONE_HANDED_MODE; -import static com.android.systemui.onehanded.OneHandedSettingsUtil.ONE_HANDED_TIMEOUT_MEDIUM_IN_SECONDS; +import static android.view.Display.DEFAULT_DISPLAY; + +import static com.android.wm.shell.onehanded.OneHandedController.SUPPORT_ONE_HANDED_MODE; +import static com.android.wm.shell.onehanded.OneHandedSettingsUtil.ONE_HANDED_TIMEOUT_MEDIUM_IN_SECONDS; import static org.junit.Assume.assumeTrue; +import android.content.Context; +import android.hardware.display.DisplayManager; import android.os.SystemProperties; import android.provider.Settings; -import com.android.systemui.SysuiTestCase; +import androidx.test.platform.app.InstrumentationRegistry; import org.junit.After; import org.junit.Before; @@ -32,14 +36,26 @@ import org.junit.Before; /** * Base class that does One Handed specific setup. */ -public abstract class OneHandedTestCase extends SysuiTestCase { +public abstract class OneHandedTestCase { static boolean sOrigEnabled; static boolean sOrigTapsAppToExitEnabled; static int sOrigTimeout; static boolean sOrigSwipeToNotification; + protected Context mContext; + @Before public void setupSettings() { + final Context testContext = + InstrumentationRegistry.getInstrumentation().getTargetContext(); + final DisplayManager dm = testContext.getSystemService(DisplayManager.class); + mContext = testContext.createDisplayContext(dm.getDisplay(DEFAULT_DISPLAY)); + + InstrumentationRegistry + .getInstrumentation() + .getUiAutomation() + .adoptShellPermissionIdentity(); + sOrigEnabled = OneHandedSettingsUtil.getSettingsOneHandedModeEnabled( getContext().getContentResolver()); sOrigTimeout = OneHandedSettingsUtil.getSettingsOneHandedModeTimeout( @@ -74,6 +90,15 @@ public abstract class OneHandedTestCase extends SysuiTestCase { Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, sOrigSwipeToNotification ? 1 : 0); + + InstrumentationRegistry + .getInstrumentation() + .getUiAutomation() + .dropShellPermissionIdentity(); + } + + protected Context getContext() { + return mContext; } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedTimeoutHandlerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/onehanded/OneHandedTimeoutHandlerTest.java index 7d631319ec5e..e2b70c3bcc70 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedTimeoutHandlerTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/onehanded/OneHandedTimeoutHandlerTest.java @@ -14,13 +14,13 @@ * limitations under the License. */ -package com.android.systemui.onehanded; +package com.android.wm.shell.onehanded; -import static com.android.systemui.onehanded.OneHandedSettingsUtil.ONE_HANDED_TIMEOUT_LONG_IN_SECONDS; -import static com.android.systemui.onehanded.OneHandedSettingsUtil.ONE_HANDED_TIMEOUT_MEDIUM_IN_SECONDS; -import static com.android.systemui.onehanded.OneHandedSettingsUtil.ONE_HANDED_TIMEOUT_NEVER; -import static com.android.systemui.onehanded.OneHandedSettingsUtil.ONE_HANDED_TIMEOUT_SHORT_IN_SECONDS; -import static com.android.systemui.onehanded.OneHandedTimeoutHandler.ONE_HANDED_TIMEOUT_STOP_MSG; +import static com.android.wm.shell.onehanded.OneHandedSettingsUtil.ONE_HANDED_TIMEOUT_LONG_IN_SECONDS; +import static com.android.wm.shell.onehanded.OneHandedSettingsUtil.ONE_HANDED_TIMEOUT_MEDIUM_IN_SECONDS; +import static com.android.wm.shell.onehanded.OneHandedSettingsUtil.ONE_HANDED_TIMEOUT_NEVER; +import static com.android.wm.shell.onehanded.OneHandedSettingsUtil.ONE_HANDED_TIMEOUT_SHORT_IN_SECONDS; +import static com.android.wm.shell.onehanded.OneHandedTimeoutHandler.ONE_HANDED_TIMEOUT_STOP_MSG; import static com.google.common.truth.Truth.assertThat; diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/onehanded/OneHandedTouchHandlerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/onehanded/OneHandedTouchHandlerTest.java new file mode 100644 index 000000000000..c69e385b2602 --- /dev/null +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/onehanded/OneHandedTouchHandlerTest.java @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.wm.shell.onehanded; + +import static com.google.common.truth.Truth.assertThat; + +import android.testing.AndroidTestingRunner; +import android.testing.TestableLooper; + +import androidx.test.filters.SmallTest; + +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.MockitoAnnotations; + +@SmallTest +@RunWith(AndroidTestingRunner.class) +@TestableLooper.RunWithLooper +public class OneHandedTouchHandlerTest extends OneHandedTestCase { + OneHandedTouchHandler mTouchHandler; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + mTouchHandler = new OneHandedTouchHandler(); + } + + @Test + public void testRegisterTouchEventListener() { + OneHandedTouchHandler.OneHandedTouchEventCallback callback = () -> { + }; + mTouchHandler.registerTouchEventListener(callback); + + assertThat(mTouchHandler.mTouchEventCallback).isEqualTo(callback); + } + + @Test + public void testOneHandedDisabled_shouldDisposeInputChannel() { + mTouchHandler.onOneHandedEnabled(false); + + assertThat(mTouchHandler.mInputMonitor).isNull(); + assertThat(mTouchHandler.mInputEventReceiver).isNull(); + } + + @Ignore("b/167943723, refactor it and fix it") + @Test + public void testOneHandedEnabled_monitorInputChannel() { + mTouchHandler.onOneHandedEnabled(true); + + assertThat(mTouchHandler.mInputMonitor).isNotNull(); + assertThat(mTouchHandler.mInputEventReceiver).isNotNull(); + } +}
\ No newline at end of file diff --git a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedTutorialHandlerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/onehanded/OneHandedTutorialHandlerTest.java index 8ea5524eb7e6..4a133d39291a 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedTutorialHandlerTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/onehanded/OneHandedTutorialHandlerTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.systemui.onehanded; +package com.android.wm.shell.onehanded; import static org.mockito.Mockito.verify; @@ -29,13 +29,13 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.Mockito; import org.mockito.MockitoAnnotations; @SmallTest @RunWith(AndroidTestingRunner.class) @TestableLooper.RunWithLooper public class OneHandedTutorialHandlerTest extends OneHandedTestCase { + @Mock OneHandedTouchHandler mTouchHandler; OneHandedTutorialHandler mTutorialHandler; OneHandedGestureHandler mGestureHandler; @@ -48,8 +48,7 @@ public class OneHandedTutorialHandlerTest extends OneHandedTestCase { @Before public void setUp() { MockitoAnnotations.initMocks(this); - mTouchHandler = new OneHandedTouchHandler(); - mTutorialHandler = Mockito.spy(new OneHandedTutorialHandler(mContext)); + mTutorialHandler = new OneHandedTutorialHandler(mContext); mGestureHandler = new OneHandedGestureHandler(mContext, mMockDisplayController); mOneHandedController = new OneHandedController( getContext(), diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml index 1c3fba2abacd..ab09a967bc26 100644 --- a/packages/SystemUI/res/values/config.xml +++ b/packages/SystemUI/res/values/config.xml @@ -560,9 +560,6 @@ <!-- If the config font scale is >= this value, potentially adjust the number of columns--> <item name="controls_max_columns_adjust_above_font_scale" translatable="false" format="float" type="dimen">1.25</item> - <!-- Allow one handed to enable round corner --> - <bool name="config_one_handed_enable_round_corner">true</bool> - <!-- Show a separate icon for low and high volume on the volume dialog --> <bool name="config_showLowMediaVolumeIcon">false</bool> </resources> diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 76c61fb6e1e5..875fe1471b1c 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -1366,8 +1366,4 @@ <dimen name="config_rounded_mask_size">@*android:dimen/rounded_corner_radius</dimen> <dimen name="config_rounded_mask_size_top">@*android:dimen/rounded_corner_radius_top</dimen> <dimen name="config_rounded_mask_size_bottom">@*android:dimen/rounded_corner_radius_bottom</dimen> - - <!-- One-Handed Mode --> - <!-- Threshold for dragging distance to enable one-handed mode --> - <dimen name="gestures_onehanded_drag_threshold">20dp</dimen> </resources> diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index e58bf3bad795..cca70f9aa518 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -2799,9 +2799,4 @@ <string name="udfps_hbm_enable_command" translatable="false"></string> <!-- Device-specific payload for disabling the high-brightness mode --> <string name="udfps_hbm_disable_command" translatable="false"></string> - - <!-- One-Handed Tutorial title [CHAR LIMIT=60] --> - <string name="one_handed_tutorial_title">Using one-handed mode</string> - <!-- One-Handed Tutorial description [CHAR LIMIT=NONE] --> - <string name="one_handed_tutorial_description">To exit, swipe up from the bottom of the screen or tap anywhere above the app</string> </resources> diff --git a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java index cba938f5e1a6..2a976f546ba4 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java +++ b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java @@ -75,8 +75,6 @@ import com.android.systemui.navigationbar.NavigationBar; import com.android.systemui.navigationbar.NavigationBarController; import com.android.systemui.navigationbar.NavigationBarView; import com.android.systemui.navigationbar.NavigationModeController; -import com.android.systemui.onehanded.OneHanded; -import com.android.systemui.onehanded.OneHandedEvents; import com.android.systemui.pip.Pip; import com.android.systemui.pip.PipAnimationController; import com.android.systemui.recents.OverviewProxyService.OverviewProxyListener; @@ -93,6 +91,8 @@ import com.android.systemui.statusbar.NotificationShadeWindowController; import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.phone.StatusBarWindowCallback; import com.android.systemui.statusbar.policy.CallbackController; +import com.android.wm.shell.onehanded.OneHanded; +import com.android.wm.shell.onehanded.OneHandedEvents; import com.android.wm.shell.splitscreen.SplitScreen; import java.io.FileDescriptor; diff --git a/packages/SystemUI/src/com/android/systemui/wmshell/WMShell.java b/packages/SystemUI/src/com/android/systemui/wmshell/WMShell.java index c7a9af3642e5..98c0b1e99fc4 100644 --- a/packages/SystemUI/src/com/android/systemui/wmshell/WMShell.java +++ b/packages/SystemUI/src/com/android/systemui/wmshell/WMShell.java @@ -38,10 +38,6 @@ import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.keyguard.ScreenLifecycle; import com.android.systemui.model.SysUiState; import com.android.systemui.navigationbar.NavigationModeController; -import com.android.systemui.onehanded.OneHanded; -import com.android.systemui.onehanded.OneHandedEvents; -import com.android.systemui.onehanded.OneHandedGestureHandler.OneHandedGestureEventCallback; -import com.android.systemui.onehanded.OneHandedTransitionCallback; import com.android.systemui.pip.Pip; import com.android.systemui.shared.system.ActivityManagerWrapper; import com.android.systemui.shared.system.TaskStackChangeListener; @@ -51,6 +47,10 @@ import com.android.systemui.tracing.ProtoTracer; import com.android.systemui.tracing.nano.SystemUiTraceProto; import com.android.wm.shell.common.DisplayImeController; import com.android.wm.shell.nano.WmShellTraceProto; +import com.android.wm.shell.onehanded.OneHanded; +import com.android.wm.shell.onehanded.OneHandedEvents; +import com.android.wm.shell.onehanded.OneHandedGestureHandler.OneHandedGestureEventCallback; +import com.android.wm.shell.onehanded.OneHandedTransitionCallback; import com.android.wm.shell.protolog.ShellProtoLogImpl; import com.android.wm.shell.splitscreen.SplitScreen; @@ -248,10 +248,9 @@ public final class WMShell extends SystemUI implements ProtoTraceable<SystemUiTr @Override public void setImeWindowStatus(int displayId, IBinder token, int vis, int backDisposition, boolean showImeSwitcher) { - if (displayId != DEFAULT_DISPLAY && (vis & InputMethodService.IME_VISIBLE) == 0) { - return; + if (displayId == DEFAULT_DISPLAY && (vis & InputMethodService.IME_VISIBLE) != 0) { + oneHanded.stopOneHanded(OneHandedEvents.EVENT_ONE_HANDED_TRIGGER_POP_IME_OUT); } - oneHanded.stopOneHanded(OneHandedEvents.EVENT_ONE_HANDED_TRIGGER_POP_IME_OUT); } }); diff --git a/packages/SystemUI/src/com/android/systemui/wmshell/WMShellBaseModule.java b/packages/SystemUI/src/com/android/systemui/wmshell/WMShellBaseModule.java index adb9186d6705..1f8cf95169d8 100644 --- a/packages/SystemUI/src/com/android/systemui/wmshell/WMShellBaseModule.java +++ b/packages/SystemUI/src/com/android/systemui/wmshell/WMShellBaseModule.java @@ -24,7 +24,6 @@ import android.view.IWindowManager; import com.android.internal.logging.UiEventLogger; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Main; -import com.android.systemui.onehanded.OneHanded; import com.android.systemui.pip.Pip; import com.android.systemui.pip.PipSurfaceTransactionHelper; import com.android.systemui.pip.PipUiEventLogger; @@ -36,6 +35,7 @@ import com.android.wm.shell.animation.FlingAnimationUtils; import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.SystemWindows; import com.android.wm.shell.common.TransactionPool; +import com.android.wm.shell.onehanded.OneHanded; import com.android.wm.shell.splitscreen.SplitScreen; import dagger.BindsOptionalOf; diff --git a/packages/SystemUI/src/com/android/systemui/wmshell/WMShellModule.java b/packages/SystemUI/src/com/android/systemui/wmshell/WMShellModule.java index 3a249d68d969..16fb2cacc950 100644 --- a/packages/SystemUI/src/com/android/systemui/wmshell/WMShellModule.java +++ b/packages/SystemUI/src/com/android/systemui/wmshell/WMShellModule.java @@ -24,8 +24,6 @@ import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.model.SysUiState; -import com.android.systemui.onehanded.OneHanded; -import com.android.systemui.onehanded.OneHandedController; import com.android.systemui.pip.Pip; import com.android.systemui.pip.PipBoundsHandler; import com.android.systemui.pip.PipSurfaceTransactionHelper; @@ -40,6 +38,8 @@ import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.DisplayImeController; import com.android.wm.shell.common.SystemWindows; import com.android.wm.shell.common.TransactionPool; +import com.android.wm.shell.onehanded.OneHanded; +import com.android.wm.shell.onehanded.OneHandedController; import com.android.wm.shell.splitscreen.SplitScreen; import com.android.wm.shell.splitscreen.SplitScreenController; diff --git a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedGestureHandlerTest.java b/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedGestureHandlerTest.java deleted file mode 100644 index 41af53b1c522..000000000000 --- a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedGestureHandlerTest.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2020 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.onehanded; - -import static com.google.common.truth.Truth.assertThat; - -import static org.mockito.Mockito.atLeast; -import static org.mockito.Mockito.atLeastOnce; -import static org.mockito.Mockito.verify; - -import android.testing.AndroidTestingRunner; -import android.testing.TestableLooper; - -import androidx.test.filters.SmallTest; - -import com.android.wm.shell.common.DisplayController; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; - -@SmallTest -@RunWith(AndroidTestingRunner.class) -@TestableLooper.RunWithLooper -public class OneHandedGestureHandlerTest extends OneHandedTestCase { - OneHandedTouchHandler mTouchHandler; - OneHandedTutorialHandler mTutorialHandler; - OneHandedGestureHandler mGestureHandler; - OneHandedController mOneHandedController; - @Mock - DisplayController mMockDisplayController; - @Mock - OneHandedDisplayAreaOrganizer mMockDisplayAreaOrganizer; - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - mTouchHandler = new OneHandedTouchHandler(); - mTutorialHandler = new OneHandedTutorialHandler(mContext); - mGestureHandler = Mockito.spy( - new OneHandedGestureHandler(mContext, mMockDisplayController)); - mOneHandedController = new OneHandedController( - getContext(), - mMockDisplayController, - mMockDisplayAreaOrganizer, - mTouchHandler, - mTutorialHandler, - mGestureHandler); - mOneHandedController.setThreeButtonModeEnabled(true); - } - - @Test - public void testOneHandedManager_registerForDisplayAreaOrganizer() { - verify(mMockDisplayAreaOrganizer, atLeastOnce()) - .registerTransitionCallback(mGestureHandler); - } - - @Test - public void testOneHandedManager_setGestureEventListener() { - OneHandedGestureHandler.OneHandedGestureEventCallback callback = - new OneHandedGestureHandler.OneHandedGestureEventCallback() { - @Override - public void onStart() {} - - @Override - public void onStop() {} - }; - mOneHandedController.registerGestureCallback(callback); - - verify(mGestureHandler).setGestureEventListener(callback); - assertThat(mGestureHandler.mGestureEventCallback).isEqualTo(callback); - } - - @Test - public void testReceiveNewConfig_whenSetOneHandedEnabled() { - // 1st called at init - verify(mGestureHandler, atLeastOnce()).onOneHandedEnabled(true); - mOneHandedController.setOneHandedEnabled(true); - // 2nd called by setOneHandedEnabled() - verify(mGestureHandler, atLeast(2)).onOneHandedEnabled(true); - } - - @Test - public void testOneHandedDisabled_shouldDisposeInputChannel() { - mOneHandedController.setOneHandedEnabled(false); - mOneHandedController.setSwipeToNotificationEnabled(false); - - assertThat(mGestureHandler.mInputMonitor).isNull(); - assertThat(mGestureHandler.mInputEventReceiver).isNull(); - } - - @Test - public void testChangeNavBarToNon3Button_shouldDisposeInputChannel() { - // 1st called at init - verify(mGestureHandler, atLeastOnce()).onOneHandedEnabled(true); - mOneHandedController.setOneHandedEnabled(true); - // 2nd called by setOneHandedEnabled() - verify(mGestureHandler, atLeast(2)).onOneHandedEnabled(true); - - mGestureHandler.onThreeButtonModeEnabled(false); - - assertThat(mGestureHandler.mInputMonitor).isNull(); - assertThat(mGestureHandler.mInputEventReceiver).isNull(); - } -} diff --git a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedTouchHandlerTest.java b/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedTouchHandlerTest.java deleted file mode 100644 index 1e408313a36e..000000000000 --- a/packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedTouchHandlerTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2020 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.onehanded; - -import static com.google.common.truth.Truth.assertThat; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.atLeast; -import static org.mockito.Mockito.atLeastOnce; -import static org.mockito.Mockito.verify; - -import android.testing.AndroidTestingRunner; -import android.testing.TestableLooper; - -import androidx.test.filters.SmallTest; - -import com.android.wm.shell.common.DisplayController; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; - -@SmallTest -@RunWith(AndroidTestingRunner.class) -@TestableLooper.RunWithLooper -public class OneHandedTouchHandlerTest extends OneHandedTestCase { - OneHandedTouchHandler mTouchHandler; - OneHandedTutorialHandler mTutorialHandler; - OneHandedGestureHandler mGestureHandler; - OneHandedController mOneHandedController; - @Mock - DisplayController mMockDisplayController; - @Mock - OneHandedDisplayAreaOrganizer mMockDisplayAreaOrganizer; - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - mTouchHandler = Mockito.spy(new OneHandedTouchHandler()); - mGestureHandler = new OneHandedGestureHandler(mContext, mMockDisplayController); - mOneHandedController = new OneHandedController( - getContext(), - mMockDisplayController, - mMockDisplayAreaOrganizer, - mTouchHandler, - mTutorialHandler, - mGestureHandler); - } - - @Test - public void testOneHandedManager_registerForDisplayAreaOrganizer() { - verify(mMockDisplayAreaOrganizer).registerTransitionCallback(mTouchHandler); - } - - @Test - public void testOneHandedManager_registerTouchEventListener() { - verify(mTouchHandler).registerTouchEventListener(any()); - assertThat(mTouchHandler.mTouchEventCallback).isNotNull(); - } - - @Test - public void testOneHandedDisabled_shouldDisposeInputChannel() { - mOneHandedController.setOneHandedEnabled(false); - assertThat(mTouchHandler.mInputMonitor).isNull(); - assertThat(mTouchHandler.mInputEventReceiver).isNull(); - } - - @Test - public void testOneHandedEnabled_monitorInputChannel() { - mOneHandedController.setOneHandedEnabled(true); - assertThat(mTouchHandler.mInputMonitor).isNotNull(); - assertThat(mTouchHandler.mInputEventReceiver).isNotNull(); - } - - @Test - public void testReceiveNewConfig_whenSetOneHandedEnabled() { - // Called at init - verify(mTouchHandler, atLeastOnce()).onOneHandedEnabled(true); - mOneHandedController.setOneHandedEnabled(true); - // Called by setOneHandedEnabled() - verify(mTouchHandler, atLeast(2)).onOneHandedEnabled(true); - } -} diff --git a/packages/SystemUI/tests/src/com/android/systemui/wmshell/WMShellTest.java b/packages/SystemUI/tests/src/com/android/systemui/wmshell/WMShellTest.java index 51cc5f175444..bcc36396e1d8 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/wmshell/WMShellTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/wmshell/WMShellTest.java @@ -30,15 +30,15 @@ import com.android.systemui.SysuiTestCase; import com.android.systemui.keyguard.ScreenLifecycle; import com.android.systemui.model.SysUiState; import com.android.systemui.navigationbar.NavigationModeController; -import com.android.systemui.onehanded.OneHanded; -import com.android.systemui.onehanded.OneHandedGestureHandler; -import com.android.systemui.onehanded.OneHandedTransitionCallback; import com.android.systemui.pip.Pip; import com.android.systemui.shared.system.ActivityManagerWrapper; import com.android.systemui.shared.system.TaskStackChangeListener; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.tracing.ProtoTracer; import com.android.wm.shell.common.DisplayImeController; +import com.android.wm.shell.onehanded.OneHanded; +import com.android.wm.shell.onehanded.OneHandedGestureHandler; +import com.android.wm.shell.onehanded.OneHandedTransitionCallback; import com.android.wm.shell.splitscreen.SplitScreen; import org.junit.Before; |