Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f36e5e00 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fixing interactive state for background states and notifying...

Merge "Fixing interactive state for background states and notifying LauncherCallback accordingly" into ub-launcher3-qt-dev
parents 2ff7b53e e9c6f4cc
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -32,7 +32,8 @@ import com.android.quickstep.views.TaskView;
public class BackgroundAppState extends OverviewState {

    private static final int STATE_FLAGS =
            FLAG_DISABLE_RESTORE | FLAG_OVERVIEW_UI | FLAG_DISABLE_ACCESSIBILITY;
            FLAG_DISABLE_RESTORE | FLAG_OVERVIEW_UI | FLAG_DISABLE_ACCESSIBILITY
                    | FLAG_DISABLE_INTERACTION;

    public BackgroundAppState(int id) {
        this(id, LauncherLogProto.ContainerType.TASKSWITCHER);
+23 −15
Original line number Diff line number Diff line
@@ -277,6 +277,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,

    final Handler mHandler = new Handler();
    private final Runnable mHandleDeferredResume = this::handleDeferredResume;
    private boolean mDeferredResumePending;

    private float mCurrentAssistantVisibility = 0f;

@@ -889,26 +890,40 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
    }

    private void handleDeferredResume() {
        if (hasBeenResumed()) {
        if (hasBeenResumed() && !mStateManager.getState().disableInteraction) {
            getUserEventDispatcher().logActionCommand(Action.Command.RESUME,
                    mStateManager.getState().containerType, -1);
            getUserEventDispatcher().startSession();

            UiFactory.onLauncherStateOrResumeChanged(this);
            AppLaunchTracker.INSTANCE.get(this).onReturnedToHome();
            resetPendingActivityResultIfNeeded();
        }
    }

    private void resetPendingActivityResultIfNeeded() {
        if (hasBeenResumed() && mPendingActivityRequestCode != -1 && isInState(NORMAL)) {
            // Process any items that were added while Launcher was away.
            InstallShortcutReceiver.disableAndFlushInstallQueue(
                    InstallShortcutReceiver.FLAG_ACTIVITY_PAUSED, this);

            // Refresh shortcuts if the permission changed.
            mModel.refreshShortcutsIfRequired();

            DiscoveryBounce.showForHomeIfNeeded(this);

            if (mPendingActivityRequestCode != -1 && isInState(NORMAL)) {
                UiFactory.resetPendingActivityResults(this, mPendingActivityRequestCode);
            }
            mDeferredResumePending = false;
        } else {
            mDeferredResumePending = true;
        }
    }

    protected void onStateSet(LauncherState state) {
        getAppWidgetHost().setResumed(state == LauncherState.NORMAL);
        resetPendingActivityResultIfNeeded();
        if (mDeferredResumePending) {
            handleDeferredResume();
        }
        if (mLauncherCallbacks != null) {
            mLauncherCallbacks.onStateChanged();
        }
    }

    @Override
@@ -922,14 +937,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
        Utilities.postAsyncCallback(mHandler, mHandleDeferredResume);

        setOnResumeCallback(null);
        // Process any items that were added while Launcher was away.
        InstallShortcutReceiver.disableAndFlushInstallQueue(
                InstallShortcutReceiver.FLAG_ACTIVITY_PAUSED, this);

        // Refresh shortcuts if the permission changed.
        mModel.refreshShortcutsIfRequired();

        DiscoveryBounce.showForHomeIfNeeded(this);
        if (mLauncherCallbacks != null) {
            mLauncherCallbacks.onResume();
        }
+5 −1
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.os.Bundle;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;

/**
 * LauncherCallbacks is an interface used to extend the Launcher activity. It includes many hooks
@@ -53,6 +52,11 @@ public interface LauncherCallbacks {
    boolean handleBackPressed();
    void onTrimMemory(int level);

    /**
     * Called when the launcher state changed
     */
    default void onStateChanged() { }

    /*
     * Extension points for providing custom behavior on certain user interactions.
     */