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:
Tracy Zhou
2023-08-29 22:39:04 -07:00
parent 20bbe42cad
commit 01cc856157
5 changed files with 112 additions and 14 deletions
@@ -27,6 +27,7 @@ import static com.android.launcher3.AbstractFloatingView.TYPE_ALL;
import static com.android.launcher3.AbstractFloatingView.TYPE_REBIND_SAFE;
import static com.android.launcher3.AbstractFloatingView.TYPE_TASKBAR_OVERLAY_PROXY;
import static com.android.launcher3.Utilities.isRunningInTestHarness;
import static com.android.launcher3.config.FeatureFlags.ENABLE_TASKBAR_NO_RECREATION;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_OPEN;
import static com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_DRAGGING;
import static com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_FULLSCREEN;
@@ -323,11 +324,11 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
mIsDestroyed = false;
}
if (!mAddedWindow) {
if (!ENABLE_TASKBAR_NO_RECREATION.get() && !mAddedWindow) {
mWindowManager.addView(mDragLayer, mWindowLayoutParams);
mAddedWindow = true;
} else {
mWindowManager.updateViewLayout(mDragLayer, mWindowLayoutParams);
notifyUpdateLayoutParams();
}
}
@@ -674,7 +675,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
mIsDestroyed = true;
setUIController(TaskbarUIController.DEFAULT);
mControllers.onDestroy();
if (!FLAG_HIDE_NAVBAR_WINDOW) {
if (!ENABLE_TASKBAR_NO_RECREATION.get() && !FLAG_HIDE_NAVBAR_WINDOW) {
mWindowManager.removeViewImmediate(mDragLayer);
mAddedWindow = false;
}
@@ -806,7 +807,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
}
mWindowLayoutParams.height = height;
mControllers.taskbarInsetsController.onTaskbarOrBubblebarWindowHeightOrInsetsChanged();
mWindowManager.updateViewLayout(mDragLayer, mWindowLayoutParams);
notifyUpdateLayoutParams();
}
/**
@@ -849,7 +850,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
} else {
mWindowLayoutParams.flags |= FLAG_NOT_FOCUSABLE;
}
mWindowManager.updateViewLayout(mDragLayer, mWindowLayoutParams);
notifyUpdateLayoutParams();
}
/**
@@ -1229,12 +1230,16 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
mWindowLayoutParams.privateFlags &=
~WindowManager.LayoutParams.PRIVATE_FLAG_EXCLUDE_FROM_SCREEN_MAGNIFICATION;
}
mWindowManager.updateViewLayout(mDragLayer, mWindowLayoutParams);
notifyUpdateLayoutParams();
}
void notifyUpdateLayoutParams() {
if (mDragLayer.isAttachedToWindow()) {
mWindowManager.updateViewLayout(mDragLayer, mWindowLayoutParams);
if (ENABLE_TASKBAR_NO_RECREATION.get()) {
mWindowManager.updateViewLayout(mDragLayer.getRootView(), mWindowLayoutParams);
} else {
mWindowManager.updateViewLayout(mDragLayer, mWindowLayoutParams);
}
}
}