Merge "Only run search edu when enabled, also make code more generic." into 24D1-dev
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index 0514456..bc71cae 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -36,14 +36,12 @@
 import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_OPEN;
 import static com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_DRAGGING;
 import static com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_FULLSCREEN;
-import static com.android.launcher3.taskbar.TaskbarDragLayerController.TASKBAR_REAPPEAR_DELAY_MS;
 import static com.android.launcher3.testing.shared.ResourceUtils.getBoolByName;
 import static com.android.quickstep.util.AnimUtils.completeRunnableListCallback;
 import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_VISIBLE;
 import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_VOICE_INTERACTION_WINDOW_SHOWING;
 
 import android.animation.AnimatorSet;
-import android.animation.ObjectAnimator;
 import android.animation.ValueAnimator;
 import android.app.ActivityOptions;
 import android.content.ActivityNotFoundException;
@@ -81,7 +79,6 @@
 import com.android.launcher3.LauncherPrefs;
 import com.android.launcher3.LauncherSettings.Favorites;
 import com.android.launcher3.R;
-import com.android.launcher3.anim.AnimatedFloat;
 import com.android.launcher3.anim.AnimatorPlaybackController;
 import com.android.launcher3.apppairs.AppPairIcon;
 import com.android.launcher3.config.FeatureFlags;
@@ -1419,23 +1416,6 @@
         });
     }
 
-    public void hideTaskbarWhenFolding() {
-        AnimatedFloat alphaAnim = mControllers.taskbarDragLayerController.getTaskbarAlpha();
-        alphaAnim.cancelAnimation();
-        alphaAnim.updateValue(0);
-        ObjectAnimator animator = alphaAnim.animateToValue(1).setDuration(0);
-        animator.setStartDelay(TASKBAR_REAPPEAR_DELAY_MS);
-        animator.start();
-    }
-
-    public void cancelHideTaskbarWhenFolding() {
-        mControllers.taskbarDragLayerController.getTaskbarAlpha().cancelAnimation();
-    }
-
-    public void resetHideTaskbarWhenUnfolding() {
-        mControllers.taskbarDragLayerController.getTaskbarAlpha().updateValue(1);
-    }
-
     protected boolean isUserSetupComplete() {
         return mIsUserSetupComplete;
     }
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java
index e48c20d..ff890fb 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java
@@ -44,12 +44,6 @@
     private static final boolean DEBUG = SystemProperties.getBoolean(
             "persist.debug.draw_taskbar_debug_ui", false);
 
-    // Delay to reset the task bar alpha back to 1 after fading it for transition from unfold to
-    // fold. Normally this is not needed since the new task bar is recreated after fading, but in
-    // case something goes wrong this provides a fallback mechanism to make sure the task bar is
-    // visible after the transition finishes.
-    public static final long TASKBAR_REAPPEAR_DELAY_MS = 2000;
-
     private final TaskbarActivityContext mActivity;
     private final TaskbarDragLayer mTaskbarDragLayer;
     private final int mFolderMargin;
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
index ecbc7e7..8072492 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
@@ -29,7 +29,6 @@
 import static com.android.launcher3.util.DisplayController.CHANGE_NAVIGATION_MODE;
 import static com.android.launcher3.util.DisplayController.CHANGE_TASKBAR_PINNING;
 import static com.android.launcher3.util.DisplayController.TASKBAR_NOT_DESTROYED_TAG;
-import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
 import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
 import static com.android.launcher3.util.FlagDebugUtils.formatFlagChange;
 import static com.android.quickstep.util.SystemActionConstants.ACTION_SHOW_TASKBAR;
@@ -43,7 +42,6 @@
 import android.content.IntentFilter;
 import android.content.pm.ActivityInfo;
 import android.content.res.Configuration;
-import android.hardware.devicestate.DeviceStateManager;
 import android.hardware.display.DisplayManager;
 import android.net.Uri;
 import android.os.Handler;
@@ -111,7 +109,6 @@
 
     private final Context mContext;
     private final @Nullable Context mNavigationBarPanelContext;
-    private final DeviceStateManager mDeviceStateManager;
     private WindowManager mWindowManager;
     private FrameLayout mTaskbarRootLayout;
     private boolean mAddedWindow;
@@ -180,8 +177,7 @@
         }
     };
 
-    private final UnfoldTransitionProgressProvider.TransitionProgressListener
-            mUnfoldTransitionProgressListener =
+    UnfoldTransitionProgressProvider.TransitionProgressListener mUnfoldTransitionProgressListener =
             new UnfoldTransitionProgressProvider.TransitionProgressListener() {
                 @Override
                 public void onTransitionStarted() {
@@ -210,9 +206,6 @@
                 }
             };
 
-    private final DeviceStateManager.FoldStateListener mFoldStateListener;
-    private Boolean mFolded;
-
     @SuppressLint("WrongConstant")
     public TaskbarManager(
             TouchInteractionService service, AllAppsActionManager allAppsActionManager) {
@@ -240,29 +233,6 @@
                 }
             };
         }
-        // Temporary solution to mitigate the visual jump from folding the device. Currently, the
-        // screen turns on much earlier than we receive the onConfigurationChanged callback or
-        // receiving the correct device profile. While the ideal the solution is to align turning
-        // the screen on after onConfigurationChanged (by either delaying turning on the screen or
-        // figuring out what is causing the delay in getting onConfigurationChanged callback), one
-        // easy temporary mitigation is to dimming the bar so that the visual jump isn't as glaring.
-        mFoldStateListener = new DeviceStateManager.FoldStateListener(mContext, folded -> {
-            boolean firstTime = mFolded == null;
-            if (mTaskbarActivityContext == null) {
-                return;
-            }
-            if (!firstTime && mFolded.booleanValue() != folded) {
-                mTaskbarActivityContext.cancelHideTaskbarWhenFolding();
-            }
-            mFolded = folded;
-            if (folded && !firstTime) {
-                mTaskbarActivityContext.hideTaskbarWhenFolding();
-            } else {
-                mTaskbarActivityContext.resetHideTaskbarWhenUnfolding();
-            }
-        });
-        mDeviceStateManager = mContext.getSystemService(DeviceStateManager.class);
-        mDeviceStateManager.registerCallback(MAIN_EXECUTOR, mFoldStateListener);
         mNavButtonController = new TaskbarNavButtonController(service,
                 SystemUiProxy.INSTANCE.get(mContext), new Handler(),
                 AssistUtils.newInstance(mContext));
@@ -473,8 +443,8 @@
                 LauncherAppState.getIDP(mContext).getDeviceProfile(mContext) : null;
 
             // All Apps action is unrelated to navbar unification, so we only need to check DP.
-            mAllAppsActionManager.setTaskbarPresent(dp != null && dp.isTaskbarPresent);
-
+            final boolean isLargeScreenTaskbar = dp != null && dp.isTaskbarPresent;
+            mAllAppsActionManager.setTaskbarPresent(isLargeScreenTaskbar);
             destroyExistingTaskbar();
 
             boolean isTaskbarEnabled = dp != null && isTaskbarEnabled(dp);
@@ -497,6 +467,7 @@
             }
             mSharedState.startTaskbarVariantIsTransient =
                     DisplayController.isTransientTaskbar(mTaskbarActivityContext);
+            mSharedState.allAppsVisible = mSharedState.allAppsVisible && isLargeScreenTaskbar;
             mTaskbarActivityContext.init(mSharedState);
 
             if (mActivity != null) {
@@ -619,7 +590,6 @@
         Log.d(TASKBAR_NOT_DESTROYED_TAG, "unregistering component callbacks from destroy().");
         mContext.unregisterComponentCallbacks(mComponentCallbacks);
         mContext.unregisterReceiver(mShutdownReceiver);
-        mDeviceStateManager.unregisterCallback(mFoldStateListener);
     }
 
     public @Nullable TaskbarActivityContext getCurrentActivityContext() {