Merge "Move UserController.dispatchOnBeforeUserSwitching to mHandler thread." into main
diff --git a/Android.bp b/Android.bp
index 811755d..d4776f5 100644
--- a/Android.bp
+++ b/Android.bp
@@ -170,12 +170,6 @@
//same purpose.
"//external/robolectric:__subpackages__",
"//frameworks/layoutlib:__subpackages__",
-
- // This is for the same purpose as robolectric -- to build "framework.jar" for host-side
- // testing.
- // TODO: Once Ravenwood is stable, move the host side jar targets to this directory,
- // and remove this line.
- "//frameworks/base/tools/hoststubgen:__subpackages__",
],
}
diff --git a/Ravenwood.bp b/Ravenwood.bp
index ec58210..2e038e0 100644
--- a/Ravenwood.bp
+++ b/Ravenwood.bp
@@ -12,256 +12,19 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-// We need this "trampoline" rule to force soong to give a host-side jar to
-// framework-minus-apex.ravenwood-base. Otherwise, soong would mix up the arch (?) and we'd get
-// a dex jar.
-java_library {
- name: "framework-minus-apex-for-hoststubgen",
- installable: false, // host only jar.
- static_libs: [
- "framework-minus-apex",
- ],
- sdk_version: "core_platform",
- visibility: ["//visibility:private"],
-}
-
-// Process framework-all with hoststubgen for Ravenwood.
-// This step takes several tens of seconds, so we manually shard it to multiple modules.
-// All the copies have to be kept in sync.
-// TODO: Do the sharding better, either by making hostsubgen support sharding natively, or
-// making a better build rule.
-
-genrule_defaults {
- name: "framework-minus-apex.ravenwood-base_defaults",
- defaults: ["ravenwood-internal-only-visibility-genrule"],
- tools: ["hoststubgen"],
- srcs: [
- ":framework-minus-apex-for-hoststubgen",
- ":ravenwood-framework-policies",
- ":ravenwood-standard-options",
- ":ravenwood-annotation-allowed-classes",
- ],
- out: [
- "ravenwood.jar",
- "hoststubgen_framework-minus-apex.log",
- ],
-}
-
-framework_minus_apex_cmd = "$(location hoststubgen) " +
- "@$(location :ravenwood-standard-options) " +
- "--debug-log $(location hoststubgen_framework-minus-apex.log) " +
- "--out-jar $(location ravenwood.jar) " +
- "--in-jar $(location :framework-minus-apex-for-hoststubgen) " +
- "--policy-override-file $(location :ravenwood-framework-policies) " +
- "--annotation-allowed-classes-file $(location :ravenwood-annotation-allowed-classes) "
-
-java_genrule {
- name: "framework-minus-apex.ravenwood-base_X0",
- defaults: ["framework-minus-apex.ravenwood-base_defaults"],
- cmd: framework_minus_apex_cmd + " --num-shards 10 --shard-index 0",
-}
-
-java_genrule {
- name: "framework-minus-apex.ravenwood-base_X1",
- defaults: ["framework-minus-apex.ravenwood-base_defaults"],
- cmd: framework_minus_apex_cmd + " --num-shards 10 --shard-index 1",
-}
-
-java_genrule {
- name: "framework-minus-apex.ravenwood-base_X2",
- defaults: ["framework-minus-apex.ravenwood-base_defaults"],
- cmd: framework_minus_apex_cmd + " --num-shards 10 --shard-index 2",
-}
-
-java_genrule {
- name: "framework-minus-apex.ravenwood-base_X3",
- defaults: ["framework-minus-apex.ravenwood-base_defaults"],
- cmd: framework_minus_apex_cmd + " --num-shards 10 --shard-index 3",
-}
-
-java_genrule {
- name: "framework-minus-apex.ravenwood-base_X4",
- defaults: ["framework-minus-apex.ravenwood-base_defaults"],
- cmd: framework_minus_apex_cmd + " --num-shards 10 --shard-index 4",
-}
-
-java_genrule {
- name: "framework-minus-apex.ravenwood-base_X5",
- defaults: ["framework-minus-apex.ravenwood-base_defaults"],
- cmd: framework_minus_apex_cmd + " --num-shards 10 --shard-index 5",
-}
-
-java_genrule {
- name: "framework-minus-apex.ravenwood-base_X6",
- defaults: ["framework-minus-apex.ravenwood-base_defaults"],
- cmd: framework_minus_apex_cmd + " --num-shards 10 --shard-index 6",
-}
-
-java_genrule {
- name: "framework-minus-apex.ravenwood-base_X7",
- defaults: ["framework-minus-apex.ravenwood-base_defaults"],
- cmd: framework_minus_apex_cmd + " --num-shards 10 --shard-index 7",
-}
-
-java_genrule {
- name: "framework-minus-apex.ravenwood-base_X8",
- defaults: ["framework-minus-apex.ravenwood-base_defaults"],
- cmd: framework_minus_apex_cmd + " --num-shards 10 --shard-index 8",
-}
-
-java_genrule {
- name: "framework-minus-apex.ravenwood-base_X9",
- defaults: ["framework-minus-apex.ravenwood-base_defaults"],
- cmd: framework_minus_apex_cmd + " --num-shards 10 --shard-index 9",
-}
-
-// Build framework-minus-apex.ravenwood-base without sharding.
-// We extract the various dump files from this one, rather than the sharded ones, because
-// some dumps use the output from other classes (e.g. base classes) which may not be in the
-// same shard. Also some of the dump files ("apis") may be slow even when sharded, because
-// the output contains the information from all the input classes, rather than the output classes.
-// Not using sharding is fine for this module because it's only used for collecting the
-// dump / stats files, which don't have to happen regularly.
-java_genrule {
- name: "framework-minus-apex.ravenwood-base_all",
- defaults: ["framework-minus-apex.ravenwood-base_defaults"],
- cmd: framework_minus_apex_cmd +
- "--stats-file $(location hoststubgen_framework-minus-apex_stats.csv) " +
- "--supported-api-list-file $(location hoststubgen_framework-minus-apex_apis.csv) " +
-
- "--gen-keep-all-file $(location hoststubgen_framework-minus-apex_keep_all.txt) " +
- "--gen-input-dump-file $(location hoststubgen_framework-minus-apex_dump.txt) ",
-
- out: [
- "hoststubgen_framework-minus-apex_keep_all.txt",
- "hoststubgen_framework-minus-apex_dump.txt",
- "hoststubgen_framework-minus-apex_stats.csv",
- "hoststubgen_framework-minus-apex_apis.csv",
- ],
-}
-
-// Marge all the sharded jars
-java_genrule {
- name: "framework-minus-apex.ravenwood",
- defaults: ["ravenwood-internal-only-visibility-java"],
- cmd: "$(location merge_zips) $(out) $(in)",
- tools: ["merge_zips"],
- srcs: [
- ":framework-minus-apex.ravenwood-base_X0{ravenwood.jar}",
- ":framework-minus-apex.ravenwood-base_X1{ravenwood.jar}",
- ":framework-minus-apex.ravenwood-base_X2{ravenwood.jar}",
- ":framework-minus-apex.ravenwood-base_X3{ravenwood.jar}",
- ":framework-minus-apex.ravenwood-base_X4{ravenwood.jar}",
- ":framework-minus-apex.ravenwood-base_X5{ravenwood.jar}",
- ":framework-minus-apex.ravenwood-base_X6{ravenwood.jar}",
- ":framework-minus-apex.ravenwood-base_X7{ravenwood.jar}",
- ":framework-minus-apex.ravenwood-base_X8{ravenwood.jar}",
- ":framework-minus-apex.ravenwood-base_X9{ravenwood.jar}",
- ],
- out: [
- "framework-minus-apex.ravenwood.jar",
- ],
-}
+// "framework-minus-apex" and "all-updatable-modules-system-stubs" are not
+// visible publicly. We re-export them to Ravenwood in this file.
java_library {
- name: "services.core-for-hoststubgen",
- installable: false, // host only jar.
- static_libs: [
- "services.core",
- ],
- sdk_version: "core_platform",
- visibility: ["//visibility:private"],
-}
-
-java_genrule {
- name: "services.core.ravenwood-base",
- tools: ["hoststubgen"],
- cmd: "$(location hoststubgen) " +
- "@$(location :ravenwood-standard-options) " +
-
- "--debug-log $(location hoststubgen_services.core.log) " +
- "--stats-file $(location hoststubgen_services.core_stats.csv) " +
- "--supported-api-list-file $(location hoststubgen_services.core_apis.csv) " +
-
- "--out-jar $(location ravenwood.jar) " +
-
- "--gen-keep-all-file $(location hoststubgen_services.core_keep_all.txt) " +
- "--gen-input-dump-file $(location hoststubgen_services.core_dump.txt) " +
-
- "--in-jar $(location :services.core-for-hoststubgen) " +
- "--policy-override-file $(location :ravenwood-services-policies) " +
- "--annotation-allowed-classes-file $(location :ravenwood-annotation-allowed-classes) ",
- srcs: [
- ":services.core-for-hoststubgen",
- ":ravenwood-services-policies",
- ":ravenwood-standard-options",
- ":ravenwood-annotation-allowed-classes",
- ],
- out: [
- "ravenwood.jar",
-
- // Following files are created just as FYI.
- "hoststubgen_services.core_keep_all.txt",
- "hoststubgen_services.core_dump.txt",
-
- "hoststubgen_services.core.log",
- "hoststubgen_services.core_stats.csv",
- "hoststubgen_services.core_apis.csv",
- ],
- defaults: ["ravenwood-internal-only-visibility-genrule"],
-}
-
-java_genrule {
- name: "services.core.ravenwood",
- defaults: ["ravenwood-internal-only-visibility-genrule"],
- cmd: "cp $(in) $(out)",
- srcs: [
- ":services.core.ravenwood-base{ravenwood.jar}",
- ],
- out: [
- "services.core.ravenwood.jar",
- ],
-}
-
-// TODO(b/313930116) This jarjar is a bit slow. We should use hoststubgen for renaming,
-// but services.core.ravenwood has complex dependencies, so it'll take more than
-// just using hoststubgen "rename"s.
-java_library {
- name: "services.core.ravenwood-jarjar",
- defaults: ["ravenwood-internal-only-visibility-java"],
+ name: "framework-minus-apex-for-host",
installable: false,
- static_libs: [
- "services.core.ravenwood",
- ],
- jarjar_rules: ":ravenwood-services-jarjar-rules",
+ static_libs: ["framework-minus-apex"],
+ visibility: ["//frameworks/base/ravenwood"],
}
-// Jars in "ravenwood-runtime" are set to the classpath, sorted alphabetically.
-// Rename some of the dependencies to make sure they're included in the intended order.
java_library {
- name: "100-framework-minus-apex.ravenwood",
- defaults: ["ravenwood-internal-only-visibility-java"],
- static_libs: [
- "framework-minus-apex.ravenwood",
- ],
- sdk_version: "core_platform",
- // See b/313930116. Jarjar is too slow on this jar. We use HostStubGen to do the rename.
- // jarjar_rules: ":ravenwood-framework-jarjar-rules",
-}
-
-java_genrule {
- // Use 200 to make sure it comes before the mainline stub ("all-updatable...").
- name: "200-kxml2-android",
- defaults: ["ravenwood-internal-only-visibility-genrule"],
- cmd: "cp $(in) $(out)",
- srcs: [":kxml2-android"],
- out: ["200-kxml2-android.jar"],
-}
-
-java_genrule {
- name: "z00-all-updatable-modules-system-stubs",
- defaults: ["ravenwood-internal-only-visibility-genrule"],
- cmd: "cp $(in) $(out)",
- srcs: [":all-updatable-modules-system-stubs"],
- out: ["z00-all-updatable-modules-system-stubs.jar"],
+ name: "all-updatable-modules-system-stubs-for-host",
+ installable: false,
+ static_libs: ["all-updatable-modules-system-stubs"],
+ visibility: ["//frameworks/base/ravenwood"],
}
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index 7781f88..10206f2 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -3489,41 +3489,41 @@
public static class VirtualDeviceManager.VirtualDevice implements java.lang.AutoCloseable {
method public void addActivityListener(@NonNull java.util.concurrent.Executor, @NonNull android.companion.virtual.VirtualDeviceManager.ActivityListener);
- method @FlaggedApi("android.companion.virtual.flags.dynamic_policy") @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void addActivityPolicyExemption(@NonNull android.content.ComponentName);
- method @FlaggedApi("android.companion.virtualdevice.flags.activity_control_api") @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void addActivityPolicyExemption(@NonNull android.companion.virtual.ActivityPolicyExemption);
+ method @FlaggedApi("android.companion.virtual.flags.dynamic_policy") public void addActivityPolicyExemption(@NonNull android.content.ComponentName);
+ method @FlaggedApi("android.companion.virtualdevice.flags.activity_control_api") public void addActivityPolicyExemption(@NonNull android.companion.virtual.ActivityPolicyExemption);
method public void addSoundEffectListener(@NonNull java.util.concurrent.Executor, @NonNull android.companion.virtual.VirtualDeviceManager.SoundEffectListener);
- method @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void close();
+ method public void close();
method @NonNull public android.content.Context createContext();
- method @NonNull @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public android.companion.virtual.audio.VirtualAudioDevice createVirtualAudioDevice(@NonNull android.hardware.display.VirtualDisplay, @Nullable java.util.concurrent.Executor, @Nullable android.companion.virtual.audio.VirtualAudioDevice.AudioConfigurationChangeCallback);
- method @FlaggedApi("android.companion.virtual.flags.virtual_camera") @NonNull @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public android.companion.virtual.camera.VirtualCamera createVirtualCamera(@NonNull android.companion.virtual.camera.VirtualCameraConfig);
- method @Deprecated @Nullable @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public android.hardware.display.VirtualDisplay createVirtualDisplay(@IntRange(from=1) int, @IntRange(from=1) int, @IntRange(from=1) int, @Nullable android.view.Surface, int, @Nullable java.util.concurrent.Executor, @Nullable android.hardware.display.VirtualDisplay.Callback);
- method @Nullable @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public android.hardware.display.VirtualDisplay createVirtualDisplay(@NonNull android.hardware.display.VirtualDisplayConfig, @Nullable java.util.concurrent.Executor, @Nullable android.hardware.display.VirtualDisplay.Callback);
- method @NonNull @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public android.hardware.input.VirtualDpad createVirtualDpad(@NonNull android.hardware.input.VirtualDpadConfig);
- method @NonNull @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public android.hardware.input.VirtualKeyboard createVirtualKeyboard(@NonNull android.hardware.input.VirtualKeyboardConfig);
- method @Deprecated @NonNull @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public android.hardware.input.VirtualKeyboard createVirtualKeyboard(@NonNull android.hardware.display.VirtualDisplay, @NonNull String, int, int);
- method @NonNull @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public android.hardware.input.VirtualMouse createVirtualMouse(@NonNull android.hardware.input.VirtualMouseConfig);
- method @Deprecated @NonNull @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public android.hardware.input.VirtualMouse createVirtualMouse(@NonNull android.hardware.display.VirtualDisplay, @NonNull String, int, int);
- method @NonNull @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public android.hardware.input.VirtualNavigationTouchpad createVirtualNavigationTouchpad(@NonNull android.hardware.input.VirtualNavigationTouchpadConfig);
- method @FlaggedApi("android.companion.virtualdevice.flags.virtual_rotary") @NonNull @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public android.hardware.input.VirtualRotaryEncoder createVirtualRotaryEncoder(@NonNull android.hardware.input.VirtualRotaryEncoderConfig);
- method @FlaggedApi("android.companion.virtual.flags.virtual_stylus") @NonNull @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public android.hardware.input.VirtualStylus createVirtualStylus(@NonNull android.hardware.input.VirtualStylusConfig);
- method @NonNull @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public android.hardware.input.VirtualTouchscreen createVirtualTouchscreen(@NonNull android.hardware.input.VirtualTouchscreenConfig);
- method @Deprecated @NonNull @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public android.hardware.input.VirtualTouchscreen createVirtualTouchscreen(@NonNull android.hardware.display.VirtualDisplay, @NonNull String, int, int);
+ method @NonNull public android.companion.virtual.audio.VirtualAudioDevice createVirtualAudioDevice(@NonNull android.hardware.display.VirtualDisplay, @Nullable java.util.concurrent.Executor, @Nullable android.companion.virtual.audio.VirtualAudioDevice.AudioConfigurationChangeCallback);
+ method @FlaggedApi("android.companion.virtual.flags.virtual_camera") @NonNull public android.companion.virtual.camera.VirtualCamera createVirtualCamera(@NonNull android.companion.virtual.camera.VirtualCameraConfig);
+ method @Deprecated @Nullable public android.hardware.display.VirtualDisplay createVirtualDisplay(@IntRange(from=1) int, @IntRange(from=1) int, @IntRange(from=1) int, @Nullable android.view.Surface, int, @Nullable java.util.concurrent.Executor, @Nullable android.hardware.display.VirtualDisplay.Callback);
+ method @Nullable public android.hardware.display.VirtualDisplay createVirtualDisplay(@NonNull android.hardware.display.VirtualDisplayConfig, @Nullable java.util.concurrent.Executor, @Nullable android.hardware.display.VirtualDisplay.Callback);
+ method @NonNull public android.hardware.input.VirtualDpad createVirtualDpad(@NonNull android.hardware.input.VirtualDpadConfig);
+ method @NonNull public android.hardware.input.VirtualKeyboard createVirtualKeyboard(@NonNull android.hardware.input.VirtualKeyboardConfig);
+ method @Deprecated @NonNull public android.hardware.input.VirtualKeyboard createVirtualKeyboard(@NonNull android.hardware.display.VirtualDisplay, @NonNull String, int, int);
+ method @NonNull public android.hardware.input.VirtualMouse createVirtualMouse(@NonNull android.hardware.input.VirtualMouseConfig);
+ method @Deprecated @NonNull public android.hardware.input.VirtualMouse createVirtualMouse(@NonNull android.hardware.display.VirtualDisplay, @NonNull String, int, int);
+ method @NonNull public android.hardware.input.VirtualNavigationTouchpad createVirtualNavigationTouchpad(@NonNull android.hardware.input.VirtualNavigationTouchpadConfig);
+ method @FlaggedApi("android.companion.virtualdevice.flags.virtual_rotary") @NonNull public android.hardware.input.VirtualRotaryEncoder createVirtualRotaryEncoder(@NonNull android.hardware.input.VirtualRotaryEncoderConfig);
+ method @FlaggedApi("android.companion.virtual.flags.virtual_stylus") @NonNull public android.hardware.input.VirtualStylus createVirtualStylus(@NonNull android.hardware.input.VirtualStylusConfig);
+ method @NonNull public android.hardware.input.VirtualTouchscreen createVirtualTouchscreen(@NonNull android.hardware.input.VirtualTouchscreenConfig);
+ method @Deprecated @NonNull public android.hardware.input.VirtualTouchscreen createVirtualTouchscreen(@NonNull android.hardware.display.VirtualDisplay, @NonNull String, int, int);
method public int getDeviceId();
method @FlaggedApi("android.companion.virtual.flags.vdm_public_apis") @Nullable public String getPersistentDeviceId();
- method @NonNull @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public java.util.List<android.companion.virtual.sensor.VirtualSensor> getVirtualSensorList();
- method @FlaggedApi("android.companion.virtualdevice.flags.device_aware_display_power") @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void goToSleep();
- method @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void launchPendingIntent(int, @NonNull android.app.PendingIntent, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.IntConsumer);
- method @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void registerIntentInterceptor(@NonNull android.content.IntentFilter, @NonNull java.util.concurrent.Executor, @NonNull android.companion.virtual.VirtualDeviceManager.IntentInterceptorCallback);
+ method @NonNull public java.util.List<android.companion.virtual.sensor.VirtualSensor> getVirtualSensorList();
+ method @FlaggedApi("android.companion.virtualdevice.flags.device_aware_display_power") public void goToSleep();
+ method public void launchPendingIntent(int, @NonNull android.app.PendingIntent, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.IntConsumer);
+ method public void registerIntentInterceptor(@NonNull android.content.IntentFilter, @NonNull java.util.concurrent.Executor, @NonNull android.companion.virtual.VirtualDeviceManager.IntentInterceptorCallback);
method public void removeActivityListener(@NonNull android.companion.virtual.VirtualDeviceManager.ActivityListener);
- method @FlaggedApi("android.companion.virtual.flags.dynamic_policy") @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void removeActivityPolicyExemption(@NonNull android.content.ComponentName);
- method @FlaggedApi("android.companion.virtualdevice.flags.activity_control_api") @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void removeActivityPolicyExemption(@NonNull android.companion.virtual.ActivityPolicyExemption);
+ method @FlaggedApi("android.companion.virtual.flags.dynamic_policy") public void removeActivityPolicyExemption(@NonNull android.content.ComponentName);
+ method @FlaggedApi("android.companion.virtualdevice.flags.activity_control_api") public void removeActivityPolicyExemption(@NonNull android.companion.virtual.ActivityPolicyExemption);
method public void removeSoundEffectListener(@NonNull android.companion.virtual.VirtualDeviceManager.SoundEffectListener);
- method @FlaggedApi("android.companion.virtual.flags.dynamic_policy") @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void setDevicePolicy(int, int);
- method @FlaggedApi("android.companion.virtualdevice.flags.activity_control_api") @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void setDevicePolicy(int, int, int);
- method @FlaggedApi("android.companion.virtual.flags.vdm_custom_ime") @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void setDisplayImePolicy(int, int);
- method @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void setShowPointerIcon(boolean);
- method @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void unregisterIntentInterceptor(@NonNull android.companion.virtual.VirtualDeviceManager.IntentInterceptorCallback);
- method @FlaggedApi("android.companion.virtualdevice.flags.device_aware_display_power") @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void wakeUp();
+ method @FlaggedApi("android.companion.virtual.flags.dynamic_policy") public void setDevicePolicy(int, int);
+ method @FlaggedApi("android.companion.virtualdevice.flags.activity_control_api") public void setDevicePolicy(int, int, int);
+ method @FlaggedApi("android.companion.virtual.flags.vdm_custom_ime") public void setDisplayImePolicy(int, int);
+ method public void setShowPointerIcon(boolean);
+ method public void unregisterIntentInterceptor(@NonNull android.companion.virtual.VirtualDeviceManager.IntentInterceptorCallback);
+ method @FlaggedApi("android.companion.virtualdevice.flags.device_aware_display_power") public void wakeUp();
}
public final class VirtualDeviceParams implements android.os.Parcelable {
@@ -3632,7 +3632,7 @@
package android.companion.virtual.camera {
@FlaggedApi("android.companion.virtual.flags.virtual_camera") public final class VirtualCamera implements java.io.Closeable {
- method @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void close();
+ method public void close();
method @NonNull public android.companion.virtual.camera.VirtualCameraConfig getConfig();
}
@@ -3684,7 +3684,7 @@
method public int getDeviceId();
method @NonNull public String getName();
method public int getType();
- method @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void sendEvent(@NonNull android.companion.virtual.sensor.VirtualSensorEvent);
+ method public void sendEvent(@NonNull android.companion.virtual.sensor.VirtualSensorEvent);
method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.companion.virtual.sensor.VirtualSensor> CREATOR;
}
@@ -5695,8 +5695,8 @@
package android.hardware.input {
public class VirtualDpad implements java.io.Closeable {
- method @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void close();
- method @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void sendKeyEvent(@NonNull android.hardware.input.VirtualKeyEvent);
+ method public void close();
+ method public void sendKeyEvent(@NonNull android.hardware.input.VirtualKeyEvent);
}
public final class VirtualDpadConfig extends android.hardware.input.VirtualInputDeviceConfig implements android.os.Parcelable {
@@ -5747,8 +5747,8 @@
}
public class VirtualKeyboard implements java.io.Closeable {
- method @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void close();
- method @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void sendKeyEvent(@NonNull android.hardware.input.VirtualKeyEvent);
+ method public void close();
+ method public void sendKeyEvent(@NonNull android.hardware.input.VirtualKeyEvent);
}
public final class VirtualKeyboardConfig extends android.hardware.input.VirtualInputDeviceConfig implements android.os.Parcelable {
@@ -5769,11 +5769,11 @@
}
public class VirtualMouse implements java.io.Closeable {
- method @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void close();
- method @NonNull @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public android.graphics.PointF getCursorPosition();
- method @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void sendButtonEvent(@NonNull android.hardware.input.VirtualMouseButtonEvent);
- method @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void sendRelativeEvent(@NonNull android.hardware.input.VirtualMouseRelativeEvent);
- method @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void sendScrollEvent(@NonNull android.hardware.input.VirtualMouseScrollEvent);
+ method public void close();
+ method @NonNull public android.graphics.PointF getCursorPosition();
+ method public void sendButtonEvent(@NonNull android.hardware.input.VirtualMouseButtonEvent);
+ method public void sendRelativeEvent(@NonNull android.hardware.input.VirtualMouseRelativeEvent);
+ method public void sendScrollEvent(@NonNull android.hardware.input.VirtualMouseScrollEvent);
}
public final class VirtualMouseButtonEvent implements android.os.Parcelable {
@@ -5846,8 +5846,8 @@
}
public class VirtualNavigationTouchpad implements java.io.Closeable {
- method @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void close();
- method @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void sendTouchEvent(@NonNull android.hardware.input.VirtualTouchEvent);
+ method public void close();
+ method public void sendTouchEvent(@NonNull android.hardware.input.VirtualTouchEvent);
}
public final class VirtualNavigationTouchpadConfig extends android.hardware.input.VirtualInputDeviceConfig implements android.os.Parcelable {
@@ -5864,8 +5864,8 @@
}
@FlaggedApi("android.companion.virtualdevice.flags.virtual_rotary") public class VirtualRotaryEncoder implements java.io.Closeable {
- method @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void close();
- method @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void sendScrollEvent(@NonNull android.hardware.input.VirtualRotaryEncoderScrollEvent);
+ method public void close();
+ method public void sendScrollEvent(@NonNull android.hardware.input.VirtualRotaryEncoderScrollEvent);
}
@FlaggedApi("android.companion.virtualdevice.flags.virtual_rotary") public final class VirtualRotaryEncoderConfig extends android.hardware.input.VirtualInputDeviceConfig implements android.os.Parcelable {
@@ -5895,9 +5895,9 @@
}
@FlaggedApi("android.companion.virtual.flags.virtual_stylus") public class VirtualStylus implements java.io.Closeable {
- method @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void close();
- method @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void sendButtonEvent(@NonNull android.hardware.input.VirtualStylusButtonEvent);
- method @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void sendMotionEvent(@NonNull android.hardware.input.VirtualStylusMotionEvent);
+ method public void close();
+ method public void sendButtonEvent(@NonNull android.hardware.input.VirtualStylusButtonEvent);
+ method public void sendMotionEvent(@NonNull android.hardware.input.VirtualStylusMotionEvent);
}
@FlaggedApi("android.companion.virtual.flags.virtual_stylus") public final class VirtualStylusButtonEvent implements android.os.Parcelable {
@@ -6000,8 +6000,8 @@
}
public class VirtualTouchscreen implements java.io.Closeable {
- method @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void close();
- method @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void sendTouchEvent(@NonNull android.hardware.input.VirtualTouchEvent);
+ method public void close();
+ method public void sendTouchEvent(@NonNull android.hardware.input.VirtualTouchEvent);
}
public final class VirtualTouchscreenConfig extends android.hardware.input.VirtualInputDeviceConfig implements android.os.Parcelable {
diff --git a/core/java/android/app/AppOps.md b/core/java/android/app/AppOps.md
index 7b11a03..535d62c 100644
--- a/core/java/android/app/AppOps.md
+++ b/core/java/android/app/AppOps.md
@@ -119,20 +119,20 @@
In addition to proc state, the `AppOpsService` also receives process capability update from the
`ActivityManagerService`. Proc capability specifies what while-in-use(`MODE_FOREGROUND`) operations
the proc is allowed to perform in its current proc state. There are three proc capabilities
- defined so far:
+ defined so far:
`PROCESS_CAPABILITY_FOREGROUND_LOCATION`, `PROCESS_CAPABILITY_FOREGROUND_CAMERA` and
`PROCESS_CAPABILITY_FOREGROUND_MICROPHONE`, they correspond to the while-in-use operation of
location, camera and microphone (microphone is `RECORD_AUDIO`).
In `ActivityManagerService`, `PROCESS_STATE_TOP` and `PROCESS_STATE_PERSISTENT` have all
three capabilities, `PROCESS_STATE_FOREGROUND_SERVICE` has capabilities defined by
- `foregroundServiceType` that is specified in foreground service's manifest file. A client process
+ `foregroundServiceType` that is specified in foreground service's manifest file. A client process
can pass its capabilities to service using `BIND_INCLUDE_CAPABILITIES` flag.
The proc state and capability are used for two use cases: Firstly, Tracking remembers the proc state
for each tracked event. Secondly, `noteOp`/`checkOp` calls for app-op that are set to
`MODE_FOREGROUND` are translated using the `AppOpsService.UidState.evalMode` method into
- `MODE_ALLOWED` when the app has the capability and `MODE_IGNORED` when the app does not have the
+ `MODE_ALLOWED` when the app has the capability and `MODE_IGNORED` when the app does not have the
capability. `checkOpRaw` calls are not affected.
The current proc state and capability for an app can be read from `dumpsys appops`.
@@ -284,7 +284,7 @@
##### Self data accesses
This is similar to the [synchronous data access](#synchronous-data-accesses) case only that the data
-provider and client are in the same process. In this case Android's RPC code is no involved and
+provider and client are in the same process. In this case Android's RPC code is not involved and
`AppOpsManager.noteOp` directly triggers `OnOpNotedCallback.onSelfNoted`. This should be a uncommon
case as it is uncommon for an app to provide data, esp. to itself.
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index bc7ebce..8b33417 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -115,6 +115,7 @@
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.ContrastColorUtil;
import com.android.internal.util.NotificationBigTextNormalizer;
+import com.android.internal.widget.NotificationProgressModel;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -7318,12 +7319,16 @@
*/
@VisibleForTesting
public static int ensureButtonFillContrast(int color, int bg) {
- return isColorDark(bg)
- ? ContrastColorUtil.findContrastColorAgainstDark(color, bg, true, 1.3)
- : ContrastColorUtil.findContrastColor(color, bg, true, 1.3);
+ return ensureColorContrast(color, bg, 1.3);
}
+ private static int ensureColorContrast(int color, int bg, double contrastRatio) {
+ return isColorDark(bg)
+ ? ContrastColorUtil.findContrastColorAgainstDark(color, bg, true, contrastRatio)
+ : ContrastColorUtil.findContrastColor(color, bg, true, contrastRatio);
+ }
+
/**
* @return Whether we are currently building a notification from a legacy (an app that
* doesn't create material notifications by itself) app.
@@ -11657,6 +11662,7 @@
StandardTemplateParams p = mBuilder.mParams.reset()
.viewType(StandardTemplateParams.VIEW_TYPE_BIG)
.allowTextWithProgress(true)
+ .hideProgress(true)
.fillTextsFrom(mBuilder);
// Replace the text with the big text, but only if the big text is not empty.
@@ -11678,10 +11684,28 @@
contentView.setViewVisibility(R.id.notification_progress_end_icon, View.GONE);
}
+ contentView.setViewVisibility(R.id.progress, View.VISIBLE);
+
+ final int backgroundColor = mBuilder.getColors(p).getBackgroundColor();
+ final int defaultProgressColor = mBuilder.getPrimaryAccentColor(p);
+ final NotificationProgressModel model = createProgressModel(
+ defaultProgressColor, backgroundColor);
+ contentView.setBundle(R.id.progress,
+ "setProgressModel", model.toBundle());
+
+ if (mTrackerIcon != null) {
+ contentView.setIcon(R.id.progress,
+ "setProgressTrackerIcon",
+ mTrackerIcon);
+ }
+
return contentView;
}
- private static @NonNull ArrayList<Bundle> getProgressSegmentsAsBundleList(
+ /**
+ * @hide
+ */
+ public static @NonNull ArrayList<Bundle> getProgressSegmentsAsBundleList(
@Nullable List<Segment> progressSegments) {
final ArrayList<Bundle> segments = new ArrayList<>();
if (progressSegments != null && !progressSegments.isEmpty()) {
@@ -11703,7 +11727,10 @@
return segments;
}
- private static @NonNull List<Segment> getProgressSegmentsFromBundleList(
+ /**
+ * @hide
+ */
+ public static @NonNull List<Segment> getProgressSegmentsFromBundleList(
@Nullable List<Bundle> segmentBundleList) {
final ArrayList<Segment> segments = new ArrayList<>();
if (segmentBundleList != null && !segmentBundleList.isEmpty()) {
@@ -11726,8 +11753,10 @@
return segments;
}
-
- private static @NonNull ArrayList<Bundle> getProgressPointsAsBundleList(
+ /**
+ * @hide
+ */
+ public static @NonNull ArrayList<Bundle> getProgressPointsAsBundleList(
@Nullable List<Point> progressPoints) {
final ArrayList<Bundle> points = new ArrayList<>();
if (progressPoints != null && !progressPoints.isEmpty()) {
@@ -11749,7 +11778,10 @@
return points;
}
- private static @NonNull List<Point> getProgressPointsFromBundleList(
+ /**
+ * @hide
+ */
+ public static @NonNull List<Point> getProgressPointsFromBundleList(
@Nullable List<Bundle> pointBundleList) {
final ArrayList<Point> points = new ArrayList<>();
@@ -11771,6 +11803,78 @@
return points;
}
+ @NonNull
+ private NotificationProgressModel createProgressModel(int defaultProgressColor,
+ int backgroundColor) {
+ final NotificationProgressModel model;
+ if (mIndeterminate) {
+ final int indeterminateColor;
+ if (!mProgressSegments.isEmpty()) {
+ indeterminateColor = mProgressSegments.get(0).mColor;
+ } else {
+ indeterminateColor = defaultProgressColor;
+ }
+
+ model = new NotificationProgressModel(
+ sanitizeProgressColor(indeterminateColor,
+ backgroundColor, defaultProgressColor));
+ } else {
+
+ // Ensure segment color contrasts.
+ final List<Segment> segments = new ArrayList<>();
+ for (Segment segment : mProgressSegments) {
+ segments.add(sanitizeSegment(segment, backgroundColor,
+ defaultProgressColor));
+ }
+
+ // Create default segment when no segments are provided.
+ if (segments.isEmpty()) {
+ segments.add(sanitizeSegment(new Segment(100), backgroundColor,
+ defaultProgressColor));
+ }
+
+ // Ensure point color contrasts.
+ final List<Point> points = new ArrayList<>();
+ for (Point point : mProgressPoints) {
+ points.add(sanitizePoint(point, backgroundColor, defaultProgressColor));
+ }
+
+ model = new NotificationProgressModel(segments, points,
+ mProgress, mIsStyledByProgress);
+ }
+ return model;
+ }
+
+ private Segment sanitizeSegment(@NonNull Segment segment,
+ @ColorInt int bg,
+ @ColorInt int defaultColor) {
+ return new Segment(segment.getLength())
+ .setId(segment.getId())
+ .setColor(sanitizeProgressColor(segment.getColor(), bg, defaultColor));
+ }
+
+ private Point sanitizePoint(@NonNull Point point,
+ @ColorInt int bg,
+ @ColorInt int defaultColor) {
+ return new Point(point.getPosition()).setId(point.getId())
+ .setColor(sanitizeProgressColor(point.getColor(), bg, defaultColor));
+ }
+
+ /**
+ * Finds steps and points fill color with sufficient contrast over bg (1.3:1) that
+ * has the same hue as the original color, but is lightened or darkened depending on
+ * whether the background is dark or light.
+ *
+ */
+ private int sanitizeProgressColor(@ColorInt int color,
+ @ColorInt int bg,
+ @ColorInt int defaultColor) {
+ return Builder.ensureColorContrast(
+ Color.alpha(color) == 0 ? defaultColor : color,
+ bg,
+ 1.3);
+ }
+
/**
* A segment of the progress bar, which defines its length and color.
* Segments allow for creating progress bars with multiple colors or sections
diff --git a/core/java/android/app/appfunctions/AppFunctionManagerConfiguration.java b/core/java/android/app/appfunctions/AppFunctionManagerConfiguration.java
index fa77e79..cb21d1f 100644
--- a/core/java/android/app/appfunctions/AppFunctionManagerConfiguration.java
+++ b/core/java/android/app/appfunctions/AppFunctionManagerConfiguration.java
@@ -20,7 +20,6 @@
import android.annotation.NonNull;
import android.content.Context;
-import android.content.pm.PackageManager;
/**
* Represents the system configuration of support for the {@code AppFunctionManager} and associated
@@ -29,15 +28,13 @@
* @hide
*/
public class AppFunctionManagerConfiguration {
- private final Context mContext;
-
/**
* Constructs a new instance of {@code AppFunctionManagerConfiguration}.
*
* @param context context
*/
public AppFunctionManagerConfiguration(@NonNull final Context context) {
- mContext = context;
+ // Context can be used to access system features, etc.
}
/**
@@ -46,7 +43,7 @@
* @return {@code true} if supported; otherwise {@code false}
*/
public boolean isSupported() {
- return enableAppFunctionManager() && !isWatch();
+ return enableAppFunctionManager();
}
/**
@@ -58,8 +55,4 @@
public static boolean isSupported(@NonNull final Context context) {
return new AppFunctionManagerConfiguration(context).isSupported();
}
-
- private boolean isWatch() {
- return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH);
- }
}
diff --git a/core/java/android/companion/virtual/IVirtualDevice.aidl b/core/java/android/companion/virtual/IVirtualDevice.aidl
index 40debe8..d3a1c25 100644
--- a/core/java/android/companion/virtual/IVirtualDevice.aidl
+++ b/core/java/android/companion/virtual/IVirtualDevice.aidl
@@ -98,191 +98,160 @@
/*
* Turns off all trusted non-mirror displays of the virtual device.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
void goToSleep();
/**
* Turns on all trusted non-mirror displays of the virtual device.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
void wakeUp();
/**
* Closes the virtual device and frees all associated resources.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
void close();
/**
* Specifies a policy for this virtual device.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
void setDevicePolicy(int policyType, int devicePolicy);
/**
* Adds an exemption to the default activity launch policy.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
void addActivityPolicyExemption(in ActivityPolicyExemption exemption);
/**
* Removes an exemption to the default activity launch policy.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
void removeActivityPolicyExemption(in ActivityPolicyExemption exemption);
/**
* Specifies a policy for this virtual device on the given display.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
void setDevicePolicyForDisplay(int displayId, int policyType, int devicePolicy);
/**
* Notifies that an audio session being started.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
void onAudioSessionStarting(int displayId, IAudioRoutingCallback routingCallback,
IAudioConfigChangedCallback configChangedCallback);
/**
* Notifies that an audio session has ended.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
void onAudioSessionEnded();
/**
* Creates a virtual display and registers it with the display framework.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
int createVirtualDisplay(in VirtualDisplayConfig virtualDisplayConfig,
in IVirtualDisplayCallback callback);
/**
* Creates a new dpad and registers it with the input framework with the given token.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
void createVirtualDpad(in VirtualDpadConfig config, IBinder token);
/**
* Creates a new keyboard and registers it with the input framework with the given token.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
void createVirtualKeyboard(in VirtualKeyboardConfig config, IBinder token);
/**
* Creates a new mouse and registers it with the input framework with the given token.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
void createVirtualMouse(in VirtualMouseConfig config, IBinder token);
/**
* Creates a new touchscreen and registers it with the input framework with the given token.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
void createVirtualTouchscreen(in VirtualTouchscreenConfig config, IBinder token);
/**
* Creates a new navigation touchpad and registers it with the input framework with the given
* token.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
void createVirtualNavigationTouchpad(in VirtualNavigationTouchpadConfig config, IBinder token);
/**
* Creates a new stylus and registers it with the input framework with the given token.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
void createVirtualStylus(in VirtualStylusConfig config, IBinder token);
/**
* Creates a new rotary encoder and registers it with the input framework with the given token.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
void createVirtualRotaryEncoder(in VirtualRotaryEncoderConfig config, IBinder token);
/**
* Removes the input device corresponding to the given token from the framework.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
void unregisterInputDevice(IBinder token);
/**
* Returns the ID of the device corresponding to the given token, as registered with the input
* framework.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
int getInputDeviceId(IBinder token);
/**
* Injects a key event to the virtual dpad corresponding to the given token.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
boolean sendDpadKeyEvent(IBinder token, in VirtualKeyEvent event);
/**
* Injects a key event to the virtual keyboard corresponding to the given token.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
boolean sendKeyEvent(IBinder token, in VirtualKeyEvent event);
/**
* Injects a button event to the virtual mouse corresponding to the given token.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
boolean sendButtonEvent(IBinder token, in VirtualMouseButtonEvent event);
/**
* Injects a relative event to the virtual mouse corresponding to the given token.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
boolean sendRelativeEvent(IBinder token, in VirtualMouseRelativeEvent event);
/**
* Injects a scroll event to the virtual mouse corresponding to the given token.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
boolean sendScrollEvent(IBinder token, in VirtualMouseScrollEvent event);
/**
* Injects a touch event to the virtual touch input device corresponding to the given token.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
boolean sendTouchEvent(IBinder token, in VirtualTouchEvent event);
/**
* Injects a motion event from the virtual stylus input device corresponding to the given token.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
boolean sendStylusMotionEvent(IBinder token, in VirtualStylusMotionEvent event);
/**
* Injects a button event from the virtual stylus input device corresponding to the given token.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
boolean sendStylusButtonEvent(IBinder token, in VirtualStylusButtonEvent event);
/**
* Injects a scroll event from the virtual rotary encoder corresponding to the given token.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
boolean sendRotaryEncoderScrollEvent(IBinder token, in VirtualRotaryEncoderScrollEvent event);
/**
* Returns all virtual sensors created for this device.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
List<VirtualSensor> getVirtualSensorList();
/**
* Sends an event to the virtual sensor corresponding to the given token.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
boolean sendSensorEvent(IBinder token, in VirtualSensorEvent event);
/**
* Launches a pending intent on the given display that is owned by this virtual device.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
void launchPendingIntent(int displayId, in PendingIntent pendingIntent,
in ResultReceiver resultReceiver);
@@ -290,15 +259,12 @@
* Returns the current cursor position of the mouse corresponding to the given token, in x and y
* coordinates.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
PointF getCursorPosition(IBinder token);
/** Sets whether to show or hide the cursor while this virtual device is active. */
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
void setShowPointerIcon(boolean showPointerIcon);
/** Sets an IME policy for the given display. */
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
void setDisplayImePolicy(int displayId, int policy);
/**
@@ -306,33 +272,28 @@
* when matching the provided IntentFilter and calls the callback with the intercepted
* intent.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
void registerIntentInterceptor(in IVirtualDeviceIntentInterceptor intentInterceptor,
in IntentFilter filter);
/**
* Unregisters a previously registered intent interceptor.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
void unregisterIntentInterceptor(in IVirtualDeviceIntentInterceptor intentInterceptor);
/**
* Creates a new virtual camera and registers it with the virtual camera service.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
void registerVirtualCamera(in VirtualCameraConfig camera);
/**
* Destroys the virtual camera with given config and unregisters it from the virtual camera
* service.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
void unregisterVirtualCamera(in VirtualCameraConfig camera);
/**
* Returns the id of the virtual camera with given config.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
String getVirtualCameraId(in VirtualCameraConfig camera);
/**
@@ -342,7 +303,6 @@
* This is needed for virtual devices that are created by the system, as the VirtualDeviceImpl
* object is created before the returned VirtualDeviceInternal one.
*/
- @EnforcePermission("CREATE_VIRTUAL_DEVICE")
void setListeners(in IVirtualDeviceActivityListener activityListener,
in IVirtualDeviceSoundEffectListener soundEffectListener);
}
diff --git a/core/java/android/companion/virtual/VirtualDeviceInternal.java b/core/java/android/companion/virtual/VirtualDeviceInternal.java
index 6708cce..d63a443 100644
--- a/core/java/android/companion/virtual/VirtualDeviceInternal.java
+++ b/core/java/android/companion/virtual/VirtualDeviceInternal.java
@@ -26,7 +26,6 @@
import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
import android.annotation.Nullable;
-import android.annotation.RequiresPermission;
import android.annotation.UserIdInt;
import android.app.PendingIntent;
import android.companion.virtual.audio.VirtualAudioDevice;
@@ -242,7 +241,6 @@
}
}
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@NonNull
List<VirtualSensor> getVirtualSensorList() {
try {
@@ -252,7 +250,6 @@
}
}
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
void goToSleep() {
try {
mVirtualDevice.goToSleep();
@@ -261,7 +258,6 @@
}
}
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
void wakeUp() {
try {
mVirtualDevice.wakeUp();
@@ -270,7 +266,6 @@
}
}
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
void launchPendingIntent(
int displayId,
@NonNull PendingIntent pendingIntent,
@@ -292,7 +287,6 @@
}
}
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@Nullable
VirtualDisplay createVirtualDisplay(
@NonNull VirtualDisplayConfig config,
@@ -310,7 +304,6 @@
return displayManager.createVirtualDisplayWrapper(config, callbackWrapper, displayId);
}
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
void close() {
try {
// This also takes care of unregistering all virtual sensors.
@@ -324,7 +317,6 @@
}
}
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
void setDevicePolicy(@VirtualDeviceParams.DynamicPolicyType int policyType,
@VirtualDeviceParams.DevicePolicy int devicePolicy) {
switch (policyType) {
@@ -344,7 +336,6 @@
}
}
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
void addActivityPolicyExemption(@NonNull ActivityPolicyExemption exemption) {
try {
mVirtualDevice.addActivityPolicyExemption(exemption);
@@ -353,7 +344,6 @@
}
}
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
void removeActivityPolicyExemption(@NonNull ActivityPolicyExemption exemption) {
try {
mVirtualDevice.removeActivityPolicyExemption(exemption);
@@ -362,7 +352,6 @@
}
}
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
void setDevicePolicyForDisplay(int displayId,
@VirtualDeviceParams.DynamicDisplayPolicyType int policyType,
@VirtualDeviceParams.DevicePolicy int devicePolicy) {
@@ -382,7 +371,6 @@
}
}
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@NonNull
VirtualDpad createVirtualDpad(@NonNull VirtualDpadConfig config) {
try {
@@ -395,7 +383,6 @@
}
}
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@NonNull
VirtualKeyboard createVirtualKeyboard(@NonNull VirtualKeyboardConfig config) {
try {
@@ -408,7 +395,6 @@
}
}
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@NonNull
VirtualMouse createVirtualMouse(@NonNull VirtualMouseConfig config) {
try {
@@ -421,7 +407,6 @@
}
}
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@NonNull
VirtualTouchscreen createVirtualTouchscreen(
@NonNull VirtualTouchscreenConfig config) {
@@ -435,7 +420,6 @@
}
}
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@NonNull
VirtualStylus createVirtualStylus(@NonNull VirtualStylusConfig config) {
try {
@@ -448,7 +432,6 @@
}
}
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@NonNull
VirtualRotaryEncoder createVirtualRotaryEncoder(@NonNull VirtualRotaryEncoderConfig config) {
try {
@@ -461,7 +444,6 @@
}
}
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@NonNull
VirtualNavigationTouchpad createVirtualNavigationTouchpad(
@NonNull VirtualNavigationTouchpadConfig config) {
@@ -476,7 +458,6 @@
}
}
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@NonNull
VirtualAudioDevice createVirtualAudioDevice(
@NonNull VirtualDisplay display,
@@ -501,7 +482,6 @@
return mVirtualAudioDevice;
}
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@NonNull
VirtualCamera createVirtualCamera(@NonNull VirtualCameraConfig config) {
try {
@@ -513,7 +493,6 @@
}
}
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
void setShowPointerIcon(boolean showPointerIcon) {
try {
mVirtualDevice.setShowPointerIcon(showPointerIcon);
@@ -522,7 +501,6 @@
}
}
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
void setDisplayImePolicy(int displayId, @WindowManager.DisplayImePolicy int policy) {
try {
mVirtualDevice.setDisplayImePolicy(displayId, policy);
@@ -564,7 +542,6 @@
}
}
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
void registerIntentInterceptor(
@NonNull IntentFilter interceptorFilter,
@CallbackExecutor @NonNull Executor executor,
@@ -584,7 +561,6 @@
}
}
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
void unregisterIntentInterceptor(
@NonNull VirtualDeviceManager.IntentInterceptorCallback interceptorCallback) {
Objects.requireNonNull(interceptorCallback);
diff --git a/core/java/android/companion/virtual/VirtualDeviceManager.java b/core/java/android/companion/virtual/VirtualDeviceManager.java
index 70211bf..6ea7834 100644
--- a/core/java/android/companion/virtual/VirtualDeviceManager.java
+++ b/core/java/android/companion/virtual/VirtualDeviceManager.java
@@ -614,7 +614,6 @@
*
* @return A list of all sensors for this device, or an empty list if no sensors exist.
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@NonNull
public List<VirtualSensor> getVirtualSensorList() {
return mVirtualDeviceInternal.getVirtualSensorList();
@@ -635,7 +634,6 @@
* @see DisplayManager#VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY
*/
@FlaggedApi(android.companion.virtualdevice.flags.Flags.FLAG_DEVICE_AWARE_DISPLAY_POWER)
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void goToSleep() {
mVirtualDeviceInternal.goToSleep();
}
@@ -654,7 +652,6 @@
* @see DisplayManager#VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY
*/
@FlaggedApi(android.companion.virtualdevice.flags.Flags.FLAG_DEVICE_AWARE_DISPLAY_POWER)
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void wakeUp() {
mVirtualDeviceInternal.wakeUp();
}
@@ -677,7 +674,6 @@
* on the virtual display, or one of the {@code LAUNCH_FAILED} status explaining why it
* failed.
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void launchPendingIntent(
int displayId,
@NonNull PendingIntent pendingIntent,
@@ -718,7 +714,6 @@
* VirtualDisplay.Callback)}
*/
@Deprecated
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@Nullable
public VirtualDisplay createVirtualDisplay(
@IntRange(from = 1) int width,
@@ -756,7 +751,6 @@
*
* @see DisplayManager#createVirtualDisplay
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@Nullable
public VirtualDisplay createVirtualDisplay(
@NonNull VirtualDisplayConfig config,
@@ -770,7 +764,6 @@
* Closes the virtual device, stopping and tearing down any virtual displays, associated
* virtual audio device, and event injection that's currently in progress.
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void close() {
mVirtualDeviceInternal.close();
}
@@ -789,7 +782,6 @@
* @see VirtualDeviceParams#POLICY_TYPE_ACTIVITY
*/
@FlaggedApi(Flags.FLAG_DYNAMIC_POLICY)
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void setDevicePolicy(@VirtualDeviceParams.DynamicPolicyType int policyType,
@VirtualDeviceParams.DevicePolicy int devicePolicy) {
mVirtualDeviceInternal.setDevicePolicy(policyType, devicePolicy);
@@ -812,7 +804,6 @@
* @see #setDevicePolicy
*/
@FlaggedApi(Flags.FLAG_DYNAMIC_POLICY)
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void addActivityPolicyExemption(@NonNull ComponentName componentName) {
addActivityPolicyExemption(new ActivityPolicyExemption.Builder()
.setComponentName(componentName)
@@ -836,7 +827,6 @@
* @see #setDevicePolicy
*/
@FlaggedApi(Flags.FLAG_DYNAMIC_POLICY)
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void removeActivityPolicyExemption(@NonNull ComponentName componentName) {
removeActivityPolicyExemption(new ActivityPolicyExemption.Builder()
.setComponentName(componentName)
@@ -861,7 +851,6 @@
* @see #setDevicePolicy
*/
@FlaggedApi(android.companion.virtualdevice.flags.Flags.FLAG_ACTIVITY_CONTROL_API)
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void addActivityPolicyExemption(@NonNull ActivityPolicyExemption exemption) {
mVirtualDeviceInternal.addActivityPolicyExemption(Objects.requireNonNull(exemption));
}
@@ -877,7 +866,6 @@
* @see #setDevicePolicy
*/
@FlaggedApi(android.companion.virtualdevice.flags.Flags.FLAG_ACTIVITY_CONTROL_API)
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void removeActivityPolicyExemption(@NonNull ActivityPolicyExemption exemption) {
mVirtualDeviceInternal.removeActivityPolicyExemption(Objects.requireNonNull(exemption));
}
@@ -900,7 +888,6 @@
* @see VirtualDeviceParams#POLICY_TYPE_ACTIVITY
*/
@FlaggedApi(android.companion.virtualdevice.flags.Flags.FLAG_ACTIVITY_CONTROL_API)
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void setDevicePolicy(
@VirtualDeviceParams.DynamicDisplayPolicyType int policyType,
@VirtualDeviceParams.DevicePolicy int devicePolicy,
@@ -913,7 +900,6 @@
*
* @param config the configurations of the virtual dpad.
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@NonNull
public VirtualDpad createVirtualDpad(@NonNull VirtualDpadConfig config) {
Objects.requireNonNull(config, "config must not be null");
@@ -925,7 +911,6 @@
*
* @param config the configurations of the virtual keyboard.
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@NonNull
public VirtualKeyboard createVirtualKeyboard(@NonNull VirtualKeyboardConfig config) {
Objects.requireNonNull(config, "config must not be null");
@@ -943,7 +928,6 @@
* @deprecated Use {@link #createVirtualKeyboard(VirtualKeyboardConfig config)} instead
*/
@Deprecated
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@NonNull
public VirtualKeyboard createVirtualKeyboard(@NonNull VirtualDisplay display,
@NonNull String inputDeviceName, int vendorId, int productId) {
@@ -962,7 +946,6 @@
*
* @param config the configurations of the virtual mouse.
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@NonNull
public VirtualMouse createVirtualMouse(@NonNull VirtualMouseConfig config) {
Objects.requireNonNull(config, "config must not be null");
@@ -980,7 +963,6 @@
* @deprecated Use {@link #createVirtualMouse(VirtualMouseConfig config)} instead
*/
@Deprecated
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@NonNull
public VirtualMouse createVirtualMouse(@NonNull VirtualDisplay display,
@NonNull String inputDeviceName, int vendorId, int productId) {
@@ -999,7 +981,6 @@
*
* @param config the configurations of the virtual touchscreen.
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@NonNull
public VirtualTouchscreen createVirtualTouchscreen(
@NonNull VirtualTouchscreenConfig config) {
@@ -1019,7 +1000,6 @@
* instead
*/
@Deprecated
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@NonNull
public VirtualTouchscreen createVirtualTouchscreen(@NonNull VirtualDisplay display,
@NonNull String inputDeviceName, int vendorId, int productId) {
@@ -1046,7 +1026,6 @@
* @param config the configurations of the virtual navigation touchpad.
* @see android.view.InputDevice#SOURCE_TOUCH_NAVIGATION
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@NonNull
public VirtualNavigationTouchpad createVirtualNavigationTouchpad(
@NonNull VirtualNavigationTouchpadConfig config) {
@@ -1058,7 +1037,6 @@
*
* @param config the touchscreen configurations for the virtual stylus.
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@NonNull
@FlaggedApi(Flags.FLAG_VIRTUAL_STYLUS)
public VirtualStylus createVirtualStylus(
@@ -1072,7 +1050,6 @@
* @param config the configuration for the virtual rotary encoder.
* @see android.view.InputDevice#SOURCE_ROTARY_ENCODER
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@NonNull
@FlaggedApi(android.companion.virtualdevice.flags.Flags.FLAG_VIRTUAL_ROTARY)
public VirtualRotaryEncoder createVirtualRotaryEncoder(
@@ -1100,7 +1077,6 @@
* applications running on virtual display is changed.
* @return A {@link VirtualAudioDevice} instance.
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@NonNull
public VirtualAudioDevice createVirtualAudioDevice(
@NonNull VirtualDisplay display,
@@ -1121,7 +1097,6 @@
* @throws UnsupportedOperationException if virtual camera isn't supported on this device.
* @see VirtualDeviceParams#POLICY_TYPE_CAMERA
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@NonNull
@FlaggedApi(Flags.FLAG_VIRTUAL_CAMERA)
public VirtualCamera createVirtualCamera(@NonNull VirtualCameraConfig config) {
@@ -1141,7 +1116,6 @@
* visibility is true.
* @see DisplayManager#VIRTUAL_DISPLAY_FLAG_TRUSTED
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void setShowPointerIcon(boolean showPointerIcon) {
mVirtualDeviceInternal.setShowPointerIcon(showPointerIcon);
}
@@ -1156,7 +1130,6 @@
* @throws SecurityException if the display is not owned by this device or is not
* {@link DisplayManager#VIRTUAL_DISPLAY_FLAG_TRUSTED trusted}
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@FlaggedApi(Flags.FLAG_VDM_CUSTOM_IME)
public void setDisplayImePolicy(int displayId, @WindowManager.DisplayImePolicy int policy) {
if (Flags.vdmCustomIme()) {
@@ -1220,7 +1193,6 @@
* is intercepted.
* @see #unregisterIntentInterceptor(IntentInterceptorCallback)
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void registerIntentInterceptor(
@NonNull IntentFilter interceptorFilter,
@CallbackExecutor @NonNull Executor executor,
@@ -1233,7 +1205,6 @@
* Unregisters the intent interceptor previously registered with
* {@link #registerIntentInterceptor}.
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void unregisterIntentInterceptor(
@NonNull IntentInterceptorCallback interceptorCallback) {
mVirtualDeviceInternal.unregisterIntentInterceptor(interceptorCallback);
diff --git a/core/java/android/companion/virtual/camera/VirtualCamera.java b/core/java/android/companion/virtual/camera/VirtualCamera.java
index f727589..ece048d 100644
--- a/core/java/android/companion/virtual/camera/VirtualCamera.java
+++ b/core/java/android/companion/virtual/camera/VirtualCamera.java
@@ -17,7 +17,6 @@
package android.companion.virtual.camera;
import android.annotation.FlaggedApi;
-import android.annotation.RequiresPermission;
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.annotation.TestApi;
@@ -94,7 +93,6 @@
}
@Override
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void close() {
try {
mVirtualDevice.unregisterVirtualCamera(mConfig);
diff --git a/core/java/android/companion/virtual/sensor/VirtualSensor.java b/core/java/android/companion/virtual/sensor/VirtualSensor.java
index 37e494b..934a1a8 100644
--- a/core/java/android/companion/virtual/sensor/VirtualSensor.java
+++ b/core/java/android/companion/virtual/sensor/VirtualSensor.java
@@ -17,7 +17,6 @@
package android.companion.virtual.sensor;
import android.annotation.NonNull;
-import android.annotation.RequiresPermission;
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.annotation.TestApi;
@@ -136,7 +135,6 @@
/**
* Send a sensor event to the system.
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void sendEvent(@NonNull VirtualSensorEvent event) {
try {
mVirtualDevice.sendSensorEvent(mToken, event);
diff --git a/core/java/android/content/pm/multiuser.aconfig b/core/java/android/content/pm/multiuser.aconfig
index ff0a3dd..7de7131 100644
--- a/core/java/android/content/pm/multiuser.aconfig
+++ b/core/java/android/content/pm/multiuser.aconfig
@@ -68,6 +68,16 @@
}
flag {
+ name: "multiple_alarm_notifications_support"
+ namespace: "multiuser"
+ description: "Implement handling of multiple simultaneous alarms/timers on bg users"
+ bug: "367615180"
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+}
+
+flag {
name: "enable_biometrics_to_unlock_private_space"
is_exported: true
namespace: "profile_experiences"
diff --git a/core/java/android/hardware/devicestate/DeviceStateManagerGlobal.java b/core/java/android/hardware/devicestate/DeviceStateManagerGlobal.java
index 1845827..739dbe1 100644
--- a/core/java/android/hardware/devicestate/DeviceStateManagerGlobal.java
+++ b/core/java/android/hardware/devicestate/DeviceStateManagerGlobal.java
@@ -32,6 +32,7 @@
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting.Visibility;
+import com.android.window.flags.Flags;
import java.util.ArrayList;
import java.util.List;
@@ -47,6 +48,7 @@
@VisibleForTesting(visibility = Visibility.PACKAGE)
public final class DeviceStateManagerGlobal {
@Nullable
+ @GuardedBy("DeviceStateManagerGlobal.class")
private static DeviceStateManagerGlobal sInstance;
private static final String TAG = "DeviceStateManagerGlobal";
private static final boolean DEBUG = Build.IS_DEBUGGABLE;
@@ -84,10 +86,12 @@
@GuardedBy("mLock")
private DeviceStateInfo mLastReceivedInfo;
+ // Constructor should be called while holding the lock.
+ // @GuardedBy("DeviceStateManagerGlobal.class") can't be used on constructors.
@VisibleForTesting
public DeviceStateManagerGlobal(@NonNull IDeviceStateManager deviceStateManager) {
mDeviceStateManager = deviceStateManager;
- registerCallbackIfNeededLocked();
+ registerCallbackLocked();
}
/**
@@ -279,14 +283,17 @@
}
}
- private void registerCallbackIfNeededLocked() {
- if (mCallback != null) {
- return;
- }
-
+ @GuardedBy("DeviceStateManagerGlobal.class")
+ private void registerCallbackLocked() {
mCallback = new DeviceStateManagerCallback();
try {
- mDeviceStateManager.registerCallback(mCallback);
+ if (Flags.wlinfoOncreate()) {
+ synchronized (mLock) {
+ mLastReceivedInfo = mDeviceStateManager.registerCallback(mCallback);
+ }
+ } else {
+ mDeviceStateManager.registerCallback(mCallback);
+ }
} catch (RemoteException ex) {
mCallback = null;
throw ex.rethrowFromSystemServer();
diff --git a/core/java/android/hardware/devicestate/IDeviceStateManager.aidl b/core/java/android/hardware/devicestate/IDeviceStateManager.aidl
index ea4fe26..50d0623 100644
--- a/core/java/android/hardware/devicestate/IDeviceStateManager.aidl
+++ b/core/java/android/hardware/devicestate/IDeviceStateManager.aidl
@@ -32,16 +32,24 @@
DeviceStateInfo getDeviceStateInfo();
/**
- * Registers a callback to receive notifications from the device state manager. Only one
- * callback can be registered per-process.
+ * Registers a callback to receive notifications from the device state manager and returns the
+ * current {@link DeviceStateInfo}. Only one callback can be registered per-process.
* <p>
* As the callback mechanism is used to alert the caller of changes to request status a callback
* <b>MUST</b> be registered before calling {@link #requestState(IBinder, int, int)} or
* {@link #cancelRequest(IBinder)}, otherwise an exception will be thrown.
+ * <p>
+ * Upon successful registration, this method returns the committed {@link DeviceStateInfo} if
+ * available, ensuring the availability of the device state after the callback is registered.
+ * This guarantees that the client will have access to the latest device state immediately upon
+ * completion of the two-way IPC call.
*
+ * @param callback the callback to register for device state notifications.
+ * @return DeviceStateInfo the current device state information including the committed state
+ * or null if no state has been committed by the {@link DeviceStateProvider} yet.
* @throws SecurityException if a callback is already registered for the calling process.
*/
- void registerCallback(in IDeviceStateManagerCallback callback);
+ @nullable DeviceStateInfo registerCallback(in IDeviceStateManagerCallback callback);
/**
* Requests that the device enter the supplied {@code state}. A callback <b>MUST</b> have been
diff --git a/core/java/android/hardware/display/DisplayManagerInternal.java b/core/java/android/hardware/display/DisplayManagerInternal.java
index 6c1aa90..75ffcc3 100644
--- a/core/java/android/hardware/display/DisplayManagerInternal.java
+++ b/core/java/android/hardware/display/DisplayManagerInternal.java
@@ -461,6 +461,16 @@
public abstract void stylusGestureStarted(long eventTime);
/**
+ * Called by {@link com.android.server.wm.ContentRecorder} to verify whether
+ * the display is allowed to mirror primary display's content.
+ * @param displayId the id of the display where we mirror to.
+ * @return true if the mirroring dialog is confirmed (display is enabled), or
+ * {@link com.android.server.display.ExternalDisplayPolicy#ENABLE_ON_CONNECT}
+ * system property is enabled.
+ */
+ public abstract boolean isDisplayReadyForMirroring(int displayId);
+
+ /**
* Describes the requested power state of the display.
*
* This object is intended to describe the general characteristics of the
diff --git a/core/java/android/hardware/input/InputSettings.java b/core/java/android/hardware/input/InputSettings.java
index 177ee6f..897ce4a 100644
--- a/core/java/android/hardware/input/InputSettings.java
+++ b/core/java/android/hardware/input/InputSettings.java
@@ -24,6 +24,8 @@
import static com.android.hardware.input.Flags.keyboardA11ySlowKeysFlag;
import static com.android.hardware.input.Flags.keyboardA11yStickyKeysFlag;
import static com.android.hardware.input.Flags.keyboardA11yMouseKeys;
+import static com.android.hardware.input.Flags.mouseReverseVerticalScrolling;
+import static com.android.hardware.input.Flags.mouseSwapPrimaryButton;
import static com.android.hardware.input.Flags.touchpadTapDragging;
import static com.android.hardware.input.Flags.touchpadVisualizer;
import static com.android.input.flags.Flags.enableInputFilterRustImpl;
@@ -363,6 +365,22 @@
}
/**
+ * Returns true if the feature flag for mouse reverse vertical scrolling is enabled.
+ * @hide
+ */
+ public static boolean isMouseReverseVerticalScrollingFeatureFlagEnabled() {
+ return mouseReverseVerticalScrolling();
+ }
+
+ /**
+ * Returns true if the feature flag for mouse swap primary button is enabled.
+ * @hide
+ */
+ public static boolean isMouseSwapPrimaryButtonFeatureFlagEnabled() {
+ return mouseSwapPrimaryButton();
+ }
+
+ /**
* Returns true if the touchpad visualizer is allowed to appear.
*
* @param context The application context.
@@ -501,6 +519,86 @@
}
/**
+ * Whether mouse vertical scrolling is enabled, this applies only to connected mice.
+ *
+ * @param context The application context.
+ * @return Whether the mouse will have its vertical scrolling reversed
+ * (scroll down to move up).
+ *
+ * @hide
+ */
+ public static boolean isMouseReverseVerticalScrollingEnabled(@NonNull Context context) {
+ if (!isMouseReverseVerticalScrollingFeatureFlagEnabled()) {
+ return false;
+ }
+
+ return Settings.System.getIntForUser(context.getContentResolver(),
+ Settings.System.MOUSE_REVERSE_VERTICAL_SCROLLING, 0, UserHandle.USER_CURRENT)
+ != 0;
+ }
+
+ /**
+ * Sets whether the connected mouse will have its vertical scrolling reversed.
+ *
+ * @param context The application context.
+ * @param reverseScrolling Whether reverse scrolling is enabled.
+ *
+ * @hide
+ */
+ @RequiresPermission(Manifest.permission.WRITE_SETTINGS)
+ public static void setMouseReverseVerticalScrolling(@NonNull Context context,
+ boolean reverseScrolling) {
+ if (!isMouseReverseVerticalScrollingFeatureFlagEnabled()) {
+ return;
+ }
+
+ Settings.System.putIntForUser(context.getContentResolver(),
+ Settings.System.MOUSE_REVERSE_VERTICAL_SCROLLING, reverseScrolling ? 1 : 0,
+ UserHandle.USER_CURRENT);
+ }
+
+ /**
+ * Whether the primary mouse button is swapped on connected mice.
+ *
+ * @param context The application context.
+ * @return Whether mice will have their primary buttons swapped, so that left clicking will
+ * perform the secondary action (e.g. show menu) and right clicking will perform the primary
+ * action.
+ *
+ * @hide
+ */
+ public static boolean isMouseSwapPrimaryButtonEnabled(@NonNull Context context) {
+ if (!isMouseSwapPrimaryButtonFeatureFlagEnabled()) {
+ return false;
+ }
+
+ return Settings.System.getIntForUser(context.getContentResolver(),
+ Settings.System.MOUSE_SWAP_PRIMARY_BUTTON, 0, UserHandle.USER_CURRENT)
+ != 0;
+ }
+
+ /**
+ * Sets whether mice will have their primary buttons swapped between left and right
+ * clicks.
+ *
+ * @param context The application context.
+ * @param swapPrimaryButton Whether swapping the primary button is enabled.
+ *
+ * @hide
+ */
+ @RequiresPermission(Manifest.permission.WRITE_SETTINGS)
+ public static void setMouseSwapPrimaryButton(@NonNull Context context,
+ boolean swapPrimaryButton) {
+ if (!isMouseSwapPrimaryButtonFeatureFlagEnabled()) {
+ return;
+ }
+
+ Settings.System.putIntForUser(context.getContentResolver(),
+ Settings.System.MOUSE_SWAP_PRIMARY_BUTTON, swapPrimaryButton ? 1 : 0,
+ UserHandle.USER_CURRENT);
+ }
+
+ /**
* Whether Accessibility bounce keys feature is enabled.
*
* <p>
diff --git a/core/java/android/hardware/input/VirtualDpad.java b/core/java/android/hardware/input/VirtualDpad.java
index 5985c39..5b08a0e 100644
--- a/core/java/android/hardware/input/VirtualDpad.java
+++ b/core/java/android/hardware/input/VirtualDpad.java
@@ -17,7 +17,6 @@
package android.hardware.input;
import android.annotation.NonNull;
-import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.companion.virtual.IVirtualDevice;
import android.os.IBinder;
@@ -72,7 +71,6 @@
*
* @param event the event to send
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void sendKeyEvent(@NonNull VirtualKeyEvent event) {
try {
if (!mSupportedKeyCodes.contains(event.getKeyCode())) {
diff --git a/core/java/android/hardware/input/VirtualInputDevice.java b/core/java/android/hardware/input/VirtualInputDevice.java
index affa4ed..8e4e097 100644
--- a/core/java/android/hardware/input/VirtualInputDevice.java
+++ b/core/java/android/hardware/input/VirtualInputDevice.java
@@ -16,7 +16,6 @@
package android.hardware.input;
-import android.annotation.RequiresPermission;
import android.companion.virtual.IVirtualDevice;
import android.os.IBinder;
import android.os.RemoteException;
@@ -68,7 +67,6 @@
}
@Override
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void close() {
Log.d(TAG, "Closing virtual input device " + mConfig.getInputDeviceName());
try {
diff --git a/core/java/android/hardware/input/VirtualKeyboard.java b/core/java/android/hardware/input/VirtualKeyboard.java
index 6a7d195..9664004 100644
--- a/core/java/android/hardware/input/VirtualKeyboard.java
+++ b/core/java/android/hardware/input/VirtualKeyboard.java
@@ -17,7 +17,6 @@
package android.hardware.input;
import android.annotation.NonNull;
-import android.annotation.RequiresPermission;
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.annotation.TestApi;
@@ -31,8 +30,8 @@
* A virtual keyboard representing a key input mechanism on a remote device, such as a built-in
* keyboard on a laptop, a software keyboard on a tablet, or a keypad on a TV remote control.
*
- * This registers an InputDevice that is interpreted like a physically-connected device and
- * dispatches received events to it.
+ * <p>This registers an InputDevice that is interpreted like a physically-connected device and
+ * dispatches received events to it.</p>
*
* @hide
*/
@@ -52,7 +51,6 @@
*
* @param event the event to send
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void sendKeyEvent(@NonNull VirtualKeyEvent event) {
try {
if (mUnsupportedKeyCode == event.getKeyCode()) {
diff --git a/core/java/android/hardware/input/VirtualMouse.java b/core/java/android/hardware/input/VirtualMouse.java
index fb0f700..f2d113c 100644
--- a/core/java/android/hardware/input/VirtualMouse.java
+++ b/core/java/android/hardware/input/VirtualMouse.java
@@ -17,7 +17,6 @@
package android.hardware.input;
import android.annotation.NonNull;
-import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.companion.virtual.IVirtualDevice;
import android.graphics.PointF;
@@ -30,8 +29,8 @@
* A virtual mouse representing a relative input mechanism on a remote device, such as a mouse or
* trackpad.
*
- * This registers an InputDevice that is interpreted like a physically-connected device and
- * dispatches received events to it.
+ * <p>This registers an InputDevice that is interpreted like a physically-connected device and
+ * dispatches received events to it.</p>
*
* @hide
*/
@@ -50,7 +49,6 @@
* @throws IllegalStateException if the display this mouse is associated with is not currently
* targeted
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void sendButtonEvent(@NonNull VirtualMouseButtonEvent event) {
try {
if (!mVirtualDevice.sendButtonEvent(mToken, event)) {
@@ -70,7 +68,6 @@
* @throws IllegalStateException if the display this mouse is associated with is not currently
* targeted
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void sendScrollEvent(@NonNull VirtualMouseScrollEvent event) {
try {
if (!mVirtualDevice.sendScrollEvent(mToken, event)) {
@@ -89,7 +86,6 @@
* @throws IllegalStateException if the display this mouse is associated with is not currently
* targeted
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void sendRelativeEvent(@NonNull VirtualMouseRelativeEvent event) {
try {
if (!mVirtualDevice.sendRelativeEvent(mToken, event)) {
@@ -108,7 +104,6 @@
* @throws IllegalStateException if the display this mouse is associated with is not currently
* targeted
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public @NonNull PointF getCursorPosition() {
try {
return mVirtualDevice.getCursorPosition(mToken);
diff --git a/core/java/android/hardware/input/VirtualNavigationTouchpad.java b/core/java/android/hardware/input/VirtualNavigationTouchpad.java
index 3dbb385..94e2151 100644
--- a/core/java/android/hardware/input/VirtualNavigationTouchpad.java
+++ b/core/java/android/hardware/input/VirtualNavigationTouchpad.java
@@ -17,7 +17,6 @@
package android.hardware.input;
import android.annotation.NonNull;
-import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.companion.virtual.IVirtualDevice;
import android.os.IBinder;
@@ -51,7 +50,6 @@
*
* @param event the event to send
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void sendTouchEvent(@NonNull VirtualTouchEvent event) {
try {
if (!mVirtualDevice.sendTouchEvent(mToken, event)) {
diff --git a/core/java/android/hardware/input/VirtualRotaryEncoder.java b/core/java/android/hardware/input/VirtualRotaryEncoder.java
index bc131df..47c92c8 100644
--- a/core/java/android/hardware/input/VirtualRotaryEncoder.java
+++ b/core/java/android/hardware/input/VirtualRotaryEncoder.java
@@ -18,7 +18,6 @@
import android.annotation.FlaggedApi;
import android.annotation.NonNull;
-import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.companion.virtual.IVirtualDevice;
import android.companion.virtualdevice.flags.Flags;
@@ -48,7 +47,6 @@
*
* @param event the event to send
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void sendScrollEvent(@NonNull VirtualRotaryEncoderScrollEvent event) {
try {
if (!mVirtualDevice.sendRotaryEncoderScrollEvent(mToken, event)) {
diff --git a/core/java/android/hardware/input/VirtualStylus.java b/core/java/android/hardware/input/VirtualStylus.java
index c763f740..4b79bc4 100644
--- a/core/java/android/hardware/input/VirtualStylus.java
+++ b/core/java/android/hardware/input/VirtualStylus.java
@@ -18,7 +18,6 @@
import android.annotation.FlaggedApi;
import android.annotation.NonNull;
-import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.companion.virtual.IVirtualDevice;
import android.companion.virtual.flags.Flags;
@@ -30,8 +29,8 @@
* A virtual stylus which can be used to inject input into the framework that represents a stylus
* on a remote device.
*
- * This registers an {@link android.view.InputDevice} that is interpreted like a
- * physically-connected device and dispatches received events to it.
+ * <p>This registers an {@link android.view.InputDevice} that is interpreted like a
+ * physically-connected device and dispatches received events to it.</p>
*
* @hide
*/
@@ -49,7 +48,6 @@
*
* @param event the event to send
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void sendMotionEvent(@NonNull VirtualStylusMotionEvent event) {
try {
if (!mVirtualDevice.sendStylusMotionEvent(mToken, event)) {
@@ -66,7 +64,6 @@
*
* @param event the event to send
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void sendButtonEvent(@NonNull VirtualStylusButtonEvent event) {
try {
if (!mVirtualDevice.sendStylusButtonEvent(mToken, event)) {
diff --git a/core/java/android/hardware/input/VirtualTouchscreen.java b/core/java/android/hardware/input/VirtualTouchscreen.java
index 2c800aa..d0537f0 100644
--- a/core/java/android/hardware/input/VirtualTouchscreen.java
+++ b/core/java/android/hardware/input/VirtualTouchscreen.java
@@ -17,7 +17,6 @@
package android.hardware.input;
import android.annotation.NonNull;
-import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.companion.virtual.IVirtualDevice;
import android.os.IBinder;
@@ -27,8 +26,8 @@
/**
* A virtual touchscreen representing a touch-based display input mechanism on a remote device.
*
- * This registers an InputDevice that is interpreted like a physically-connected device and
- * dispatches received events to it.
+ * <p>This registers an InputDevice that is interpreted like a physically-connected device and
+ * dispatches received events to it.</p>
*
* @hide
*/
@@ -45,7 +44,6 @@
*
* @param event the event to send
*/
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void sendTouchEvent(@NonNull VirtualTouchEvent event) {
try {
if (!mVirtualDevice.sendTouchEvent(mToken, event)) {
diff --git a/core/java/android/os/flags.aconfig b/core/java/android/os/flags.aconfig
index 16cb66e..81987907 100644
--- a/core/java/android/os/flags.aconfig
+++ b/core/java/android/os/flags.aconfig
@@ -240,3 +240,11 @@
is_fixed_read_only: true
bug: "370845648"
}
+
+flag {
+ name: "api_for_backported_fixes"
+ namespace: "media_reliability"
+ description: "Public API app developers use to check if a known issue is fixed on a device."
+ bug: "308461809"
+ is_exported: true
+}
diff --git a/core/java/android/permission/flags.aconfig b/core/java/android/permission/flags.aconfig
index 271970b..1d8fcec 100644
--- a/core/java/android/permission/flags.aconfig
+++ b/core/java/android/permission/flags.aconfig
@@ -261,7 +261,7 @@
is_fixed_read_only: true
namespace: "permissions"
description: "If proc state is decreasing over the restriction threshold and capability is changed, delay if no new capabilities are added"
- bug: "308573169"
+ bug: "347891382"
metadata {
purpose: PURPOSE_BUGFIX
}
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 5453c0a..594005c 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -6210,6 +6210,25 @@
public static final String TOUCHPAD_RIGHT_CLICK_ZONE = "touchpad_right_click_zone";
/**
+ * Whether to enable reversed vertical scrolling for connected mice.
+ *
+ * When enabled, scrolling down on the mouse wheel will move the screen up and vice versa.
+ * @hide
+ */
+ public static final String MOUSE_REVERSE_VERTICAL_SCROLLING =
+ "mouse_reverse_vertical_scrolling";
+
+ /**
+ * Whether to enable swapping the primary button for connected mice.
+ *
+ * When enabled, right clicking will be the primary button and left clicking will be the
+ * secondary button (e.g. show menu).
+ * @hide
+ */
+ public static final String MOUSE_SWAP_PRIMARY_BUTTON =
+ "mouse_swap_primary_button";
+
+ /**
* Pointer fill style, specified by
* {@link android.view.PointerIcon.PointerIconVectorStyleFill} constants.
*
@@ -6447,6 +6466,8 @@
PRIVATE_SETTINGS.add(SCREEN_FLASH_NOTIFICATION);
PRIVATE_SETTINGS.add(SCREEN_FLASH_NOTIFICATION_COLOR);
PRIVATE_SETTINGS.add(DEFAULT_DEVICE_FONT_SCALE);
+ PRIVATE_SETTINGS.add(MOUSE_REVERSE_VERTICAL_SCROLLING);
+ PRIVATE_SETTINGS.add(MOUSE_SWAP_PRIMARY_BUTTON);
}
/**
diff --git a/core/java/android/view/ImeInsetsSourceConsumer.java b/core/java/android/view/ImeInsetsSourceConsumer.java
index 229e8ee7..4f74198 100644
--- a/core/java/android/view/ImeInsetsSourceConsumer.java
+++ b/core/java/android/view/ImeInsetsSourceConsumer.java
@@ -221,13 +221,13 @@
@Override
public boolean setControl(@Nullable InsetsSourceControl control, int[] showTypes,
- int[] hideTypes) {
+ int[] hideTypes, int[] cancelTypes) {
if (Flags.refactorInsetsController()) {
- return super.setControl(control, showTypes, hideTypes);
+ return super.setControl(control, showTypes, hideTypes, cancelTypes);
} else {
ImeTracing.getInstance().triggerClientDump("ImeInsetsSourceConsumer#setControl",
mController.getHost().getInputMethodManager(), null /* icProto */);
- if (!super.setControl(control, showTypes, hideTypes)) {
+ if (!super.setControl(control, showTypes, hideTypes, cancelTypes)) {
return false;
}
if (control == null && !mIsRequestedVisibleAwaitingLeash) {
diff --git a/core/java/android/view/InsetsAnimationControlImpl.java b/core/java/android/view/InsetsAnimationControlImpl.java
index 97facc1..4fead2a 100644
--- a/core/java/android/view/InsetsAnimationControlImpl.java
+++ b/core/java/android/view/InsetsAnimationControlImpl.java
@@ -371,6 +371,7 @@
mPendingInsets = mLayoutInsetsDuringAnimation == LAYOUT_INSETS_DURING_ANIMATION_SHOWN
? mShownInsets : mHiddenInsets;
mPendingAlpha = 1f;
+ mPendingFraction = 1f;
applyChangeInsets(null);
mCancelled = true;
mListener.onCancelled(mReadyDispatched ? this : null);
@@ -486,6 +487,17 @@
if (controls == null) {
return;
}
+
+ final boolean visible = mPendingFraction == 0
+ // The first frame of ANIMATION_TYPE_SHOW should be invisible since it is
+ // animated from the hidden state.
+ ? mAnimationType != ANIMATION_TYPE_SHOW
+ : mPendingFraction < 1f || (mFinished
+ ? mShownOnFinish
+ // If the animation is cancelled, mFinished and mShownOnFinish are not set.
+ // Here uses mLayoutInsetsDuringAnimation to decide if it should be visible.
+ : mLayoutInsetsDuringAnimation == LAYOUT_INSETS_DURING_ANIMATION_SHOWN);
+
// TODO: Implement behavior when inset spans over multiple types
for (int i = controls.size() - 1; i >= 0; i--) {
final InsetsSourceControl control = controls.valueAt(i);
@@ -498,12 +510,6 @@
}
addTranslationToMatrix(side, offset, mTmpMatrix, mTmpFrame);
- // The first frame of ANIMATION_TYPE_SHOW should be invisible since it is animated from
- // the hidden state.
- final boolean visible = mPendingFraction == 0
- ? mAnimationType != ANIMATION_TYPE_SHOW
- : !mFinished || mShownOnFinish;
-
if (outState != null && source != null) {
outState.addSource(new InsetsSource(source)
.setVisible(visible)
diff --git a/core/java/android/view/InsetsController.java b/core/java/android/view/InsetsController.java
index 8ac5532..d08873c 100644
--- a/core/java/android/view/InsetsController.java
+++ b/core/java/android/view/InsetsController.java
@@ -957,6 +957,7 @@
int consumedControlCount = 0;
final @InsetsType int[] showTypes = new int[1];
final @InsetsType int[] hideTypes = new int[1];
+ final @InsetsType int[] cancelTypes = new int[1];
ImeTracker.Token statsToken = null;
// Ensure to update all existing source consumers
@@ -982,7 +983,7 @@
// control may be null, but we still need to update the control to null if it got
// revoked.
- consumer.setControl(control, showTypes, hideTypes);
+ consumer.setControl(control, showTypes, hideTypes, cancelTypes);
}
// Ensure to create source consumers if not available yet.
@@ -990,7 +991,7 @@
for (int i = mTmpControlArray.size() - 1; i >= 0; i--) {
final InsetsSourceControl control = mTmpControlArray.valueAt(i);
getSourceConsumer(control.getId(), control.getType())
- .setControl(control, showTypes, hideTypes);
+ .setControl(control, showTypes, hideTypes, cancelTypes);
}
}
@@ -1002,6 +1003,10 @@
}
mTmpControlArray.clear();
+ if (cancelTypes[0] != 0) {
+ cancelExistingControllers(cancelTypes[0]);
+ }
+
// Do not override any animations that the app started in the OnControllableInsetsChanged
// listeners.
int animatingTypes = invokeControllableInsetsChangedListeners();
@@ -2154,12 +2159,12 @@
new InsetsSourceControl(ID_IME_CAPTION_BAR, captionBar(),
null /* leash */, false /* initialVisible */,
new Point(), Insets.NONE),
- new int[1], new int[1]);
+ new int[1], new int[1], new int[1]);
} else {
mState.removeSource(ID_IME_CAPTION_BAR);
InsetsSourceConsumer sourceConsumer = mSourceConsumers.get(ID_IME_CAPTION_BAR);
if (sourceConsumer != null) {
- sourceConsumer.setControl(null, new int[1], new int[1]);
+ sourceConsumer.setControl(null, new int[1], new int[1], new int[1]);
}
}
mHost.notifyInsetsChanged();
diff --git a/core/java/android/view/InsetsSourceConsumer.java b/core/java/android/view/InsetsSourceConsumer.java
index da788a7..17f33c1 100644
--- a/core/java/android/view/InsetsSourceConsumer.java
+++ b/core/java/android/view/InsetsSourceConsumer.java
@@ -122,7 +122,7 @@
/**
* Updates the control delivered from the server.
-
+ *
* @param showTypes An integer array with a single entry that determines which types a show
* animation should be run after setting the control.
* @param hideTypes An integer array with a single entry that determines which types a hide
@@ -130,7 +130,7 @@
* @return Whether the control has changed from the server
*/
public boolean setControl(@Nullable InsetsSourceControl control,
- @InsetsType int[] showTypes, @InsetsType int[] hideTypes) {
+ @InsetsType int[] showTypes, @InsetsType int[] hideTypes, int[] cancelTypes) {
if (Objects.equals(mSourceControl, control)) {
if (mSourceControl != null && mSourceControl != control) {
mSourceControl.release(SurfaceControl::release);
@@ -165,6 +165,12 @@
// Reset the applier to the default one which has the most lightweight implementation.
setSurfaceParamsApplier(InsetsAnimationControlRunner.SurfaceParamsApplier.DEFAULT);
} else {
+ if (lastControl != null && InsetsSource.getInsetSide(lastControl.getInsetsHint())
+ != InsetsSource.getInsetSide(control.getInsetsHint())) {
+ // The source has been moved to a different side. The coordinates are stale.
+ // Canceling existing animation if there is any.
+ cancelTypes[0] |= mType;
+ }
final boolean requestedVisible = isRequestedVisibleAwaitingControl();
final SurfaceControl oldLeash = lastControl != null ? lastControl.getLeash() : null;
final SurfaceControl newLeash = control.getLeash();
diff --git a/core/java/com/android/internal/util/MemInfoReader.java b/core/java/com/android/internal/util/MemInfoReader.java
index 0c5c853..d34bca6 100644
--- a/core/java/com/android/internal/util/MemInfoReader.java
+++ b/core/java/com/android/internal/util/MemInfoReader.java
@@ -88,6 +88,13 @@
}
/**
+ * Amount of RAM that used by shared memory (shmem) and tmpfs
+ */
+ public long getShmemSizeKb() {
+ return mInfos[Debug.MEMINFO_SHMEM];
+ }
+
+ /**
* Amount of RAM that the kernel is being used for caches, not counting caches
* that are mapped in to processes.
*/
diff --git a/core/java/com/android/internal/widget/NotificationProgressBar.java b/core/java/com/android/internal/widget/NotificationProgressBar.java
index 12e1dd9..3e597d7 100644
--- a/core/java/com/android/internal/widget/NotificationProgressBar.java
+++ b/core/java/com/android/internal/widget/NotificationProgressBar.java
@@ -16,15 +16,22 @@
package com.android.internal.widget;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.app.Notification.ProgressStyle;
import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.Icon;
+import android.os.Bundle;
import android.util.AttributeSet;
+import android.view.RemotableViewMethod;
import android.widget.ProgressBar;
import android.widget.RemoteViews;
import androidx.annotation.ColorInt;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.util.Preconditions;
import com.android.internal.widget.NotificationProgressDrawable.Part;
import com.android.internal.widget.NotificationProgressDrawable.Point;
import com.android.internal.widget.NotificationProgressDrawable.Segment;
@@ -42,6 +49,10 @@
*/
@RemoteViews.RemoteView
public class NotificationProgressBar extends ProgressBar {
+ private NotificationProgressModel mProgressModel;
+ @Nullable
+ private Drawable mProgressTrackerDrawable = null;
+
public NotificationProgressBar(Context context) {
this(context, null);
}
@@ -60,6 +71,53 @@
}
/**
+ * Setter for the notification progress model.
+ *
+ * @see NotificationProgressModel#fromBundle
+ * @see #setProgressModelAsync
+ */
+ @RemotableViewMethod(asyncImpl = "setProgressModelAsync")
+ public void setProgressModel(@Nullable Bundle bundle) {
+ Preconditions.checkArgument(bundle != null,
+ "Bundle shouldn't be null");
+
+ mProgressModel = NotificationProgressModel.fromBundle(bundle);
+ }
+
+ private void setProgressModel(@NonNull NotificationProgressModel model) {
+ mProgressModel = model;
+ }
+
+ /**
+ * Setter for the progress tracker icon.
+ *
+ * @see #setProgressTrackerIconAsync
+ */
+ @RemotableViewMethod(asyncImpl = "setProgressTrackerIconAsync")
+ public void setProgressTrackerIcon(@Nullable Icon icon) {
+ }
+
+
+ /**
+ * Async version of {@link #setProgressTrackerIcon}
+ */
+ public Runnable setProgressTrackerIconAsync(@Nullable Icon icon) {
+ final Drawable progressTrackerDrawable;
+ if (icon != null) {
+ progressTrackerDrawable = icon.loadDrawable(getContext());
+ } else {
+ progressTrackerDrawable = null;
+ }
+ return () -> {
+ setProgressTrackerDrawable(progressTrackerDrawable);
+ };
+ }
+
+ private void setProgressTrackerDrawable(@Nullable Drawable drawable) {
+ mProgressTrackerDrawable = drawable;
+ }
+
+ /**
* Processes the ProgressStyle data and convert to list of {@code
* NotificationProgressDrawable.Part}.
*/
diff --git a/core/java/com/android/internal/widget/NotificationProgressModel.java b/core/java/com/android/internal/widget/NotificationProgressModel.java
new file mode 100644
index 0000000..e51ea99
--- /dev/null
+++ b/core/java/com/android/internal/widget/NotificationProgressModel.java
@@ -0,0 +1,183 @@
+/*
+ * 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.internal.widget;
+
+
+import android.annotation.ColorInt;
+import android.annotation.FlaggedApi;
+import android.annotation.NonNull;
+import android.app.Flags;
+import android.app.Notification;
+import android.app.Notification.ProgressStyle.Point;
+import android.app.Notification.ProgressStyle.Segment;
+import android.graphics.Color;
+import android.os.Bundle;
+
+import com.android.internal.util.Preconditions;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * Data model for {@link NotificationProgressBar}.
+ *
+ * This class holds the necessary data to render the notification progressbar.
+ * It is used to bind the progress style progress data to {@link NotificationProgressBar}.
+ *
+ * @hide
+ * @see NotificationProgressModel#toBundle
+ * @see NotificationProgressModel#fromBundle
+ */
+@FlaggedApi(Flags.FLAG_API_RICH_ONGOING)
+public final class NotificationProgressModel {
+ private static final int INVALID_INDETERMINATE_COLOR = Color.TRANSPARENT;
+ private static final String KEY_SEGMENTS = "segments";
+ private static final String KEY_POINTS = "points";
+ private static final String KEY_PROGRESS = "progress";
+ private static final String KEY_IS_STYLED_BY_PROGRESS = "isStyledByProgress";
+ private static final String KEY_INDETERMINATE_COLOR = "indeterminateColor";
+ private final List<Segment> mSegments;
+ private final List<Point> mPoints;
+ private final int mProgress;
+ private final boolean mIsStyledByProgress;
+ @ColorInt
+ private final int mIndeterminateColor;
+
+ public NotificationProgressModel(
+ @NonNull List<Segment> segments,
+ @NonNull List<Point> points,
+ int progress,
+ boolean isStyledByProgress
+ ) {
+ Preconditions.checkArgument(progress >= 0);
+ Preconditions.checkArgument(!segments.isEmpty());
+ mSegments = segments;
+ mPoints = points;
+ mProgress = progress;
+ mIsStyledByProgress = isStyledByProgress;
+ mIndeterminateColor = INVALID_INDETERMINATE_COLOR;
+ }
+
+ public NotificationProgressModel(
+ @ColorInt int indeterminateColor
+ ) {
+ Preconditions.checkArgument(indeterminateColor != INVALID_INDETERMINATE_COLOR);
+ mSegments = Collections.emptyList();
+ mPoints = Collections.emptyList();
+ mProgress = 0;
+ mIsStyledByProgress = false;
+ mIndeterminateColor = indeterminateColor;
+ }
+
+ public List<Segment> getSegments() {
+ return mSegments;
+ }
+
+ public List<Point> getPoints() {
+ return mPoints;
+ }
+
+ public int getProgress() {
+ return mProgress;
+ }
+
+ public boolean isStyledByProgress() {
+ return mIsStyledByProgress;
+ }
+
+ @ColorInt
+ public int getIndeterminateColor() {
+ return mIndeterminateColor;
+ }
+
+ public boolean isIndeterminate() {
+ return mIndeterminateColor != INVALID_INDETERMINATE_COLOR;
+ }
+
+ /**
+ * Returns a {@link Bundle} representation of this {@link NotificationProgressModel}.
+ */
+ @NonNull
+ public Bundle toBundle() {
+ final Bundle bundle = new Bundle();
+ if (mIndeterminateColor != INVALID_INDETERMINATE_COLOR) {
+ bundle.putInt(KEY_INDETERMINATE_COLOR, mIndeterminateColor);
+ } else {
+ bundle.putParcelableList(KEY_SEGMENTS,
+ Notification.ProgressStyle.getProgressSegmentsAsBundleList(mSegments));
+ bundle.putParcelableList(KEY_POINTS,
+ Notification.ProgressStyle.getProgressPointsAsBundleList(mPoints));
+ bundle.putInt(KEY_PROGRESS, mProgress);
+ bundle.putBoolean(KEY_IS_STYLED_BY_PROGRESS, mIsStyledByProgress);
+ }
+ return bundle;
+ }
+
+ /**
+ * Creates a {@link NotificationProgressModel} from a {@link Bundle}.
+ */
+ @NonNull
+ public static NotificationProgressModel fromBundle(@NonNull Bundle bundle) {
+ final int indeterminateColor = bundle.getInt(KEY_INDETERMINATE_COLOR,
+ INVALID_INDETERMINATE_COLOR);
+ if (indeterminateColor != INVALID_INDETERMINATE_COLOR) {
+ return new NotificationProgressModel(indeterminateColor);
+ } else {
+ final List<Segment> segments =
+ Notification.ProgressStyle.getProgressSegmentsFromBundleList(
+ bundle.getParcelableArrayList(KEY_SEGMENTS, Bundle.class));
+ final List<Point> points =
+ Notification.ProgressStyle.getProgressPointsFromBundleList(
+ bundle.getParcelableArrayList(KEY_POINTS, Bundle.class));
+ final int progress = bundle.getInt(KEY_PROGRESS);
+ final boolean isStyledByProgress = bundle.getBoolean(KEY_IS_STYLED_BY_PROGRESS);
+ return new NotificationProgressModel(segments, points, progress, isStyledByProgress);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "NotificationProgressModel{"
+ + "mSegments=" + mSegments
+ + ", mPoints=" + mPoints
+ + ", mProgress=" + mProgress
+ + ", mIsStyledByProgress=" + mIsStyledByProgress
+ + ", mIndeterminateColor=" + mIndeterminateColor + "}";
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ final NotificationProgressModel that = (NotificationProgressModel) o;
+ return mProgress == that.mProgress
+ && mIsStyledByProgress == that.mIsStyledByProgress
+ && mIndeterminateColor == that.mIndeterminateColor
+ && Objects.equals(mSegments, that.mSegments)
+ && Objects.equals(mPoints, that.mPoints);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mSegments,
+ mPoints,
+ mProgress,
+ mIsStyledByProgress,
+ mIndeterminateColor);
+ }
+}
diff --git a/core/proto/android/providers/settings/system.proto b/core/proto/android/providers/settings/system.proto
index e795e809..9779dc0e 100644
--- a/core/proto/android/providers/settings/system.proto
+++ b/core/proto/android/providers/settings/system.proto
@@ -220,6 +220,15 @@
}
optional Touchpad touchpad = 36;
+ message Mouse {
+ option (android.msg_privacy).dest = DEST_EXPLICIT;
+
+ optional SettingProto reverse_vertical_scrolling = 1 [ (android.privacy).dest = DEST_AUTOMATIC ];
+ optional SettingProto swap_primary_button = 2 [ (android.privacy).dest = DEST_AUTOMATIC ];
+ }
+
+ optional Mouse mouse = 38;
+
optional SettingProto tty_mode = 31 [ (android.privacy).dest = DEST_AUTOMATIC ];
message Vibrate {
@@ -277,5 +286,5 @@
// Please insert fields in alphabetical order and group them into messages
// if possible (to avoid reaching the method limit).
- // Next tag = 38;
+ // Next tag = 39;
}
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 549f8df..5693d66 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -155,6 +155,7 @@
<protected-broadcast android:name="android.bluetooth.intent.DISCOVERABLE_TIMEOUT" />
<protected-broadcast android:name="android.bluetooth.action.AUTO_ON_STATE_CHANGED" />
+ <protected-broadcast android:name="android.bluetooth.action.CONNECTION_STATE_CHANGED" />
<protected-broadcast android:name="android.bluetooth.adapter.action.STATE_CHANGED" />
<protected-broadcast android:name="android.bluetooth.adapter.action.SCAN_MODE_CHANGED" />
<protected-broadcast android:name="android.bluetooth.adapter.action.DISCOVERY_STARTED" />
@@ -240,6 +241,8 @@
<protected-broadcast
android:name="android.bluetooth.avrcp-controller.profile.action.FOLDER_LIST" />
<protected-broadcast
+ android:name="android.bluetooth.avrcp-controller.profile.action.PLAYER_SETTING" />
+ <protected-broadcast
android:name="android.bluetooth.avrcp-controller.profile.action.TRACK_EVENT" />
<protected-broadcast
android:name="android.bluetooth.input.profile.action.CONNECTION_STATE_CHANGED" />
@@ -266,6 +269,7 @@
<protected-broadcast
android:name="android.bluetooth.pan.profile.action.CONNECTION_STATE_CHANGED" />
<protected-broadcast android:name="android.bluetooth.action.HAP_CONNECTION_STATE_CHANGED" />
+ <protected-broadcast android:name="android.bluetooth.action.HAP_DEVICE_AVAILABLE" />
<protected-broadcast android:name="android.bluetooth.action.LE_AUDIO_CONNECTION_STATE_CHANGED" />
<protected-broadcast android:name="android.bluetooth.action.LE_AUDIO_ACTIVE_DEVICE_CHANGED" />
<protected-broadcast android:name="android.bluetooth.action.LE_AUDIO_CONF_CHANGED" />
diff --git a/core/res/res/layout/input_method_switch_dialog_new.xml b/core/res/res/layout/input_method_switch_dialog_new.xml
index 058fe3f..118f93b 100644
--- a/core/res/res/layout/input_method_switch_dialog_new.xml
+++ b/core/res/res/layout/input_method_switch_dialog_new.xml
@@ -39,7 +39,7 @@
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:paddingVertical="8dp"
+ android:paddingTop="8dp"
android:clipToPadding="false"
android:layoutManager="com.android.internal.widget.LinearLayoutManager"/>
@@ -74,8 +74,7 @@
android:text="@string/input_method_switcher_settings_button"
android:fontFamily="google-sans-text"
android:textAppearance="?attr/textAppearance"
- android:contentDescription="@string/input_method_language_settings"
- android:visibility="gone"/>
+ android:contentDescription="@string/input_method_language_settings"/>
</LinearLayout>
diff --git a/core/res/res/layout/input_method_switch_item_divider.xml b/core/res/res/layout/input_method_switch_item_divider.xml
new file mode 100644
index 0000000..4f8c963
--- /dev/null
+++ b/core/res/res/layout/input_method_switch_item_divider.xml
@@ -0,0 +1,34 @@
+<?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="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:layout_marginHorizontal="16dp"
+ android:layout_marginTop="8dp"
+ android:layout_marginBottom="16dp">
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="1dp"
+ android:background="?attr/materialColorOutlineVariant"
+ android:layout_marginStart="20dp"
+ android:layout_marginEnd="24dp"
+ android:importantForAccessibility="no"/>
+
+</LinearLayout>
diff --git a/core/res/res/layout/input_method_switch_item_header.xml b/core/res/res/layout/input_method_switch_item_header.xml
new file mode 100644
index 0000000..f0080a6
--- /dev/null
+++ b/core/res/res/layout/input_method_switch_item_header.xml
@@ -0,0 +1,38 @@
+<?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="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:layout_marginHorizontal="16dp"
+ android:layout_marginTop="4dp"
+ android:layout_marginBottom="16dp">
+
+ <TextView
+ android:id="@+id/header_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginHorizontal="8dp"
+ android:ellipsize="end"
+ android:singleLine="true"
+ android:fontFamily="google-sans-text"
+ android:textAppearance="?attr/textAppearance"
+ android:accessibilityHeading="true"
+ android:textColor="?attr/materialColorPrimary"/>
+
+</LinearLayout>
diff --git a/core/res/res/layout/input_method_switch_item_new.xml b/core/res/res/layout/input_method_switch_item_new.xml
index 10d938c..f8710cc 100644
--- a/core/res/res/layout/input_method_switch_item_new.xml
+++ b/core/res/res/layout/input_method_switch_item_new.xml
@@ -16,76 +16,45 @@
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/list_item"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:paddingHorizontal="16dp"
- android:paddingBottom="8dp">
-
- <View
- android:id="@+id/divider"
- android:layout_width="match_parent"
- android:layout_height="1dp"
- android:background="?attr/materialColorSurfaceVariant"
- android:layout_marginStart="20dp"
- android:layout_marginTop="8dp"
- android:layout_marginEnd="24dp"
- android:layout_marginBottom="12dp"
- android:visibility="gone"
- android:importantForAccessibility="no"/>
-
- <TextView
- android:id="@+id/header_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:padding="8dp"
- android:ellipsize="end"
- android:singleLine="true"
- android:fontFamily="google-sans-text"
- android:textAppearance="?attr/textAppearance"
- android:textColor="?attr/materialColorPrimary"
- android:visibility="gone"/>
+ android:layout_height="72dp"
+ android:background="@drawable/input_method_switch_item_background"
+ android:gravity="center_vertical"
+ android:orientation="horizontal"
+ android:layout_marginHorizontal="16dp"
+ android:layout_marginBottom="8dp"
+ android:paddingStart="20dp"
+ android:paddingEnd="24dp">
<LinearLayout
- android:id="@+id/list_item"
- android:layout_width="match_parent"
- android:layout_height="72dp"
- android:background="@drawable/input_method_switch_item_background"
- android:gravity="center_vertical"
- android:orientation="horizontal"
- android:paddingStart="20dp"
- android:paddingEnd="24dp">
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:gravity="start|center_vertical"
+ android:orientation="vertical">
- <LinearLayout
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:gravity="start|center_vertical"
- android:orientation="vertical">
-
- <TextView
- android:id="@+id/text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:ellipsize="marquee"
- android:singleLine="true"
- android:fontFamily="google-sans-text"
- android:textColor="@color/input_method_switch_on_item"
- android:textAppearance="?attr/textAppearanceListItem"/>
-
- </LinearLayout>
-
- <ImageView
- android:id="@+id/image"
- android:layout_width="24dp"
- android:layout_height="24dp"
- android:gravity="center_vertical"
- android:layout_marginStart="12dp"
- android:src="@drawable/ic_check_24dp"
- android:tint="@color/input_method_switch_on_item"
- android:visibility="gone"
- android:importantForAccessibility="no"/>
+ <TextView
+ android:id="@+id/text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:ellipsize="marquee"
+ android:singleLine="true"
+ android:fontFamily="google-sans-text"
+ android:textColor="@color/input_method_switch_on_item"
+ android:textAppearance="?attr/textAppearanceListItem"/>
</LinearLayout>
+ <ImageView
+ android:id="@+id/image"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:gravity="center_vertical"
+ android:layout_marginStart="12dp"
+ android:src="@drawable/ic_check_24dp"
+ android:tint="@color/input_method_switch_on_item"
+ android:visibility="gone"
+ android:importantForAccessibility="no"/>
+
</LinearLayout>
diff --git a/core/res/res/layout/notification_template_material_progress.xml b/core/res/res/layout/notification_template_material_progress.xml
index b413c70..fdcefcc 100644
--- a/core/res/res/layout/notification_template_material_progress.xml
+++ b/core/res/res/layout/notification_template_material_progress.xml
@@ -75,10 +75,11 @@
/>
- <include
+ <com.android.internal.widget.NotificationProgressBar
+ android:id="@+id/progress"
android:layout_width="0dp"
android:layout_height="@dimen/notification_progress_bar_height"
- layout="@layout/notification_template_progress"
+ style="@style/Widget.Material.Light.ProgressBar.Horizontal"
android:layout_weight="1"
/>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index c1893ab..4f63fac 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -1582,6 +1582,8 @@
<java-symbol type="layout" name="input_method" />
<java-symbol type="layout" name="input_method_extract_view" />
<java-symbol type="layout" name="input_method_switch_item" />
+ <java-symbol type="layout" name="input_method_switch_item_divider" />
+ <java-symbol type="layout" name="input_method_switch_item_header" />
<java-symbol type="layout" name="input_method_switch_item_new" />
<java-symbol type="layout" name="input_method_switch_dialog_new" />
<java-symbol type="layout" name="input_method_switch_dialog_title" />
diff --git a/core/tests/coretests/src/android/view/InsetsAnimationControlImplTest.java b/core/tests/coretests/src/android/view/InsetsAnimationControlImplTest.java
index ba6f62c..d7f6a29 100644
--- a/core/tests/coretests/src/android/view/InsetsAnimationControlImplTest.java
+++ b/core/tests/coretests/src/android/view/InsetsAnimationControlImplTest.java
@@ -100,14 +100,14 @@
topConsumer.setControl(
new InsetsSourceControl(ID_STATUS_BAR, WindowInsets.Type.statusBars(),
mStatusLeash, true, new Point(0, 0), Insets.of(0, 100, 0, 0)),
- new int[1], new int[1]);
+ new int[1], new int[1], new int[1]);
InsetsSourceConsumer navConsumer = new InsetsSourceConsumer(ID_NAVIGATION_BAR,
WindowInsets.Type.navigationBars(), mInsetsState, mMockController);
navConsumer.setControl(
new InsetsSourceControl(ID_NAVIGATION_BAR, WindowInsets.Type.navigationBars(),
mNavLeash, true, new Point(400, 0), Insets.of(0, 0, 100, 0)),
- new int[1], new int[1]);
+ new int[1], new int[1], new int[1]);
mMockController.setRequestedVisibleTypes(0, WindowInsets.Type.navigationBars());
navConsumer.applyLocalVisibilityOverride();
diff --git a/core/tests/coretests/src/android/view/InsetsSourceConsumerTest.java b/core/tests/coretests/src/android/view/InsetsSourceConsumerTest.java
index d6d45e8..3a8f7ee 100644
--- a/core/tests/coretests/src/android/view/InsetsSourceConsumerTest.java
+++ b/core/tests/coretests/src/android/view/InsetsSourceConsumerTest.java
@@ -117,7 +117,23 @@
mConsumer.setControl(
new InsetsSourceControl(ID_STATUS_BAR, statusBars(), mLeash,
true /* initialVisible */, new Point(), Insets.NONE),
- new int[1], new int[1]);
+ new int[1], new int[1], new int[1]);
+ }
+
+ @Test
+ public void testSetControl_cancelAnimation() {
+ InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
+ final InsetsSourceControl newControl = new InsetsSourceControl(mConsumer.getControl());
+
+ // Change the side of the insets hint.
+ newControl.setInsetsHint(Insets.of(0, 0, 0, 100));
+
+ int[] cancelTypes = {0};
+ mConsumer.setControl(newControl, new int[1], new int[1], cancelTypes);
+
+ assertEquals(statusBars(), cancelTypes[0]);
+ });
+
}
@Test
@@ -180,7 +196,7 @@
@Test
public void testRestore() {
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
- mConsumer.setControl(null, new int[1], new int[1]);
+ mConsumer.setControl(null, new int[1], new int[1], new int[1]);
mSurfaceParamsApplied = false;
mController.setRequestedVisibleTypes(0 /* visibleTypes */, statusBars());
assertFalse(mSurfaceParamsApplied);
@@ -188,7 +204,7 @@
mConsumer.setControl(
new InsetsSourceControl(ID_STATUS_BAR, statusBars(), mLeash,
true /* initialVisible */, new Point(), Insets.NONE),
- new int[1], hideTypes);
+ new int[1], hideTypes, new int[1]);
assertEquals(statusBars(), hideTypes[0]);
assertFalse(mRemoveSurfaceCalled);
});
@@ -198,7 +214,7 @@
public void testRestore_noAnimation() {
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
mController.setRequestedVisibleTypes(0 /* visibleTypes */, statusBars());
- mConsumer.setControl(null, new int[1], new int[1]);
+ mConsumer.setControl(null, new int[1], new int[1], new int[1]);
mLeash = new SurfaceControl.Builder(mSession)
.setName("testSurface")
.build();
@@ -207,7 +223,7 @@
mConsumer.setControl(
new InsetsSourceControl(ID_STATUS_BAR, statusBars(), mLeash,
false /* initialVisible */, new Point(), Insets.NONE),
- new int[1], hideTypes);
+ new int[1], hideTypes, new int[1]);
assertTrue(mRemoveSurfaceCalled);
assertEquals(0, hideTypes[0]);
});
@@ -235,7 +251,8 @@
// Initial IME insets source control with its leash.
imeConsumer.setControl(new InsetsSourceControl(ID_IME, ime(), mLeash,
- false /* initialVisible */, new Point(), Insets.NONE), new int[1], new int[1]);
+ false /* initialVisible */, new Point(), Insets.NONE), new int[1], new int[1],
+ new int[1]);
mSurfaceParamsApplied = false;
// Verify when the app requests controlling show IME animation, the IME leash
@@ -244,7 +261,8 @@
null /* interpolator */, null /* cancellationSignal */, null /* listener */);
assertEquals(ANIMATION_TYPE_USER, insetsController.getAnimationType(ime()));
imeConsumer.setControl(new InsetsSourceControl(ID_IME, ime(), mLeash,
- true /* initialVisible */, new Point(), Insets.NONE), new int[1], new int[1]);
+ true /* initialVisible */, new Point(), Insets.NONE), new int[1], new int[1],
+ new int[1]);
assertFalse(mSurfaceParamsApplied);
});
}
diff --git a/core/tests/coretests/src/com/android/internal/widget/NotificationProgressModelTest.java b/core/tests/coretests/src/com/android/internal/widget/NotificationProgressModelTest.java
new file mode 100644
index 0000000..962399e
--- /dev/null
+++ b/core/tests/coretests/src/com/android/internal/widget/NotificationProgressModelTest.java
@@ -0,0 +1,111 @@
+/*
+ * 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.internal.widget;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.app.Flags;
+import android.app.Notification;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.platform.test.annotations.EnableFlags;
+import android.platform.test.flag.junit.SetFlagsRule;
+
+import androidx.test.filters.SmallTest;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import java.util.List;
+
+@SmallTest
+@EnableFlags(Flags.FLAG_API_RICH_ONGOING)
+public class NotificationProgressModelTest {
+
+ @Rule
+ public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
+
+ @Test(expected = IllegalArgumentException.class)
+ public void throw_exception_on_transparent_indeterminate_color() {
+ new NotificationProgressModel(Color.TRANSPARENT);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void throw_exception_on_empty_segments() {
+ new NotificationProgressModel(List.of(),
+ List.of(),
+ 10,
+ false);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void throw_exception_on_negative_progress() {
+ new NotificationProgressModel(
+ List.of(new Notification.ProgressStyle.Segment(50).setColor(Color.YELLOW)),
+ List.of(),
+ -1,
+ false);
+ }
+
+ @Test
+ public void save_and_restore_indeterminate_progress_model() {
+ // GIVEN
+ final NotificationProgressModel savedModel = new NotificationProgressModel(Color.RED);
+ final Bundle bundle = savedModel.toBundle();
+
+ // WHEN
+ final NotificationProgressModel restoredModel =
+ NotificationProgressModel.fromBundle(bundle);
+
+ // THEN
+ assertThat(restoredModel.getIndeterminateColor()).isEqualTo(Color.RED);
+ assertThat(restoredModel.isIndeterminate()).isTrue();
+ assertThat(restoredModel.getProgress()).isEqualTo(-1);
+ assertThat(restoredModel.getSegments()).isEmpty();
+ assertThat(restoredModel.getPoints()).isEmpty();
+ assertThat(restoredModel.isStyledByProgress()).isFalse();
+ }
+
+ @Test
+ public void save_and_restore_non_indeterminate_progress_model() {
+ // GIVEN
+ final List<Notification.ProgressStyle.Segment> segments = List.of(
+ new Notification.ProgressStyle.Segment(50).setColor(Color.YELLOW),
+ new Notification.ProgressStyle.Segment(50).setColor(Color.LTGRAY));
+ final List<Notification.ProgressStyle.Point> points = List.of(
+ new Notification.ProgressStyle.Point(0).setColor(Color.RED),
+ new Notification.ProgressStyle.Point(20).setColor(Color.BLUE));
+ final NotificationProgressModel savedModel = new NotificationProgressModel(segments,
+ points,
+ 100,
+ true);
+
+ final Bundle bundle = savedModel.toBundle();
+
+ // WHEN
+ final NotificationProgressModel restoredModel =
+ NotificationProgressModel.fromBundle(bundle);
+
+ // THEN
+ assertThat(restoredModel.isIndeterminate()).isFalse();
+ assertThat(restoredModel.getSegments()).isEqualTo(segments);
+ assertThat(restoredModel.getPoints()).isEqualTo(points);
+ assertThat(restoredModel.getProgress()).isEqualTo(100);
+ assertThat(restoredModel.isStyledByProgress()).isTrue();
+ assertThat(restoredModel.getIndeterminateColor()).isEqualTo(-1);
+ }
+}
diff --git a/core/tests/devicestatetests/Android.bp b/core/tests/devicestatetests/Android.bp
index a2aa62d..e573a51 100644
--- a/core/tests/devicestatetests/Android.bp
+++ b/core/tests/devicestatetests/Android.bp
@@ -28,8 +28,10 @@
static_libs: [
"androidx.test.ext.junit",
"androidx.test.rules",
+ "flag-junit",
"frameworks-base-testutils",
"mockito-target-minus-junit4",
+ "platform-parametric-runner-lib",
"platform-test-annotations",
"truth",
],
diff --git a/core/tests/devicestatetests/src/android/hardware/devicestate/DeviceStateManagerGlobalTest.java b/core/tests/devicestatetests/src/android/hardware/devicestate/DeviceStateManagerGlobalTest.java
index 7c01ecc..e640ce5 100644
--- a/core/tests/devicestatetests/src/android/hardware/devicestate/DeviceStateManagerGlobalTest.java
+++ b/core/tests/devicestatetests/src/android/hardware/devicestate/DeviceStateManagerGlobalTest.java
@@ -18,8 +18,10 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
@@ -29,15 +31,20 @@
import android.os.IBinder;
import android.os.RemoteException;
import android.os.test.FakePermissionEnforcer;
+import android.platform.test.annotations.DisableFlags;
+import android.platform.test.annotations.EnableFlags;
+import android.platform.test.flag.junit.FlagsParameterization;
+import android.platform.test.flag.junit.SetFlagsRule;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.util.ConcurrentUtils;
+import com.android.window.flags.Flags;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -46,6 +53,9 @@
import java.util.List;
import java.util.Set;
+import platform.test.runner.parameterized.ParameterizedAndroidJunit4;
+import platform.test.runner.parameterized.Parameters;
+
/**
* Unit tests for {@link DeviceStateManagerGlobal}.
*
@@ -53,18 +63,30 @@
* atest FrameworksCoreDeviceStateManagerTests:DeviceStateManagerGlobalTest
*/
@SmallTest
-@RunWith(AndroidJUnit4.class)
+@RunWith(ParameterizedAndroidJunit4.class)
public final class DeviceStateManagerGlobalTest {
private static final DeviceState DEFAULT_DEVICE_STATE = new DeviceState(
new DeviceState.Configuration.Builder(0 /* identifier */, "" /* name */).build());
private static final DeviceState OTHER_DEVICE_STATE = new DeviceState(
new DeviceState.Configuration.Builder(1 /* identifier */, "" /* name */).build());
+ @Rule
+ public final SetFlagsRule mSetFlagsRule;
+
+ @Parameters(name = "{0}")
+ public static List<FlagsParameterization> getParams() {
+ return FlagsParameterization.allCombinationsOf(Flags.FLAG_WLINFO_ONCREATE);
+ }
+
@NonNull
private TestDeviceStateManagerService mService;
@NonNull
private DeviceStateManagerGlobal mDeviceStateManagerGlobal;
+ public DeviceStateManagerGlobalTest(FlagsParameterization flags) {
+ mSetFlagsRule = new SetFlagsRule(flags);
+ }
+
@Before
public void setUp() {
final FakePermissionEnforcer permissionEnforcer = new FakePermissionEnforcer();
@@ -74,6 +96,36 @@
}
@Test
+ @DisableFlags(Flags.FLAG_WLINFO_ONCREATE)
+ public void create_whenWlinfoOncreateIsDisabled_receivesDeviceStateInfoFromCallback() {
+ final FakePermissionEnforcer permissionEnforcer = new FakePermissionEnforcer();
+ final TestDeviceStateManagerService service = new TestDeviceStateManagerService(
+ permissionEnforcer, true /* simulatePostCallback */);
+ final DeviceStateManagerGlobal dsmGlobal = new DeviceStateManagerGlobal(service);
+ final DeviceStateCallback callback = mock(DeviceStateCallback.class);
+ dsmGlobal.registerDeviceStateCallback(callback, ConcurrentUtils.DIRECT_EXECUTOR);
+
+ verify(callback, never()).onDeviceStateChanged(any());
+
+ // Simulate DeviceStateManagerService#registerProcess by notifying clients of current device
+ // state via callback.
+ service.notifyDeviceStateInfoChanged();
+ verify(callback).onDeviceStateChanged(eq(DEFAULT_DEVICE_STATE));
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_WLINFO_ONCREATE)
+ public void create_whenWlinfoOncreateIsEnabled_returnsDeviceStateInfoFromRegistration() {
+ final FakePermissionEnforcer permissionEnforcer = new FakePermissionEnforcer();
+ final IDeviceStateManager service = new TestDeviceStateManagerService(permissionEnforcer);
+ final DeviceStateManagerGlobal dsmGlobal = new DeviceStateManagerGlobal(service);
+ final DeviceStateCallback callback = mock(DeviceStateCallback.class);
+ dsmGlobal.registerDeviceStateCallback(callback, ConcurrentUtils.DIRECT_EXECUTOR);
+
+ verify(callback).onDeviceStateChanged(eq(DEFAULT_DEVICE_STATE));
+ }
+
+ @Test
public void registerCallback() {
final DeviceStateCallback callback1 = mock(DeviceStateCallback.class);
final DeviceStateCallback callback2 = mock(DeviceStateCallback.class);
@@ -267,10 +319,17 @@
@Nullable
private Request mBaseStateRequest;
+ private final boolean mSimulatePostCallback;
private final Set<IDeviceStateManagerCallback> mCallbacks = new HashSet<>();
TestDeviceStateManagerService(@NonNull FakePermissionEnforcer enforcer) {
+ this(enforcer, false /* simulatePostCallback */);
+ }
+
+ TestDeviceStateManagerService(@NonNull FakePermissionEnforcer enforcer,
+ boolean simulatePostCallback) {
super(enforcer);
+ mSimulatePostCallback = simulatePostCallback;
}
@NonNull
@@ -304,18 +363,26 @@
return getInfo();
}
+ @Nullable
@Override
- public void registerCallback(IDeviceStateManagerCallback callback) {
+ public DeviceStateInfo registerCallback(IDeviceStateManagerCallback callback) {
if (mCallbacks.contains(callback)) {
throw new SecurityException("Callback is already registered.");
}
mCallbacks.add(callback);
- try {
- callback.onDeviceStateInfoChanged(getInfo());
- } catch (RemoteException e) {
- e.rethrowFromSystemServer();
+ if (Flags.wlinfoOncreate()) {
+ return getInfo();
}
+
+ if (!mSimulatePostCallback) {
+ try {
+ callback.onDeviceStateInfoChanged(getInfo());
+ } catch (RemoteException e) {
+ e.rethrowFromSystemServer();
+ }
+ }
+ return null;
}
@Override
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
index b74d922..2d5597e 100644
--- a/libs/WindowManager/Shell/res/drawable/app_handle_education_tooltip_icon.xml
+++ b/libs/WindowManager/Shell/res/drawable/app_handle_education_tooltip_icon.xml
@@ -19,9 +19,15 @@
android:width="24dp"
android:height="24dp"
android:tint="?android:attr/textColorTertiary"
- android:viewportHeight="960"
- android:viewportWidth="960">
+ android:viewportHeight="24"
+ android:viewportWidth="24">
<path
android:fillColor="@android:color/system_on_tertiary_container_light"
- 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>
+ android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4C10,21.1 10.9,22 12,22z"/>
+ <path
+ android:fillColor="@android:color/system_on_tertiary_container_light"
+ android:pathData="M8,17h8v2h-8z"/>
+ <path
+ android:fillColor="@android:color/system_on_tertiary_container_light"
+ android:pathData="M12,2C7.86,2 4.5,5.36 4.5,9.5c0,3.82 2.66,5.86 3.77,6.5h7.46c1.11,-0.64 3.77,-2.68 3.77,-6.5C19.5,5.36 16.14,2 12,2z"/>
+ </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
index a12a746..473236c 100644
--- a/libs/WindowManager/Shell/res/drawable/desktop_windowing_education_tooltip_background.xml
+++ b/libs/WindowManager/Shell/res/drawable/desktop_windowing_education_tooltip_background.xml
@@ -18,7 +18,7 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
- <corners android:radius="30dp" />
+ <corners android:radius="28dp" />
<solid android:color="@android:color/system_tertiary_fixed" />
</shape>
</item>
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
index a269b9e..fd75827 100644
--- 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
@@ -26,6 +26,7 @@
android:id="@+id/arrow_icon"
android:layout_width="10dp"
android:layout_height="12dp"
+ android:elevation="2dp"
android:layout_gravity="center_vertical"
android:src="@drawable/desktop_windowing_education_tooltip_left_arrow" />
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
index 09a049c..42f955d 100644
--- a/libs/WindowManager/Shell/res/layout/desktop_windowing_education_tooltip_container.xml
+++ b/libs/WindowManager/Shell/res/layout/desktop_windowing_education_tooltip_container.xml
@@ -16,16 +16,18 @@
<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:layout_width="wrap_content"
+ android:layout_height="wrap_content"
android:background="@drawable/desktop_windowing_education_tooltip_background"
android:orientation="horizontal"
+ android:elevation="2dp"
android:padding="@dimen/desktop_windowing_education_tooltip_padding">
<ImageView
android:id="@+id/tooltip_icon"
android:layout_width="32dp"
android:layout_height="32dp"
+ android:layout_margin="8dp"
android:layout_gravity="center_vertical"
android:src="@drawable/app_handle_education_tooltip_icon" />
@@ -34,9 +36,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
- android:layout_marginStart="2dp"
+ android:layout_marginHorizontal="8dp"
android:lineHeight="20dp"
- android:maxWidth="150dp"
+ android:maxWidth="220dp"
android:textColor="@android:color/system_on_tertiary_container_light"
android:textFontWeight="500"
android:textSize="14sp" />
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
index c73c1da..83d7ef7 100644
--- 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
@@ -25,6 +25,7 @@
android:id="@+id/arrow_icon"
android:layout_width="12dp"
android:layout_height="9dp"
+ android:elevation="2dp"
android:layout_gravity="center_horizontal"
android:src="@drawable/desktop_windowing_education_tooltip_top_arrow" />
diff --git a/libs/WindowManager/Shell/res/values/strings.xml b/libs/WindowManager/Shell/res/values/strings.xml
index 5ef8432..621e2aa 100644
--- a/libs/WindowManager/Shell/res/values/strings.xml
+++ b/libs/WindowManager/Shell/res/values/strings.xml
@@ -220,13 +220,13 @@
<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>
+ <string name="windowing_app_handle_education_tooltip">The app menu can be found here</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>
+ <string name="windowing_desktop_mode_image_button_education_tooltip">Enter desktop view to open 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>
+ <string name="windowing_desktop_mode_exit_education_tooltip">Return to full screen anytime 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/hwui/apex/LayoutlibLoader.cpp b/libs/hwui/apex/LayoutlibLoader.cpp
index b4e6b72..56191c0 100644
--- a/libs/hwui/apex/LayoutlibLoader.cpp
+++ b/libs/hwui/apex/LayoutlibLoader.cpp
@@ -205,6 +205,13 @@
jmethodID getPropertyMethod = GetStaticMethodIDOrDie(env, system, "getProperty",
"(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;");
+ auto formatProperty = (jstring)env->CallStaticObjectMethod(
+ system, getPropertyMethod, env->NewStringUTF("method_binding_format"),
+ env->NewStringUTF(""));
+ const char* methodFormatChars = env->GetStringUTFChars(formatProperty, 0);
+ setJniMethodFormat(string(methodFormatChars));
+ env->ReleaseStringUTFChars(formatProperty, methodFormatChars);
+
// Get the names of classes that need to register their native methods
auto nativesClassesJString = (jstring)env->CallStaticObjectMethod(
system, getPropertyMethod, env->NewStringUTF("graphics_native_classes"),
diff --git a/nfc/api/system-current.txt b/nfc/api/system-current.txt
index 4428ade..24e14e6 100644
--- a/nfc/api/system-current.txt
+++ b/nfc/api/system-current.txt
@@ -63,7 +63,7 @@
method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean isAutoChangeEnabled();
method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean isTagPresent();
method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void maybeTriggerFirmwareUpdate();
- method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void overwriteRoutingTable(int, int, int);
+ method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void overwriteRoutingTable(int, int, int, int);
method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void pausePolling(int);
method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void registerCallback(@NonNull java.util.concurrent.Executor, @NonNull android.nfc.NfcOemExtension.Callback);
method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void resumePolling();
diff --git a/nfc/java/android/nfc/INfcCardEmulation.aidl b/nfc/java/android/nfc/INfcCardEmulation.aidl
index 1eae3c6..8535e4a 100644
--- a/nfc/java/android/nfc/INfcCardEmulation.aidl
+++ b/nfc/java/android/nfc/INfcCardEmulation.aidl
@@ -54,5 +54,5 @@
void setAutoChangeStatus(boolean state);
boolean isAutoChangeEnabled();
List<String> getRoutingStatus();
- void overwriteRoutingTable(int userHandle, String emptyAid, String protocol, String tech);
+ void overwriteRoutingTable(int userHandle, String emptyAid, String protocol, String tech, String sc);
}
diff --git a/nfc/java/android/nfc/NfcOemExtension.java b/nfc/java/android/nfc/NfcOemExtension.java
index fb63b5c..bc410c7 100644
--- a/nfc/java/android/nfc/NfcOemExtension.java
+++ b/nfc/java/android/nfc/NfcOemExtension.java
@@ -647,24 +647,29 @@
* {@link ProtocolAndTechnologyRoute}
* @param emptyAid Zero-length AID route destination, where the possible inputs are defined in
* {@link ProtocolAndTechnologyRoute}
+ * @param systemCode System Code route destination, where the possible inputs are defined in
+ * {@link ProtocolAndTechnologyRoute}
*/
@RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS)
@FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION)
public void overwriteRoutingTable(
@CardEmulation.ProtocolAndTechnologyRoute int protocol,
@CardEmulation.ProtocolAndTechnologyRoute int technology,
- @CardEmulation.ProtocolAndTechnologyRoute int emptyAid) {
+ @CardEmulation.ProtocolAndTechnologyRoute int emptyAid,
+ @CardEmulation.ProtocolAndTechnologyRoute int systemCode) {
String protocolRoute = routeIntToString(protocol);
String technologyRoute = routeIntToString(technology);
String emptyAidRoute = routeIntToString(emptyAid);
+ String systemCodeRoute = routeIntToString(systemCode);
NfcAdapter.callService(() ->
NfcAdapter.sCardEmulationService.overwriteRoutingTable(
mContext.getUser().getIdentifier(),
emptyAidRoute,
protocolRoute,
- technologyRoute
+ technologyRoute,
+ systemCodeRoute
));
}
diff --git a/packages/CrashRecovery/framework/Android.bp b/packages/CrashRecovery/framework/Android.bp
index 9480327..1be776d 100644
--- a/packages/CrashRecovery/framework/Android.bp
+++ b/packages/CrashRecovery/framework/Android.bp
@@ -1,53 +1,12 @@
-soong_config_module_type {
- name: "platform_filegroup",
- module_type: "filegroup",
- config_namespace: "ANDROID",
- bool_variables: [
- "crashrecovery_files_in_platform",
- ],
- properties: [
- "srcs",
- ],
-}
-
-platform_filegroup {
+filegroup {
name: "framework-crashrecovery-sources",
- soong_config_variables: {
- // if this flag is enabled, then files are part of platform
- crashrecovery_files_in_platform: {
- srcs: [
- "java/**/*.java",
- "java/**/*.aidl",
- ],
- },
- },
- path: "java",
- visibility: ["//frameworks/base:__subpackages__"],
-}
-
-soong_config_module_type {
- name: "module_filegroup",
- module_type: "filegroup",
- config_namespace: "ANDROID",
- bool_variables: [
- "crashrecovery_files_in_module",
+ srcs: [
+ "java/**/*.java",
+ "java/**/*.aidl",
],
- properties: [
- "srcs",
- ],
-}
-
-module_filegroup {
- name: "framework-crashrecovery-module-sources",
- soong_config_variables: {
- // if this flag is enabled, then files are part of module
- crashrecovery_files_in_module: {
- srcs: [
- "java/**/*.java",
- "java/**/*.aidl",
- ],
- },
- },
path: "java",
- visibility: ["//packages/modules/CrashRecovery/framework"],
+ visibility: [
+ "//frameworks/base:__subpackages__",
+ "//packages/modules/CrashRecovery/framework",
+ ],
}
diff --git a/packages/SettingsLib/DataStore/src/com/android/settingslib/datastore/KeyValueStore.kt b/packages/SettingsLib/DataStore/src/com/android/settingslib/datastore/KeyValueStore.kt
index 3d41337..5f1f8df 100644
--- a/packages/SettingsLib/DataStore/src/com/android/settingslib/datastore/KeyValueStore.kt
+++ b/packages/SettingsLib/DataStore/src/com/android/settingslib/datastore/KeyValueStore.kt
@@ -25,6 +25,7 @@
fun contains(key: String): Boolean
/** Gets default value of given key. */
+ @Suppress("UNCHECKED_CAST")
fun <T : Any> getDefaultValue(key: String, valueType: Class<T>): T? =
when (valueType) {
Boolean::class.javaObjectType -> false
@@ -56,6 +57,7 @@
override fun contains(key: String): Boolean = sharedPreferences.contains(key)
+ @Suppress("IMPLICIT_CAST_TO_ANY", "UNCHECKED_CAST")
override fun <T : Any> getValue(key: String, valueType: Class<T>): T? =
when (valueType) {
Boolean::class.javaObjectType -> sharedPreferences.getBoolean(key, false)
@@ -68,6 +70,7 @@
}
as T?
+ @Suppress("UNCHECKED_CAST")
override fun <T : Any> setValue(key: String, valueType: Class<T>, value: T?) {
if (value == null) {
sharedPreferences.edit().remove(key).apply()
diff --git a/packages/SettingsLib/DataStore/src/com/android/settingslib/datastore/SettingsGlobalStore.kt b/packages/SettingsLib/DataStore/src/com/android/settingslib/datastore/SettingsGlobalStore.kt
index 4aef0fc..fb93559 100644
--- a/packages/SettingsLib/DataStore/src/com/android/settingslib/datastore/SettingsGlobalStore.kt
+++ b/packages/SettingsLib/DataStore/src/com/android/settingslib/datastore/SettingsGlobalStore.kt
@@ -34,6 +34,7 @@
override fun contains(key: String): Boolean = Global.getString(contentResolver, key) != null
+ @Suppress("UNCHECKED_CAST")
override fun <T : Any> getValue(key: String, valueType: Class<T>): T? =
try {
when (valueType) {
diff --git a/packages/SettingsLib/DataStore/src/com/android/settingslib/datastore/SettingsSecureStore.kt b/packages/SettingsLib/DataStore/src/com/android/settingslib/datastore/SettingsSecureStore.kt
index 9f41ecb..bc37571 100644
--- a/packages/SettingsLib/DataStore/src/com/android/settingslib/datastore/SettingsSecureStore.kt
+++ b/packages/SettingsLib/DataStore/src/com/android/settingslib/datastore/SettingsSecureStore.kt
@@ -34,6 +34,7 @@
override fun contains(key: String): Boolean = Secure.getString(contentResolver, key) != null
+ @Suppress("UNCHECKED_CAST")
override fun <T : Any> getValue(key: String, valueType: Class<T>): T? =
try {
when (valueType) {
diff --git a/packages/SettingsLib/DataStore/src/com/android/settingslib/datastore/SettingsStore.kt b/packages/SettingsLib/DataStore/src/com/android/settingslib/datastore/SettingsStore.kt
index 5981688..fdefa39 100644
--- a/packages/SettingsLib/DataStore/src/com/android/settingslib/datastore/SettingsStore.kt
+++ b/packages/SettingsLib/DataStore/src/com/android/settingslib/datastore/SettingsStore.kt
@@ -27,7 +27,7 @@
import java.util.concurrent.atomic.AtomicInteger
/** Base class of the Settings provider data stores. */
-open abstract class SettingsStore(protected val contentResolver: ContentResolver) :
+abstract class SettingsStore(protected val contentResolver: ContentResolver) :
KeyedDataObservable<String>(), KeyValueStore {
/**
diff --git a/packages/SettingsLib/DataStore/src/com/android/settingslib/datastore/SettingsSystemStore.kt b/packages/SettingsLib/DataStore/src/com/android/settingslib/datastore/SettingsSystemStore.kt
index 6cca7ed..1c75c7c 100644
--- a/packages/SettingsLib/DataStore/src/com/android/settingslib/datastore/SettingsSystemStore.kt
+++ b/packages/SettingsLib/DataStore/src/com/android/settingslib/datastore/SettingsSystemStore.kt
@@ -34,6 +34,7 @@
override fun contains(key: String): Boolean = System.getString(contentResolver, key) != null
+ @Suppress("UNCHECKED_CAST")
override fun <T : Any> getValue(key: String, valueType: Class<T>): T? =
try {
when (valueType) {
diff --git a/packages/SettingsLib/Preference/src/com/android/settingslib/preference/PreferenceDataStoreAdapter.kt b/packages/SettingsLib/Preference/src/com/android/settingslib/preference/PreferenceDataStoreAdapter.kt
index 02acfca..c2728b4 100644
--- a/packages/SettingsLib/Preference/src/com/android/settingslib/preference/PreferenceDataStoreAdapter.kt
+++ b/packages/SettingsLib/Preference/src/com/android/settingslib/preference/PreferenceDataStoreAdapter.kt
@@ -37,6 +37,7 @@
override fun getString(key: String, defValue: String?): String? =
keyValueStore.getValue(key, String::class.javaObjectType) ?: defValue
+ @Suppress("UNCHECKED_CAST")
override fun getStringSet(key: String, defValues: Set<String>?): Set<String>? =
(keyValueStore.getValue(key, Set::class.javaObjectType) as Set<String>?) ?: defValues
diff --git a/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/framework/theme/SettingsDimension.kt b/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/framework/theme/SettingsDimension.kt
index 5dca637..3957483 100644
--- a/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/framework/theme/SettingsDimension.kt
+++ b/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/framework/theme/SettingsDimension.kt
@@ -22,6 +22,7 @@
object SettingsDimension {
val paddingTiny = 2.dp
val paddingExtraSmall = 4.dp
+ val paddingExtraSmall1 = 6.dp
val paddingSmall = if (isSpaExpressiveEnabled) 8.dp else 4.dp
val paddingExtraSmall5 = 10.dp
val paddingExtraSmall6 = 12.dp
@@ -87,4 +88,7 @@
val illustrationCornerRadius = 28.dp
val preferenceMinHeight = 72.dp
+
+ val spinnerOptionMinHeight = 48.dp
+ val spinnerIconSize = 20.dp
}
diff --git a/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/framework/theme/SettingsShape.kt b/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/framework/theme/SettingsShape.kt
index c787715..86ba686 100644
--- a/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/framework/theme/SettingsShape.kt
+++ b/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/framework/theme/SettingsShape.kt
@@ -24,7 +24,9 @@
val CornerMedium = RoundedCornerShape(12.dp)
- val categoryCorner = RoundedCornerShape(20.dp)
+ val CornerMedium2 = RoundedCornerShape(20.dp)
+
+ val CornerLarge = RoundedCornerShape(24.dp)
val CornerExtraLarge = RoundedCornerShape(28.dp)
}
diff --git a/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/ui/Category.kt b/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/ui/Category.kt
index 6c5581f..acbdec0 100644
--- a/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/ui/Category.kt
+++ b/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/ui/Category.kt
@@ -85,7 +85,7 @@
}
.then(
if (isSpaExpressiveEnabled)
- Modifier.fillMaxWidth().clip(SettingsShape.categoryCorner)
+ Modifier.fillMaxWidth().clip(SettingsShape.CornerMedium2)
else Modifier
),
verticalArrangement =
diff --git a/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/ui/Spinner.kt b/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/ui/Spinner.kt
index 6b2db90..a9d2ef6 100644
--- a/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/ui/Spinner.kt
+++ b/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/ui/Spinner.kt
@@ -19,9 +19,14 @@
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.selection.selectableGroup
import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.outlined.Check
import androidx.compose.material.icons.outlined.ExpandLess
import androidx.compose.material.icons.outlined.ExpandMore
import androidx.compose.material3.Button
@@ -38,20 +43,19 @@
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.role
import androidx.compose.ui.semantics.semantics
+import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.android.settingslib.spa.framework.theme.SettingsDimension
+import com.android.settingslib.spa.framework.theme.SettingsShape
import com.android.settingslib.spa.framework.theme.SettingsTheme
import com.android.settingslib.spa.framework.theme.isSpaExpressiveEnabled
-data class SpinnerOption(
- val id: Int,
- val text: String,
-)
+data class SpinnerOption(val id: Int, val text: String)
@Composable
fun Spinner(options: List<SpinnerOption>, selectedId: Int?, setId: (id: Int) -> Unit) {
@@ -62,51 +66,101 @@
var expanded by rememberSaveable { mutableStateOf(false) }
Box(
- modifier = Modifier
- .padding(
- start = SettingsDimension.itemPaddingStart,
- top = SettingsDimension.itemPaddingAround,
- end = SettingsDimension.itemPaddingEnd,
- bottom = SettingsDimension.itemPaddingAround,
- )
- .selectableGroup(),
- ) {
- val contentPadding = if (isSpaExpressiveEnabled) PaddingValues(
- horizontal = SettingsDimension.spinnerHorizontalPadding,
- vertical = SettingsDimension.spinnerVerticalPadding
- ) else PaddingValues(horizontal = SettingsDimension.itemPaddingEnd)
- Button(
- modifier = Modifier.semantics { role = Role.DropdownList },
- onClick = { expanded = true },
- colors = ButtonDefaults.buttonColors(
- containerColor = MaterialTheme.colorScheme.primaryContainer,
- contentColor = MaterialTheme.colorScheme.onPrimaryContainer,
- ),
- contentPadding = contentPadding,
- ) {
- SpinnerText(options.find { it.id == selectedId })
- ExpandIcon(expanded)
- }
- DropdownMenu(
- expanded = expanded,
- onDismissRequest = { expanded = false },
- modifier = Modifier.background(MaterialTheme.colorScheme.secondaryContainer),
- ) {
- for (option in options) {
- DropdownMenuItem(
- text = {
- SpinnerText(
- option = option,
- modifier = Modifier.padding(end = 24.dp),
- color = MaterialTheme.colorScheme.onSecondaryContainer,
- )
- },
- onClick = {
- expanded = false
- setId(option.id)
- },
- contentPadding = contentPadding,
+ modifier =
+ Modifier.padding(
+ start = SettingsDimension.itemPaddingStart,
+ top = SettingsDimension.itemPaddingAround,
+ end = SettingsDimension.itemPaddingEnd,
+ bottom = SettingsDimension.itemPaddingAround,
)
+ .selectableGroup()
+ ) {
+ if (isSpaExpressiveEnabled) {
+ Button(
+ modifier = Modifier.semantics { role = Role.DropdownList },
+ onClick = { expanded = true },
+ colors =
+ ButtonDefaults.buttonColors(
+ containerColor = MaterialTheme.colorScheme.secondaryContainer,
+ contentColor = MaterialTheme.colorScheme.onSecondaryContainer,
+ ),
+ contentPadding =
+ PaddingValues(
+ horizontal = SettingsDimension.spinnerHorizontalPadding,
+ vertical = SettingsDimension.spinnerVerticalPadding,
+ ),
+ ) {
+ SpinnerText(options.find { it.id == selectedId })
+ ExpandIcon(expanded)
+ }
+ DropdownMenu(
+ expanded = expanded,
+ onDismissRequest = { expanded = false },
+ shape = SettingsShape.CornerLarge,
+ modifier =
+ Modifier.background(MaterialTheme.colorScheme.surfaceContainerLow)
+ .padding(horizontal = SettingsDimension.paddingSmall),
+ ) {
+ for ((index, option) in options.withIndex()) {
+ val selected = index + 1 == selectedId
+ DropdownMenuItem(
+ text = { SpinnerOptionText(option = option, selected) },
+ onClick = {
+ expanded = false
+ setId(option.id)
+ },
+ contentPadding =
+ PaddingValues(
+ horizontal = SettingsDimension.paddingSmall,
+ vertical = SettingsDimension.paddingExtraSmall1,
+ ),
+ modifier =
+ Modifier.heightIn(min = SettingsDimension.spinnerOptionMinHeight)
+ .then(
+ if (selected)
+ Modifier.clip(SettingsShape.CornerMedium2)
+ .background(MaterialTheme.colorScheme.primaryContainer)
+ else Modifier
+ ),
+ )
+ }
+ }
+ } else {
+ val contentPadding = PaddingValues(horizontal = SettingsDimension.itemPaddingEnd)
+ Button(
+ modifier = Modifier.semantics { role = Role.DropdownList },
+ onClick = { expanded = true },
+ colors =
+ ButtonDefaults.buttonColors(
+ containerColor = MaterialTheme.colorScheme.primaryContainer,
+ contentColor = MaterialTheme.colorScheme.onPrimaryContainer,
+ ),
+ contentPadding = contentPadding,
+ ) {
+ SpinnerText(options.find { it.id == selectedId })
+ ExpandIcon(expanded)
+ }
+ DropdownMenu(
+ expanded = expanded,
+ onDismissRequest = { expanded = false },
+ modifier = Modifier.background(MaterialTheme.colorScheme.secondaryContainer),
+ ) {
+ for (option in options) {
+ DropdownMenuItem(
+ text = {
+ SpinnerText(
+ option = option,
+ modifier = Modifier.padding(end = 24.dp),
+ color = MaterialTheme.colorScheme.onSecondaryContainer,
+ )
+ },
+ onClick = {
+ expanded = false
+ setId(option.id)
+ },
+ contentPadding = contentPadding,
+ )
+ }
}
}
}
@@ -115,10 +169,11 @@
@Composable
internal fun ExpandIcon(expanded: Boolean) {
Icon(
- imageVector = when {
- expanded -> Icons.Outlined.ExpandLess
- else -> Icons.Outlined.ExpandMore
- },
+ imageVector =
+ when {
+ expanded -> Icons.Outlined.ExpandLess
+ else -> Icons.Outlined.ExpandMore
+ },
contentDescription = null,
)
}
@@ -131,18 +186,42 @@
) {
Text(
text = option?.text ?: "",
- modifier = modifier
- .padding(end = SettingsDimension.itemPaddingEnd)
- .then(
- if (!isSpaExpressiveEnabled)
- Modifier.padding(vertical = SettingsDimension.itemPaddingAround)
- else Modifier
- ),
+ modifier =
+ modifier
+ .padding(end = SettingsDimension.itemPaddingEnd)
+ .then(
+ if (!isSpaExpressiveEnabled)
+ Modifier.padding(vertical = SettingsDimension.itemPaddingAround)
+ else Modifier
+ ),
color = color,
style = MaterialTheme.typography.labelLarge,
)
}
+@Composable
+private fun SpinnerOptionText(option: SpinnerOption?, selected: Boolean) {
+ Row {
+ if (selected) {
+ Icon(
+ imageVector = Icons.Outlined.Check,
+ modifier = Modifier.size(SettingsDimension.spinnerIconSize),
+ tint = MaterialTheme.colorScheme.onPrimaryContainer,
+ contentDescription = null,
+ )
+ Spacer(Modifier.padding(SettingsDimension.paddingSmall))
+ }
+ Text(
+ text = option?.text ?: "",
+ modifier = Modifier.padding(end = SettingsDimension.itemPaddingEnd),
+ color =
+ if (selected) MaterialTheme.colorScheme.onPrimaryContainer
+ else MaterialTheme.colorScheme.onSurface,
+ style = MaterialTheme.typography.labelLarge,
+ )
+ }
+}
+
@Preview(showBackground = true)
@Composable
private fun SpinnerPreview() {
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcastAssistant.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcastAssistant.java
index c9f9d1b..a4c5a00d 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcastAssistant.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcastAssistant.java
@@ -42,6 +42,7 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
/**
* LocalBluetoothLeBroadcastAssistant provides an interface between the Settings app and the
@@ -63,6 +64,7 @@
private BluetoothLeBroadcastMetadata mBluetoothLeBroadcastMetadata;
private BluetoothLeBroadcastMetadata.Builder mBuilder;
private boolean mIsProfileReady;
+ private Executor mExecutor;
// Cached assistant callbacks being register before service is connected.
private final Map<BluetoothLeBroadcastAssistant.Callback, Executor> mCachedCallbackExecutorMap =
new ConcurrentHashMap<>();
@@ -98,15 +100,19 @@
}
mProfileManager.callServiceConnectedListeners();
- mIsProfileReady = true;
- if (DEBUG) {
- Log.d(
- TAG,
- "onServiceConnected, register mCachedCallbackExecutorMap = "
- + mCachedCallbackExecutorMap);
+ if (!mIsProfileReady) {
+ mIsProfileReady = true;
+ registerServiceCallBack(mExecutor, mAssistantCallback);
+ if (DEBUG) {
+ Log.d(
+ TAG,
+ "onServiceConnected, register mCachedCallbackExecutorMap = "
+ + mCachedCallbackExecutorMap);
+ }
+ mCachedCallbackExecutorMap.forEach(
+ (callback, executor) -> registerServiceCallBack(executor,
+ callback));
}
- mCachedCallbackExecutorMap.forEach(
- (callback, executor) -> registerServiceCallBack(executor, callback));
}
@Override
@@ -119,17 +125,71 @@
Log.d(TAG, "Bluetooth service disconnected");
}
mProfileManager.callServiceDisconnectedListeners();
- mIsProfileReady = false;
- mCachedCallbackExecutorMap.clear();
+ if (mIsProfileReady) {
+ mIsProfileReady = false;
+ unregisterServiceCallBack(mAssistantCallback);
+ mCachedCallbackExecutorMap.clear();
+ }
}
};
+ private final BluetoothLeBroadcastAssistant.Callback mAssistantCallback =
+ new BluetoothLeBroadcastAssistant.Callback() {
+ @Override
+ public void onSourceAdded(@NonNull BluetoothDevice sink, int sourceId, int reason) {
+ }
+
+ @Override
+ public void onSearchStarted(int reason) {}
+
+ @Override
+ public void onSearchStartFailed(int reason) {}
+
+ @Override
+ public void onSearchStopped(int reason) {}
+
+ @Override
+ public void onSearchStopFailed(int reason) {}
+
+ @Override
+ public void onSourceFound(@NonNull BluetoothLeBroadcastMetadata source) {}
+
+ @Override
+ public void onSourceAddFailed(
+ @NonNull BluetoothDevice sink,
+ @NonNull BluetoothLeBroadcastMetadata source,
+ int reason) {}
+
+ @Override
+ public void onSourceModified(
+ @NonNull BluetoothDevice sink, int sourceId, int reason) {}
+
+ @Override
+ public void onSourceModifyFailed(
+ @NonNull BluetoothDevice sink, int sourceId, int reason) {}
+
+ @Override
+ public void onSourceRemoved(
+ @NonNull BluetoothDevice sink, int sourceId, int reason) {}
+
+ @Override
+ public void onSourceRemoveFailed(
+ @NonNull BluetoothDevice sink, int sourceId, int reason) {}
+
+ @Override
+ public void onReceiveStateChanged(
+ @NonNull BluetoothDevice sink,
+ int sourceId,
+ @NonNull BluetoothLeBroadcastReceiveState state) {}
+ };
+
public LocalBluetoothLeBroadcastAssistant(
Context context,
CachedBluetoothDeviceManager deviceManager,
LocalBluetoothProfileManager profileManager) {
mProfileManager = profileManager;
mDeviceManager = deviceManager;
+ mExecutor = Executors.newSingleThreadExecutor();
BluetoothAdapter.getDefaultAdapter()
.getProfileProxy(
context, mServiceListener, BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT);
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcastCallbackExt.kt b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcastCallbackExt.kt
index 0bcf7fe..07abb6b 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcastCallbackExt.kt
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcastCallbackExt.kt
@@ -68,3 +68,44 @@
awaitClose { unregisterServiceCallBack(listener) }
}
.buffer(capacity = Channel.CONFLATED)
+
+/** [Flow] for [BluetoothLeBroadcast.Callback] onPlaybackStarted event */
+val LocalBluetoothLeBroadcast.onPlaybackStarted: Flow<Unit>
+ get() =
+ callbackFlow {
+ val listener =
+ object : BluetoothLeBroadcast.Callback {
+ override fun onBroadcastStarted(reason: Int, broadcastId: Int) {}
+
+ override fun onBroadcastStartFailed(reason: Int) {
+ }
+
+ override fun onBroadcastStopped(reason: Int, broadcastId: Int) {
+ }
+
+ override fun onBroadcastStopFailed(reason: Int) {
+ }
+
+ override fun onPlaybackStarted(reason: Int, broadcastId: Int) {
+ launch { trySend(Unit) }
+ }
+
+ override fun onPlaybackStopped(reason: Int, broadcastId: Int) {
+ }
+
+ override fun onBroadcastUpdated(reason: Int, broadcastId: Int) {}
+
+ override fun onBroadcastUpdateFailed(reason: Int, broadcastId: Int) {}
+
+ override fun onBroadcastMetadataChanged(
+ broadcastId: Int,
+ metadata: BluetoothLeBroadcastMetadata
+ ) {}
+ }
+ registerServiceCallBack(
+ ConcurrentUtils.DIRECT_EXECUTOR,
+ listener,
+ )
+ awaitClose { unregisterServiceCallBack(listener) }
+ }
+ .buffer(capacity = Channel.CONFLATED)
diff --git a/packages/SettingsLib/src/com/android/settingslib/media/InputRouteManager.java b/packages/SettingsLib/src/com/android/settingslib/media/InputRouteManager.java
index 727662b..4f315a2 100644
--- a/packages/SettingsLib/src/com/android/settingslib/media/InputRouteManager.java
+++ b/packages/SettingsLib/src/com/android/settingslib/media/InputRouteManager.java
@@ -22,6 +22,7 @@
import android.media.AudioDeviceAttributes;
import android.media.AudioDeviceCallback;
import android.media.AudioDeviceInfo;
+import android.media.AudioDeviceInfo.AudioDeviceType;
import android.media.AudioManager;
import android.media.MediaRecorder;
import android.os.Handler;
@@ -63,7 +64,7 @@
@VisibleForTesting final List<MediaDevice> mInputMediaDevices = new CopyOnWriteArrayList<>();
- private MediaDevice mSelectedInputDevice;
+ private @AudioDeviceType int mSelectedInputDeviceType;
private final Collection<InputDeviceCallback> mCallbacks = new CopyOnWriteArrayList<>();
private final Object mCallbackLock = new Object();
@@ -73,12 +74,12 @@
new AudioDeviceCallback() {
@Override
public void onAudioDevicesAdded(@NonNull AudioDeviceInfo[] addedDevices) {
- dispatchInputDeviceListUpdate();
+ applyDefaultSelectedTypeToAllPresets();
}
@Override
public void onAudioDevicesRemoved(@NonNull AudioDeviceInfo[] removedDevices) {
- dispatchInputDeviceListUpdate();
+ applyDefaultSelectedTypeToAllPresets();
}
};
@@ -92,9 +93,12 @@
mAudioManager.addOnPreferredDevicesForCapturePresetChangedListener(
new HandlerExecutor(handler),
this::onPreferredDevicesForCapturePresetChangedListener);
+
+ applyDefaultSelectedTypeToAllPresets();
}
- private void onPreferredDevicesForCapturePresetChangedListener(
+ @VisibleForTesting
+ void onPreferredDevicesForCapturePresetChangedListener(
@MediaRecorder.SystemSource int capturePreset,
@NonNull List<AudioDeviceAttributes> devices) {
if (capturePreset == MediaRecorder.AudioSource.MIC) {
@@ -117,12 +121,30 @@
}
}
+ // TODO(b/355684672): handle edge case where there are two devices with the same type. Only
+ // using a single mSelectedInputDeviceType might not be enough to recognize the correct device.
public @Nullable MediaDevice getSelectedInputDevice() {
- return mSelectedInputDevice;
+ for (MediaDevice device : mInputMediaDevices) {
+ if (((InputMediaDevice) device).getAudioDeviceInfoType() == mSelectedInputDeviceType) {
+ return device;
+ }
+ }
+ return null;
}
- private void dispatchInputDeviceListUpdate() {
- // Get selected input device.
+ private void applyDefaultSelectedTypeToAllPresets() {
+ mSelectedInputDeviceType = retrieveDefaultSelectedDeviceType();
+ AudioDeviceAttributes deviceAttributes =
+ createInputDeviceAttributes(mSelectedInputDeviceType);
+ setPreferredDeviceForAllPresets(deviceAttributes);
+ }
+
+ private AudioDeviceAttributes createInputDeviceAttributes(@AudioDeviceType int type) {
+ // Address is not used.
+ return new AudioDeviceAttributes(AudioDeviceAttributes.ROLE_INPUT, type, /* address= */ "");
+ }
+
+ private @AudioDeviceType int retrieveDefaultSelectedDeviceType() {
List<AudioDeviceAttributes> attributesOfSelectedInputDevices =
mAudioManager.getDevicesForAttributes(INPUT_ATTRIBUTES);
int selectedInputDeviceAttributesType;
@@ -138,7 +160,10 @@
}
selectedInputDeviceAttributesType = attributesOfSelectedInputDevices.get(0).getType();
}
+ return selectedInputDeviceAttributesType;
+ }
+ private void dispatchInputDeviceListUpdate() {
// Get all input devices.
AudioDeviceInfo[] audioDeviceInfos =
mAudioManager.getDevices(AudioManager.GET_DEVICES_INPUTS);
@@ -154,9 +179,8 @@
isInputGainFixed(),
getProductNameFromAudioDeviceInfo(info));
if (mediaDevice != null) {
- if (info.getType() == selectedInputDeviceAttributesType) {
+ if (info.getType() == mSelectedInputDeviceType) {
mediaDevice.setState(STATE_SELECTED);
- mSelectedInputDevice = mediaDevice;
}
mInputMediaDevices.add(mediaDevice);
}
@@ -190,12 +214,12 @@
}
public void selectDevice(@NonNull MediaDevice device) {
- if (!(device instanceof InputMediaDevice)) {
+ if (!(device instanceof InputMediaDevice inputMediaDevice)) {
Slog.w(TAG, "This device is not an InputMediaDevice: " + device.getName());
return;
}
- if (device.equals(mSelectedInputDevice)) {
+ if (inputMediaDevice.getAudioDeviceInfoType() == mSelectedInputDeviceType) {
Slog.w(TAG, "This device is already selected: " + device.getName());
return;
}
@@ -206,12 +230,11 @@
return;
}
- // TODO(b/355684672): apply address for BT devices.
+ // Update mSelectedInputDeviceType directly based on user action.
+ mSelectedInputDeviceType = inputMediaDevice.getAudioDeviceInfoType();
+
AudioDeviceAttributes deviceAttributes =
- new AudioDeviceAttributes(
- AudioDeviceAttributes.ROLE_INPUT,
- ((InputMediaDevice) device).getAudioDeviceInfoType(),
- /* address= */ "");
+ createInputDeviceAttributes(inputMediaDevice.getAudioDeviceInfoType());
try {
setPreferredDeviceForAllPresets(deviceAttributes);
} catch (IllegalArgumentException e) {
diff --git a/packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioSharingRepository.kt b/packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioSharingRepository.kt
index 2f8105a..b41e970 100644
--- a/packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioSharingRepository.kt
+++ b/packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioSharingRepository.kt
@@ -74,6 +74,8 @@
/** The headset groupId to volume map during audio sharing. */
val volumeMap: StateFlow<GroupIdToVolumes>
+ suspend fun audioSharingAvailable(): Boolean
+
/** Set the volume of secondary headset during audio sharing. */
suspend fun setSecondaryVolume(
@IntRange(from = AUDIO_SHARING_VOLUME_MIN.toLong(), to = AUDIO_SHARING_VOLUME_MAX.toLong())
@@ -216,6 +218,12 @@
}
.stateIn(coroutineScope, SharingStarted.WhileSubscribed(), emptyMap())
+ override suspend fun audioSharingAvailable(): Boolean {
+ return withContext(backgroundCoroutineContext) {
+ BluetoothUtils.isAudioSharingEnabled()
+ }
+ }
+
override suspend fun setSecondaryVolume(
@IntRange(from = AUDIO_SHARING_VOLUME_MIN.toLong(), to = AUDIO_SHARING_VOLUME_MAX.toLong())
volume: Int
@@ -262,6 +270,8 @@
MutableStateFlow(BluetoothCsipSetCoordinator.GROUP_ID_INVALID)
override val volumeMap: StateFlow<GroupIdToVolumes> = MutableStateFlow(emptyMap())
+ override suspend fun audioSharingAvailable(): Boolean = false
+
override suspend fun setSecondaryVolume(
@IntRange(from = AUDIO_SHARING_VOLUME_MIN.toLong(), to = AUDIO_SHARING_VOLUME_MAX.toLong())
volume: Int
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/media/InputRouteManagerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/media/InputRouteManagerTest.java
index f63bfc7..782cee2 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/media/InputRouteManagerTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/media/InputRouteManagerTest.java
@@ -21,6 +21,7 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -55,6 +56,7 @@
private static final int INPUT_USB_DEVICE_ID = 3;
private static final int INPUT_USB_HEADSET_ID = 4;
private static final int INPUT_USB_ACCESSORY_ID = 5;
+ private static final int HDMI_ID = 6;
private static final int MAX_VOLUME = 1;
private static final int CURRENT_VOLUME = 0;
private static final boolean VOLUME_FIXED_TRUE = true;
@@ -63,10 +65,86 @@
private static final String PRODUCT_NAME_USB_HEADSET = "My USB Headset";
private static final String PRODUCT_NAME_USB_DEVICE = "My USB Device";
private static final String PRODUCT_NAME_USB_ACCESSORY = "My USB Accessory";
+ private static final String PRODUCT_NAME_HDMI_DEVICE = "HDMI device";
private final Context mContext = spy(RuntimeEnvironment.application);
private InputRouteManager mInputRouteManager;
+ private AudioDeviceInfo mockBuiltinMicInfo() {
+ final AudioDeviceInfo info = mock(AudioDeviceInfo.class);
+ when(info.getType()).thenReturn(AudioDeviceInfo.TYPE_BUILTIN_MIC);
+ when(info.getId()).thenReturn(BUILTIN_MIC_ID);
+ when(info.getAddress()).thenReturn("");
+ when(info.getProductName()).thenReturn(PRODUCT_NAME_BUILTIN_MIC);
+ return info;
+ }
+
+ private AudioDeviceInfo mockWiredHeadsetInfo() {
+ final AudioDeviceInfo info = mock(AudioDeviceInfo.class);
+ when(info.getType()).thenReturn(AudioDeviceInfo.TYPE_WIRED_HEADSET);
+ when(info.getId()).thenReturn(INPUT_WIRED_HEADSET_ID);
+ when(info.getAddress()).thenReturn("");
+ when(info.getProductName()).thenReturn(PRODUCT_NAME_WIRED_HEADSET);
+ return info;
+ }
+
+ private AudioDeviceInfo mockUsbDeviceInfo() {
+ final AudioDeviceInfo info = mock(AudioDeviceInfo.class);
+ when(info.getType()).thenReturn(AudioDeviceInfo.TYPE_USB_DEVICE);
+ when(info.getId()).thenReturn(INPUT_USB_DEVICE_ID);
+ when(info.getAddress()).thenReturn("");
+ when(info.getProductName()).thenReturn(PRODUCT_NAME_USB_DEVICE);
+ return info;
+ }
+
+ private AudioDeviceInfo mockUsbHeadsetInfo() {
+ final AudioDeviceInfo info = mock(AudioDeviceInfo.class);
+ when(info.getType()).thenReturn(AudioDeviceInfo.TYPE_USB_HEADSET);
+ when(info.getId()).thenReturn(INPUT_USB_HEADSET_ID);
+ when(info.getAddress()).thenReturn("");
+ when(info.getProductName()).thenReturn(PRODUCT_NAME_USB_HEADSET);
+ return info;
+ }
+
+ private AudioDeviceInfo mockUsbAccessoryInfo() {
+ final AudioDeviceInfo info = mock(AudioDeviceInfo.class);
+ when(info.getType()).thenReturn(AudioDeviceInfo.TYPE_USB_ACCESSORY);
+ when(info.getId()).thenReturn(INPUT_USB_ACCESSORY_ID);
+ when(info.getAddress()).thenReturn("");
+ when(info.getProductName()).thenReturn(PRODUCT_NAME_USB_ACCESSORY);
+ return info;
+ }
+
+ private AudioDeviceInfo mockHdmiInfo() {
+ final AudioDeviceInfo info = mock(AudioDeviceInfo.class);
+ when(info.getType()).thenReturn(AudioDeviceInfo.TYPE_HDMI);
+ when(info.getId()).thenReturn(HDMI_ID);
+ when(info.getAddress()).thenReturn("");
+ when(info.getProductName()).thenReturn(PRODUCT_NAME_HDMI_DEVICE);
+ return info;
+ }
+
+ private AudioDeviceAttributes getBuiltinMicDeviceAttributes() {
+ return new AudioDeviceAttributes(
+ AudioDeviceAttributes.ROLE_INPUT,
+ AudioDeviceInfo.TYPE_BUILTIN_MIC,
+ /* address= */ "");
+ }
+
+ private AudioDeviceAttributes getWiredHeadsetDeviceAttributes() {
+ return new AudioDeviceAttributes(
+ AudioDeviceAttributes.ROLE_INPUT,
+ AudioDeviceInfo.TYPE_WIRED_HEADSET,
+ /* address= */ "");
+ }
+
+ private void onPreferredDevicesForCapturePresetChanged(InputRouteManager inputRouteManager) {
+ final List<AudioDeviceAttributes> audioDeviceAttributesList =
+ new ArrayList<AudioDeviceAttributes>();
+ inputRouteManager.onPreferredDevicesForCapturePresetChangedListener(
+ MediaRecorder.AudioSource.MIC, audioDeviceAttributesList);
+ }
+
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
@@ -77,37 +155,15 @@
@Test
public void onAudioDevicesAdded_shouldUpdateInputMediaDevice() {
- final AudioDeviceInfo info1 = mock(AudioDeviceInfo.class);
- when(info1.getType()).thenReturn(AudioDeviceInfo.TYPE_BUILTIN_MIC);
- when(info1.getId()).thenReturn(BUILTIN_MIC_ID);
- when(info1.getProductName()).thenReturn(PRODUCT_NAME_BUILTIN_MIC);
-
- final AudioDeviceInfo info2 = mock(AudioDeviceInfo.class);
- when(info2.getType()).thenReturn(AudioDeviceInfo.TYPE_WIRED_HEADSET);
- when(info2.getId()).thenReturn(INPUT_WIRED_HEADSET_ID);
- when(info2.getProductName()).thenReturn(PRODUCT_NAME_WIRED_HEADSET);
-
- final AudioDeviceInfo info3 = mock(AudioDeviceInfo.class);
- when(info3.getType()).thenReturn(AudioDeviceInfo.TYPE_USB_DEVICE);
- when(info3.getId()).thenReturn(INPUT_USB_DEVICE_ID);
- when(info3.getProductName()).thenReturn(PRODUCT_NAME_USB_DEVICE);
-
- final AudioDeviceInfo info4 = mock(AudioDeviceInfo.class);
- when(info4.getType()).thenReturn(AudioDeviceInfo.TYPE_USB_HEADSET);
- when(info4.getId()).thenReturn(INPUT_USB_HEADSET_ID);
- when(info4.getProductName()).thenReturn(PRODUCT_NAME_USB_HEADSET);
-
- final AudioDeviceInfo info5 = mock(AudioDeviceInfo.class);
- when(info5.getType()).thenReturn(AudioDeviceInfo.TYPE_USB_ACCESSORY);
- when(info5.getId()).thenReturn(INPUT_USB_ACCESSORY_ID);
- when(info5.getProductName()).thenReturn(PRODUCT_NAME_USB_ACCESSORY);
-
- final AudioDeviceInfo unsupportedInfo = mock(AudioDeviceInfo.class);
- when(unsupportedInfo.getType()).thenReturn(AudioDeviceInfo.TYPE_HDMI);
- when(unsupportedInfo.getProductName()).thenReturn("HDMI device");
-
final AudioManager audioManager = mock(AudioManager.class);
- AudioDeviceInfo[] devices = {info1, info2, info3, info4, info5, unsupportedInfo};
+ AudioDeviceInfo[] devices = {
+ mockBuiltinMicInfo(),
+ mockWiredHeadsetInfo(),
+ mockUsbDeviceInfo(),
+ mockUsbHeadsetInfo(),
+ mockUsbAccessoryInfo(),
+ mockHdmiInfo()
+ };
when(audioManager.getDevices(AudioManager.GET_DEVICES_INPUTS)).thenReturn(devices);
InputRouteManager inputRouteManager = new InputRouteManager(mContext, audioManager);
@@ -115,8 +171,9 @@
assertThat(inputRouteManager.mInputMediaDevices).isEmpty();
inputRouteManager.mAudioDeviceCallback.onAudioDevicesAdded(devices);
+ onPreferredDevicesForCapturePresetChanged(inputRouteManager);
- // The unsupported info should be filtered out.
+ // The unsupported (hdmi) info should be filtered out.
assertThat(inputRouteManager.mInputMediaDevices).hasSize(devices.length - 1);
assertThat(inputRouteManager.mInputMediaDevices.get(0).getId())
.isEqualTo(String.valueOf(BUILTIN_MIC_ID));
@@ -141,36 +198,25 @@
final MediaDevice device = mock(MediaDevice.class);
inputRouteManager.mInputMediaDevices.add(device);
- final AudioDeviceInfo info = mock(AudioDeviceInfo.class);
- when(info.getType()).thenReturn(AudioDeviceInfo.TYPE_WIRED_HEADSET);
- inputRouteManager.mAudioDeviceCallback.onAudioDevicesRemoved(new AudioDeviceInfo[] {info});
+ inputRouteManager.mAudioDeviceCallback.onAudioDevicesRemoved(
+ new AudioDeviceInfo[] {mockWiredHeadsetInfo()});
+ onPreferredDevicesForCapturePresetChanged(inputRouteManager);
assertThat(inputRouteManager.mInputMediaDevices).isEmpty();
}
@Test
public void getSelectedInputDevice_returnOneFromAudioManager() {
- final AudioDeviceInfo info1 = mock(AudioDeviceInfo.class);
- when(info1.getType()).thenReturn(AudioDeviceInfo.TYPE_WIRED_HEADSET);
- when(info1.getId()).thenReturn(INPUT_WIRED_HEADSET_ID);
- when(info1.getProductName()).thenReturn(PRODUCT_NAME_WIRED_HEADSET);
-
- final AudioDeviceInfo info2 = mock(AudioDeviceInfo.class);
- when(info2.getType()).thenReturn(AudioDeviceInfo.TYPE_BUILTIN_MIC);
- when(info2.getId()).thenReturn(BUILTIN_MIC_ID);
- when(info2.getProductName()).thenReturn(PRODUCT_NAME_BUILTIN_MIC);
-
final AudioManager audioManager = mock(AudioManager.class);
- AudioDeviceInfo[] devices = {info1, info2};
+ AudioDeviceInfo[] devices = {mockWiredHeadsetInfo(), mockBuiltinMicInfo()};
when(audioManager.getDevices(AudioManager.GET_DEVICES_INPUTS)).thenReturn(devices);
// Mock audioManager.getDevicesForAttributes returns exactly one audioDeviceAttributes.
- AudioDeviceAttributes audioDeviceAttributes = new AudioDeviceAttributes(info1);
when(audioManager.getDevicesForAttributes(INPUT_ATTRIBUTES))
- .thenReturn(Collections.singletonList(audioDeviceAttributes));
+ .thenReturn(Collections.singletonList(getWiredHeadsetDeviceAttributes()));
InputRouteManager inputRouteManager = new InputRouteManager(mContext, audioManager);
- inputRouteManager.mAudioDeviceCallback.onAudioDevicesAdded(devices);
+ onPreferredDevicesForCapturePresetChanged(inputRouteManager);
// The selected input device has the same type as the one returned from AudioManager.
InputMediaDevice selectedInputDevice =
@@ -181,31 +227,19 @@
@Test
public void getSelectedInputDevice_returnMoreThanOneFromAudioManager() {
- final AudioDeviceInfo info1 = mock(AudioDeviceInfo.class);
- when(info1.getType()).thenReturn(AudioDeviceInfo.TYPE_WIRED_HEADSET);
- when(info1.getId()).thenReturn(INPUT_WIRED_HEADSET_ID);
- when(info1.getProductName()).thenReturn(PRODUCT_NAME_WIRED_HEADSET);
-
- final AudioDeviceInfo info2 = mock(AudioDeviceInfo.class);
- when(info2.getType()).thenReturn(AudioDeviceInfo.TYPE_BUILTIN_MIC);
- when(info2.getId()).thenReturn(BUILTIN_MIC_ID);
- when(info2.getProductName()).thenReturn(PRODUCT_NAME_BUILTIN_MIC);
-
final AudioManager audioManager = mock(AudioManager.class);
- AudioDeviceInfo[] devices = {info1, info2};
+ AudioDeviceInfo[] devices = {mockWiredHeadsetInfo(), mockBuiltinMicInfo()};
when(audioManager.getDevices(AudioManager.GET_DEVICES_INPUTS)).thenReturn(devices);
// Mock audioManager.getDevicesForAttributes returns more than one audioDeviceAttributes.
- AudioDeviceAttributes audioDeviceAttributes1 = new AudioDeviceAttributes(info1);
- AudioDeviceAttributes audioDeviceAttributes2 = new AudioDeviceAttributes(info2);
List<AudioDeviceAttributes> attributesOfSelectedInputDevices = new ArrayList<>();
- attributesOfSelectedInputDevices.add(audioDeviceAttributes1);
- attributesOfSelectedInputDevices.add(audioDeviceAttributes2);
+ attributesOfSelectedInputDevices.add(getWiredHeadsetDeviceAttributes());
+ attributesOfSelectedInputDevices.add(getBuiltinMicDeviceAttributes());
when(audioManager.getDevicesForAttributes(INPUT_ATTRIBUTES))
.thenReturn(attributesOfSelectedInputDevices);
InputRouteManager inputRouteManager = new InputRouteManager(mContext, audioManager);
- inputRouteManager.mAudioDeviceCallback.onAudioDevicesAdded(devices);
+ onPreferredDevicesForCapturePresetChanged(inputRouteManager);
// The selected input device has the same type as the first one returned from AudioManager.
InputMediaDevice selectedInputDevice =
@@ -216,27 +250,17 @@
@Test
public void getSelectedInputDevice_returnEmptyFromAudioManager() {
- final AudioDeviceInfo info1 = mock(AudioDeviceInfo.class);
- when(info1.getType()).thenReturn(AudioDeviceInfo.TYPE_WIRED_HEADSET);
- when(info1.getId()).thenReturn(INPUT_WIRED_HEADSET_ID);
- when(info1.getProductName()).thenReturn(PRODUCT_NAME_WIRED_HEADSET);
-
- final AudioDeviceInfo info2 = mock(AudioDeviceInfo.class);
- when(info2.getType()).thenReturn(AudioDeviceInfo.TYPE_BUILTIN_MIC);
- when(info2.getId()).thenReturn(BUILTIN_MIC_ID);
- when(info2.getProductName()).thenReturn(PRODUCT_NAME_BUILTIN_MIC);
-
final AudioManager audioManager = mock(AudioManager.class);
- AudioDeviceInfo[] devices = {info1, info2};
+ AudioDeviceInfo[] devices = {mockWiredHeadsetInfo(), mockBuiltinMicInfo()};
when(audioManager.getDevices(AudioManager.GET_DEVICES_INPUTS)).thenReturn(devices);
// Mock audioManager.getDevicesForAttributes returns empty list of audioDeviceAttributes.
- List<AudioDeviceAttributes> attributesOfSelectedInputDevices = new ArrayList<>();
+ List<AudioDeviceAttributes> emptyAttributesOfSelectedInputDevices = new ArrayList<>();
when(audioManager.getDevicesForAttributes(INPUT_ATTRIBUTES))
- .thenReturn(attributesOfSelectedInputDevices);
+ .thenReturn(emptyAttributesOfSelectedInputDevices);
InputRouteManager inputRouteManager = new InputRouteManager(mContext, audioManager);
- inputRouteManager.mAudioDeviceCallback.onAudioDevicesAdded(devices);
+ onPreferredDevicesForCapturePresetChanged(inputRouteManager);
// The selected input device has default type AudioDeviceInfo.TYPE_BUILTIN_MIC.
InputMediaDevice selectedInputDevice =
@@ -249,7 +273,7 @@
public void selectDevice() {
final AudioManager audioManager = mock(AudioManager.class);
InputRouteManager inputRouteManager = new InputRouteManager(mContext, audioManager);
- final MediaDevice inputMediaDevice =
+ final MediaDevice builtinMicDevice =
InputMediaDevice.create(
mContext,
String.valueOf(BUILTIN_MIC_ID),
@@ -258,16 +282,57 @@
CURRENT_VOLUME,
VOLUME_FIXED_TRUE,
PRODUCT_NAME_BUILTIN_MIC);
- inputRouteManager.selectDevice(inputMediaDevice);
+ inputRouteManager.selectDevice(builtinMicDevice);
- AudioDeviceAttributes deviceAttributes =
- new AudioDeviceAttributes(
- AudioDeviceAttributes.ROLE_INPUT,
- AudioDeviceInfo.TYPE_BUILTIN_MIC,
- /* address= */ "");
for (@MediaRecorder.Source int preset : PRESETS) {
verify(audioManager, atLeastOnce())
- .setPreferredDeviceForCapturePreset(preset, deviceAttributes);
+ .setPreferredDeviceForCapturePreset(preset, getBuiltinMicDeviceAttributes());
+ }
+ }
+
+ @Test
+ public void onInitiation_shouldApplyDefaultSelectedDeviceToAllPresets() {
+ final AudioManager audioManager = mock(AudioManager.class);
+ new InputRouteManager(mContext, audioManager);
+
+ verify(audioManager, atLeastOnce()).getDevicesForAttributes(INPUT_ATTRIBUTES);
+ for (@MediaRecorder.Source int preset : PRESETS) {
+ verify(audioManager, atLeastOnce())
+ .setPreferredDeviceForCapturePreset(preset, getBuiltinMicDeviceAttributes());
+ }
+ }
+
+ @Test
+ public void onAudioDevicesAdded_shouldApplyDefaultSelectedDeviceToAllPresets() {
+ final AudioManager audioManager = mock(AudioManager.class);
+ AudioDeviceAttributes wiredHeadsetDeviceAttributes = getWiredHeadsetDeviceAttributes();
+ when(audioManager.getDevicesForAttributes(INPUT_ATTRIBUTES))
+ .thenReturn(Collections.singletonList(wiredHeadsetDeviceAttributes));
+
+ InputRouteManager inputRouteManager = new InputRouteManager(mContext, audioManager);
+ AudioDeviceInfo[] devices = {mockWiredHeadsetInfo()};
+ inputRouteManager.mAudioDeviceCallback.onAudioDevicesAdded(devices);
+
+ // Called twice, one after initiation, the other after onAudioDevicesAdded call.
+ verify(audioManager, atLeast(2)).getDevicesForAttributes(INPUT_ATTRIBUTES);
+ for (@MediaRecorder.Source int preset : PRESETS) {
+ verify(audioManager, atLeast(2))
+ .setPreferredDeviceForCapturePreset(preset, wiredHeadsetDeviceAttributes);
+ }
+ }
+
+ @Test
+ public void onAudioDevicesRemoved_shouldApplyDefaultSelectedDeviceToAllPresets() {
+ final AudioManager audioManager = mock(AudioManager.class);
+ InputRouteManager inputRouteManager = new InputRouteManager(mContext, audioManager);
+ AudioDeviceInfo[] devices = {mockWiredHeadsetInfo()};
+ inputRouteManager.mAudioDeviceCallback.onAudioDevicesRemoved(devices);
+
+ // Called twice, one after initiation, the other after onAudioDevicesRemoved call.
+ verify(audioManager, atLeast(2)).getDevicesForAttributes(INPUT_ATTRIBUTES);
+ for (@MediaRecorder.Source int preset : PRESETS) {
+ verify(audioManager, atLeast(2))
+ .setPreferredDeviceForCapturePreset(preset, getBuiltinMicDeviceAttributes());
}
}
@@ -288,27 +353,25 @@
@Test
public void onAudioDevicesAdded_shouldSetProductNameCorrectly() {
- final AudioDeviceInfo info1 = mock(AudioDeviceInfo.class);
- when(info1.getType()).thenReturn(AudioDeviceInfo.TYPE_WIRED_HEADSET);
- when(info1.getId()).thenReturn(INPUT_WIRED_HEADSET_ID);
+ final AudioDeviceInfo info1 = mockWiredHeadsetInfo();
String firstProductName = "My first headset";
when(info1.getProductName()).thenReturn(firstProductName);
+ InputMediaDevice inputMediaDevice1 = createInputMediaDeviceFromDeviceInfo(info1);
- final AudioDeviceInfo info2 = mock(AudioDeviceInfo.class);
- when(info2.getType()).thenReturn(AudioDeviceInfo.TYPE_WIRED_HEADSET);
- when(info2.getId()).thenReturn(INPUT_WIRED_HEADSET_ID);
+ final AudioDeviceInfo info2 = mockWiredHeadsetInfo();
String secondProductName = "My second headset";
when(info2.getProductName()).thenReturn(secondProductName);
+ InputMediaDevice inputMediaDevice2 = createInputMediaDeviceFromDeviceInfo(info2);
- final AudioDeviceInfo infoWithNullProductName = mock(AudioDeviceInfo.class);
- when(infoWithNullProductName.getType()).thenReturn(AudioDeviceInfo.TYPE_WIRED_HEADSET);
- when(infoWithNullProductName.getId()).thenReturn(INPUT_WIRED_HEADSET_ID);
+ final AudioDeviceInfo infoWithNullProductName = mockWiredHeadsetInfo();
when(infoWithNullProductName.getProductName()).thenReturn(null);
+ InputMediaDevice inputMediaDevice3 =
+ createInputMediaDeviceFromDeviceInfo(infoWithNullProductName);
- final AudioDeviceInfo infoWithBlankProductName = mock(AudioDeviceInfo.class);
- when(infoWithBlankProductName.getType()).thenReturn(AudioDeviceInfo.TYPE_WIRED_HEADSET);
- when(infoWithBlankProductName.getId()).thenReturn(INPUT_WIRED_HEADSET_ID);
+ final AudioDeviceInfo infoWithBlankProductName = mockWiredHeadsetInfo();
when(infoWithBlankProductName.getProductName()).thenReturn("");
+ InputMediaDevice inputMediaDevice4 =
+ createInputMediaDeviceFromDeviceInfo(infoWithBlankProductName);
final AudioManager audioManager = mock(AudioManager.class);
AudioDeviceInfo[] devices = {
@@ -321,15 +384,22 @@
assertThat(inputRouteManager.mInputMediaDevices).isEmpty();
inputRouteManager.mAudioDeviceCallback.onAudioDevicesAdded(devices);
+ onPreferredDevicesForCapturePresetChanged(inputRouteManager);
- assertThat(getProductNameAtIndex(inputRouteManager, 1)).isEqualTo(firstProductName);
- assertThat(getProductNameAtIndex(inputRouteManager, 2)).isEqualTo(secondProductName);
- assertThat(getProductNameAtIndex(inputRouteManager, 3)).isNull();
- assertThat(getProductNameAtIndex(inputRouteManager, 4)).isNull();
+ assertThat(inputRouteManager.mInputMediaDevices)
+ .containsExactly(
+ inputMediaDevice1, inputMediaDevice2, inputMediaDevice3, inputMediaDevice4)
+ .inOrder();
}
- private String getProductNameAtIndex(InputRouteManager inputRouteManager, int index) {
- return ((InputMediaDevice) inputRouteManager.mInputMediaDevices.get(index))
- .getProductName();
+ private InputMediaDevice createInputMediaDeviceFromDeviceInfo(AudioDeviceInfo info) {
+ return InputMediaDevice.create(
+ mContext,
+ String.valueOf(info.getId()),
+ info.getType(),
+ MAX_VOLUME,
+ CURRENT_VOLUME,
+ VOLUME_FIXED_TRUE,
+ info.getProductName() == null ? null : info.getProductName().toString());
}
}
diff --git a/packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java b/packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java
index 2cdd0ae..3530e0f 100644
--- a/packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java
+++ b/packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java
@@ -106,6 +106,8 @@
Settings.System.UNREAD_NOTIFICATION_DOT_INDICATOR,
Settings.System.AUTO_LAUNCH_MEDIA_CONTROLS,
Settings.System.LOCALE_PREFERENCES,
+ Settings.System.MOUSE_REVERSE_VERTICAL_SCROLLING,
+ Settings.System.MOUSE_SWAP_PRIMARY_BUTTON,
Settings.System.TOUCHPAD_POINTER_SPEED,
Settings.System.TOUCHPAD_NATURAL_SCROLLING,
Settings.System.TOUCHPAD_TAP_TO_CLICK,
diff --git a/packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java b/packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java
index 2823277..509b88b 100644
--- a/packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java
+++ b/packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java
@@ -221,6 +221,8 @@
POINTER_ICON_VECTOR_STYLE_STROKE_END));
VALIDATORS.put(System.POINTER_SCALE,
new InclusiveFloatRangeValidator(DEFAULT_POINTER_SCALE, LARGE_POINTER_SCALE));
+ VALIDATORS.put(System.MOUSE_REVERSE_VERTICAL_SCROLLING, BOOLEAN_VALIDATOR);
+ VALIDATORS.put(System.MOUSE_SWAP_PRIMARY_BUTTON, BOOLEAN_VALIDATOR);
VALIDATORS.put(System.TOUCHPAD_POINTER_SPEED, new InclusiveIntegerRangeValidator(-7, 7));
VALIDATORS.put(System.TOUCHPAD_NATURAL_SCROLLING, BOOLEAN_VALIDATOR);
VALIDATORS.put(System.TOUCHPAD_TAP_TO_CLICK, BOOLEAN_VALIDATOR);
diff --git a/packages/SystemUI/Android.bp b/packages/SystemUI/Android.bp
index 1f10ead..2863531 100644
--- a/packages/SystemUI/Android.bp
+++ b/packages/SystemUI/Android.bp
@@ -425,8 +425,8 @@
"tests/src/**/systemui/media/controls/domain/pipeline/LegacyMediaDataManagerImplTest.kt",
"tests/src/**/systemui/shared/system/RemoteTransitionTest.java",
"tests/src/**/systemui/navigationbar/NavigationBarControllerImplTest.java",
- "tests/src/**/systemui/bluetooth/qsdialog/AudioSharingInteractorTest.kt",
- "tests/src/**/systemui/bluetooth/qsdialog/DeviceItemActionInteractorTest.kt",
+ "tests/src/**/systemui/bluetooth/qsdialog/AudioSharingButtonViewModelTest.kt",
+ "tests/src/**/systemui/bluetooth/qsdialog/AudioSharingDeviceItemActionInteractorTest.kt",
"tests/src/**/systemui/notetask/quickaffordance/NoteTaskQuickAffordanceConfigTest.kt",
"tests/src/**/systemui/notetask/LaunchNotesRoleSettingsTrampolineActivityTest.kt",
"tests/src/**/systemui/notetask/shortcut/LaunchNoteTaskActivityTest.kt",
@@ -802,6 +802,7 @@
"SystemUICustomizationTestUtils",
"androidx.compose.runtime_runtime",
"kosmos",
+ "testables",
"androidx.test.rules",
],
libs: [
diff --git a/packages/SystemUI/TEST_MAPPING b/packages/SystemUI/TEST_MAPPING
index 07a1e63..380344a 100644
--- a/packages/SystemUI/TEST_MAPPING
+++ b/packages/SystemUI/TEST_MAPPING
@@ -148,5 +148,10 @@
{
"name": "SystemUIGoogleRobo2RNGTests"
}
+ ],
+ "imports": [
+ {
+ "path": "cts/tests/tests/multiuser"
+ }
]
}
diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityTransitionAnimator.kt b/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityTransitionAnimator.kt
index d025275..93a99bd 100644
--- a/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityTransitionAnimator.kt
+++ b/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityTransitionAnimator.kt
@@ -136,6 +136,23 @@
)
/**
+ * The timings when animating a View into an app using a spring animator.
+ *
+ * Important: since springs don't have fixed durations, these timings represent fractions of
+ * the progress between the spring's initial value and its final value.
+ *
+ * TODO(b/372858592): make this a separate class explicitly using percentages.
+ */
+ val SPRING_TIMINGS =
+ TransitionAnimator.Timings(
+ totalDuration = 1000L,
+ contentBeforeFadeOutDelay = 0L,
+ contentBeforeFadeOutDuration = 800L,
+ contentAfterFadeInDelay = 850L,
+ contentAfterFadeInDuration = 135L,
+ )
+
+ /**
* The timings when animating a Dialog into an app. We need to wait at least 200ms before
* showing the app (which is under the dialog window) so that the dialog window dim is fully
* faded out, to avoid flicker.
@@ -152,6 +169,13 @@
contentAfterFadeInInterpolator = PathInterpolator(0f, 0f, 0.6f, 1f),
)
+ /** The interpolators when animating a View into an app using a spring animator. */
+ val SPRING_INTERPOLATORS =
+ INTERPOLATORS.copy(
+ contentBeforeFadeOutInterpolator = Interpolators.DECELERATE_1_5,
+ contentAfterFadeInInterpolator = Interpolators.SLOW_OUT_LINEAR_IN,
+ )
+
// TODO(b/288507023): Remove this flag.
@JvmField val DEBUG_TRANSITION_ANIMATION = Build.IS_DEBUGGABLE
diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/TransitionAnimator.kt b/packages/SystemUI/animation/src/com/android/systemui/animation/TransitionAnimator.kt
index 3dc0657..1d8ff77 100644
--- a/packages/SystemUI/animation/src/com/android/systemui/animation/TransitionAnimator.kt
+++ b/packages/SystemUI/animation/src/com/android/systemui/animation/TransitionAnimator.kt
@@ -23,6 +23,7 @@
import android.graphics.PorterDuff
import android.graphics.PorterDuffXfermode
import android.graphics.drawable.GradientDrawable
+import android.util.FloatProperty
import android.util.Log
import android.util.MathUtils
import android.view.View
@@ -31,10 +32,15 @@
import android.view.ViewOverlay
import android.view.animation.Interpolator
import android.window.WindowAnimationState
-import androidx.annotation.VisibleForTesting
import com.android.app.animation.Interpolators.LINEAR
+import com.android.app.animation.MathUtils.max
+import com.android.internal.annotations.VisibleForTesting
+import com.android.internal.dynamicanimation.animation.SpringAnimation
+import com.android.internal.dynamicanimation.animation.SpringForce
import com.android.systemui.shared.Flags.returnAnimationFrameworkLibrary
import java.util.concurrent.Executor
+import kotlin.math.abs
+import kotlin.math.min
import kotlin.math.roundToInt
private const val TAG = "TransitionAnimator"
@@ -44,11 +50,27 @@
private val mainExecutor: Executor,
private val timings: Timings,
private val interpolators: Interpolators,
+
+ /** [springTimings] and [springInterpolators] must either both be null or both not null. */
+ private val springTimings: Timings? = null,
+ private val springInterpolators: Interpolators? = null,
+ private val springParams: SpringParams = DEFAULT_SPRING_PARAMS,
) {
companion object {
internal const val DEBUG = false
private val SRC_MODE = PorterDuffXfermode(PorterDuff.Mode.SRC)
+ /** Default parameters for the multi-spring animator. */
+ private val DEFAULT_SPRING_PARAMS =
+ SpringParams(
+ centerXStiffness = 450f,
+ centerXDampingRatio = 0.965f,
+ centerYStiffness = 400f,
+ centerYDampingRatio = 0.95f,
+ scaleStiffness = 500f,
+ scaleDampingRatio = 0.99f,
+ )
+
/**
* Given the [linearProgress] of a transition animation, return the linear progress of the
* sub-animation starting [delay] ms after the transition animation and that lasts
@@ -86,11 +108,32 @@
it.bottomCornerRadius = (bottomLeftRadius + bottomRightRadius) / 2
it.topCornerRadius = (topLeftRadius + topRightRadius) / 2
}
+
+ /** Builds a [FloatProperty] for updating the defined [property] using a spring. */
+ private fun buildProperty(
+ property: SpringProperty,
+ updateProgress: (SpringState) -> Unit,
+ ): FloatProperty<SpringState> {
+ return object : FloatProperty<SpringState>(property.name) {
+ override fun get(state: SpringState): Float {
+ return property.get(state)
+ }
+
+ override fun setValue(state: SpringState, value: Float) {
+ property.setValue(state, value)
+ updateProgress(state)
+ }
+ }
+ }
}
private val transitionContainerLocation = IntArray(2)
private val cornerRadii = FloatArray(8)
+ init {
+ check((springTimings == null) == (springInterpolators == null))
+ }
+
/**
* A controller that takes care of applying the animation to an expanding view.
*
@@ -198,6 +241,65 @@
var visible: Boolean = true
}
+ /** Encapsulated the state of a multi-spring animation. */
+ internal class SpringState(
+ // Animated values.
+ var centerX: Float,
+ var centerY: Float,
+ var scale: Float = 0f,
+
+ // Cached values.
+ var previousCenterX: Float = -1f,
+ var previousCenterY: Float = -1f,
+ var previousScale: Float = -1f,
+
+ // Completion flags.
+ var isCenterXDone: Boolean = false,
+ var isCenterYDone: Boolean = false,
+ var isScaleDone: Boolean = false,
+ ) {
+ /** Whether all springs composing the animation have settled in the final position. */
+ val isDone
+ get() = isCenterXDone && isCenterYDone && isScaleDone
+ }
+
+ /** Supported [SpringState] properties with getters and setters to update them. */
+ private enum class SpringProperty {
+ CENTER_X {
+ override fun get(state: SpringState): Float {
+ return state.centerX
+ }
+
+ override fun setValue(state: SpringState, value: Float) {
+ state.centerX = value
+ }
+ },
+ CENTER_Y {
+ override fun get(state: SpringState): Float {
+ return state.centerY
+ }
+
+ override fun setValue(state: SpringState, value: Float) {
+ state.centerY = value
+ }
+ },
+ SCALE {
+ override fun get(state: SpringState): Float {
+ return state.scale
+ }
+
+ override fun setValue(state: SpringState, value: Float) {
+ state.scale = value
+ }
+ };
+
+ /** Extracts the current value of the underlying property from [state]. */
+ abstract fun get(state: SpringState): Float
+
+ /** Update's the [value] of the underlying property inside [state]. */
+ abstract fun setValue(state: SpringState, value: Float)
+ }
+
interface Animation {
/** Start the animation. */
fun start()
@@ -217,6 +319,33 @@
}
}
+ @VisibleForTesting
+ class MultiSpringAnimation
+ internal constructor(
+ @get:VisibleForTesting val springX: SpringAnimation,
+ @get:VisibleForTesting val springY: SpringAnimation,
+ @get:VisibleForTesting val springScale: SpringAnimation,
+ private val springState: SpringState,
+ private val onAnimationStart: Runnable,
+ ) : Animation {
+ @get:VisibleForTesting
+ val isDone
+ get() = springState.isDone
+
+ override fun start() {
+ onAnimationStart.run()
+ springX.start()
+ springY.start()
+ springScale.start()
+ }
+
+ override fun cancel() {
+ springX.cancel()
+ springY.cancel()
+ springScale.cancel()
+ }
+ }
+
/** The timings (durations and delays) used by this animator. */
data class Timings(
/** The total duration of the animation. */
@@ -256,6 +385,21 @@
val contentAfterFadeInInterpolator: Interpolator,
)
+ /** The parameters (stiffnesses and damping ratios) used by the multi-spring animator. */
+ data class SpringParams(
+ // Parameters for the X position spring.
+ val centerXStiffness: Float,
+ val centerXDampingRatio: Float,
+
+ // Parameters for the Y position spring.
+ val centerYStiffness: Float,
+ val centerYDampingRatio: Float,
+
+ // Parameters for the scale spring.
+ val scaleStiffness: Float,
+ val scaleDampingRatio: Float,
+ )
+
/**
* Start a transition animation controlled by [controller] towards [endState]. An intermediary
* layer with [windowBackgroundColor] will fade in then (optionally) fade out above the
@@ -266,6 +410,9 @@
* the animation (if ![Controller.isLaunching]), and will have SRC blending mode (ultimately
* punching a hole in the [transition container][Controller.transitionContainer]) iff [drawHole]
* is true.
+ *
+ * If [useSpring] is true, a multi-spring animation will be used instead of the default
+ * interpolators.
*/
fun startAnimation(
controller: Controller,
@@ -273,8 +420,9 @@
windowBackgroundColor: Int,
fadeWindowBackgroundLayer: Boolean = true,
drawHole: Boolean = false,
+ useSpring: Boolean = false,
): Animation {
- if (!controller.isLaunching) checkReturnAnimationFrameworkFlag()
+ if (!controller.isLaunching || useSpring) checkReturnAnimationFrameworkFlag()
// We add an extra layer with the same color as the dialog/app splash screen background
// color, which is usually the same color of the app background. We first fade in this layer
@@ -293,6 +441,7 @@
windowBackgroundLayer,
fadeWindowBackgroundLayer,
drawHole,
+ useSpring,
)
.apply { start() }
}
@@ -304,6 +453,7 @@
endState: State,
windowBackgroundLayer: GradientDrawable,
fadeWindowBackgroundLayer: Boolean = true,
+ useSpring: Boolean = false,
drawHole: Boolean = false,
): Animation {
val transitionContainer = controller.transitionContainer
@@ -321,19 +471,35 @@
openingWindowSyncView != null &&
openingWindowSyncView.viewRootImpl != controller.transitionContainer.viewRootImpl
- return createInterpolatedAnimation(
- controller,
- startState,
- endState,
- windowBackgroundLayer,
- transitionContainer,
- transitionContainerOverlay,
- openingWindowSyncView,
- openingWindowSyncViewOverlay,
- fadeWindowBackgroundLayer,
- drawHole,
- moveBackgroundLayerWhenAppVisibilityChanges,
- )
+ return if (useSpring && springTimings != null && springInterpolators != null) {
+ createSpringAnimation(
+ controller,
+ startState,
+ endState,
+ windowBackgroundLayer,
+ transitionContainer,
+ transitionContainerOverlay,
+ openingWindowSyncView,
+ openingWindowSyncViewOverlay,
+ fadeWindowBackgroundLayer,
+ drawHole,
+ moveBackgroundLayerWhenAppVisibilityChanges,
+ )
+ } else {
+ createInterpolatedAnimation(
+ controller,
+ startState,
+ endState,
+ windowBackgroundLayer,
+ transitionContainer,
+ transitionContainerOverlay,
+ openingWindowSyncView,
+ openingWindowSyncViewOverlay,
+ fadeWindowBackgroundLayer,
+ drawHole,
+ moveBackgroundLayerWhenAppVisibilityChanges,
+ )
+ }
}
/**
@@ -478,6 +644,7 @@
fadeWindowBackgroundLayer,
drawHole,
controller.isLaunching,
+ useSpring = false,
)
controller.onTransitionAnimationProgress(state, progress, linearProgress)
@@ -486,6 +653,215 @@
return InterpolatedAnimation(animator)
}
+ /**
+ * Creates a compound animator made up of three springs: one for the center x position, one for
+ * the center-y position, and one for the overall scale.
+ *
+ * This animator uses [springTimings] and [springInterpolators] for opacity, based on the scale
+ * progress.
+ */
+ private fun createSpringAnimation(
+ controller: Controller,
+ startState: State,
+ endState: State,
+ windowBackgroundLayer: GradientDrawable,
+ transitionContainer: View,
+ transitionContainerOverlay: ViewGroupOverlay,
+ openingWindowSyncView: View?,
+ openingWindowSyncViewOverlay: ViewOverlay?,
+ fadeWindowBackgroundLayer: Boolean = true,
+ drawHole: Boolean = false,
+ moveBackgroundLayerWhenAppVisibilityChanges: Boolean = false,
+ ): Animation {
+ var springX: SpringAnimation? = null
+ var springY: SpringAnimation? = null
+ var targetX = endState.centerX
+ var targetY = endState.centerY
+
+ var movedBackgroundLayer = false
+
+ fun maybeUpdateEndState() {
+ if (endState.centerX != targetX && endState.centerY != targetY) {
+ targetX = endState.centerX
+ targetY = endState.centerY
+
+ springX?.animateToFinalPosition(targetX)
+ springY?.animateToFinalPosition(targetY)
+ }
+ }
+
+ fun updateProgress(state: SpringState) {
+ if (
+ (!state.isCenterXDone && state.centerX == state.previousCenterX) ||
+ (!state.isCenterYDone && state.centerY == state.previousCenterY) ||
+ (!state.isScaleDone && state.scale == state.previousScale)
+ ) {
+ // Because all three springs use the same update method, we only actually update
+ // when all values have changed, avoiding two redundant calls per frame.
+ return
+ }
+
+ // Update the latest values for the check above.
+ state.previousCenterX = state.centerX
+ state.previousCenterY = state.centerY
+ state.previousScale = state.scale
+
+ // Current scale-based values, that will be used to find the new animation bounds.
+ val width =
+ MathUtils.lerp(startState.width.toFloat(), endState.width.toFloat(), state.scale)
+ val height =
+ MathUtils.lerp(startState.height.toFloat(), endState.height.toFloat(), state.scale)
+
+ val newState =
+ State(
+ left = (state.centerX - width / 2).toInt(),
+ top = (state.centerY - height / 2).toInt(),
+ right = (state.centerX + width / 2).toInt(),
+ bottom = (state.centerY + height / 2).toInt(),
+ topCornerRadius =
+ MathUtils.lerp(
+ startState.topCornerRadius,
+ endState.topCornerRadius,
+ state.scale,
+ ),
+ bottomCornerRadius =
+ MathUtils.lerp(
+ startState.bottomCornerRadius,
+ endState.bottomCornerRadius,
+ state.scale,
+ ),
+ )
+ .apply {
+ visible = checkVisibility(timings, state.scale, controller.isLaunching)
+ }
+
+ if (!movedBackgroundLayer) {
+ movedBackgroundLayer =
+ maybeMoveBackgroundLayer(
+ controller,
+ newState,
+ windowBackgroundLayer,
+ transitionContainer,
+ transitionContainerOverlay,
+ openingWindowSyncView,
+ openingWindowSyncViewOverlay,
+ moveBackgroundLayerWhenAppVisibilityChanges,
+ )
+ }
+
+ val container =
+ if (movedBackgroundLayer) {
+ openingWindowSyncView!!
+ } else {
+ controller.transitionContainer
+ }
+ applyStateToWindowBackgroundLayer(
+ windowBackgroundLayer,
+ newState,
+ state.scale,
+ container,
+ fadeWindowBackgroundLayer,
+ drawHole,
+ isLaunching = false,
+ useSpring = true,
+ )
+
+ controller.onTransitionAnimationProgress(newState, state.scale, state.scale)
+
+ maybeUpdateEndState()
+ }
+
+ val springState = SpringState(centerX = startState.centerX, centerY = startState.centerY)
+ val isExpandingFullyAbove = isExpandingFullyAbove(transitionContainer, endState)
+
+ /** End listener for each spring, which only does the end work if all springs are done. */
+ fun onAnimationEnd() {
+ if (!springState.isDone) return
+ onAnimationEnd(
+ controller,
+ isExpandingFullyAbove,
+ windowBackgroundLayer,
+ transitionContainerOverlay,
+ openingWindowSyncViewOverlay,
+ moveBackgroundLayerWhenAppVisibilityChanges,
+ )
+ }
+
+ springX =
+ SpringAnimation(
+ springState,
+ buildProperty(SpringProperty.CENTER_X) { state -> updateProgress(state) },
+ )
+ .apply {
+ spring =
+ SpringForce(endState.centerX).apply {
+ stiffness = springParams.centerXStiffness
+ dampingRatio = springParams.centerXDampingRatio
+ }
+
+ setStartValue(startState.centerX)
+ setMinValue(min(startState.centerX, endState.centerX))
+ setMaxValue(max(startState.centerX, endState.centerX))
+
+ addEndListener { _, _, _, _ ->
+ springState.isCenterXDone = true
+ onAnimationEnd()
+ }
+ }
+ springY =
+ SpringAnimation(
+ springState,
+ buildProperty(SpringProperty.CENTER_Y) { state -> updateProgress(state) },
+ )
+ .apply {
+ spring =
+ SpringForce(endState.centerY).apply {
+ stiffness = springParams.centerYStiffness
+ dampingRatio = springParams.centerYDampingRatio
+ }
+
+ setStartValue(startState.centerY)
+ setMinValue(min(startState.centerY, endState.centerY))
+ setMaxValue(max(startState.centerY, endState.centerY))
+
+ addEndListener { _, _, _, _ ->
+ springState.isCenterYDone = true
+ onAnimationEnd()
+ }
+ }
+ val springScale =
+ SpringAnimation(
+ springState,
+ buildProperty(SpringProperty.SCALE) { state -> updateProgress(state) },
+ )
+ .apply {
+ spring =
+ SpringForce(1f).apply {
+ stiffness = springParams.scaleStiffness
+ dampingRatio = springParams.scaleDampingRatio
+ }
+
+ setStartValue(0f)
+ setMaxValue(1f)
+ setMinimumVisibleChange(abs(1f / startState.height))
+
+ addEndListener { _, _, _, _ ->
+ springState.isScaleDone = true
+ onAnimationEnd()
+ }
+ }
+
+ return MultiSpringAnimation(springX, springY, springScale, springState) {
+ onAnimationStart(
+ controller,
+ isExpandingFullyAbove,
+ windowBackgroundLayer,
+ transitionContainerOverlay,
+ openingWindowSyncViewOverlay,
+ )
+ }
+ }
+
private fun onAnimationStart(
controller: Controller,
isExpandingFullyAbove: Boolean,
@@ -623,6 +999,7 @@
fadeWindowBackgroundLayer: Boolean,
drawHole: Boolean,
isLaunching: Boolean,
+ useSpring: Boolean,
) {
// Update position.
transitionContainer.getLocationOnScreen(transitionContainerLocation)
@@ -644,8 +1021,19 @@
cornerRadii[7] = state.bottomCornerRadius
drawable.cornerRadii = cornerRadii
- // We first fade in the background layer to hide the expanding view, then fade it out
- // with SRC mode to draw a hole punch in the status bar and reveal the opening window.
+ val timings: Timings
+ val interpolators: Interpolators
+ if (useSpring) {
+ timings = springTimings!!
+ interpolators = springInterpolators!!
+ } else {
+ timings = this.timings
+ interpolators = this.interpolators
+ }
+
+ // We first fade in the background layer to hide the expanding view, then fade it out with
+ // SRC mode to draw a hole punch in the status bar and reveal the opening window (if
+ // needed). If !isLaunching, the reverse happens.
val fadeInProgress =
getProgress(
timings,
@@ -653,6 +1041,13 @@
timings.contentBeforeFadeOutDelay,
timings.contentBeforeFadeOutDuration,
)
+ val fadeOutProgress =
+ getProgress(
+ timings,
+ linearProgress,
+ timings.contentAfterFadeInDelay,
+ timings.contentAfterFadeInDuration,
+ )
if (isLaunching) {
if (fadeInProgress < 1) {
@@ -660,13 +1055,6 @@
interpolators.contentBeforeFadeOutInterpolator.getInterpolation(fadeInProgress)
drawable.alpha = (alpha * 0xFF).roundToInt()
} else if (fadeWindowBackgroundLayer) {
- val fadeOutProgress =
- getProgress(
- timings,
- linearProgress,
- timings.contentAfterFadeInDelay,
- timings.contentAfterFadeInDuration,
- )
val alpha =
1 -
interpolators.contentAfterFadeInInterpolator.getInterpolation(
@@ -690,13 +1078,6 @@
drawable.setXfermode(SRC_MODE)
}
} else {
- val fadeOutProgress =
- getProgress(
- timings,
- linearProgress,
- timings.contentAfterFadeInDelay,
- timings.contentAfterFadeInDuration,
- )
val alpha =
1 -
interpolators.contentAfterFadeInInterpolator.getInterpolation(
diff --git a/packages/SystemUI/compose/core/src/com/android/compose/animation/Easings.kt b/packages/SystemUI/compose/core/src/com/android/compose/animation/Easings.kt
index 4fe9f89..dc6e0ce 100644
--- a/packages/SystemUI/compose/core/src/com/android/compose/animation/Easings.kt
+++ b/packages/SystemUI/compose/core/src/com/android/compose/animation/Easings.kt
@@ -16,6 +16,7 @@
package com.android.compose.animation
+import androidx.compose.animation.core.CubicBezierEasing
import androidx.compose.animation.core.Easing
import androidx.core.animation.Interpolator
import com.android.app.animation.InterpolatorsAndroidX
@@ -59,6 +60,17 @@
/** The linear interpolator. */
val Linear = fromInterpolator(InterpolatorsAndroidX.LINEAR)
+ /**
+ * Use this easing for animating progress values coming from the back callback to get the
+ * predictive-back-typical decelerate motion.
+ *
+ * This easing is similar to [StandardDecelerate] but has a slight acceleration phase at the
+ * start.
+ *
+ * See also [InterpolatorsAndroidX.BACK_GESTURE].
+ */
+ val PredictiveBack = CubicBezierEasing(0.1f, 0.1f, 0f, 1f)
+
/** The default legacy interpolator as defined in Material 1. Also known as FAST_OUT_SLOW_IN. */
val Legacy = fromInterpolator(InterpolatorsAndroidX.LEGACY)
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromLockscreenToBouncerTransition.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromLockscreenToBouncerTransition.kt
index dd37b53..cdf8d00 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromLockscreenToBouncerTransition.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromLockscreenToBouncerTransition.kt
@@ -1,6 +1,6 @@
package com.android.systemui.scene.ui.composable.transitions
-import androidx.compose.animation.core.CubicBezierEasing
+import com.android.compose.animation.Easings
import com.android.compose.animation.scene.TransitionBuilder
import com.android.systemui.bouncer.ui.composable.Bouncer
@@ -9,7 +9,7 @@
}
fun TransitionBuilder.bouncerToLockscreenPreview() {
- fractionRange(easing = CubicBezierEasing(0.1f, 0.1f, 0f, 1f)) {
+ fractionRange(easing = Easings.PredictiveBack) {
scaleDraw(Bouncer.Elements.Content, scaleY = 0.8f, scaleX = 0.8f)
}
}
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPatternViewControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardPatternViewControllerTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/keyguard/KeyguardPatternViewControllerTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardPatternViewControllerTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinViewControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardPinViewControllerTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinViewControllerTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardPinViewControllerTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityViewFlipperControllerTest.java b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSecurityViewFlipperControllerTest.java
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityViewFlipperControllerTest.java
rename to packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSecurityViewFlipperControllerTest.java
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSimPinViewControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSimPinViewControllerTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/keyguard/KeyguardSimPinViewControllerTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSimPinViewControllerTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSimPukViewControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSimPukViewControllerTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/keyguard/KeyguardSimPukViewControllerTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSimPukViewControllerTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSliceViewControllerTest.java b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSliceViewControllerTest.java
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/keyguard/KeyguardSliceViewControllerTest.java
rename to packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSliceViewControllerTest.java
diff --git a/packages/SystemUI/tests/src/com/android/systemui/clipboardoverlay/ClipboardOverlaySuppressionControllerImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/clipboardoverlay/ClipboardOverlaySuppressionControllerImplTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/clipboardoverlay/ClipboardOverlaySuppressionControllerImplTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/clipboardoverlay/ClipboardOverlaySuppressionControllerImplTest.kt
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalEditModeViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalEditModeViewModelTest.kt
index 179ba22..cecc11e 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalEditModeViewModelTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalEditModeViewModelTest.kt
@@ -19,7 +19,6 @@
import android.appwidget.AppWidgetProviderInfo
import android.content.ActivityNotFoundException
import android.content.ComponentName
-import android.content.Intent
import android.content.pm.PackageManager
import android.content.pm.UserInfo
import android.provider.Settings
@@ -27,7 +26,6 @@
import android.view.accessibility.AccessibilityManager
import android.view.accessibility.accessibilityManager
import android.widget.RemoteViews
-import androidx.activity.result.ActivityResultLauncher
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.UiEventLogger
@@ -88,7 +86,6 @@
@Mock private lateinit var mediaHost: MediaHost
@Mock private lateinit var uiEventLogger: UiEventLogger
@Mock private lateinit var packageManager: PackageManager
- @Mock private lateinit var activityResultLauncher: ActivityResultLauncher<Intent>
@Mock private lateinit var metricsLogger: CommunalMetricsLogger
private val kosmos = testKosmos()
@@ -117,10 +114,7 @@
communalSceneInteractor = kosmos.communalSceneInteractor
communalInteractor = spy(kosmos.communalInteractor)
kosmos.fakeUserRepository.setUserInfos(listOf(MAIN_USER_INFO))
- kosmos.fakeUserTracker.set(
- userInfos = listOf(MAIN_USER_INFO),
- selectedUserIndex = 0,
- )
+ kosmos.fakeUserTracker.set(userInfos = listOf(MAIN_USER_INFO), selectedUserIndex = 0)
kosmos.fakeFeatureFlagsClassic.set(Flags.COMMUNAL_SERVICE_ENABLED, true)
accessibilityManager = kosmos.accessibilityManager
@@ -257,10 +251,13 @@
@Test
fun onOpenWidgetPicker_launchesWidgetPickerActivity() {
testScope.runTest {
+ var activityStarted = false
val success =
- underTest.onOpenWidgetPicker(testableResources.resources, activityResultLauncher)
+ underTest.onOpenWidgetPicker(testableResources.resources) { _ ->
+ run { activityStarted = true }
+ }
- verify(activityResultLauncher).launch(any())
+ assertTrue(activityStarted)
assertTrue(success)
}
}
@@ -268,14 +265,10 @@
@Test
fun onOpenWidgetPicker_activityLaunchThrowsException_failure() {
testScope.runTest {
- whenever(activityResultLauncher.launch(any()))
- .thenThrow(ActivityNotFoundException::class.java)
-
val success =
- underTest.onOpenWidgetPicker(
- testableResources.resources,
- activityResultLauncher,
- )
+ underTest.onOpenWidgetPicker(testableResources.resources) { _ ->
+ run { throw ActivityNotFoundException() }
+ }
assertFalse(success)
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/lifecycle/HydratorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/lifecycle/HydratorTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/lifecycle/HydratorTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/lifecycle/HydratorTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/navigationbar/views/NavigationBarButtonTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/navigationbar/views/NavigationBarButtonTest.java
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/navigationbar/views/NavigationBarButtonTest.java
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/navigationbar/views/NavigationBarButtonTest.java
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/data/repository/QSColumnsRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/data/repository/QSColumnsRepositoryTest.kt
new file mode 100644
index 0000000..fd1f52b
--- /dev/null
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/data/repository/QSColumnsRepositoryTest.kt
@@ -0,0 +1,83 @@
+/*
+ * 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.qs.panels.data.repository
+
+import android.platform.test.annotations.EnableFlags
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.common.ui.data.repository.fakeConfigurationRepository
+import com.android.systemui.coroutines.collectLastValue
+import com.android.systemui.kosmos.testCase
+import com.android.systemui.kosmos.testScope
+import com.android.systemui.res.R
+import com.android.systemui.shade.shared.flag.DualShade
+import com.android.systemui.testKosmos
+import com.google.common.truth.Truth.assertThat
+import kotlinx.coroutines.test.runTest
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@SmallTest
+@RunWith(AndroidJUnit4::class)
+class QSColumnsRepositoryTest : SysuiTestCase() {
+ private val kosmos = testKosmos()
+ private lateinit var underTest: QSColumnsRepository
+
+ @Before
+ fun setUp() {
+ underTest = with(kosmos) { qsColumnsRepository }
+ }
+
+ @Test
+ fun configChanges_triggerColumnsUpdate() =
+ with(kosmos) {
+ testScope.runTest {
+ val latest by collectLastValue(underTest.columns)
+
+ setColumnsInConfig(4)
+ assertThat(latest).isEqualTo(4)
+
+ setColumnsInConfig(8)
+ assertThat(latest).isEqualTo(8)
+ }
+ }
+
+ @Test
+ @EnableFlags(DualShade.FLAG_NAME)
+ fun withDualShade_returnsCorrectValue() =
+ with(kosmos) {
+ testScope.runTest {
+ val latest by collectLastValue(underTest.columns)
+ assertThat(latest).isEqualTo(4)
+
+ setColumnsInConfig(8, id = R.integer.quick_settings_dual_shade_num_columns)
+ // Asserts config changes are ignored
+ assertThat(latest).isEqualTo(4)
+ }
+ }
+
+ private fun setColumnsInConfig(
+ columns: Int,
+ id: Int = R.integer.quick_settings_infinite_grid_num_columns,
+ ) =
+ with(kosmos) {
+ testCase.context.orCreateTestableResources.addOverride(id, columns)
+ fakeConfigurationRepository.onConfigurationChange()
+ }
+}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/viewmodel/QuickQuickSettingsViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/viewmodel/QuickQuickSettingsViewModelTest.kt
index ef85302..a1c0ef2 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/viewmodel/QuickQuickSettingsViewModelTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/viewmodel/QuickQuickSettingsViewModelTest.kt
@@ -58,6 +58,11 @@
qsPreferencesInteractor.setLargeTilesSpecs(
tiles.filter { it.spec.startsWith(PREFIX_LARGE) }.toSet()
)
+ testCase.context.orCreateTestableResources.addOverride(
+ R.integer.quick_settings_infinite_grid_num_columns,
+ 4,
+ )
+ fakeConfigurationRepository.onConfigurationChange()
}
private val underTest = kosmos.quickQuickSettingsViewModel
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/RecordIssueTileTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/RecordIssueTileTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/qs/tiles/RecordIssueTileTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/RecordIssueTileTest.kt
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/screenrecord/data/model/ScreenRecordModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/screenrecord/data/model/ScreenRecordModelTest.kt
index 9331c8d..0bbf47c 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/screenrecord/data/model/ScreenRecordModelTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/screenrecord/data/model/ScreenRecordModelTest.kt
@@ -16,13 +16,16 @@
package com.android.systemui.screenrecord.data.model
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.screenrecord.data.model.ScreenRecordModel.Starting.Companion.toCountdownSeconds
import com.google.common.truth.Truth.assertThat
+import org.junit.runner.RunWith
import kotlin.test.Test
@SmallTest
+@RunWith(AndroidJUnit4::class)
class ScreenRecordModelTest : SysuiTestCase() {
@Test
fun countdownSeconds_millis0_is0() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/screenshot/ScreenshotDataTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/screenshot/ScreenshotDataTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/screenshot/ScreenshotDataTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/screenshot/ScreenshotDataTest.kt
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java
index 0e9ef06..0454317 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java
@@ -22,6 +22,10 @@
import static com.google.common.truth.Truth.assertThat;
+import static kotlinx.coroutines.flow.FlowKt.emptyFlow;
+import static kotlinx.coroutines.flow.SharedFlowKt.MutableSharedFlow;
+import static kotlinx.coroutines.flow.StateFlowKt.MutableStateFlow;
+
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyFloat;
@@ -36,10 +40,6 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import static kotlinx.coroutines.flow.FlowKt.emptyFlow;
-import static kotlinx.coroutines.flow.SharedFlowKt.MutableSharedFlow;
-import static kotlinx.coroutines.flow.StateFlowKt.MutableStateFlow;
-
import android.animation.Animator;
import android.annotation.IdRes;
import android.content.ContentResolver;
@@ -201,6 +201,12 @@
import com.android.systemui.util.time.SystemClock;
import com.android.wm.shell.animation.FlingAnimationUtils;
+import dagger.Lazy;
+
+import kotlinx.coroutines.CoroutineDispatcher;
+import kotlinx.coroutines.channels.BufferOverflow;
+import kotlinx.coroutines.test.TestScope;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
@@ -215,11 +221,6 @@
import java.util.List;
import java.util.Optional;
-import dagger.Lazy;
-import kotlinx.coroutines.CoroutineDispatcher;
-import kotlinx.coroutines.channels.BufferOverflow;
-import kotlinx.coroutines.test.TestScope;
-
public class NotificationPanelViewControllerBaseTest extends SysuiTestCase {
protected static final int SPLIT_SHADE_FULL_TRANSITION_DISTANCE = 400;
@@ -461,7 +462,8 @@
() -> mKosmos.getSceneInteractor(),
() -> mKosmos.getSceneContainerOcclusionInteractor(),
() -> mKosmos.getKeyguardClockInteractor(),
- () -> mKosmos.getSceneBackInteractor());
+ () -> mKosmos.getSceneBackInteractor(),
+ () -> mKosmos.getAlternateBouncerInteractor());
KeyguardStatusView keyguardStatusView = new KeyguardStatusView(mContext);
keyguardStatusView.setId(R.id.keyguard_status_view);
@@ -622,7 +624,8 @@
() -> mKosmos.getSceneInteractor(),
() -> mKosmos.getSceneContainerOcclusionInteractor(),
() -> mKosmos.getKeyguardClockInteractor(),
- () -> mKosmos.getSceneBackInteractor()),
+ () -> mKosmos.getSceneBackInteractor(),
+ () -> mKosmos.getAlternateBouncerInteractor()),
mKeyguardBypassController,
mDozeParameters,
mScreenOffAnimationController,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/OperatorNameViewControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/OperatorNameViewControllerTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/OperatorNameViewControllerTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/OperatorNameViewControllerTest.kt
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt
index db274cc..f8720b4 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt
@@ -28,6 +28,8 @@
import com.android.systemui.SysuiTestCase
import com.android.systemui.authentication.data.repository.fakeAuthenticationRepository
import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
+import com.android.systemui.bouncer.domain.interactor.alternateBouncerInteractor
+import com.android.systemui.bouncer.domain.interactor.givenCanShowAlternateBouncer
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.deviceentry.domain.interactor.deviceUnlockedInteractor
import com.android.systemui.flags.DisableSceneContainer
@@ -83,8 +85,9 @@
private val kosmos = testKosmos()
private val testScope = kosmos.testScope
- private val sceneInteractor = kosmos.sceneInteractor
- private val keyguardTransitionRepository = kosmos.fakeKeyguardTransitionRepository
+ private val sceneInteractor by lazy { kosmos.sceneInteractor }
+ private val keyguardTransitionRepository by lazy { kosmos.fakeKeyguardTransitionRepository }
+ private val alternateBouncerInteractor by lazy { kosmos.alternateBouncerInteractor }
private val mockDarkAnimator = mock<ObjectAnimator>()
private lateinit var underTest: StatusBarStateControllerImpl
@@ -121,6 +124,7 @@
{ kosmos.sceneContainerOcclusionInteractor },
{ kosmos.keyguardClockInteractor },
{ kosmos.sceneBackInteractor },
+ { kosmos.alternateBouncerInteractor },
) {
override fun createDarkAnimator(): ObjectAnimator {
return mockDarkAnimator
@@ -299,6 +303,52 @@
@Test
@EnableSceneContainer
+ @DisableFlags(DualShade.FLAG_NAME)
+ fun start_hydratesStatusBarState_withAlternateBouncer() =
+ testScope.runTest {
+ var statusBarState = underTest.state
+ val listener =
+ object : StatusBarStateController.StateListener {
+ override fun onStateChanged(newState: Int) {
+ statusBarState = newState
+ }
+ }
+ underTest.addCallback(listener)
+
+ val currentScene by collectLastValue(sceneInteractor.currentScene)
+ val deviceUnlockStatus by
+ collectLastValue(kosmos.deviceUnlockedInteractor.deviceUnlockStatus)
+ val alternateBouncerIsVisible by collectLastValue(alternateBouncerInteractor.isVisible)
+
+ kosmos.fakeAuthenticationRepository.setAuthenticationMethod(
+ AuthenticationMethodModel.Password
+ )
+ kosmos.fakeDeviceEntryFingerprintAuthRepository.setAuthenticationStatus(
+ SuccessFingerprintAuthenticationStatus(0, true)
+ )
+ runCurrent()
+ assertThat(deviceUnlockStatus!!.isUnlocked).isTrue()
+
+ sceneInteractor.changeScene(toScene = Scenes.Lockscreen, loggingReason = "reason")
+ runCurrent()
+ assertThat(currentScene).isEqualTo(Scenes.Lockscreen)
+
+ kosmos.givenCanShowAlternateBouncer()
+ alternateBouncerInteractor.forceShow()
+ runCurrent()
+ assertThat(alternateBouncerIsVisible).isTrue()
+
+ // Call start to begin hydrating based on the scene framework:
+ underTest.start()
+
+ sceneInteractor.changeScene(toScene = Scenes.Gone, loggingReason = "reason")
+ runCurrent()
+ assertThat(currentScene).isEqualTo(Scenes.Gone)
+ assertThat(statusBarState).isEqualTo(StatusBarState.KEYGUARD)
+ }
+
+ @Test
+ @EnableSceneContainer
@EnableFlags(DualShade.FLAG_NAME)
fun start_hydratesStatusBarState_dualShade_whileLocked() =
testScope.runTest {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/call/domain/interactor/CallChipInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/call/domain/interactor/CallChipInteractorTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/call/domain/interactor/CallChipInteractorTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/call/domain/interactor/CallChipInteractorTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModelTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModelTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModelTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/casttootherdevice/domian/interactor/MediaRouterChipInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/casttootherdevice/domian/interactor/MediaRouterChipInteractorTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/casttootherdevice/domian/interactor/MediaRouterChipInteractorTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/casttootherdevice/domian/interactor/MediaRouterChipInteractorTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/view/EndCastScreenToOtherDeviceDialogDelegateTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/view/EndCastScreenToOtherDeviceDialogDelegateTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/view/EndCastScreenToOtherDeviceDialogDelegateTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/view/EndCastScreenToOtherDeviceDialogDelegateTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/view/EndGenericCastToOtherDeviceDialogDelegateTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/view/EndGenericCastToOtherDeviceDialogDelegateTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/view/EndGenericCastToOtherDeviceDialogDelegateTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/view/EndGenericCastToOtherDeviceDialogDelegateTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/viewmodel/CastToOtherDeviceChipViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/viewmodel/CastToOtherDeviceChipViewModelTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/viewmodel/CastToOtherDeviceChipViewModelTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/viewmodel/CastToOtherDeviceChipViewModelTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/mediaprojection/domain/interactor/MediaProjectionChipInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/mediaprojection/domain/interactor/MediaProjectionChipInteractorTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/mediaprojection/domain/interactor/MediaProjectionChipInteractorTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/mediaprojection/domain/interactor/MediaProjectionChipInteractorTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/mediaprojection/ui/view/EndMediaProjectionDialogHelperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/mediaprojection/ui/view/EndMediaProjectionDialogHelperTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/mediaprojection/ui/view/EndMediaProjectionDialogHelperTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/mediaprojection/ui/view/EndMediaProjectionDialogHelperTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/ron/demo/ui/viewmodel/DemoRonChipViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ron/demo/ui/viewmodel/DemoRonChipViewModelTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/ron/demo/ui/viewmodel/DemoRonChipViewModelTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ron/demo/ui/viewmodel/DemoRonChipViewModelTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/screenrecord/domain/interactor/ScreenRecordChipInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/screenrecord/domain/interactor/ScreenRecordChipInteractorTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/screenrecord/domain/interactor/ScreenRecordChipInteractorTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/screenrecord/domain/interactor/ScreenRecordChipInteractorTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/screenrecord/ui/view/EndScreenRecordingDialogDelegateTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/screenrecord/ui/view/EndScreenRecordingDialogDelegateTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/screenrecord/ui/view/EndScreenRecordingDialogDelegateTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/screenrecord/ui/view/EndScreenRecordingDialogDelegateTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/screenrecord/ui/viewmodel/ScreenRecordChipViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/screenrecord/ui/viewmodel/ScreenRecordChipViewModelTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/screenrecord/ui/viewmodel/ScreenRecordChipViewModelTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/screenrecord/ui/viewmodel/ScreenRecordChipViewModelTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/sharetoapp/ui/view/EndShareToAppDialogDelegateTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/sharetoapp/ui/view/EndShareToAppDialogDelegateTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/sharetoapp/ui/view/EndShareToAppDialogDelegateTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/sharetoapp/ui/view/EndShareToAppDialogDelegateTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/sharetoapp/ui/viewmodel/ShareToAppChipViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/sharetoapp/ui/viewmodel/ShareToAppChipViewModelTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/sharetoapp/ui/viewmodel/ShareToAppChipViewModelTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/sharetoapp/ui/viewmodel/ShareToAppChipViewModelTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/ui/viewmodel/ChipTransitionHelperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/ChipTransitionHelperTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/ui/viewmodel/ChipTransitionHelperTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/ChipTransitionHelperTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipViewModelTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipViewModelTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipViewModelTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsViewModelTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsViewModelTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsViewModelTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsWithRonsViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsWithRonsViewModelTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsWithRonsViewModelTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsWithRonsViewModelTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/AboveShelfObserverTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/AboveShelfObserverTest.java
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/AboveShelfObserverTest.java
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/AboveShelfObserverTest.java
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationTransitionAnimatorControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/NotificationTransitionAnimatorControllerTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationTransitionAnimatorControllerTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/NotificationTransitionAnimatorControllerTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/domain/interactor/HeadsUpNotificationInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/domain/interactor/HeadsUpNotificationInteractorTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/domain/interactor/HeadsUpNotificationInteractorTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/domain/interactor/HeadsUpNotificationInteractorTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowDragControllerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowDragControllerTest.java
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowDragControllerTest.java
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowDragControllerTest.java
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationRowContentBinderImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/NotificationRowContentBinderImplTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationRowContentBinderImplTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/NotificationRowContentBinderImplTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationSnoozeTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/NotificationSnoozeTest.java
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationSnoozeTest.java
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/NotificationSnoozeTest.java
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationTestHelper.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/NotificationTestHelper.java
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationTestHelper.java
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/NotificationTestHelper.java
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationBigPictureTemplateViewWrapperTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationBigPictureTemplateViewWrapperTest.java
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationBigPictureTemplateViewWrapperTest.java
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationBigPictureTemplateViewWrapperTest.java
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationConversationTemplateViewWrapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationConversationTemplateViewWrapperTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationConversationTemplateViewWrapperTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationConversationTemplateViewWrapperTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationCustomViewWrapperTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationCustomViewWrapperTest.java
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationCustomViewWrapperTest.java
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationCustomViewWrapperTest.java
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationMessagingTemplateViewWrapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationMessagingTemplateViewWrapperTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationMessagingTemplateViewWrapperTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationMessagingTemplateViewWrapperTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapperTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapperTest.java
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapperTest.java
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapperTest.java
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainerTest.java
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainerTest.java
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainerTest.java
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationTargetsHelperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/NotificationTargetsHelperTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationTargetsHelperTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/NotificationTargetsHelperTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewControllerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewControllerTest.java
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewControllerTest.java
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewControllerTest.java
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewTest.java
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewTest.java
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewTest.java
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/LightBarTransitionsControllerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/LightBarTransitionsControllerTest.java
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/LightBarTransitionsControllerTest.java
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/LightBarTransitionsControllerTest.java
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicyTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicyTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicyTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicyTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/SystemUIBottomSheetDialogTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/SystemUIBottomSheetDialogTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/SystemUIBottomSheetDialogTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/SystemUIBottomSheetDialogTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationControllerTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationControllerTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationControllerTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/CollapsedStatusBarViewModelImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/CollapsedStatusBarViewModelImplTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/CollapsedStatusBarViewModelImplTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/CollapsedStatusBarViewModelImplTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CastDeviceTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/CastDeviceTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CastDeviceTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/CastDeviceTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/ui/dialog/ModesDialogDelegateTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/ui/dialog/ModesDialogDelegateTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/ui/dialog/ModesDialogDelegateTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/ui/dialog/ModesDialogDelegateTest.kt
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/BackGestureMonitorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/BackGestureRecognizerTest.kt
similarity index 90%
rename from packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/BackGestureMonitorTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/BackGestureRecognizerTest.kt
index cd18925..40c3f22 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/BackGestureMonitorTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/BackGestureRecognizerTest.kt
@@ -31,15 +31,15 @@
@SmallTest
@RunWith(AndroidJUnit4::class)
-class BackGestureMonitorTest : SysuiTestCase() {
+class BackGestureRecognizerTest : SysuiTestCase() {
private var gestureState: GestureState = NotStarted
- private val gestureMonitor =
- BackGestureMonitor(gestureDistanceThresholdPx = SWIPE_DISTANCE.toInt())
+ private val gestureRecognizer =
+ BackGestureRecognizer(gestureDistanceThresholdPx = SWIPE_DISTANCE.toInt())
@Before
fun before() {
- gestureMonitor.addGestureStateCallback { gestureState = it }
+ gestureRecognizer.addGestureStateCallback { gestureState = it }
}
@Test
@@ -85,7 +85,7 @@
}
private fun assertStateAfterEvents(events: List<MotionEvent>, expectedState: GestureState) {
- events.forEach { gestureMonitor.accept(it) }
+ events.forEach { gestureRecognizer.accept(it) }
assertThat(gestureState).isEqualTo(expectedState)
}
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/EasterEggGestureTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/EasterEggGestureTest.kt
index 3f1633a..8406d3b 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/EasterEggGestureTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/EasterEggGestureTest.kt
@@ -36,7 +36,7 @@
private var triggered = false
private val handler =
TouchpadGestureHandler(
- BackGestureMonitor(gestureDistanceThresholdPx = SWIPE_DISTANCE.toInt()),
+ BackGestureRecognizer(gestureDistanceThresholdPx = SWIPE_DISTANCE.toInt()),
EasterEggGestureMonitor(callback = { triggered = true }),
)
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/HomeGestureMonitorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/HomeGestureRecognizerTest.kt
similarity index 90%
rename from packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/HomeGestureMonitorTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/HomeGestureRecognizerTest.kt
index edf0e56..043b775 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/HomeGestureMonitorTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/HomeGestureRecognizerTest.kt
@@ -31,15 +31,15 @@
@SmallTest
@RunWith(AndroidJUnit4::class)
-class HomeGestureMonitorTest : SysuiTestCase() {
+class HomeGestureRecognizerTest : SysuiTestCase() {
private var gestureState: GestureState = GestureState.NotStarted
- private val gestureMonitor =
- HomeGestureMonitor(gestureDistanceThresholdPx = SWIPE_DISTANCE.toInt())
+ private val gestureRecognizer =
+ HomeGestureRecognizer(gestureDistanceThresholdPx = SWIPE_DISTANCE.toInt())
@Before
fun before() {
- gestureMonitor.addGestureStateCallback { gestureState = it }
+ gestureRecognizer.addGestureStateCallback { gestureState = it }
}
@Test
@@ -81,7 +81,7 @@
}
private fun assertStateAfterEvents(events: List<MotionEvent>, expectedState: GestureState) {
- events.forEach { gestureMonitor.accept(it) }
+ events.forEach { gestureRecognizer.accept(it) }
assertThat(gestureState).isEqualTo(expectedState)
}
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/RecentAppsGestureMonitorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/RecentAppsGestureRecognizerTest.kt
similarity index 93%
rename from packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/RecentAppsGestureMonitorTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/RecentAppsGestureRecognizerTest.kt
index f68e773..7095a91 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/RecentAppsGestureMonitorTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/RecentAppsGestureRecognizerTest.kt
@@ -35,7 +35,7 @@
@SmallTest
@RunWith(AndroidJUnit4::class)
-class RecentAppsGestureMonitorTest : SysuiTestCase() {
+class RecentAppsGestureRecognizerTest : SysuiTestCase() {
companion object {
const val THRESHOLD_VELOCITY_PX_PER_MS = 0.1f
@@ -50,8 +50,8 @@
// by default return correct speed for the gesture - as if pointer is slowing down
on { calculateVelocity() } doReturn SLOW
}
- private val gestureMonitor =
- RecentAppsGestureMonitor(
+ private val gestureRecognizer =
+ RecentAppsGestureRecognizer(
gestureDistanceThresholdPx = SWIPE_DISTANCE.toInt(),
velocityThresholdPxPerMs = THRESHOLD_VELOCITY_PX_PER_MS,
velocityTracker = VerticalVelocityTracker(velocityTracker1D),
@@ -59,7 +59,7 @@
@Before
fun before() {
- gestureMonitor.addGestureStateCallback { gestureState = it }
+ gestureRecognizer.addGestureStateCallback { gestureState = it }
}
@Test
@@ -107,7 +107,7 @@
}
private fun assertStateAfterEvents(events: List<MotionEvent>, expectedState: GestureState) {
- events.forEach { gestureMonitor.accept(it) }
+ events.forEach { gestureRecognizer.accept(it) }
assertThat(gestureState).isEqualTo(expectedState)
}
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/TouchpadGestureHandlerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/TouchpadGestureHandlerTest.kt
index 9f7ea679..a867eb3 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/TouchpadGestureHandlerTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/TouchpadGestureHandlerTest.kt
@@ -36,13 +36,13 @@
class TouchpadGestureHandlerTest : SysuiTestCase() {
private var gestureState: GestureState = GestureState.NotStarted
- private val gestureMonitor =
- BackGestureMonitor(gestureDistanceThresholdPx = SWIPE_DISTANCE.toInt())
- private val handler = TouchpadGestureHandler(gestureMonitor, EasterEggGestureMonitor {})
+ private val gestureRecognizer =
+ BackGestureRecognizer(gestureDistanceThresholdPx = SWIPE_DISTANCE.toInt())
+ private val handler = TouchpadGestureHandler(gestureRecognizer, EasterEggGestureMonitor {})
@Before
fun before() {
- gestureMonitor.addGestureStateCallback { gestureState = it }
+ gestureRecognizer.addGestureStateCallback { gestureState = it }
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/wallpapers/data/repository/WallpaperRepositoryImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/wallpapers/data/repository/WallpaperRepositoryImplTest.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/wallpapers/data/repository/WallpaperRepositoryImplTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/wallpapers/data/repository/WallpaperRepositoryImplTest.kt
diff --git a/packages/SystemUI/res/layout/audio_sharing_dialog.xml b/packages/SystemUI/res/layout/audio_sharing_dialog.xml
new file mode 100644
index 0000000..7534e15
--- /dev/null
+++ b/packages/SystemUI/res/layout/audio_sharing_dialog.xml
@@ -0,0 +1,115 @@
+<?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.
+ -->
+
+<androidx.constraintlayout.widget.ConstraintLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/root"
+ style="@style/Widget.SliceView.Panel"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content">
+
+ <ImageView android:id="@+id/icon"
+ android:layout_width="28dp"
+ android:layout_height="28dp"
+ android:src="@drawable/ic_bt_le_audio_sharing"
+ android:layout_marginTop="5dp"
+ android:layout_marginBottom="20dp"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintBottom_toTopOf="@id/title"
+ app:layout_constraintTop_toTopOf="parent" />
+
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="20dp"
+ android:gravity="center_vertical|center_horizontal"
+ android:maxLines="1"
+ android:ellipsize="end"
+ android:text="@string/quick_settings_bluetooth_audio_sharing_dialog_title"
+ android:textAppearance="@style/TextAppearance.Dialog.Title"
+ android:textSize="24sp"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintBottom_toTopOf="@id/subtitle"
+ app:layout_constraintTop_toBottomOf="@id/icon" />
+
+ <TextView
+ android:id="@+id/subtitle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="20dp"
+ android:gravity="center_vertical|center_horizontal"
+ android:ellipsize="end"
+ android:maxLines="2"
+ android:textAppearance="@style/TextAppearance.Dialog.Body.Message"
+ android:textFontWeight="500"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintBottom_toTopOf="@id/message"
+ app:layout_constraintTop_toBottomOf="@id/title" />
+
+ <TextView
+ android:id="@+id/message"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="20dp"
+ android:gravity="center_vertical|center_horizontal"
+ android:ellipsize="end"
+ android:maxLines="2"
+ android:text="@string/quick_settings_bluetooth_audio_sharing_dialog_message"
+ android:textAppearance="@style/TextAppearance.Dialog.Body.Message"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintBottom_toTopOf="@id/share_audio_button"
+ app:layout_constraintTop_toBottomOf="@id/subtitle" />
+
+ <Button
+ android:id="@+id/share_audio_button"
+ style="@style/SettingsLibActionButton"
+ android:textColor="?androidprv:attr/textColorOnAccent"
+ android:background="@drawable/audio_sharing_rounded_bg_ripple"
+ android:layout_marginBottom="4dp"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:minHeight="64dp"
+ android:contentDescription="@string/accessibility_bluetooth_device_settings_see_all"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/message"
+ app:layout_constraintBottom_toTopOf="@+id/switch_active_button"
+ android:text="@string/quick_settings_bluetooth_audio_sharing_button"
+ android:maxLines="2" />
+
+ <Button
+ android:id="@+id/switch_active_button"
+ style="@style/SettingsLibActionButton"
+ android:textColor="?androidprv:attr/textColorOnAccent"
+ android:background="@drawable/audio_sharing_rounded_bg_ripple"
+ android:layout_marginBottom="20dp"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:minHeight="64dp"
+ android:contentDescription="@string/accessibility_bluetooth_device_settings_pair_new_device"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/share_audio_button"
+ app:layout_constraintBottom_toBottomOf="parent"
+ android:maxLines="2" />
+</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
diff --git a/packages/SystemUI/res/values-land/config.xml b/packages/SystemUI/res/values-land/config.xml
index db526b1..b5efeb5 100644
--- a/packages/SystemUI/res/values-land/config.xml
+++ b/packages/SystemUI/res/values-land/config.xml
@@ -25,6 +25,9 @@
<integer name="quick_settings_num_columns">4</integer>
+ <!-- The number of columns in the infinite grid QuickSettings -->
+ <integer name="quick_settings_infinite_grid_num_columns">8</integer>
+
<!-- The number of columns that the top level tiles span in the QuickSettings -->
<integer name="quick_settings_user_time_settings_tile_span">2</integer>
diff --git a/packages/SystemUI/res/values-sw600dp-port/config.xml b/packages/SystemUI/res/values-sw600dp-port/config.xml
index 857e162..7daad1a 100644
--- a/packages/SystemUI/res/values-sw600dp-port/config.xml
+++ b/packages/SystemUI/res/values-sw600dp-port/config.xml
@@ -24,6 +24,9 @@
<!-- The number of columns in the QuickSettings -->
<integer name="quick_settings_num_columns">3</integer>
+ <!-- The number of columns in the infinite grid QuickSettings -->
+ <integer name="quick_settings_infinite_grid_num_columns">6</integer>
+
<integer name="power_menu_lite_max_columns">2</integer>
<integer name="power_menu_lite_max_rows">3</integer>
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index 38ef0e9..6f94f9e 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -73,6 +73,9 @@
<!-- The number of columns in the infinite grid QuickSettings -->
<integer name="quick_settings_infinite_grid_num_columns">4</integer>
+ <!-- The number of columns in the Dual Shade QuickSettings -->
+ <integer name="quick_settings_dual_shade_num_columns">4</integer>
+
<!-- Override column number for quick settings.
For now, this value has effect only when flag lockscreen.enable_landscape is enabled.
TODO (b/293252410) - change this comment/resource when flag is enabled -->
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 7225061..2c5fb56 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -765,6 +765,14 @@
<string name="quick_settings_bluetooth_audio_sharing_button_sharing">Sharing audio</string>
<!-- QuickSettings: Bluetooth dialog audio sharing button text accessibility label. Used as part of the string "Double tap to enter audio sharing settings". [CHAR LIMIT=50]-->
<string name="quick_settings_bluetooth_audio_sharing_button_accessibility">enter audio sharing settings</string>
+ <!-- QuickSettings: Bluetooth audio sharing dialog message. [CHAR LIMIT=NONE]-->
+ <string name="quick_settings_bluetooth_audio_sharing_dialog_message">This device\'s music and videos will play on both pairs of headphones</string>
+ <!-- QuickSettings: Bluetooth audio sharing dialog title. [CHAR LIMIT=NONE]-->
+ <string name="quick_settings_bluetooth_audio_sharing_dialog_title">Share your audio</string>
+ <!-- QuickSettings: Bluetooth audio sharing dialog subtitle. [CHAR LIMIT=NONE]-->
+ <string name="quick_settings_bluetooth_audio_sharing_dialog_subtitle"><xliff:g id="available_device_name" example="device 1">%1$s</xliff:g> and <xliff:g id="active_device_name" example="device 2">%2$s</xliff:g></string>
+ <!-- QuickSettings: Bluetooth audio sharing dialog button text. [CHAR LIMIT=NONE]-->
+ <string name="quick_settings_bluetooth_audio_sharing_dialog_switch_to_button">Switch to <xliff:g id="available_device_name" example="device 1">%1$s</xliff:g></string>
<!-- QuickSettings: Bluetooth secondary label for the battery level of a connected device [CHAR LIMIT=20]-->
<string name="quick_settings_bluetooth_secondary_label_battery_level"><xliff:g id="battery_level_as_percentage">%s</xliff:g> battery</string>
diff --git a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingButtonViewModel.kt b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingButtonViewModel.kt
new file mode 100644
index 0000000..a6fb150
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingButtonViewModel.kt
@@ -0,0 +1,101 @@
+/*
+ * 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.bluetooth.qsdialog
+
+import androidx.annotation.StringRes
+import com.android.settingslib.bluetooth.BluetoothUtils
+import com.android.settingslib.bluetooth.LocalBluetoothManager
+import com.android.systemui.lifecycle.ExclusiveActivatable
+import com.android.systemui.res.R
+import dagger.assisted.AssistedFactory
+import dagger.assisted.AssistedInject
+import kotlinx.coroutines.awaitCancellation
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.flow.asStateFlow
+import kotlinx.coroutines.flow.combine
+
+sealed class AudioSharingButtonState {
+ object Gone : AudioSharingButtonState()
+
+ data class Visible(@StringRes val resId: Int, val isActive: Boolean) :
+ AudioSharingButtonState()
+}
+
+class AudioSharingButtonViewModel
+@AssistedInject
+constructor(
+ private val localBluetoothManager: LocalBluetoothManager?,
+ private val audioSharingInteractor: AudioSharingInteractor,
+ private val bluetoothStateInteractor: BluetoothStateInteractor,
+ private val deviceItemInteractor: DeviceItemInteractor,
+) : ExclusiveActivatable() {
+
+ private val mutableButtonState =
+ MutableStateFlow<AudioSharingButtonState>(AudioSharingButtonState.Gone)
+ /** Flow representing the update of AudioSharingButtonState. */
+ val audioSharingButtonStateUpdate: StateFlow<AudioSharingButtonState> =
+ mutableButtonState.asStateFlow()
+
+ override suspend fun onActivated(): Nothing {
+ combine(
+ bluetoothStateInteractor.bluetoothStateUpdate,
+ deviceItemInteractor.deviceItemUpdate,
+ audioSharingInteractor.isAudioSharingOn
+ ) { bluetoothState, deviceItem, audioSharingOn ->
+ getButtonState(bluetoothState, deviceItem, audioSharingOn)
+ }
+ .collect { mutableButtonState.value = it }
+ awaitCancellation()
+ }
+
+ private fun getButtonState(
+ bluetoothState: Boolean,
+ deviceItem: List<DeviceItem>,
+ audioSharingOn: Boolean
+ ): AudioSharingButtonState {
+ return when {
+ // Don't show button when bluetooth is off
+ !bluetoothState -> AudioSharingButtonState.Gone
+ // Show sharing audio when broadcasting
+ audioSharingOn ->
+ AudioSharingButtonState.Visible(
+ R.string.quick_settings_bluetooth_audio_sharing_button_sharing,
+ isActive = true
+ )
+ // When not broadcasting, don't show button if there's connected source in any device
+ deviceItem.any {
+ BluetoothUtils.hasConnectedBroadcastSource(
+ it.cachedBluetoothDevice,
+ localBluetoothManager
+ )
+ } -> AudioSharingButtonState.Gone
+ // Show audio sharing when there's a connected LE audio device
+ deviceItem.any { BluetoothUtils.isActiveLeAudioDevice(it.cachedBluetoothDevice) } ->
+ AudioSharingButtonState.Visible(
+ R.string.quick_settings_bluetooth_audio_sharing_button,
+ isActive = false
+ )
+ else -> AudioSharingButtonState.Gone
+ }
+ }
+
+ @AssistedFactory
+ interface Factory {
+ fun create(): AudioSharingButtonViewModel
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDeviceItemActionInteractorImpl.kt b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDeviceItemActionInteractorImpl.kt
new file mode 100644
index 0000000..692a78b
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDeviceItemActionInteractorImpl.kt
@@ -0,0 +1,152 @@
+/*
+ * 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.bluetooth.qsdialog
+
+import android.bluetooth.BluetoothDevice
+import android.content.Intent
+import android.os.Bundle
+import android.provider.Settings
+import com.android.internal.logging.UiEventLogger
+import com.android.settingslib.bluetooth.A2dpProfile
+import com.android.settingslib.bluetooth.BluetoothUtils
+import com.android.settingslib.bluetooth.HeadsetProfile
+import com.android.settingslib.bluetooth.HearingAidProfile
+import com.android.settingslib.bluetooth.LeAudioProfile
+import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast
+import com.android.settingslib.bluetooth.LocalBluetoothManager
+import com.android.settingslib.flags.Flags.audioSharingQsDialogImprovement
+import com.android.systemui.animation.DialogTransitionAnimator
+import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.dagger.qualifiers.Background
+import com.android.systemui.dagger.qualifiers.Main
+import com.android.systemui.plugins.ActivityStarter
+import com.android.systemui.statusbar.phone.SystemUIDialog
+import javax.inject.Inject
+import kotlinx.coroutines.CoroutineDispatcher
+import kotlinx.coroutines.withContext
+
+@SysUISingleton
+class AudioSharingDeviceItemActionInteractorImpl
+@Inject
+constructor(
+ private val activityStarter: ActivityStarter,
+ private val audioSharingInteractor: AudioSharingInteractor,
+ private val dialogTransitionAnimator: DialogTransitionAnimator,
+ private val localBluetoothManager: LocalBluetoothManager?,
+ @Main private val mainDispatcher: CoroutineDispatcher,
+ @Background private val backgroundDispatcher: CoroutineDispatcher,
+ private val logger: BluetoothTileDialogLogger,
+ private val uiEventLogger: UiEventLogger,
+ private val delegateFactory: AudioSharingDialogDelegate.Factory,
+ private val deviceItemActionInteractorImpl: DeviceItemActionInteractorImpl,
+) : DeviceItemActionInteractor {
+
+ override suspend fun onClick(deviceItem: DeviceItem, dialog: SystemUIDialog) {
+ withContext(backgroundDispatcher) {
+ if (!audioSharingInteractor.audioSharingAvailable()) {
+ return@withContext deviceItemActionInteractorImpl.onClick(deviceItem, dialog)
+ }
+ val inAudioSharing = BluetoothUtils.isBroadcasting(localBluetoothManager)
+ logger.logDeviceClickInAudioSharingWhenEnabled(inAudioSharing)
+
+ when {
+ deviceItem.type ==
+ DeviceItemType.AVAILABLE_AUDIO_SHARING_MEDIA_BLUETOOTH_DEVICE -> {
+ if (audioSharingQsDialogImprovement()) {
+ withContext(mainDispatcher) {
+ delegateFactory
+ .create(deviceItem.cachedBluetoothDevice)
+ .createDialog()
+ .let { dialogTransitionAnimator.showFromDialog(it, dialog) }
+ }
+ } else {
+ launchSettings(deviceItem.cachedBluetoothDevice.device, dialog)
+ logger.logLaunchSettingsCriteriaMatched(
+ "AvailableAudioSharingDeviceClicked",
+ deviceItem,
+ )
+ }
+ uiEventLogger.log(
+ BluetoothTileDialogUiEvent.AVAILABLE_AUDIO_SHARING_DEVICE_CLICKED
+ )
+ }
+ inSharingAndDeviceNoSource(inAudioSharing, deviceItem) -> {
+ launchSettings(deviceItem.cachedBluetoothDevice.device, dialog)
+ logger.logLaunchSettingsCriteriaMatched("InSharingClickedNoSource", deviceItem)
+ uiEventLogger.log(
+ if (deviceItem.isLeAudioSupported)
+ BluetoothTileDialogUiEvent.LAUNCH_SETTINGS_IN_SHARING_LE_DEVICE_CLICKED
+ else
+ BluetoothTileDialogUiEvent
+ .LAUNCH_SETTINGS_IN_SHARING_NON_LE_DEVICE_CLICKED
+ )
+ }
+ else -> {
+ deviceItemActionInteractorImpl.onClick(deviceItem, dialog)
+ }
+ }
+ }
+ }
+
+ private fun inSharingAndDeviceNoSource(
+ inAudioSharing: Boolean,
+ deviceItem: DeviceItem,
+ ): Boolean {
+ return inAudioSharing &&
+ deviceItem.isMediaDevice &&
+ !BluetoothUtils.hasConnectedBroadcastSource(
+ deviceItem.cachedBluetoothDevice,
+ localBluetoothManager,
+ )
+ }
+
+ private fun launchSettings(device: BluetoothDevice, dialog: SystemUIDialog) {
+ val intent =
+ Intent(Settings.ACTION_BLUETOOTH_SETTINGS).apply {
+ putExtra(
+ EXTRA_SHOW_FRAGMENT_ARGUMENTS,
+ Bundle().apply {
+ putParcelable(LocalBluetoothLeBroadcast.EXTRA_BLUETOOTH_DEVICE, device)
+ },
+ )
+ }
+ intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK
+ activityStarter.postStartActivityDismissingKeyguard(
+ intent,
+ 0,
+ dialogTransitionAnimator.createActivityTransitionController(dialog),
+ )
+ }
+
+ private companion object {
+ const val EXTRA_SHOW_FRAGMENT_ARGUMENTS = ":settings:show_fragment_args"
+
+ val DeviceItem.isLeAudioSupported: Boolean
+ get() =
+ cachedBluetoothDevice.profiles.any { profile ->
+ profile is LeAudioProfile && profile.isEnabled(cachedBluetoothDevice.device)
+ }
+
+ val DeviceItem.isMediaDevice: Boolean
+ get() =
+ cachedBluetoothDevice.uiAccessibleProfiles.any {
+ it is A2dpProfile ||
+ it is HearingAidProfile ||
+ it is LeAudioProfile ||
+ it is HeadsetProfile
+ }
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDialogDelegate.kt b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDialogDelegate.kt
new file mode 100644
index 0000000..3ac942b
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDialogDelegate.kt
@@ -0,0 +1,88 @@
+/*
+ * 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.bluetooth.qsdialog
+
+import android.os.Bundle
+import android.widget.Button
+import android.widget.TextView
+import com.android.internal.logging.UiEventLogger
+import com.android.settingslib.bluetooth.CachedBluetoothDevice
+import com.android.systemui.dagger.qualifiers.Application
+import com.android.systemui.res.R
+import com.android.systemui.statusbar.phone.SystemUIDialog
+import dagger.assisted.Assisted
+import dagger.assisted.AssistedFactory
+import dagger.assisted.AssistedInject
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.launch
+
+class AudioSharingDialogDelegate
+@AssistedInject
+constructor(
+ @Assisted private val cachedBluetoothDevice: CachedBluetoothDevice,
+ @Application private val coroutineScope: CoroutineScope,
+ private val viewModelFactory: AudioSharingDialogViewModel.Factory,
+ private val sysuiDialogFactory: SystemUIDialog.Factory,
+ private val uiEventLogger: UiEventLogger,
+) : SystemUIDialog.Delegate {
+
+ override fun createDialog(): SystemUIDialog = sysuiDialogFactory.create(this)
+
+ override fun beforeCreate(dialog: SystemUIDialog, savedInstanceState: Bundle?) {
+ with(dialog.layoutInflater.inflate(R.layout.audio_sharing_dialog, null)) {
+ dialog.setView(this)
+ val subtitleTextView = requireViewById<TextView>(R.id.subtitle)
+ val shareAudioButton = requireViewById<TextView>(R.id.share_audio_button)
+ val switchActiveButton = requireViewById<Button>(R.id.switch_active_button)
+ val job =
+ coroutineScope.launch {
+ val viewModel = viewModelFactory.create(cachedBluetoothDevice, this)
+ viewModel.dialogState.collect {
+ when (it) {
+ is AudioSharingDialogState.Hide -> dialog.dismiss()
+ is AudioSharingDialogState.Show -> {
+ subtitleTextView.text = it.subtitle
+ switchActiveButton.text = it.switchButtonText
+ switchActiveButton.setOnClickListener {
+ viewModel.switchActiveClicked()
+ uiEventLogger.log(
+ BluetoothTileDialogUiEvent
+ .AUDIO_SHARING_DIALOG_SWITCH_ACTIVE_CLICKED
+ )
+ dialog.dismiss()
+ }
+ shareAudioButton.setOnClickListener {
+ viewModel.shareAudioClicked()
+ uiEventLogger.log(
+ BluetoothTileDialogUiEvent
+ .AUDIO_SHARING_DIALOG_SHARE_AUDIO_CLICKED
+ )
+ dialog.dismiss()
+ }
+ }
+ }
+ }
+ }
+ SystemUIDialog.registerDismissListener(dialog) { job.cancel() }
+ }
+ }
+
+ @AssistedFactory
+ interface Factory {
+ fun create(cachedBluetoothDevice: CachedBluetoothDevice): AudioSharingDialogDelegate
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDialogViewModel.kt b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDialogViewModel.kt
new file mode 100644
index 0000000..dc970aea
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDialogViewModel.kt
@@ -0,0 +1,109 @@
+/*
+ * 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.bluetooth.qsdialog
+
+import android.content.Context
+import com.android.settingslib.bluetooth.CachedBluetoothDevice
+import com.android.settingslib.bluetooth.LocalBluetoothManager
+import com.android.systemui.dagger.qualifiers.Background
+import com.android.systemui.res.R
+import dagger.assisted.Assisted
+import dagger.assisted.AssistedFactory
+import dagger.assisted.AssistedInject
+import kotlinx.coroutines.CoroutineDispatcher
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.distinctUntilChanged
+import kotlinx.coroutines.flow.flowOn
+import kotlinx.coroutines.flow.map
+import kotlinx.coroutines.flow.onStart
+import kotlinx.coroutines.launch
+
+sealed class AudioSharingDialogState {
+ data object Hide : AudioSharingDialogState()
+
+ data class Show(val subtitle: String, val switchButtonText: String) : AudioSharingDialogState()
+}
+
+class AudioSharingDialogViewModel
+@AssistedInject
+constructor(
+ deviceItemInteractor: DeviceItemInteractor,
+ private val audioSharingInteractor: AudioSharingInteractor,
+ private val context: Context,
+ private val localBluetoothManager: LocalBluetoothManager?,
+ @Assisted private val cachedBluetoothDevice: CachedBluetoothDevice,
+ @Assisted private val coroutineScope: CoroutineScope,
+ @Background private val backgroundDispatcher: CoroutineDispatcher,
+) {
+ val dialogState: Flow<AudioSharingDialogState> =
+ deviceItemInteractor.deviceItemUpdateRequest
+ .map {
+ if (
+ audioSharingInteractor.isAvailableAudioSharingMediaBluetoothDevice(
+ cachedBluetoothDevice
+ )
+ ) {
+ createShowState(cachedBluetoothDevice)
+ } else {
+ AudioSharingDialogState.Hide
+ }
+ }
+ .onStart { emit(createShowState(cachedBluetoothDevice)) }
+ .flowOn(backgroundDispatcher)
+ .distinctUntilChanged()
+
+ fun switchActiveClicked() {
+ coroutineScope.launch { audioSharingInteractor.switchActive(cachedBluetoothDevice) }
+ }
+
+ fun shareAudioClicked() {
+ coroutineScope.launch { audioSharingInteractor.startAudioSharing() }
+ }
+
+ private fun createShowState(
+ cachedBluetoothDevice: CachedBluetoothDevice
+ ): AudioSharingDialogState {
+ val activeDeviceName =
+ localBluetoothManager
+ ?.profileManager
+ ?.leAudioProfile
+ ?.activeDevices
+ ?.firstOrNull()
+ ?.let { localBluetoothManager.cachedDeviceManager?.findDevice(it)?.name } ?: ""
+ val availableDeviceName = cachedBluetoothDevice.name
+ return AudioSharingDialogState.Show(
+ context.getString(
+ R.string.quick_settings_bluetooth_audio_sharing_dialog_subtitle,
+ availableDeviceName,
+ activeDeviceName
+ ),
+ context.getString(
+ R.string.quick_settings_bluetooth_audio_sharing_dialog_switch_to_button,
+ availableDeviceName
+ )
+ )
+ }
+
+ @AssistedFactory
+ interface Factory {
+ fun create(
+ cachedBluetoothDevice: CachedBluetoothDevice,
+ coroutineScope: CoroutineScope
+ ): AudioSharingDialogViewModel
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingInteractor.kt b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingInteractor.kt
index 817f2d7..65f1105 100644
--- a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingInteractor.kt
@@ -16,82 +16,148 @@
package com.android.systemui.bluetooth.qsdialog
-import androidx.annotation.StringRes
import com.android.settingslib.bluetooth.BluetoothUtils
+import com.android.settingslib.bluetooth.CachedBluetoothDevice
import com.android.settingslib.bluetooth.LocalBluetoothManager
+import com.android.settingslib.bluetooth.onPlaybackStarted
import com.android.systemui.dagger.SysUISingleton
-import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Background
-import com.android.systemui.res.R
import javax.inject.Inject
import kotlinx.coroutines.CoroutineDispatcher
-import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.SharingStarted
-import kotlinx.coroutines.flow.combine
+import kotlinx.coroutines.flow.emptyFlow
+import kotlinx.coroutines.flow.firstOrNull
+import kotlinx.coroutines.flow.flatMapLatest
+import kotlinx.coroutines.flow.flow
+import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.flowOn
-import kotlinx.coroutines.flow.stateIn
-
-internal sealed class AudioSharingButtonState {
- object Gone : AudioSharingButtonState()
-
- data class Visible(@StringRes val resId: Int, val isActive: Boolean) :
- AudioSharingButtonState()
-}
+import kotlinx.coroutines.flow.mapNotNull
+import kotlinx.coroutines.withContext
/** Holds business logic for the audio sharing state. */
+interface AudioSharingInteractor {
+ val isAudioSharingOn: Flow<Boolean>
+
+ val audioSourceStateUpdate: Flow<Unit>
+
+ suspend fun handleAudioSourceWhenReady()
+
+ suspend fun isAvailableAudioSharingMediaBluetoothDevice(
+ cachedBluetoothDevice: CachedBluetoothDevice
+ ): Boolean
+
+ suspend fun switchActive(cachedBluetoothDevice: CachedBluetoothDevice)
+
+ suspend fun startAudioSharing()
+
+ suspend fun audioSharingAvailable(): Boolean
+}
+
@SysUISingleton
-internal class AudioSharingInteractor
+@OptIn(ExperimentalCoroutinesApi::class)
+class AudioSharingInteractorImpl
@Inject
constructor(
private val localBluetoothManager: LocalBluetoothManager?,
- bluetoothStateInteractor: BluetoothStateInteractor,
- deviceItemInteractor: DeviceItemInteractor,
- @Application private val coroutineScope: CoroutineScope,
+ private val audioSharingRepository: AudioSharingRepository,
@Background private val backgroundDispatcher: CoroutineDispatcher,
-) {
- /** Flow representing the update of AudioSharingButtonState. */
- internal val audioSharingButtonStateUpdate: Flow<AudioSharingButtonState> =
- combine(
- bluetoothStateInteractor.bluetoothStateUpdate,
- deviceItemInteractor.deviceItemUpdate
- ) { bluetoothState, deviceItem ->
- getButtonState(bluetoothState, deviceItem)
+) : AudioSharingInteractor {
+
+ override val isAudioSharingOn: Flow<Boolean> =
+ flow { emit(audioSharingAvailable()) }
+ .flatMapLatest { isEnabled ->
+ if (isEnabled) {
+ audioSharingRepository.inAudioSharing
+ } else {
+ flowOf(false)
+ }
}
.flowOn(backgroundDispatcher)
- .stateIn(
- coroutineScope,
- SharingStarted.WhileSubscribed(replayExpirationMillis = 0),
- initialValue = AudioSharingButtonState.Gone
- )
- private fun getButtonState(
- bluetoothState: Boolean,
- deviceItem: List<DeviceItem>
- ): AudioSharingButtonState {
- return when {
- // Don't show button when bluetooth is off
- !bluetoothState -> AudioSharingButtonState.Gone
- // Show sharing audio when broadcasting
- BluetoothUtils.isBroadcasting(localBluetoothManager) ->
- AudioSharingButtonState.Visible(
- R.string.quick_settings_bluetooth_audio_sharing_button_sharing,
- isActive = true
- )
- // When not broadcasting, don't show button if there's connected source in any device
- deviceItem.any {
- BluetoothUtils.hasConnectedBroadcastSource(
- it.cachedBluetoothDevice,
- localBluetoothManager
- )
- } -> AudioSharingButtonState.Gone
- // Show audio sharing when there's a connected LE audio device
- deviceItem.any { BluetoothUtils.isActiveLeAudioDevice(it.cachedBluetoothDevice) } ->
- AudioSharingButtonState.Visible(
- R.string.quick_settings_bluetooth_audio_sharing_button,
- isActive = false
- )
- else -> AudioSharingButtonState.Gone
+ override val audioSourceStateUpdate =
+ isAudioSharingOn
+ .flatMapLatest {
+ if (it) {
+ audioSharingRepository.audioSourceStateUpdate
+ } else {
+ emptyFlow()
+ }
+ }
+ .flowOn(backgroundDispatcher)
+
+ override suspend fun handleAudioSourceWhenReady() {
+ withContext(backgroundDispatcher) {
+ if (audioSharingAvailable()) {
+ audioSharingRepository.leAudioBroadcastProfile?.let { profile ->
+ isAudioSharingOn
+ .mapNotNull { audioSharingOn ->
+ if (audioSharingOn) {
+ // onPlaybackStarted could emit multiple times during one
+ // audio sharing session, we only perform add source on the
+ // first time
+ profile.onPlaybackStarted.firstOrNull()
+ } else {
+ null
+ }
+ }
+ .flowOn(backgroundDispatcher)
+ .collect { audioSharingRepository.addSource() }
+ }
+ }
}
}
+
+ override suspend fun isAvailableAudioSharingMediaBluetoothDevice(
+ cachedBluetoothDevice: CachedBluetoothDevice
+ ): Boolean {
+ return withContext(backgroundDispatcher) {
+ if (audioSharingAvailable()) {
+ BluetoothUtils.isAvailableAudioSharingMediaBluetoothDevice(
+ cachedBluetoothDevice,
+ localBluetoothManager,
+ )
+ } else {
+ false
+ }
+ }
+ }
+
+ override suspend fun switchActive(cachedBluetoothDevice: CachedBluetoothDevice) {
+ if (!audioSharingAvailable()) {
+ return
+ }
+ audioSharingRepository.setActive(cachedBluetoothDevice)
+ }
+
+ override suspend fun startAudioSharing() {
+ if (!audioSharingAvailable()) {
+ return
+ }
+ audioSharingRepository.startAudioSharing()
+ }
+
+ // TODO(b/367965193): Move this after flags rollout
+ override suspend fun audioSharingAvailable(): Boolean {
+ return audioSharingRepository.audioSharingAvailable()
+ }
+}
+
+@SysUISingleton
+class AudioSharingInteractorEmptyImpl @Inject constructor() : AudioSharingInteractor {
+ override val isAudioSharingOn: Flow<Boolean> = flowOf(false)
+
+ override val audioSourceStateUpdate: Flow<Unit> = emptyFlow()
+
+ override suspend fun handleAudioSourceWhenReady() {}
+
+ override suspend fun isAvailableAudioSharingMediaBluetoothDevice(
+ cachedBluetoothDevice: CachedBluetoothDevice
+ ) = false
+
+ override suspend fun switchActive(cachedBluetoothDevice: CachedBluetoothDevice) {}
+
+ override suspend fun startAudioSharing() {}
+
+ override suspend fun audioSharingAvailable(): Boolean = false
}
diff --git a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingRepository.kt b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingRepository.kt
new file mode 100644
index 0000000..b9b8d36
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingRepository.kt
@@ -0,0 +1,120 @@
+/*
+ * 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.bluetooth.qsdialog
+
+import com.android.settingslib.bluetooth.CachedBluetoothDevice
+import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast
+import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcastAssistant
+import com.android.settingslib.bluetooth.LocalBluetoothManager
+import com.android.settingslib.bluetooth.onSourceConnectedOrRemoved
+import com.android.settingslib.volume.data.repository.AudioSharingRepository as SettingsLibAudioSharingRepository
+import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.dagger.qualifiers.Background
+import kotlinx.coroutines.CoroutineDispatcher
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.flow.emptyFlow
+import kotlinx.coroutines.withContext
+
+interface AudioSharingRepository {
+ val leAudioBroadcastProfile: LocalBluetoothLeBroadcast?
+
+ val audioSourceStateUpdate: Flow<Unit>
+
+ val inAudioSharing: StateFlow<Boolean>
+
+ suspend fun audioSharingAvailable(): Boolean
+
+ suspend fun addSource()
+
+ suspend fun setActive(cachedBluetoothDevice: CachedBluetoothDevice)
+
+ suspend fun startAudioSharing()
+}
+
+@SysUISingleton
+class AudioSharingRepositoryImpl(
+ private val localBluetoothManager: LocalBluetoothManager,
+ private val settingsLibAudioSharingRepository: SettingsLibAudioSharingRepository,
+ @Background private val backgroundDispatcher: CoroutineDispatcher,
+) : AudioSharingRepository {
+
+ override val leAudioBroadcastProfile: LocalBluetoothLeBroadcast?
+ get() = localBluetoothManager.profileManager?.leAudioBroadcastProfile
+
+ private val leAudioBroadcastAssistantProfile: LocalBluetoothLeBroadcastAssistant?
+ get() = localBluetoothManager.profileManager?.leAudioBroadcastAssistantProfile
+
+ override val audioSourceStateUpdate: Flow<Unit> =
+ leAudioBroadcastAssistantProfile?.onSourceConnectedOrRemoved ?: emptyFlow()
+
+ override val inAudioSharing: StateFlow<Boolean> =
+ settingsLibAudioSharingRepository.inAudioSharing
+
+ override suspend fun audioSharingAvailable(): Boolean {
+ return settingsLibAudioSharingRepository.audioSharingAvailable()
+ }
+
+ override suspend fun addSource() {
+ withContext(backgroundDispatcher) {
+ if (!settingsLibAudioSharingRepository.audioSharingAvailable()) {
+ return@withContext
+ }
+ leAudioBroadcastProfile?.latestBluetoothLeBroadcastMetadata?.let { metadata ->
+ leAudioBroadcastAssistantProfile?.let {
+ it.allConnectedDevices.forEach { sink -> it.addSource(sink, metadata, false) }
+ }
+ }
+ }
+ }
+
+ override suspend fun setActive(cachedBluetoothDevice: CachedBluetoothDevice) {
+ withContext(backgroundDispatcher) {
+ if (!settingsLibAudioSharingRepository.audioSharingAvailable()) {
+ return@withContext
+ }
+ cachedBluetoothDevice.setActive()
+ }
+ }
+
+ override suspend fun startAudioSharing() {
+ withContext(backgroundDispatcher) {
+ if (!settingsLibAudioSharingRepository.audioSharingAvailable()) {
+ return@withContext
+ }
+ leAudioBroadcastProfile?.startPrivateBroadcast()
+ }
+ }
+}
+
+@SysUISingleton
+class AudioSharingRepositoryEmptyImpl : AudioSharingRepository {
+ override val leAudioBroadcastProfile: LocalBluetoothLeBroadcast? = null
+
+ override val audioSourceStateUpdate: Flow<Unit> = emptyFlow()
+
+ override val inAudioSharing: StateFlow<Boolean> = MutableStateFlow(false)
+
+ override suspend fun audioSharingAvailable(): Boolean = false
+
+ override suspend fun addSource() {}
+
+ override suspend fun setActive(cachedBluetoothDevice: CachedBluetoothDevice) {}
+
+ override suspend fun startAudioSharing() {}
+}
diff --git a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothStateInteractor.kt b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothStateInteractor.kt
index 17f9e63..55d4d3e 100644
--- a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothStateInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothStateInteractor.kt
@@ -39,7 +39,7 @@
/** Holds business logic for the Bluetooth Dialog's bluetooth and device connection state */
@SysUISingleton
-internal class BluetoothStateInteractor
+class BluetoothStateInteractor
@Inject
constructor(
private val localBluetoothManager: LocalBluetoothManager?,
diff --git a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothTileDialogDelegate.kt b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothTileDialogDelegate.kt
index 7deea73..a9c5c69 100644
--- a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothTileDialogDelegate.kt
+++ b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothTileDialogDelegate.kt
@@ -300,7 +300,7 @@
}
private fun getProgressBarBackground(dialog: SystemUIDialog): View {
- return dialog.requireViewById(R.id.bluetooth_tile_dialog_progress_animation)
+ return dialog.requireViewById(R.id.bluetooth_tile_dialog_progress_background)
}
private fun getScrollViewContent(dialog: SystemUIDialog): View {
diff --git a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothTileDialogUiEvent.kt b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothTileDialogUiEvent.kt
index bdd4c16..aad233f 100644
--- a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothTileDialogUiEvent.kt
+++ b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothTileDialogUiEvent.kt
@@ -42,6 +42,7 @@
LAUNCH_SETTINGS_IN_SHARING_LE_DEVICE_CLICKED(1717),
@UiEvent(doc = "Currently broadcasting and a non-LE audio supported device is clicked")
LAUNCH_SETTINGS_IN_SHARING_NON_LE_DEVICE_CLICKED(1718),
+ @Deprecated("Use case no longer needed")
@UiEvent(
doc = "Not broadcasting, having one connected, another saved LE audio device is clicked"
)
@@ -52,8 +53,13 @@
)
@UiEvent(doc = "Not broadcasting, one of the two connected LE audio devices is clicked")
LAUNCH_SETTINGS_NOT_SHARING_CONNECTED_LE_DEVICE_CLICKED(1720),
+ @Deprecated("Use case no longer needed")
@UiEvent(doc = "Not broadcasting, having two connected, the active LE audio devices is clicked")
- LAUNCH_SETTINGS_NOT_SHARING_ACTIVE_LE_DEVICE_CLICKED(1881);
+ LAUNCH_SETTINGS_NOT_SHARING_ACTIVE_LE_DEVICE_CLICKED(1881),
+ @UiEvent(doc = "Clicked on switch active button on audio sharing dialog")
+ AUDIO_SHARING_DIALOG_SWITCH_ACTIVE_CLICKED(1890),
+ @UiEvent(doc = "Clicked on share audio button on audio sharing dialog")
+ AUDIO_SHARING_DIALOG_SHARE_AUDIO_CLICKED(1891);
override fun getId() = metricId
}
diff --git a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothTileDialogViewModel.kt b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothTileDialogViewModel.kt
index a8f7fc3..5c35c52 100644
--- a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothTileDialogViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothTileDialogViewModel.kt
@@ -28,8 +28,8 @@
import androidx.annotation.VisibleForTesting
import com.android.internal.jank.InteractionJankMonitor
import com.android.internal.logging.UiEventLogger
-import com.android.settingslib.bluetooth.BluetoothUtils
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast
+import com.android.settingslib.flags.Flags.audioSharingQsDialogImprovement
import com.android.systemui.Prefs
import com.android.systemui.animation.DialogCuj
import com.android.systemui.animation.DialogTransitionAnimator
@@ -51,6 +51,7 @@
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.channels.produce
import kotlinx.coroutines.flow.combine
+import kotlinx.coroutines.flow.emptyFlow
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.merge
@@ -68,10 +69,12 @@
private val bluetoothStateInteractor: BluetoothStateInteractor,
private val bluetoothAutoOnInteractor: BluetoothAutoOnInteractor,
private val audioSharingInteractor: AudioSharingInteractor,
+ private val audioSharingButtonViewModelFactory: AudioSharingButtonViewModel.Factory,
private val bluetoothDeviceMetadataInteractor: BluetoothDeviceMetadataInteractor,
private val dialogTransitionAnimator: DialogTransitionAnimator,
private val activityStarter: ActivityStarter,
private val uiEventLogger: UiEventLogger,
+ private val logger: BluetoothTileDialogLogger,
@Application private val coroutineScope: CoroutineScope,
@Main private val mainDispatcher: CoroutineDispatcher,
@Background private val backgroundDispatcher: CoroutineDispatcher,
@@ -102,7 +105,7 @@
expandable?.dialogTransitionController(
DialogCuj(
InteractionJankMonitor.CUJ_SHADE_DIALOG_OPEN,
- INTERACTION_JANK_TAG
+ INTERACTION_JANK_TAG,
)
)
controller?.let {
@@ -117,7 +120,7 @@
// stop the progress bar.
combine(
deviceItemInteractor.deviceItemUpdate,
- deviceItemInteractor.showSeeAllUpdate
+ deviceItemInteractor.showSeeAllUpdate,
) { deviceItem, showSeeAll ->
updateDialogUiJob?.cancel()
updateDialogUiJob = launch {
@@ -127,7 +130,7 @@
deviceItem,
showSeeAll,
showPairNewDevice =
- bluetoothStateInteractor.isBluetoothEnabled()
+ bluetoothStateInteractor.isBluetoothEnabled(),
)
animateProgressBar(dialog, false)
}
@@ -139,7 +142,15 @@
// the device item list and animate the progress bar.
merge(
deviceItemInteractor.deviceItemUpdateRequest,
- bluetoothDeviceMetadataInteractor.metadataUpdate
+ bluetoothDeviceMetadataInteractor.metadataUpdate,
+ if (
+ audioSharingInteractor.audioSharingAvailable() &&
+ audioSharingQsDialogImprovement()
+ ) {
+ audioSharingInteractor.audioSourceStateUpdate
+ } else {
+ emptyFlow()
+ },
)
.onEach {
dialogDelegate.animateProgressBar(dialog, true)
@@ -147,35 +158,42 @@
updateDeviceItemJob = launch {
deviceItemInteractor.updateDeviceItems(
context,
- DeviceFetchTrigger.BLUETOOTH_CALLBACK_RECEIVED
+ DeviceFetchTrigger.BLUETOOTH_CALLBACK_RECEIVED,
)
}
}
.launchIn(this)
- if (BluetoothUtils.isAudioSharingEnabled()) {
- audioSharingInteractor.audioSharingButtonStateUpdate
- .onEach {
- when (it) {
- is AudioSharingButtonState.Visible -> {
- dialogDelegate.onAudioSharingButtonUpdated(
- dialog,
- VISIBLE,
- context.getString(it.resId),
- it.isActive
- )
- }
- is AudioSharingButtonState.Gone -> {
- dialogDelegate.onAudioSharingButtonUpdated(
- dialog,
- GONE,
- label = null,
- isActive = false
- )
+ if (audioSharingInteractor.audioSharingAvailable()) {
+ if (audioSharingQsDialogImprovement()) {
+ launch { audioSharingInteractor.handleAudioSourceWhenReady() }
+ }
+
+ audioSharingButtonViewModelFactory.create().run {
+ audioSharingButtonStateUpdate
+ .onEach {
+ when (it) {
+ is AudioSharingButtonState.Visible -> {
+ dialogDelegate.onAudioSharingButtonUpdated(
+ dialog,
+ VISIBLE,
+ context.getString(it.resId),
+ it.isActive,
+ )
+ }
+ is AudioSharingButtonState.Gone -> {
+ dialogDelegate.onAudioSharingButtonUpdated(
+ dialog,
+ GONE,
+ label = null,
+ isActive = false,
+ )
+ }
}
}
- }
- .launchIn(this)
+ .launchIn(this@launch)
+ launch { activate() }
+ }
}
// bluetoothStateUpdate is emitted when bluetooth on/off state is changed, re-fetch
@@ -185,13 +203,13 @@
dialogDelegate.onBluetoothStateUpdated(
dialog,
it,
- UiProperties.build(it, isAutoOnToggleFeatureAvailable())
+ UiProperties.build(it, isAutoOnToggleFeatureAvailable()),
)
updateDeviceItemJob?.cancel()
updateDeviceItemJob = launch {
deviceItemInteractor.updateDeviceItems(
context,
- DeviceFetchTrigger.BLUETOOTH_STATE_CHANGE_RECEIVED
+ DeviceFetchTrigger.BLUETOOTH_STATE_CHANGE_RECEIVED,
)
}
}
@@ -209,7 +227,10 @@
// deviceItemClick is emitted when user clicked on a device item.
dialogDelegate.deviceItemClick
- .onEach { deviceItemActionInteractor.onClick(it, dialog) }
+ .onEach {
+ deviceItemActionInteractor.onClick(it, dialog)
+ logger.logDeviceClick(it.cachedBluetoothDevice.address, it.type)
+ }
.launchIn(this)
// contentHeight is emitted when the dialog is dismissed.
@@ -230,7 +251,7 @@
dialog,
it,
if (it) R.string.turn_on_bluetooth_auto_info_enabled
- else R.string.turn_on_bluetooth_auto_info_disabled
+ else R.string.turn_on_bluetooth_auto_info_disabled,
)
}
.launchIn(this)
@@ -252,18 +273,18 @@
withContext(backgroundDispatcher) {
sharedPreferences.getInt(
CONTENT_HEIGHT_PREF_KEY,
- ViewGroup.LayoutParams.WRAP_CONTENT
+ ViewGroup.LayoutParams.WRAP_CONTENT,
)
}
return bluetoothDialogDelegateFactory.create(
UiProperties.build(
bluetoothStateInteractor.isBluetoothEnabled(),
- isAutoOnToggleFeatureAvailable()
+ isAutoOnToggleFeatureAvailable(),
),
cachedContentHeight,
this@BluetoothTileDialogViewModel,
- { cancelJob() }
+ { cancelJob() },
)
}
@@ -275,7 +296,7 @@
EXTRA_SHOW_FRAGMENT_ARGUMENTS,
Bundle().apply {
putString("device_address", deviceItem.cachedBluetoothDevice.address)
- }
+ },
)
}
startSettingsActivity(intent, view)
@@ -299,7 +320,7 @@
EXTRA_SHOW_FRAGMENT_ARGUMENTS,
Bundle().apply {
putBoolean(LocalBluetoothLeBroadcast.EXTRA_START_LE_AUDIO_SHARING, true)
- }
+ },
)
}
startSettingsActivity(intent, view)
@@ -345,7 +366,7 @@
companion object {
internal fun build(
isBluetoothEnabled: Boolean,
- isAutoOnToggleFeatureAvailable: Boolean
+ isAutoOnToggleFeatureAvailable: Boolean,
) =
UiProperties(
subTitleResId = getSubtitleResId(isBluetoothEnabled),
@@ -355,7 +376,7 @@
scrollViewMinHeightResId =
if (isAutoOnToggleFeatureAvailable)
R.dimen.bluetooth_dialog_scroll_view_min_height_with_auto_on
- else R.dimen.bluetooth_dialog_scroll_view_min_height
+ else R.dimen.bluetooth_dialog_scroll_view_min_height,
)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemActionInteractor.kt b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemActionInteractor.kt
index f1894d3..cf0f19f 100644
--- a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemActionInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemActionInteractor.kt
@@ -16,87 +16,28 @@
package com.android.systemui.bluetooth.qsdialog
-import android.bluetooth.BluetoothDevice
-import android.bluetooth.BluetoothProfile
-import android.content.Intent
-import android.os.Bundle
-import android.provider.Settings
import com.android.internal.logging.UiEventLogger
-import com.android.settingslib.bluetooth.A2dpProfile
-import com.android.settingslib.bluetooth.BluetoothUtils
-import com.android.settingslib.bluetooth.HeadsetProfile
-import com.android.settingslib.bluetooth.HearingAidProfile
-import com.android.settingslib.bluetooth.LeAudioProfile
-import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast
-import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcastAssistant
-import com.android.settingslib.bluetooth.LocalBluetoothManager
-import com.android.systemui.animation.DialogTransitionAnimator
-import com.android.systemui.bluetooth.qsdialog.DeviceItemActionInteractor.LaunchSettingsCriteria.Companion.getCurrentConnectedLeByGroupId
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
-import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.statusbar.phone.SystemUIDialog
import javax.inject.Inject
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.withContext
+interface DeviceItemActionInteractor {
+ suspend fun onClick(deviceItem: DeviceItem, dialog: SystemUIDialog) {}
+}
+
@SysUISingleton
-class DeviceItemActionInteractor
+class DeviceItemActionInteractorImpl
@Inject
constructor(
- private val activityStarter: ActivityStarter,
- private val dialogTransitionAnimator: DialogTransitionAnimator,
- private val localBluetoothManager: LocalBluetoothManager?,
@Background private val backgroundDispatcher: CoroutineDispatcher,
- private val logger: BluetoothTileDialogLogger,
private val uiEventLogger: UiEventLogger,
-) {
- private val leAudioProfile: LeAudioProfile?
- get() = localBluetoothManager?.profileManager?.leAudioProfile
+) : DeviceItemActionInteractor {
- private val assistantProfile: LocalBluetoothLeBroadcastAssistant?
- get() = localBluetoothManager?.profileManager?.leAudioBroadcastAssistantProfile
-
- private val launchSettingsCriteriaList: List<LaunchSettingsCriteria>
- get() =
- listOf(
- InSharingClickedNoSource(localBluetoothManager, backgroundDispatcher, logger),
- NotSharingClickedNonConnect(
- leAudioProfile,
- assistantProfile,
- backgroundDispatcher,
- logger
- ),
- NotSharingClickedActive(
- leAudioProfile,
- assistantProfile,
- backgroundDispatcher,
- logger
- )
- )
-
- suspend fun onClick(deviceItem: DeviceItem, dialog: SystemUIDialog) {
+ override suspend fun onClick(deviceItem: DeviceItem, dialog: SystemUIDialog) {
withContext(backgroundDispatcher) {
- logger.logDeviceClick(deviceItem.cachedBluetoothDevice.address, deviceItem.type)
- if (
- BluetoothUtils.isAudioSharingEnabled() &&
- localBluetoothManager != null &&
- leAudioProfile != null &&
- assistantProfile != null
- ) {
- val inAudioSharing = BluetoothUtils.isBroadcasting(localBluetoothManager)
- logger.logDeviceClickInAudioSharingWhenEnabled(inAudioSharing)
-
- val criteriaMatched =
- launchSettingsCriteriaList.firstOrNull {
- it.matched(inAudioSharing, deviceItem)
- }
- if (criteriaMatched != null) {
- uiEventLogger.log(criteriaMatched.getClickUiEvent(deviceItem))
- launchSettings(deviceItem.cachedBluetoothDevice.device, dialog)
- return@withContext
- }
- }
deviceItem.cachedBluetoothDevice.apply {
when (deviceItem.type) {
DeviceItemType.ACTIVE_MEDIA_BLUETOOTH_DEVICE -> {
@@ -106,12 +47,6 @@
DeviceItemType.AUDIO_SHARING_MEDIA_BLUETOOTH_DEVICE -> {
uiEventLogger.log(BluetoothTileDialogUiEvent.AUDIO_SHARING_DEVICE_CLICKED)
}
- DeviceItemType.AVAILABLE_AUDIO_SHARING_MEDIA_BLUETOOTH_DEVICE -> {
- // TODO(b/360759048): pop up dialog
- uiEventLogger.log(
- BluetoothTileDialogUiEvent.AVAILABLE_AUDIO_SHARING_DEVICE_CLICKED
- )
- }
DeviceItemType.AVAILABLE_MEDIA_BLUETOOTH_DEVICE -> {
setActive()
uiEventLogger.log(BluetoothTileDialogUiEvent.CONNECTED_DEVICE_SET_ACTIVE)
@@ -126,186 +61,12 @@
connect()
uiEventLogger.log(BluetoothTileDialogUiEvent.SAVED_DEVICE_CONNECT)
}
- }
- }
- }
- }
-
- private fun launchSettings(device: BluetoothDevice, dialog: SystemUIDialog) {
- val intent =
- Intent(Settings.ACTION_BLUETOOTH_SETTINGS).apply {
- putExtra(
- EXTRA_SHOW_FRAGMENT_ARGUMENTS,
- Bundle().apply {
- putParcelable(LocalBluetoothLeBroadcast.EXTRA_BLUETOOTH_DEVICE, device)
+ DeviceItemType.AVAILABLE_AUDIO_SHARING_MEDIA_BLUETOOTH_DEVICE -> {
+ // Do nothing. Should already be handled in
+ // AudioSharingDeviceItemActionInteractor.
}
- )
- }
- intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK
- activityStarter.postStartActivityDismissingKeyguard(
- intent,
- 0,
- dialogTransitionAnimator.createActivityTransitionController(dialog)
- )
- }
-
- private interface LaunchSettingsCriteria {
- suspend fun matched(inAudioSharing: Boolean, deviceItem: DeviceItem): Boolean
-
- suspend fun getClickUiEvent(deviceItem: DeviceItem): BluetoothTileDialogUiEvent
-
- companion object {
- suspend fun getCurrentConnectedLeByGroupId(
- leAudioProfile: LeAudioProfile,
- assistantProfile: LocalBluetoothLeBroadcastAssistant,
- @Background backgroundDispatcher: CoroutineDispatcher,
- logger: BluetoothTileDialogLogger,
- ): Map<Int, List<BluetoothDevice>> {
- return withContext(backgroundDispatcher) {
- assistantProfile
- .getDevicesMatchingConnectionStates(
- intArrayOf(BluetoothProfile.STATE_CONNECTED)
- )
- ?.filterNotNull()
- ?.groupBy { leAudioProfile.getGroupId(it) }
- ?.also { logger.logConnectedLeByGroupId(it) } ?: emptyMap()
}
}
}
}
-
- private class InSharingClickedNoSource(
- private val localBluetoothManager: LocalBluetoothManager?,
- @Background private val backgroundDispatcher: CoroutineDispatcher,
- private val logger: BluetoothTileDialogLogger,
- ) : LaunchSettingsCriteria {
- // If currently broadcasting and the clicked device is not connected to the source
- override suspend fun matched(inAudioSharing: Boolean, deviceItem: DeviceItem): Boolean {
- return withContext(backgroundDispatcher) {
- val matched =
- inAudioSharing &&
- deviceItem.isMediaDevice &&
- !BluetoothUtils.hasConnectedBroadcastSource(
- deviceItem.cachedBluetoothDevice,
- localBluetoothManager
- )
-
- if (matched) {
- logger.logLaunchSettingsCriteriaMatched("InSharingClickedNoSource", deviceItem)
- }
-
- matched
- }
- }
-
- override suspend fun getClickUiEvent(deviceItem: DeviceItem) =
- if (deviceItem.isLeAudioSupported)
- BluetoothTileDialogUiEvent.LAUNCH_SETTINGS_IN_SHARING_LE_DEVICE_CLICKED
- else BluetoothTileDialogUiEvent.LAUNCH_SETTINGS_IN_SHARING_NON_LE_DEVICE_CLICKED
- }
-
- private class NotSharingClickedNonConnect(
- private val leAudioProfile: LeAudioProfile?,
- private val assistantProfile: LocalBluetoothLeBroadcastAssistant?,
- @Background private val backgroundDispatcher: CoroutineDispatcher,
- private val logger: BluetoothTileDialogLogger,
- ) : LaunchSettingsCriteria {
- // If not broadcasting, having one device connected, and clicked on a not yet connected LE
- // audio device
- override suspend fun matched(inAudioSharing: Boolean, deviceItem: DeviceItem): Boolean {
- return withContext(backgroundDispatcher) {
- val matched =
- leAudioProfile?.let { leAudio ->
- assistantProfile?.let { assistant ->
- !inAudioSharing &&
- getCurrentConnectedLeByGroupId(
- leAudio,
- assistant,
- backgroundDispatcher,
- logger
- )
- .size == 1 &&
- deviceItem.isNotConnectedLeAudioSupported
- }
- } ?: false
-
- if (matched) {
- logger.logLaunchSettingsCriteriaMatched(
- "NotSharingClickedNonConnect",
- deviceItem
- )
- }
-
- matched
- }
- }
-
- override suspend fun getClickUiEvent(deviceItem: DeviceItem) =
- BluetoothTileDialogUiEvent.LAUNCH_SETTINGS_NOT_SHARING_SAVED_LE_DEVICE_CLICKED
- }
-
- private class NotSharingClickedActive(
- private val leAudioProfile: LeAudioProfile?,
- private val assistantProfile: LocalBluetoothLeBroadcastAssistant?,
- @Background private val backgroundDispatcher: CoroutineDispatcher,
- private val logger: BluetoothTileDialogLogger,
- ) : LaunchSettingsCriteria {
- // If not broadcasting, having two device connected, clicked on the active LE audio
- // device
- override suspend fun matched(inAudioSharing: Boolean, deviceItem: DeviceItem): Boolean {
- return withContext(backgroundDispatcher) {
- val matched =
- leAudioProfile?.let { leAudio ->
- assistantProfile?.let { assistant ->
- !inAudioSharing &&
- getCurrentConnectedLeByGroupId(
- leAudio,
- assistant,
- backgroundDispatcher,
- logger
- )
- .size == 2 &&
- deviceItem.isActiveLeAudioSupported
- }
- } ?: false
-
- if (matched) {
- logger.logLaunchSettingsCriteriaMatched(
- "NotSharingClickedConnected",
- deviceItem
- )
- }
-
- matched
- }
- }
-
- override suspend fun getClickUiEvent(deviceItem: DeviceItem) =
- BluetoothTileDialogUiEvent.LAUNCH_SETTINGS_NOT_SHARING_ACTIVE_LE_DEVICE_CLICKED
- }
-
- private companion object {
- const val EXTRA_SHOW_FRAGMENT_ARGUMENTS = ":settings:show_fragment_args"
-
- val DeviceItem.isLeAudioSupported: Boolean
- get() =
- cachedBluetoothDevice.profiles.any { profile ->
- profile is LeAudioProfile && profile.isEnabled(cachedBluetoothDevice.device)
- }
-
- val DeviceItem.isNotConnectedLeAudioSupported: Boolean
- get() = type == DeviceItemType.SAVED_BLUETOOTH_DEVICE && isLeAudioSupported
-
- val DeviceItem.isActiveLeAudioSupported: Boolean
- get() = type == DeviceItemType.ACTIVE_MEDIA_BLUETOOTH_DEVICE && isLeAudioSupported
-
- val DeviceItem.isMediaDevice: Boolean
- get() =
- cachedBluetoothDevice.uiAccessibleProfiles.any {
- it is A2dpProfile ||
- it is HearingAidProfile ||
- it is LeAudioProfile ||
- it is HeadsetProfile
- }
- }
}
diff --git a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemFactory.kt b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemFactory.kt
index 7280489..7ed5629 100644
--- a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemFactory.kt
+++ b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemFactory.kt
@@ -23,7 +23,6 @@
import com.android.settingslib.bluetooth.CachedBluetoothDevice
import com.android.settingslib.bluetooth.LocalBluetoothManager
import com.android.settingslib.flags.Flags
-import com.android.settingslib.flags.Flags.enableLeAudioSharing
import com.android.systemui.res.R
private val backgroundOn = R.drawable.settingslib_switch_bar_bg_on
@@ -56,7 +55,7 @@
connectionSummary: String,
background: Int,
actionAccessibilityLabel: String,
- isActive: Boolean
+ isActive: Boolean,
): DeviceItem {
return DeviceItem(
type = type,
@@ -70,7 +69,7 @@
background = background,
isEnabled = !cachedDevice.isBusy,
actionAccessibilityLabel = actionAccessibilityLabel,
- isActive = isActive
+ isActive = isActive,
)
}
}
@@ -80,7 +79,7 @@
override fun isFilterMatched(
context: Context,
cachedDevice: CachedBluetoothDevice,
- audioManager: AudioManager
+ audioManager: AudioManager,
): Boolean {
return BluetoothUtils.isActiveMediaDevice(cachedDevice) &&
BluetoothUtils.isAvailableMediaBluetoothDevice(cachedDevice, audioManager)
@@ -94,20 +93,20 @@
cachedDevice.connectionSummary ?: "",
backgroundOn,
context.getString(actionAccessibilityLabelDisconnect),
- isActive = true
+ isActive = true,
)
}
}
internal class AudioSharingMediaDeviceItemFactory(
- private val localBluetoothManager: LocalBluetoothManager?
+ private val localBluetoothManager: LocalBluetoothManager
) : DeviceItemFactory() {
override fun isFilterMatched(
context: Context,
cachedDevice: CachedBluetoothDevice,
- audioManager: AudioManager
+ audioManager: AudioManager,
): Boolean {
- return enableLeAudioSharing() &&
+ return BluetoothUtils.isAudioSharingEnabled() &&
BluetoothUtils.hasConnectedBroadcastSource(cachedDevice, localBluetoothManager)
}
@@ -120,24 +119,24 @@
?: context.getString(audioSharing),
if (cachedDevice.isBusy) backgroundOffBusy else backgroundOn,
"",
- isActive = !cachedDevice.isBusy
+ isActive = !cachedDevice.isBusy,
)
}
}
internal class AvailableAudioSharingMediaDeviceItemFactory(
- private val localBluetoothManager: LocalBluetoothManager?
+ private val localBluetoothManager: LocalBluetoothManager
) : AvailableMediaDeviceItemFactory() {
override fun isFilterMatched(
context: Context,
cachedDevice: CachedBluetoothDevice,
- audioManager: AudioManager
+ audioManager: AudioManager,
): Boolean {
return BluetoothUtils.isAudioSharingEnabled() &&
super.isFilterMatched(context, cachedDevice, audioManager) &&
BluetoothUtils.isAvailableAudioSharingMediaBluetoothDevice(
cachedDevice,
- localBluetoothManager
+ localBluetoothManager,
)
}
@@ -151,7 +150,7 @@
),
if (cachedDevice.isBusy) backgroundOffBusy else backgroundOff,
"",
- isActive = false
+ isActive = false,
)
}
}
@@ -160,7 +159,7 @@
override fun isFilterMatched(
context: Context,
cachedDevice: CachedBluetoothDevice,
- audioManager: AudioManager
+ audioManager: AudioManager,
): Boolean {
return BluetoothUtils.isActiveMediaDevice(cachedDevice) &&
BluetoothUtils.isAvailableHearingDevice(cachedDevice)
@@ -171,7 +170,7 @@
override fun isFilterMatched(
context: Context,
cachedDevice: CachedBluetoothDevice,
- audioManager: AudioManager
+ audioManager: AudioManager,
): Boolean {
return !BluetoothUtils.isActiveMediaDevice(cachedDevice) &&
BluetoothUtils.isAvailableMediaBluetoothDevice(cachedDevice, audioManager)
@@ -186,7 +185,7 @@
?: context.getString(connected),
if (cachedDevice.isBusy) backgroundOffBusy else backgroundOff,
context.getString(actionAccessibilityLabelActivate),
- isActive = false
+ isActive = false,
)
}
}
@@ -195,7 +194,7 @@
override fun isFilterMatched(
context: Context,
cachedDevice: CachedBluetoothDevice,
- audioManager: AudioManager
+ audioManager: AudioManager,
): Boolean {
return !BluetoothUtils.isActiveMediaDevice(cachedDevice) &&
BluetoothUtils.isAvailableHearingDevice(cachedDevice)
@@ -206,7 +205,7 @@
override fun isFilterMatched(
context: Context,
cachedDevice: CachedBluetoothDevice,
- audioManager: AudioManager
+ audioManager: AudioManager,
): Boolean {
return if (Flags.enableHideExclusivelyManagedBluetoothDevice()) {
!BluetoothUtils.isExclusivelyManagedBluetoothDevice(context, cachedDevice.device) &&
@@ -225,7 +224,7 @@
?: context.getString(connected),
if (cachedDevice.isBusy) backgroundOffBusy else backgroundOff,
context.getString(actionAccessibilityLabelDisconnect),
- isActive = false
+ isActive = false,
)
}
}
@@ -234,7 +233,7 @@
override fun isFilterMatched(
context: Context,
cachedDevice: CachedBluetoothDevice,
- audioManager: AudioManager
+ audioManager: AudioManager,
): Boolean {
return if (Flags.enableHideExclusivelyManagedBluetoothDevice()) {
!BluetoothUtils.isExclusivelyManagedBluetoothDevice(context, cachedDevice.device) &&
@@ -254,7 +253,7 @@
?: context.getString(saved),
if (cachedDevice.isBusy) backgroundOffBusy else backgroundOff,
context.getString(actionAccessibilityLabelActivate),
- isActive = false
+ isActive = false,
)
}
}
@@ -263,12 +262,12 @@
override fun isFilterMatched(
context: Context,
cachedDevice: CachedBluetoothDevice,
- audioManager: AudioManager
+ audioManager: AudioManager,
): Boolean {
return if (Flags.enableHideExclusivelyManagedBluetoothDevice()) {
!BluetoothUtils.isExclusivelyManagedBluetoothDevice(
context,
- cachedDevice.getDevice()
+ cachedDevice.getDevice(),
) &&
cachedDevice.isHearingAidDevice &&
cachedDevice.bondState == BluetoothDevice.BOND_BONDED &&
diff --git a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemInteractor.kt b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemInteractor.kt
index 9114eca..01b84da 100644
--- a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemInteractor.kt
@@ -39,6 +39,7 @@
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.flow.asStateFlow
+import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.shareIn
import kotlinx.coroutines.isActive
import kotlinx.coroutines.withContext
@@ -54,6 +55,8 @@
private val localBluetoothManager: LocalBluetoothManager?,
private val systemClock: SystemClock,
private val logger: BluetoothTileDialogLogger,
+ private val deviceItemFactoryList: List<@JvmSuppressWildcards DeviceItemFactory>,
+ private val deviceItemDisplayPriority: List<@JvmSuppressWildcards DeviceItemType>,
@Application private val coroutineScope: CoroutineScope,
@Background private val backgroundDispatcher: CoroutineDispatcher,
) {
@@ -67,7 +70,7 @@
internal val showSeeAllUpdate
get() = mutableShowSeeAllUpdate.asStateFlow()
- internal val deviceItemUpdateRequest: SharedFlow<Unit> =
+ val deviceItemUpdateRequest: SharedFlow<Unit> =
conflatedCallbackFlow {
val listener =
object : BluetoothCallback {
@@ -112,28 +115,9 @@
localBluetoothManager?.eventManager?.registerCallback(listener)
awaitClose { localBluetoothManager?.eventManager?.unregisterCallback(listener) }
}
+ .flowOn(backgroundDispatcher)
.shareIn(coroutineScope, SharingStarted.WhileSubscribed(replayExpirationMillis = 0))
- private var deviceItemFactoryList: List<DeviceItemFactory> =
- listOf(
- ActiveMediaDeviceItemFactory(),
- AudioSharingMediaDeviceItemFactory(localBluetoothManager),
- AvailableAudioSharingMediaDeviceItemFactory(localBluetoothManager),
- AvailableMediaDeviceItemFactory(),
- ConnectedDeviceItemFactory(),
- SavedDeviceItemFactory()
- )
-
- private var displayPriority: List<DeviceItemType> =
- listOf(
- DeviceItemType.ACTIVE_MEDIA_BLUETOOTH_DEVICE,
- DeviceItemType.AUDIO_SHARING_MEDIA_BLUETOOTH_DEVICE,
- DeviceItemType.AVAILABLE_AUDIO_SHARING_MEDIA_BLUETOOTH_DEVICE,
- DeviceItemType.AVAILABLE_MEDIA_BLUETOOTH_DEVICE,
- DeviceItemType.CONNECTED_BLUETOOTH_DEVICE,
- DeviceItemType.SAVED_BLUETOOTH_DEVICE,
- )
-
internal suspend fun updateDeviceItems(context: Context, trigger: DeviceFetchTrigger) {
withContext(backgroundDispatcher) {
val start = systemClock.elapsedRealtime()
@@ -144,7 +128,7 @@
.firstOrNull { it.isFilterMatched(context, cachedDevice, audioManager) }
?.create(context, cachedDevice)
}
- .sort(displayPriority, bluetoothAdapter?.mostRecentlyConnectedDevices)
+ .sort(deviceItemDisplayPriority, bluetoothAdapter?.mostRecentlyConnectedDevices)
// Only emit when the job is not cancelled
if (isActive) {
mutableDeviceItemUpdate.tryEmit(deviceItems.take(MAX_DEVICE_ITEM_ENTRY))
@@ -176,14 +160,6 @@
)
}
- internal fun setDeviceItemFactoryListForTesting(list: List<DeviceItemFactory>) {
- deviceItemFactoryList = list
- }
-
- internal fun setDisplayPriorityForTesting(list: List<DeviceItemType>) {
- displayPriority = list
- }
-
companion object {
private const val TAG = "DeviceItemInteractor"
private const val MAX_DEVICE_ITEM_ENTRY = 3
diff --git a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/dagger/AudioSharingModule.kt b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/dagger/AudioSharingModule.kt
new file mode 100644
index 0000000..50970a5
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/dagger/AudioSharingModule.kt
@@ -0,0 +1,128 @@
+/*
+ * 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.bluetooth.qsdialog.dagger
+
+import com.android.settingslib.bluetooth.LocalBluetoothManager
+import com.android.settingslib.flags.Flags
+import com.android.settingslib.volume.data.repository.AudioSharingRepository as SettingsLibAudioSharingRepository
+import com.android.systemui.bluetooth.qsdialog.ActiveMediaDeviceItemFactory
+import com.android.systemui.bluetooth.qsdialog.AudioSharingDeviceItemActionInteractorImpl
+import com.android.systemui.bluetooth.qsdialog.AudioSharingInteractor
+import com.android.systemui.bluetooth.qsdialog.AudioSharingInteractorEmptyImpl
+import com.android.systemui.bluetooth.qsdialog.AudioSharingInteractorImpl
+import com.android.systemui.bluetooth.qsdialog.AudioSharingMediaDeviceItemFactory
+import com.android.systemui.bluetooth.qsdialog.AudioSharingRepository
+import com.android.systemui.bluetooth.qsdialog.AudioSharingRepositoryEmptyImpl
+import com.android.systemui.bluetooth.qsdialog.AudioSharingRepositoryImpl
+import com.android.systemui.bluetooth.qsdialog.AvailableAudioSharingMediaDeviceItemFactory
+import com.android.systemui.bluetooth.qsdialog.AvailableMediaDeviceItemFactory
+import com.android.systemui.bluetooth.qsdialog.ConnectedDeviceItemFactory
+import com.android.systemui.bluetooth.qsdialog.DeviceItemActionInteractor
+import com.android.systemui.bluetooth.qsdialog.DeviceItemActionInteractorImpl
+import com.android.systemui.bluetooth.qsdialog.DeviceItemFactory
+import com.android.systemui.bluetooth.qsdialog.DeviceItemType
+import com.android.systemui.bluetooth.qsdialog.SavedDeviceItemFactory
+import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.dagger.qualifiers.Background
+import dagger.Lazy
+import dagger.Module
+import dagger.Provides
+import kotlinx.coroutines.CoroutineDispatcher
+
+/** Dagger module for audio sharing code for BT QS dialog */
+@Module
+interface AudioSharingModule {
+
+ companion object {
+ @Provides
+ @SysUISingleton
+ fun provideAudioSharingRepository(
+ localBluetoothManager: LocalBluetoothManager?,
+ settingsLibAudioSharingRepository: SettingsLibAudioSharingRepository,
+ @Background backgroundDispatcher: CoroutineDispatcher,
+ ): AudioSharingRepository =
+ if (
+ Flags.enableLeAudioSharing() &&
+ Flags.audioSharingQsDialogImprovement() &&
+ localBluetoothManager != null
+ ) {
+ AudioSharingRepositoryImpl(
+ localBluetoothManager,
+ settingsLibAudioSharingRepository,
+ backgroundDispatcher,
+ )
+ } else {
+ AudioSharingRepositoryEmptyImpl()
+ }
+
+ @Provides
+ @SysUISingleton
+ fun provideAudioSharingInteractor(
+ localBluetoothManager: LocalBluetoothManager?,
+ impl: Lazy<AudioSharingInteractorImpl>,
+ emptyImpl: Lazy<AudioSharingInteractorEmptyImpl>,
+ ): AudioSharingInteractor =
+ if (Flags.enableLeAudioSharing() && localBluetoothManager != null) {
+ impl.get()
+ } else {
+ emptyImpl.get()
+ }
+
+ @Provides
+ @SysUISingleton
+ fun provideDeviceItemActionInteractor(
+ localBluetoothManager: LocalBluetoothManager?,
+ audioSharingImpl: Lazy<AudioSharingDeviceItemActionInteractorImpl>,
+ impl: Lazy<DeviceItemActionInteractorImpl>,
+ ): DeviceItemActionInteractor =
+ if (Flags.enableLeAudioSharing() && localBluetoothManager != null) {
+ audioSharingImpl.get()
+ } else {
+ impl.get()
+ }
+
+ @Provides
+ @SysUISingleton
+ fun provideDeviceItemFactoryList(
+ localBluetoothManager: LocalBluetoothManager?
+ ): List<DeviceItemFactory> = buildList {
+ add(ActiveMediaDeviceItemFactory())
+ if (Flags.enableLeAudioSharing() && localBluetoothManager != null) {
+ add(AudioSharingMediaDeviceItemFactory(localBluetoothManager))
+ add(AvailableAudioSharingMediaDeviceItemFactory(localBluetoothManager))
+ }
+ add(AvailableMediaDeviceItemFactory())
+ add(ConnectedDeviceItemFactory())
+ add(SavedDeviceItemFactory())
+ }
+
+ @Provides
+ @SysUISingleton
+ fun provideDeviceItemDisplayPriority(
+ localBluetoothManager: LocalBluetoothManager?
+ ): List<DeviceItemType> = buildList {
+ add(DeviceItemType.ACTIVE_MEDIA_BLUETOOTH_DEVICE)
+ if (Flags.enableLeAudioSharing() && localBluetoothManager != null) {
+ add(DeviceItemType.AUDIO_SHARING_MEDIA_BLUETOOTH_DEVICE)
+ add(DeviceItemType.AVAILABLE_AUDIO_SHARING_MEDIA_BLUETOOTH_DEVICE)
+ }
+ add(DeviceItemType.AVAILABLE_MEDIA_BLUETOOTH_DEVICE)
+ add(DeviceItemType.CONNECTED_BLUETOOTH_DEVICE)
+ add(DeviceItemType.SAVED_BLUETOOTH_DEVICE)
+ }
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalEditModeViewModel.kt b/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalEditModeViewModel.kt
index 3ae9250..6508e4b5 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalEditModeViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalEditModeViewModel.kt
@@ -27,7 +27,6 @@
import android.util.Log
import android.view.accessibility.AccessibilityEvent
import android.view.accessibility.AccessibilityManager
-import androidx.activity.result.ActivityResultLauncher
import com.android.internal.logging.UiEventLogger
import com.android.systemui.communal.dagger.CommunalModule.Companion.LAUNCHER_PACKAGE
import com.android.systemui.communal.data.model.CommunalWidgetCategories
@@ -184,10 +183,10 @@
val isIdleOnCommunal: StateFlow<Boolean> = communalInteractor.isIdleOnCommunal
- /** Launch the widget picker activity using the given {@link ActivityResultLauncher}. */
+ /** Launch the widget picker activity using the given startActivity method. */
suspend fun onOpenWidgetPicker(
resources: Resources,
- activityLauncher: ActivityResultLauncher<Intent>,
+ startActivity: (intent: Intent) -> Unit,
): Boolean =
withContext(backgroundDispatcher) {
val widgets = communalInteractor.widgetContent.first()
@@ -199,7 +198,7 @@
}
getWidgetPickerActivityIntent(resources, excludeList)?.let {
try {
- activityLauncher.launch(it)
+ startActivity(it)
return@withContext true
} catch (e: Exception) {
Log.e(TAG, "Failed to launch widget picker activity", e)
diff --git a/packages/SystemUI/src/com/android/systemui/communal/widgets/EditWidgetsActivity.kt b/packages/SystemUI/src/com/android/systemui/communal/widgets/EditWidgetsActivity.kt
index 6228ac5..8c14d63 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/widgets/EditWidgetsActivity.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/widgets/EditWidgetsActivity.kt
@@ -27,8 +27,6 @@
import android.view.WindowInsets
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
-import androidx.activity.result.ActivityResultLauncher
-import androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
@@ -51,6 +49,7 @@
import com.android.systemui.log.core.Logger
import com.android.systemui.log.dagger.CommunalLog
import com.android.systemui.scene.shared.flag.SceneContainerFlag
+import com.android.systemui.settings.UserTracker
import javax.inject.Inject
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
@@ -64,12 +63,15 @@
private val uiEventLogger: UiEventLogger,
private val widgetConfiguratorFactory: WidgetConfigurationController.Factory,
private val widgetSection: CommunalAppWidgetSection,
+ private val userTracker: UserTracker,
@CommunalLog logBuffer: LogBuffer,
) : ComponentActivity() {
companion object {
private const val TAG = "EditWidgetsActivity"
private const val EXTRA_IS_PENDING_WIDGET_DRAG = "is_pending_widget_drag"
const val EXTRA_OPEN_WIDGET_PICKER_ON_START = "open_widget_picker_on_start"
+
+ private const val REQUEST_CODE_WIDGET_PICKER = 200
}
/**
@@ -110,7 +112,7 @@
object : ActivityLifecycleCallbacks {
override fun onActivityCreated(
activity: Activity,
- savedInstanceState: Bundle?
+ savedInstanceState: Bundle?,
) {
waitingForResult =
savedInstanceState?.getBoolean(STATE_EXTRA_IS_WAITING_FOR_RESULT)
@@ -172,41 +174,6 @@
if (communalEditWidgetsActivityFinishFix()) ActivityControllerImpl(this)
else NopActivityController()
- private val addWidgetActivityLauncher: ActivityResultLauncher<Intent> =
- registerForActivityResult(StartActivityForResult()) { result ->
- when (result.resultCode) {
- RESULT_OK -> {
- uiEventLogger.log(CommunalUiEvent.COMMUNAL_HUB_WIDGET_PICKER_SHOWN)
-
- result.data?.let { intent ->
- val isPendingWidgetDrag =
- intent.getBooleanExtra(EXTRA_IS_PENDING_WIDGET_DRAG, false)
- // Nothing to do when a widget is being dragged & dropped. The drop
- // target in the communal grid will receive the widget to be added (if
- // the user drops it over).
- if (!isPendingWidgetDrag) {
- val (componentName, user) = getWidgetExtraFromIntent(intent)
- if (componentName != null && user != null) {
- // Add widget at the end.
- communalViewModel.onAddWidget(
- componentName,
- user,
- configurator = widgetConfigurator,
- )
- } else {
- run { Log.w(TAG, "No AppWidgetProviderInfo found in result.") }
- }
- }
- } ?: run { Log.w(TAG, "No data in result.") }
- }
- else ->
- Log.w(
- TAG,
- "Failed to receive result from widget picker, code=${result.resultCode}"
- )
- }
- }
-
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -226,8 +193,7 @@
PlatformTheme {
Box(
modifier =
- Modifier.fillMaxSize()
- .background(MaterialTheme.colorScheme.surfaceDim),
+ Modifier.fillMaxSize().background(MaterialTheme.colorScheme.surfaceDim)
) {
CommunalHub(
viewModel = communalViewModel,
@@ -274,7 +240,13 @@
private fun onOpenWidgetPicker() {
lifecycleScope.launch {
- communalViewModel.onOpenWidgetPicker(resources, addWidgetActivityLauncher)
+ communalViewModel.onOpenWidgetPicker(resources) { intent: Intent ->
+ startActivityForResultAsUser(
+ intent,
+ REQUEST_CODE_WIDGET_PICKER,
+ userTracker.userHandle,
+ )
+ }
}
}
@@ -285,7 +257,7 @@
communalViewModel.changeScene(
scene = CommunalScenes.Communal,
loggingReason = "edit mode closing",
- transitionKey = CommunalTransitionKeys.FromEditMode
+ transitionKey = CommunalTransitionKeys.FromEditMode,
)
// Wait for the current scene to be idle on communal.
@@ -309,7 +281,7 @@
flagsMask: Int,
flagsValues: Int,
extraFlags: Int,
- options: Bundle?
+ options: Bundle?,
) {
activityController.onWaitingForResult(true)
super.startIntentSenderForResult(
@@ -319,15 +291,46 @@
flagsMask,
flagsValues,
extraFlags,
- options
+ options,
)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
activityController.onWaitingForResult(false)
super.onActivityResult(requestCode, resultCode, data)
- if (requestCode == WidgetConfigurationController.REQUEST_CODE) {
- widgetConfigurator.setConfigurationResult(resultCode)
+
+ when (requestCode) {
+ WidgetConfigurationController.REQUEST_CODE ->
+ widgetConfigurator.setConfigurationResult(resultCode)
+ REQUEST_CODE_WIDGET_PICKER -> {
+ if (resultCode != RESULT_OK) {
+ Log.w(TAG, "Failed to receive result from widget picker, code=$resultCode")
+ return
+ }
+
+ uiEventLogger.log(CommunalUiEvent.COMMUNAL_HUB_WIDGET_PICKER_SHOWN)
+
+ data?.let { intent ->
+ val isPendingWidgetDrag =
+ intent.getBooleanExtra(EXTRA_IS_PENDING_WIDGET_DRAG, false)
+ // Nothing to do when a widget is being dragged & dropped. The drop
+ // target in the communal grid will receive the widget to be added (if
+ // the user drops it over).
+ if (!isPendingWidgetDrag) {
+ val (componentName, user) = getWidgetExtraFromIntent(intent)
+ if (componentName != null && user != null) {
+ // Add widget at the end.
+ communalViewModel.onAddWidget(
+ componentName,
+ user,
+ configurator = widgetConfigurator,
+ )
+ } else {
+ run { Log.w(TAG, "No AppWidgetProviderInfo found in result.") }
+ }
+ }
+ } ?: run { Log.w(TAG, "No data in result.") }
+ }
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/ui/composable/ShortcutHelper.kt b/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/ui/composable/ShortcutHelper.kt
index b2acc2a..3c8bb09 100644
--- a/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/ui/composable/ShortcutHelper.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/ui/composable/ShortcutHelper.kt
@@ -48,6 +48,7 @@
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
+import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
@@ -434,11 +435,13 @@
@Composable
private fun EndSidePanel(searchQuery: String, modifier: Modifier, category: ShortcutCategory?) {
+ val listState = rememberLazyListState()
+ LaunchedEffect(key1 = category) { if (category != null) listState.animateScrollToItem(0) }
if (category == null) {
NoSearchResultsText(horizontalPadding = 24.dp, fillHeight = false)
return
}
- LazyColumn(modifier = modifier) {
+ LazyColumn(modifier = modifier, state = listState) {
items(category.subCategories) { subcategory ->
SubCategoryContainerDualPane(searchQuery = searchQuery, subCategory = subcategory)
Spacer(modifier = Modifier.height(8.dp))
diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/dagger/PanelsModule.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/dagger/PanelsModule.kt
index 1fe54e4..31e867e 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/panels/dagger/PanelsModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/panels/dagger/PanelsModule.kt
@@ -31,12 +31,12 @@
import com.android.systemui.qs.panels.ui.compose.PaginatableGridLayout
import com.android.systemui.qs.panels.ui.compose.PaginatedGridLayout
import com.android.systemui.qs.panels.ui.compose.infinitegrid.InfiniteGridLayout
-import com.android.systemui.qs.panels.ui.viewmodel.FixedColumnsSizeViewModel
-import com.android.systemui.qs.panels.ui.viewmodel.FixedColumnsSizeViewModelImpl
import com.android.systemui.qs.panels.ui.viewmodel.IconLabelVisibilityViewModel
import com.android.systemui.qs.panels.ui.viewmodel.IconLabelVisibilityViewModelImpl
import com.android.systemui.qs.panels.ui.viewmodel.IconTilesViewModel
import com.android.systemui.qs.panels.ui.viewmodel.IconTilesViewModelImpl
+import com.android.systemui.qs.panels.ui.viewmodel.QSColumnsSizeViewModelImpl
+import com.android.systemui.qs.panels.ui.viewmodel.QSColumnsViewModel
import dagger.Binds
import dagger.Module
import dagger.Provides
@@ -55,7 +55,7 @@
@Binds fun bindIconTilesViewModel(impl: IconTilesViewModelImpl): IconTilesViewModel
- @Binds fun bindGridSizeViewModel(impl: FixedColumnsSizeViewModelImpl): FixedColumnsSizeViewModel
+ @Binds fun bindQSColumnsViewModel(impl: QSColumnsSizeViewModelImpl): QSColumnsViewModel
@Binds
fun bindIconLabelVisibilityViewModel(
diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/data/repository/FixedColumnsRepository.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/data/repository/FixedColumnsRepository.kt
deleted file mode 100644
index 32ce973..0000000
--- a/packages/SystemUI/src/com/android/systemui/qs/panels/data/repository/FixedColumnsRepository.kt
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.qs.panels.data.repository
-
-import com.android.systemui.dagger.SysUISingleton
-import javax.inject.Inject
-import kotlinx.coroutines.flow.MutableStateFlow
-import kotlinx.coroutines.flow.StateFlow
-import kotlinx.coroutines.flow.asStateFlow
-
-@SysUISingleton
-class FixedColumnsRepository @Inject constructor() {
- // Number of columns in the narrowest state for consistency
- private val _columns = MutableStateFlow(4)
- val columns: StateFlow<Int> = _columns.asStateFlow()
-}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/data/repository/QSColumnsRepository.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/data/repository/QSColumnsRepository.kt
new file mode 100644
index 0000000..082f622
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/qs/panels/data/repository/QSColumnsRepository.kt
@@ -0,0 +1,58 @@
+/*
+ * 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.qs.panels.data.repository
+
+import android.content.res.Resources
+import com.android.systemui.common.ui.data.repository.ConfigurationRepository
+import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.dagger.qualifiers.Application
+import com.android.systemui.dagger.qualifiers.Main
+import com.android.systemui.res.R
+import com.android.systemui.shade.shared.flag.DualShade
+import com.android.systemui.util.kotlin.emitOnStart
+import javax.inject.Inject
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.flow.SharingStarted
+import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.flow.flowOf
+import kotlinx.coroutines.flow.mapLatest
+import kotlinx.coroutines.flow.stateIn
+
+@OptIn(ExperimentalCoroutinesApi::class)
+@SysUISingleton
+class QSColumnsRepository
+@Inject
+constructor(
+ @Application scope: CoroutineScope,
+ @Main private val resources: Resources,
+ configurationRepository: ConfigurationRepository,
+) {
+ val columns: StateFlow<Int> =
+ if (DualShade.isEnabled) {
+ flowOf(resources.getInteger(R.integer.quick_settings_dual_shade_num_columns))
+ } else {
+ configurationRepository.onConfigurationChange.emitOnStart().mapLatest {
+ resources.getInteger(R.integer.quick_settings_infinite_grid_num_columns)
+ }
+ }
+ .stateIn(
+ scope,
+ SharingStarted.WhileSubscribed(),
+ resources.getInteger(R.integer.quick_settings_infinite_grid_num_columns),
+ )
+}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/domain/interactor/FixedColumnsSizeInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/domain/interactor/QSColumnsInteractor.kt
similarity index 84%
rename from packages/SystemUI/src/com/android/systemui/qs/panels/domain/interactor/FixedColumnsSizeInteractor.kt
rename to packages/SystemUI/src/com/android/systemui/qs/panels/domain/interactor/QSColumnsInteractor.kt
index 9591002..9b45c56 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/panels/domain/interactor/FixedColumnsSizeInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/panels/domain/interactor/QSColumnsInteractor.kt
@@ -17,11 +17,11 @@
package com.android.systemui.qs.panels.domain.interactor
import com.android.systemui.dagger.SysUISingleton
-import com.android.systemui.qs.panels.data.repository.FixedColumnsRepository
+import com.android.systemui.qs.panels.data.repository.QSColumnsRepository
import javax.inject.Inject
import kotlinx.coroutines.flow.StateFlow
@SysUISingleton
-class FixedColumnsSizeInteractor @Inject constructor(repo: FixedColumnsRepository) {
+class QSColumnsInteractor @Inject constructor(repo: QSColumnsRepository) {
val columns: StateFlow<Int> = repo.columns
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/infinitegrid/InfiniteGridLayout.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/infinitegrid/InfiniteGridLayout.kt
index 3ba49ad..6920e49 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/infinitegrid/InfiniteGridLayout.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/infinitegrid/InfiniteGridLayout.kt
@@ -31,8 +31,8 @@
import com.android.systemui.qs.panels.ui.compose.PaginatableGridLayout
import com.android.systemui.qs.panels.ui.compose.rememberEditListState
import com.android.systemui.qs.panels.ui.viewmodel.EditTileViewModel
-import com.android.systemui.qs.panels.ui.viewmodel.FixedColumnsSizeViewModel
import com.android.systemui.qs.panels.ui.viewmodel.IconTilesViewModel
+import com.android.systemui.qs.panels.ui.viewmodel.QSColumnsViewModel
import com.android.systemui.qs.panels.ui.viewmodel.TileSquishinessViewModel
import com.android.systemui.qs.panels.ui.viewmodel.TileViewModel
import com.android.systemui.qs.pipeline.shared.TileSpec
@@ -45,7 +45,7 @@
@Inject
constructor(
private val iconTilesViewModel: IconTilesViewModel,
- private val gridSizeViewModel: FixedColumnsSizeViewModel,
+ private val gridSizeViewModel: QSColumnsViewModel,
private val squishinessViewModel: TileSquishinessViewModel,
) : PaginatableGridLayout {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/PaginatedGridViewModel.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/PaginatedGridViewModel.kt
index d4f8298..78212b2 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/PaginatedGridViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/PaginatedGridViewModel.kt
@@ -29,13 +29,13 @@
@Inject
constructor(
iconTilesViewModel: IconTilesViewModel,
- gridSizeViewModel: FixedColumnsSizeViewModel,
+ gridSizeViewModel: QSColumnsViewModel,
iconLabelVisibilityViewModel: IconLabelVisibilityViewModel,
paginatedGridInteractor: PaginatedGridInteractor,
@Application applicationScope: CoroutineScope,
) :
IconTilesViewModel by iconTilesViewModel,
- FixedColumnsSizeViewModel by gridSizeViewModel,
+ QSColumnsViewModel by gridSizeViewModel,
IconLabelVisibilityViewModel by iconLabelVisibilityViewModel {
val rows =
paginatedGridInteractor.rows.stateIn(
diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/PartitionedGridViewModel.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/PartitionedGridViewModel.kt
deleted file mode 100644
index 2049edb..0000000
--- a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/PartitionedGridViewModel.kt
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.qs.panels.ui.viewmodel
-
-import com.android.systemui.dagger.SysUISingleton
-import javax.inject.Inject
-
-@SysUISingleton
-class PartitionedGridViewModel
-@Inject
-constructor(
- iconTilesViewModel: IconTilesViewModel,
- gridSizeViewModel: FixedColumnsSizeViewModel,
- iconLabelVisibilityViewModel: IconLabelVisibilityViewModel,
-) :
- IconTilesViewModel by iconTilesViewModel,
- FixedColumnsSizeViewModel by gridSizeViewModel,
- IconLabelVisibilityViewModel by iconLabelVisibilityViewModel
diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/FixedColumnsSizeViewModel.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/QSColumnsViewModel.kt
similarity index 78%
rename from packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/FixedColumnsSizeViewModel.kt
rename to packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/QSColumnsViewModel.kt
index 865c86b..0f1c77e 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/FixedColumnsSizeViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/QSColumnsViewModel.kt
@@ -17,16 +17,16 @@
package com.android.systemui.qs.panels.ui.viewmodel
import com.android.systemui.dagger.SysUISingleton
-import com.android.systemui.qs.panels.domain.interactor.FixedColumnsSizeInteractor
+import com.android.systemui.qs.panels.domain.interactor.QSColumnsInteractor
import javax.inject.Inject
import kotlinx.coroutines.flow.StateFlow
-interface FixedColumnsSizeViewModel {
+interface QSColumnsViewModel {
val columns: StateFlow<Int>
}
@SysUISingleton
-class FixedColumnsSizeViewModelImpl @Inject constructor(interactor: FixedColumnsSizeInteractor) :
- FixedColumnsSizeViewModel {
+class QSColumnsSizeViewModelImpl @Inject constructor(interactor: QSColumnsInteractor) :
+ QSColumnsViewModel {
override val columns: StateFlow<Int> = interactor.columns
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/QuickQuickSettingsViewModel.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/QuickQuickSettingsViewModel.kt
index 88e3019..72b586a 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/QuickQuickSettingsViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/QuickQuickSettingsViewModel.kt
@@ -40,14 +40,14 @@
@Inject
constructor(
tilesInteractor: CurrentTilesInteractor,
- fixedColumnsSizeViewModel: FixedColumnsSizeViewModel,
+ qsColumnsViewModel: QSColumnsViewModel,
quickQuickSettingsRowInteractor: QuickQuickSettingsRowInteractor,
val squishinessViewModel: TileSquishinessViewModel,
private val iconTilesViewModel: IconTilesViewModel,
@Application private val applicationScope: CoroutineScope,
) {
- val columns = fixedColumnsSizeViewModel.columns
+ val columns = qsColumnsViewModel.columns
private val rows =
quickQuickSettingsRowInteractor.rows.stateIn(
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java
index 73ad0e5..da04f6e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java
@@ -46,6 +46,7 @@
import com.android.internal.logging.UiEventLogger;
import com.android.keyguard.KeyguardClockSwitch;
import com.android.systemui.DejankUtils;
+import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.deviceentry.domain.interactor.DeviceUnlockedInteractor;
import com.android.systemui.deviceentry.shared.model.DeviceUnlockStatus;
@@ -123,6 +124,7 @@
private final Lazy<SceneContainerOcclusionInteractor> mSceneContainerOcclusionInteractorLazy;
private final Lazy<KeyguardClockInteractor> mKeyguardClockInteractorLazy;
private final Lazy<SceneBackInteractor> mSceneBackInteractorLazy;
+ private final Lazy<AlternateBouncerInteractor> mAlternateBouncerInteractorLazy;
private int mState;
private int mLastState;
private int mUpcomingState;
@@ -193,7 +195,8 @@
Lazy<SceneInteractor> sceneInteractorLazy,
Lazy<SceneContainerOcclusionInteractor> sceneContainerOcclusionInteractor,
Lazy<KeyguardClockInteractor> keyguardClockInteractorLazy,
- Lazy<SceneBackInteractor> sceneBackInteractorLazy) {
+ Lazy<SceneBackInteractor> sceneBackInteractorLazy,
+ Lazy<AlternateBouncerInteractor> alternateBouncerInteractorLazy) {
mUiEventLogger = uiEventLogger;
mInteractionJankMonitorLazy = interactionJankMonitorLazy;
mJavaAdapter = javaAdapter;
@@ -205,6 +208,7 @@
mSceneContainerOcclusionInteractorLazy = sceneContainerOcclusionInteractor;
mKeyguardClockInteractorLazy = keyguardClockInteractorLazy;
mSceneBackInteractorLazy = sceneBackInteractorLazy;
+ mAlternateBouncerInteractorLazy = alternateBouncerInteractorLazy;
for (int i = 0; i < HISTORY_SIZE; i++) {
mHistoricalRecords[i] = new HistoricalState();
}
@@ -233,6 +237,7 @@
mSceneInteractorLazy.get().getCurrentOverlays(),
mSceneBackInteractorLazy.get().getBackStack(),
mSceneContainerOcclusionInteractorLazy.get().getInvisibleDueToOcclusion(),
+ mAlternateBouncerInteractorLazy.get().isVisible(),
this::calculateStateFromSceneFramework),
this::onStatusBarStateChanged);
@@ -693,7 +698,8 @@
SceneKey currentScene,
Set<OverlayKey> currentOverlays,
SceneStack backStack,
- boolean isOccluded) {
+ boolean isOccluded,
+ boolean alternateBouncerIsVisible) {
SceneContainerFlag.isUnexpectedlyInLegacyMode();
final boolean onBouncer = currentScene.equals(Scenes.Bouncer);
@@ -714,7 +720,8 @@
final String inputLogString = "currentScene=" + currentScene.getTestTag()
+ " currentOverlays=" + currentOverlays + " backStack=" + backStack
- + " isUnlocked=" + isUnlocked + " isOccluded=" + isOccluded;
+ + " isUnlocked=" + isUnlocked + " isOccluded=" + isOccluded
+ + " alternateBouncerIsVisible=" + alternateBouncerIsVisible;
int newState;
@@ -722,6 +729,7 @@
// 1. deviceUnlockStatus.isUnlocked changes from false to true.
// 2. Lockscreen changes to Gone, either in currentScene or in backStack.
// 3. Bouncer is removed from currentScene or backStack, if it was present.
+ // 4. the alternate bouncer is hidden, if it was visible.
//
// From this function's perspective, though, deviceUnlockStatus, currentScene, and backStack
// each update separately, and the relative order of those updates is not well-defined. This
@@ -733,6 +741,7 @@
// 1. deviceUnlockStatus.isUnlocked is false.
// 2. currentScene is a keyguardish scene (Lockscreen, Bouncer, or Communal).
// 3. backStack contains a keyguardish scene (Lockscreen or Communal).
+ // 4. the alternate bouncer is visible.
final boolean onKeyguardish = onLockscreen || onBouncer || onCommunal;
final boolean overKeyguardish = overLockscreen || overCommunal;
@@ -741,7 +750,7 @@
// Occlusion is special; even though the device is still technically on the lockscreen,
// the UI behaves as if it is unlocked.
newState = StatusBarState.SHADE;
- } else if (onKeyguardish || overKeyguardish) {
+ } else if (onKeyguardish || overKeyguardish || alternateBouncerIsVisible) {
// We get here if we are on or over a keyguardish scene, even if isUnlocked is true; we
// want to return SHADE_LOCKED or KEYGUARD until we are also neither on nor over a
// keyguardish scene.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/ConnectivityModule.kt b/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/ConnectivityModule.kt
index dac0102..10090283 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/ConnectivityModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/ConnectivityModule.kt
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.connectivity
import android.os.UserManager
+import com.android.systemui.bluetooth.qsdialog.dagger.AudioSharingModule
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags.SIGNAL_CALLBACK_DEPRECATION
import com.android.systemui.qs.QsEventLogger
@@ -56,7 +57,7 @@
import dagger.multibindings.IntoMap
import dagger.multibindings.StringKey
-@Module
+@Module(includes = [AudioSharingModule::class])
interface ConnectivityModule {
/** Inject BluetoothTile into tileMap in QSModule */
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/SingleLineViewInflater.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/SingleLineViewInflater.kt
index d67947d..4e26ae8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/SingleLineViewInflater.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/SingleLineViewInflater.kt
@@ -90,7 +90,7 @@
notification = notification,
isGroupConversation = isGroupConversation,
builder = builder,
- systemUiContext = systemUiContext
+ systemUiContext = systemUiContext,
)
val conversationData =
@@ -98,7 +98,7 @@
// We don't show the sender's name for one-to-one conversation
conversationSenderName =
if (isGroupConversation) conversationTextData?.senderName else null,
- avatar = conversationAvatar
+ avatar = conversationAvatar,
)
return SingleLineViewModel(
@@ -111,7 +111,7 @@
@JvmStatic
fun inflateRedactedSingleLineViewModel(
context: Context,
- isConversation: Boolean = false
+ isConversation: Boolean = false,
): SingleLineViewModel {
val conversationData =
if (isConversation) {
@@ -122,7 +122,7 @@
com.android.systemui.res.R.drawable
.ic_redacted_notification_single_line_icon
)
- )
+ ),
)
} else {
null
@@ -134,7 +134,7 @@
context.getString(
com.android.systemui.res.R.string.redacted_notification_single_line_text
),
- conversationData
+ conversationData,
)
}
@@ -159,11 +159,13 @@
}
// load the sender's name to display
- val name = lastMessage.senderPerson?.name
+ // null senderPerson means the current user.
+ val name = lastMessage.senderPerson?.name ?: user.name
+
val senderName =
systemUiContext.resources.getString(
R.string.conversation_single_line_name_display,
- if (Flags.cleanUpSpansAndNewLines()) name?.toString() else name
+ if (Flags.cleanUpSpansAndNewLines()) name?.toString() else name,
)
// We need to find back-up values for those texts if they are needed and empty
@@ -333,7 +335,7 @@
sender.icon
?: builder.getDefaultAvatar(
name = sender.name,
- uniqueNames = uniqueNames
+ uniqueNames = uniqueNames,
)
lastKey = senderKey
} else {
@@ -341,7 +343,7 @@
sender.icon
?: builder.getDefaultAvatar(
name = sender.name,
- uniqueNames = uniqueNames
+ uniqueNames = uniqueNames,
)
break
}
@@ -424,7 +426,7 @@
private fun Notification.Builder.getDefaultAvatar(
name: CharSequence?,
- uniqueNames: PeopleHelper.NameToPrefixMap? = null
+ uniqueNames: PeopleHelper.NameToPrefixMap? = null,
): Icon {
val layoutColor = getSmallIconColor(/* isHeader= */ false)
if (!name.isNullOrEmpty()) {
@@ -432,7 +434,7 @@
return peopleHelper.createAvatarSymbol(
/* name = */ name,
/* symbol = */ symbol,
- /* layoutColor = */ layoutColor
+ /* layoutColor = */ layoutColor,
)
}
// If name is null, create default avatar with background color
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/data/repository/ConnectivityRepository.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/data/repository/ConnectivityRepository.kt
index f5cfc8c..e0bf00f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/data/repository/ConnectivityRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/data/repository/ConnectivityRepository.kt
@@ -26,6 +26,7 @@
import android.net.NetworkCapabilities.TRANSPORT_ETHERNET
import android.net.NetworkCapabilities.TRANSPORT_WIFI
import android.net.vcn.VcnTransportInfo
+import android.net.vcn.VcnUtils
import android.net.wifi.WifiInfo
import android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID
import androidx.annotation.ArrayRes
@@ -161,7 +162,9 @@
defaultNetworkCapabilities
.map { networkCapabilities ->
networkCapabilities?.run {
- val subId = (transportInfo as? VcnTransportInfo)?.subId
+ val subId =
+ VcnUtils.getSubIdFromVcnCaps(connectivityManager, networkCapabilities)
+
// Never return an INVALID_SUBSCRIPTION_ID (-1)
if (subId != INVALID_SUBSCRIPTION_ID) {
subId
@@ -245,9 +248,9 @@
* info.
*/
fun NetworkCapabilities.getMainOrUnderlyingWifiInfo(
- connectivityManager: ConnectivityManager,
+ connectivityManager: ConnectivityManager
): WifiInfo? {
- val mainWifiInfo = this.getMainWifiInfo()
+ val mainWifiInfo = this.getMainWifiInfo(connectivityManager)
if (mainWifiInfo != null) {
return mainWifiInfo
}
@@ -264,7 +267,9 @@
// eventually traced to a wifi or carrier merged connection. So, check those underlying
// networks for possible wifi information as well. See b/225902574.
return this.underlyingNetworks?.firstNotNullOfOrNull { underlyingNetwork ->
- connectivityManager.getNetworkCapabilities(underlyingNetwork)?.getMainWifiInfo()
+ connectivityManager
+ .getNetworkCapabilities(underlyingNetwork)
+ ?.getMainWifiInfo(connectivityManager)
}
}
@@ -272,7 +277,9 @@
* Checks the network capabilities for wifi info, but does *not* check the underlying
* networks. See [getMainOrUnderlyingWifiInfo].
*/
- private fun NetworkCapabilities.getMainWifiInfo(): WifiInfo? {
+ private fun NetworkCapabilities.getMainWifiInfo(
+ connectivityManager: ConnectivityManager
+ ): WifiInfo? {
// Wifi info can either come from a WIFI Transport, or from a CELLULAR transport for
// virtual networks like VCN.
val canHaveWifiInfo =
@@ -286,7 +293,7 @@
// [com.android.settingslib.Utils.tryGetWifiInfoForVcn]. It's copied instead of
// re-used because it makes the logic here clearer, and because the method will be
// removed once this pipeline is fully launched.
- is VcnTransportInfo -> currentTransportInfo.wifiInfo
+ is VcnTransportInfo -> VcnUtils.getWifiInfoFromVcnCaps(connectivityManager, this)
is WifiInfo -> currentTransportInfo
else -> null
}
diff --git a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/BackGestureTutorialScreen.kt b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/BackGestureTutorialScreen.kt
index 6879a34..d85cfcd 100644
--- a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/BackGestureTutorialScreen.kt
+++ b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/BackGestureTutorialScreen.kt
@@ -24,7 +24,7 @@
import com.android.systemui.inputdevice.tutorial.ui.composable.TutorialScreenConfig
import com.android.systemui.inputdevice.tutorial.ui.composable.rememberColorFilterProperty
import com.android.systemui.res.R
-import com.android.systemui.touchpad.tutorial.ui.gesture.BackGestureMonitor
+import com.android.systemui.touchpad.tutorial.ui.gesture.BackGestureRecognizer
@Composable
fun BackGestureTutorialScreen(onDoneButtonClicked: () -> Unit, onBack: () -> Unit) {
@@ -44,15 +44,15 @@
successResId = R.raw.trackpad_back_success,
),
)
- val gestureMonitorProvider =
- DistanceBasedGestureMonitorProvider(
- monitorFactory = { distanceThresholdPx, gestureStateCallback ->
- BackGestureMonitor(distanceThresholdPx).also {
+ val gestureRecognizerProvider =
+ DistanceBasedGestureRecognizerProvider(
+ recognizerFactory = { distanceThresholdPx, gestureStateCallback ->
+ BackGestureRecognizer(distanceThresholdPx).also {
it.addGestureStateCallback(gestureStateCallback)
}
}
)
- GestureTutorialScreen(screenConfig, gestureMonitorProvider, onDoneButtonClicked, onBack)
+ GestureTutorialScreen(screenConfig, gestureRecognizerProvider, onDoneButtonClicked, onBack)
}
@Composable
diff --git a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/GestureTutorialScreen.kt b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/GestureTutorialScreen.kt
index 72389cd..75c66f2 100644
--- a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/GestureTutorialScreen.kt
+++ b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/GestureTutorialScreen.kt
@@ -37,39 +37,39 @@
import com.android.systemui.inputdevice.tutorial.ui.composable.TutorialActionState
import com.android.systemui.inputdevice.tutorial.ui.composable.TutorialScreenConfig
import com.android.systemui.touchpad.tutorial.ui.gesture.EasterEggGestureMonitor
+import com.android.systemui.touchpad.tutorial.ui.gesture.GestureRecognizer
import com.android.systemui.touchpad.tutorial.ui.gesture.GestureState
import com.android.systemui.touchpad.tutorial.ui.gesture.GestureState.Finished
import com.android.systemui.touchpad.tutorial.ui.gesture.GestureState.InProgress
import com.android.systemui.touchpad.tutorial.ui.gesture.GestureState.NotStarted
import com.android.systemui.touchpad.tutorial.ui.gesture.TouchpadGestureHandler
-import com.android.systemui.touchpad.tutorial.ui.gesture.TouchpadGestureMonitor
-interface GestureMonitorProvider {
+interface GestureRecognizerProvider {
@Composable
- fun rememberGestureMonitor(
+ fun rememberGestureRecognizer(
resources: Resources,
gestureStateChangedCallback: (GestureState) -> Unit,
- ): TouchpadGestureMonitor
+ ): GestureRecognizer
}
typealias gestureStateCallback = (GestureState) -> Unit
-class DistanceBasedGestureMonitorProvider(
- val monitorFactory: (Int, gestureStateCallback) -> TouchpadGestureMonitor
-) : GestureMonitorProvider {
+class DistanceBasedGestureRecognizerProvider(
+ val recognizerFactory: (Int, gestureStateCallback) -> GestureRecognizer
+) : GestureRecognizerProvider {
@Composable
- override fun rememberGestureMonitor(
+ override fun rememberGestureRecognizer(
resources: Resources,
gestureStateChangedCallback: (GestureState) -> Unit,
- ): TouchpadGestureMonitor {
+ ): GestureRecognizer {
val distanceThresholdPx =
resources.getDimensionPixelSize(
com.android.internal.R.dimen.system_gestures_distance_threshold
)
return remember(distanceThresholdPx) {
- monitorFactory(distanceThresholdPx, gestureStateChangedCallback)
+ recognizerFactory(distanceThresholdPx, gestureStateChangedCallback)
}
}
}
@@ -77,7 +77,7 @@
fun GestureState.toTutorialActionState(): TutorialActionState {
return when (this) {
NotStarted -> TutorialActionState.NotStarted
- is InProgress -> TutorialActionState.InProgress()
+ is InProgress -> TutorialActionState.InProgress(progress)
Finished -> TutorialActionState.Finished
}
}
@@ -85,21 +85,21 @@
@Composable
fun GestureTutorialScreen(
screenConfig: TutorialScreenConfig,
- gestureMonitorProvider: GestureMonitorProvider,
+ gestureRecognizerProvider: GestureRecognizerProvider,
onDoneButtonClicked: () -> Unit,
onBack: () -> Unit,
) {
BackHandler(onBack = onBack)
var gestureState: GestureState by remember { mutableStateOf(NotStarted) }
var easterEggTriggered by remember { mutableStateOf(false) }
- val gestureMonitor =
- gestureMonitorProvider.rememberGestureMonitor(
+ val gestureRecognizer =
+ gestureRecognizerProvider.rememberGestureRecognizer(
resources = LocalContext.current.resources,
gestureStateChangedCallback = { gestureState = it },
)
val easterEggMonitor = EasterEggGestureMonitor { easterEggTriggered = true }
val gestureHandler =
- remember(gestureMonitor) { TouchpadGestureHandler(gestureMonitor, easterEggMonitor) }
+ remember(gestureRecognizer) { TouchpadGestureHandler(gestureRecognizer, easterEggMonitor) }
TouchpadGesturesHandlingBox(
gestureHandler,
gestureState,
diff --git a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/HomeGestureTutorialScreen.kt b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/HomeGestureTutorialScreen.kt
index a55fa44..69ec598 100644
--- a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/HomeGestureTutorialScreen.kt
+++ b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/HomeGestureTutorialScreen.kt
@@ -23,7 +23,7 @@
import com.android.systemui.inputdevice.tutorial.ui.composable.TutorialScreenConfig
import com.android.systemui.inputdevice.tutorial.ui.composable.rememberColorFilterProperty
import com.android.systemui.res.R
-import com.android.systemui.touchpad.tutorial.ui.gesture.HomeGestureMonitor
+import com.android.systemui.touchpad.tutorial.ui.gesture.HomeGestureRecognizer
@Composable
fun HomeGestureTutorialScreen(onDoneButtonClicked: () -> Unit, onBack: () -> Unit) {
@@ -43,15 +43,15 @@
successResId = R.raw.trackpad_home_success,
),
)
- val gestureMonitorProvider =
- DistanceBasedGestureMonitorProvider(
- monitorFactory = { distanceThresholdPx, gestureStateCallback ->
- HomeGestureMonitor(distanceThresholdPx).also {
+ val gestureRecognizerProvider =
+ DistanceBasedGestureRecognizerProvider(
+ recognizerFactory = { distanceThresholdPx, gestureStateCallback ->
+ HomeGestureRecognizer(distanceThresholdPx).also {
it.addGestureStateCallback(gestureStateCallback)
}
}
)
- GestureTutorialScreen(screenConfig, gestureMonitorProvider, onDoneButtonClicked, onBack)
+ GestureTutorialScreen(screenConfig, gestureRecognizerProvider, onDoneButtonClicked, onBack)
}
@Composable
diff --git a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/RecentAppsGestureTutorialScreen.kt b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/RecentAppsGestureTutorialScreen.kt
index 6ee15aa..3097a18 100644
--- a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/RecentAppsGestureTutorialScreen.kt
+++ b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/RecentAppsGestureTutorialScreen.kt
@@ -24,9 +24,9 @@
import com.android.systemui.inputdevice.tutorial.ui.composable.TutorialScreenConfig
import com.android.systemui.inputdevice.tutorial.ui.composable.rememberColorFilterProperty
import com.android.systemui.res.R
+import com.android.systemui.touchpad.tutorial.ui.gesture.GestureRecognizer
import com.android.systemui.touchpad.tutorial.ui.gesture.GestureState
-import com.android.systemui.touchpad.tutorial.ui.gesture.RecentAppsGestureMonitor
-import com.android.systemui.touchpad.tutorial.ui.gesture.TouchpadGestureMonitor
+import com.android.systemui.touchpad.tutorial.ui.gesture.RecentAppsGestureRecognizer
@Composable
fun RecentAppsGestureTutorialScreen(onDoneButtonClicked: () -> Unit, onBack: () -> Unit) {
@@ -46,13 +46,13 @@
successResId = R.raw.trackpad_recent_apps_success,
),
)
- val gestureMonitorProvider =
- object : GestureMonitorProvider {
+ val gestureRecognizerProvider =
+ object : GestureRecognizerProvider {
@Composable
- override fun rememberGestureMonitor(
+ override fun rememberGestureRecognizer(
resources: Resources,
gestureStateChangedCallback: (GestureState) -> Unit,
- ): TouchpadGestureMonitor {
+ ): GestureRecognizer {
val distanceThresholdPx =
resources.getDimensionPixelSize(
com.android.internal.R.dimen.system_gestures_distance_threshold
@@ -60,13 +60,12 @@
val velocityThresholdPxPerMs =
resources.getDimension(R.dimen.touchpad_recent_apps_gesture_velocity_threshold)
return remember(distanceThresholdPx, velocityThresholdPxPerMs) {
- RecentAppsGestureMonitor(distanceThresholdPx, velocityThresholdPxPerMs).also {
- it.addGestureStateCallback(gestureStateChangedCallback)
- }
+ RecentAppsGestureRecognizer(distanceThresholdPx, velocityThresholdPxPerMs)
+ .also { it.addGestureStateCallback(gestureStateChangedCallback) }
}
}
}
- GestureTutorialScreen(screenConfig, gestureMonitorProvider, onDoneButtonClicked, onBack)
+ GestureTutorialScreen(screenConfig, gestureRecognizerProvider, onDoneButtonClicked, onBack)
}
@Composable
diff --git a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/BackGestureMonitor.kt b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/BackGestureRecognizer.kt
similarity index 87%
rename from packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/BackGestureMonitor.kt
rename to packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/BackGestureRecognizer.kt
index 490f04d..56e97a3 100644
--- a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/BackGestureMonitor.kt
+++ b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/BackGestureRecognizer.kt
@@ -19,8 +19,8 @@
import android.view.MotionEvent
import kotlin.math.abs
-/** Monitors for touchpad back gesture, that is three fingers swiping left or right */
-class BackGestureMonitor(private val gestureDistanceThresholdPx: Int) : TouchpadGestureMonitor {
+/** Recognizes touchpad back gesture, that is three fingers swiping left or right */
+class BackGestureRecognizer(private val gestureDistanceThresholdPx: Int) : GestureRecognizer {
private val distanceTracker = DistanceTracker()
private var gestureStateChangedCallback: (GestureState) -> Unit = {}
diff --git a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/TouchpadGestureMonitor.kt b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/GestureRecognizer.kt
similarity index 89%
rename from packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/TouchpadGestureMonitor.kt
rename to packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/GestureRecognizer.kt
index 9216821..d146268 100644
--- a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/TouchpadGestureMonitor.kt
+++ b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/GestureRecognizer.kt
@@ -19,8 +19,8 @@
import android.view.MotionEvent
import java.util.function.Consumer
-/** Monitor for touchpad gestures that can notify callback when [GestureState] changes. */
-interface TouchpadGestureMonitor : Consumer<MotionEvent> {
+/** Based on passed [MotionEvent]s recognizes different states of gesture and notifies callback. */
+interface GestureRecognizer : Consumer<MotionEvent> {
fun addGestureStateCallback(callback: (GestureState) -> Unit)
}
diff --git a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/HomeGestureMonitor.kt b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/HomeGestureRecognizer.kt
similarity index 88%
rename from packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/HomeGestureMonitor.kt
rename to packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/HomeGestureRecognizer.kt
index 83d4f56..3db9d7c 100644
--- a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/HomeGestureMonitor.kt
+++ b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/HomeGestureRecognizer.kt
@@ -18,8 +18,8 @@
import android.view.MotionEvent
-/** Monitors for touchpad home gesture, that is three fingers swiping up */
-class HomeGestureMonitor(private val gestureDistanceThresholdPx: Int) : TouchpadGestureMonitor {
+/** Recognizes touchpad home gesture, that is three fingers swiping up */
+class HomeGestureRecognizer(private val gestureDistanceThresholdPx: Int) : GestureRecognizer {
private val distanceTracker = DistanceTracker()
private var gestureStateChangedCallback: (GestureState) -> Unit = {}
diff --git a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/RecentAppsGestureMonitor.kt b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/RecentAppsGestureRecognizer.kt
similarity index 83%
rename from packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/RecentAppsGestureMonitor.kt
rename to packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/RecentAppsGestureRecognizer.kt
index 1731bb8..a194ad6 100644
--- a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/RecentAppsGestureMonitor.kt
+++ b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/RecentAppsGestureRecognizer.kt
@@ -20,16 +20,16 @@
import kotlin.math.abs
/**
- * Monitors recent apps gesture completion. That is - using three fingers on touchpad - swipe up
- * over some distance threshold and then slow down gesture before fingers are lifted. Implementation
- * is based on [com.android.quickstep.util.TriggerSwipeUpTouchTracker]
+ * Recognizes apps gesture completion. That is - using three fingers on touchpad - swipe up over
+ * some distance threshold and then slow down gesture before fingers are lifted. Implementation is
+ * based on [com.android.quickstep.util.TriggerSwipeUpTouchTracker]
*/
-class RecentAppsGestureMonitor(
+class RecentAppsGestureRecognizer(
private val gestureDistanceThresholdPx: Int,
private val velocityThresholdPxPerMs: Float,
private val distanceTracker: DistanceTracker = DistanceTracker(),
private val velocityTracker: VerticalVelocityTracker = VerticalVelocityTracker(),
-) : TouchpadGestureMonitor {
+) : GestureRecognizer {
private var gestureStateChangedCallback: (GestureState) -> Unit = {}
diff --git a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/TouchpadGestureHandler.kt b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/TouchpadGestureHandler.kt
index 4b82ba1..21e2917 100644
--- a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/TouchpadGestureHandler.kt
+++ b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/TouchpadGestureHandler.kt
@@ -25,7 +25,7 @@
* motion events passed to [onMotionEvent] and will filter touchpad events accordingly
*/
class TouchpadGestureHandler(
- private val gestureMonitor: Consumer<MotionEvent>,
+ private val gestureRecognizer: Consumer<MotionEvent>,
private val easterEggGestureMonitor: EasterEggGestureMonitor,
) {
@@ -41,7 +41,7 @@
if (isTwoFingerSwipe(event)) {
easterEggGestureMonitor.processTouchpadEvent(event)
} else {
- gestureMonitor.accept(event)
+ gestureRecognizer.accept(event)
}
true
} else {
diff --git a/packages/SystemUI/tests/goldens/backgroundAnimationWithoutFade_whenLaunching.json b/packages/SystemUI/tests/goldens/backgroundAnimationWithoutFade_whenLaunching.json
index 60bff17..7f62357 100644
--- a/packages/SystemUI/tests/goldens/backgroundAnimationWithoutFade_whenLaunching.json
+++ b/packages/SystemUI/tests/goldens/backgroundAnimationWithoutFade_whenLaunching.json
@@ -1,25 +1,30 @@
{
"frame_ids": [
- "before",
0,
- 26,
- 52,
- 78,
- 105,
- 131,
- 157,
- 184,
- 210,
- 236,
- 263,
- 289,
- 315,
- 342,
- 368,
- 394,
- 421,
- 447,
- 473,
+ 20,
+ 40,
+ 60,
+ 80,
+ 100,
+ 120,
+ 140,
+ 160,
+ 180,
+ 200,
+ 220,
+ 240,
+ 260,
+ 280,
+ 300,
+ 320,
+ 340,
+ 360,
+ 380,
+ 400,
+ 420,
+ 440,
+ 460,
+ 480,
500
],
"features": [
@@ -28,70 +33,82 @@
"type": "rect",
"data_points": [
{
- "left": 0,
- "top": 0,
- "right": 0,
- "bottom": 0
- },
- {
"left": 100,
"top": 300,
"right": 200,
"bottom": 400
},
{
- "left": 98,
- "top": 293,
- "right": 203,
- "bottom": 407
+ "left": 99,
+ "top": 296,
+ "right": 202,
+ "bottom": 404
},
{
- "left": 91,
- "top": 269,
- "right": 213,
- "bottom": 430
+ "left": 95,
+ "top": 283,
+ "right": 207,
+ "bottom": 417
},
{
- "left": 71,
- "top": 206,
- "right": 240,
- "bottom": 491
+ "left": 86,
+ "top": 256,
+ "right": 219,
+ "bottom": 443
},
{
- "left": 34,
- "top": 98,
- "right": 283,
- "bottom": 595
+ "left": 68,
+ "top": 198,
+ "right": 243,
+ "bottom": 499
},
{
- "left": 22,
- "top": 63,
- "right": 296,
- "bottom": 629
+ "left": 39,
+ "top": 110,
+ "right": 278,
+ "bottom": 584
+ },
+ {
+ "left": 26,
+ "top": 74,
+ "right": 292,
+ "bottom": 618
+ },
+ {
+ "left": 19,
+ "top": 55,
+ "right": 299,
+ "bottom": 637
},
{
"left": 15,
- "top": 44,
- "right": 303,
- "bottom": 648
+ "top": 42,
+ "right": 304,
+ "bottom": 649
},
{
- "left": 11,
- "top": 32,
- "right": 308,
- "bottom": 659
+ "left": 12,
+ "top": 33,
+ "right": 307,
+ "bottom": 658
},
{
- "left": 8,
- "top": 23,
- "right": 311,
- "bottom": 667
+ "left": 9,
+ "top": 27,
+ "right": 310,
+ "bottom": 664
+ },
+ {
+ "left": 7,
+ "top": 21,
+ "right": 312,
+ "bottom": 669
},
{
"left": 6,
- "top": 18,
- "right": 313,
- "bottom": 673
+ "top": 17,
+ "right": 314,
+ "bottom": 674
},
{
"left": 5,
@@ -100,16 +117,22 @@
"bottom": 677
},
{
- "left": 3,
- "top": 9,
+ "left": 4,
+ "top": 10,
"right": 316,
- "bottom": 681
+ "bottom": 680
+ },
+ {
+ "left": 3,
+ "top": 8,
+ "right": 317,
+ "bottom": 682
},
{
"left": 2,
- "top": 7,
- "right": 317,
- "bottom": 683
+ "top": 6,
+ "right": 318,
+ "bottom": 684
},
{
"left": 2,
@@ -119,7 +142,7 @@
},
{
"left": 1,
- "top": 3,
+ "top": 4,
"right": 319,
"bottom": 687
},
@@ -130,6 +153,18 @@
"bottom": 688
},
{
+ "left": 1,
+ "top": 2,
+ "right": 319,
+ "bottom": 688
+ },
+ {
+ "left": 0,
+ "top": 1,
+ "right": 320,
+ "bottom": 689
+ },
+ {
"left": 0,
"top": 1,
"right": 320,
@@ -159,7 +194,6 @@
"name": "corner_radii",
"type": "cornerRadii",
"data_points": [
- null,
{
"top_left_x": 10,
"top_left_y": 10,
@@ -171,184 +205,244 @@
"bottom_left_y": 20
},
{
- "top_left_x": 9.762664,
- "top_left_y": 9.762664,
- "top_right_x": 9.762664,
- "top_right_y": 9.762664,
- "bottom_right_x": 19.525328,
- "bottom_right_y": 19.525328,
- "bottom_left_x": 19.525328,
- "bottom_left_y": 19.525328
+ "top_left_x": 9.865689,
+ "top_left_y": 9.865689,
+ "top_right_x": 9.865689,
+ "top_right_y": 9.865689,
+ "bottom_right_x": 19.731379,
+ "bottom_right_y": 19.731379,
+ "bottom_left_x": 19.731379,
+ "bottom_left_y": 19.731379
},
{
- "top_left_x": 8.969244,
- "top_left_y": 8.969244,
- "top_right_x": 8.969244,
- "top_right_y": 8.969244,
- "bottom_right_x": 17.938488,
- "bottom_right_y": 17.938488,
- "bottom_left_x": 17.938488,
- "bottom_left_y": 17.938488
+ "top_left_x": 9.419104,
+ "top_left_y": 9.419104,
+ "top_right_x": 9.419104,
+ "top_right_y": 9.419104,
+ "bottom_right_x": 18.838207,
+ "bottom_right_y": 18.838207,
+ "bottom_left_x": 18.838207,
+ "bottom_left_y": 18.838207
},
{
- "top_left_x": 6.8709626,
- "top_left_y": 6.8709626,
- "top_right_x": 6.8709626,
- "top_right_y": 6.8709626,
- "bottom_right_x": 13.741925,
- "bottom_right_y": 13.741925,
- "bottom_left_x": 13.741925,
- "bottom_left_y": 13.741925
+ "top_left_x": 8.533693,
+ "top_left_y": 8.533693,
+ "top_right_x": 8.533693,
+ "top_right_y": 8.533693,
+ "bottom_right_x": 17.067387,
+ "bottom_right_y": 17.067387,
+ "bottom_left_x": 17.067387,
+ "bottom_left_y": 17.067387
},
{
- "top_left_x": 3.260561,
- "top_left_y": 3.260561,
- "top_right_x": 3.260561,
- "top_right_y": 3.260561,
- "bottom_right_x": 6.521122,
- "bottom_right_y": 6.521122,
- "bottom_left_x": 6.521122,
- "bottom_left_y": 6.521122
+ "top_left_x": 6.5919456,
+ "top_left_y": 6.5919456,
+ "top_right_x": 6.5919456,
+ "top_right_y": 6.5919456,
+ "bottom_right_x": 13.183891,
+ "bottom_right_y": 13.183891,
+ "bottom_left_x": 13.183891,
+ "bottom_left_y": 13.183891
},
{
- "top_left_x": 2.0915751,
- "top_left_y": 2.0915751,
- "top_right_x": 2.0915751,
- "top_right_y": 2.0915751,
- "bottom_right_x": 4.1831503,
- "bottom_right_y": 4.1831503,
- "bottom_left_x": 4.1831503,
- "bottom_left_y": 4.1831503
+ "top_left_x": 3.6674318,
+ "top_left_y": 3.6674318,
+ "top_right_x": 3.6674318,
+ "top_right_y": 3.6674318,
+ "bottom_right_x": 7.3348637,
+ "bottom_right_y": 7.3348637,
+ "bottom_left_x": 7.3348637,
+ "bottom_left_y": 7.3348637
},
{
- "top_left_x": 1.4640827,
- "top_left_y": 1.4640827,
- "top_right_x": 1.4640827,
- "top_right_y": 1.4640827,
- "bottom_right_x": 2.9281654,
- "bottom_right_y": 2.9281654,
- "bottom_left_x": 2.9281654,
- "bottom_left_y": 2.9281654
+ "top_left_x": 2.4832253,
+ "top_left_y": 2.4832253,
+ "top_right_x": 2.4832253,
+ "top_right_y": 2.4832253,
+ "bottom_right_x": 4.9664507,
+ "bottom_right_y": 4.9664507,
+ "bottom_left_x": 4.9664507,
+ "bottom_left_y": 4.9664507
},
{
- "top_left_x": 1.057313,
- "top_left_y": 1.057313,
- "top_right_x": 1.057313,
- "top_right_y": 1.057313,
- "bottom_right_x": 2.114626,
- "bottom_right_y": 2.114626,
- "bottom_left_x": 2.114626,
- "bottom_left_y": 2.114626
+ "top_left_x": 1.8252907,
+ "top_left_y": 1.8252907,
+ "top_right_x": 1.8252907,
+ "top_right_y": 1.8252907,
+ "bottom_right_x": 3.6505814,
+ "bottom_right_y": 3.6505814,
+ "bottom_left_x": 3.6505814,
+ "bottom_left_y": 3.6505814
},
{
- "top_left_x": 0.7824335,
- "top_left_y": 0.7824335,
- "top_right_x": 0.7824335,
- "top_right_y": 0.7824335,
- "bottom_right_x": 1.564867,
- "bottom_right_y": 1.564867,
- "bottom_left_x": 1.564867,
- "bottom_left_y": 1.564867
+ "top_left_x": 1.4077549,
+ "top_left_y": 1.4077549,
+ "top_right_x": 1.4077549,
+ "top_right_y": 1.4077549,
+ "bottom_right_x": 2.8155098,
+ "bottom_right_y": 2.8155098,
+ "bottom_left_x": 2.8155098,
+ "bottom_left_y": 2.8155098
},
{
- "top_left_x": 0.5863056,
- "top_left_y": 0.5863056,
- "top_right_x": 0.5863056,
- "top_right_y": 0.5863056,
- "bottom_right_x": 1.1726112,
- "bottom_right_y": 1.1726112,
- "bottom_left_x": 1.1726112,
- "bottom_left_y": 1.1726112
+ "top_left_x": 1.1067667,
+ "top_left_y": 1.1067667,
+ "top_right_x": 1.1067667,
+ "top_right_y": 1.1067667,
+ "bottom_right_x": 2.2135334,
+ "bottom_right_y": 2.2135334,
+ "bottom_left_x": 2.2135334,
+ "bottom_left_y": 2.2135334
},
{
- "top_left_x": 0.4332962,
- "top_left_y": 0.4332962,
- "top_right_x": 0.4332962,
- "top_right_y": 0.4332962,
- "bottom_right_x": 0.8665924,
- "bottom_right_y": 0.8665924,
- "bottom_left_x": 0.8665924,
- "bottom_left_y": 0.8665924
+ "top_left_x": 0.88593864,
+ "top_left_y": 0.88593864,
+ "top_right_x": 0.88593864,
+ "top_right_y": 0.88593864,
+ "bottom_right_x": 1.7718773,
+ "bottom_right_y": 1.7718773,
+ "bottom_left_x": 1.7718773,
+ "bottom_left_y": 1.7718773
},
{
- "top_left_x": 0.3145876,
- "top_left_y": 0.3145876,
- "top_right_x": 0.3145876,
- "top_right_y": 0.3145876,
- "bottom_right_x": 0.6291752,
- "bottom_right_y": 0.6291752,
- "bottom_left_x": 0.6291752,
- "bottom_left_y": 0.6291752
+ "top_left_x": 0.7069988,
+ "top_left_y": 0.7069988,
+ "top_right_x": 0.7069988,
+ "top_right_y": 0.7069988,
+ "bottom_right_x": 1.4139977,
+ "bottom_right_y": 1.4139977,
+ "bottom_left_x": 1.4139977,
+ "bottom_left_y": 1.4139977
},
{
- "top_left_x": 0.22506618,
- "top_left_y": 0.22506618,
- "top_right_x": 0.22506618,
- "top_right_y": 0.22506618,
- "bottom_right_x": 0.45013237,
- "bottom_right_y": 0.45013237,
- "bottom_left_x": 0.45013237,
- "bottom_left_y": 0.45013237
+ "top_left_x": 0.55613136,
+ "top_left_y": 0.55613136,
+ "top_right_x": 0.55613136,
+ "top_right_y": 0.55613136,
+ "bottom_right_x": 1.1122627,
+ "bottom_right_y": 1.1122627,
+ "bottom_left_x": 1.1122627,
+ "bottom_left_y": 1.1122627
},
{
- "top_left_x": 0.15591621,
- "top_left_y": 0.15591621,
- "top_right_x": 0.15591621,
- "top_right_y": 0.15591621,
- "bottom_right_x": 0.31183243,
- "bottom_right_y": 0.31183243,
- "bottom_left_x": 0.31183243,
- "bottom_left_y": 0.31183243
+ "top_left_x": 0.44889355,
+ "top_left_y": 0.44889355,
+ "top_right_x": 0.44889355,
+ "top_right_y": 0.44889355,
+ "bottom_right_x": 0.8977871,
+ "bottom_right_y": 0.8977871,
+ "bottom_left_x": 0.8977871,
+ "bottom_left_y": 0.8977871
},
{
- "top_left_x": 0.100948334,
- "top_left_y": 0.100948334,
- "top_right_x": 0.100948334,
- "top_right_y": 0.100948334,
- "bottom_right_x": 0.20189667,
- "bottom_right_y": 0.20189667,
- "bottom_left_x": 0.20189667,
- "bottom_left_y": 0.20189667
+ "top_left_x": 0.34557533,
+ "top_left_y": 0.34557533,
+ "top_right_x": 0.34557533,
+ "top_right_y": 0.34557533,
+ "bottom_right_x": 0.69115067,
+ "bottom_right_y": 0.69115067,
+ "bottom_left_x": 0.69115067,
+ "bottom_left_y": 0.69115067
},
{
- "top_left_x": 0.06496239,
- "top_left_y": 0.06496239,
- "top_right_x": 0.06496239,
- "top_right_y": 0.06496239,
- "bottom_right_x": 0.12992477,
- "bottom_right_y": 0.12992477,
- "bottom_left_x": 0.12992477,
- "bottom_left_y": 0.12992477
+ "top_left_x": 0.27671337,
+ "top_left_y": 0.27671337,
+ "top_right_x": 0.27671337,
+ "top_right_y": 0.27671337,
+ "bottom_right_x": 0.55342674,
+ "bottom_right_y": 0.55342674,
+ "bottom_left_x": 0.55342674,
+ "bottom_left_y": 0.55342674
},
{
- "top_left_x": 0.03526497,
- "top_left_y": 0.03526497,
- "top_right_x": 0.03526497,
- "top_right_y": 0.03526497,
- "bottom_right_x": 0.07052994,
- "bottom_right_y": 0.07052994,
- "bottom_left_x": 0.07052994,
- "bottom_left_y": 0.07052994
+ "top_left_x": 0.20785141,
+ "top_left_y": 0.20785141,
+ "top_right_x": 0.20785141,
+ "top_right_y": 0.20785141,
+ "bottom_right_x": 0.41570282,
+ "bottom_right_y": 0.41570282,
+ "bottom_left_x": 0.41570282,
+ "bottom_left_y": 0.41570282
},
{
- "top_left_x": 0.014661789,
- "top_left_y": 0.014661789,
- "top_right_x": 0.014661789,
- "top_right_y": 0.014661789,
- "bottom_right_x": 0.029323578,
- "bottom_right_y": 0.029323578,
- "bottom_left_x": 0.029323578,
- "bottom_left_y": 0.029323578
+ "top_left_x": 0.1601448,
+ "top_left_y": 0.1601448,
+ "top_right_x": 0.1601448,
+ "top_right_y": 0.1601448,
+ "bottom_right_x": 0.3202896,
+ "bottom_right_y": 0.3202896,
+ "bottom_left_x": 0.3202896,
+ "bottom_left_y": 0.3202896
},
{
- "top_left_x": 0.0041856766,
- "top_left_y": 0.0041856766,
- "top_right_x": 0.0041856766,
- "top_right_y": 0.0041856766,
- "bottom_right_x": 0.008371353,
- "bottom_right_y": 0.008371353,
- "bottom_left_x": 0.008371353,
- "bottom_left_y": 0.008371353
+ "top_left_x": 0.117860794,
+ "top_left_y": 0.117860794,
+ "top_right_x": 0.117860794,
+ "top_right_y": 0.117860794,
+ "bottom_right_x": 0.23572159,
+ "bottom_right_y": 0.23572159,
+ "bottom_left_x": 0.23572159,
+ "bottom_left_y": 0.23572159
+ },
+ {
+ "top_left_x": 0.08036041,
+ "top_left_y": 0.08036041,
+ "top_right_x": 0.08036041,
+ "top_right_y": 0.08036041,
+ "bottom_right_x": 0.16072083,
+ "bottom_right_y": 0.16072083,
+ "bottom_left_x": 0.16072083,
+ "bottom_left_y": 0.16072083
+ },
+ {
+ "top_left_x": 0.05836296,
+ "top_left_y": 0.05836296,
+ "top_right_x": 0.05836296,
+ "top_right_y": 0.05836296,
+ "bottom_right_x": 0.11672592,
+ "bottom_right_y": 0.11672592,
+ "bottom_left_x": 0.11672592,
+ "bottom_left_y": 0.11672592
+ },
+ {
+ "top_left_x": 0.03636551,
+ "top_left_y": 0.03636551,
+ "top_right_x": 0.03636551,
+ "top_right_y": 0.03636551,
+ "bottom_right_x": 0.07273102,
+ "bottom_right_y": 0.07273102,
+ "bottom_left_x": 0.07273102,
+ "bottom_left_y": 0.07273102
+ },
+ {
+ "top_left_x": 0.018137932,
+ "top_left_y": 0.018137932,
+ "top_right_x": 0.018137932,
+ "top_right_y": 0.018137932,
+ "bottom_right_x": 0.036275864,
+ "bottom_right_y": 0.036275864,
+ "bottom_left_x": 0.036275864,
+ "bottom_left_y": 0.036275864
+ },
+ {
+ "top_left_x": 0.0082063675,
+ "top_left_y": 0.0082063675,
+ "top_right_x": 0.0082063675,
+ "top_right_y": 0.0082063675,
+ "bottom_right_x": 0.016412735,
+ "bottom_right_y": 0.016412735,
+ "bottom_left_x": 0.016412735,
+ "bottom_left_y": 0.016412735
+ },
+ {
+ "top_left_x": 0.0031013489,
+ "top_left_y": 0.0031013489,
+ "top_right_x": 0.0031013489,
+ "top_right_y": 0.0031013489,
+ "bottom_right_x": 0.0062026978,
+ "bottom_right_y": 0.0062026978,
+ "bottom_left_x": 0.0062026978,
+ "bottom_left_y": 0.0062026978
},
{
"top_left_x": 0,
@@ -367,12 +461,17 @@
"type": "int",
"data_points": [
0,
- 0,
- 115,
- 178,
- 217,
- 241,
- 253,
+ 96,
+ 153,
+ 192,
+ 220,
+ 238,
+ 249,
+ 254,
+ 255,
+ 255,
+ 255,
+ 255,
255,
255,
255,
diff --git a/packages/SystemUI/tests/goldens/backgroundAnimationWithoutFade_whenLaunching_withSpring.json b/packages/SystemUI/tests/goldens/backgroundAnimationWithoutFade_whenLaunching_withSpring.json
new file mode 100644
index 0000000..18eedd4
--- /dev/null
+++ b/packages/SystemUI/tests/goldens/backgroundAnimationWithoutFade_whenLaunching_withSpring.json
@@ -0,0 +1,375 @@
+{
+ "frame_ids": [
+ 0,
+ 16,
+ 32,
+ 48,
+ 64,
+ 80,
+ 96,
+ 112,
+ 128,
+ 144,
+ 160,
+ 176,
+ 192,
+ 208,
+ 224,
+ 240,
+ 256,
+ 272,
+ 288,
+ 304
+ ],
+ "features": [
+ {
+ "name": "bounds",
+ "type": "rect",
+ "data_points": [
+ {
+ "left": 0,
+ "top": 0,
+ "right": 0,
+ "bottom": 0
+ },
+ {
+ "left": 94,
+ "top": 284,
+ "right": 206,
+ "bottom": 414
+ },
+ {
+ "left": 83,
+ "top": 251,
+ "right": 219,
+ "bottom": 447
+ },
+ {
+ "left": 70,
+ "top": 212,
+ "right": 234,
+ "bottom": 485
+ },
+ {
+ "left": 57,
+ "top": 173,
+ "right": 250,
+ "bottom": 522
+ },
+ {
+ "left": 46,
+ "top": 139,
+ "right": 264,
+ "bottom": 555
+ },
+ {
+ "left": 36,
+ "top": 109,
+ "right": 276,
+ "bottom": 584
+ },
+ {
+ "left": 28,
+ "top": 84,
+ "right": 285,
+ "bottom": 608
+ },
+ {
+ "left": 21,
+ "top": 65,
+ "right": 293,
+ "bottom": 627
+ },
+ {
+ "left": 16,
+ "top": 49,
+ "right": 300,
+ "bottom": 642
+ },
+ {
+ "left": 12,
+ "top": 36,
+ "right": 305,
+ "bottom": 653
+ },
+ {
+ "left": 9,
+ "top": 27,
+ "right": 308,
+ "bottom": 662
+ },
+ {
+ "left": 7,
+ "top": 20,
+ "right": 312,
+ "bottom": 669
+ },
+ {
+ "left": 5,
+ "top": 14,
+ "right": 314,
+ "bottom": 675
+ },
+ {
+ "left": 4,
+ "top": 11,
+ "right": 315,
+ "bottom": 678
+ },
+ {
+ "left": 3,
+ "top": 8,
+ "right": 316,
+ "bottom": 681
+ },
+ {
+ "left": 2,
+ "top": 5,
+ "right": 317,
+ "bottom": 684
+ },
+ {
+ "left": 1,
+ "top": 4,
+ "right": 318,
+ "bottom": 685
+ },
+ {
+ "left": 1,
+ "top": 3,
+ "right": 318,
+ "bottom": 686
+ },
+ {
+ "left": 0,
+ "top": 2,
+ "right": 319,
+ "bottom": 687
+ }
+ ]
+ },
+ {
+ "name": "corner_radii",
+ "type": "cornerRadii",
+ "data_points": [
+ null,
+ {
+ "top_left_x": 9.492916,
+ "top_left_y": 9.492916,
+ "top_right_x": 9.492916,
+ "top_right_y": 9.492916,
+ "bottom_right_x": 18.985832,
+ "bottom_right_y": 18.985832,
+ "bottom_left_x": 18.985832,
+ "bottom_left_y": 18.985832
+ },
+ {
+ "top_left_x": 8.381761,
+ "top_left_y": 8.381761,
+ "top_right_x": 8.381761,
+ "top_right_y": 8.381761,
+ "bottom_right_x": 16.763521,
+ "bottom_right_y": 16.763521,
+ "bottom_left_x": 16.763521,
+ "bottom_left_y": 16.763521
+ },
+ {
+ "top_left_x": 7.07397,
+ "top_left_y": 7.07397,
+ "top_right_x": 7.07397,
+ "top_right_y": 7.07397,
+ "bottom_right_x": 14.14794,
+ "bottom_right_y": 14.14794,
+ "bottom_left_x": 14.14794,
+ "bottom_left_y": 14.14794
+ },
+ {
+ "top_left_x": 5.7880254,
+ "top_left_y": 5.7880254,
+ "top_right_x": 5.7880254,
+ "top_right_y": 5.7880254,
+ "bottom_right_x": 11.576051,
+ "bottom_right_y": 11.576051,
+ "bottom_left_x": 11.576051,
+ "bottom_left_y": 11.576051
+ },
+ {
+ "top_left_x": 4.6295347,
+ "top_left_y": 4.6295347,
+ "top_right_x": 4.6295347,
+ "top_right_y": 4.6295347,
+ "bottom_right_x": 9.259069,
+ "bottom_right_y": 9.259069,
+ "bottom_left_x": 9.259069,
+ "bottom_left_y": 9.259069
+ },
+ {
+ "top_left_x": 3.638935,
+ "top_left_y": 3.638935,
+ "top_right_x": 3.638935,
+ "top_right_y": 3.638935,
+ "bottom_right_x": 7.27787,
+ "bottom_right_y": 7.27787,
+ "bottom_left_x": 7.27787,
+ "bottom_left_y": 7.27787
+ },
+ {
+ "top_left_x": 2.8209057,
+ "top_left_y": 2.8209057,
+ "top_right_x": 2.8209057,
+ "top_right_y": 2.8209057,
+ "bottom_right_x": 5.6418114,
+ "bottom_right_y": 5.6418114,
+ "bottom_left_x": 5.6418114,
+ "bottom_left_y": 5.6418114
+ },
+ {
+ "top_left_x": 2.1620893,
+ "top_left_y": 2.1620893,
+ "top_right_x": 2.1620893,
+ "top_right_y": 2.1620893,
+ "bottom_right_x": 4.3241787,
+ "bottom_right_y": 4.3241787,
+ "bottom_left_x": 4.3241787,
+ "bottom_left_y": 4.3241787
+ },
+ {
+ "top_left_x": 1.6414614,
+ "top_left_y": 1.6414614,
+ "top_right_x": 1.6414614,
+ "top_right_y": 1.6414614,
+ "bottom_right_x": 3.2829227,
+ "bottom_right_y": 3.2829227,
+ "bottom_left_x": 3.2829227,
+ "bottom_left_y": 3.2829227
+ },
+ {
+ "top_left_x": 1.2361269,
+ "top_left_y": 1.2361269,
+ "top_right_x": 1.2361269,
+ "top_right_y": 1.2361269,
+ "bottom_right_x": 2.4722538,
+ "bottom_right_y": 2.4722538,
+ "bottom_left_x": 2.4722538,
+ "bottom_left_y": 2.4722538
+ },
+ {
+ "top_left_x": 0.92435074,
+ "top_left_y": 0.92435074,
+ "top_right_x": 0.92435074,
+ "top_right_y": 0.92435074,
+ "bottom_right_x": 1.8487015,
+ "bottom_right_y": 1.8487015,
+ "bottom_left_x": 1.8487015,
+ "bottom_left_y": 1.8487015
+ },
+ {
+ "top_left_x": 0.68693924,
+ "top_left_y": 0.68693924,
+ "top_right_x": 0.68693924,
+ "top_right_y": 0.68693924,
+ "bottom_right_x": 1.3738785,
+ "bottom_right_y": 1.3738785,
+ "bottom_left_x": 1.3738785,
+ "bottom_left_y": 1.3738785
+ },
+ {
+ "top_left_x": 0.5076904,
+ "top_left_y": 0.5076904,
+ "top_right_x": 0.5076904,
+ "top_right_y": 0.5076904,
+ "bottom_right_x": 1.0153809,
+ "bottom_right_y": 1.0153809,
+ "bottom_left_x": 1.0153809,
+ "bottom_left_y": 1.0153809
+ },
+ {
+ "top_left_x": 0.3733511,
+ "top_left_y": 0.3733511,
+ "top_right_x": 0.3733511,
+ "top_right_y": 0.3733511,
+ "bottom_right_x": 0.7467022,
+ "bottom_right_y": 0.7467022,
+ "bottom_left_x": 0.7467022,
+ "bottom_left_y": 0.7467022
+ },
+ {
+ "top_left_x": 0.27331638,
+ "top_left_y": 0.27331638,
+ "top_right_x": 0.27331638,
+ "top_right_y": 0.27331638,
+ "bottom_right_x": 0.54663277,
+ "bottom_right_y": 0.54663277,
+ "bottom_left_x": 0.54663277,
+ "bottom_left_y": 0.54663277
+ },
+ {
+ "top_left_x": 0.19925308,
+ "top_left_y": 0.19925308,
+ "top_right_x": 0.19925308,
+ "top_right_y": 0.19925308,
+ "bottom_right_x": 0.39850616,
+ "bottom_right_y": 0.39850616,
+ "bottom_left_x": 0.39850616,
+ "bottom_left_y": 0.39850616
+ },
+ {
+ "top_left_x": 0.14470005,
+ "top_left_y": 0.14470005,
+ "top_right_x": 0.14470005,
+ "top_right_y": 0.14470005,
+ "bottom_right_x": 0.2894001,
+ "bottom_right_y": 0.2894001,
+ "bottom_left_x": 0.2894001,
+ "bottom_left_y": 0.2894001
+ },
+ {
+ "top_left_x": 0.10470486,
+ "top_left_y": 0.10470486,
+ "top_right_x": 0.10470486,
+ "top_right_y": 0.10470486,
+ "bottom_right_x": 0.20940971,
+ "bottom_right_y": 0.20940971,
+ "bottom_left_x": 0.20940971,
+ "bottom_left_y": 0.20940971
+ },
+ {
+ "top_left_x": 0.07550812,
+ "top_left_y": 0.07550812,
+ "top_right_x": 0.07550812,
+ "top_right_y": 0.07550812,
+ "bottom_right_x": 0.15101624,
+ "bottom_right_y": 0.15101624,
+ "bottom_left_x": 0.15101624,
+ "bottom_left_y": 0.15101624
+ }
+ ]
+ },
+ {
+ "name": "alpha",
+ "type": "int",
+ "data_points": [
+ 0,
+ 255,
+ 255,
+ 255,
+ 255,
+ 255,
+ 255,
+ 255,
+ 255,
+ 255,
+ 249,
+ 226,
+ 192,
+ 153,
+ 112,
+ 72,
+ 34,
+ 0,
+ 0,
+ 0
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/SystemUI/tests/goldens/backgroundAnimationWithoutFade_whenReturning.json b/packages/SystemUI/tests/goldens/backgroundAnimationWithoutFade_whenReturning.json
index ea768c0..98005c5 100644
--- a/packages/SystemUI/tests/goldens/backgroundAnimationWithoutFade_whenReturning.json
+++ b/packages/SystemUI/tests/goldens/backgroundAnimationWithoutFade_whenReturning.json
@@ -1,25 +1,30 @@
{
"frame_ids": [
- "before",
0,
- 26,
- 52,
- 78,
- 105,
- 131,
- 157,
- 184,
- 210,
- 236,
- 263,
- 289,
- 315,
- 342,
- 368,
- 394,
- 421,
- 447,
- 473,
+ 20,
+ 40,
+ 60,
+ 80,
+ 100,
+ 120,
+ 140,
+ 160,
+ 180,
+ 200,
+ 220,
+ 240,
+ 260,
+ 280,
+ 300,
+ 320,
+ 340,
+ 360,
+ 380,
+ 400,
+ 420,
+ 440,
+ 460,
+ 480,
500
],
"features": [
@@ -28,70 +33,82 @@
"type": "rect",
"data_points": [
{
- "left": 0,
- "top": 0,
- "right": 0,
- "bottom": 0
- },
- {
"left": 100,
"top": 300,
"right": 200,
"bottom": 400
},
{
- "left": 98,
- "top": 293,
- "right": 203,
- "bottom": 407
+ "left": 99,
+ "top": 296,
+ "right": 202,
+ "bottom": 404
},
{
- "left": 91,
- "top": 269,
- "right": 213,
- "bottom": 430
+ "left": 95,
+ "top": 283,
+ "right": 207,
+ "bottom": 417
},
{
- "left": 71,
- "top": 206,
- "right": 240,
- "bottom": 491
+ "left": 86,
+ "top": 256,
+ "right": 219,
+ "bottom": 443
},
{
- "left": 34,
- "top": 98,
- "right": 283,
- "bottom": 595
+ "left": 68,
+ "top": 198,
+ "right": 243,
+ "bottom": 499
},
{
- "left": 22,
- "top": 63,
- "right": 296,
- "bottom": 629
+ "left": 39,
+ "top": 110,
+ "right": 278,
+ "bottom": 584
+ },
+ {
+ "left": 26,
+ "top": 74,
+ "right": 292,
+ "bottom": 618
+ },
+ {
+ "left": 19,
+ "top": 55,
+ "right": 299,
+ "bottom": 637
},
{
"left": 15,
- "top": 44,
- "right": 303,
- "bottom": 648
+ "top": 42,
+ "right": 304,
+ "bottom": 649
},
{
- "left": 11,
- "top": 32,
- "right": 308,
- "bottom": 659
+ "left": 12,
+ "top": 33,
+ "right": 307,
+ "bottom": 658
},
{
- "left": 8,
- "top": 23,
- "right": 311,
- "bottom": 667
+ "left": 9,
+ "top": 27,
+ "right": 310,
+ "bottom": 664
+ },
+ {
+ "left": 7,
+ "top": 21,
+ "right": 312,
+ "bottom": 669
},
{
"left": 6,
- "top": 18,
- "right": 313,
- "bottom": 673
+ "top": 17,
+ "right": 314,
+ "bottom": 674
},
{
"left": 5,
@@ -100,16 +117,22 @@
"bottom": 677
},
{
- "left": 3,
- "top": 9,
+ "left": 4,
+ "top": 10,
"right": 316,
- "bottom": 681
+ "bottom": 680
+ },
+ {
+ "left": 3,
+ "top": 8,
+ "right": 317,
+ "bottom": 682
},
{
"left": 2,
- "top": 7,
- "right": 317,
- "bottom": 683
+ "top": 6,
+ "right": 318,
+ "bottom": 684
},
{
"left": 2,
@@ -119,7 +142,7 @@
},
{
"left": 1,
- "top": 3,
+ "top": 4,
"right": 319,
"bottom": 687
},
@@ -130,6 +153,18 @@
"bottom": 688
},
{
+ "left": 1,
+ "top": 2,
+ "right": 319,
+ "bottom": 688
+ },
+ {
+ "left": 0,
+ "top": 1,
+ "right": 320,
+ "bottom": 689
+ },
+ {
"left": 0,
"top": 1,
"right": 320,
@@ -159,7 +194,6 @@
"name": "corner_radii",
"type": "cornerRadii",
"data_points": [
- null,
{
"top_left_x": 10,
"top_left_y": 10,
@@ -171,184 +205,244 @@
"bottom_left_y": 20
},
{
- "top_left_x": 9.762664,
- "top_left_y": 9.762664,
- "top_right_x": 9.762664,
- "top_right_y": 9.762664,
- "bottom_right_x": 19.525328,
- "bottom_right_y": 19.525328,
- "bottom_left_x": 19.525328,
- "bottom_left_y": 19.525328
+ "top_left_x": 9.865689,
+ "top_left_y": 9.865689,
+ "top_right_x": 9.865689,
+ "top_right_y": 9.865689,
+ "bottom_right_x": 19.731379,
+ "bottom_right_y": 19.731379,
+ "bottom_left_x": 19.731379,
+ "bottom_left_y": 19.731379
},
{
- "top_left_x": 8.969244,
- "top_left_y": 8.969244,
- "top_right_x": 8.969244,
- "top_right_y": 8.969244,
- "bottom_right_x": 17.938488,
- "bottom_right_y": 17.938488,
- "bottom_left_x": 17.938488,
- "bottom_left_y": 17.938488
+ "top_left_x": 9.419104,
+ "top_left_y": 9.419104,
+ "top_right_x": 9.419104,
+ "top_right_y": 9.419104,
+ "bottom_right_x": 18.838207,
+ "bottom_right_y": 18.838207,
+ "bottom_left_x": 18.838207,
+ "bottom_left_y": 18.838207
},
{
- "top_left_x": 6.8709626,
- "top_left_y": 6.8709626,
- "top_right_x": 6.8709626,
- "top_right_y": 6.8709626,
- "bottom_right_x": 13.741925,
- "bottom_right_y": 13.741925,
- "bottom_left_x": 13.741925,
- "bottom_left_y": 13.741925
+ "top_left_x": 8.533693,
+ "top_left_y": 8.533693,
+ "top_right_x": 8.533693,
+ "top_right_y": 8.533693,
+ "bottom_right_x": 17.067387,
+ "bottom_right_y": 17.067387,
+ "bottom_left_x": 17.067387,
+ "bottom_left_y": 17.067387
},
{
- "top_left_x": 3.260561,
- "top_left_y": 3.260561,
- "top_right_x": 3.260561,
- "top_right_y": 3.260561,
- "bottom_right_x": 6.521122,
- "bottom_right_y": 6.521122,
- "bottom_left_x": 6.521122,
- "bottom_left_y": 6.521122
+ "top_left_x": 6.5919456,
+ "top_left_y": 6.5919456,
+ "top_right_x": 6.5919456,
+ "top_right_y": 6.5919456,
+ "bottom_right_x": 13.183891,
+ "bottom_right_y": 13.183891,
+ "bottom_left_x": 13.183891,
+ "bottom_left_y": 13.183891
},
{
- "top_left_x": 2.0915751,
- "top_left_y": 2.0915751,
- "top_right_x": 2.0915751,
- "top_right_y": 2.0915751,
- "bottom_right_x": 4.1831503,
- "bottom_right_y": 4.1831503,
- "bottom_left_x": 4.1831503,
- "bottom_left_y": 4.1831503
+ "top_left_x": 3.6674318,
+ "top_left_y": 3.6674318,
+ "top_right_x": 3.6674318,
+ "top_right_y": 3.6674318,
+ "bottom_right_x": 7.3348637,
+ "bottom_right_y": 7.3348637,
+ "bottom_left_x": 7.3348637,
+ "bottom_left_y": 7.3348637
},
{
- "top_left_x": 1.4640827,
- "top_left_y": 1.4640827,
- "top_right_x": 1.4640827,
- "top_right_y": 1.4640827,
- "bottom_right_x": 2.9281654,
- "bottom_right_y": 2.9281654,
- "bottom_left_x": 2.9281654,
- "bottom_left_y": 2.9281654
+ "top_left_x": 2.4832253,
+ "top_left_y": 2.4832253,
+ "top_right_x": 2.4832253,
+ "top_right_y": 2.4832253,
+ "bottom_right_x": 4.9664507,
+ "bottom_right_y": 4.9664507,
+ "bottom_left_x": 4.9664507,
+ "bottom_left_y": 4.9664507
},
{
- "top_left_x": 1.057313,
- "top_left_y": 1.057313,
- "top_right_x": 1.057313,
- "top_right_y": 1.057313,
- "bottom_right_x": 2.114626,
- "bottom_right_y": 2.114626,
- "bottom_left_x": 2.114626,
- "bottom_left_y": 2.114626
+ "top_left_x": 1.8252907,
+ "top_left_y": 1.8252907,
+ "top_right_x": 1.8252907,
+ "top_right_y": 1.8252907,
+ "bottom_right_x": 3.6505814,
+ "bottom_right_y": 3.6505814,
+ "bottom_left_x": 3.6505814,
+ "bottom_left_y": 3.6505814
},
{
- "top_left_x": 0.7824335,
- "top_left_y": 0.7824335,
- "top_right_x": 0.7824335,
- "top_right_y": 0.7824335,
- "bottom_right_x": 1.564867,
- "bottom_right_y": 1.564867,
- "bottom_left_x": 1.564867,
- "bottom_left_y": 1.564867
+ "top_left_x": 1.4077549,
+ "top_left_y": 1.4077549,
+ "top_right_x": 1.4077549,
+ "top_right_y": 1.4077549,
+ "bottom_right_x": 2.8155098,
+ "bottom_right_y": 2.8155098,
+ "bottom_left_x": 2.8155098,
+ "bottom_left_y": 2.8155098
},
{
- "top_left_x": 0.5863056,
- "top_left_y": 0.5863056,
- "top_right_x": 0.5863056,
- "top_right_y": 0.5863056,
- "bottom_right_x": 1.1726112,
- "bottom_right_y": 1.1726112,
- "bottom_left_x": 1.1726112,
- "bottom_left_y": 1.1726112
+ "top_left_x": 1.1067667,
+ "top_left_y": 1.1067667,
+ "top_right_x": 1.1067667,
+ "top_right_y": 1.1067667,
+ "bottom_right_x": 2.2135334,
+ "bottom_right_y": 2.2135334,
+ "bottom_left_x": 2.2135334,
+ "bottom_left_y": 2.2135334
},
{
- "top_left_x": 0.4332962,
- "top_left_y": 0.4332962,
- "top_right_x": 0.4332962,
- "top_right_y": 0.4332962,
- "bottom_right_x": 0.8665924,
- "bottom_right_y": 0.8665924,
- "bottom_left_x": 0.8665924,
- "bottom_left_y": 0.8665924
+ "top_left_x": 0.88593864,
+ "top_left_y": 0.88593864,
+ "top_right_x": 0.88593864,
+ "top_right_y": 0.88593864,
+ "bottom_right_x": 1.7718773,
+ "bottom_right_y": 1.7718773,
+ "bottom_left_x": 1.7718773,
+ "bottom_left_y": 1.7718773
},
{
- "top_left_x": 0.3145876,
- "top_left_y": 0.3145876,
- "top_right_x": 0.3145876,
- "top_right_y": 0.3145876,
- "bottom_right_x": 0.6291752,
- "bottom_right_y": 0.6291752,
- "bottom_left_x": 0.6291752,
- "bottom_left_y": 0.6291752
+ "top_left_x": 0.7069988,
+ "top_left_y": 0.7069988,
+ "top_right_x": 0.7069988,
+ "top_right_y": 0.7069988,
+ "bottom_right_x": 1.4139977,
+ "bottom_right_y": 1.4139977,
+ "bottom_left_x": 1.4139977,
+ "bottom_left_y": 1.4139977
},
{
- "top_left_x": 0.22506618,
- "top_left_y": 0.22506618,
- "top_right_x": 0.22506618,
- "top_right_y": 0.22506618,
- "bottom_right_x": 0.45013237,
- "bottom_right_y": 0.45013237,
- "bottom_left_x": 0.45013237,
- "bottom_left_y": 0.45013237
+ "top_left_x": 0.55613136,
+ "top_left_y": 0.55613136,
+ "top_right_x": 0.55613136,
+ "top_right_y": 0.55613136,
+ "bottom_right_x": 1.1122627,
+ "bottom_right_y": 1.1122627,
+ "bottom_left_x": 1.1122627,
+ "bottom_left_y": 1.1122627
},
{
- "top_left_x": 0.15591621,
- "top_left_y": 0.15591621,
- "top_right_x": 0.15591621,
- "top_right_y": 0.15591621,
- "bottom_right_x": 0.31183243,
- "bottom_right_y": 0.31183243,
- "bottom_left_x": 0.31183243,
- "bottom_left_y": 0.31183243
+ "top_left_x": 0.44889355,
+ "top_left_y": 0.44889355,
+ "top_right_x": 0.44889355,
+ "top_right_y": 0.44889355,
+ "bottom_right_x": 0.8977871,
+ "bottom_right_y": 0.8977871,
+ "bottom_left_x": 0.8977871,
+ "bottom_left_y": 0.8977871
},
{
- "top_left_x": 0.100948334,
- "top_left_y": 0.100948334,
- "top_right_x": 0.100948334,
- "top_right_y": 0.100948334,
- "bottom_right_x": 0.20189667,
- "bottom_right_y": 0.20189667,
- "bottom_left_x": 0.20189667,
- "bottom_left_y": 0.20189667
+ "top_left_x": 0.34557533,
+ "top_left_y": 0.34557533,
+ "top_right_x": 0.34557533,
+ "top_right_y": 0.34557533,
+ "bottom_right_x": 0.69115067,
+ "bottom_right_y": 0.69115067,
+ "bottom_left_x": 0.69115067,
+ "bottom_left_y": 0.69115067
},
{
- "top_left_x": 0.06496239,
- "top_left_y": 0.06496239,
- "top_right_x": 0.06496239,
- "top_right_y": 0.06496239,
- "bottom_right_x": 0.12992477,
- "bottom_right_y": 0.12992477,
- "bottom_left_x": 0.12992477,
- "bottom_left_y": 0.12992477
+ "top_left_x": 0.27671337,
+ "top_left_y": 0.27671337,
+ "top_right_x": 0.27671337,
+ "top_right_y": 0.27671337,
+ "bottom_right_x": 0.55342674,
+ "bottom_right_y": 0.55342674,
+ "bottom_left_x": 0.55342674,
+ "bottom_left_y": 0.55342674
},
{
- "top_left_x": 0.03526497,
- "top_left_y": 0.03526497,
- "top_right_x": 0.03526497,
- "top_right_y": 0.03526497,
- "bottom_right_x": 0.07052994,
- "bottom_right_y": 0.07052994,
- "bottom_left_x": 0.07052994,
- "bottom_left_y": 0.07052994
+ "top_left_x": 0.20785141,
+ "top_left_y": 0.20785141,
+ "top_right_x": 0.20785141,
+ "top_right_y": 0.20785141,
+ "bottom_right_x": 0.41570282,
+ "bottom_right_y": 0.41570282,
+ "bottom_left_x": 0.41570282,
+ "bottom_left_y": 0.41570282
},
{
- "top_left_x": 0.014661789,
- "top_left_y": 0.014661789,
- "top_right_x": 0.014661789,
- "top_right_y": 0.014661789,
- "bottom_right_x": 0.029323578,
- "bottom_right_y": 0.029323578,
- "bottom_left_x": 0.029323578,
- "bottom_left_y": 0.029323578
+ "top_left_x": 0.1601448,
+ "top_left_y": 0.1601448,
+ "top_right_x": 0.1601448,
+ "top_right_y": 0.1601448,
+ "bottom_right_x": 0.3202896,
+ "bottom_right_y": 0.3202896,
+ "bottom_left_x": 0.3202896,
+ "bottom_left_y": 0.3202896
},
{
- "top_left_x": 0.0041856766,
- "top_left_y": 0.0041856766,
- "top_right_x": 0.0041856766,
- "top_right_y": 0.0041856766,
- "bottom_right_x": 0.008371353,
- "bottom_right_y": 0.008371353,
- "bottom_left_x": 0.008371353,
- "bottom_left_y": 0.008371353
+ "top_left_x": 0.117860794,
+ "top_left_y": 0.117860794,
+ "top_right_x": 0.117860794,
+ "top_right_y": 0.117860794,
+ "bottom_right_x": 0.23572159,
+ "bottom_right_y": 0.23572159,
+ "bottom_left_x": 0.23572159,
+ "bottom_left_y": 0.23572159
+ },
+ {
+ "top_left_x": 0.08036041,
+ "top_left_y": 0.08036041,
+ "top_right_x": 0.08036041,
+ "top_right_y": 0.08036041,
+ "bottom_right_x": 0.16072083,
+ "bottom_right_y": 0.16072083,
+ "bottom_left_x": 0.16072083,
+ "bottom_left_y": 0.16072083
+ },
+ {
+ "top_left_x": 0.05836296,
+ "top_left_y": 0.05836296,
+ "top_right_x": 0.05836296,
+ "top_right_y": 0.05836296,
+ "bottom_right_x": 0.11672592,
+ "bottom_right_y": 0.11672592,
+ "bottom_left_x": 0.11672592,
+ "bottom_left_y": 0.11672592
+ },
+ {
+ "top_left_x": 0.03636551,
+ "top_left_y": 0.03636551,
+ "top_right_x": 0.03636551,
+ "top_right_y": 0.03636551,
+ "bottom_right_x": 0.07273102,
+ "bottom_right_y": 0.07273102,
+ "bottom_left_x": 0.07273102,
+ "bottom_left_y": 0.07273102
+ },
+ {
+ "top_left_x": 0.018137932,
+ "top_left_y": 0.018137932,
+ "top_right_x": 0.018137932,
+ "top_right_y": 0.018137932,
+ "bottom_right_x": 0.036275864,
+ "bottom_right_y": 0.036275864,
+ "bottom_left_x": 0.036275864,
+ "bottom_left_y": 0.036275864
+ },
+ {
+ "top_left_x": 0.0082063675,
+ "top_left_y": 0.0082063675,
+ "top_right_x": 0.0082063675,
+ "top_right_y": 0.0082063675,
+ "bottom_right_x": 0.016412735,
+ "bottom_right_y": 0.016412735,
+ "bottom_left_x": 0.016412735,
+ "bottom_left_y": 0.016412735
+ },
+ {
+ "top_left_x": 0.0031013489,
+ "top_left_y": 0.0031013489,
+ "top_right_x": 0.0031013489,
+ "top_right_y": 0.0031013489,
+ "bottom_right_x": 0.0062026978,
+ "bottom_right_y": 0.0062026978,
+ "bottom_left_x": 0.0062026978,
+ "bottom_left_y": 0.0062026978
},
{
"top_left_x": 0,
@@ -366,20 +460,25 @@
"name": "alpha",
"type": "int",
"data_points": [
+ 255,
+ 255,
+ 255,
+ 255,
+ 255,
+ 255,
+ 255,
+ 255,
+ 233,
+ 191,
+ 153,
+ 117,
+ 85,
+ 57,
+ 33,
+ 14,
+ 3,
0,
- 255,
- 255,
- 255,
- 255,
- 255,
- 255,
- 239,
- 183,
- 135,
- 91,
- 53,
- 23,
- 5,
+ 0,
0,
0,
0,
diff --git a/packages/SystemUI/tests/goldens/backgroundAnimationWithoutFade_whenReturning_withSpring.json b/packages/SystemUI/tests/goldens/backgroundAnimationWithoutFade_whenReturning_withSpring.json
new file mode 100644
index 0000000..18eedd4
--- /dev/null
+++ b/packages/SystemUI/tests/goldens/backgroundAnimationWithoutFade_whenReturning_withSpring.json
@@ -0,0 +1,375 @@
+{
+ "frame_ids": [
+ 0,
+ 16,
+ 32,
+ 48,
+ 64,
+ 80,
+ 96,
+ 112,
+ 128,
+ 144,
+ 160,
+ 176,
+ 192,
+ 208,
+ 224,
+ 240,
+ 256,
+ 272,
+ 288,
+ 304
+ ],
+ "features": [
+ {
+ "name": "bounds",
+ "type": "rect",
+ "data_points": [
+ {
+ "left": 0,
+ "top": 0,
+ "right": 0,
+ "bottom": 0
+ },
+ {
+ "left": 94,
+ "top": 284,
+ "right": 206,
+ "bottom": 414
+ },
+ {
+ "left": 83,
+ "top": 251,
+ "right": 219,
+ "bottom": 447
+ },
+ {
+ "left": 70,
+ "top": 212,
+ "right": 234,
+ "bottom": 485
+ },
+ {
+ "left": 57,
+ "top": 173,
+ "right": 250,
+ "bottom": 522
+ },
+ {
+ "left": 46,
+ "top": 139,
+ "right": 264,
+ "bottom": 555
+ },
+ {
+ "left": 36,
+ "top": 109,
+ "right": 276,
+ "bottom": 584
+ },
+ {
+ "left": 28,
+ "top": 84,
+ "right": 285,
+ "bottom": 608
+ },
+ {
+ "left": 21,
+ "top": 65,
+ "right": 293,
+ "bottom": 627
+ },
+ {
+ "left": 16,
+ "top": 49,
+ "right": 300,
+ "bottom": 642
+ },
+ {
+ "left": 12,
+ "top": 36,
+ "right": 305,
+ "bottom": 653
+ },
+ {
+ "left": 9,
+ "top": 27,
+ "right": 308,
+ "bottom": 662
+ },
+ {
+ "left": 7,
+ "top": 20,
+ "right": 312,
+ "bottom": 669
+ },
+ {
+ "left": 5,
+ "top": 14,
+ "right": 314,
+ "bottom": 675
+ },
+ {
+ "left": 4,
+ "top": 11,
+ "right": 315,
+ "bottom": 678
+ },
+ {
+ "left": 3,
+ "top": 8,
+ "right": 316,
+ "bottom": 681
+ },
+ {
+ "left": 2,
+ "top": 5,
+ "right": 317,
+ "bottom": 684
+ },
+ {
+ "left": 1,
+ "top": 4,
+ "right": 318,
+ "bottom": 685
+ },
+ {
+ "left": 1,
+ "top": 3,
+ "right": 318,
+ "bottom": 686
+ },
+ {
+ "left": 0,
+ "top": 2,
+ "right": 319,
+ "bottom": 687
+ }
+ ]
+ },
+ {
+ "name": "corner_radii",
+ "type": "cornerRadii",
+ "data_points": [
+ null,
+ {
+ "top_left_x": 9.492916,
+ "top_left_y": 9.492916,
+ "top_right_x": 9.492916,
+ "top_right_y": 9.492916,
+ "bottom_right_x": 18.985832,
+ "bottom_right_y": 18.985832,
+ "bottom_left_x": 18.985832,
+ "bottom_left_y": 18.985832
+ },
+ {
+ "top_left_x": 8.381761,
+ "top_left_y": 8.381761,
+ "top_right_x": 8.381761,
+ "top_right_y": 8.381761,
+ "bottom_right_x": 16.763521,
+ "bottom_right_y": 16.763521,
+ "bottom_left_x": 16.763521,
+ "bottom_left_y": 16.763521
+ },
+ {
+ "top_left_x": 7.07397,
+ "top_left_y": 7.07397,
+ "top_right_x": 7.07397,
+ "top_right_y": 7.07397,
+ "bottom_right_x": 14.14794,
+ "bottom_right_y": 14.14794,
+ "bottom_left_x": 14.14794,
+ "bottom_left_y": 14.14794
+ },
+ {
+ "top_left_x": 5.7880254,
+ "top_left_y": 5.7880254,
+ "top_right_x": 5.7880254,
+ "top_right_y": 5.7880254,
+ "bottom_right_x": 11.576051,
+ "bottom_right_y": 11.576051,
+ "bottom_left_x": 11.576051,
+ "bottom_left_y": 11.576051
+ },
+ {
+ "top_left_x": 4.6295347,
+ "top_left_y": 4.6295347,
+ "top_right_x": 4.6295347,
+ "top_right_y": 4.6295347,
+ "bottom_right_x": 9.259069,
+ "bottom_right_y": 9.259069,
+ "bottom_left_x": 9.259069,
+ "bottom_left_y": 9.259069
+ },
+ {
+ "top_left_x": 3.638935,
+ "top_left_y": 3.638935,
+ "top_right_x": 3.638935,
+ "top_right_y": 3.638935,
+ "bottom_right_x": 7.27787,
+ "bottom_right_y": 7.27787,
+ "bottom_left_x": 7.27787,
+ "bottom_left_y": 7.27787
+ },
+ {
+ "top_left_x": 2.8209057,
+ "top_left_y": 2.8209057,
+ "top_right_x": 2.8209057,
+ "top_right_y": 2.8209057,
+ "bottom_right_x": 5.6418114,
+ "bottom_right_y": 5.6418114,
+ "bottom_left_x": 5.6418114,
+ "bottom_left_y": 5.6418114
+ },
+ {
+ "top_left_x": 2.1620893,
+ "top_left_y": 2.1620893,
+ "top_right_x": 2.1620893,
+ "top_right_y": 2.1620893,
+ "bottom_right_x": 4.3241787,
+ "bottom_right_y": 4.3241787,
+ "bottom_left_x": 4.3241787,
+ "bottom_left_y": 4.3241787
+ },
+ {
+ "top_left_x": 1.6414614,
+ "top_left_y": 1.6414614,
+ "top_right_x": 1.6414614,
+ "top_right_y": 1.6414614,
+ "bottom_right_x": 3.2829227,
+ "bottom_right_y": 3.2829227,
+ "bottom_left_x": 3.2829227,
+ "bottom_left_y": 3.2829227
+ },
+ {
+ "top_left_x": 1.2361269,
+ "top_left_y": 1.2361269,
+ "top_right_x": 1.2361269,
+ "top_right_y": 1.2361269,
+ "bottom_right_x": 2.4722538,
+ "bottom_right_y": 2.4722538,
+ "bottom_left_x": 2.4722538,
+ "bottom_left_y": 2.4722538
+ },
+ {
+ "top_left_x": 0.92435074,
+ "top_left_y": 0.92435074,
+ "top_right_x": 0.92435074,
+ "top_right_y": 0.92435074,
+ "bottom_right_x": 1.8487015,
+ "bottom_right_y": 1.8487015,
+ "bottom_left_x": 1.8487015,
+ "bottom_left_y": 1.8487015
+ },
+ {
+ "top_left_x": 0.68693924,
+ "top_left_y": 0.68693924,
+ "top_right_x": 0.68693924,
+ "top_right_y": 0.68693924,
+ "bottom_right_x": 1.3738785,
+ "bottom_right_y": 1.3738785,
+ "bottom_left_x": 1.3738785,
+ "bottom_left_y": 1.3738785
+ },
+ {
+ "top_left_x": 0.5076904,
+ "top_left_y": 0.5076904,
+ "top_right_x": 0.5076904,
+ "top_right_y": 0.5076904,
+ "bottom_right_x": 1.0153809,
+ "bottom_right_y": 1.0153809,
+ "bottom_left_x": 1.0153809,
+ "bottom_left_y": 1.0153809
+ },
+ {
+ "top_left_x": 0.3733511,
+ "top_left_y": 0.3733511,
+ "top_right_x": 0.3733511,
+ "top_right_y": 0.3733511,
+ "bottom_right_x": 0.7467022,
+ "bottom_right_y": 0.7467022,
+ "bottom_left_x": 0.7467022,
+ "bottom_left_y": 0.7467022
+ },
+ {
+ "top_left_x": 0.27331638,
+ "top_left_y": 0.27331638,
+ "top_right_x": 0.27331638,
+ "top_right_y": 0.27331638,
+ "bottom_right_x": 0.54663277,
+ "bottom_right_y": 0.54663277,
+ "bottom_left_x": 0.54663277,
+ "bottom_left_y": 0.54663277
+ },
+ {
+ "top_left_x": 0.19925308,
+ "top_left_y": 0.19925308,
+ "top_right_x": 0.19925308,
+ "top_right_y": 0.19925308,
+ "bottom_right_x": 0.39850616,
+ "bottom_right_y": 0.39850616,
+ "bottom_left_x": 0.39850616,
+ "bottom_left_y": 0.39850616
+ },
+ {
+ "top_left_x": 0.14470005,
+ "top_left_y": 0.14470005,
+ "top_right_x": 0.14470005,
+ "top_right_y": 0.14470005,
+ "bottom_right_x": 0.2894001,
+ "bottom_right_y": 0.2894001,
+ "bottom_left_x": 0.2894001,
+ "bottom_left_y": 0.2894001
+ },
+ {
+ "top_left_x": 0.10470486,
+ "top_left_y": 0.10470486,
+ "top_right_x": 0.10470486,
+ "top_right_y": 0.10470486,
+ "bottom_right_x": 0.20940971,
+ "bottom_right_y": 0.20940971,
+ "bottom_left_x": 0.20940971,
+ "bottom_left_y": 0.20940971
+ },
+ {
+ "top_left_x": 0.07550812,
+ "top_left_y": 0.07550812,
+ "top_right_x": 0.07550812,
+ "top_right_y": 0.07550812,
+ "bottom_right_x": 0.15101624,
+ "bottom_right_y": 0.15101624,
+ "bottom_left_x": 0.15101624,
+ "bottom_left_y": 0.15101624
+ }
+ ]
+ },
+ {
+ "name": "alpha",
+ "type": "int",
+ "data_points": [
+ 0,
+ 255,
+ 255,
+ 255,
+ 255,
+ 255,
+ 255,
+ 255,
+ 255,
+ 255,
+ 249,
+ 226,
+ 192,
+ 153,
+ 112,
+ 72,
+ 34,
+ 0,
+ 0,
+ 0
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/SystemUI/tests/goldens/backgroundAnimation_whenLaunching.json b/packages/SystemUI/tests/goldens/backgroundAnimation_whenLaunching.json
index 608e633..aa80445 100644
--- a/packages/SystemUI/tests/goldens/backgroundAnimation_whenLaunching.json
+++ b/packages/SystemUI/tests/goldens/backgroundAnimation_whenLaunching.json
@@ -1,25 +1,30 @@
{
"frame_ids": [
- "before",
0,
- 26,
- 52,
- 78,
- 105,
- 131,
- 157,
- 184,
- 210,
- 236,
- 263,
- 289,
- 315,
- 342,
- 368,
- 394,
- 421,
- 447,
- 473,
+ 20,
+ 40,
+ 60,
+ 80,
+ 100,
+ 120,
+ 140,
+ 160,
+ 180,
+ 200,
+ 220,
+ 240,
+ 260,
+ 280,
+ 300,
+ 320,
+ 340,
+ 360,
+ 380,
+ 400,
+ 420,
+ 440,
+ 460,
+ 480,
500
],
"features": [
@@ -28,70 +33,82 @@
"type": "rect",
"data_points": [
{
- "left": 0,
- "top": 0,
- "right": 0,
- "bottom": 0
- },
- {
"left": 100,
"top": 300,
"right": 200,
"bottom": 400
},
{
- "left": 98,
- "top": 293,
- "right": 203,
- "bottom": 407
+ "left": 99,
+ "top": 296,
+ "right": 202,
+ "bottom": 404
},
{
- "left": 91,
- "top": 269,
- "right": 213,
- "bottom": 430
+ "left": 95,
+ "top": 283,
+ "right": 207,
+ "bottom": 417
},
{
- "left": 71,
- "top": 206,
- "right": 240,
- "bottom": 491
+ "left": 86,
+ "top": 256,
+ "right": 219,
+ "bottom": 443
},
{
- "left": 34,
- "top": 98,
- "right": 283,
- "bottom": 595
+ "left": 68,
+ "top": 198,
+ "right": 243,
+ "bottom": 499
},
{
- "left": 22,
- "top": 63,
- "right": 296,
- "bottom": 629
+ "left": 39,
+ "top": 110,
+ "right": 278,
+ "bottom": 584
+ },
+ {
+ "left": 26,
+ "top": 74,
+ "right": 292,
+ "bottom": 618
+ },
+ {
+ "left": 19,
+ "top": 55,
+ "right": 299,
+ "bottom": 637
},
{
"left": 15,
- "top": 44,
- "right": 303,
- "bottom": 648
+ "top": 42,
+ "right": 304,
+ "bottom": 649
},
{
- "left": 11,
- "top": 32,
- "right": 308,
- "bottom": 659
+ "left": 12,
+ "top": 33,
+ "right": 307,
+ "bottom": 658
},
{
- "left": 8,
- "top": 23,
- "right": 311,
- "bottom": 667
+ "left": 9,
+ "top": 27,
+ "right": 310,
+ "bottom": 664
+ },
+ {
+ "left": 7,
+ "top": 21,
+ "right": 312,
+ "bottom": 669
},
{
"left": 6,
- "top": 18,
- "right": 313,
- "bottom": 673
+ "top": 17,
+ "right": 314,
+ "bottom": 674
},
{
"left": 5,
@@ -100,16 +117,22 @@
"bottom": 677
},
{
- "left": 3,
- "top": 9,
+ "left": 4,
+ "top": 10,
"right": 316,
- "bottom": 681
+ "bottom": 680
+ },
+ {
+ "left": 3,
+ "top": 8,
+ "right": 317,
+ "bottom": 682
},
{
"left": 2,
- "top": 7,
- "right": 317,
- "bottom": 683
+ "top": 6,
+ "right": 318,
+ "bottom": 684
},
{
"left": 2,
@@ -119,7 +142,7 @@
},
{
"left": 1,
- "top": 3,
+ "top": 4,
"right": 319,
"bottom": 687
},
@@ -130,6 +153,18 @@
"bottom": 688
},
{
+ "left": 1,
+ "top": 2,
+ "right": 319,
+ "bottom": 688
+ },
+ {
+ "left": 0,
+ "top": 1,
+ "right": 320,
+ "bottom": 689
+ },
+ {
"left": 0,
"top": 1,
"right": 320,
@@ -159,7 +194,6 @@
"name": "corner_radii",
"type": "cornerRadii",
"data_points": [
- null,
{
"top_left_x": 10,
"top_left_y": 10,
@@ -171,184 +205,244 @@
"bottom_left_y": 20
},
{
- "top_left_x": 9.762664,
- "top_left_y": 9.762664,
- "top_right_x": 9.762664,
- "top_right_y": 9.762664,
- "bottom_right_x": 19.525328,
- "bottom_right_y": 19.525328,
- "bottom_left_x": 19.525328,
- "bottom_left_y": 19.525328
+ "top_left_x": 9.865689,
+ "top_left_y": 9.865689,
+ "top_right_x": 9.865689,
+ "top_right_y": 9.865689,
+ "bottom_right_x": 19.731379,
+ "bottom_right_y": 19.731379,
+ "bottom_left_x": 19.731379,
+ "bottom_left_y": 19.731379
},
{
- "top_left_x": 8.969244,
- "top_left_y": 8.969244,
- "top_right_x": 8.969244,
- "top_right_y": 8.969244,
- "bottom_right_x": 17.938488,
- "bottom_right_y": 17.938488,
- "bottom_left_x": 17.938488,
- "bottom_left_y": 17.938488
+ "top_left_x": 9.419104,
+ "top_left_y": 9.419104,
+ "top_right_x": 9.419104,
+ "top_right_y": 9.419104,
+ "bottom_right_x": 18.838207,
+ "bottom_right_y": 18.838207,
+ "bottom_left_x": 18.838207,
+ "bottom_left_y": 18.838207
},
{
- "top_left_x": 6.8709626,
- "top_left_y": 6.8709626,
- "top_right_x": 6.8709626,
- "top_right_y": 6.8709626,
- "bottom_right_x": 13.741925,
- "bottom_right_y": 13.741925,
- "bottom_left_x": 13.741925,
- "bottom_left_y": 13.741925
+ "top_left_x": 8.533693,
+ "top_left_y": 8.533693,
+ "top_right_x": 8.533693,
+ "top_right_y": 8.533693,
+ "bottom_right_x": 17.067387,
+ "bottom_right_y": 17.067387,
+ "bottom_left_x": 17.067387,
+ "bottom_left_y": 17.067387
},
{
- "top_left_x": 3.260561,
- "top_left_y": 3.260561,
- "top_right_x": 3.260561,
- "top_right_y": 3.260561,
- "bottom_right_x": 6.521122,
- "bottom_right_y": 6.521122,
- "bottom_left_x": 6.521122,
- "bottom_left_y": 6.521122
+ "top_left_x": 6.5919456,
+ "top_left_y": 6.5919456,
+ "top_right_x": 6.5919456,
+ "top_right_y": 6.5919456,
+ "bottom_right_x": 13.183891,
+ "bottom_right_y": 13.183891,
+ "bottom_left_x": 13.183891,
+ "bottom_left_y": 13.183891
},
{
- "top_left_x": 2.0915751,
- "top_left_y": 2.0915751,
- "top_right_x": 2.0915751,
- "top_right_y": 2.0915751,
- "bottom_right_x": 4.1831503,
- "bottom_right_y": 4.1831503,
- "bottom_left_x": 4.1831503,
- "bottom_left_y": 4.1831503
+ "top_left_x": 3.6674318,
+ "top_left_y": 3.6674318,
+ "top_right_x": 3.6674318,
+ "top_right_y": 3.6674318,
+ "bottom_right_x": 7.3348637,
+ "bottom_right_y": 7.3348637,
+ "bottom_left_x": 7.3348637,
+ "bottom_left_y": 7.3348637
},
{
- "top_left_x": 1.4640827,
- "top_left_y": 1.4640827,
- "top_right_x": 1.4640827,
- "top_right_y": 1.4640827,
- "bottom_right_x": 2.9281654,
- "bottom_right_y": 2.9281654,
- "bottom_left_x": 2.9281654,
- "bottom_left_y": 2.9281654
+ "top_left_x": 2.4832253,
+ "top_left_y": 2.4832253,
+ "top_right_x": 2.4832253,
+ "top_right_y": 2.4832253,
+ "bottom_right_x": 4.9664507,
+ "bottom_right_y": 4.9664507,
+ "bottom_left_x": 4.9664507,
+ "bottom_left_y": 4.9664507
},
{
- "top_left_x": 1.057313,
- "top_left_y": 1.057313,
- "top_right_x": 1.057313,
- "top_right_y": 1.057313,
- "bottom_right_x": 2.114626,
- "bottom_right_y": 2.114626,
- "bottom_left_x": 2.114626,
- "bottom_left_y": 2.114626
+ "top_left_x": 1.8252907,
+ "top_left_y": 1.8252907,
+ "top_right_x": 1.8252907,
+ "top_right_y": 1.8252907,
+ "bottom_right_x": 3.6505814,
+ "bottom_right_y": 3.6505814,
+ "bottom_left_x": 3.6505814,
+ "bottom_left_y": 3.6505814
},
{
- "top_left_x": 0.7824335,
- "top_left_y": 0.7824335,
- "top_right_x": 0.7824335,
- "top_right_y": 0.7824335,
- "bottom_right_x": 1.564867,
- "bottom_right_y": 1.564867,
- "bottom_left_x": 1.564867,
- "bottom_left_y": 1.564867
+ "top_left_x": 1.4077549,
+ "top_left_y": 1.4077549,
+ "top_right_x": 1.4077549,
+ "top_right_y": 1.4077549,
+ "bottom_right_x": 2.8155098,
+ "bottom_right_y": 2.8155098,
+ "bottom_left_x": 2.8155098,
+ "bottom_left_y": 2.8155098
},
{
- "top_left_x": 0.5863056,
- "top_left_y": 0.5863056,
- "top_right_x": 0.5863056,
- "top_right_y": 0.5863056,
- "bottom_right_x": 1.1726112,
- "bottom_right_y": 1.1726112,
- "bottom_left_x": 1.1726112,
- "bottom_left_y": 1.1726112
+ "top_left_x": 1.1067667,
+ "top_left_y": 1.1067667,
+ "top_right_x": 1.1067667,
+ "top_right_y": 1.1067667,
+ "bottom_right_x": 2.2135334,
+ "bottom_right_y": 2.2135334,
+ "bottom_left_x": 2.2135334,
+ "bottom_left_y": 2.2135334
},
{
- "top_left_x": 0.4332962,
- "top_left_y": 0.4332962,
- "top_right_x": 0.4332962,
- "top_right_y": 0.4332962,
- "bottom_right_x": 0.8665924,
- "bottom_right_y": 0.8665924,
- "bottom_left_x": 0.8665924,
- "bottom_left_y": 0.8665924
+ "top_left_x": 0.88593864,
+ "top_left_y": 0.88593864,
+ "top_right_x": 0.88593864,
+ "top_right_y": 0.88593864,
+ "bottom_right_x": 1.7718773,
+ "bottom_right_y": 1.7718773,
+ "bottom_left_x": 1.7718773,
+ "bottom_left_y": 1.7718773
},
{
- "top_left_x": 0.3145876,
- "top_left_y": 0.3145876,
- "top_right_x": 0.3145876,
- "top_right_y": 0.3145876,
- "bottom_right_x": 0.6291752,
- "bottom_right_y": 0.6291752,
- "bottom_left_x": 0.6291752,
- "bottom_left_y": 0.6291752
+ "top_left_x": 0.7069988,
+ "top_left_y": 0.7069988,
+ "top_right_x": 0.7069988,
+ "top_right_y": 0.7069988,
+ "bottom_right_x": 1.4139977,
+ "bottom_right_y": 1.4139977,
+ "bottom_left_x": 1.4139977,
+ "bottom_left_y": 1.4139977
},
{
- "top_left_x": 0.22506618,
- "top_left_y": 0.22506618,
- "top_right_x": 0.22506618,
- "top_right_y": 0.22506618,
- "bottom_right_x": 0.45013237,
- "bottom_right_y": 0.45013237,
- "bottom_left_x": 0.45013237,
- "bottom_left_y": 0.45013237
+ "top_left_x": 0.55613136,
+ "top_left_y": 0.55613136,
+ "top_right_x": 0.55613136,
+ "top_right_y": 0.55613136,
+ "bottom_right_x": 1.1122627,
+ "bottom_right_y": 1.1122627,
+ "bottom_left_x": 1.1122627,
+ "bottom_left_y": 1.1122627
},
{
- "top_left_x": 0.15591621,
- "top_left_y": 0.15591621,
- "top_right_x": 0.15591621,
- "top_right_y": 0.15591621,
- "bottom_right_x": 0.31183243,
- "bottom_right_y": 0.31183243,
- "bottom_left_x": 0.31183243,
- "bottom_left_y": 0.31183243
+ "top_left_x": 0.44889355,
+ "top_left_y": 0.44889355,
+ "top_right_x": 0.44889355,
+ "top_right_y": 0.44889355,
+ "bottom_right_x": 0.8977871,
+ "bottom_right_y": 0.8977871,
+ "bottom_left_x": 0.8977871,
+ "bottom_left_y": 0.8977871
},
{
- "top_left_x": 0.100948334,
- "top_left_y": 0.100948334,
- "top_right_x": 0.100948334,
- "top_right_y": 0.100948334,
- "bottom_right_x": 0.20189667,
- "bottom_right_y": 0.20189667,
- "bottom_left_x": 0.20189667,
- "bottom_left_y": 0.20189667
+ "top_left_x": 0.34557533,
+ "top_left_y": 0.34557533,
+ "top_right_x": 0.34557533,
+ "top_right_y": 0.34557533,
+ "bottom_right_x": 0.69115067,
+ "bottom_right_y": 0.69115067,
+ "bottom_left_x": 0.69115067,
+ "bottom_left_y": 0.69115067
},
{
- "top_left_x": 0.06496239,
- "top_left_y": 0.06496239,
- "top_right_x": 0.06496239,
- "top_right_y": 0.06496239,
- "bottom_right_x": 0.12992477,
- "bottom_right_y": 0.12992477,
- "bottom_left_x": 0.12992477,
- "bottom_left_y": 0.12992477
+ "top_left_x": 0.27671337,
+ "top_left_y": 0.27671337,
+ "top_right_x": 0.27671337,
+ "top_right_y": 0.27671337,
+ "bottom_right_x": 0.55342674,
+ "bottom_right_y": 0.55342674,
+ "bottom_left_x": 0.55342674,
+ "bottom_left_y": 0.55342674
},
{
- "top_left_x": 0.03526497,
- "top_left_y": 0.03526497,
- "top_right_x": 0.03526497,
- "top_right_y": 0.03526497,
- "bottom_right_x": 0.07052994,
- "bottom_right_y": 0.07052994,
- "bottom_left_x": 0.07052994,
- "bottom_left_y": 0.07052994
+ "top_left_x": 0.20785141,
+ "top_left_y": 0.20785141,
+ "top_right_x": 0.20785141,
+ "top_right_y": 0.20785141,
+ "bottom_right_x": 0.41570282,
+ "bottom_right_y": 0.41570282,
+ "bottom_left_x": 0.41570282,
+ "bottom_left_y": 0.41570282
},
{
- "top_left_x": 0.014661789,
- "top_left_y": 0.014661789,
- "top_right_x": 0.014661789,
- "top_right_y": 0.014661789,
- "bottom_right_x": 0.029323578,
- "bottom_right_y": 0.029323578,
- "bottom_left_x": 0.029323578,
- "bottom_left_y": 0.029323578
+ "top_left_x": 0.1601448,
+ "top_left_y": 0.1601448,
+ "top_right_x": 0.1601448,
+ "top_right_y": 0.1601448,
+ "bottom_right_x": 0.3202896,
+ "bottom_right_y": 0.3202896,
+ "bottom_left_x": 0.3202896,
+ "bottom_left_y": 0.3202896
},
{
- "top_left_x": 0.0041856766,
- "top_left_y": 0.0041856766,
- "top_right_x": 0.0041856766,
- "top_right_y": 0.0041856766,
- "bottom_right_x": 0.008371353,
- "bottom_right_y": 0.008371353,
- "bottom_left_x": 0.008371353,
- "bottom_left_y": 0.008371353
+ "top_left_x": 0.117860794,
+ "top_left_y": 0.117860794,
+ "top_right_x": 0.117860794,
+ "top_right_y": 0.117860794,
+ "bottom_right_x": 0.23572159,
+ "bottom_right_y": 0.23572159,
+ "bottom_left_x": 0.23572159,
+ "bottom_left_y": 0.23572159
+ },
+ {
+ "top_left_x": 0.08036041,
+ "top_left_y": 0.08036041,
+ "top_right_x": 0.08036041,
+ "top_right_y": 0.08036041,
+ "bottom_right_x": 0.16072083,
+ "bottom_right_y": 0.16072083,
+ "bottom_left_x": 0.16072083,
+ "bottom_left_y": 0.16072083
+ },
+ {
+ "top_left_x": 0.05836296,
+ "top_left_y": 0.05836296,
+ "top_right_x": 0.05836296,
+ "top_right_y": 0.05836296,
+ "bottom_right_x": 0.11672592,
+ "bottom_right_y": 0.11672592,
+ "bottom_left_x": 0.11672592,
+ "bottom_left_y": 0.11672592
+ },
+ {
+ "top_left_x": 0.03636551,
+ "top_left_y": 0.03636551,
+ "top_right_x": 0.03636551,
+ "top_right_y": 0.03636551,
+ "bottom_right_x": 0.07273102,
+ "bottom_right_y": 0.07273102,
+ "bottom_left_x": 0.07273102,
+ "bottom_left_y": 0.07273102
+ },
+ {
+ "top_left_x": 0.018137932,
+ "top_left_y": 0.018137932,
+ "top_right_x": 0.018137932,
+ "top_right_y": 0.018137932,
+ "bottom_right_x": 0.036275864,
+ "bottom_right_y": 0.036275864,
+ "bottom_left_x": 0.036275864,
+ "bottom_left_y": 0.036275864
+ },
+ {
+ "top_left_x": 0.0082063675,
+ "top_left_y": 0.0082063675,
+ "top_right_x": 0.0082063675,
+ "top_right_y": 0.0082063675,
+ "bottom_right_x": 0.016412735,
+ "bottom_right_y": 0.016412735,
+ "bottom_left_x": 0.016412735,
+ "bottom_left_y": 0.016412735
+ },
+ {
+ "top_left_x": 0.0031013489,
+ "top_left_y": 0.0031013489,
+ "top_right_x": 0.0031013489,
+ "top_right_y": 0.0031013489,
+ "bottom_right_x": 0.0062026978,
+ "bottom_right_y": 0.0062026978,
+ "bottom_left_x": 0.0062026978,
+ "bottom_left_y": 0.0062026978
},
{
"top_left_x": 0,
@@ -367,19 +461,24 @@
"type": "int",
"data_points": [
0,
+ 96,
+ 153,
+ 192,
+ 220,
+ 238,
+ 249,
+ 254,
+ 233,
+ 191,
+ 153,
+ 117,
+ 85,
+ 57,
+ 33,
+ 14,
+ 3,
0,
- 115,
- 178,
- 217,
- 241,
- 253,
- 239,
- 183,
- 135,
- 91,
- 53,
- 23,
- 5,
+ 0,
0,
0,
0,
diff --git a/packages/SystemUI/tests/goldens/backgroundAnimation_whenLaunching_withSpring.json b/packages/SystemUI/tests/goldens/backgroundAnimation_whenLaunching_withSpring.json
new file mode 100644
index 0000000..a840d3c
--- /dev/null
+++ b/packages/SystemUI/tests/goldens/backgroundAnimation_whenLaunching_withSpring.json
@@ -0,0 +1,375 @@
+{
+ "frame_ids": [
+ 0,
+ 16,
+ 32,
+ 48,
+ 64,
+ 80,
+ 96,
+ 112,
+ 128,
+ 144,
+ 160,
+ 176,
+ 192,
+ 208,
+ 224,
+ 240,
+ 256,
+ 272,
+ 288,
+ 304
+ ],
+ "features": [
+ {
+ "name": "bounds",
+ "type": "rect",
+ "data_points": [
+ {
+ "left": 0,
+ "top": 0,
+ "right": 0,
+ "bottom": 0
+ },
+ {
+ "left": 94,
+ "top": 284,
+ "right": 206,
+ "bottom": 414
+ },
+ {
+ "left": 83,
+ "top": 251,
+ "right": 219,
+ "bottom": 447
+ },
+ {
+ "left": 70,
+ "top": 212,
+ "right": 234,
+ "bottom": 485
+ },
+ {
+ "left": 57,
+ "top": 173,
+ "right": 250,
+ "bottom": 522
+ },
+ {
+ "left": 46,
+ "top": 139,
+ "right": 264,
+ "bottom": 555
+ },
+ {
+ "left": 36,
+ "top": 109,
+ "right": 276,
+ "bottom": 584
+ },
+ {
+ "left": 28,
+ "top": 84,
+ "right": 285,
+ "bottom": 608
+ },
+ {
+ "left": 21,
+ "top": 65,
+ "right": 293,
+ "bottom": 627
+ },
+ {
+ "left": 16,
+ "top": 49,
+ "right": 300,
+ "bottom": 642
+ },
+ {
+ "left": 12,
+ "top": 36,
+ "right": 305,
+ "bottom": 653
+ },
+ {
+ "left": 9,
+ "top": 27,
+ "right": 308,
+ "bottom": 662
+ },
+ {
+ "left": 7,
+ "top": 20,
+ "right": 312,
+ "bottom": 669
+ },
+ {
+ "left": 5,
+ "top": 14,
+ "right": 314,
+ "bottom": 675
+ },
+ {
+ "left": 4,
+ "top": 11,
+ "right": 315,
+ "bottom": 678
+ },
+ {
+ "left": 3,
+ "top": 8,
+ "right": 316,
+ "bottom": 681
+ },
+ {
+ "left": 2,
+ "top": 5,
+ "right": 317,
+ "bottom": 684
+ },
+ {
+ "left": 1,
+ "top": 4,
+ "right": 318,
+ "bottom": 685
+ },
+ {
+ "left": 1,
+ "top": 3,
+ "right": 318,
+ "bottom": 686
+ },
+ {
+ "left": 0,
+ "top": 2,
+ "right": 319,
+ "bottom": 687
+ }
+ ]
+ },
+ {
+ "name": "corner_radii",
+ "type": "cornerRadii",
+ "data_points": [
+ null,
+ {
+ "top_left_x": 9.492916,
+ "top_left_y": 9.492916,
+ "top_right_x": 9.492916,
+ "top_right_y": 9.492916,
+ "bottom_right_x": 18.985832,
+ "bottom_right_y": 18.985832,
+ "bottom_left_x": 18.985832,
+ "bottom_left_y": 18.985832
+ },
+ {
+ "top_left_x": 8.381761,
+ "top_left_y": 8.381761,
+ "top_right_x": 8.381761,
+ "top_right_y": 8.381761,
+ "bottom_right_x": 16.763521,
+ "bottom_right_y": 16.763521,
+ "bottom_left_x": 16.763521,
+ "bottom_left_y": 16.763521
+ },
+ {
+ "top_left_x": 7.07397,
+ "top_left_y": 7.07397,
+ "top_right_x": 7.07397,
+ "top_right_y": 7.07397,
+ "bottom_right_x": 14.14794,
+ "bottom_right_y": 14.14794,
+ "bottom_left_x": 14.14794,
+ "bottom_left_y": 14.14794
+ },
+ {
+ "top_left_x": 5.7880254,
+ "top_left_y": 5.7880254,
+ "top_right_x": 5.7880254,
+ "top_right_y": 5.7880254,
+ "bottom_right_x": 11.576051,
+ "bottom_right_y": 11.576051,
+ "bottom_left_x": 11.576051,
+ "bottom_left_y": 11.576051
+ },
+ {
+ "top_left_x": 4.6295347,
+ "top_left_y": 4.6295347,
+ "top_right_x": 4.6295347,
+ "top_right_y": 4.6295347,
+ "bottom_right_x": 9.259069,
+ "bottom_right_y": 9.259069,
+ "bottom_left_x": 9.259069,
+ "bottom_left_y": 9.259069
+ },
+ {
+ "top_left_x": 3.638935,
+ "top_left_y": 3.638935,
+ "top_right_x": 3.638935,
+ "top_right_y": 3.638935,
+ "bottom_right_x": 7.27787,
+ "bottom_right_y": 7.27787,
+ "bottom_left_x": 7.27787,
+ "bottom_left_y": 7.27787
+ },
+ {
+ "top_left_x": 2.8209057,
+ "top_left_y": 2.8209057,
+ "top_right_x": 2.8209057,
+ "top_right_y": 2.8209057,
+ "bottom_right_x": 5.6418114,
+ "bottom_right_y": 5.6418114,
+ "bottom_left_x": 5.6418114,
+ "bottom_left_y": 5.6418114
+ },
+ {
+ "top_left_x": 2.1620893,
+ "top_left_y": 2.1620893,
+ "top_right_x": 2.1620893,
+ "top_right_y": 2.1620893,
+ "bottom_right_x": 4.3241787,
+ "bottom_right_y": 4.3241787,
+ "bottom_left_x": 4.3241787,
+ "bottom_left_y": 4.3241787
+ },
+ {
+ "top_left_x": 1.6414614,
+ "top_left_y": 1.6414614,
+ "top_right_x": 1.6414614,
+ "top_right_y": 1.6414614,
+ "bottom_right_x": 3.2829227,
+ "bottom_right_y": 3.2829227,
+ "bottom_left_x": 3.2829227,
+ "bottom_left_y": 3.2829227
+ },
+ {
+ "top_left_x": 1.2361269,
+ "top_left_y": 1.2361269,
+ "top_right_x": 1.2361269,
+ "top_right_y": 1.2361269,
+ "bottom_right_x": 2.4722538,
+ "bottom_right_y": 2.4722538,
+ "bottom_left_x": 2.4722538,
+ "bottom_left_y": 2.4722538
+ },
+ {
+ "top_left_x": 0.92435074,
+ "top_left_y": 0.92435074,
+ "top_right_x": 0.92435074,
+ "top_right_y": 0.92435074,
+ "bottom_right_x": 1.8487015,
+ "bottom_right_y": 1.8487015,
+ "bottom_left_x": 1.8487015,
+ "bottom_left_y": 1.8487015
+ },
+ {
+ "top_left_x": 0.68693924,
+ "top_left_y": 0.68693924,
+ "top_right_x": 0.68693924,
+ "top_right_y": 0.68693924,
+ "bottom_right_x": 1.3738785,
+ "bottom_right_y": 1.3738785,
+ "bottom_left_x": 1.3738785,
+ "bottom_left_y": 1.3738785
+ },
+ {
+ "top_left_x": 0.5076904,
+ "top_left_y": 0.5076904,
+ "top_right_x": 0.5076904,
+ "top_right_y": 0.5076904,
+ "bottom_right_x": 1.0153809,
+ "bottom_right_y": 1.0153809,
+ "bottom_left_x": 1.0153809,
+ "bottom_left_y": 1.0153809
+ },
+ {
+ "top_left_x": 0.3733511,
+ "top_left_y": 0.3733511,
+ "top_right_x": 0.3733511,
+ "top_right_y": 0.3733511,
+ "bottom_right_x": 0.7467022,
+ "bottom_right_y": 0.7467022,
+ "bottom_left_x": 0.7467022,
+ "bottom_left_y": 0.7467022
+ },
+ {
+ "top_left_x": 0.27331638,
+ "top_left_y": 0.27331638,
+ "top_right_x": 0.27331638,
+ "top_right_y": 0.27331638,
+ "bottom_right_x": 0.54663277,
+ "bottom_right_y": 0.54663277,
+ "bottom_left_x": 0.54663277,
+ "bottom_left_y": 0.54663277
+ },
+ {
+ "top_left_x": 0.19925308,
+ "top_left_y": 0.19925308,
+ "top_right_x": 0.19925308,
+ "top_right_y": 0.19925308,
+ "bottom_right_x": 0.39850616,
+ "bottom_right_y": 0.39850616,
+ "bottom_left_x": 0.39850616,
+ "bottom_left_y": 0.39850616
+ },
+ {
+ "top_left_x": 0.14470005,
+ "top_left_y": 0.14470005,
+ "top_right_x": 0.14470005,
+ "top_right_y": 0.14470005,
+ "bottom_right_x": 0.2894001,
+ "bottom_right_y": 0.2894001,
+ "bottom_left_x": 0.2894001,
+ "bottom_left_y": 0.2894001
+ },
+ {
+ "top_left_x": 0.10470486,
+ "top_left_y": 0.10470486,
+ "top_right_x": 0.10470486,
+ "top_right_y": 0.10470486,
+ "bottom_right_x": 0.20940971,
+ "bottom_right_y": 0.20940971,
+ "bottom_left_x": 0.20940971,
+ "bottom_left_y": 0.20940971
+ },
+ {
+ "top_left_x": 0.07550812,
+ "top_left_y": 0.07550812,
+ "top_right_x": 0.07550812,
+ "top_right_y": 0.07550812,
+ "bottom_right_x": 0.15101624,
+ "bottom_right_y": 0.15101624,
+ "bottom_left_x": 0.15101624,
+ "bottom_left_y": 0.15101624
+ }
+ ]
+ },
+ {
+ "name": "alpha",
+ "type": "int",
+ "data_points": [
+ 0,
+ 45,
+ 126,
+ 190,
+ 228,
+ 246,
+ 253,
+ 255,
+ 255,
+ 255,
+ 249,
+ 226,
+ 192,
+ 153,
+ 112,
+ 72,
+ 34,
+ 0,
+ 0,
+ 0
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/SystemUI/tests/goldens/backgroundAnimation_whenReturning.json b/packages/SystemUI/tests/goldens/backgroundAnimation_whenReturning.json
index 608e633..aa80445 100644
--- a/packages/SystemUI/tests/goldens/backgroundAnimation_whenReturning.json
+++ b/packages/SystemUI/tests/goldens/backgroundAnimation_whenReturning.json
@@ -1,25 +1,30 @@
{
"frame_ids": [
- "before",
0,
- 26,
- 52,
- 78,
- 105,
- 131,
- 157,
- 184,
- 210,
- 236,
- 263,
- 289,
- 315,
- 342,
- 368,
- 394,
- 421,
- 447,
- 473,
+ 20,
+ 40,
+ 60,
+ 80,
+ 100,
+ 120,
+ 140,
+ 160,
+ 180,
+ 200,
+ 220,
+ 240,
+ 260,
+ 280,
+ 300,
+ 320,
+ 340,
+ 360,
+ 380,
+ 400,
+ 420,
+ 440,
+ 460,
+ 480,
500
],
"features": [
@@ -28,70 +33,82 @@
"type": "rect",
"data_points": [
{
- "left": 0,
- "top": 0,
- "right": 0,
- "bottom": 0
- },
- {
"left": 100,
"top": 300,
"right": 200,
"bottom": 400
},
{
- "left": 98,
- "top": 293,
- "right": 203,
- "bottom": 407
+ "left": 99,
+ "top": 296,
+ "right": 202,
+ "bottom": 404
},
{
- "left": 91,
- "top": 269,
- "right": 213,
- "bottom": 430
+ "left": 95,
+ "top": 283,
+ "right": 207,
+ "bottom": 417
},
{
- "left": 71,
- "top": 206,
- "right": 240,
- "bottom": 491
+ "left": 86,
+ "top": 256,
+ "right": 219,
+ "bottom": 443
},
{
- "left": 34,
- "top": 98,
- "right": 283,
- "bottom": 595
+ "left": 68,
+ "top": 198,
+ "right": 243,
+ "bottom": 499
},
{
- "left": 22,
- "top": 63,
- "right": 296,
- "bottom": 629
+ "left": 39,
+ "top": 110,
+ "right": 278,
+ "bottom": 584
+ },
+ {
+ "left": 26,
+ "top": 74,
+ "right": 292,
+ "bottom": 618
+ },
+ {
+ "left": 19,
+ "top": 55,
+ "right": 299,
+ "bottom": 637
},
{
"left": 15,
- "top": 44,
- "right": 303,
- "bottom": 648
+ "top": 42,
+ "right": 304,
+ "bottom": 649
},
{
- "left": 11,
- "top": 32,
- "right": 308,
- "bottom": 659
+ "left": 12,
+ "top": 33,
+ "right": 307,
+ "bottom": 658
},
{
- "left": 8,
- "top": 23,
- "right": 311,
- "bottom": 667
+ "left": 9,
+ "top": 27,
+ "right": 310,
+ "bottom": 664
+ },
+ {
+ "left": 7,
+ "top": 21,
+ "right": 312,
+ "bottom": 669
},
{
"left": 6,
- "top": 18,
- "right": 313,
- "bottom": 673
+ "top": 17,
+ "right": 314,
+ "bottom": 674
},
{
"left": 5,
@@ -100,16 +117,22 @@
"bottom": 677
},
{
- "left": 3,
- "top": 9,
+ "left": 4,
+ "top": 10,
"right": 316,
- "bottom": 681
+ "bottom": 680
+ },
+ {
+ "left": 3,
+ "top": 8,
+ "right": 317,
+ "bottom": 682
},
{
"left": 2,
- "top": 7,
- "right": 317,
- "bottom": 683
+ "top": 6,
+ "right": 318,
+ "bottom": 684
},
{
"left": 2,
@@ -119,7 +142,7 @@
},
{
"left": 1,
- "top": 3,
+ "top": 4,
"right": 319,
"bottom": 687
},
@@ -130,6 +153,18 @@
"bottom": 688
},
{
+ "left": 1,
+ "top": 2,
+ "right": 319,
+ "bottom": 688
+ },
+ {
+ "left": 0,
+ "top": 1,
+ "right": 320,
+ "bottom": 689
+ },
+ {
"left": 0,
"top": 1,
"right": 320,
@@ -159,7 +194,6 @@
"name": "corner_radii",
"type": "cornerRadii",
"data_points": [
- null,
{
"top_left_x": 10,
"top_left_y": 10,
@@ -171,184 +205,244 @@
"bottom_left_y": 20
},
{
- "top_left_x": 9.762664,
- "top_left_y": 9.762664,
- "top_right_x": 9.762664,
- "top_right_y": 9.762664,
- "bottom_right_x": 19.525328,
- "bottom_right_y": 19.525328,
- "bottom_left_x": 19.525328,
- "bottom_left_y": 19.525328
+ "top_left_x": 9.865689,
+ "top_left_y": 9.865689,
+ "top_right_x": 9.865689,
+ "top_right_y": 9.865689,
+ "bottom_right_x": 19.731379,
+ "bottom_right_y": 19.731379,
+ "bottom_left_x": 19.731379,
+ "bottom_left_y": 19.731379
},
{
- "top_left_x": 8.969244,
- "top_left_y": 8.969244,
- "top_right_x": 8.969244,
- "top_right_y": 8.969244,
- "bottom_right_x": 17.938488,
- "bottom_right_y": 17.938488,
- "bottom_left_x": 17.938488,
- "bottom_left_y": 17.938488
+ "top_left_x": 9.419104,
+ "top_left_y": 9.419104,
+ "top_right_x": 9.419104,
+ "top_right_y": 9.419104,
+ "bottom_right_x": 18.838207,
+ "bottom_right_y": 18.838207,
+ "bottom_left_x": 18.838207,
+ "bottom_left_y": 18.838207
},
{
- "top_left_x": 6.8709626,
- "top_left_y": 6.8709626,
- "top_right_x": 6.8709626,
- "top_right_y": 6.8709626,
- "bottom_right_x": 13.741925,
- "bottom_right_y": 13.741925,
- "bottom_left_x": 13.741925,
- "bottom_left_y": 13.741925
+ "top_left_x": 8.533693,
+ "top_left_y": 8.533693,
+ "top_right_x": 8.533693,
+ "top_right_y": 8.533693,
+ "bottom_right_x": 17.067387,
+ "bottom_right_y": 17.067387,
+ "bottom_left_x": 17.067387,
+ "bottom_left_y": 17.067387
},
{
- "top_left_x": 3.260561,
- "top_left_y": 3.260561,
- "top_right_x": 3.260561,
- "top_right_y": 3.260561,
- "bottom_right_x": 6.521122,
- "bottom_right_y": 6.521122,
- "bottom_left_x": 6.521122,
- "bottom_left_y": 6.521122
+ "top_left_x": 6.5919456,
+ "top_left_y": 6.5919456,
+ "top_right_x": 6.5919456,
+ "top_right_y": 6.5919456,
+ "bottom_right_x": 13.183891,
+ "bottom_right_y": 13.183891,
+ "bottom_left_x": 13.183891,
+ "bottom_left_y": 13.183891
},
{
- "top_left_x": 2.0915751,
- "top_left_y": 2.0915751,
- "top_right_x": 2.0915751,
- "top_right_y": 2.0915751,
- "bottom_right_x": 4.1831503,
- "bottom_right_y": 4.1831503,
- "bottom_left_x": 4.1831503,
- "bottom_left_y": 4.1831503
+ "top_left_x": 3.6674318,
+ "top_left_y": 3.6674318,
+ "top_right_x": 3.6674318,
+ "top_right_y": 3.6674318,
+ "bottom_right_x": 7.3348637,
+ "bottom_right_y": 7.3348637,
+ "bottom_left_x": 7.3348637,
+ "bottom_left_y": 7.3348637
},
{
- "top_left_x": 1.4640827,
- "top_left_y": 1.4640827,
- "top_right_x": 1.4640827,
- "top_right_y": 1.4640827,
- "bottom_right_x": 2.9281654,
- "bottom_right_y": 2.9281654,
- "bottom_left_x": 2.9281654,
- "bottom_left_y": 2.9281654
+ "top_left_x": 2.4832253,
+ "top_left_y": 2.4832253,
+ "top_right_x": 2.4832253,
+ "top_right_y": 2.4832253,
+ "bottom_right_x": 4.9664507,
+ "bottom_right_y": 4.9664507,
+ "bottom_left_x": 4.9664507,
+ "bottom_left_y": 4.9664507
},
{
- "top_left_x": 1.057313,
- "top_left_y": 1.057313,
- "top_right_x": 1.057313,
- "top_right_y": 1.057313,
- "bottom_right_x": 2.114626,
- "bottom_right_y": 2.114626,
- "bottom_left_x": 2.114626,
- "bottom_left_y": 2.114626
+ "top_left_x": 1.8252907,
+ "top_left_y": 1.8252907,
+ "top_right_x": 1.8252907,
+ "top_right_y": 1.8252907,
+ "bottom_right_x": 3.6505814,
+ "bottom_right_y": 3.6505814,
+ "bottom_left_x": 3.6505814,
+ "bottom_left_y": 3.6505814
},
{
- "top_left_x": 0.7824335,
- "top_left_y": 0.7824335,
- "top_right_x": 0.7824335,
- "top_right_y": 0.7824335,
- "bottom_right_x": 1.564867,
- "bottom_right_y": 1.564867,
- "bottom_left_x": 1.564867,
- "bottom_left_y": 1.564867
+ "top_left_x": 1.4077549,
+ "top_left_y": 1.4077549,
+ "top_right_x": 1.4077549,
+ "top_right_y": 1.4077549,
+ "bottom_right_x": 2.8155098,
+ "bottom_right_y": 2.8155098,
+ "bottom_left_x": 2.8155098,
+ "bottom_left_y": 2.8155098
},
{
- "top_left_x": 0.5863056,
- "top_left_y": 0.5863056,
- "top_right_x": 0.5863056,
- "top_right_y": 0.5863056,
- "bottom_right_x": 1.1726112,
- "bottom_right_y": 1.1726112,
- "bottom_left_x": 1.1726112,
- "bottom_left_y": 1.1726112
+ "top_left_x": 1.1067667,
+ "top_left_y": 1.1067667,
+ "top_right_x": 1.1067667,
+ "top_right_y": 1.1067667,
+ "bottom_right_x": 2.2135334,
+ "bottom_right_y": 2.2135334,
+ "bottom_left_x": 2.2135334,
+ "bottom_left_y": 2.2135334
},
{
- "top_left_x": 0.4332962,
- "top_left_y": 0.4332962,
- "top_right_x": 0.4332962,
- "top_right_y": 0.4332962,
- "bottom_right_x": 0.8665924,
- "bottom_right_y": 0.8665924,
- "bottom_left_x": 0.8665924,
- "bottom_left_y": 0.8665924
+ "top_left_x": 0.88593864,
+ "top_left_y": 0.88593864,
+ "top_right_x": 0.88593864,
+ "top_right_y": 0.88593864,
+ "bottom_right_x": 1.7718773,
+ "bottom_right_y": 1.7718773,
+ "bottom_left_x": 1.7718773,
+ "bottom_left_y": 1.7718773
},
{
- "top_left_x": 0.3145876,
- "top_left_y": 0.3145876,
- "top_right_x": 0.3145876,
- "top_right_y": 0.3145876,
- "bottom_right_x": 0.6291752,
- "bottom_right_y": 0.6291752,
- "bottom_left_x": 0.6291752,
- "bottom_left_y": 0.6291752
+ "top_left_x": 0.7069988,
+ "top_left_y": 0.7069988,
+ "top_right_x": 0.7069988,
+ "top_right_y": 0.7069988,
+ "bottom_right_x": 1.4139977,
+ "bottom_right_y": 1.4139977,
+ "bottom_left_x": 1.4139977,
+ "bottom_left_y": 1.4139977
},
{
- "top_left_x": 0.22506618,
- "top_left_y": 0.22506618,
- "top_right_x": 0.22506618,
- "top_right_y": 0.22506618,
- "bottom_right_x": 0.45013237,
- "bottom_right_y": 0.45013237,
- "bottom_left_x": 0.45013237,
- "bottom_left_y": 0.45013237
+ "top_left_x": 0.55613136,
+ "top_left_y": 0.55613136,
+ "top_right_x": 0.55613136,
+ "top_right_y": 0.55613136,
+ "bottom_right_x": 1.1122627,
+ "bottom_right_y": 1.1122627,
+ "bottom_left_x": 1.1122627,
+ "bottom_left_y": 1.1122627
},
{
- "top_left_x": 0.15591621,
- "top_left_y": 0.15591621,
- "top_right_x": 0.15591621,
- "top_right_y": 0.15591621,
- "bottom_right_x": 0.31183243,
- "bottom_right_y": 0.31183243,
- "bottom_left_x": 0.31183243,
- "bottom_left_y": 0.31183243
+ "top_left_x": 0.44889355,
+ "top_left_y": 0.44889355,
+ "top_right_x": 0.44889355,
+ "top_right_y": 0.44889355,
+ "bottom_right_x": 0.8977871,
+ "bottom_right_y": 0.8977871,
+ "bottom_left_x": 0.8977871,
+ "bottom_left_y": 0.8977871
},
{
- "top_left_x": 0.100948334,
- "top_left_y": 0.100948334,
- "top_right_x": 0.100948334,
- "top_right_y": 0.100948334,
- "bottom_right_x": 0.20189667,
- "bottom_right_y": 0.20189667,
- "bottom_left_x": 0.20189667,
- "bottom_left_y": 0.20189667
+ "top_left_x": 0.34557533,
+ "top_left_y": 0.34557533,
+ "top_right_x": 0.34557533,
+ "top_right_y": 0.34557533,
+ "bottom_right_x": 0.69115067,
+ "bottom_right_y": 0.69115067,
+ "bottom_left_x": 0.69115067,
+ "bottom_left_y": 0.69115067
},
{
- "top_left_x": 0.06496239,
- "top_left_y": 0.06496239,
- "top_right_x": 0.06496239,
- "top_right_y": 0.06496239,
- "bottom_right_x": 0.12992477,
- "bottom_right_y": 0.12992477,
- "bottom_left_x": 0.12992477,
- "bottom_left_y": 0.12992477
+ "top_left_x": 0.27671337,
+ "top_left_y": 0.27671337,
+ "top_right_x": 0.27671337,
+ "top_right_y": 0.27671337,
+ "bottom_right_x": 0.55342674,
+ "bottom_right_y": 0.55342674,
+ "bottom_left_x": 0.55342674,
+ "bottom_left_y": 0.55342674
},
{
- "top_left_x": 0.03526497,
- "top_left_y": 0.03526497,
- "top_right_x": 0.03526497,
- "top_right_y": 0.03526497,
- "bottom_right_x": 0.07052994,
- "bottom_right_y": 0.07052994,
- "bottom_left_x": 0.07052994,
- "bottom_left_y": 0.07052994
+ "top_left_x": 0.20785141,
+ "top_left_y": 0.20785141,
+ "top_right_x": 0.20785141,
+ "top_right_y": 0.20785141,
+ "bottom_right_x": 0.41570282,
+ "bottom_right_y": 0.41570282,
+ "bottom_left_x": 0.41570282,
+ "bottom_left_y": 0.41570282
},
{
- "top_left_x": 0.014661789,
- "top_left_y": 0.014661789,
- "top_right_x": 0.014661789,
- "top_right_y": 0.014661789,
- "bottom_right_x": 0.029323578,
- "bottom_right_y": 0.029323578,
- "bottom_left_x": 0.029323578,
- "bottom_left_y": 0.029323578
+ "top_left_x": 0.1601448,
+ "top_left_y": 0.1601448,
+ "top_right_x": 0.1601448,
+ "top_right_y": 0.1601448,
+ "bottom_right_x": 0.3202896,
+ "bottom_right_y": 0.3202896,
+ "bottom_left_x": 0.3202896,
+ "bottom_left_y": 0.3202896
},
{
- "top_left_x": 0.0041856766,
- "top_left_y": 0.0041856766,
- "top_right_x": 0.0041856766,
- "top_right_y": 0.0041856766,
- "bottom_right_x": 0.008371353,
- "bottom_right_y": 0.008371353,
- "bottom_left_x": 0.008371353,
- "bottom_left_y": 0.008371353
+ "top_left_x": 0.117860794,
+ "top_left_y": 0.117860794,
+ "top_right_x": 0.117860794,
+ "top_right_y": 0.117860794,
+ "bottom_right_x": 0.23572159,
+ "bottom_right_y": 0.23572159,
+ "bottom_left_x": 0.23572159,
+ "bottom_left_y": 0.23572159
+ },
+ {
+ "top_left_x": 0.08036041,
+ "top_left_y": 0.08036041,
+ "top_right_x": 0.08036041,
+ "top_right_y": 0.08036041,
+ "bottom_right_x": 0.16072083,
+ "bottom_right_y": 0.16072083,
+ "bottom_left_x": 0.16072083,
+ "bottom_left_y": 0.16072083
+ },
+ {
+ "top_left_x": 0.05836296,
+ "top_left_y": 0.05836296,
+ "top_right_x": 0.05836296,
+ "top_right_y": 0.05836296,
+ "bottom_right_x": 0.11672592,
+ "bottom_right_y": 0.11672592,
+ "bottom_left_x": 0.11672592,
+ "bottom_left_y": 0.11672592
+ },
+ {
+ "top_left_x": 0.03636551,
+ "top_left_y": 0.03636551,
+ "top_right_x": 0.03636551,
+ "top_right_y": 0.03636551,
+ "bottom_right_x": 0.07273102,
+ "bottom_right_y": 0.07273102,
+ "bottom_left_x": 0.07273102,
+ "bottom_left_y": 0.07273102
+ },
+ {
+ "top_left_x": 0.018137932,
+ "top_left_y": 0.018137932,
+ "top_right_x": 0.018137932,
+ "top_right_y": 0.018137932,
+ "bottom_right_x": 0.036275864,
+ "bottom_right_y": 0.036275864,
+ "bottom_left_x": 0.036275864,
+ "bottom_left_y": 0.036275864
+ },
+ {
+ "top_left_x": 0.0082063675,
+ "top_left_y": 0.0082063675,
+ "top_right_x": 0.0082063675,
+ "top_right_y": 0.0082063675,
+ "bottom_right_x": 0.016412735,
+ "bottom_right_y": 0.016412735,
+ "bottom_left_x": 0.016412735,
+ "bottom_left_y": 0.016412735
+ },
+ {
+ "top_left_x": 0.0031013489,
+ "top_left_y": 0.0031013489,
+ "top_right_x": 0.0031013489,
+ "top_right_y": 0.0031013489,
+ "bottom_right_x": 0.0062026978,
+ "bottom_right_y": 0.0062026978,
+ "bottom_left_x": 0.0062026978,
+ "bottom_left_y": 0.0062026978
},
{
"top_left_x": 0,
@@ -367,19 +461,24 @@
"type": "int",
"data_points": [
0,
+ 96,
+ 153,
+ 192,
+ 220,
+ 238,
+ 249,
+ 254,
+ 233,
+ 191,
+ 153,
+ 117,
+ 85,
+ 57,
+ 33,
+ 14,
+ 3,
0,
- 115,
- 178,
- 217,
- 241,
- 253,
- 239,
- 183,
- 135,
- 91,
- 53,
- 23,
- 5,
+ 0,
0,
0,
0,
diff --git a/packages/SystemUI/tests/goldens/backgroundAnimation_whenReturning_withSpring.json b/packages/SystemUI/tests/goldens/backgroundAnimation_whenReturning_withSpring.json
new file mode 100644
index 0000000..a840d3c
--- /dev/null
+++ b/packages/SystemUI/tests/goldens/backgroundAnimation_whenReturning_withSpring.json
@@ -0,0 +1,375 @@
+{
+ "frame_ids": [
+ 0,
+ 16,
+ 32,
+ 48,
+ 64,
+ 80,
+ 96,
+ 112,
+ 128,
+ 144,
+ 160,
+ 176,
+ 192,
+ 208,
+ 224,
+ 240,
+ 256,
+ 272,
+ 288,
+ 304
+ ],
+ "features": [
+ {
+ "name": "bounds",
+ "type": "rect",
+ "data_points": [
+ {
+ "left": 0,
+ "top": 0,
+ "right": 0,
+ "bottom": 0
+ },
+ {
+ "left": 94,
+ "top": 284,
+ "right": 206,
+ "bottom": 414
+ },
+ {
+ "left": 83,
+ "top": 251,
+ "right": 219,
+ "bottom": 447
+ },
+ {
+ "left": 70,
+ "top": 212,
+ "right": 234,
+ "bottom": 485
+ },
+ {
+ "left": 57,
+ "top": 173,
+ "right": 250,
+ "bottom": 522
+ },
+ {
+ "left": 46,
+ "top": 139,
+ "right": 264,
+ "bottom": 555
+ },
+ {
+ "left": 36,
+ "top": 109,
+ "right": 276,
+ "bottom": 584
+ },
+ {
+ "left": 28,
+ "top": 84,
+ "right": 285,
+ "bottom": 608
+ },
+ {
+ "left": 21,
+ "top": 65,
+ "right": 293,
+ "bottom": 627
+ },
+ {
+ "left": 16,
+ "top": 49,
+ "right": 300,
+ "bottom": 642
+ },
+ {
+ "left": 12,
+ "top": 36,
+ "right": 305,
+ "bottom": 653
+ },
+ {
+ "left": 9,
+ "top": 27,
+ "right": 308,
+ "bottom": 662
+ },
+ {
+ "left": 7,
+ "top": 20,
+ "right": 312,
+ "bottom": 669
+ },
+ {
+ "left": 5,
+ "top": 14,
+ "right": 314,
+ "bottom": 675
+ },
+ {
+ "left": 4,
+ "top": 11,
+ "right": 315,
+ "bottom": 678
+ },
+ {
+ "left": 3,
+ "top": 8,
+ "right": 316,
+ "bottom": 681
+ },
+ {
+ "left": 2,
+ "top": 5,
+ "right": 317,
+ "bottom": 684
+ },
+ {
+ "left": 1,
+ "top": 4,
+ "right": 318,
+ "bottom": 685
+ },
+ {
+ "left": 1,
+ "top": 3,
+ "right": 318,
+ "bottom": 686
+ },
+ {
+ "left": 0,
+ "top": 2,
+ "right": 319,
+ "bottom": 687
+ }
+ ]
+ },
+ {
+ "name": "corner_radii",
+ "type": "cornerRadii",
+ "data_points": [
+ null,
+ {
+ "top_left_x": 9.492916,
+ "top_left_y": 9.492916,
+ "top_right_x": 9.492916,
+ "top_right_y": 9.492916,
+ "bottom_right_x": 18.985832,
+ "bottom_right_y": 18.985832,
+ "bottom_left_x": 18.985832,
+ "bottom_left_y": 18.985832
+ },
+ {
+ "top_left_x": 8.381761,
+ "top_left_y": 8.381761,
+ "top_right_x": 8.381761,
+ "top_right_y": 8.381761,
+ "bottom_right_x": 16.763521,
+ "bottom_right_y": 16.763521,
+ "bottom_left_x": 16.763521,
+ "bottom_left_y": 16.763521
+ },
+ {
+ "top_left_x": 7.07397,
+ "top_left_y": 7.07397,
+ "top_right_x": 7.07397,
+ "top_right_y": 7.07397,
+ "bottom_right_x": 14.14794,
+ "bottom_right_y": 14.14794,
+ "bottom_left_x": 14.14794,
+ "bottom_left_y": 14.14794
+ },
+ {
+ "top_left_x": 5.7880254,
+ "top_left_y": 5.7880254,
+ "top_right_x": 5.7880254,
+ "top_right_y": 5.7880254,
+ "bottom_right_x": 11.576051,
+ "bottom_right_y": 11.576051,
+ "bottom_left_x": 11.576051,
+ "bottom_left_y": 11.576051
+ },
+ {
+ "top_left_x": 4.6295347,
+ "top_left_y": 4.6295347,
+ "top_right_x": 4.6295347,
+ "top_right_y": 4.6295347,
+ "bottom_right_x": 9.259069,
+ "bottom_right_y": 9.259069,
+ "bottom_left_x": 9.259069,
+ "bottom_left_y": 9.259069
+ },
+ {
+ "top_left_x": 3.638935,
+ "top_left_y": 3.638935,
+ "top_right_x": 3.638935,
+ "top_right_y": 3.638935,
+ "bottom_right_x": 7.27787,
+ "bottom_right_y": 7.27787,
+ "bottom_left_x": 7.27787,
+ "bottom_left_y": 7.27787
+ },
+ {
+ "top_left_x": 2.8209057,
+ "top_left_y": 2.8209057,
+ "top_right_x": 2.8209057,
+ "top_right_y": 2.8209057,
+ "bottom_right_x": 5.6418114,
+ "bottom_right_y": 5.6418114,
+ "bottom_left_x": 5.6418114,
+ "bottom_left_y": 5.6418114
+ },
+ {
+ "top_left_x": 2.1620893,
+ "top_left_y": 2.1620893,
+ "top_right_x": 2.1620893,
+ "top_right_y": 2.1620893,
+ "bottom_right_x": 4.3241787,
+ "bottom_right_y": 4.3241787,
+ "bottom_left_x": 4.3241787,
+ "bottom_left_y": 4.3241787
+ },
+ {
+ "top_left_x": 1.6414614,
+ "top_left_y": 1.6414614,
+ "top_right_x": 1.6414614,
+ "top_right_y": 1.6414614,
+ "bottom_right_x": 3.2829227,
+ "bottom_right_y": 3.2829227,
+ "bottom_left_x": 3.2829227,
+ "bottom_left_y": 3.2829227
+ },
+ {
+ "top_left_x": 1.2361269,
+ "top_left_y": 1.2361269,
+ "top_right_x": 1.2361269,
+ "top_right_y": 1.2361269,
+ "bottom_right_x": 2.4722538,
+ "bottom_right_y": 2.4722538,
+ "bottom_left_x": 2.4722538,
+ "bottom_left_y": 2.4722538
+ },
+ {
+ "top_left_x": 0.92435074,
+ "top_left_y": 0.92435074,
+ "top_right_x": 0.92435074,
+ "top_right_y": 0.92435074,
+ "bottom_right_x": 1.8487015,
+ "bottom_right_y": 1.8487015,
+ "bottom_left_x": 1.8487015,
+ "bottom_left_y": 1.8487015
+ },
+ {
+ "top_left_x": 0.68693924,
+ "top_left_y": 0.68693924,
+ "top_right_x": 0.68693924,
+ "top_right_y": 0.68693924,
+ "bottom_right_x": 1.3738785,
+ "bottom_right_y": 1.3738785,
+ "bottom_left_x": 1.3738785,
+ "bottom_left_y": 1.3738785
+ },
+ {
+ "top_left_x": 0.5076904,
+ "top_left_y": 0.5076904,
+ "top_right_x": 0.5076904,
+ "top_right_y": 0.5076904,
+ "bottom_right_x": 1.0153809,
+ "bottom_right_y": 1.0153809,
+ "bottom_left_x": 1.0153809,
+ "bottom_left_y": 1.0153809
+ },
+ {
+ "top_left_x": 0.3733511,
+ "top_left_y": 0.3733511,
+ "top_right_x": 0.3733511,
+ "top_right_y": 0.3733511,
+ "bottom_right_x": 0.7467022,
+ "bottom_right_y": 0.7467022,
+ "bottom_left_x": 0.7467022,
+ "bottom_left_y": 0.7467022
+ },
+ {
+ "top_left_x": 0.27331638,
+ "top_left_y": 0.27331638,
+ "top_right_x": 0.27331638,
+ "top_right_y": 0.27331638,
+ "bottom_right_x": 0.54663277,
+ "bottom_right_y": 0.54663277,
+ "bottom_left_x": 0.54663277,
+ "bottom_left_y": 0.54663277
+ },
+ {
+ "top_left_x": 0.19925308,
+ "top_left_y": 0.19925308,
+ "top_right_x": 0.19925308,
+ "top_right_y": 0.19925308,
+ "bottom_right_x": 0.39850616,
+ "bottom_right_y": 0.39850616,
+ "bottom_left_x": 0.39850616,
+ "bottom_left_y": 0.39850616
+ },
+ {
+ "top_left_x": 0.14470005,
+ "top_left_y": 0.14470005,
+ "top_right_x": 0.14470005,
+ "top_right_y": 0.14470005,
+ "bottom_right_x": 0.2894001,
+ "bottom_right_y": 0.2894001,
+ "bottom_left_x": 0.2894001,
+ "bottom_left_y": 0.2894001
+ },
+ {
+ "top_left_x": 0.10470486,
+ "top_left_y": 0.10470486,
+ "top_right_x": 0.10470486,
+ "top_right_y": 0.10470486,
+ "bottom_right_x": 0.20940971,
+ "bottom_right_y": 0.20940971,
+ "bottom_left_x": 0.20940971,
+ "bottom_left_y": 0.20940971
+ },
+ {
+ "top_left_x": 0.07550812,
+ "top_left_y": 0.07550812,
+ "top_right_x": 0.07550812,
+ "top_right_y": 0.07550812,
+ "bottom_right_x": 0.15101624,
+ "bottom_right_y": 0.15101624,
+ "bottom_left_x": 0.15101624,
+ "bottom_left_y": 0.15101624
+ }
+ ]
+ },
+ {
+ "name": "alpha",
+ "type": "int",
+ "data_points": [
+ 0,
+ 45,
+ 126,
+ 190,
+ 228,
+ 246,
+ 253,
+ 255,
+ 255,
+ 255,
+ 249,
+ 226,
+ 192,
+ 153,
+ 112,
+ 72,
+ 34,
+ 0,
+ 0,
+ 0
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/SystemUI/tests/src/com/android/systemui/animation/TransitionAnimatorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/animation/TransitionAnimatorTest.kt
index 762cfa0..8b427fb 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/animation/TransitionAnimatorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/animation/TransitionAnimatorTest.kt
@@ -16,43 +16,44 @@
package com.android.systemui.animation
-import android.animation.AnimatorSet
+import android.animation.AnimatorRuleRecordingSpec
+import android.animation.AnimatorTestRuleToolkit
+import android.animation.MotionControl
+import android.animation.recordMotion
import android.graphics.drawable.GradientDrawable
import android.platform.test.annotations.MotionTest
import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.test.ext.junit.rules.ActivityScenarioRule
-import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
+import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
import com.android.systemui.SysuiTestCase
import com.android.systemui.activity.EmptyTestActivity
import com.android.systemui.concurrency.fakeExecutor
import com.android.systemui.kosmos.Kosmos
+import com.android.systemui.kosmos.testScope
+import kotlin.test.assertTrue
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import platform.test.motion.MotionTestRule
import platform.test.motion.RecordedMotion
-import platform.test.motion.view.AnimationSampling.Companion.evenlySampled
import platform.test.motion.view.DrawableFeatureCaptures
-import platform.test.motion.view.ViewRecordingSpec.Companion.captureWithoutScreenshot
-import platform.test.motion.view.ViewToolkit
-import platform.test.motion.view.record
-import platform.test.screenshot.DeviceEmulationRule
-import platform.test.screenshot.DeviceEmulationSpec
-import platform.test.screenshot.DisplaySpec
+import platform.test.runner.parameterized.ParameterizedAndroidJunit4
+import platform.test.runner.parameterized.Parameters
import platform.test.screenshot.GoldenPathManager
import platform.test.screenshot.PathConfig
@SmallTest
@MotionTest
-@RunWith(AndroidJUnit4::class)
-class TransitionAnimatorTest : SysuiTestCase() {
+@RunWith(ParameterizedAndroidJunit4::class)
+class TransitionAnimatorTest(val useSpring: Boolean) : SysuiTestCase() {
companion object {
private const val GOLDENS_PATH = "frameworks/base/packages/SystemUI/tests/goldens"
- private val emulationSpec =
- DeviceEmulationSpec(DisplaySpec("phone", width = 320, height = 690, densityDpi = 160))
+ @get:Parameters(name = "{0}")
+ @JvmStatic
+ val useSpringValues = booleanArrayOf(false, true).toList()
}
private val kosmos = Kosmos()
@@ -62,31 +63,50 @@
kosmos.fakeExecutor,
ActivityTransitionAnimator.TIMINGS,
ActivityTransitionAnimator.INTERPOLATORS,
+ ActivityTransitionAnimator.SPRING_TIMINGS,
+ ActivityTransitionAnimator.SPRING_INTERPOLATORS,
)
+ private val withSpring =
+ if (useSpring) {
+ "_withSpring"
+ } else {
+ ""
+ }
- @get:Rule(order = 0) val deviceEmulationRule = DeviceEmulationRule(emulationSpec)
@get:Rule(order = 1) val activityRule = ActivityScenarioRule(EmptyTestActivity::class.java)
- @get:Rule(order = 2)
- val motionRule = MotionTestRule(ViewToolkit { activityRule.scenario }, pathManager)
+ @get:Rule(order = 2) val animatorTestRule = android.animation.AnimatorTestRule(this)
+ @get:Rule(order = 3)
+ val motionRule =
+ MotionTestRule(AnimatorTestRuleToolkit(animatorTestRule, kosmos.testScope), pathManager)
@Test
fun backgroundAnimation_whenLaunching() {
val backgroundLayer = GradientDrawable().apply { alpha = 0 }
- val animator = setUpTest(backgroundLayer, isLaunching = true)
+ val animator =
+ setUpTest(backgroundLayer, isLaunching = true).apply {
+ getInstrumentation().runOnMainSync { start() }
+ }
val recordedMotion = recordMotion(backgroundLayer, animator)
- motionRule.assertThat(recordedMotion).timeSeriesMatchesGolden()
+ motionRule
+ .assertThat(recordedMotion)
+ .timeSeriesMatchesGolden("backgroundAnimation_whenLaunching$withSpring")
}
@Test
fun backgroundAnimation_whenReturning() {
val backgroundLayer = GradientDrawable().apply { alpha = 0 }
- val animator = setUpTest(backgroundLayer, isLaunching = false)
+ val animator =
+ setUpTest(backgroundLayer, isLaunching = false).apply {
+ getInstrumentation().runOnMainSync { start() }
+ }
val recordedMotion = recordMotion(backgroundLayer, animator)
- motionRule.assertThat(recordedMotion).timeSeriesMatchesGolden()
+ motionRule
+ .assertThat(recordedMotion)
+ .timeSeriesMatchesGolden("backgroundAnimation_whenReturning$withSpring")
}
@Test
@@ -94,10 +114,13 @@
val backgroundLayer = GradientDrawable().apply { alpha = 0 }
val animator =
setUpTest(backgroundLayer, isLaunching = true, fadeWindowBackgroundLayer = false)
+ .apply { getInstrumentation().runOnMainSync { start() } }
val recordedMotion = recordMotion(backgroundLayer, animator)
- motionRule.assertThat(recordedMotion).timeSeriesMatchesGolden()
+ motionRule
+ .assertThat(recordedMotion)
+ .timeSeriesMatchesGolden("backgroundAnimationWithoutFade_whenLaunching$withSpring")
}
@Test
@@ -105,17 +128,20 @@
val backgroundLayer = GradientDrawable().apply { alpha = 0 }
val animator =
setUpTest(backgroundLayer, isLaunching = false, fadeWindowBackgroundLayer = false)
+ .apply { getInstrumentation().runOnMainSync { start() } }
val recordedMotion = recordMotion(backgroundLayer, animator)
- motionRule.assertThat(recordedMotion).timeSeriesMatchesGolden()
+ motionRule
+ .assertThat(recordedMotion)
+ .timeSeriesMatchesGolden("backgroundAnimationWithoutFade_whenReturning$withSpring")
}
private fun setUpTest(
backgroundLayer: GradientDrawable,
isLaunching: Boolean,
fadeWindowBackgroundLayer: Boolean = true,
- ): AnimatorSet {
+ ): TransitionAnimator.Animation {
lateinit var transitionContainer: ViewGroup
activityRule.scenario.onActivity { activity ->
transitionContainer = FrameLayout(activity).apply { setBackgroundColor(0x00FF00) }
@@ -124,18 +150,14 @@
waitForIdleSync()
val controller = TestController(transitionContainer, isLaunching)
- val animation =
- transitionAnimator.createAnimation(
- controller,
- controller.createAnimatorState(),
- createEndState(transitionContainer),
- backgroundLayer,
- fadeWindowBackgroundLayer,
- ) as TransitionAnimator.InterpolatedAnimation
- return AnimatorSet().apply {
- duration = animation.animator.duration
- play(animation.animator)
- }
+ return transitionAnimator.createAnimation(
+ controller,
+ controller.createAnimatorState(),
+ createEndState(transitionContainer),
+ backgroundLayer,
+ fadeWindowBackgroundLayer,
+ useSpring,
+ )
}
private fun createEndState(container: ViewGroup): TransitionAnimator.State {
@@ -144,8 +166,8 @@
return TransitionAnimator.State(
left = containerLocation[0],
top = containerLocation[1],
- right = containerLocation[0] + emulationSpec.display.width,
- bottom = containerLocation[1] + emulationSpec.display.height,
+ right = containerLocation[0] + 320,
+ bottom = containerLocation[1] + 690,
topCornerRadius = 0f,
bottomCornerRadius = 0f,
)
@@ -153,16 +175,35 @@
private fun recordMotion(
backgroundLayer: GradientDrawable,
- animator: AnimatorSet,
+ animation: TransitionAnimator.Animation,
): RecordedMotion {
- return motionRule.record(
- animator,
- backgroundLayer.captureWithoutScreenshot(evenlySampled(20)) {
- feature(DrawableFeatureCaptures.bounds, "bounds")
- feature(DrawableFeatureCaptures.cornerRadii, "corner_radii")
- feature(DrawableFeatureCaptures.alpha, "alpha")
- },
- )
+ fun record(motionControl: MotionControl, sampleIntervalMs: Long): RecordedMotion {
+ return motionRule.recordMotion(
+ AnimatorRuleRecordingSpec(backgroundLayer, motionControl, sampleIntervalMs) {
+ feature(DrawableFeatureCaptures.bounds, "bounds")
+ feature(DrawableFeatureCaptures.cornerRadii, "corner_radii")
+ feature(DrawableFeatureCaptures.alpha, "alpha")
+ }
+ )
+ }
+
+ val motionControl: MotionControl
+ val sampleIntervalMs: Long
+ if (useSpring) {
+ assertTrue { animation is TransitionAnimator.MultiSpringAnimation }
+ motionControl = MotionControl {
+ awaitCondition { (animation as TransitionAnimator.MultiSpringAnimation).isDone }
+ }
+ sampleIntervalMs = 16L
+ } else {
+ assertTrue { animation is TransitionAnimator.InterpolatedAnimation }
+ motionControl = MotionControl { awaitFrames(count = 26) }
+ sampleIntervalMs = 20L
+ }
+
+ var recording: RecordedMotion? = null
+ getInstrumentation().runOnMainSync { recording = record(motionControl, sampleIntervalMs) }
+ return recording!!
}
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/AuthContainerViewTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.kt
similarity index 100%
rename from packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/AuthContainerViewTest.kt
rename to packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.kt
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/UdfpsViewTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsViewTest.kt
similarity index 100%
rename from packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/UdfpsViewTest.kt
rename to packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsViewTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingButtonViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingButtonViewModelTest.kt
new file mode 100644
index 0000000..655b2cc
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingButtonViewModelTest.kt
@@ -0,0 +1,185 @@
+/*
+ * 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.bluetooth.qsdialog
+
+import android.testing.TestableLooper
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.SmallTest
+import com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession
+import com.android.dx.mockito.inline.extended.StaticMockitoSession
+import com.android.settingslib.bluetooth.BluetoothUtils
+import com.android.settingslib.bluetooth.CachedBluetoothDevice
+import com.android.settingslib.bluetooth.LocalBluetoothManager
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.coroutines.collectLastValue
+import com.android.systemui.kosmos.testScope
+import com.android.systemui.lifecycle.activateIn
+import com.android.systemui.res.R
+import com.android.systemui.testKosmos
+import com.android.systemui.util.mockito.whenever
+import com.google.common.truth.Truth.assertThat
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.flow.MutableSharedFlow
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.test.runCurrent
+import kotlinx.coroutines.test.runTest
+import org.junit.After
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.Mock
+
+@ExperimentalCoroutinesApi
+@SmallTest
+@RunWith(AndroidJUnit4::class)
+@TestableLooper.RunWithLooper(setAsMainLooper = true)
+class AudioSharingButtonViewModelTest : SysuiTestCase() {
+ private val kosmos = testKosmos()
+ private val testScope = kosmos.testScope
+ private val bluetoothState = MutableStateFlow(false)
+ private val deviceItemUpdate: MutableSharedFlow<List<DeviceItem>> = MutableSharedFlow()
+ @Mock private lateinit var cachedBluetoothDevice: CachedBluetoothDevice
+ @Mock private lateinit var localBluetoothManager: LocalBluetoothManager
+ @Mock private lateinit var bluetoothStateInteractor: BluetoothStateInteractor
+ @Mock private lateinit var deviceItemInteractor: DeviceItemInteractor
+ @Mock private lateinit var deviceItem: DeviceItem
+ private lateinit var mockitoSession: StaticMockitoSession
+ private lateinit var audioSharingButtonViewModel: AudioSharingButtonViewModel
+
+ @Before
+ fun setUp() {
+ mockitoSession =
+ mockitoSession().initMocks(this).mockStatic(BluetoothUtils::class.java).startMocking()
+ whenever(bluetoothStateInteractor.bluetoothStateUpdate).thenReturn(bluetoothState)
+ whenever(deviceItemInteractor.deviceItemUpdate).thenReturn(deviceItemUpdate)
+ audioSharingButtonViewModel =
+ AudioSharingButtonViewModel(
+ localBluetoothManager,
+ kosmos.audioSharingInteractor,
+ bluetoothStateInteractor,
+ deviceItemInteractor,
+ )
+ audioSharingButtonViewModel.activateIn(testScope)
+ }
+
+ @After
+ fun tearDown() {
+ mockitoSession.finishMocking()
+ }
+
+ @Test
+ fun testButtonStateUpdate_bluetoothOff_returnGone() {
+ testScope.runTest {
+ val actual by
+ collectLastValue(audioSharingButtonViewModel.audioSharingButtonStateUpdate)
+ kosmos.bluetoothTileDialogAudioSharingRepository.setAudioSharingAvailable(true)
+
+ runCurrent()
+
+ assertThat(actual).isEqualTo(AudioSharingButtonState.Gone)
+ }
+ }
+
+ @Test
+ fun testButtonStateUpdate_noDevice_returnGone() {
+ testScope.runTest {
+ val actual by
+ collectLastValue(audioSharingButtonViewModel.audioSharingButtonStateUpdate)
+ kosmos.bluetoothTileDialogAudioSharingRepository.setAudioSharingAvailable(true)
+ bluetoothState.value = true
+ runCurrent()
+
+ assertThat(actual).isEqualTo(AudioSharingButtonState.Gone)
+ }
+ }
+
+ @Test
+ fun testButtonStateUpdate_isBroadcasting_returnSharingAudio() {
+ testScope.runTest {
+ val actual by
+ collectLastValue(audioSharingButtonViewModel.audioSharingButtonStateUpdate)
+ kosmos.bluetoothTileDialogAudioSharingRepository.setAudioSharingAvailable(true)
+ bluetoothState.value = true
+ runCurrent()
+ deviceItemUpdate.emit(listOf())
+ runCurrent()
+ kosmos.bluetoothTileDialogAudioSharingRepository.setInAudioSharing(true)
+ runCurrent()
+
+ assertThat(actual)
+ .isEqualTo(
+ AudioSharingButtonState.Visible(
+ R.string.quick_settings_bluetooth_audio_sharing_button_sharing,
+ isActive = true,
+ )
+ )
+ }
+ }
+
+ @Test
+ fun testButtonStateUpdate_hasSource_returnGone() {
+ testScope.runTest {
+ val actual by
+ collectLastValue(audioSharingButtonViewModel.audioSharingButtonStateUpdate)
+ kosmos.bluetoothTileDialogAudioSharingRepository.setAudioSharingAvailable(true)
+ whenever(deviceItem.cachedBluetoothDevice).thenReturn(cachedBluetoothDevice)
+ whenever(
+ BluetoothUtils.hasConnectedBroadcastSource(
+ cachedBluetoothDevice,
+ localBluetoothManager,
+ )
+ )
+ .thenReturn(true)
+ bluetoothState.value = true
+ runCurrent()
+ deviceItemUpdate.emit(listOf(deviceItem))
+ runCurrent()
+
+ assertThat(actual).isEqualTo(AudioSharingButtonState.Gone)
+ }
+ }
+
+ @Test
+ fun testButtonStateUpdate_hasActiveDevice_returnAudioSharing() {
+ testScope.runTest {
+ val actual by
+ collectLastValue(audioSharingButtonViewModel.audioSharingButtonStateUpdate)
+ kosmos.bluetoothTileDialogAudioSharingRepository.setAudioSharingAvailable(true)
+ whenever(deviceItem.cachedBluetoothDevice).thenReturn(cachedBluetoothDevice)
+ whenever(
+ BluetoothUtils.hasConnectedBroadcastSource(
+ cachedBluetoothDevice,
+ localBluetoothManager,
+ )
+ )
+ .thenReturn(false)
+ whenever(BluetoothUtils.isActiveLeAudioDevice(cachedBluetoothDevice)).thenReturn(true)
+ bluetoothState.value = true
+ runCurrent()
+ deviceItemUpdate.emit(listOf(deviceItem))
+ runCurrent()
+
+ assertThat(actual)
+ .isEqualTo(
+ AudioSharingButtonState.Visible(
+ R.string.quick_settings_bluetooth_audio_sharing_button,
+ isActive = false,
+ )
+ )
+ }
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDeviceItemActionInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDeviceItemActionInteractorTest.kt
new file mode 100644
index 0000000..ce37eee
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDeviceItemActionInteractorTest.kt
@@ -0,0 +1,193 @@
+/*
+ * 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.bluetooth.qsdialog
+
+import android.bluetooth.BluetoothDevice
+import android.platform.test.annotations.DisableFlags
+import android.platform.test.annotations.EnableFlags
+import android.testing.AndroidTestingRunner
+import android.testing.TestableLooper
+import androidx.test.filters.SmallTest
+import com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession
+import com.android.dx.mockito.inline.extended.StaticMockitoSession
+import com.android.settingslib.bluetooth.BluetoothUtils
+import com.android.settingslib.bluetooth.LeAudioProfile
+import com.android.settingslib.flags.Flags
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.kosmos.testDispatcher
+import com.android.systemui.kosmos.testScope
+import com.android.systemui.plugins.activityStarter
+import com.android.systemui.statusbar.phone.SystemUIDialog
+import com.android.systemui.testKosmos
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.test.UnconfinedTestDispatcher
+import kotlinx.coroutines.test.runTest
+import org.junit.After
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.ArgumentMatchers
+import org.mockito.ArgumentMatchers.anyBoolean
+import org.mockito.Mock
+import org.mockito.Mockito
+import org.mockito.Mockito.verify
+import org.mockito.junit.MockitoJUnit
+import org.mockito.junit.MockitoRule
+import org.mockito.kotlin.any
+import org.mockito.kotlin.eq
+import org.mockito.kotlin.never
+import org.mockito.kotlin.whenever
+
+@SmallTest
+@RunWith(AndroidTestingRunner::class)
+@TestableLooper.RunWithLooper(setAsMainLooper = true)
+@OptIn(ExperimentalCoroutinesApi::class)
+class AudioSharingDeviceItemActionInteractorTest : SysuiTestCase() {
+ @get:Rule val mockitoRule: MockitoRule = MockitoJUnit.rule()
+ private val kosmos = testKosmos().apply { testDispatcher = UnconfinedTestDispatcher() }
+ private lateinit var actionInteractorImpl: DeviceItemActionInteractor
+ private lateinit var mockitoSession: StaticMockitoSession
+ private lateinit var connectedAudioSharingMediaDeviceItem: DeviceItem
+ private lateinit var connectedMediaDeviceItem: DeviceItem
+ @Mock private lateinit var dialog: SystemUIDialog
+ @Mock private lateinit var leAudioProfile: LeAudioProfile
+ @Mock private lateinit var bluetoothDevice: BluetoothDevice
+
+ @Before
+ fun setUp() {
+ mockitoSession =
+ mockitoSession().initMocks(this).mockStatic(BluetoothUtils::class.java).startMocking()
+ connectedMediaDeviceItem =
+ DeviceItem(
+ type = DeviceItemType.AVAILABLE_MEDIA_BLUETOOTH_DEVICE,
+ cachedBluetoothDevice = kosmos.cachedBluetoothDevice,
+ deviceName = DEVICE_NAME,
+ connectionSummary = DEVICE_CONNECTION_SUMMARY,
+ iconWithDescription = null,
+ background = null,
+ )
+ connectedAudioSharingMediaDeviceItem =
+ DeviceItem(
+ type = DeviceItemType.AVAILABLE_AUDIO_SHARING_MEDIA_BLUETOOTH_DEVICE,
+ cachedBluetoothDevice = kosmos.cachedBluetoothDevice,
+ deviceName = DEVICE_NAME,
+ connectionSummary = DEVICE_CONNECTION_SUMMARY,
+ iconWithDescription = null,
+ background = null,
+ )
+ actionInteractorImpl = kosmos.audioSharingDeviceItemActionInteractorImpl
+ }
+
+ @After
+ fun tearDown() {
+ mockitoSession.finishMocking()
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_AUDIO_SHARING_QS_DIALOG_IMPROVEMENT)
+ fun testOnClick_connectedAudioSharingMediaDevice_flagOn_createDialog() {
+ with(kosmos) {
+ testScope.runTest {
+ bluetoothTileDialogAudioSharingRepository.setAudioSharingAvailable(true)
+ actionInteractorImpl.onClick(connectedAudioSharingMediaDeviceItem, dialog)
+ verify(dialogTransitionAnimator)
+ .showFromDialog(any(), any(), eq(null), anyBoolean())
+ }
+ }
+ }
+
+ @Test
+ @DisableFlags(Flags.FLAG_AUDIO_SHARING_QS_DIALOG_IMPROVEMENT)
+ fun testOnClick_connectedAudioSharingMediaDevice_flagOff_shouldLaunchSettings() {
+ with(kosmos) {
+ testScope.runTest {
+ bluetoothTileDialogAudioSharingRepository.setAudioSharingAvailable(true)
+ whenever(cachedBluetoothDevice.device).thenReturn(bluetoothDevice)
+ actionInteractorImpl.onClick(connectedAudioSharingMediaDeviceItem, dialog)
+ verify(activityStarter)
+ .postStartActivityDismissingKeyguard(
+ ArgumentMatchers.any(),
+ ArgumentMatchers.anyInt(),
+ ArgumentMatchers.any(),
+ )
+ verify(dialogTransitionAnimator, never())
+ .showFromDialog(any(), any(), eq(null), anyBoolean())
+ }
+ }
+ }
+
+ @Test
+ fun testOnClick_inAudioSharing_clickedDeviceHasSource_shouldNotLaunchSettings() {
+ with(kosmos) {
+ testScope.runTest {
+ bluetoothTileDialogAudioSharingRepository.setAudioSharingAvailable(true)
+ whenever(cachedBluetoothDevice.uiAccessibleProfiles)
+ .thenReturn(listOf(leAudioProfile))
+ whenever(BluetoothUtils.isBroadcasting(ArgumentMatchers.any())).thenReturn(true)
+ whenever(
+ BluetoothUtils.hasConnectedBroadcastSource(
+ ArgumentMatchers.any(),
+ ArgumentMatchers.any(),
+ )
+ )
+ .thenReturn(true)
+
+ actionInteractorImpl.onClick(connectedMediaDeviceItem, dialog)
+ verify(activityStarter, Mockito.never())
+ .postStartActivityDismissingKeyguard(
+ ArgumentMatchers.any(),
+ ArgumentMatchers.anyInt(),
+ ArgumentMatchers.any(),
+ )
+ }
+ }
+ }
+
+ @Test
+ fun testOnClick_inAudioSharing_clickedDeviceNoSource_shouldLaunchSettings() {
+ with(kosmos) {
+ testScope.runTest {
+ bluetoothTileDialogAudioSharingRepository.setAudioSharingAvailable(true)
+ whenever(cachedBluetoothDevice.device).thenReturn(bluetoothDevice)
+ whenever(cachedBluetoothDevice.uiAccessibleProfiles)
+ .thenReturn(listOf(leAudioProfile))
+
+ whenever(BluetoothUtils.isBroadcasting(ArgumentMatchers.any())).thenReturn(true)
+ whenever(
+ BluetoothUtils.hasConnectedBroadcastSource(
+ ArgumentMatchers.any(),
+ ArgumentMatchers.any(),
+ )
+ )
+ .thenReturn(false)
+
+ actionInteractorImpl.onClick(connectedMediaDeviceItem, dialog)
+ verify(activityStarter)
+ .postStartActivityDismissingKeyguard(
+ ArgumentMatchers.any(),
+ ArgumentMatchers.anyInt(),
+ ArgumentMatchers.any(),
+ )
+ }
+ }
+ }
+
+ private companion object {
+ const val DEVICE_NAME = "device"
+ const val DEVICE_CONNECTION_SUMMARY = "active"
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDialogDelegateTest.kt b/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDialogDelegateTest.kt
new file mode 100644
index 0000000..25b85b5
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDialogDelegateTest.kt
@@ -0,0 +1,118 @@
+/*
+ * 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.bluetooth.qsdialog
+
+import android.testing.AndroidTestingRunner
+import android.testing.TestableLooper
+import android.widget.Button
+import android.widget.TextView
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.kosmos.testScope
+import com.android.systemui.res.R
+import com.android.systemui.statusbar.phone.SystemUIDialog
+import com.android.systemui.testKosmos
+import com.google.common.truth.Truth.assertThat
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.flow.MutableSharedFlow
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.test.runCurrent
+import kotlinx.coroutines.test.runTest
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.junit.MockitoJUnit
+import org.mockito.junit.MockitoRule
+import org.mockito.kotlin.spy
+import org.mockito.kotlin.verify
+import org.mockito.kotlin.whenever
+
+@SmallTest
+@RunWith(AndroidTestingRunner::class)
+@TestableLooper.RunWithLooper(setAsMainLooper = true)
+@OptIn(ExperimentalCoroutinesApi::class)
+class AudioSharingDialogDelegateTest : SysuiTestCase() {
+ @get:Rule val mockitoRule: MockitoRule = MockitoJUnit.rule()
+ private val kosmos = testKosmos()
+ private val updateFlow = MutableSharedFlow<Unit>()
+ private lateinit var underTest: AudioSharingDialogDelegate
+
+ @Before
+ fun setUp() {
+ with(kosmos) {
+ // TODO(b/364515243): use real object instead of mock
+ whenever(deviceItemInteractor.deviceItemUpdateRequest).thenReturn(updateFlow)
+ whenever(deviceItemInteractor.deviceItemUpdate)
+ .thenReturn(MutableStateFlow(emptyList()))
+ underTest = audioSharingDialogDelegate
+ }
+ }
+
+ @Test
+ fun testCreateDialog() =
+ kosmos.testScope.runTest {
+ val dialog = underTest.createDialog()
+ assertThat(dialog).isInstanceOf(SystemUIDialog::class.java)
+ }
+
+ @Test
+ fun testCreateDialog_showState() =
+ with(kosmos) {
+ testScope.runTest {
+ val availableDeviceName = "name"
+ whenever(cachedBluetoothDevice.name).thenReturn(availableDeviceName)
+ val dialog = spy(underTest.createDialog())
+ dialog.show()
+ runCurrent()
+ val subtitleTextView = dialog.findViewById<TextView>(R.id.subtitle)
+ val switchActiveButton = dialog.findViewById<Button>(R.id.switch_active_button)
+ val shareAudioButton = dialog.findViewById<Button>(R.id.share_audio_button)
+ val subtitle =
+ context.getString(
+ R.string.quick_settings_bluetooth_audio_sharing_dialog_subtitle,
+ availableDeviceName,
+ ""
+ )
+ val switchButtonText =
+ context.getString(
+ R.string.quick_settings_bluetooth_audio_sharing_dialog_switch_to_button,
+ availableDeviceName
+ )
+ assertThat(subtitleTextView.text).isEqualTo(subtitle)
+ assertThat(switchActiveButton.text).isEqualTo(switchButtonText)
+ assertThat(switchActiveButton.hasOnClickListeners()).isTrue()
+ assertThat(shareAudioButton.hasOnClickListeners()).isTrue()
+
+ switchActiveButton.performClick()
+ verify(dialog).dismiss()
+ }
+ }
+
+ @Test
+ fun testCreateDialog_hideState() =
+ with(kosmos) {
+ testScope.runTest {
+ val dialog = spy(underTest.createDialog())
+ dialog.show()
+ runCurrent()
+ updateFlow.emit(Unit)
+ runCurrent()
+ verify(dialog).dismiss()
+ }
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDialogViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDialogViewModelTest.kt
new file mode 100644
index 0000000..beb816c
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDialogViewModelTest.kt
@@ -0,0 +1,142 @@
+/*
+ * 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.bluetooth.qsdialog
+
+import android.bluetooth.BluetoothDevice
+import android.testing.AndroidTestingRunner
+import android.testing.TestableLooper
+import androidx.test.filters.SmallTest
+import com.android.settingslib.bluetooth.LeAudioProfile
+import com.android.settingslib.bluetooth.LocalBluetoothProfileManager
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.bluetooth.cachedBluetoothDeviceManager
+import com.android.systemui.coroutines.collectLastValue
+import com.android.systemui.kosmos.testDispatcher
+import com.android.systemui.kosmos.testScope
+import com.android.systemui.res.R
+import com.android.systemui.testKosmos
+import com.google.common.truth.Truth.assertThat
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.flow.MutableSharedFlow
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.test.UnconfinedTestDispatcher
+import kotlinx.coroutines.test.runCurrent
+import kotlinx.coroutines.test.runTest
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.Mock
+import org.mockito.junit.MockitoJUnit
+import org.mockito.junit.MockitoRule
+import org.mockito.kotlin.any
+import org.mockito.kotlin.mock
+import org.mockito.kotlin.whenever
+
+@SmallTest
+@RunWith(AndroidTestingRunner::class)
+@TestableLooper.RunWithLooper(setAsMainLooper = true)
+@OptIn(ExperimentalCoroutinesApi::class)
+class AudioSharingDialogViewModelTest : SysuiTestCase() {
+ @get:Rule val mockitoRule: MockitoRule = MockitoJUnit.rule()
+ private val kosmos = testKosmos().apply { testDispatcher = UnconfinedTestDispatcher() }
+ @Mock private lateinit var profileManager: LocalBluetoothProfileManager
+ @Mock private lateinit var leAudioProfile: LeAudioProfile
+ private val updateFlow = MutableSharedFlow<Unit>()
+ private lateinit var underTest: AudioSharingDialogViewModel
+
+ @Before
+ fun setUp() {
+ with(kosmos) {
+ // TODO(b/364515243): use real object instead of mock
+ whenever(deviceItemInteractor.deviceItemUpdateRequest).thenReturn(updateFlow)
+ whenever(deviceItemInteractor.deviceItemUpdate)
+ .thenReturn(MutableStateFlow(emptyList()))
+ underTest = audioSharingDialogViewModel
+ }
+ }
+
+ @Test
+ fun testDialogState_show() =
+ with(kosmos) {
+ testScope.runTest {
+ val deviceName = "name"
+ whenever(cachedBluetoothDevice.name).thenReturn(deviceName)
+ val actual by collectLastValue(underTest.dialogState)
+ runCurrent()
+ assertThat(actual)
+ .isEqualTo(
+ AudioSharingDialogState.Show(
+ context.getString(
+ R.string.quick_settings_bluetooth_audio_sharing_dialog_subtitle,
+ deviceName,
+ ""
+ ),
+ context.getString(
+ R.string
+ .quick_settings_bluetooth_audio_sharing_dialog_switch_to_button,
+ deviceName
+ )
+ )
+ )
+ }
+ }
+
+ @Test
+ fun testDialogState_showWithActiveDeviceName() =
+ with(kosmos) {
+ testScope.runTest {
+ val deviceName = "name"
+ whenever(cachedBluetoothDevice.name).thenReturn(deviceName)
+ whenever(localBluetoothManager.profileManager).thenReturn(profileManager)
+ whenever(localBluetoothManager.cachedDeviceManager)
+ .thenReturn(cachedBluetoothDeviceManager)
+ whenever(profileManager.leAudioProfile).thenReturn(leAudioProfile)
+ whenever(leAudioProfile.activeDevices).thenReturn(listOf(mock<BluetoothDevice>()))
+ whenever(cachedBluetoothDeviceManager.findDevice(any()))
+ .thenReturn(cachedBluetoothDevice)
+ val actual by collectLastValue(underTest.dialogState)
+ runCurrent()
+ assertThat(actual)
+ .isEqualTo(
+ AudioSharingDialogState.Show(
+ context.getString(
+ R.string.quick_settings_bluetooth_audio_sharing_dialog_subtitle,
+ deviceName,
+ deviceName
+ ),
+ context.getString(
+ R.string
+ .quick_settings_bluetooth_audio_sharing_dialog_switch_to_button,
+ deviceName
+ )
+ )
+ )
+ }
+ }
+
+ @Test
+ fun testDialogState_hide() =
+ with(kosmos) {
+ testScope.runTest {
+ val actual by collectLastValue(underTest.dialogState)
+ runCurrent()
+ updateFlow.emit(Unit)
+ assertThat(actual).isEqualTo(AudioSharingDialogState.Hide)
+ }
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingInteractorTest.kt
index 2c53fd6..25f9565 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingInteractorTest.kt
@@ -16,158 +16,197 @@
package com.android.systemui.bluetooth.qsdialog
+import android.bluetooth.BluetoothLeBroadcast
import android.testing.TestableLooper
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
-import com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession
-import com.android.dx.mockito.inline.extended.StaticMockitoSession
-import com.android.settingslib.bluetooth.BluetoothUtils
-import com.android.settingslib.bluetooth.CachedBluetoothDevice
-import com.android.settingslib.bluetooth.LocalBluetoothManager
+import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectLastValue
-import com.android.systemui.res.R
-import com.android.systemui.util.mockito.whenever
+import com.android.systemui.kosmos.testScope
+import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.flow.MutableSharedFlow
-import kotlinx.coroutines.flow.MutableStateFlow
-import kotlinx.coroutines.test.TestScope
-import kotlinx.coroutines.test.UnconfinedTestDispatcher
+import kotlinx.coroutines.launch
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
-import org.junit.After
import org.junit.Before
+import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
import org.mockito.Mock
+import org.mockito.Mockito.verify
+import org.mockito.junit.MockitoJUnit
+import org.mockito.junit.MockitoRule
+import org.mockito.kotlin.any
-@ExperimentalCoroutinesApi
@SmallTest
@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
+@OptIn(ExperimentalCoroutinesApi::class)
class AudioSharingInteractorTest : SysuiTestCase() {
- private val testDispatcher = UnconfinedTestDispatcher()
- private val testScope = TestScope(testDispatcher)
- private val bluetoothState = MutableStateFlow(false)
- private val deviceItemUpdate: MutableSharedFlow<List<DeviceItem>> = MutableSharedFlow()
- @Mock private lateinit var cachedBluetoothDevice: CachedBluetoothDevice
- @Mock private lateinit var localBluetoothManager: LocalBluetoothManager
- @Mock private lateinit var bluetoothStateInteractor: BluetoothStateInteractor
- @Mock private lateinit var deviceItemInteractor: DeviceItemInteractor
- @Mock private lateinit var deviceItem: DeviceItem
- private lateinit var mockitoSession: StaticMockitoSession
- private lateinit var audioSharingInteractor: AudioSharingInteractor
+ @get:Rule val mockito: MockitoRule = MockitoJUnit.rule()
+ private val kosmos = testKosmos()
+ @Mock private lateinit var localBluetoothLeBroadcast: LocalBluetoothLeBroadcast
+ @Captor private lateinit var callbackCaptor: ArgumentCaptor<BluetoothLeBroadcast.Callback>
+ private lateinit var underTest: AudioSharingInteractor
@Before
fun setUp() {
- mockitoSession =
- mockitoSession().initMocks(this).mockStatic(BluetoothUtils::class.java).startMocking()
- whenever(bluetoothStateInteractor.bluetoothStateUpdate).thenReturn(bluetoothState)
- whenever(deviceItemInteractor.deviceItemUpdate).thenReturn(deviceItemUpdate)
- audioSharingInteractor =
- AudioSharingInteractor(
- localBluetoothManager,
- bluetoothStateInteractor,
- deviceItemInteractor,
- testScope.backgroundScope,
- testDispatcher,
- )
- }
-
- @After
- fun tearDown() {
- mockitoSession.finishMocking()
+ with(kosmos) { underTest = audioSharingInteractor }
}
@Test
- fun testButtonStateUpdate_bluetoothOff_returnGone() {
- testScope.runTest {
- val actual by collectLastValue(audioSharingInteractor.audioSharingButtonStateUpdate)
+ fun testIsAudioSharingOn_flagOff_false() =
+ with(kosmos) {
+ testScope.runTest {
+ bluetoothTileDialogAudioSharingRepository.setAudioSharingAvailable(false)
+ val value by collectLastValue(underTest.isAudioSharingOn)
+ runCurrent()
- assertThat(actual).isEqualTo(AudioSharingButtonState.Gone)
+ assertThat(value).isFalse()
+ }
}
- }
@Test
- fun testButtonStateUpdate_noDevice_returnGone() {
- testScope.runTest {
- val actual by collectLastValue(audioSharingInteractor.audioSharingButtonStateUpdate)
- bluetoothState.value = true
- runCurrent()
+ fun testIsAudioSharingOn_flagOn_notInAudioSharing_false() =
+ with(kosmos) {
+ testScope.runTest {
+ bluetoothTileDialogAudioSharingRepository.setAudioSharingAvailable(true)
+ bluetoothTileDialogAudioSharingRepository.setInAudioSharing(false)
+ val value by collectLastValue(underTest.isAudioSharingOn)
+ runCurrent()
- assertThat(actual).isEqualTo(AudioSharingButtonState.Gone)
+ assertThat(value).isFalse()
+ }
}
- }
@Test
- fun testButtonStateUpdate_isBroadcasting_returnSharingAudio() {
- testScope.runTest {
- whenever(BluetoothUtils.isBroadcasting(localBluetoothManager)).thenReturn(true)
+ fun testIsAudioSharingOn_flagOn_inAudioSharing_true() =
+ with(kosmos) {
+ testScope.runTest {
+ bluetoothTileDialogAudioSharingRepository.setAudioSharingAvailable(true)
+ bluetoothTileDialogAudioSharingRepository.setInAudioSharing(true)
+ val value by collectLastValue(underTest.isAudioSharingOn)
+ runCurrent()
- val actual by collectLastValue(audioSharingInteractor.audioSharingButtonStateUpdate)
- bluetoothState.value = true
- deviceItemUpdate.emit(listOf())
- runCurrent()
+ assertThat(value).isTrue()
+ }
+ }
- assertThat(actual)
- .isEqualTo(
- AudioSharingButtonState.Visible(
- R.string.quick_settings_bluetooth_audio_sharing_button_sharing,
- isActive = true
- )
+ @Test
+ fun testAudioSourceStateUpdate_notInAudioSharing_returnEmpty() =
+ with(kosmos) {
+ testScope.runTest {
+ bluetoothTileDialogAudioSharingRepository.setAudioSharingAvailable(true)
+ bluetoothTileDialogAudioSharingRepository.setInAudioSharing(false)
+ val value by collectLastValue(underTest.audioSourceStateUpdate)
+ runCurrent()
+
+ assertThat(value).isNull()
+ }
+ }
+
+ @Test
+ fun testAudioSourceStateUpdate_inAudioSharing_returnUnit() =
+ with(kosmos) {
+ testScope.runTest {
+ bluetoothTileDialogAudioSharingRepository.setAudioSharingAvailable(true)
+ bluetoothTileDialogAudioSharingRepository.setInAudioSharing(true)
+ val value by collectLastValue(underTest.audioSourceStateUpdate)
+ runCurrent()
+ bluetoothTileDialogAudioSharingRepository.emitAudioSourceStateUpdate()
+ runCurrent()
+
+ assertThat(value).isNull()
+ }
+ }
+
+ @Test
+ fun testHandleAudioSourceWhenReady_flagOff_sourceNotAdded() =
+ with(kosmos) {
+ testScope.runTest {
+ bluetoothTileDialogAudioSharingRepository.setAudioSharingAvailable(false)
+ val job = launch { underTest.handleAudioSourceWhenReady() }
+ runCurrent()
+
+ assertThat(bluetoothTileDialogAudioSharingRepository.sourceAdded).isFalse()
+ job.cancel()
+ }
+ }
+
+ @Test
+ fun testHandleAudioSourceWhenReady_noProfile_sourceNotAdded() =
+ with(kosmos) {
+ testScope.runTest {
+ bluetoothTileDialogAudioSharingRepository.setAudioSharingAvailable(true)
+ bluetoothTileDialogAudioSharingRepository.setLeAudioBroadcastProfile(null)
+ val job = launch { underTest.handleAudioSourceWhenReady() }
+ runCurrent()
+
+ assertThat(bluetoothTileDialogAudioSharingRepository.sourceAdded).isFalse()
+ job.cancel()
+ }
+ }
+
+ @Test
+ fun testHandleAudioSourceWhenReady_hasProfileButAudioSharingOff_sourceNotAdded() =
+ with(kosmos) {
+ testScope.runTest {
+ bluetoothTileDialogAudioSharingRepository.setInAudioSharing(false)
+ bluetoothTileDialogAudioSharingRepository.setAudioSharingAvailable(true)
+ bluetoothTileDialogAudioSharingRepository.setLeAudioBroadcastProfile(
+ localBluetoothLeBroadcast
)
+ val job = launch { underTest.handleAudioSourceWhenReady() }
+ runCurrent()
+
+ assertThat(bluetoothTileDialogAudioSharingRepository.sourceAdded).isFalse()
+ job.cancel()
+ }
}
- }
@Test
- fun testButtonStateUpdate_hasSource_returnGone() {
- testScope.runTest {
- whenever(BluetoothUtils.isBroadcasting(localBluetoothManager)).thenReturn(false)
- whenever(deviceItem.cachedBluetoothDevice).thenReturn(cachedBluetoothDevice)
- whenever(
- BluetoothUtils.hasConnectedBroadcastSource(
- cachedBluetoothDevice,
- localBluetoothManager
- )
+ fun testHandleAudioSourceWhenReady_audioSharingOnButNoPlayback_sourceNotAdded() =
+ with(kosmos) {
+ testScope.runTest {
+ bluetoothTileDialogAudioSharingRepository.setInAudioSharing(true)
+ bluetoothTileDialogAudioSharingRepository.setAudioSharingAvailable(true)
+ bluetoothTileDialogAudioSharingRepository.setLeAudioBroadcastProfile(
+ localBluetoothLeBroadcast
)
- .thenReturn(true)
+ val job = launch { underTest.handleAudioSourceWhenReady() }
+ runCurrent()
+ verify(localBluetoothLeBroadcast)
+ .registerServiceCallBack(any(), callbackCaptor.capture())
+ runCurrent()
- val actual by collectLastValue(audioSharingInteractor.audioSharingButtonStateUpdate)
- bluetoothState.value = true
- deviceItemUpdate.emit(listOf(deviceItem))
- runCurrent()
-
- assertThat(actual).isEqualTo(AudioSharingButtonState.Gone)
+ assertThat(bluetoothTileDialogAudioSharingRepository.sourceAdded).isFalse()
+ job.cancel()
+ }
}
- }
@Test
- fun testButtonStateUpdate_hasActiveDevice_returnAudioSharing() {
- testScope.runTest {
- whenever(BluetoothUtils.isBroadcasting(localBluetoothManager)).thenReturn(false)
- whenever(deviceItem.cachedBluetoothDevice).thenReturn(cachedBluetoothDevice)
- whenever(
- BluetoothUtils.hasConnectedBroadcastSource(
- cachedBluetoothDevice,
- localBluetoothManager
- )
+ fun testHandleAudioSourceWhenReady_audioSharingOnAndPlaybackStarts_sourceAdded() =
+ with(kosmos) {
+ testScope.runTest {
+ bluetoothTileDialogAudioSharingRepository.setInAudioSharing(true)
+ bluetoothTileDialogAudioSharingRepository.setAudioSharingAvailable(true)
+ bluetoothTileDialogAudioSharingRepository.setLeAudioBroadcastProfile(
+ localBluetoothLeBroadcast
)
- .thenReturn(false)
- whenever(BluetoothUtils.isActiveLeAudioDevice(cachedBluetoothDevice)).thenReturn(true)
+ val job = launch { underTest.handleAudioSourceWhenReady() }
+ runCurrent()
+ verify(localBluetoothLeBroadcast)
+ .registerServiceCallBack(any(), callbackCaptor.capture())
+ runCurrent()
+ callbackCaptor.value.onPlaybackStarted(0, 0)
+ runCurrent()
- val actual by collectLastValue(audioSharingInteractor.audioSharingButtonStateUpdate)
- bluetoothState.value = true
- deviceItemUpdate.emit(listOf(deviceItem))
- runCurrent()
-
- assertThat(actual)
- .isEqualTo(
- AudioSharingButtonState.Visible(
- R.string.quick_settings_bluetooth_audio_sharing_button,
- isActive = false
- )
- )
+ assertThat(bluetoothTileDialogAudioSharingRepository.sourceAdded).isTrue()
+ job.cancel()
+ }
}
- }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingRepositoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingRepositoryTest.kt
new file mode 100644
index 0000000..c9e8813
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingRepositoryTest.kt
@@ -0,0 +1,183 @@
+/*
+ * 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.bluetooth.qsdialog
+
+import android.bluetooth.BluetoothDevice
+import android.bluetooth.BluetoothLeBroadcastMetadata
+import android.testing.AndroidTestingRunner
+import android.testing.TestableLooper
+import androidx.test.filters.SmallTest
+import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast
+import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcastAssistant
+import com.android.settingslib.bluetooth.LocalBluetoothProfileManager
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.kosmos.testDispatcher
+import com.android.systemui.kosmos.testScope
+import com.android.systemui.testKosmos
+import com.android.systemui.volume.data.repository.audioSharingRepository
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.test.runCurrent
+import kotlinx.coroutines.test.runTest
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.ArgumentMatchers.anyBoolean
+import org.mockito.Mock
+import org.mockito.junit.MockitoJUnit
+import org.mockito.junit.MockitoRule
+import org.mockito.kotlin.any
+import org.mockito.kotlin.never
+import org.mockito.kotlin.verify
+import org.mockito.kotlin.whenever
+
+@ExperimentalCoroutinesApi
+@SmallTest
+@RunWith(AndroidTestingRunner::class)
+@TestableLooper.RunWithLooper(setAsMainLooper = true)
+class AudioSharingRepositoryTest : SysuiTestCase() {
+ @get:Rule val mockitoRule: MockitoRule = MockitoJUnit.rule()
+ @Mock private lateinit var profileManager: LocalBluetoothProfileManager
+ @Mock private lateinit var leAudioBroadcastProfile: LocalBluetoothLeBroadcast
+ @Mock private lateinit var leAudioBroadcastAssistant: LocalBluetoothLeBroadcastAssistant
+ @Mock private lateinit var metadata: BluetoothLeBroadcastMetadata
+ @Mock private lateinit var bluetoothDevice: BluetoothDevice
+ private val kosmos = testKosmos()
+ private lateinit var underTest: AudioSharingRepository
+
+ @Before
+ fun setUp() {
+ underTest =
+ AudioSharingRepositoryImpl(
+ kosmos.localBluetoothManager,
+ kosmos.audioSharingRepository,
+ kosmos.testDispatcher,
+ )
+ }
+
+ @Test
+ fun testSwitchActive() =
+ with(kosmos) {
+ testScope.runTest {
+ audioSharingRepository.setAudioSharingAvailable(true)
+ underTest.setActive(cachedBluetoothDevice)
+ verify(cachedBluetoothDevice).setActive()
+ }
+ }
+
+ @Test
+ fun testSwitchActive_flagOff_doNothing() =
+ with(kosmos) {
+ testScope.runTest {
+ audioSharingRepository.setAudioSharingAvailable(false)
+ underTest.setActive(cachedBluetoothDevice)
+ verify(cachedBluetoothDevice, never()).setActive()
+ }
+ }
+
+ @Test
+ fun testStartAudioSharing() =
+ with(kosmos) {
+ testScope.runTest {
+ whenever(localBluetoothManager.profileManager).thenReturn(profileManager)
+ whenever(profileManager.leAudioBroadcastProfile).thenReturn(leAudioBroadcastProfile)
+ audioSharingRepository.setAudioSharingAvailable(true)
+ underTest.startAudioSharing()
+ verify(leAudioBroadcastProfile).startPrivateBroadcast()
+ }
+ }
+
+ @Test
+ fun testStartAudioSharing_flagOff_doNothing() =
+ with(kosmos) {
+ testScope.runTest {
+ audioSharingRepository.setAudioSharingAvailable(false)
+ underTest.startAudioSharing()
+ verify(leAudioBroadcastProfile, never()).startPrivateBroadcast()
+ }
+ }
+
+ @Test
+ fun testAddSource_flagOff_doesNothing() =
+ with(kosmos) {
+ testScope.runTest {
+ audioSharingRepository.setAudioSharingAvailable(false)
+
+ underTest.addSource()
+ runCurrent()
+
+ verify(leAudioBroadcastAssistant, never()).allConnectedDevices
+ }
+ }
+
+ @Test
+ fun testAddSource_noMetadata_doesNothing() =
+ with(kosmos) {
+ testScope.runTest {
+ whenever(localBluetoothManager.profileManager).thenReturn(profileManager)
+ whenever(profileManager.leAudioBroadcastProfile).thenReturn(leAudioBroadcastProfile)
+ audioSharingRepository.setAudioSharingAvailable(true)
+ whenever(leAudioBroadcastProfile.latestBluetoothLeBroadcastMetadata)
+ .thenReturn(null)
+
+ underTest.addSource()
+ runCurrent()
+
+ verify(leAudioBroadcastAssistant, never()).allConnectedDevices
+ }
+ }
+
+ @Test
+ fun testAddSource_noConnectedDevice_doesNothing() =
+ with(kosmos) {
+ testScope.runTest {
+ whenever(localBluetoothManager.profileManager).thenReturn(profileManager)
+ whenever(profileManager.leAudioBroadcastProfile).thenReturn(leAudioBroadcastProfile)
+ whenever(profileManager.leAudioBroadcastAssistantProfile)
+ .thenReturn(leAudioBroadcastAssistant)
+ audioSharingRepository.setAudioSharingAvailable(true)
+ whenever(leAudioBroadcastProfile.latestBluetoothLeBroadcastMetadata)
+ .thenReturn(metadata)
+ whenever(leAudioBroadcastAssistant.allConnectedDevices).thenReturn(emptyList())
+
+ underTest.addSource()
+ runCurrent()
+
+ verify(leAudioBroadcastAssistant, never()).addSource(any(), any(), anyBoolean())
+ }
+ }
+
+ @Test
+ fun testAddSource_hasConnectedDeviceAndMetadata_addSource() =
+ with(kosmos) {
+ testScope.runTest {
+ whenever(localBluetoothManager.profileManager).thenReturn(profileManager)
+ whenever(profileManager.leAudioBroadcastProfile).thenReturn(leAudioBroadcastProfile)
+ whenever(profileManager.leAudioBroadcastAssistantProfile)
+ .thenReturn(leAudioBroadcastAssistant)
+ audioSharingRepository.setAudioSharingAvailable(true)
+ whenever(leAudioBroadcastProfile.latestBluetoothLeBroadcastMetadata)
+ .thenReturn(metadata)
+ whenever(leAudioBroadcastAssistant.allConnectedDevices)
+ .thenReturn(listOf(bluetoothDevice))
+
+ underTest.addSource()
+ runCurrent()
+
+ verify(leAudioBroadcastAssistant).addSource(bluetoothDevice, metadata, false)
+ }
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/BluetoothTileDialogViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/BluetoothTileDialogViewModelTest.kt
index d7bea66..a56c2cb 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/BluetoothTileDialogViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/BluetoothTileDialogViewModelTest.kt
@@ -31,8 +31,11 @@
import com.android.systemui.SysuiTestCase
import com.android.systemui.animation.DialogTransitionAnimator
import com.android.systemui.animation.Expandable
+import com.android.systemui.kosmos.testDispatcher
+import com.android.systemui.kosmos.testScope
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.statusbar.phone.SystemUIDialog
+import com.android.systemui.testKosmos
import com.android.systemui.util.FakeSharedPreferences
import com.android.systemui.util.concurrency.FakeExecutor
import com.android.systemui.util.kotlin.getMutableStateFlow
@@ -42,12 +45,12 @@
import com.android.systemui.util.time.FakeSystemClock
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.CoroutineDispatcher
+import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
-import kotlinx.coroutines.test.TestCoroutineScheduler
import kotlinx.coroutines.test.TestScope
-import kotlinx.coroutines.test.UnconfinedTestDispatcher
+import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Rule
@@ -64,10 +67,12 @@
@SmallTest
@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
+@OptIn(ExperimentalCoroutinesApi::class)
@EnableFlags(Flags.FLAG_BLUETOOTH_QS_TILE_DIALOG_AUTO_ON_TOGGLE)
class BluetoothTileDialogViewModelTest : SysuiTestCase() {
@get:Rule val mockitoRule: MockitoRule = MockitoJUnit.rule()
+ private val kosmos = testKosmos()
private val fakeSystemClock = FakeSystemClock()
private val backgroundExecutor = FakeExecutor(fakeSystemClock)
@@ -75,8 +80,6 @@
@Mock private lateinit var bluetoothStateInteractor: BluetoothStateInteractor
- @Mock private lateinit var audioSharingInteractor: AudioSharingInteractor
-
@Mock private lateinit var bluetoothDeviceMetadataInteractor: BluetoothDeviceMetadataInteractor
@Mock private lateinit var deviceItemInteractor: DeviceItemInteractor
@@ -111,15 +114,15 @@
private val sharedPreferences = FakeSharedPreferences()
- private lateinit var scheduler: TestCoroutineScheduler
private lateinit var dispatcher: CoroutineDispatcher
private lateinit var testScope: TestScope
@Before
fun setUp() {
- scheduler = TestCoroutineScheduler()
- dispatcher = UnconfinedTestDispatcher(scheduler)
- testScope = TestScope(dispatcher)
+ dispatcher = kosmos.testDispatcher
+ testScope = kosmos.testScope
+ // TODO(b/364515243): use real object instead of mock
+ whenever(kosmos.deviceItemInteractor.deviceItemUpdate).thenReturn(MutableSharedFlow())
bluetoothTileDialogViewModel =
BluetoothTileDialogViewModel(
deviceItemInteractor,
@@ -139,11 +142,13 @@
dispatcher
)
),
- audioSharingInteractor,
+ kosmos.audioSharingInteractor,
+ kosmos.audioSharingButtonViewModelFactory,
bluetoothDeviceMetadataInteractor,
mDialogTransitionAnimator,
activityStarter,
uiEventLogger,
+ bluetoothTileDialogLogger,
testScope.backgroundScope,
dispatcher,
dispatcher,
@@ -161,13 +166,10 @@
whenever(sysuiDialog.context).thenReturn(mContext)
whenever(bluetoothTileDialogDelegate.bluetoothStateToggle)
.thenReturn(getMutableStateFlow(false))
- whenever(bluetoothTileDialogDelegate.deviceItemClick)
- .thenReturn(getMutableStateFlow(deviceItem))
+ whenever(bluetoothTileDialogDelegate.deviceItemClick).thenReturn(MutableSharedFlow())
whenever(bluetoothTileDialogDelegate.contentHeight).thenReturn(getMutableStateFlow(0))
whenever(bluetoothTileDialogDelegate.bluetoothAutoOnToggle)
.thenReturn(getMutableStateFlow(false))
- whenever(audioSharingInteractor.audioSharingButtonStateUpdate)
- .thenReturn(getMutableStateFlow(AudioSharingButtonState.Gone))
whenever(expandable.dialogTransitionController(any())).thenReturn(controller)
}
@@ -175,6 +177,7 @@
fun testShowDialog_noAnimation() {
testScope.runTest {
bluetoothTileDialogViewModel.showDialog(null)
+ runCurrent()
verify(mDialogTransitionAnimator, never()).show(any(), any(), any())
}
@@ -184,6 +187,7 @@
fun testShowDialog_animated() {
testScope.runTest {
bluetoothTileDialogViewModel.showDialog(expandable)
+ runCurrent()
verify(mDialogTransitionAnimator).show(any(), any(), anyBoolean())
}
@@ -194,6 +198,7 @@
testScope.runTest {
backgroundExecutor.execute {
bluetoothTileDialogViewModel.showDialog(expandable)
+ runCurrent()
verify(mDialogTransitionAnimator).show(any(), any(), anyBoolean())
}
@@ -204,6 +209,7 @@
fun testShowDialog_fetchDeviceItem() {
testScope.runTest {
bluetoothTileDialogViewModel.showDialog(null)
+ runCurrent()
verify(deviceItemInteractor).deviceItemUpdate
}
@@ -214,6 +220,7 @@
testScope.runTest {
whenever(deviceItem.cachedBluetoothDevice).thenReturn(cachedBluetoothDevice)
bluetoothTileDialogViewModel.showDialog(null)
+ runCurrent()
val clickedView = View(context)
bluetoothTileDialogViewModel.onPairNewDeviceClicked(clickedView)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/DeviceItemActionInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/DeviceItemActionInteractorTest.kt
index 681ea75..9c427c6 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/DeviceItemActionInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/DeviceItemActionInteractorTest.kt
@@ -15,34 +15,22 @@
*/
package com.android.systemui.bluetooth.qsdialog
-import android.bluetooth.BluetoothDevice
import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import androidx.test.filters.SmallTest
-import com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession
-import com.android.dx.mockito.inline.extended.StaticMockitoSession
-import com.android.settingslib.bluetooth.BluetoothUtils
-import com.android.settingslib.bluetooth.CachedBluetoothDevice
-import com.android.settingslib.bluetooth.LeAudioProfile
-import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcastAssistant
-import com.android.settingslib.bluetooth.LocalBluetoothProfileManager
import com.android.systemui.SysuiTestCase
import com.android.systemui.kosmos.testDispatcher
import com.android.systemui.kosmos.testScope
-import com.android.systemui.plugins.activityStarter
import com.android.systemui.statusbar.phone.SystemUIDialog
import com.android.systemui.testKosmos
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.UnconfinedTestDispatcher
import kotlinx.coroutines.test.runTest
-import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
-import org.mockito.ArgumentMatchers
import org.mockito.Mock
-import org.mockito.Mockito
import org.mockito.Mockito.verify
import org.mockito.junit.MockitoJUnit
import org.mockito.junit.MockitoRule
@@ -56,28 +44,18 @@
@get:Rule val mockitoRule: MockitoRule = MockitoJUnit.rule()
private val kosmos = testKosmos().apply { testDispatcher = UnconfinedTestDispatcher() }
private lateinit var actionInteractorImpl: DeviceItemActionInteractor
- private lateinit var mockitoSession: StaticMockitoSession
private lateinit var activeMediaDeviceItem: DeviceItem
private lateinit var notConnectedDeviceItem: DeviceItem
- private lateinit var connectedAudioSharingMediaDeviceItem: DeviceItem
private lateinit var connectedMediaDeviceItem: DeviceItem
private lateinit var connectedOtherDeviceItem: DeviceItem
@Mock private lateinit var dialog: SystemUIDialog
- @Mock private lateinit var profileManager: LocalBluetoothProfileManager
- @Mock private lateinit var leAudioProfile: LeAudioProfile
- @Mock private lateinit var assistantProfile: LocalBluetoothLeBroadcastAssistant
- @Mock private lateinit var bluetoothDevice: BluetoothDevice
- @Mock private lateinit var bluetoothDeviceGroupId2: BluetoothDevice
- @Mock private lateinit var cachedBluetoothDevice: CachedBluetoothDevice
@Before
fun setUp() {
- mockitoSession =
- mockitoSession().initMocks(this).mockStatic(BluetoothUtils::class.java).startMocking()
activeMediaDeviceItem =
DeviceItem(
type = DeviceItemType.ACTIVE_MEDIA_BLUETOOTH_DEVICE,
- cachedBluetoothDevice = cachedBluetoothDevice,
+ cachedBluetoothDevice = kosmos.cachedBluetoothDevice,
deviceName = DEVICE_NAME,
connectionSummary = DEVICE_CONNECTION_SUMMARY,
iconWithDescription = null,
@@ -86,7 +64,7 @@
notConnectedDeviceItem =
DeviceItem(
type = DeviceItemType.SAVED_BLUETOOTH_DEVICE,
- cachedBluetoothDevice = cachedBluetoothDevice,
+ cachedBluetoothDevice = kosmos.cachedBluetoothDevice,
deviceName = DEVICE_NAME,
connectionSummary = DEVICE_CONNECTION_SUMMARY,
iconWithDescription = null,
@@ -95,16 +73,7 @@
connectedMediaDeviceItem =
DeviceItem(
type = DeviceItemType.AVAILABLE_MEDIA_BLUETOOTH_DEVICE,
- cachedBluetoothDevice = cachedBluetoothDevice,
- deviceName = DEVICE_NAME,
- connectionSummary = DEVICE_CONNECTION_SUMMARY,
- iconWithDescription = null,
- background = null
- )
- connectedAudioSharingMediaDeviceItem =
- DeviceItem(
- type = DeviceItemType.AVAILABLE_AUDIO_SHARING_MEDIA_BLUETOOTH_DEVICE,
- cachedBluetoothDevice = cachedBluetoothDevice,
+ cachedBluetoothDevice = kosmos.cachedBluetoothDevice,
deviceName = DEVICE_NAME,
connectionSummary = DEVICE_CONNECTION_SUMMARY,
iconWithDescription = null,
@@ -113,18 +82,13 @@
connectedOtherDeviceItem =
DeviceItem(
type = DeviceItemType.CONNECTED_BLUETOOTH_DEVICE,
- cachedBluetoothDevice = cachedBluetoothDevice,
+ cachedBluetoothDevice = kosmos.cachedBluetoothDevice,
deviceName = DEVICE_NAME,
connectionSummary = DEVICE_CONNECTION_SUMMARY,
iconWithDescription = null,
background = null
)
- actionInteractorImpl = kosmos.deviceItemActionInteractor
- }
-
- @After
- fun tearDown() {
- mockitoSession.finishMocking()
+ actionInteractorImpl = kosmos.deviceItemActionInteractorImpl
}
@Test
@@ -132,14 +96,8 @@
with(kosmos) {
testScope.runTest {
whenever(cachedBluetoothDevice.address).thenReturn(DEVICE_ADDRESS)
- whenever(BluetoothUtils.isAudioSharingEnabled()).thenReturn(false)
actionInteractorImpl.onClick(connectedMediaDeviceItem, dialog)
verify(cachedBluetoothDevice).setActive()
- verify(bluetoothTileDialogLogger)
- .logDeviceClick(
- cachedBluetoothDevice.address,
- DeviceItemType.AVAILABLE_MEDIA_BLUETOOTH_DEVICE
- )
}
}
}
@@ -149,14 +107,8 @@
with(kosmos) {
testScope.runTest {
whenever(cachedBluetoothDevice.address).thenReturn(DEVICE_ADDRESS)
- whenever(BluetoothUtils.isAudioSharingEnabled()).thenReturn(false)
actionInteractorImpl.onClick(activeMediaDeviceItem, dialog)
verify(cachedBluetoothDevice).disconnect()
- verify(bluetoothTileDialogLogger)
- .logDeviceClick(
- cachedBluetoothDevice.address,
- DeviceItemType.ACTIVE_MEDIA_BLUETOOTH_DEVICE
- )
}
}
}
@@ -166,14 +118,8 @@
with(kosmos) {
testScope.runTest {
whenever(cachedBluetoothDevice.address).thenReturn(DEVICE_ADDRESS)
- whenever(BluetoothUtils.isAudioSharingEnabled()).thenReturn(false)
actionInteractorImpl.onClick(connectedOtherDeviceItem, dialog)
verify(cachedBluetoothDevice).disconnect()
- verify(bluetoothTileDialogLogger)
- .logDeviceClick(
- cachedBluetoothDevice.address,
- DeviceItemType.CONNECTED_BLUETOOTH_DEVICE
- )
}
}
}
@@ -183,293 +129,8 @@
with(kosmos) {
testScope.runTest {
whenever(cachedBluetoothDevice.address).thenReturn(DEVICE_ADDRESS)
- whenever(BluetoothUtils.isAudioSharingEnabled()).thenReturn(false)
actionInteractorImpl.onClick(notConnectedDeviceItem, dialog)
verify(cachedBluetoothDevice).connect()
- verify(bluetoothTileDialogLogger)
- .logDeviceClick(
- cachedBluetoothDevice.address,
- DeviceItemType.SAVED_BLUETOOTH_DEVICE
- )
- }
- }
- }
-
- @Test
- fun testOnClick_connectedAudioSharingMediaDevice_logClick() {
- with(kosmos) {
- testScope.runTest {
- whenever(cachedBluetoothDevice.address).thenReturn(DEVICE_ADDRESS)
- actionInteractorImpl.onClick(connectedAudioSharingMediaDeviceItem, dialog)
- verify(bluetoothTileDialogLogger)
- .logDeviceClick(
- cachedBluetoothDevice.address,
- DeviceItemType.AVAILABLE_AUDIO_SHARING_MEDIA_BLUETOOTH_DEVICE
- )
- }
- }
- }
-
- @Test
- fun testOnClick_audioSharingDisabled_shouldNotLaunchSettings() {
- with(kosmos) {
- testScope.runTest {
- whenever(cachedBluetoothDevice.address).thenReturn(DEVICE_ADDRESS)
- whenever(BluetoothUtils.isAudioSharingEnabled()).thenReturn(false)
-
- actionInteractorImpl.onClick(connectedMediaDeviceItem, dialog)
- verify(activityStarter, Mockito.never())
- .postStartActivityDismissingKeyguard(
- ArgumentMatchers.any(),
- ArgumentMatchers.anyInt(),
- ArgumentMatchers.any()
- )
- }
- }
- }
-
- @Test
- fun testOnClick_inAudioSharing_clickedDeviceHasSource_shouldNotLaunchSettings() {
- with(kosmos) {
- testScope.runTest {
- whenever(cachedBluetoothDevice.address).thenReturn(DEVICE_ADDRESS)
- whenever(cachedBluetoothDevice.uiAccessibleProfiles)
- .thenReturn(listOf(leAudioProfile))
-
- whenever(BluetoothUtils.isAudioSharingEnabled()).thenReturn(true)
- whenever(localBluetoothManager.profileManager).thenReturn(profileManager)
- whenever(profileManager.leAudioProfile).thenReturn(leAudioProfile)
- whenever(profileManager.leAudioBroadcastAssistantProfile)
- .thenReturn(assistantProfile)
-
- whenever(BluetoothUtils.isBroadcasting(ArgumentMatchers.any())).thenReturn(true)
- whenever(
- BluetoothUtils.hasConnectedBroadcastSource(
- ArgumentMatchers.any(),
- ArgumentMatchers.any()
- )
- )
- .thenReturn(true)
-
- actionInteractorImpl.onClick(connectedMediaDeviceItem, dialog)
- verify(activityStarter, Mockito.never())
- .postStartActivityDismissingKeyguard(
- ArgumentMatchers.any(),
- ArgumentMatchers.anyInt(),
- ArgumentMatchers.any()
- )
- }
- }
- }
-
- @Test
- fun testOnClick_inAudioSharing_clickedDeviceNoSource_shouldLaunchSettings() {
- with(kosmos) {
- testScope.runTest {
- whenever(cachedBluetoothDevice.address).thenReturn(DEVICE_ADDRESS)
- whenever(cachedBluetoothDevice.device).thenReturn(bluetoothDevice)
- whenever(cachedBluetoothDevice.uiAccessibleProfiles)
- .thenReturn(listOf(leAudioProfile))
-
- whenever(BluetoothUtils.isAudioSharingEnabled()).thenReturn(true)
- whenever(localBluetoothManager.profileManager).thenReturn(profileManager)
- whenever(profileManager.leAudioProfile).thenReturn(leAudioProfile)
- whenever(profileManager.leAudioBroadcastAssistantProfile)
- .thenReturn(assistantProfile)
-
- whenever(BluetoothUtils.isBroadcasting(ArgumentMatchers.any())).thenReturn(true)
- whenever(
- BluetoothUtils.hasConnectedBroadcastSource(
- ArgumentMatchers.any(),
- ArgumentMatchers.any()
- )
- )
- .thenReturn(false)
-
- actionInteractorImpl.onClick(connectedMediaDeviceItem, dialog)
- verify(activityStarter)
- .postStartActivityDismissingKeyguard(
- ArgumentMatchers.any(),
- ArgumentMatchers.anyInt(),
- ArgumentMatchers.any()
- )
- }
- }
- }
-
- @Test
- fun testOnClick_noConnectedLeDevice_shouldNotLaunchSettings() {
- with(kosmos) {
- testScope.runTest {
- whenever(cachedBluetoothDevice.address).thenReturn(DEVICE_ADDRESS)
-
- whenever(BluetoothUtils.isAudioSharingEnabled()).thenReturn(true)
- whenever(localBluetoothManager.profileManager).thenReturn(profileManager)
- whenever(profileManager.leAudioProfile).thenReturn(leAudioProfile)
- whenever(profileManager.leAudioBroadcastAssistantProfile)
- .thenReturn(assistantProfile)
-
- actionInteractorImpl.onClick(notConnectedDeviceItem, dialog)
- verify(activityStarter, Mockito.never())
- .postStartActivityDismissingKeyguard(
- ArgumentMatchers.any(),
- ArgumentMatchers.anyInt(),
- ArgumentMatchers.any()
- )
- }
- }
- }
-
- @Test
- fun testOnClick_hasOneConnectedLeDevice_clickedNonLe_shouldNotLaunchSettings() {
- with(kosmos) {
- testScope.runTest {
- whenever(cachedBluetoothDevice.address).thenReturn(DEVICE_ADDRESS)
-
- whenever(BluetoothUtils.isAudioSharingEnabled()).thenReturn(true)
- whenever(localBluetoothManager.profileManager).thenReturn(profileManager)
- whenever(profileManager.leAudioProfile).thenReturn(leAudioProfile)
- whenever(profileManager.leAudioBroadcastAssistantProfile)
- .thenReturn(assistantProfile)
-
- whenever(
- assistantProfile.getDevicesMatchingConnectionStates(ArgumentMatchers.any())
- )
- .thenReturn(listOf(bluetoothDevice))
-
- actionInteractorImpl.onClick(notConnectedDeviceItem, dialog)
- verify(activityStarter, Mockito.never())
- .postStartActivityDismissingKeyguard(
- ArgumentMatchers.any(),
- ArgumentMatchers.anyInt(),
- ArgumentMatchers.any()
- )
- }
- }
- }
-
- @Test
- fun testOnClick_hasOneConnectedLeDevice_clickedLe_shouldLaunchSettings() {
- with(kosmos) {
- testScope.runTest {
- whenever(cachedBluetoothDevice.device).thenReturn(bluetoothDevice)
- whenever(cachedBluetoothDevice.address).thenReturn(DEVICE_ADDRESS)
- whenever(cachedBluetoothDevice.profiles).thenReturn(listOf(leAudioProfile))
- whenever(leAudioProfile.isEnabled(ArgumentMatchers.any())).thenReturn(true)
-
- whenever(BluetoothUtils.isAudioSharingEnabled()).thenReturn(true)
- whenever(localBluetoothManager.profileManager).thenReturn(profileManager)
- whenever(profileManager.leAudioProfile).thenReturn(leAudioProfile)
- whenever(profileManager.leAudioBroadcastAssistantProfile)
- .thenReturn(assistantProfile)
-
- whenever(
- assistantProfile.getDevicesMatchingConnectionStates(ArgumentMatchers.any())
- )
- .thenReturn(listOf(bluetoothDevice))
-
- actionInteractorImpl.onClick(notConnectedDeviceItem, dialog)
- verify(activityStarter)
- .postStartActivityDismissingKeyguard(
- ArgumentMatchers.any(),
- ArgumentMatchers.anyInt(),
- ArgumentMatchers.any()
- )
- }
- }
- }
-
- @Test
- fun testOnClick_hasOneConnectedLeDevice_clickedConnectedLe_shouldNotLaunchSettings() {
- with(kosmos) {
- testScope.runTest {
- whenever(cachedBluetoothDevice.address).thenReturn(DEVICE_ADDRESS)
-
- whenever(BluetoothUtils.isAudioSharingEnabled()).thenReturn(true)
- whenever(localBluetoothManager.profileManager).thenReturn(profileManager)
- whenever(profileManager.leAudioProfile).thenReturn(leAudioProfile)
- whenever(profileManager.leAudioBroadcastAssistantProfile)
- .thenReturn(assistantProfile)
-
- whenever(
- assistantProfile.getDevicesMatchingConnectionStates(ArgumentMatchers.any())
- )
- .thenReturn(listOf(bluetoothDevice))
-
- actionInteractorImpl.onClick(connectedMediaDeviceItem, dialog)
- verify(activityStarter, Mockito.never())
- .postStartActivityDismissingKeyguard(
- ArgumentMatchers.any(),
- ArgumentMatchers.anyInt(),
- ArgumentMatchers.any()
- )
- }
- }
- }
-
- @Test
- fun testOnClick_hasTwoConnectedLeDevice_clickedNotConnectedLe_shouldNotLaunchSettings() {
- with(kosmos) {
- testScope.runTest {
- whenever(cachedBluetoothDevice.address).thenReturn(DEVICE_ADDRESS)
-
- whenever(BluetoothUtils.isAudioSharingEnabled()).thenReturn(true)
- whenever(localBluetoothManager.profileManager).thenReturn(profileManager)
- whenever(profileManager.leAudioProfile).thenReturn(leAudioProfile)
- whenever(profileManager.leAudioBroadcastAssistantProfile)
- .thenReturn(assistantProfile)
-
- whenever(
- assistantProfile.getDevicesMatchingConnectionStates(ArgumentMatchers.any())
- )
- .thenReturn(listOf(bluetoothDevice, bluetoothDeviceGroupId2))
- whenever(leAudioProfile.getGroupId(ArgumentMatchers.any())).thenAnswer {
- val device = it.arguments.first() as BluetoothDevice
- if (device == bluetoothDevice) GROUP_ID_1 else GROUP_ID_2
- }
-
- actionInteractorImpl.onClick(notConnectedDeviceItem, dialog)
- verify(activityStarter, Mockito.never())
- .postStartActivityDismissingKeyguard(
- ArgumentMatchers.any(),
- ArgumentMatchers.anyInt(),
- ArgumentMatchers.any()
- )
- }
- }
- }
-
- @Test
- fun testOnClick_hasTwoConnectedLeDevice_clickedActiveLe_shouldLaunchSettings() {
- with(kosmos) {
- testScope.runTest {
- whenever(cachedBluetoothDevice.device).thenReturn(bluetoothDevice)
- whenever(cachedBluetoothDevice.address).thenReturn(DEVICE_ADDRESS)
- whenever(cachedBluetoothDevice.profiles).thenReturn(listOf(leAudioProfile))
- whenever(leAudioProfile.isEnabled(ArgumentMatchers.any())).thenReturn(true)
-
- whenever(BluetoothUtils.isAudioSharingEnabled()).thenReturn(true)
- whenever(localBluetoothManager.profileManager).thenReturn(profileManager)
- whenever(profileManager.leAudioProfile).thenReturn(leAudioProfile)
- whenever(profileManager.leAudioBroadcastAssistantProfile)
- .thenReturn(assistantProfile)
-
- whenever(
- assistantProfile.getDevicesMatchingConnectionStates(ArgumentMatchers.any())
- )
- .thenReturn(listOf(bluetoothDevice, bluetoothDeviceGroupId2))
- whenever(leAudioProfile.getGroupId(ArgumentMatchers.any())).thenAnswer {
- val device = it.arguments.first() as BluetoothDevice
- if (device == bluetoothDevice) GROUP_ID_1 else GROUP_ID_2
- }
-
- actionInteractorImpl.onClick(activeMediaDeviceItem, dialog)
- verify(activityStarter)
- .postStartActivityDismissingKeyguard(
- ArgumentMatchers.any(),
- ArgumentMatchers.anyInt(),
- ArgumentMatchers.any()
- )
}
}
}
@@ -478,7 +139,5 @@
const val DEVICE_NAME = "device"
const val DEVICE_CONNECTION_SUMMARY = "active"
const val DEVICE_ADDRESS = "address"
- const val GROUP_ID_1 = 1
- const val GROUP_ID_2 = 2
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/DeviceItemFactoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/DeviceItemFactoryTest.kt
index ef441c1..10c3457 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/DeviceItemFactoryTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/DeviceItemFactoryTest.kt
@@ -133,8 +133,8 @@
@Test
fun testAvailableAudioSharingMediaDeviceItemFactory_isFilterMatched_flagOff_returnsFalse() {
- // Flags.FLAG_ENABLE_LE_AUDIO_SHARING off or the device doesn't support broadcast
- // source or assistant.
+ // Flags.FLAG_ENABLE_LE_AUDIO_SHARING off or the device doesn't support broadcast
+ // source or assistant.
`when`(BluetoothUtils.isAudioSharingEnabled()).thenReturn(false)
assertThat(
@@ -145,9 +145,9 @@
}
@Test
- fun testAvailableAudioSharingMediaDeviceItemFactory_isFilterMatched_isActiveDevice_returnsFalse() {
- // Flags.FLAG_ENABLE_LE_AUDIO_SHARING on and the device support broadcast source and
- // assistant.
+ fun testAvailableAudioSharingMediaDeviceItemFactory_isFilterMatched_isActiveDevice_false() {
+ // Flags.FLAG_ENABLE_LE_AUDIO_SHARING on and the device support broadcast source and
+ // assistant.
`when`(BluetoothUtils.isAudioSharingEnabled()).thenReturn(true)
`when`(BluetoothUtils.isActiveMediaDevice(any())).thenReturn(true)
@@ -159,9 +159,9 @@
}
@Test
- fun testAvailableAudioSharingMediaDeviceItemFactory_isFilterMatched_isNotAvailable_returnsFalse() {
- // Flags.FLAG_ENABLE_LE_AUDIO_SHARING on and the device support broadcast source and
- // assistant.
+ fun testAvailableAudioSharingMediaDeviceItemFactory_isFilterMatched_isNotAvailable_false() {
+ // Flags.FLAG_ENABLE_LE_AUDIO_SHARING on and the device support broadcast source and
+ // assistant.
`when`(BluetoothUtils.isAudioSharingEnabled()).thenReturn(true)
`when`(BluetoothUtils.isActiveMediaDevice(any())).thenReturn(false)
`when`(BluetoothUtils.isAvailableMediaBluetoothDevice(any(), any())).thenReturn(true)
@@ -177,8 +177,8 @@
@Test
fun testAvailableAudioSharingMediaDeviceItemFactory_isFilterMatched_returnsTrue() {
- // Flags.FLAG_ENABLE_LE_AUDIO_SHARING on and the device support broadcast source and
- // assistant.
+ // Flags.FLAG_ENABLE_LE_AUDIO_SHARING on and the device support broadcast source and
+ // assistant.
`when`(BluetoothUtils.isAudioSharingEnabled()).thenReturn(true)
`when`(BluetoothUtils.isActiveMediaDevice(any())).thenReturn(false)
`when`(BluetoothUtils.isAvailableMediaBluetoothDevice(any(), any())).thenReturn(true)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/DeviceItemInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/DeviceItemInteractorTest.kt
index 194590c..c39b9a6 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/DeviceItemInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/DeviceItemInteractorTest.kt
@@ -83,18 +83,6 @@
fun setUp() {
dispatcher = UnconfinedTestDispatcher()
testScope = TestScope(dispatcher)
- interactor =
- DeviceItemInteractor(
- bluetoothTileDialogRepository,
- audioManager,
- adapter,
- localBluetoothManager,
- fakeSystemClock,
- logger,
- testScope.backgroundScope,
- dispatcher
- )
-
`when`(deviceItem1.cachedBluetoothDevice).thenReturn(cachedDevice1)
`when`(deviceItem2.cachedBluetoothDevice).thenReturn(cachedDevice2)
`when`(cachedDevice1.address).thenReturn("ADDRESS")
@@ -108,9 +96,19 @@
fun testUpdateDeviceItems_noCachedDevice_returnEmpty() {
testScope.runTest {
`when`(bluetoothTileDialogRepository.cachedDevices).thenReturn(emptyList())
- interactor.setDeviceItemFactoryListForTesting(
- listOf(createFactory({ true }, deviceItem1))
- )
+ interactor =
+ DeviceItemInteractor(
+ bluetoothTileDialogRepository,
+ audioManager,
+ adapter,
+ localBluetoothManager,
+ fakeSystemClock,
+ logger,
+ listOf(createFactory({ true }, deviceItem1)),
+ emptyList(),
+ testScope.backgroundScope,
+ dispatcher
+ )
val latest by collectLastValue(interactor.deviceItemUpdate)
val latestShowSeeAll by collectLastValue(interactor.showSeeAllUpdate)
@@ -125,9 +123,19 @@
fun testUpdateDeviceItems_hasCachedDevice_filterNotMatch_returnEmpty() {
testScope.runTest {
`when`(bluetoothTileDialogRepository.cachedDevices).thenReturn(listOf(cachedDevice1))
- interactor.setDeviceItemFactoryListForTesting(
- listOf(createFactory({ false }, deviceItem1))
- )
+ interactor =
+ DeviceItemInteractor(
+ bluetoothTileDialogRepository,
+ audioManager,
+ adapter,
+ localBluetoothManager,
+ fakeSystemClock,
+ logger,
+ listOf(createFactory({ false }, deviceItem1)),
+ emptyList(),
+ testScope.backgroundScope,
+ dispatcher
+ )
val latest by collectLastValue(interactor.deviceItemUpdate)
val latestShowSeeAll by collectLastValue(interactor.showSeeAllUpdate)
@@ -142,9 +150,19 @@
fun testUpdateDeviceItems_hasCachedDevice_filterMatch_returnDeviceItem() {
testScope.runTest {
`when`(bluetoothTileDialogRepository.cachedDevices).thenReturn(listOf(cachedDevice1))
- interactor.setDeviceItemFactoryListForTesting(
- listOf(createFactory({ true }, deviceItem1))
- )
+ interactor =
+ DeviceItemInteractor(
+ bluetoothTileDialogRepository,
+ audioManager,
+ adapter,
+ localBluetoothManager,
+ fakeSystemClock,
+ logger,
+ listOf(createFactory({ true }, deviceItem1)),
+ emptyList(),
+ testScope.backgroundScope,
+ dispatcher
+ )
val latest by collectLastValue(interactor.deviceItemUpdate)
val latestShowSeeAll by collectLastValue(interactor.showSeeAllUpdate)
@@ -159,9 +177,22 @@
fun testUpdateDeviceItems_hasCachedDevice_filterMatch_returnMultipleDeviceItem() {
testScope.runTest {
`when`(adapter.mostRecentlyConnectedDevices).thenReturn(null)
- interactor.setDeviceItemFactoryListForTesting(
- listOf(createFactory({ false }, deviceItem1), createFactory({ true }, deviceItem2))
- )
+ interactor =
+ DeviceItemInteractor(
+ bluetoothTileDialogRepository,
+ audioManager,
+ adapter,
+ localBluetoothManager,
+ fakeSystemClock,
+ logger,
+ listOf(
+ createFactory({ false }, deviceItem1),
+ createFactory({ true }, deviceItem2)
+ ),
+ emptyList(),
+ testScope.backgroundScope,
+ dispatcher
+ )
val latest by collectLastValue(interactor.deviceItemUpdate)
val latestShowSeeAll by collectLastValue(interactor.showSeeAllUpdate)
@@ -176,18 +207,31 @@
fun testUpdateDeviceItems_sortByDisplayPriority() {
testScope.runTest {
`when`(adapter.mostRecentlyConnectedDevices).thenReturn(null)
- interactor.setDeviceItemFactoryListForTesting(
- listOf(
- createFactory({ cachedDevice -> cachedDevice.device == device1 }, deviceItem1),
- createFactory({ cachedDevice -> cachedDevice.device == device2 }, deviceItem2)
+ interactor =
+ DeviceItemInteractor(
+ bluetoothTileDialogRepository,
+ audioManager,
+ adapter,
+ localBluetoothManager,
+ fakeSystemClock,
+ logger,
+ listOf(
+ createFactory(
+ { cachedDevice -> cachedDevice.device == device1 },
+ deviceItem1
+ ),
+ createFactory(
+ { cachedDevice -> cachedDevice.device == device2 },
+ deviceItem2
+ )
+ ),
+ listOf(
+ DeviceItemType.SAVED_BLUETOOTH_DEVICE,
+ DeviceItemType.CONNECTED_BLUETOOTH_DEVICE
+ ),
+ testScope.backgroundScope,
+ dispatcher
)
- )
- interactor.setDisplayPriorityForTesting(
- listOf(
- DeviceItemType.SAVED_BLUETOOTH_DEVICE,
- DeviceItemType.CONNECTED_BLUETOOTH_DEVICE
- )
- )
`when`(deviceItem1.type).thenReturn(DeviceItemType.CONNECTED_BLUETOOTH_DEVICE)
`when`(deviceItem2.type).thenReturn(DeviceItemType.SAVED_BLUETOOTH_DEVICE)
@@ -204,15 +248,28 @@
fun testUpdateDeviceItems_sameType_sortByRecentlyConnected() {
testScope.runTest {
`when`(adapter.mostRecentlyConnectedDevices).thenReturn(listOf(device2, device1))
- interactor.setDeviceItemFactoryListForTesting(
- listOf(
- createFactory({ cachedDevice -> cachedDevice.device == device1 }, deviceItem1),
- createFactory({ cachedDevice -> cachedDevice.device == device2 }, deviceItem2)
+ interactor =
+ DeviceItemInteractor(
+ bluetoothTileDialogRepository,
+ audioManager,
+ adapter,
+ localBluetoothManager,
+ fakeSystemClock,
+ logger,
+ listOf(
+ createFactory(
+ { cachedDevice -> cachedDevice.device == device1 },
+ deviceItem1
+ ),
+ createFactory(
+ { cachedDevice -> cachedDevice.device == device2 },
+ deviceItem2
+ )
+ ),
+ listOf(DeviceItemType.CONNECTED_BLUETOOTH_DEVICE),
+ testScope.backgroundScope,
+ dispatcher
)
- )
- interactor.setDisplayPriorityForTesting(
- listOf(DeviceItemType.CONNECTED_BLUETOOTH_DEVICE)
- )
`when`(deviceItem1.type).thenReturn(DeviceItemType.CONNECTED_BLUETOOTH_DEVICE)
`when`(deviceItem2.type).thenReturn(DeviceItemType.CONNECTED_BLUETOOTH_DEVICE)
@@ -231,10 +288,19 @@
`when`(bluetoothTileDialogRepository.cachedDevices)
.thenReturn(listOf(cachedDevice2, cachedDevice2, cachedDevice2, cachedDevice2))
`when`(adapter.mostRecentlyConnectedDevices).thenReturn(null)
- interactor.setDeviceItemFactoryListForTesting(
- listOf(createFactory({ true }, deviceItem2))
- )
-
+ interactor =
+ DeviceItemInteractor(
+ bluetoothTileDialogRepository,
+ audioManager,
+ adapter,
+ localBluetoothManager,
+ fakeSystemClock,
+ logger,
+ listOf(createFactory({ true }, deviceItem2)),
+ emptyList(),
+ testScope.backgroundScope,
+ dispatcher
+ )
val latest by collectLastValue(interactor.deviceItemUpdate)
val latestShowSeeAll by collectLastValue(interactor.showSeeAllUpdate)
interactor.updateDeviceItems(mContext, DeviceFetchTrigger.FIRST_LOAD)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/clipboardoverlay/ClipboardModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/clipboardoverlay/ClipboardModelTest.kt
index 85e8ab4..5741d64 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/clipboardoverlay/ClipboardModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/clipboardoverlay/ClipboardModelTest.kt
@@ -122,6 +122,7 @@
@Test
@Throws(IOException::class)
+ @DisableFlags(FLAG_CLIPBOARD_USE_DESCRIPTION_MIMETYPE)
fun test_imageClipData_loadFailure() {
whenever(mMockContext.contentResolver).thenReturn(mMockContentResolver)
whenever(mMockContext.resources).thenReturn(mContext.resources)
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/backup/CommunalBackupUtilsTest.kt b/packages/SystemUI/tests/src/com/android/systemui/communal/data/backup/CommunalBackupUtilsTest.kt
similarity index 100%
rename from packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/backup/CommunalBackupUtilsTest.kt
rename to packages/SystemUI/tests/src/com/android/systemui/communal/data/backup/CommunalBackupUtilsTest.kt
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/db/CommunalWidgetDaoTest.kt b/packages/SystemUI/tests/src/com/android/systemui/communal/data/db/CommunalWidgetDaoTest.kt
similarity index 100%
rename from packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/db/CommunalWidgetDaoTest.kt
rename to packages/SystemUI/tests/src/com/android/systemui/communal/data/db/CommunalWidgetDaoTest.kt
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/data/repository/KeyboardRepositoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyboard/data/repository/KeyboardRepositoryTest.kt
similarity index 100%
rename from packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/data/repository/KeyboardRepositoryTest.kt
rename to packages/SystemUI/tests/src/com/android/systemui/keyboard/data/repository/KeyboardRepositoryTest.kt
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModelTest.kt
similarity index 100%
rename from packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModelTest.kt
rename to packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModelTest.kt
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordancesCombinedViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordancesCombinedViewModelTest.kt
similarity index 100%
rename from packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordancesCombinedViewModelTest.kt
rename to packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordancesCombinedViewModelTest.kt
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/lifecycle/ActivatableTest.kt b/packages/SystemUI/tests/src/com/android/systemui/lifecycle/ActivatableTest.kt
similarity index 100%
rename from packages/SystemUI/multivalentTests/src/com/android/systemui/lifecycle/ActivatableTest.kt
rename to packages/SystemUI/tests/src/com/android/systemui/lifecycle/ActivatableTest.kt
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/lifecycle/SysUiViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/lifecycle/SysUiViewModelTest.kt
similarity index 100%
rename from packages/SystemUI/multivalentTests/src/com/android/systemui/lifecycle/SysUiViewModelTest.kt
rename to packages/SystemUI/tests/src/com/android/systemui/lifecycle/SysUiViewModelTest.kt
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/QSImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSImplTest.java
similarity index 100%
rename from packages/SystemUI/multivalentTests/src/com/android/systemui/qs/QSImplTest.java
rename to packages/SystemUI/tests/src/com/android/systemui/qs/QSImplTest.java
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/compose/DragAndDropTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/panels/ui/compose/DragAndDropTest.kt
similarity index 100%
rename from packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/compose/DragAndDropTest.kt
rename to packages/SystemUI/tests/src/com/android/systemui/qs/panels/ui/compose/DragAndDropTest.kt
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/compose/ResizingTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/panels/ui/compose/ResizingTest.kt
similarity index 100%
rename from packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/compose/ResizingTest.kt
rename to packages/SystemUI/tests/src/com/android/systemui/qs/panels/ui/compose/ResizingTest.kt
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/RecordIssueDialogDelegateTest.kt b/packages/SystemUI/tests/src/com/android/systemui/recordissue/RecordIssueDialogDelegateTest.kt
similarity index 100%
rename from packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/RecordIssueDialogDelegateTest.kt
rename to packages/SystemUI/tests/src/com/android/systemui/recordissue/RecordIssueDialogDelegateTest.kt
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/screenshot/ScreenshotDetectionControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/screenshot/ScreenshotDetectionControllerTest.kt
similarity index 100%
rename from packages/SystemUI/multivalentTests/src/com/android/systemui/screenshot/ScreenshotDetectionControllerTest.kt
rename to packages/SystemUI/tests/src/com/android/systemui/screenshot/ScreenshotDetectionControllerTest.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/connectivity/NetworkControllerWifiTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/connectivity/NetworkControllerWifiTest.java
index 6febb91..7a579ba 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/connectivity/NetworkControllerWifiTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/connectivity/NetworkControllerWifiTest.java
@@ -58,7 +58,7 @@
private static final int MIN_RSSI = -100;
private static final int MAX_RSSI = -55;
private WifiInfo mWifiInfo = mock(WifiInfo.class);
- private VcnTransportInfo mVcnTransportInfo = mock(VcnTransportInfo.class);
+ private VcnTransportInfo mVcnTransportInfo = new VcnTransportInfo.Builder().build();
@Before
public void setUp() throws Exception {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionsRepositoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionsRepositoryTest.kt
index 328d310..c48898a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionsRepositoryTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionsRepositoryTest.kt
@@ -136,6 +136,7 @@
private val wifiLogBuffer = LogBuffer("wifi", maxSize = 100, logcatEchoTracker = mock())
private val wifiPickerTrackerCallback =
argumentCaptor<WifiPickerTracker.WifiPickerTrackerCallback>()
+ private val vcnTransportInfo = VcnTransportInfo.Builder().build()
private val testDispatcher = StandardTestDispatcher()
private val testScope = TestScope(testDispatcher)
@@ -1003,6 +1004,18 @@
assertThat(latest).isTrue()
}
+ private fun newWifiNetwork(wifiInfo: WifiInfo): Network {
+ val network = mock<Network>()
+ val capabilities =
+ mock<NetworkCapabilities>().also {
+ whenever(it.hasTransport(TRANSPORT_WIFI)).thenReturn(true)
+ whenever(it.transportInfo).thenReturn(wifiInfo)
+ }
+ whenever(connectivityManager.getNetworkCapabilities(network)).thenReturn(capabilities)
+
+ return network
+ }
+
/** Regression test for b/272586234. */
@Test
fun hasCarrierMergedConnection_carrierMergedViaWifiWithVcnTransport_isTrue() =
@@ -1012,10 +1025,12 @@
whenever(this.isCarrierMerged).thenReturn(true)
whenever(this.isPrimary).thenReturn(true)
}
+ val underlyingWifi = newWifiNetwork(carrierMergedInfo)
val caps =
mock<NetworkCapabilities>().also {
whenever(it.hasTransport(TRANSPORT_WIFI)).thenReturn(true)
- whenever(it.transportInfo).thenReturn(VcnTransportInfo(carrierMergedInfo))
+ whenever(it.transportInfo).thenReturn(vcnTransportInfo)
+ whenever(it.underlyingNetworks).thenReturn(listOf(underlyingWifi))
}
val latest by collectLastValue(underTest.hasCarrierMergedConnection)
@@ -1034,10 +1049,12 @@
whenever(this.isCarrierMerged).thenReturn(true)
whenever(this.isPrimary).thenReturn(true)
}
+ val underlyingWifi = newWifiNetwork(carrierMergedInfo)
val caps =
mock<NetworkCapabilities>().also {
whenever(it.hasTransport(TRANSPORT_CELLULAR)).thenReturn(true)
- whenever(it.transportInfo).thenReturn(VcnTransportInfo(carrierMergedInfo))
+ whenever(it.transportInfo).thenReturn(vcnTransportInfo)
+ whenever(it.underlyingNetworks).thenReturn(listOf(underlyingWifi))
}
val latest by collectLastValue(underTest.hasCarrierMergedConnection)
@@ -1094,10 +1111,15 @@
whenever(this.isCarrierMerged).thenReturn(true)
whenever(this.isPrimary).thenReturn(true)
}
+
+ // The Wifi network that is under the VCN network
+ val physicalWifiNetwork = newWifiNetwork(carrierMergedInfo)
+
val underlyingCapabilities =
mock<NetworkCapabilities>().also {
whenever(it.hasTransport(TRANSPORT_CELLULAR)).thenReturn(true)
- whenever(it.transportInfo).thenReturn(VcnTransportInfo(carrierMergedInfo))
+ whenever(it.transportInfo).thenReturn(vcnTransportInfo)
+ whenever(it.underlyingNetworks).thenReturn(listOf(physicalWifiNetwork))
}
whenever(connectivityManager.getNetworkCapabilities(underlyingCarrierMergedNetwork))
.thenReturn(underlyingCapabilities)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/data/repository/ConnectivityRepositoryImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/data/repository/ConnectivityRepositoryImplTest.kt
index 0945742..88f262b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/data/repository/ConnectivityRepositoryImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/data/repository/ConnectivityRepositoryImplTest.kt
@@ -23,6 +23,7 @@
import android.net.NetworkCapabilities.TRANSPORT_ETHERNET
import android.net.NetworkCapabilities.TRANSPORT_VPN
import android.net.NetworkCapabilities.TRANSPORT_WIFI
+import android.net.TelephonyNetworkSpecifier
import android.net.VpnTransportInfo
import android.net.vcn.VcnTransportInfo
import android.net.wifi.WifiInfo
@@ -74,6 +75,8 @@
private val testScope = kosmos.testScope
private val tunerService = mock<TunerService>()
+ private val vcnTransportInfo = VcnTransportInfo.Builder().build()
+
@Before
fun setUp() {
createAndSetRepo()
@@ -343,6 +346,30 @@
assertThat(latest!!.wifi.isDefault).isTrue()
}
+ private fun newWifiNetwork(wifiInfo: WifiInfo): Network {
+ val network = mock<Network>()
+ val capabilities =
+ mock<NetworkCapabilities>().also {
+ whenever(it.hasTransport(TRANSPORT_WIFI)).thenReturn(true)
+ whenever(it.transportInfo).thenReturn(wifiInfo)
+ }
+ whenever(connectivityManager.getNetworkCapabilities(network)).thenReturn(capabilities)
+
+ return network
+ }
+
+ private fun newCellNetwork(subId: Int): Network {
+ val network = mock<Network>()
+ val capabilities =
+ mock<NetworkCapabilities>().also {
+ whenever(it.hasTransport(TRANSPORT_CELLULAR)).thenReturn(true)
+ whenever(it.networkSpecifier).thenReturn(TelephonyNetworkSpecifier(subId))
+ }
+ whenever(connectivityManager.getNetworkCapabilities(network)).thenReturn(capabilities)
+
+ return network
+ }
+
@Test
fun defaultConnections_carrierMergedViaWifiWithVcnTransport_wifiAndCarrierMergedDefault() =
testScope.runTest {
@@ -350,10 +377,12 @@
val carrierMergedInfo =
mock<WifiInfo>().apply { whenever(this.isCarrierMerged).thenReturn(true) }
+ val underlyingWifi = newWifiNetwork(carrierMergedInfo)
val capabilities =
mock<NetworkCapabilities>().also {
whenever(it.hasTransport(TRANSPORT_WIFI)).thenReturn(true)
- whenever(it.transportInfo).thenReturn(VcnTransportInfo(carrierMergedInfo))
+ whenever(it.transportInfo).thenReturn(vcnTransportInfo)
+ whenever(it.underlyingNetworks).thenReturn(listOf(underlyingWifi))
whenever(it.hasTransport(TRANSPORT_CELLULAR)).thenReturn(false)
whenever(it.hasTransport(TRANSPORT_ETHERNET)).thenReturn(false)
}
@@ -373,10 +402,12 @@
val carrierMergedInfo =
mock<WifiInfo>().apply { whenever(this.isCarrierMerged).thenReturn(true) }
+ val underlyingWifi = newWifiNetwork(carrierMergedInfo)
val capabilities =
mock<NetworkCapabilities>().also {
whenever(it.hasTransport(TRANSPORT_CELLULAR)).thenReturn(true)
- whenever(it.transportInfo).thenReturn(VcnTransportInfo(carrierMergedInfo))
+ whenever(it.transportInfo).thenReturn(vcnTransportInfo)
+ whenever(it.underlyingNetworks).thenReturn(listOf(underlyingWifi))
whenever(it.hasTransport(TRANSPORT_ETHERNET)).thenReturn(false)
whenever(it.hasTransport(TRANSPORT_WIFI)).thenReturn(false)
}
@@ -561,10 +592,12 @@
val underlyingCarrierMergedNetwork = mock<Network>()
val carrierMergedInfo =
mock<WifiInfo>().apply { whenever(this.isCarrierMerged).thenReturn(true) }
+ val underlyingWifi = newWifiNetwork(carrierMergedInfo)
val underlyingCapabilities =
mock<NetworkCapabilities>().also {
whenever(it.hasTransport(TRANSPORT_CELLULAR)).thenReturn(true)
- whenever(it.transportInfo).thenReturn(VcnTransportInfo(carrierMergedInfo))
+ whenever(it.transportInfo).thenReturn(vcnTransportInfo)
+ whenever(it.underlyingNetworks).thenReturn(listOf(underlyingWifi))
}
whenever(connectivityManager.getNetworkCapabilities(underlyingCarrierMergedNetwork))
.thenReturn(underlyingCapabilities)
@@ -645,14 +678,15 @@
@Test
fun vcnSubId_tracksVcnTransportInfo() =
testScope.runTest {
- val vcnInfo = VcnTransportInfo(SUB_1_ID)
+ val underlyingCell = newCellNetwork(SUB_1_ID)
val latest by collectLastValue(underTest.vcnSubId)
val capabilities =
mock<NetworkCapabilities>().also {
whenever(it.hasTransport(TRANSPORT_CELLULAR)).thenReturn(true)
- whenever(it.transportInfo).thenReturn(vcnInfo)
+ whenever(it.transportInfo).thenReturn(vcnTransportInfo)
+ whenever(it.underlyingNetworks).thenReturn(listOf(underlyingCell))
}
getDefaultNetworkCallback().onCapabilitiesChanged(NETWORK, capabilities)
@@ -663,14 +697,15 @@
@Test
fun vcnSubId_filersOutInvalid() =
testScope.runTest {
- val vcnInfo = VcnTransportInfo(INVALID_SUBSCRIPTION_ID)
+ val underlyingCell = newCellNetwork(INVALID_SUBSCRIPTION_ID)
val latest by collectLastValue(underTest.vcnSubId)
val capabilities =
mock<NetworkCapabilities>().also {
whenever(it.hasTransport(TRANSPORT_CELLULAR)).thenReturn(true)
- whenever(it.transportInfo).thenReturn(vcnInfo)
+ whenever(it.transportInfo).thenReturn(vcnTransportInfo)
+ whenever(it.underlyingNetworks).thenReturn(listOf(underlyingCell))
}
getDefaultNetworkCallback().onCapabilitiesChanged(NETWORK, capabilities)
@@ -703,11 +738,12 @@
val latest by collectLastValue(underTest.vcnSubId)
val wifiInfo = mock<WifiInfo>()
- val vcnInfo = VcnTransportInfo(wifiInfo)
+ val underlyingWifi = newWifiNetwork(wifiInfo)
val capabilities =
mock<NetworkCapabilities>().also {
whenever(it.hasTransport(TRANSPORT_CELLULAR)).thenReturn(true)
- whenever(it.transportInfo).thenReturn(vcnInfo)
+ whenever(it.transportInfo).thenReturn(vcnTransportInfo)
+ whenever(it.underlyingNetworks).thenReturn(listOf(underlyingWifi))
}
getDefaultNetworkCallback().onCapabilitiesChanged(NETWORK, capabilities)
@@ -721,14 +757,15 @@
val latest by collectLastValue(underTest.vcnSubId)
val wifiInfo = mock<WifiInfo>()
- val wifiVcnInfo = VcnTransportInfo(wifiInfo)
- val sub1VcnInfo = VcnTransportInfo(SUB_1_ID)
- val sub2VcnInfo = VcnTransportInfo(SUB_2_ID)
+ val underlyingWifi = newWifiNetwork(wifiInfo)
+ val underlyingCell1 = newCellNetwork(SUB_1_ID)
+ val underlyingCell2 = newCellNetwork(SUB_2_ID)
val capabilities =
mock<NetworkCapabilities>().also {
whenever(it.hasTransport(TRANSPORT_WIFI)).thenReturn(true)
- whenever(it.transportInfo).thenReturn(wifiVcnInfo)
+ whenever(it.transportInfo).thenReturn(vcnTransportInfo)
+ whenever(it.underlyingNetworks).thenReturn(listOf(underlyingWifi))
}
// WIFI VCN info
@@ -738,14 +775,16 @@
// Cellular VCN info with subId 1
whenever(capabilities.hasTransport(eq(TRANSPORT_CELLULAR))).thenReturn(true)
- whenever(capabilities.transportInfo).thenReturn(sub1VcnInfo)
+ whenever(capabilities.transportInfo).thenReturn(vcnTransportInfo)
+ whenever(capabilities.underlyingNetworks).thenReturn(listOf(underlyingCell1))
getDefaultNetworkCallback().onCapabilitiesChanged(NETWORK, capabilities)
assertThat(latest).isEqualTo(SUB_1_ID)
// Cellular VCN info with subId 2
- whenever(capabilities.transportInfo).thenReturn(sub2VcnInfo)
+ whenever(capabilities.transportInfo).thenReturn(vcnTransportInfo)
+ whenever(capabilities.underlyingNetworks).thenReturn(listOf(underlyingCell2))
getDefaultNetworkCallback().onCapabilitiesChanged(NETWORK, capabilities)
@@ -776,11 +815,12 @@
@Test
fun getMainOrUnderlyingWifiInfo_vcnWithWifi_hasInfo() {
val wifiInfo = mock<WifiInfo>()
- val vcnInfo = VcnTransportInfo(wifiInfo)
+ val underlyingWifi = newWifiNetwork(wifiInfo)
val capabilities =
mock<NetworkCapabilities>().also {
whenever(it.hasTransport(TRANSPORT_WIFI)).thenReturn(true)
- whenever(it.transportInfo).thenReturn(vcnInfo)
+ whenever(it.transportInfo).thenReturn(vcnTransportInfo)
+ whenever(it.underlyingNetworks).thenReturn(listOf(underlyingWifi))
}
val result = capabilities.getMainOrUnderlyingWifiInfo(connectivityManager)
@@ -860,11 +900,15 @@
fun getMainOrUnderlyingWifiInfo_cellular_underlyingVcnWithWifi_hasInfo() {
val wifiInfo = mock<WifiInfo>()
val underlyingNetwork = mock<Network>()
- val underlyingVcnInfo = VcnTransportInfo(wifiInfo)
+
+ // The Wifi network that is under the VCN network
+ val physicalWifiNetwork = newWifiNetwork(wifiInfo)
+
val underlyingWifiCapabilities =
mock<NetworkCapabilities>().also {
whenever(it.hasTransport(TRANSPORT_WIFI)).thenReturn(true)
- whenever(it.transportInfo).thenReturn(underlyingVcnInfo)
+ whenever(it.transportInfo).thenReturn(vcnTransportInfo)
+ whenever(it.underlyingNetworks).thenReturn(listOf(physicalWifiNetwork))
}
whenever(connectivityManager.getNetworkCapabilities(underlyingNetwork))
.thenReturn(underlyingWifiCapabilities)
@@ -887,11 +931,15 @@
@DisableFlags(FLAG_STATUS_BAR_ALWAYS_CHECK_UNDERLYING_NETWORKS)
fun getMainOrUnderlyingWifiInfo_notCellular_underlyingVcnWithWifi_noInfo() {
val underlyingNetwork = mock<Network>()
- val underlyingVcnInfo = VcnTransportInfo(mock<WifiInfo>())
+
+ // The Wifi network that is under the VCN network
+ val physicalWifiNetwork = newWifiNetwork(mock<WifiInfo>())
+
val underlyingWifiCapabilities =
mock<NetworkCapabilities>().also {
whenever(it.hasTransport(TRANSPORT_WIFI)).thenReturn(true)
- whenever(it.transportInfo).thenReturn(underlyingVcnInfo)
+ whenever(it.transportInfo).thenReturn(vcnTransportInfo)
+ whenever(it.underlyingNetworks).thenReturn(listOf(physicalWifiNetwork))
}
whenever(connectivityManager.getNetworkCapabilities(underlyingNetwork))
.thenReturn(underlyingWifiCapabilities)
@@ -917,10 +965,15 @@
val underlyingCarrierMergedNetwork = mock<Network>()
val carrierMergedInfo =
mock<WifiInfo>().apply { whenever(this.isCarrierMerged).thenReturn(true) }
+
+ // The Wifi network that is under the VCN network
+ val physicalWifiNetwork = newWifiNetwork(carrierMergedInfo)
+
val underlyingCapabilities =
mock<NetworkCapabilities>().also {
whenever(it.hasTransport(TRANSPORT_CELLULAR)).thenReturn(true)
- whenever(it.transportInfo).thenReturn(VcnTransportInfo(carrierMergedInfo))
+ whenever(it.transportInfo).thenReturn(vcnTransportInfo)
+ whenever(it.underlyingNetworks).thenReturn(listOf(physicalWifiNetwork))
}
whenever(connectivityManager.getNetworkCapabilities(underlyingCarrierMergedNetwork))
.thenReturn(underlyingCapabilities)
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/AudioSharingButtonViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/AudioSharingButtonViewModelKosmos.kt
new file mode 100644
index 0000000..cac4ff3
--- /dev/null
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/AudioSharingButtonViewModelKosmos.kt
@@ -0,0 +1,38 @@
+/*
+ * 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.bluetooth.qsdialog
+
+import com.android.systemui.kosmos.Kosmos
+
+val Kosmos.audioSharingButtonViewModel: AudioSharingButtonViewModel by
+ Kosmos.Fixture {
+ AudioSharingButtonViewModel(
+ localBluetoothManager,
+ audioSharingInteractor,
+ bluetoothStateInteractor,
+ deviceItemInteractor,
+ )
+ }
+
+val Kosmos.audioSharingButtonViewModelFactory: AudioSharingButtonViewModel.Factory by
+ Kosmos.Fixture {
+ object : AudioSharingButtonViewModel.Factory {
+ override fun create(): AudioSharingButtonViewModel {
+ return audioSharingButtonViewModel
+ }
+ }
+ }
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDeviceItemActionInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDeviceItemActionInteractorKosmos.kt
new file mode 100644
index 0000000..8019efc
--- /dev/null
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDeviceItemActionInteractorKosmos.kt
@@ -0,0 +1,50 @@
+/*
+ * 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.bluetooth.qsdialog
+
+import com.android.internal.logging.uiEventLogger
+import com.android.settingslib.bluetooth.CachedBluetoothDevice
+import com.android.systemui.kosmos.Kosmos
+import com.android.systemui.kosmos.testDispatcher
+import com.android.systemui.plugins.activityStarter
+
+val Kosmos.audioSharingDeviceItemActionInteractorImpl: AudioSharingDeviceItemActionInteractorImpl by
+ Kosmos.Fixture {
+ AudioSharingDeviceItemActionInteractorImpl(
+ activityStarter,
+ audioSharingInteractor,
+ dialogTransitionAnimator,
+ localBluetoothManager,
+ testDispatcher,
+ testDispatcher,
+ bluetoothTileDialogLogger,
+ uiEventLogger,
+ audioSharingDialogDelegateFactory,
+ deviceItemActionInteractorImpl,
+ )
+ }
+
+val Kosmos.audioSharingDialogDelegateFactory: AudioSharingDialogDelegate.Factory by
+ Kosmos.Fixture {
+ object : AudioSharingDialogDelegate.Factory {
+ override fun create(
+ cachedBluetoothDevice: CachedBluetoothDevice
+ ): AudioSharingDialogDelegate {
+ return audioSharingDialogDelegate
+ }
+ }
+ }
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDialogViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDialogViewModelKosmos.kt
new file mode 100644
index 0000000..b8899de8
--- /dev/null
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDialogViewModelKosmos.kt
@@ -0,0 +1,65 @@
+/*
+ * 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.bluetooth.qsdialog
+
+import android.content.applicationContext
+import com.android.internal.logging.uiEventLogger
+import com.android.settingslib.bluetooth.CachedBluetoothDevice
+import com.android.systemui.kosmos.Kosmos
+import com.android.systemui.kosmos.testDispatcher
+import com.android.systemui.kosmos.testScope
+import com.android.systemui.statusbar.phone.systemUIDialogDotFactory
+import kotlinx.coroutines.CoroutineScope
+import org.mockito.kotlin.mock
+
+val Kosmos.cachedBluetoothDevice: CachedBluetoothDevice by Kosmos.Fixture { mock {} }
+
+val Kosmos.audioSharingDialogViewModel: AudioSharingDialogViewModel by
+ Kosmos.Fixture {
+ AudioSharingDialogViewModel(
+ deviceItemInteractor,
+ audioSharingInteractor,
+ applicationContext,
+ localBluetoothManager,
+ cachedBluetoothDevice,
+ testScope.backgroundScope,
+ testDispatcher
+ )
+ }
+
+val Kosmos.audioSharingDialogViewModelFactory: AudioSharingDialogViewModel.Factory by
+ Kosmos.Fixture {
+ object : AudioSharingDialogViewModel.Factory {
+ override fun create(
+ cachedBluetoothDevice: CachedBluetoothDevice,
+ coroutineScope: CoroutineScope
+ ): AudioSharingDialogViewModel {
+ return audioSharingDialogViewModel
+ }
+ }
+ }
+
+val Kosmos.audioSharingDialogDelegate: AudioSharingDialogDelegate by
+ Kosmos.Fixture {
+ AudioSharingDialogDelegate(
+ cachedBluetoothDevice,
+ testScope.backgroundScope,
+ audioSharingDialogViewModelFactory,
+ systemUIDialogDotFactory,
+ uiEventLogger
+ )
+ }
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/ui/viewmodel/PartitionedGridViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/AudioSharingInteractorKosmos.kt
similarity index 68%
rename from packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/ui/viewmodel/PartitionedGridViewModelKosmos.kt
rename to packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/AudioSharingInteractorKosmos.kt
index fde174d..4f4d1da 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/ui/viewmodel/PartitionedGridViewModelKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/AudioSharingInteractorKosmos.kt
@@ -14,15 +14,16 @@
* limitations under the License.
*/
-package com.android.systemui.qs.panels.ui.viewmodel
+package com.android.systemui.bluetooth.qsdialog
import com.android.systemui.kosmos.Kosmos
+import com.android.systemui.kosmos.testDispatcher
-val Kosmos.partitionedGridViewModel by
+val Kosmos.audioSharingInteractor: AudioSharingInteractor by
Kosmos.Fixture {
- PartitionedGridViewModel(
- iconTilesViewModel,
- fixedColumnsSizeViewModel,
- iconLabelVisibilityViewModel,
+ AudioSharingInteractorImpl(
+ localBluetoothManager,
+ bluetoothTileDialogAudioSharingRepository,
+ testDispatcher,
)
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/data/repository/FixedColumnsRepositoryKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/AudioSharingRepositoryKosmos.kt
similarity index 80%
rename from packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/data/repository/FixedColumnsRepositoryKosmos.kt
rename to packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/AudioSharingRepositoryKosmos.kt
index 2f5daaa..d15d0e5 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/data/repository/FixedColumnsRepositoryKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/AudioSharingRepositoryKosmos.kt
@@ -14,8 +14,9 @@
* limitations under the License.
*/
-package com.android.systemui.qs.panels.data.repository
+package com.android.systemui.bluetooth.qsdialog
import com.android.systemui.kosmos.Kosmos
-val Kosmos.fixedColumnsRepository by Kosmos.Fixture { FixedColumnsRepository() }
+val Kosmos.bluetoothTileDialogAudioSharingRepository by
+ Kosmos.Fixture { FakeAudioSharingRepository() }
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/bluetooth/qsdialog/BluetoothDeviceMetadataInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/BluetoothDeviceMetadataInteractorKosmos.kt
similarity index 100%
rename from packages/SystemUI/multivalentTests/src/com/android/systemui/bluetooth/qsdialog/BluetoothDeviceMetadataInteractorKosmos.kt
rename to packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/BluetoothDeviceMetadataInteractorKosmos.kt
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/ui/viewmodel/PartitionedGridViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/BluetoothStateInteractorKosmos.kt
similarity index 64%
copy from packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/ui/viewmodel/PartitionedGridViewModelKosmos.kt
copy to packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/BluetoothStateInteractorKosmos.kt
index fde174d..aaa918c 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/ui/viewmodel/PartitionedGridViewModelKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/BluetoothStateInteractorKosmos.kt
@@ -14,15 +14,18 @@
* limitations under the License.
*/
-package com.android.systemui.qs.panels.ui.viewmodel
+package com.android.systemui.bluetooth.qsdialog
import com.android.systemui.kosmos.Kosmos
+import com.android.systemui.kosmos.testDispatcher
+import com.android.systemui.kosmos.testScope
-val Kosmos.partitionedGridViewModel by
+val Kosmos.bluetoothStateInteractor: BluetoothStateInteractor by
Kosmos.Fixture {
- PartitionedGridViewModel(
- iconTilesViewModel,
- fixedColumnsSizeViewModel,
- iconLabelVisibilityViewModel,
+ BluetoothStateInteractor(
+ localBluetoothManager,
+ bluetoothTileDialogLogger,
+ testScope.backgroundScope,
+ testDispatcher
)
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/bluetooth/qsdialog/DeviceItemActionInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/DeviceItemActionInteractorKosmos.kt
similarity index 79%
rename from packages/SystemUI/multivalentTests/src/com/android/systemui/bluetooth/qsdialog/DeviceItemActionInteractorKosmos.kt
rename to packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/DeviceItemActionInteractorKosmos.kt
index 5ff4634..b5b2f5e 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/bluetooth/qsdialog/DeviceItemActionInteractorKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/DeviceItemActionInteractorKosmos.kt
@@ -20,8 +20,7 @@
import com.android.systemui.animation.DialogTransitionAnimator
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.testDispatcher
-import com.android.systemui.plugins.activityStarter
-import com.android.systemui.util.mockito.mock
+import org.mockito.kotlin.mock
val Kosmos.bluetoothTileDialogLogger: BluetoothTileDialogLogger by Kosmos.Fixture { mock {} }
@@ -29,14 +28,10 @@
val Kosmos.dialogTransitionAnimator: DialogTransitionAnimator by Kosmos.Fixture { mock {} }
-val Kosmos.deviceItemActionInteractor: DeviceItemActionInteractor by
+val Kosmos.deviceItemActionInteractorImpl: DeviceItemActionInteractorImpl by
Kosmos.Fixture {
- DeviceItemActionInteractor(
- activityStarter,
- dialogTransitionAnimator,
- localBluetoothManager,
+ DeviceItemActionInteractorImpl(
testDispatcher,
- bluetoothTileDialogLogger,
uiEventLogger,
)
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/FakeAudioSharingRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/FakeAudioSharingRepository.kt
new file mode 100644
index 0000000..a839f17
--- /dev/null
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/FakeAudioSharingRepository.kt
@@ -0,0 +1,70 @@
+/*
+ * 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.bluetooth.qsdialog
+
+import com.android.settingslib.bluetooth.CachedBluetoothDevice
+import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.MutableSharedFlow
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.StateFlow
+
+class FakeAudioSharingRepository : AudioSharingRepository {
+ private var mutableAvailable: Boolean = false
+
+ private val mutableInAudioSharing: MutableStateFlow<Boolean> = MutableStateFlow(false)
+
+ private val mutableAudioSourceStateUpdate = MutableSharedFlow<Unit>()
+
+ var sourceAdded: Boolean = false
+ private set
+
+ private var profile: LocalBluetoothLeBroadcast? = null
+
+ override val leAudioBroadcastProfile: LocalBluetoothLeBroadcast?
+ get() = profile
+
+ override val audioSourceStateUpdate: Flow<Unit> = mutableAudioSourceStateUpdate
+
+ override val inAudioSharing: StateFlow<Boolean> = mutableInAudioSharing
+
+ override suspend fun audioSharingAvailable(): Boolean = mutableAvailable
+
+ override suspend fun addSource() {
+ sourceAdded = true
+ }
+
+ override suspend fun setActive(cachedBluetoothDevice: CachedBluetoothDevice) {}
+
+ override suspend fun startAudioSharing() {}
+
+ fun setAudioSharingAvailable(available: Boolean) {
+ mutableAvailable = available
+ }
+
+ fun setInAudioSharing(state: Boolean) {
+ mutableInAudioSharing.value = state
+ }
+
+ fun setLeAudioBroadcastProfile(leAudioBroadcastProfile: LocalBluetoothLeBroadcast?) {
+ profile = leAudioBroadcastProfile
+ }
+
+ fun emitAudioSourceStateUpdate() {
+ mutableAudioSourceStateUpdate.tryEmit(Unit)
+ }
+}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt
index f97f303..522c387 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt
@@ -23,6 +23,7 @@
import com.android.systemui.SysuiTestCase
import com.android.systemui.bouncer.data.repository.bouncerRepository
import com.android.systemui.bouncer.data.repository.fakeKeyguardBouncerRepository
+import com.android.systemui.bouncer.domain.interactor.alternateBouncerInteractor
import com.android.systemui.bouncer.domain.interactor.simBouncerInteractor
import com.android.systemui.classifier.falsingCollector
import com.android.systemui.common.ui.data.repository.fakeConfigurationRepository
@@ -152,6 +153,7 @@
val wifiInteractor by lazy { kosmos.wifiInteractor }
val fakeWifiRepository by lazy { kosmos.fakeWifiRepository }
val volumeDialogInteractor by lazy { kosmos.volumeDialogInteractor }
+ val alternateBouncerInteractor by lazy { kosmos.alternateBouncerInteractor }
val ongoingActivityChipsViewModel by lazy { kosmos.ongoingActivityChipsViewModel }
val scrimController by lazy { kosmos.scrimController }
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/plugins/statusbar/StatusBarStateControllerKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/plugins/statusbar/StatusBarStateControllerKosmos.kt
index cfc31c7..10b073e 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/plugins/statusbar/StatusBarStateControllerKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/plugins/statusbar/StatusBarStateControllerKosmos.kt
@@ -17,6 +17,7 @@
package com.android.systemui.plugins.statusbar
import com.android.internal.logging.uiEventLogger
+import com.android.systemui.bouncer.domain.interactor.alternateBouncerInteractor
import com.android.systemui.deviceentry.domain.interactor.deviceUnlockedInteractor
import com.android.systemui.jank.interactionJankMonitor
import com.android.systemui.keyguard.domain.interactor.keyguardClockInteractor
@@ -45,5 +46,6 @@
{ sceneContainerOcclusionInteractor },
{ keyguardClockInteractor },
{ sceneBackInteractor },
+ { alternateBouncerInteractor },
)
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/data/repository/FixedColumnsRepositoryKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/data/repository/QSColumnsRepositoryKosmos.kt
similarity index 68%
copy from packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/data/repository/FixedColumnsRepositoryKosmos.kt
copy to packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/data/repository/QSColumnsRepositoryKosmos.kt
index 2f5daaa..0ca025f 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/data/repository/FixedColumnsRepositoryKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/data/repository/QSColumnsRepositoryKosmos.kt
@@ -16,6 +16,12 @@
package com.android.systemui.qs.panels.data.repository
+import android.content.res.mainResources
+import com.android.systemui.common.ui.data.repository.configurationRepository
import com.android.systemui.kosmos.Kosmos
+import com.android.systemui.kosmos.applicationCoroutineScope
-val Kosmos.fixedColumnsRepository by Kosmos.Fixture { FixedColumnsRepository() }
+val Kosmos.qsColumnsRepository by
+ Kosmos.Fixture {
+ QSColumnsRepository(applicationCoroutineScope, mainResources, configurationRepository)
+ }
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/domain/interactor/InfiniteGridLayoutKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/domain/interactor/InfiniteGridLayoutKosmos.kt
index 546129f..b4317ad 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/domain/interactor/InfiniteGridLayoutKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/domain/interactor/InfiniteGridLayoutKosmos.kt
@@ -18,11 +18,11 @@
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.qs.panels.ui.compose.infinitegrid.InfiniteGridLayout
-import com.android.systemui.qs.panels.ui.viewmodel.fixedColumnsSizeViewModel
import com.android.systemui.qs.panels.ui.viewmodel.iconTilesViewModel
+import com.android.systemui.qs.panels.ui.viewmodel.qsColumnsViewModel
import com.android.systemui.qs.panels.ui.viewmodel.tileSquishinessViewModel
val Kosmos.infiniteGridLayout by
Kosmos.Fixture {
- InfiniteGridLayout(iconTilesViewModel, fixedColumnsSizeViewModel, tileSquishinessViewModel)
+ InfiniteGridLayout(iconTilesViewModel, qsColumnsViewModel, tileSquishinessViewModel)
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/domain/interactor/FixedColumnsSizeInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/domain/interactor/QSColumnsInteractorKosmos.kt
similarity index 78%
rename from packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/domain/interactor/FixedColumnsSizeInteractorKosmos.kt
rename to packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/domain/interactor/QSColumnsInteractorKosmos.kt
index f4d281d..02ed264 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/domain/interactor/FixedColumnsSizeInteractorKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/domain/interactor/QSColumnsInteractorKosmos.kt
@@ -17,7 +17,6 @@
package com.android.systemui.qs.panels.domain.interactor
import com.android.systemui.kosmos.Kosmos
-import com.android.systemui.qs.panels.data.repository.fixedColumnsRepository
+import com.android.systemui.qs.panels.data.repository.qsColumnsRepository
-val Kosmos.fixedColumnsSizeInteractor by
- Kosmos.Fixture { FixedColumnsSizeInteractor(fixedColumnsRepository) }
+val Kosmos.qsColumnsInteractor by Kosmos.Fixture { QSColumnsInteractor(qsColumnsRepository) }
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/ui/viewmodel/PaginatedGridViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/ui/viewmodel/PaginatedGridViewModelKosmos.kt
index 85e9265..10d8e1e 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/ui/viewmodel/PaginatedGridViewModelKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/ui/viewmodel/PaginatedGridViewModelKosmos.kt
@@ -24,7 +24,7 @@
Kosmos.Fixture {
PaginatedGridViewModel(
iconTilesViewModel,
- fixedColumnsSizeViewModel,
+ qsColumnsViewModel,
iconLabelVisibilityViewModel,
paginatedGridInteractor,
applicationCoroutineScope,
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/ui/viewmodel/FixedColumnsSizeViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/ui/viewmodel/QSColumnsViewModelKosmos.kt
similarity index 77%
rename from packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/ui/viewmodel/FixedColumnsSizeViewModelKosmos.kt
rename to packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/ui/viewmodel/QSColumnsViewModelKosmos.kt
index feadc91..16b2f54 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/ui/viewmodel/FixedColumnsSizeViewModelKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/ui/viewmodel/QSColumnsViewModelKosmos.kt
@@ -17,7 +17,6 @@
package com.android.systemui.qs.panels.ui.viewmodel
import com.android.systemui.kosmos.Kosmos
-import com.android.systemui.qs.panels.domain.interactor.fixedColumnsSizeInteractor
+import com.android.systemui.qs.panels.domain.interactor.qsColumnsInteractor
-val Kosmos.fixedColumnsSizeViewModel by
- Kosmos.Fixture { FixedColumnsSizeViewModelImpl(fixedColumnsSizeInteractor) }
+val Kosmos.qsColumnsViewModel by Kosmos.Fixture { QSColumnsSizeViewModelImpl(qsColumnsInteractor) }
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/ui/viewmodel/QuickQuickSettingsViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/ui/viewmodel/QuickQuickSettingsViewModelKosmos.kt
index babbd50..67d9e0e 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/ui/viewmodel/QuickQuickSettingsViewModelKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/ui/viewmodel/QuickQuickSettingsViewModelKosmos.kt
@@ -25,7 +25,7 @@
Kosmos.Fixture {
QuickQuickSettingsViewModel(
currentTilesInteractor,
- fixedColumnsSizeViewModel,
+ qsColumnsViewModel,
quickQuickSettingsRowInteractor,
tileSquishinessViewModel,
iconTilesViewModel,
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/volume/data/repository/FakeAudioSharingRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/volume/data/repository/FakeAudioSharingRepository.kt
index a4719e5..5da6ee9 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/volume/data/repository/FakeAudioSharingRepository.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/volume/data/repository/FakeAudioSharingRepository.kt
@@ -22,6 +22,7 @@
import kotlinx.coroutines.flow.StateFlow
class FakeAudioSharingRepository : AudioSharingRepository {
+ private var mutableAvailable: Boolean = false
private val mutableInAudioSharing: MutableStateFlow<Boolean> = MutableStateFlow(false)
private val mutablePrimaryGroupId: MutableStateFlow<Int> =
MutableStateFlow(TEST_GROUP_ID_INVALID)
@@ -34,8 +35,14 @@
override val secondaryGroupId: StateFlow<Int> = mutableSecondaryGroupId
override val volumeMap: StateFlow<GroupIdToVolumes> = mutableVolumeMap
+ override suspend fun audioSharingAvailable(): Boolean = mutableAvailable
+
override suspend fun setSecondaryVolume(volume: Int) {}
+ fun setAudioSharingAvailable(available: Boolean) {
+ mutableAvailable = available
+ }
+
fun setInAudioSharing(state: Boolean) {
mutableInAudioSharing.value = state
}
diff --git a/ravenwood/Android.bp b/ravenwood/Android.bp
index 9629a87..8896d77 100644
--- a/ravenwood/Android.bp
+++ b/ravenwood/Android.bp
@@ -12,11 +12,19 @@
}
filegroup {
+ name: "ravenwood-common-policies",
+ srcs: [
+ "texts/ravenwood-common-policies.txt",
+ ],
+ visibility: ["//visibility:private"],
+}
+
+filegroup {
name: "ravenwood-services-policies",
srcs: [
"texts/ravenwood-services-policies.txt",
],
- visibility: ["//visibility:public"],
+ visibility: ["//visibility:private"],
}
filegroup {
@@ -24,7 +32,7 @@
srcs: [
"texts/ravenwood-framework-policies.txt",
],
- visibility: ["//visibility:public"],
+ visibility: ["//visibility:private"],
}
filegroup {
@@ -32,7 +40,7 @@
srcs: [
"texts/ravenwood-standard-options.txt",
],
- visibility: ["//visibility:public"],
+ visibility: ["//visibility:private"],
}
filegroup {
@@ -40,7 +48,7 @@
srcs: [
"texts/ravenwood-annotation-allowed-classes.txt",
],
- visibility: ["//visibility:public"],
+ visibility: ["//visibility:private"],
}
// This and the next module contain the same classes with different implementations.
@@ -337,6 +345,30 @@
],
}
+// JARs in "ravenwood-runtime" are set to the classpath, sorted alphabetically.
+// Rename some of the dependencies to make sure they're included in the intended order.
+
+java_library {
+ name: "100-framework-minus-apex.ravenwood",
+ installable: false,
+ static_libs: ["framework-minus-apex.ravenwood"],
+ visibility: ["//visibility:private"],
+}
+
+java_library {
+ name: "200-kxml2-android",
+ installable: false,
+ static_libs: ["kxml2-android"],
+ visibility: ["//visibility:private"],
+}
+
+java_library {
+ name: "z00-all-updatable-modules-system-stubs",
+ installable: false,
+ static_libs: ["all-updatable-modules-system-stubs-for-host"],
+ visibility: ["//visibility:private"],
+}
+
android_ravenwood_libgroup {
name: "ravenwood-runtime",
data: [
@@ -395,3 +427,7 @@
"inline-mockito-ravenwood-prebuilt",
],
}
+
+build = [
+ "Framework.bp",
+]
diff --git a/ravenwood/Framework.bp b/ravenwood/Framework.bp
new file mode 100644
index 0000000..5cb1479
--- /dev/null
+++ b/ravenwood/Framework.bp
@@ -0,0 +1,292 @@
+// 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.
+
+// This file hosts all the genrule and module definitions for all Android specific
+// code that needs further post-processing by hoststubgen to support Ravenwood.
+
+/////////////////////////
+// framework-minus-apex
+/////////////////////////
+
+// Process framework-minus-apex with hoststubgen for Ravenwood.
+// This step takes several tens of seconds, so we manually shard it to multiple modules.
+// All the copies have to be kept in sync.
+// TODO: Do the sharding better, either by making hostsubgen support sharding natively, or
+// making a better build rule.
+
+genrule_defaults {
+ name: "framework-minus-apex.ravenwood-base_defaults",
+ tools: ["hoststubgen"],
+ srcs: [
+ ":framework-minus-apex-for-host",
+ ":ravenwood-common-policies",
+ ":ravenwood-framework-policies",
+ ":ravenwood-standard-options",
+ ":ravenwood-annotation-allowed-classes",
+ ],
+ out: [
+ "ravenwood.jar",
+ "hoststubgen_framework-minus-apex.log",
+ ],
+ visibility: ["//visibility:private"],
+}
+
+framework_minus_apex_cmd = "$(location hoststubgen) " +
+ "@$(location :ravenwood-standard-options) " +
+ "--debug-log $(location hoststubgen_framework-minus-apex.log) " +
+ "--out-jar $(location ravenwood.jar) " +
+ "--in-jar $(location :framework-minus-apex-for-host) " +
+ "--policy-override-file $(location :ravenwood-common-policies) " +
+ "--policy-override-file $(location :ravenwood-framework-policies) " +
+ "--annotation-allowed-classes-file $(location :ravenwood-annotation-allowed-classes) "
+
+java_genrule {
+ name: "framework-minus-apex.ravenwood-base_X0",
+ defaults: ["framework-minus-apex.ravenwood-base_defaults"],
+ cmd: framework_minus_apex_cmd + " --num-shards 10 --shard-index 0",
+}
+
+java_genrule {
+ name: "framework-minus-apex.ravenwood-base_X1",
+ defaults: ["framework-minus-apex.ravenwood-base_defaults"],
+ cmd: framework_minus_apex_cmd + " --num-shards 10 --shard-index 1",
+}
+
+java_genrule {
+ name: "framework-minus-apex.ravenwood-base_X2",
+ defaults: ["framework-minus-apex.ravenwood-base_defaults"],
+ cmd: framework_minus_apex_cmd + " --num-shards 10 --shard-index 2",
+}
+
+java_genrule {
+ name: "framework-minus-apex.ravenwood-base_X3",
+ defaults: ["framework-minus-apex.ravenwood-base_defaults"],
+ cmd: framework_minus_apex_cmd + " --num-shards 10 --shard-index 3",
+}
+
+java_genrule {
+ name: "framework-minus-apex.ravenwood-base_X4",
+ defaults: ["framework-minus-apex.ravenwood-base_defaults"],
+ cmd: framework_minus_apex_cmd + " --num-shards 10 --shard-index 4",
+}
+
+java_genrule {
+ name: "framework-minus-apex.ravenwood-base_X5",
+ defaults: ["framework-minus-apex.ravenwood-base_defaults"],
+ cmd: framework_minus_apex_cmd + " --num-shards 10 --shard-index 5",
+}
+
+java_genrule {
+ name: "framework-minus-apex.ravenwood-base_X6",
+ defaults: ["framework-minus-apex.ravenwood-base_defaults"],
+ cmd: framework_minus_apex_cmd + " --num-shards 10 --shard-index 6",
+}
+
+java_genrule {
+ name: "framework-minus-apex.ravenwood-base_X7",
+ defaults: ["framework-minus-apex.ravenwood-base_defaults"],
+ cmd: framework_minus_apex_cmd + " --num-shards 10 --shard-index 7",
+}
+
+java_genrule {
+ name: "framework-minus-apex.ravenwood-base_X8",
+ defaults: ["framework-minus-apex.ravenwood-base_defaults"],
+ cmd: framework_minus_apex_cmd + " --num-shards 10 --shard-index 8",
+}
+
+java_genrule {
+ name: "framework-minus-apex.ravenwood-base_X9",
+ defaults: ["framework-minus-apex.ravenwood-base_defaults"],
+ cmd: framework_minus_apex_cmd + " --num-shards 10 --shard-index 9",
+}
+
+// Build framework-minus-apex.ravenwood-base without sharding.
+// We extract the various dump files from this one, rather than the sharded ones, because
+// some dumps use the output from other classes (e.g. base classes) which may not be in the
+// same shard. Also some of the dump files ("apis") may be slow even when sharded, because
+// the output contains the information from all the input classes, rather than the output classes.
+// Not using sharding is fine for this module because it's only used for collecting the
+// dump / stats files, which don't have to happen regularly.
+java_genrule {
+ name: "framework-minus-apex.ravenwood-base_all",
+ defaults: ["framework-minus-apex.ravenwood-base_defaults"],
+ cmd: framework_minus_apex_cmd +
+ "--stats-file $(location hoststubgen_framework-minus-apex_stats.csv) " +
+ "--supported-api-list-file $(location hoststubgen_framework-minus-apex_apis.csv) " +
+
+ "--gen-keep-all-file $(location hoststubgen_framework-minus-apex_keep_all.txt) " +
+ "--gen-input-dump-file $(location hoststubgen_framework-minus-apex_dump.txt) ",
+
+ out: [
+ "hoststubgen_framework-minus-apex_keep_all.txt",
+ "hoststubgen_framework-minus-apex_dump.txt",
+ "hoststubgen_framework-minus-apex_stats.csv",
+ "hoststubgen_framework-minus-apex_apis.csv",
+ ],
+}
+
+// Marge all the sharded jars
+java_genrule {
+ name: "framework-minus-apex.ravenwood",
+ defaults: ["ravenwood-internal-only-visibility-java"],
+ cmd: "$(location merge_zips) $(out) $(in)",
+ tools: ["merge_zips"],
+ srcs: [
+ ":framework-minus-apex.ravenwood-base_X0{ravenwood.jar}",
+ ":framework-minus-apex.ravenwood-base_X1{ravenwood.jar}",
+ ":framework-minus-apex.ravenwood-base_X2{ravenwood.jar}",
+ ":framework-minus-apex.ravenwood-base_X3{ravenwood.jar}",
+ ":framework-minus-apex.ravenwood-base_X4{ravenwood.jar}",
+ ":framework-minus-apex.ravenwood-base_X5{ravenwood.jar}",
+ ":framework-minus-apex.ravenwood-base_X6{ravenwood.jar}",
+ ":framework-minus-apex.ravenwood-base_X7{ravenwood.jar}",
+ ":framework-minus-apex.ravenwood-base_X8{ravenwood.jar}",
+ ":framework-minus-apex.ravenwood-base_X9{ravenwood.jar}",
+ ],
+ out: [
+ "framework-minus-apex.ravenwood.jar",
+ ],
+}
+
+//////////////////
+// services.core
+//////////////////
+
+java_library {
+ name: "services.core-for-host",
+ installable: false, // host only jar.
+ static_libs: [
+ "services.core",
+ ],
+ sdk_version: "core_platform",
+ visibility: ["//visibility:private"],
+}
+
+java_genrule {
+ name: "services.core.ravenwood-base",
+ tools: ["hoststubgen"],
+ cmd: "$(location hoststubgen) " +
+ "@$(location :ravenwood-standard-options) " +
+
+ "--debug-log $(location hoststubgen_services.core.log) " +
+ "--stats-file $(location hoststubgen_services.core_stats.csv) " +
+ "--supported-api-list-file $(location hoststubgen_services.core_apis.csv) " +
+ "--gen-keep-all-file $(location hoststubgen_services.core_keep_all.txt) " +
+ "--gen-input-dump-file $(location hoststubgen_services.core_dump.txt) " +
+
+ "--out-jar $(location ravenwood.jar) " +
+ "--in-jar $(location :services.core-for-host) " +
+
+ "--policy-override-file $(location :ravenwood-common-policies) " +
+ "--policy-override-file $(location :ravenwood-services-policies) " +
+ "--annotation-allowed-classes-file $(location :ravenwood-annotation-allowed-classes) ",
+ srcs: [
+ ":services.core-for-host",
+ ":ravenwood-common-policies",
+ ":ravenwood-services-policies",
+ ":ravenwood-standard-options",
+ ":ravenwood-annotation-allowed-classes",
+ ],
+ out: [
+ "ravenwood.jar",
+
+ // Following files are created just as FYI.
+ "hoststubgen_services.core_keep_all.txt",
+ "hoststubgen_services.core_dump.txt",
+
+ "hoststubgen_services.core.log",
+ "hoststubgen_services.core_stats.csv",
+ "hoststubgen_services.core_apis.csv",
+ ],
+ visibility: ["//visibility:private"],
+}
+
+java_genrule {
+ name: "services.core.ravenwood",
+ defaults: ["ravenwood-internal-only-visibility-genrule"],
+ cmd: "cp $(in) $(out)",
+ srcs: [
+ ":services.core.ravenwood-base{ravenwood.jar}",
+ ],
+ out: [
+ "services.core.ravenwood.jar",
+ ],
+}
+
+// TODO(b/313930116) This jarjar is a bit slow. We should use hoststubgen for renaming,
+// but services.core.ravenwood has complex dependencies, so it'll take more than
+// just using hoststubgen "rename"s.
+java_library {
+ name: "services.core.ravenwood-jarjar",
+ defaults: ["ravenwood-internal-only-visibility-java"],
+ installable: false,
+ static_libs: [
+ "services.core.ravenwood",
+ ],
+ jarjar_rules: ":ravenwood-services-jarjar-rules",
+}
+
+///////////////
+// core-icu4j
+///////////////
+
+java_genrule {
+ name: "core-icu4j-for-host.ravenwood-base",
+ tools: ["hoststubgen"],
+ cmd: "$(location hoststubgen) " +
+ "@$(location :ravenwood-standard-options) " +
+
+ "--debug-log $(location hoststubgen_core-icu4j-for-host.log) " +
+ "--stats-file $(location hoststubgen_core-icu4j-for-host_stats.csv) " +
+ "--supported-api-list-file $(location hoststubgen_core-icu4j-for-host_apis.csv) " +
+ "--gen-keep-all-file $(location hoststubgen_core-icu4j-for-host_keep_all.txt) " +
+ "--gen-input-dump-file $(location hoststubgen_core-icu4j-for-host_dump.txt) " +
+
+ "--out-jar $(location ravenwood.jar) " +
+ "--in-jar $(location :core-icu4j-for-host) " +
+
+ "--policy-override-file $(location :ravenwood-common-policies) " +
+ "--policy-override-file $(location :icu-ravenwood-policies) ",
+ srcs: [
+ ":core-icu4j-for-host",
+
+ ":ravenwood-common-policies",
+ ":icu-ravenwood-policies",
+ ":ravenwood-standard-options",
+ ],
+ out: [
+ "ravenwood.jar",
+
+ // Following files are created just as FYI.
+ "hoststubgen_core-icu4j-for-host_keep_all.txt",
+ "hoststubgen_core-icu4j-for-host_dump.txt",
+
+ "hoststubgen_core-icu4j-for-host.log",
+ "hoststubgen_core-icu4j-for-host_stats.csv",
+ "hoststubgen_core-icu4j-for-host_apis.csv",
+ ],
+ visibility: ["//visibility:private"],
+}
+
+java_genrule {
+ name: "core-icu4j-for-host.ravenwood",
+ defaults: ["ravenwood-internal-only-visibility-genrule"],
+ cmd: "cp $(in) $(out)",
+ srcs: [
+ ":core-icu4j-for-host.ravenwood-base{ravenwood.jar}",
+ ],
+ out: [
+ "core-icu4j-for-host.ravenwood.jar",
+ ],
+}
diff --git a/ravenwood/texts/ravenwood-common-policies.txt b/ravenwood/texts/ravenwood-common-policies.txt
new file mode 100644
index 0000000..08f53977
--- /dev/null
+++ b/ravenwood/texts/ravenwood-common-policies.txt
@@ -0,0 +1,20 @@
+# Ravenwood "policy" that should apply to all code.
+
+# Keep all AIDL interfaces
+class :aidl keepclass
+
+# Keep all feature flag implementations
+class :feature_flags keepclass
+
+# Keep all sysprops generated code implementations
+class :sysprops keepclass
+
+# Keep all resource R classes
+class :r keepclass
+
+# Support APIs not available in standard JRE
+class java.io.FileDescriptor keep
+ method getInt$ ()I @com.android.ravenwood.RavenwoodJdkPatch.getInt$
+ method setInt$ (I)V @com.android.ravenwood.RavenwoodJdkPatch.setInt$
+class java.util.LinkedHashMap keep
+ method eldest ()Ljava/util/Map$Entry; @com.android.ravenwood.RavenwoodJdkPatch.eldest
diff --git a/ravenwood/texts/ravenwood-framework-policies.txt b/ravenwood/texts/ravenwood-framework-policies.txt
index d962c82..3649f0e 100644
--- a/ravenwood/texts/ravenwood-framework-policies.txt
+++ b/ravenwood/texts/ravenwood-framework-policies.txt
@@ -1,29 +1,10 @@
# Ravenwood "policy" file for framework-minus-apex.
-# Keep all AIDL interfaces
-class :aidl keepclass
-
-# Keep all feature flag implementations
-class :feature_flags keepclass
-
-# Keep all sysprops generated code implementations
-class :sysprops keepclass
-
-# Keep all resource R classes
-class :r keepclass
-
# To avoid VerifyError on nano proto files (b/324063814), we rename nano proto classes.
# Note: The "rename" directive must use slashes (/) as a package name separator.
rename com/.*/nano/ devicenano/
rename android/.*/nano/ devicenano/
-# Support APIs not available in standard JRE
-class java.io.FileDescriptor keep
- method getInt$ ()I @com.android.ravenwood.RavenwoodJdkPatch.getInt$
- method setInt$ (I)V @com.android.ravenwood.RavenwoodJdkPatch.setInt$
-class java.util.LinkedHashMap keep
- method eldest ()Ljava/util/Map$Entry; @com.android.ravenwood.RavenwoodJdkPatch.eldest
-
# Exported to Mainline modules; cannot use annotations
class com.android.internal.util.FastXmlSerializer keepclass
class com.android.internal.util.FileRotator keepclass
diff --git a/ravenwood/texts/ravenwood-services-policies.txt b/ravenwood/texts/ravenwood-services-policies.txt
index 5cdb4f7..cc2fa60 100644
--- a/ravenwood/texts/ravenwood-services-policies.txt
+++ b/ravenwood/texts/ravenwood-services-policies.txt
@@ -1,7 +1 @@
# Ravenwood "policy" file for services.core.
-
-# Keep all AIDL interfaces
-class :aidl keepclass
-
-# Keep all feature flag implementations
-class :feature_flags keepclass
diff --git a/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java b/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java
index c5fef19..5d57408 100644
--- a/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java
+++ b/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java
@@ -65,8 +65,6 @@
import com.android.internal.infra.AndroidFuture;
import com.android.internal.util.DumpUtils;
import com.android.server.SystemService.TargetUser;
-import com.android.server.appfunctions.RemoteServiceCaller.RunServiceCallCallback;
-import com.android.server.appfunctions.RemoteServiceCaller.ServiceUsageCompleteListener;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -233,6 +231,9 @@
"Caller does not have permission to execute the"
+ " appfunction",
/* extras= */ null));
+ throw new SecurityException(
+ "Caller does not have permission to execute the"
+ + " appfunction");
}
})
.thenCompose(
@@ -380,7 +381,8 @@
runtimeMetadataSearchSession));
AppFunctionRuntimeMetadata newMetadata =
new AppFunctionRuntimeMetadata.Builder(existingMetadata)
- .setEnabled(enabledState).build();
+ .setEnabled(enabledState)
+ .build();
AppSearchBatchResult<String, Void> putDocumentBatchResult =
runtimeMetadataSearchSession
.put(
diff --git a/services/companion/java/com/android/server/companion/virtual/VirtualDeviceImpl.java b/services/companion/java/com/android/server/companion/virtual/VirtualDeviceImpl.java
index 2968ff3d..281a2ce 100644
--- a/services/companion/java/com/android/server/companion/virtual/VirtualDeviceImpl.java
+++ b/services/companion/java/com/android/server/companion/virtual/VirtualDeviceImpl.java
@@ -33,7 +33,6 @@
import static android.companion.virtual.VirtualDeviceParams.POLICY_TYPE_RECENTS;
import static android.companion.virtualdevice.flags.Flags.virtualCameraServiceDiscovery;
-import android.annotation.EnforcePermission;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
@@ -98,7 +97,6 @@
import android.os.IBinder;
import android.os.LocaleList;
import android.os.Looper;
-import android.os.PermissionEnforcer;
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.ResultReceiver;
@@ -405,7 +403,6 @@
VirtualDeviceParams params,
DisplayManagerGlobal displayManager,
VirtualCameraController virtualCameraController) {
- super(PermissionEnforcer.fromContext(context));
mVirtualDeviceLog = virtualDeviceLog;
mOwnerPackageName = attributionSource.getPackageName();
mAttributionSource = attributionSource;
@@ -565,10 +562,8 @@
* object is created before the returned VirtualDeviceInternal one.
*/
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void setListeners(@NonNull IVirtualDeviceActivityListener activityListener,
@NonNull IVirtualDeviceSoundEffectListener soundEffectListener) {
- super.setListeners_enforcePermission();
mActivityListener = Objects.requireNonNull(activityListener);
mSoundEffectListener = Objects.requireNonNull(soundEffectListener);
}
@@ -615,9 +610,8 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void goToSleep() {
- super.goToSleep_enforcePermission();
+ checkCallerIsDeviceOwner();
synchronized (mVirtualDeviceLock) {
mRequestedToBeAwake = false;
}
@@ -630,9 +624,8 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void wakeUp() {
- super.wakeUp_enforcePermission();
+ checkCallerIsDeviceOwner();
synchronized (mVirtualDeviceLock) {
mRequestedToBeAwake = true;
if (mLockdownActive) {
@@ -650,16 +643,12 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void launchPendingIntent(int displayId, PendingIntent pendingIntent,
ResultReceiver resultReceiver) {
- super.launchPendingIntent_enforcePermission();
+ checkCallerIsDeviceOwner();
Objects.requireNonNull(pendingIntent);
synchronized (mVirtualDeviceLock) {
- if (!mVirtualDisplays.contains(displayId)) {
- throw new SecurityException("Display ID " + displayId
- + " not found for this virtual device");
- }
+ checkDisplayOwnedByVirtualDeviceLocked(displayId);
}
if (pendingIntent.isActivity()) {
try {
@@ -691,9 +680,8 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void addActivityPolicyExemption(@NonNull ActivityPolicyExemption exemption) {
- super.addActivityPolicyExemption_enforcePermission();
+ checkCallerIsDeviceOwner();
final int displayId = exemption.getDisplayId();
if (exemption.getComponentName() == null || displayId != Display.INVALID_DISPLAY) {
if (!android.companion.virtualdevice.flags.Flags.activityControlApi()) {
@@ -729,9 +717,8 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void removeActivityPolicyExemption(@NonNull ActivityPolicyExemption exemption) {
- super.removeActivityPolicyExemption_enforcePermission();
+ checkCallerIsDeviceOwner();
final int displayId = exemption.getDisplayId();
if (exemption.getComponentName() == null || displayId != Display.INVALID_DISPLAY) {
if (!android.companion.virtualdevice.flags.Flags.activityControlApi()) {
@@ -782,9 +769,7 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void close() {
- super.close_enforcePermission();
// Remove about-to-be-closed virtual device from the service before butchering it.
if (!mService.removeVirtualDevice(mDeviceId)) {
// Device is already closed.
@@ -859,11 +844,10 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void onAudioSessionStarting(int displayId,
@NonNull IAudioRoutingCallback routingCallback,
@Nullable IAudioConfigChangedCallback configChangedCallback) {
- super.onAudioSessionStarting_enforcePermission();
+ checkCallerIsDeviceOwner();
synchronized (mVirtualDeviceLock) {
checkDisplayOwnedByVirtualDeviceLocked(displayId);
if (mVirtualAudioController == null) {
@@ -877,9 +861,8 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void onAudioSessionEnded() {
- super.onAudioSessionEnded_enforcePermission();
+ checkCallerIsDeviceOwner();
synchronized (mVirtualDeviceLock) {
if (mVirtualAudioController != null) {
mVirtualAudioController.stopListening();
@@ -889,10 +872,9 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void setDevicePolicy(@VirtualDeviceParams.DynamicPolicyType int policyType,
@VirtualDeviceParams.DevicePolicy int devicePolicy) {
- super.setDevicePolicy_enforcePermission();
+ checkCallerIsDeviceOwner();
if (!Flags.dynamicPolicy()) {
return;
}
@@ -927,7 +909,7 @@
break;
case POLICY_TYPE_CLIPBOARD:
if (Flags.crossDeviceClipboard()) {
- if (policyType == DEVICE_POLICY_CUSTOM
+ if (devicePolicy == DEVICE_POLICY_CUSTOM
&& mContext.checkCallingOrSelfPermission(ADD_TRUSTED_DISPLAY)
!= PackageManager.PERMISSION_GRANTED) {
throw new SecurityException("Requires ADD_TRUSTED_DISPLAY permission to "
@@ -959,11 +941,10 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void setDevicePolicyForDisplay(int displayId,
@VirtualDeviceParams.DynamicDisplayPolicyType int policyType,
@VirtualDeviceParams.DevicePolicy int devicePolicy) {
- super.setDevicePolicyForDisplay_enforcePermission();
+ checkCallerIsDeviceOwner();
if (!android.companion.virtualdevice.flags.Flags.activityControlApi()) {
return;
}
@@ -989,9 +970,8 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void createVirtualDpad(VirtualDpadConfig config, @NonNull IBinder deviceToken) {
- super.createVirtualDpad_enforcePermission();
+ checkCallerIsDeviceOwner();
Objects.requireNonNull(config);
checkVirtualInputDeviceDisplayIdAssociation(config.getAssociatedDisplayId());
final long ident = Binder.clearCallingIdentity();
@@ -1007,9 +987,8 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void createVirtualKeyboard(VirtualKeyboardConfig config, @NonNull IBinder deviceToken) {
- super.createVirtualKeyboard_enforcePermission();
+ checkCallerIsDeviceOwner();
Objects.requireNonNull(config);
checkVirtualInputDeviceDisplayIdAssociation(config.getAssociatedDisplayId());
final long ident = Binder.clearCallingIdentity();
@@ -1029,9 +1008,8 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void createVirtualMouse(VirtualMouseConfig config, @NonNull IBinder deviceToken) {
- super.createVirtualMouse_enforcePermission();
+ checkCallerIsDeviceOwner();
Objects.requireNonNull(config);
checkVirtualInputDeviceDisplayIdAssociation(config.getAssociatedDisplayId());
final long ident = Binder.clearCallingIdentity();
@@ -1046,10 +1024,9 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void createVirtualTouchscreen(VirtualTouchscreenConfig config,
@NonNull IBinder deviceToken) {
- super.createVirtualTouchscreen_enforcePermission();
+ checkCallerIsDeviceOwner();
Objects.requireNonNull(config);
checkVirtualInputDeviceDisplayIdAssociation(config.getAssociatedDisplayId());
final long ident = Binder.clearCallingIdentity();
@@ -1065,10 +1042,9 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void createVirtualNavigationTouchpad(VirtualNavigationTouchpadConfig config,
@NonNull IBinder deviceToken) {
- super.createVirtualNavigationTouchpad_enforcePermission();
+ checkCallerIsDeviceOwner();
Objects.requireNonNull(config);
checkVirtualInputDeviceDisplayIdAssociation(config.getAssociatedDisplayId());
final long ident = Binder.clearCallingIdentity();
@@ -1086,10 +1062,9 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void createVirtualStylus(@NonNull VirtualStylusConfig config,
@NonNull IBinder deviceToken) {
- super.createVirtualStylus_enforcePermission();
+ checkCallerIsDeviceOwner();
Objects.requireNonNull(config);
Objects.requireNonNull(deviceToken);
checkVirtualInputDeviceDisplayIdAssociation(config.getAssociatedDisplayId());
@@ -1106,10 +1081,9 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void createVirtualRotaryEncoder(@NonNull VirtualRotaryEncoderConfig config,
@NonNull IBinder deviceToken) {
- super.createVirtualRotaryEncoder_enforcePermission();
+ checkCallerIsDeviceOwner();
Objects.requireNonNull(config);
Objects.requireNonNull(deviceToken);
checkVirtualInputDeviceDisplayIdAssociation(config.getAssociatedDisplayId());
@@ -1126,9 +1100,8 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void unregisterInputDevice(IBinder token) {
- super.unregisterInputDevice_enforcePermission();
+ checkCallerIsDeviceOwner();
final long ident = Binder.clearCallingIdentity();
try {
mInputController.unregisterInputDevice(token);
@@ -1138,9 +1111,7 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public int getInputDeviceId(IBinder token) {
- super.getInputDeviceId_enforcePermission();
final long ident = Binder.clearCallingIdentity();
try {
return mInputController.getInputDeviceId(token);
@@ -1151,9 +1122,8 @@
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public boolean sendDpadKeyEvent(IBinder token, VirtualKeyEvent event) {
- super.sendDpadKeyEvent_enforcePermission();
+ checkCallerIsDeviceOwner();
final long ident = Binder.clearCallingIdentity();
try {
return mInputController.sendDpadKeyEvent(token, event);
@@ -1163,9 +1133,8 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public boolean sendKeyEvent(IBinder token, VirtualKeyEvent event) {
- super.sendKeyEvent_enforcePermission();
+ checkCallerIsDeviceOwner();
final long ident = Binder.clearCallingIdentity();
try {
return mInputController.sendKeyEvent(token, event);
@@ -1175,9 +1144,8 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public boolean sendButtonEvent(IBinder token, VirtualMouseButtonEvent event) {
- super.sendButtonEvent_enforcePermission();
+ checkCallerIsDeviceOwner();
final long ident = Binder.clearCallingIdentity();
try {
return mInputController.sendButtonEvent(token, event);
@@ -1187,9 +1155,8 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public boolean sendTouchEvent(IBinder token, VirtualTouchEvent event) {
- super.sendTouchEvent_enforcePermission();
+ checkCallerIsDeviceOwner();
final long ident = Binder.clearCallingIdentity();
try {
return mInputController.sendTouchEvent(token, event);
@@ -1199,9 +1166,8 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public boolean sendRelativeEvent(IBinder token, VirtualMouseRelativeEvent event) {
- super.sendRelativeEvent_enforcePermission();
+ checkCallerIsDeviceOwner();
final long ident = Binder.clearCallingIdentity();
try {
return mInputController.sendRelativeEvent(token, event);
@@ -1211,9 +1177,8 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public boolean sendScrollEvent(IBinder token, VirtualMouseScrollEvent event) {
- super.sendScrollEvent_enforcePermission();
+ checkCallerIsDeviceOwner();
final long ident = Binder.clearCallingIdentity();
try {
return mInputController.sendScrollEvent(token, event);
@@ -1223,9 +1188,7 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public PointF getCursorPosition(IBinder token) {
- super.getCursorPosition_enforcePermission();
final long ident = Binder.clearCallingIdentity();
try {
return mInputController.getCursorPosition(token);
@@ -1235,10 +1198,9 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public boolean sendStylusMotionEvent(@NonNull IBinder token,
@NonNull VirtualStylusMotionEvent event) {
- super.sendStylusMotionEvent_enforcePermission();
+ checkCallerIsDeviceOwner();
Objects.requireNonNull(token);
Objects.requireNonNull(event);
final long ident = Binder.clearCallingIdentity();
@@ -1250,10 +1212,9 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public boolean sendStylusButtonEvent(@NonNull IBinder token,
@NonNull VirtualStylusButtonEvent event) {
- super.sendStylusButtonEvent_enforcePermission();
+ checkCallerIsDeviceOwner();
Objects.requireNonNull(token);
Objects.requireNonNull(event);
final long ident = Binder.clearCallingIdentity();
@@ -1265,10 +1226,9 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public boolean sendRotaryEncoderScrollEvent(@NonNull IBinder token,
@NonNull VirtualRotaryEncoderScrollEvent event) {
- super.sendRotaryEncoderScrollEvent_enforcePermission();
+ checkCallerIsDeviceOwner();
final long ident = Binder.clearCallingIdentity();
try {
return mInputController.sendRotaryEncoderScrollEvent(token, event);
@@ -1278,9 +1238,8 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void setShowPointerIcon(boolean showPointerIcon) {
- super.setShowPointerIcon_enforcePermission();
+ checkCallerIsDeviceOwner();
final long ident = Binder.clearCallingIdentity();
try {
synchronized (mVirtualDeviceLock) {
@@ -1299,14 +1258,10 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void setDisplayImePolicy(int displayId, @WindowManager.DisplayImePolicy int policy) {
- super.setDisplayImePolicy_enforcePermission();
+ checkCallerIsDeviceOwner();
synchronized (mVirtualDeviceLock) {
- if (!mVirtualDisplays.contains(displayId)) {
- throw new SecurityException("Display ID " + displayId
- + " not found for this virtual device");
- }
+ checkDisplayOwnedByVirtualDeviceLocked(displayId);
}
final long ident = Binder.clearCallingIdentity();
try {
@@ -1317,10 +1272,9 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@Nullable
public List<VirtualSensor> getVirtualSensorList() {
- super.getVirtualSensorList_enforcePermission();
+ checkCallerIsDeviceOwner();
return mSensorController.getSensorList();
}
@@ -1330,9 +1284,8 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public boolean sendSensorEvent(@NonNull IBinder token, @NonNull VirtualSensorEvent event) {
- super.sendSensorEvent_enforcePermission();
+ checkCallerIsDeviceOwner();
final long ident = Binder.clearCallingIdentity();
try {
return mSensorController.sendSensorEvent(token, event);
@@ -1342,10 +1295,9 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void registerIntentInterceptor(IVirtualDeviceIntentInterceptor intentInterceptor,
IntentFilter filter) {
- super.registerIntentInterceptor_enforcePermission();
+ checkCallerIsDeviceOwner();
Objects.requireNonNull(intentInterceptor);
Objects.requireNonNull(filter);
synchronized (mVirtualDeviceLock) {
@@ -1354,10 +1306,9 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void unregisterIntentInterceptor(
@NonNull IVirtualDeviceIntentInterceptor intentInterceptor) {
- super.unregisterIntentInterceptor_enforcePermission();
+ checkCallerIsDeviceOwner();
Objects.requireNonNull(intentInterceptor);
synchronized (mVirtualDeviceLock) {
mIntentInterceptors.remove(intentInterceptor.asBinder());
@@ -1365,10 +1316,9 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void registerVirtualCamera(@NonNull VirtualCameraConfig cameraConfig)
throws RemoteException {
- super.registerVirtualCamera_enforcePermission();
+ checkCallerIsDeviceOwner();
Objects.requireNonNull(cameraConfig);
if (mVirtualCameraController == null) {
throw new UnsupportedOperationException("Virtual camera controller is not available");
@@ -1377,10 +1327,9 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void unregisterVirtualCamera(@NonNull VirtualCameraConfig cameraConfig)
throws RemoteException {
- super.unregisterVirtualCamera_enforcePermission();
+ checkCallerIsDeviceOwner();
Objects.requireNonNull(cameraConfig);
if (mVirtualCameraController == null) {
throw new UnsupportedOperationException("Virtual camera controller is not available");
@@ -1389,10 +1338,8 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public String getVirtualCameraId(@NonNull VirtualCameraConfig cameraConfig)
throws RemoteException {
- super.getVirtualCameraId_enforcePermission();
Objects.requireNonNull(cameraConfig);
if (mVirtualCameraController == null) {
throw new UnsupportedOperationException("Virtual camera controller is not available");
@@ -1515,10 +1462,9 @@
}
@Override // Binder call
- @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public int createVirtualDisplay(@NonNull VirtualDisplayConfig virtualDisplayConfig,
@NonNull IVirtualDisplayCallback callback) {
- super.createVirtualDisplay_enforcePermission();
+ checkCallerIsDeviceOwner();
GenericWindowPolicyController gwpc;
synchronized (mVirtualDeviceLock) {
gwpc = createWindowPolicyControllerLocked(virtualDisplayConfig.getDisplayCategories());
@@ -1683,6 +1629,13 @@
}
}
+ private void checkCallerIsDeviceOwner() {
+ if (Binder.getCallingUid() != mOwnerUid) {
+ throw new SecurityException(
+ "Caller is not the owner of this virtual device");
+ }
+ }
+
void goToSleepInternal(@PowerManager.GoToSleepReason int reason) {
final long now = SystemClock.uptimeMillis();
synchronized (mVirtualDeviceLock) {
diff --git a/services/companion/java/com/android/server/companion/virtual/VirtualDeviceManagerService.java b/services/companion/java/com/android/server/companion/virtual/VirtualDeviceManagerService.java
index 41b6a85..f87e3c3 100644
--- a/services/companion/java/com/android/server/companion/virtual/VirtualDeviceManagerService.java
+++ b/services/companion/java/com/android/server/companion/virtual/VirtualDeviceManagerService.java
@@ -21,6 +21,7 @@
import static com.android.server.wm.ActivityInterceptorCallback.VIRTUAL_DEVICE_SERVICE_ORDERED_ID;
+import android.annotation.EnforcePermission;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
@@ -122,7 +123,6 @@
private final CompanionDeviceManager.OnAssociationsChangedListener mCdmAssociationListener =
new CompanionDeviceManager.OnAssociationsChangedListener() {
@Override
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
public void onAssociationsChanged(@NonNull List<AssociationInfo> associations) {
syncVirtualDevicesToCdmAssociations(associations);
}
@@ -339,7 +339,6 @@
return true;
}
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
private void syncVirtualDevicesToCdmAssociations(List<AssociationInfo> associations) {
Set<VirtualDeviceImpl> virtualDevicesToRemove = new HashSet<>();
synchronized (mVirtualDeviceManagerLock) {
@@ -382,7 +381,6 @@
cdm.removeOnAssociationsChangedListener(mCdmAssociationListener);
}
- @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
void onCdmAssociationsChanged(List<AssociationInfo> associations) {
ArrayMap<String, AssociationInfo> vdmAssociations = new ArrayMap<>();
for (int i = 0; i < associations.size(); ++i) {
@@ -452,7 +450,7 @@
}
};
- @android.annotation.EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
+ @EnforcePermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@Override // Binder call
public IVirtualDevice createVirtualDevice(
IBinder token,
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index bcca20b..f42f91e 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -12824,6 +12824,8 @@
final long lostRAM = memInfo.getTotalSizeKb()
- (ss[INDEX_TOTAL_PSS] - ss[INDEX_TOTAL_SWAP_PSS])
- memInfo.getFreeSizeKb() - memInfo.getCachedSizeKb()
+ // NR_SHMEM is subtracted twice (getCachedSizeKb() and getKernelUsedSizeKb())
+ + memInfo.getShmemSizeKb()
- kernelUsed - memInfo.getZramTotalSizeKb();
if (!opts.isCompact) {
pw.print(" Used RAM: "); pw.print(stringifyKBSize(ss[INDEX_TOTAL_PSS] - cachedPss
@@ -13337,6 +13339,8 @@
long lostRAM = memInfo.getTotalSizeKb()
- (ss[INDEX_TOTAL_PSS] - ss[INDEX_TOTAL_SWAP_PSS])
- memInfo.getFreeSizeKb() - memInfo.getCachedSizeKb()
+ // NR_SHMEM is subtracted twice (getCachedSizeKb() and getKernelUsedSizeKb())
+ + memInfo.getShmemSizeKb()
- memInfo.getKernelUsedSizeKb() - memInfo.getZramTotalSizeKb();
proto.write(MemInfoDumpProto.USED_PSS_KB, ss[INDEX_TOTAL_PSS] - cachedPss);
proto.write(MemInfoDumpProto.USED_KERNEL_KB, memInfo.getKernelUsedSizeKb());
diff --git a/services/core/java/com/android/server/am/ProcessList.java b/services/core/java/com/android/server/am/ProcessList.java
index 2485626..5236b03 100644
--- a/services/core/java/com/android/server/am/ProcessList.java
+++ b/services/core/java/com/android/server/am/ProcessList.java
@@ -3629,42 +3629,68 @@
}
@GuardedBy({"mService", "mProcLock"})
- private int updateLruProcessInternalLSP(ProcessRecord app, long now, int index,
- int lruSeq, String what, Object obj, ProcessRecord srcApp) {
+ private int offerLruProcessInternalLSP(ProcessRecord app, long now, String what, Object obj,
+ ProcessRecord srcApp) {
app.setLastActivityTime(now);
if (app.hasActivitiesOrRecentTasks()) {
// Don't want to touch dependent processes that are hosting activities.
- return index;
+ return -1;
}
- int lrui = mLruProcesses.lastIndexOf(app);
+ final int lrui = mLruProcesses.lastIndexOf(app);
if (lrui < 0) {
Slog.wtf(TAG, "Adding dependent process " + app + " not on LRU list: "
+ what + " " + obj + " from " + srcApp);
- return index;
}
+ return lrui;
+ }
- if (lrui >= index) {
- // Don't want to cause this to move dependent processes *back* in the
- // list as if they were less frequently used.
- return index;
- }
+ /**
+ * This method is called after the indices array is populated by the indices offered by
+ * {@link #offerLruProcessInternalLSP} to actually move the processes to the desired locations
+ * in the LRU list. Since the indices array is a SparseBooleanArray, the indices are sorted
+ * and this allows us to preserve the previous order of the processes relative to each other.
+ * Key of the indices array holds the current index of the process in the LRU list and the value
+ * is a boolean indicating whether the process is an activity process or not. Activity processes
+ * are moved to the nextActivityIndex and non-activity processes are moved to the nextIndex
+ * positions, which are provided by the caller.
+ *
+ * @param indices The indices of the processes to move.
+ * @param nextActivityIndex The next index to insert an activity process.
+ * @param nextIndex The next index to insert a non-activity process.
+ */
+ @GuardedBy({"mService", "mProcLock"})
+ private void completeLruProcessInternalLSP(SparseBooleanArray indices, int nextActivityIndex,
+ int nextIndex) {
+ for (int i = indices.size() - 1; i >= 0; i--) {
+ final int lrui = indices.keyAt(i);
+ if (lrui < 0) {
+ // Rest of the indices are invalid, we can return early.
+ return;
+ }
+ final boolean isActivity = indices.valueAt(i);
+ int index = isActivity ? nextActivityIndex : nextIndex;
- if (lrui >= mLruProcessActivityStart && index < mLruProcessActivityStart) {
- // Don't want to touch dependent processes that are hosting activities.
- return index;
- }
+ if (lrui >= index) {
+ // Don't want to cause this to move dependent processes *back* in the
+ // list as if they were less frequently used.
+ continue;
+ }
- mLruProcesses.remove(lrui);
- if (index > 0) {
+ final ProcessRecord app = mLruProcesses.remove(lrui);
index--;
+ if (DEBUG_LRU) Slog.d(TAG_LRU, "Moving dep from " + lrui + " to " + index
+ + " in LRU list: " + app);
+ mLruProcesses.add(index, app);
+ app.setLruSeq(mLruSeq);
+
+ if (isActivity) {
+ nextActivityIndex = index;
+ } else {
+ nextIndex = index;
+ }
}
- if (DEBUG_LRU) Slog.d(TAG_LRU, "Moving dep from " + lrui + " to " + index
- + " in LRU list: " + app);
- mLruProcesses.add(index, app);
- app.setLruSeq(lruSeq);
- return index;
}
/**
@@ -4058,6 +4084,15 @@
app.setLruSeq(mLruSeq);
+ // Key of the indices array holds the current index of the process in the LRU list and the
+ // value is a boolean indicating whether the process is an activity process or not.
+ // Activity processes will be moved to the nextActivityIndex and non-activity processes will
+ // be moved to the nextIndex positions when completeLruProcessInternalLSP is called.
+ // Since SparseBooleanArray's keys are sorted, we'll be able to keep the existing order of
+ // the processes relative to each other after the move.
+ final SparseBooleanArray indices = new SparseBooleanArray(psr.numberOfConnections()
+ + app.mProviders.numberOfProviderConnections());
+
// If the app is currently using a content provider or service,
// bump those processes as well.
for (int j = psr.numberOfConnections() - 1; j >= 0; j--) {
@@ -4069,16 +4104,12 @@
&& !cr.binding.service.app.isPersistent()) {
if (cr.binding.service.app.mServices.hasClientActivities()) {
if (nextActivityIndex >= 0) {
- nextActivityIndex = updateLruProcessInternalLSP(cr.binding.service.app,
- now,
- nextActivityIndex, mLruSeq,
- "service connection", cr, app);
+ indices.append(offerLruProcessInternalLSP(cr.binding.service.app, now,
+ "service connection", cr, app), true);
}
} else {
- nextIndex = updateLruProcessInternalLSP(cr.binding.service.app,
- now,
- nextIndex, mLruSeq,
- "service connection", cr, app);
+ indices.append(offerLruProcessInternalLSP(cr.binding.service.app, now,
+ "service connection", cr, app), false);
}
}
}
@@ -4086,10 +4117,11 @@
for (int j = ppr.numberOfProviderConnections() - 1; j >= 0; j--) {
ContentProviderRecord cpr = ppr.getProviderConnectionAt(j).provider;
if (cpr.proc != null && cpr.proc.getLruSeq() != mLruSeq && !cpr.proc.isPersistent()) {
- nextIndex = updateLruProcessInternalLSP(cpr.proc, now, nextIndex, mLruSeq,
- "provider reference", cpr, app);
+ indices.append(offerLruProcessInternalLSP(cpr.proc, now,
+ "provider reference", cpr, app), false);
}
}
+ completeLruProcessInternalLSP(indices, nextActivityIndex, nextIndex);
}
@GuardedBy(anyOf = {"mService", "mProcLock"})
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index d206b20..fdf7dec 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -286,7 +286,6 @@
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.CancellationException;
-import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
@@ -8049,7 +8048,14 @@
}
synchronized (mAbsoluteVolumeDeviceInfoMapLock) {
if (mAbsoluteVolumeDeviceInfoMap.containsKey(audioSystemDeviceOut)) {
- return mAbsoluteVolumeDeviceInfoMap.get(audioSystemDeviceOut).mDeviceVolumeBehavior;
+ final AbsoluteVolumeDeviceInfo deviceInfo = mAbsoluteVolumeDeviceInfoMap.get(
+ audioSystemDeviceOut);
+ if (deviceInfo != null) {
+ return deviceInfo.mDeviceVolumeBehavior;
+ }
+
+ Log.e(TAG,
+ "Null absolute volume device info stored for key " + audioSystemDeviceOut);
}
}
@@ -15043,6 +15049,11 @@
private void addAudioSystemDeviceOutToAbsVolumeDevices(int audioSystemDeviceOut,
AbsoluteVolumeDeviceInfo info) {
+ if (info == null) {
+ Log.e(TAG, "Cannot add null absolute volume info for audioSystemDeviceOut "
+ + audioSystemDeviceOut);
+ return;
+ }
if (DEBUG_VOL) {
Log.d(TAG, "Adding DeviceType: 0x" + Integer.toHexString(audioSystemDeviceOut)
+ " to mAbsoluteVolumeDeviceInfoMap with behavior "
diff --git a/services/core/java/com/android/server/devicestate/DeviceStateManagerService.java b/services/core/java/com/android/server/devicestate/DeviceStateManagerService.java
index 6216a58..8b9c664 100644
--- a/services/core/java/com/android/server/devicestate/DeviceStateManagerService.java
+++ b/services/core/java/com/android/server/devicestate/DeviceStateManagerService.java
@@ -778,7 +778,8 @@
processRecord.notifyRequestActiveAsync(request.getToken());
}
- private void registerProcess(int pid, IDeviceStateManagerCallback callback) {
+ @Nullable
+ private DeviceStateInfo registerProcess(int pid, IDeviceStateManagerCallback callback) {
synchronized (mLock) {
if (mProcessRecords.contains(pid)) {
throw new SecurityException("The calling process has already registered an"
@@ -794,15 +795,20 @@
}
mProcessRecords.put(pid, record);
- // Callback clients should not be notified of invalid device states, so calls to
- // #getDeviceStateInfoLocked should be gated on checks if a committed state is present
- // before getting the device state info.
final DeviceStateInfo currentInfo =
mCommittedState.isPresent() ? getDeviceStateInfoLocked() : null;
- if (currentInfo != null) {
- // If there is not a committed state we'll wait to notify the process of the initial
- // value.
- record.notifyDeviceStateInfoAsync(currentInfo);
+ if (com.android.window.flags.Flags.wlinfoOncreate()) {
+ return currentInfo;
+ } else {
+ // Callback clients should not be notified of invalid device states, so calls to
+ // #getDeviceStateInfoLocked should be gated on checks if a committed state is
+ // present before getting the device state info.
+ if (currentInfo != null) {
+ // If there is not a committed state we'll wait to notify the process of the
+ // initial value.
+ record.notifyDeviceStateInfoAsync(currentInfo);
+ }
+ return null;
}
}
}
@@ -1286,8 +1292,9 @@
}
}
+ @Nullable
@Override // Binder call
- public void registerCallback(IDeviceStateManagerCallback callback) {
+ public DeviceStateInfo registerCallback(IDeviceStateManagerCallback callback) {
if (callback == null) {
throw new IllegalArgumentException("Device state callback must not be null.");
}
@@ -1295,7 +1302,7 @@
final int callingPid = Binder.getCallingPid();
final long token = Binder.clearCallingIdentity();
try {
- registerProcess(callingPid, callback);
+ return registerProcess(callingPid, callback);
} finally {
Binder.restoreCallingIdentity(token);
}
diff --git a/services/core/java/com/android/server/display/DisplayManagerService.java b/services/core/java/com/android/server/display/DisplayManagerService.java
index a53b8df..c7a70fa 100644
--- a/services/core/java/com/android/server/display/DisplayManagerService.java
+++ b/services/core/java/com/android/server/display/DisplayManagerService.java
@@ -5666,6 +5666,11 @@
displayPowerController.stylusGestureStarted(eventTime);
}
}
+
+ @Override
+ public boolean isDisplayReadyForMirroring(int displayId) {
+ return mExternalDisplayPolicy.isDisplayReadyForMirroring(displayId);
+ }
}
class DesiredDisplayModeSpecsObserver
diff --git a/services/core/java/com/android/server/display/ExternalDisplayPolicy.java b/services/core/java/com/android/server/display/ExternalDisplayPolicy.java
index 28a0b28..f34d2cc 100644
--- a/services/core/java/com/android/server/display/ExternalDisplayPolicy.java
+++ b/services/core/java/com/android/server/display/ExternalDisplayPolicy.java
@@ -375,6 +375,54 @@
}
}
+ boolean isDisplayReadyForMirroring(int displayId) {
+ if (!mFlags.isWaitingConfirmationBeforeMirroringEnabled()) {
+ if (DEBUG) {
+ Slog.d(TAG, "isDisplayReadyForMirroring: mirroring CONFIRMED - "
+ + " flag 'waiting for confirmation before mirroring' is disabled");
+ }
+ return true;
+ }
+
+ synchronized (mSyncRoot) {
+ if (!mIsBootCompleted) {
+ if (DEBUG) {
+ Slog.d(TAG, "isDisplayReadyForMirroring: mirroring is not confirmed - "
+ + "boot is in progress");
+ }
+ return false;
+ }
+
+ var logicalDisplay = mLogicalDisplayMapper.getDisplayLocked(displayId);
+ if (logicalDisplay == null) {
+ if (DEBUG) {
+ Slog.d(TAG, "isDisplayReadyForMirroring: mirroring is not confirmed - "
+ + "logicalDisplay is null");
+ }
+ return false;
+ }
+
+ if (!isExternalDisplayLocked(logicalDisplay)) {
+ if (DEBUG) {
+ Slog.d(TAG, "isDisplayReadyForMirroring: mirroring is not confirmed - "
+ + "logicalDisplay" + logicalDisplay.getDisplayIdLocked()
+ + " type is " + logicalDisplay.getDisplayInfoLocked().type);
+ }
+ return false;
+ }
+
+ if (!logicalDisplay.isEnabledLocked()) {
+ if (DEBUG) {
+ Slog.d(TAG, "isDisplayReadyForMirroring: mirroring is not confirmed - "
+ + "logicalDisplay is disabled");
+ }
+ return false;
+ }
+ }
+
+ return true;
+ }
+
private final class SkinThermalStatusObserver extends IThermalEventListener.Stub {
@Override
public void notifyThrottling(@NonNull final Temperature temp) {
diff --git a/services/core/java/com/android/server/display/feature/DisplayManagerFlags.java b/services/core/java/com/android/server/display/feature/DisplayManagerFlags.java
index 99ced7f..b2e98bc 100644
--- a/services/core/java/com/android/server/display/feature/DisplayManagerFlags.java
+++ b/services/core/java/com/android/server/display/feature/DisplayManagerFlags.java
@@ -217,6 +217,11 @@
Flags::enableUserRefreshRateForExternalDisplay
);
+ private final FlagState mEnableWaitingConfirmationBeforeMirroring = new FlagState(
+ Flags.FLAG_ENABLE_WAITING_CONFIRMATION_BEFORE_MIRRORING,
+ Flags::enableWaitingConfirmationBeforeMirroring
+ );
+
private final FlagState mEnableBatteryStatsForAllDisplays = new FlagState(
Flags.FLAG_ENABLE_BATTERY_STATS_FOR_ALL_DISPLAYS,
Flags::enableBatteryStatsForAllDisplays
@@ -445,6 +450,14 @@
}
/**
+ * @return {@code true} if mirroring won't be enabled until boot completes and the user enables
+ * the display.
+ */
+ public boolean isWaitingConfirmationBeforeMirroringEnabled() {
+ return mEnableWaitingConfirmationBeforeMirroring.isEnabled();
+ }
+
+ /**
* @return {@code true} if battery stats is enabled for all displays, not just the primary
* display.
*/
@@ -511,6 +524,7 @@
pw.println(" " + mVirtualDisplayLimit);
pw.println(" " + mNormalBrightnessForDozeParameter);
pw.println(" " + mIdleScreenConfigInSubscribingLightSensor);
+ pw.println(" " + mEnableWaitingConfirmationBeforeMirroring);
pw.println(" " + mEnableBatteryStatsForAllDisplays);
pw.println(" " + mBlockAutobrightnessChangesOnStylusUsage);
pw.println(" " + mIsUserRefreshRateForExternalDisplayEnabled);
diff --git a/services/core/java/com/android/server/display/feature/display_flags.aconfig b/services/core/java/com/android/server/display/feature/display_flags.aconfig
index 2f04d9e..df62638 100644
--- a/services/core/java/com/android/server/display/feature/display_flags.aconfig
+++ b/services/core/java/com/android/server/display/feature/display_flags.aconfig
@@ -367,6 +367,17 @@
}
flag {
+ name: "enable_waiting_confirmation_before_mirroring"
+ namespace: "display_manager"
+ description: "Allow ContentRecorder checking whether user confirmed mirroring after boot"
+ bug: "361698995"
+ is_fixed_read_only: true
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+}
+
+flag {
name: "enable_battery_stats_for_all_displays"
namespace: "display_manager"
description: "Flag to enable battery stats for all displays."
diff --git a/services/core/java/com/android/server/input/InputSettingsObserver.java b/services/core/java/com/android/server/input/InputSettingsObserver.java
index d70bd8b..d1a6d3b 100644
--- a/services/core/java/com/android/server/input/InputSettingsObserver.java
+++ b/services/core/java/com/android/server/input/InputSettingsObserver.java
@@ -63,6 +63,12 @@
mObservers = Map.ofEntries(
Map.entry(Settings.System.getUriFor(Settings.System.POINTER_SPEED),
(reason) -> updateMousePointerSpeed()),
+ Map.entry(Settings.System.getUriFor(
+ Settings.System.MOUSE_REVERSE_VERTICAL_SCROLLING),
+ (reason) -> updateMouseReverseVerticalScrolling()),
+ Map.entry(Settings.System.getUriFor(
+ Settings.System.MOUSE_SWAP_PRIMARY_BUTTON),
+ (reason) -> updateMouseSwapPrimaryButton()),
Map.entry(Settings.System.getUriFor(Settings.System.TOUCHPAD_POINTER_SPEED),
(reason) -> updateTouchpadPointerSpeed()),
Map.entry(Settings.System.getUriFor(Settings.System.TOUCHPAD_NATURAL_SCROLLING),
@@ -163,6 +169,16 @@
mNative.setPointerSpeed(constrainPointerSpeedValue(speed));
}
+ private void updateMouseReverseVerticalScrolling() {
+ mNative.setMouseReverseVerticalScrollingEnabled(
+ InputSettings.isMouseReverseVerticalScrollingEnabled(mContext));
+ }
+
+ private void updateMouseSwapPrimaryButton() {
+ mNative.setMouseSwapPrimaryButtonEnabled(
+ InputSettings.isMouseSwapPrimaryButtonEnabled(mContext));
+ }
+
private void updateTouchpadPointerSpeed() {
mNative.setTouchpadPointerSpeed(
constrainPointerSpeedValue(InputSettings.getTouchpadPointerSpeed(mContext)));
diff --git a/services/core/java/com/android/server/input/NativeInputManagerService.java b/services/core/java/com/android/server/input/NativeInputManagerService.java
index 4404d63..21e8bcc 100644
--- a/services/core/java/com/android/server/input/NativeInputManagerService.java
+++ b/services/core/java/com/android/server/input/NativeInputManagerService.java
@@ -127,6 +127,10 @@
void setMousePointerAccelerationEnabled(int displayId, boolean enabled);
+ void setMouseReverseVerticalScrollingEnabled(boolean enabled);
+
+ void setMouseSwapPrimaryButtonEnabled(boolean enabled);
+
void setTouchpadPointerSpeed(int speed);
void setTouchpadNaturalScrollingEnabled(boolean enabled);
@@ -388,6 +392,12 @@
public native void setMousePointerAccelerationEnabled(int displayId, boolean enabled);
@Override
+ public native void setMouseReverseVerticalScrollingEnabled(boolean enabled);
+
+ @Override
+ public native void setMouseSwapPrimaryButtonEnabled(boolean enabled);
+
+ @Override
public native void setTouchpadPointerSpeed(int speed);
@Override
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
index 35b5171..939aad4 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
@@ -187,7 +187,6 @@
import com.android.server.companion.virtual.VirtualDeviceManagerInternal;
import com.android.server.input.InputManagerInternal;
import com.android.server.inputmethod.InputMethodManagerInternal.InputMethodListListener;
-import com.android.server.inputmethod.InputMethodMenuControllerNew.MenuItem;
import com.android.server.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem;
import com.android.server.pm.UserManagerInternal;
import com.android.server.statusbar.StatusBarManagerInternal;
@@ -4078,65 +4077,6 @@
}
}
- /**
- * Gets the list of Input Method Switcher Menu items and the index of the selected item.
- *
- * @param items the list of input method and subtype items.
- * @param selectedImeId the ID of the selected input method.
- * @param selectedSubtypeIndex the index of the selected subtype in the input method's array of
- * subtypes, or {@link InputMethodUtils#NOT_A_SUBTYPE_INDEX} if no
- * subtype is selected.
- * @param userId the ID of the user for which to get the menu items.
- * @return the list of menu items, and the index of the selected item,
- * or {@code -1} if no item is selected.
- */
- @GuardedBy("ImfLock.class")
- @NonNull
- private Pair<List<MenuItem>, Integer> getInputMethodPickerItems(
- @NonNull List<ImeSubtypeListItem> items, @Nullable String selectedImeId,
- int selectedSubtypeIndex, @UserIdInt int userId) {
- final var bindingController = getInputMethodBindingController(userId);
- final var settings = InputMethodSettingsRepository.get(userId);
-
- if (selectedSubtypeIndex == NOT_A_SUBTYPE_INDEX) {
- // TODO(b/351124299): Check if this fallback logic is still necessary.
- final var curSubtype = bindingController.getCurrentInputMethodSubtype();
- if (curSubtype != null) {
- final var curMethodId = bindingController.getSelectedMethodId();
- final var curImi = settings.getMethodMap().get(curMethodId);
- selectedSubtypeIndex = SubtypeUtils.getSubtypeIndexFromHashCode(
- curImi, curSubtype.hashCode());
- }
- }
-
- // No item is selected by default. When we have a list of explicitly enabled
- // subtypes, the implicit subtype is no longer listed. If the implicit one
- // is still selected, no items will be shown as selected.
- int selectedIndex = -1;
- String prevImeId = null;
- final var menuItems = new ArrayList<MenuItem>();
- for (int i = 0; i < items.size(); i++) {
- final var item = items.get(i);
- final var imeId = item.mImi.getId();
- if (imeId.equals(selectedImeId)) {
- final int subtypeIndex = item.mSubtypeIndex;
- // Check if this is the selected IME-subtype pair.
- if ((subtypeIndex == 0 && selectedSubtypeIndex == NOT_A_SUBTYPE_INDEX)
- || subtypeIndex == NOT_A_SUBTYPE_INDEX
- || subtypeIndex == selectedSubtypeIndex) {
- selectedIndex = i;
- }
- }
- final boolean hasHeader = !imeId.equals(prevImeId);
- final boolean hasDivider = hasHeader && prevImeId != null;
- prevImeId = imeId;
- menuItems.add(new MenuItem(item.mImeName, item.mSubtypeName, item.mImi,
- item.mSubtypeIndex, hasHeader, hasDivider));
- }
-
- return new Pair<>(menuItems, selectedIndex);
- }
-
@IInputMethodManagerImpl.PermissionVerified(allOf = {
Manifest.permission.INTERACT_ACROSS_USERS_FULL,
Manifest.permission.WRITE_SECURE_SETTINGS})
@@ -4973,18 +4913,21 @@
+ " preferredInputMethodSubtypeIndex=" + lastInputMethodSubtypeIndex);
}
- final var itemsAndIndex = getInputMethodPickerItems(imList,
- lastInputMethodId, lastInputMethodSubtypeIndex, userId);
- final var menuItems = itemsAndIndex.first;
- final int selectedIndex = itemsAndIndex.second;
-
- if (selectedIndex == -1) {
- Slog.w(TAG, "Switching menu shown with no item selected"
- + ", IME id: " + lastInputMethodId
- + ", subtype index: " + lastInputMethodSubtypeIndex);
+ int selectedSubtypeIndex = lastInputMethodSubtypeIndex;
+ if (selectedSubtypeIndex == NOT_A_SUBTYPE_INDEX) {
+ // TODO(b/351124299): Check if this fallback logic is still necessary.
+ final var bindingController = getInputMethodBindingController(userId);
+ final var curSubtype = bindingController.getCurrentInputMethodSubtype();
+ if (curSubtype != null) {
+ final var curMethodId = bindingController.getSelectedMethodId();
+ final var curImi = settings.getMethodMap().get(curMethodId);
+ selectedSubtypeIndex = SubtypeUtils.getSubtypeIndexFromHashCode(
+ curImi, curSubtype.hashCode());
+ }
}
- mMenuControllerNew.show(menuItems, selectedIndex, displayId, userId);
+ mMenuControllerNew.show(imList, lastInputMethodId, selectedSubtypeIndex, displayId,
+ userId);
} else {
mMenuController.showInputMethodMenuLocked(showAuxSubtypes, displayId,
lastInputMethodId, lastInputMethodSubtypeIndex, imList, userId);
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodMenuControllerNew.java b/services/core/java/com/android/server/inputmethod/InputMethodMenuControllerNew.java
index cf2cdc1..1d0e3c6 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodMenuControllerNew.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodMenuControllerNew.java
@@ -30,7 +30,6 @@
import android.annotation.UserIdInt;
import android.app.AlertDialog;
import android.content.Context;
-import android.content.DialogInterface;
import android.content.Intent;
import android.os.UserHandle;
import android.provider.Settings;
@@ -48,8 +47,11 @@
import android.widget.ImageView;
import android.widget.TextView;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.widget.RecyclerView;
+import com.android.server.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -80,18 +82,27 @@
/**
* Shows the Input Method Switcher Menu, with a list of IMEs and their subtypes.
*
- * @param items the list of menu items.
- * @param selectedIndex the index of the menu item that is selected.
- * If no other IMEs are enabled, this index will be out of reach.
- * @param displayId the ID of the display where the menu was requested.
- * @param userId the ID of the user that requested the menu.
+ * @param items the list of input method and subtype items.
+ * @param selectedImeId the ID of the selected input method.
+ * @param selectedSubtypeIndex the index of the selected subtype in the input method's array of
+ * subtypes, or {@link InputMethodUtils#NOT_A_SUBTYPE_INDEX} if no
+ * subtype is selected.
+ * @param displayId the ID of the display where the menu was requested.
+ * @param userId the ID of the user that requested the menu.
*/
@RequiresPermission(allOf = {INTERACT_ACROSS_USERS, HIDE_OVERLAY_WINDOWS})
- void show(@NonNull List<MenuItem> items, int selectedIndex, int displayId,
- @UserIdInt int userId) {
+ void show(@NonNull List<ImeSubtypeListItem> items, @Nullable String selectedImeId,
+ int selectedSubtypeIndex, int displayId, @UserIdInt int userId) {
// Hide the menu in case it was already showing.
hide(displayId, userId);
+ final var menuItems = getMenuItems(items);
+ final int selectedIndex = getSelectedIndex(menuItems, selectedImeId, selectedSubtypeIndex);
+ if (selectedIndex == -1) {
+ Slog.w(TAG, "Switching menu shown with no item selected, IME id: " + selectedImeId
+ + ", subtype index: " + selectedSubtypeIndex);
+ }
+
final Context dialogWindowContext = mDialogWindowContext.get(displayId);
final var builder = new AlertDialog.Builder(dialogWindowContext,
com.android.internal.R.style.Theme_DeviceDefault_InputMethodSwitcherDialog);
@@ -104,52 +115,28 @@
dialogWindowContext.getText(com.android.internal.R.string.select_input_method));
builder.setView(contentView);
- final DialogInterface.OnClickListener onClickListener = (dialog, which) -> {
- if (which != selectedIndex) {
- final var item = items.get(which);
+ final OnClickListener onClickListener = (item, isSelected) -> {
+ if (!isSelected) {
InputMethodManagerInternal.get()
.switchToInputMethod(item.mImi.getId(), item.mSubtypeIndex, userId);
}
hide(displayId, userId);
};
- final var selectedImi = selectedIndex >= 0 ? items.get(selectedIndex).mImi : null;
- final var languageSettingsIntent = selectedImi != null
- ? selectedImi.createImeLanguageSettingsActivityIntent() : null;
- final boolean isDeviceProvisioned = Settings.Global.getInt(
- dialogWindowContext.getContentResolver(), Settings.Global.DEVICE_PROVISIONED,
- 0) != 0;
- final boolean hasLanguageSettingsButton = languageSettingsIntent != null
- && isDeviceProvisioned;
- if (hasLanguageSettingsButton) {
- final View buttonBar = contentView
- .requireViewById(com.android.internal.R.id.button_bar);
- buttonBar.setVisibility(View.VISIBLE);
-
- languageSettingsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- final Button languageSettingsButton = contentView
- .requireViewById(com.android.internal.R.id.button1);
- languageSettingsButton.setVisibility(View.VISIBLE);
- languageSettingsButton.setOnClickListener(v -> {
- v.getContext().startActivityAsUser(languageSettingsIntent, UserHandle.of(userId));
- hide(displayId, userId);
- });
- }
-
// Create the current IME subtypes list.
final RecyclerView recyclerView = contentView
.requireViewById(com.android.internal.R.id.list);
- recyclerView.setAdapter(new Adapter(items, selectedIndex, inflater, onClickListener));
+ recyclerView.setAdapter(new Adapter(menuItems, selectedIndex, inflater, onClickListener));
// Scroll to the currently selected IME. This must run after the recycler view is laid out.
recyclerView.post(() -> recyclerView.scrollToPosition(selectedIndex));
- // Indicate that the list can be scrolled.
- recyclerView.setScrollIndicators(
- hasLanguageSettingsButton ? View.SCROLL_INDICATOR_BOTTOM : 0);
// Request focus to enable rotary scrolling on watches.
recyclerView.requestFocus();
+ final var selectedItem = selectedIndex > -1 ? menuItems.get(selectedIndex) : null;
+ updateLanguageSettingsButton(selectedItem, contentView, displayId, userId);
+
builder.setOnCancelListener(dialog -> hide(displayId, userId));
- mMenuItems = items;
+ mMenuItems = menuItems;
mDialog = builder.create();
mDialog.setCanceledOnTouchOutside(true);
final Window w = mDialog.getWindow();
@@ -208,98 +195,303 @@
}
/**
- * Item to be shown in the Input Method Switcher Menu, containing an input method and
- * optionally an input method subtype.
+ * Creates the list of menu items from the given list of input methods and subtypes. This
+ * handles adding headers and dividers between groups of items from different input methods
+ * as follows:
+ *
+ * <li>If there is only one group, no divider or header will be added.</li>
+ * <li>A divider is added before each group, except the first one.</li>
+ * <li>A header is added before each group (after the divider, if it exists) if the group has
+ * at least two items, or a single item with a subtype name.</li>
+ *
+ * @param items the list of input method and subtype items.
*/
- static class MenuItem {
+ @VisibleForTesting
+ @NonNull
+ static List<MenuItem> getMenuItems(@NonNull List<ImeSubtypeListItem> items) {
+ final var menuItems = new ArrayList<MenuItem>();
+ if (items.isEmpty()) {
+ return menuItems;
+ }
+
+ final var itemsArray = (ArrayList<ImeSubtypeListItem>) items;
+ final int numItems = itemsArray.size();
+ // Initialize to the last IME id to avoid headers if there is only a single IME.
+ String prevImeId = itemsArray.getLast().mImi.getId();
+ boolean firstGroup = true;
+ for (int i = 0; i < numItems; i++) {
+ final var item = itemsArray.get(i);
+
+ final var imeId = item.mImi.getId();
+ final boolean groupChange = !imeId.equals(prevImeId);
+ if (groupChange) {
+ if (!firstGroup) {
+ menuItems.add(DividerItem.getInstance());
+ }
+ // Add a header if we have at least two items, or a single item with a subtype name.
+ final var nextItemId = i + 1 < numItems ? itemsArray.get(i + 1).mImi.getId() : null;
+ final boolean addHeader = item.mSubtypeName != null || imeId.equals(nextItemId);
+ if (addHeader) {
+ menuItems.add(new HeaderItem(item.mImeName));
+ }
+ firstGroup = false;
+ prevImeId = imeId;
+ }
+
+ menuItems.add(new SubtypeItem(item.mImeName, item.mSubtypeName, item.mImi,
+ item.mSubtypeIndex));
+ }
+
+ return menuItems;
+ }
+
+ /**
+ * Gets the index of the selected item.
+ *
+ * @param items the list of menu items.
+ * @param selectedImeId the ID of the selected input method.
+ * @param selectedSubtypeIndex the index of the selected subtype in the input method's array of
+ * subtypes, or {@link InputMethodUtils#NOT_A_SUBTYPE_INDEX} if no
+ * subtype is selected.
+ * @return the index of the selected item, or {@code -1} if no item is selected.
+ */
+ @VisibleForTesting
+ @IntRange(from = -1)
+ static int getSelectedIndex(@NonNull List<MenuItem> items, @Nullable String selectedImeId,
+ int selectedSubtypeIndex) {
+ for (int i = 0; i < items.size(); i++) {
+ final var item = items.get(i);
+ if (item instanceof SubtypeItem subtypeItem) {
+ final var imeId = subtypeItem.mImi.getId();
+ final int subtypeIndex = subtypeItem.mSubtypeIndex;
+ if (imeId.equals(selectedImeId)
+ && ((subtypeIndex == 0 && selectedSubtypeIndex == NOT_A_SUBTYPE_INDEX)
+ || subtypeIndex == NOT_A_SUBTYPE_INDEX
+ || subtypeIndex == selectedSubtypeIndex)) {
+ return i;
+ }
+ }
+ }
+ // Either there is no selected IME, or the selected subtype is enabled but not in the list.
+ // This can happen if an implicit subtype is selected, but we got a list of explicit
+ // subtypes. In this case, the implicit subtype will no longer be included in the list.
+ return -1;
+ }
+
+ /**
+ * Updates the visibility of the Language Settings button to visible if the currently selected
+ * item specifies a (language) settings activity and the device is provisioned. Otherwise,
+ * the button won't be shown.
+ *
+ * @param selectedItem the currently selected item, or {@code null} if no item is selected.
+ * @param view the menu dialog view.
+ * @param displayId the ID of the display where the menu was requested.
+ * @param userId the ID of the user that requested the menu.
+ */
+ @RequiresPermission(allOf = {INTERACT_ACROSS_USERS})
+ private void updateLanguageSettingsButton(@Nullable MenuItem selectedItem, @NonNull View view,
+ int displayId, @UserIdInt int userId) {
+ final var settingsIntent = (selectedItem instanceof SubtypeItem selectedSubtypeItem)
+ ? selectedSubtypeItem.mImi.createImeLanguageSettingsActivityIntent() : null;
+ final boolean isDeviceProvisioned = Settings.Global.getInt(
+ view.getContext().getContentResolver(), Settings.Global.DEVICE_PROVISIONED,
+ 0) != 0;
+ final boolean hasButton = settingsIntent != null && isDeviceProvisioned;
+ final View buttonBar = view.requireViewById(com.android.internal.R.id.button_bar);
+ final Button button = view.requireViewById(com.android.internal.R.id.button1);
+ final RecyclerView recyclerView = view.requireViewById(com.android.internal.R.id.list);
+ if (hasButton) {
+ settingsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ buttonBar.setVisibility(View.VISIBLE);
+ button.setOnClickListener(v -> {
+ v.getContext().startActivityAsUser(settingsIntent, UserHandle.of(userId));
+ hide(displayId, userId);
+ });
+ // Indicate that the list can be scrolled.
+ recyclerView.setScrollIndicators(View.SCROLL_INDICATOR_BOTTOM);
+ } else {
+ buttonBar.setVisibility(View.GONE);
+ button.setOnClickListener(null);
+ // Remove scroll indicator as there is nothing drawn below the list.
+ recyclerView.setScrollIndicators(0 /* indicators */);
+ }
+ }
+
+ /**
+ * Interface definition for callbacks to be invoked when a {@link SubtypeItem} is clicked.
+ */
+ private interface OnClickListener {
+
+ /**
+ * Called when an item is clicked.
+ *
+ * @param item The item that was clicked.
+ * @param isSelected Whether the item is the currently selected one.
+ */
+ void onClick(@NonNull SubtypeItem item, boolean isSelected);
+ }
+
+ /** Item to be displayed in the menu. */
+ sealed interface MenuItem {}
+
+ /** Subtype item containing an input method and optionally an input method subtype. */
+ static final class SubtypeItem implements MenuItem {
/** The name of the input method. */
@NonNull
- private final CharSequence mImeName;
+ final CharSequence mImeName;
/**
* The name of the input method subtype, or {@code null} if this item doesn't have a
* subtype.
*/
@Nullable
- private final CharSequence mSubtypeName;
+ final CharSequence mSubtypeName;
/** The info of the input method. */
@NonNull
- private final InputMethodInfo mImi;
+ final InputMethodInfo mImi;
/**
* The index of the subtype in the input method's array of subtypes,
* or {@link InputMethodUtils#NOT_A_SUBTYPE_INDEX} if this item doesn't have a subtype.
*/
@IntRange(from = NOT_A_SUBTYPE_INDEX)
- private final int mSubtypeIndex;
+ final int mSubtypeIndex;
- /** Whether this item has a group header (only the first item of each input method). */
- private final boolean mHasHeader;
-
- /**
- * Whether this item should has a group divider (same as {@link #mHasHeader},
- * excluding the first IME).
- */
- private final boolean mHasDivider;
-
- MenuItem(@NonNull CharSequence imeName, @Nullable CharSequence subtypeName,
+ SubtypeItem(@NonNull CharSequence imeName, @Nullable CharSequence subtypeName,
@NonNull InputMethodInfo imi,
- @IntRange(from = NOT_A_SUBTYPE_INDEX) int subtypeIndex, boolean hasHeader,
- boolean hasDivider) {
+ @IntRange(from = NOT_A_SUBTYPE_INDEX) int subtypeIndex) {
mImeName = imeName;
mSubtypeName = subtypeName;
mImi = imi;
mSubtypeIndex = subtypeIndex;
- mHasHeader = hasHeader;
- mHasDivider = hasDivider;
}
@Override
public String toString() {
- return "MenuItem{"
+ return "SubtypeItem{"
+ "mImeName=" + mImeName
+ " mSubtypeName=" + mSubtypeName
+ " mSubtypeIndex=" + mSubtypeIndex
- + " mHasHeader=" + mHasHeader
- + " mHasDivider=" + mHasDivider
+ "}";
}
}
- private static class Adapter extends RecyclerView.Adapter<Adapter.ViewHolder> {
+ /** Header item displayed before a group of {@link SubtypeItem} of the same input method. */
+ static final class HeaderItem implements MenuItem {
+
+ /** The header title. */
+ @NonNull
+ final CharSequence mTitle;
+
+ HeaderItem(@NonNull CharSequence title) {
+ mTitle = title;
+ }
+
+ @Override
+ public String toString() {
+ return "HeaderItem{"
+ + "mTitle=" + mTitle
+ + "}";
+ }
+ }
+
+ /** Divider item displayed before a {@link HeaderItem}. */
+ static final class DividerItem implements MenuItem {
+
+ private static DividerItem sInstance;
+
+ /** Gets a singleton instance of DividerItem. */
+ @NonNull
+ static DividerItem getInstance() {
+ if (sInstance == null) {
+ sInstance = new DividerItem();
+ }
+ return sInstance;
+ }
+
+ @Override
+ public String toString() {
+ return "DividerItem{}";
+ }
+ }
+
+ private static final class Adapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
+
+ /** View type for unknown item. */
+ private static final int TYPE_UNKNOWN = -1;
+
+ /** View type for {@link SubtypeItem}. */
+ private static final int TYPE_SUBTYPE = 0;
+
+ /** View type for {@link HeaderItem}. */
+ private static final int TYPE_HEADER = 1;
+
+ /** View type for {@link DividerItem}. */
+ private static final int TYPE_DIVIDER = 2;
/** The list of items to show. */
@NonNull
private final List<MenuItem> mItems;
/** The index of the selected item. */
+ @IntRange(from = -1)
private final int mSelectedIndex;
@NonNull
private final LayoutInflater mInflater;
+ /** The listener used to handle clicks on {@link SubtypeViewHolder} items. */
@NonNull
- private final DialogInterface.OnClickListener mOnClickListener;
+ private final OnClickListener mListener;
- Adapter(@NonNull List<MenuItem> items, int selectedIndex,
+ Adapter(@NonNull List<MenuItem> items, @IntRange(from = -1) int selectedIndex,
@NonNull LayoutInflater inflater,
- @NonNull DialogInterface.OnClickListener onClickListener) {
+ @NonNull OnClickListener listener) {
mItems = items;
mSelectedIndex = selectedIndex;
mInflater = inflater;
- mOnClickListener = onClickListener;
+ mListener = listener;
}
@Override
- public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- final View view = mInflater.inflate(
- com.android.internal.R.layout.input_method_switch_item_new, parent, false);
-
- return new ViewHolder(view, mOnClickListener);
+ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ switch (viewType) {
+ case TYPE_SUBTYPE -> {
+ final View view = mInflater.inflate(
+ com.android.internal.R.layout.input_method_switch_item_new, parent,
+ false);
+ return new SubtypeViewHolder(view, mListener);
+ }
+ case TYPE_HEADER -> {
+ final View view = mInflater.inflate(
+ com.android.internal.R.layout.input_method_switch_item_header, parent,
+ false);
+ return new HeaderViewHolder(view);
+ }
+ case TYPE_DIVIDER -> {
+ final View view = mInflater.inflate(
+ com.android.internal.R.layout.input_method_switch_item_divider, parent,
+ false);
+ return new DividerViewHolder(view);
+ }
+ default -> throw new IllegalArgumentException("Unknown viewType: " + viewType);
+ }
}
@Override
- public void onBindViewHolder(ViewHolder holder, int position) {
- holder.bind(mItems.get(position), position == mSelectedIndex /* isSelected */);
+ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
+ final var item = mItems.get(position);
+ if (holder instanceof SubtypeViewHolder subtypeHolder
+ && item instanceof SubtypeItem subtypeItem) {
+ subtypeHolder.bind(subtypeItem, position == mSelectedIndex /* isSelected */);
+ } else if (holder instanceof HeaderViewHolder headerHolder
+ && item instanceof HeaderItem headerItem) {
+ headerHolder.bind(headerItem);
+ } else if (holder instanceof DividerViewHolder && item instanceof DividerItem) {
+ // Nothing to bind for dividers.
+ return;
+ } else {
+ Slog.w(TAG, "Holder type: " + holder + " doesn't match item type: " + item);
+ }
}
@Override
@@ -307,7 +499,21 @@
return mItems.size();
}
- private static class ViewHolder extends RecyclerView.ViewHolder {
+ @Override
+ public int getItemViewType(int position) {
+ final var item = mItems.get(position);
+ if (item instanceof SubtypeItem) {
+ return TYPE_SUBTYPE;
+ } else if (item instanceof HeaderItem) {
+ return TYPE_HEADER;
+ } else if (item instanceof DividerItem) {
+ return TYPE_DIVIDER;
+ } else {
+ return TYPE_UNKNOWN;
+ }
+ }
+
+ private static final class SubtypeViewHolder extends RecyclerView.ViewHolder {
/** The container of the item. */
@NonNull
@@ -318,46 +524,74 @@
/** Indicator for the selected status of the item. */
@NonNull
private final ImageView mCheckmark;
- /** The group header optionally drawn above the item. */
- @NonNull
- private final TextView mHeader;
- /** The group divider optionally drawn above the item. */
- @NonNull
- private final View mDivider;
- private ViewHolder(@NonNull View itemView,
- @NonNull DialogInterface.OnClickListener onClickListener) {
+ /** The bound item data, or {@code null} if no item was bound yet. */
+ @Nullable
+ private SubtypeItem mItem;
+ /** Whether this item is the currently selected one. */
+ private boolean mIsSelected;
+
+ SubtypeViewHolder(@NonNull View itemView, @NonNull OnClickListener listener) {
super(itemView);
- mContainer = itemView.requireViewById(com.android.internal.R.id.list_item);
+ mContainer = itemView;
mName = itemView.requireViewById(com.android.internal.R.id.text);
mCheckmark = itemView.requireViewById(com.android.internal.R.id.image);
- mHeader = itemView.requireViewById(com.android.internal.R.id.header_text);
- mDivider = itemView.requireViewById(com.android.internal.R.id.divider);
- mContainer.setOnClickListener((v) ->
- onClickListener.onClick(null /* dialog */, getAdapterPosition()));
+ mContainer.setOnClickListener((v) -> {
+ if (mItem != null) {
+ listener.onClick(mItem, mIsSelected);
+ }
+ });
}
/**
* Binds the given item to the current view.
*
* @param item the item to bind.
- * @param isSelected whether this is selected.
+ * @param isSelected whether the item is selected.
*/
- private void bind(@NonNull MenuItem item, boolean isSelected) {
+ void bind(@NonNull SubtypeItem item, boolean isSelected) {
+ mItem = item;
+ mIsSelected = isSelected;
// Use the IME name for subtypes with an empty subtype name.
final var name = TextUtils.isEmpty(item.mSubtypeName)
? item.mImeName : item.mSubtypeName;
mContainer.setActivated(isSelected);
// Activated is the correct state, but we also set selected for accessibility info.
mContainer.setSelected(isSelected);
+ // Trigger the ellipsize marquee behaviour by selecting the name.
mName.setSelected(isSelected);
mName.setText(name);
mCheckmark.setVisibility(isSelected ? View.VISIBLE : View.GONE);
- mHeader.setText(item.mImeName);
- mHeader.setVisibility(item.mHasHeader ? View.VISIBLE : View.GONE);
- mDivider.setVisibility(item.mHasDivider ? View.VISIBLE : View.GONE);
+ }
+ }
+
+ private static final class HeaderViewHolder extends RecyclerView.ViewHolder {
+
+ /** The title view, only visible if the bound item has a title. */
+ private final TextView mTitle;
+
+ HeaderViewHolder(@NonNull View itemView) {
+ super(itemView);
+
+ mTitle = itemView.requireViewById(com.android.internal.R.id.header_text);
+ }
+
+ /**
+ * Binds the given item to the current view.
+ *
+ * @param item the item to bind.
+ */
+ void bind(@NonNull HeaderItem item) {
+ mTitle.setText(item.mTitle);
+ }
+ }
+
+ private static final class DividerViewHolder extends RecyclerView.ViewHolder {
+
+ DividerViewHolder(@NonNull View itemView) {
+ super(itemView);
}
}
}
diff --git a/services/core/java/com/android/server/notification/PreferencesHelper.java b/services/core/java/com/android/server/notification/PreferencesHelper.java
index 9e70f81..3349b13 100644
--- a/services/core/java/com/android/server/notification/PreferencesHelper.java
+++ b/services/core/java/com/android/server/notification/PreferencesHelper.java
@@ -1986,6 +1986,7 @@
* bypassing DND. It should be called whenever a channel is created, updated, or deleted, or
* when the current user (or its profiles) change.
*/
+ // TODO: b/368247671 - remove fromSystemOrSystemUi argument when modes_ui is inlined.
private void updateCurrentUserHasChannelsBypassingDnd(int callingUid,
boolean fromSystemOrSystemUi) {
ArraySet<Pair<String, Integer>> candidatePkgs = new ArraySet<>();
@@ -2016,7 +2017,12 @@
boolean haveBypassingApps = candidatePkgs.size() > 0;
if (mCurrentUserHasChannelsBypassingDnd != haveBypassingApps) {
mCurrentUserHasChannelsBypassingDnd = haveBypassingApps;
- updateZenPolicy(mCurrentUserHasChannelsBypassingDnd, callingUid, fromSystemOrSystemUi);
+ if (android.app.Flags.modesUi()) {
+ mZenModeHelper.updateHasPriorityChannels(mCurrentUserHasChannelsBypassingDnd);
+ } else {
+ updateZenPolicy(mCurrentUserHasChannelsBypassingDnd, callingUid,
+ fromSystemOrSystemUi);
+ }
}
}
@@ -2034,6 +2040,9 @@
return true;
}
+ // TODO: b/368247671 - delete this method when modes_ui is inlined, as
+ // updateCurrentUserHasChannelsBypassingDnd was the only caller and
+ // PreferencesHelper should otherwise not need to modify actual policy
public void updateZenPolicy(boolean areChannelsBypassingDnd, int callingUid,
boolean fromSystemOrSystemUi) {
NotificationManager.Policy policy = mZenModeHelper.getNotificationPolicy();
diff --git a/services/core/java/com/android/server/notification/ZenModeHelper.java b/services/core/java/com/android/server/notification/ZenModeHelper.java
index ea211a9..5547bd3 100644
--- a/services/core/java/com/android/server/notification/ZenModeHelper.java
+++ b/services/core/java/com/android/server/notification/ZenModeHelper.java
@@ -1567,6 +1567,28 @@
return azr;
}
+ // Update only the hasPriorityChannels state (aka areChannelsBypassingDnd) without modifying
+ // any of the rest of the existing policy. This allows components that only want to modify
+ // this bit (PreferencesHelper) to not have to adjust the rest of the policy.
+ protected void updateHasPriorityChannels(boolean hasPriorityChannels) {
+ if (!Flags.modesUi()) {
+ Log.wtf(TAG, "updateHasPriorityChannels called without modes_ui");
+ }
+ synchronized (mConfigLock) {
+ // If it already matches, do nothing
+ if (mConfig.areChannelsBypassingDnd == hasPriorityChannels) {
+ return;
+ }
+
+ ZenModeConfig newConfig = mConfig.copy();
+ newConfig.areChannelsBypassingDnd = hasPriorityChannels;
+ // The updated calculation of whether there are priority channels is always done by
+ // the system, even if the event causing the calculation had a different origin.
+ setConfigLocked(newConfig, null, ORIGIN_SYSTEM, "updateHasPriorityChannels",
+ Process.SYSTEM_UID);
+ }
+ }
+
@SuppressLint("MissingPermission")
void scheduleActivationBroadcast(String pkg, @UserIdInt int userId, String ruleId,
boolean activated) {
diff --git a/services/core/java/com/android/server/notification/flags.aconfig b/services/core/java/com/android/server/notification/flags.aconfig
index 0b34177..a24c743 100644
--- a/services/core/java/com/android/server/notification/flags.aconfig
+++ b/services/core/java/com/android/server/notification/flags.aconfig
@@ -180,3 +180,10 @@
purpose: PURPOSE_BUGFIX
}
}
+
+flag {
+ name: "notification_vibration_in_sound_uri_for_channel"
+ namespace: "systemui"
+ description: "Enables sound uri with vibration source in notification channel"
+ bug: "351975435"
+}
diff --git a/services/core/java/com/android/server/pm/ComputerEngine.java b/services/core/java/com/android/server/pm/ComputerEngine.java
index b228bb9..be7631d 100644
--- a/services/core/java/com/android/server/pm/ComputerEngine.java
+++ b/services/core/java/com/android/server/pm/ComputerEngine.java
@@ -2768,7 +2768,8 @@
enforceCrossUserPermission(Binder.getCallingUid(), userId, false, false,
!isRecentsAccessingChildProfiles(Binder.getCallingUid(), userId),
"MATCH_ANY_USER flag requires INTERACT_ACROSS_USERS permission");
- } else if ((flags & PackageManager.MATCH_UNINSTALLED_PACKAGES) != 0
+ } else if (!Flags.removeCrossUserPermissionHack()
+ && (flags & PackageManager.MATCH_UNINSTALLED_PACKAGES) != 0
&& isCallerSystemUser
&& mUserManager.hasProfile(UserHandle.USER_SYSTEM)) {
// If the caller wants all packages and has a profile associated with it,
diff --git a/services/core/java/com/android/server/wm/ConfigurationContainer.java b/services/core/java/com/android/server/wm/ConfigurationContainer.java
index 670a61d..05dcbb7 100644
--- a/services/core/java/com/android/server/wm/ConfigurationContainer.java
+++ b/services/core/java/com/android/server/wm/ConfigurationContainer.java
@@ -25,6 +25,7 @@
import static android.app.WindowConfiguration.ROTATION_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
+import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.app.WindowConfiguration.activityTypeToString;
@@ -268,7 +269,16 @@
}
final DisplayPolicy.DecorInsets.Info decor =
displayContent.getDisplayPolicy().getDecorInsetsInfo(rotation, dw, dh);
- outAppBounds.intersectUnchecked(decor.mOverrideNonDecorFrame);
+ if (!outAppBounds.intersect(decor.mOverrideNonDecorFrame)) {
+ // TODO (b/364883053): When a split screen is requested from an app intent for a new
+ // task, the bounds is not the final bounds, and this is also not a bounds change
+ // event handled correctly with the offset. Revert back to legacy method for this
+ // case.
+ if (inOutConfig.windowConfiguration.getWindowingMode()
+ == WINDOWING_MODE_MULTI_WINDOW) {
+ outAppBounds.inset(decor.mOverrideNonDecorInsets);
+ }
+ }
if (task != null && (task.mOffsetYForInsets != 0 || task.mOffsetXForInsets != 0)) {
outAppBounds.offset(-task.mOffsetXForInsets, -task.mOffsetYForInsets);
}
diff --git a/services/core/java/com/android/server/wm/ContentRecorder.java b/services/core/java/com/android/server/wm/ContentRecorder.java
index bc33946..0b5872b 100644
--- a/services/core/java/com/android/server/wm/ContentRecorder.java
+++ b/services/core/java/com/android/server/wm/ContentRecorder.java
@@ -285,6 +285,11 @@
}
}
+ private boolean isDisplayReadyForMirroring() {
+ return mDisplayContent.getDisplayInfo().type != Display.TYPE_EXTERNAL
+ || mDisplayContent.mWmService.mDisplayManagerInternal.isDisplayReadyForMirroring(
+ mDisplayContent.getDisplayId());
+ }
/**
* Ensure recording does not fall back to the display stack; ensure the recording is stopped
@@ -335,7 +340,7 @@
return;
}
- if (mContentRecordingSession.isWaitingForConsent()) {
+ if (mContentRecordingSession.isWaitingForConsent() || !isDisplayReadyForMirroring()) {
ProtoLog.v(WM_DEBUG_CONTENT_RECORDING, "Content Recording: waiting to record, so do "
+ "nothing");
return;
diff --git a/services/core/java/com/android/server/wm/InsetsSourceProvider.java b/services/core/java/com/android/server/wm/InsetsSourceProvider.java
index 8f28f59..6067a99 100644
--- a/services/core/java/com/android/server/wm/InsetsSourceProvider.java
+++ b/services/core/java/com/android/server/wm/InsetsSourceProvider.java
@@ -384,16 +384,19 @@
}
final boolean serverVisibleChanged = mServerVisible != isServerVisible;
setServerVisible(isServerVisible);
- final boolean positionChanged = updateInsetsControlPosition(windowState);
- if (mControl != null && !positionChanged
- // The insets hint would be updated if the position is changed. Here updates it for
- // the possible change of the bounds or the server visibility.
- && (updateInsetsHint()
- || serverVisibleChanged
- && android.view.inputmethod.Flags.refactorInsetsController())) {
- // Only call notifyControlChanged here when the position is not changed. Otherwise, it
- // is called or is scheduled to be called during updateInsetsControlPosition.
- mStateController.notifyControlChanged(mControlTarget, this);
+ if (mControl != null) {
+ final boolean positionChanged = updateInsetsControlPosition(windowState);
+ if (!(positionChanged || mHasPendingPosition)
+ // The insets hint would be updated while changing the position. Here updates it
+ // for the possible change of the bounds or the server visibility.
+ && (updateInsetsHint()
+ || (android.view.inputmethod.Flags.refactorInsetsController()))
+ && serverVisibleChanged) {
+ // Only call notifyControlChanged here when the position hasn't been or won't be
+ // changed. Otherwise, it has been called or scheduled to be called during
+ // updateInsetsControlPosition.
+ mStateController.notifyControlChanged(mControlTarget, this);
+ }
}
}
@@ -409,6 +412,7 @@
mPosition.set(position.x, position.y);
if (windowState != null && windowState.getWindowFrames().didFrameSizeChange()
&& windowState.mWinAnimator.getShown() && mWindowContainer.okToDisplay()) {
+ mHasPendingPosition = true;
windowState.applyWithNextDraw(mSetControlPositionConsumer);
} else {
Transaction t = mWindowContainer.getSyncTransaction();
diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_InputManagerService.cpp
index efca902..248ed1a 100644
--- a/services/core/jni/com_android_server_input_InputManagerService.cpp
+++ b/services/core/jni/com_android_server_input_InputManagerService.cpp
@@ -337,6 +337,8 @@
int32_t getMousePointerSpeed();
void setPointerSpeed(int32_t speed);
void setMousePointerAccelerationEnabled(ui::LogicalDisplayId displayId, bool enabled);
+ void setMouseReverseVerticalScrollingEnabled(bool enabled);
+ void setMouseSwapPrimaryButtonEnabled(bool enabled);
void setTouchpadPointerSpeed(int32_t speed);
void setTouchpadNaturalScrollingEnabled(bool enabled);
void setTouchpadTapToClickEnabled(bool enabled);
@@ -482,6 +484,12 @@
// True if stylus button reporting through motion events is enabled.
bool stylusButtonMotionEventsEnabled{true};
+ // True if mouse vertical scrolling is reversed.
+ bool mouseReverseVerticalScrollingEnabled{false};
+
+ // True if the mouse primary button is swapped (left/right buttons).
+ bool mouseSwapPrimaryButtonEnabled{false};
+
// The touchpad pointer speed, as a number from -7 (slowest) to 7 (fastest).
int32_t touchpadPointerSpeed{0};
@@ -762,6 +770,10 @@
outConfig->defaultPointerDisplayId = mLocked.pointerDisplayId;
+ outConfig->mouseReverseVerticalScrollingEnabled =
+ mLocked.mouseReverseVerticalScrollingEnabled;
+ outConfig->mouseSwapPrimaryButtonEnabled = mLocked.mouseSwapPrimaryButtonEnabled;
+
outConfig->touchpadPointerSpeed = mLocked.touchpadPointerSpeed;
outConfig->touchpadNaturalScrollingEnabled = mLocked.touchpadNaturalScrollingEnabled;
outConfig->touchpadTapToClickEnabled = mLocked.touchpadTapToClickEnabled;
@@ -1317,6 +1329,36 @@
return mLocked.pointerSpeed;
}
+void NativeInputManager::setMouseReverseVerticalScrollingEnabled(bool enabled) {
+ { // acquire lock
+ std::scoped_lock _l(mLock);
+
+ if (mLocked.mouseReverseVerticalScrollingEnabled == enabled) {
+ return;
+ }
+
+ mLocked.mouseReverseVerticalScrollingEnabled = enabled;
+ } // release lock
+
+ mInputManager->getReader().requestRefreshConfiguration(
+ InputReaderConfiguration::Change::MOUSE_SETTINGS);
+}
+
+void NativeInputManager::setMouseSwapPrimaryButtonEnabled(bool enabled) {
+ { // acquire lock
+ std::scoped_lock _l(mLock);
+
+ if (mLocked.mouseSwapPrimaryButtonEnabled == enabled) {
+ return;
+ }
+
+ mLocked.mouseSwapPrimaryButtonEnabled = enabled;
+ } // release lock
+
+ mInputManager->getReader().requestRefreshConfiguration(
+ InputReaderConfiguration::Change::MOUSE_SETTINGS);
+}
+
void NativeInputManager::setPointerSpeed(int32_t speed) {
{ // acquire lock
std::scoped_lock _l(mLock);
@@ -3002,6 +3044,18 @@
return static_cast<jint>(im->getInputManager()->getReader().getLastUsedInputDeviceId());
}
+static void nativeSetMouseReverseVerticalScrollingEnabled(JNIEnv* env, jobject nativeImplObj,
+ bool enabled) {
+ NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
+ im->setMouseReverseVerticalScrollingEnabled(enabled);
+}
+
+static void nativeSetMouseSwapPrimaryButtonEnabled(JNIEnv* env, jobject nativeImplObj,
+ bool enabled) {
+ NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
+ im->setMouseSwapPrimaryButtonEnabled(enabled);
+}
+
// ----------------------------------------------------------------------------
static const JNINativeMethod gInputManagerMethods[] = {
@@ -3048,6 +3102,9 @@
{"setPointerSpeed", "(I)V", (void*)nativeSetPointerSpeed},
{"setMousePointerAccelerationEnabled", "(IZ)V",
(void*)nativeSetMousePointerAccelerationEnabled},
+ {"setMouseReverseVerticalScrollingEnabled", "(Z)V",
+ (void*)nativeSetMouseReverseVerticalScrollingEnabled},
+ {"setMouseSwapPrimaryButtonEnabled", "(Z)V", (void*)nativeSetMouseSwapPrimaryButtonEnabled},
{"setTouchpadPointerSpeed", "(I)V", (void*)nativeSetTouchpadPointerSpeed},
{"setTouchpadNaturalScrollingEnabled", "(Z)V",
(void*)nativeSetTouchpadNaturalScrollingEnabled},
diff --git a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodMenuControllerTest.java b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodMenuControllerTest.java
new file mode 100644
index 0000000..02dc86b
--- /dev/null
+++ b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodMenuControllerTest.java
@@ -0,0 +1,234 @@
+/*
+ * 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.server.inputmethod;
+
+import static com.android.server.inputmethod.InputMethodMenuControllerNew.getMenuItems;
+import static com.android.server.inputmethod.InputMethodMenuControllerNew.getSelectedIndex;
+import static com.android.server.inputmethod.InputMethodSubtypeSwitchingControllerTest.addTestImeSubtypeListItems;
+import static com.android.server.inputmethod.InputMethodUtils.NOT_A_SUBTYPE_INDEX;
+
+import static com.google.common.truth.Truth.assertThat;
+import static com.google.common.truth.Truth.assertWithMessage;
+
+import android.platform.test.annotations.RequiresFlagsEnabled;
+import android.platform.test.flag.junit.CheckFlagsRule;
+import android.platform.test.flag.junit.DeviceFlagsValueProvider;
+import android.view.inputmethod.Flags;
+
+import com.android.server.inputmethod.InputMethodMenuControllerNew.DividerItem;
+import com.android.server.inputmethod.InputMethodMenuControllerNew.HeaderItem;
+import com.android.server.inputmethod.InputMethodMenuControllerNew.SubtypeItem;
+import com.android.server.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@RequiresFlagsEnabled(Flags.FLAG_IME_SWITCHER_REVAMP)
+public class InputMethodMenuControllerTest {
+
+ @Rule
+ public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
+
+ /** Verifies that getMenuItems maintains the same order and information from the given items. */
+ @Test
+ public void testGetMenuItems() {
+ final var items = new ArrayList<ImeSubtypeListItem>();
+ addTestImeSubtypeListItems(items, "LatinIme", "LatinIme",
+ List.of("en", "fr"), true /* supportsSwitchingToNextInputMethod */);
+ addTestImeSubtypeListItems(items, "SimpleIme", "SimpleIme",
+ null, true /* supportsSwitchingToNextInputMethod */);
+
+ final var menuItems = getMenuItems(items);
+
+ int itemsIndex = 0;
+
+ for (int i = 0; i < menuItems.size(); i++) {
+ final var menuItem = menuItems.get(i);
+ if (menuItem instanceof SubtypeItem subtypeItem) {
+ final var item = items.get(itemsIndex);
+
+ assertWithMessage("IME name does not match").that(subtypeItem.mImeName)
+ .isEqualTo(item.mImeName);
+ assertWithMessage("Subtype name does not match").that(subtypeItem.mSubtypeName)
+ .isEqualTo(item.mSubtypeName);
+ assertWithMessage("InputMethodInfo does not match").that(subtypeItem.mImi)
+ .isEqualTo(item.mImi);
+ assertWithMessage("Subtype index does not match").that(subtypeItem.mSubtypeIndex)
+ .isEqualTo(item.mSubtypeIndex);
+
+ itemsIndex++;
+ }
+ }
+
+ assertWithMessage("Items list was not fully traversed").that(itemsIndex)
+ .isEqualTo(items.size());
+ }
+
+ /**
+ * Verifies that getMenuItems does not add a header or divider if all the items belong to
+ * a single input method.
+ */
+ @Test
+ public void testGetMenuItemsNoHeaderOrDividerForSingleInputMethod() {
+ final var items = new ArrayList<ImeSubtypeListItem>();
+ addTestImeSubtypeListItems(items, "LatinIme", "LatinIme",
+ List.of("en", "fr"), true /* supportsSwitchingToNextInputMethod */);
+
+ final var menuItems = getMenuItems(items);
+
+ assertThat(menuItems.stream()
+ .filter(item -> item instanceof HeaderItem || item instanceof DividerItem).toList())
+ .isEmpty();
+ }
+
+ /**
+ * Verifies that getMenuItems only adds headers for item groups with at least two items,
+ * or with a single item with a subtype name.
+ */
+ @Test
+ public void testGetMenuItemsHeaders() {
+ final var items = new ArrayList<ImeSubtypeListItem>();
+ addTestImeSubtypeListItems(items, "DefaultIme", "DefaultIme",
+ null, true /* supportsSwitchingToNextInputMethod */);
+ addTestImeSubtypeListItems(items, "LatinIme", "LatinIme",
+ List.of("en", "fr"), true /* supportsSwitchingToNextInputMethod */);
+ addTestImeSubtypeListItems(items, "ItalianIme", "ItalianIme",
+ List.of("it"), true /* supportsSwitchingToNextInputMethod */);
+ addTestImeSubtypeListItems(items, "SimpleIme", "SimpleIme",
+ null, true /* supportsSwitchingToNextInputMethod */);
+
+ final var menuItems = getMenuItems(items);
+
+ assertWithMessage("Must have menu items").that(menuItems).isNotEmpty();
+
+ final var headersAndDividers = menuItems.stream()
+ .filter(item -> item instanceof HeaderItem || item instanceof DividerItem)
+ .toList();
+
+ assertWithMessage("Must have header and divider items").that(headersAndDividers).hasSize(5);
+
+ assertWithMessage("First group has no header")
+ .that(menuItems.getFirst()).isInstanceOf(SubtypeItem.class);
+ assertWithMessage("Group with multiple items has divider")
+ .that(headersAndDividers.get(0)).isInstanceOf(DividerItem.class);
+ assertWithMessage("Group with multiple items has header")
+ .that(headersAndDividers.get(1)).isInstanceOf(HeaderItem.class);
+ assertWithMessage("Group with single item with subtype name has divider")
+ .that(headersAndDividers.get(2)).isInstanceOf(DividerItem.class);
+ assertWithMessage("Group with single item with subtype name has header")
+ .that(headersAndDividers.get(3)).isInstanceOf(HeaderItem.class);
+ assertWithMessage("Group with single item without subtype name has divider only")
+ .that(headersAndDividers.get(4)).isInstanceOf(DividerItem.class);
+ }
+
+ /** Verifies that getMenuItems adds a divider before every header except the first one. */
+ @Test
+ public void testGetMenuItemsDivider() {
+ final var items = new ArrayList<ImeSubtypeListItem>();
+ addTestImeSubtypeListItems(items, "LatinIme", "LatinIme",
+ List.of("en", "fr"), true /* supportsSwitchingToNextInputMethod */);
+ addTestImeSubtypeListItems(items, "ItalianIme", "ItalianIme",
+ List.of("it"), true /* supportsSwitchingToNextInputMethod */);
+ addTestImeSubtypeListItems(items, "SimpleIme", "SimpleIme",
+ null, true /* supportsSwitchingToNextInputMethod */);
+
+ final var menuItems = getMenuItems(items);
+
+ assertWithMessage("First item is a header")
+ .that(menuItems.getFirst()).isInstanceOf(HeaderItem.class);
+ assertWithMessage("Last item is a subtype")
+ .that(menuItems.getLast()).isInstanceOf(SubtypeItem.class);
+
+ for (int i = 0; i < menuItems.size(); i++) {
+ final var item = menuItems.get(i);
+ if (item instanceof HeaderItem && i > 0) {
+ final var prevItem = menuItems.get(i - 1);
+ assertWithMessage("The item before a header should be a divider")
+ .that(prevItem).isInstanceOf(DividerItem.class);
+ } else if (item instanceof DividerItem && i < menuItems.size() - 1) {
+ final var nextItem = menuItems.get(i + 1);
+ assertWithMessage("The item after a divider should be a header or subtype")
+ .that(nextItem instanceof HeaderItem || nextItem instanceof SubtypeItem)
+ .isTrue();
+ }
+ }
+ }
+
+ /**
+ * Verifies that getSelectedIndex returns the matching item when the selected subtype is given.
+ */
+ @Test
+ public void testGetSelectedIndexWithSelectedSubtype() {
+ final var items = new ArrayList<ImeSubtypeListItem>();
+ addTestImeSubtypeListItems(items, "LatinIme", "LatinIme",
+ List.of("en", "fr"), true /* supportsSwitchingToNextInputMethod */);
+ addTestImeSubtypeListItems(items, "SimpleIme", "SimpleIme",
+ List.of("it", "jp", "pt"), true /* supportsSwitchingToNextInputMethod */);
+
+ final var simpleImeId = items.get(2).mImi.getId();
+ final var menuItems = getMenuItems(items);
+
+ final int selectedIndex = getSelectedIndex(menuItems, simpleImeId, 1);
+ // Two headers + one divider + three items
+ assertThat(selectedIndex).isEqualTo(6);
+ }
+
+ /**
+ * Verifies that getSelectedIndex returns the first item of the selected input method,
+ * when no selected subtype is given.
+ */
+ @Test
+ public void testGetSelectedIndexWithoutSelectedSubtype() {
+ final var items = new ArrayList<ImeSubtypeListItem>();
+ addTestImeSubtypeListItems(items, "LatinIme", "LatinIme",
+ List.of("en", "fr"), true /* supportsSwitchingToNextInputMethod */);
+ addTestImeSubtypeListItems(items, "SimpleIme", "SimpleIme",
+ List.of("it", "jp", "pt"), true /* supportsSwitchingToNextInputMethod */);
+
+ final var simpleImeId = items.get(2).mImi.getId();
+ final var menuItems = getMenuItems(items);
+
+ final int selectedIndex = getSelectedIndex(menuItems, simpleImeId, NOT_A_SUBTYPE_INDEX);
+
+ // Two headers + one divider + two items
+ assertThat(selectedIndex).isEqualTo(5);
+ }
+
+ /**
+ * Verifies that getSelectedIndex will return the item of the selected input method that has
+ * no subtype, when this is the first one reached, regardless of the given selected subtype.
+ */
+ @Test
+ public void getSelectedIndexNoSubtype() {
+ final var items = new ArrayList<ImeSubtypeListItem>();
+ addTestImeSubtypeListItems(items, "LatinIme", "LatinIme",
+ List.of("en", "fr"), true /* supportsSwitchingToNextInputMethod */);
+ addTestImeSubtypeListItems(items, "SimpleIme", "SimpleIme",
+ null, true /* supportsSwitchingToNextInputMethod */);
+
+ final var simpleImeId = items.get(2).mImi.getId();
+ final var menuItems = getMenuItems(items);
+
+ final int selectedIndex = getSelectedIndex(menuItems, simpleImeId, 1);
+
+ // One header + one divider + two items
+ assertThat(selectedIndex).isEqualTo(4);
+ }
+}
diff --git a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodSubtypeSwitchingControllerTest.java b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodSubtypeSwitchingControllerTest.java
index 770451c..a804f24 100644
--- a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodSubtypeSwitchingControllerTest.java
+++ b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodSubtypeSwitchingControllerTest.java
@@ -75,7 +75,7 @@
.build();
}
- private static void addTestImeSubtypeListItems(@NonNull List<ImeSubtypeListItem> items,
+ static void addTestImeSubtypeListItems(@NonNull List<ImeSubtypeListItem> items,
@NonNull String imeName, @NonNull String imeLabel,
@Nullable List<String> subtypeLocales, boolean supportsSwitchingToNextInputMethod) {
final ApplicationInfo ai = new ApplicationInfo();
diff --git a/services/tests/displayservicetests/src/com/android/server/display/ExternalDisplayPolicyTest.java b/services/tests/displayservicetests/src/com/android/server/display/ExternalDisplayPolicyTest.java
index f728168..782262d 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/ExternalDisplayPolicyTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/ExternalDisplayPolicyTest.java
@@ -18,6 +18,7 @@
import static android.hardware.display.DisplayManagerGlobal.EVENT_DISPLAY_CONNECTED;
import static android.view.Display.TYPE_EXTERNAL;
+import static android.view.Display.TYPE_INTERNAL;
import static com.google.common.truth.Truth.assertThat;
@@ -36,6 +37,7 @@
import android.os.IThermalService;
import android.os.RemoteException;
import android.os.Temperature;
+import android.view.Display;
import android.view.DisplayInfo;
import androidx.test.filters.SmallTest;
@@ -97,6 +99,8 @@
@Mock
private LogicalDisplay mMockedLogicalDisplay;
@Mock
+ private LogicalDisplay mMockedDefaultDisplay;
+ @Mock
private DisplayNotificationManager mMockedDisplayNotificationManager;
@Mock
private ExternalDisplayStatsService mMockedExternalDisplayStatsService;
@@ -141,6 +145,15 @@
when(mMockedLogicalDisplay.getDisplayInfoLocked()).thenReturn(mockedLogicalDisplayInfo);
when(mMockedLogicalDisplayMapper.getDisplayLocked(EXTERNAL_DISPLAY_ID)).thenReturn(
mMockedLogicalDisplay);
+
+ // Initialize default logical display
+ when(mMockedDefaultDisplay.getDisplayIdLocked()).thenReturn(Display.DEFAULT_DISPLAY);
+ when(mMockedDefaultDisplay.isEnabledLocked()).thenReturn(true);
+ final var mockedDefaultDisplayInfo = new DisplayInfo();
+ mockedDefaultDisplayInfo.type = TYPE_INTERNAL;
+ when(mMockedDefaultDisplay.getDisplayInfoLocked()).thenReturn(mockedDefaultDisplayInfo);
+ when(mMockedLogicalDisplayMapper.getDisplayLocked(Display.DEFAULT_DISPLAY)).thenReturn(
+ mMockedDefaultDisplay);
}
@Test
@@ -293,6 +306,52 @@
verify(mMockedLogicalDisplayMapper, never()).forEachLocked(any());
}
+ @Test
+ public void testMirroringAlwaysConfirmedByUser_flagDisabled() {
+ when(mMockedFlags.isWaitingConfirmationBeforeMirroringEnabled()).thenReturn(false);
+ assertThat(mExternalDisplayPolicy.isDisplayReadyForMirroring(EXTERNAL_DISPLAY_ID)).isTrue();
+ }
+
+ @Test
+ public void testMirroringConfirmed_afterBootForEnabledDisplay() {
+ when(mMockedFlags.isWaitingConfirmationBeforeMirroringEnabled()).thenReturn(true);
+ mExternalDisplayPolicy.onBootCompleted();
+ assertThat(mExternalDisplayPolicy.isDisplayReadyForMirroring(EXTERNAL_DISPLAY_ID))
+ .isTrue();
+ }
+
+ @Test
+ public void testMirroringNotConfirmed_afterBootForDisabledDisplay() {
+ when(mMockedFlags.isWaitingConfirmationBeforeMirroringEnabled()).thenReturn(true);
+ mExternalDisplayPolicy.onBootCompleted();
+ when(mMockedLogicalDisplay.isEnabledLocked()).thenReturn(false);
+ assertThat(mExternalDisplayPolicy.isDisplayReadyForMirroring(EXTERNAL_DISPLAY_ID))
+ .isFalse();
+ }
+
+ @Test
+ public void testMirroringNeverConfirmed_forNonExternalDisplays() {
+ when(mMockedFlags.isWaitingConfirmationBeforeMirroringEnabled()).thenReturn(true);
+ mExternalDisplayPolicy.onBootCompleted();
+ assertThat(mExternalDisplayPolicy.isDisplayReadyForMirroring(Display.DEFAULT_DISPLAY))
+ .isFalse();
+ }
+
+ @Test
+ public void testMirroringNeverConfirmed_forNonExistingDisplays() {
+ when(mMockedFlags.isWaitingConfirmationBeforeMirroringEnabled()).thenReturn(true);
+ mExternalDisplayPolicy.onBootCompleted();
+ assertThat(mExternalDisplayPolicy.isDisplayReadyForMirroring(Display.INVALID_DISPLAY))
+ .isFalse();
+ }
+
+ @Test
+ public void testMirroringNeverConfirmed_duringBoot() {
+ when(mMockedFlags.isWaitingConfirmationBeforeMirroringEnabled()).thenReturn(true);
+ assertThat(mExternalDisplayPolicy.isDisplayReadyForMirroring(EXTERNAL_DISPLAY_ID))
+ .isFalse();
+ }
+
private void setTemperature(final IThermalEventListener thermalEventListener,
final List<Temperature> temperature) throws RemoteException {
for (var t : temperature) {
diff --git a/services/tests/servicestests/Android.bp b/services/tests/servicestests/Android.bp
index 6ede334..359755a 100644
--- a/services/tests/servicestests/Android.bp
+++ b/services/tests/servicestests/Android.bp
@@ -67,6 +67,7 @@
"androidx.test.ext.junit",
"cts-wm-util",
"platform-compat-test-rules",
+ "platform-parametric-runner-lib",
"mockito-target-minus-junit4",
"mockito-kotlin2",
"platform-test-annotations",
diff --git a/services/tests/servicestests/src/com/android/server/companion/virtual/VirtualDeviceManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/companion/virtual/VirtualDeviceManagerServiceTest.java
index e09933a..e386808 100644
--- a/services/tests/servicestests/src/com/android/server/companion/virtual/VirtualDeviceManagerServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/companion/virtual/VirtualDeviceManagerServiceTest.java
@@ -116,7 +116,6 @@
import androidx.test.platform.app.InstrumentationRegistry;
-import com.android.compatibility.common.util.SystemUtil;
import com.android.internal.app.BlockedAppStreamingActivity;
import com.android.internal.os.BackgroundThread;
import com.android.server.LocalServices;
@@ -161,8 +160,8 @@
private static final int DISPLAY_ID_1 = 2;
private static final int DISPLAY_ID_2 = 3;
private static final int NON_EXISTENT_DISPLAY_ID = 42;
- private static final int DEVICE_OWNER_UID_1 = 50;
- private static final int DEVICE_OWNER_UID_2 = 51;
+ private static final int DEVICE_OWNER_UID_1 = Process.myUid();
+ private static final int DEVICE_OWNER_UID_2 = DEVICE_OWNER_UID_1 + 1;
private static final int UID_1 = 0;
private static final int UID_2 = 10;
private static final int UID_3 = 10000;
@@ -559,6 +558,68 @@
}
@Test
+ public void deviceOwner_cannotMessWithAnotherDeviceTheyDoNotOwn() {
+ VirtualDeviceImpl unownedDevice =
+ createVirtualDevice(VIRTUAL_DEVICE_ID_2, DEVICE_OWNER_UID_2);
+
+ // The arguments don't matter, the owner uid check is always the first statement.
+ assertThrows(SecurityException.class, () -> unownedDevice.goToSleep());
+ assertThrows(SecurityException.class, () -> unownedDevice.wakeUp());
+
+ assertThrows(SecurityException.class,
+ () -> unownedDevice.launchPendingIntent(0, null, null));
+ assertThrows(SecurityException.class,
+ () -> unownedDevice.registerIntentInterceptor(null, null));
+ assertThrows(SecurityException.class,
+ () -> unownedDevice.unregisterIntentInterceptor(null));
+
+ assertThrows(SecurityException.class,
+ () -> unownedDevice.addActivityPolicyExemption(null));
+ assertThrows(SecurityException.class,
+ () -> unownedDevice.removeActivityPolicyExemption(null));
+ assertThrows(SecurityException.class, () -> unownedDevice.setDevicePolicy(0, 0));
+ assertThrows(SecurityException.class,
+ () -> unownedDevice.setDevicePolicyForDisplay(0, 0, 0));
+ assertThrows(SecurityException.class, () -> unownedDevice.setDisplayImePolicy(0, 0));
+
+ assertThrows(SecurityException.class, () -> unownedDevice.registerVirtualCamera(null));
+ assertThrows(SecurityException.class, () -> unownedDevice.unregisterVirtualCamera(null));
+
+ assertThrows(SecurityException.class,
+ () -> unownedDevice.onAudioSessionStarting(0, null, null));
+ assertThrows(SecurityException.class, () -> unownedDevice.onAudioSessionEnded());
+
+ assertThrows(SecurityException.class, () -> unownedDevice.createVirtualDisplay(null, null));
+ assertThrows(SecurityException.class, () -> unownedDevice.createVirtualDpad(null, null));
+ assertThrows(SecurityException.class, () -> unownedDevice.createVirtualMouse(null, null));
+ assertThrows(SecurityException.class,
+ () -> unownedDevice.createVirtualTouchscreen(null, null));
+ assertThrows(SecurityException.class,
+ () -> unownedDevice.createVirtualNavigationTouchpad(null, null));
+ assertThrows(SecurityException.class, () -> unownedDevice.createVirtualStylus(null, null));
+ assertThrows(SecurityException.class,
+ () -> unownedDevice.createVirtualRotaryEncoder(null, null));
+ assertThrows(SecurityException.class, () -> unownedDevice.unregisterInputDevice(null));
+
+ assertThrows(SecurityException.class, () -> unownedDevice.sendDpadKeyEvent(null, null));
+ assertThrows(SecurityException.class, () -> unownedDevice.sendKeyEvent(null, null));
+ assertThrows(SecurityException.class, () -> unownedDevice.sendButtonEvent(null, null));
+ assertThrows(SecurityException.class, () -> unownedDevice.sendTouchEvent(null, null));
+ assertThrows(SecurityException.class, () -> unownedDevice.sendRelativeEvent(null, null));
+ assertThrows(SecurityException.class, () -> unownedDevice.sendScrollEvent(null, null));
+ assertThrows(SecurityException.class,
+ () -> unownedDevice.sendStylusMotionEvent(null, null));
+ assertThrows(SecurityException.class,
+ () -> unownedDevice.sendStylusButtonEvent(null, null));
+ assertThrows(SecurityException.class,
+ () -> unownedDevice.sendRotaryEncoderScrollEvent(null, null));
+ assertThrows(SecurityException.class, () -> unownedDevice.setShowPointerIcon(true));
+
+ assertThrows(SecurityException.class, () -> unownedDevice.getVirtualSensorList());
+ assertThrows(SecurityException.class, () -> unownedDevice.sendSensorEvent(null, null));
+ }
+
+ @Test
public void getDeviceOwnerUid_oneDevice_returnsCorrectId() {
int ownerUid = mLocalService.getDeviceOwnerUid(mDeviceImpl.getDeviceId());
assertThat(ownerUid).isEqualTo(mDeviceImpl.getOwnerUid());
@@ -676,7 +737,7 @@
@Test
public void getDeviceIdsForUid_twoDevicesUidOnOne_returnsCorrectId() {
VirtualDeviceImpl secondDevice = createVirtualDevice(VIRTUAL_DEVICE_ID_2,
- DEVICE_OWNER_UID_2);
+ DEVICE_OWNER_UID_1);
addVirtualDisplay(secondDevice, DISPLAY_ID_2);
secondDevice.getDisplayWindowPolicyControllerForTest(DISPLAY_ID_2).onRunningAppsChanged(
@@ -691,7 +752,7 @@
public void getDeviceIdsForUid_twoDevicesUidOnBoth_returnsCorrectId() {
addVirtualDisplay(mDeviceImpl, DISPLAY_ID_1);
VirtualDeviceImpl secondDevice = createVirtualDevice(VIRTUAL_DEVICE_ID_2,
- DEVICE_OWNER_UID_2);
+ DEVICE_OWNER_UID_1);
addVirtualDisplay(secondDevice, DISPLAY_ID_2);
@@ -729,7 +790,7 @@
@Test
public void getPreferredLocaleListForApp_appOnMultipleVD_localeOnFirstVDReturned() {
VirtualDeviceImpl secondDevice = createVirtualDevice(VIRTUAL_DEVICE_ID_2,
- DEVICE_OWNER_UID_2);
+ DEVICE_OWNER_UID_1);
Binder secondBinder = new Binder("secondBinder");
VirtualKeyboardConfig firstKeyboardConfig =
new VirtualKeyboardConfig.Builder()
@@ -767,7 +828,7 @@
assertThat(mCameraAccessController.getObserverCount()).isEqualTo(1);
VirtualDeviceImpl secondDevice =
- createVirtualDevice(VIRTUAL_DEVICE_ID_2, DEVICE_OWNER_UID_2);
+ createVirtualDevice(VIRTUAL_DEVICE_ID_2, DEVICE_OWNER_UID_1);
assertThat(mCameraAccessController.getObserverCount()).isEqualTo(2);
mDeviceImpl.close();
@@ -1130,70 +1191,6 @@
}
@Test
- public void createVirtualDpad_noPermission_failsSecurityException() {
- addVirtualDisplay(mDeviceImpl, DISPLAY_ID_1);
- // Shell doesn't have CREATE_VIRTUAL_DEVICE permission.
- SystemUtil.runWithShellPermissionIdentity(() ->
- assertThrows(SecurityException.class,
- () -> mDeviceImpl.createVirtualDpad(DPAD_CONFIG, BINDER)));
- }
-
- @Test
- public void createVirtualKeyboard_noPermission_failsSecurityException() {
- addVirtualDisplay(mDeviceImpl, DISPLAY_ID_1);
- // Shell doesn't have CREATE_VIRTUAL_DEVICE permission.
- SystemUtil.runWithShellPermissionIdentity(() ->
- assertThrows(SecurityException.class,
- () -> mDeviceImpl.createVirtualKeyboard(KEYBOARD_CONFIG, BINDER)));
- }
-
- @Test
- public void createVirtualMouse_noPermission_failsSecurityException() {
- addVirtualDisplay(mDeviceImpl, DISPLAY_ID_1);
- // Shell doesn't have CREATE_VIRTUAL_DEVICE permission.
- SystemUtil.runWithShellPermissionIdentity(() ->
- assertThrows(SecurityException.class,
- () -> mDeviceImpl.createVirtualMouse(MOUSE_CONFIG, BINDER)));
- }
-
- @Test
- public void createVirtualTouchscreen_noPermission_failsSecurityException() {
- addVirtualDisplay(mDeviceImpl, DISPLAY_ID_1);
- // Shell doesn't have CREATE_VIRTUAL_DEVICE permission.
- SystemUtil.runWithShellPermissionIdentity(() ->
- assertThrows(SecurityException.class,
- () -> mDeviceImpl.createVirtualTouchscreen(TOUCHSCREEN_CONFIG, BINDER)));
- }
-
- @Test
- public void createVirtualNavigationTouchpad_noPermission_failsSecurityException() {
- addVirtualDisplay(mDeviceImpl, DISPLAY_ID_1);
- // Shell doesn't have CREATE_VIRTUAL_DEVICE permission.
- SystemUtil.runWithShellPermissionIdentity(() ->
- assertThrows(SecurityException.class,
- () -> mDeviceImpl.createVirtualNavigationTouchpad(
- NAVIGATION_TOUCHPAD_CONFIG,
- BINDER)));
- }
-
- @Test
- public void onAudioSessionStarting_noPermission_failsSecurityException() {
- addVirtualDisplay(mDeviceImpl, DISPLAY_ID_1);
- // Shell doesn't have CREATE_VIRTUAL_DEVICE permission.
- SystemUtil.runWithShellPermissionIdentity(() ->
- assertThrows(SecurityException.class,
- () -> mDeviceImpl.onAudioSessionStarting(
- DISPLAY_ID_1, mRoutingCallback, mConfigChangedCallback)));
- }
-
- @Test
- public void onAudioSessionEnded_noPermission_failsSecurityException() {
- // Shell doesn't have CREATE_VIRTUAL_DEVICE permission.
- SystemUtil.runWithShellPermissionIdentity(() ->
- assertThrows(SecurityException.class, () -> mDeviceImpl.onAudioSessionEnded()));
- }
-
- @Test
public void createVirtualDpad_hasDisplay_obtainFileDescriptor() {
addVirtualDisplay(mDeviceImpl, DISPLAY_ID_1, Display.FLAG_TRUSTED);
mDeviceImpl.createVirtualDpad(DPAD_CONFIG, BINDER);
diff --git a/services/tests/servicestests/src/com/android/server/devicestate/DeviceStateManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/devicestate/DeviceStateManagerServiceTest.java
index b565f4b..ab5a5a9 100644
--- a/services/tests/servicestests/src/com/android/server/devicestate/DeviceStateManagerServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/devicestate/DeviceStateManagerServiceTest.java
@@ -35,17 +35,20 @@
import android.os.IBinder;
import android.os.RemoteException;
import android.platform.test.annotations.Presubmit;
+import android.platform.test.flag.junit.FlagsParameterization;
+import android.platform.test.flag.junit.SetFlagsRule;
import androidx.annotation.NonNull;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.FlakyTest;
import androidx.test.platform.app.InstrumentationRegistry;
import com.android.compatibility.common.util.PollingCheck;
import com.android.server.wm.ActivityTaskManagerInternal;
import com.android.server.wm.WindowProcessController;
+import com.android.window.flags.Flags;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -58,6 +61,9 @@
import javax.annotation.Nullable;
+import platform.test.runner.parameterized.ParameterizedAndroidJunit4;
+import platform.test.runner.parameterized.Parameters;
+
/**
* Unit tests for {@link DeviceStateManagerService}.
*
@@ -65,7 +71,7 @@
* atest FrameworksServicesTests:DeviceStateManagerServiceTest
*/
@Presubmit
-@RunWith(AndroidJUnit4.class)
+@RunWith(ParameterizedAndroidJunit4.class)
public final class DeviceStateManagerServiceTest {
private static final DeviceState DEFAULT_DEVICE_STATE = new DeviceState(
new DeviceState.Configuration.Builder(0, "DEFAULT").build());
@@ -99,6 +105,14 @@
private static final int TIMEOUT = 2000;
+ @Rule
+ public final SetFlagsRule mSetFlagsRule;
+
+ @Parameters(name = "{0}")
+ public static List<FlagsParameterization> getParams() {
+ return FlagsParameterization.allCombinationsOf(Flags.FLAG_WLINFO_ONCREATE);
+ }
+
private final Context mContext = InstrumentationRegistry.getInstrumentation().getContext();
@NonNull
private TestDeviceStatePolicy mPolicy;
@@ -111,13 +125,19 @@
@NonNull
private WindowProcessController mWindowProcessController;
+ public DeviceStateManagerServiceTest(FlagsParameterization flags) {
+ mSetFlagsRule = new SetFlagsRule(flags);
+ }
+
@Before
public void setup() {
mProvider = new TestDeviceStateProvider();
mPolicy = new TestDeviceStatePolicy(mContext, mProvider);
mSysPropSetter = new TestSystemPropertySetter();
setupDeviceStateManagerService();
- flushHandler(); // Flush the handler to ensure the initial values are committed.
+ if (!Flags.wlinfoOncreate()) {
+ flushHandler(); // Flush the handler to ensure the initial values are committed.
+ }
}
private void setupDeviceStateManagerService() {
@@ -255,9 +275,11 @@
final TestDeviceStateManagerCallback callback = new TestDeviceStateManagerCallback();
mService.getBinderService().registerCallback(callback);
- // An initial callback will be triggered on registration, so we clear it here.
- flushHandler();
- callback.clearLastNotifiedInfo();
+ if (!Flags.wlinfoOncreate()) {
+ // An initial callback will be triggered on registration, so we clear it here.
+ flushHandler();
+ callback.clearLastNotifiedInfo();
+ }
assertThat(mService.getCommittedState()).hasValue(DEFAULT_DEVICE_STATE);
assertThat(mService.getPendingState()).isEmpty();
@@ -301,7 +323,9 @@
mProvider = new TestDeviceStateProvider(null /* initialState */);
mPolicy = new TestDeviceStatePolicy(mContext, mProvider);
setupDeviceStateManagerService();
- flushHandler(); // Flush the handler to ensure the initial values are committed.
+ if (!Flags.wlinfoOncreate()) {
+ flushHandler(); // Flush the handler to ensure the initial values are committed.
+ }
final DeviceStateInfo info = mService.getBinderService().getDeviceStateInfo();
@@ -317,6 +341,9 @@
mService.getBinderService().registerCallback(callback);
mProvider.setState(OTHER_DEVICE_STATE_IDENTIFIER);
+ if (Flags.wlinfoOncreate()) {
+ waitAndAssert(() -> callback.getLastNotifiedInfo() != null);
+ }
waitAndAssert(() -> callback.getLastNotifiedInfo().baseState.getIdentifier()
== OTHER_DEVICE_STATE_IDENTIFIER);
waitAndAssert(() -> callback.getLastNotifiedInfo().currentState.getIdentifier()
@@ -350,9 +377,14 @@
public void registerCallback_initialValueAvailable_emitsDeviceState() throws RemoteException {
final TestDeviceStateManagerCallback callback = new TestDeviceStateManagerCallback();
- mService.getBinderService().registerCallback(callback);
- flushHandler();
- final DeviceStateInfo stateInfo = callback.getLastNotifiedInfo();
+ final DeviceStateInfo stateInfo;
+ if (Flags.wlinfoOncreate()) {
+ stateInfo = mService.getBinderService().registerCallback(callback);
+ } else {
+ mService.getBinderService().registerCallback(callback);
+ flushHandler();
+ stateInfo = callback.getLastNotifiedInfo();
+ }
assertThat(stateInfo).isNotNull();
assertThat(stateInfo.baseState).isEqualTo(DEFAULT_DEVICE_STATE);
@@ -365,14 +397,22 @@
mProvider = new TestDeviceStateProvider(null /* initialState */);
mPolicy = new TestDeviceStatePolicy(mContext, mProvider);
setupDeviceStateManagerService();
- flushHandler(); // Flush the handler to ensure the initial values are committed.
+ if (!Flags.wlinfoOncreate()) {
+ flushHandler(); // Flush the handler to ensure the initial values are committed.
+ }
final TestDeviceStateManagerCallback callback = new TestDeviceStateManagerCallback();
- mService.getBinderService().registerCallback(callback);
- flushHandler();
- final DeviceStateInfo stateInfo = callback.getLastNotifiedInfo();
+ final DeviceStateInfo stateInfo;
+ if (Flags.wlinfoOncreate()) {
+ // Return null when the base state is not set yet.
+ stateInfo = mService.getBinderService().registerCallback(callback);
+ } else {
+ mService.getBinderService().registerCallback(callback);
+ flushHandler();
+ // The callback should never be called when the base state is not set yet.
+ stateInfo = callback.getLastNotifiedInfo();
+ }
- // The callback should never be called when the base state is not set yet.
assertThat(stateInfo).isNull();
}
@@ -380,7 +420,9 @@
public void requestState() throws RemoteException {
final TestDeviceStateManagerCallback callback = new TestDeviceStateManagerCallback();
mService.getBinderService().registerCallback(callback);
- flushHandler();
+ if (!Flags.wlinfoOncreate()) {
+ flushHandler();
+ }
final IBinder token = new Binder();
assertThat(callback.getLastNotifiedStatus(token))
@@ -424,7 +466,9 @@
public void requestState_pendingStateAtRequest() throws RemoteException {
final TestDeviceStateManagerCallback callback = new TestDeviceStateManagerCallback();
mService.getBinderService().registerCallback(callback);
- flushHandler();
+ if (!Flags.wlinfoOncreate()) {
+ flushHandler();
+ }
mPolicy.blockConfigure();
@@ -498,7 +542,9 @@
public void requestState_sameAsBaseState() throws RemoteException {
final TestDeviceStateManagerCallback callback = new TestDeviceStateManagerCallback();
mService.getBinderService().registerCallback(callback);
- flushHandler();
+ if (!Flags.wlinfoOncreate()) {
+ flushHandler();
+ }
final IBinder token = new Binder();
assertThat(callback.getLastNotifiedStatus(token))
@@ -516,7 +562,9 @@
public void requestState_flagCancelWhenBaseChanges() throws RemoteException {
final TestDeviceStateManagerCallback callback = new TestDeviceStateManagerCallback();
mService.getBinderService().registerCallback(callback);
- flushHandler();
+ if (!Flags.wlinfoOncreate()) {
+ flushHandler();
+ }
final IBinder token = new Binder();
assertThat(callback.getLastNotifiedStatus(token))
@@ -613,7 +661,9 @@
public void requestState_becomesUnsupported() throws RemoteException {
final TestDeviceStateManagerCallback callback = new TestDeviceStateManagerCallback();
mService.getBinderService().registerCallback(callback);
- flushHandler();
+ if (!Flags.wlinfoOncreate()) {
+ flushHandler();
+ }
final IBinder token = new Binder();
assertThat(callback.getLastNotifiedStatus(token))
@@ -687,7 +737,9 @@
public void requestBaseStateOverride() throws RemoteException {
final TestDeviceStateManagerCallback callback = new TestDeviceStateManagerCallback();
mService.getBinderService().registerCallback(callback);
- flushHandler();
+ if (!Flags.wlinfoOncreate()) {
+ flushHandler();
+ }
final IBinder token = new Binder();
assertThat(callback.getLastNotifiedStatus(token))
@@ -833,7 +885,9 @@
) throws RemoteException {
final TestDeviceStateManagerCallback callback = new TestDeviceStateManagerCallback();
mService.getBinderService().registerCallback(callback);
- flushHandler();
+ if (!Flags.wlinfoOncreate()) {
+ flushHandler();
+ }
final IBinder token = new Binder();
assertThat(callback.getLastNotifiedStatus(token))
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java b/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java
index d64b9e8..404ede6 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java
@@ -18,6 +18,7 @@
import static android.app.AppOpsManager.MODE_ALLOWED;
import static android.app.AppOpsManager.MODE_DEFAULT;
import static android.app.AppOpsManager.OP_SYSTEM_ALERT_WINDOW;
+import static android.app.Flags.FLAG_MODES_UI;
import static android.app.Notification.VISIBILITY_PRIVATE;
import static android.app.Notification.VISIBILITY_SECRET;
import static android.app.NotificationChannel.ALLOW_BUBBLE_ON;
@@ -81,6 +82,7 @@
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
@@ -248,7 +250,7 @@
@Parameters(name = "{0}")
public static List<FlagsParameterization> getParams() {
return FlagsParameterization.allCombinationsOf(
- FLAG_NOTIFICATION_CLASSIFICATION);
+ FLAG_NOTIFICATION_CLASSIFICATION, FLAG_MODES_UI);
}
public PreferencesHelperTest(FlagsParameterization flags) {
@@ -2701,7 +2703,11 @@
mHelper.createNotificationChannel(PKG_N_MR1, uid, channel, true, false,
uid, false);
assertFalse(mHelper.areChannelsBypassingDnd());
- verify(mMockZenModeHelper, never()).setNotificationPolicy(any(), anyInt(), anyInt());
+ if (android.app.Flags.modesUi()) {
+ verify(mMockZenModeHelper, never()).updateHasPriorityChannels(anyBoolean());
+ } else {
+ verify(mMockZenModeHelper, never()).setNotificationPolicy(any(), anyInt(), anyInt());
+ }
resetZenModeHelper();
// create notification channel that can bypass dnd
@@ -2711,18 +2717,30 @@
mHelper.createNotificationChannel(PKG_N_MR1, uid, channel2, true, true,
uid, false);
assertTrue(mHelper.areChannelsBypassingDnd());
- verify(mMockZenModeHelper, times(1)).setNotificationPolicy(any(), anyInt(), anyInt());
+ if (android.app.Flags.modesUi()) {
+ verify(mMockZenModeHelper, times(1)).updateHasPriorityChannels(eq(true));
+ } else {
+ verify(mMockZenModeHelper, times(1)).setNotificationPolicy(any(), anyInt(), anyInt());
+ }
resetZenModeHelper();
// delete channels
mHelper.deleteNotificationChannel(PKG_N_MR1, uid, channel.getId(), uid, false);
assertTrue(mHelper.areChannelsBypassingDnd()); // channel2 can still bypass DND
- verify(mMockZenModeHelper, never()).setNotificationPolicy(any(), anyInt(), anyInt());
+ if (android.app.Flags.modesUi()) {
+ verify(mMockZenModeHelper, never()).updateHasPriorityChannels(anyBoolean());
+ } else {
+ verify(mMockZenModeHelper, never()).setNotificationPolicy(any(), anyInt(), anyInt());
+ }
resetZenModeHelper();
mHelper.deleteNotificationChannel(PKG_N_MR1, uid, channel2.getId(), uid, false);
assertFalse(mHelper.areChannelsBypassingDnd());
- verify(mMockZenModeHelper, times(1)).setNotificationPolicy(any(), anyInt(), anyInt());
+ if (android.app.Flags.modesUi()) {
+ verify(mMockZenModeHelper, times(1)).updateHasPriorityChannels(eq(false));
+ } else {
+ verify(mMockZenModeHelper, times(1)).setNotificationPolicy(any(), anyInt(), anyInt());
+ }
resetZenModeHelper();
}
@@ -2738,7 +2756,11 @@
mHelper.createNotificationChannel(PKG_N_MR1, uid, channel, true, false,
uid, false);
assertFalse(mHelper.areChannelsBypassingDnd());
- verify(mMockZenModeHelper, never()).setNotificationPolicy(any(), anyInt(), anyInt());
+ if (android.app.Flags.modesUi()) {
+ verify(mMockZenModeHelper, never()).updateHasPriorityChannels(anyBoolean());
+ } else {
+ verify(mMockZenModeHelper, never()).setNotificationPolicy(any(), anyInt(), anyInt());
+ }
resetZenModeHelper();
// Recreate a channel & now the app has dnd access granted and can set the bypass dnd field
@@ -2748,7 +2770,11 @@
uid, false);
assertTrue(mHelper.areChannelsBypassingDnd());
- verify(mMockZenModeHelper, times(1)).setNotificationPolicy(any(), anyInt(), anyInt());
+ if (android.app.Flags.modesUi()) {
+ verify(mMockZenModeHelper, times(1)).updateHasPriorityChannels(eq(true));
+ } else {
+ verify(mMockZenModeHelper, times(1)).setNotificationPolicy(any(), anyInt(), anyInt());
+ }
resetZenModeHelper();
}
@@ -2764,7 +2790,11 @@
mHelper.createNotificationChannel(PKG_N_MR1, uid, channel, true, false,
uid, false);
assertFalse(mHelper.areChannelsBypassingDnd());
- verify(mMockZenModeHelper, never()).setNotificationPolicy(any(), anyInt(), anyInt());
+ if (android.app.Flags.modesUi()) {
+ verify(mMockZenModeHelper, never()).updateHasPriorityChannels(anyBoolean());
+ } else {
+ verify(mMockZenModeHelper, never()).setNotificationPolicy(any(), anyInt(), anyInt());
+ }
resetZenModeHelper();
// create notification channel that can bypass dnd, using local app level settings
@@ -2774,18 +2804,30 @@
mHelper.createNotificationChannel(PKG_N_MR1, uid, channel2, true, true,
uid, false);
assertTrue(mHelper.areChannelsBypassingDnd());
- verify(mMockZenModeHelper, times(1)).setNotificationPolicy(any(), anyInt(), anyInt());
+ if (android.app.Flags.modesUi()) {
+ verify(mMockZenModeHelper, times(1)).updateHasPriorityChannels(eq(true));
+ } else {
+ verify(mMockZenModeHelper, times(1)).setNotificationPolicy(any(), anyInt(), anyInt());
+ }
resetZenModeHelper();
// delete channels
mHelper.deleteNotificationChannel(PKG_N_MR1, uid, channel.getId(), uid, false);
assertTrue(mHelper.areChannelsBypassingDnd()); // channel2 can still bypass DND
- verify(mMockZenModeHelper, never()).setNotificationPolicy(any(), anyInt(), anyInt());
+ if (android.app.Flags.modesUi()) {
+ verify(mMockZenModeHelper, never()).updateHasPriorityChannels(anyBoolean());
+ } else {
+ verify(mMockZenModeHelper, never()).setNotificationPolicy(any(), anyInt(), anyInt());
+ }
resetZenModeHelper();
mHelper.deleteNotificationChannel(PKG_N_MR1, uid, channel2.getId(), uid, false);
assertFalse(mHelper.areChannelsBypassingDnd());
- verify(mMockZenModeHelper, times(1)).setNotificationPolicy(any(), anyInt(), anyInt());
+ if (android.app.Flags.modesUi()) {
+ verify(mMockZenModeHelper, times(1)).updateHasPriorityChannels(eq(false));
+ } else {
+ verify(mMockZenModeHelper, times(1)).setNotificationPolicy(any(), anyInt(), anyInt());
+ }
resetZenModeHelper();
}
@@ -2812,7 +2854,11 @@
mHelper.createNotificationChannel(PKG_N_MR1, uid, channel2, true, true,
uid, false);
assertFalse(mHelper.areChannelsBypassingDnd());
- verify(mMockZenModeHelper, times(1)).setNotificationPolicy(any(), anyInt(), anyInt());
+ if (android.app.Flags.modesUi()) {
+ verify(mMockZenModeHelper, times(1)).updateHasPriorityChannels(eq(false));
+ } else {
+ verify(mMockZenModeHelper, times(1)).setNotificationPolicy(any(), anyInt(), anyInt());
+ }
resetZenModeHelper();
}
@@ -2834,7 +2880,11 @@
mHelper.createNotificationChannel(PKG_N_MR1, uid, channel2, true, true,
uid, false);
assertFalse(mHelper.areChannelsBypassingDnd());
- verify(mMockZenModeHelper, times(1)).setNotificationPolicy(any(), anyInt(), anyInt());
+ if (android.app.Flags.modesUi()) {
+ verify(mMockZenModeHelper, times(1)).updateHasPriorityChannels(eq(false));
+ } else {
+ verify(mMockZenModeHelper, times(1)).setNotificationPolicy(any(), anyInt(), anyInt());
+ }
resetZenModeHelper();
}
@@ -2856,7 +2906,11 @@
mHelper.createNotificationChannel(PKG_N_MR1, uid, channel2, true, true,
uid, false);
assertFalse(mHelper.areChannelsBypassingDnd());
- verify(mMockZenModeHelper, times(1)).setNotificationPolicy(any(), anyInt(), anyInt());
+ if (android.app.Flags.modesUi()) {
+ verify(mMockZenModeHelper, times(1)).updateHasPriorityChannels(eq(false));
+ } else {
+ verify(mMockZenModeHelper, times(1)).setNotificationPolicy(any(), anyInt(), anyInt());
+ }
resetZenModeHelper();
}
@@ -2872,7 +2926,11 @@
mHelper.createNotificationChannel(PKG_N_MR1, uid, channel, true, false,
uid, false);
assertFalse(mHelper.areChannelsBypassingDnd());
- verify(mMockZenModeHelper, never()).setNotificationPolicy(any(), anyInt(), anyInt());
+ if (android.app.Flags.modesUi()) {
+ verify(mMockZenModeHelper, never()).updateHasPriorityChannels(anyBoolean());
+ } else {
+ verify(mMockZenModeHelper, never()).setNotificationPolicy(any(), anyInt(), anyInt());
+ }
resetZenModeHelper();
// update channel so it CAN bypass dnd:
@@ -2880,7 +2938,11 @@
channel.setBypassDnd(true);
mHelper.updateNotificationChannel(PKG_N_MR1, uid, channel, true, SYSTEM_UID, true);
assertTrue(mHelper.areChannelsBypassingDnd());
- verify(mMockZenModeHelper, times(1)).setNotificationPolicy(any(), anyInt(), anyInt());
+ if (android.app.Flags.modesUi()) {
+ verify(mMockZenModeHelper, times(1)).updateHasPriorityChannels(eq(true));
+ } else {
+ verify(mMockZenModeHelper, times(1)).setNotificationPolicy(any(), anyInt(), anyInt());
+ }
resetZenModeHelper();
// update channel so it can't bypass dnd:
@@ -2888,7 +2950,11 @@
channel.setBypassDnd(false);
mHelper.updateNotificationChannel(PKG_N_MR1, uid, channel, true, SYSTEM_UID, true);
assertFalse(mHelper.areChannelsBypassingDnd());
- verify(mMockZenModeHelper, times(1)).setNotificationPolicy(any(), anyInt(), anyInt());
+ if (android.app.Flags.modesUi()) {
+ verify(mMockZenModeHelper, times(1)).updateHasPriorityChannels(eq(false));
+ } else {
+ verify(mMockZenModeHelper, times(1)).setNotificationPolicy(any(), anyInt(), anyInt());
+ }
resetZenModeHelper();
}
@@ -2901,7 +2967,11 @@
when(mMockZenModeHelper.getNotificationPolicy()).thenReturn(mTestNotificationPolicy);
mHelper.syncChannelsBypassingDnd();
assertFalse(mHelper.areChannelsBypassingDnd());
- verify(mMockZenModeHelper, times(1)).setNotificationPolicy(any(), anyInt(), anyInt());
+ if (android.app.Flags.modesUi()) {
+ verify(mMockZenModeHelper, times(1)).updateHasPriorityChannels(eq(false));
+ } else {
+ verify(mMockZenModeHelper, times(1)).setNotificationPolicy(any(), anyInt(), anyInt());
+ }
resetZenModeHelper();
}
@@ -2911,7 +2981,11 @@
mTestNotificationPolicy = new NotificationManager.Policy(0, 0, 0, 0, 0, 0);
when(mMockZenModeHelper.getNotificationPolicy()).thenReturn(mTestNotificationPolicy);
assertFalse(mHelper.areChannelsBypassingDnd());
- verify(mMockZenModeHelper, never()).setNotificationPolicy(any(), anyInt(), anyInt());
+ if (android.app.Flags.modesUi()) {
+ verify(mMockZenModeHelper, never()).updateHasPriorityChannels(anyBoolean());
+ } else {
+ verify(mMockZenModeHelper, never()).setNotificationPolicy(any(), anyInt(), anyInt());
+ }
resetZenModeHelper();
}
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java b/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java
index 294027b..8b3ac2b 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java
@@ -7027,6 +7027,29 @@
ZenModeConfig.EVENTS_OBSOLETE_RULE_ID);
}
+ @Test
+ @EnableFlags({FLAG_MODES_API, FLAG_MODES_UI})
+ public void updateHasPriorityChannels_keepsChannelSettings() {
+ setupZenConfig();
+
+ // Set priority channels setting on manual mode to confirm that it is unaffected by changes
+ // to the state describing the existence of such channels.
+ mZenModeHelper.mConfig.manualRule.zenPolicy =
+ new ZenPolicy.Builder(mZenModeHelper.mConfig.manualRule.zenPolicy)
+ .allowPriorityChannels(false)
+ .build();
+
+ mZenModeHelper.updateHasPriorityChannels(true);
+ assertThat(mZenModeHelper.getNotificationPolicy().hasPriorityChannels()).isTrue();
+
+ // getNotificationPolicy() gets its policy from the manual rule; channels not permitted
+ assertThat(mZenModeHelper.getNotificationPolicy().allowPriorityChannels()).isFalse();
+
+ mZenModeHelper.updateHasPriorityChannels(false);
+ assertThat(mZenModeHelper.getNotificationPolicy().hasPriorityChannels()).isFalse();
+ assertThat(mZenModeHelper.getNotificationPolicy().allowPriorityChannels()).isFalse();
+ }
+
private static void addZenRule(ZenModeConfig config, String id, String ownerPkg, int zenMode,
@Nullable ZenPolicy zenPolicy) {
ZenRule rule = new ZenRule();
diff --git a/services/tests/wmtests/src/com/android/server/wm/ContentRecorderTests.java b/services/tests/wmtests/src/com/android/server/wm/ContentRecorderTests.java
index e443696..c51261f 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ContentRecorderTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ContentRecorderTests.java
@@ -52,6 +52,7 @@
import android.os.IBinder;
import android.platform.test.annotations.Presubmit;
import android.view.ContentRecordingSession;
+import android.view.Display;
import android.view.DisplayInfo;
import android.view.Gravity;
import android.view.SurfaceControl;
@@ -93,9 +94,11 @@
private boolean mHandleAnisotropicDisplayMirroring = false;
@Before public void setUp() {
+ mDisplayInfo.type = Display.TYPE_VIRTUAL;
MockitoAnnotations.initMocks(this);
doReturn(INVALID_DISPLAY).when(mWm.mDisplayManagerInternal).getDisplayIdToMirror(anyInt());
+ doReturn(false).when(mWm.mDisplayManagerInternal).isDisplayReadyForMirroring(anyInt());
// Skip unnecessary operations of relayout.
spyOn(mWm.mWindowPlacerLocked);
@@ -163,6 +166,25 @@
}
@Test
+ public void testUpdateRecording_externalDisplayWithoutUserConfirmation() {
+ mDisplayInfo.type = Display.TYPE_EXTERNAL;
+ defaultInit();
+ mContentRecorder.setContentRecordingSession(mDisplaySession);
+ mContentRecorder.updateRecording();
+ assertThat(mContentRecorder.isCurrentlyRecording()).isFalse();
+ }
+
+ @Test
+ public void testUpdateRecording_externalDisplayWithUserConfirmation() {
+ doReturn(true).when(mWm.mDisplayManagerInternal).isDisplayReadyForMirroring(anyInt());
+ mDisplayInfo.type = Display.TYPE_EXTERNAL;
+ defaultInit();
+ mContentRecorder.setContentRecordingSession(mDisplaySession);
+ mContentRecorder.updateRecording();
+ assertThat(mContentRecorder.isCurrentlyRecording()).isTrue();
+ }
+
+ @Test
public void testUpdateRecording_display_invalidDisplayIdToMirror() {
defaultInit();
ContentRecordingSession session = ContentRecordingSession.createDisplaySession(
diff --git a/telephony/java/android/telephony/satellite/SatelliteManager.java b/telephony/java/android/telephony/satellite/SatelliteManager.java
index 49ca6f3..44de65a 100644
--- a/telephony/java/android/telephony/satellite/SatelliteManager.java
+++ b/telephony/java/android/telephony/satellite/SatelliteManager.java
@@ -1965,13 +1965,14 @@
}
/**
- * Inform whether the device is aligned with the satellite for demo mode.
+ * Inform whether the device is aligned with the satellite in both real and demo mode.
*
- * Framework can send datagram to modem only when device is aligned with the satellite.
- * This method helps framework to simulate the experience of sending datagram over satellite.
+ * In demo mode, framework will send datagram to modem only when device is aligned with
+ * the satellite. This method helps framework to simulate the experience of sending datagram
+ * over satellite.
*
- * @param isAligned {@true} Device is aligned with the satellite for demo mode
- * {@false} Device is not aligned with the satellite for demo mode
+ * @param isAligned {code @true} Device is aligned with the satellite
+ * {code @false} Device is not aligned with the satellite
*
* @throws SecurityException if the caller doesn't have required permission.
* @throws IllegalStateException if the Telephony process is not currently available.
diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl
index 61f0146..231c8f5 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -2977,10 +2977,10 @@
void requestTimeForNextSatelliteVisibility(in ResultReceiver receiver);
/**
- * Inform whether the device is aligned with the satellite within in margin for demo mode.
+ * Inform whether the device is aligned with the satellite in both real and demo mode.
*
- * @param isAligned {@true} Device is aligned with the satellite for demo mode
- * {@false} Device is not aligned with the satellite for demo mode
+ * @param isAligned {@true} Device is aligned with the satellite.
+ * {@false} Device is not aligned with the satellite.
*/
@JavaPassthrough(annotation="@android.annotation.RequiresPermission("
+ "android.Manifest.permission.SATELLITE_COMMUNICATION)")
diff --git a/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/HostStubGen.kt b/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/HostStubGen.kt
index 165bb57..6d8d7b7 100644
--- a/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/HostStubGen.kt
+++ b/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/HostStubGen.kt
@@ -27,7 +27,7 @@
import com.android.hoststubgen.filters.KeepNativeFilter
import com.android.hoststubgen.filters.OutputFilter
import com.android.hoststubgen.filters.SanitizationFilter
-import com.android.hoststubgen.filters.createFilterFromTextPolicyFile
+import com.android.hoststubgen.filters.TextFileFilterPolicyParser
import com.android.hoststubgen.filters.printAsTextPolicy
import com.android.hoststubgen.utils.ClassFilter
import com.android.hoststubgen.visitors.BaseAdapter
@@ -178,8 +178,10 @@
// Next, "text based" filter, which allows to override polices without touching
// the target code.
- options.policyOverrideFile.ifSet {
- filter = createFilterFromTextPolicyFile(it, allClasses, filter)
+ if (options.policyOverrideFiles.isNotEmpty()) {
+ val parser = TextFileFilterPolicyParser(allClasses, filter)
+ options.policyOverrideFiles.forEach(parser::parse)
+ filter = parser.createOutputFilter()
}
// Apply the implicit filter.
diff --git a/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/HostStubGenOptions.kt b/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/HostStubGenOptions.kt
index b083d89..55e853e 100644
--- a/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/HostStubGenOptions.kt
+++ b/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/HostStubGenOptions.kt
@@ -100,7 +100,7 @@
var defaultClassLoadHook: SetOnce<String?> = SetOnce(null),
var defaultMethodCallHook: SetOnce<String?> = SetOnce(null),
- var policyOverrideFile: SetOnce<String?> = SetOnce(null),
+ var policyOverrideFiles: MutableList<String> = mutableListOf(),
var defaultPolicy: SetOnce<FilterPolicy> = SetOnce(FilterPolicy.Remove),
@@ -164,7 +164,7 @@
"--out-jar", "--out-impl-jar" -> ret.outJar.set(nextArg())
"--policy-override-file" ->
- ret.policyOverrideFile.set(nextArg())!!.ensureFileExists()
+ ret.policyOverrideFiles.add(nextArg().ensureFileExists())
"--clean-up-on-error" -> ret.cleanUpOnError.set(true)
"--no-clean-up-on-error" -> ret.cleanUpOnError.set(false)
@@ -291,7 +291,7 @@
annotationAllowedClassesFile=$annotationAllowedClassesFile,
defaultClassLoadHook=$defaultClassLoadHook,
defaultMethodCallHook=$defaultMethodCallHook,
- policyOverrideFile=$policyOverrideFile,
+ policyOverrideFiles=${policyOverrideFiles.toTypedArray().contentToString()},
defaultPolicy=$defaultPolicy,
cleanUpOnError=$cleanUpOnError,
enableClassChecker=$enableClassChecker,
diff --git a/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/filters/TextFileFilterPolicyParser.kt b/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/filters/TextFileFilterPolicyParser.kt
index 073b503..caf80eb 100644
--- a/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/filters/TextFileFilterPolicyParser.kt
+++ b/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/filters/TextFileFilterPolicyParser.kt
@@ -23,13 +23,10 @@
import com.android.hoststubgen.log
import com.android.hoststubgen.normalizeTextLine
import com.android.hoststubgen.whitespaceRegex
-import org.objectweb.asm.Opcodes
-import org.objectweb.asm.tree.ClassNode
-import java.io.BufferedReader
-import java.io.FileReader
+import java.io.File
import java.io.PrintWriter
-import java.util.Objects
import java.util.regex.Pattern
+import org.objectweb.asm.tree.ClassNode
/**
* Print a class node as a "keep" policy.
@@ -49,256 +46,56 @@
}
}
-/** Return true if [access] is either public or protected. */
-private fun isVisible(access: Int): Boolean {
- return (access and (Opcodes.ACC_PUBLIC or Opcodes.ACC_PROTECTED)) != 0
-}
-
private const val FILTER_REASON = "file-override"
-/**
- * Read a given "policy" file and return as an [OutputFilter]
- */
-fun createFilterFromTextPolicyFile(
- filename: String,
- classes: ClassNodes,
- fallback: OutputFilter,
- ): OutputFilter {
- log.i("Loading offloaded annotations from $filename ...")
- log.withIndent {
- val subclassFilter = SubclassFilter(classes, fallback)
- val packageFilter = PackageFilter(subclassFilter)
- val imf = InMemoryOutputFilter(classes, packageFilter)
+private enum class SpecialClass {
+ NotSpecial,
+ Aidl,
+ FeatureFlags,
+ Sysprops,
+ RFile,
+}
- var lineNo = 0
+class TextFileFilterPolicyParser(
+ private val classes: ClassNodes,
+ fallback: OutputFilter
+) {
+ private val subclassFilter = SubclassFilter(classes, fallback)
+ private val packageFilter = PackageFilter(subclassFilter)
+ private val imf = InMemoryOutputFilter(classes, packageFilter)
+ private var aidlPolicy: FilterPolicyWithReason? = null
+ private var featureFlagsPolicy: FilterPolicyWithReason? = null
+ private var syspropsPolicy: FilterPolicyWithReason? = null
+ private var rFilePolicy: FilterPolicyWithReason? = null
+ private val typeRenameSpec = mutableListOf<TextFilePolicyRemapperFilter.TypeRenameSpec>()
+ private val methodReplaceSpec =
+ mutableListOf<TextFilePolicyMethodReplaceFilter.MethodCallReplaceSpec>()
- var aidlPolicy: FilterPolicyWithReason? = null
- var featureFlagsPolicy: FilterPolicyWithReason? = null
- var syspropsPolicy: FilterPolicyWithReason? = null
- var rFilePolicy: FilterPolicyWithReason? = null
- val typeRenameSpec = mutableListOf<TextFilePolicyRemapperFilter.TypeRenameSpec>()
- val methodReplaceSpec =
- mutableListOf<TextFilePolicyMethodReplaceFilter.MethodCallReplaceSpec>()
+ private lateinit var currentClassName: String
- try {
- BufferedReader(FileReader(filename)).use { reader ->
- var className = ""
-
- while (true) {
- var line = reader.readLine() ?: break
+ /**
+ * Read a given "policy" file and return as an [OutputFilter]
+ */
+ fun parse(file: String) {
+ log.i("Loading offloaded annotations from $file ...")
+ log.withIndent {
+ var lineNo = 0
+ try {
+ File(file).forEachLine {
lineNo++
-
- line = normalizeTextLine(line)
-
+ val line = normalizeTextLine(it)
if (line.isEmpty()) {
- continue // skip empty lines.
+ return@forEachLine // skip empty lines.
}
-
-
- // TODO: Method too long, break it up.
-
- val fields = line.split(whitespaceRegex).toTypedArray()
- when (fields[0].lowercase()) {
- "p", "package" -> {
- if (fields.size < 3) {
- throw ParseException("Package ('p') expects 2 fields.")
- }
- val name = fields[1]
- val rawPolicy = fields[2]
- if (resolveExtendingClass(name) != null) {
- throw ParseException("Package can't be a super class type")
- }
- if (resolveSpecialClass(name) != SpecialClass.NotSpecial) {
- throw ParseException("Package can't be a special class type")
- }
- if (rawPolicy.startsWith("!")) {
- throw ParseException("Package can't have a substitution")
- }
- if (rawPolicy.startsWith("~")) {
- throw ParseException("Package can't have a class load hook")
- }
- val policy = parsePolicy(rawPolicy)
- if (!policy.isUsableWithClasses) {
- throw ParseException("Package can't have policy '$policy'")
- }
- packageFilter.addPolicy(name, policy.withReason(FILTER_REASON))
- }
-
- "c", "class" -> {
- if (fields.size < 3) {
- throw ParseException("Class ('c') expects 2 fields.")
- }
- className = fields[1]
-
- // superClass is set when the class name starts with a "*".
- val superClass = resolveExtendingClass(className)
-
- // :aidl, etc?
- val classType = resolveSpecialClass(className)
-
- if (fields[2].startsWith("!")) {
- if (classType != SpecialClass.NotSpecial) {
- // We could support it, but not needed at least for now.
- throw ParseException(
- "Special class can't have a substitution")
- }
- // It's a redirection class.
- val toClass = fields[2].substring(1)
- imf.setRedirectionClass(className, toClass)
- } else if (fields[2].startsWith("~")) {
- if (classType != SpecialClass.NotSpecial) {
- // We could support it, but not needed at least for now.
- throw ParseException(
- "Special class can't have a class load hook")
- }
- // It's a class-load hook
- val callback = fields[2].substring(1)
- imf.setClassLoadHook(className, callback)
- } else {
- val policy = parsePolicy(fields[2])
- if (!policy.isUsableWithClasses) {
- throw ParseException("Class can't have policy '$policy'")
- }
- Objects.requireNonNull(className)
-
- when (classType) {
- SpecialClass.NotSpecial -> {
- // TODO: Duplicate check, etc
- if (superClass == null) {
- imf.setPolicyForClass(
- className, policy.withReason(FILTER_REASON)
- )
- } else {
- subclassFilter.addPolicy(superClass,
- policy.withReason("extends $superClass"))
- }
- }
- SpecialClass.Aidl -> {
- if (aidlPolicy != null) {
- throw ParseException(
- "Policy for AIDL classes already defined")
- }
- aidlPolicy = policy.withReason(
- "$FILTER_REASON (special-class AIDL)")
- }
- SpecialClass.FeatureFlags -> {
- if (featureFlagsPolicy != null) {
- throw ParseException(
- "Policy for feature flags already defined")
- }
- featureFlagsPolicy = policy.withReason(
- "$FILTER_REASON (special-class feature flags)")
- }
- SpecialClass.Sysprops -> {
- if (syspropsPolicy != null) {
- throw ParseException(
- "Policy for sysprops already defined")
- }
- syspropsPolicy = policy.withReason(
- "$FILTER_REASON (special-class sysprops)")
- }
- SpecialClass.RFile -> {
- if (rFilePolicy != null) {
- throw ParseException(
- "Policy for R file already defined")
- }
- rFilePolicy = policy.withReason(
- "$FILTER_REASON (special-class R file)")
- }
- }
- }
- }
-
- "f", "field" -> {
- if (fields.size < 3) {
- throw ParseException("Field ('f') expects 2 fields.")
- }
- val name = fields[1]
- val policy = parsePolicy(fields[2])
- if (!policy.isUsableWithFields) {
- throw ParseException("Field can't have policy '$policy'")
- }
- Objects.requireNonNull(className)
-
- // TODO: Duplicate check, etc
- imf.setPolicyForField(className, name, policy.withReason(FILTER_REASON))
- }
-
- "m", "method" -> {
- if (fields.size < 4) {
- throw ParseException("Method ('m') expects 3 fields.")
- }
- val name = fields[1]
- val signature = fields[2]
- val policy = parsePolicy(fields[3])
-
- if (!policy.isUsableWithMethods) {
- throw ParseException("Method can't have policy '$policy'")
- }
-
- Objects.requireNonNull(className)
-
- imf.setPolicyForMethod(className, name, signature,
- policy.withReason(FILTER_REASON))
- if (policy == FilterPolicy.Substitute) {
- val fromName = fields[3].substring(1)
-
- if (fromName == name) {
- throw ParseException(
- "Substitution must have a different name")
- }
-
- // Set the policy for the "from" method.
- imf.setPolicyForMethod(className, fromName, signature,
- FilterPolicy.Keep.withReason(FILTER_REASON))
-
- val classAndMethod = splitWithLastPeriod(fromName)
- if (classAndMethod != null) {
- // If the substitution target contains a ".", then
- // it's a method call redirect.
- methodReplaceSpec.add(
- TextFilePolicyMethodReplaceFilter.MethodCallReplaceSpec(
- className.toJvmClassName(),
- name,
- signature,
- classAndMethod.first.toJvmClassName(),
- classAndMethod.second,
- )
- )
- } else {
- // It's an in-class replace.
- // ("@RavenwoodReplace" equivalent)
- imf.setRenameTo(className, fromName, signature, name)
- }
- }
- }
- "r", "rename" -> {
- if (fields.size < 3) {
- throw ParseException("Rename ('r') expects 2 fields.")
- }
- // Add ".*" to make it a prefix match.
- val pattern = Pattern.compile(fields[1] + ".*")
-
- // Removing the leading /'s from the prefix. This allows
- // using a single '/' as an empty suffix, which is useful to have a
- // "negative" rename rule to avoid subsequent raname's from getting
- // applied. (Which is needed for services.jar)
- val prefix = fields[2].trimStart('/')
-
- typeRenameSpec += TextFilePolicyRemapperFilter.TypeRenameSpec(
- pattern, prefix)
- }
-
- else -> {
- throw ParseException("Unknown directive \"${fields[0]}\"")
- }
- }
+ parseLine(line)
}
+ } catch (e: ParseException) {
+ throw e.withSourceInfo(file, lineNo)
}
- } catch (e: ParseException) {
- throw e.withSourceInfo(filename, lineNo)
}
+ }
+ fun createOutputFilter(): OutputFilter {
var ret: OutputFilter = imf
if (typeRenameSpec.isNotEmpty()) {
ret = TextFilePolicyRemapperFilter(typeRenameSpec, ret)
@@ -309,54 +106,271 @@
// Wrap the in-memory-filter with AHF.
ret = AndroidHeuristicsFilter(
- classes, aidlPolicy, featureFlagsPolicy, syspropsPolicy, rFilePolicy, ret)
+ classes, aidlPolicy, featureFlagsPolicy, syspropsPolicy, rFilePolicy, ret
+ )
return ret
}
-}
-private enum class SpecialClass {
- NotSpecial,
- Aidl,
- FeatureFlags,
- Sysprops,
- RFile,
-}
-
-private fun resolveSpecialClass(className: String): SpecialClass {
- if (!className.startsWith(":")) {
- return SpecialClass.NotSpecial
+ private fun parseLine(line: String) {
+ val fields = line.split(whitespaceRegex).toTypedArray()
+ when (fields[0].lowercase()) {
+ "p", "package" -> parsePackage(fields)
+ "c", "class" -> parseClass(fields)
+ "f", "field" -> parseField(fields)
+ "m", "method" -> parseMethod(fields)
+ "r", "rename" -> parseRename(fields)
+ else -> throw ParseException("Unknown directive \"${fields[0]}\"")
+ }
}
- when (className.lowercase()) {
- ":aidl" -> return SpecialClass.Aidl
- ":feature_flags" -> return SpecialClass.FeatureFlags
- ":sysprops" -> return SpecialClass.Sysprops
- ":r" -> return SpecialClass.RFile
- }
- throw ParseException("Invalid special class name \"$className\"")
-}
-private fun resolveExtendingClass(className: String): String? {
- if (!className.startsWith("*")) {
- return null
+ private fun resolveSpecialClass(className: String): SpecialClass {
+ if (!className.startsWith(":")) {
+ return SpecialClass.NotSpecial
+ }
+ when (className.lowercase()) {
+ ":aidl" -> return SpecialClass.Aidl
+ ":feature_flags" -> return SpecialClass.FeatureFlags
+ ":sysprops" -> return SpecialClass.Sysprops
+ ":r" -> return SpecialClass.RFile
+ }
+ throw ParseException("Invalid special class name \"$className\"")
}
- return className.substring(1)
-}
-private fun parsePolicy(s: String): FilterPolicy {
- return when (s.lowercase()) {
- "k", "keep" -> FilterPolicy.Keep
- "t", "throw" -> FilterPolicy.Throw
- "r", "remove" -> FilterPolicy.Remove
- "kc", "keepclass" -> FilterPolicy.KeepClass
- "i", "ignore" -> FilterPolicy.Ignore
- "rdr", "redirect" -> FilterPolicy.Redirect
- else -> {
- if (s.startsWith("@")) {
- FilterPolicy.Substitute
- } else {
- throw ParseException("Invalid policy \"$s\"")
+ private fun resolveExtendingClass(className: String): String? {
+ if (!className.startsWith("*")) {
+ return null
+ }
+ return className.substring(1)
+ }
+
+ private fun parsePolicy(s: String): FilterPolicy {
+ return when (s.lowercase()) {
+ "k", "keep" -> FilterPolicy.Keep
+ "t", "throw" -> FilterPolicy.Throw
+ "r", "remove" -> FilterPolicy.Remove
+ "kc", "keepclass" -> FilterPolicy.KeepClass
+ "i", "ignore" -> FilterPolicy.Ignore
+ "rdr", "redirect" -> FilterPolicy.Redirect
+ else -> {
+ if (s.startsWith("@")) {
+ FilterPolicy.Substitute
+ } else {
+ throw ParseException("Invalid policy \"$s\"")
+ }
}
}
}
+
+ private fun parsePackage(fields: Array<String>) {
+ if (fields.size < 3) {
+ throw ParseException("Package ('p') expects 2 fields.")
+ }
+ val name = fields[1]
+ val rawPolicy = fields[2]
+ if (resolveExtendingClass(name) != null) {
+ throw ParseException("Package can't be a super class type")
+ }
+ if (resolveSpecialClass(name) != SpecialClass.NotSpecial) {
+ throw ParseException("Package can't be a special class type")
+ }
+ if (rawPolicy.startsWith("!")) {
+ throw ParseException("Package can't have a substitution")
+ }
+ if (rawPolicy.startsWith("~")) {
+ throw ParseException("Package can't have a class load hook")
+ }
+ val policy = parsePolicy(rawPolicy)
+ if (!policy.isUsableWithClasses) {
+ throw ParseException("Package can't have policy '$policy'")
+ }
+ packageFilter.addPolicy(name, policy.withReason(FILTER_REASON))
+ }
+
+ private fun parseClass(fields: Array<String>) {
+ if (fields.size < 3) {
+ throw ParseException("Class ('c') expects 2 fields.")
+ }
+ currentClassName = fields[1]
+
+ // superClass is set when the class name starts with a "*".
+ val superClass = resolveExtendingClass(currentClassName)
+
+ // :aidl, etc?
+ val classType = resolveSpecialClass(currentClassName)
+
+ if (fields[2].startsWith("!")) {
+ if (classType != SpecialClass.NotSpecial) {
+ // We could support it, but not needed at least for now.
+ throw ParseException(
+ "Special class can't have a substitution"
+ )
+ }
+ // It's a redirection class.
+ val toClass = fields[2].substring(1)
+ imf.setRedirectionClass(currentClassName, toClass)
+ } else if (fields[2].startsWith("~")) {
+ if (classType != SpecialClass.NotSpecial) {
+ // We could support it, but not needed at least for now.
+ throw ParseException(
+ "Special class can't have a class load hook"
+ )
+ }
+ // It's a class-load hook
+ val callback = fields[2].substring(1)
+ imf.setClassLoadHook(currentClassName, callback)
+ } else {
+ val policy = parsePolicy(fields[2])
+ if (!policy.isUsableWithClasses) {
+ throw ParseException("Class can't have policy '$policy'")
+ }
+
+ when (classType) {
+ SpecialClass.NotSpecial -> {
+ // TODO: Duplicate check, etc
+ if (superClass == null) {
+ imf.setPolicyForClass(
+ currentClassName, policy.withReason(FILTER_REASON)
+ )
+ } else {
+ subclassFilter.addPolicy(
+ superClass,
+ policy.withReason("extends $superClass")
+ )
+ }
+ }
+
+ SpecialClass.Aidl -> {
+ if (aidlPolicy != null) {
+ throw ParseException(
+ "Policy for AIDL classes already defined"
+ )
+ }
+ aidlPolicy = policy.withReason(
+ "$FILTER_REASON (special-class AIDL)"
+ )
+ }
+
+ SpecialClass.FeatureFlags -> {
+ if (featureFlagsPolicy != null) {
+ throw ParseException(
+ "Policy for feature flags already defined"
+ )
+ }
+ featureFlagsPolicy = policy.withReason(
+ "$FILTER_REASON (special-class feature flags)"
+ )
+ }
+
+ SpecialClass.Sysprops -> {
+ if (syspropsPolicy != null) {
+ throw ParseException(
+ "Policy for sysprops already defined"
+ )
+ }
+ syspropsPolicy = policy.withReason(
+ "$FILTER_REASON (special-class sysprops)"
+ )
+ }
+
+ SpecialClass.RFile -> {
+ if (rFilePolicy != null) {
+ throw ParseException(
+ "Policy for R file already defined"
+ )
+ }
+ rFilePolicy = policy.withReason(
+ "$FILTER_REASON (special-class R file)"
+ )
+ }
+ }
+ }
+ }
+
+ private fun parseField(fields: Array<String>) {
+ if (fields.size < 3) {
+ throw ParseException("Field ('f') expects 2 fields.")
+ }
+ val name = fields[1]
+ val policy = parsePolicy(fields[2])
+ if (!policy.isUsableWithFields) {
+ throw ParseException("Field can't have policy '$policy'")
+ }
+ require(this::currentClassName.isInitialized)
+
+ // TODO: Duplicate check, etc
+ imf.setPolicyForField(currentClassName, name, policy.withReason(FILTER_REASON))
+ }
+
+ private fun parseMethod(fields: Array<String>) {
+ if (fields.size < 4) {
+ throw ParseException("Method ('m') expects 3 fields.")
+ }
+ val name = fields[1]
+ val signature = fields[2]
+ val policy = parsePolicy(fields[3])
+
+ if (!policy.isUsableWithMethods) {
+ throw ParseException("Method can't have policy '$policy'")
+ }
+
+ require(this::currentClassName.isInitialized)
+
+ imf.setPolicyForMethod(
+ currentClassName, name, signature,
+ policy.withReason(FILTER_REASON)
+ )
+ if (policy == FilterPolicy.Substitute) {
+ val fromName = fields[3].substring(1)
+
+ if (fromName == name) {
+ throw ParseException(
+ "Substitution must have a different name"
+ )
+ }
+
+ // Set the policy for the "from" method.
+ imf.setPolicyForMethod(
+ currentClassName, fromName, signature,
+ FilterPolicy.Keep.withReason(FILTER_REASON)
+ )
+
+ val classAndMethod = splitWithLastPeriod(fromName)
+ if (classAndMethod != null) {
+ // If the substitution target contains a ".", then
+ // it's a method call redirect.
+ methodReplaceSpec.add(
+ TextFilePolicyMethodReplaceFilter.MethodCallReplaceSpec(
+ currentClassName.toJvmClassName(),
+ name,
+ signature,
+ classAndMethod.first.toJvmClassName(),
+ classAndMethod.second,
+ )
+ )
+ } else {
+ // It's an in-class replace.
+ // ("@RavenwoodReplace" equivalent)
+ imf.setRenameTo(currentClassName, fromName, signature, name)
+ }
+ }
+ }
+
+ private fun parseRename(fields: Array<String>) {
+ if (fields.size < 3) {
+ throw ParseException("Rename ('r') expects 2 fields.")
+ }
+ // Add ".*" to make it a prefix match.
+ val pattern = Pattern.compile(fields[1] + ".*")
+
+ // Removing the leading /'s from the prefix. This allows
+ // using a single '/' as an empty suffix, which is useful to have a
+ // "negative" rename rule to avoid subsequent raname's from getting
+ // applied. (Which is needed for services.jar)
+ val prefix = fields[2].trimStart('/')
+
+ typeRenameSpec += TextFilePolicyRemapperFilter.TypeRenameSpec(
+ pattern, prefix
+ )
+ }
}