Prevent taskbar on phone from crashing
* Update code behind flag to work with transient taskbar
* We explicitly set the mDestroyed flag to false in
TaskbarActivityContext because it gets set to true when
the flag is on, but nothing resets it unless it gets
recreated normally.
Bug: 274517647
Flag: persist.wm.debug.hide_navbar_window
Test: Enable flag and verify no crash
Change-Id: I9a149ffb47a10efedfc9dff8399d12d4c1a31553
diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
index a713ff5..9a9e0ba 100644
--- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
@@ -714,6 +714,8 @@
* setup wizard, or normal 3 button nav.
*/
private void updateButtonLayoutSpacing() {
+ boolean isThreeButtonNav = mContext.isThreeButtonNav();
+
DeviceProfile dp = mContext.getDeviceProfile();
Resources res = mContext.getResources();
boolean isInSetup = !mContext.isUserSetupComplete();
@@ -721,7 +723,9 @@
boolean isInKidsMode = mContext.isNavBarKidsModeActive();
if (TaskbarManager.FLAG_HIDE_NAVBAR_WINDOW) {
- boolean isThreeButtonNav = mContext.isThreeButtonNav();
+ if (!isThreeButtonNav) {
+ return;
+ }
NavButtonLayoutter navButtonLayoutter =
NavButtonLayoutFactory.Companion.getUiLayoutter(
@@ -803,7 +807,7 @@
mNavButtonContainer.requestLayout();
mHomeButton.setOnLongClickListener(null);
- } else if (mContext.isThreeButtonNav()) {
+ } else if (isThreeButtonNav) {
final RotateDrawable rotateDrawable = new RotateDrawable();
rotateDrawable.setDrawable(mContext.getDrawable(R.drawable.ic_sysbar_back));
rotateDrawable.setFromDegrees(0f);
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index 5c53b5f..232b761 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -186,7 +186,8 @@
mRightCorner = display.getRoundedCorner(RoundedCorner.POSITION_BOTTOM_RIGHT);
// Inflate views.
- int taskbarLayout = DisplayController.isTransientTaskbar(this)
+ boolean phoneMode = TaskbarManager.isPhoneMode(mDeviceProfile);
+ int taskbarLayout = DisplayController.isTransientTaskbar(this) && !phoneMode
? R.layout.transient_taskbar
: R.layout.taskbar;
mDragLayer = (TaskbarDragLayer) mLayoutInflater.inflate(taskbarLayout, null, false);
@@ -254,6 +255,12 @@
sharedState.systemBarAttrsBehavior);
onNavButtonsDarkIntensityChanged(sharedState.navButtonsDarkIntensity);
+ if (FLAG_HIDE_NAVBAR_WINDOW) {
+ // W/ the flag not set this entire class gets re-created, which resets the value of
+ // mIsDestroyed. We re-use the class for small-screen, so we explicitly have to mark
+ // this class as non-destroyed
+ mIsDestroyed = false;
+ }
if (!mAddedWindow) {
mWindowManager.addView(mDragLayer, mWindowLayoutParams);
@@ -334,7 +341,7 @@
public WindowManager.LayoutParams createDefaultWindowLayoutParams(int type, String title) {
DeviceProfile deviceProfile = getDeviceProfile();
// Taskbar is on the logical bottom of the screen
- boolean isVerticalBarLayout = TaskbarManager.isPhoneMode(deviceProfile) &&
+ boolean isVerticalBarLayout = TaskbarManager.isPhoneButtonNavMode(this) &&
deviceProfile.isLandscape;
int windowFlags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt
index 07cea01..fe365f7 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt
@@ -16,11 +16,13 @@
package com.android.launcher3.taskbar
+import android.content.res.Resources
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.graphics.Path
import android.graphics.RectF
+import com.android.launcher3.DeviceProfile
import com.android.launcher3.R
import com.android.launcher3.Utilities
import com.android.launcher3.Utilities.mapRange
@@ -61,7 +63,7 @@
private val invertedLeftCornerPath: Path = Path()
private val invertedRightCornerPath: Path = Path()
- private val stashedHandleWidth =
+ private var stashedHandleWidth =
context.resources.getDimensionPixelSize(R.dimen.taskbar_stashed_handle_width)
private val stashedHandleHeight =
@@ -86,6 +88,13 @@
setCornerRoundness(DEFAULT_ROUNDNESS)
}
+ fun updateStashedHandleWidth(dp: DeviceProfile, res: Resources) {
+ stashedHandleWidth = res.getDimensionPixelSize(
+ if (TaskbarManager.isPhoneMode(dp)) R.dimen.taskbar_stashed_small_screen
+ else R.dimen.taskbar_stashed_handle_width
+ )
+ }
+
/**
* Sets the roundness of the round corner above Taskbar. No effect on transient Taskkbar.
*
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayer.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayer.java
index c53460d..7681fe0 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayer.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayer.java
@@ -71,7 +71,7 @@
public void init(TaskbarDragLayerController.TaskbarDragLayerCallbacks callbacks) {
mControllerCallbacks = callbacks;
-
+ mBackgroundRenderer.updateStashedHandleWidth(mActivity.getDeviceProfile(), getResources());
recreateControllers();
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
index a3e6814..6034739 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
@@ -114,7 +114,8 @@
mActivityContext = ActivityContext.lookupContext(context);
mIconLayoutBounds = mActivityContext.getTransientTaskbarBounds();
Resources resources = getResources();
- boolean isTransientTaskbar = DisplayController.isTransientTaskbar(mActivityContext);
+ boolean isTransientTaskbar = DisplayController.isTransientTaskbar(mActivityContext)
+ && !TaskbarManager.isPhoneMode(mActivityContext.getDeviceProfile());
mIsRtl = Utilities.isRtl(resources);
mTransientTaskbarMinWidth = mContext.getResources().getDimension(
R.dimen.transient_taskbar_min_width);
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index 1cf682b..ba9988d 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -77,6 +77,7 @@
import androidx.annotation.UiThread;
import com.android.launcher3.BaseDraggingActivity;
+import com.android.launcher3.DeviceProfile;
import com.android.launcher3.LauncherPrefs;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
@@ -835,12 +836,18 @@
// If Taskbar is present, we listen for long press to unstash it.
TaskbarActivityContext tac = mTaskbarManager.getCurrentActivityContext();
- if (tac != null && canStartSystemGesture) {
- reasonString.append(NEWLINE_PREFIX)
- .append(reasonPrefix)
- .append(SUBSTRING_PREFIX)
- .append("TaskbarActivityContext != null, using TaskbarStashInputConsumer");
- base = new TaskbarStashInputConsumer(this, base, mInputMonitorCompat, tac);
+ if (tac != null) {
+ // Present always on large screen or on small screen w/ flag
+ DeviceProfile dp = tac.getDeviceProfile();
+ boolean useTaskbarConsumer = dp.isTaskbarPresent && !TaskbarManager.isPhoneMode(dp);
+ if (canStartSystemGesture && useTaskbarConsumer) {
+ reasonString.append(NEWLINE_PREFIX)
+ .append(reasonPrefix)
+ .append(SUBSTRING_PREFIX)
+ .append("TaskbarActivityContext != null, "
+ + "using TaskbarStashInputConsumer");
+ base = new TaskbarStashInputConsumer(this, base, mInputMonitorCompat, tac);
+ }
}
if (mDeviceState.isBubblesExpanded()) {