Merge "Refactor app open code."
diff --git a/quickstep/AndroidManifest.xml b/quickstep/AndroidManifest.xml
index 4e7c3fa..8dab915 100644
--- a/quickstep/AndroidManifest.xml
+++ b/quickstep/AndroidManifest.xml
@@ -27,6 +27,7 @@
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
android:protectionLevel="signatureOrSystem" />
+ <uses-permission android:name="android.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS" />
<uses-permission android:name="android.permission.CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
diff --git a/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java b/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java
index eb33f98..b258a10 100644
--- a/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java
+++ b/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java
@@ -66,6 +66,7 @@
private final RectF mOneHandedModeRegion = new RectF();
private int mCurrentDisplayRotation;
private int mNavBarGesturalHeight;
+ private int mNavBarLargerGesturalHeight;
private boolean mEnableMultipleRegions;
private Resources mResources;
private OrientationRectF mLastRectTouched;
@@ -106,6 +107,9 @@
mMode = mode;
mContractInfo = contractInfo;
mNavBarGesturalHeight = getNavbarSize(ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE);
+ mNavBarLargerGesturalHeight = ResourceUtils.getDimenByName(
+ ResourceUtils.NAVBAR_BOTTOM_GESTURE_LARGER_SIZE, resources,
+ mNavBarGesturalHeight);
}
private void refreshTouchRegion(Info info, Resources newRes) {
@@ -234,6 +238,7 @@
Point size = display.realSize;
int rotation = display.rotation;
int touchHeight = mNavBarGesturalHeight;
+ int largerGesturalHeight = mNavBarLargerGesturalHeight;
OrientationRectF orientationRectF =
new OrientationRectF(0, 0, size.x, size.y, rotation);
if (mMode == SysUINavigationMode.Mode.NO_BUTTON) {
@@ -256,7 +261,8 @@
}
}
// One handed gestural only active on portrait mode
- mOneHandedModeRegion.set(0, orientationRectF.bottom - touchHeight, size.x, size.y);
+ mOneHandedModeRegion.set(0, orientationRectF.bottom - mNavBarLargerGesturalHeight,
+ size.x, size.y);
return orientationRectF;
}
@@ -378,6 +384,7 @@
}
pw.println(regions.toString());
pw.println(" mNavBarGesturalHeight=" + mNavBarGesturalHeight);
+ pw.println(" mNavBarLargerGesturalHeight=" + mNavBarLargerGesturalHeight);
pw.println(" mOneHandedModeRegion=" + mOneHandedModeRegion);
}
diff --git a/quickstep/src/com/android/quickstep/OverviewComponentObserver.java b/quickstep/src/com/android/quickstep/OverviewComponentObserver.java
index 49feef0..7bf7712 100644
--- a/quickstep/src/com/android/quickstep/OverviewComponentObserver.java
+++ b/quickstep/src/com/android/quickstep/OverviewComponentObserver.java
@@ -23,7 +23,6 @@
import static com.android.launcher3.config.FeatureFlags.SEPARATE_RECENTS_ACTIVITY;
import static com.android.launcher3.util.PackageManagerHelper.getPackageFilter;
import static com.android.systemui.shared.system.PackageManagerWrapper.ACTION_PREFERRED_ACTIVITY_CHANGED;
-import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_ASSIST_GESTURE_CONSTRAINED;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
@@ -119,10 +118,6 @@
updateOverviewTargets();
}
- public boolean assistantGestureIsConstrained() {
- return (mDeviceState.getSystemUiStateFlags() & SYSUI_STATE_ASSIST_GESTURE_CONSTRAINED) != 0;
- }
-
/**
* Update overview intent and {@link BaseActivityInterface} based off the current launcher home
* component.
diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
index 960abeb..74b56e9 100644
--- a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
+++ b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
@@ -23,6 +23,7 @@
import static com.android.quickstep.SysUINavigationMode.Mode.THREE_BUTTONS;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_A11Y_BUTTON_CLICKABLE;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE;
+import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_ASSIST_GESTURE_CONSTRAINED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BUBBLES_EXPANDED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_GLOBAL_ACTIONS_SHOWING;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_HOME_DISABLED;
@@ -373,7 +374,7 @@
* @return the system ui state flags.
*/
// TODO(141886704): See if we can remove this
- public @SystemUiStateFlags int getSystemUiStateFlags() {
+ public int getSystemUiStateFlags() {
return mSystemUiStateFlags;
}
@@ -406,6 +407,13 @@
}
/**
+ * @return whether assistant gesture is constraint
+ */
+ public boolean isAssistantGestureIsConstrained() {
+ return (mSystemUiStateFlags & SYSUI_STATE_ASSIST_GESTURE_CONSTRAINED) != 0;
+ }
+
+ /**
* @return whether the bubble stack is expanded
*/
public boolean isBubblesExpanded() {
diff --git a/quickstep/src/com/android/quickstep/SysUINavigationMode.java b/quickstep/src/com/android/quickstep/SysUINavigationMode.java
index 71bf1bb..efec037 100644
--- a/quickstep/src/com/android/quickstep/SysUINavigationMode.java
+++ b/quickstep/src/com/android/quickstep/SysUINavigationMode.java
@@ -73,6 +73,7 @@
private Mode mMode;
private int mNavBarGesturalHeight;
+ private int mNavBarLargerGesturalHeight;
private final List<NavigationModeChangeListener> mChangeListeners = new ArrayList<>();
private final List<OneHandedModeChangeListener> mOneHandedOverlayChangeListeners =
@@ -112,6 +113,17 @@
if (mNavBarGesturalHeight != newGesturalHeight) {
mNavBarGesturalHeight = newGesturalHeight;
+ }
+
+ int newLargerGesturalHeight = ResourceUtils.getDimenByName(
+ ResourceUtils.NAVBAR_BOTTOM_GESTURE_LARGER_SIZE, mContext.getResources(),
+ INVALID_RESOURCE_HANDLE);
+ if (newLargerGesturalHeight == INVALID_RESOURCE_HANDLE) {
+ Log.e(TAG, "Failed to get system resource ID. Incompatible framework version?");
+ return;
+ }
+ if (mNavBarLargerGesturalHeight != newLargerGesturalHeight) {
+ mNavBarLargerGesturalHeight = newLargerGesturalHeight;
dispatchOneHandedOverlayChange();
}
}
@@ -122,6 +134,9 @@
mNavBarGesturalHeight = ResourceUtils.getDimenByName(
ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, mContext.getResources(),
INVALID_RESOURCE_HANDLE);
+ mNavBarLargerGesturalHeight = ResourceUtils.getDimenByName(
+ ResourceUtils.NAVBAR_BOTTOM_GESTURE_LARGER_SIZE, mContext.getResources(),
+ mNavBarGesturalHeight);
if (modeInt == INVALID_RESOURCE_HANDLE) {
Log.e(TAG, "Failed to get system resource ID. Incompatible framework version?");
@@ -143,7 +158,7 @@
private void dispatchOneHandedOverlayChange() {
for (OneHandedModeChangeListener listener : mOneHandedOverlayChangeListeners) {
- listener.onOneHandedModeChanged(mNavBarGesturalHeight);
+ listener.onOneHandedModeChanged(mNavBarLargerGesturalHeight);
}
}
@@ -158,7 +173,7 @@
public int addOneHandedOverlayChangeListener(OneHandedModeChangeListener listener) {
mOneHandedOverlayChangeListeners.add(listener);
- return mNavBarGesturalHeight;
+ return mNavBarLargerGesturalHeight;
}
public void removeOneHandedOverlayChangeListener(OneHandedModeChangeListener listener) {
@@ -182,4 +197,4 @@
public interface OneHandedModeChangeListener {
void onOneHandedModeChanged(int newGesturalHeight);
}
-}
\ No newline at end of file
+}
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index 1e0a00a..e59035c 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -466,7 +466,8 @@
this,
mGestureState,
InputConsumer.NO_OP, mInputMonitorCompat,
- mOverviewComponentObserver.assistantGestureIsConstrained());
+ mDeviceState,
+ event);
} else if (mDeviceState.canTriggerOneHandedAction(event)
&& !mDeviceState.isOneHandedModeActive()) {
// Consume gesture event for triggering one handed feature.
@@ -563,12 +564,8 @@
}
if (mDeviceState.isFullyGesturalNavMode()) {
if (mDeviceState.canTriggerAssistantAction(event, newGestureState.getRunningTask())) {
- base = new AssistantInputConsumer(
- this,
- newGestureState,
- base,
- mInputMonitorCompat,
- mOverviewComponentObserver.assistantGestureIsConstrained());
+ base = new AssistantInputConsumer(this, newGestureState, base, mInputMonitorCompat,
+ mDeviceState, event);
}
if (FeatureFlags.ENABLE_QUICK_CAPTURE_GESTURE.get()) {
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/AssistantInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/AssistantInputConsumer.java
index 580e4ec..a3cd7df 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/AssistantInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/AssistantInputConsumer.java
@@ -44,9 +44,12 @@
import com.android.quickstep.BaseActivityInterface;
import com.android.quickstep.GestureState;
import com.android.quickstep.InputConsumer;
+import com.android.quickstep.RecentsAnimationDeviceState;
import com.android.quickstep.SystemUiProxy;
import com.android.systemui.shared.system.InputMonitorCompat;
+import java.util.function.Consumer;
+
/**
* Touch consumer for handling events to launch assistant from launcher
*/
@@ -81,19 +84,18 @@
private final int mAngleThreshold;
private final float mSquaredSlop;
private final Context mContext;
- private final GestureDetector mGestureDetector;
- private final boolean mIsAssistGestureConstrained;
+ private final Consumer<MotionEvent> mGestureDetector;
public AssistantInputConsumer(
Context context,
GestureState gestureState,
InputConsumer delegate,
InputMonitorCompat inputMonitor,
- boolean isAssistGestureConstrained) {
+ RecentsAnimationDeviceState deviceState,
+ MotionEvent startEvent) {
super(delegate, inputMonitor);
final Resources res = context.getResources();
mContext = context;
- mIsAssistGestureConstrained = isAssistGestureConstrained;
mDragDistThreshold = res.getDimension(R.dimen.gestures_assistant_drag_threshold);
mFlingDistThreshold = res.getDimension(R.dimen.gestures_assistant_fling_threshold);
mTimeThreshold = res.getInteger(R.integer.assistant_gesture_min_time_threshold);
@@ -104,7 +106,11 @@
mSquaredSlop = slop * slop;
mActivityInterface = gestureState.getActivityInterface();
- mGestureDetector = new GestureDetector(context, new AssistantGestureListener());
+ boolean flingDisabled = deviceState.isAssistantGestureIsConstrained()
+ || deviceState.isInDeferredGestureRegion(startEvent);
+ mGestureDetector = flingDisabled
+ ? ev -> { }
+ : new GestureDetector(context, new AssistantGestureListener())::onTouchEvent;
}
@Override
@@ -201,7 +207,7 @@
break;
}
- mGestureDetector.onTouchEvent(ev);
+ mGestureDetector.accept(ev);
if (mState != STATE_ACTIVE) {
mDelegate.onMotionEvent(ev);
@@ -214,12 +220,6 @@
if (mDistance >= mDragDistThreshold && mTimeFraction >= 1) {
SystemUiProxy.INSTANCE.get(mContext).onAssistantGestureCompletion(0);
startAssistantInternal();
-
- Bundle args = new Bundle();
- args.putInt(OPA_BUNDLE_TRIGGER, OPA_BUNDLE_TRIGGER_DIAG_SWIPE_GESTURE);
- args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE);
- SystemUiProxy.INSTANCE.get(mContext).startAssistant(args);
- mLaunchedAssistant = true;
} else {
SystemUiProxy.INSTANCE.get(mContext).onAssistantProgress(mLastProgress);
}
@@ -233,6 +233,12 @@
13, // HapticFeedbackConstants.GESTURE_END
HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
}
+
+ Bundle args = new Bundle();
+ args.putInt(OPA_BUNDLE_TRIGGER, OPA_BUNDLE_TRIGGER_DIAG_SWIPE_GESTURE);
+ args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE);
+ SystemUiProxy.INSTANCE.get(mContext).startAssistant(args);
+ mLaunchedAssistant = true;
}
/**
@@ -250,8 +256,7 @@
private class AssistantGestureListener extends SimpleOnGestureListener {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
- if (!mIsAssistGestureConstrained
- && isValidAssistantGestureAngle(velocityX, -velocityY)
+ if (isValidAssistantGestureAngle(velocityX, -velocityY)
&& mDistance >= mFlingDistThreshold
&& !mLaunchedAssistant
&& mState != STATE_DELEGATE_ACTIVE) {
@@ -259,11 +264,6 @@
SystemUiProxy.INSTANCE.get(mContext).onAssistantGestureCompletion(
(float) Math.sqrt(velocityX * velocityX + velocityY * velocityY));
startAssistantInternal();
-
- Bundle args = new Bundle();
- args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE);
- SystemUiProxy.INSTANCE.get(mContext).startAssistant(args);
- mLaunchedAssistant = true;
}
return true;
}
diff --git a/src/com/android/launcher3/ResourceUtils.java b/src/com/android/launcher3/ResourceUtils.java
index c9fb75a..f60e1f8 100644
--- a/src/com/android/launcher3/ResourceUtils.java
+++ b/src/com/android/launcher3/ResourceUtils.java
@@ -25,6 +25,8 @@
public static final int INVALID_RESOURCE_HANDLE = -1;
public static final String NAVBAR_LANDSCAPE_LEFT_RIGHT_SIZE = "navigation_bar_width";
public static final String NAVBAR_BOTTOM_GESTURE_SIZE = "navigation_bar_gesture_height";
+ public static final String NAVBAR_BOTTOM_GESTURE_LARGER_SIZE =
+ "navigation_bar_gesture_larger_height";
public static int getNavbarSize(String resName, Resources res) {
return getDimenByName(resName, res, DEFAULT_NAVBAR_VALUE);
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index f9ab196..c03619e 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -142,7 +142,8 @@
float shiftCurrent = progress * mShiftRange;
mAppsView.setTranslationY(shiftCurrent);
- if (FeatureFlags.ENABLE_DEVICE_SEARCH.get()) {
+ if (FeatureFlags.ENABLE_DEVICE_SEARCH.get()
+ && !FeatureFlags.DISABLE_INITIAL_IME_IN_ALLAPPS.get()) {
mInsetController.setProgress(progress);
}
}
@@ -233,7 +234,9 @@
public void setupViews(AllAppsContainerView appsView, ScrimView scrimView) {
mAppsView = appsView;
mScrimView = scrimView;
- if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() && BuildCompat.isAtLeastR()) {
+ if (FeatureFlags.ENABLE_DEVICE_SEARCH.get()
+ && !FeatureFlags.DISABLE_INITIAL_IME_IN_ALLAPPS.get()
+ && BuildCompat.isAtLeastR()) {
mInsetController = new AllAppsInsetTransitionController(mShiftRange, mAppsView);
mLauncher.getSystemUiController().updateUiState(UI_STATE_ALLAPPS,
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
@@ -261,7 +264,8 @@
if (Float.compare(mProgress, 1f) == 0) {
mAppsView.reset(false /* animate */);
}
- if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() && BuildCompat.isAtLeastR()) {
+ if (FeatureFlags.ENABLE_DEVICE_SEARCH.get()
+ && !FeatureFlags.DISABLE_INITIAL_IME_IN_ALLAPPS.get() && BuildCompat.isAtLeastR()) {
mInsetController.onAnimationEnd(mProgress);
if (Float.compare(mProgress, 0f) == 0) {
mLauncher.getLiveSearchManager().start();
diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java
index 68641d9..24df653 100644
--- a/src/com/android/launcher3/config/FeatureFlags.java
+++ b/src/com/android/launcher3/config/FeatureFlags.java
@@ -98,6 +98,9 @@
public static final BooleanFlag ENABLE_DEVICE_SEARCH = getDebugFlag(
"ENABLE_DEVICE_SEARCH", false, "Allows on device search in all apps");
+ public static final BooleanFlag DISABLE_INITIAL_IME_IN_ALLAPPS = getDebugFlag(
+ "DISABLE_INITIAL_IME_IN_ALLAPPS", false, "Disable default IME state in all apps");
+
public static final BooleanFlag FOLDER_NAME_SUGGEST = new DeviceFlag(
"FOLDER_NAME_SUGGEST", true,
"Suggests folder names instead of blank text.");
diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
index 23baaf0..10cd04c 100644
--- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
+++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
@@ -261,7 +261,9 @@
mCanBlockFling = mFromState == NORMAL;
mFlingBlockCheck.unblockFling();
// Must be called after all the animation controllers have been paused
- if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() && BuildCompat.isAtLeastR()
+ if (FeatureFlags.ENABLE_DEVICE_SEARCH.get()
+ && !FeatureFlags.DISABLE_INITIAL_IME_IN_ALLAPPS.get()
+ && BuildCompat.isAtLeastR()
&& (mToState == ALL_APPS || mToState == NORMAL)) {
mLauncher.getAllAppsController().getInsetController().onDragStart(
mFromState == NORMAL ? 1f : 0f);
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index e118481..d3fc89e 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -234,25 +234,11 @@
return mDevice;
}
- private boolean hasSystemUiObject(String resId) {
- return mDevice.hasObject(By.res(SYSTEMUI_PACKAGE, resId));
- }
-
@Before
public void setUp() throws Exception {
- Log.d(TAG, "Before disabling battery defender");
- mDevice.executeShellCommand("setprop vendor.battery.defender.disable 1");
- Log.d(TAG, "Before enabling stay awake");
- mDevice.executeShellCommand("settings put global stay_on_while_plugged_in 3");
- for (int i = 0; i < 10 && hasSystemUiObject("keyguard_status_view"); ++i) {
- Log.d(TAG, "Before unlocking the phone");
- mDevice.executeShellCommand("input keyevent 82");
- mDevice.waitForIdle();
- }
- Assert.assertTrue("Keyguard still visible",
+ Assert.assertTrue("Keyguard is visible",
mDevice.wait(
Until.gone(By.res(SYSTEMUI_PACKAGE, "keyguard_status_view")), 60000));
- Log.d(TAG, "Keyguard is not visible");
final String launcherPackageName = mDevice.getLauncherPackageName();
try {