Merge "Allow to show pinned taskbar when Launcher is visible" into main

This commit is contained in:
Toshiki Kikuchi
2024-09-18 23:16:57 +00:00
committed by Android (Google) Code Review
7 changed files with 100 additions and 4 deletions
@@ -194,6 +194,13 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
INSTANCE.get(context).handleInfoChange(context.getDisplay());
}
/**
* Handles info change for launcher visibility.
*/
public static void handleInfoChangeForLauncherVisibilityChanged(Context context) {
INSTANCE.get(context).handleInfoChange(context.getDisplay());
}
/**
* Enables transient taskbar status for tests.
*/
@@ -217,6 +224,13 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
return INSTANCE.get(context).getInfo().isPinnedTaskbar();
}
/**
* Returns whether the taskbar is forced to be pinned when home is visible.
*/
public static boolean showLockedTaskbarOnHome(Context context) {
return INSTANCE.get(context).getInfo().showLockedTaskbarOnHome();
}
@Override
public void close() {
mDestroyed = true;
@@ -345,7 +359,8 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
}
if ((newInfo.mIsTaskbarPinned != oldInfo.mIsTaskbarPinned)
|| (newInfo.mIsTaskbarPinnedInDesktopMode
!= oldInfo.mIsTaskbarPinnedInDesktopMode)) {
!= oldInfo.mIsTaskbarPinnedInDesktopMode)
|| newInfo.isPinnedTaskbar() != oldInfo.isPinnedTaskbar()) {
change |= CHANGE_TASKBAR_PINNING;
}
if (newInfo.mIsInDesktopMode != oldInfo.mIsInDesktopMode) {
@@ -399,6 +414,9 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
private final boolean mIsInDesktopMode;
private final boolean mShowLockedTaskbarOnHome;
private final boolean mIsHomeVisible;
public Info(Context displayInfoContext) {
/* don't need system overrides for external displays */
this(displayInfoContext, new WindowManagerProxy(), new ArrayMap<>());
@@ -460,6 +478,8 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
mIsTaskbarPinnedInDesktopMode = LauncherPrefs.get(displayInfoContext).get(
TASKBAR_PINNING_IN_DESKTOP_MODE);
mIsInDesktopMode = wmProxy.isInDesktopMode();
mShowLockedTaskbarOnHome = wmProxy.showLockedTaskbarOnHome(displayInfoContext);
mIsHomeVisible = wmProxy.isHomeVisible(displayInfoContext);
}
/**
@@ -476,6 +496,10 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
return sTransientTaskbarStatusForTests;
}
if (enableTaskbarPinning()) {
// If Launcher is visible on the freeform display, ensure the taskbar is pinned.
if (mShowLockedTaskbarOnHome && mIsHomeVisible) {
return false;
}
if (mIsInDesktopMode) {
return !mIsTaskbarPinnedInDesktopMode;
}
@@ -543,6 +567,13 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
return TYPE_PHONE;
}
}
/**
* Returns whether the taskbar is forced to be pinned when home is visible.
*/
public boolean showLockedTaskbarOnHome() {
return mShowLockedTaskbarOnHome;
}
}
/**
@@ -121,6 +121,20 @@ public class WindowManagerProxy implements ResourceBasedOverride, SafeCloseable
return false;
}
/**
* Returns if the pinned taskbar should be shown when home is visible.
*/
public boolean showLockedTaskbarOnHome(Context displayInfoContext) {
return false;
}
/**
* Returns if the home is visible.
*/
public boolean isHomeVisible(Context context) {
return false;
}
/**
* Returns the real bounds for the provided display after applying any insets normalization
*/