Search in sources :

Example 31 with Wait

use of com.android.launcher3.util.Wait in project android_packages_apps_Launcher3 by AOSPA.

the class AbsSwipeUpHandler method onSettledOnEndTarget.

private void onSettledOnEndTarget() {
    // Fast-finish the attaching animation if it's still running.
    maybeUpdateRecentsAttachedState(false);
    final GestureEndTarget endTarget = mGestureState.getEndTarget();
    // Wait until the given View (if supplied) draws before resuming the last task.
    View postResumeLastTask = mActivityInterface.onSettledOnEndTarget(endTarget);
    if (endTarget != NEW_TASK) {
        InteractionJankMonitorWrapper.cancel(InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH);
    }
    if (endTarget != HOME) {
        InteractionJankMonitorWrapper.cancel(InteractionJankMonitorWrapper.CUJ_APP_CLOSE_TO_HOME);
    }
    switch(endTarget) {
        case HOME:
            mStateCallback.setState(STATE_SCALED_CONTROLLER_HOME | STATE_CAPTURE_SCREENSHOT);
            // Notify swipe-to-home (recents animation) is finished
            SystemUiProxy.INSTANCE.get(mContext).notifySwipeToHomeFinished();
            LauncherSplitScreenListener.INSTANCE.getNoCreate().notifySwipingToHome();
            break;
        case RECENTS:
            mStateCallback.setState(STATE_SCALED_CONTROLLER_RECENTS | STATE_CAPTURE_SCREENSHOT | STATE_SCREENSHOT_VIEW_SHOWN);
            break;
        case NEW_TASK:
            mStateCallback.setState(STATE_START_NEW_TASK | STATE_CAPTURE_SCREENSHOT);
            break;
        case LAST_TASK:
            if (postResumeLastTask != null) {
                ViewUtils.postFrameDrawn(postResumeLastTask, () -> mStateCallback.setState(STATE_RESUME_LAST_TASK));
            } else {
                mStateCallback.setState(STATE_RESUME_LAST_TASK);
            }
            if (mRecentsAnimationTargets != null) {
                TaskViewUtils.setSplitAuxiliarySurfacesShown(mRecentsAnimationTargets.nonApps, true, /*shown*/
                false);
            }
            break;
    }
    ActiveGestureLog.INSTANCE.addLog("onSettledOnEndTarget " + endTarget);
}
Also used : TaskView(com.android.quickstep.views.TaskView) View(android.view.View) RecentsView(com.android.quickstep.views.RecentsView) AbstractFloatingView(com.android.launcher3.AbstractFloatingView) GestureEndTarget(com.android.quickstep.GestureState.GestureEndTarget)

Example 32 with Wait

use of com.android.launcher3.util.Wait in project android_packages_apps_Launcher3 by ArrowOS.

the class TaplTestsLauncher3 method testDragShortcut.

@Test
@PortraitLandscape
public void testDragShortcut() throws Throwable {
    // 1. Open all apps and wait for load complete.
    // 2. Find the app and long press it to show shortcuts.
    // 3. Press icon center until shortcuts appear
    final AllApps allApps = mLauncher.getWorkspace().switchToAllApps();
    allApps.freeze();
    try {
        final AppIconMenu menu = allApps.getAppIcon(APP_NAME).openDeepShortcutMenu();
        final AppIconMenuItem menuItem0 = menu.getMenuItem(0);
        final AppIconMenuItem menuItem2 = menu.getMenuItem(2);
        final AppIconMenuItem menuItem;
        final String expectedShortcutName = "Shortcut 3";
        if (menuItem0.getText().equals(expectedShortcutName)) {
            menuItem = menuItem0;
        } else {
            final String shortcutName2 = menuItem2.getText();
            assertEquals("Wrong menu item", expectedShortcutName, shortcutName2);
            menuItem = menuItem2;
        }
        menuItem.dragToWorkspace(false, false);
        mLauncher.getWorkspace().getWorkspaceAppIcon(expectedShortcutName).launch(getAppPackageName());
    } finally {
        allApps.unfreeze();
    }
}
Also used : AllApps(com.android.launcher3.tapl.AllApps) AppIconMenu(com.android.launcher3.tapl.AppIconMenu) AppIconMenuItem(com.android.launcher3.tapl.AppIconMenuItem) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Example 33 with Wait

use of com.android.launcher3.util.Wait in project android_packages_apps_Launcher3 by ArrowOS.

the class TaplTestsLauncher3 method testDragAppIcon.

@Test
@PortraitLandscape
public void testDragAppIcon() throws Throwable {
    // 1. Open all apps and wait for load complete.
    // 2. Drag icon to homescreen.
    // 3. Verify that the icon works on homescreen.
    final AllApps allApps = mLauncher.getWorkspace().switchToAllApps();
    allApps.freeze();
    try {
        allApps.getAppIcon(APP_NAME).dragToWorkspace(false, false);
        mLauncher.getWorkspace().getWorkspaceAppIcon(APP_NAME).launch(getAppPackageName());
    } finally {
        allApps.unfreeze();
    }
    executeOnLauncher(launcher -> assertTrue("Launcher activity is the top activity; expecting another activity to be the top " + "one", isInBackground(launcher)));
}
Also used : AllApps(com.android.launcher3.tapl.AllApps) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Example 34 with Wait

use of com.android.launcher3.util.Wait in project android_packages_apps_Launcher3 by ArrowOS.

the class AbsSwipeUpHandler method onLauncherStart.

private void onLauncherStart() {
    final T activity = mActivityInterface.getCreatedActivity();
    if (mActivity != activity) {
        return;
    }
    if (mStateCallback.hasStates(STATE_HANDLER_INVALIDATED)) {
        return;
    }
    // RecentsView never updates the display rotation until swipe-up, force update
    // RecentsOrientedState before passing to TaskViewSimulator.
    mRecentsView.updateRecentsRotation();
    runActionOnRemoteHandles(remoteTargetHandle -> remoteTargetHandle.getTaskViewSimulator().setOrientationState(mRecentsView.getPagedViewOrientedState()));
    // as that will set the state as BACKGROUND_APP, overriding the animation to NORMAL.
    if (mGestureState.getEndTarget() != HOME) {
        Runnable initAnimFactory = () -> {
            mAnimationFactory = mActivityInterface.prepareRecentsUI(mDeviceState, mWasLauncherAlreadyVisible, this::onAnimatorPlaybackControllerCreated);
            maybeUpdateRecentsAttachedState(false);
            if (mGestureState.getEndTarget() != null) {
                // Update the end target in case the gesture ended before we init.
                mAnimationFactory.setEndTarget(mGestureState.getEndTarget());
            }
        };
        if (mWasLauncherAlreadyVisible) {
            // Launcher is visible, but might be about to stop. Thus, if we prepare recents
            // now, it might get overridden by moveToRestState() in onStop(). To avoid this,
            // wait until the next gesture (and possibly launcher) starts.
            mStateCallback.runOnceAtState(STATE_GESTURE_STARTED, initAnimFactory);
        } else {
            initAnimFactory.run();
        }
    }
    AbstractFloatingView.closeAllOpenViewsExcept(activity, mWasLauncherAlreadyVisible, AbstractFloatingView.TYPE_LISTENER);
    if (mWasLauncherAlreadyVisible) {
        mStateCallback.setState(STATE_LAUNCHER_DRAWN);
    } else {
        Object traceToken = TraceHelper.INSTANCE.beginSection("WTS-init");
        View dragLayer = activity.getDragLayer();
        dragLayer.getViewTreeObserver().addOnDrawListener(new OnDrawListener() {

            boolean mHandled = false;

            @Override
            public void onDraw() {
                if (mHandled) {
                    return;
                }
                mHandled = true;
                TraceHelper.INSTANCE.endSection(traceToken);
                dragLayer.post(() -> dragLayer.getViewTreeObserver().removeOnDrawListener(this));
                if (activity != mActivity) {
                    return;
                }
                mStateCallback.setState(STATE_LAUNCHER_DRAWN);
            }
        });
    }
    activity.getRootView().setOnApplyWindowInsetsListener(this);
    mStateCallback.setState(STATE_LAUNCHER_STARTED);
}
Also used : LAUNCHER_QUICKSWITCH_RIGHT(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_QUICKSWITCH_RIGHT) STATE_END_TARGET_SET(com.android.quickstep.GestureState.STATE_END_TARGET_SET) LAUNCHER_QUICKSWITCH_LEFT(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_QUICKSWITCH_LEFT) LENGTH_SHORT(android.widget.Toast.LENGTH_SHORT) OnDrawListener(android.view.ViewTreeObserver.OnDrawListener) TaskView(com.android.quickstep.views.TaskView) View(android.view.View) RecentsView(com.android.quickstep.views.RecentsView) AbstractFloatingView(com.android.launcher3.AbstractFloatingView)

Example 35 with Wait

use of com.android.launcher3.util.Wait in project android_packages_apps_Launcher3 by ArrowOS.

the class AbsSwipeUpHandler method onSettledOnEndTarget.

private void onSettledOnEndTarget() {
    // Fast-finish the attaching animation if it's still running.
    maybeUpdateRecentsAttachedState(false);
    final GestureEndTarget endTarget = mGestureState.getEndTarget();
    // Wait until the given View (if supplied) draws before resuming the last task.
    View postResumeLastTask = mActivityInterface.onSettledOnEndTarget(endTarget);
    if (endTarget != NEW_TASK) {
        InteractionJankMonitorWrapper.cancel(InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH);
    }
    if (endTarget != HOME) {
        InteractionJankMonitorWrapper.cancel(InteractionJankMonitorWrapper.CUJ_APP_CLOSE_TO_HOME);
    }
    switch(endTarget) {
        case HOME:
            mStateCallback.setState(STATE_SCALED_CONTROLLER_HOME | STATE_CAPTURE_SCREENSHOT);
            // Notify swipe-to-home (recents animation) is finished
            SystemUiProxy.INSTANCE.get(mContext).notifySwipeToHomeFinished();
            LauncherSplitScreenListener.INSTANCE.getNoCreate().notifySwipingToHome();
            break;
        case RECENTS:
            mStateCallback.setState(STATE_SCALED_CONTROLLER_RECENTS | STATE_CAPTURE_SCREENSHOT | STATE_SCREENSHOT_VIEW_SHOWN);
            break;
        case NEW_TASK:
            mStateCallback.setState(STATE_START_NEW_TASK | STATE_CAPTURE_SCREENSHOT);
            break;
        case LAST_TASK:
            if (postResumeLastTask != null) {
                ViewUtils.postFrameDrawn(postResumeLastTask, () -> mStateCallback.setState(STATE_RESUME_LAST_TASK));
            } else {
                mStateCallback.setState(STATE_RESUME_LAST_TASK);
            }
            if (mRecentsAnimationTargets != null) {
                TaskViewUtils.setSplitAuxiliarySurfacesShown(mRecentsAnimationTargets.nonApps, true, /*shown*/
                false);
            }
            break;
    }
    ActiveGestureLog.INSTANCE.addLog("onSettledOnEndTarget " + endTarget);
}
Also used : TaskView(com.android.quickstep.views.TaskView) View(android.view.View) RecentsView(com.android.quickstep.views.RecentsView) AbstractFloatingView(com.android.launcher3.AbstractFloatingView) GestureEndTarget(com.android.quickstep.GestureState.GestureEndTarget)

Aggregations

LargeTest (androidx.test.filters.LargeTest)14 AllApps (com.android.launcher3.tapl.AllApps)14 Test (org.junit.Test)14 View (android.view.View)11 AbstractFloatingView (com.android.launcher3.AbstractFloatingView)11 RecentsView (com.android.quickstep.views.RecentsView)11 TaskView (com.android.quickstep.views.TaskView)11 AppWidgetProviderInfo (android.appwidget.AppWidgetProviderInfo)8 ComponentName (android.content.ComponentName)8 CancellationException (java.util.concurrent.CancellationException)8 ContentResolver (android.content.ContentResolver)7 Context (android.content.Context)7 Intent (android.content.Intent)7 SessionInfo (android.content.pm.PackageInstaller.SessionInfo)7 ShortcutInfo (android.content.pm.ShortcutInfo)7 UserHandle (android.os.UserHandle)7 LongSparseArray (android.util.LongSparseArray)7 OnDrawListener (android.view.ViewTreeObserver.OnDrawListener)7 FolderGridOrganizer (com.android.launcher3.folder.FolderGridOrganizer)7 ShortcutKey (com.android.launcher3.shortcuts.ShortcutKey)7