Merge "Use DISPLAY_CATEGORY_ALL_INCLUDING_DISABLED for getDisplays" into tm-qpr-dev
diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
index 5d576f7..01cf23b 100644
--- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
@@ -35,6 +35,7 @@
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_OVERVIEW_DISABLED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_QUICK_SETTINGS_EXPANDED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SCREEN_PINNING;
+import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_VOICE_INTERACTION_WINDOW_SHOWING;
import static com.android.systemui.shared.system.ViewTreeObserverWrapper.InsetsInfo.TOUCHABLE_INSETS_REGION;
import android.animation.ArgbEvaluator;
@@ -105,6 +106,7 @@
private static final int FLAG_DISABLE_BACK = 1 << 9;
private static final int FLAG_NOTIFICATION_SHADE_EXPANDED = 1 << 10;
private static final int FLAG_SCREEN_PINNING_ACTIVE = 1 << 11;
+ private static final int FLAG_VOICE_INTERACTION_WINDOW_SHOWING = 1 << 12;
private static final int MASK_IME_SWITCHER_VISIBLE = FLAG_SWITCHER_SUPPORTED | FLAG_IME_VISIBLE;
@@ -207,9 +209,12 @@
boolean isInKidsMode = mContext.isNavBarKidsModeActive();
boolean alwaysShowButtons = isThreeButtonNav || isInSetup;
- // Make sure to remove nav bar buttons translation when notification shade is expanded or
- // IME is showing (add separate translation for IME).
- int flagsToRemoveTranslation = FLAG_NOTIFICATION_SHADE_EXPANDED | FLAG_IME_VISIBLE;
+ // Make sure to remove nav bar buttons translation when any of the following occur:
+ // - Notification shade is expanded
+ // - IME is showing (add separate translation for IME)
+ // - VoiceInteractionWindow (assistant) is showing
+ int flagsToRemoveTranslation = FLAG_NOTIFICATION_SHADE_EXPANDED | FLAG_IME_VISIBLE
+ | FLAG_VOICE_INTERACTION_WINDOW_SHOWING;
mPropertyHolders.add(new StatePropertyHolder(mNavButtonInAppDisplayProgressForSysui,
flags -> (flags & flagsToRemoveTranslation) != 0, AnimatedFloat.VALUE,
1, 0));
@@ -443,6 +448,8 @@
| SYSUI_STATE_QUICK_SETTINGS_EXPANDED;
boolean isNotificationShadeExpanded = (sysUiStateFlags & shadeExpandedFlags) != 0;
boolean isScreenPinningActive = (sysUiStateFlags & SYSUI_STATE_SCREEN_PINNING) != 0;
+ boolean isVoiceInteractionWindowShowing =
+ (sysUiStateFlags & SYSUI_STATE_VOICE_INTERACTION_WINDOW_SHOWING) != 0;
// TODO(b/202218289) we're getting IME as not visible on lockscreen from system
updateStateForFlag(FLAG_IME_VISIBLE, isImeVisible);
@@ -453,6 +460,7 @@
updateStateForFlag(FLAG_DISABLE_BACK, isBackDisabled);
updateStateForFlag(FLAG_NOTIFICATION_SHADE_EXPANDED, isNotificationShadeExpanded);
updateStateForFlag(FLAG_SCREEN_PINNING_ACTIVE, isScreenPinningActive);
+ updateStateForFlag(FLAG_VOICE_INTERACTION_WINDOW_SHOWING, isVoiceInteractionWindowShowing);
if (mA11yButton != null) {
// Only used in 3 button
@@ -750,6 +758,8 @@
appendFlag(str, flags, FLAG_NOTIFICATION_SHADE_EXPANDED,
"FLAG_NOTIFICATION_SHADE_EXPANDED");
appendFlag(str, flags, FLAG_SCREEN_PINNING_ACTIVE, "FLAG_SCREEN_PINNING_ACTIVE");
+ appendFlag(str, flags, FLAG_VOICE_INTERACTION_WINDOW_SHOWING,
+ "FLAG_VOICE_INTERACTION_WINDOW_SHOWING");
return str.toString();
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java b/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java
index b797807..f472427 100644
--- a/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java
@@ -43,7 +43,8 @@
public static final int ALPHA_INDEX_STASHED = 0;
public static final int ALPHA_INDEX_HOME_DISABLED = 1;
- private static final int NUM_ALPHA_CHANNELS = 2;
+ public static final int ALPHA_INDEX_ASSISTANT_INVOKED = 2;
+ private static final int NUM_ALPHA_CHANNELS = 3;
/**
* The SharedPreferences key for whether the stashed handle region is dark.
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index 95da118..61fad50 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -27,6 +27,7 @@
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_OPEN;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_QUICK_SETTINGS_EXPANDED;
+import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_VOICE_INTERACTION_WINDOW_SHOWING;
import android.animation.AnimatorSet;
import android.animation.ValueAnimator;
@@ -200,7 +201,8 @@
new TaskbarPopupController(this),
new TaskbarForceVisibleImmersiveController(this),
new TaskbarAllAppsController(this, dp),
- new TaskbarInsetsController(this));
+ new TaskbarInsetsController(this),
+ new VoiceInteractionWindowController(this));
}
public void init(@NonNull TaskbarSharedState sharedState) {
@@ -246,12 +248,20 @@
return super.getStatsLogManager();
}
- /** Creates LayoutParams for adding a view directly to WindowManager as a new window */
+ /** @see #createDefaultWindowLayoutParams(int) */
public WindowManager.LayoutParams createDefaultWindowLayoutParams() {
+ return createDefaultWindowLayoutParams(TYPE_NAVIGATION_BAR_PANEL);
+ }
+
+ /**
+ * Creates LayoutParams for adding a view directly to WindowManager as a new window.
+ * @param type The window type to pass to the created WindowManager.LayoutParams.
+ */
+ public WindowManager.LayoutParams createDefaultWindowLayoutParams(int type) {
WindowManager.LayoutParams windowLayoutParams = new WindowManager.LayoutParams(
MATCH_PARENT,
mLastRequestedNonFullscreenHeight,
- TYPE_NAVIGATION_BAR_PANEL,
+ type,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_SLIPPERY,
PixelFormat.TRANSLUCENT);
@@ -468,6 +478,8 @@
fromInit);
mControllers.navButtonController.updateSysuiFlags(systemUiStateFlags);
mControllers.taskbarForceVisibleImmersiveController.updateSysuiFlags(systemUiStateFlags);
+ mControllers.voiceInteractionWindowController.setIsVoiceInteractionWindowVisible(
+ (systemUiStateFlags & SYSUI_STATE_VOICE_INTERACTION_WINDOW_SHOWING) != 0, fromInit);
}
/**
@@ -612,7 +624,9 @@
/** Removes the given view from WindowManager. See {@link #addWindowView}. */
public void removeWindowView(View view) {
- mWindowManager.removeViewImmediate(view);
+ if (view.isAttachedToWindow()) {
+ mWindowManager.removeViewImmediate(view);
+ }
}
protected void onTaskbarIconClicked(View view) {
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java
index 449e0a7..d7b50b0 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java
@@ -52,6 +52,7 @@
public final TaskbarForceVisibleImmersiveController taskbarForceVisibleImmersiveController;
public final TaskbarAllAppsController taskbarAllAppsController;
public final TaskbarInsetsController taskbarInsetsController;
+ public final VoiceInteractionWindowController voiceInteractionWindowController;
@Nullable private LoggableTaskbarController[] mControllersToLog = null;
@@ -80,7 +81,8 @@
TaskbarPopupController taskbarPopupController,
TaskbarForceVisibleImmersiveController taskbarForceVisibleImmersiveController,
TaskbarAllAppsController taskbarAllAppsController,
- TaskbarInsetsController taskbarInsetsController) {
+ TaskbarInsetsController taskbarInsetsController,
+ VoiceInteractionWindowController voiceInteractionWindowController) {
this.taskbarActivityContext = taskbarActivityContext;
this.taskbarDragController = taskbarDragController;
this.navButtonController = navButtonController;
@@ -99,6 +101,7 @@
this.taskbarForceVisibleImmersiveController = taskbarForceVisibleImmersiveController;
this.taskbarAllAppsController = taskbarAllAppsController;
this.taskbarInsetsController = taskbarInsetsController;
+ this.voiceInteractionWindowController = voiceInteractionWindowController;
}
/**
@@ -126,13 +129,15 @@
taskbarAllAppsController.init(this, sharedState.allAppsVisible);
navButtonController.init(this);
taskbarInsetsController.init(this);
+ voiceInteractionWindowController.init(this);
mControllersToLog = new LoggableTaskbarController[] {
taskbarDragController, navButtonController, navbarButtonsViewController,
taskbarDragLayerController, taskbarScrimViewController, taskbarViewController,
taskbarUnfoldAnimationController, taskbarKeyguardController,
stashedHandleViewController, taskbarStashController, taskbarEduController,
- taskbarAutohideSuspendController, taskbarPopupController, taskbarInsetsController
+ taskbarAutohideSuspendController, taskbarPopupController, taskbarInsetsController,
+ voiceInteractionWindowController
};
mAreAllControllersInitialized = true;
@@ -172,6 +177,7 @@
taskbarAllAppsController.onDestroy();
navButtonController.onDestroy();
taskbarInsetsController.onDestroy();
+ voiceInteractionWindowController.onDestroy();
mControllersToLog = null;
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
index 3562f5b..fdd9de5 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
@@ -63,7 +63,8 @@
public static final int ALPHA_INDEX_STASH = 2;
public static final int ALPHA_INDEX_RECENTS_DISABLED = 3;
public static final int ALPHA_INDEX_NOTIFICATION_EXPANDED = 4;
- private static final int NUM_ALPHA_CHANNELS = 5;
+ public static final int ALPHA_INDEX_ASSISTANT_INVOKED = 5;
+ private static final int NUM_ALPHA_CHANNELS = 6;
private final TaskbarActivityContext mActivity;
private final TaskbarView mTaskbarView;
diff --git a/quickstep/src/com/android/launcher3/taskbar/VoiceInteractionWindowController.kt b/quickstep/src/com/android/launcher3/taskbar/VoiceInteractionWindowController.kt
new file mode 100644
index 0000000..946873e
--- /dev/null
+++ b/quickstep/src/com/android/launcher3/taskbar/VoiceInteractionWindowController.kt
@@ -0,0 +1,109 @@
+package com.android.launcher3.taskbar
+
+import android.graphics.Canvas
+import android.view.WindowManager
+import android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
+import com.android.launcher3.views.BaseDragLayer
+import com.android.systemui.animation.ViewRootSync
+import java.io.PrintWriter
+
+private const val TASKBAR_ICONS_FADE_DURATION = 300L
+private const val STASHED_HANDLE_FADE_DURATION = 180L
+
+/**
+ * Controls Taskbar behavior while Voice Interaction Window (assistant) is showing.
+ */
+class VoiceInteractionWindowController(val context: TaskbarActivityContext)
+ : TaskbarControllers.LoggableTaskbarController {
+
+ private val taskbarBackgroundRenderer = TaskbarBackgroundRenderer(context)
+
+ // Initialized in init.
+ private lateinit var controllers: TaskbarControllers
+ private lateinit var separateWindowForTaskbarBackground: BaseDragLayer<TaskbarActivityContext>
+ private lateinit var separateWindowLayoutParams: WindowManager.LayoutParams
+
+ private var isVoiceInteractionWindowVisible: Boolean = false
+
+ fun init(controllers: TaskbarControllers) {
+ this.controllers = controllers
+
+ separateWindowForTaskbarBackground =
+ object : BaseDragLayer<TaskbarActivityContext>(context, null, 0) {
+ override fun recreateControllers() {
+ mControllers = emptyArray()
+ }
+
+ override fun draw(canvas: Canvas) {
+ super.draw(canvas)
+ taskbarBackgroundRenderer.draw(canvas)
+ }
+ }
+ separateWindowForTaskbarBackground.recreateControllers()
+ separateWindowForTaskbarBackground.setWillNotDraw(false)
+
+ separateWindowLayoutParams = context.createDefaultWindowLayoutParams(
+ TYPE_APPLICATION_OVERLAY)
+ separateWindowLayoutParams.isSystemApplicationOverlay = true
+ }
+
+ fun onDestroy() {
+ setIsVoiceInteractionWindowVisible(visible = false, skipAnim = true)
+ }
+
+ fun setIsVoiceInteractionWindowVisible(visible: Boolean, skipAnim: Boolean) {
+ if (isVoiceInteractionWindowVisible == visible) {
+ return
+ }
+ isVoiceInteractionWindowVisible = visible
+
+ // Fade out taskbar icons and stashed handle.
+ val taskbarIconAlpha = if (isVoiceInteractionWindowVisible) 0f else 1f
+ val fadeTaskbarIcons = controllers.taskbarViewController.taskbarIconAlpha
+ .getProperty(TaskbarViewController.ALPHA_INDEX_ASSISTANT_INVOKED)
+ .animateToValue(taskbarIconAlpha)
+ .setDuration(TASKBAR_ICONS_FADE_DURATION)
+ val fadeStashedHandle = controllers.stashedHandleViewController.stashedHandleAlpha
+ .getProperty(StashedHandleViewController.ALPHA_INDEX_ASSISTANT_INVOKED)
+ .animateToValue(taskbarIconAlpha)
+ .setDuration(STASHED_HANDLE_FADE_DURATION)
+ fadeTaskbarIcons.start()
+ fadeStashedHandle.start()
+ if (skipAnim) {
+ fadeTaskbarIcons.end()
+ fadeStashedHandle.end()
+ }
+
+ if (context.isGestureNav && controllers.taskbarStashController.isInAppAndNotStashed) {
+ moveTaskbarBackgroundToLowerLayer()
+ }
+ }
+
+ /**
+ * Hides the TaskbarDragLayer background and creates a new window to draw just that background.
+ */
+ private fun moveTaskbarBackgroundToLowerLayer() {
+ val taskbarBackgroundOverride = controllers.taskbarDragLayerController
+ .overrideBackgroundAlpha
+ if (isVoiceInteractionWindowVisible) {
+ // First add the temporary window, then hide the overlapping taskbar background.
+ context.addWindowView(separateWindowForTaskbarBackground, separateWindowLayoutParams)
+ ViewRootSync.synchronizeNextDraw(separateWindowForTaskbarBackground, context.dragLayer
+ ) {
+ taskbarBackgroundOverride.updateValue(0f)
+ }
+ } else {
+ // First reapply the original taskbar background, then remove the temporary window.
+ taskbarBackgroundOverride.updateValue(1f)
+ ViewRootSync.synchronizeNextDraw(separateWindowForTaskbarBackground, context.dragLayer
+ ) {
+ context.removeWindowView(separateWindowForTaskbarBackground)
+ }
+ }
+ }
+
+ override fun dumpLogs(prefix: String, pw: PrintWriter) {
+ pw.println(prefix + "VoiceInteractionWindowController:")
+ pw.println("$prefix\tisVoiceInteractionWindowVisible=$isVoiceInteractionWindowVisible")
+ }
+}
\ No newline at end of file
diff --git a/quickstep/src/com/android/quickstep/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java
index 6179b81..db402af 100644
--- a/quickstep/src/com/android/quickstep/TaskViewUtils.java
+++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java
@@ -514,9 +514,6 @@
for (SurfaceControl leash: openingTargets) {
t.setAlpha(leash, progress);
}
- for (SurfaceControl leash: closingTargets) {
- t.setAlpha(leash, 1 - progress);
- }
t.apply();
});
animator.addListener(new AnimatorListenerAdapter() {
diff --git a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java
index 85ef6cb..3b9e2b2 100644
--- a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java
+++ b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java
@@ -462,6 +462,7 @@
private LatencyType mType = LatencyType.UNKNOWN;
private int mPackageId = 0;
private long mLatencyInMillis;
+ private int mQueryLength = -1;
StatsCompatLatencyLogger(Context context, ActivityContext activityContext) {
mContext = context;
@@ -493,6 +494,12 @@
}
@Override
+ public StatsLatencyLogger withQueryLength(int queryLength) {
+ this.mQueryLength = queryLength;
+ return this;
+ }
+
+ @Override
public void log(EventEnum event) {
if (IS_VERBOSE) {
String name = (event instanceof Enum) ? ((Enum) event).name() :
@@ -508,7 +515,8 @@
mInstanceId.getId(), // instance_id
mPackageId, // package_id
mLatencyInMillis, // latency_in_millis
- mType.getId() //type
+ mType.getId(), //type
+ mQueryLength // query_length
);
}
}
diff --git a/src/com/android/launcher3/DropTargetBar.java b/src/com/android/launcher3/DropTargetBar.java
index d908440..c1304d4 100644
--- a/src/com/android/launcher3/DropTargetBar.java
+++ b/src/com/android/launcher3/DropTargetBar.java
@@ -194,9 +194,10 @@
int widthSpec = MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST);
firstButton.measure(widthSpec, heightSpec);
if (!mIsVertical) {
- // Remove icons and put the button's text on two lines if text is truncated.
+ // Remove both icons and put the button's text on two lines if text is truncated.
if (firstButton.isTextTruncated(availableWidth)) {
firstButton.setIconVisible(false);
+ secondButton.setIconVisible(false);
firstButton.setTextMultiLine(true);
firstButton.setPadding(horizontalPadding, verticalPadding / 2,
horizontalPadding, verticalPadding / 2);
@@ -209,8 +210,10 @@
}
secondButton.measure(widthSpec, heightSpec);
if (!mIsVertical) {
+ // Remove both icons and put the button's text on two lines if text is truncated.
if (secondButton.isTextTruncated(availableWidth)) {
secondButton.setIconVisible(false);
+ firstButton.setIconVisible(false);
secondButton.setTextMultiLine(true);
secondButton.setPadding(horizontalPadding, verticalPadding / 2,
horizontalPadding, verticalPadding / 2);
diff --git a/src/com/android/launcher3/LauncherAnimUtils.java b/src/com/android/launcher3/LauncherAnimUtils.java
index 808bf96..0c7c311 100644
--- a/src/com/android/launcher3/LauncherAnimUtils.java
+++ b/src/com/android/launcher3/LauncherAnimUtils.java
@@ -26,6 +26,7 @@
import android.util.IntProperty;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
+import android.widget.TextView;
import com.android.launcher3.util.MultiScalePropertyFactory;
@@ -115,6 +116,32 @@
}
};
+ public static final IntProperty<TextView> TEXT_COLOR =
+ new IntProperty<TextView>("textColor") {
+ @Override
+ public Integer get(TextView view) {
+ return view.getTextColors().getDefaultColor();
+ }
+
+ @Override
+ public void setValue(TextView view, int color) {
+ view.setTextColor(color);
+ }
+ };
+
+ public static final IntProperty<TextView> HINT_TEXT_COLOR =
+ new IntProperty<TextView>("hintTextColor") {
+ @Override
+ public Integer get(TextView view) {
+ return view.getHintTextColors().getDefaultColor();
+ }
+
+ @Override
+ public void setValue(TextView view, int color) {
+ view.setHintTextColor(color);
+ }
+ };
+
public static final FloatProperty<View> VIEW_TRANSLATE_X =
View.TRANSLATION_X instanceof FloatProperty ? (FloatProperty) View.TRANSLATION_X
: new FloatProperty<View>("translateX") {
diff --git a/src/com/android/launcher3/anim/AnimatedPropertySetter.java b/src/com/android/launcher3/anim/AnimatedPropertySetter.java
index 01301f2..82e645a 100644
--- a/src/com/android/launcher3/anim/AnimatedPropertySetter.java
+++ b/src/com/android/launcher3/anim/AnimatedPropertySetter.java
@@ -97,6 +97,18 @@
return anim;
}
+ @NonNull
+ @Override
+ public <T> Animator setColor(T target, IntProperty<T> property, int value,
+ TimeInterpolator interpolator) {
+ if (property.get(target) == value) {
+ return NO_OP;
+ }
+ Animator anim = ObjectAnimator.ofArgb(target, property, value);
+ anim.setInterpolator(interpolator);
+ add(anim);
+ return anim;
+ }
/**
* Adds a callback to be run on every frame of the animation
diff --git a/src/com/android/launcher3/anim/PropertySetter.java b/src/com/android/launcher3/anim/PropertySetter.java
index d2207f6..b0ed2d2 100644
--- a/src/com/android/launcher3/anim/PropertySetter.java
+++ b/src/com/android/launcher3/anim/PropertySetter.java
@@ -89,6 +89,16 @@
}
/**
+ * Updates a color property of the target using the provided interpolator
+ */
+ @NonNull
+ public <T> Animator setColor(T target, IntProperty<T> property, int value,
+ TimeInterpolator interpolator) {
+ property.setValue(target, value);
+ return NO_OP;
+ }
+
+ /**
* Runs the animation as part of setting the property
*/
public abstract void add(Animator animatorSet);
diff --git a/src/com/android/launcher3/logging/StatsLogManager.java b/src/com/android/launcher3/logging/StatsLogManager.java
index 5dcd48c..7d24fe8 100644
--- a/src/com/android/launcher3/logging/StatsLogManager.java
+++ b/src/com/android/launcher3/logging/StatsLogManager.java
@@ -772,6 +772,13 @@
}
/**
+ * Sets query length of the event.
+ */
+ default StatsLatencyLogger withQueryLength(int queryLength) {
+ return this;
+ }
+
+ /**
* Sets packageId of log message.
*/
default StatsLatencyLogger withPackageId(int packageId) {