Merge "Fixed TestWithLooperRule switch for UiThreadStatement and ExpectException" into main
diff --git a/core/java/android/app/appfunctions/GenericDocumentWrapper.java b/core/java/android/app/appfunctions/GenericDocumentWrapper.java
index 84b1837..b29b64e 100644
--- a/core/java/android/app/appfunctions/GenericDocumentWrapper.java
+++ b/core/java/android/app/appfunctions/GenericDocumentWrapper.java
@@ -16,10 +16,13 @@
package android.app.appfunctions;
+import android.annotation.Nullable;
import android.app.appsearch.GenericDocument;
import android.os.Parcel;
import android.os.Parcelable;
+import android.util.MathUtils;
+import androidx.annotation.GuardedBy;
import androidx.annotation.NonNull;
import java.util.Objects;
@@ -31,24 +34,33 @@
* <p>{#link {@link Parcel#writeBlob(byte[])}} could take care of whether to pass data via binder
* directly or Android shared memory if the data is large.
*
+ * <p>This class performs lazy unparcelling. The `GenericDocument` is only unparcelled
+ * from the underlying `Parcel` when {@link #getValue()} is called. This optimization
+ * allows the system server to pass through the generic document, without unparcel and parcel it.
+ *
* @hide
* @see Parcel#writeBlob(byte[])
*/
public final class GenericDocumentWrapper implements Parcelable {
+ @Nullable
+ @GuardedBy("mLock")
+ private GenericDocument mGenericDocument;
+ @GuardedBy("mLock")
+ @Nullable private Parcel mParcel;
+ private final Object mLock = new Object();
+
public static final Creator<GenericDocumentWrapper> CREATOR =
new Creator<>() {
@Override
public GenericDocumentWrapper createFromParcel(Parcel in) {
- byte[] dataBlob = Objects.requireNonNull(in.readBlob());
- Parcel unmarshallParcel = Parcel.obtain();
- try {
- unmarshallParcel.unmarshall(dataBlob, 0, dataBlob.length);
- unmarshallParcel.setDataPosition(0);
- return new GenericDocumentWrapper(
- GenericDocument.createFromParcel(unmarshallParcel));
- } finally {
- unmarshallParcel.recycle();
- }
+ int length = in.readInt();
+ int offset = in.dataPosition();
+ in.setDataPosition(MathUtils.addOrThrow(offset, length));
+
+ Parcel p = Parcel.obtain();
+ p.appendFrom(in, offset, length);
+ p.setDataPosition(0);
+ return new GenericDocumentWrapper(p);
}
@Override
@@ -56,16 +68,42 @@
return new GenericDocumentWrapper[size];
}
};
- @NonNull private final GenericDocument mGenericDocument;
public GenericDocumentWrapper(@NonNull GenericDocument genericDocument) {
mGenericDocument = Objects.requireNonNull(genericDocument);
+ mParcel = null;
+ }
+
+ public GenericDocumentWrapper(@NonNull Parcel parcel) {
+ mGenericDocument = null;
+ mParcel = Objects.requireNonNull(parcel);
}
/** Returns the wrapped {@link android.app.appsearch.GenericDocument} */
@NonNull
public GenericDocument getValue() {
- return mGenericDocument;
+ unparcel();
+ synchronized (mLock) {
+ return Objects.requireNonNull(mGenericDocument);
+ }
+ }
+
+ private void unparcel() {
+ synchronized (mLock) {
+ if (mGenericDocument != null) {
+ return;
+ }
+ byte[] dataBlob = Objects.requireNonNull(Objects.requireNonNull(mParcel).readBlob());
+ Parcel unmarshallParcel = Parcel.obtain();
+ try {
+ unmarshallParcel.unmarshall(dataBlob, 0, dataBlob.length);
+ unmarshallParcel.setDataPosition(0);
+ mGenericDocument = GenericDocument.createFromParcel(unmarshallParcel);
+ mParcel = null;
+ } finally {
+ unmarshallParcel.recycle();
+ }
+ }
}
@Override
@@ -75,13 +113,32 @@
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
- Parcel parcel = Parcel.obtain();
- try {
- mGenericDocument.writeToParcel(parcel, flags);
- byte[] bytes = parcel.marshall();
- dest.writeBlob(bytes);
- } finally {
- parcel.recycle();
+ synchronized (mLock) {
+ if (mGenericDocument != null) {
+ int lengthPos = dest.dataPosition();
+ // write a placeholder for length
+ dest.writeInt(-1);
+ Parcel tempParcel = Parcel.obtain();
+ byte[] bytes;
+ try {
+ mGenericDocument.writeToParcel(tempParcel, flags);
+ bytes = tempParcel.marshall();
+ } finally {
+ tempParcel.recycle();
+ }
+ int startPos = dest.dataPosition();
+ dest.writeBlob(bytes);
+ int endPos = dest.dataPosition();
+ dest.setDataPosition(lengthPos);
+ // Overwrite the length placeholder
+ dest.writeInt(endPos - startPos);
+ dest.setDataPosition(endPos);
+
+ } else {
+ Parcel originalParcel = Objects.requireNonNull(mParcel);
+ dest.writeInt(originalParcel.dataSize());
+ dest.appendFrom(originalParcel, 0, originalParcel.dataSize());
+ }
}
}
}
diff --git a/libs/WindowManager/Shell/res/drawable/app_handle_education_tooltip_icon.xml b/libs/WindowManager/Shell/res/drawable/app_handle_education_tooltip_icon.xml
new file mode 100644
index 0000000..07e5ac1
--- /dev/null
+++ b/libs/WindowManager/Shell/res/drawable/app_handle_education_tooltip_icon.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2024 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:tint="?android:attr/textColorTertiary"
+ android:viewportHeight="960"
+ android:viewportWidth="960">
+ <path
+ android:fillColor="@android:color/system_on_tertiary_fixed"
+ android:pathData="M419,880Q391,880 366.5,868Q342,856 325,834L107,557L126,537Q146,516 174,512Q202,508 226,523L300,568L300,240Q300,223 311.5,211.5Q323,200 340,200Q357,200 369,211.5Q381,223 381,240L381,712L284,652L388,785Q394,792 402,796Q410,800 419,800L640,800Q673,800 696.5,776.5Q720,753 720,720L720,560Q720,543 708.5,531.5Q697,520 680,520L461,520L461,440L680,440Q730,440 765,475Q800,510 800,560L800,720Q800,786 753,833Q706,880 640,880L419,880ZM167,340Q154,318 147,292.5Q140,267 140,240Q140,157 198.5,98.5Q257,40 340,40Q423,40 481.5,98.5Q540,157 540,240Q540,267 533,292.5Q526,318 513,340L444,300Q452,286 456,271.5Q460,257 460,240Q460,190 425,155Q390,120 340,120Q290,120 255,155Q220,190 220,240Q220,257 224,271.5Q228,286 236,300L167,340ZM502,620L502,620L502,620L502,620Q502,620 502,620Q502,620 502,620L502,620Q502,620 502,620Q502,620 502,620L502,620Q502,620 502,620Q502,620 502,620L502,620L502,620Z" />
+</vector>
diff --git a/libs/WindowManager/Shell/res/drawable/desktop_windowing_education_tooltip_background.xml b/libs/WindowManager/Shell/res/drawable/desktop_windowing_education_tooltip_background.xml
new file mode 100644
index 0000000..a12a746
--- /dev/null
+++ b/libs/WindowManager/Shell/res/drawable/desktop_windowing_education_tooltip_background.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2024 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+ <item>
+ <shape android:shape="rectangle">
+ <corners android:radius="30dp" />
+ <solid android:color="@android:color/system_tertiary_fixed" />
+ </shape>
+ </item>
+</layer-list>
diff --git a/libs/WindowManager/Shell/res/drawable/desktop_windowing_education_tooltip_left_arrow.xml b/libs/WindowManager/Shell/res/drawable/desktop_windowing_education_tooltip_left_arrow.xml
new file mode 100644
index 0000000..aadffb5
--- /dev/null
+++ b/libs/WindowManager/Shell/res/drawable/desktop_windowing_education_tooltip_left_arrow.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2024 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<!-- An arrow that points towards left. -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="10dp"
+ android:height="12dp"
+ android:viewportWidth="10"
+ android:viewportHeight="12">
+ <path
+ android:pathData="M2.858,4.285C1.564,5.062 1.564,6.938 2.858,7.715L10,12L10,0L2.858,4.285Z"
+ android:fillColor="@android:color/system_tertiary_fixed"/>
+</vector>
diff --git a/libs/WindowManager/Shell/res/drawable/desktop_windowing_education_tooltip_top_arrow.xml b/libs/WindowManager/Shell/res/drawable/desktop_windowing_education_tooltip_top_arrow.xml
new file mode 100644
index 0000000..e3c9a66
--- /dev/null
+++ b/libs/WindowManager/Shell/res/drawable/desktop_windowing_education_tooltip_top_arrow.xml
@@ -0,0 +1,26 @@
+<!--
+ ~ Copyright (C) 2024 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<!-- An arrow that points upwards. -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="12dp"
+ android:height="9dp"
+ android:viewportWidth="12"
+ android:viewportHeight="9">
+ <path
+ android:pathData="M7.715,1.858C6.938,0.564 5.062,0.564 4.285,1.858L0,9L12,9L7.715,1.858Z"
+ android:fillColor="@android:color/system_tertiary_fixed"/>
+</vector>
diff --git a/libs/WindowManager/Shell/res/layout/desktop_windowing_education_left_arrow_tooltip.xml b/libs/WindowManager/Shell/res/layout/desktop_windowing_education_left_arrow_tooltip.xml
new file mode 100644
index 0000000..a269b9e
--- /dev/null
+++ b/libs/WindowManager/Shell/res/layout/desktop_windowing_education_left_arrow_tooltip.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ Copyright (C) 2024 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:elevation="1dp"
+ android:orientation="horizontal">
+
+ <!-- ImageView for the arrow icon, positioned horizontally at the start of the tooltip
+ container. -->
+ <ImageView
+ android:id="@+id/arrow_icon"
+ android:layout_width="10dp"
+ android:layout_height="12dp"
+ android:layout_gravity="center_vertical"
+ android:src="@drawable/desktop_windowing_education_tooltip_left_arrow" />
+
+ <!-- Layout for the tooltip, excluding the arrow. Separating the tooltip content from the arrow
+ allows scaling of only the tooltip container when the content changes, without affecting the
+ arrow. -->
+ <include layout="@layout/desktop_windowing_education_tooltip_container" />
+</LinearLayout>
diff --git a/libs/WindowManager/Shell/res/layout/desktop_windowing_education_tooltip_container.xml b/libs/WindowManager/Shell/res/layout/desktop_windowing_education_tooltip_container.xml
new file mode 100644
index 0000000..bdee883
--- /dev/null
+++ b/libs/WindowManager/Shell/res/layout/desktop_windowing_education_tooltip_container.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ Copyright (C) 2024 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/tooltip_container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@drawable/desktop_windowing_education_tooltip_background"
+ android:orientation="horizontal"
+ android:padding="@dimen/desktop_windowing_education_tooltip_padding">
+
+ <ImageView
+ android:id="@+id/tooltip_icon"
+ android:layout_width="32dp"
+ android:layout_height="32dp"
+ android:layout_gravity="center_vertical"
+ android:src="@drawable/app_handle_education_tooltip_icon" />
+
+ <TextView
+ android:id="@+id/tooltip_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:layout_marginStart="2dp"
+ android:lineHeight="20dp"
+ android:maxWidth="150dp"
+ android:textColor="@android:color/system_on_tertiary_fixed"
+ android:textFontWeight="500"
+ android:textSize="14sp" />
+</LinearLayout>
\ No newline at end of file
diff --git a/libs/WindowManager/Shell/res/layout/desktop_windowing_education_top_arrow_tooltip.xml b/libs/WindowManager/Shell/res/layout/desktop_windowing_education_top_arrow_tooltip.xml
new file mode 100644
index 0000000..c73c1da
--- /dev/null
+++ b/libs/WindowManager/Shell/res/layout/desktop_windowing_education_top_arrow_tooltip.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ Copyright (C) 2024 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:elevation="1dp"
+ android:orientation="vertical">
+
+ <!-- ImageView for the arrow icon, positioned vertically above the tooltip container. -->
+ <ImageView
+ android:id="@+id/arrow_icon"
+ android:layout_width="12dp"
+ android:layout_height="9dp"
+ android:layout_gravity="center_horizontal"
+ android:src="@drawable/desktop_windowing_education_tooltip_top_arrow" />
+
+ <!-- Layout for the tooltip, excluding the arrow. Separating the tooltip content from the arrow
+ allows scaling of only the tooltip container when the content changes, without affecting the
+ arrow. -->
+ <include layout="@layout/desktop_windowing_education_tooltip_container" />
+</LinearLayout>
diff --git a/libs/WindowManager/Shell/res/values/dimen.xml b/libs/WindowManager/Shell/res/values/dimen.xml
index 3d87183..c7109f5 100644
--- a/libs/WindowManager/Shell/res/values/dimen.xml
+++ b/libs/WindowManager/Shell/res/values/dimen.xml
@@ -608,6 +608,9 @@
<!-- The horizontal inset to apply to the close button's ripple drawable -->
<dimen name="desktop_mode_header_close_ripple_inset_horizontal">6dp</dimen>
+ <!-- The padding added to all sides of windowing education tooltip -->
+ <dimen name="desktop_windowing_education_tooltip_padding">8dp</dimen>
+
<!-- The acceptable area ratio of fg icon area/bg icon area, i.e. (72 x 72) / (108 x 108) -->
<item type="dimen" format="float" name="splash_icon_enlarge_foreground_threshold">0.44</item>
<!-- Scaling factor applied to splash icons without provided background i.e. (192 / 160) -->
diff --git a/libs/WindowManager/Shell/res/values/strings.xml b/libs/WindowManager/Shell/res/values/strings.xml
index 266eca8..56f25da 100644
--- a/libs/WindowManager/Shell/res/values/strings.xml
+++ b/libs/WindowManager/Shell/res/values/strings.xml
@@ -219,6 +219,15 @@
compatibility control. [CHAR LIMIT=NONE] -->
<string name="camera_compat_dismiss_button_description">No camera issues? Tap to dismiss.</string>
+ <!-- App handle education tooltip text for tooltip pointing to app handle -->
+ <string name="windowing_app_handle_education_tooltip">Tap to open the app menu</string>
+
+ <!-- App handle education tooltip text for tooltip pointing to windowing image button -->
+ <string name="windowing_desktop_mode_image_button_education_tooltip">Tap to show multiple apps together</string>
+
+ <!-- App handle education tooltip text for tooltip pointing to app chip -->
+ <string name="windowing_desktop_mode_exit_education_tooltip">Return to fullscreen from the app menu</string>
+
<!-- The title of the letterbox education dialog. [CHAR LIMIT=NONE] -->
<string name="letterbox_education_dialog_title">See and do more</string>
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java
index 2138acc..cbb08b8 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java
@@ -1344,6 +1344,9 @@
final SurfaceControl leash = pipChange.getLeash();
final Rect destBounds = mPipOrganizer.getCurrentOrAnimatingBounds();
final boolean isInPip = mPipTransitionState.isInPip();
+ ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
+ "%s: Update pip for unhandled transition, change=%s, destBounds=%s, isInPip=%b",
+ TAG, pipChange, destBounds, isInPip);
mSurfaceTransactionHelper
.crop(startTransaction, leash, destBounds)
.round(startTransaction, leash, isInPip)
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/additionalviewcontainer/AdditionalSystemViewContainer.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/additionalviewcontainer/AdditionalSystemViewContainer.kt
index 226b0fb..1be26f0 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/additionalviewcontainer/AdditionalSystemViewContainer.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/additionalviewcontainer/AdditionalSystemViewContainer.kt
@@ -107,4 +107,27 @@
}
windowManagerWrapper.updateViewLayout(view, lp)
}
+
+ class Factory {
+ fun create(
+ windowManagerWrapper: WindowManagerWrapper,
+ taskId: Int,
+ x: Int,
+ y: Int,
+ width: Int,
+ height: Int,
+ flags: Int,
+ view: View,
+ ): AdditionalSystemViewContainer =
+ AdditionalSystemViewContainer(
+ windowManagerWrapper = windowManagerWrapper,
+ taskId = taskId,
+ x = x,
+ y = y,
+ width = width,
+ height = height,
+ flags = flags,
+ view = view
+ )
+ }
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/education/DesktopWindowingEducationTooltipController.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/education/DesktopWindowingEducationTooltipController.kt
new file mode 100644
index 0000000..98413ee
--- /dev/null
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/education/DesktopWindowingEducationTooltipController.kt
@@ -0,0 +1,249 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.wm.shell.windowdecor.education
+
+import android.annotation.DimenRes
+import android.annotation.LayoutRes
+import android.content.Context
+import android.content.res.Resources
+import android.graphics.Point
+import android.util.Size
+import android.view.LayoutInflater
+import android.view.MotionEvent
+import android.view.View
+import android.view.View.MeasureSpec.UNSPECIFIED
+import android.view.WindowManager
+import android.widget.ImageView
+import android.widget.LinearLayout
+import android.widget.TextView
+import androidx.dynamicanimation.animation.DynamicAnimation
+import androidx.dynamicanimation.animation.SpringForce
+import com.android.wm.shell.R
+import com.android.wm.shell.shared.animation.PhysicsAnimator
+import com.android.wm.shell.windowdecor.WindowManagerWrapper
+import com.android.wm.shell.windowdecor.additionalviewcontainer.AdditionalSystemViewContainer
+
+/**
+ * Controls the lifecycle of an education tooltip, including showing and hiding it. Ensures that
+ * only one tooltip is displayed at a time.
+ */
+class DesktopWindowingEducationTooltipController(
+ private val context: Context,
+ private val additionalSystemViewContainerFactory: AdditionalSystemViewContainer.Factory,
+) {
+ // TODO: b/369384567 - Set tooltip color scheme to match LT/DT of app theme
+ private var tooltipView: View? = null
+ private var animator: PhysicsAnimator<View>? = null
+ private val springConfig by lazy {
+ PhysicsAnimator.SpringConfig(SpringForce.STIFFNESS_MEDIUM, SpringForce.DAMPING_RATIO_LOW_BOUNCY)
+ }
+ private var popupWindow: AdditionalSystemViewContainer? = null
+
+ /**
+ * Shows education tooltip.
+ *
+ * @param tooltipViewConfig features of tooltip.
+ * @param taskId is used in the title of popup window created for the tooltip view.
+ */
+ fun showEducationTooltip(tooltipViewConfig: EducationViewConfig, taskId: Int) {
+ hideEducationTooltip()
+ tooltipView = createEducationTooltipView(tooltipViewConfig, taskId)
+ animator = createAnimator()
+ animateShowTooltipTransition()
+ }
+
+ /** Hide the current education view if visible */
+ private fun hideEducationTooltip() = animateHideTooltipTransition { cleanUp() }
+
+ /** Create education view by inflating layout provided. */
+ private fun createEducationTooltipView(
+ tooltipViewConfig: EducationViewConfig,
+ taskId: Int,
+ ): View {
+ val tooltipView =
+ LayoutInflater.from(context)
+ .inflate(
+ tooltipViewConfig.tooltipViewLayout, /* root= */ null, /* attachToRoot= */ false)
+ .apply {
+ alpha = 0f
+ scaleX = 0f
+ scaleY = 0f
+
+ requireViewById<TextView>(R.id.tooltip_text).apply {
+ text = tooltipViewConfig.tooltipText
+ }
+
+ setOnTouchListener { _, motionEvent ->
+ if (motionEvent.action == MotionEvent.ACTION_OUTSIDE) {
+ hideEducationTooltip()
+ tooltipViewConfig.onDismissAction()
+ true
+ } else {
+ false
+ }
+ }
+ setOnClickListener {
+ hideEducationTooltip()
+ tooltipViewConfig.onEducationClickAction()
+ }
+ }
+
+ val tooltipDimens = tooltipDimens(tooltipView = tooltipView, tooltipViewConfig.arrowDirection)
+ val tooltipViewGlobalCoordinates =
+ tooltipViewGlobalCoordinates(
+ tooltipViewGlobalCoordinates = tooltipViewConfig.tooltipViewGlobalCoordinates,
+ arrowDirection = tooltipViewConfig.arrowDirection,
+ tooltipDimen = tooltipDimens)
+ createTooltipPopupWindow(
+ taskId, tooltipViewGlobalCoordinates, tooltipDimens, tooltipView = tooltipView)
+
+ return tooltipView
+ }
+
+ /** Create animator for education transitions */
+ private fun createAnimator(): PhysicsAnimator<View>? =
+ tooltipView?.let {
+ PhysicsAnimator.getInstance(it).apply { setDefaultSpringConfig(springConfig) }
+ }
+
+ /** Animate show transition for the education view */
+ private fun animateShowTooltipTransition() {
+ animator
+ ?.spring(DynamicAnimation.ALPHA, 1f)
+ ?.spring(DynamicAnimation.SCALE_X, 1f)
+ ?.spring(DynamicAnimation.SCALE_Y, 1f)
+ ?.start()
+ }
+
+ /** Animate hide transition for the education view */
+ private fun animateHideTooltipTransition(endActions: () -> Unit) {
+ animator
+ ?.spring(DynamicAnimation.ALPHA, 0f)
+ ?.spring(DynamicAnimation.SCALE_X, 0f)
+ ?.spring(DynamicAnimation.SCALE_Y, 0f)
+ ?.start()
+ endActions()
+ }
+
+ /** Remove education tooltip and clean up all relative properties */
+ private fun cleanUp() {
+ tooltipView = null
+ animator = null
+ popupWindow?.releaseView()
+ popupWindow = null
+ }
+
+ private fun createTooltipPopupWindow(
+ taskId: Int,
+ tooltipViewGlobalCoordinates: Point,
+ tooltipDimen: Size,
+ tooltipView: View,
+ ) {
+ popupWindow =
+ additionalSystemViewContainerFactory.create(
+ windowManagerWrapper =
+ WindowManagerWrapper(context.getSystemService(WindowManager::class.java)),
+ taskId = taskId,
+ x = tooltipViewGlobalCoordinates.x,
+ y = tooltipViewGlobalCoordinates.y,
+ width = tooltipDimen.width,
+ height = tooltipDimen.height,
+ flags =
+ WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or
+ WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
+ view = tooltipView)
+ }
+
+ private fun tooltipViewGlobalCoordinates(
+ tooltipViewGlobalCoordinates: Point,
+ arrowDirection: TooltipArrowDirection,
+ tooltipDimen: Size,
+ ): Point {
+ var tooltipX = tooltipViewGlobalCoordinates.x
+ var tooltipY = tooltipViewGlobalCoordinates.y
+
+ // Current values of [tooltipX]/[tooltipY] are the coordinates of tip of the arrow.
+ // Parameter x and y passed to [AdditionalSystemViewContainer] is the top left position of
+ // the window to be created. Hence we will need to move the coordinates left/up in order
+ // to position the tooltip correctly.
+ if (arrowDirection == TooltipArrowDirection.UP) {
+ // Arrow is placed at horizontal center on top edge of the tooltip. Hence decrement
+ // half of tooltip width from [tooltipX] to horizontally position the tooltip.
+ tooltipX -= tooltipDimen.width / 2
+ } else {
+ // Arrow is placed at vertical center on the left edge of the tooltip. Hence decrement
+ // half of tooltip height from [tooltipY] to vertically position the tooltip.
+ tooltipY -= tooltipDimen.height / 2
+ }
+ return Point(tooltipX, tooltipY)
+ }
+
+ private fun tooltipDimens(tooltipView: View, arrowDirection: TooltipArrowDirection): Size {
+ val tooltipBackground = tooltipView.requireViewById<LinearLayout>(R.id.tooltip_container)
+ val arrowView = tooltipView.requireViewById<ImageView>(R.id.arrow_icon)
+ tooltipBackground.measure(
+ /* widthMeasureSpec= */ UNSPECIFIED, /* heightMeasureSpec= */ UNSPECIFIED)
+ arrowView.measure(/* widthMeasureSpec= */ UNSPECIFIED, /* heightMeasureSpec= */ UNSPECIFIED)
+
+ var desiredWidth =
+ tooltipBackground.measuredWidth +
+ 2 * loadDimensionPixelSize(R.dimen.desktop_windowing_education_tooltip_padding)
+ var desiredHeight =
+ tooltipBackground.measuredHeight +
+ 2 * loadDimensionPixelSize(R.dimen.desktop_windowing_education_tooltip_padding)
+ if (arrowDirection == TooltipArrowDirection.UP) {
+ // desiredHeight currently does not account for the height of arrow, hence adding it.
+ desiredHeight += arrowView.height
+ } else {
+ // desiredWidth currently does not account for the width of arrow, hence adding it.
+ desiredWidth += arrowView.width
+ }
+
+ return Size(desiredWidth, desiredHeight)
+ }
+
+ private fun loadDimensionPixelSize(@DimenRes resourceId: Int): Int {
+ if (resourceId == Resources.ID_NULL) return 0
+ return context.resources.getDimensionPixelSize(resourceId)
+ }
+
+ /**
+ * The configuration for education view features:
+ *
+ * @property tooltipViewLayout Layout resource ID of the view to be used for education tooltip.
+ * @property tooltipViewGlobalCoordinates Global (screen) coordinates of the tip of the tooltip
+ * arrow.
+ * @property tooltipText Text to be added to the TextView of tooltip.
+ * @property arrowDirection Direction of arrow of the tooltip.
+ * @property onEducationClickAction Lambda to be executed when the tooltip is clicked.
+ * @property onDismissAction Lambda to be executed when the tooltip is dismissed.
+ */
+ data class EducationViewConfig(
+ @LayoutRes val tooltipViewLayout: Int,
+ val tooltipViewGlobalCoordinates: Point,
+ val tooltipText: String,
+ val arrowDirection: TooltipArrowDirection,
+ val onEducationClickAction: () -> Unit,
+ val onDismissAction: () -> Unit,
+ )
+
+ /** Direction of arrow of the tooltip */
+ enum class TooltipArrowDirection {
+ UP,
+ LEFT,
+ }
+}
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt
index 29aea00..94e3616 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt
@@ -40,6 +40,7 @@
import android.graphics.PointF
import android.graphics.Rect
import android.os.Binder
+import android.os.Bundle
import android.os.Handler
import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
@@ -2865,6 +2866,108 @@
}
@Test
+ @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MULTI_INSTANCE_FEATURES)
+ fun newWindow_fromFullscreenOpensInSplit() {
+ setUpLandscapeDisplay()
+ val task = setUpFullscreenTask()
+ val optionsCaptor = ArgumentCaptor.forClass(Bundle::class.java)
+ runOpenNewWindow(task)
+ verify(splitScreenController)
+ .startIntent(any(), anyInt(), any(), any(),
+ optionsCaptor.capture(), anyOrNull())
+ assertThat(ActivityOptions.fromBundle(optionsCaptor.value).launchWindowingMode)
+ .isEqualTo(WINDOWING_MODE_MULTI_WINDOW)
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MULTI_INSTANCE_FEATURES)
+ fun newWindow_fromSplitOpensInSplit() {
+ setUpLandscapeDisplay()
+ val task = setUpSplitScreenTask()
+ val optionsCaptor = ArgumentCaptor.forClass(Bundle::class.java)
+ runOpenNewWindow(task)
+ verify(splitScreenController)
+ .startIntent(
+ any(), anyInt(), any(), any(),
+ optionsCaptor.capture(), anyOrNull()
+ )
+ assertThat(ActivityOptions.fromBundle(optionsCaptor.value).launchWindowingMode)
+ .isEqualTo(WINDOWING_MODE_MULTI_WINDOW)
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MULTI_INSTANCE_FEATURES)
+ fun newWindow_fromFreeformAddsNewWindow() {
+ setUpLandscapeDisplay()
+ val task = setUpFreeformTask()
+ val wctCaptor = ArgumentCaptor.forClass(WindowContainerTransaction::class.java)
+ runOpenNewWindow(task)
+ verify(transitions).startTransition(anyInt(), wctCaptor.capture(), anyOrNull())
+ assertThat(ActivityOptions.fromBundle(wctCaptor.value.hierarchyOps[0].launchOptions)
+ .launchWindowingMode).isEqualTo(WINDOWING_MODE_FREEFORM)
+ }
+
+ private fun runOpenNewWindow(task: RunningTaskInfo) {
+ markTaskVisible(task)
+ task.baseActivity = mock(ComponentName::class.java)
+ task.isFocused = true
+ runningTasks.add(task)
+ controller.openNewWindow(task)
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MULTI_INSTANCE_FEATURES)
+ fun openInstance_fromFullscreenOpensInSplit() {
+ setUpLandscapeDisplay()
+ val task = setUpFullscreenTask()
+ val taskToRequest = setUpFreeformTask()
+ val optionsCaptor = ArgumentCaptor.forClass(Bundle::class.java)
+ runOpenInstance(task, taskToRequest.taskId)
+ verify(splitScreenController)
+ .startTask(anyInt(), anyInt(), optionsCaptor.capture(), anyOrNull())
+ assertThat(ActivityOptions.fromBundle(optionsCaptor.value).launchWindowingMode)
+ .isEqualTo(WINDOWING_MODE_MULTI_WINDOW)
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MULTI_INSTANCE_FEATURES)
+ fun openInstance_fromSplitOpensInSplit() {
+ setUpLandscapeDisplay()
+ val task = setUpSplitScreenTask()
+ val taskToRequest = setUpFreeformTask()
+ val optionsCaptor = ArgumentCaptor.forClass(Bundle::class.java)
+ runOpenInstance(task, taskToRequest.taskId)
+ verify(splitScreenController)
+ .startTask(anyInt(), anyInt(), optionsCaptor.capture(), anyOrNull())
+ assertThat(ActivityOptions.fromBundle(optionsCaptor.value).launchWindowingMode)
+ .isEqualTo(WINDOWING_MODE_MULTI_WINDOW)
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MULTI_INSTANCE_FEATURES)
+ fun openInstance_fromFreeformAddsNewWindow() {
+ setUpLandscapeDisplay()
+ val task = setUpFreeformTask()
+ val taskToRequest = setUpFreeformTask()
+ val wctCaptor = ArgumentCaptor.forClass(WindowContainerTransaction::class.java)
+ runOpenInstance(task, taskToRequest.taskId)
+ verify(transitions).startTransition(anyInt(), wctCaptor.capture(), anyOrNull())
+ assertThat(ActivityOptions.fromBundle(wctCaptor.value.hierarchyOps[0].launchOptions)
+ .launchWindowingMode).isEqualTo(WINDOWING_MODE_FREEFORM)
+ }
+
+ private fun runOpenInstance(
+ callingTask: RunningTaskInfo,
+ requestedTaskId: Int
+ ) {
+ markTaskVisible(callingTask)
+ callingTask.baseActivity = mock(ComponentName::class.java)
+ callingTask.isFocused = true
+ runningTasks.add(callingTask)
+ controller.openInstance(callingTask, requestedTaskId)
+ }
+
+ @Test
fun toggleBounds_togglesToStableBounds() {
val bounds = Rect(0, 0, 100, 100)
val task = setUpFreeformTask(DEFAULT_DISPLAY, bounds)
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/education/DesktopWindowingEducationTooltipControllerTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/education/DesktopWindowingEducationTooltipControllerTest.kt
new file mode 100644
index 0000000..5594981
--- /dev/null
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/education/DesktopWindowingEducationTooltipControllerTest.kt
@@ -0,0 +1,237 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.wm.shell.windowdecor.education
+
+import android.annotation.LayoutRes
+import android.content.Context
+import android.graphics.Point
+import android.testing.AndroidTestingRunner
+import android.testing.TestableContext
+import android.testing.TestableLooper
+import android.testing.TestableResources
+import android.view.MotionEvent
+import android.view.View
+import android.view.WindowManager
+import android.widget.TextView
+import androidx.test.filters.SmallTest
+import com.android.wm.shell.R
+import com.android.wm.shell.ShellTestCase
+import com.android.wm.shell.windowdecor.additionalviewcontainer.AdditionalSystemViewContainer
+import com.android.wm.shell.windowdecor.education.DesktopWindowingEducationTooltipController.TooltipArrowDirection
+import com.google.common.truth.Truth.assertThat
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.ArgumentMatchers.anyInt
+import org.mockito.Mock
+import org.mockito.MockitoAnnotations
+import org.mockito.kotlin.any
+import org.mockito.kotlin.anyOrNull
+import org.mockito.kotlin.argumentCaptor
+import org.mockito.kotlin.mock
+import org.mockito.kotlin.times
+import org.mockito.kotlin.verify
+
+@SmallTest
+@TestableLooper.RunWithLooper(setAsMainLooper = true)
+@RunWith(AndroidTestingRunner::class)
+class DesktopWindowingEducationTooltipControllerTest : ShellTestCase() {
+ @Mock private lateinit var mockWindowManager: WindowManager
+ @Mock private lateinit var mockViewContainerFactory: AdditionalSystemViewContainer.Factory
+ private lateinit var testableResources: TestableResources
+ private lateinit var testableContext: TestableContext
+ private lateinit var tooltipController: DesktopWindowingEducationTooltipController
+ private val tooltipViewArgumentCaptor = argumentCaptor<View>()
+
+ @Before
+ fun setUp() {
+ MockitoAnnotations.initMocks(this)
+ testableContext = TestableContext(mContext)
+ testableResources =
+ testableContext.orCreateTestableResources.apply {
+ addOverride(R.dimen.desktop_windowing_education_tooltip_padding, 10)
+ }
+ testableContext.addMockSystemService(
+ Context.LAYOUT_INFLATER_SERVICE, context.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
+ testableContext.addMockSystemService(WindowManager::class.java, mockWindowManager)
+ tooltipController =
+ DesktopWindowingEducationTooltipController(testableContext, mockViewContainerFactory)
+ }
+
+ @Test
+ fun showEducationTooltip_createsTooltipWithCorrectText() {
+ val tooltipText = "This is a tooltip"
+ val tooltipViewConfig = createTooltipConfig(tooltipText = tooltipText)
+
+ tooltipController.showEducationTooltip(tooltipViewConfig = tooltipViewConfig, taskId = 123)
+
+ verify(mockViewContainerFactory, times(1))
+ .create(
+ windowManagerWrapper = any(),
+ taskId = anyInt(),
+ x = anyInt(),
+ y = anyInt(),
+ width = anyInt(),
+ height = anyInt(),
+ flags = anyInt(),
+ view = tooltipViewArgumentCaptor.capture())
+ val tooltipTextView =
+ tooltipViewArgumentCaptor.lastValue.findViewById<TextView>(R.id.tooltip_text)
+ assertThat(tooltipTextView.text).isEqualTo(tooltipText)
+ }
+
+ @Test
+ fun showEducationTooltip_usesCorrectTaskIdForWindow() {
+ val tooltipViewConfig = createTooltipConfig()
+ val taskIdArgumentCaptor = argumentCaptor<Int>()
+
+ tooltipController.showEducationTooltip(tooltipViewConfig = tooltipViewConfig, taskId = 123)
+
+ verify(mockViewContainerFactory, times(1))
+ .create(
+ windowManagerWrapper = any(),
+ taskId = taskIdArgumentCaptor.capture(),
+ x = anyInt(),
+ y = anyInt(),
+ width = anyInt(),
+ height = anyInt(),
+ flags = anyInt(),
+ view = anyOrNull())
+ assertThat(taskIdArgumentCaptor.lastValue).isEqualTo(123)
+ }
+
+ @Test
+ fun showEducationTooltip_tooltipPointsUpwards_horizontallyPositionTooltip() {
+ val initialTooltipX = 0
+ val initialTooltipY = 0
+ val tooltipViewConfig =
+ createTooltipConfig(
+ arrowDirection = TooltipArrowDirection.UP,
+ tooltipViewGlobalCoordinates = Point(initialTooltipX, initialTooltipY))
+ val tooltipXArgumentCaptor = argumentCaptor<Int>()
+ val tooltipWidthArgumentCaptor = argumentCaptor<Int>()
+
+ tooltipController.showEducationTooltip(tooltipViewConfig = tooltipViewConfig, taskId = 123)
+
+ verify(mockViewContainerFactory, times(1))
+ .create(
+ windowManagerWrapper = any(),
+ taskId = anyInt(),
+ x = tooltipXArgumentCaptor.capture(),
+ y = anyInt(),
+ width = tooltipWidthArgumentCaptor.capture(),
+ height = anyInt(),
+ flags = anyInt(),
+ view = tooltipViewArgumentCaptor.capture())
+ val expectedTooltipX = initialTooltipX - tooltipWidthArgumentCaptor.lastValue / 2
+ assertThat(tooltipXArgumentCaptor.lastValue).isEqualTo(expectedTooltipX)
+ }
+
+ @Test
+ fun showEducationTooltip_tooltipPointsLeft_verticallyPositionTooltip() {
+ val initialTooltipX = 0
+ val initialTooltipY = 0
+ val tooltipViewConfig =
+ createTooltipConfig(
+ arrowDirection = TooltipArrowDirection.LEFT,
+ tooltipViewGlobalCoordinates = Point(initialTooltipX, initialTooltipY))
+ val tooltipYArgumentCaptor = argumentCaptor<Int>()
+ val tooltipHeightArgumentCaptor = argumentCaptor<Int>()
+
+ tooltipController.showEducationTooltip(tooltipViewConfig = tooltipViewConfig, taskId = 123)
+
+ verify(mockViewContainerFactory, times(1))
+ .create(
+ windowManagerWrapper = any(),
+ taskId = anyInt(),
+ x = anyInt(),
+ y = tooltipYArgumentCaptor.capture(),
+ width = anyInt(),
+ height = tooltipHeightArgumentCaptor.capture(),
+ flags = anyInt(),
+ view = tooltipViewArgumentCaptor.capture())
+ val expectedTooltipY = initialTooltipY - tooltipHeightArgumentCaptor.lastValue / 2
+ assertThat(tooltipYArgumentCaptor.lastValue).isEqualTo(expectedTooltipY)
+ }
+
+ @Test
+ fun showEducationTooltip_touchEventActionOutside_dismissActionPerformed() {
+ val mockLambda: () -> Unit = mock()
+ val tooltipViewConfig = createTooltipConfig(onDismissAction = mockLambda)
+
+ tooltipController.showEducationTooltip(tooltipViewConfig = tooltipViewConfig, taskId = 123)
+ verify(mockViewContainerFactory, times(1))
+ .create(
+ windowManagerWrapper = any(),
+ taskId = anyInt(),
+ x = anyInt(),
+ y = anyInt(),
+ width = anyInt(),
+ height = anyInt(),
+ flags = anyInt(),
+ view = tooltipViewArgumentCaptor.capture())
+ val motionEvent =
+ MotionEvent.obtain(
+ /* downTime= */ 0L,
+ /* eventTime= */ 0L,
+ MotionEvent.ACTION_OUTSIDE,
+ /* x= */ 0f,
+ /* y= */ 0f,
+ /* metaState= */ 0)
+ tooltipViewArgumentCaptor.lastValue.dispatchTouchEvent(motionEvent)
+
+ verify(mockLambda).invoke()
+ }
+
+ @Test
+ fun showEducationTooltip_tooltipClicked_onClickActionPerformed() {
+ val mockLambda: () -> Unit = mock()
+ val tooltipViewConfig = createTooltipConfig(onEducationClickAction = mockLambda)
+
+ tooltipController.showEducationTooltip(tooltipViewConfig = tooltipViewConfig, taskId = 123)
+ verify(mockViewContainerFactory, times(1))
+ .create(
+ windowManagerWrapper = any(),
+ taskId = anyInt(),
+ x = anyInt(),
+ y = anyInt(),
+ width = anyInt(),
+ height = anyInt(),
+ flags = anyInt(),
+ view = tooltipViewArgumentCaptor.capture())
+ tooltipViewArgumentCaptor.lastValue.performClick()
+
+ verify(mockLambda).invoke()
+ }
+
+ private fun createTooltipConfig(
+ @LayoutRes tooltipViewLayout: Int = R.layout.desktop_windowing_education_top_arrow_tooltip,
+ tooltipViewGlobalCoordinates: Point = Point(0, 0),
+ tooltipText: String = "This is a tooltip",
+ arrowDirection: TooltipArrowDirection = TooltipArrowDirection.UP,
+ onEducationClickAction: () -> Unit = {},
+ onDismissAction: () -> Unit = {}
+ ) =
+ DesktopWindowingEducationTooltipController.EducationViewConfig(
+ tooltipViewLayout = tooltipViewLayout,
+ tooltipViewGlobalCoordinates = tooltipViewGlobalCoordinates,
+ tooltipText = tooltipText,
+ arrowDirection = arrowDirection,
+ onEducationClickAction = onEducationClickAction,
+ onDismissAction = onDismissAction,
+ )
+}
diff --git a/media/java/android/media/tv/flags/media_tv.aconfig b/media/java/android/media/tv/flags/media_tv.aconfig
index c814c95..10423b9 100644
--- a/media/java/android/media/tv/flags/media_tv.aconfig
+++ b/media/java/android/media/tv/flags/media_tv.aconfig
@@ -56,3 +56,11 @@
description: "Enhance HDMI-CEC power state and activeness transitions"
bug: "332780751"
}
+
+flag {
+ name: "media_quality_fw"
+ is_exported: true
+ namespace: "media_tv"
+ description: "Media Quality V1.0 APIs for Android W"
+ bug: "348412562"
+}
diff --git a/media/jni/android_media_ImageWriter.cpp b/media/jni/android_media_ImageWriter.cpp
index 6776f61..33650d9 100644
--- a/media/jni/android_media_ImageWriter.cpp
+++ b/media/jni/android_media_ImageWriter.cpp
@@ -735,10 +735,15 @@
}
static status_t attachAndQeueuGraphicBuffer(JNIEnv* env, JNIImageWriterContext *ctx,
- sp<Surface> surface, sp<GraphicBuffer> gb, jlong timestampNs, jint dataSpace,
+ sp<GraphicBuffer> gb, jlong timestampNs, jint dataSpace,
jint left, jint top, jint right, jint bottom, jint transform, jint scalingMode) {
status_t res = OK;
// Step 1. Attach Image
+ sp<Surface> surface = ctx->getProducer();
+ if (surface == nullptr) {
+ jniThrowException(env, "java/lang/IllegalStateException",
+ "Producer surface is null, ImageWriter seems already closed");
+ }
res = surface->attachBuffer(gb.get());
if (res != OK) {
ALOGE("Attach image failed: %s (%d)", strerror(-res), res);
@@ -835,7 +840,6 @@
return -1;
}
- sp<Surface> surface = ctx->getProducer();
if (isFormatOpaque(ctx->getBufferFormat()) != isFormatOpaque(nativeHalFormat)) {
jniThrowException(env, "java/lang/IllegalStateException",
"Trying to attach an opaque image into a non-opaque ImageWriter, or vice versa");
@@ -851,7 +855,7 @@
return -1;
}
- return attachAndQeueuGraphicBuffer(env, ctx, surface, buffer->mGraphicBuffer, timestampNs,
+ return attachAndQeueuGraphicBuffer(env, ctx, buffer->mGraphicBuffer, timestampNs,
dataSpace, left, top, right, bottom, transform, scalingMode);
}
@@ -866,7 +870,6 @@
return -1;
}
- sp<Surface> surface = ctx->getProducer();
if (isFormatOpaque(ctx->getBufferFormat()) != isFormatOpaque(nativeHalFormat)) {
jniThrowException(env, "java/lang/IllegalStateException",
"Trying to attach an opaque image into a non-opaque ImageWriter, or vice versa");
@@ -880,7 +883,8 @@
"Trying to attach an invalid graphic buffer");
return -1;
}
- return attachAndQeueuGraphicBuffer(env, ctx, surface, graphicBuffer, timestampNs,
+
+ return attachAndQeueuGraphicBuffer(env, ctx, graphicBuffer, timestampNs,
dataSpace, left, top, right, bottom, transform, scalingMode);
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/graph/SignalDrawable.java b/packages/SettingsLib/src/com/android/settingslib/graph/SignalDrawable.java
index ef0f6cb..13a0601 100644
--- a/packages/SettingsLib/src/com/android/settingslib/graph/SignalDrawable.java
+++ b/packages/SettingsLib/src/com/android/settingslib/graph/SignalDrawable.java
@@ -42,6 +42,8 @@
import com.android.settingslib.R;
import com.android.settingslib.Utils;
+import java.util.Objects;
+
/**
* Drawable displaying a mobile cell signal indicator.
*/
@@ -90,6 +92,10 @@
private int mCurrentDot;
public SignalDrawable(Context context) {
+ this(context, new Handler());
+ }
+
+ public SignalDrawable(@NonNull Context context, @NonNull Handler handler) {
super(context.getDrawable(ICON_RES));
final String attributionPathString = context.getString(
com.android.internal.R.string.config_signalAttributionPath);
@@ -106,7 +112,7 @@
mIntrinsicSize = context.getResources().getDimensionPixelSize(R.dimen.signal_icon_size);
mTransparentPaint.setColor(context.getColor(android.R.color.transparent));
mTransparentPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
- mHandler = new Handler();
+ mHandler = handler;
setDarkIntensity(0);
}
@@ -304,6 +310,17 @@
| level;
}
+ @Override
+ public boolean equals(@Nullable Object other) {
+ return other instanceof SignalDrawable
+ && ((SignalDrawable) other).getLevel() == this.getLevel();
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getLevel());
+ }
+
/** Returns the state representing empty mobile signal with the given number of levels. */
public static int getEmptyState(int numLevels) {
return getState(0, numLevels, true);
diff --git a/packages/SystemUI/animation/lib/src/com/android/systemui/animation/OriginRemoteTransition.java b/packages/SystemUI/animation/lib/src/com/android/systemui/animation/OriginRemoteTransition.java
new file mode 100644
index 0000000..08db95e
--- /dev/null
+++ b/packages/SystemUI/animation/lib/src/com/android/systemui/animation/OriginRemoteTransition.java
@@ -0,0 +1,374 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.animation;
+
+import android.animation.Animator;
+import android.animation.Animator.AnimatorListener;
+import android.animation.ValueAnimator;
+import android.annotation.Nullable;
+import android.content.Context;
+import android.graphics.Rect;
+import android.hardware.display.DisplayManager;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.util.DisplayMetrics;
+import android.util.Log;
+import android.view.SurfaceControl;
+import android.window.IRemoteTransition;
+import android.window.IRemoteTransitionFinishedCallback;
+import android.window.TransitionInfo;
+import android.window.TransitionInfo.Change;
+import android.window.WindowAnimationState;
+
+import com.android.internal.policy.ScreenDecorationsUtils;
+import com.android.wm.shell.shared.TransitionUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * An implementation of {@link IRemoteTransition} that accepts a {@link UIComponent} as the origin
+ * and automatically attaches it to the transition leash before the transition starts.
+ */
+public class OriginRemoteTransition extends IRemoteTransition.Stub {
+ private static final String TAG = "OriginRemoteTransition";
+
+ private final Context mContext;
+ private final boolean mIsEntry;
+ private final UIComponent mOrigin;
+ private final TransitionPlayer mPlayer;
+ private final long mDuration;
+ private final Handler mHandler;
+
+ @Nullable private SurfaceControl.Transaction mStartTransaction;
+ @Nullable private IRemoteTransitionFinishedCallback mFinishCallback;
+ @Nullable private UIComponent.Transaction mOriginTransaction;
+ @Nullable private ValueAnimator mAnimator;
+ @Nullable private SurfaceControl mOriginLeash;
+ private boolean mCancelled;
+
+ OriginRemoteTransition(
+ Context context,
+ boolean isEntry,
+ UIComponent origin,
+ TransitionPlayer player,
+ long duration,
+ Handler handler) {
+ mContext = context;
+ mIsEntry = isEntry;
+ mOrigin = origin;
+ mPlayer = player;
+ mDuration = duration;
+ mHandler = handler;
+ }
+
+ @Override
+ public void startAnimation(
+ IBinder token,
+ TransitionInfo info,
+ SurfaceControl.Transaction t,
+ IRemoteTransitionFinishedCallback finishCallback) {
+ logD("startAnimation - " + info);
+ mHandler.post(
+ () -> {
+ mStartTransaction = t;
+ mFinishCallback = finishCallback;
+ startAnimationInternal(info);
+ });
+ }
+
+ @Override
+ public void mergeAnimation(
+ IBinder transition,
+ TransitionInfo info,
+ SurfaceControl.Transaction t,
+ IBinder mergeTarget,
+ IRemoteTransitionFinishedCallback finishCallback) {
+ logD("mergeAnimation - " + info);
+ mHandler.post(this::cancel);
+ }
+
+ @Override
+ public void takeOverAnimation(
+ IBinder transition,
+ TransitionInfo info,
+ SurfaceControl.Transaction t,
+ IRemoteTransitionFinishedCallback finishCallback,
+ WindowAnimationState[] states) {
+ logD("takeOverAnimation - " + info);
+ }
+
+ @Override
+ public void onTransitionConsumed(IBinder transition, boolean aborted) {
+ logD("onTransitionConsumed - aborted: " + aborted);
+ mHandler.post(this::cancel);
+ }
+
+ private void startAnimationInternal(TransitionInfo info) {
+ if (!prepareUIs(info)) {
+ logE("Unable to prepare UI!");
+ finishAnimation(/* finished= */ false);
+ return;
+ }
+ // Notify player that we are starting.
+ mPlayer.onStart(info, mStartTransaction, mOrigin, mOriginTransaction);
+
+ // Start the animator.
+ mAnimator = ValueAnimator.ofFloat(0.0f, 1.0f);
+ mAnimator.setDuration(mDuration);
+ mAnimator.addListener(
+ new AnimatorListener() {
+ @Override
+ public void onAnimationStart(Animator a) {}
+
+ @Override
+ public void onAnimationEnd(Animator a) {
+ finishAnimation(/* finished= */ !mCancelled);
+ }
+
+ @Override
+ public void onAnimationCancel(Animator a) {
+ mCancelled = true;
+ }
+
+ @Override
+ public void onAnimationRepeat(Animator a) {}
+ });
+ mAnimator.addUpdateListener(
+ a -> {
+ mPlayer.onProgress((float) a.getAnimatedValue());
+ });
+ mAnimator.start();
+ }
+
+ private boolean prepareUIs(TransitionInfo info) {
+ if (info.getRootCount() == 0) {
+ logE("prepareUIs: no root leash!");
+ return false;
+ }
+ if (info.getRootCount() > 1) {
+ logE("prepareUIs: multi-display transition is not supported yet!");
+ return false;
+ }
+ if (info.getChanges().isEmpty()) {
+ logE("prepareUIs: no changes!");
+ return false;
+ }
+
+ SurfaceControl rootLeash = info.getRoot(0).getLeash();
+ int displayId = info.getChanges().get(0).getEndDisplayId();
+ Rect displayBounds = getDisplayBounds(displayId);
+ float windowRadius = ScreenDecorationsUtils.getWindowCornerRadius(mContext);
+ logD("prepareUIs: windowRadius=" + windowRadius + ", displayBounds=" + displayBounds);
+
+ // Create the origin leash and add to the transition root leash.
+ mOriginLeash =
+ new SurfaceControl.Builder().setName("OriginTransition-origin-leash").build();
+ mStartTransaction
+ .reparent(mOriginLeash, rootLeash)
+ .show(mOriginLeash)
+ .setCornerRadius(mOriginLeash, windowRadius)
+ .setWindowCrop(mOriginLeash, displayBounds.width(), displayBounds.height());
+
+ // Process surfaces
+ List<SurfaceControl> openingSurfaces = new ArrayList<>();
+ List<SurfaceControl> closingSurfaces = new ArrayList<>();
+ for (Change change : info.getChanges()) {
+ int mode = change.getMode();
+ SurfaceControl leash = change.getLeash();
+ // Reparent leash to the transition root.
+ mStartTransaction.reparent(leash, rootLeash);
+ if (TransitionUtil.isOpeningMode(mode)) {
+ openingSurfaces.add(change.getLeash());
+ // For opening surfaces, ending bounds are base bound. Apply corner radius if
+ // it's full screen.
+ Rect bounds = change.getEndAbsBounds();
+ if (displayBounds.equals(bounds)) {
+ mStartTransaction
+ .setCornerRadius(leash, windowRadius)
+ .setWindowCrop(leash, bounds.width(), bounds.height());
+ }
+ } else if (TransitionUtil.isClosingMode(mode)) {
+ closingSurfaces.add(change.getLeash());
+ // For closing surfaces, starting bounds are base bounds. Apply corner radius if
+ // it's full screen.
+ Rect bounds = change.getStartAbsBounds();
+ if (displayBounds.equals(bounds)) {
+ mStartTransaction
+ .setCornerRadius(leash, windowRadius)
+ .setWindowCrop(leash, bounds.width(), bounds.height());
+ }
+ }
+ }
+
+ // Set relative order:
+ // ---- App1 ----
+ // ---- origin ----
+ // ---- App2 ----
+ if (mIsEntry) {
+ mStartTransaction
+ .setRelativeLayer(mOriginLeash, closingSurfaces.get(0), 1)
+ .setRelativeLayer(
+ openingSurfaces.get(openingSurfaces.size() - 1), mOriginLeash, 1);
+ } else {
+ mStartTransaction
+ .setRelativeLayer(mOriginLeash, openingSurfaces.get(0), 1)
+ .setRelativeLayer(
+ closingSurfaces.get(closingSurfaces.size() - 1), mOriginLeash, 1);
+ }
+
+ // Attach origin UIComponent to origin leash.
+ mOriginTransaction = mOrigin.newTransaction();
+ mOriginTransaction
+ .attachToTransitionLeash(
+ mOrigin, mOriginLeash, displayBounds.width(), displayBounds.height())
+ .commit();
+
+ // Apply all surface changes.
+ mStartTransaction.apply();
+ return true;
+ }
+
+ private Rect getDisplayBounds(int displayId) {
+ DisplayManager dm = mContext.getSystemService(DisplayManager.class);
+ DisplayMetrics metrics = new DisplayMetrics();
+ dm.getDisplay(displayId).getMetrics(metrics);
+ return new Rect(0, 0, metrics.widthPixels, metrics.heightPixels);
+ }
+
+ private void finishAnimation(boolean finished) {
+ logD("finishAnimation: finished=" + finished);
+ if (mAnimator == null) {
+ // The transition didn't start. Ensure we apply the start transaction and report
+ // finish afterwards.
+ mStartTransaction
+ .addTransactionCommittedListener(
+ mContext.getMainExecutor(), this::finishInternal)
+ .apply();
+ return;
+ }
+ mAnimator = null;
+ // Notify client that we have ended.
+ mPlayer.onEnd(finished);
+ // Detach the origin from the transition leash and report finish after it's done.
+ mOriginTransaction
+ .detachFromTransitionLeash(
+ mOrigin, mContext.getMainExecutor(), this::finishInternal)
+ .commit();
+ }
+
+ private void finishInternal() {
+ logD("finishInternal");
+ if (mOriginLeash != null) {
+ // Release origin leash.
+ mOriginLeash.release();
+ mOriginLeash = null;
+ }
+ try {
+ mFinishCallback.onTransitionFinished(null, null);
+ } catch (RemoteException e) {
+ logE("Unable to report transition finish!", e);
+ }
+ mStartTransaction = null;
+ mOriginTransaction = null;
+ mFinishCallback = null;
+ }
+
+ private void cancel() {
+ if (mAnimator != null) {
+ mAnimator.cancel();
+ }
+ }
+
+ private static void logD(String msg) {
+ if (OriginTransitionSession.DEBUG) {
+ Log.d(TAG, msg);
+ }
+ }
+
+ private static void logE(String msg) {
+ Log.e(TAG, msg);
+ }
+
+ private static void logE(String msg, Throwable e) {
+ Log.e(TAG, msg, e);
+ }
+
+ private static UIComponent wrapSurfaces(TransitionInfo info, boolean isOpening) {
+ List<SurfaceControl> surfaces = new ArrayList<>();
+ Rect maxBounds = new Rect();
+ for (Change change : info.getChanges()) {
+ int mode = change.getMode();
+ if (TransitionUtil.isOpeningMode(mode) == isOpening) {
+ surfaces.add(change.getLeash());
+ Rect bounds = isOpening ? change.getEndAbsBounds() : change.getStartAbsBounds();
+ maxBounds.union(bounds);
+ }
+ }
+ return new SurfaceUIComponent(
+ surfaces,
+ /* alpha= */ 1.0f,
+ /* visible= */ true,
+ /* bounds= */ maxBounds,
+ /* baseBounds= */ maxBounds);
+ }
+
+ /** An interface that represents an origin transitions. */
+ public interface TransitionPlayer {
+
+ /**
+ * Called when an origin transition starts. This method exposes the raw {@link
+ * TransitionInfo} so that clients can extract more information from it.
+ */
+ default void onStart(
+ TransitionInfo transitionInfo,
+ SurfaceControl.Transaction sfTransaction,
+ UIComponent origin,
+ UIComponent.Transaction uiTransaction) {
+ // Wrap transactions.
+ Transactions transactions =
+ new Transactions()
+ .registerTransactionForClass(origin.getClass(), uiTransaction)
+ .registerTransactionForClass(
+ SurfaceUIComponent.class,
+ new SurfaceUIComponent.Transaction(sfTransaction));
+ // Wrap surfaces and start.
+ onStart(
+ transactions,
+ origin,
+ wrapSurfaces(transitionInfo, /* isOpening= */ false),
+ wrapSurfaces(transitionInfo, /* isOpening= */ true));
+ }
+
+ /**
+ * Called when an origin transition starts. This method exposes the opening and closing
+ * windows as wrapped {@link UIComponent} to provide simplified interface to clients.
+ */
+ void onStart(
+ UIComponent.Transaction transaction,
+ UIComponent origin,
+ UIComponent closingApp,
+ UIComponent openingApp);
+
+ /** Called to update the transition frame. */
+ void onProgress(float progress);
+
+ /** Called when the transition ended. */
+ void onEnd(boolean finished);
+ }
+}
diff --git a/packages/SystemUI/animation/lib/src/com/android/systemui/animation/OriginTransitionSession.java b/packages/SystemUI/animation/lib/src/com/android/systemui/animation/OriginTransitionSession.java
index 64bedd3..23693b6 100644
--- a/packages/SystemUI/animation/lib/src/com/android/systemui/animation/OriginTransitionSession.java
+++ b/packages/SystemUI/animation/lib/src/com/android/systemui/animation/OriginTransitionSession.java
@@ -24,11 +24,14 @@
import android.content.Context;
import android.content.Intent;
import android.os.Build;
+import android.os.Handler;
+import android.os.Looper;
import android.os.RemoteException;
import android.util.Log;
import android.window.IRemoteTransition;
import android.window.RemoteTransition;
+import com.android.systemui.animation.OriginRemoteTransition.TransitionPlayer;
import com.android.systemui.animation.shared.IOriginTransitions;
import java.lang.annotation.Retention;
@@ -182,6 +185,7 @@
@Nullable private final IOriginTransitions mOriginTransitions;
@Nullable private Supplier<IRemoteTransition> mEntryTransitionSupplier;
@Nullable private Supplier<IRemoteTransition> mExitTransitionSupplier;
+ private Handler mHandler = new Handler(Looper.getMainLooper());
private String mName;
@Nullable private Predicate<RemoteTransition> mIntentStarter;
@@ -259,12 +263,48 @@
return this;
}
+ /** Add an origin entry transition to the builder. */
+ public Builder withEntryTransition(
+ UIComponent entryOrigin, TransitionPlayer entryPlayer, long entryDuration) {
+ mEntryTransitionSupplier =
+ () ->
+ new OriginRemoteTransition(
+ mContext,
+ /* isEntry= */ true,
+ entryOrigin,
+ entryPlayer,
+ entryDuration,
+ mHandler);
+ return this;
+ }
+
/** Add an exit transition to the builder. */
public Builder withExitTransition(IRemoteTransition transition) {
mExitTransitionSupplier = () -> transition;
return this;
}
+ /** Add an origin exit transition to the builder. */
+ public Builder withExitTransition(
+ UIComponent exitTarget, TransitionPlayer exitPlayer, long exitDuration) {
+ mExitTransitionSupplier =
+ () ->
+ new OriginRemoteTransition(
+ mContext,
+ /* isEntry= */ false,
+ exitTarget,
+ exitPlayer,
+ exitDuration,
+ mHandler);
+ return this;
+ }
+
+ /** Supply a handler where transition callbacks will run. */
+ public Builder withHandler(Handler handler) {
+ mHandler = handler;
+ return this;
+ }
+
/** Build an {@link OriginTransitionSession}. */
public OriginTransitionSession build() {
if (mIntentStarter == null) {
diff --git a/packages/SystemUI/animation/lib/src/com/android/systemui/animation/SurfaceUIComponent.java b/packages/SystemUI/animation/lib/src/com/android/systemui/animation/SurfaceUIComponent.java
new file mode 100644
index 0000000..2438736
--- /dev/null
+++ b/packages/SystemUI/animation/lib/src/com/android/systemui/animation/SurfaceUIComponent.java
@@ -0,0 +1,169 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.animation;
+
+import android.graphics.Matrix;
+import android.graphics.Rect;
+import android.graphics.RectF;
+import android.view.SurfaceControl;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.concurrent.Executor;
+
+/** A {@link UIComponent} representing a {@link SurfaceControl}. */
+public class SurfaceUIComponent implements UIComponent {
+ private final Collection<SurfaceControl> mSurfaces;
+ private final Rect mBaseBounds;
+ private final float[] mFloat9 = new float[9];
+
+ private float mAlpha;
+ private boolean mVisible;
+ private Rect mBounds;
+
+ public SurfaceUIComponent(
+ SurfaceControl sc, float alpha, boolean visible, Rect bounds, Rect baseBounds) {
+ this(Arrays.asList(sc), alpha, visible, bounds, baseBounds);
+ }
+
+ public SurfaceUIComponent(
+ Collection<SurfaceControl> surfaces,
+ float alpha,
+ boolean visible,
+ Rect bounds,
+ Rect baseBounds) {
+ mSurfaces = surfaces;
+ mAlpha = alpha;
+ mVisible = visible;
+ mBounds = bounds;
+ mBaseBounds = baseBounds;
+ }
+
+ @Override
+ public float getAlpha() {
+ return mAlpha;
+ }
+
+ @Override
+ public boolean isVisible() {
+ return mVisible;
+ }
+
+ @Override
+ public Rect getBounds() {
+ return mBounds;
+ }
+
+ @Override
+ public Transaction newTransaction() {
+ return new Transaction(new SurfaceControl.Transaction());
+ }
+
+ @Override
+ public String toString() {
+ return "SurfaceUIComponent{mSurfaces="
+ + mSurfaces
+ + ", mAlpha="
+ + mAlpha
+ + ", mVisible="
+ + mVisible
+ + ", mBounds="
+ + mBounds
+ + ", mBaseBounds="
+ + mBaseBounds
+ + "}";
+ }
+
+ /** A {@link Transaction} wrapping a {@link SurfaceControl.Transaction}. */
+ public static class Transaction implements UIComponent.Transaction<SurfaceUIComponent> {
+ private final SurfaceControl.Transaction mTransaction;
+ private final ArrayList<Runnable> mChanges = new ArrayList<>();
+
+ public Transaction(SurfaceControl.Transaction transaction) {
+ mTransaction = transaction;
+ }
+
+ @Override
+ public Transaction setAlpha(SurfaceUIComponent ui, float alpha) {
+ mChanges.add(
+ () -> {
+ ui.mAlpha = alpha;
+ ui.mSurfaces.forEach(s -> mTransaction.setAlpha(s, alpha));
+ });
+ return this;
+ }
+
+ @Override
+ public Transaction setVisible(SurfaceUIComponent ui, boolean visible) {
+ mChanges.add(
+ () -> {
+ ui.mVisible = visible;
+ if (visible) {
+ ui.mSurfaces.forEach(s -> mTransaction.show(s));
+ } else {
+ ui.mSurfaces.forEach(s -> mTransaction.hide(s));
+ }
+ });
+ return this;
+ }
+
+ @Override
+ public Transaction setBounds(SurfaceUIComponent ui, Rect bounds) {
+ mChanges.add(
+ () -> {
+ if (ui.mBounds.equals(bounds)) {
+ return;
+ }
+ ui.mBounds = bounds;
+ Matrix matrix = new Matrix();
+ matrix.setRectToRect(
+ new RectF(ui.mBaseBounds),
+ new RectF(ui.mBounds),
+ Matrix.ScaleToFit.FILL);
+ ui.mSurfaces.forEach(s -> mTransaction.setMatrix(s, matrix, ui.mFloat9));
+ });
+ return this;
+ }
+
+ @Override
+ public Transaction attachToTransitionLeash(
+ SurfaceUIComponent ui, SurfaceControl transitionLeash, int w, int h) {
+ mChanges.add(
+ () -> ui.mSurfaces.forEach(s -> mTransaction.reparent(s, transitionLeash)));
+ return this;
+ }
+
+ @Override
+ public Transaction detachFromTransitionLeash(
+ SurfaceUIComponent ui, Executor executor, Runnable onDone) {
+ mChanges.add(
+ () -> {
+ ui.mSurfaces.forEach(s -> mTransaction.reparent(s, null));
+ mTransaction.addTransactionCommittedListener(executor, onDone::run);
+ });
+ return this;
+ }
+
+ @Override
+ public void commit() {
+ mChanges.forEach(Runnable::run);
+ mChanges.clear();
+ mTransaction.apply();
+ }
+ }
+}
diff --git a/packages/SystemUI/animation/lib/src/com/android/systemui/animation/Transactions.java b/packages/SystemUI/animation/lib/src/com/android/systemui/animation/Transactions.java
new file mode 100644
index 0000000..5240d99
--- /dev/null
+++ b/packages/SystemUI/animation/lib/src/com/android/systemui/animation/Transactions.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.animation;
+
+import android.annotation.FloatRange;
+import android.graphics.Rect;
+import android.util.ArrayMap;
+import android.view.SurfaceControl;
+
+import java.util.Map;
+import java.util.concurrent.Executor;
+
+/**
+ * A composite {@link UIComponent.Transaction} that combines multiple other transactions for each ui
+ * type.
+ */
+public class Transactions implements UIComponent.Transaction<UIComponent> {
+ private final Map<Class, UIComponent.Transaction> mTransactions = new ArrayMap<>();
+
+ /** Register a transaction object for updating a certain {@link UIComponent} type. */
+ public <T extends UIComponent> Transactions registerTransactionForClass(
+ Class<T> clazz, UIComponent.Transaction transaction) {
+ mTransactions.put(clazz, transaction);
+ return this;
+ }
+
+ private UIComponent.Transaction getTransactionFor(UIComponent ui) {
+ UIComponent.Transaction transaction = mTransactions.get(ui.getClass());
+ if (transaction == null) {
+ transaction = ui.newTransaction();
+ mTransactions.put(ui.getClass(), transaction);
+ }
+ return transaction;
+ }
+
+ @Override
+ public Transactions setAlpha(UIComponent ui, @FloatRange(from = 0.0, to = 1.0) float alpha) {
+ getTransactionFor(ui).setAlpha(ui, alpha);
+ return this;
+ }
+
+ @Override
+ public Transactions setVisible(UIComponent ui, boolean visible) {
+ getTransactionFor(ui).setVisible(ui, visible);
+ return this;
+ }
+
+ @Override
+ public Transactions setBounds(UIComponent ui, Rect bounds) {
+ getTransactionFor(ui).setBounds(ui, bounds);
+ return this;
+ }
+
+ @Override
+ public Transactions attachToTransitionLeash(
+ UIComponent ui, SurfaceControl transitionLeash, int w, int h) {
+ getTransactionFor(ui).attachToTransitionLeash(ui, transitionLeash, w, h);
+ return this;
+ }
+
+ @Override
+ public Transactions detachFromTransitionLeash(
+ UIComponent ui, Executor executor, Runnable onDone) {
+ getTransactionFor(ui).detachFromTransitionLeash(ui, executor, onDone);
+ return this;
+ }
+
+ @Override
+ public void commit() {
+ mTransactions.values().forEach(UIComponent.Transaction::commit);
+ }
+}
diff --git a/packages/SystemUI/animation/lib/src/com/android/systemui/animation/UIComponent.java b/packages/SystemUI/animation/lib/src/com/android/systemui/animation/UIComponent.java
new file mode 100644
index 0000000..747e4d1
--- /dev/null
+++ b/packages/SystemUI/animation/lib/src/com/android/systemui/animation/UIComponent.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.animation;
+
+import android.annotation.FloatRange;
+import android.graphics.Rect;
+import android.view.SurfaceControl;
+
+import java.util.concurrent.Executor;
+
+/** An interface representing an UI component on the display. */
+public interface UIComponent {
+
+ /** Get the current alpha of this UI. */
+ float getAlpha();
+
+ /** Check if this UI is visible. */
+ boolean isVisible();
+
+ /** Get the bounds of this UI in its display. */
+ Rect getBounds();
+
+ /** Create a new {@link Transaction} that can update this UI. */
+ Transaction newTransaction();
+
+ /**
+ * A transaction class for updating {@link UIComponent}.
+ *
+ * @param <T> the subtype of {@link UIComponent} that this {@link Transaction} can handle.
+ */
+ interface Transaction<T extends UIComponent> {
+ /** Update alpha of an UI. Execution will be delayed until {@link #commit()} is called. */
+ Transaction setAlpha(T ui, @FloatRange(from = 0.0, to = 1.0) float alpha);
+
+ /**
+ * Update visibility of an UI. Execution will be delayed until {@link #commit()} is called.
+ */
+ Transaction setVisible(T ui, boolean visible);
+
+ /** Update bounds of an UI. Execution will be delayed until {@link #commit()} is called. */
+ Transaction setBounds(T ui, Rect bounds);
+
+ /**
+ * Attach a ui to the transition leash. Execution will be delayed until {@link #commit()} is
+ * called.
+ */
+ Transaction attachToTransitionLeash(T ui, SurfaceControl transitionLeash, int w, int h);
+
+ /**
+ * Detach a ui from the transition leash. Execution will be delayed until {@link #commit} is
+ * called.
+ */
+ Transaction detachFromTransitionLeash(T ui, Executor executor, Runnable onDone);
+
+ /** Commit any pending changes added to this transaction. */
+ void commit();
+ }
+}
diff --git a/packages/SystemUI/animation/lib/src/com/android/systemui/animation/ViewUIComponent.java b/packages/SystemUI/animation/lib/src/com/android/systemui/animation/ViewUIComponent.java
new file mode 100644
index 0000000..313789c
--- /dev/null
+++ b/packages/SystemUI/animation/lib/src/com/android/systemui/animation/ViewUIComponent.java
@@ -0,0 +1,278 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.animation;
+
+import android.annotation.Nullable;
+import android.graphics.Canvas;
+import android.graphics.PorterDuff;
+import android.graphics.Rect;
+import android.os.Build;
+import android.util.Log;
+import android.view.Surface;
+import android.view.SurfaceControl;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewTreeObserver.OnDrawListener;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Executor;
+
+/**
+ * A {@link UIComponent} wrapping a {@link View}. After being attached to the transition leash, this
+ * class will draw the content of the {@link View} directly into the leash, and the actual View will
+ * be changed to INVISIBLE in its view tree. This allows the {@link View} to transform in the
+ * full-screen size leash without being constrained by the view tree's boundary or inheriting its
+ * parent's alpha and transformation.
+ */
+public class ViewUIComponent implements UIComponent {
+ private static final String TAG = "ViewUIComponent";
+ private static final boolean DEBUG = Build.IS_USERDEBUG || Log.isLoggable(TAG, Log.DEBUG);
+ private final OnDrawListener mOnDrawListener = this::postDraw;
+ private final View mView;
+
+ @Nullable private SurfaceControl mSurfaceControl;
+ @Nullable private Surface mSurface;
+ @Nullable private Rect mViewBoundsOverride;
+ private boolean mVisibleOverride;
+ private boolean mDirty;
+
+ public ViewUIComponent(View view) {
+ mView = view;
+ }
+
+ @Override
+ public float getAlpha() {
+ return mView.getAlpha();
+ }
+
+ @Override
+ public boolean isVisible() {
+ return isAttachedToLeash() ? mVisibleOverride : mView.getVisibility() == View.VISIBLE;
+ }
+
+ @Override
+ public Rect getBounds() {
+ if (isAttachedToLeash() && mViewBoundsOverride != null) {
+ return mViewBoundsOverride;
+ }
+ return getRealBounds();
+ }
+
+ @Override
+ public Transaction newTransaction() {
+ return new Transaction();
+ }
+
+ private void attachToTransitionLeash(SurfaceControl transitionLeash, int w, int h) {
+ logD("attachToTransitionLeash");
+ // Remember current visibility.
+ mVisibleOverride = mView.getVisibility() == View.VISIBLE;
+
+ // Create the surface
+ mSurfaceControl =
+ new SurfaceControl.Builder().setName("ViewUIComponent").setBufferSize(w, h).build();
+ mSurface = new Surface(mSurfaceControl);
+ forceDraw();
+
+ // Attach surface to transition leash
+ SurfaceControl.Transaction t = new SurfaceControl.Transaction();
+ t.reparent(mSurfaceControl, transitionLeash).show(mSurfaceControl);
+
+ // Make sure view draw triggers surface draw.
+ mView.getViewTreeObserver().addOnDrawListener(mOnDrawListener);
+
+ // Make the view invisible AFTER the surface is shown.
+ t.addTransactionCommittedListener(
+ mView.getContext().getMainExecutor(),
+ () -> mView.setVisibility(View.INVISIBLE))
+ .apply();
+ }
+
+ private void detachFromTransitionLeash(Executor executor, Runnable onDone) {
+ logD("detachFromTransitionLeash");
+ Surface s = mSurface;
+ SurfaceControl sc = mSurfaceControl;
+ mSurface = null;
+ mSurfaceControl = null;
+ mView.getViewTreeObserver().removeOnDrawListener(mOnDrawListener);
+ // Restore view visibility
+ mView.setVisibility(mVisibleOverride ? View.VISIBLE : View.INVISIBLE);
+ mView.invalidate();
+ // Clean up surfaces.
+ SurfaceControl.Transaction t = new SurfaceControl.Transaction();
+ t.reparent(sc, null)
+ .addTransactionCommittedListener(
+ mView.getContext().getMainExecutor(),
+ () -> {
+ s.release();
+ sc.release();
+ executor.execute(onDone);
+ });
+ // Apply transaction AFTER the view is drawn.
+ mView.getRootSurfaceControl().applyTransactionOnDraw(t);
+ }
+
+ @Override
+ public String toString() {
+ return "ViewUIComponent{"
+ + "alpha="
+ + getAlpha()
+ + ", visible="
+ + isVisible()
+ + ", bounds="
+ + getBounds()
+ + ", attached="
+ + isAttachedToLeash()
+ + "}";
+ }
+
+ private void draw() {
+ if (!mDirty) {
+ // No need to draw. This is probably a duplicate call.
+ logD("draw: skipped - clean");
+ return;
+ }
+ mDirty = false;
+ if (!isAttachedToLeash()) {
+ // Not attached.
+ logD("draw: skipped - not attached");
+ return;
+ }
+ ViewGroup.LayoutParams params = mView.getLayoutParams();
+ if (params == null || params.width == 0 || params.height == 0) {
+ // layout pass didn't happen.
+ logD("draw: skipped - no layout");
+ return;
+ }
+ Canvas canvas = mSurface.lockHardwareCanvas();
+ // Clear the canvas first.
+ canvas.drawColor(0, PorterDuff.Mode.CLEAR);
+ if (mVisibleOverride) {
+ Rect realBounds = getRealBounds();
+ Rect renderBounds = getBounds();
+ canvas.translate(renderBounds.left, renderBounds.top);
+ canvas.scale(
+ (float) renderBounds.width() / realBounds.width(),
+ (float) renderBounds.height() / realBounds.height());
+ canvas.saveLayerAlpha(null, (int) (255 * mView.getAlpha()));
+ mView.draw(canvas);
+ canvas.restore();
+ }
+ mSurface.unlockCanvasAndPost(canvas);
+ logD("draw: done");
+ }
+
+ private void forceDraw() {
+ mDirty = true;
+ draw();
+ }
+
+ private Rect getRealBounds() {
+ Rect output = new Rect();
+ mView.getBoundsOnScreen(output);
+ return output;
+ }
+
+ private boolean isAttachedToLeash() {
+ return mSurfaceControl != null && mSurface != null;
+ }
+
+ private void logD(String msg) {
+ if (DEBUG) {
+ Log.d(TAG, msg);
+ }
+ }
+
+ private void setVisible(boolean visible) {
+ logD("setVisibility: " + visible);
+ if (isAttachedToLeash()) {
+ mVisibleOverride = visible;
+ postDraw();
+ } else {
+ mView.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
+ }
+ }
+
+ private void setBounds(Rect bounds) {
+ logD("setBounds: " + bounds);
+ mViewBoundsOverride = bounds;
+ if (isAttachedToLeash()) {
+ postDraw();
+ } else {
+ Log.w(TAG, "setBounds: not attached to leash!");
+ }
+ }
+
+ private void setAlpha(float alpha) {
+ logD("setAlpha: " + alpha);
+ mView.setAlpha(alpha);
+ if (isAttachedToLeash()) {
+ postDraw();
+ }
+ }
+
+ private void postDraw() {
+ if (mDirty) {
+ return;
+ }
+ mDirty = true;
+ mView.post(this::draw);
+ }
+
+ public static class Transaction implements UIComponent.Transaction<ViewUIComponent> {
+ private final List<Runnable> mChanges = new ArrayList<>();
+
+ @Override
+ public Transaction setAlpha(ViewUIComponent ui, float alpha) {
+ mChanges.add(() -> ui.setAlpha(alpha));
+ return this;
+ }
+
+ @Override
+ public Transaction setVisible(ViewUIComponent ui, boolean visible) {
+ mChanges.add(() -> ui.setVisible(visible));
+ return this;
+ }
+
+ @Override
+ public Transaction setBounds(ViewUIComponent ui, Rect bounds) {
+ mChanges.add(() -> ui.setBounds(bounds));
+ return this;
+ }
+
+ @Override
+ public Transaction attachToTransitionLeash(
+ ViewUIComponent ui, SurfaceControl transitionLeash, int w, int h) {
+ mChanges.add(() -> ui.attachToTransitionLeash(transitionLeash, w, h));
+ return this;
+ }
+
+ @Override
+ public Transaction detachFromTransitionLeash(
+ ViewUIComponent ui, Executor executor, Runnable onDone) {
+ mChanges.add(() -> ui.detachFromTransitionLeash(executor, onDone));
+ return this;
+ }
+
+ @Override
+ public void commit() {
+ mChanges.forEach(Runnable::run);
+ mChanges.clear();
+ }
+ }
+}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/notifications/ui/viewmodel/NotificationsShadeOverlayContentViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/notifications/ui/viewmodel/NotificationsShadeOverlayContentViewModelTest.kt
index 3388c75..ada2138 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/notifications/ui/viewmodel/NotificationsShadeOverlayContentViewModelTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/notifications/ui/viewmodel/NotificationsShadeOverlayContentViewModelTest.kt
@@ -21,19 +21,34 @@
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
+import com.android.systemui.authentication.data.repository.FakeAuthenticationRepository
+import com.android.systemui.authentication.domain.interactor.AuthenticationResult
+import com.android.systemui.authentication.domain.interactor.authenticationInteractor
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.flags.EnableSceneContainer
import com.android.systemui.kosmos.testScope
+import com.android.systemui.lifecycle.activateIn
+import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAsleepForTest
+import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAwakeForTest
+import com.android.systemui.power.domain.interactor.powerInteractor
import com.android.systemui.scene.domain.interactor.sceneInteractor
+import com.android.systemui.scene.domain.startable.sceneContainerStartable
import com.android.systemui.scene.shared.model.Overlays
+import com.android.systemui.scene.shared.model.Scenes
+import com.android.systemui.shade.domain.interactor.shadeInteractor
import com.android.systemui.shade.shared.flag.DualShade
import com.android.systemui.shade.ui.viewmodel.notificationsShadeOverlayContentViewModel
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.test.TestScope
+import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
+import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
+@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper
@@ -47,18 +62,84 @@
private val underTest by lazy { kosmos.notificationsShadeOverlayContentViewModel }
+ @Before
+ fun setUp() {
+ kosmos.sceneContainerStartable.start()
+ underTest.activateIn(testScope)
+ }
+
@Test
fun onScrimClicked_hidesShade() =
testScope.runTest {
val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
- sceneInteractor.showOverlay(
- overlay = Overlays.NotificationsShade,
- loggingReason = "test",
- )
+ sceneInteractor.showOverlay(Overlays.NotificationsShade, "test")
assertThat(currentOverlays).contains(Overlays.NotificationsShade)
underTest.onScrimClicked()
assertThat(currentOverlays).doesNotContain(Overlays.NotificationsShade)
}
+
+ @Test
+ fun deviceLocked_hidesShade() =
+ testScope.runTest {
+ val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
+ unlockDevice()
+ sceneInteractor.showOverlay(Overlays.NotificationsShade, "test")
+ assertThat(currentOverlays).contains(Overlays.NotificationsShade)
+
+ lockDevice()
+
+ assertThat(currentOverlays).doesNotContain(Overlays.NotificationsShade)
+ }
+
+ @Test
+ fun bouncerShown_hidesShade() =
+ testScope.runTest {
+ val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
+ lockDevice()
+ sceneInteractor.showOverlay(Overlays.NotificationsShade, "test")
+ assertThat(currentOverlays).contains(Overlays.NotificationsShade)
+
+ sceneInteractor.changeScene(Scenes.Bouncer, "test")
+ runCurrent()
+
+ assertThat(currentOverlays).doesNotContain(Overlays.NotificationsShade)
+ }
+
+ @Test
+ fun shadeNotTouchable_hidesShade() =
+ testScope.runTest {
+ val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
+ val isShadeTouchable by collectLastValue(kosmos.shadeInteractor.isShadeTouchable)
+ assertThat(isShadeTouchable).isTrue()
+ sceneInteractor.showOverlay(Overlays.NotificationsShade, "test")
+ assertThat(currentOverlays).contains(Overlays.NotificationsShade)
+
+ lockDevice()
+ assertThat(isShadeTouchable).isFalse()
+ assertThat(currentOverlays).doesNotContain(Overlays.NotificationsShade)
+ }
+
+ private fun TestScope.lockDevice() {
+ val currentScene by collectLastValue(sceneInteractor.currentScene)
+ kosmos.powerInteractor.setAsleepForTest()
+ runCurrent()
+
+ assertThat(currentScene).isEqualTo(Scenes.Lockscreen)
+ }
+
+ private suspend fun TestScope.unlockDevice() {
+ val currentScene by collectLastValue(sceneInteractor.currentScene)
+ kosmos.powerInteractor.setAwakeForTest()
+ runCurrent()
+ assertThat(
+ kosmos.authenticationInteractor.authenticate(
+ FakeAuthenticationRepository.DEFAULT_PIN
+ )
+ )
+ .isEqualTo(AuthenticationResult.SUCCEEDED)
+
+ assertThat(currentScene).isEqualTo(Scenes.Gone)
+ }
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tileimpl/QSIconViewImplTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tileimpl/QSIconViewImplTest.java
index 2580ac2..7798f46 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tileimpl/QSIconViewImplTest.java
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tileimpl/QSIconViewImplTest.java
@@ -14,6 +14,8 @@
package com.android.systemui.qs.tileimpl;
+import static com.android.systemui.Flags.FLAG_QS_NEW_TILES;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.mockito.ArgumentMatchers.any;
@@ -21,11 +23,16 @@
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.content.Context;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.Drawable;
+import android.platform.test.annotations.DisableFlags;
+import android.platform.test.annotations.EnableFlags;
import android.service.quicksettings.Tile;
import android.testing.UiThreadTest;
import android.widget.ImageView;
@@ -47,7 +54,6 @@
@UiThreadTest
@SmallTest
public class QSIconViewImplTest extends SysuiTestCase {
-
private QSIconViewImpl mIconView;
@Before
@@ -106,6 +112,34 @@
verify(iv).setImageTintList(argThat(stateList -> stateList.getColors()[0] == desiredColor));
}
+
+ @EnableFlags(FLAG_QS_NEW_TILES)
+ @Test
+ public void testIconPreloaded_withFlagOn_immediatelyLoadsAll3TintColors() {
+ Context ctx = spy(mContext);
+
+ QSIconViewImpl iconView = new QSIconViewImpl(ctx);
+
+ verify(ctx, times(3)).obtainStyledAttributes(any());
+
+ iconView.getColor(new State()); // this should not increase the call count
+
+ verify(ctx, times(3)).obtainStyledAttributes(any());
+ }
+
+ @DisableFlags(FLAG_QS_NEW_TILES)
+ @Test
+ public void testIconPreloaded_withFlagOff_loadsOneTintColorAfterIconColorIsRead() {
+ Context ctx = spy(mContext);
+ QSIconViewImpl iconView = new QSIconViewImpl(ctx);
+
+ verify(ctx, never()).obtainStyledAttributes(any()); // none of the colors are preloaded
+
+ iconView.getColor(new State());
+
+ verify(ctx, times(1)).obtainStyledAttributes(any());
+ }
+
@Test
public void testStateSetCorrectly_toString() {
ImageView iv = mock(ImageView.class);
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapperTest.kt
index 620e90d..d32ba47 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapperTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapperTest.kt
@@ -17,13 +17,17 @@
package com.android.systemui.qs.tiles.impl.internet.domain
import android.graphics.drawable.TestStubDrawable
+import android.os.fakeExecutorHandler
import android.widget.Switch
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
+import com.android.settingslib.graph.SignalDrawable
import com.android.systemui.SysuiTestCase
import com.android.systemui.common.shared.model.ContentDescription
+import com.android.systemui.common.shared.model.ContentDescription.Companion.loadContentDescription
import com.android.systemui.common.shared.model.Icon
import com.android.systemui.common.shared.model.Text
+import com.android.systemui.common.shared.model.Text.Companion.loadText
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.qs.tiles.impl.custom.QSTileStateSubject
import com.android.systemui.qs.tiles.impl.internet.domain.model.InternetTileModel
@@ -31,6 +35,9 @@
import com.android.systemui.qs.tiles.viewmodel.QSTileState
import com.android.systemui.res.R
import com.android.systemui.statusbar.connectivity.WifiIcons.WIFI_FULL_ICONS
+import com.android.systemui.statusbar.pipeline.mobile.domain.model.SignalIconModel
+import com.android.systemui.statusbar.pipeline.satellite.ui.model.SatelliteIconModel
+import com.android.systemui.statusbar.pipeline.shared.ui.model.InternetTileIconModel
import org.junit.Test
import org.junit.runner.RunWith
@@ -39,25 +46,93 @@
class InternetTileMapperTest : SysuiTestCase() {
private val kosmos = Kosmos()
private val internetTileConfig = kosmos.qsInternetTileConfig
+ private val handler = kosmos.fakeExecutorHandler
private val mapper by lazy {
InternetTileMapper(
context.orCreateTestableResources
.apply {
addOverride(R.drawable.ic_qs_no_internet_unavailable, TestStubDrawable())
+ addOverride(R.drawable.ic_satellite_connected_2, TestStubDrawable())
addOverride(wifiRes, TestStubDrawable())
}
.resources,
context.theme,
- context
+ context,
+ handler,
)
}
@Test
- fun withActiveModel_mappedStateMatchesDataModel() {
+ fun withActiveCellularModel_mappedStateMatchesDataModel() {
val inputModel =
InternetTileModel.Active(
secondaryLabel = Text.Resource(R.string.quick_settings_networks_available),
- iconId = wifiRes,
+ icon = InternetTileIconModel.Cellular(3),
+ stateDescription = null,
+ contentDescription =
+ ContentDescription.Resource(R.string.quick_settings_internet_label),
+ )
+
+ val outputState = mapper.map(internetTileConfig, inputModel)
+
+ val signalDrawable = SignalDrawable(context, handler)
+ signalDrawable.setLevel(3)
+ val expectedState =
+ createInternetTileState(
+ QSTileState.ActivationState.ACTIVE,
+ context.getString(R.string.quick_settings_networks_available),
+ Icon.Loaded(signalDrawable, null),
+ null,
+ context.getString(R.string.quick_settings_internet_label),
+ )
+ QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState)
+ }
+
+ @Test
+ fun withActiveSatelliteModel_mappedStateMatchesDataModel() {
+ val inputIcon =
+ SignalIconModel.Satellite(
+ 3,
+ Icon.Resource(
+ res = R.drawable.ic_satellite_connected_2,
+ contentDescription =
+ ContentDescription.Resource(
+ R.string.accessibility_status_bar_satellite_good_connection
+ ),
+ ),
+ )
+ val inputModel =
+ InternetTileModel.Active(
+ secondaryLabel = Text.Resource(R.string.quick_settings_networks_available),
+ icon = InternetTileIconModel.Satellite(inputIcon.icon),
+ stateDescription = null,
+ contentDescription =
+ ContentDescription.Resource(
+ R.string.accessibility_status_bar_satellite_good_connection
+ ),
+ )
+
+ val outputState = mapper.map(internetTileConfig, inputModel)
+
+ val expectedSatIcon = SatelliteIconModel.fromSignalStrength(3)
+
+ val expectedState =
+ createInternetTileState(
+ QSTileState.ActivationState.ACTIVE,
+ inputModel.secondaryLabel.loadText(context).toString(),
+ Icon.Loaded(context.getDrawable(expectedSatIcon!!.res)!!, null),
+ expectedSatIcon.res,
+ expectedSatIcon.contentDescription.loadContentDescription(context).toString(),
+ )
+ QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState)
+ }
+
+ @Test
+ fun withActiveWifiModel_mappedStateMatchesDataModel() {
+ val inputModel =
+ InternetTileModel.Active(
+ secondaryLabel = Text.Resource(R.string.quick_settings_networks_available),
+ icon = InternetTileIconModel.ResourceId(wifiRes),
stateDescription = null,
contentDescription =
ContentDescription.Resource(R.string.quick_settings_internet_label),
@@ -71,7 +146,7 @@
context.getString(R.string.quick_settings_networks_available),
Icon.Loaded(context.getDrawable(wifiRes)!!, contentDescription = null),
wifiRes,
- context.getString(R.string.quick_settings_internet_label)
+ context.getString(R.string.quick_settings_internet_label),
)
QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState)
}
@@ -81,7 +156,7 @@
val inputModel =
InternetTileModel.Inactive(
secondaryLabel = Text.Resource(R.string.quick_settings_networks_unavailable),
- iconId = R.drawable.ic_qs_no_internet_unavailable,
+ icon = InternetTileIconModel.ResourceId(R.drawable.ic_qs_no_internet_unavailable),
stateDescription = null,
contentDescription =
ContentDescription.Resource(R.string.quick_settings_networks_unavailable),
@@ -95,10 +170,10 @@
context.getString(R.string.quick_settings_networks_unavailable),
Icon.Loaded(
context.getDrawable(R.drawable.ic_qs_no_internet_unavailable)!!,
- contentDescription = null
+ contentDescription = null,
),
R.drawable.ic_qs_no_internet_unavailable,
- context.getString(R.string.quick_settings_networks_unavailable)
+ context.getString(R.string.quick_settings_networks_unavailable),
)
QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState)
}
@@ -107,7 +182,7 @@
activationState: QSTileState.ActivationState,
secondaryLabel: String,
icon: Icon,
- iconRes: Int,
+ iconRes: Int? = null,
contentDescription: String,
): QSTileState {
val label = context.getString(R.string.quick_settings_internet_label)
@@ -120,13 +195,13 @@
setOf(
QSTileState.UserAction.CLICK,
QSTileState.UserAction.TOGGLE_CLICK,
- QSTileState.UserAction.LONG_CLICK
+ QSTileState.UserAction.LONG_CLICK,
),
contentDescription,
null,
QSTileState.SideViewIcon.Chevron,
QSTileState.EnabledState.ENABLED,
- Switch::class.qualifiedName
+ Switch::class.qualifiedName,
)
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileDataInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileDataInteractorTest.kt
index 5a45060..5259aa8 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileDataInteractorTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileDataInteractorTest.kt
@@ -18,14 +18,12 @@
import android.graphics.drawable.TestStubDrawable
import android.os.UserHandle
-import android.testing.TestableLooper
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.settingslib.AccessibilityContentDescriptions
import com.android.systemui.SysuiTestCase
import com.android.systemui.common.shared.model.ContentDescription
import com.android.systemui.common.shared.model.ContentDescription.Companion.loadContentDescription
-import com.android.systemui.common.shared.model.Icon
import com.android.systemui.common.shared.model.Text
import com.android.systemui.common.shared.model.Text.Companion.loadText
import com.android.systemui.coroutines.collectLastValue
@@ -49,6 +47,7 @@
import com.android.systemui.statusbar.pipeline.mobile.util.FakeMobileMappingsProxy
import com.android.systemui.statusbar.pipeline.shared.data.model.DefaultConnectionModel
import com.android.systemui.statusbar.pipeline.shared.data.repository.FakeConnectivityRepository
+import com.android.systemui.statusbar.pipeline.shared.ui.model.InternetTileIconModel
import com.android.systemui.statusbar.pipeline.wifi.data.repository.FakeWifiRepository
import com.android.systemui.statusbar.pipeline.wifi.domain.interactor.WifiInteractorImpl
import com.android.systemui.statusbar.pipeline.wifi.shared.model.WifiNetworkModel
@@ -60,9 +59,7 @@
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.flowOf
-import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
-import org.junit.Assume.assumeFalse
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -144,7 +141,6 @@
underTest =
InternetTileDataInteractor(
context,
- testScope.coroutineContext,
testScope.backgroundScope,
airplaneModeRepository,
connectivityRepository,
@@ -164,9 +160,11 @@
connectivityRepository.defaultConnections.value = DefaultConnectionModel()
+ val expectedIcon =
+ InternetTileIconModel.ResourceId(R.drawable.ic_qs_no_internet_unavailable)
assertThat(latest?.secondaryLabel)
.isEqualTo(Text.Resource(R.string.quick_settings_networks_unavailable))
- assertThat(latest?.iconId).isEqualTo(R.drawable.ic_qs_no_internet_unavailable)
+ assertThat(latest?.icon).isEqualTo(expectedIcon)
}
@Test
@@ -183,11 +181,8 @@
underTest.tileData(testUser, flowOf(DataUpdateTrigger.InitialRequest))
)
- val networkModel =
- WifiNetworkModel.Active.of(
- level = 4,
- ssid = "test ssid",
- )
+ val networkModel = WifiNetworkModel.Active.of(level = 4, ssid = "test ssid")
+
val wifiIcon =
WifiIcon.fromModel(model = networkModel, context = context, showHotspotInfo = true)
as WifiIcon.Visible
@@ -198,12 +193,9 @@
assertThat(latest?.secondaryTitle).isEqualTo("test ssid")
assertThat(latest?.secondaryLabel).isNull()
- val expectedIcon =
- Icon.Loaded(context.getDrawable(WifiIcons.WIFI_NO_INTERNET_ICONS[4])!!, null)
- val actualIcon = latest?.icon
- assertThat(actualIcon).isEqualTo(expectedIcon)
- assertThat(latest?.iconId).isEqualTo(WifiIcons.WIFI_NO_INTERNET_ICONS[4])
+ val expectedIcon = InternetTileIconModel.ResourceId(WifiIcons.WIFI_NO_INTERNET_ICONS[4])
+ assertThat(latest?.icon).isEqualTo(expectedIcon)
assertThat(latest?.contentDescription.loadContentDescription(context))
.isEqualTo("$internet,test ssid")
val expectedSd = wifiIcon.contentDescription
@@ -229,8 +221,7 @@
wifiRepository.setIsWifiDefault(true)
wifiRepository.setWifiNetwork(networkModel)
- val expectedIcon =
- Icon.Loaded(context.getDrawable(WifiIcons.WIFI_NO_INTERNET_ICONS[4])!!, null)
+ val expectedIcon = InternetTileIconModel.ResourceId(WifiIcons.WIFI_NO_INTERNET_ICONS[4])
assertThat(latest?.icon).isEqualTo(expectedIcon)
assertThat(latest?.stateDescription.loadContentDescription(context))
.doesNotContain(
@@ -249,9 +240,8 @@
setWifiNetworkWithHotspot(WifiNetworkModel.HotspotDeviceType.TABLET)
val expectedIcon =
- Icon.Loaded(
- context.getDrawable(com.android.settingslib.R.drawable.ic_hotspot_tablet)!!,
- null
+ InternetTileIconModel.ResourceId(
+ com.android.settingslib.R.drawable.ic_hotspot_tablet
)
assertThat(latest?.icon).isEqualTo(expectedIcon)
assertThat(latest?.stateDescription.loadContentDescription(context))
@@ -271,9 +261,8 @@
setWifiNetworkWithHotspot(WifiNetworkModel.HotspotDeviceType.LAPTOP)
val expectedIcon =
- Icon.Loaded(
- context.getDrawable(com.android.settingslib.R.drawable.ic_hotspot_laptop)!!,
- null
+ InternetTileIconModel.ResourceId(
+ com.android.settingslib.R.drawable.ic_hotspot_laptop
)
assertThat(latest?.icon).isEqualTo(expectedIcon)
assertThat(latest?.stateDescription.loadContentDescription(context))
@@ -293,10 +282,10 @@
setWifiNetworkWithHotspot(WifiNetworkModel.HotspotDeviceType.WATCH)
val expectedIcon =
- Icon.Loaded(
- context.getDrawable(com.android.settingslib.R.drawable.ic_hotspot_watch)!!,
- null
+ InternetTileIconModel.ResourceId(
+ com.android.settingslib.R.drawable.ic_hotspot_watch
)
+
assertThat(latest?.icon).isEqualTo(expectedIcon)
assertThat(latest?.stateDescription.loadContentDescription(context))
.isEqualTo(
@@ -315,10 +304,7 @@
setWifiNetworkWithHotspot(WifiNetworkModel.HotspotDeviceType.AUTO)
val expectedIcon =
- Icon.Loaded(
- context.getDrawable(com.android.settingslib.R.drawable.ic_hotspot_auto)!!,
- null
- )
+ InternetTileIconModel.ResourceId(com.android.settingslib.R.drawable.ic_hotspot_auto)
assertThat(latest?.icon).isEqualTo(expectedIcon)
assertThat(latest?.stateDescription.loadContentDescription(context))
.isEqualTo(
@@ -336,9 +322,8 @@
setWifiNetworkWithHotspot(WifiNetworkModel.HotspotDeviceType.PHONE)
val expectedIcon =
- Icon.Loaded(
- context.getDrawable(com.android.settingslib.R.drawable.ic_hotspot_phone)!!,
- null
+ InternetTileIconModel.ResourceId(
+ com.android.settingslib.R.drawable.ic_hotspot_phone
)
assertThat(latest?.icon).isEqualTo(expectedIcon)
assertThat(latest?.stateDescription.loadContentDescription(context))
@@ -358,9 +343,8 @@
setWifiNetworkWithHotspot(WifiNetworkModel.HotspotDeviceType.UNKNOWN)
val expectedIcon =
- Icon.Loaded(
- context.getDrawable(com.android.settingslib.R.drawable.ic_hotspot_phone)!!,
- null
+ InternetTileIconModel.ResourceId(
+ com.android.settingslib.R.drawable.ic_hotspot_phone
)
assertThat(latest?.icon).isEqualTo(expectedIcon)
assertThat(latest?.stateDescription.loadContentDescription(context))
@@ -380,10 +364,10 @@
setWifiNetworkWithHotspot(WifiNetworkModel.HotspotDeviceType.INVALID)
val expectedIcon =
- Icon.Loaded(
- context.getDrawable(com.android.settingslib.R.drawable.ic_hotspot_phone)!!,
- null
+ InternetTileIconModel.ResourceId(
+ com.android.settingslib.R.drawable.ic_hotspot_phone
)
+
assertThat(latest?.icon).isEqualTo(expectedIcon)
assertThat(latest?.stateDescription.loadContentDescription(context))
.isEqualTo(
@@ -426,8 +410,9 @@
assertThat(latest?.secondaryLabel).isNull()
assertThat(latest?.secondaryTitle)
.isEqualTo(context.getString(R.string.quick_settings_networks_available))
- assertThat(latest?.icon).isNull()
- assertThat(latest?.iconId).isEqualTo(R.drawable.ic_qs_no_internet_available)
+ val expectedIcon =
+ InternetTileIconModel.ResourceId(R.drawable.ic_qs_no_internet_available)
+ assertThat(latest?.icon).isEqualTo(expectedIcon)
assertThat(latest?.stateDescription).isNull()
val expectedCd =
"$internet,${context.getString(R.string.quick_settings_networks_available)}"
@@ -435,54 +420,19 @@
.isEqualTo(expectedCd)
}
- /**
- * We expect a RuntimeException because [underTest] instantiates a SignalDrawable on the
- * provided context, and so the SignalDrawable constructor attempts to instantiate a Handler()
- * on the mentioned context. Since that context does not have a looper assigned to it, the
- * handler instantiation will throw a RuntimeException.
- *
- * TODO(b/338068066): Robolectric behavior differs in that it does not throw the exception So
- * either we should make Robolectric behave similar to the device test, or change this test to
- * look for a different signal than the exception, when run by Robolectric. For now we just
- * assume the test is not Robolectric.
- */
- @Test(expected = java.lang.RuntimeException::class)
- fun mobileDefault_usesNetworkNameAndIcon_throwsRunTimeException() =
- testScope.runTest {
- assumeFalse(isRobolectricTest())
-
- collectLastValue(underTest.tileData(testUser, flowOf(DataUpdateTrigger.InitialRequest)))
-
- connectivityRepository.setMobileConnected()
- mobileConnectionsRepository.mobileIsDefault.value = true
- mobileConnectionRepository.apply {
- setAllLevels(3)
- setAllRoaming(false)
- networkName.value = NetworkNameModel.Default("test network")
- }
-
- runCurrent()
- }
-
- /**
- * See [mobileDefault_usesNetworkNameAndIcon_throwsRunTimeException] for description of the
- * problem this test solves. The solution here is to assign a looper to the context via
- * RunWithLooper. In the production code, the solution is to use a Main CoroutineContext for
- * creating the SignalDrawable.
- */
- @TestableLooper.RunWithLooper
@Test
- fun mobileDefault_run_withLooper_usesNetworkNameAndIcon() =
+ fun mobileDefault_usesNetworkNameAndIcon() =
testScope.runTest {
val latest by
collectLastValue(
underTest.tileData(testUser, flowOf(DataUpdateTrigger.InitialRequest))
)
+ val iconLevel = 3
connectivityRepository.setMobileConnected()
mobileConnectionsRepository.mobileIsDefault.value = true
mobileConnectionRepository.apply {
- setAllLevels(3)
+ setAllLevels(iconLevel)
setAllRoaming(false)
networkName.value = NetworkNameModel.Default("test network")
}
@@ -491,8 +441,9 @@
assertThat(latest?.secondaryTitle).isNotNull()
assertThat(latest?.secondaryTitle.toString()).contains("test network")
assertThat(latest?.secondaryLabel).isNull()
- assertThat(latest?.icon).isInstanceOf(Icon.Loaded::class.java)
- assertThat(latest?.iconId).isNull()
+ val expectedIcon = InternetTileIconModel.Cellular(iconLevel)
+
+ assertThat(latest?.icon).isEqualTo(expectedIcon)
assertThat(latest?.stateDescription.loadContentDescription(context))
.isEqualTo(latest?.secondaryTitle.toString())
assertThat(latest?.contentDescription.loadContentDescription(context))
@@ -513,8 +464,8 @@
assertThat(latest?.secondaryLabel.loadText(context))
.isEqualTo(ethernetIcon!!.contentDescription.loadContentDescription(context))
assertThat(latest?.secondaryTitle).isNull()
- assertThat(latest?.iconId).isEqualTo(R.drawable.stat_sys_ethernet_fully)
- assertThat(latest?.icon).isNull()
+ val expectedIcon = InternetTileIconModel.ResourceId(R.drawable.stat_sys_ethernet_fully)
+ assertThat(latest?.icon).isEqualTo(expectedIcon)
assertThat(latest?.stateDescription).isNull()
assertThat(latest?.contentDescription.loadContentDescription(context))
.isEqualTo(latest?.secondaryLabel.loadText(context))
@@ -534,8 +485,8 @@
assertThat(latest?.secondaryLabel.loadText(context))
.isEqualTo(ethernetIcon!!.contentDescription.loadContentDescription(context))
assertThat(latest?.secondaryTitle).isNull()
- assertThat(latest?.iconId).isEqualTo(R.drawable.stat_sys_ethernet)
- assertThat(latest?.icon).isNull()
+ val expectedIcon = InternetTileIconModel.ResourceId(R.drawable.stat_sys_ethernet)
+ assertThat(latest?.icon).isEqualTo(expectedIcon)
assertThat(latest?.stateDescription).isNull()
assertThat(latest?.contentDescription.loadContentDescription(context))
.isEqualTo(latest?.secondaryLabel.loadText(context))
@@ -543,11 +494,7 @@
private fun setWifiNetworkWithHotspot(hotspot: WifiNetworkModel.HotspotDeviceType) {
val networkModel =
- WifiNetworkModel.Active.of(
- level = 4,
- ssid = "test ssid",
- hotspotDeviceType = hotspot,
- )
+ WifiNetworkModel.Active.of(level = 4, ssid = "test ssid", hotspotDeviceType = hotspot)
connectivityRepository.setWifiConnected()
wifiRepository.setIsWifiDefault(true)
@@ -560,7 +507,7 @@
val NOT_CONNECTED_NETWORKS_UNAVAILABLE =
InternetTileModel.Inactive(
secondaryLabel = Text.Resource(R.string.quick_settings_networks_unavailable),
- iconId = R.drawable.ic_qs_no_internet_unavailable,
+ icon = InternetTileIconModel.ResourceId(R.drawable.ic_qs_no_internet_unavailable),
stateDescription = null,
contentDescription =
ContentDescription.Resource(R.string.quick_settings_networks_unavailable),
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayContentViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayContentViewModelTest.kt
index 8c7ec47..f32894d 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayContentViewModelTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayContentViewModelTest.kt
@@ -21,18 +21,33 @@
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
+import com.android.systemui.authentication.data.repository.FakeAuthenticationRepository
+import com.android.systemui.authentication.domain.interactor.AuthenticationResult
+import com.android.systemui.authentication.domain.interactor.authenticationInteractor
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.flags.EnableSceneContainer
import com.android.systemui.kosmos.testScope
+import com.android.systemui.lifecycle.activateIn
+import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAsleepForTest
+import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAwakeForTest
+import com.android.systemui.power.domain.interactor.powerInteractor
import com.android.systemui.scene.domain.interactor.sceneInteractor
+import com.android.systemui.scene.domain.startable.sceneContainerStartable
import com.android.systemui.scene.shared.model.Overlays
+import com.android.systemui.scene.shared.model.Scenes
+import com.android.systemui.shade.domain.interactor.shadeInteractor
import com.android.systemui.shade.shared.flag.DualShade
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.test.TestScope
+import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
+import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
+@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper
@@ -46,18 +61,84 @@
private val underTest by lazy { kosmos.quickSettingsShadeOverlayContentViewModel }
+ @Before
+ fun setUp() {
+ kosmos.sceneContainerStartable.start()
+ underTest.activateIn(testScope)
+ }
+
@Test
fun onScrimClicked_hidesShade() =
testScope.runTest {
val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
- sceneInteractor.showOverlay(
- overlay = Overlays.QuickSettingsShade,
- loggingReason = "test",
- )
+ sceneInteractor.showOverlay(Overlays.QuickSettingsShade, "test")
assertThat(currentOverlays).contains(Overlays.QuickSettingsShade)
underTest.onScrimClicked()
assertThat(currentOverlays).doesNotContain(Overlays.QuickSettingsShade)
}
+
+ @Test
+ fun deviceLocked_hidesShade() =
+ testScope.runTest {
+ val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
+ unlockDevice()
+ sceneInteractor.showOverlay(Overlays.QuickSettingsShade, "test")
+ assertThat(currentOverlays).contains(Overlays.QuickSettingsShade)
+
+ lockDevice()
+
+ assertThat(currentOverlays).isEmpty()
+ }
+
+ @Test
+ fun bouncerShown_hidesShade() =
+ testScope.runTest {
+ val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
+ lockDevice()
+ sceneInteractor.showOverlay(Overlays.QuickSettingsShade, "test")
+ assertThat(currentOverlays).contains(Overlays.QuickSettingsShade)
+
+ sceneInteractor.changeScene(Scenes.Bouncer, "test")
+ runCurrent()
+
+ assertThat(currentOverlays).doesNotContain(Overlays.QuickSettingsShade)
+ }
+
+ @Test
+ fun shadeNotTouchable_hidesShade() =
+ testScope.runTest {
+ val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
+ val isShadeTouchable by collectLastValue(kosmos.shadeInteractor.isShadeTouchable)
+ assertThat(isShadeTouchable).isTrue()
+ sceneInteractor.showOverlay(Overlays.QuickSettingsShade, "test")
+ assertThat(currentOverlays).contains(Overlays.QuickSettingsShade)
+
+ lockDevice()
+ assertThat(isShadeTouchable).isFalse()
+ assertThat(currentOverlays).doesNotContain(Overlays.QuickSettingsShade)
+ }
+
+ private fun TestScope.lockDevice() {
+ val currentScene by collectLastValue(sceneInteractor.currentScene)
+ kosmos.powerInteractor.setAsleepForTest()
+ runCurrent()
+
+ assertThat(currentScene).isEqualTo(Scenes.Lockscreen)
+ }
+
+ private suspend fun TestScope.unlockDevice() {
+ val currentScene by collectLastValue(sceneInteractor.currentScene)
+ kosmos.powerInteractor.setAwakeForTest()
+ runCurrent()
+ assertThat(
+ kosmos.authenticationInteractor.authenticate(
+ FakeAuthenticationRepository.DEFAULT_PIN
+ )
+ )
+ .isEqualTo(AuthenticationResult.SUCCEEDED)
+
+ assertThat(currentScene).isEqualTo(Scenes.Gone)
+ }
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/IssueRecordingServiceCommandHandlerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/IssueRecordingServiceSessionTest.kt
similarity index 88%
rename from packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/IssueRecordingServiceCommandHandlerTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/IssueRecordingServiceSessionTest.kt
index 57cfe1b..3e5dee6 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/IssueRecordingServiceCommandHandlerTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/IssueRecordingServiceSessionTest.kt
@@ -47,7 +47,7 @@
@SmallTest
@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
-class IssueRecordingServiceCommandHandlerTest : SysuiTestCase() {
+class IssueRecordingServiceSessionTest : SysuiTestCase() {
private val kosmos = Kosmos().also { it.testCase = this }
private val bgExecutor = kosmos.fakeExecutor
@@ -61,13 +61,13 @@
private val notificationManager = mock<NotificationManager>()
private val panelInteractor = mock<PanelInteractor>()
- private lateinit var underTest: IssueRecordingServiceCommandHandler
+ private lateinit var underTest: IssueRecordingServiceSession
@Before
fun setup() {
traceurMessageSender = mock<TraceurMessageSender>()
underTest =
- IssueRecordingServiceCommandHandler(
+ IssueRecordingServiceSession(
bgExecutor,
dialogTransitionAnimator,
panelInteractor,
@@ -75,13 +75,13 @@
issueRecordingState,
iActivityManager,
notificationManager,
- userContextProvider
+ userContextProvider,
)
}
@Test
fun startsTracing_afterReceivingActionStartCommand() {
- underTest.handleStartCommand()
+ underTest.start()
bgExecutor.runAllReady()
Truth.assertThat(issueRecordingState.isRecording).isTrue()
@@ -90,7 +90,7 @@
@Test
fun stopsTracing_afterReceivingStopTracingCommand() {
- underTest.handleStopCommand(mContext.contentResolver)
+ underTest.stop(mContext.contentResolver)
bgExecutor.runAllReady()
Truth.assertThat(issueRecordingState.isRecording).isFalse()
@@ -99,7 +99,7 @@
@Test
fun cancelsNotification_afterReceivingShareCommand() {
- underTest.handleShareCommand(0, null, mContext)
+ underTest.share(0, null, mContext)
bgExecutor.runAllReady()
verify(notificationManager).cancelAsUser(isNull(), anyInt(), any<UserHandle>())
@@ -110,7 +110,7 @@
issueRecordingState.takeBugreport = true
val uri = mock<Uri>()
- underTest.handleShareCommand(0, uri, mContext)
+ underTest.share(0, uri, mContext)
bgExecutor.runAllReady()
verify(iActivityManager).requestBugReportWithExtraAttachment(uri)
@@ -121,7 +121,7 @@
issueRecordingState.takeBugreport = false
val uri = mock<Uri>()
- underTest.handleShareCommand(0, uri, mContext)
+ underTest.share(0, uri, mContext)
bgExecutor.runAllReady()
verify(traceurMessageSender).shareTraces(mContext, uri)
@@ -131,7 +131,7 @@
fun closesShade_afterReceivingShareCommand() {
val uri = mock<Uri>()
- underTest.handleShareCommand(0, uri, mContext)
+ underTest.share(0, uri, mContext)
bgExecutor.runAllReady()
verify(panelInteractor).collapsePanels()
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSTile.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSTile.java
index be44dee..73626b4 100644
--- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSTile.java
+++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSTile.java
@@ -184,7 +184,10 @@
}
}
- /** Get the text for secondaryLabel. */
+ /**
+ * If the current secondaryLabel value is not empty, ignore the given input and return
+ * the current value. Otherwise return current value.
+ */
public CharSequence getSecondaryLabel(CharSequence stateText) {
// Use a local reference as the value might change from other threads
CharSequence localSecondaryLabel = secondaryLabel;
diff --git a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java
index 113e001..83f86a7 100644
--- a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java
+++ b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java
@@ -65,6 +65,7 @@
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor;
import com.android.systemui.navigationbar.gestural.domain.GestureInteractor;
import com.android.systemui.navigationbar.gestural.domain.TaskMatcher;
+import com.android.systemui.scene.shared.flag.SceneContainerFlag;
import com.android.systemui.shade.ShadeExpansionChangeEvent;
import com.android.systemui.touch.TouchInsetManager;
import com.android.systemui.util.concurrency.DelayableExecutor;
@@ -499,8 +500,11 @@
mDreamOverlayContainerViewController =
dreamOverlayComponent.getDreamOverlayContainerViewController();
- mTouchMonitor = ambientTouchComponent.getTouchMonitor();
- mTouchMonitor.init();
+
+ if (!SceneContainerFlag.isEnabled()) {
+ mTouchMonitor = ambientTouchComponent.getTouchMonitor();
+ mTouchMonitor.init();
+ }
mStateController.setShouldShowComplications(shouldShowComplications());
diff --git a/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/KeyboardTouchpadTutorialMetricsLogger.kt b/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/KeyboardTouchpadTutorialMetricsLogger.kt
new file mode 100644
index 0000000..144c5ead
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/KeyboardTouchpadTutorialMetricsLogger.kt
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.inputdevice.tutorial
+
+import com.android.systemui.inputdevice.tutorial.ui.view.KeyboardTouchpadTutorialActivity.Companion.INTENT_TUTORIAL_ENTRY_POINT_CONTEXTUAL_EDU
+import com.android.systemui.inputdevice.tutorial.ui.view.KeyboardTouchpadTutorialActivity.Companion.INTENT_TUTORIAL_ENTRY_POINT_SCHEDULER
+import com.android.systemui.inputdevice.tutorial.ui.view.KeyboardTouchpadTutorialActivity.Companion.INTENT_TUTORIAL_TYPE_KEYBOARD
+import com.android.systemui.inputdevice.tutorial.ui.view.KeyboardTouchpadTutorialActivity.Companion.INTENT_TUTORIAL_TYPE_TOUCHPAD
+import com.android.systemui.shared.system.SysUiStatsLog
+import javax.inject.Inject
+
+class KeyboardTouchpadTutorialMetricsLogger @Inject constructor() {
+
+ fun logPeripheralTutorialLaunched(entryPointExtra: String?, tutorialTypeExtra: String?) {
+ val entryPoint =
+ when (entryPointExtra) {
+ INTENT_TUTORIAL_ENTRY_POINT_SCHEDULER ->
+ SysUiStatsLog.PERIPHERAL_TUTORIAL_LAUNCHED__ENTRY_POINT__SCHEDULED
+ INTENT_TUTORIAL_ENTRY_POINT_CONTEXTUAL_EDU ->
+ SysUiStatsLog.PERIPHERAL_TUTORIAL_LAUNCHED__ENTRY_POINT__CONTEXTUAL_EDU
+ else -> SysUiStatsLog.PERIPHERAL_TUTORIAL_LAUNCHED__ENTRY_POINT__APP
+ }
+
+ val tutorialType =
+ when (tutorialTypeExtra) {
+ INTENT_TUTORIAL_TYPE_KEYBOARD ->
+ SysUiStatsLog.PERIPHERAL_TUTORIAL_LAUNCHED__TUTORIAL_TYPE__KEYBOARD
+ INTENT_TUTORIAL_TYPE_TOUCHPAD ->
+ SysUiStatsLog.PERIPHERAL_TUTORIAL_LAUNCHED__TUTORIAL_TYPE__TOUCHPAD
+ else -> SysUiStatsLog.PERIPHERAL_TUTORIAL_LAUNCHED__TUTORIAL_TYPE__BOTH
+ }
+
+ SysUiStatsLog.write(SysUiStatsLog.PERIPHERAL_TUTORIAL_LAUNCHED, entryPoint, tutorialType)
+ }
+
+ fun logPeripheralTutorialLaunchedFromSettings() {
+ val entryPoint = SysUiStatsLog.PERIPHERAL_TUTORIAL_LAUNCHED__ENTRY_POINT__SETTINGS
+ val tutorialType = SysUiStatsLog.PERIPHERAL_TUTORIAL_LAUNCHED__TUTORIAL_TYPE__TOUCHPAD
+ SysUiStatsLog.write(SysUiStatsLog.PERIPHERAL_TUTORIAL_LAUNCHED, entryPoint, tutorialType)
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/TutorialNotificationCoordinator.kt b/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/TutorialNotificationCoordinator.kt
index 5d9dda3..f2afaee 100644
--- a/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/TutorialNotificationCoordinator.kt
+++ b/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/TutorialNotificationCoordinator.kt
@@ -31,6 +31,8 @@
import com.android.systemui.inputdevice.tutorial.domain.interactor.TutorialSchedulerInteractor.Companion.TAG
import com.android.systemui.inputdevice.tutorial.domain.interactor.TutorialSchedulerInteractor.TutorialType
import com.android.systemui.inputdevice.tutorial.ui.view.KeyboardTouchpadTutorialActivity
+import com.android.systemui.inputdevice.tutorial.ui.view.KeyboardTouchpadTutorialActivity.Companion.INTENT_TUTORIAL_ENTRY_POINT_KEY
+import com.android.systemui.inputdevice.tutorial.ui.view.KeyboardTouchpadTutorialActivity.Companion.INTENT_TUTORIAL_ENTRY_POINT_SCHEDULER
import com.android.systemui.inputdevice.tutorial.ui.view.KeyboardTouchpadTutorialActivity.Companion.INTENT_TUTORIAL_TYPE_BOTH
import com.android.systemui.inputdevice.tutorial.ui.view.KeyboardTouchpadTutorialActivity.Companion.INTENT_TUTORIAL_TYPE_KEY
import com.android.systemui.inputdevice.tutorial.ui.view.KeyboardTouchpadTutorialActivity.Companion.INTENT_TUTORIAL_TYPE_KEYBOARD
@@ -48,7 +50,7 @@
@Background private val backgroundScope: CoroutineScope,
@Application private val context: Context,
private val tutorialSchedulerInteractor: TutorialSchedulerInteractor,
- private val notificationManager: NotificationManager
+ private val notificationManager: NotificationManager,
) {
fun start() {
backgroundScope.launch {
@@ -68,7 +70,7 @@
val extras = Bundle()
extras.putString(
Notification.EXTRA_SUBSTITUTE_APP_NAME,
- context.getString(com.android.internal.R.string.android_system_label)
+ context.getString(com.android.internal.R.string.android_system_label),
)
val info = getNotificationInfo(tutorialType)!!
@@ -91,7 +93,7 @@
NotificationChannel(
CHANNEL_ID,
context.getString(com.android.internal.R.string.android_system_label),
- NotificationManager.IMPORTANCE_DEFAULT
+ NotificationManager.IMPORTANCE_DEFAULT,
)
notificationManager.createNotificationChannel(channel)
}
@@ -100,13 +102,14 @@
val intent =
Intent(context, KeyboardTouchpadTutorialActivity::class.java).apply {
putExtra(INTENT_TUTORIAL_TYPE_KEY, tutorialType)
+ putExtra(INTENT_TUTORIAL_ENTRY_POINT_KEY, INTENT_TUTORIAL_ENTRY_POINT_SCHEDULER)
flags = Intent.FLAG_ACTIVITY_NEW_TASK
}
return PendingIntent.getActivity(
context,
/* requestCode= */ 0,
intent,
- PendingIntent.FLAG_IMMUTABLE
+ PendingIntent.FLAG_IMMUTABLE,
)
}
@@ -118,13 +121,13 @@
NotificationInfo(
context.getString(R.string.launch_keyboard_tutorial_notification_title),
context.getString(R.string.launch_keyboard_tutorial_notification_content),
- INTENT_TUTORIAL_TYPE_KEYBOARD
+ INTENT_TUTORIAL_TYPE_KEYBOARD,
)
TutorialType.TOUCHPAD ->
NotificationInfo(
context.getString(R.string.launch_touchpad_tutorial_notification_title),
context.getString(R.string.launch_touchpad_tutorial_notification_content),
- INTENT_TUTORIAL_TYPE_TOUCHPAD
+ INTENT_TUTORIAL_TYPE_TOUCHPAD,
)
TutorialType.BOTH ->
NotificationInfo(
@@ -134,7 +137,7 @@
context.getString(
R.string.launch_keyboard_touchpad_tutorial_notification_content
),
- INTENT_TUTORIAL_TYPE_BOTH
+ INTENT_TUTORIAL_TYPE_BOTH,
)
TutorialType.NONE -> null
}
diff --git a/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/view/KeyboardTouchpadTutorialActivity.kt b/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/view/KeyboardTouchpadTutorialActivity.kt
index c130c6c..29febd3 100644
--- a/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/view/KeyboardTouchpadTutorialActivity.kt
+++ b/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/view/KeyboardTouchpadTutorialActivity.kt
@@ -30,6 +30,7 @@
import com.android.compose.theme.PlatformTheme
import com.android.systemui.inputdevice.tutorial.InputDeviceTutorialLogger
import com.android.systemui.inputdevice.tutorial.InputDeviceTutorialLogger.TutorialContext
+import com.android.systemui.inputdevice.tutorial.KeyboardTouchpadTutorialMetricsLogger
import com.android.systemui.inputdevice.tutorial.TouchpadTutorialScreensProvider
import com.android.systemui.inputdevice.tutorial.ui.composable.ActionKeyTutorialScreen
import com.android.systemui.inputdevice.tutorial.ui.viewmodel.KeyboardTouchpadTutorialViewModel
@@ -51,6 +52,7 @@
private val viewModelFactoryAssistedProvider: ViewModelFactoryAssistedProvider,
private val touchpadTutorialScreensProvider: Optional<TouchpadTutorialScreensProvider>,
private val logger: InputDeviceTutorialLogger,
+ private val metricsLogger: KeyboardTouchpadTutorialMetricsLogger,
) : ComponentActivity() {
companion object {
@@ -58,6 +60,9 @@
const val INTENT_TUTORIAL_TYPE_TOUCHPAD = "touchpad"
const val INTENT_TUTORIAL_TYPE_KEYBOARD = "keyboard"
const val INTENT_TUTORIAL_TYPE_BOTH = "both"
+ const val INTENT_TUTORIAL_ENTRY_POINT_KEY = "entry_point"
+ const val INTENT_TUTORIAL_ENTRY_POINT_SCHEDULER = "scheduler"
+ const val INTENT_TUTORIAL_ENTRY_POINT_CONTEXTUAL_EDU = "contextual_edu"
}
private val vm by
@@ -86,6 +91,10 @@
PlatformTheme { KeyboardTouchpadTutorialContainer(vm, touchpadTutorialScreensProvider) }
}
if (savedInstanceState == null) {
+ metricsLogger.logPeripheralTutorialLaunched(
+ intent.getStringExtra(INTENT_TUTORIAL_ENTRY_POINT_KEY),
+ intent.getStringExtra(INTENT_TUTORIAL_TYPE_KEY),
+ )
logger.logOpenTutorial(TutorialContext.KEYBOARD_TOUCHPAD_TUTORIAL)
}
}
@@ -109,7 +118,7 @@
ACTION_KEY ->
ActionKeyTutorialScreen(
onDoneButtonClicked = vm::onDoneButtonClicked,
- onBack = vm::onBack
+ onBack = vm::onBack,
)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/ui/view/ShortcutHelperActivity.kt b/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/ui/view/ShortcutHelperActivity.kt
index b9a16c4..52263ce 100644
--- a/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/ui/view/ShortcutHelperActivity.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/ui/view/ShortcutHelperActivity.kt
@@ -18,6 +18,7 @@
import android.content.ActivityNotFoundException
import android.content.Intent
+import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import android.content.res.Configuration
import android.os.Bundle
import android.provider.Settings
@@ -125,7 +126,7 @@
private fun onKeyboardSettingsClicked() {
try {
startActivityAsUser(
- Intent(Settings.ACTION_HARD_KEYBOARD_SETTINGS),
+ Intent(Settings.ACTION_HARD_KEYBOARD_SETTINGS).addFlags(FLAG_ACTIVITY_NEW_TASK),
userTracker.userHandle,
)
} catch (e: ActivityNotFoundException) {
diff --git a/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/MediaProjectionPermissionActivity.java b/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/MediaProjectionPermissionActivity.java
index 8351597..c3729c0 100644
--- a/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/MediaProjectionPermissionActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/MediaProjectionPermissionActivity.java
@@ -68,12 +68,12 @@
import com.android.systemui.statusbar.phone.AlertDialogWithDelegate;
import com.android.systemui.statusbar.phone.SystemUIDialog;
+import dagger.Lazy;
+
import java.util.function.Consumer;
import javax.inject.Inject;
-import dagger.Lazy;
-
public class MediaProjectionPermissionActivity extends Activity {
private static final String TAG = "MediaProjectionPermissionActivity";
private static final float MAX_APP_NAME_SIZE_PX = 500f;
@@ -132,8 +132,7 @@
mPackageName = launchingIntent.getStringExtra(
EXTRA_PACKAGE_REUSING_GRANTED_CONSENT);
} else {
- setResult(RESULT_CANCELED);
- finish(RECORD_CANCEL, /* projection= */ null);
+ finishAsCancelled();
return;
}
}
@@ -145,8 +144,7 @@
mUid = aInfo.uid;
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Unable to look up package name", e);
- setResult(RESULT_CANCELED);
- finish(RECORD_CANCEL, /* projection= */ null);
+ finishAsCancelled();
return;
}
@@ -176,15 +174,13 @@
}
} catch (RemoteException e) {
Log.e(TAG, "Error checking projection permissions", e);
- setResult(RESULT_CANCELED);
- finish(RECORD_CANCEL, /* projection= */ null);
+ finishAsCancelled();
return;
}
if (mFeatureFlags.isEnabled(Flags.WM_ENABLE_PARTIAL_SCREEN_SHARING_ENTERPRISE_POLICIES)) {
if (showScreenCaptureDisabledDialogIfNeeded()) {
- setResult(RESULT_CANCELED);
- finish(RECORD_CANCEL, /* projection= */ null);
+ finishAsCancelled();
return;
}
}
@@ -346,6 +342,21 @@
private void requestDeviceUnlock() {
mKeyguardManager.requestDismissKeyguard(this,
new KeyguardManager.KeyguardDismissCallback() {
+
+ @Override
+ public void onDismissError() {
+ if (com.android.systemui.Flags.mediaProjectionDialogBehindLockscreen()) {
+ finishAsCancelled();
+ }
+ }
+
+ @Override
+ public void onDismissCancelled() {
+ if (com.android.systemui.Flags.mediaProjectionDialogBehindLockscreen()) {
+ finishAsCancelled();
+ }
+ }
+
@Override
public void onDismissSucceeded() {
mDialog.show();
@@ -386,8 +397,7 @@
}
} catch (RemoteException e) {
Log.e(TAG, "Error granting projection permission", e);
- setResult(RESULT_CANCELED);
- finish(RECORD_CANCEL, /* projection= */ null);
+ finishAsCancelled();
} finally {
if (mDialog != null) {
mDialog.dismiss();
@@ -436,6 +446,14 @@
}
}
+ /**
+ * Finishes this activity and cancel the projection request.
+ */
+ private void finishAsCancelled() {
+ setResult(RESULT_CANCELED);
+ finish(RECORD_CANCEL, /* projection= */ null);
+ }
+
@Nullable
private MediaProjectionConfig getMediaProjectionConfig() {
Intent intent = getIntent();
diff --git a/packages/SystemUI/src/com/android/systemui/notifications/ui/viewmodel/NotificationsShadeOverlayContentViewModel.kt b/packages/SystemUI/src/com/android/systemui/notifications/ui/viewmodel/NotificationsShadeOverlayContentViewModel.kt
index 219e45c..0e54041 100644
--- a/packages/SystemUI/src/com/android/systemui/notifications/ui/viewmodel/NotificationsShadeOverlayContentViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/notifications/ui/viewmodel/NotificationsShadeOverlayContentViewModel.kt
@@ -16,11 +16,19 @@
package com.android.systemui.notifications.ui.viewmodel
+import com.android.systemui.lifecycle.ExclusiveActivatable
+import com.android.systemui.scene.domain.interactor.SceneInteractor
+import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.shade.ui.viewmodel.ShadeHeaderViewModel
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationsPlaceholderViewModel
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
+import kotlinx.coroutines.awaitCancellation
+import kotlinx.coroutines.coroutineScope
+import kotlinx.coroutines.flow.distinctUntilChanged
+import kotlinx.coroutines.flow.filter
+import kotlinx.coroutines.launch
/**
* Models UI state used to render the content of the notifications shade overlay.
@@ -33,10 +41,40 @@
constructor(
val shadeHeaderViewModelFactory: ShadeHeaderViewModel.Factory,
val notificationsPlaceholderViewModelFactory: NotificationsPlaceholderViewModel.Factory,
+ val sceneInteractor: SceneInteractor,
private val shadeInteractor: ShadeInteractor,
-) {
+) : ExclusiveActivatable() {
+
+ override suspend fun onActivated(): Nothing {
+ coroutineScope {
+ launch {
+ sceneInteractor.currentScene.collect { currentScene ->
+ when (currentScene) {
+ // TODO(b/369513770): The ShadeSession should be preserved in this scenario.
+ Scenes.Bouncer ->
+ shadeInteractor.collapseNotificationsShade(
+ loggingReason = "bouncer shown while shade is open"
+ )
+ }
+ }
+ }
+
+ launch {
+ shadeInteractor.isShadeTouchable
+ .distinctUntilChanged()
+ .filter { !it }
+ .collect {
+ shadeInteractor.collapseNotificationsShade(
+ loggingReason = "device became non-interactive"
+ )
+ }
+ }
+ }
+ awaitCancellation()
+ }
+
fun onScrimClicked() {
- shadeInteractor.collapseNotificationsShade(loggingReason = "Shade scrim clicked")
+ shadeInteractor.collapseNotificationsShade(loggingReason = "shade scrim clicked")
}
@AssistedFactory
diff --git a/packages/SystemUI/src/com/android/systemui/qs/logging/QSLogger.kt b/packages/SystemUI/src/com/android/systemui/qs/logging/QSLogger.kt
index 278352c..ead38f3 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/logging/QSLogger.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/logging/QSLogger.kt
@@ -33,6 +33,7 @@
import com.android.systemui.log.dagger.QSConfigLog
import com.android.systemui.log.dagger.QSLog
import com.android.systemui.plugins.qs.QSTile
+import com.android.systemui.plugins.qs.QSTile.State
import com.android.systemui.statusbar.StatusBarState
import com.google.errorprone.annotations.CompileTimeConstant
import javax.inject.Inject
@@ -57,6 +58,7 @@
fun d(@CompileTimeConstant msg: String, arg: Any) {
buffer.log(TAG, DEBUG, { str1 = arg.toString() }, { "$msg: $str1" })
}
+
fun i(@CompileTimeConstant msg: String, arg: Any) {
buffer.log(TAG, INFO, { str1 = arg.toString() }, { "$msg: $str1" })
}
@@ -73,7 +75,19 @@
str1 = tileSpec
str2 = reason
},
- { "[$str1] Tile destroyed. Reason: $str2" }
+ { "[$str1] Tile destroyed. Reason: $str2" },
+ )
+ }
+
+ fun logStateChanged(tileSpec: String, state: State) {
+ buffer.log(
+ TAG,
+ DEBUG,
+ {
+ str1 = tileSpec
+ str2 = state.toString()
+ },
+ { "[$str1] Tile state=$str2" },
)
}
@@ -85,7 +99,7 @@
bool1 = listening
str1 = tileSpec
},
- { "[$str1] Tile listening=$bool1" }
+ { "[$str1] Tile listening=$bool1" },
)
}
@@ -98,7 +112,7 @@
str1 = containerName
str2 = allSpecs
},
- { "Tiles listening=$bool1 in $str1. $str2" }
+ { "Tiles listening=$bool1 in $str1. $str2" },
)
}
@@ -112,7 +126,7 @@
str2 = StatusBarState.toString(statusBarState)
str3 = toStateString(state)
},
- { "[$str1][$int1] Tile clicked. StatusBarState=$str2. TileState=$str3" }
+ { "[$str1][$int1] Tile clicked. StatusBarState=$str2. TileState=$str3" },
)
}
@@ -124,7 +138,7 @@
str1 = tileSpec
int1 = eventId
},
- { "[$str1][$int1] Tile handling click." }
+ { "[$str1][$int1] Tile handling click." },
)
}
@@ -138,7 +152,7 @@
str2 = StatusBarState.toString(statusBarState)
str3 = toStateString(state)
},
- { "[$str1][$int1] Tile secondary clicked. StatusBarState=$str2. TileState=$str3" }
+ { "[$str1][$int1] Tile secondary clicked. StatusBarState=$str2. TileState=$str3" },
)
}
@@ -150,7 +164,7 @@
str1 = tileSpec
int1 = eventId
},
- { "[$str1][$int1] Tile handling secondary click." }
+ { "[$str1][$int1] Tile handling secondary click." },
)
}
@@ -164,7 +178,7 @@
str2 = StatusBarState.toString(statusBarState)
str3 = toStateString(state)
},
- { "[$str1][$int1] Tile long clicked. StatusBarState=$str2. TileState=$str3" }
+ { "[$str1][$int1] Tile long clicked. StatusBarState=$str2. TileState=$str3" },
)
}
@@ -176,7 +190,7 @@
str1 = tileSpec
int1 = eventId
},
- { "[$str1][$int1] Tile handling long click." }
+ { "[$str1][$int1] Tile handling long click." },
)
}
@@ -189,7 +203,7 @@
int1 = lastType
str2 = callback
},
- { "[$str1] mLastTileState=$int1, Callback=$str2." }
+ { "[$str1] mLastTileState=$int1, Callback=$str2." },
)
}
@@ -198,7 +212,7 @@
tileSpec: String,
state: Int,
disabledByPolicy: Boolean,
- color: Int
+ color: Int,
) {
// This method is added to further debug b/250618218 which has only been observed from the
// InternetTile, so we are only logging the background color change for the InternetTile
@@ -215,7 +229,7 @@
bool1 = disabledByPolicy
int2 = color
},
- { "[$str1] state=$int1, disabledByPolicy=$bool1, color=$int2." }
+ { "[$str1] state=$int1, disabledByPolicy=$bool1, color=$int2." },
)
}
@@ -229,7 +243,7 @@
str3 = state.icon?.toString()
int1 = state.state
},
- { "[$str1] Tile updated. Label=$str2. State=$int1. Icon=$str3." }
+ { "[$str1] Tile updated. Label=$str2. State=$int1. Icon=$str3." },
)
}
@@ -241,7 +255,7 @@
str1 = containerName
bool1 = expanded
},
- { "$str1 expanded=$bool1" }
+ { "$str1 expanded=$bool1" },
)
}
@@ -253,7 +267,7 @@
str1 = containerName
int1 = orientation
},
- { "onViewAttached: $str1 orientation $int1" }
+ { "onViewAttached: $str1 orientation $int1" },
)
}
@@ -265,7 +279,7 @@
str1 = containerName
int1 = orientation
},
- { "onViewDetached: $str1 orientation $int1" }
+ { "onViewDetached: $str1 orientation $int1" },
)
}
@@ -276,7 +290,7 @@
newShouldUseSplitShade: Boolean,
oldScreenLayout: Int,
newScreenLayout: Int,
- containerName: String
+ containerName: String,
) {
configChangedBuffer.log(
TAG,
@@ -297,7 +311,7 @@
"screen layout=${toScreenLayoutString(long1.toInt())} " +
"(was ${toScreenLayoutString(long2.toInt())}), " +
"splitShade=$bool2 (was $bool1)"
- }
+ },
)
}
@@ -305,7 +319,7 @@
after: Boolean,
before: Boolean,
force: Boolean,
- containerName: String
+ containerName: String,
) {
buffer.log(
TAG,
@@ -316,7 +330,7 @@
bool2 = before
bool3 = force
},
- { "change tile layout: $str1 horizontal=$bool1 (was $bool2), force? $bool3" }
+ { "change tile layout: $str1 horizontal=$bool1 (was $bool2), force? $bool3" },
)
}
@@ -328,7 +342,7 @@
int1 = tilesPerPageCount
int2 = totalTilesCount
},
- { "Distributing tiles: [tilesPerPageCount=$int1] [totalTilesCount=$int2]" }
+ { "Distributing tiles: [tilesPerPageCount=$int1] [totalTilesCount=$int2]" },
)
}
@@ -340,7 +354,7 @@
str1 = tileName
int1 = pageIndex
},
- { "Adding $str1 to page number $int1" }
+ { "Adding $str1 to page number $int1" },
)
}
@@ -361,7 +375,7 @@
str1 = viewName
str2 = toVisibilityString(visibility)
},
- { "$str1 visibility: $str2" }
+ { "$str1 visibility: $str2" },
)
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java
index 5ea8c21..a4f3c7a 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java
@@ -14,6 +14,7 @@
package com.android.systemui.qs.tileimpl;
+import static com.android.systemui.Flags.qsNewTiles;
import static com.android.systemui.Flags.removeUpdateListenerInQsIconViewImpl;
import android.animation.Animator;
@@ -66,12 +67,22 @@
private ValueAnimator mColorAnimator = new ValueAnimator();
+ private int mColorUnavailable;
+ private int mColorInactive;
+ private int mColorActive;
+
public QSIconViewImpl(Context context) {
super(context);
final Resources res = context.getResources();
mIconSizePx = res.getDimensionPixelSize(R.dimen.qs_icon_size);
+ if (qsNewTiles()) { // pre-load icon tint colors
+ mColorUnavailable = Utils.getColorAttrDefaultColor(context, R.attr.outline);
+ mColorInactive = Utils.getColorAttrDefaultColor(context, R.attr.onShadeInactiveVariant);
+ mColorActive = Utils.getColorAttrDefaultColor(context, R.attr.onShadeActive);
+ }
+
mIcon = createIcon();
addView(mIcon);
mColorAnimator.setDuration(QS_ANIM_LENGTH);
@@ -195,7 +206,11 @@
}
protected int getColor(QSTile.State state) {
- return getIconColorForState(getContext(), state);
+ if (qsNewTiles()) {
+ return getCachedIconColorForState(state);
+ } else {
+ return getIconColorForState(getContext(), state);
+ }
}
private void animateGrayScale(int fromColor, int toColor, ImageView iv,
@@ -267,6 +282,19 @@
}
}
+ private int getCachedIconColorForState(QSTile.State state) {
+ if (state.disabledByPolicy || state.state == Tile.STATE_UNAVAILABLE) {
+ return mColorUnavailable;
+ } else if (state.state == Tile.STATE_INACTIVE) {
+ return mColorInactive;
+ } else if (state.state == Tile.STATE_ACTIVE) {
+ return mColorActive;
+ } else {
+ Log.e("QSIconView", "Invalid state " + state);
+ return 0;
+ }
+ }
+
private static class EndRunnableAnimatorListener extends AnimatorListenerAdapter {
private Runnable mRunnable;
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt
index 4f3ea83..18b1f07 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt
@@ -643,7 +643,6 @@
}
// HANDLE STATE CHANGES RELATED METHODS
-
protected open fun handleStateChanged(state: QSTile.State) {
val allowAnimations = animationsEnabled()
isClickable = state.state != Tile.STATE_UNAVAILABLE
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapper.kt
index 8965ef2..bb0b9b7 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapper.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapper.kt
@@ -18,7 +18,9 @@
import android.content.Context
import android.content.res.Resources
+import android.os.Handler
import android.widget.Switch
+import com.android.settingslib.graph.SignalDrawable
import com.android.systemui.common.shared.model.ContentDescription.Companion.loadContentDescription
import com.android.systemui.common.shared.model.Icon
import com.android.systemui.common.shared.model.Text.Companion.loadText
@@ -28,6 +30,7 @@
import com.android.systemui.qs.tiles.viewmodel.QSTileConfig
import com.android.systemui.qs.tiles.viewmodel.QSTileState
import com.android.systemui.res.R
+import com.android.systemui.statusbar.pipeline.shared.ui.model.InternetTileIconModel
import javax.inject.Inject
/** Maps [InternetTileModel] to [QSTileState]. */
@@ -37,6 +40,7 @@
@Main private val resources: Resources,
private val theme: Resources.Theme,
private val context: Context,
+ @Main private val handler: Handler,
) : QSTileDataToStateMapper<InternetTileModel> {
override fun map(config: QSTileConfig, data: InternetTileModel): QSTileState =
@@ -44,25 +48,42 @@
label = resources.getString(R.string.quick_settings_internet_label)
expandedAccessibilityClass = Switch::class
- if (data.secondaryLabel != null) {
- secondaryLabel = data.secondaryLabel.loadText(context)
- } else {
- secondaryLabel = data.secondaryTitle
- }
+ secondaryLabel =
+ if (data.secondaryLabel != null) {
+ data.secondaryLabel.loadText(context)
+ } else {
+ data.secondaryTitle
+ }
stateDescription = data.stateDescription.loadContentDescription(context)
contentDescription = data.contentDescription.loadContentDescription(context)
- iconRes = data.iconId
- if (data.icon != null) {
- this.icon = { data.icon }
- } else if (data.iconId != null) {
- val loadedIcon =
- Icon.Loaded(
- resources.getDrawable(data.iconId!!, theme),
- contentDescription = null
- )
- this.icon = { loadedIcon }
+ when (val dataIcon = data.icon) {
+ is InternetTileIconModel.ResourceId -> {
+ iconRes = dataIcon.resId
+ icon = {
+ Icon.Loaded(
+ resources.getDrawable(dataIcon.resId, theme),
+ contentDescription = null,
+ )
+ }
+ }
+
+ is InternetTileIconModel.Cellular -> {
+ val signalDrawable = SignalDrawable(context, handler)
+ signalDrawable.setLevel(dataIcon.level)
+ icon = { Icon.Loaded(signalDrawable, contentDescription = null) }
+ }
+
+ is InternetTileIconModel.Satellite -> {
+ iconRes = dataIcon.resourceIcon.res // level is inferred from res
+ icon = {
+ Icon.Loaded(
+ resources.getDrawable(dataIcon.resourceIcon.res, theme),
+ contentDescription = null,
+ )
+ }
+ }
}
sideViewIcon = QSTileState.SideViewIcon.Chevron
@@ -75,7 +96,7 @@
setOf(
QSTileState.UserAction.CLICK,
QSTileState.UserAction.TOGGLE_CLICK,
- QSTileState.UserAction.LONG_CLICK
+ QSTileState.UserAction.LONG_CLICK,
)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileDataInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileDataInteractor.kt
index 204ead3..6fe3979 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileDataInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileDataInteractor.kt
@@ -20,13 +20,10 @@
import android.content.Context
import android.os.UserHandle
import android.text.Html
-import com.android.settingslib.graph.SignalDrawable
import com.android.systemui.common.shared.model.ContentDescription
import com.android.systemui.common.shared.model.ContentDescription.Companion.loadContentDescription
-import com.android.systemui.common.shared.model.Icon
import com.android.systemui.common.shared.model.Text
import com.android.systemui.dagger.qualifiers.Application
-import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.qs.tiles.base.interactor.DataUpdateTrigger
import com.android.systemui.qs.tiles.base.interactor.QSTileDataInteractor
import com.android.systemui.qs.tiles.impl.internet.domain.model.InternetTileModel
@@ -36,12 +33,12 @@
import com.android.systemui.statusbar.pipeline.mobile.domain.interactor.MobileIconsInteractor
import com.android.systemui.statusbar.pipeline.mobile.domain.model.SignalIconModel
import com.android.systemui.statusbar.pipeline.shared.data.repository.ConnectivityRepository
+import com.android.systemui.statusbar.pipeline.shared.ui.model.InternetTileIconModel
import com.android.systemui.statusbar.pipeline.wifi.domain.interactor.WifiInteractor
import com.android.systemui.statusbar.pipeline.wifi.shared.model.WifiNetworkModel
import com.android.systemui.statusbar.pipeline.wifi.ui.model.WifiIcon
import com.android.systemui.utils.coroutines.flow.mapLatestConflated
import javax.inject.Inject
-import kotlin.coroutines.CoroutineContext
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
@@ -51,7 +48,6 @@
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.stateIn
-import kotlinx.coroutines.withContext
@OptIn(ExperimentalCoroutinesApi::class)
/** Observes internet state changes providing the [InternetTileModel]. */
@@ -59,7 +55,6 @@
@Inject
constructor(
private val context: Context,
- @Main private val mainCoroutineContext: CoroutineContext,
@Application private val scope: CoroutineScope,
airplaneModeRepository: AirplaneModeRepository,
private val connectivityRepository: ConnectivityRepository,
@@ -79,8 +74,7 @@
flowOf(
InternetTileModel.Active(
secondaryTitle = secondary,
- iconId = wifiIcon.icon.res,
- icon = Icon.Loaded(context.getDrawable(wifiIcon.icon.res)!!, null),
+ icon = InternetTileIconModel.ResourceId(wifiIcon.icon.res),
stateDescription = wifiIcon.contentDescription,
contentDescription = ContentDescription.Loaded("$internetLabel,$secondary"),
)
@@ -116,11 +110,10 @@
if (it == null) {
notConnectedFlow
} else {
- combine(
- it.networkName,
- it.signalLevelIcon,
- mobileDataContentName,
- ) { networkNameModel, signalIcon, dataContentDescription ->
+ combine(it.networkName, it.signalLevelIcon, mobileDataContentName) {
+ networkNameModel,
+ signalIcon,
+ dataContentDescription ->
Triple(networkNameModel, signalIcon, dataContentDescription)
}
.mapLatestConflated { (networkNameModel, signalIcon, dataContentDescription) ->
@@ -129,17 +122,12 @@
val secondary =
mobileDataContentConcat(
networkNameModel.name,
- dataContentDescription
+ dataContentDescription,
)
- val drawable =
- withContext(mainCoroutineContext) { SignalDrawable(context) }
- drawable.setLevel(signalIcon.level)
- val loadedIcon = Icon.Loaded(drawable, null)
-
InternetTileModel.Active(
secondaryTitle = secondary,
- icon = loadedIcon,
+ icon = InternetTileIconModel.Cellular(signalIcon.level),
stateDescription =
ContentDescription.Loaded(secondary.toString()),
contentDescription = ContentDescription.Loaded(internetLabel),
@@ -150,9 +138,10 @@
signalIcon.icon.contentDescription.loadContentDescription(
context
)
+
InternetTileModel.Active(
secondaryTitle = secondary,
- iconId = signalIcon.icon.res,
+ icon = InternetTileIconModel.Satellite(signalIcon.icon),
stateDescription = ContentDescription.Loaded(secondary),
contentDescription = ContentDescription.Loaded(internetLabel),
)
@@ -164,7 +153,7 @@
private fun mobileDataContentConcat(
networkName: String?,
- dataContentDescription: CharSequence?
+ dataContentDescription: CharSequence?,
): CharSequence {
if (dataContentDescription == null) {
return networkName ?: ""
@@ -177,9 +166,9 @@
context.getString(
R.string.mobile_carrier_text_format,
networkName,
- dataContentDescription
+ dataContentDescription,
),
- 0
+ 0,
)
}
@@ -199,7 +188,7 @@
flowOf(
InternetTileModel.Active(
secondaryLabel = secondary?.toText(),
- iconId = it.res,
+ icon = InternetTileIconModel.ResourceId(it.res),
stateDescription = null,
contentDescription = secondary,
)
@@ -208,16 +197,18 @@
}
private val notConnectedFlow: StateFlow<InternetTileModel> =
- combine(
- wifiInteractor.areNetworksAvailable,
- airplaneModeRepository.isAirplaneMode,
- ) { networksAvailable, isAirplaneMode ->
+ combine(wifiInteractor.areNetworksAvailable, airplaneModeRepository.isAirplaneMode) {
+ networksAvailable,
+ isAirplaneMode ->
when {
isAirplaneMode -> {
val secondary = context.getString(R.string.status_bar_airplane)
InternetTileModel.Inactive(
secondaryTitle = secondary,
- iconId = R.drawable.ic_qs_no_internet_unavailable,
+ icon =
+ InternetTileIconModel.ResourceId(
+ R.drawable.ic_qs_no_internet_unavailable
+ ),
stateDescription = null,
contentDescription = ContentDescription.Loaded(secondary),
)
@@ -227,10 +218,13 @@
context.getString(R.string.quick_settings_networks_available)
InternetTileModel.Inactive(
secondaryTitle = secondary,
- iconId = R.drawable.ic_qs_no_internet_available,
+ icon =
+ InternetTileIconModel.ResourceId(
+ R.drawable.ic_qs_no_internet_available
+ ),
stateDescription = null,
contentDescription =
- ContentDescription.Loaded("$internetLabel,$secondary")
+ ContentDescription.Loaded("$internetLabel,$secondary"),
)
}
else -> {
@@ -248,7 +242,7 @@
*/
override fun tileData(
user: UserHandle,
- triggers: Flow<DataUpdateTrigger>
+ triggers: Flow<DataUpdateTrigger>,
): Flow<InternetTileModel> =
connectivityRepository.defaultConnections.flatMapLatest {
when {
@@ -265,7 +259,7 @@
val NOT_CONNECTED_NETWORKS_UNAVAILABLE =
InternetTileModel.Inactive(
secondaryLabel = Text.Resource(R.string.quick_settings_networks_unavailable),
- iconId = R.drawable.ic_qs_no_internet_unavailable,
+ icon = InternetTileIconModel.ResourceId(R.drawable.ic_qs_no_internet_unavailable),
stateDescription = null,
contentDescription =
ContentDescription.Resource(R.string.quick_settings_networks_unavailable),
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/internet/domain/model/InternetTileModel.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/internet/domain/model/InternetTileModel.kt
index ece90461..15b4e47 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/internet/domain/model/InternetTileModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/internet/domain/model/InternetTileModel.kt
@@ -17,23 +17,21 @@
package com.android.systemui.qs.tiles.impl.internet.domain.model
import com.android.systemui.common.shared.model.ContentDescription
-import com.android.systemui.common.shared.model.Icon
import com.android.systemui.common.shared.model.Text
+import com.android.systemui.statusbar.pipeline.shared.ui.model.InternetTileIconModel
/** Model describing the state that the QS Internet tile should be in. */
sealed interface InternetTileModel {
val secondaryTitle: CharSequence?
val secondaryLabel: Text?
- val iconId: Int?
- val icon: Icon?
+ val icon: InternetTileIconModel
val stateDescription: ContentDescription?
val contentDescription: ContentDescription?
data class Active(
override val secondaryTitle: CharSequence? = null,
override val secondaryLabel: Text? = null,
- override val iconId: Int? = null,
- override val icon: Icon? = null,
+ override val icon: InternetTileIconModel = InternetTileIconModel.Cellular(1),
override val stateDescription: ContentDescription? = null,
override val contentDescription: ContentDescription? = null,
) : InternetTileModel
@@ -41,8 +39,7 @@
data class Inactive(
override val secondaryTitle: CharSequence? = null,
override val secondaryLabel: Text? = null,
- override val iconId: Int? = null,
- override val icon: Icon? = null,
+ override val icon: InternetTileIconModel = InternetTileIconModel.Cellular(1),
override val stateDescription: ContentDescription? = null,
override val contentDescription: ContentDescription? = null,
) : InternetTileModel
diff --git a/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayContentViewModel.kt b/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayContentViewModel.kt
index 7c8fbea..afb9a78 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayContentViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayContentViewModel.kt
@@ -16,10 +16,18 @@
package com.android.systemui.qs.ui.viewmodel
+import com.android.systemui.lifecycle.ExclusiveActivatable
+import com.android.systemui.scene.domain.interactor.SceneInteractor
+import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.shade.ui.viewmodel.ShadeHeaderViewModel
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
+import kotlinx.coroutines.awaitCancellation
+import kotlinx.coroutines.coroutineScope
+import kotlinx.coroutines.flow.distinctUntilChanged
+import kotlinx.coroutines.flow.filter
+import kotlinx.coroutines.launch
/**
* Models UI state used to render the content of the quick settings shade overlay.
@@ -31,11 +39,42 @@
@AssistedInject
constructor(
val shadeInteractor: ShadeInteractor,
+ val sceneInteractor: SceneInteractor,
val shadeHeaderViewModelFactory: ShadeHeaderViewModel.Factory,
val quickSettingsContainerViewModel: QuickSettingsContainerViewModel,
-) {
+) : ExclusiveActivatable() {
+
+ override suspend fun onActivated(): Nothing {
+ coroutineScope {
+ launch {
+ sceneInteractor.currentScene.collect { currentScene ->
+ when (currentScene) {
+ // TODO(b/369513770): The ShadeSession should be preserved in this scenario.
+ Scenes.Bouncer ->
+ shadeInteractor.collapseQuickSettingsShade(
+ loggingReason = "bouncer shown while shade is open"
+ )
+ }
+ }
+ }
+
+ launch {
+ shadeInteractor.isShadeTouchable
+ .distinctUntilChanged()
+ .filter { !it }
+ .collect {
+ shadeInteractor.collapseQuickSettingsShade(
+ loggingReason = "device became non-interactive"
+ )
+ }
+ }
+ }
+
+ awaitCancellation()
+ }
+
fun onScrimClicked() {
- shadeInteractor.collapseQuickSettingsShade(loggingReason = "Shade scrim clicked")
+ shadeInteractor.collapseQuickSettingsShade(loggingReason = "shade scrim clicked")
}
@AssistedFactory
diff --git a/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingService.kt b/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingService.kt
index a5f4a89..4d2bc91 100644
--- a/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingService.kt
+++ b/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingService.kt
@@ -61,11 +61,11 @@
uiEventLogger,
notificationManager,
userContextProvider,
- keyguardDismissUtil
+ keyguardDismissUtil,
) {
- private val commandHandler =
- IssueRecordingServiceCommandHandler(
+ private val session =
+ IssueRecordingServiceSession(
bgExecutor,
dialogTransitionAnimator,
panelInteractor,
@@ -86,7 +86,7 @@
Log.d(getTag(), "handling action: ${intent?.action}")
when (intent?.action) {
ACTION_START -> {
- commandHandler.handleStartCommand()
+ session.start()
if (!issueRecordingState.recordScreen) {
// If we don't want to record the screen, the ACTION_SHOW_START_NOTIF action
// will circumvent the RecordingService's screen recording start code.
@@ -94,12 +94,12 @@
}
}
ACTION_STOP,
- ACTION_STOP_NOTIF -> commandHandler.handleStopCommand(contentResolver)
+ ACTION_STOP_NOTIF -> session.stop(contentResolver)
ACTION_SHARE -> {
- commandHandler.handleShareCommand(
+ session.share(
intent.getIntExtra(EXTRA_NOTIFICATION_ID, mNotificationId),
intent.getParcelableExtra(EXTRA_PATH, Uri::class.java),
- this
+ this,
)
// Unlike all other actions, action_share has different behavior for the screen
// recording qs tile than it does for the record issue qs tile. Return sticky to
diff --git a/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingServiceCommandHandler.kt b/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingServiceSession.kt
similarity index 88%
rename from packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingServiceCommandHandler.kt
rename to packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingServiceSession.kt
index 32de0f3..e4d3e6c 100644
--- a/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingServiceCommandHandler.kt
+++ b/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingServiceSession.kt
@@ -34,9 +34,11 @@
/**
* This class exists to unit test the business logic encapsulated in IssueRecordingService. Android
* specifically calls out that there is no supported way to test IntentServices here:
- * https://developer.android.com/training/testing/other-components/services
+ * https://developer.android.com/training/testing/other-components/services, and mentions that the
+ * best way to add unit tests, is to introduce a separate class containing the business logic of
+ * that service, and test the functionality via that class.
*/
-class IssueRecordingServiceCommandHandler(
+class IssueRecordingServiceSession(
private val bgExecutor: Executor,
private val dialogTransitionAnimator: DialogTransitionAnimator,
private val panelInteractor: PanelInteractor,
@@ -47,12 +49,12 @@
private val userContextProvider: UserContextProvider,
) {
- fun handleStartCommand() {
+ fun start() {
bgExecutor.execute { traceurMessageSender.startTracing(issueRecordingState.traceConfig) }
issueRecordingState.isRecording = true
}
- fun handleStopCommand(contentResolver: ContentResolver) {
+ fun stop(contentResolver: ContentResolver) {
bgExecutor.execute {
if (issueRecordingState.traceConfig.longTrace) {
Settings.Global.putInt(contentResolver, NOTIFY_SESSION_ENDED_SETTING, DISABLED)
@@ -62,12 +64,12 @@
issueRecordingState.isRecording = false
}
- fun handleShareCommand(notificationId: Int, screenRecording: Uri?, context: Context) {
+ fun share(notificationId: Int, screenRecording: Uri?, context: Context) {
bgExecutor.execute {
notificationManager.cancelAsUser(
null,
notificationId,
- UserHandle(userContextProvider.userContext.userId)
+ UserHandle(userContextProvider.userContext.userId),
)
if (issueRecordingState.takeBugreport) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/RemoteInputCoordinator.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/RemoteInputCoordinator.kt
index 5ff5d2d..1fe32c9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/RemoteInputCoordinator.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/RemoteInputCoordinator.kt
@@ -117,18 +117,12 @@
(entry.getSbn().getNotification().flags and
FLAG_LIFETIME_EXTENDED_BY_DIRECT_REPLY) > 0
) {
+ // If we've received an update from the system and the entry is marked
+ // as lifetime extended, that means system server has received a
+ // cancelation in response to a direct reply, and sent an update to
+ // let system ui know that it should rebuild the notification with
+ // that direct reply.
if (
- mNotificationRemoteInputManager.shouldKeepForRemoteInputHistory(
- entry
- )
- ) {
- val newSbn = mRebuilder.rebuildForRemoteInputReply(entry)
- entry.onRemoteInputInserted()
- mNotifUpdater.onInternalNotificationUpdate(
- newSbn,
- "Extending lifetime of notification with remote input",
- )
- } else if (
mNotificationRemoteInputManager.shouldKeepForSmartReplyHistory(
entry
)
@@ -140,16 +134,11 @@
"Extending lifetime of notification with smart reply",
)
} else {
- // The app may have re-cancelled a notification after it had already
- // been lifetime extended.
- // Rebuild the notification with the replies it already had to
- // ensure
- // those replies continue to be displayed.
- val newSbn = mRebuilder.rebuildWithExistingReplies(entry)
+ val newSbn = mRebuilder.rebuildForRemoteInputReply(entry)
+ entry.onRemoteInputInserted()
mNotifUpdater.onInternalNotificationUpdate(
newSbn,
- "Extending lifetime of notification that has already been " +
- "lifetime extended.",
+ "Extending lifetime of notification with remote input",
)
}
} else {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/model/InternetTileIconModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/model/InternetTileIconModel.kt
new file mode 100644
index 0000000..f8958e0
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/model/InternetTileIconModel.kt
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.statusbar.pipeline.shared.ui.model
+
+import com.android.systemui.common.shared.model.Icon
+
+sealed interface InternetTileIconModel {
+ data class ResourceId(val resId: Int) : InternetTileIconModel
+
+ data class Cellular(val level: Int) : InternetTileIconModel
+
+ data class Satellite(val resourceIcon: Icon.Resource) : InternetTileIconModel
+}
diff --git a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/view/TouchpadTutorialActivity.kt b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/view/TouchpadTutorialActivity.kt
index d03b2e7..e1f7bd5 100644
--- a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/view/TouchpadTutorialActivity.kt
+++ b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/view/TouchpadTutorialActivity.kt
@@ -29,6 +29,7 @@
import com.android.compose.theme.PlatformTheme
import com.android.systemui.inputdevice.tutorial.InputDeviceTutorialLogger
import com.android.systemui.inputdevice.tutorial.InputDeviceTutorialLogger.TutorialContext
+import com.android.systemui.inputdevice.tutorial.KeyboardTouchpadTutorialMetricsLogger
import com.android.systemui.touchpad.tutorial.ui.composable.BackGestureTutorialScreen
import com.android.systemui.touchpad.tutorial.ui.composable.HomeGestureTutorialScreen
import com.android.systemui.touchpad.tutorial.ui.composable.RecentAppsGestureTutorialScreen
@@ -45,6 +46,7 @@
constructor(
private val viewModelFactory: TouchpadTutorialViewModel.Factory,
private val logger: InputDeviceTutorialLogger,
+ private val metricsLogger: KeyboardTouchpadTutorialMetricsLogger,
) : ComponentActivity() {
private val vm by viewModels<TouchpadTutorialViewModel>(factoryProducer = { viewModelFactory })
@@ -57,6 +59,7 @@
}
// required to handle 3+ fingers on touchpad
window.addPrivateFlags(WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY)
+ metricsLogger.logPeripheralTutorialLaunchedFromSettings()
logger.logOpenTutorial(TutorialContext.TOUCHPAD_TUTORIAL)
}
@@ -85,7 +88,7 @@
onBackTutorialClicked = { vm.goTo(BACK_GESTURE) },
onHomeTutorialClicked = { vm.goTo(HOME_GESTURE) },
onRecentAppsTutorialClicked = { vm.goTo(RECENT_APPS_GESTURE) },
- onDoneButtonClicked = closeTutorial
+ onDoneButtonClicked = closeTutorial,
)
BACK_GESTURE ->
BackGestureTutorialScreen(
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/RemoteInputCoordinatorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/RemoteInputCoordinatorTest.kt
index deb3fc1..a3f8452 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/RemoteInputCoordinatorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/RemoteInputCoordinatorTest.kt
@@ -15,8 +15,8 @@
*/
package com.android.systemui.statusbar.notification.collection.coordinator
-import android.app.Flags.lifetimeExtensionRefactor
import android.app.Flags.FLAG_LIFETIME_EXTENSION_REFACTOR
+import android.app.Flags.lifetimeExtensionRefactor
import android.app.Notification
import android.app.RemoteInputHistoryItem
import android.os.Handler
@@ -47,10 +47,10 @@
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock
-import org.mockito.Mockito.`when`
import org.mockito.Mockito.never
import org.mockito.Mockito.times
import org.mockito.Mockito.verify
+import org.mockito.Mockito.`when`
import org.mockito.MockitoAnnotations.initMocks
@SmallTest
@@ -78,21 +78,20 @@
@Before
fun setUp() {
initMocks(this)
- coordinator = RemoteInputCoordinator(
+ coordinator =
+ RemoteInputCoordinator(
dumpManager,
rebuilder,
remoteInputManager,
mainHandler,
- smartReplyController
- )
+ smartReplyController,
+ )
`when`(pipeline.addNotificationLifetimeExtender(any())).thenAnswer {
(it.arguments[0] as NotifLifetimeExtender).setCallback(lifetimeExtensionCallback)
}
`when`(pipeline.getInternalNotifUpdater(any())).thenReturn(notifUpdater)
coordinator.attach(pipeline)
- listener = withArgCaptor {
- verify(remoteInputManager).setRemoteInputListener(capture())
- }
+ listener = withArgCaptor { verify(remoteInputManager).setRemoteInputListener(capture()) }
entry1 = NotificationEntryBuilder().setId(1).build()
entry2 = NotificationEntryBuilder().setId(2).build()
`when`(rebuilder.rebuildForCanceledSmartReplies(any())).thenReturn(sbn)
@@ -101,13 +100,17 @@
`when`(rebuilder.rebuildWithExistingReplies(any())).thenReturn(sbn)
}
- val remoteInputActiveExtender get() = coordinator.mRemoteInputActiveExtender
- val remoteInputHistoryExtender get() = coordinator.mRemoteInputHistoryExtender
- val smartReplyHistoryExtender get() = coordinator.mSmartReplyHistoryExtender
+ val remoteInputActiveExtender
+ get() = coordinator.mRemoteInputActiveExtender
- val collectionListeners get() = captureMany {
- verify(pipeline, times(1)).addCollectionListener(capture())
- }
+ val remoteInputHistoryExtender
+ get() = coordinator.mRemoteInputHistoryExtender
+
+ val smartReplyHistoryExtender
+ get() = coordinator.mSmartReplyHistoryExtender
+
+ val collectionListeners
+ get() = captureMany { verify(pipeline, times(1)).addCollectionListener(capture()) }
@Test
fun testRemoteInputActive() {
@@ -179,7 +182,8 @@
@EnableFlags(FLAG_LIFETIME_EXTENSION_REFACTOR)
fun testRemoteInputLifetimeExtensionListenerTrigger() {
// Create notification with LIFETIME_EXTENDED_BY_DIRECT_REPLY flag.
- val entry = NotificationEntryBuilder()
+ val entry =
+ NotificationEntryBuilder()
.setId(3)
.setTag("entry")
.setFlag(mContext, Notification.FLAG_LIFETIME_EXTENDED_BY_DIRECT_REPLY, true)
@@ -187,9 +191,7 @@
`when`(remoteInputManager.shouldKeepForRemoteInputHistory(entry)).thenReturn(true)
`when`(remoteInputManager.shouldKeepForSmartReplyHistory(entry)).thenReturn(false)
- collectionListeners.forEach {
- it.onEntryUpdated(entry, true)
- }
+ collectionListeners.forEach { it.onEntryUpdated(entry, true) }
verify(rebuilder, times(1)).rebuildForRemoteInputReply(entry)
}
@@ -198,16 +200,15 @@
@EnableFlags(FLAG_LIFETIME_EXTENSION_REFACTOR)
fun testSmartReplyLifetimeExtensionListenerTrigger() {
// Create notification with LIFETIME_EXTENDED_BY_DIRECT_REPLY flag.
- val entry = NotificationEntryBuilder()
+ val entry =
+ NotificationEntryBuilder()
.setId(3)
.setTag("entry")
.setFlag(mContext, Notification.FLAG_LIFETIME_EXTENDED_BY_DIRECT_REPLY, true)
.build()
`when`(remoteInputManager.shouldKeepForRemoteInputHistory(entry)).thenReturn(false)
`when`(remoteInputManager.shouldKeepForSmartReplyHistory(entry)).thenReturn(true)
- collectionListeners.forEach {
- it.onEntryUpdated(entry, true)
- }
+ collectionListeners.forEach { it.onEntryUpdated(entry, true) }
verify(rebuilder, times(1)).rebuildForCanceledSmartReplies(entry)
verify(smartReplyController, times(1)).stopSending(entry)
@@ -217,25 +218,25 @@
@EnableFlags(FLAG_LIFETIME_EXTENSION_REFACTOR)
fun testRepeatedUpdateTriggersRebuild() {
// Create notification with LIFETIME_EXTENDED_BY_DIRECT_REPLY flag.
- val entry = NotificationEntryBuilder()
+ val entry =
+ NotificationEntryBuilder()
.setId(3)
.setTag("entry")
.setFlag(mContext, Notification.FLAG_LIFETIME_EXTENDED_BY_DIRECT_REPLY, true)
.build()
`when`(remoteInputManager.shouldKeepForRemoteInputHistory(entry)).thenReturn(false)
`when`(remoteInputManager.shouldKeepForSmartReplyHistory(entry)).thenReturn(false)
- collectionListeners.forEach {
- it.onEntryUpdated(entry, true)
- }
+ collectionListeners.forEach { it.onEntryUpdated(entry, true) }
- verify(rebuilder, times(1)).rebuildWithExistingReplies(entry)
+ verify(rebuilder, times(1)).rebuildForRemoteInputReply(entry)
}
@Test
@EnableFlags(FLAG_LIFETIME_EXTENSION_REFACTOR)
fun testLifetimeExtensionListenerClearsRemoteInputs() {
// Create notification with LIFETIME_EXTENDED_BY_DIRECT_REPLY flag.
- val entry = NotificationEntryBuilder()
+ val entry =
+ NotificationEntryBuilder()
.setId(3)
.setTag("entry")
.setFlag(mContext, Notification.FLAG_LIFETIME_EXTENDED_BY_DIRECT_REPLY, false)
@@ -245,9 +246,7 @@
`when`(remoteInputManager.shouldKeepForRemoteInputHistory(entry)).thenReturn(false)
`when`(remoteInputManager.shouldKeepForSmartReplyHistory(entry)).thenReturn(false)
- collectionListeners.forEach {
- it.onEntryUpdated(entry, true)
- }
+ collectionListeners.forEach { it.onEntryUpdated(entry, true) }
assertThat(entry.remoteInputs).isNull()
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayContentViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayContentViewModelKosmos.kt
index a80a409..6540ed6 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayContentViewModelKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayContentViewModelKosmos.kt
@@ -17,6 +17,7 @@
package com.android.systemui.qs.ui.viewmodel
import com.android.systemui.kosmos.Kosmos
+import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.shade.domain.interactor.shadeInteractor
import com.android.systemui.shade.ui.viewmodel.shadeHeaderViewModelFactory
@@ -24,6 +25,7 @@
Kosmos.Fixture {
QuickSettingsShadeOverlayContentViewModel(
shadeInteractor = shadeInteractor,
+ sceneInteractor = sceneInteractor,
shadeHeaderViewModelFactory = shadeHeaderViewModelFactory,
quickSettingsContainerViewModel = quickSettingsContainerViewModel,
)
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/shade/ui/viewmodel/NotificationsShadeOverlayContentViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/shade/ui/viewmodel/NotificationsShadeOverlayContentViewModelKosmos.kt
index 7a15fdf..718347f 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/shade/ui/viewmodel/NotificationsShadeOverlayContentViewModelKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/shade/ui/viewmodel/NotificationsShadeOverlayContentViewModelKosmos.kt
@@ -19,6 +19,7 @@
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.Kosmos.Fixture
import com.android.systemui.notifications.ui.viewmodel.NotificationsShadeOverlayContentViewModel
+import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.shade.domain.interactor.shadeInteractor
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.notificationsPlaceholderViewModelFactory
@@ -27,6 +28,7 @@
NotificationsShadeOverlayContentViewModel(
shadeHeaderViewModelFactory = shadeHeaderViewModelFactory,
notificationsPlaceholderViewModelFactory = notificationsPlaceholderViewModelFactory,
+ sceneInteractor = sceneInteractor,
shadeInteractor = shadeInteractor,
)
}
diff --git a/services/core/java/com/android/server/inputmethod/HardwareKeyboardShortcutController.java b/services/core/java/com/android/server/inputmethod/HardwareKeyboardShortcutController.java
index 41313fa..ef1220f 100644
--- a/services/core/java/com/android/server/inputmethod/HardwareKeyboardShortcutController.java
+++ b/services/core/java/com/android/server/inputmethod/HardwareKeyboardShortcutController.java
@@ -33,9 +33,6 @@
@GuardedBy("ImfLock.class")
private final ArrayList<InputMethodSubtypeHandle> mSubtypeHandles = new ArrayList<>();
- HardwareKeyboardShortcutController() {
- }
-
@GuardedBy("ImfLock.class")
void update(@NonNull InputMethodSettings settings) {
mSubtypeHandles.clear();
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodDeviceConfigs.java b/services/core/java/com/android/server/inputmethod/InputMethodDeviceConfigs.java
index 6cd2493..fc4c0fc 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodDeviceConfigs.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodDeviceConfigs.java
@@ -40,6 +40,7 @@
if (KEY_HIDE_IME_WHEN_NO_EDITOR_FOCUS.equals(name)) {
mHideImeWhenNoEditorFocus = properties.getBoolean(name,
true /* defaultValue */);
+ break;
}
}
};
diff --git a/services/core/java/com/android/server/inputmethod/ZeroJankProxy.java b/services/core/java/com/android/server/inputmethod/ZeroJankProxy.java
index 214aa1d..49d4332 100644
--- a/services/core/java/com/android/server/inputmethod/ZeroJankProxy.java
+++ b/services/core/java/com/android/server/inputmethod/ZeroJankProxy.java
@@ -394,6 +394,7 @@
flags),
this::offload).get();
} catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
throw new RuntimeException(e);
} catch (ExecutionException e) {
throw new RuntimeException(e);
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index 86bb75a..14f034b 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -66,6 +66,7 @@
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_LOCKTASK;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_STATES;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_TASKS;
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_WINDOW_TRANSITIONS_MIN;
import static com.android.server.wm.ActivityRecord.State.PAUSED;
import static com.android.server.wm.ActivityRecord.State.PAUSING;
import static com.android.server.wm.ActivityRecord.State.RESUMED;
@@ -6177,6 +6178,8 @@
void maybeApplyLastRecentsAnimationTransaction() {
if (mLastRecentsAnimationTransaction != null) {
+ ProtoLog.d(WM_DEBUG_WINDOW_TRANSITIONS_MIN,
+ "Applying last recents animation transaction.");
final SurfaceControl.Transaction tx = getPendingTransaction();
if (mLastRecentsAnimationOverlay != null) {
tx.reparent(mLastRecentsAnimationOverlay, mSurfaceControl);
diff --git a/services/tests/RemoteProvisioningServiceTests/Android.bp b/services/tests/RemoteProvisioningServiceTests/Android.bp
index 19c9136..3a73c39 100644
--- a/services/tests/RemoteProvisioningServiceTests/Android.bp
+++ b/services/tests/RemoteProvisioningServiceTests/Android.bp
@@ -31,7 +31,6 @@
"service-rkp.impl",
"services.core",
"truth",
- "truth-java8-extension",
],
test_suites: [
"device-tests",
diff --git a/services/tests/RemoteProvisioningServiceTests/src/com/android/server/security/rkp/RemoteProvisioningShellCommandTest.java b/services/tests/RemoteProvisioningServiceTests/src/com/android/server/security/rkp/RemoteProvisioningShellCommandTest.java
index 007c0db..a1616c6 100644
--- a/services/tests/RemoteProvisioningServiceTests/src/com/android/server/security/rkp/RemoteProvisioningShellCommandTest.java
+++ b/services/tests/RemoteProvisioningServiceTests/src/com/android/server/security/rkp/RemoteProvisioningShellCommandTest.java
@@ -17,7 +17,6 @@
package com.android.server.security.rkp;
import static com.google.common.truth.Truth.assertThat;
-import static com.google.common.truth.Truth8.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
diff --git a/services/tests/appfunctions/src/android/app/appfunctions/GenericDocumentWrapperTest.kt b/services/tests/appfunctions/src/android/app/appfunctions/GenericDocumentWrapperTest.kt
new file mode 100644
index 0000000..413eb31
--- /dev/null
+++ b/services/tests/appfunctions/src/android/app/appfunctions/GenericDocumentWrapperTest.kt
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.app.appfunctions
+
+import android.app.appsearch.GenericDocument
+import android.os.Parcel
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+
+@RunWith(JUnit4::class)
+class GenericDocumentWrapperTest {
+
+ @Test
+ fun parcelUnparcel() {
+ val doc =
+ GenericDocument.Builder<GenericDocument.Builder<*>>("", "", "")
+ .setPropertyLong("test", 42)
+ .build()
+ val wrapper = GenericDocumentWrapper(doc)
+
+ val recovered = parcelUnparcel(wrapper)
+
+ assertThat(recovered.value.getPropertyLong("test")).isEqualTo(42)
+ }
+
+ @Test
+ fun parcelUnparcel_afterGetValue() {
+ val doc =
+ GenericDocument.Builder<GenericDocument.Builder<*>>("", "", "")
+ .setPropertyLong("test", 42)
+ .build()
+ val wrapper = GenericDocumentWrapper(doc)
+ assertThat(wrapper.value.getPropertyLong("test")).isEqualTo(42)
+
+ val recovered = parcelUnparcel(wrapper)
+
+ assertThat(recovered.value.getPropertyLong("test")).isEqualTo(42)
+ }
+
+
+ @Test
+ fun getValue() {
+ val doc =
+ GenericDocument.Builder<GenericDocument.Builder<*>>("", "", "")
+ .setPropertyLong("test", 42)
+ .build()
+ val wrapper = GenericDocumentWrapper(doc)
+
+ assertThat(wrapper.value.getPropertyLong("test")).isEqualTo(42)
+ }
+
+ private fun parcelUnparcel(obj: GenericDocumentWrapper): GenericDocumentWrapper {
+ val parcel = Parcel.obtain()
+ try {
+ obj.writeToParcel(parcel, 0)
+ parcel.setDataPosition(0)
+ return GenericDocumentWrapper.CREATOR.createFromParcel(parcel)
+ } finally {
+ parcel.recycle()
+ }
+ }
+}
\ No newline at end of file
diff --git a/services/tests/servicestests/src/com/android/server/locksettings/RebootEscrowManagerTests.java b/services/tests/servicestests/src/com/android/server/locksettings/RebootEscrowManagerTests.java
index d071c15..ae781dc 100644
--- a/services/tests/servicestests/src/com/android/server/locksettings/RebootEscrowManagerTests.java
+++ b/services/tests/servicestests/src/com/android/server/locksettings/RebootEscrowManagerTests.java
@@ -60,6 +60,7 @@
import android.os.ServiceSpecificException;
import android.os.UserManager;
import android.platform.test.annotations.Presubmit;
+import android.platform.test.annotations.RequiresFlagsDisabled;
import android.platform.test.annotations.RequiresFlagsEnabled;
import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
@@ -130,6 +131,7 @@
private SecretKey mAesKey;
private MockInjector mMockInjector;
private Handler mHandler;
+ private Network mNetwork;
public interface MockableRebootEscrowInjected {
int getBootCount();
@@ -342,6 +344,7 @@
when(mCallbacks.isUserSecure(NONSECURE_SECONDARY_USER_ID)).thenReturn(false);
when(mCallbacks.isUserSecure(SECURE_SECONDARY_USER_ID)).thenReturn(true);
mInjected = mock(MockableRebootEscrowInjected.class);
+ mNetwork = mock(Network.class);
mMockInjector =
new MockInjector(
mContext,
@@ -351,6 +354,10 @@
mKeyStoreManager,
mStorage,
mInjected);
+ mMockInjector.mNetworkConsumer =
+ (callback) -> {
+ callback.onAvailable(mNetwork);
+ };
HandlerThread thread = new HandlerThread("RebootEscrowManagerTest");
thread.start();
mHandler = new Handler(thread.getLooper());
@@ -367,6 +374,10 @@
mKeyStoreManager,
mStorage,
mInjected);
+ mMockInjector.mNetworkConsumer =
+ (callback) -> {
+ callback.onAvailable(mNetwork);
+ };
mService = new RebootEscrowManager(mMockInjector, mCallbacks, mStorage, mHandler);
}
@@ -621,7 +632,7 @@
// pretend reboot happens here
when(mInjected.getBootCount()).thenReturn(1);
- mService.loadRebootEscrowDataIfAvailable(null);
+ mService.loadRebootEscrowDataIfAvailable(mHandler);
verify(mServiceConnection, never()).unwrap(any(), anyLong());
verify(mCallbacks, never()).onRebootEscrowRestored(anyByte(), any(), anyInt());
}
@@ -678,7 +689,7 @@
when(mServiceConnection.unwrap(any(), anyLong()))
.thenAnswer(invocation -> invocation.getArgument(0));
- mService.loadRebootEscrowDataIfAvailable(null);
+ mService.loadRebootEscrowDataIfAvailable(mHandler);
verify(mServiceConnection).unwrap(any(), anyLong());
verify(mCallbacks).onRebootEscrowRestored(anyByte(), any(), eq(PRIMARY_USER_ID));
@@ -734,7 +745,7 @@
when(mServiceConnection.unwrap(any(), anyLong()))
.thenAnswer(invocation -> invocation.getArgument(0));
- mService.loadRebootEscrowDataIfAvailable(null);
+ mService.loadRebootEscrowDataIfAvailable(mHandler);
verify(mServiceConnection).unwrap(any(), anyLong());
verify(mCallbacks).onRebootEscrowRestored(anyByte(), any(), eq(PRIMARY_USER_ID));
@@ -783,7 +794,7 @@
when(mServiceConnection.unwrap(any(), anyLong()))
.thenAnswer(invocation -> invocation.getArgument(0));
- mService.loadRebootEscrowDataIfAvailable(null);
+ mService.loadRebootEscrowDataIfAvailable(mHandler);
verify(mServiceConnection).unwrap(any(), anyLong());
assertTrue(metricsSuccessCaptor.getValue());
verify(mKeyStoreManager).clearKeyStoreEncryptionKey();
@@ -827,7 +838,7 @@
anyInt());
when(mServiceConnection.unwrap(any(), anyLong())).thenThrow(RemoteException.class);
- mService.loadRebootEscrowDataIfAvailable(null);
+ mService.loadRebootEscrowDataIfAvailable(mHandler);
verify(mServiceConnection).unwrap(any(), anyLong());
assertFalse(metricsSuccessCaptor.getValue());
assertEquals(
@@ -836,6 +847,7 @@
}
@Test
+ @RequiresFlagsDisabled(Flags.FLAG_WAIT_FOR_INTERNET_ROR)
public void loadRebootEscrowDataIfAvailable_ServerBasedIoError_RetryFailure() throws Exception {
setServerBasedRebootEscrowProvider();
@@ -930,114 +942,6 @@
@Test
@RequiresFlagsEnabled(Flags.FLAG_WAIT_FOR_INTERNET_ROR)
- public void loadRebootEscrowDataIfAvailable_serverBasedWaitForInternet_success()
- throws Exception {
- setServerBasedRebootEscrowProvider();
-
- when(mInjected.getBootCount()).thenReturn(0);
- RebootEscrowListener mockListener = mock(RebootEscrowListener.class);
- mService.setRebootEscrowListener(mockListener);
- mService.prepareRebootEscrow();
-
- clearInvocations(mServiceConnection);
- callToRebootEscrowIfNeededAndWait(PRIMARY_USER_ID);
- verify(mockListener).onPreparedForReboot(eq(true));
- verify(mServiceConnection, never()).wrapBlob(any(), anyLong(), anyLong());
-
- // Use x -> x for both wrap & unwrap functions.
- when(mServiceConnection.wrapBlob(any(), anyLong(), anyLong()))
- .thenAnswer(invocation -> invocation.getArgument(0));
- assertEquals(ARM_REBOOT_ERROR_NONE, mService.armRebootEscrowIfNeeded());
- verify(mServiceConnection).wrapBlob(any(), anyLong(), anyLong());
- assertTrue(mStorage.hasRebootEscrowServerBlob());
-
- // pretend reboot happens here
- when(mInjected.getBootCount()).thenReturn(1);
- ArgumentCaptor<Boolean> metricsSuccessCaptor = ArgumentCaptor.forClass(Boolean.class);
- doNothing()
- .when(mInjected)
- .reportMetric(
- metricsSuccessCaptor.capture(),
- eq(0) /* error code */,
- eq(2) /* Server based */,
- eq(1) /* attempt count */,
- anyInt(),
- eq(0) /* vbmeta status */,
- anyInt());
-
- // load escrow data
- when(mServiceConnection.unwrap(any(), anyLong()))
- .thenAnswer(invocation -> invocation.getArgument(0));
- Network mockNetwork = mock(Network.class);
- mMockInjector.mNetworkConsumer =
- (callback) -> {
- callback.onAvailable(mockNetwork);
- };
-
- mService.loadRebootEscrowDataIfAvailable(mHandler);
- verify(mServiceConnection).unwrap(any(), anyLong());
- assertTrue(metricsSuccessCaptor.getValue());
- verify(mKeyStoreManager).clearKeyStoreEncryptionKey();
- assertNull(mMockInjector.mNetworkCallback);
- }
-
- @Test
- @RequiresFlagsEnabled(Flags.FLAG_WAIT_FOR_INTERNET_ROR)
- public void loadRebootEscrowDataIfAvailable_serverBasedWaitForInternetRemoteException_Failure()
- throws Exception {
- setServerBasedRebootEscrowProvider();
-
- when(mInjected.getBootCount()).thenReturn(0);
- RebootEscrowListener mockListener = mock(RebootEscrowListener.class);
- mService.setRebootEscrowListener(mockListener);
- mService.prepareRebootEscrow();
-
- clearInvocations(mServiceConnection);
- callToRebootEscrowIfNeededAndWait(PRIMARY_USER_ID);
- verify(mockListener).onPreparedForReboot(eq(true));
- verify(mServiceConnection, never()).wrapBlob(any(), anyLong(), anyLong());
-
- // Use x -> x for both wrap & unwrap functions.
- when(mServiceConnection.wrapBlob(any(), anyLong(), anyLong()))
- .thenAnswer(invocation -> invocation.getArgument(0));
- assertEquals(ARM_REBOOT_ERROR_NONE, mService.armRebootEscrowIfNeeded());
- verify(mServiceConnection).wrapBlob(any(), anyLong(), anyLong());
- assertTrue(mStorage.hasRebootEscrowServerBlob());
-
- // pretend reboot happens here
- when(mInjected.getBootCount()).thenReturn(1);
- ArgumentCaptor<Boolean> metricsSuccessCaptor = ArgumentCaptor.forClass(Boolean.class);
- ArgumentCaptor<Integer> metricsErrorCodeCaptor = ArgumentCaptor.forClass(Integer.class);
- doNothing()
- .when(mInjected)
- .reportMetric(
- metricsSuccessCaptor.capture(),
- metricsErrorCodeCaptor.capture(),
- eq(2) /* Server based */,
- eq(1) /* attempt count */,
- anyInt(),
- eq(0) /* vbmeta status */,
- anyInt());
-
- // load escrow data
- when(mServiceConnection.unwrap(any(), anyLong())).thenThrow(RemoteException.class);
- Network mockNetwork = mock(Network.class);
- mMockInjector.mNetworkConsumer =
- (callback) -> {
- callback.onAvailable(mockNetwork);
- };
-
- mService.loadRebootEscrowDataIfAvailable(mHandler);
- verify(mServiceConnection).unwrap(any(), anyLong());
- assertFalse(metricsSuccessCaptor.getValue());
- assertEquals(
- Integer.valueOf(RebootEscrowManager.ERROR_LOAD_ESCROW_KEY),
- metricsErrorCodeCaptor.getValue());
- assertNull(mMockInjector.mNetworkCallback);
- }
-
- @Test
- @RequiresFlagsEnabled(Flags.FLAG_WAIT_FOR_INTERNET_ROR)
public void loadRebootEscrowDataIfAvailable_waitForInternet_networkUnavailable()
throws Exception {
setServerBasedRebootEscrowProvider();
diff --git a/telephony/java/android/telephony/satellite/SatelliteManager.java b/telephony/java/android/telephony/satellite/SatelliteManager.java
index 4eefaac..bd5c759 100644
--- a/telephony/java/android/telephony/satellite/SatelliteManager.java
+++ b/telephony/java/android/telephony/satellite/SatelliteManager.java
@@ -1113,6 +1113,12 @@
* @hide
*/
public static final int DATAGRAM_TYPE_SMS = 6;
+ /**
+ * Datagram type indicating that the message to be sent is an SMS checking
+ * for pending incoming SMS.
+ * @hide
+ */
+ public static final int DATAGRAM_TYPE_CHECK_PENDING_INCOMING_SMS = 7;
/** @hide */
@IntDef(prefix = "DATAGRAM_TYPE_", value = {
@@ -1122,7 +1128,8 @@
DATAGRAM_TYPE_KEEP_ALIVE,
DATAGRAM_TYPE_LAST_SOS_MESSAGE_STILL_NEED_HELP,
DATAGRAM_TYPE_LAST_SOS_MESSAGE_NO_HELP_NEEDED,
- DATAGRAM_TYPE_SMS
+ DATAGRAM_TYPE_SMS,
+ DATAGRAM_TYPE_CHECK_PENDING_INCOMING_SMS
})
@Retention(RetentionPolicy.SOURCE)
public @interface DatagramType {}