Merge "Fixing interactive state for background states and notifying LauncherCallback accordingly" into ub-launcher3-qt-dev

This commit is contained in:
TreeHugger Robot
2019-05-31 06:01:25 +00:00
committed by Android (Google) Code Review
3 changed files with 30 additions and 17 deletions
@@ -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
View File
@@ -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)) {
UiFactory.resetPendingActivityResults(this, mPendingActivityRequestCode);
// 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();
}
@@ -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.
*/