From acf0a5da0bcb0c1d0ce918699a764c3b256b496e Mon Sep 17 00:00:00 2001 From: Samuel Fufa Date: Wed, 4 Mar 2020 14:46:47 -0800 Subject: [PATCH 1/2] [DO NOT MERGE] Prevent hotseat touch hijack Currently in AllAppsContinerView#onInterceptTouchEvent we check if a touch event is in bounds of RecyclerViewFastScroller and set mTouchHandler so the scroll bar handles onTouchEvent. However, if a user performs a back gesture from the right side (which overlaps with the scroller) and returns home, touches to the hotseat get intercepted. Bug: 148639821 Test: Manual Change-Id: Ie44f3a16b628b12ad00a7ae6c6bc5703171fbb56 --- .../allapps/AllAppsContainerView.java | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index 37ee24850e..2d5b04058c 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -26,14 +26,18 @@ import android.os.Process; import android.text.Selection; import android.text.SpannableStringBuilder; import android.util.AttributeSet; -import android.util.Log; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.WindowInsets; - +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.StringRes; +import androidx.dynamicanimation.animation.DynamicAnimation; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import com.android.launcher3.AppInfo; import com.android.launcher3.DeviceProfile; import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener; @@ -45,11 +49,11 @@ import com.android.launcher3.ItemInfo; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; import com.android.launcher3.R; -import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.Utilities; import com.android.launcher3.compat.AccessibilityManagerCompat; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.keyboard.FocusedItemDecorator; +import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; import com.android.launcher3.userevent.nano.LauncherLogProto.Target; import com.android.launcher3.util.ItemInfoMatcher; @@ -60,13 +64,6 @@ import com.android.launcher3.views.BottomUserEducationView; import com.android.launcher3.views.RecyclerViewFastScroller; import com.android.launcher3.views.SpringRelativeLayout; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.annotation.StringRes; -import androidx.dynamicanimation.animation.DynamicAnimation; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - /** * The all apps view container. */ @@ -200,7 +197,10 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo // The AllAppsContainerView houses the QSB and is hence visible from the Workspace // Overview states. We shouldn't intercept for the scrubber in these cases. - if (!mLauncher.isInState(LauncherState.ALL_APPS)) return false; + if (!mLauncher.isInState(LauncherState.ALL_APPS)) { + mTouchHandler = null; + return false; + } if (ev.getAction() == MotionEvent.ACTION_DOWN) { AllAppsRecyclerView rv = getActiveRecyclerView(); @@ -219,6 +219,16 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo @Override public boolean onTouchEvent(MotionEvent ev) { + if (ev.getAction() == MotionEvent.ACTION_DOWN) { + AllAppsRecyclerView rv = getActiveRecyclerView(); + if (rv != null && rv.getScrollbar() + .isHitInParent(ev.getX(), ev.getY(), mFastScrollerOffset)) { + mTouchHandler = rv.getScrollbar(); + } else { + mTouchHandler = null; + } + } + if (mTouchHandler != null) { mTouchHandler.handleTouchEvent(ev, mFastScrollerOffset); return true; From 38d2e3086ce3a6636bd7647c170d51e04a56186a Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Thu, 5 Mar 2020 18:04:41 +0000 Subject: [PATCH 2/2] Revert "Fixed portrait orientation if fixed_rotation flag" This reverts commit e1aff298891495a422d3595f90749a457e7c4ae6. Reason for revert: An equivalent change was made in ub-launcher3-master with slight variations, causing conflicts when merging from there to platform master. Once this is reverted, conflicts should go away and the new solution should be good to go. Change-Id: I19ba4af5f1e5f089fb771ada8b20c28a4b09b68c --- src/com/android/launcher3/PagedView.java | 23 ++----------------- src/com/android/launcher3/Utilities.java | 9 -------- .../launcher3/states/RotationHelper.java | 6 +---- 3 files changed, 3 insertions(+), 35 deletions(-) diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index 66dba98e0f..4c6e1f3ebc 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -20,15 +20,12 @@ import static com.android.launcher3.compat.AccessibilityManagerCompat.isAccessib import static com.android.launcher3.compat.AccessibilityManagerCompat.isObservedEventType; import static com.android.launcher3.config.FeatureFlags.QUICKSTEP_SPRINGS; import static com.android.launcher3.touch.OverScroll.OVERSCROLL_DAMP_FACTOR; -import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import android.animation.LayoutTransition; import android.animation.TimeInterpolator; import android.annotation.SuppressLint; -import android.content.ContentResolver; import android.content.Context; import android.content.res.TypedArray; -import android.database.ContentObserver; import android.graphics.Canvas; import android.graphics.Rect; import android.os.Bundle; @@ -67,9 +64,6 @@ public abstract class PagedView extends ViewGrou private static final String TAG = "PagedView"; private static final boolean DEBUG = false; - public static boolean sFlagForcedRotation = false; - public static final String FIXED_ROTATION_TRANSFORM_SETTING_NAME = "fixed_rotation_transform"; - public static final int INVALID_PAGE = -1; protected static final ComputePageScrollsLogic SIMPLE_SCROLL_LOGIC = (v) -> v.getVisibility() != GONE; @@ -172,12 +166,11 @@ public abstract class PagedView extends ViewGrou * Initializes various states for this workspace. */ protected void init() { - Context context = getContext(); - mScroller = new OverScroller(context); + mScroller = new OverScroller(getContext()); setDefaultInterpolator(Interpolators.SCROLL); mCurrentPage = 0; - final ViewConfiguration configuration = ViewConfiguration.get(context); + final ViewConfiguration configuration = ViewConfiguration.get(getContext()); mTouchSlop = configuration.getScaledPagingTouchSlop(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); @@ -189,18 +182,6 @@ public abstract class PagedView extends ViewGrou if (Utilities.ATLEAST_OREO) { setDefaultFocusHighlightEnabled(false); } - - sFlagForcedRotation = Utilities.isFixedRotationTransformEnabled(context); - final ContentResolver resolver = context.getContentResolver(); - final ContentObserver observer = new ContentObserver(MAIN_EXECUTOR.getHandler()) { - @Override - public void onChange(boolean selfChange) { - sFlagForcedRotation = Utilities.isFixedRotationTransformEnabled(context); - } - }; - resolver.registerContentObserver(Settings.Global.getUriFor( - FIXED_ROTATION_TRANSFORM_SETTING_NAME), - false, observer); } protected void setDefaultInterpolator(Interpolator interpolator) { diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index 571f745080..e0e4cc0ce4 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -17,7 +17,6 @@ package com.android.launcher3; import static com.android.launcher3.ItemInfoWithIcon.FLAG_ICON_BADGED; -import static com.android.launcher3.PagedView.FIXED_ROTATION_TRANSFORM_SETTING_NAME; import android.animation.ValueAnimator; import android.annotation.TargetApi; @@ -128,14 +127,6 @@ public final class Utilities { Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0; } - /** - * Checks whether the fixed_rotation_flag is enabled. - */ - public static boolean isFixedRotationTransformEnabled(Context context) { - return Settings.Global.getInt(context.getContentResolver(), - FIXED_ROTATION_TRANSFORM_SETTING_NAME, 0) != 0; - } - // An intent extra to indicate the horizontal scroll of the wallpaper. public static final String EXTRA_WALLPAPER_OFFSET = "com.android.launcher3.WALLPAPER_OFFSET"; public static final String EXTRA_WALLPAPER_FLAVOR = "com.android.launcher3.WALLPAPER_FLAVOR"; diff --git a/src/com/android/launcher3/states/RotationHelper.java b/src/com/android/launcher3/states/RotationHelper.java index 3a64f9aeb8..852928b416 100644 --- a/src/com/android/launcher3/states/RotationHelper.java +++ b/src/com/android/launcher3/states/RotationHelper.java @@ -17,7 +17,6 @@ package com.android.launcher3.states; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LOCKED; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; -import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; import static android.util.DisplayMetrics.DENSITY_DEVICE_STABLE; @@ -27,7 +26,6 @@ import android.content.res.Resources; import android.view.WindowManager; import com.android.launcher3.Launcher; -import com.android.launcher3.PagedView; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.config.FeatureFlags; @@ -184,9 +182,7 @@ public class RotationHelper implements OnSharedPreferenceChangeListener { } final int activityFlags; - if (PagedView.sFlagForcedRotation) { - activityFlags = SCREEN_ORIENTATION_PORTRAIT; - } else if (mStateHandlerRequest != REQUEST_NONE) { + if (mStateHandlerRequest != REQUEST_NONE) { activityFlags = mStateHandlerRequest == REQUEST_LOCK ? SCREEN_ORIENTATION_LOCKED : SCREEN_ORIENTATION_UNSPECIFIED; } else if (mCurrentTransitionRequest != REQUEST_NONE) {