Merging ub-launcher3-qt-dev, build 5656472 am: 0e57817adc am: 96a61f0923

am: a7ef17b218

Change-Id: Ibb056cb6d57c1f5d4c6d1946980741bbbb6bb316
This commit is contained in:
Sunny Goyal
2019-06-14 09:26:39 -07:00
committed by android-build-merger
33 changed files with 426 additions and 162 deletions
@@ -61,4 +61,9 @@ public abstract class GoActivityControlHelper<T extends BaseDraggingActivity> im
// Go does not support live tiles.
return false;
}
@Override
public void onLaunchTaskFailed(T activity) {
// Go does not support gestures from one task to another.
}
}
@@ -64,10 +64,12 @@ public class BackgroundAppState extends OverviewState {
public ScaleAndTranslation getOverviewScaleAndTranslation(Launcher launcher) {
// Initialize the recents view scale to what it would be when starting swipe up
RecentsView recentsView = launcher.getOverviewPanel();
if (recentsView.getTaskViewCount() == 0) {
int taskCount = recentsView.getTaskViewCount();
if (taskCount == 0) {
return super.getOverviewScaleAndTranslation(launcher);
}
TaskView dummyTask = recentsView.getTaskViewAt(recentsView.getCurrentPage());
TaskView dummyTask = recentsView.getTaskViewAt(Math.max(taskCount - 1,
recentsView.getCurrentPage()));
return recentsView.getTempClipAnimationHelper().updateForFullscreenOverview(dummyTask)
.getScaleAndTranslation();
}
@@ -15,6 +15,9 @@
*/
package com.android.launcher3.uioverrides.states;
import android.os.Handler;
import android.os.Looper;
import com.android.launcher3.Launcher;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.quickstep.views.RecentsView;
@@ -27,6 +30,8 @@ import com.android.quickstep.views.TaskView;
*/
public class QuickSwitchState extends BackgroundAppState {
private static final String TAG = "QuickSwitchState";
public QuickSwitchState(int id) {
super(id, LauncherLogProto.ContainerType.APP);
}
@@ -48,7 +53,12 @@ public class QuickSwitchState extends BackgroundAppState {
public void onStateTransitionEnd(Launcher launcher) {
TaskView tasktolaunch = launcher.<RecentsView>getOverviewPanel().getTaskViewAt(0);
if (tasktolaunch != null) {
tasktolaunch.launchTask(false);
tasktolaunch.launchTask(false, success -> {
if (!success) {
launcher.getStateManager().goToState(OVERVIEW);
tasktolaunch.notifyTaskLaunchFailed(TAG);
}
}, new Handler(Looper.getMainLooper()));
} else {
launcher.getStateManager().goToState(NORMAL);
}
@@ -224,4 +224,10 @@ public final class FallbackActivityControllerHelper implements
public boolean isInLiveTileMode() {
return false;
}
@Override
public void onLaunchTaskFailed(RecentsActivity activity) {
// TODO: probably go back to overview instead.
activity.<RecentsView>getOverviewPanel().startHome();
}
}
@@ -16,13 +16,17 @@
package com.android.quickstep;
import static android.view.View.TRANSLATION_Y;
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
import static com.android.launcher3.LauncherState.BACKGROUND_APP;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.LauncherStateManager.ANIM_ALL;
import static com.android.launcher3.allapps.AllAppsTransitionController.SPRING_DAMPING_RATIO;
import static com.android.launcher3.allapps.AllAppsTransitionController.SPRING_STIFFNESS;
import static com.android.launcher3.anim.Interpolators.ACCEL_2;
import static com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL;
import static com.android.launcher3.anim.Interpolators.INSTANT;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.quickstep.WindowTransformSwipeHandler.RECENTS_ATTACH_DURATION;
@@ -44,16 +48,19 @@ import android.view.animation.Interpolator;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.dynamicanimation.animation.SpringAnimation;
import androidx.dynamicanimation.animation.SpringForce;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherInitListenerEx;
import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherStateManager;
import com.android.launcher3.allapps.DiscoveryBounce;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.anim.SpringObjectAnimator;
import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.views.FloatingIconView;
@@ -99,6 +106,13 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe
DiscoveryBounce.showForOverviewIfNeeded(activity);
}
@Override
public void onSwipeUpToHomeComplete(Launcher activity) {
// Ensure recents is at the correct position for NORMAL state. For example, when we detach
// recents, we assume the first task is invisible, making translation off by one task.
activity.getStateManager().reapplyState();
}
@Override
public void onAssistantVisibilityChanged(float visibility) {
Launcher launcher = getCreatedActivity();
@@ -156,18 +170,23 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe
public AnimatorPlaybackController createActivityAnimationToHome() {
// Return an empty APC here since we have an non-user controlled animation to home.
long accuracy = 2 * Math.max(dp.widthPx, dp.heightPx);
AnimatorSet as = new AnimatorSet();
as.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
activity.getStateManager().goToState(NORMAL, false);
}
});
return AnimatorPlaybackController.wrap(as, accuracy);
return activity.getStateManager().createAnimationToNewWorkspace(NORMAL, accuracy,
0 /* animComponents */);
}
@Override
public void playAtomicAnimation(float velocity) {
// Setup workspace with 0 duration to prepare for our staggered animation.
LauncherStateManager stateManager = activity.getStateManager();
AnimatorSetBuilder builder = new AnimatorSetBuilder();
// setRecentsAttachedToAppWindow() will animate recents out.
builder.addFlag(AnimatorSetBuilder.FLAG_DONT_ANIMATE_OVERVIEW);
stateManager.createAtomicAnimation(BACKGROUND_APP, NORMAL, builder, ANIM_ALL, 0);
builder.build().start();
// Stop scrolling so that it doesn't interfere with the translation offscreen.
recentsView.getScroller().forceFinished(true);
new StaggeredWorkspaceAnim(activity, workspaceView, velocity).start();
}
};
@@ -196,12 +215,11 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe
// Optimization, hide the all apps view to prevent layout while initializing
activity.getAppsView().getContentView().setVisibility(View.GONE);
AccessibilityManagerCompat.sendStateEventToTest(activity, fromState.ordinal);
return new AnimationFactory() {
private Animator mShelfAnim;
private ShelfAnimState mShelfState;
private Animator mAttachToWindowAnim;
private Animator mAttachToWindowFadeAnim;
private SpringAnimation mAttachToWindowTranslationXAnim;
private boolean mIsAttachedToWindow;
@Override
@@ -267,20 +285,60 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe
return;
}
mIsAttachedToWindow = attached;
if (mAttachToWindowAnim != null) {
mAttachToWindowAnim.cancel();
if (mAttachToWindowFadeAnim != null) {
mAttachToWindowFadeAnim.cancel();
}
mAttachToWindowAnim = ObjectAnimator.ofFloat(activity.getOverviewPanel(),
RecentsView recentsView = activity.getOverviewPanel();
mAttachToWindowFadeAnim = ObjectAnimator.ofFloat(recentsView,
RecentsView.CONTENT_ALPHA, attached ? 1 : 0);
mAttachToWindowAnim.addListener(new AnimatorListenerAdapter() {
int runningTaskIndex = recentsView.getRunningTaskIndex();
if (runningTaskIndex == 0) {
// If we are on the first task (we haven't quick switched), translate recents in
// from the side. Calculate the start translation based on current scale/scroll.
float currScale = recentsView.getScaleX();
float scrollOffsetX = recentsView.getScrollOffset();
float offscreenX = NORMAL.getOverviewScaleAndTranslation(activity).translationX;
// The first task is hidden, so offset by its width.
int firstTaskWidth = recentsView.getTaskViewAt(0).getWidth();
offscreenX -= (firstTaskWidth + recentsView.getPageSpacing()) * currScale;
// Offset since scale pushes tasks outwards.
offscreenX += firstTaskWidth * (currScale - 1) / 2;
offscreenX = Math.max(0, offscreenX);
if (recentsView.isRtl()) {
offscreenX = -offscreenX;
}
float fromTranslationX = attached ? offscreenX - scrollOffsetX : 0;
float toTranslationX = attached ? 0 : offscreenX - scrollOffsetX;
if (mAttachToWindowTranslationXAnim == null) {
mAttachToWindowTranslationXAnim = new SpringAnimation(recentsView,
SpringAnimation.TRANSLATION_X).setSpring(new SpringForce()
.setDampingRatio(0.8f)
.setStiffness(250));
}
if (!recentsView.isShown() && animate) {
recentsView.setTranslationX(fromTranslationX);
mAttachToWindowTranslationXAnim.setStartValue(fromTranslationX);
}
mAttachToWindowTranslationXAnim.animateToFinalPosition(toTranslationX);
if (!animate && mAttachToWindowTranslationXAnim.canSkipToEnd()) {
mAttachToWindowTranslationXAnim.skipToEnd();
}
mAttachToWindowFadeAnim.setInterpolator(attached ? INSTANT : ACCEL_2);
} else {
mAttachToWindowFadeAnim.setInterpolator(ACCEL_DEACCEL);
}
mAttachToWindowFadeAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mAttachToWindowAnim = null;
mAttachToWindowFadeAnim = null;
}
});
mAttachToWindowAnim.setInterpolator(ACCEL_DEACCEL);
mAttachToWindowAnim.setDuration(animate ? RECENTS_ATTACH_DURATION : 0);
mAttachToWindowAnim.start();
mAttachToWindowFadeAnim.setDuration(animate ? RECENTS_ATTACH_DURATION : 0);
mAttachToWindowFadeAnim.start();
}
};
}
@@ -448,4 +506,9 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe
return launcher != null && launcher.getStateManager().getState() == OVERVIEW &&
launcher.isStarted();
}
@Override
public void onLaunchTaskFailed(Launcher launcher) {
launcher.getStateManager().goToState(OVERVIEW);
}
}
@@ -15,8 +15,11 @@
*/
package com.android.quickstep;
import static com.android.quickstep.TouchInteractionService.MAIN_THREAD_EXECUTOR;
import android.util.Log;
import com.android.launcher3.Utilities;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.util.Preconditions;
import com.android.quickstep.util.RecentsAnimationListenerSet;
@@ -29,7 +32,7 @@ import java.io.PrintWriter;
*/
public class SwipeSharedState implements SwipeAnimationListener {
private final OverviewComponentObserver mOverviewComponentObserver;
private OverviewComponentObserver mOverviewComponentObserver;
private RecentsAnimationListenerSet mRecentsAnimationListener;
private SwipeAnimationTargetSet mLastAnimationTarget;
@@ -42,8 +45,8 @@ public class SwipeSharedState implements SwipeAnimationListener {
public boolean recentsAnimationFinishInterrupted;
public int nextRunningTaskId = -1;
public SwipeSharedState(OverviewComponentObserver overviewComponentObserver) {
mOverviewComponentObserver = overviewComponentObserver;
public void setOverviewComponentObserver(OverviewComponentObserver observer) {
mOverviewComponentObserver = observer;
}
@Override
@@ -72,6 +75,12 @@ public class SwipeSharedState implements SwipeAnimationListener {
private void clearListenerState() {
if (mRecentsAnimationListener != null) {
mRecentsAnimationListener.removeListener(this);
mRecentsAnimationListener.cancelListener();
if (mLastAnimationRunning && mLastAnimationTarget != null) {
Utilities.postAsyncCallback(MAIN_THREAD_EXECUTOR.getHandler(),
mLastAnimationTarget::cancelAnimation);
mLastAnimationTarget = null;
}
}
mRecentsAnimationListener = null;
clearAnimationTarget();
@@ -98,9 +107,10 @@ public class SwipeSharedState implements SwipeAnimationListener {
}
clearListenerState();
mRecentsAnimationListener = new RecentsAnimationListenerSet(mOverviewComponentObserver
.getActivityControlHelper().shouldMinimizeSplitScreen(),
this::onSwipeAnimationFinished);
boolean shouldMinimiseSplitScreen = mOverviewComponentObserver == null ? false
: mOverviewComponentObserver.getActivityControlHelper().shouldMinimizeSplitScreen();
mRecentsAnimationListener = new RecentsAnimationListenerSet(
shouldMinimiseSplitScreen, this::onSwipeAnimationFinished);
mRecentsAnimationListener.addListener(this);
return mRecentsAnimationListener;
}
@@ -24,6 +24,7 @@ import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.R;
import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.launcher3.util.ResourceBasedOverride;
import com.android.quickstep.views.TaskThumbnailView;
import com.android.quickstep.views.TaskView;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.recents.model.ThumbnailData;
@@ -62,7 +63,7 @@ public class TaskOverlayFactory implements ResourceBasedOverride {
return shortcuts;
}
public TaskOverlay createOverlay(View thumbnailView) {
public TaskOverlay createOverlay(TaskThumbnailView thumbnailView) {
return new TaskOverlay();
}
@@ -17,7 +17,12 @@ package com.android.quickstep;
import static android.view.MotionEvent.ACTION_DOWN;
import static com.android.launcher3.config.FeatureFlags.ADAPTIVE_ICON_WINDOW_ANIM;
import static com.android.launcher3.config.FeatureFlags.APPLY_CONFIG_AT_RUNTIME;
import static com.android.launcher3.config.FeatureFlags.ENABLE_HINTS_IN_OVERVIEW;
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
import static com.android.launcher3.config.FeatureFlags.FAKE_LANDSCAPE_UI;
import static com.android.launcher3.config.FeatureFlags.QUICKSTEP_SPRINGS;
import static com.android.systemui.shared.system.QuickStepContract.KEY_EXTRA_INPUT_MONITOR;
import static com.android.systemui.shared.system.QuickStepContract.KEY_EXTRA_SYSUI_PROXY;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_A11Y_BUTTON_CLICKABLE;
@@ -27,7 +32,6 @@ import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_N
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_OVERVIEW_DISABLED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SCREEN_PINNING;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING_OCCLUDED;
import android.annotation.TargetApi;
@@ -61,6 +65,7 @@ import android.view.Surface;
import android.view.WindowManager;
import androidx.annotation.BinderThread;
import androidx.annotation.UiThread;
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.MainThreadExecutor;
@@ -81,6 +86,7 @@ import com.android.quickstep.inputconsumers.InputConsumer;
import com.android.quickstep.inputconsumers.OtherActivityInputConsumer;
import com.android.quickstep.inputconsumers.OverviewInputConsumer;
import com.android.quickstep.inputconsumers.OverviewWithoutFocusInputConsumer;
import com.android.quickstep.inputconsumers.ResetGestureInputConsumer;
import com.android.quickstep.inputconsumers.ScreenPinnedInputConsumer;
import com.android.systemui.shared.recents.IOverviewProxy;
import com.android.systemui.shared.recents.ISystemUiProxy;
@@ -94,7 +100,6 @@ import com.android.systemui.shared.system.SystemGestureExclusionListenerCompat;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
@@ -146,10 +151,7 @@ public class TouchInteractionService extends Service implements
mISystemUiProxy = ISystemUiProxy.Stub
.asInterface(bundle.getBinder(KEY_EXTRA_SYSUI_PROXY));
MAIN_THREAD_EXECUTOR.execute(TouchInteractionService.this::initInputMonitor);
runWhenUserUnlocked(() -> {
mRecentsModel.setSystemUiProxy(mISystemUiProxy);
mOverviewInteractionState.setSystemUiProxy(mISystemUiProxy);
});
MAIN_THREAD_EXECUTOR.execute(TouchInteractionService.this::onSystemUiProxySet);
}
@Override
@@ -182,16 +184,9 @@ public class TouchInteractionService extends Service implements
@Override
public void onAssistantVisibilityChanged(float visibility) {
if (mOverviewComponentObserver == null) {
// Save the visibility to be applied when the user is unlocked
mPendingAssistantVisibility = visibility;
return;
}
MAIN_THREAD_EXECUTOR.execute(() -> {
mOverviewComponentObserver.getActivityControlHelper()
.onAssistantVisibilityChanged(visibility);
});
mLastAssistantVisibility = visibility;
MAIN_THREAD_EXECUTOR.execute(
TouchInteractionService.this::onAssistantVisibilityChanged);
}
public void onBackAction(boolean completed, int downX, int downY, boolean isButton,
@@ -208,8 +203,7 @@ public class TouchInteractionService extends Service implements
public void onSystemUiStateChanged(int stateFlags) {
mSystemUiStateFlags = stateFlags;
mOverviewInteractionState.setSystemUiStateFlags(stateFlags);
mOverviewComponentObserver.onSystemUiStateChanged(stateFlags);
MAIN_THREAD_EXECUTOR.execute(TouchInteractionService.this::onSystemUiFlagsChanged);
}
/** Deprecated methods **/
@@ -236,6 +230,10 @@ public class TouchInteractionService extends Service implements
return sConnected;
}
private final SwipeSharedState mSwipeSharedState = new SwipeSharedState();
private final InputConsumer mResetGestureInputConsumer =
new ResetGestureInputConsumer(mSwipeSharedState);
private KeyguardManager mKM;
private ActivityManagerWrapper mAM;
private RecentsModel mRecentsModel;
@@ -246,13 +244,11 @@ public class TouchInteractionService extends Service implements
private OverviewCallbacks mOverviewCallbacks;
private TaskOverlayFactory mTaskOverlayFactory;
private InputConsumerController mInputConsumer;
private SwipeSharedState mSwipeSharedState;
private boolean mAssistantAvailable;
private float mPendingAssistantVisibility = 0;
private float mLastAssistantVisibility = 0;
private @SystemUiStateFlags int mSystemUiStateFlags;
private boolean mIsUserUnlocked;
private List<Runnable> mOnUserUnlockedCallbacks;
private BroadcastReceiver mUserUnlockedReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@@ -286,7 +282,7 @@ public class TouchInteractionService extends Service implements
// Everything else should be initialized in initWhenUserUnlocked() below.
mKM = getSystemService(KeyguardManager.class);
mMainChoreographer = Choreographer.getInstance();
mOnUserUnlockedCallbacks = new ArrayList<>();
mAM = ActivityManagerWrapper.getInstance();
if (UserManagerCompat.getInstance(this).isUserUnlocked(Process.myUserHandle())) {
initWhenUserUnlocked();
@@ -413,26 +409,21 @@ public class TouchInteractionService extends Service implements
}
private void initWhenUserUnlocked() {
mIsUserUnlocked = true;
mAM = ActivityManagerWrapper.getInstance();
mRecentsModel = RecentsModel.INSTANCE.get(this);
mOverviewComponentObserver = new OverviewComponentObserver(this);
mOverviewComponentObserver.getActivityControlHelper().onAssistantVisibilityChanged(
mPendingAssistantVisibility);
mOverviewCommandHelper = new OverviewCommandHelper(this, mOverviewComponentObserver);
mOverviewInteractionState = OverviewInteractionState.INSTANCE.get(this);
mOverviewCallbacks = OverviewCallbacks.get(this);
mTaskOverlayFactory = TaskOverlayFactory.INSTANCE.get(this);
mSwipeSharedState = new SwipeSharedState(mOverviewComponentObserver);
mInputConsumer = InputConsumerController.getRecentsAnimationInputConsumer();
mInputConsumer.registerInputConsumer();
mIsUserUnlocked = true;
for (Runnable callback : mOnUserUnlockedCallbacks) {
callback.run();
}
mOnUserUnlockedCallbacks.clear();
mSwipeSharedState.setOverviewComponentObserver(mOverviewComponentObserver);
mInputConsumer.registerInputConsumer();
onSystemUiProxySet();
onSystemUiFlagsChanged();
onAssistantVisibilityChanged();
// Temporarily disable model preload
// new ModelPreload().start(this);
@@ -440,11 +431,27 @@ public class TouchInteractionService extends Service implements
Utilities.unregisterReceiverSafely(this, mUserUnlockedReceiver);
}
private void runWhenUserUnlocked(Runnable callback) {
@UiThread
private void onSystemUiProxySet() {
if (mIsUserUnlocked) {
callback.run();
} else {
mOnUserUnlockedCallbacks.add(callback);
mRecentsModel.setSystemUiProxy(mISystemUiProxy);
mOverviewInteractionState.setSystemUiProxy(mISystemUiProxy);
}
}
@UiThread
private void onSystemUiFlagsChanged() {
if (mIsUserUnlocked) {
mOverviewInteractionState.setSystemUiStateFlags(mSystemUiStateFlags);
mOverviewComponentObserver.onSystemUiStateChanged(mSystemUiStateFlags);
}
}
@UiThread
private void onAssistantVisibilityChanged() {
if (mIsUserUnlocked) {
mOverviewComponentObserver.getActivityControlHelper().onAssistantVisibilityChanged(
mLastAssistantVisibility);
}
}
@@ -510,12 +517,14 @@ public class TouchInteractionService extends Service implements
// launched while device is locked even after exiting direct boot mode (e.g. camera).
return createDeviceLockedInputConsumer(mAM.getRunningTask(0));
} else {
return InputConsumer.NO_OP;
return mResetGestureInputConsumer;
}
}
InputConsumer base = isInValidSystemUiState
? newBaseConsumer(useSharedState, event) : InputConsumer.NO_OP;
// When using sharedState, bypass systemState check as this is a followup gesture and the
// first gesture started in a valid system state.
InputConsumer base = isInValidSystemUiState || useSharedState
? newBaseConsumer(useSharedState, event) : mResetGestureInputConsumer;
if (mMode == Mode.NO_BUTTON) {
final ActivityControlHelper activityControl =
mOverviewComponentObserver.getActivityControlHelper();
@@ -560,7 +569,7 @@ public class TouchInteractionService extends Service implements
if (runningTaskInfo == null && !mSwipeSharedState.goingToLauncher
&& !mSwipeSharedState.recentsAnimationFinishInterrupted) {
return InputConsumer.NO_OP;
return mResetGestureInputConsumer;
} else if (mSwipeSharedState.recentsAnimationFinishInterrupted) {
// If the finish animation was interrupted, then continue using the other activity input
// consumer but with the next task as the running task
@@ -573,7 +582,7 @@ public class TouchInteractionService extends Service implements
return createOverviewInputConsumer(event);
} else if (mGestureBlockingActivity != null && runningTaskInfo != null
&& mGestureBlockingActivity.equals(runningTaskInfo.topActivity)) {
return InputConsumer.NO_OP;
return mResetGestureInputConsumer;
} else {
return createOtherActivityInputConsumer(event, runningTaskInfo);
}
@@ -604,7 +613,7 @@ public class TouchInteractionService extends Service implements
return new DeviceLockedInputConsumer(this, mSwipeSharedState, mInputMonitorCompat,
mSwipeTouchRegion, taskInfo.taskId);
} else {
return InputConsumer.NO_OP;
return mResetGestureInputConsumer;
}
}
@@ -613,10 +622,10 @@ public class TouchInteractionService extends Service implements
mOverviewComponentObserver.getActivityControlHelper();
BaseDraggingActivity activity = activityControl.getCreatedActivity();
if (activity == null) {
return InputConsumer.NO_OP;
return mResetGestureInputConsumer;
}
if (activity.getRootView().hasWindowFocus()) {
if (activity.getRootView().hasWindowFocus() || mSwipeSharedState.goingToLauncher) {
return new OverviewInputConsumer(activity, mInputMonitorCompat,
false /* startingInActivityBounds */);
} else {
@@ -630,7 +639,8 @@ public class TouchInteractionService extends Service implements
*/
private void onConsumerInactive(InputConsumer caller) {
if (mConsumer == caller) {
mConsumer = InputConsumer.NO_OP;
mConsumer = mResetGestureInputConsumer;
mUncheckedConsumer = mConsumer;
}
}
@@ -666,6 +676,13 @@ public class TouchInteractionService extends Service implements
mSwipeSharedState.dump(" ", pw);
}
pw.println(" mConsumer=" + mConsumer.getName());
pw.println("FeatureFlags:");
pw.println(" APPLY_CONFIG_AT_RUNTIME=" + APPLY_CONFIG_AT_RUNTIME.get());
pw.println(" QUICKSTEP_SPRINGS=" + QUICKSTEP_SPRINGS.get());
pw.println(" ADAPTIVE_ICON_WINDOW_ANIM=" + ADAPTIVE_ICON_WINDOW_ANIM.get());
pw.println(" ENABLE_QUICKSTEP_LIVE_TILE=" + ENABLE_QUICKSTEP_LIVE_TILE.get());
pw.println(" ENABLE_HINTS_IN_OVERVIEW=" + ENABLE_HINTS_IN_OVERVIEW.get());
pw.println(" FAKE_LANDSCAPE_UI=" + FAKE_LANDSCAPE_UI.get());
TOUCH_INTERACTION_LOG.dump("", pw);
}
@@ -21,7 +21,6 @@ import static com.android.launcher3.Utilities.SINGLE_FRAME_MS;
import static com.android.launcher3.Utilities.postAsyncCallback;
import static com.android.launcher3.anim.Interpolators.ACCEL_1_5;
import static com.android.launcher3.anim.Interpolators.DEACCEL;
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2;
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
@@ -218,7 +217,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
Math.min(1 / MIN_PROGRESS_FOR_OVERVIEW, 1 / (1 - MIN_PROGRESS_FOR_OVERVIEW));
private static final String SCREENSHOT_CAPTURED_EVT = "ScreenshotCaptured";
private static final long SHELF_ANIM_DURATION = 120;
private static final long SHELF_ANIM_DURATION = 240;
public static final long RECENTS_ATTACH_DURATION = 300;
// Start resisting when swiping past this factor of mTransitionDragLength.
@@ -602,7 +601,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
}
public void onMotionPauseChanged(boolean isPaused) {
setShelfState(isPaused ? PEEK : HIDE, FAST_OUT_SLOW_IN, SHELF_ANIM_DURATION);
setShelfState(isPaused ? PEEK : HIDE, OVERSHOOT_1_2, SHELF_ANIM_DURATION);
}
public void maybeUpdateRecentsAttachedState() {
@@ -625,7 +624,10 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
: mRecentsAnimationWrapper.targetSet.findTask(mRunningTaskId);
final boolean recentsAttachedToAppWindow;
int runningTaskIndex = mRecentsView.getRunningTaskIndex();
if (mContinuingLastGesture) {
if (mGestureEndTarget != null) {
recentsAttachedToAppWindow = mGestureEndTarget.recentsAttachedToAppWindow;
} else if (mContinuingLastGesture
&& mRecentsView.getRunningTaskIndex() != mRecentsView.getNextPage()) {
recentsAttachedToAppWindow = true;
animate = false;
} else if (runningTaskTarget != null && isNotInRecents(runningTaskTarget)) {
@@ -633,17 +635,16 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
recentsAttachedToAppWindow = true;
animate = false;
} else {
if (mGestureEndTarget != null) {
recentsAttachedToAppWindow = mGestureEndTarget.recentsAttachedToAppWindow;
} else {
recentsAttachedToAppWindow = mIsShelfPeeking || mIsLikelyToStartNewTask;
}
recentsAttachedToAppWindow = mIsShelfPeeking || mIsLikelyToStartNewTask;
if (animate) {
// Only animate if an adjacent task view is visible on screen.
TaskView adjacentTask1 = mRecentsView.getTaskViewAt(runningTaskIndex + 1);
TaskView adjacentTask2 = mRecentsView.getTaskViewAt(runningTaskIndex - 1);
float prevTranslationX = mRecentsView.getTranslationX();
mRecentsView.setTranslationX(0);
animate = (adjacentTask1 != null && adjacentTask1.getGlobalVisibleRect(TEMP_RECT))
|| (adjacentTask2 != null && adjacentTask2.getGlobalVisibleRect(TEMP_RECT));
mRecentsView.setTranslationX(prevTranslationX);
}
}
mAnimationFactory.setRecentsAttachedToAppWindow(recentsAttachedToAppWindow, animate);
@@ -701,13 +702,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
SwipeAnimationTargetSet controller = mRecentsAnimationWrapper.getController();
if (controller != null) {
float offsetX = 0;
if (mRecentsView != null) {
int startScroll = mRecentsView.getScrollForPage(mRecentsView.indexOfChild(
mRecentsView.getRunningTaskView()));
offsetX = startScroll - mRecentsView.getScrollX();
offsetX *= mRecentsView.getScaleX();
}
float offsetX = mRecentsView == null ? 0 : mRecentsView.getScrollOffset();
float offsetScale = getTaskCurveScaleForOffsetX(offsetX,
mClipAnimationHelper.getTargetRect().width());
mTransformParams.setProgress(shift).setOffsetX(offsetX).setOffsetScale(offsetScale);
@@ -751,6 +746,9 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
? 0 : (progress - mShiftAtGestureStart) / (1 - mShiftAtGestureStart));
}
/**
* @param windowProgress 0 == app, 1 == overview
*/
private void updateSysUiFlags(float windowProgress) {
if (mRecentsView != null) {
TaskView centermostTask = mRecentsView.getTaskViewAt(mRecentsView
@@ -873,9 +871,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
@UiThread
private InputConsumer createNewInputProxyHandler() {
endRunningWindowAnim();
if (mLauncherTransitionController != null) {
mLauncherTransitionController.getAnimationPlayer().end();
}
endLauncherTransitionController();
if (!ENABLE_QUICKSTEP_LIVE_TILE.get()) {
// Hide the task view, if not already hidden
setTargetAlphaProvider(WindowTransformSwipeHandler::getHiddenTargetAlpha);
@@ -1217,6 +1213,9 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
if (mRecentsView != null) {
mRecentsView.post(mRecentsView::resetTaskVisuals);
}
// Make sure recents is in its final state
maybeUpdateRecentsAttachedState(false);
mActivityControlHelper.onSwipeUpToHomeComplete(mActivity);
}
});
return anim;
@@ -1251,7 +1250,17 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
if (!mCanceled) {
TaskView nextTask = mRecentsView.getTaskView(taskId);
if (nextTask != null) {
nextTask.launchTask(false /* animate */, true /* freezeTaskList */);
nextTask.launchTask(false /* animate */, true /* freezeTaskList */,
success -> {
if (!success) {
// We couldn't launch the task, so take user to overview so they can
// decide what to do instead of staying in this broken state.
endLauncherTransitionController();
mActivityControlHelper.onLaunchTaskFailed(mActivity);
nextTask.notifyTaskLaunchFailed(TAG);
updateSysUiFlags(1 /* windowProgress == overview */);
}
}, mMainThreadHandler);
doLogGesture(NEW_TASK);
}
reset();
@@ -1314,6 +1323,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
}
private void endLauncherTransitionController() {
setShelfState(ShelfAnimState.CANCEL, LINEAR, 0);
if (mLauncherTransitionController != null) {
mLauncherTransitionController.getAnimationPlayer().end();
mLauncherTransitionController = null;
@@ -32,6 +32,19 @@ public interface InputConsumer {
int TYPE_ACCESSIBILITY = 1 << 5;
int TYPE_SCREEN_PINNED = 1 << 6;
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;
@@ -66,23 +79,15 @@ public interface InputConsumer {
}
default String getName() {
switch (getType()) {
case TYPE_OVERVIEW:
return "OVERVIEW";
case TYPE_OTHER_ACTIVITY:
return "OTHER_ACTIVITY";
case TYPE_ASSISTANT:
return "ASSISTANT";
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";
String name = "";
for (int i = 0; i < NAMES.length; i++) {
if ((getType() & (1 << i)) != 0) {
if (name.length() > 0) {
name += ":";
}
name += NAMES[i];
}
}
return name;
}
}
@@ -27,7 +27,6 @@ import androidx.annotation.Nullable;
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.Utilities;
import com.android.launcher3.views.BaseDragLayer;
import com.android.quickstep.ActivityControlHelper;
import com.android.quickstep.OverviewCallbacks;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.InputMonitorCompat;
@@ -114,13 +113,5 @@ public class OverviewInputConsumer<T extends BaseDraggingActivity>
mActivity.dispatchKeyEvent(ev);
}
}
public static InputConsumer newInstanceWithinActivityBounds(
ActivityControlHelper activityHelper) {
BaseDraggingActivity activity = activityHelper.getCreatedActivity();
if (activity == null) {
return InputConsumer.NO_OP;
}
return new OverviewInputConsumer(activity, null, true);
}
}
@@ -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();
}
}
}
@@ -192,6 +192,7 @@ public class ClipAnimationHelper {
float cornerRadius = 0f;
float scale = Math.max(params.currentRect.width(), mTargetRect.width()) / crop.width();
if (app.mode == targetSet.targetMode) {
alpha = mTaskAlphaCallback.apply(app, params.targetAlpha);
if (app.activityType != RemoteAnimationTargetCompat.ACTIVITY_TYPE_HOME) {
mTmpMatrix.setRectToRect(mSourceRect, params.currentRect, ScaleToFit.FILL);
mTmpMatrix.postTranslate(app.position.x, app.position.y);
@@ -208,8 +209,11 @@ public class ClipAnimationHelper {
}
mCurrentCornerRadius = cornerRadius;
}
} else if (targetSet.hasRecents) {
// If home has a different target then recents, reverse anim the
// home target.
alpha = 1 - (progress * params.targetAlpha);
}
alpha = mTaskAlphaCallback.apply(app, params.targetAlpha);
} else if (ENABLE_QUICKSTEP_LIVE_TILE.get() && launcherOnTop) {
crop = null;
layer = Integer.MAX_VALUE;
@@ -49,6 +49,8 @@ public class RecentsAnimationListenerSet implements RecentsAnimationListener {
private final Consumer<SwipeAnimationTargetSet> mOnFinishListener;
private RecentsAnimationControllerCompat mController;
private boolean mCancelled;
public RecentsAnimationListenerSet(boolean shouldMinimizeSplitScreen,
Consumer<SwipeAnimationTargetSet> onFinishListener) {
mShouldMinimizeSplitScreen = shouldMinimizeSplitScreen;
@@ -75,11 +77,16 @@ public class RecentsAnimationListenerSet implements RecentsAnimationListener {
SwipeAnimationTargetSet targetSet = new SwipeAnimationTargetSet(controller, targets,
homeContentInsets, minimizedHomeBounds, mShouldMinimizeSplitScreen,
mOnFinishListener);
Utilities.postAsyncCallback(MAIN_THREAD_EXECUTOR.getHandler(), () -> {
for (SwipeAnimationListener listener : getListeners()) {
listener.onRecentsAnimationStart(targetSet);
}
});
if (mCancelled) {
targetSet.cancelAnimation();
} else {
Utilities.postAsyncCallback(MAIN_THREAD_EXECUTOR.getHandler(), () -> {
for (SwipeAnimationListener listener : getListeners()) {
listener.onRecentsAnimationStart(targetSet);
}
});
}
}
@Override
@@ -99,4 +106,9 @@ public class RecentsAnimationListenerSet implements RecentsAnimationListener {
private SwipeAnimationListener[] getListeners() {
return mListeners.toArray(new SwipeAnimationListener[mListeners.size()]);
}
public void cancelListener() {
mCancelled = true;
onAnimationCanceled(false);
}
}
@@ -36,7 +36,6 @@ public class SwipeAnimationTargetSet extends RemoteAnimationTargetSet {
private final boolean mShouldMinimizeSplitScreen;
private final Consumer<SwipeAnimationTargetSet> mOnFinishListener;
public final RecentsAnimationControllerCompat controller;
public final Rect homeContentInsets;
public final Rect minimizedHomeBounds;
@@ -103,6 +102,10 @@ public class SwipeAnimationTargetSet extends RemoteAnimationTargetSet {
return controller != null ? controller.screenshotTask(taskId) : null;
}
public void cancelAnimation() {
finishController(false /* toRecents */, null, false /* sendUserLeaveHint */);
}
public interface SwipeAnimationListener {
void onRecentsAnimationStart(SwipeAnimationTargetSet targetSet);
@@ -37,7 +37,7 @@ import android.widget.TextView;
import androidx.annotation.StringRes;
import com.android.launcher3.Launcher;
import com.android.launcher3.BaseActivity;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.userevent.nano.LauncherLogProto;
@@ -187,12 +187,12 @@ public final class DigitalWellBeingToast extends LinearLayout {
mTask.getTopComponent().getPackageName()).addFlags(
Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
try {
final Launcher launcher = Launcher.getLauncher(getContext());
final BaseActivity activity = BaseActivity.fromContext(getContext());
final ActivityOptions options = ActivityOptions.makeScaleUpAnimation(
this, 0, 0,
getWidth(), getHeight());
launcher.startActivity(intent, options.toBundle());
launcher.getUserEventDispatcher().logActionOnControl(LauncherLogProto.Action.Touch.TAP,
activity.startActivity(intent, options.toBundle());
activity.getUserEventDispatcher().logActionOnControl(LauncherLogProto.Action.Touch.TAP,
LauncherLogProto.ControlType.APP_USAGE_SETTINGS, this);
} catch (ActivityNotFoundException e) {
Log.e(TAG, "Failed to open app usage settings for task "
@@ -892,7 +892,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
mRunningTaskTileHidden = isHidden;
TaskView runningTask = getRunningTaskView();
if (runningTask != null) {
runningTask.setAlpha(isHidden ? 0 : mContentAlpha);
runningTask.setStableAlpha(isHidden ? 0 : mContentAlpha);
}
}
@@ -1294,7 +1294,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
for (int i = getTaskViewCount() - 1; i >= 0; i--) {
TaskView child = getTaskViewAt(i);
if (!mRunningTaskTileHidden || child.getTask().key.id != mRunningTaskId) {
getChildAt(i).setAlpha(alpha);
child.setStableAlpha(alpha);
}
}
mClearAllButton.setContentAlpha(mContentAlpha);
@@ -1676,6 +1676,16 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
return mClearAllButton;
}
/**
* @return How many pixels the running task is offset on the x-axis due to the current scrollX.
*/
public float getScrollOffset() {
int startScroll = getScrollForPage(getRunningTaskIndex());
int offsetX = startScroll - getScrollX();
offsetX *= getScaleX();
return offsetX;
}
public Consumer<MotionEvent> getEventDispatcher(RotationMode rotationMode) {
if (rotationMode.isTransposed) {
Matrix transform = new Matrix();
@@ -252,7 +252,7 @@ public class TaskThumbnailView extends View {
}
}
protected TaskView getTaskView() {
public TaskView getTaskView() {
return (TaskView) getParent();
}
@@ -163,6 +163,7 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
private ObjectAnimator mIconAndDimAnimator;
private float mIconScaleAnimStartProgress = 0;
private float mFocusTransitionProgress = 1;
private float mStableAlpha = 1;
private boolean mShowScreenshot;
@@ -353,14 +354,15 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
mIconLoadRequest = iconCache.updateIconInBackground(mTask,
(task) -> {
setIcon(task.icon);
if (isRunningTask()) {
if (ENABLE_QUICKSTEP_LIVE_TILE.get() && isRunningTask()) {
getRecentsView().updateLiveTileIcon(task.icon);
}
mDigitalWellBeingToast.initialize(
mTask,
contentDescription -> {
setContentDescription(contentDescription);
if (mDigitalWellBeingToast.getVisibility() == VISIBLE) {
if (mDigitalWellBeingToast.getVisibility() == VISIBLE
&& getRecentsView() != null) {
getRecentsView().onDigitalWellbeingToastShown();
}
});
@@ -468,7 +470,7 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
setTranslationX(0f);
setTranslationY(0f);
setTranslationZ(0);
setAlpha(1f);
setAlpha(mStableAlpha);
setIconScaleAndDim(1);
}
@@ -477,6 +479,11 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
setFullscreenProgress(0);
}
public void setStableAlpha(float parentAlpha) {
mStableAlpha = parentAlpha;
setAlpha(mStableAlpha);
}
@Override
public void onRecycle() {
resetViewTransforms();
@@ -498,6 +505,8 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
mSnapshotView.setDimAlpha(curveInterpolation * MAX_PAGE_SCRIM_ALPHA);
setCurveScale(getCurveScaleForCurveInterpolation(curveInterpolation));
float fade = Utilities.boundToRange(1.0f - 2 * scrollState.linearInterpolation, 0f, 1f);
mTaskFooterContainer.setAlpha(fade);
if (mMenuView != null) {
mMenuView.setPosition(getX() - getRecentsView().getScrollX(), getY());
mMenuView.setScaleX(getScaleX());
@@ -716,6 +725,9 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
}
public boolean isRunningTask() {
if (getRecentsView() == null) {
return false;
}
return this == getRecentsView().getRunningTaskView();
}
+2
View File
@@ -40,6 +40,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:animateLayoutChanges="true"
android:forceHasOverlappingRendering="true"
android:layout_gravity="bottom|center_horizontal">
<FrameLayout
android:id="@+id/proactive_suggest_container"
@@ -31,7 +31,7 @@ public class StartActivityParams implements Parcelable {
private static final String TAG = "StartActivityParams";
private final PendingIntent mCallback;
private final PendingIntent mPICallback;
public final int requestCode;
public Intent intent;
@@ -44,13 +44,17 @@ public class StartActivityParams implements Parcelable {
public Bundle options;
public StartActivityParams(Activity activity, int requestCode) {
mCallback = activity.createPendingResult(requestCode, new Intent(),
PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT);
this(activity.createPendingResult(requestCode, new Intent(),
PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT), requestCode);
}
public StartActivityParams(PendingIntent pendingIntent, int requestCode) {
this.mPICallback = pendingIntent;
this.requestCode = requestCode;
}
private StartActivityParams(Parcel parcel) {
mCallback = parcel.readTypedObject(PendingIntent.CREATOR);
mPICallback = parcel.readTypedObject(PendingIntent.CREATOR);
requestCode = parcel.readInt();
intent = parcel.readTypedObject(Intent.CREATOR);
@@ -70,7 +74,7 @@ public class StartActivityParams implements Parcelable {
@Override
public void writeToParcel(Parcel parcel, int flags) {
parcel.writeTypedObject(mCallback, flags);
parcel.writeTypedObject(mPICallback, flags);
parcel.writeInt(requestCode);
parcel.writeTypedObject(intent, flags);
@@ -84,7 +88,9 @@ public class StartActivityParams implements Parcelable {
public void deliverResult(Context context, int resultCode, Intent data) {
try {
mCallback.send(context, resultCode, data);
if (mPICallback != null) {
mPICallback.send(context, resultCode, data);
}
} catch (CanceledException e) {
Log.e(TAG, "Unable to send back result", e);
}
@@ -53,6 +53,7 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> {
void onSwipeUpToRecentsComplete(T activity);
default void onSwipeUpToHomeComplete(T activity) { }
void onAssistantVisibilityChanged(float visibility);
@NonNull HomeAnimationFactory prepareHomeUI(T activity);
@@ -92,6 +93,8 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> {
boolean isInLiveTileMode();
void onLaunchTaskFailed(T activity);
interface ActivityInitListener {
void register();
@@ -33,20 +33,26 @@ public class RemoteAnimationTargetSet {
public final RemoteAnimationTargetCompat[] unfilteredApps;
public final RemoteAnimationTargetCompat[] apps;
public final int targetMode;
public final boolean hasRecents;
public RemoteAnimationTargetSet(RemoteAnimationTargetCompat[] apps, int targetMode) {
ArrayList<RemoteAnimationTargetCompat> filteredApps = new ArrayList<>();
boolean hasRecents = false;
if (apps != null) {
for (RemoteAnimationTargetCompat target : apps) {
if (target.mode == targetMode) {
filteredApps.add(target);
}
hasRecents |= target.activityType ==
RemoteAnimationTargetCompat.ACTIVITY_TYPE_RECENTS;
}
}
this.unfilteredApps = apps;
this.apps = filteredApps.toArray(new RemoteAnimationTargetCompat[filteredApps.size()]);
this.targetMode = targetMode;
this.hasRecents = hasRecents;
}
public RemoteAnimationTargetCompat findTask(int taskId) {
@@ -22,6 +22,7 @@ import static androidx.test.InstrumentationRegistry.getInstrumentation;
import static com.android.launcher3.tapl.LauncherInstrumentation.WAIT_TIME_MS;
import static com.android.launcher3.tapl.TestHelpers.getHomeIntentInPackage;
import static com.android.launcher3.tapl.TestHelpers.getLauncherInMyProcess;
import static com.android.launcher3.ui.AbstractLauncherUiTest.resolveSystemApp;
import static com.android.launcher3.util.rule.ShellCommandRule.disableHeadsUpNotification;
import static com.android.launcher3.util.rule.ShellCommandRule.getLauncherCommand;
import static com.android.quickstep.NavigationModeSwitchRule.Mode.THREE_BUTTON;
@@ -108,7 +109,7 @@ public class FallbackRecentsTest {
@NavigationModeSwitch(mode = THREE_BUTTON)
@Test
public void goToOverviewFromApp() {
startAppFast("com.android.settings");
startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR));
mLauncher.getBackground().switchToOverview();
}
@@ -175,6 +175,10 @@ public abstract class BaseActivity extends Activity
mActivityFlags &= ~ACTIVITY_STATE_STARTED & ~ACTIVITY_STATE_USER_ACTIVE;
mForceInvisible = 0;
super.onStop();
// Reset the overridden sysui flags used for the task-swipe launch animation, this is a
// catch all for if we do not get resumed (and therefore not paused below)
getSystemUiController().updateUiState(UI_STATE_OVERVIEW, 0);
}
@Override
+10 -3
View File
@@ -461,13 +461,18 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
private void onIdpChanged(InvariantDeviceProfile idp) {
mUserEventDispatcher = null;
DeviceProfile oldWallpaperProfile = getWallpaperDeviceProfile();
initDeviceProfile(idp);
dispatchDeviceProfileChanged();
reapplyUi();
mDragLayer.recreateControllers();
// TODO: We can probably avoid rebind when only screen size changed.
rebindModel();
// Calling onSaveInstanceState ensures that static cache used by listWidgets is
// initialized properly.
onSaveInstanceState(new Bundle());
if (oldWallpaperProfile != getWallpaperDeviceProfile()) {
rebindModel();
}
}
public void onAssistantVisibilityChanged(float visibility) {
@@ -889,7 +894,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
mLauncherCallbacks.onStart();
}
mAppWidgetHost.setListenIfResumed(true);
NotificationListener.setNotificationsChangedListener(mPopupDataProvider);
RaceConditionTracker.onEvent(ON_START_EVT, EXIT);
}
@@ -909,6 +913,9 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
// Refresh shortcuts if the permission changed.
mModel.refreshShortcutsIfRequired();
// Set the notification listener and fetch updated notifications when we resume
NotificationListener.setNotificationsChangedListener(mPopupDataProvider);
DiscoveryBounce.showForHomeIfNeeded(this);
if (mPendingActivityRequestCode != -1 && isInState(NORMAL)) {
@@ -8,18 +8,22 @@ import android.app.ActivityManager;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Insets;
import android.graphics.Paint;
import android.graphics.Rect;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewDebug;
import android.view.WindowInsets;
import java.util.Collections;
import java.util.List;
public class LauncherRootView extends InsettableFrameLayout {
private final Rect mTempRect = new Rect();
private final Launcher mLauncher;
private final Paint mOpaquePaint;
@@ -56,9 +60,7 @@ public class LauncherRootView extends InsettableFrameLayout {
super.onFinishInflate();
}
@TargetApi(23)
@Override
protected boolean fitSystemWindows(Rect insets) {
private void handleSystemWindowInsets(Rect insets) {
mConsumedInsets.setEmpty();
boolean drawInsetBar = false;
if (mLauncher.isInMultiWindowMode()
@@ -66,13 +68,13 @@ public class LauncherRootView extends InsettableFrameLayout {
mConsumedInsets.left = insets.left;
mConsumedInsets.right = insets.right;
mConsumedInsets.bottom = insets.bottom;
insets = new Rect(0, insets.top, 0, 0);
insets.set(0, insets.top, 0, 0);
drawInsetBar = true;
} else if ((insets.right > 0 || insets.left > 0) &&
getContext().getSystemService(ActivityManager.class).isLowRamDevice()) {
mConsumedInsets.left = insets.left;
mConsumedInsets.right = insets.right;
insets = new Rect(0, insets.top, 0, insets.bottom);
insets.set(0, insets.top, 0, insets.bottom);
drawInsetBar = true;
}
@@ -99,8 +101,19 @@ public class LauncherRootView extends InsettableFrameLayout {
if (resetState) {
mLauncher.getStateManager().reapplyState(true /* cancelCurrentAnimation */);
}
}
return false; // Let children get the full insets
@Override
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
mTempRect.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
handleSystemWindowInsets(mTempRect);
if (Utilities.ATLEAST_Q) {
return insets.inset(mConsumedInsets.left, mConsumedInsets.top,
mConsumedInsets.right, mConsumedInsets.bottom);
} else {
return insets.replaceSystemWindowInsets(mTempRect);
}
}
@Override
@@ -49,6 +49,7 @@ import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.anim.PropertySetter.AnimatedPropertySetter;
import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.uioverrides.UiFactory;
@@ -496,6 +497,8 @@ public class LauncherStateManager {
for (int i = mListeners.size() - 1; i >= 0; i--) {
mListeners.get(i).onStateTransitionComplete(state);
}
AccessibilityManagerCompat.sendStateEventToTest(mLauncher, state.ordinal);
}
public void onWindowFocusChanged() {
@@ -37,6 +37,7 @@ import com.android.launcher3.DropTarget.DragObject;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.states.InternalStateHandler;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.widget.PendingItemDragHelper;
import java.util.UUID;
@@ -136,6 +137,9 @@ public abstract class BaseItemDragListener extends InternalStateHandler implemen
@Override
public boolean shouldStartDrag(double distanceDragged) {
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.NO_DRAG_TAG, "BIDL.shouldStartDrag");
}
// Stay in pre-drag mode, if workspace is locked.
return !mLauncher.isWorkspaceLocked();
}
@@ -36,6 +36,7 @@ import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Pair;
import android.view.MotionEvent;
import android.view.View;
@@ -67,6 +68,7 @@ import com.android.launcher3.popup.PopupDataProvider.PopupDataChangeListener;
import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.shortcuts.DeepShortcutView;
import com.android.launcher3.shortcuts.ShortcutDragPreviewProvider;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.touch.ItemClickHandler;
import com.android.launcher3.touch.ItemLongClickListener;
import com.android.launcher3.util.PackageUserKey;
@@ -447,6 +449,11 @@ public class PopupContainerWithArrow extends ArrowPopup implements DragSource,
@Override
public boolean shouldStartDrag(double distanceDragged) {
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.NO_DRAG_TAG,
"createPreDragCondition().shouldStartDrag " + distanceDragged + ", "
+ mStartDragThreshold);
}
return distanceDragged > mStartDragThreshold;
}
@@ -43,7 +43,6 @@ import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
@@ -541,7 +540,6 @@ public abstract class AbstractStateChangeTouchController
android.util.Log.e(
TestProtocol.NO_ALLAPPS_EVENT_TAG, "onSwipeInteractionCompleted 2");
}
AccessibilityManagerCompat.sendStateEventToTest(mLauncher, targetState.ordinal);
}
}
@@ -395,7 +395,7 @@ public abstract class AbstractLauncherUiTest {
DEFAULT_UI_TIMEOUT));
}
protected static String resolveSystemApp(String category) {
public static String resolveSystemApp(String category) {
return getInstrumentation().getContext().getPackageManager().resolveActivity(
new Intent(Intent.ACTION_MAIN).addCategory(category),
PackageManager.MATCH_SYSTEM_ONLY).
@@ -20,7 +20,6 @@ import android.graphics.Point;
import androidx.test.uiautomator.By;
import androidx.test.uiautomator.BySelector;
import androidx.test.uiautomator.UiDevice;
import androidx.test.uiautomator.UiObject2;
import androidx.test.uiautomator.Until;
@@ -70,11 +69,16 @@ abstract class Launchable {
* Drags an object to the center of homescreen.
*/
public Workspace dragToWorkspace() {
final UiDevice device = mLauncher.getDevice();
final Point launchableCenter = getObject().getVisibleCenter();
final Point displaySize = mLauncher.getRealDisplaySize();
final int width = displaySize.x / 2;
Workspace.dragIconToWorkspace(
mLauncher,
this,
new Point(device.getDisplayWidth() / 2, device.getDisplayHeight() / 2),
new Point(
launchableCenter.x >= width ?
launchableCenter.x - width / 2 : launchableCenter.x + width / 2,
displaySize.y / 2),
getLongPressIndicator());
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"dragged launchable to workspace")) {