Merge "Taskbar System Action with Broadcast Receiver." into tm-qpr-dev

This commit is contained in:
Jagrut Desai
2023-03-29 23:26:26 +00:00
committed by Android (Google) Code Review
6 changed files with 115 additions and 4 deletions

View File

@@ -263,6 +263,13 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
}
}
/**
* Show Taskbar upon receiving broadcast
*/
public void showTaskbarFromBroadcast() {
mControllers.taskbarStashController.showTaskbarFromBroadcast();
}
@Override
public DeviceProfile getDeviceProfile() {
return mDeviceProfile;

View File

@@ -154,7 +154,7 @@ public class TaskbarControllers {
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 @@ public class TaskbarControllers {
voiceInteractionWindowController.onDestroy();
taskbarRecentAppsController.onDestroy();
keyboardQuickSwitchController.onDestroy();
taskbarStashController.onDestroy();
mControllersToLog = null;
mBackgroundRendererControllers = null;

View File

@@ -62,7 +62,8 @@ class TaskbarEduTooltipController(val activityContext: TaskbarActivityContext) :
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

View File

@@ -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 @@ public class TaskbarManager {
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 @@ public class TaskbarManager {
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();
}
@@ -213,6 +239,15 @@ public class TaskbarManager {
}
}
/**
* 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.
*
@@ -405,6 +440,8 @@ public class TaskbarManager {
* 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,

View File

@@ -17,6 +17,8 @@ package com.android.launcher3.taskbar;
import static com.android.launcher3.taskbar.LauncherTaskbarUIController.DISPLAY_PROGRESS_COUNT;
import android.app.PendingIntent;
/**
* State shared across different taskbar instance
*/
@@ -43,4 +45,7 @@ public class TaskbarSharedState {
// LauncherTaskbarUIController#mTaskbarInAppDisplayProgressMultiProp
public float[] inAppDisplayProgressMultiPropValues = new float[DISPLAY_PROGRESS_COUNT];
// Taskbar System Action
public PendingIntent taskbarSystemActionPendingIntent;
}

View File

@@ -28,6 +28,8 @@ import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCH
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 static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_S
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 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
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 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
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 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
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.
@@ -1000,6 +1027,39 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
mControllers.rotationButtonController.onTaskbarStateChange(visible, stashed);
}
/**
* 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.
*/