From 1a3bde55c1647905a0cf590b51ad04d0bae24100 Mon Sep 17 00:00:00 2001 From: Samuel Fufa Date: Mon, 3 Feb 2020 12:20:05 -0800 Subject: [PATCH] Prevent prediction updates while app is launching Bug:148800229 Change-Id: Ide9d029139f5d25ac39c276b90b2a514c2679dc9 --- .../HotseatPredictionController.java | 13 ++++++++++++- .../uioverrides/QuickstepLauncher.java | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java index 109439f41b..f567a493da 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java @@ -108,6 +108,7 @@ public class HotseatPredictionController implements DragController.DragListener, private AppPredictor mAppPredictor; private AllAppsStore mAllAppsStore; private AnimatorSet mIconRemoveAnimators; + private boolean mUIUpdatePaused = false; private HotseatEduController mHotseatEduController; @@ -167,7 +168,7 @@ public class HotseatPredictionController implements DragController.DragListener, } private void fillGapsWithPrediction(boolean animate, Runnable callback) { - if (!isReady() || mDragObject != null) { + if (!isReady() || mUIUpdatePaused || mDragObject != null) { return; } List predictedApps = mapToWorkspaceItemInfo(mComponentKeyMappers); @@ -248,6 +249,16 @@ public class HotseatPredictionController implements DragController.DragListener, } } + /** + * start and pauses predicted apps update on the hotseat + */ + public void setPauseUIUpdate(boolean paused) { + mUIUpdatePaused = paused; + if (!paused) { + fillGapsWithPrediction(); + } + } + /** * Creates App Predictor with all the current apps pinned on the hotseat */ diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index c359423085..8faa743016 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -20,13 +20,18 @@ import static com.android.launcher3.LauncherState.OVERVIEW; import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON; import android.content.Context; +import android.content.Intent; import android.content.res.Configuration; import android.graphics.Rect; import android.os.Bundle; import android.view.Gravity; +import android.view.View; + +import androidx.annotation.Nullable; import com.android.launcher3.BaseQuickstepLauncher; import com.android.launcher3.DeviceProfile; +import com.android.launcher3.ItemInfo; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; import com.android.launcher3.anim.AnimatorPlaybackController; @@ -157,6 +162,15 @@ public class QuickstepLauncher extends BaseQuickstepLauncher { onStateOrResumeChanged(); } + @Override + public boolean startActivitySafely(View v, Intent intent, ItemInfo item, + @Nullable String sourceContainer) { + if (mHotseatPredictionController != null) { + mHotseatPredictionController.setPauseUIUpdate(true); + } + return super.startActivitySafely(v, intent, item, sourceContainer); + } + @Override protected void onActivityFlagsChanged(int changeBits) { super.onActivityFlagsChanged(changeBits); @@ -166,6 +180,11 @@ public class QuickstepLauncher extends BaseQuickstepLauncher { && (getActivityFlags() & ACTIVITY_STATE_TRANSITION_ACTIVE) == 0) { onStateOrResumeChanged(); } + + if ((changeBits & ACTIVITY_STATE_STARTED) != 0 && mHotseatPredictionController != null + && (getActivityFlags() & ACTIVITY_STATE_USER_ACTIVE) == 0) { + mHotseatPredictionController.setPauseUIUpdate(false); + } } @Override