Merge "Add a growth broadcast receiver in taskbar." into main
diff --git a/aconfig/launcher_growth.aconfig b/aconfig/launcher_growth.aconfig
new file mode 100644
index 0000000..35a91d7
--- /dev/null
+++ b/aconfig/launcher_growth.aconfig
@@ -0,0 +1,9 @@
+package: "com.android.launcher3"
+container: "system"
+
+flag {
+ name: "enable_growth_nudge"
+ namespace: "desktop_oobe"
+ description: "Add growth nudge in launcher"
+ bug: "396165728"
+}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
index f7014ff..943c44e 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
@@ -16,10 +16,12 @@
package com.android.launcher3.taskbar;
import static android.content.Context.RECEIVER_NOT_EXPORTED;
+import static android.content.Context.RECEIVER_EXPORTED;
import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR;
import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL;
import static com.android.launcher3.BaseActivity.EVENT_DESTROYED;
+import static com.android.launcher3.Flags.enableGrowthNudge;
import static com.android.launcher3.Flags.enableUnfoldStateAnimation;
import static com.android.launcher3.config.FeatureFlags.ENABLE_TASKBAR_NAVBAR_UNIFICATION;
import static com.android.launcher3.config.FeatureFlags.enableTaskbarNoRecreate;
@@ -30,6 +32,7 @@
import static com.android.launcher3.util.DisplayController.CHANGE_TASKBAR_PINNING;
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
import static com.android.launcher3.util.FlagDebugUtils.formatFlagChange;
+import static com.android.launcher3.taskbar.growth.GrowthConstants.BROADCAST_SHOW_NUDGE;
import static com.android.quickstep.util.SystemActionConstants.ACTION_SHOW_TASKBAR;
import static com.android.quickstep.util.SystemActionConstants.SYSTEM_ACTION_ID_TASKBAR;
@@ -104,6 +107,9 @@
private static final boolean DEBUG = false;
private static final int TASKBAR_DESTROY_DURATION = 100;
+ // TODO: b/397738606 - Remove all logs with this tag after the growth framework is integrated.
+ public static final String GROWTH_FRAMEWORK_TAG = "Growth Framework";
+
/**
* All the configurations which do not initiate taskbar recreation.
* This includes all the configurations defined in Launcher's manifest entry and
@@ -325,6 +331,8 @@
private final SimpleBroadcastReceiver mTaskbarBroadcastReceiver;
+ private final SimpleBroadcastReceiver mGrowthBroadcastReceiver;
+
private final AllAppsActionManager mAllAppsActionManager;
private final RecentsDisplayModel mRecentsDisplayModel;
@@ -416,7 +424,18 @@
mTaskbarBroadcastReceiver =
new SimpleBroadcastReceiver(mPrimaryWindowContext,
UI_HELPER_EXECUTOR, this::showTaskbarFromBroadcast);
+
mShutdownReceiver.register(Intent.ACTION_SHUTDOWN);
+ if (enableGrowthNudge()) {
+ // TODO: b/397739323 - Add permission to limit access to Growth Framework.
+ mGrowthBroadcastReceiver =
+ new SimpleBroadcastReceiver(
+ mPrimaryWindowContext, UI_HELPER_EXECUTOR, this::showGrowthNudge);
+ mGrowthBroadcastReceiver.register(RECEIVER_EXPORTED,
+ BROADCAST_SHOW_NUDGE);
+ } else {
+ mGrowthBroadcastReceiver = null;
+ }
UI_HELPER_EXECUTOR.execute(() -> {
mSharedState.taskbarSystemActionPendingIntent = PendingIntent.getBroadcast(
mPrimaryWindowContext,
@@ -474,11 +493,21 @@
debugPrimaryTaskbar("destroyTaskbarForDisplay");
// TODO: make this code displayId specific
TaskbarActivityContext taskbar = getTaskbarForDisplay(getDefaultDisplayId());
- if (ACTION_SHOW_TASKBAR.equals(intent.getAction()) && taskbar != null) {
+ if (ACTION_SHOW_TASKBAR.equals(intent.getAction())) {
taskbar.showTaskbarFromBroadcast();
}
}
+ private void showGrowthNudge(Intent intent) {
+ if (!enableGrowthNudge()) {
+ return;
+ }
+ if (BROADCAST_SHOW_NUDGE.equals(intent.getAction())) {
+ // TODO: b/397738606 - extract the details and create a nudge payload.
+ Log.d(GROWTH_FRAMEWORK_TAG, "Intent received");
+ }
+ }
+
/**
* Toggles All Apps for Taskbar or Launcher depending on the current state.
*/
@@ -790,7 +819,7 @@
}
public void transitionTo(int displayId, @BarTransitions.TransitionMode int barMode,
- boolean animate) {
+ boolean animate) {
TaskbarActivityContext taskbar = getTaskbarForDisplay(displayId);
if (taskbar != null) {
taskbar.transitionTo(barMode, animate);
@@ -996,6 +1025,9 @@
mTaskbarDesktopModeListener);
removeActivityCallbacksAndListeners();
mTaskbarBroadcastReceiver.unregisterReceiverSafely();
+ if (mGrowthBroadcastReceiver != null) {
+ mGrowthBroadcastReceiver.unregisterReceiverSafely();
+ }
if (mUserUnlocked) {
DisplayController.INSTANCE.get(mPrimaryWindowContext).removeChangeListener(
diff --git a/quickstep/src/com/android/launcher3/taskbar/growth/GrowthConstants.java b/quickstep/src/com/android/launcher3/taskbar/growth/GrowthConstants.java
new file mode 100644
index 0000000..78ef152
--- /dev/null
+++ b/quickstep/src/com/android/launcher3/taskbar/growth/GrowthConstants.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2025 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.launcher3.taskbar.growth;
+
+/**
+ * Constants for registering Growth framework.
+ */
+public final class GrowthConstants {
+ /**
+ * For Taskbar broadcast intent filter.
+ */
+ public static final String BROADCAST_SHOW_NUDGE =
+ "com.android.launcher3.growth.BROADCAST_SHOW_NUDGE";
+ private GrowthConstants() {}
+}