[CD Taskbar] Cache displayId & Consolidate DisplayController methods
TaskbarActivityContext should store displayId and return a cached value to avoid unnessary binder calls. Flag: com.android.window.flags.enable_taskbar_connected_displays Bug: 406019031 Test: m Change-Id: I808352e7098ee731abc7362b2f8f1b7a675457f9
This commit is contained in:
1 parent
21c065ae3d
commit
5da5e1c9e1
9 files changed
+132
-108
No files matched your search
@@ -18,6 +18,7 @@ package com.android.launcher3.taskbar;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ShortcutInfo;
|
||||
import android.graphics.Point;
|
||||
import android.os.UserHandle;
|
||||
import android.view.LayoutInflater;
|
||||
|
||||
@@ -32,13 +33,29 @@ import com.android.quickstep.SystemUiProxy;
|
||||
public abstract class BaseTaskbarContext extends BaseContext
|
||||
implements SystemShortcut.BubbleActivityStarter {
|
||||
|
||||
private final int mDisplayId;
|
||||
private final boolean mIsPrimaryDisplay;
|
||||
protected final LayoutInflater mLayoutInflater;
|
||||
|
||||
public BaseTaskbarContext(Context windowContext, boolean isPrimaryDisplay) {
|
||||
public BaseTaskbarContext(Context windowContext, int displayId, boolean isPrimaryDisplay) {
|
||||
super(windowContext, Themes.getActivityThemeRes(windowContext));
|
||||
mDisplayId = displayId;
|
||||
mIsPrimaryDisplay = isPrimaryDisplay;
|
||||
mLayoutInflater = LayoutInflater.from(this).cloneInContext(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDisplayId() {
|
||||
return mDisplayId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the taskbar is displayed on primary or external display.
|
||||
*/
|
||||
public final boolean isPrimaryDisplay() {
|
||||
return mIsPrimaryDisplay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether taskbar is transient or persistent. External displays will be persistent.
|
||||
*
|
||||
@@ -80,9 +97,20 @@ public abstract class BaseTaskbarContext extends BaseContext
|
||||
public abstract boolean showDesktopTaskbarForFreeformDisplay();
|
||||
|
||||
/**
|
||||
* Returns whether the taskbar is displayed on primary or external display.
|
||||
* Returns screen size.
|
||||
*/
|
||||
public abstract boolean isPrimaryDisplay();
|
||||
public abstract Point getScreenSize();
|
||||
|
||||
/**
|
||||
* Returns display height.
|
||||
*/
|
||||
public abstract int getDisplayHeight();
|
||||
|
||||
/**
|
||||
* Notifies the context that the configuration has changed.
|
||||
*/
|
||||
public abstract void notifyConfigChanged();
|
||||
|
||||
|
||||
@Override
|
||||
public final LayoutInflater getLayoutInflater() {
|
||||
|
||||
@@ -273,8 +273,8 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
|
||||
}
|
||||
|
||||
if (!ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY.isTrue()
|
||||
&& mControllers.taskbarDesktopModeController
|
||||
.isInDesktopModeAndNotInOverview(mLauncher.getDisplayId())) {
|
||||
&& mControllers.taskbarDesktopModeController.isInDesktopModeAndNotInOverview(
|
||||
mControllers.taskbarActivityContext.getDisplayId())) {
|
||||
// TODO: b/333533253 - Remove after flag rollout
|
||||
isVisible = false;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package com.android.launcher3.taskbar;
|
||||
|
||||
import static android.os.Trace.TRACE_TAG_APP;
|
||||
import static android.view.Display.DEFAULT_DISPLAY;
|
||||
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
||||
@@ -64,6 +63,7 @@ import android.content.pm.ActivityInfo.Config;
|
||||
import android.content.pm.LauncherApps;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.hardware.display.DisplayManager;
|
||||
@@ -218,7 +218,6 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
private final TaskbarControllers mControllers;
|
||||
|
||||
private final WindowManager mWindowManager;
|
||||
private final boolean mIsPrimaryDisplay;
|
||||
private DeviceProfile mDeviceProfile;
|
||||
private WindowManager.LayoutParams mWindowLayoutParams;
|
||||
private WindowManager.LayoutParams mLastUpdatedLayoutParams;
|
||||
@@ -266,13 +265,12 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
private @Nullable View mTaskbarSnapshotView;
|
||||
private @Nullable TaskbarOverlayContext mTaskbarSnapshotOverlay;
|
||||
|
||||
public TaskbarActivityContext(Context windowContext,
|
||||
public TaskbarActivityContext(int displayId, Context windowContext,
|
||||
@Nullable Context navigationBarPanelContext, DeviceProfile launcherDp,
|
||||
TaskbarNavButtonController buttonController,
|
||||
ScopedUnfoldTransitionProgressProvider unfoldTransitionProgressProvider,
|
||||
boolean isPrimaryDisplay, SystemUiProxy sysUiProxy) {
|
||||
super(windowContext, isPrimaryDisplay);
|
||||
mIsPrimaryDisplay = isPrimaryDisplay;
|
||||
super(windowContext, displayId, isPrimaryDisplay);
|
||||
mNavigationBarPanelContext = navigationBarPanelContext;
|
||||
mSysUiProxy = sysUiProxy;
|
||||
applyDeviceProfile(launcherDp);
|
||||
@@ -320,11 +318,8 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
BubbleBarController.onTaskbarRecreated();
|
||||
final boolean deviceBubbleBarEnabled = enableBubbleBarOnPhones()
|
||||
|| (!mDeviceProfile.isPhone && !mDeviceProfile.isVerticalBarLayout());
|
||||
if (BubbleBarController.isBubbleBarEnabled()
|
||||
&& deviceBubbleBarEnabled
|
||||
&& bubbleBarView != null
|
||||
&& isPrimaryDisplay
|
||||
) {
|
||||
if (BubbleBarController.isBubbleBarEnabled() && deviceBubbleBarEnabled
|
||||
&& bubbleBarView != null && isPrimaryDisplay) {
|
||||
Optional<BubbleStashedHandleViewController> bubbleHandleController = Optional.empty();
|
||||
Optional<BubbleBarSwipeController> bubbleBarSwipeController = Optional.empty();
|
||||
if (isTransientTaskbar) {
|
||||
@@ -346,10 +341,8 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
bubbleHandleController,
|
||||
new BubbleDragController(this, mDragLayer),
|
||||
new BubbleDismissController(this, mDragLayer),
|
||||
new BubbleBarPinController(this, bubbleBarContainer,
|
||||
() -> DisplayController.INSTANCE.get(this).getInfo().currentSize),
|
||||
new BubblePinController(this, bubbleBarContainer,
|
||||
() -> DisplayController.INSTANCE.get(this).getInfo().currentSize),
|
||||
new BubbleBarPinController(this, bubbleBarContainer, this::getScreenSize),
|
||||
new BubblePinController(this, bubbleBarContainer, this::getScreenSize),
|
||||
bubbleBarSwipeController,
|
||||
new BubbleCreator(this)
|
||||
));
|
||||
@@ -422,7 +415,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
|
||||
@Override
|
||||
public boolean isTransientTaskbar() {
|
||||
return DisplayController.isTransientTaskbar(this) && mIsPrimaryDisplay && !isPhoneMode();
|
||||
return DisplayController.isTransientTaskbar(this) && isPrimaryDisplay() && !isPhoneMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -460,8 +453,18 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrimaryDisplay() {
|
||||
return mIsPrimaryDisplay;
|
||||
public Point getScreenSize() {
|
||||
return DisplayController.INSTANCE.get(this).getInfo().currentSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDisplayHeight() {
|
||||
return DisplayController.INSTANCE.get(this).getInfo().currentSize.y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyConfigChanged() {
|
||||
DisplayController.INSTANCE.get(this).notifyConfigChange();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -744,7 +747,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
*/
|
||||
private WindowManager.LayoutParams createAllWindowParams() {
|
||||
final int windowType =
|
||||
(ENABLE_TASKBAR_NAVBAR_UNIFICATION && mIsPrimaryDisplay) ? TYPE_NAVIGATION_BAR
|
||||
(ENABLE_TASKBAR_NAVBAR_UNIFICATION && isPrimaryDisplay()) ? TYPE_NAVIGATION_BAR
|
||||
: TYPE_NAVIGATION_BAR_PANEL;
|
||||
WindowManager.LayoutParams windowLayoutParams =
|
||||
createDefaultWindowLayoutParams(windowType, TaskbarActivityContext.WINDOW_TITLE);
|
||||
@@ -1663,8 +1666,8 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
@Nullable Runnable onStartCallback,
|
||||
@Nullable Runnable onFinishCallback) {
|
||||
if (task instanceof DesktopTask) {
|
||||
UI_HELPER_EXECUTOR.execute(() ->
|
||||
SystemUiProxy.INSTANCE.get(this).showDesktopApps(getDisplay().getDisplayId(),
|
||||
UI_HELPER_EXECUTOR.execute(
|
||||
() -> SystemUiProxy.INSTANCE.get(this).showDesktopApps(getDisplayId(),
|
||||
remoteTransition));
|
||||
return;
|
||||
}
|
||||
@@ -1738,7 +1741,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
@Nullable View launchingIconView, List<? extends ItemInfo> itemInfos) {
|
||||
boolean launchedFromExternalDisplay =
|
||||
DesktopExperienceFlags.ENABLE_TASKBAR_CONNECTED_DISPLAYS.isTrue()
|
||||
&& !mIsPrimaryDisplay;
|
||||
&& !isPrimaryDisplay();
|
||||
if (recents == null && !launchedFromExternalDisplay) {
|
||||
return;
|
||||
}
|
||||
@@ -1829,7 +1832,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
intent.getComponent(), info.user, intent.getSourceBounds(), null);
|
||||
return;
|
||||
}
|
||||
int displayId = getDisplay() == null ? DEFAULT_DISPLAY : getDisplay().getDisplayId();
|
||||
int displayId = getDisplayId();
|
||||
// TODO(b/216683257): Use startActivityForResult for search results that require it.
|
||||
if (taskInRecents != null) {
|
||||
// Re launch instance from recents
|
||||
|
||||
@@ -207,8 +207,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
debugTaskbarManager("onDisplayInfoChanged: Navigation mode changed", displayId);
|
||||
}
|
||||
if ((flags & CHANGE_DESKTOP_MODE) != 0) {
|
||||
debugTaskbarManager("onDisplayInfoChanged: Desktop mode changed",
|
||||
context.getDisplayId());
|
||||
debugTaskbarManager("onDisplayInfoChanged: Desktop mode changed", displayId);
|
||||
handleDisplayUpdatesForPerceptibleTasks();
|
||||
}
|
||||
if ((flags & CHANGE_TASKBAR_PINNING) != 0) {
|
||||
@@ -316,8 +315,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
public void onExitDesktopMode(int duration) {
|
||||
for (int taskbarIndex = 0; taskbarIndex < mTaskbars.size(); taskbarIndex++) {
|
||||
int displayId = mTaskbars.keyAt(taskbarIndex);
|
||||
if (DesktopExperienceFlags.ENABLE_TASKBAR_CONNECTED_DISPLAYS.isTrue()
|
||||
&& !isDefaultDisplay(displayId)) {
|
||||
if (isExternalDisplay(displayId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -329,8 +327,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
AnimatorSet animatorSet = taskbarActivityContext.onDestroyAnimation(
|
||||
TASKBAR_DESTROY_DURATION);
|
||||
animatorSet.addListener(AnimatorListeners.forEndCallback(
|
||||
() -> recreateTaskbarForDisplay(getDefaultDisplayId(),
|
||||
duration)));
|
||||
() -> recreateTaskbarForDisplay(mPrimaryDisplayId, duration)));
|
||||
animatorSet.start();
|
||||
}
|
||||
}
|
||||
@@ -340,8 +337,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
public void onEnterDesktopMode(int duration) {
|
||||
for (int taskbarIndex = 0; taskbarIndex < mTaskbars.size(); taskbarIndex++) {
|
||||
int displayId = mTaskbars.keyAt(taskbarIndex);
|
||||
if (DesktopExperienceFlags.ENABLE_TASKBAR_CONNECTED_DISPLAYS.isTrue()
|
||||
&& !isDefaultDisplay(displayId)) {
|
||||
if (isExternalDisplay(displayId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -352,8 +348,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
AnimatorSet animatorSet = taskbarActivityContext.onDestroyAnimation(
|
||||
TASKBAR_DESTROY_DURATION);
|
||||
animatorSet.addListener(AnimatorListeners.forEndCallback(
|
||||
() -> recreateTaskbarForDisplay(getDefaultDisplayId(),
|
||||
duration)));
|
||||
() -> recreateTaskbarForDisplay(mPrimaryDisplayId, duration)));
|
||||
animatorSet.start();
|
||||
}
|
||||
}
|
||||
@@ -378,7 +373,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
private final Runnable mActivityOnDestroyCallback = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int displayId = getDefaultDisplayId();
|
||||
int displayId = mPrimaryDisplayId;
|
||||
debugTaskbarManager("onActivityDestroyed:", displayId);
|
||||
if (mActivity != null) {
|
||||
displayId = mActivity.getDisplayId();
|
||||
@@ -444,14 +439,14 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
|
||||
// Set up primary display.
|
||||
debugPrimaryTaskbar("TaskbarManager constructor");
|
||||
mPrimaryWindowContext = createWindowContext(getDefaultDisplayId());
|
||||
mPrimaryWindowContext = createWindowContext(mPrimaryDisplayId);
|
||||
mPrimaryWindowManager = mPrimaryWindowContext.getSystemService(WindowManager.class);
|
||||
DesktopVisibilityController.INSTANCE.get(
|
||||
mPrimaryWindowContext).registerTaskbarDesktopModeListener(
|
||||
mTaskbarDesktopModeListener);
|
||||
createTaskbarRootLayout(getDefaultDisplayId());
|
||||
createNavButtonController(getDefaultDisplayId());
|
||||
createAndRegisterComponentCallbacks(getDefaultDisplayId());
|
||||
createTaskbarRootLayout(mPrimaryDisplayId);
|
||||
createNavButtonController(mPrimaryDisplayId);
|
||||
createAndRegisterComponentCallbacks(mPrimaryDisplayId);
|
||||
|
||||
SettingsCache.INSTANCE.get(mPrimaryWindowContext)
|
||||
.register(USER_SETUP_COMPLETE_URI, mOnSettingsChangeListener);
|
||||
@@ -596,7 +591,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
* progress.
|
||||
*/
|
||||
public AnimatorPlaybackController createLauncherStartFromSuwAnim(int duration) {
|
||||
TaskbarActivityContext taskbar = getTaskbarForDisplay(getDefaultDisplayId());
|
||||
TaskbarActivityContext taskbar = getTaskbarForDisplay(mPrimaryDisplayId);
|
||||
return taskbar == null ? null : taskbar.createLauncherStartFromSuwAnim(duration);
|
||||
}
|
||||
|
||||
@@ -727,8 +722,8 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
debugPrimaryTaskbar("recreateTaskbars");
|
||||
// Handles initial creation case.
|
||||
if (mTaskbars.size() == 0) {
|
||||
debugTaskbarManager("recreateTaskbars: create primary taskbar", getDefaultDisplayId());
|
||||
recreateTaskbarForDisplay(getDefaultDisplayId(), 0);
|
||||
debugTaskbarManager("recreateTaskbars: create primary taskbar", mPrimaryDisplayId);
|
||||
recreateTaskbarForDisplay(mPrimaryDisplayId, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -797,8 +792,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
|
||||
// Non default displays should not use LauncherTaskbarUIController as they shouldn't
|
||||
// have access to the Launcher activity.
|
||||
if (!isDefaultDisplay(displayId)
|
||||
&& DesktopExperienceFlags.ENABLE_TASKBAR_CONNECTED_DISPLAYS.isTrue()) {
|
||||
if (isExternalDisplay(displayId)) {
|
||||
taskbar.setUIController(createTaskbarUIControllerForNonDefaultDisplay(displayId));
|
||||
} else if (mRecentsViewContainer != null) {
|
||||
taskbar.setUIController(
|
||||
@@ -849,7 +843,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
public void setSetupUIVisible(boolean isVisible) {
|
||||
mSharedState.setupUIVisible = isVisible;
|
||||
mAllAppsActionManager.setSetupUiVisible(isVisible);
|
||||
TaskbarActivityContext taskbar = getTaskbarForDisplay(getDefaultDisplayId());
|
||||
TaskbarActivityContext taskbar = getTaskbarForDisplay(mPrimaryDisplayId);
|
||||
if (taskbar != null) {
|
||||
taskbar.setSetupUIVisible(isVisible);
|
||||
}
|
||||
@@ -896,7 +890,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
}
|
||||
|
||||
public void appTransitionPending(boolean pending) {
|
||||
TaskbarActivityContext taskbar = getTaskbarForDisplay(getDefaultDisplayId());
|
||||
TaskbarActivityContext taskbar = getTaskbarForDisplay(mPrimaryDisplayId);
|
||||
if (taskbar != null) {
|
||||
taskbar.appTransitionPending(pending);
|
||||
}
|
||||
@@ -907,7 +901,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
}
|
||||
|
||||
public void onRotationProposal(int rotation, boolean isValid) {
|
||||
TaskbarActivityContext taskbar = getTaskbarForDisplay(getDefaultDisplayId());
|
||||
TaskbarActivityContext taskbar = getTaskbarForDisplay(mPrimaryDisplayId);
|
||||
if (taskbar != null) {
|
||||
taskbar.onRotationProposal(rotation, isValid);
|
||||
}
|
||||
@@ -934,7 +928,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
|
||||
public void onTransitionModeUpdated(int barMode, boolean checkBarModes) {
|
||||
mSharedState.barMode = barMode;
|
||||
TaskbarActivityContext taskbar = getTaskbarForDisplay(getDefaultDisplayId());
|
||||
TaskbarActivityContext taskbar = getTaskbarForDisplay(mPrimaryDisplayId);
|
||||
if (taskbar != null) {
|
||||
taskbar.onTransitionModeUpdated(barMode, checkBarModes);
|
||||
}
|
||||
@@ -942,7 +936,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
|
||||
public void onNavButtonsDarkIntensityChanged(float darkIntensity) {
|
||||
mSharedState.navButtonsDarkIntensity = darkIntensity;
|
||||
TaskbarActivityContext taskbar = getTaskbarForDisplay(getDefaultDisplayId());
|
||||
TaskbarActivityContext taskbar = getTaskbarForDisplay(mPrimaryDisplayId);
|
||||
if (taskbar != null) {
|
||||
taskbar.onNavButtonsDarkIntensityChanged(darkIntensity);
|
||||
}
|
||||
@@ -970,13 +964,10 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!DesktopExperienceFlags.ENABLE_TASKBAR_CONNECTED_DISPLAYS.isTrue() || isDefaultDisplay(
|
||||
displayId)) {
|
||||
if (!isExternalDisplay(displayId)) {
|
||||
debugTaskbarManager(
|
||||
"onDisplayAddSystemDecorations: not an external display! | "
|
||||
+ "ENABLE_TASKBAR_CONNECTED_DISPLAYS="
|
||||
+ DesktopExperienceFlags.ENABLE_TASKBAR_CONNECTED_DISPLAYS.isTrue()
|
||||
+ " isDefaultDisplay=" + isDefaultDisplay(displayId), displayId);
|
||||
+ "isExternalDisplay=" + isExternalDisplay(displayId), displayId);
|
||||
return;
|
||||
}
|
||||
debugTaskbarManager("onDisplayAddSystemDecorations: creating new windowContext!",
|
||||
@@ -1028,13 +1019,10 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
@Override
|
||||
public void onDisplayRemoved(int displayId) {
|
||||
debugTaskbarManager("onDisplayRemoved: ", displayId);
|
||||
if (!DesktopExperienceFlags.ENABLE_TASKBAR_CONNECTED_DISPLAYS.isTrue() || isDefaultDisplay(
|
||||
displayId)) {
|
||||
if (!isExternalDisplay(displayId)) {
|
||||
debugTaskbarManager(
|
||||
"onDisplayRemoved: not an external display! | "
|
||||
+ "ENABLE_TASKBAR_CONNECTED_DISPLAYS="
|
||||
+ DesktopExperienceFlags.ENABLE_TASKBAR_CONNECTED_DISPLAYS.isTrue()
|
||||
+ " isDefaultDisplay=" + isDefaultDisplay(displayId), displayId);
|
||||
+ "isExternalDisplay=" + isExternalDisplay(displayId), displayId);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1058,7 +1046,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
|
||||
debugTaskbarManager("onDisplayRemoved: finished!", displayId);
|
||||
} else {
|
||||
debugTaskbarManager("onDisplayRemoved: removing NavButtonController!", displayId);
|
||||
debugTaskbarManager("onDisplayRemoved: windowContext is null!", displayId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1112,7 +1100,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
SystemDecorationChangeObserver.getINSTANCE().get(mPrimaryWindowContext)
|
||||
.unregisterDisplayDecorationListener(this);
|
||||
debugPrimaryTaskbar("destroy: unregistering component callbacks");
|
||||
removeAndUnregisterComponentCallbacks(getDefaultDisplayId());
|
||||
removeAndUnregisterComponentCallbacks(mPrimaryDisplayId);
|
||||
mShutdownReceiver.unregisterReceiverSafely();
|
||||
if (mTaskStackListener != null) {
|
||||
mTaskStackListener.unregisterListener();
|
||||
@@ -1135,7 +1123,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
}
|
||||
|
||||
public @Nullable TaskbarActivityContext getCurrentActivityContext() {
|
||||
return getTaskbarForDisplay(getDefaultDisplayId());
|
||||
return getTaskbarForDisplay(mPrimaryDisplayId);
|
||||
}
|
||||
|
||||
public void dumpLogs(String prefix, PrintWriter pw) {
|
||||
@@ -1264,13 +1252,10 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
TYPE_NAVIGATION_BAR_PANEL, null);
|
||||
}
|
||||
|
||||
boolean isPrimaryDisplay = isDefaultDisplay(displayId)
|
||||
|| !DesktopExperienceFlags.ENABLE_TASKBAR_CONNECTED_DISPLAYS.isTrue();
|
||||
|
||||
TaskbarActivityContext newTaskbar = new TaskbarActivityContext(getWindowContext(displayId),
|
||||
navigationBarPanelContext, dp, getNavButtonController(displayId),
|
||||
mUnfoldProgressProvider, isPrimaryDisplay,
|
||||
SystemUiProxy.INSTANCE.get(mBaseContext));
|
||||
TaskbarActivityContext newTaskbar = new TaskbarActivityContext(displayId,
|
||||
getWindowContext(displayId), navigationBarPanelContext, dp,
|
||||
getNavButtonController(displayId), mUnfoldProgressProvider,
|
||||
!isExternalDisplay(displayId), SystemUiProxy.INSTANCE.get(mBaseContext));
|
||||
|
||||
addTaskbarToMap(displayId, newTaskbar);
|
||||
return newTaskbar;
|
||||
@@ -1314,9 +1299,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean isPrimary = isDefaultDisplay(displayId)
|
||||
|| !DesktopExperienceFlags.ENABLE_TASKBAR_CONNECTED_DISPLAYS.isTrue();
|
||||
if (isPrimary) {
|
||||
if (!isExternalDisplay(displayId)) {
|
||||
return idp.getDeviceProfile(mPrimaryWindowContext);
|
||||
}
|
||||
|
||||
@@ -1373,7 +1356,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
debugPrimaryTaskbar(
|
||||
"onConfigurationChanged: isTaskbarEnabled(dp)=False | "
|
||||
+ "destroyTaskbarForDisplay");
|
||||
destroyTaskbarForDisplay(getDefaultDisplayId());
|
||||
destroyTaskbarForDisplay(mPrimaryDisplayId);
|
||||
} else {
|
||||
debugPrimaryTaskbar("onConfigurationChanged: isTaskbarEnabled(dp)=True");
|
||||
if (ENABLE_TASKBAR_NAVBAR_UNIFICATION) {
|
||||
@@ -1402,8 +1385,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
public void onLowMemory() {
|
||||
}
|
||||
};
|
||||
if (isDefaultDisplay(displayId)
|
||||
|| !DesktopExperienceFlags.ENABLE_TASKBAR_CONNECTED_DISPLAYS.isTrue()) {
|
||||
if (!isExternalDisplay(displayId)) {
|
||||
mPrimaryComponentCallbacks = callbacks;
|
||||
mPrimaryWindowContext.registerComponentCallbacks(callbacks);
|
||||
} else {
|
||||
@@ -1419,8 +1401,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
* @param displayId The ID of the display.
|
||||
*/
|
||||
private void removeAndUnregisterComponentCallbacks(int displayId) {
|
||||
if (isDefaultDisplay(displayId)
|
||||
|| !DesktopExperienceFlags.ENABLE_TASKBAR_CONNECTED_DISPLAYS.isTrue()) {
|
||||
if (!isExternalDisplay(displayId)) {
|
||||
mPrimaryWindowContext.unregisterComponentCallbacks(mPrimaryComponentCallbacks);
|
||||
} else {
|
||||
ComponentCallbacks callbacks = mComponentCallbacks.get(displayId);
|
||||
@@ -1436,8 +1417,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
* @param displayId The ID of the display
|
||||
*/
|
||||
private void createNavButtonController(int displayId) {
|
||||
if (isDefaultDisplay(displayId)
|
||||
|| !DesktopExperienceFlags.ENABLE_TASKBAR_CONNECTED_DISPLAYS.isTrue()) {
|
||||
if (!isExternalDisplay(displayId)) {
|
||||
mPrimaryNavButtonController = new TaskbarNavButtonController(
|
||||
mPrimaryWindowContext,
|
||||
mNavCallbacks,
|
||||
@@ -1456,14 +1436,12 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
}
|
||||
|
||||
private TaskbarNavButtonController getNavButtonController(int displayId) {
|
||||
return (isDefaultDisplay(displayId)
|
||||
|| !DesktopExperienceFlags.ENABLE_TASKBAR_CONNECTED_DISPLAYS.isTrue())
|
||||
? mPrimaryNavButtonController : mNavButtonControllers.get(displayId);
|
||||
return (!isExternalDisplay(displayId)) ? mPrimaryNavButtonController
|
||||
: mNavButtonControllers.get(displayId);
|
||||
}
|
||||
|
||||
private void removeNavButtonController(int displayId) {
|
||||
if (isDefaultDisplay(displayId)
|
||||
|| !DesktopExperienceFlags.ENABLE_TASKBAR_CONNECTED_DISPLAYS.isTrue()) {
|
||||
if (!isExternalDisplay(displayId)) {
|
||||
mPrimaryNavButtonController = null;
|
||||
} else {
|
||||
mNavButtonControllers.delete(displayId);
|
||||
@@ -1522,7 +1500,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
}
|
||||
|
||||
private boolean isDefaultDisplay(int displayId) {
|
||||
return displayId == getDefaultDisplayId();
|
||||
return displayId == mPrimaryDisplayId;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1589,7 +1567,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
}
|
||||
|
||||
int windowType = TYPE_NAVIGATION_BAR_PANEL;
|
||||
if (ENABLE_TASKBAR_NAVBAR_UNIFICATION && isDefaultDisplay(displayId)) {
|
||||
if (ENABLE_TASKBAR_NAVBAR_UNIFICATION && !isExternalDisplay(displayId)) {
|
||||
windowType = TYPE_NAVIGATION_BAR;
|
||||
}
|
||||
debugTaskbarManager(
|
||||
@@ -1622,8 +1600,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
* @return The Window Context {@link Context} for a given display or {@code null}.
|
||||
*/
|
||||
private Context getWindowContext(int displayId) {
|
||||
return (isDefaultDisplay(displayId)
|
||||
|| !DesktopExperienceFlags.ENABLE_TASKBAR_CONNECTED_DISPLAYS.isTrue())
|
||||
return (!isExternalDisplay(displayId))
|
||||
? mPrimaryWindowContext : mWindowContexts.get(displayId);
|
||||
}
|
||||
|
||||
@@ -1639,8 +1616,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
* @return The window manager {@link WindowManager} for a given display or {@code null}.
|
||||
*/
|
||||
private @Nullable WindowManager getWindowManager(int displayId) {
|
||||
if (isDefaultDisplay(displayId)
|
||||
|| !DesktopExperienceFlags.ENABLE_TASKBAR_CONNECTED_DISPLAYS.isTrue()) {
|
||||
if (!isExternalDisplay(displayId)) {
|
||||
debugTaskbarManager("cannot get mPrimaryWindowManager", displayId);
|
||||
return mPrimaryWindowManager;
|
||||
}
|
||||
@@ -1677,8 +1653,9 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
}
|
||||
}
|
||||
|
||||
private int getDefaultDisplayId() {
|
||||
return mPrimaryDisplayId;
|
||||
private boolean isExternalDisplay(int displayId) {
|
||||
return DesktopExperienceFlags.ENABLE_TASKBAR_CONNECTED_DISPLAYS.isTrue() && (
|
||||
mPrimaryDisplayId != displayId);
|
||||
}
|
||||
|
||||
private int getFocusedDisplayId() {
|
||||
@@ -1692,7 +1669,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
*/
|
||||
public void debugTaskbarManager(String debugReason, int displayId) {
|
||||
StringJoiner log = new StringJoiner("\n");
|
||||
log.add(debugReason + " displayId=" + displayId + " isDefaultDisplay=" + isDefaultDisplay(
|
||||
log.add(debugReason + " displayId=" + displayId + " isDefaultDisplay=" + isExternalDisplay(
|
||||
displayId));
|
||||
Log.d(TAG, log.toString());
|
||||
}
|
||||
@@ -1719,7 +1696,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
*
|
||||
*/
|
||||
public void debugPrimaryTaskbar(String debugReason) {
|
||||
debugTaskbarManager(debugReason, getDefaultDisplayId(), false);
|
||||
debugTaskbarManager(debugReason, mPrimaryDisplayId, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1728,7 +1705,7 @@ public class TaskbarManager implements DisplayDecorationListener {
|
||||
*
|
||||
*/
|
||||
public void debugPrimaryTaskbar(String debugReason, boolean verbose) {
|
||||
debugTaskbarManager(debugReason, getDefaultDisplayId(), verbose);
|
||||
debugTaskbarManager(debugReason, mPrimaryDisplayId, verbose);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,7 +43,7 @@ open class TaskbarViewCallbacksFactory : ResourceBasedOverride {
|
||||
val runningPackage =
|
||||
TopTaskTracker.INSTANCE[activity].getCachedTopTask(
|
||||
/* filterOnlyVisibleRecents */ true,
|
||||
activity.display.displayId,
|
||||
activity.displayId,
|
||||
)
|
||||
.getPackageName()
|
||||
activity.statsLogManager
|
||||
|
||||
@@ -44,7 +44,6 @@ import com.android.launcher3.R;
|
||||
import com.android.launcher3.anim.AnimatorListeners;
|
||||
import com.android.launcher3.taskbar.BarsLocationAnimatorHelper;
|
||||
import com.android.launcher3.taskbar.bubbles.animation.BubbleAnimator;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.wm.shell.shared.bubbles.BubbleBarLocation;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
@@ -656,7 +655,7 @@ public class BubbleBarView extends FrameLayout {
|
||||
* Get bubble bar top coordinate on screen when bar is resting
|
||||
*/
|
||||
public int getRestingTopPositionOnScreen() {
|
||||
int displayHeight = DisplayController.INSTANCE.get(getContext()).getInfo().currentSize.y;
|
||||
int displayHeight = mController.getScreenHeight();
|
||||
int bubbleBarHeight = getBubbleBarBounds().height();
|
||||
return displayHeight - bubbleBarHeight + (int) mController.getBubbleBarTranslationY();
|
||||
}
|
||||
@@ -1646,6 +1645,9 @@ public class BubbleBarView extends FrameLayout {
|
||||
/** Interface for BubbleBarView to communicate with its controller. */
|
||||
interface Controller {
|
||||
|
||||
/** Returns the screen height. */
|
||||
int getScreenHeight();
|
||||
|
||||
/** Returns the translation Y that the bubble bar should have. */
|
||||
float getBubbleBarTranslationY();
|
||||
|
||||
|
||||
@@ -60,7 +60,6 @@ import com.android.launcher3.taskbar.bubbles.flyout.BubbleBarFlyoutController;
|
||||
import com.android.launcher3.taskbar.bubbles.flyout.BubbleBarFlyoutPositioner;
|
||||
import com.android.launcher3.taskbar.bubbles.flyout.FlyoutCallbacks;
|
||||
import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.MultiPropertyFactory;
|
||||
import com.android.launcher3.util.MultiValueAlpha;
|
||||
import com.android.quickstep.SystemUiProxy;
|
||||
@@ -130,7 +129,7 @@ public class BubbleBarViewController {
|
||||
@Override
|
||||
public void getBubbleBarLocationHitRect(@NonNull BubbleBarLocation bubbleBarLocation,
|
||||
Rect outRect) {
|
||||
Point screenSize = DisplayController.INSTANCE.get(mActivity).getInfo().currentSize;
|
||||
Point screenSize = mActivity.getScreenSize();
|
||||
outRect.top = screenSize.y - mBubbleBarDropTargetSize;
|
||||
outRect.bottom = screenSize.y;
|
||||
if (bubbleBarLocation.isOnLeft(mBarView.isLayoutRtl())) {
|
||||
@@ -281,6 +280,11 @@ public class BubbleBarViewController {
|
||||
: PINNING_PERSISTENT;
|
||||
mBubbleBarPinning.updateValue(pinningValue);
|
||||
mBarView.setController(new BubbleBarView.Controller() {
|
||||
@Override
|
||||
public int getScreenHeight() {
|
||||
return mActivity.getScreenSize().y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBubbleBarTranslationY() {
|
||||
return mBubbleStashController.getBubbleBarTranslationY();
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.android.launcher3.Utilities
|
||||
import com.android.launcher3.taskbar.TaskbarActivityContext
|
||||
import com.android.launcher3.taskbar.TaskbarControllers
|
||||
import com.android.launcher3.taskbar.TaskbarControllers.LoggableTaskbarController
|
||||
import com.android.launcher3.util.DisplayController
|
||||
import com.android.launcher3.views.ActivityContext
|
||||
import java.io.PrintWriter
|
||||
|
||||
@@ -43,7 +42,7 @@ class NudgeController(context: Context) : LoggableTaskbarController {
|
||||
}
|
||||
|
||||
fun maybeShow(payload: NudgePayload) {
|
||||
if (!isNudgeEnabled || !DisplayController.isTransientTaskbar(activityContext)) {
|
||||
if (!isNudgeEnabled || !activityContext.isTransientTaskbar) {
|
||||
return
|
||||
}
|
||||
// TODO: b/398033012 - create and show nudge view based on the payload.
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.android.launcher3.taskbar.overlay;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Point;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -56,7 +57,7 @@ public class TaskbarOverlayContext extends BaseTaskbarContext {
|
||||
Context windowContext,
|
||||
TaskbarActivityContext taskbarContext,
|
||||
TaskbarControllers controllers) {
|
||||
super(windowContext, taskbarContext.isPrimaryDisplay());
|
||||
super(windowContext, taskbarContext.getDisplayId(), taskbarContext.isPrimaryDisplay());
|
||||
mTaskbarContext = taskbarContext;
|
||||
mOverlayController = controllers.taskbarOverlayController;
|
||||
mDragController = new TaskbarDragController(this);
|
||||
@@ -178,8 +179,18 @@ public class TaskbarOverlayContext extends BaseTaskbarContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrimaryDisplay() {
|
||||
return mTaskbarContext.isPrimaryDisplay();
|
||||
public Point getScreenSize() {
|
||||
return mTaskbarContext.getScreenSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDisplayHeight() {
|
||||
return mTaskbarContext.getDisplayHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyConfigChanged() {
|
||||
mTaskbarContext.notifyConfigChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user