summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2019-05-30 11:35:25 -0700
committerSunny Goyal <sunnygoyal@google.com>2019-05-30 11:59:29 -0700
commite9c6f4cc6965943c09b06765e380f695fccece51 (patch)
tree9941a22029b117cb4428ba6effd73418235b7cbd /src/com
parentf07cf179dce2f07a28dab0ad51065f093f74c884 (diff)
downloadandroid_packages_apps_Trebuchet-e9c6f4cc6965943c09b06765e380f695fccece51.tar.gz
android_packages_apps_Trebuchet-e9c6f4cc6965943c09b06765e380f695fccece51.tar.bz2
android_packages_apps_Trebuchet-e9c6f4cc6965943c09b06765e380f695fccece51.zip
Fixing interactive state for background states and
notifying LauncherCallback accordingly During quick switch Launcher can get resumed only to be paused again when launching a new app. Updating the logic for deferred resume to account for that and moving some additional calls to deferredResume Bug: 134062513 Change-Id: Ia607f178bc17d45d53fb032a06cd70f9abc6b513
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/launcher3/Launcher.java38
-rw-r--r--src/com/android/launcher3/LauncherCallbacks.java6
2 files changed, 28 insertions, 16 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 711cfd288..e6f583f47 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -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;
@@ -890,26 +891,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
@@ -923,14 +938,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();
}
diff --git a/src/com/android/launcher3/LauncherCallbacks.java b/src/com/android/launcher3/LauncherCallbacks.java
index edac516e1..dfe75ec34 100644
--- a/src/com/android/launcher3/LauncherCallbacks.java
+++ b/src/com/android/launcher3/LauncherCallbacks.java
@@ -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.
*/