Merge "Bypass systemstate check when using shared state" into ub-launcher3-qt-dev
am: 329097b179
Change-Id: I4f9f26cda32ddd45e3d6e32879832a78b86f744c
This commit is contained in:
@@ -15,8 +15,11 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.quickstep;
|
package com.android.quickstep;
|
||||||
|
|
||||||
|
import static com.android.quickstep.TouchInteractionService.MAIN_THREAD_EXECUTOR;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.android.launcher3.Utilities;
|
||||||
import com.android.launcher3.config.FeatureFlags;
|
import com.android.launcher3.config.FeatureFlags;
|
||||||
import com.android.launcher3.util.Preconditions;
|
import com.android.launcher3.util.Preconditions;
|
||||||
import com.android.quickstep.util.RecentsAnimationListenerSet;
|
import com.android.quickstep.util.RecentsAnimationListenerSet;
|
||||||
@@ -29,7 +32,7 @@ import java.io.PrintWriter;
|
|||||||
*/
|
*/
|
||||||
public class SwipeSharedState implements SwipeAnimationListener {
|
public class SwipeSharedState implements SwipeAnimationListener {
|
||||||
|
|
||||||
private final OverviewComponentObserver mOverviewComponentObserver;
|
private OverviewComponentObserver mOverviewComponentObserver;
|
||||||
|
|
||||||
private RecentsAnimationListenerSet mRecentsAnimationListener;
|
private RecentsAnimationListenerSet mRecentsAnimationListener;
|
||||||
private SwipeAnimationTargetSet mLastAnimationTarget;
|
private SwipeAnimationTargetSet mLastAnimationTarget;
|
||||||
@@ -42,8 +45,8 @@ public class SwipeSharedState implements SwipeAnimationListener {
|
|||||||
public boolean recentsAnimationFinishInterrupted;
|
public boolean recentsAnimationFinishInterrupted;
|
||||||
public int nextRunningTaskId = -1;
|
public int nextRunningTaskId = -1;
|
||||||
|
|
||||||
public SwipeSharedState(OverviewComponentObserver overviewComponentObserver) {
|
public void setOverviewComponentObserver(OverviewComponentObserver observer) {
|
||||||
mOverviewComponentObserver = overviewComponentObserver;
|
mOverviewComponentObserver = observer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -72,6 +75,12 @@ public class SwipeSharedState implements SwipeAnimationListener {
|
|||||||
private void clearListenerState() {
|
private void clearListenerState() {
|
||||||
if (mRecentsAnimationListener != null) {
|
if (mRecentsAnimationListener != null) {
|
||||||
mRecentsAnimationListener.removeListener(this);
|
mRecentsAnimationListener.removeListener(this);
|
||||||
|
mRecentsAnimationListener.cancelListener();
|
||||||
|
if (mLastAnimationRunning && mLastAnimationTarget != null) {
|
||||||
|
Utilities.postAsyncCallback(MAIN_THREAD_EXECUTOR.getHandler(),
|
||||||
|
mLastAnimationTarget::cancelAnimation);
|
||||||
|
mLastAnimationTarget = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mRecentsAnimationListener = null;
|
mRecentsAnimationListener = null;
|
||||||
clearAnimationTarget();
|
clearAnimationTarget();
|
||||||
@@ -98,9 +107,10 @@ public class SwipeSharedState implements SwipeAnimationListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
clearListenerState();
|
clearListenerState();
|
||||||
mRecentsAnimationListener = new RecentsAnimationListenerSet(mOverviewComponentObserver
|
boolean shouldMinimiseSplitScreen = mOverviewComponentObserver == null ? false
|
||||||
.getActivityControlHelper().shouldMinimizeSplitScreen(),
|
: mOverviewComponentObserver.getActivityControlHelper().shouldMinimizeSplitScreen();
|
||||||
this::onSwipeAnimationFinished);
|
mRecentsAnimationListener = new RecentsAnimationListenerSet(
|
||||||
|
shouldMinimiseSplitScreen, this::onSwipeAnimationFinished);
|
||||||
mRecentsAnimationListener.addListener(this);
|
mRecentsAnimationListener.addListener(this);
|
||||||
return mRecentsAnimationListener;
|
return mRecentsAnimationListener;
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-10
@@ -86,6 +86,7 @@ import com.android.quickstep.inputconsumers.InputConsumer;
|
|||||||
import com.android.quickstep.inputconsumers.OtherActivityInputConsumer;
|
import com.android.quickstep.inputconsumers.OtherActivityInputConsumer;
|
||||||
import com.android.quickstep.inputconsumers.OverviewInputConsumer;
|
import com.android.quickstep.inputconsumers.OverviewInputConsumer;
|
||||||
import com.android.quickstep.inputconsumers.OverviewWithoutFocusInputConsumer;
|
import com.android.quickstep.inputconsumers.OverviewWithoutFocusInputConsumer;
|
||||||
|
import com.android.quickstep.inputconsumers.ResetGestureInputConsumer;
|
||||||
import com.android.quickstep.inputconsumers.ScreenPinnedInputConsumer;
|
import com.android.quickstep.inputconsumers.ScreenPinnedInputConsumer;
|
||||||
import com.android.systemui.shared.recents.IOverviewProxy;
|
import com.android.systemui.shared.recents.IOverviewProxy;
|
||||||
import com.android.systemui.shared.recents.ISystemUiProxy;
|
import com.android.systemui.shared.recents.ISystemUiProxy;
|
||||||
@@ -229,6 +230,10 @@ public class TouchInteractionService extends Service implements
|
|||||||
return sConnected;
|
return sConnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final SwipeSharedState mSwipeSharedState = new SwipeSharedState();
|
||||||
|
private final InputConsumer mResetGestureInputConsumer =
|
||||||
|
new ResetGestureInputConsumer(mSwipeSharedState);
|
||||||
|
|
||||||
private KeyguardManager mKM;
|
private KeyguardManager mKM;
|
||||||
private ActivityManagerWrapper mAM;
|
private ActivityManagerWrapper mAM;
|
||||||
private RecentsModel mRecentsModel;
|
private RecentsModel mRecentsModel;
|
||||||
@@ -239,7 +244,6 @@ public class TouchInteractionService extends Service implements
|
|||||||
private OverviewCallbacks mOverviewCallbacks;
|
private OverviewCallbacks mOverviewCallbacks;
|
||||||
private TaskOverlayFactory mTaskOverlayFactory;
|
private TaskOverlayFactory mTaskOverlayFactory;
|
||||||
private InputConsumerController mInputConsumer;
|
private InputConsumerController mInputConsumer;
|
||||||
private SwipeSharedState mSwipeSharedState;
|
|
||||||
private boolean mAssistantAvailable;
|
private boolean mAssistantAvailable;
|
||||||
private float mLastAssistantVisibility = 0;
|
private float mLastAssistantVisibility = 0;
|
||||||
private @SystemUiStateFlags int mSystemUiStateFlags;
|
private @SystemUiStateFlags int mSystemUiStateFlags;
|
||||||
@@ -412,10 +416,10 @@ public class TouchInteractionService extends Service implements
|
|||||||
mOverviewInteractionState = OverviewInteractionState.INSTANCE.get(this);
|
mOverviewInteractionState = OverviewInteractionState.INSTANCE.get(this);
|
||||||
mOverviewCallbacks = OverviewCallbacks.get(this);
|
mOverviewCallbacks = OverviewCallbacks.get(this);
|
||||||
mTaskOverlayFactory = TaskOverlayFactory.INSTANCE.get(this);
|
mTaskOverlayFactory = TaskOverlayFactory.INSTANCE.get(this);
|
||||||
mSwipeSharedState = new SwipeSharedState(mOverviewComponentObserver);
|
|
||||||
mInputConsumer = InputConsumerController.getRecentsAnimationInputConsumer();
|
mInputConsumer = InputConsumerController.getRecentsAnimationInputConsumer();
|
||||||
mIsUserUnlocked = true;
|
mIsUserUnlocked = true;
|
||||||
|
|
||||||
|
mSwipeSharedState.setOverviewComponentObserver(mOverviewComponentObserver);
|
||||||
mInputConsumer.registerInputConsumer();
|
mInputConsumer.registerInputConsumer();
|
||||||
onSystemUiProxySet();
|
onSystemUiProxySet();
|
||||||
onSystemUiFlagsChanged();
|
onSystemUiFlagsChanged();
|
||||||
@@ -513,12 +517,14 @@ public class TouchInteractionService extends Service implements
|
|||||||
// launched while device is locked even after exiting direct boot mode (e.g. camera).
|
// launched while device is locked even after exiting direct boot mode (e.g. camera).
|
||||||
return createDeviceLockedInputConsumer(mAM.getRunningTask(0));
|
return createDeviceLockedInputConsumer(mAM.getRunningTask(0));
|
||||||
} else {
|
} else {
|
||||||
return InputConsumer.NO_OP;
|
return mResetGestureInputConsumer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InputConsumer base = isInValidSystemUiState
|
// When using sharedState, bypass systemState check as this is a followup gesture and the
|
||||||
? newBaseConsumer(useSharedState, event) : InputConsumer.NO_OP;
|
// first gesture started in a valid system state.
|
||||||
|
InputConsumer base = isInValidSystemUiState || useSharedState
|
||||||
|
? newBaseConsumer(useSharedState, event) : mResetGestureInputConsumer;
|
||||||
if (mMode == Mode.NO_BUTTON) {
|
if (mMode == Mode.NO_BUTTON) {
|
||||||
final ActivityControlHelper activityControl =
|
final ActivityControlHelper activityControl =
|
||||||
mOverviewComponentObserver.getActivityControlHelper();
|
mOverviewComponentObserver.getActivityControlHelper();
|
||||||
@@ -563,7 +569,7 @@ public class TouchInteractionService extends Service implements
|
|||||||
|
|
||||||
if (runningTaskInfo == null && !mSwipeSharedState.goingToLauncher
|
if (runningTaskInfo == null && !mSwipeSharedState.goingToLauncher
|
||||||
&& !mSwipeSharedState.recentsAnimationFinishInterrupted) {
|
&& !mSwipeSharedState.recentsAnimationFinishInterrupted) {
|
||||||
return InputConsumer.NO_OP;
|
return mResetGestureInputConsumer;
|
||||||
} else if (mSwipeSharedState.recentsAnimationFinishInterrupted) {
|
} else if (mSwipeSharedState.recentsAnimationFinishInterrupted) {
|
||||||
// If the finish animation was interrupted, then continue using the other activity input
|
// If the finish animation was interrupted, then continue using the other activity input
|
||||||
// consumer but with the next task as the running task
|
// consumer but with the next task as the running task
|
||||||
@@ -576,7 +582,7 @@ public class TouchInteractionService extends Service implements
|
|||||||
return createOverviewInputConsumer(event);
|
return createOverviewInputConsumer(event);
|
||||||
} else if (mGestureBlockingActivity != null && runningTaskInfo != null
|
} else if (mGestureBlockingActivity != null && runningTaskInfo != null
|
||||||
&& mGestureBlockingActivity.equals(runningTaskInfo.topActivity)) {
|
&& mGestureBlockingActivity.equals(runningTaskInfo.topActivity)) {
|
||||||
return InputConsumer.NO_OP;
|
return mResetGestureInputConsumer;
|
||||||
} else {
|
} else {
|
||||||
return createOtherActivityInputConsumer(event, runningTaskInfo);
|
return createOtherActivityInputConsumer(event, runningTaskInfo);
|
||||||
}
|
}
|
||||||
@@ -607,7 +613,7 @@ public class TouchInteractionService extends Service implements
|
|||||||
return new DeviceLockedInputConsumer(this, mSwipeSharedState, mInputMonitorCompat,
|
return new DeviceLockedInputConsumer(this, mSwipeSharedState, mInputMonitorCompat,
|
||||||
mSwipeTouchRegion, taskInfo.taskId);
|
mSwipeTouchRegion, taskInfo.taskId);
|
||||||
} else {
|
} else {
|
||||||
return InputConsumer.NO_OP;
|
return mResetGestureInputConsumer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -616,7 +622,7 @@ public class TouchInteractionService extends Service implements
|
|||||||
mOverviewComponentObserver.getActivityControlHelper();
|
mOverviewComponentObserver.getActivityControlHelper();
|
||||||
BaseDraggingActivity activity = activityControl.getCreatedActivity();
|
BaseDraggingActivity activity = activityControl.getCreatedActivity();
|
||||||
if (activity == null) {
|
if (activity == null) {
|
||||||
return InputConsumer.NO_OP;
|
return mResetGestureInputConsumer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activity.getRootView().hasWindowFocus() || mSwipeSharedState.goingToLauncher) {
|
if (activity.getRootView().hasWindowFocus() || mSwipeSharedState.goingToLauncher) {
|
||||||
@@ -633,7 +639,8 @@ public class TouchInteractionService extends Service implements
|
|||||||
*/
|
*/
|
||||||
private void onConsumerInactive(InputConsumer caller) {
|
private void onConsumerInactive(InputConsumer caller) {
|
||||||
if (mConsumer == caller) {
|
if (mConsumer == caller) {
|
||||||
mConsumer = InputConsumer.NO_OP;
|
mConsumer = mResetGestureInputConsumer;
|
||||||
|
mUncheckedConsumer = mConsumer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+22
-17
@@ -32,6 +32,19 @@ public interface InputConsumer {
|
|||||||
int TYPE_ACCESSIBILITY = 1 << 5;
|
int TYPE_ACCESSIBILITY = 1 << 5;
|
||||||
int TYPE_SCREEN_PINNED = 1 << 6;
|
int TYPE_SCREEN_PINNED = 1 << 6;
|
||||||
int TYPE_OVERVIEW_WITHOUT_FOCUS = 1 << 7;
|
int TYPE_OVERVIEW_WITHOUT_FOCUS = 1 << 7;
|
||||||
|
int TYPE_RESET_GESTURE = 1 << 8;
|
||||||
|
|
||||||
|
String[] NAMES = new String[] {
|
||||||
|
"TYPE_NO_OP", // 0
|
||||||
|
"TYPE_OVERVIEW", // 1
|
||||||
|
"TYPE_OTHER_ACTIVITY", // 2
|
||||||
|
"TYPE_ASSISTANT", // 3
|
||||||
|
"TYPE_DEVICE_LOCKED", // 4
|
||||||
|
"TYPE_ACCESSIBILITY", // 5
|
||||||
|
"TYPE_SCREEN_PINNED", // 6
|
||||||
|
"TYPE_OVERVIEW_WITHOUT_FOCUS", // 7
|
||||||
|
"TYPE_RESET_GESTURE", // 8
|
||||||
|
};
|
||||||
|
|
||||||
InputConsumer NO_OP = () -> TYPE_NO_OP;
|
InputConsumer NO_OP = () -> TYPE_NO_OP;
|
||||||
|
|
||||||
@@ -66,23 +79,15 @@ public interface InputConsumer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default String getName() {
|
default String getName() {
|
||||||
switch (getType()) {
|
String name = "";
|
||||||
case TYPE_OVERVIEW:
|
for (int i = 0; i < NAMES.length; i++) {
|
||||||
return "OVERVIEW";
|
if ((getType() & (1 << i)) != 0) {
|
||||||
case TYPE_OTHER_ACTIVITY:
|
if (name.length() > 0) {
|
||||||
return "OTHER_ACTIVITY";
|
name += ":";
|
||||||
case TYPE_ASSISTANT:
|
}
|
||||||
return "ASSISTANT";
|
name += NAMES[i];
|
||||||
case TYPE_DEVICE_LOCKED:
|
}
|
||||||
return "DEVICE_LOCKED";
|
|
||||||
case TYPE_ACCESSIBILITY:
|
|
||||||
return "ACCESSIBILITY";
|
|
||||||
case TYPE_SCREEN_PINNED:
|
|
||||||
return "SCREEN_PINNED";
|
|
||||||
case TYPE_OVERVIEW_WITHOUT_FOCUS:
|
|
||||||
return "TYPE_OVERVIEW_WITHOUT_FOCUS";
|
|
||||||
default:
|
|
||||||
return "NO_OP";
|
|
||||||
}
|
}
|
||||||
|
return name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+45
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 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.quickstep.inputconsumers;
|
||||||
|
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
|
||||||
|
import com.android.quickstep.SwipeSharedState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A NO_OP input consumer which also resets any pending gesture
|
||||||
|
*/
|
||||||
|
public class ResetGestureInputConsumer implements InputConsumer {
|
||||||
|
|
||||||
|
private final SwipeSharedState mSwipeSharedState;
|
||||||
|
|
||||||
|
public ResetGestureInputConsumer(SwipeSharedState swipeSharedState) {
|
||||||
|
mSwipeSharedState = swipeSharedState;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getType() {
|
||||||
|
return TYPE_RESET_GESTURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMotionEvent(MotionEvent ev) {
|
||||||
|
if (ev.getAction() == MotionEvent.ACTION_DOWN
|
||||||
|
&& mSwipeSharedState.getActiveListener() != null) {
|
||||||
|
mSwipeSharedState.clearAllState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+17
-5
@@ -49,6 +49,8 @@ public class RecentsAnimationListenerSet implements RecentsAnimationListener {
|
|||||||
private final Consumer<SwipeAnimationTargetSet> mOnFinishListener;
|
private final Consumer<SwipeAnimationTargetSet> mOnFinishListener;
|
||||||
private RecentsAnimationControllerCompat mController;
|
private RecentsAnimationControllerCompat mController;
|
||||||
|
|
||||||
|
private boolean mCancelled;
|
||||||
|
|
||||||
public RecentsAnimationListenerSet(boolean shouldMinimizeSplitScreen,
|
public RecentsAnimationListenerSet(boolean shouldMinimizeSplitScreen,
|
||||||
Consumer<SwipeAnimationTargetSet> onFinishListener) {
|
Consumer<SwipeAnimationTargetSet> onFinishListener) {
|
||||||
mShouldMinimizeSplitScreen = shouldMinimizeSplitScreen;
|
mShouldMinimizeSplitScreen = shouldMinimizeSplitScreen;
|
||||||
@@ -75,11 +77,16 @@ public class RecentsAnimationListenerSet implements RecentsAnimationListener {
|
|||||||
SwipeAnimationTargetSet targetSet = new SwipeAnimationTargetSet(controller, targets,
|
SwipeAnimationTargetSet targetSet = new SwipeAnimationTargetSet(controller, targets,
|
||||||
homeContentInsets, minimizedHomeBounds, mShouldMinimizeSplitScreen,
|
homeContentInsets, minimizedHomeBounds, mShouldMinimizeSplitScreen,
|
||||||
mOnFinishListener);
|
mOnFinishListener);
|
||||||
Utilities.postAsyncCallback(MAIN_THREAD_EXECUTOR.getHandler(), () -> {
|
|
||||||
for (SwipeAnimationListener listener : getListeners()) {
|
if (mCancelled) {
|
||||||
listener.onRecentsAnimationStart(targetSet);
|
targetSet.cancelAnimation();
|
||||||
}
|
} else {
|
||||||
});
|
Utilities.postAsyncCallback(MAIN_THREAD_EXECUTOR.getHandler(), () -> {
|
||||||
|
for (SwipeAnimationListener listener : getListeners()) {
|
||||||
|
listener.onRecentsAnimationStart(targetSet);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -99,4 +106,9 @@ public class RecentsAnimationListenerSet implements RecentsAnimationListener {
|
|||||||
private SwipeAnimationListener[] getListeners() {
|
private SwipeAnimationListener[] getListeners() {
|
||||||
return mListeners.toArray(new SwipeAnimationListener[mListeners.size()]);
|
return mListeners.toArray(new SwipeAnimationListener[mListeners.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void cancelListener() {
|
||||||
|
mCancelled = true;
|
||||||
|
onAnimationCanceled(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -36,7 +36,6 @@ public class SwipeAnimationTargetSet extends RemoteAnimationTargetSet {
|
|||||||
private final boolean mShouldMinimizeSplitScreen;
|
private final boolean mShouldMinimizeSplitScreen;
|
||||||
private final Consumer<SwipeAnimationTargetSet> mOnFinishListener;
|
private final Consumer<SwipeAnimationTargetSet> mOnFinishListener;
|
||||||
|
|
||||||
|
|
||||||
public final RecentsAnimationControllerCompat controller;
|
public final RecentsAnimationControllerCompat controller;
|
||||||
public final Rect homeContentInsets;
|
public final Rect homeContentInsets;
|
||||||
public final Rect minimizedHomeBounds;
|
public final Rect minimizedHomeBounds;
|
||||||
@@ -103,6 +102,10 @@ public class SwipeAnimationTargetSet extends RemoteAnimationTargetSet {
|
|||||||
return controller != null ? controller.screenshotTask(taskId) : null;
|
return controller != null ? controller.screenshotTask(taskId) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void cancelAnimation() {
|
||||||
|
finishController(false /* toRecents */, null, false /* sendUserLeaveHint */);
|
||||||
|
}
|
||||||
|
|
||||||
public interface SwipeAnimationListener {
|
public interface SwipeAnimationListener {
|
||||||
|
|
||||||
void onRecentsAnimationStart(SwipeAnimationTargetSet targetSet);
|
void onRecentsAnimationStart(SwipeAnimationTargetSet targetSet);
|
||||||
|
|||||||
Reference in New Issue
Block a user