[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:
Sukesh Ram committed 2025-04-03 23:40:45 -07:00
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() {