Merge "Always recreate TaskbarActivityContext" into main
This commit is contained in:
commit
ca9b884118
5 files changed
+112
-14
No files matched your search
@@ -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;
|
||||
@@ -105,6 +108,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;
|
||||
|
||||
@@ -176,6 +182,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(),
|
||||
AssistUtils.newInstance(mContext));
|
||||
@@ -258,10 +268,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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -310,6 +325,7 @@ public class TaskbarManager {
|
||||
mUserUnlocked = true;
|
||||
LauncherAppState.getIDP(mContext).addOnChangeListener(mIdpChangeListener);
|
||||
recreateTaskbar();
|
||||
addTaskbarRootViewToWindow();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -390,10 +406,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);
|
||||
}
|
||||
@@ -404,6 +419,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);
|
||||
@@ -525,6 +547,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