Revert "Update state and touch region after one handed overlay changed"

This reverts commit a66dafe617f6d200697a9129b1b322d88490b777.

Reason for revert: b/159183864 introduce com.android.launcher3.memory.MemoryTests failed after this CL merged.

Due to I need more time to investigate the root cause and do not block MemoryTests, revert this CL temporary. 

Change-Id: I0408123e36c55a262ee0f1080cd6612785b3f527
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
index 901c981..a696c21 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
@@ -58,7 +58,6 @@
 
 import com.android.launcher3.BaseDraggingActivity;
 import com.android.launcher3.R;
-import com.android.launcher3.ResourceUtils;
 import com.android.launcher3.Utilities;
 import com.android.launcher3.config.FeatureFlags;
 import com.android.launcher3.logging.UserEventDispatcher;
@@ -299,7 +298,6 @@
         mAM = ActivityManagerWrapper.getInstance();
         mDeviceState = new RecentsAnimationDeviceState(this);
         mDeviceState.addNavigationModeChangedCallback(this::onNavigationModeChanged);
-        mDeviceState.addOneHandedModeChangedCallback(this::onOneHandedModeOverlayChanged);
         mDeviceState.runOnUserUnlocked(this::onUserUnlocked);
         ProtoTracer.INSTANCE.get(this).add(this);
 
@@ -340,13 +338,6 @@
         resetHomeBounceSeenOnQuickstepEnabledFirstTime();
     }
 
-    /**
-     * Called when the one handed mode overlay package changes, to recreate touch region.
-     */
-    private void onOneHandedModeOverlayChanged(int newGesturalHeight) {
-        initInputMonitor();
-    }
-
     @UiThread
     public void onUserUnlocked() {
         mTaskAnimationManager = new TaskAnimationManager();
@@ -820,13 +811,6 @@
         }
         if (mOverviewComponentObserver.canHandleConfigChanges(activity.getComponentName(),
                 activity.getResources().getConfiguration().diff(newConfig))) {
-            // Since navBar gestural height are different between portrait and landscape,
-            // can handle orientation changes and refresh navigation gestural region through
-            // onOneHandedModeChanged()
-            int newGesturalHeight = ResourceUtils.getNavbarSize(
-                    ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE,
-                    getApplicationContext().getResources());
-            mDeviceState.onOneHandedModeChanged(newGesturalHeight);
             return;
         }
 
diff --git a/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java b/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java
index 5dcdd7a..b49bc5a 100644
--- a/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java
+++ b/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java
@@ -65,7 +65,6 @@
     private final RectF mAssistantRightRegion = new RectF();
     private final RectF mOneHandedModeRegion = new RectF();
     private int mCurrentDisplayRotation;
-    private int mNavBarGesturalHeight;
     private boolean mEnableMultipleRegions;
     private Resources mResources;
     private OrientationRectF mLastRectTouched;
@@ -105,33 +104,18 @@
         mResources = resources;
         mMode = mode;
         mContractInfo = contractInfo;
-        mNavBarGesturalHeight = getNavbarSize(ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE);
     }
 
-    private void refreshTouchRegion(DefaultDisplay.Info info, Resources newRes) {
-        // Swipe touch regions are independent of nav mode, so we have to clear them explicitly
-        // here to avoid, for ex, a nav region for 2-button rotation 0 being used for 3-button mode
-        // It tries to cache and reuse swipe regions whenever possible based only on rotation
-        mResources = newRes;
-        mSwipeTouchRegions.clear();
-        resetSwipeRegions(info);
-    }
-
-    void setNavigationMode(SysUINavigationMode.Mode newMode, DefaultDisplay.Info info,
-            Resources newRes) {
+    void setNavigationMode(SysUINavigationMode.Mode newMode, DefaultDisplay.Info info) {
         if (mMode == newMode) {
             return;
         }
         this.mMode = newMode;
-        refreshTouchRegion(info, newRes);
-    }
-
-    void setGesturalHeight(int newGesturalHeight, DefaultDisplay.Info info, Resources newRes) {
-        if (mNavBarGesturalHeight == newGesturalHeight) {
-            return;
-        }
-        mNavBarGesturalHeight = newGesturalHeight;
-        refreshTouchRegion(info, newRes);
+        // Swipe touch regions are independent of nav mode, so we have to clear them explicitly
+        // here to avoid, for ex, a nav region for 2-button rotation 0 being used for 3-button mode
+        // It tries to cache and reuse swipe regions whenever possible based only on rotation
+        mSwipeTouchRegions.clear();
+        resetSwipeRegions(info);
     }
 
     /**
@@ -213,7 +197,7 @@
 
         Point size = display.realSize;
         int rotation = display.rotation;
-        int touchHeight = mNavBarGesturalHeight;
+        int touchHeight = getNavbarSize(ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE);
         OrientationRectF orientationRectF =
                 new OrientationRectF(0, 0, size.x, size.y, rotation);
         if (mMode == SysUINavigationMode.Mode.NO_BUTTON) {
@@ -354,7 +338,6 @@
             regions.append(rectF.mRotation).append(" ");
         }
         pw.println(regions.toString());
-        pw.println("  mNavBarGesturalHeight=" + mNavBarGesturalHeight);
         pw.println("  mOneHandedModeRegion=" + mOneHandedModeRegion);
     }
 
diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
index 8a1c30f..04aba22 100644
--- a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
+++ b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
@@ -52,8 +52,8 @@
 import android.text.TextUtils;
 import android.util.DisplayMetrics;
 import android.view.MotionEvent;
-import android.view.OrientationEventListener;
 import android.view.Surface;
+import android.view.OrientationEventListener;
 
 import androidx.annotation.BinderThread;
 
@@ -63,7 +63,6 @@
 import com.android.launcher3.util.DefaultDisplay;
 import com.android.launcher3.util.SecureSettingsObserver;
 import com.android.quickstep.SysUINavigationMode.NavigationModeChangeListener;
-import com.android.quickstep.SysUINavigationMode.OneHandedModeChangeListener;
 import com.android.quickstep.util.NavBarPosition;
 import com.android.quickstep.util.RecentsOrientedState;
 import com.android.systemui.shared.system.ActivityManagerWrapper;
@@ -82,8 +81,7 @@
  */
 public class RecentsAnimationDeviceState implements
         NavigationModeChangeListener,
-        DefaultDisplay.DisplayInfoChangeListener,
-        OneHandedModeChangeListener {
+        DefaultDisplay.DisplayInfoChangeListener {
 
     private final Context mContext;
     private final SysUINavigationMode mSysUiNavMode;
@@ -312,15 +310,6 @@
         runOnDestroy(() -> mSysUiNavMode.removeModeChangeListener(listener));
     }
 
-    /**
-     * Adds a listener for the one handed mode change,
-     * guaranteed to be called after the device state's mode has changed.
-     */
-    public void addOneHandedModeChangedCallback(OneHandedModeChangeListener listener) {
-        listener.onOneHandedModeChanged(mSysUiNavMode.addOneHandedOverlayChangeListener(listener));
-        runOnDestroy(() -> mSysUiNavMode.removeOneHandedOverlayChangeListener(listener));
-    }
-
     @Override
     public void onNavigationModeChanged(SysUINavigationMode.Mode newMode) {
         mDefaultDisplay.removeChangeListener(this);
@@ -335,8 +324,7 @@
 
         mNavBarPosition = new NavBarPosition(newMode, mDefaultDisplay.getInfo());
 
-        mOrientationTouchTransformer.setNavigationMode(newMode, mDefaultDisplay.getInfo(),
-                mContext.getApplicationContext().getResources());
+        mOrientationTouchTransformer.setNavigationMode(newMode, mDefaultDisplay.getInfo());
         if (!mMode.hasGestures && newMode.hasGestures) {
             setupOrientationSwipeHandler();
         } else if (mMode.hasGestures && !newMode.hasGestures){
@@ -375,12 +363,6 @@
         }
     }
 
-    @Override
-    public void onOneHandedModeChanged(int newGesturalHeight) {
-        mOrientationTouchTransformer.setGesturalHeight(newGesturalHeight, mDefaultDisplay.getInfo(),
-                mContext.getApplicationContext().getResources());
-    }
-
     /**
      * @return the current navigation mode for the device.
      */
diff --git a/quickstep/src/com/android/quickstep/SysUINavigationMode.java b/quickstep/src/com/android/quickstep/SysUINavigationMode.java
index 26c72a2..05ce2a2 100644
--- a/quickstep/src/com/android/quickstep/SysUINavigationMode.java
+++ b/quickstep/src/com/android/quickstep/SysUINavigationMode.java
@@ -24,7 +24,6 @@
 import android.content.res.Resources;
 import android.util.Log;
 
-import com.android.launcher3.ResourceUtils;
 import com.android.launcher3.touch.PagedOrientationHandler;
 import com.android.launcher3.util.MainThreadInitializedObject;
 
@@ -63,20 +62,11 @@
     private static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
     private static final String NAV_BAR_INTERACTION_MODE_RES_NAME =
             "config_navBarInteractionMode";
-    private static final String NAV_BAR_INTERACTION_MODE_OVERLAY_PACKAGE_PREFIX =
-            "com.android.internal.systemui.navbar";
-    private static final String ONE_HANDED_MODE_OVERLAY_PACKAGE_PREFIX =
-            "com.android.internal.systemui.onehanded";
-    private static final int INVALID_RESOURCE_HANDLE = -1;
 
     private final Context mContext;
     private Mode mMode;
 
-    private int mNavBarGesturalHeight;
-
     private final List<NavigationModeChangeListener> mChangeListeners = new ArrayList<>();
-    private final List<OneHandedModeChangeListener> mOneHandedOverlayChangeListeners =
-            new ArrayList<>();
 
     public SysUINavigationMode(Context context) {
         mContext = context;
@@ -87,15 +77,7 @@
             public void onReceive(Context context, Intent intent) {
                 updateMode();
             }
-        }, getPackageFilter(NAV_BAR_INTERACTION_MODE_OVERLAY_PACKAGE_PREFIX,
-                ACTION_OVERLAY_CHANGED));
-
-        mContext.registerReceiver(new BroadcastReceiver() {
-            @Override
-            public void onReceive(Context context, Intent intent) {
-                updateGesturalHeight();
-            }
-        }, getPackageFilter(ONE_HANDED_MODE_OVERLAY_PACKAGE_PREFIX, ACTION_OVERLAY_CHANGED));
+        }, getPackageFilter("android", ACTION_OVERLAY_CHANGED));
     }
 
     /** Updates navigation mode when needed. */
@@ -107,24 +89,8 @@
         }
     }
 
-    private void updateGesturalHeight() {
-        int newGesturalHeight = getSystemIntegerRes(mContext,
-                ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE);
-
-        if (newGesturalHeight == INVALID_RESOURCE_HANDLE) {
-            return;
-        }
-
-        if (mNavBarGesturalHeight != newGesturalHeight) {
-            mNavBarGesturalHeight = newGesturalHeight;
-            dispatchOneHandedOverlayChange();
-        }
-    }
-
     private void initializeMode() {
         int modeInt = getSystemIntegerRes(mContext, NAV_BAR_INTERACTION_MODE_RES_NAME);
-        mNavBarGesturalHeight = getSystemIntegerRes(mContext,
-                ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE);
         for(Mode m : Mode.values()) {
             if (m.resValue == modeInt) {
                 mMode = m;
@@ -138,12 +104,6 @@
         }
     }
 
-    private void dispatchOneHandedOverlayChange() {
-        for (OneHandedModeChangeListener listener : mOneHandedOverlayChangeListeners) {
-            listener.onOneHandedModeChanged(mNavBarGesturalHeight);
-        }
-    }
-
     public Mode addModeChangeListener(NavigationModeChangeListener listener) {
         mChangeListeners.add(listener);
         return mMode;
@@ -153,15 +113,6 @@
         mChangeListeners.remove(listener);
     }
 
-    public int addOneHandedOverlayChangeListener(OneHandedModeChangeListener listener) {
-        mOneHandedOverlayChangeListeners.add(listener);
-        return mNavBarGesturalHeight;
-    }
-
-    public void removeOneHandedOverlayChangeListener(OneHandedModeChangeListener listener) {
-        mOneHandedOverlayChangeListeners.remove(listener);
-    }
-
     public Mode getMode() {
         return mMode;
     }
@@ -174,7 +125,7 @@
             return res.getInteger(resId);
         } else {
             Log.e(TAG, "Failed to get system resource ID. Incompatible framework version?");
-            return INVALID_RESOURCE_HANDLE;
+            return -1;
         }
     }
 
@@ -199,9 +150,4 @@
 
         void onNavigationModeChanged(Mode newMode);
     }
-
-    public interface OneHandedModeChangeListener {
-
-        void onOneHandedModeChanged(int newGesturalHeight);
-    }
 }
\ No newline at end of file