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

Commit 1343a696 authored by Sunny Goyal's avatar Sunny Goyal Committed by android-build-merger
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
am: f36e5e00

Change-Id: I7cf80c0047fce5c189dcaf0c77d3642300eaa458
parents 88c2fd60 f36e5e00
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -32,7 +32,8 @@ import com.android.quickstep.views.TaskView;
public class BackgroundAppState extends OverviewState {
public class BackgroundAppState extends OverviewState {


    private static final int STATE_FLAGS =
    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) {
    public BackgroundAppState(int id) {
        this(id, LauncherLogProto.ContainerType.TASKSWITCHER);
        this(id, LauncherLogProto.ContainerType.TASKSWITCHER);
+23 −15
Original line number Original line Diff line number Diff line
@@ -277,6 +277,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,


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


    private float mCurrentAssistantVisibility = 0f;
    private float mCurrentAssistantVisibility = 0f;


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


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


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


    private void resetPendingActivityResultIfNeeded() {
            // Process any items that were added while Launcher was away.
        if (hasBeenResumed() && mPendingActivityRequestCode != -1 && isInState(NORMAL)) {
            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);
                UiFactory.resetPendingActivityResults(this, mPendingActivityRequestCode);
            }
            }
            mDeferredResumePending = false;
        } else {
            mDeferredResumePending = true;
        }
    }
    }


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


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


        setOnResumeCallback(null);
        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) {
        if (mLauncherCallbacks != null) {
            mLauncherCallbacks.onResume();
            mLauncherCallbacks.onResume();
        }
        }
+5 −1
Original line number Original line Diff line number Diff line
@@ -21,7 +21,6 @@ import android.os.Bundle;


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


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


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

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