Merge "Taskbar System Action with Broadcast Receiver." into tm-qpr-dev
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index 547f462..a779d44 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -263,6 +263,13 @@
}
}
+ /**
+ * Show Taskbar upon receiving broadcast
+ */
+ public void showTaskbarFromBroadcast() {
+ mControllers.taskbarStashController.showTaskbarFromBroadcast();
+ }
+
@Override
public DeviceProfile getDeviceProfile() {
return mDeviceProfile;
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java
index a6da56d..a71e5db 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java
@@ -154,7 +154,7 @@
taskbarKeyguardController.init(navbarButtonsViewController);
taskbarSpringOnStashController.init(this);
stashedHandleViewController.init(this);
- taskbarStashController.init(this, sharedState.setupUIVisible);
+ taskbarStashController.init(this, sharedState.setupUIVisible, mSharedState);
taskbarEduController.init(this);
taskbarPopupController.init(this);
taskbarForceVisibleImmersiveController.init(this);
@@ -225,6 +225,7 @@
voiceInteractionWindowController.onDestroy();
taskbarRecentAppsController.onDestroy();
keyboardQuickSwitchController.onDestroy();
+ taskbarStashController.onDestroy();
mControllersToLog = null;
mBackgroundRendererControllers = null;
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt
index bd8e346..22ed284 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt
@@ -62,7 +62,8 @@
get() = !Utilities.isRunningInTestHarness() && ENABLE_TASKBAR_EDU_TOOLTIP.get()
private val isOpen: Boolean
get() = tooltip?.isOpen ?: false
-
+ val isBeforeTooltipFeaturesStep: Boolean
+ get() = isTooltipEnabled && tooltipStep <= TOOLTIP_STEP_FEATURES
private lateinit var controllers: TaskbarControllers
@TaskbarEduTooltipStep
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
index 4c131ee..c537106 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
@@ -15,17 +15,22 @@
*/
package com.android.launcher3.taskbar;
+import static android.content.Context.RECEIVER_NOT_EXPORTED;
import static android.content.pm.PackageManager.FEATURE_PC;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL;
import static com.android.launcher3.util.DisplayController.CHANGE_DENSITY;
import static com.android.launcher3.util.DisplayController.CHANGE_NAVIGATION_MODE;
+import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
import static com.android.launcher3.util.FlagDebugUtils.formatFlagChange;
+import android.annotation.SuppressLint;
+import android.app.PendingIntent;
import android.content.ComponentCallbacks;
import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.hardware.display.DisplayManager;
@@ -116,6 +121,17 @@
private boolean mUserUnlocked = false;
+ public static final int SYSTEM_ACTION_ID_TASKBAR = 499;
+
+ /**
+ * For Taskbar broadcast intent filter.
+ */
+ public static final String ACTION_SHOW_TASKBAR = "ACTION_SHOW_TASKBAR";
+
+ private final SimpleBroadcastReceiver mTaskbarBroadcastReceiver =
+ new SimpleBroadcastReceiver(this::showTaskbarFromBroadcast);
+
+ @SuppressLint("WrongConstant")
public TaskbarManager(TouchInteractionService service) {
mDisplayController = DisplayController.INSTANCE.get(service);
Display display =
@@ -200,7 +216,17 @@
mNavBarKidsModeListener);
mContext.registerComponentCallbacks(mComponentCallbacks);
mShutdownReceiver.register(mContext, Intent.ACTION_SHUTDOWN);
-
+ UI_HELPER_EXECUTOR.execute(() -> {
+ mSharedState.taskbarSystemActionPendingIntent = PendingIntent.getBroadcast(
+ mContext,
+ SYSTEM_ACTION_ID_TASKBAR,
+ new Intent(ACTION_SHOW_TASKBAR).setPackage(mContext.getPackageName()),
+ PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
+ mContext.registerReceiver(
+ mTaskbarBroadcastReceiver,
+ new IntentFilter(ACTION_SHOW_TASKBAR),
+ RECEIVER_NOT_EXPORTED);
+ });
recreateTaskbar();
}
@@ -214,6 +240,15 @@
}
/**
+ * Show Taskbar upon receiving broadcast
+ */
+ private void showTaskbarFromBroadcast(Intent intent) {
+ if (ACTION_SHOW_TASKBAR.equals(intent.getAction()) && mTaskbarActivityContext != null) {
+ mTaskbarActivityContext.showTaskbarFromBroadcast();
+ }
+ }
+
+ /**
* Displays a frame of the first Launcher reveal animation.
*
* This should be used to run a first Launcher reveal animation whose progress matches a swipe
@@ -405,6 +440,8 @@
* Called when the manager is no longer needed
*/
public void destroy() {
+ UI_HELPER_EXECUTOR.execute(
+ () -> mTaskbarBroadcastReceiver.unregisterReceiverSafely(mContext));
destroyExistingTaskbar();
mDisplayController.removeChangeListener(mDispInfoChangeListener);
SettingsCache.INSTANCE.get(mContext).unregister(USER_SETUP_COMPLETE_URI,
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarSharedState.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarSharedState.java
index 6092998..66ca7d9 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarSharedState.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarSharedState.java
@@ -17,6 +17,8 @@
import static com.android.launcher3.taskbar.LauncherTaskbarUIController.DISPLAY_PROGRESS_COUNT;
+import android.app.PendingIntent;
+
/**
* State shared across different taskbar instance
*/
@@ -43,4 +45,7 @@
// LauncherTaskbarUIController#mTaskbarInAppDisplayProgressMultiProp
public float[] inAppDisplayProgressMultiPropValues = new float[DISPLAY_PROGRESS_COUNT];
+
+ // Taskbar System Action
+ public PendingIntent taskbarSystemActionPendingIntent;
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
index b98f172..c43b621 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
@@ -28,6 +28,8 @@
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TRANSIENT_TASKBAR_HIDE;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TRANSIENT_TASKBAR_SHOW;
import static com.android.launcher3.taskbar.TaskbarKeyguardController.MASK_ANY_SYSUI_LOCKED;
+import static com.android.launcher3.taskbar.TaskbarManager.SYSTEM_ACTION_ID_TASKBAR;
+import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
import static com.android.launcher3.util.FlagDebugUtils.appendFlag;
import static com.android.launcher3.util.FlagDebugUtils.formatFlagChange;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_IME_SHOWING;
@@ -38,7 +40,9 @@
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
+import android.app.RemoteAction;
import android.content.SharedPreferences;
+import android.graphics.drawable.Icon;
import android.util.Log;
import android.view.InsetsController;
import android.view.View;
@@ -224,6 +228,9 @@
return (inApp && stashedInApp) || (!inApp && stashedLauncherState) || forceStashed;
});
+ private boolean mIsTaskbarSystemActionRegistered = false;
+ private TaskbarSharedState mTaskbarSharedState;
+
public TaskbarStashController(TaskbarActivityContext activity) {
mActivity = activity;
mPrefs = LauncherPrefs.getPrefs(mActivity);
@@ -234,8 +241,27 @@
mStashedHeight = mActivity.getDeviceProfile().stashedTaskbarHeight;
}
- public void init(TaskbarControllers controllers, boolean setupUIVisible) {
+ /**
+ * Show Taskbar upon receiving broadcast
+ */
+ public void showTaskbarFromBroadcast() {
+ // If user is in middle of taskbar education handle go to next step of education
+ if (mControllers.taskbarEduTooltipController.isBeforeTooltipFeaturesStep()) {
+ mControllers.taskbarEduTooltipController.hide();
+ mControllers.taskbarEduTooltipController.maybeShowFeaturesEdu();
+ }
+ updateAndAnimateTransientTaskbar(false);
+ }
+
+ /**
+ * Initializes the controller
+ */
+ public void init(
+ TaskbarControllers controllers,
+ boolean setupUIVisible,
+ TaskbarSharedState sharedState) {
mControllers = controllers;
+ mTaskbarSharedState = sharedState;
TaskbarDragLayerController dragLayerController = controllers.taskbarDragLayerController;
mTaskbarBackgroundOffset = dragLayerController.getTaskbarBackgroundOffset();
@@ -992,6 +1018,7 @@
private void notifyStashChange(boolean visible, boolean stashed) {
mSystemUiProxy.notifyTaskbarStatus(visible, stashed);
+ setUpTaskbarSystemAction(visible);
// If stashing taskbar is caused by IME visibility, we could just skip updating rounded
// corner insets since the rounded corners will be covered by IME during IME is showing and
// taskbar will be restored back to unstashed when IME is hidden.
@@ -1001,6 +1028,39 @@
}
/**
+ * Setup system action for showing Taskbar depending on its visibility.
+ */
+ public void setUpTaskbarSystemAction(boolean visible) {
+ UI_HELPER_EXECUTOR.execute(() -> {
+ if (!visible || !DisplayController.isTransientTaskbar(mActivity)) {
+ mAccessibilityManager.unregisterSystemAction(SYSTEM_ACTION_ID_TASKBAR);
+ mIsTaskbarSystemActionRegistered = false;
+ return;
+ }
+
+ if (!mIsTaskbarSystemActionRegistered) {
+ RemoteAction taskbarRemoteAction = new RemoteAction(
+ Icon.createWithResource(mActivity, R.drawable.ic_info_no_shadow),
+ mActivity.getString(R.string.taskbar_a11y_title),
+ mActivity.getString(R.string.taskbar_a11y_title),
+ mTaskbarSharedState.taskbarSystemActionPendingIntent);
+
+ mAccessibilityManager.registerSystemAction(taskbarRemoteAction,
+ SYSTEM_ACTION_ID_TASKBAR);
+ mIsTaskbarSystemActionRegistered = true;
+ }
+ });
+ }
+
+ /**
+ * Clean up on destroy from TaskbarControllers
+ */
+ public void onDestroy() {
+ UI_HELPER_EXECUTOR.execute(
+ () -> mAccessibilityManager.unregisterSystemAction(SYSTEM_ACTION_ID_TASKBAR));
+ }
+
+ /**
* Cancels a timeout if any exists.
*/
public void cancelTimeoutIfExists() {