Always recreate TaskbarActivityContext
- Add ENABLE_TASKBAR_NO_RECREATION flag When the flag is turned on, * Always destroy and recreate * Move task bar drag layer lifecycle from TaskbarActivityContext to TaskbarManager * Wrap the drag layer into a fullscreen root view Note that in order to preserve the window across multiple TaskbarActivityContext creations, the inset types and ids must stay the same, so it's extracted out. Bug: 274517647 Test: Fold and unfold a few times. Use a few applications. Make sure the task bar is visible and in the right place (tested with ENABLE_TASKBAR_NO_RECREATION and FLAG_HIDE_NAVBAR_WINDOW both on, both off, and one on and one off) Change-Id: Ic3f0aa3d056fe178a53b76b2ad6cc6b9bffd5898
This commit is contained in:
@@ -23,6 +23,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL;
|
||||
import static com.android.launcher3.LauncherPrefs.TASKBAR_PINNING;
|
||||
import static com.android.launcher3.LauncherPrefs.TASKBAR_PINNING_KEY;
|
||||
import static com.android.launcher3.LauncherState.OVERVIEW;
|
||||
import static com.android.launcher3.config.FeatureFlags.ENABLE_TASKBAR_NO_RECREATION;
|
||||
import static com.android.launcher3.util.DisplayController.TASKBAR_NOT_DESTROYED_TAG;
|
||||
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
|
||||
import static com.android.launcher3.util.FlagDebugUtils.formatFlagChange;
|
||||
@@ -45,6 +46,8 @@ import android.os.Trace;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -104,6 +107,9 @@ public class TaskbarManager {
|
||||
Settings.Secure.NAV_BAR_KIDS_MODE);
|
||||
|
||||
private final Context mContext;
|
||||
private WindowManager mWindowManager;
|
||||
private FrameLayout mTaskbarRootLayout;
|
||||
private boolean mAddedWindow;
|
||||
private final TaskbarNavButtonController mNavButtonController;
|
||||
private final ComponentCallbacks mComponentCallbacks;
|
||||
|
||||
@@ -175,6 +181,10 @@ public class TaskbarManager {
|
||||
Display display =
|
||||
service.getSystemService(DisplayManager.class).getDisplay(DEFAULT_DISPLAY);
|
||||
mContext = service.createWindowContext(display, TYPE_NAVIGATION_BAR_PANEL, null);
|
||||
if (ENABLE_TASKBAR_NO_RECREATION.get()) {
|
||||
mWindowManager = mContext.getSystemService(WindowManager.class);
|
||||
mTaskbarRootLayout = new FrameLayout(mContext);
|
||||
}
|
||||
mNavButtonController = new TaskbarNavButtonController(service,
|
||||
SystemUiProxy.INSTANCE.get(mContext), new Handler());
|
||||
mComponentCallbacks = new ComponentCallbacks() {
|
||||
@@ -256,10 +266,15 @@ public class TaskbarManager {
|
||||
LauncherPrefs.get(mContext).removeListener(mTaskbarPinningPreferenceChangeListener,
|
||||
TASKBAR_PINNING);
|
||||
mTaskbarActivityContext.onDestroy();
|
||||
if (!FLAG_HIDE_NAVBAR_WINDOW) {
|
||||
if (!FLAG_HIDE_NAVBAR_WINDOW || ENABLE_TASKBAR_NO_RECREATION.get()) {
|
||||
mTaskbarActivityContext = null;
|
||||
}
|
||||
}
|
||||
DeviceProfile dp = mUserUnlocked ?
|
||||
LauncherAppState.getIDP(mContext).getDeviceProfile(mContext) : null;
|
||||
if (dp == null || !isTaskbarPresent(dp)) {
|
||||
removeTaskbarRootViewFromWindow();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -308,6 +323,7 @@ public class TaskbarManager {
|
||||
mUserUnlocked = true;
|
||||
LauncherAppState.getIDP(mContext).addOnChangeListener(mIdpChangeListener);
|
||||
recreateTaskbar();
|
||||
addTaskbarRootViewToWindow();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -388,10 +404,9 @@ public class TaskbarManager {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mTaskbarActivityContext == null) {
|
||||
if (ENABLE_TASKBAR_NO_RECREATION.get() || mTaskbarActivityContext == null) {
|
||||
mTaskbarActivityContext = new TaskbarActivityContext(mContext, dp,
|
||||
mNavButtonController,
|
||||
mUnfoldProgressProvider);
|
||||
mNavButtonController, mUnfoldProgressProvider);
|
||||
} else {
|
||||
mTaskbarActivityContext.updateDeviceProfile(dp);
|
||||
}
|
||||
@@ -402,6 +417,13 @@ public class TaskbarManager {
|
||||
createTaskbarUIControllerForActivity(mActivity));
|
||||
}
|
||||
|
||||
if (ENABLE_TASKBAR_NO_RECREATION.get()) {
|
||||
addTaskbarRootViewToWindow();
|
||||
mTaskbarRootLayout.removeAllViews();
|
||||
mTaskbarRootLayout.addView(mTaskbarActivityContext.getDragLayer());
|
||||
mTaskbarActivityContext.notifyUpdateLayoutParams();
|
||||
}
|
||||
|
||||
// We to wait until user unlocks the device to attach listener.
|
||||
LauncherPrefs.get(mContext).addListener(mTaskbarPinningPreferenceChangeListener,
|
||||
TASKBAR_PINNING);
|
||||
@@ -523,6 +545,22 @@ public class TaskbarManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void addTaskbarRootViewToWindow() {
|
||||
if (ENABLE_TASKBAR_NO_RECREATION.get() && !mAddedWindow
|
||||
&& mTaskbarActivityContext != null) {
|
||||
mWindowManager.addView(mTaskbarRootLayout,
|
||||
mTaskbarActivityContext.getWindowLayoutParams());
|
||||
mAddedWindow = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void removeTaskbarRootViewFromWindow() {
|
||||
if (ENABLE_TASKBAR_NO_RECREATION.get() && mAddedWindow) {
|
||||
mWindowManager.removeViewImmediate(mTaskbarRootLayout);
|
||||
mAddedWindow = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** Temp logs for b/254119092. */
|
||||
public void debugWhyTaskbarNotDestroyed(String debugReason) {
|
||||
StringJoiner log = new StringJoiner("\n");
|
||||
|
||||
Reference in New Issue
Block a user