diff options
504 files changed, 10255 insertions, 4710 deletions
diff --git a/AconfigFlags.bp b/AconfigFlags.bp index 1b0ee6397784..f9cc1259a375 100644 --- a/AconfigFlags.bp +++ b/AconfigFlags.bp @@ -348,6 +348,7 @@ aconfig_declarations { name: "android.location.flags-aconfig", package: "android.location.flags", container: "system", + exportable: true, srcs: [ "location/java/android/location/flags/*.aconfig", ], @@ -588,7 +589,6 @@ aconfig_declarations { java_aconfig_library { name: "android.view.inputmethod.flags-aconfig-java", aconfig_declarations: "android.view.inputmethod.flags-aconfig", - host_supported: true, defaults: ["framework-minus-apex-aconfig-java-defaults"], } diff --git a/core/api/system-current.txt b/core/api/system-current.txt index b9d61cd334e3..35720fd17769 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -3643,11 +3643,26 @@ package android.companion.virtual.sensor { method public int getDeviceId(); method @NonNull public String getName(); method public int getType(); + method @FlaggedApi("android.companion.virtualdevice.flags.virtual_sensor_additional_info") public void sendAdditionalInfo(@NonNull android.companion.virtual.sensor.VirtualSensorAdditionalInfo); 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; } + @FlaggedApi("android.companion.virtualdevice.flags.virtual_sensor_additional_info") public final class VirtualSensorAdditionalInfo implements android.os.Parcelable { + method public int describeContents(); + method public int getType(); + method @NonNull public java.util.List<float[]> getValues(); + method public void writeToParcel(@NonNull android.os.Parcel, int); + field @NonNull public static final android.os.Parcelable.Creator<android.companion.virtual.sensor.VirtualSensorAdditionalInfo> CREATOR; + } + + public static final class VirtualSensorAdditionalInfo.Builder { + ctor public VirtualSensorAdditionalInfo.Builder(int); + method @NonNull public android.companion.virtual.sensor.VirtualSensorAdditionalInfo.Builder addValues(@NonNull float[]); + method @NonNull public android.companion.virtual.sensor.VirtualSensorAdditionalInfo build(); + } + public interface VirtualSensorCallback { method public void onConfigurationChanged(@NonNull android.companion.virtual.sensor.VirtualSensor, boolean, @NonNull java.time.Duration, @NonNull java.time.Duration); } @@ -3665,6 +3680,7 @@ package android.companion.virtual.sensor { method public float getResolution(); method public int getType(); method @Nullable public String getVendor(); + method @FlaggedApi("android.companion.virtualdevice.flags.virtual_sensor_additional_info") public boolean isAdditionalInfoSupported(); method @FlaggedApi("android.companion.virtualdevice.flags.device_aware_display_power") public boolean isWakeUpSensor(); method public void writeToParcel(@NonNull android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.companion.virtual.sensor.VirtualSensorConfig> CREATOR; @@ -3673,6 +3689,7 @@ package android.companion.virtual.sensor { public static final class VirtualSensorConfig.Builder { ctor public VirtualSensorConfig.Builder(@IntRange(from=1) int, @NonNull String); method @NonNull public android.companion.virtual.sensor.VirtualSensorConfig build(); + method @FlaggedApi("android.companion.virtualdevice.flags.virtual_sensor_additional_info") @NonNull public android.companion.virtual.sensor.VirtualSensorConfig.Builder setAdditionalInfoSupported(boolean); method @NonNull public android.companion.virtual.sensor.VirtualSensorConfig.Builder setDirectChannelTypesSupported(int); method @NonNull public android.companion.virtual.sensor.VirtualSensorConfig.Builder setHighestDirectReportRateLevel(int); method @NonNull public android.companion.virtual.sensor.VirtualSensorConfig.Builder setMaxDelay(int); diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java index 1ed64f9416c0..00fa1c1a4f80 100644 --- a/core/java/android/app/ApplicationPackageManager.java +++ b/core/java/android/app/ApplicationPackageManager.java @@ -200,6 +200,8 @@ public class ApplicationPackageManager extends PackageManager { @GuardedBy("mPackageMonitorCallbacks") private final ArraySet<IRemoteCallback> mPackageMonitorCallbacks = new ArraySet<>(); + private final boolean mUseSystemFeaturesCache; + UserManager getUserManager() { if (mUserManager == null) { mUserManager = UserManager.get(mContext); @@ -824,8 +826,7 @@ public class ApplicationPackageManager extends PackageManager { if (maybeHasSystemFeature != null) { return maybeHasSystemFeature; } - if (com.android.internal.os.Flags.applicationSharedMemoryEnabled() - && android.content.pm.Flags.cacheSdkSystemFeatures()) { + if (mUseSystemFeaturesCache) { maybeHasSystemFeature = SystemFeaturesCache.getInstance().maybeHasFeature(name, version); if (maybeHasSystemFeature != null) { @@ -2221,6 +2222,25 @@ public class ApplicationPackageManager extends PackageManager { protected ApplicationPackageManager(ContextImpl context, IPackageManager pm) { mContext = context; mPM = pm; + mUseSystemFeaturesCache = isSystemFeaturesCacheEnabledAndAvailable(); + } + + private static boolean isSystemFeaturesCacheEnabledAndAvailable() { + if (!android.content.pm.Flags.cacheSdkSystemFeatures()) { + return false; + } + if (!com.android.internal.os.Flags.applicationSharedMemoryEnabled()) { + return false; + } + if (ActivityThread.isSystem() && !SystemFeaturesCache.hasInstance()) { + // There are a handful of utility "system" processes that are neither system_server nor + // bound as applications. For these processes, we don't have access to application + // shared memory or the dependent system features cache. + // TODO(b/400713460): Revisit this exception after deprecating these command-like + // system processes. + return false; + } + return true; } /** diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index c74bd1a092ee..c528db8f1809 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -224,7 +224,7 @@ import java.util.function.Consumer; * <li>A <i id="deviceowner">Device Owner</i>, which only ever exists on the * {@link UserManager#isSystemUser System User} or Main User, is * the most powerful type of Device Policy Controller and can affect policy across the device. - * <li>A <i id="profileowner">Profile Owner<i>, which can exist on any user, can + * <li>A <i id="profileowner">Profile Owner</i>, which can exist on any user, can * affect policy on the user it is on, and when it is running on * {@link UserManager#isProfile a profile} has * <a href="#profile-on-parent">limited</a> ability to affect policy on its parent. diff --git a/core/java/android/app/jank/TEST_MAPPING b/core/java/android/app/jank/TEST_MAPPING new file mode 100644 index 000000000000..271eb4332f79 --- /dev/null +++ b/core/java/android/app/jank/TEST_MAPPING @@ -0,0 +1,10 @@ +{ + "postsubmit": [ + { + "name": "CoreAppJankTestCases" + }, + { + "name": "CtsAppJankTestCases" + } + ] +}
\ No newline at end of file diff --git a/core/java/android/app/notification.aconfig b/core/java/android/app/notification.aconfig index 5891bddfbbe6..6f0eafe487af 100644 --- a/core/java/android/app/notification.aconfig +++ b/core/java/android/app/notification.aconfig @@ -269,7 +269,7 @@ flag { namespace: "systemui" description: "enables metrics when redacting notifications on the lockscreen" bug: "343631648" - metadata { + metadata { purpose: PURPOSE_BUGFIX } } @@ -279,7 +279,16 @@ flag { namespace: "systemui" description: "enables user expanding the public view of a notification" bug: "398853084" - metadata { + metadata { + purpose: PURPOSE_BUGFIX + } + } +flag { + name: "notif_entry_creation_time_use_elapsed_realtime" + namespace: "systemui" + description: "makes the notification entry expect its creation time to be elapsedRealtime, not uptimeMillis" + bug: "343631648" + metadata { purpose: PURPOSE_BUGFIX } } diff --git a/core/java/android/companion/virtual/IVirtualDevice.aidl b/core/java/android/companion/virtual/IVirtualDevice.aidl index f8ac27de1754..db77adeb5a3d 100644 --- a/core/java/android/companion/virtual/IVirtualDevice.aidl +++ b/core/java/android/companion/virtual/IVirtualDevice.aidl @@ -24,6 +24,7 @@ import android.companion.virtual.IVirtualDeviceSoundEffectListener; import android.companion.virtual.audio.IAudioConfigChangedCallback; import android.companion.virtual.audio.IAudioRoutingCallback; import android.companion.virtual.sensor.VirtualSensor; +import android.companion.virtual.sensor.VirtualSensorAdditionalInfo; import android.companion.virtual.sensor.VirtualSensorConfig; import android.companion.virtual.sensor.VirtualSensorEvent; import android.companion.virtual.camera.VirtualCameraConfig; @@ -251,6 +252,11 @@ interface IVirtualDevice { boolean sendSensorEvent(IBinder token, in VirtualSensorEvent event); /** + * Sends additional information about the virtual sensor corresponding to the given token. + */ + boolean sendSensorAdditionalInfo(IBinder token, in VirtualSensorAdditionalInfo info); + + /** * Launches a pending intent on the given display that is owned by this virtual device. */ void launchPendingIntent(int displayId, in PendingIntent pendingIntent, diff --git a/core/java/android/companion/virtual/flags/flags.aconfig b/core/java/android/companion/virtual/flags/flags.aconfig index 4fb3982c3754..615a6dffdf99 100644 --- a/core/java/android/companion/virtual/flags/flags.aconfig +++ b/core/java/android/companion/virtual/flags/flags.aconfig @@ -158,3 +158,11 @@ flag { bug: "370720522" is_exported: true } + +flag { + name: "virtual_sensor_additional_info" + namespace: "virtual_devices" + description: "API for injecting SensorAdditionalInfo for VirtualSensor" + bug: "393517834" + is_exported: true +} diff --git a/core/java/android/companion/virtual/sensor/VirtualSensor.java b/core/java/android/companion/virtual/sensor/VirtualSensor.java index 934a1a8ffcbd..8d4acfcb30d7 100644 --- a/core/java/android/companion/virtual/sensor/VirtualSensor.java +++ b/core/java/android/companion/virtual/sensor/VirtualSensor.java @@ -16,12 +16,15 @@ package android.companion.virtual.sensor; +import android.annotation.FlaggedApi; import android.annotation.NonNull; import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.annotation.TestApi; import android.companion.virtual.IVirtualDevice; +import android.companion.virtualdevice.flags.Flags; import android.hardware.Sensor; +import android.hardware.SensorAdditionalInfo; import android.os.IBinder; import android.os.Parcel; import android.os.Parcelable; @@ -37,20 +40,33 @@ import android.os.RemoteException; */ @SystemApi public final class VirtualSensor implements Parcelable { + private final int mHandle; private final int mType; private final String mName; + private final int mFlags; private final IVirtualDevice mVirtualDevice; private final IBinder mToken; + // Only one additional info frame set at a time. + private final Object mAdditionalInfoLock = new Object(); /** * @hide */ public VirtualSensor(int handle, int type, String name, IVirtualDevice virtualDevice, IBinder token) { + this(handle, type, name, /*flags=*/0, virtualDevice, token); + } + + /** + * @hide + */ + public VirtualSensor(int handle, int type, String name, int flags, IVirtualDevice virtualDevice, + IBinder token) { mHandle = handle; mType = type; mName = name; + mFlags = flags; mVirtualDevice = virtualDevice; mToken = token; } @@ -61,13 +77,14 @@ public final class VirtualSensor implements Parcelable { @SuppressLint("UnflaggedApi") // @TestApi without associated feature. @TestApi public VirtualSensor(int handle, int type, @NonNull String name) { - this(handle, type, name, /*virtualDevice=*/null, /*token=*/null); + this(handle, type, name, /*flags=*/0, /*virtualDevice=*/null, /*token=*/null); } private VirtualSensor(Parcel parcel) { mHandle = parcel.readInt(); mType = parcel.readInt(); mName = parcel.readString8(); + mFlags = parcel.readInt(); mVirtualDevice = IVirtualDevice.Stub.asInterface(parcel.readStrongBinder()); mToken = parcel.readStrongBinder(); } @@ -123,6 +140,7 @@ public final class VirtualSensor implements Parcelable { parcel.writeInt(mHandle); parcel.writeInt(mType); parcel.writeString8(mName); + parcel.writeInt(mFlags); parcel.writeStrongBinder(mVirtualDevice.asBinder()); parcel.writeStrongBinder(mToken); } @@ -143,6 +161,33 @@ public final class VirtualSensor implements Parcelable { } } + /** + * Send additional information about the sensor to the system. + * + * @param info the additional sensor information to send. + * @throws UnsupportedOperationException if the sensor does not support sending additional info. + * @see Sensor#isAdditionalInfoSupported() + * @see VirtualSensorConfig.Builder#setAdditionalInfoSupported(boolean) + * @see SensorAdditionalInfo + * @see VirtualSensorAdditionalInfo + */ + @FlaggedApi(Flags.FLAG_VIRTUAL_SENSOR_ADDITIONAL_INFO) + public void sendAdditionalInfo(@NonNull VirtualSensorAdditionalInfo info) { + if (!Flags.virtualSensorAdditionalInfo()) { + return; + } + if ((mFlags & VirtualSensorConfig.ADDITIONAL_INFO_MASK) == 0) { + throw new UnsupportedOperationException("Sensor additional info not supported."); + } + try { + synchronized (mAdditionalInfoLock) { + mVirtualDevice.sendSensorAdditionalInfo(mToken, info); + } + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + @NonNull public static final Parcelable.Creator<VirtualSensor> CREATOR = new Parcelable.Creator<VirtualSensor>() { diff --git a/core/java/android/companion/virtual/sensor/VirtualSensorAdditionalInfo.aidl b/core/java/android/companion/virtual/sensor/VirtualSensorAdditionalInfo.aidl new file mode 100644 index 000000000000..7267be88ca75 --- /dev/null +++ b/core/java/android/companion/virtual/sensor/VirtualSensorAdditionalInfo.aidl @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.companion.virtual.sensor; + +parcelable VirtualSensorAdditionalInfo;
\ No newline at end of file diff --git a/core/java/android/companion/virtual/sensor/VirtualSensorAdditionalInfo.java b/core/java/android/companion/virtual/sensor/VirtualSensorAdditionalInfo.java new file mode 100644 index 000000000000..a4fca507b1d5 --- /dev/null +++ b/core/java/android/companion/virtual/sensor/VirtualSensorAdditionalInfo.java @@ -0,0 +1,202 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.companion.virtual.sensor; + +import android.annotation.FlaggedApi; +import android.annotation.IntDef; +import android.annotation.NonNull; +import android.annotation.SystemApi; +import android.companion.virtualdevice.flags.Flags; +import android.hardware.SensorAdditionalInfo; +import android.os.Parcel; +import android.os.Parcelable; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.util.ArrayList; +import java.util.List; + +/** + * An additional information frame for a {@link VirtualSensor}, which is reported through listener + * callback {@link android.hardware.SensorEventCallback#onSensorAdditionalInfo}. + * + * @see SensorAdditionalInfo + * @see VirtualSensorConfig.Builder#setAdditionalInfoSupported(boolean) + * @hide + */ +@FlaggedApi(Flags.FLAG_VIRTUAL_SENSOR_ADDITIONAL_INFO) +@SystemApi +public final class VirtualSensorAdditionalInfo implements Parcelable { + + private final int mType; + @NonNull + private final List<float[]> mValues; + + /** @hide */ + @IntDef(prefix = "TYPE_", value = { + SensorAdditionalInfo.TYPE_UNTRACKED_DELAY, + SensorAdditionalInfo.TYPE_INTERNAL_TEMPERATURE, + SensorAdditionalInfo.TYPE_VEC3_CALIBRATION, + SensorAdditionalInfo.TYPE_SENSOR_PLACEMENT, + SensorAdditionalInfo.TYPE_SAMPLING, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface Type {} + + private VirtualSensorAdditionalInfo(int type, @NonNull List<float[]> values) { + mType = type; + mValues = values; + } + + private VirtualSensorAdditionalInfo(@NonNull Parcel parcel) { + mType = parcel.readInt(); + final int valuesLength = parcel.readInt(); + mValues = new ArrayList<>(valuesLength); + for (int i = 0; i < valuesLength; ++i) { + mValues.add(parcel.createFloatArray()); + } + } + + @Override + public void writeToParcel(@NonNull Parcel parcel, int parcelableFlags) { + parcel.writeInt(mType); + parcel.writeInt(mValues.size()); + for (int i = 0; i < mValues.size(); ++i) { + parcel.writeFloatArray(mValues.get(i)); + } + } + + @Override + public int describeContents() { + return 0; + } + + /** + * Returns the type of this information frame. + * + * @see SensorAdditionalInfo#type + */ + public int getType() { + return mType; + } + + /** + * Returns the float values of this information frame, if any. + * + * @see SensorAdditionalInfo#floatValues + */ + @NonNull + public List<float[]> getValues() { + return mValues; + } + + /** + * Builder for {@link VirtualSensorAdditionalInfo}. + */ + public static final class Builder { + + @VirtualSensorAdditionalInfo.Type + private final int mType; + @NonNull + private final ArrayList<float[]> mValues = new ArrayList<>(); + + /** + * Creates a new builder. + * + * @param type type of this additional info frame. + * @see SensorAdditionalInfo + */ + public Builder(@VirtualSensorAdditionalInfo.Type int type) { + switch (type) { + case SensorAdditionalInfo.TYPE_UNTRACKED_DELAY: + case SensorAdditionalInfo.TYPE_SAMPLING: + case SensorAdditionalInfo.TYPE_INTERNAL_TEMPERATURE: + case SensorAdditionalInfo.TYPE_VEC3_CALIBRATION: + case SensorAdditionalInfo.TYPE_SENSOR_PLACEMENT: + break; + default: + throw new IllegalArgumentException("Unsupported type " + type); + } + mType = type; + } + + /** + * Additional info payload data represented in float values. Depending on the type of + * information, this may be null. + * + * @see SensorAdditionalInfo#floatValues + */ + @NonNull + public Builder addValues(@NonNull float[] values) { + if (values.length > 14) { + throw new IllegalArgumentException("Maximum payload value size is 14."); + } + if (mValues.isEmpty()) { + switch (mType) { + case SensorAdditionalInfo.TYPE_UNTRACKED_DELAY: + case SensorAdditionalInfo.TYPE_SAMPLING: + assertValuesLength(values, 2); + break; + case SensorAdditionalInfo.TYPE_INTERNAL_TEMPERATURE: + assertValuesLength(values, 1); + break; + case SensorAdditionalInfo.TYPE_VEC3_CALIBRATION: + case SensorAdditionalInfo.TYPE_SENSOR_PLACEMENT: + assertValuesLength(values, 11); + break; + } + } else if (values.length != mValues.getFirst().length) { + throw new IllegalArgumentException("All payload values must have the same length"); + } + + mValues.add(values); + return this; + } + + private void assertValuesLength(float[] values, int expected) { + if (values.length != expected) { + throw new IllegalArgumentException( + "Payload values must have size " + expected + " for type " + mType); + } + } + + /** + * Creates a new {@link VirtualSensorAdditionalInfo}. + * + * @throws IllegalArgumentException if the payload doesn't match the expectation for the + * given type, as documented in {@link SensorAdditionalInfo}. + */ + @NonNull + public VirtualSensorAdditionalInfo build() { + if (mValues.isEmpty()) { + throw new IllegalArgumentException("Payload is required"); + } + return new VirtualSensorAdditionalInfo(mType, mValues); + } + } + + public static final @NonNull Creator<VirtualSensorAdditionalInfo> CREATOR = + new Creator<>() { + public VirtualSensorAdditionalInfo createFromParcel(Parcel source) { + return new VirtualSensorAdditionalInfo(source); + } + + public VirtualSensorAdditionalInfo[] newArray(int size) { + return new VirtualSensorAdditionalInfo[size]; + } + }; +} diff --git a/core/java/android/companion/virtual/sensor/VirtualSensorConfig.java b/core/java/android/companion/virtual/sensor/VirtualSensorConfig.java index 68bc9bce28d2..be8974ec29ad 100644 --- a/core/java/android/companion/virtual/sensor/VirtualSensorConfig.java +++ b/core/java/android/companion/virtual/sensor/VirtualSensorConfig.java @@ -59,10 +59,14 @@ public final class VirtualSensorConfig implements Parcelable { private static final int REPORTING_MODE_MASK = 0xE; private static final int REPORTING_MODE_SHIFT = 1; + // Mask for indication bit of sensor additional information support, bit 6. + static final int ADDITIONAL_INFO_MASK = 0x40; + // Mask for direct mode highest rate level, bit 7, 8, 9. private static final int DIRECT_REPORT_MASK = 0x380; private static final int DIRECT_REPORT_SHIFT = 7; + // Mask for supported direct channel, bit 10, 11 private static final int DIRECT_CHANNEL_SHIFT = 10; @@ -253,6 +257,18 @@ public final class VirtualSensorConfig implements Parcelable { } /** + * Returns whether the sensor supports additional information. + * + * @see Builder#setAdditionalInfoSupported(boolean) + * @see Sensor#isAdditionalInfoSupported() + * @see android.hardware.SensorAdditionalInfo + */ + @FlaggedApi(Flags.FLAG_VIRTUAL_SENSOR_ADDITIONAL_INFO) + public boolean isAdditionalInfoSupported() { + return (mFlags & ADDITIONAL_INFO_MASK) > 0; + } + + /** * Returns the reporting mode of this sensor. * * @see Builder#setReportingMode(int) @@ -450,6 +466,25 @@ public final class VirtualSensorConfig implements Parcelable { } /** + * Sets whether this sensor supports sensor additional information. + * + * @see Sensor#isAdditionalInfoSupported() + * @see android.hardware.SensorAdditionalInfo + * @see VirtualSensorAdditionalInfo + */ + @FlaggedApi(Flags.FLAG_VIRTUAL_SENSOR_ADDITIONAL_INFO) + @NonNull + public VirtualSensorConfig.Builder setAdditionalInfoSupported( + boolean additionalInfoSupported) { + if (additionalInfoSupported) { + mFlags |= ADDITIONAL_INFO_MASK; + } else { + mFlags &= ~ADDITIONAL_INFO_MASK; + } + return this; + } + + /** * Sets the reporting mode of this sensor. * * @throws IllegalArgumentException if the reporting mode is not one of diff --git a/core/java/android/content/pm/SystemFeaturesCache.java b/core/java/android/content/pm/SystemFeaturesCache.java index b3d70fa8bfaf..57dd1e6f4d3b 100644 --- a/core/java/android/content/pm/SystemFeaturesCache.java +++ b/core/java/android/content/pm/SystemFeaturesCache.java @@ -74,6 +74,11 @@ public final class SystemFeaturesCache { return instance; } + /** Checks for existence of the process-global instance. */ + public static boolean hasInstance() { + return sInstance != null; + } + /** Clears the process-global cache instance for testing. */ @VisibleForTesting public static void clearInstance() { diff --git a/core/java/android/content/pm/TEST_MAPPING b/core/java/android/content/pm/TEST_MAPPING index 23f1ff8926df..92ae15a296b7 100644 --- a/core/java/android/content/pm/TEST_MAPPING +++ b/core/java/android/content/pm/TEST_MAPPING @@ -136,6 +136,28 @@ ] }, { + "name": "CtsPackageInstallerCUJInstallationViaIntentForResultTestCases", + "options":[ + { + "exclude-annotation":"androidx.test.filters.FlakyTest" + }, + { + "exclude-annotation":"org.junit.Ignore" + } + ] + }, + { + "name": "CtsPackageInstallerCUJInstallationViaSessionTestCases", + "options":[ + { + "exclude-annotation":"androidx.test.filters.FlakyTest" + }, + { + "exclude-annotation":"org.junit.Ignore" + } + ] + }, + { "name": "CtsPackageInstallerCUJMultiUsersTestCases", "options":[ { @@ -261,6 +283,28 @@ ] }, { + "name": "CtsPackageInstallerCUJInstallationViaIntentForResultTestCases", + "options":[ + { + "exclude-annotation":"androidx.test.filters.FlakyTest" + }, + { + "exclude-annotation":"org.junit.Ignore" + } + ] + }, + { + "name": "CtsPackageInstallerCUJInstallationViaSessionTestCases", + "options":[ + { + "exclude-annotation":"androidx.test.filters.FlakyTest" + }, + { + "exclude-annotation":"org.junit.Ignore" + } + ] + }, + { "name": "CtsPackageInstallerCUJMultiUsersTestCases", "options":[ { diff --git a/core/java/android/content/pm/multiuser.aconfig b/core/java/android/content/pm/multiuser.aconfig index 7f57f5dbf0ab..3411a4897e83 100644 --- a/core/java/android/content/pm/multiuser.aconfig +++ b/core/java/android/content/pm/multiuser.aconfig @@ -636,3 +636,13 @@ flag { description: "Enables support for new supervising user type" bug: "389712089" } + +flag { + name: "use_unified_resources" + namespace: "multiuser" + description: "Use same resources" + bug: "392972139" + metadata { + purpose: PURPOSE_BUGFIX + } +} diff --git a/core/java/android/hardware/serial/OWNERS b/core/java/android/hardware/serial/OWNERS index bc2c66ae7ecd..13f6774a4264 100644 --- a/core/java/android/hardware/serial/OWNERS +++ b/core/java/android/hardware/serial/OWNERS @@ -3,4 +3,5 @@ mjel@google.com chominskib@google.com wzwonarz@google.com gstepniewski@google.com -xutan@google.com
\ No newline at end of file +xutan@google.com +ovn@google.com diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index 894b068b1528..2e7bc6d9b9f7 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -428,6 +428,9 @@ public class InputMethodService extends AbstractInputMethodService { */ @AnyThread public static boolean canImeRenderGesturalNavButtons() { + if (Flags.disallowDisablingImeNavigationBar()) { + return true; + } return SystemProperties.getBoolean(PROP_CAN_RENDER_GESTURAL_NAV_BUTTONS, true); } diff --git a/core/java/android/permission/PermissionManager.java b/core/java/android/permission/PermissionManager.java index 0433c76fbbf4..17033d1143c6 100644 --- a/core/java/android/permission/PermissionManager.java +++ b/core/java/android/permission/PermissionManager.java @@ -1907,9 +1907,9 @@ public final class PermissionManager { @Context.PermissionRequestState public int getPermissionRequestState(@NonNull String packageName, @NonNull String permission, int deviceId) { - int actualDeviceId = resolveDeviceIdForPermissionCheck(mContext, deviceId, permission); + int resolvedDeviceId = resolveDeviceIdForPermissionCheck(mContext, deviceId, permission); return sPermissionRequestStateCache.query( - new PermissionRequestStateQuery(packageName, permission, actualDeviceId)); + new PermissionRequestStateQuery(packageName, permission, resolvedDeviceId)); } /** @@ -2036,8 +2036,8 @@ public final class PermissionManager { */ public int checkPackageNamePermission(String permName, String pkgName, int deviceId, @UserIdInt int userId) { - int actualDeviceId = resolveDeviceIdForPermissionCheck(mContext, deviceId, permName); - String persistentDeviceId = getPersistentDeviceId(actualDeviceId); + int resolvedDeviceId = resolveDeviceIdForPermissionCheck(mContext, deviceId, permName); + String persistentDeviceId = getPersistentDeviceId(resolvedDeviceId); return sPackageNamePermissionCache.query( new PackageNamePermissionQuery(permName, pkgName, persistentDeviceId, userId)); } diff --git a/core/java/android/security/advancedprotection/AdvancedProtectionManager.java b/core/java/android/security/advancedprotection/AdvancedProtectionManager.java index 0b2239aa42b2..62b2bcf32442 100644 --- a/core/java/android/security/advancedprotection/AdvancedProtectionManager.java +++ b/core/java/android/security/advancedprotection/AdvancedProtectionManager.java @@ -124,6 +124,18 @@ public final class AdvancedProtectionManager { @Retention(RetentionPolicy.SOURCE) public @interface FeatureId {} + /** @hide */ + public static String featureIdToString(@FeatureId int featureId) { + return switch(featureId) { + case FEATURE_ID_DISALLOW_CELLULAR_2G -> "DISALLOW_CELLULAR_2G"; + case FEATURE_ID_DISALLOW_INSTALL_UNKNOWN_SOURCES -> "DISALLOW_INSTALL_UNKNOWN_SOURCES"; + case FEATURE_ID_DISALLOW_USB -> "DISALLOW_USB"; + case FEATURE_ID_DISALLOW_WEP -> "DISALLOW_WEP"; + case FEATURE_ID_ENABLE_MTE -> "ENABLE_MTE"; + default -> "UNKNOWN"; + }; + } + private static final Set<Integer> ALL_FEATURE_IDS = Set.of( FEATURE_ID_DISALLOW_CELLULAR_2G, FEATURE_ID_DISALLOW_INSTALL_UNKNOWN_SOURCES, @@ -147,7 +159,7 @@ public final class AdvancedProtectionManager { "android.security.advancedprotection.action.SHOW_ADVANCED_PROTECTION_SUPPORT_DIALOG"; /** - * A string extra used with {@link #createSupportIntent} to identify the feature that needs to + * An int extra used with {@link #createSupportIntent} to identify the feature that needs to * show a support dialog explaining it was disabled by advanced protection. * * @hide */ @@ -156,7 +168,7 @@ public final class AdvancedProtectionManager { "android.security.advancedprotection.extra.SUPPORT_DIALOG_FEATURE"; /** - * A string extra used with {@link #createSupportIntent} to identify the type of the action that + * An int extra used with {@link #createSupportIntent} to identify the type of the action that * needs to be explained in the support dialog. * * @hide */ @@ -194,6 +206,16 @@ public final class AdvancedProtectionManager { @Retention(RetentionPolicy.SOURCE) public @interface SupportDialogType {} + /** @hide */ + public static String supportDialogTypeToString(@SupportDialogType int type) { + return switch(type) { + case SUPPORT_DIALOG_TYPE_UNKNOWN -> "UNKNOWN"; + case SUPPORT_DIALOG_TYPE_BLOCKED_INTERACTION -> "BLOCKED_INTERACTION"; + case SUPPORT_DIALOG_TYPE_DISABLED_SETTING -> "DISABLED_SETTING"; + default -> "UNKNOWN"; + }; + } + private static final Set<Integer> ALL_SUPPORT_DIALOG_TYPES = Set.of( SUPPORT_DIALOG_TYPE_UNKNOWN, SUPPORT_DIALOG_TYPE_BLOCKED_INTERACTION, @@ -372,6 +394,17 @@ public final class AdvancedProtectionManager { return createSupportIntent(featureId, type); } + /** @hide */ + @RequiresPermission(Manifest.permission.MANAGE_ADVANCED_PROTECTION_MODE) + public void logDialogShown(@FeatureId int featureId, @SupportDialogType int type, + boolean learnMoreClicked) { + try { + mService.logDialogShown(featureId, type, learnMoreClicked); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + /** * A callback class for monitoring changes to Advanced Protection state * diff --git a/core/java/android/security/advancedprotection/IAdvancedProtectionService.aidl b/core/java/android/security/advancedprotection/IAdvancedProtectionService.aidl index 1939f829c700..0fc0fbea2989 100644 --- a/core/java/android/security/advancedprotection/IAdvancedProtectionService.aidl +++ b/core/java/android/security/advancedprotection/IAdvancedProtectionService.aidl @@ -35,4 +35,6 @@ interface IAdvancedProtectionService { void setAdvancedProtectionEnabled(boolean enabled); @EnforcePermission("MANAGE_ADVANCED_PROTECTION_MODE") List<AdvancedProtectionFeature> getAdvancedProtectionFeatures(); + @EnforcePermission("MANAGE_ADVANCED_PROTECTION_MODE") + void logDialogShown(int featureId, int type, boolean learnMoreClicked); }
\ No newline at end of file diff --git a/core/java/android/security/flags.aconfig b/core/java/android/security/flags.aconfig index 7013f7d705f8..9fd4618bc5da 100644 --- a/core/java/android/security/flags.aconfig +++ b/core/java/android/security/flags.aconfig @@ -83,13 +83,6 @@ flag { } flag { - name: "report_primary_auth_attempts" - namespace: "biometrics" - description: "Report primary auth attempts from LockSettingsService" - bug: "285053096" -} - -flag { name: "dump_attestation_verifications" namespace: "hardware_backed_security" description: "Add a dump capability for attestation_verification service" diff --git a/core/java/android/service/quickaccesswallet/QuickAccessWalletClientImpl.java b/core/java/android/service/quickaccesswallet/QuickAccessWalletClientImpl.java index 6ed8c6d195e6..929e39f8b65c 100644 --- a/core/java/android/service/quickaccesswallet/QuickAccessWalletClientImpl.java +++ b/core/java/android/service/quickaccesswallet/QuickAccessWalletClientImpl.java @@ -421,7 +421,12 @@ public class QuickAccessWalletClientImpl implements QuickAccessWalletClient, Ser Intent intent = new Intent(SERVICE_INTERFACE); intent.setComponent(serviceInfo.getComponentName()); int flags = Context.BIND_AUTO_CREATE | Context.BIND_WAIVE_PRIORITY; - mLifecycleExecutor.execute(() -> mContext.bindService(intent, this, flags)); + if (mServiceInfo == null) { + mLifecycleExecutor.execute(() -> mContext.bindService(intent, this, flags)); + } else { + mLifecycleExecutor.execute(() -> mContext.bindServiceAsUser(intent, this, flags, + UserHandle.of(mServiceInfo.getUserId()))); + } resetServiceConnectionTimeout(); } diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl index 4fc894ca9ff4..237d8f96496f 100644 --- a/core/java/android/view/IWindowManager.aidl +++ b/core/java/android/view/IWindowManager.aidl @@ -699,7 +699,7 @@ interface IWindowManager /** * Indicates the display should show system decors. * <p> - * System decors include status bar, navigation bar, launcher. + * System decors include status bar, navigation bar, launcher, and wallpaper. * </p> * * @param displayId The id of the display. @@ -719,6 +719,23 @@ interface IWindowManager void setShouldShowSystemDecors(int displayId, boolean shouldShow); /** + * Indicates that the display is eligible for the desktop mode from WindowManager's perspective. + * This includes: + * - The default display; + * - Any display that is allowed to switch the content mode between extended and mirroring + * (which means it can dynamically add or remove system decors), and it is now in extended mode + * (should currently show system decors). + * <p> + * System decors include status bar, navigation bar, launcher, and wallpaper. + * </p> + * + * @param displayId The id of the display. + * @return {@code true} if the display is eligible for the desktop mode from WindowManager's + * perspective. + */ + boolean isEligibleForDesktopMode(int displayId); + + /** * Indicates the policy for how the display should show IME. * * @param displayId The id of the display. @@ -792,7 +809,8 @@ interface IWindowManager * Updates the currently animating insets types of a remote process. */ @EnforcePermission("MANAGE_APP_TOKENS") - void updateDisplayWindowAnimatingTypes(int displayId, int animatingTypes); + void updateDisplayWindowAnimatingTypes(int displayId, int animatingTypes, + in @nullable ImeTracker.Token statsToken); /** * Called to get the expected window insets. diff --git a/core/java/android/view/IWindowSession.aidl b/core/java/android/view/IWindowSession.aidl index 7d6d5a269b4c..ab656ebc6492 100644 --- a/core/java/android/view/IWindowSession.aidl +++ b/core/java/android/view/IWindowSession.aidl @@ -277,8 +277,10 @@ interface IWindowSession { * * @param window The window that is insets animaiton is running. * @param animatingTypes Indicates the currently animating insets types. + * @param imeStatsToken the token tracking the current IME request or {@code null} otherwise. */ - oneway void updateAnimatingTypes(IWindow window, int animatingTypes); + oneway void updateAnimatingTypes(IWindow window, int animatingTypes, + in @nullable ImeTracker.Token imeStatsToken); /** * Called when the system gesture exclusion has changed. diff --git a/core/java/android/view/InsetsController.java b/core/java/android/view/InsetsController.java index 394ac8f8c6e9..6b7b81887706 100644 --- a/core/java/android/view/InsetsController.java +++ b/core/java/android/view/InsetsController.java @@ -215,8 +215,11 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation * contain all types, which have an ongoing animation. * * @param animatingTypes the {@link InsetsType}s that are currently animating + * @param statsToken the token tracking the current IME request or {@code null} otherwise. */ - default void updateAnimatingTypes(@InsetsType int animatingTypes) {} + default void updateAnimatingTypes(@InsetsType int animatingTypes, + @Nullable ImeTracker.Token statsToken) { + } /** @see ViewRootImpl#isHandlingPointerEvent */ default boolean isHandlingPointerEvent() { @@ -748,7 +751,9 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation mFrame, mFromState, mToState, RESIZE_INTERPOLATOR, ANIMATION_DURATION_RESIZE, mTypes, InsetsController.this); if (mRunningAnimations.isEmpty()) { - mHost.updateAnimatingTypes(runner.getTypes()); + mHost.updateAnimatingTypes(runner.getTypes(), + runner.getAnimationType() == ANIMATION_TYPE_HIDE + ? runner.getStatsToken() : null); } mRunningAnimations.add(new RunningAnimation(runner, runner.getAnimationType())); mAnimatingTypes |= runner.getTypes(); @@ -1421,6 +1426,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation if (DEBUG) Log.d(TAG, "no types to animate in controlAnimationUnchecked"); Trace.asyncTraceEnd(TRACE_TAG_VIEW, "IC.showRequestFromApi", 0); Trace.asyncTraceEnd(TRACE_TAG_VIEW, "IC.showRequestFromApiToImeReady", 0); + ImeTracker.forLogging().onFailed(statsToken, ImeTracker.PHASE_CLIENT_CONTROL_ANIMATION); return; } if (DEBUG) Log.d(TAG, "controlAnimation types: " + types); @@ -1569,7 +1575,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation } ImeTracker.forLogging().onProgress(statsToken, ImeTracker.PHASE_CLIENT_ANIMATION_RUNNING); mAnimatingTypes |= runner.getTypes(); - mHost.updateAnimatingTypes(mAnimatingTypes); + mHost.updateAnimatingTypes(mAnimatingTypes, null /* statsToken */); mRunningAnimations.add(new RunningAnimation(runner, animationType)); if (DEBUG) Log.d(TAG, "Animation added to runner. useInsetsAnimationThread: " + useInsetsAnimationThread); @@ -1778,7 +1784,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation ImeTracker.forLogging().onHidden(statsToken); } } - reportRequestedVisibleTypes(shown ? null : runner.getStatsToken()); + reportRequestedVisibleTypes(null /* statsToken */); } @Override @@ -1835,7 +1841,8 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation if (mHost != null) { // if the (hide) animation is cancelled, the // requestedVisibleTypes should be reported at this point. - reportRequestedVisibleTypes(control.getStatsToken()); + reportRequestedVisibleTypes(!Flags.reportAnimatingInsetsTypes() + ? control.getStatsToken() : null); mHost.getInputMethodManager().removeImeSurface( mHost.getWindowToken()); } @@ -1847,7 +1854,13 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation } if (removedTypes > 0) { mAnimatingTypes &= ~removedTypes; - mHost.updateAnimatingTypes(mAnimatingTypes); + if (mHost != null) { + final boolean dispatchStatsToken = + Flags.reportAnimatingInsetsTypes() && (removedTypes & ime()) != 0 + && control.getAnimationType() == ANIMATION_TYPE_HIDE; + mHost.updateAnimatingTypes(mAnimatingTypes, + dispatchStatsToken ? control.getStatsToken() : null); + } } onAnimationStateChanged(removedTypes, false /* running */); @@ -2003,6 +2016,11 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation if (Flags.refactorInsetsController()) { ImeTracker.forLogging().onProgress(statsToken, ImeTracker.PHASE_CLIENT_REPORT_REQUESTED_VISIBLE_TYPES); + if (Flags.reportAnimatingInsetsTypes() && (typesToReport & ime()) == 0) { + // The IME hide animating flow should not be followed from here, but after + // the hide animation has finished and Host.updateAnimatingTypes is called. + statsToken = null; + } } mReportedRequestedVisibleTypes = mRequestedVisibleTypes; mHost.updateRequestedVisibleTypes(mReportedRequestedVisibleTypes, statsToken); diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 2edce5de7ace..7ea869e499fb 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -2555,9 +2555,11 @@ public final class ViewRootImpl implements ViewParent, /** * Notify the when the animating insets types have changed. + * + * @hide */ - @VisibleForTesting - public void updateAnimatingTypes(@InsetsType int animatingTypes) { + public void updateAnimatingTypes(@InsetsType int animatingTypes, + @Nullable ImeTracker.Token statsToken) { if (sToolkitSetFrameRateReadOnlyFlagValue) { boolean running = animatingTypes != 0; if (Trace.isTagEnabled(Trace.TRACE_TAG_VIEW)) { @@ -2567,7 +2569,7 @@ public final class ViewRootImpl implements ViewParent, } mInsetsAnimationRunning = running; try { - mWindowSession.updateAnimatingTypes(mWindow, animatingTypes); + mWindowSession.updateAnimatingTypes(mWindow, animatingTypes, statsToken); } catch (RemoteException e) { } } diff --git a/core/java/android/view/ViewRootInsetsControllerHost.java b/core/java/android/view/ViewRootInsetsControllerHost.java index 8954df6b1aaa..20fa77bf56ea 100644 --- a/core/java/android/view/ViewRootInsetsControllerHost.java +++ b/core/java/android/view/ViewRootInsetsControllerHost.java @@ -171,9 +171,15 @@ public class ViewRootInsetsControllerHost implements InsetsController.Host { } @Override - public void updateAnimatingTypes(@WindowInsets.Type.InsetsType int animatingTypes) { + public void updateAnimatingTypes(@WindowInsets.Type.InsetsType int animatingTypes, + @Nullable ImeTracker.Token statsToken) { if (mViewRoot != null) { - mViewRoot.updateAnimatingTypes(animatingTypes); + ImeTracker.forLogging().onProgress(statsToken, + ImeTracker.PHASE_CLIENT_UPDATE_ANIMATING_TYPES); + mViewRoot.updateAnimatingTypes(animatingTypes, statsToken); + } else { + ImeTracker.forLogging().onFailed(statsToken, + ImeTracker.PHASE_CLIENT_UPDATE_ANIMATING_TYPES); } } diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java index 39533344173b..9097849085a9 100644 --- a/core/java/android/view/Window.java +++ b/core/java/android/view/Window.java @@ -1840,6 +1840,16 @@ public abstract class Window { @NonNull public abstract LayoutInflater getLayoutInflater(); + /** + * Sets a user-facing title for the window. + * <p> + * This title may be shown to the user in the window's title or action bar + * if the {@link #requestFeature requested features} provide such a bar. + * It is also exposed through {@link + * android.view.accessibility.AccessibilityWindowInfo#getTitle}. + * + * @see WindowManager.LayoutParams#setTitle + */ public abstract void setTitle(CharSequence title); @Deprecated diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index 315f1ba58529..9d21f1aff0c3 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -5095,6 +5095,15 @@ public interface WindowManager extends ViewManager { format = _format; } + /** + * Sets a title for the window. + * <p> + * This title will be used primarily for debugging, and may be exposed via {@link + * android.view.accessibility.AccessibilityWindowInfo#getTitle} if no {@link Window#setTitle + * user-facing title} has been set. + * + * @see Window#setTitle + */ public final void setTitle(CharSequence title) { if (null == title) title = ""; diff --git a/core/java/android/view/WindowlessWindowManager.java b/core/java/android/view/WindowlessWindowManager.java index 0a86ff89c53c..a5ab917c267d 100644 --- a/core/java/android/view/WindowlessWindowManager.java +++ b/core/java/android/view/WindowlessWindowManager.java @@ -597,7 +597,8 @@ public class WindowlessWindowManager implements IWindowSession { } @Override - public void updateAnimatingTypes(IWindow window, @InsetsType int animatingTypes) { + public void updateAnimatingTypes(IWindow window, @InsetsType int animatingTypes, + @Nullable ImeTracker.Token statsToken) { // NO-OP } diff --git a/core/java/android/view/accessibility/AccessibilityWindowInfo.java b/core/java/android/view/accessibility/AccessibilityWindowInfo.java index 7b6e070f0008..c17002ed706e 100644 --- a/core/java/android/view/accessibility/AccessibilityWindowInfo.java +++ b/core/java/android/view/accessibility/AccessibilityWindowInfo.java @@ -160,6 +160,9 @@ public final class AccessibilityWindowInfo implements Parcelable { /** * Gets the title of the window. + * <p> + * This is taken from the {@link android.view.Window}'s title, or its {@link + * android.view.WindowManager.LayoutParams} if that is unset. * * @return The title of the window, or {@code null} if none is available. */ diff --git a/core/java/android/view/inputmethod/ImeTracker.java b/core/java/android/view/inputmethod/ImeTracker.java index 60178cde249f..5dadf32d2a36 100644 --- a/core/java/android/view/inputmethod/ImeTracker.java +++ b/core/java/android/view/inputmethod/ImeTracker.java @@ -226,6 +226,11 @@ public interface ImeTracker { PHASE_WM_DISPLAY_IME_CONTROLLER_SET_IME_REQUESTED_VISIBLE, PHASE_WM_UPDATE_DISPLAY_WINDOW_REQUESTED_VISIBLE_TYPES, PHASE_WM_REQUESTED_VISIBLE_TYPES_NOT_CHANGED, + PHASE_CLIENT_UPDATE_ANIMATING_TYPES, + PHASE_WM_UPDATE_ANIMATING_TYPES, + PHASE_WM_WINDOW_ANIMATING_TYPES_CHANGED, + PHASE_WM_NOTIFY_HIDE_ANIMATION_FINISHED, + PHASE_WM_UPDATE_DISPLAY_WINDOW_ANIMATING_TYPES, }) @Retention(RetentionPolicy.SOURCE) @interface Phase {} @@ -449,6 +454,21 @@ public interface ImeTracker { /** The requestedVisibleTypes have not been changed, so this request is not continued. */ int PHASE_WM_REQUESTED_VISIBLE_TYPES_NOT_CHANGED = ImeProtoEnums.PHASE_WM_REQUESTED_VISIBLE_TYPES_NOT_CHANGED; + /** Updating the currently animating types on the client side. */ + int PHASE_CLIENT_UPDATE_ANIMATING_TYPES = + ImeProtoEnums.PHASE_CLIENT_UPDATE_ANIMATING_TYPES; + /** Updating the animating types in the WindowState on the WindowManager side. */ + int PHASE_WM_UPDATE_ANIMATING_TYPES = + ImeProtoEnums.PHASE_WM_UPDATE_ANIMATING_TYPES; + /** Animating types of the WindowState have changed, now sending them to state controller. */ + int PHASE_WM_WINDOW_ANIMATING_TYPES_CHANGED = + ImeProtoEnums.PHASE_WM_WINDOW_ANIMATING_TYPES_CHANGED; + /** ImeInsetsSourceProvider got notified that the hide animation is finished. */ + int PHASE_WM_NOTIFY_HIDE_ANIMATION_FINISHED = + ImeProtoEnums.PHASE_WM_NOTIFY_HIDE_ANIMATION_FINISHED; + /** The control target reported its animatingTypes back to WindowManagerService. */ + int PHASE_WM_UPDATE_DISPLAY_WINDOW_ANIMATING_TYPES = + ImeProtoEnums.PHASE_WM_UPDATE_DISPLAY_WINDOW_ANIMATING_TYPES; /** * Called when an IME request is started. diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index a41ab368aed8..b3bd89c2a87d 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -2454,6 +2454,7 @@ public final class InputMethodManager { & WindowInsets.Type.ime()) == 0 || viewRootImpl.getInsetsController() .isPredictiveBackImeHideAnimInProgress())) { + Handler vh = view.getHandler(); ImeTracker.forLogging().onProgress(statsToken, ImeTracker.PHASE_CLIENT_NO_ONGOING_USER_ANIMATION); if (resultReceiver != null) { @@ -2464,8 +2465,17 @@ public final class InputMethodManager { : InputMethodManager.RESULT_SHOWN, null); } // TODO(b/322992891) handle case of SHOW_IMPLICIT - viewRootImpl.getInsetsController().show(WindowInsets.Type.ime(), - false /* fromIme */, statsToken); + if (vh.getLooper() != Looper.myLooper()) { + // The view is running on a different thread than our own, so + // we need to reschedule our work for over there. + if (DEBUG) Log.v(TAG, "Show soft input: reschedule to view thread"); + final var finalStatsToken = statsToken; + vh.post(() -> viewRootImpl.getInsetsController().show( + WindowInsets.Type.ime(), false /* fromIme */, finalStatsToken)); + } else { + viewRootImpl.getInsetsController().show(WindowInsets.Type.ime(), + false /* fromIme */, statsToken); + } return true; } ImeTracker.forLogging().onCancelled(statsToken, diff --git a/core/java/android/view/inputmethod/flags.aconfig b/core/java/android/view/inputmethod/flags.aconfig index 67e54423414c..cdca4102dd96 100644 --- a/core/java/android/view/inputmethod/flags.aconfig +++ b/core/java/android/view/inputmethod/flags.aconfig @@ -224,3 +224,14 @@ flag { purpose: PURPOSE_BUGFIX } } + +flag { + name: "disallow_disabling_ime_navigation_bar" + namespace: "input_method" + description: "Disallows disabling the IME navigation bar through canImeRenderGesturalNavButtons" + bug: "402442590" + is_fixed_read_only: true + metadata { + purpose: PURPOSE_BUGFIX + } +} diff --git a/core/java/android/window/DesktopExperienceFlags.java b/core/java/android/window/DesktopExperienceFlags.java index 50b8bd22350c..5e8ce5ee557f 100644 --- a/core/java/android/window/DesktopExperienceFlags.java +++ b/core/java/android/window/DesktopExperienceFlags.java @@ -61,6 +61,7 @@ public enum DesktopExperienceFlags { ENABLE_DISPLAY_RECONNECT_INTERACTION(Flags::enableDisplayReconnectInteraction, false), ENABLE_DISPLAY_WINDOWING_MODE_SWITCHING(Flags::enableDisplayWindowingModeSwitching, true), ENABLE_DRAG_TO_MAXIMIZE(Flags::enableDragToMaximize, true), + ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX(Flags::enableDynamicRadiusComputationBugfix, false), ENABLE_KEYBOARD_SHORTCUTS_TO_SWITCH_DESKS(Flags::keyboardShortcutsToSwitchDesks, false), ENABLE_MOVE_TO_NEXT_DISPLAY_SHORTCUT(Flags::enableMoveToNextDisplayShortcut, true), ENABLE_MULTIPLE_DESKTOPS_BACKEND(Flags::enableMultipleDesktopsBackend, false), diff --git a/core/java/android/window/DesktopModeFlags.java b/core/java/android/window/DesktopModeFlags.java index aecf6eb261b1..5b3044e1988a 100644 --- a/core/java/android/window/DesktopModeFlags.java +++ b/core/java/android/window/DesktopModeFlags.java @@ -146,6 +146,8 @@ public enum DesktopModeFlags { Flags::includeTopTransparentFullscreenTaskInDesktopHeuristic, true), INHERIT_TASK_BOUNDS_FOR_TRAMPOLINE_TASK_LAUNCHES( Flags::inheritTaskBoundsForTrampolineTaskLaunches, false), + SKIP_DECOR_VIEW_RELAYOUT_WHEN_CLOSING_BUGFIX( + Flags::skipDecorViewRelayoutWhenClosingBugfix, false), // go/keep-sorted end ; diff --git a/core/java/android/window/flags/lse_desktop_experience.aconfig b/core/java/android/window/flags/lse_desktop_experience.aconfig index c193e33301bd..afc9660c1a3a 100644 --- a/core/java/android/window/flags/lse_desktop_experience.aconfig +++ b/core/java/android/window/flags/lse_desktop_experience.aconfig @@ -933,6 +933,16 @@ flag { } flag { + name: "skip_decor_view_relayout_when_closing_bugfix" + namespace: "lse_desktop_experience" + description: "Enables bugfix to skip DecorView relayout when the corresponding window is closing." + bug: "394502142" + metadata { + purpose: PURPOSE_BUGFIX + } +} + +flag { name: "enable_size_compat_mode_improvements_for_connected_displays" namespace: "lse_desktop_experience" description: "Enable some improvements in size compat mode for connected displays." diff --git a/core/java/com/android/internal/os/BatteryStatsHistory.java b/core/java/com/android/internal/os/BatteryStatsHistory.java index c6207f9451c2..8151429f9139 100644 --- a/core/java/com/android/internal/os/BatteryStatsHistory.java +++ b/core/java/com/android/internal/os/BatteryStatsHistory.java @@ -672,6 +672,7 @@ public class BatteryStatsHistory { */ public void reset() { synchronized (this) { + mMonotonicHistorySize = 0; initHistoryBuffer(); if (mStore != null) { mStore.reset(); diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java index 3f9650773211..d35072fc10c3 100644 --- a/core/java/com/android/internal/widget/LockPatternUtils.java +++ b/core/java/com/android/internal/widget/LockPatternUtils.java @@ -22,7 +22,6 @@ import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_NUMERIC; import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX; import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_SOMETHING; import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED; -import static android.security.Flags.reportPrimaryAuthAttempts; import static android.security.Flags.shouldTrustManagerListenForPrimaryAuth; import static com.android.internal.widget.flags.Flags.hideLastCharWithPhysicalInput; @@ -472,7 +471,7 @@ public class LockPatternUtils { return; } getDevicePolicyManager().reportFailedPasswordAttempt(userId); - if (!reportPrimaryAuthAttempts() || !shouldTrustManagerListenForPrimaryAuth()) { + if (!shouldTrustManagerListenForPrimaryAuth()) { getTrustManager().reportUnlockAttempt(/* authenticated= */ false, userId); } } @@ -483,7 +482,7 @@ public class LockPatternUtils { return; } getDevicePolicyManager().reportSuccessfulPasswordAttempt(userId); - if (!reportPrimaryAuthAttempts() || !shouldTrustManagerListenForPrimaryAuth()) { + if (!shouldTrustManagerListenForPrimaryAuth()) { getTrustManager().reportUnlockAttempt(/* authenticated= */ true, userId); } } diff --git a/core/java/com/android/internal/widget/remotecompose/accessibility/AndroidPlatformSemanticNodeApplier.java b/core/java/com/android/internal/widget/remotecompose/accessibility/AndroidPlatformSemanticNodeApplier.java index a53d6b899898..3fe6873028cd 100644 --- a/core/java/com/android/internal/widget/remotecompose/accessibility/AndroidPlatformSemanticNodeApplier.java +++ b/core/java/com/android/internal/widget/remotecompose/accessibility/AndroidPlatformSemanticNodeApplier.java @@ -132,8 +132,13 @@ public class AndroidPlatformSemanticNodeApplier } } - // TODO correct values - nodeInfo.setCollectionInfo(AccessibilityNodeInfo.CollectionInfo.obtain(-1, 1, false)); + if (scrollDirection == RootContentBehavior.SCROLL_HORIZONTAL) { + nodeInfo.setCollectionInfo(AccessibilityNodeInfo.CollectionInfo.obtain(1, -1, false)); + nodeInfo.setClassName("android.widget.HorizontalScrollView"); + } else { + nodeInfo.setCollectionInfo(AccessibilityNodeInfo.CollectionInfo.obtain(-1, 1, false)); + nodeInfo.setClassName("android.widget.ScrollView"); + } if (scrollDirection == RootContentBehavior.SCROLL_HORIZONTAL) { nodeInfo.setClassName("android.widget.HorizontalScrollView"); diff --git a/core/java/com/android/internal/widget/remotecompose/accessibility/CoreDocumentAccessibility.java b/core/java/com/android/internal/widget/remotecompose/accessibility/CoreDocumentAccessibility.java index f70f4cbceb70..db2c46046561 100644 --- a/core/java/com/android/internal/widget/remotecompose/accessibility/CoreDocumentAccessibility.java +++ b/core/java/com/android/internal/widget/remotecompose/accessibility/CoreDocumentAccessibility.java @@ -33,6 +33,7 @@ import com.android.internal.widget.remotecompose.core.semantics.AccessibilitySem import com.android.internal.widget.remotecompose.core.semantics.AccessibleComponent; import com.android.internal.widget.remotecompose.core.semantics.CoreSemantics; import com.android.internal.widget.remotecompose.core.semantics.ScrollableComponent; +import com.android.internal.widget.remotecompose.core.semantics.ScrollableComponent.ScrollDirection; import java.util.ArrayList; import java.util.Collections; @@ -104,9 +105,9 @@ public class CoreDocumentAccessibility implements RemoteComposeDocumentAccessibi if (isClickAction(action)) { return performClick(component); } else if (isScrollForwardAction(action)) { - return scrollByOffset(mRemoteContext, component, -500) != 0; + return scrollDirection(mRemoteContext, component, ScrollDirection.FORWARD); } else if (isScrollBackwardAction(action)) { - return scrollByOffset(mRemoteContext, component, 500) != 0; + return scrollDirection(mRemoteContext, component, ScrollDirection.BACKWARD); } else if (isShowOnScreenAction(action)) { return showOnScreen(mRemoteContext, component); } else { @@ -141,17 +142,30 @@ public class CoreDocumentAccessibility implements RemoteComposeDocumentAccessibi } private boolean showOnScreen(RemoteContext context, Component component) { - if (component.getParent() instanceof LayoutComponent) { - LayoutComponent parent = (LayoutComponent) component.getParent(); + ScrollableComponent scrollable = findScrollable(component); + + if (scrollable != null) { + return scrollable.showOnScreen(context, component); + } + + return false; + } + + @Nullable + private static ScrollableComponent findScrollable(Component component) { + Component parent = component.getParent(); + + while (parent != null) { ScrollableComponent scrollable = parent.selfOrModifier(ScrollableComponent.class); if (scrollable != null) { - scrollable.showOnScreen(context, component.getComponentId()); - return true; + return scrollable; + } else { + parent = parent.getParent(); } } - return false; + return null; } /** @@ -173,6 +187,25 @@ public class CoreDocumentAccessibility implements RemoteComposeDocumentAccessibi } /** + * scroll content in a given direction + * + * @param context + * @param component + * @param direction + * @return + */ + public boolean scrollDirection( + RemoteContext context, Component component, ScrollDirection direction) { + ScrollableComponent scrollable = component.selfOrModifier(ScrollableComponent.class); + + if (scrollable != null) { + return scrollable.scrollDirection(context, direction); + } + + return false; + } + + /** * Perform a click on the given component * * @param component diff --git a/core/java/com/android/internal/widget/remotecompose/accessibility/PlatformRemoteComposeTouchHelper.java b/core/java/com/android/internal/widget/remotecompose/accessibility/PlatformRemoteComposeTouchHelper.java index c38a44ac30be..da4e8d621602 100644 --- a/core/java/com/android/internal/widget/remotecompose/accessibility/PlatformRemoteComposeTouchHelper.java +++ b/core/java/com/android/internal/widget/remotecompose/accessibility/PlatformRemoteComposeTouchHelper.java @@ -39,6 +39,7 @@ public class PlatformRemoteComposeTouchHelper extends ExploreByTouchHelper { private final RemoteComposeDocumentAccessibility mRemoteDocA11y; private final SemanticNodeApplier<AccessibilityNodeInfo> mApplier; + private final View mHost; public PlatformRemoteComposeTouchHelper( View host, @@ -47,6 +48,7 @@ public class PlatformRemoteComposeTouchHelper extends ExploreByTouchHelper { super(host); this.mRemoteDocA11y = remoteDocA11y; this.mApplier = applier; + this.mHost = host; } public static PlatformRemoteComposeTouchHelper forRemoteComposePlayer( @@ -150,6 +152,7 @@ public class PlatformRemoteComposeTouchHelper extends ExploreByTouchHelper { boolean performed = mRemoteDocA11y.performAction(component, action, arguments); if (performed) { + mHost.invalidate(); invalidateRoot(); } diff --git a/core/java/com/android/internal/widget/remotecompose/core/CoreDocument.java b/core/java/com/android/internal/widget/remotecompose/core/CoreDocument.java index caf19e1ed34a..766fbf1a80f5 100644 --- a/core/java/com/android/internal/widget/remotecompose/core/CoreDocument.java +++ b/core/java/com/android/internal/widget/remotecompose/core/CoreDocument.java @@ -73,7 +73,9 @@ public class CoreDocument implements Serializable { // We also keep a more fine-grained BUILD number, exposed as // ID_API_LEVEL = DOCUMENT_API_LEVEL + BUILD - static final float BUILD = 0.5f; + static final float BUILD = 0.7f; + + private static final boolean UPDATE_VARIABLES_BEFORE_LAYOUT = false; @NonNull ArrayList<Operation> mOperations = new ArrayList<>(); @@ -840,18 +842,25 @@ public class CoreDocument implements Serializable { @NonNull private HashMap<Integer, Component> mComponentMap = new HashMap<Integer, Component>(); + /** + * Register all the operations recursively + * + * @param context + * @param list + */ private void registerVariables( @NonNull RemoteContext context, @NonNull ArrayList<Operation> list) { for (Operation op : list) { if (op instanceof VariableSupport) { - ((VariableSupport) op).updateVariables(context); ((VariableSupport) op).registerListening(context); } if (op instanceof Component) { mComponentMap.put(((Component) op).getComponentId(), (Component) op); - registerVariables(context, ((Component) op).getList()); ((Component) op).registerVariables(context); } + if (op instanceof Container) { + registerVariables(context, ((Container) op).getList()); + } if (op instanceof ComponentValue) { ComponentValue v = (ComponentValue) op; Component component = mComponentMap.get(v.getComponentId()); @@ -864,14 +873,34 @@ public class CoreDocument implements Serializable { if (op instanceof ComponentModifiers) { for (ModifierOperation modifier : ((ComponentModifiers) op).getList()) { if (modifier instanceof VariableSupport) { - ((VariableSupport) modifier).updateVariables(context); ((VariableSupport) modifier).registerListening(context); } } } + } + } + + /** + * Apply the operations recursively, for the original initialization pass with mode == DATA + * + * @param context + * @param list + */ + private void applyOperations( + @NonNull RemoteContext context, @NonNull ArrayList<Operation> list) { + for (Operation op : list) { + if (op instanceof VariableSupport) { + ((VariableSupport) op).updateVariables(context); + } + if (op instanceof Component) { // for componentvalues... + ((Component) op).updateVariables(context); + } op.markNotDirty(); op.apply(context); context.incrementOpCount(); + if (op instanceof Container) { + applyOperations(context, ((Container) op).getList()); + } } } @@ -891,8 +920,12 @@ public class CoreDocument implements Serializable { mTimeVariables.updateTime(context); registerVariables(context, mOperations); + applyOperations(context, mOperations); context.mMode = RemoteContext.ContextMode.UNSET; - mFirstPaint = true; + + if (UPDATE_VARIABLES_BEFORE_LAYOUT) { + mFirstPaint = true; + } } /////////////////////////////////////////////////////////////////////////////////////////////// @@ -1241,11 +1274,13 @@ public class CoreDocument implements Serializable { context.mRemoteComposeState = mRemoteComposeState; context.mRemoteComposeState.setContext(context); - // Update any dirty variables - if (mFirstPaint) { - mFirstPaint = false; - } else { - updateVariables(context, theme, mOperations); + if (UPDATE_VARIABLES_BEFORE_LAYOUT) { + // Update any dirty variables + if (mFirstPaint) { + mFirstPaint = false; + } else { + updateVariables(context, theme, mOperations); + } } // If we have a content sizing set, we are going to take the original document diff --git a/core/java/com/android/internal/widget/remotecompose/core/Operations.java b/core/java/com/android/internal/widget/remotecompose/core/Operations.java index ac9f98bd6b15..add9d5bae552 100644 --- a/core/java/com/android/internal/widget/remotecompose/core/Operations.java +++ b/core/java/com/android/internal/widget/remotecompose/core/Operations.java @@ -111,6 +111,7 @@ import com.android.internal.widget.remotecompose.core.operations.layout.managers import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.BackgroundModifierOperation; import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.BorderModifierOperation; import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ClipRectModifierOperation; +import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.CollapsiblePriorityModifierOperation; import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ComponentVisibilityOperation; import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.DrawContentOperation; import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.GraphicsLayerModifierOperation; @@ -257,6 +258,7 @@ public class Operations { public static final int MODIFIER_HEIGHT = 67; public static final int MODIFIER_WIDTH_IN = 231; public static final int MODIFIER_HEIGHT_IN = 232; + public static final int MODIFIER_COLLAPSIBLE_PRIORITY = 235; public static final int MODIFIER_BACKGROUND = 55; public static final int MODIFIER_BORDER = 107; public static final int MODIFIER_PADDING = 58; @@ -368,6 +370,7 @@ public class Operations { map.put(MODIFIER_HEIGHT, HeightModifierOperation::read); map.put(MODIFIER_WIDTH_IN, WidthInModifierOperation::read); map.put(MODIFIER_HEIGHT_IN, HeightInModifierOperation::read); + map.put(MODIFIER_COLLAPSIBLE_PRIORITY, CollapsiblePriorityModifierOperation::read); map.put(MODIFIER_PADDING, PaddingModifierOperation::read); map.put(MODIFIER_BACKGROUND, BackgroundModifierOperation::read); map.put(MODIFIER_BORDER, BorderModifierOperation::read); diff --git a/core/java/com/android/internal/widget/remotecompose/core/RemoteContext.java b/core/java/com/android/internal/widget/remotecompose/core/RemoteContext.java index e37833f33fa5..b297a023d03b 100644 --- a/core/java/com/android/internal/widget/remotecompose/core/RemoteContext.java +++ b/core/java/com/android/internal/widget/remotecompose/core/RemoteContext.java @@ -46,7 +46,7 @@ public abstract class RemoteContext { new CoreDocument(); // todo: is this a valid way to initialize? bbade@ public @NonNull RemoteComposeState mRemoteComposeState = new RemoteComposeState(); // todo, is this a valid use of RemoteComposeState -- bbade@ - + private long mDocLoadTime = System.currentTimeMillis(); @Nullable protected PaintContext mPaintContext = null; protected float mDensity = Float.NaN; @@ -83,6 +83,20 @@ public abstract class RemoteContext { } } + /** + * Get the time the document was loaded + * + * @return time in ms since the document was loaded + */ + public long getDocLoadTime() { + return mDocLoadTime; + } + + /** Set the time the document was loaded */ + public void setDocLoadTime() { + mDocLoadTime = System.currentTimeMillis(); + } + public boolean isAnimationEnabled() { return mAnimate; } diff --git a/core/java/com/android/internal/widget/remotecompose/core/operations/FloatExpression.java b/core/java/com/android/internal/widget/remotecompose/core/operations/FloatExpression.java index eba201bfb216..0901ae3eca75 100644 --- a/core/java/com/android/internal/widget/remotecompose/core/operations/FloatExpression.java +++ b/core/java/com/android/internal/widget/remotecompose/core/operations/FloatExpression.java @@ -149,7 +149,6 @@ public class FloatExpression extends Operation implements VariableSupport, Seria @Override public void apply(@NonNull RemoteContext context) { - updateVariables(context); float t = context.getAnimationTime(); if (Float.isNaN(mLastChange)) { mLastChange = t; diff --git a/core/java/com/android/internal/widget/remotecompose/core/operations/ParticlesCreate.java b/core/java/com/android/internal/widget/remotecompose/core/operations/ParticlesCreate.java index ee9e7a4045cb..e86eabffbeaf 100644 --- a/core/java/com/android/internal/widget/remotecompose/core/operations/ParticlesCreate.java +++ b/core/java/com/android/internal/widget/remotecompose/core/operations/ParticlesCreate.java @@ -23,6 +23,8 @@ import android.annotation.NonNull; import com.android.internal.widget.remotecompose.core.Operation; import com.android.internal.widget.remotecompose.core.Operations; +import com.android.internal.widget.remotecompose.core.PaintContext; +import com.android.internal.widget.remotecompose.core.PaintOperation; import com.android.internal.widget.remotecompose.core.RemoteContext; import com.android.internal.widget.remotecompose.core.VariableSupport; import com.android.internal.widget.remotecompose.core.WireBuffer; @@ -30,6 +32,7 @@ import com.android.internal.widget.remotecompose.core.documentation.Documentatio import com.android.internal.widget.remotecompose.core.documentation.DocumentedOperation; import com.android.internal.widget.remotecompose.core.operations.utilities.AnimatedFloatExpression; import com.android.internal.widget.remotecompose.core.operations.utilities.NanMap; +import com.android.internal.widget.remotecompose.core.serialize.MapSerializer; import java.util.Arrays; import java.util.List; @@ -38,7 +41,7 @@ import java.util.List; * This creates a particle system. which consist of id, particleCount, array of id's and equations * for constructing the particles */ -public class ParticlesCreate extends Operation implements VariableSupport { +public class ParticlesCreate extends PaintOperation implements VariableSupport { private static final int OP_CODE = Operations.PARTICLE_DEFINE; private static final String CLASS_NAME = "ParticlesCreate"; private final int mId; @@ -214,6 +217,13 @@ public class ParticlesCreate extends Operation implements VariableSupport { return indent + toString(); } + @Override + public void paint(@NonNull PaintContext context) { + for (int i = 0; i < mParticles.length; i++) { + initializeParticle(i); + } + } + void initializeParticle(int pNo) { for (int j = 0; j < mParticles[pNo].length; j++) { for (int k = 0; k < mIndexeVars.length; k++) { @@ -226,13 +236,6 @@ public class ParticlesCreate extends Operation implements VariableSupport { } } - @Override - public void apply(@NonNull RemoteContext context) { - for (int i = 0; i < mParticles.length; i++) { - initializeParticle(i); - } - } - public float[][] getParticles() { return mParticles; } @@ -244,4 +247,7 @@ public class ParticlesCreate extends Operation implements VariableSupport { public float[][] getEquations() { return mOutEquations; } + + @Override + public void serialize(MapSerializer serializer) {} } diff --git a/core/java/com/android/internal/widget/remotecompose/core/operations/PathAppend.java b/core/java/com/android/internal/widget/remotecompose/core/operations/PathAppend.java index 8a747e134897..31d21c4d539c 100644 --- a/core/java/com/android/internal/widget/remotecompose/core/operations/PathAppend.java +++ b/core/java/com/android/internal/widget/remotecompose/core/operations/PathAppend.java @@ -258,6 +258,6 @@ public class PathAppend extends PaintOperation implements VariableSupport, Seria @Override public void serialize(MapSerializer serializer) { - serializer.addType(CLASS_NAME).add("id", mInstanceId).add("path", pathString(mFloatPath)); + serializer.addType(CLASS_NAME).add("id", mInstanceId).addPath("path", mFloatPath); } } diff --git a/core/java/com/android/internal/widget/remotecompose/core/operations/PathCreate.java b/core/java/com/android/internal/widget/remotecompose/core/operations/PathCreate.java index 78e3b9eac110..7a28992496b4 100644 --- a/core/java/com/android/internal/widget/remotecompose/core/operations/PathCreate.java +++ b/core/java/com/android/internal/widget/remotecompose/core/operations/PathCreate.java @@ -242,6 +242,6 @@ public class PathCreate extends PaintOperation implements VariableSupport, Seria @Override public void serialize(MapSerializer serializer) { - serializer.addType(CLASS_NAME).add("id", mInstanceId).add("path", pathString(mFloatPath)); + serializer.addType(CLASS_NAME).add("id", mInstanceId).addPath("path", mFloatPath); } } diff --git a/core/java/com/android/internal/widget/remotecompose/core/operations/PathData.java b/core/java/com/android/internal/widget/remotecompose/core/operations/PathData.java index cedc4f3b0e45..8b01722aea86 100644 --- a/core/java/com/android/internal/widget/remotecompose/core/operations/PathData.java +++ b/core/java/com/android/internal/widget/remotecompose/core/operations/PathData.java @@ -243,6 +243,6 @@ public class PathData extends Operation implements VariableSupport, Serializable @Override public void serialize(MapSerializer serializer) { - serializer.addType(CLASS_NAME).add("id", mInstanceId).add("path", pathString(mFloatPath)); + serializer.addType(CLASS_NAME).add("id", mInstanceId).addPath("path", mFloatPath); } } diff --git a/core/java/com/android/internal/widget/remotecompose/core/operations/TimeAttribute.java b/core/java/com/android/internal/widget/remotecompose/core/operations/TimeAttribute.java index e9cc26f58c9b..dee79a45de3d 100644 --- a/core/java/com/android/internal/widget/remotecompose/core/operations/TimeAttribute.java +++ b/core/java/com/android/internal/widget/remotecompose/core/operations/TimeAttribute.java @@ -85,6 +85,9 @@ public class TimeAttribute extends PaintOperation { /** the year */ public static final short TIME_YEAR = 12; + /** (value - doc_load_time) * 1E-3 */ + public static final short TIME_FROM_LOAD_SEC = 14; + /** * creates a new operation * @@ -226,6 +229,7 @@ public class TimeAttribute extends PaintOperation { int val = mType & 255; int flags = mType >> 8; RemoteContext ctx = context.getContext(); + long load_time = ctx.getDocLoadTime(); LongConstant longConstant = (LongConstant) ctx.getObject(mTimeId); long value = longConstant.getValue(); long delta = 0; @@ -292,6 +296,9 @@ public class TimeAttribute extends PaintOperation { case TIME_YEAR: ctx.loadFloat(mId, time.getYear()); break; + case TIME_FROM_LOAD_SEC: + ctx.loadFloat(mId, (value - load_time) * 1E-3f); + break; } } @@ -334,6 +341,8 @@ public class TimeAttribute extends PaintOperation { return "TIME_DAY_OF_WEEK"; case TIME_YEAR: return "TIME_YEAR"; + case TIME_FROM_LOAD_SEC: + return "TIME_FROM_LOAD_SEC"; default: return "INVALID_TIME_TYPE"; } diff --git a/core/java/com/android/internal/widget/remotecompose/core/operations/layout/Component.java b/core/java/com/android/internal/widget/remotecompose/core/operations/layout/Component.java index f1158d91f94b..425c61b636c4 100644 --- a/core/java/com/android/internal/widget/remotecompose/core/operations/layout/Component.java +++ b/core/java/com/android/internal/widget/remotecompose/core/operations/layout/Component.java @@ -175,20 +175,25 @@ public class Component extends PaintOperation + mComponentId); } for (ComponentValue v : mComponentValues) { - switch (v.getType()) { - case ComponentValue.WIDTH: - context.loadFloat(v.getValueId(), mWidth); - if (DEBUG) { - System.out.println("Updating WIDTH for " + mComponentId + " to " + mWidth); - } - break; - case ComponentValue.HEIGHT: - context.loadFloat(v.getValueId(), mHeight); - if (DEBUG) { - System.out.println( - "Updating HEIGHT for " + mComponentId + " to " + mHeight); - } - break; + if (context.getMode() == RemoteContext.ContextMode.DATA) { + context.loadFloat(v.getValueId(), 1f); + } else { + switch (v.getType()) { + case ComponentValue.WIDTH: + context.loadFloat(v.getValueId(), mWidth); + if (DEBUG) { + System.out.println( + "Updating WIDTH for " + mComponentId + " to " + mWidth); + } + break; + case ComponentValue.HEIGHT: + context.loadFloat(v.getValueId(), mHeight); + if (DEBUG) { + System.out.println( + "Updating HEIGHT for " + mComponentId + " to " + mHeight); + } + break; + } } } } @@ -824,15 +829,27 @@ public class Component extends PaintOperation * * @param value a 2 dimension float array that will receive the horizontal and vertical position * of the component. + * @param forSelf whether the location is for this container or a child, relevant for scrollable + * items. */ - public void getLocationInWindow(@NonNull float[] value) { + public void getLocationInWindow(@NonNull float[] value, boolean forSelf) { value[0] += mX; value[1] += mY; if (mParent != null) { - mParent.getLocationInWindow(value); + mParent.getLocationInWindow(value, false); } } + /** + * Returns the location of the component relative to the root component + * + * @param value a 2 dimension float array that will receive the horizontal and vertical position + * of the component. + */ + public void getLocationInWindow(@NonNull float[] value) { + getLocationInWindow(value, true); + } + @NonNull @Override public String toString() { diff --git a/core/java/com/android/internal/widget/remotecompose/core/operations/layout/LayoutComponent.java b/core/java/com/android/internal/widget/remotecompose/core/operations/layout/LayoutComponent.java index 6163d8099b8c..bc099e3a3b9d 100644 --- a/core/java/com/android/internal/widget/remotecompose/core/operations/layout/LayoutComponent.java +++ b/core/java/com/android/internal/widget/remotecompose/core/operations/layout/LayoutComponent.java @@ -289,11 +289,11 @@ public class LayoutComponent extends Component { } @Override - public void getLocationInWindow(@NonNull float[] value) { + public void getLocationInWindow(@NonNull float[] value, boolean forSelf) { value[0] += mX + mPaddingLeft; value[1] += mY + mPaddingTop; if (mParent != null) { - mParent.getLocationInWindow(value); + mParent.getLocationInWindow(value, false); } } diff --git a/core/java/com/android/internal/widget/remotecompose/core/operations/layout/managers/CollapsibleColumnLayout.java b/core/java/com/android/internal/widget/remotecompose/core/operations/layout/managers/CollapsibleColumnLayout.java index b0089525af5a..00ec60533087 100644 --- a/core/java/com/android/internal/widget/remotecompose/core/operations/layout/managers/CollapsibleColumnLayout.java +++ b/core/java/com/android/internal/widget/remotecompose/core/operations/layout/managers/CollapsibleColumnLayout.java @@ -24,10 +24,13 @@ import com.android.internal.widget.remotecompose.core.PaintContext; import com.android.internal.widget.remotecompose.core.RemoteContext; import com.android.internal.widget.remotecompose.core.WireBuffer; import com.android.internal.widget.remotecompose.core.operations.layout.Component; +import com.android.internal.widget.remotecompose.core.operations.layout.LayoutComponent; import com.android.internal.widget.remotecompose.core.operations.layout.measure.ComponentMeasure; import com.android.internal.widget.remotecompose.core.operations.layout.measure.MeasurePass; import com.android.internal.widget.remotecompose.core.operations.layout.measure.Size; +import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.CollapsiblePriorityModifierOperation; +import java.util.ArrayList; import java.util.List; public class CollapsibleColumnLayout extends ColumnLayout { @@ -153,7 +156,7 @@ public class CollapsibleColumnLayout extends ColumnLayout { } @Override - protected boolean hasVerticalIntrinsicDimension() { + public boolean hasVerticalIntrinsicDimension() { return true; } @@ -166,25 +169,72 @@ public class CollapsibleColumnLayout extends ColumnLayout { boolean verticalWrap, @NonNull MeasurePass measure, @NonNull Size size) { + computeVisibleChildren( + context, maxWidth, maxHeight, horizontalWrap, verticalWrap, measure, size); + } + + @Override + public void computeSize( + @NonNull PaintContext context, + float minWidth, + float maxWidth, + float minHeight, + float maxHeight, + @NonNull MeasurePass measure) { + computeVisibleChildren(context, maxWidth, maxHeight, false, false, measure, null); + } + + @Override + public void internalLayoutMeasure(@NonNull PaintContext context, @NonNull MeasurePass measure) { + // if needed, take care of weight calculations + super.internalLayoutMeasure(context, measure); + // Check again for visibility + ComponentMeasure m = measure.get(this); + computeVisibleChildren(context, m.getW(), m.getH(), false, false, measure, null); + } + + private void computeVisibleChildren( + @NonNull PaintContext context, + float maxWidth, + float maxHeight, + boolean horizontalWrap, + boolean verticalWrap, + @NonNull MeasurePass measure, + @Nullable Size size) { int visibleChildren = 0; ComponentMeasure self = measure.get(this); self.addVisibilityOverride(Visibility.OVERRIDE_VISIBLE); float currentMaxHeight = maxHeight; + boolean hasPriorities = false; for (Component c : mChildrenComponents) { - if (c instanceof CollapsibleColumnLayout) { - c.measure(context, 0f, maxWidth, 0f, currentMaxHeight, measure); - } else { - c.measure(context, 0f, maxWidth, 0f, Float.MAX_VALUE, measure); + if (!measure.contains(c.getComponentId())) { + // No need to remeasure here if already done + if (c instanceof CollapsibleColumnLayout) { + c.measure(context, 0f, maxWidth, 0f, currentMaxHeight, measure); + } else { + c.measure(context, 0f, maxWidth, 0f, Float.MAX_VALUE, measure); + } } + ComponentMeasure m = measure.get(c); if (!m.isGone()) { - size.setWidth(Math.max(size.getWidth(), m.getW())); - size.setHeight(size.getHeight() + m.getH()); + if (size != null) { + size.setWidth(Math.max(size.getWidth(), m.getW())); + size.setHeight(size.getHeight() + m.getH()); + } visibleChildren++; currentMaxHeight -= m.getH(); } + if (c instanceof LayoutComponent) { + LayoutComponent lc = (LayoutComponent) c; + CollapsiblePriorityModifierOperation priority = + lc.selfOrModifier(CollapsiblePriorityModifierOperation.class); + if (priority != null) { + hasPriorities = true; + } + } } - if (!mChildrenComponents.isEmpty()) { + if (!mChildrenComponents.isEmpty() && size != null) { size.setHeight(size.getHeight() + (mSpacedBy * (visibleChildren - 1))); } @@ -192,7 +242,14 @@ public class CollapsibleColumnLayout extends ColumnLayout { float childrenHeight = 0f; boolean overflow = false; - for (Component child : mChildrenComponents) { + ArrayList<Component> children = mChildrenComponents; + if (hasPriorities) { + // TODO: We need to cache this. + children = + CollapsiblePriority.sortWithPriorities( + mChildrenComponents, CollapsiblePriority.VERTICAL); + } + for (Component child : children) { ComponentMeasure childMeasure = measure.get(child); if (overflow || childMeasure.isGone()) { childMeasure.addVisibilityOverride(Visibility.OVERRIDE_GONE); @@ -209,10 +266,10 @@ public class CollapsibleColumnLayout extends ColumnLayout { visibleChildren++; } } - if (verticalWrap) { + if (verticalWrap && size != null) { size.setHeight(Math.min(maxHeight, childrenHeight)); } - if (visibleChildren == 0 || size.getHeight() <= 0f) { + if (visibleChildren == 0 || (size != null && size.getHeight() <= 0f)) { self.addVisibilityOverride(Visibility.OVERRIDE_GONE); } } diff --git a/core/java/com/android/internal/widget/remotecompose/core/operations/layout/managers/CollapsiblePriority.java b/core/java/com/android/internal/widget/remotecompose/core/operations/layout/managers/CollapsiblePriority.java new file mode 100644 index 000000000000..46cd45ecba8a --- /dev/null +++ b/core/java/com/android/internal/widget/remotecompose/core/operations/layout/managers/CollapsiblePriority.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2025 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.remotecompose.core.operations.layout.managers; + +import com.android.internal.widget.remotecompose.core.operations.layout.Component; +import com.android.internal.widget.remotecompose.core.operations.layout.LayoutComponent; +import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.CollapsiblePriorityModifierOperation; + +import java.util.ArrayList; + +/** Utility class to manage collapsible priorities on components */ +public class CollapsiblePriority { + + public static final int HORIZONTAL = 0; + public static final int VERTICAL = 1; + + /** + * Returns the priority of a child component + * + * @param c the child component + * @return priority value, or 0f if not found + */ + static float getPriority(Component c, int orientation) { + if (c instanceof LayoutComponent) { + LayoutComponent lc = (LayoutComponent) c; + CollapsiblePriorityModifierOperation priority = + lc.selfOrModifier(CollapsiblePriorityModifierOperation.class); + if (priority != null && priority.getOrientation() == orientation) { + return priority.getPriority(); + } + } + return Float.MAX_VALUE; + } + + /** + * Allocate and return a sorted array of components by their priorities + * + * @param components the children components + * @return list of components sorted by their priority in decreasing order + */ + static ArrayList<Component> sortWithPriorities( + ArrayList<Component> components, int orientation) { + ArrayList<Component> sorted = new ArrayList<>(components); + sorted.sort( + (t1, t2) -> { + float p1 = getPriority(t1, orientation); + float p2 = getPriority(t2, orientation); + return (int) (p2 - p1); + }); + return sorted; + } +} diff --git a/core/java/com/android/internal/widget/remotecompose/core/operations/layout/managers/CollapsibleRowLayout.java b/core/java/com/android/internal/widget/remotecompose/core/operations/layout/managers/CollapsibleRowLayout.java index 05f332960c16..e3632f9888ec 100644 --- a/core/java/com/android/internal/widget/remotecompose/core/operations/layout/managers/CollapsibleRowLayout.java +++ b/core/java/com/android/internal/widget/remotecompose/core/operations/layout/managers/CollapsibleRowLayout.java @@ -24,10 +24,13 @@ import com.android.internal.widget.remotecompose.core.PaintContext; import com.android.internal.widget.remotecompose.core.RemoteContext; import com.android.internal.widget.remotecompose.core.WireBuffer; import com.android.internal.widget.remotecompose.core.operations.layout.Component; +import com.android.internal.widget.remotecompose.core.operations.layout.LayoutComponent; import com.android.internal.widget.remotecompose.core.operations.layout.measure.ComponentMeasure; import com.android.internal.widget.remotecompose.core.operations.layout.measure.MeasurePass; import com.android.internal.widget.remotecompose.core.operations.layout.measure.Size; +import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.CollapsiblePriorityModifierOperation; +import java.util.ArrayList; import java.util.List; public class CollapsibleRowLayout extends RowLayout { @@ -135,8 +138,12 @@ public class CollapsibleRowLayout extends RowLayout { } @Override - protected boolean hasHorizontalIntrinsicDimension() { - return true; + public float minIntrinsicHeight(@NonNull RemoteContext context) { + float height = computeModifierDefinedHeight(context); + if (!mChildrenComponents.isEmpty()) { + height += mChildrenComponents.get(0).minIntrinsicHeight(context); + } + return height; } @Override @@ -149,12 +156,8 @@ public class CollapsibleRowLayout extends RowLayout { } @Override - public float minIntrinsicHeight(@NonNull RemoteContext context) { - float height = computeModifierDefinedHeight(context); - if (!mChildrenComponents.isEmpty()) { - height += mChildrenComponents.get(0).minIntrinsicHeight(context); - } - return height; + public boolean hasHorizontalIntrinsicDimension() { + return true; } @Override @@ -166,45 +169,107 @@ public class CollapsibleRowLayout extends RowLayout { boolean verticalWrap, @NonNull MeasurePass measure, @NonNull Size size) { - super.computeWrapSize( - context, Float.MAX_VALUE, maxHeight, horizontalWrap, verticalWrap, measure, size); + computeVisibleChildren( + context, maxWidth, maxHeight, horizontalWrap, verticalWrap, measure, size); } @Override - public boolean applyVisibility( - float selfWidth, float selfHeight, @NonNull MeasurePass measure) { - float childrenWidth = 0f; - float childrenHeight = 0f; - boolean changedVisibility = false; + public void computeSize( + @NonNull PaintContext context, + float minWidth, + float maxWidth, + float minHeight, + float maxHeight, + @NonNull MeasurePass measure) { + computeVisibleChildren(context, maxWidth, maxHeight, false, false, measure, null); + } + + @Override + public void internalLayoutMeasure(@NonNull PaintContext context, @NonNull MeasurePass measure) { + // if needed, take care of weight calculations + super.internalLayoutMeasure(context, measure); + // Check again for visibility + ComponentMeasure m = measure.get(this); + computeVisibleChildren(context, m.getW(), m.getH(), false, false, measure, null); + } + + private void computeVisibleChildren( + @NonNull PaintContext context, + float maxWidth, + float maxHeight, + boolean horizontalWrap, + boolean verticalWrap, + @NonNull MeasurePass measure, + @Nullable Size size) { int visibleChildren = 0; ComponentMeasure self = measure.get(this); - self.clearVisibilityOverride(); - if (selfWidth <= 0 || selfHeight <= 0) { - self.addVisibilityOverride(Visibility.OVERRIDE_GONE); - return true; + self.addVisibilityOverride(Visibility.OVERRIDE_VISIBLE); + float currentMaxWidth = maxWidth; + boolean hasPriorities = false; + for (Component c : mChildrenComponents) { + if (!measure.contains(c.getComponentId())) { + // No need to remeasure here if already done + if (c instanceof CollapsibleRowLayout) { + c.measure(context, 0f, currentMaxWidth, 0f, maxHeight, measure); + } else { + c.measure(context, 0f, Float.MAX_VALUE, 0f, maxHeight, measure); + } + } + ComponentMeasure m = measure.get(c); + if (!m.isGone()) { + if (size != null) { + size.setHeight(Math.max(size.getHeight(), m.getH())); + size.setWidth(size.getWidth() + m.getW()); + } + visibleChildren++; + currentMaxWidth -= m.getW(); + } + if (c instanceof LayoutComponent) { + LayoutComponent lc = (LayoutComponent) c; + CollapsiblePriorityModifierOperation priority = + lc.selfOrModifier(CollapsiblePriorityModifierOperation.class); + if (priority != null) { + hasPriorities = true; + } + } + } + if (!mChildrenComponents.isEmpty() && size != null) { + size.setWidth(size.getWidth() + (mSpacedBy * (visibleChildren - 1))); } - for (Component child : mChildrenComponents) { + + float childrenWidth = 0f; + float childrenHeight = 0f; + + boolean overflow = false; + ArrayList<Component> children = mChildrenComponents; + if (hasPriorities) { + // TODO: We need to cache this. + children = + CollapsiblePriority.sortWithPriorities( + mChildrenComponents, CollapsiblePriority.HORIZONTAL); + } + for (Component child : children) { ComponentMeasure childMeasure = measure.get(child); - int visibility = childMeasure.getVisibility(); - childMeasure.clearVisibilityOverride(); - if (!childMeasure.isVisible()) { + if (overflow || childMeasure.isGone()) { + childMeasure.addVisibilityOverride(Visibility.OVERRIDE_GONE); continue; } - if (childrenWidth + childMeasure.getW() > selfWidth - && childrenHeight + childMeasure.getH() > selfHeight) { + float childWidth = childMeasure.getW(); + boolean childDoesNotFits = childrenWidth + childWidth > maxWidth; + if (childDoesNotFits) { childMeasure.addVisibilityOverride(Visibility.OVERRIDE_GONE); - if (visibility != childMeasure.getVisibility()) { - changedVisibility = true; - } + overflow = true; } else { - childrenWidth += childMeasure.getW(); + childrenWidth += childWidth; childrenHeight = Math.max(childrenHeight, childMeasure.getH()); visibleChildren++; } } - if (visibleChildren == 0) { + if (horizontalWrap && size != null) { + size.setWidth(Math.min(maxWidth, childrenWidth)); + } + if (visibleChildren == 0 || (size != null && size.getWidth() <= 0f)) { self.addVisibilityOverride(Visibility.OVERRIDE_GONE); } - return changedVisibility; } } diff --git a/core/java/com/android/internal/widget/remotecompose/core/operations/layout/managers/ColumnLayout.java b/core/java/com/android/internal/widget/remotecompose/core/operations/layout/managers/ColumnLayout.java index cda90c2d3b0b..9566242ccbc5 100644 --- a/core/java/com/android/internal/widget/remotecompose/core/operations/layout/managers/ColumnLayout.java +++ b/core/java/com/android/internal/widget/remotecompose/core/operations/layout/managers/ColumnLayout.java @@ -33,6 +33,7 @@ import com.android.internal.widget.remotecompose.core.operations.layout.measure. import com.android.internal.widget.remotecompose.core.operations.layout.measure.MeasurePass; import com.android.internal.widget.remotecompose.core.operations.layout.measure.Size; import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.HeightInModifierOperation; +import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ScrollModifierOperation; import com.android.internal.widget.remotecompose.core.operations.layout.utils.DebugLog; import com.android.internal.widget.remotecompose.core.serialize.MapSerializer; @@ -372,6 +373,17 @@ public class ColumnLayout extends LayoutManager { DebugLog.e(); } + @Override + public void getLocationInWindow(@NonNull float[] value, boolean forSelf) { + super.getLocationInWindow(value, forSelf); + + if (!forSelf && mVerticalScrollDelegate instanceof ScrollModifierOperation) { + ScrollModifierOperation smo = (ScrollModifierOperation) mVerticalScrollDelegate; + + value[1] += smo.getScrollY(); + } + } + /** * The name of the class * diff --git a/core/java/com/android/internal/widget/remotecompose/core/operations/layout/managers/LayoutManager.java b/core/java/com/android/internal/widget/remotecompose/core/operations/layout/managers/LayoutManager.java index 5b66b95cf1dd..eb10ead34781 100644 --- a/core/java/com/android/internal/widget/remotecompose/core/operations/layout/managers/LayoutManager.java +++ b/core/java/com/android/internal/widget/remotecompose/core/operations/layout/managers/LayoutManager.java @@ -226,9 +226,17 @@ public abstract class LayoutManager extends LayoutComponent implements Measurabl measure, mCachedWrapSize); float w = mCachedWrapSize.getWidth(); - computeSize(context, 0f, w, 0, measuredHeight, measure); if (hasHorizontalScroll()) { + computeSize(context, 0f, w, 0, measuredHeight, measure); mComponentModifiers.setHorizontalScrollDimension(measuredWidth, w); + } else { + computeSize( + context, + 0f, + Math.min(measuredWidth, insetMaxWidth), + 0, + Math.min(measuredHeight, insetMaxHeight), + measure); } } else if (hasVerticalIntrinsicDimension()) { mCachedWrapSize.setWidth(0f); @@ -236,9 +244,17 @@ public abstract class LayoutManager extends LayoutComponent implements Measurabl computeWrapSize( context, maxWidth, Float.MAX_VALUE, false, false, measure, mCachedWrapSize); float h = mCachedWrapSize.getHeight(); - computeSize(context, 0f, measuredWidth, 0, h, measure); if (hasVerticalScroll()) { + computeSize(context, 0f, measuredWidth, 0, h, measure); mComponentModifiers.setVerticalScrollDimension(measuredHeight, h); + } else { + computeSize( + context, + 0f, + Math.min(measuredWidth, insetMaxWidth), + 0, + Math.min(measuredHeight, insetMaxHeight), + measure); } } else { float maxChildWidth = measuredWidth - mPaddingLeft - mPaddingRight; diff --git a/core/java/com/android/internal/widget/remotecompose/core/operations/layout/managers/RowLayout.java b/core/java/com/android/internal/widget/remotecompose/core/operations/layout/managers/RowLayout.java index d5d2e03c3f2a..15b54a3ce994 100644 --- a/core/java/com/android/internal/widget/remotecompose/core/operations/layout/managers/RowLayout.java +++ b/core/java/com/android/internal/widget/remotecompose/core/operations/layout/managers/RowLayout.java @@ -32,6 +32,7 @@ import com.android.internal.widget.remotecompose.core.operations.layout.LayoutCo import com.android.internal.widget.remotecompose.core.operations.layout.measure.ComponentMeasure; import com.android.internal.widget.remotecompose.core.operations.layout.measure.MeasurePass; import com.android.internal.widget.remotecompose.core.operations.layout.measure.Size; +import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ScrollModifierOperation; import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.WidthInModifierOperation; import com.android.internal.widget.remotecompose.core.operations.layout.utils.DebugLog; import com.android.internal.widget.remotecompose.core.serialize.MapSerializer; @@ -386,6 +387,17 @@ public class RowLayout extends LayoutManager { DebugLog.e(); } + @Override + public void getLocationInWindow(@NonNull float[] value, boolean forSelf) { + super.getLocationInWindow(value, forSelf); + + if (!forSelf && mHorizontalScrollDelegate instanceof ScrollModifierOperation) { + ScrollModifierOperation smo = (ScrollModifierOperation) mHorizontalScrollDelegate; + + value[0] += smo.getScrollX(); + } + } + /** * The name of the class * diff --git a/core/java/com/android/internal/widget/remotecompose/core/operations/layout/managers/TextLayout.java b/core/java/com/android/internal/widget/remotecompose/core/operations/layout/managers/TextLayout.java index d383ee9e4fc9..120c740eccda 100644 --- a/core/java/com/android/internal/widget/remotecompose/core/operations/layout/managers/TextLayout.java +++ b/core/java/com/android/internal/widget/remotecompose/core/operations/layout/managers/TextLayout.java @@ -77,6 +77,7 @@ public class TextLayout extends LayoutManager implements VariableSupport, Access private final Size mCachedSize = new Size(0f, 0f); @Nullable private String mCachedString = ""; + @Nullable private String mNewString; Platform.ComputedTextLayout mComputedTextLayout; @@ -99,7 +100,7 @@ public class TextLayout extends LayoutManager implements VariableSupport, Access if (cachedString != null && cachedString.equalsIgnoreCase(mCachedString)) { return; } - mCachedString = cachedString; + mNewString = cachedString; if (mType == -1) { if (mFontFamilyId != -1) { String fontFamily = context.getText(mFontFamilyId); @@ -119,8 +120,6 @@ public class TextLayout extends LayoutManager implements VariableSupport, Access mType = 0; } } - mTextW = -1; - mTextH = -1; if (mHorizontalScrollDelegate != null) { mHorizontalScrollDelegate.reset(); @@ -351,6 +350,9 @@ public class TextLayout extends LayoutManager implements VariableSupport, Access mPaint.setColor(mColor); context.replacePaint(mPaint); float[] bounds = new float[4]; + if (mNewString != null && !mNewString.equals(mCachedString)) { + mCachedString = mNewString; + } if (mCachedString == null) { return; } diff --git a/core/java/com/android/internal/widget/remotecompose/core/operations/layout/modifiers/CollapsiblePriorityModifierOperation.java b/core/java/com/android/internal/widget/remotecompose/core/operations/layout/modifiers/CollapsiblePriorityModifierOperation.java new file mode 100644 index 000000000000..b1f2d2d35b93 --- /dev/null +++ b/core/java/com/android/internal/widget/remotecompose/core/operations/layout/modifiers/CollapsiblePriorityModifierOperation.java @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2025 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.remotecompose.core.operations.layout.modifiers; + +import android.annotation.NonNull; + +import com.android.internal.widget.remotecompose.core.Operation; +import com.android.internal.widget.remotecompose.core.Operations; +import com.android.internal.widget.remotecompose.core.RemoteContext; +import com.android.internal.widget.remotecompose.core.WireBuffer; +import com.android.internal.widget.remotecompose.core.documentation.DocumentationBuilder; +import com.android.internal.widget.remotecompose.core.documentation.DocumentedOperation; +import com.android.internal.widget.remotecompose.core.operations.utilities.StringSerializer; +import com.android.internal.widget.remotecompose.core.serialize.MapSerializer; +import com.android.internal.widget.remotecompose.core.serialize.Serializable; +import com.android.internal.widget.remotecompose.core.serialize.SerializeTags; + +import java.util.List; + +/** Set an optional priority on a component within a collapsible layout */ +public class CollapsiblePriorityModifierOperation extends Operation + implements ModifierOperation, Serializable { + private static final int OP_CODE = Operations.MODIFIER_COLLAPSIBLE_PRIORITY; + public static final String CLASS_NAME = "CollapsiblePriorityModifierOperation"; + + private float mPriority; + private int mOrientation; + + public CollapsiblePriorityModifierOperation(int orientation, float priority) { + mOrientation = orientation; + mPriority = priority; + } + + public float getPriority() { + return mPriority; + } + + public int getOrientation() { + return mOrientation; + } + + @Override + public void write(@NonNull WireBuffer buffer) { + apply(buffer, mOrientation, mPriority); + } + + @Override + public void apply(@NonNull RemoteContext context) { + // nothing + } + + @NonNull + @Override + public String deepToString(@NonNull String indent) { + return ""; + } + + /** + * Read this operation and add it to the list of operations + * + * @param buffer the buffer to read + * @param operations the list of operations that will be added to + */ + public static void read(@NonNull WireBuffer buffer, @NonNull List<Operation> operations) { + int orientation = buffer.readInt(); + float priority = buffer.readFloat(); + operations.add(new CollapsiblePriorityModifierOperation(orientation, priority)); + } + + /** + * The OP_CODE for this command + * + * @return the opcode + */ + public static int id() { + return OP_CODE; + } + + /** + * The name of the class + * + * @return the name + */ + @NonNull + public static String name() { + return CLASS_NAME; + } + + /** + * Populate the documentation with a description of this operation + * + * @param doc to append the description to. + */ + public static void documentation(@NonNull DocumentationBuilder doc) { + doc.operation("Layout Operations", OP_CODE, "CollapsiblePriorityModifier") + .description("Add additional priority to children of Collapsible layouts") + .field(DocumentedOperation.INT, "orientation", "Horizontal(0) or Vertical (1)") + .field(DocumentedOperation.FLOAT, "priority", "The associated priority"); + } + + /** + * Writes out the CollapsiblePriorityModifier to the buffer + * + * @param buffer buffer to write to + * @param priority priority value + * @param orientation orientation (HORIZONTAL or VERTICAL) + */ + public static void apply(@NonNull WireBuffer buffer, int orientation, float priority) { + buffer.start(OP_CODE); + buffer.writeInt(orientation); + buffer.writeFloat(priority); + } + + @Override + public void serialize(MapSerializer serializer) { + serializer + .addTags(SerializeTags.MODIFIER) + .addType(name()) + .add("orientation", mOrientation) + .add("priority", mPriority); + } + + @Override + public void serializeToString(int indent, @NonNull StringSerializer serializer) { + serializer.append(indent, "PRIORITY = [" + getPriority() + "] (" + mOrientation + ")"); + } +} diff --git a/core/java/com/android/internal/widget/remotecompose/core/operations/layout/modifiers/ScrollModifierOperation.java b/core/java/com/android/internal/widget/remotecompose/core/operations/layout/modifiers/ScrollModifierOperation.java index 3e1f32de66e4..42692f95fcda 100644 --- a/core/java/com/android/internal/widget/remotecompose/core/operations/layout/modifiers/ScrollModifierOperation.java +++ b/core/java/com/android/internal/widget/remotecompose/core/operations/layout/modifiers/ScrollModifierOperation.java @@ -430,9 +430,35 @@ public class ScrollModifierOperation extends ListActionsOperation } @Override - public boolean showOnScreen(RemoteContext context, int childId) { - // TODO correct this when we trust the bounds in parent - return scrollByOffset(context, -1000) != 0; + public boolean scrollDirection(RemoteContext context, ScrollDirection direction) { + float offset = mHostDimension * 0.7f; + + if (direction == ScrollDirection.FORWARD + || direction == ScrollDirection.DOWN + || direction == ScrollDirection.RIGHT) { + offset *= -1; + } + + return scrollByOffset(context, (int) offset) != 0; + } + + @Override + public boolean showOnScreen(RemoteContext context, Component child) { + float[] locationInWindow = new float[2]; + child.getLocationInWindow(locationInWindow); + + int offset = 0; + if (handlesVerticalScroll()) { + offset = (int) -locationInWindow[1]; + } else { + offset = (int) -locationInWindow[0]; + } + + if (offset == 0) { + return true; + } else { + return scrollByOffset(context, offset) != 0; + } } @Nullable diff --git a/core/java/com/android/internal/widget/remotecompose/core/operations/utilities/StringUtils.java b/core/java/com/android/internal/widget/remotecompose/core/operations/utilities/StringUtils.java index a95a175d0edd..120c7ac9efbf 100644 --- a/core/java/com/android/internal/widget/remotecompose/core/operations/utilities/StringUtils.java +++ b/core/java/com/android/internal/widget/remotecompose/core/operations/utilities/StringUtils.java @@ -35,7 +35,10 @@ public class StringUtils { @NonNull public static String floatToString( float value, int beforeDecimalPoint, int afterDecimalPoint, char pre, char post) { - + boolean isNeg = value < 0; + if (isNeg) { + value = -value; + } int integerPart = (int) value; float fractionalPart = value % 1; @@ -54,14 +57,13 @@ public class StringUtils { integerPartString = integerPartString.substring(iLen - beforeDecimalPoint); } if (afterDecimalPoint == 0) { - return integerPartString; + return ((isNeg) ? "-" : "") + integerPartString; } // Convert fractional part to string and pad with zeros for (int i = 0; i < afterDecimalPoint; i++) { fractionalPart *= 10; } - fractionalPart = Math.round(fractionalPart); for (int i = 0; i < afterDecimalPoint; i++) { @@ -87,6 +89,6 @@ public class StringUtils { fact = fact + new String(c); } - return integerPartString + "." + fact; + return ((isNeg) ? "-" : "") + integerPartString + "." + fact; } } diff --git a/core/java/com/android/internal/widget/remotecompose/core/semantics/ScrollableComponent.java b/core/java/com/android/internal/widget/remotecompose/core/semantics/ScrollableComponent.java index 3d1bd12357c9..1610e6332c1c 100644 --- a/core/java/com/android/internal/widget/remotecompose/core/semantics/ScrollableComponent.java +++ b/core/java/com/android/internal/widget/remotecompose/core/semantics/ScrollableComponent.java @@ -18,6 +18,7 @@ package com.android.internal.widget.remotecompose.core.semantics; import android.annotation.Nullable; import com.android.internal.widget.remotecompose.core.RemoteContext; +import com.android.internal.widget.remotecompose.core.operations.layout.Component; /** * Interface for components that support scrolling. @@ -48,13 +49,23 @@ public interface ScrollableComponent extends AccessibilitySemantics { } /** + * Scrolls the content in the specified direction. + * + * @param direction the direction to scroll + * @return whether a scroll was possible + */ + default boolean scrollDirection(RemoteContext context, ScrollDirection direction) { + return false; + } + + /** * Show a child with the given ID on the screen, typically scrolling so it's fully on screen. * - * @param childId The ID of the child to check for visibility. + * @param child The child (including nested) to check for visibility. * @return {@code true} if the child with the given ID could be shown on screen; {@code false} * otherwise. */ - default boolean showOnScreen(RemoteContext context, int childId) { + default boolean showOnScreen(RemoteContext context, Component child) { return false; } @@ -108,4 +119,13 @@ public interface ScrollableComponent extends AccessibilitySemantics { return mCanScrollBackwards; } } + + enum ScrollDirection { + FORWARD, + BACKWARD, + UP, + DOWN, + LEFT, + RIGHT, + } } diff --git a/core/java/com/android/internal/widget/remotecompose/core/serialize/MapSerializer.java b/core/java/com/android/internal/widget/remotecompose/core/serialize/MapSerializer.java index 20e94ab5d898..32a0ccc01738 100644 --- a/core/java/com/android/internal/widget/remotecompose/core/serialize/MapSerializer.java +++ b/core/java/com/android/internal/widget/remotecompose/core/serialize/MapSerializer.java @@ -49,6 +49,14 @@ public interface MapSerializer { MapSerializer addIntExpressionSrc(String key, int[] value, int mask); /** + * Add a path + * + * @param key The key + * @param path The path + */ + MapSerializer addPath(String key, float[] path); + + /** * Add metadata to this map for filtering by the data format generator. * * @param value A set of tags to add diff --git a/core/java/com/android/internal/widget/remotecompose/player/platform/AndroidRemoteContext.java b/core/java/com/android/internal/widget/remotecompose/player/platform/AndroidRemoteContext.java index e1f2924021a4..575a6b2ee518 100644 --- a/core/java/com/android/internal/widget/remotecompose/player/platform/AndroidRemoteContext.java +++ b/core/java/com/android/internal/widget/remotecompose/player/platform/AndroidRemoteContext.java @@ -22,7 +22,6 @@ import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Paint; -import com.android.internal.annotations.VisibleForTesting; import com.android.internal.widget.remotecompose.core.RemoteContext; import com.android.internal.widget.remotecompose.core.TouchListener; import com.android.internal.widget.remotecompose.core.VariableSupport; @@ -43,7 +42,6 @@ import java.util.HashMap; * * <p>This is used to play the RemoteCompose operations on Android. */ -@VisibleForTesting public class AndroidRemoteContext extends RemoteContext { public void useCanvas(Canvas canvas) { diff --git a/core/java/com/android/internal/widget/remotecompose/player/platform/RemoteComposeCanvas.java b/core/java/com/android/internal/widget/remotecompose/player/platform/RemoteComposeCanvas.java index 0bc99abc17bc..17f4fc82af5f 100644 --- a/core/java/com/android/internal/widget/remotecompose/player/platform/RemoteComposeCanvas.java +++ b/core/java/com/android/internal/widget/remotecompose/player/platform/RemoteComposeCanvas.java @@ -102,6 +102,7 @@ public class RemoteComposeCanvas extends FrameLayout implements View.OnAttachSta mDocument = value; mDocument.initializeContext(mARContext); mDisable = false; + mARContext.setDocLoadTime(); mARContext.setAnimationEnabled(true); mARContext.setDensity(mDensity); mARContext.setUseChoreographer(true); diff --git a/core/jni/Android.bp b/core/jni/Android.bp index 748c5b48534f..bfa0aa9638a9 100644 --- a/core/jni/Android.bp +++ b/core/jni/Android.bp @@ -31,6 +31,7 @@ cc_library_shared_for_libandroid_runtime { name: "libandroid_runtime", host_supported: true, cflags: [ + "-Wno-cast-function-type-mismatch", "-Wno-unused-parameter", "-Wno-non-virtual-dtor", "-Wno-maybe-uninitialized", diff --git a/core/jni/android_os_Parcel.cpp b/core/jni/android_os_Parcel.cpp index b4c58b9b246a..e1b3479c7ed2 100644 --- a/core/jni/android_os_Parcel.cpp +++ b/core/jni/android_os_Parcel.cpp @@ -604,9 +604,7 @@ static jbyteArray android_os_Parcel_marshall(JNIEnv* env, jclass clazz, jlong na static long ensure_capacity(JNIEnv* env, Parcel* parcel, jint remaining) { long dataSize = parcel->dataSize(); if (remaining < dataSize) { - jniThrowExceptionFmt(env, "java/nio/BufferOverflowException", - "Destination buffer remaining capacity %d is less than the Parcel data size %d.", - remaining, dataSize); + jnihelp::ThrowException(env, "java/nio/BufferOverflowException", "()V"); return -1; } return dataSize; diff --git a/core/jni/android_window_ScreenCapture.cpp b/core/jni/android_window_ScreenCapture.cpp index 7b085b16d24b..ba74b0e8cce5 100644 --- a/core/jni/android_window_ScreenCapture.cpp +++ b/core/jni/android_window_ScreenCapture.cpp @@ -109,27 +109,29 @@ public: return binder::Status::ok(); } captureResults.fenceResult.value()->waitForever(LOG_TAG); - jobject jhardwareBuffer = android_hardware_HardwareBuffer_createFromAHardwareBuffer( - env, captureResults.buffer->toAHardwareBuffer()); - jobject jGainmap = nullptr; + auto jhardwareBuffer = ScopedLocalRef<jobject>( + env, android_hardware_HardwareBuffer_createFromAHardwareBuffer( + env, captureResults.buffer->toAHardwareBuffer())); + auto jGainmap = ScopedLocalRef<jobject>(env); if (captureResults.optionalGainMap) { - jGainmap = android_hardware_HardwareBuffer_createFromAHardwareBuffer( - env, captureResults.optionalGainMap->toAHardwareBuffer()); + jGainmap = ScopedLocalRef<jobject>( + env, android_hardware_HardwareBuffer_createFromAHardwareBuffer( + env, captureResults.optionalGainMap->toAHardwareBuffer())); } - jobject screenshotHardwareBuffer = - env->CallStaticObjectMethod(gScreenshotHardwareBufferClassInfo.clazz, + auto screenshotHardwareBuffer = + ScopedLocalRef<jobject>(env, env->CallStaticObjectMethod( + gScreenshotHardwareBufferClassInfo.clazz, gScreenshotHardwareBufferClassInfo.builder, - jhardwareBuffer, + jhardwareBuffer.get(), static_cast<jint>(captureResults.capturedDataspace), captureResults.capturedSecureLayers, - captureResults.capturedHdrLayers, jGainmap, - captureResults.hdrSdrRatio); + captureResults.capturedHdrLayers, jGainmap.get(), + captureResults.hdrSdrRatio)); checkAndClearException(env, "builder"); - env->CallVoidMethod(consumer.get(), gConsumerClassInfo.accept, screenshotHardwareBuffer, + env->CallVoidMethod(consumer.get(), gConsumerClassInfo.accept, + screenshotHardwareBuffer.get(), fenceStatus(captureResults.fenceResult)); checkAndClearException(env, "accept"); - env->DeleteLocalRef(jhardwareBuffer); - env->DeleteLocalRef(screenshotHardwareBuffer); return binder::Status::ok(); } diff --git a/core/res/res/values-watch/config.xml b/core/res/res/values-watch/config.xml index ef5875eff06f..57a09ea34ba1 100644 --- a/core/res/res/values-watch/config.xml +++ b/core/res/res/values-watch/config.xml @@ -114,4 +114,7 @@ <!-- By default ActivityOptions#makeScaleUpAnimation is only used between activities. This config enables OEMs to support its usage across tasks.--> <bool name="config_enableCrossTaskScaleUpAnimation">true</bool> + + <!-- The amount of friction applied to scrolls and flings. --> + <item name="config_scrollFriction" format="float" type="dimen">0.023</item> </resources> diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 43486f85f5d6..e47adc90fc7a 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -6112,6 +6112,9 @@ <!-- Whether to default to an expanded list of users on the lock screen user switcher. --> <bool name="config_expandLockScreenUserSwitcher">false</bool> + <!-- Help URI, action disabled by advanced protection [DO NOT TRANSLATE] --> + <string name="config_help_url_action_disabled_by_advanced_protection" translatable="false"></string> + <!-- Toasts posted from these packages will be shown to the current user, regardless of the user the process belongs to. This is useful for packages that run under a single user but serve multiple users, e.g. the system. diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index bab4a3d178cb..93fe4085e843 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -5964,6 +5964,8 @@ <!-- Device CMF Theming Settings --> <java-symbol type="array" name="theming_defaults" /> + <java-symbol type="string" name="config_help_url_action_disabled_by_advanced_protection" /> + <!-- Advanced Protection Service USB feature --> <java-symbol type="string" name="usb_apm_usb_plugged_in_when_locked_notification_title" /> <java-symbol type="string" name="usb_apm_usb_plugged_in_when_locked_notification_text" /> diff --git a/core/tests/coretests/src/android/app/PropertyInvalidatedCacheTests.java b/core/tests/coretests/src/android/app/PropertyInvalidatedCacheTests.java index f75a72d635dd..21ab8fc97802 100644 --- a/core/tests/coretests/src/android/app/PropertyInvalidatedCacheTests.java +++ b/core/tests/coretests/src/android/app/PropertyInvalidatedCacheTests.java @@ -41,7 +41,6 @@ import android.util.Log; import com.android.internal.os.ApplicationSharedMemory; import android.platform.test.annotations.DisabledOnRavenwood; -import android.platform.test.annotations.IgnoreUnderRavenwood; import android.platform.test.annotations.RequiresFlagsEnabled; import android.platform.test.flag.junit.CheckFlagsRule; import android.platform.test.flag.junit.DeviceFlagsValueProvider; diff --git a/core/tests/coretests/src/android/content/pm/SystemFeaturesCacheTest.java b/core/tests/coretests/src/android/content/pm/SystemFeaturesCacheTest.java index 8b513cb996b5..524e35535f03 100644 --- a/core/tests/coretests/src/android/content/pm/SystemFeaturesCacheTest.java +++ b/core/tests/coretests/src/android/content/pm/SystemFeaturesCacheTest.java @@ -136,9 +136,11 @@ public class SystemFeaturesCacheTest { SystemFeaturesCache cache = new SystemFeaturesCache(features); SystemFeaturesCache.clearInstance(); + assertThat(SystemFeaturesCache.hasInstance()).isFalse(); assertThrows(IllegalStateException.class, () -> SystemFeaturesCache.getInstance()); SystemFeaturesCache.setInstance(cache); + assertThat(SystemFeaturesCache.hasInstance()).isTrue(); assertThat(SystemFeaturesCache.getInstance()).isEqualTo(cache); assertThrows( @@ -149,6 +151,7 @@ public class SystemFeaturesCacheTest { @Test public void testSingletonAutomaticallySetWithFeatureEnabled() { assumeTrue(android.content.pm.Flags.cacheSdkSystemFeatures()); + assertThat(SystemFeaturesCache.hasInstance()).isTrue(); assertThat(SystemFeaturesCache.getInstance()).isNotNull(); } diff --git a/core/tests/coretests/src/android/os/AidlTest.java b/core/tests/coretests/src/android/os/AidlTest.java index 006828f12156..570f236905c2 100644 --- a/core/tests/coretests/src/android/os/AidlTest.java +++ b/core/tests/coretests/src/android/os/AidlTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.filters.SmallTest; @@ -35,7 +35,7 @@ import org.junit.Test; import java.util.List; -@IgnoreUnderRavenwood(blockedBy = Parcel.class) +@DisabledOnRavenwood(blockedBy = Parcel.class) public class AidlTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/android/os/BinderDeathRecipientTest.java b/core/tests/coretests/src/android/os/BinderDeathRecipientTest.java index 5ef14604e2ca..3125fdd73a47 100644 --- a/core/tests/coretests/src/android/os/BinderDeathRecipientTest.java +++ b/core/tests/coretests/src/android/os/BinderDeathRecipientTest.java @@ -25,7 +25,7 @@ import android.app.ActivityManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import android.util.ArraySet; import android.util.Log; @@ -55,7 +55,7 @@ import java.util.concurrent.atomic.AtomicReference; * Tests functionality of {@link android.os.IBinder.DeathRecipient} callbacks. */ @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = ActivityManager.class) +@DisabledOnRavenwood(blockedBy = ActivityManager.class) public class BinderDeathRecipientTest { private static final String TAG = BinderDeathRecipientTest.class.getSimpleName(); private static final String TEST_PACKAGE_NAME_1 = diff --git a/core/tests/coretests/src/android/os/BinderFrozenStateChangeNotificationTest.java b/core/tests/coretests/src/android/os/BinderFrozenStateChangeNotificationTest.java index 523fe1a8aa5d..0ebd2930a18d 100644 --- a/core/tests/coretests/src/android/os/BinderFrozenStateChangeNotificationTest.java +++ b/core/tests/coretests/src/android/os/BinderFrozenStateChangeNotificationTest.java @@ -27,7 +27,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import android.util.Log; @@ -55,7 +55,7 @@ import java.util.concurrent.atomic.AtomicReference; * Tests functionality of {@link android.os.IBinder.FrozenStateChangeCallback}. */ @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = ActivityManager.class) +@DisabledOnRavenwood(blockedBy = ActivityManager.class) public class BinderFrozenStateChangeNotificationTest { private static final String TAG = BinderFrozenStateChangeNotificationTest.class.getSimpleName(); diff --git a/core/tests/coretests/src/android/os/BinderProxyCountingTest.java b/core/tests/coretests/src/android/os/BinderProxyCountingTest.java index 4dfe2e28218e..31353e73a6c0 100644 --- a/core/tests/coretests/src/android/os/BinderProxyCountingTest.java +++ b/core/tests/coretests/src/android/os/BinderProxyCountingTest.java @@ -24,7 +24,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import android.util.Log; @@ -74,7 +74,7 @@ import java.util.function.Consumer; */ @LargeTest @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = ActivityManager.class) +@DisabledOnRavenwood(blockedBy = ActivityManager.class) public class BinderProxyCountingTest { private static final String TAG = BinderProxyCountingTest.class.getSimpleName(); diff --git a/core/tests/coretests/src/android/os/BinderProxyTest.java b/core/tests/coretests/src/android/os/BinderProxyTest.java index 5fff0b8d0849..656d3bfcfe93 100644 --- a/core/tests/coretests/src/android/os/BinderProxyTest.java +++ b/core/tests/coretests/src/android/os/BinderProxyTest.java @@ -27,7 +27,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.InstrumentationRegistry; @@ -43,7 +43,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = ActivityManager.class) +@DisabledOnRavenwood(blockedBy = ActivityManager.class) public class BinderProxyTest { private static class CountingListener implements Binder.ProxyTransactListener { int mStartedCount; diff --git a/core/tests/coretests/src/android/os/BinderThreadPriorityTest.java b/core/tests/coretests/src/android/os/BinderThreadPriorityTest.java index 9a679d8e8a96..343802888325 100644 --- a/core/tests/coretests/src/android/os/BinderThreadPriorityTest.java +++ b/core/tests/coretests/src/android/os/BinderThreadPriorityTest.java @@ -24,7 +24,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import android.util.Log; @@ -46,7 +46,7 @@ import java.io.IOException; * Test whether Binder calls inherit thread priorities correctly. */ @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = ActivityManager.class) +@DisabledOnRavenwood(blockedBy = ActivityManager.class) public class BinderThreadPriorityTest { private static final String TAG = "BinderThreadPriorityTest"; diff --git a/core/tests/coretests/src/android/os/BinderWorkSourceTest.java b/core/tests/coretests/src/android/os/BinderWorkSourceTest.java index 98e96c28d460..9b61cd2ff03d 100644 --- a/core/tests/coretests/src/android/os/BinderWorkSourceTest.java +++ b/core/tests/coretests/src/android/os/BinderWorkSourceTest.java @@ -24,7 +24,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.annotations.Presubmit; import android.platform.test.ravenwood.RavenwoodRule; @@ -45,7 +45,7 @@ import org.junit.runner.RunWith; @LargeTest @Presubmit @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = ActivityManager.class) +@DisabledOnRavenwood(blockedBy = ActivityManager.class) public class BinderWorkSourceTest { private static Context sContext; private static final int UID = 100; diff --git a/core/tests/coretests/src/android/os/CancellationSignalBeamerTest.java b/core/tests/coretests/src/android/os/CancellationSignalBeamerTest.java index 2117e7429a68..1e6fc15d6f20 100644 --- a/core/tests/coretests/src/android/os/CancellationSignalBeamerTest.java +++ b/core/tests/coretests/src/android/os/CancellationSignalBeamerTest.java @@ -22,7 +22,7 @@ import static com.google.common.truth.Truth.assertThat; import android.content.Context; import android.os.CancellationSignalBeamer.Receiver; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import android.util.PollingCheck; import android.util.PollingCheck.PollingCheckCondition; @@ -44,7 +44,7 @@ import java.util.concurrent.CountDownLatch; @RunWith(AndroidJUnit4.class) @SmallTest -@IgnoreUnderRavenwood(blockedBy = CancellationSignalBeamer.class) +@DisabledOnRavenwood(blockedBy = CancellationSignalBeamer.class) public class CancellationSignalBeamerTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/android/os/CancellationSignalTest.java b/core/tests/coretests/src/android/os/CancellationSignalTest.java index 8e11df5428f2..3b05cf7fbfa6 100644 --- a/core/tests/coretests/src/android/os/CancellationSignalTest.java +++ b/core/tests/coretests/src/android/os/CancellationSignalTest.java @@ -19,11 +19,8 @@ package android.os; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import android.platform.test.ravenwood.RavenwoodRule; - import androidx.test.ext.junit.runners.AndroidJUnit4; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,11 +29,6 @@ import java.util.concurrent.TimeUnit; @RunWith(AndroidJUnit4.class) public class CancellationSignalTest { - @Rule - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - @Test public void testSimple() throws Exception { final CancellationSignal signal = new CancellationSignal(); diff --git a/core/tests/coretests/src/android/os/EnvironmentTest.java b/core/tests/coretests/src/android/os/EnvironmentTest.java index 1b496243e48d..99ce175d0871 100644 --- a/core/tests/coretests/src/android/os/EnvironmentTest.java +++ b/core/tests/coretests/src/android/os/EnvironmentTest.java @@ -28,7 +28,7 @@ import static org.junit.Assert.assertEquals; import android.content.Context; import android.os.storage.StorageManager; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.InstrumentationRegistry; @@ -46,7 +46,7 @@ import java.util.UUID; import java.util.function.BiFunction; @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = Environment.class) +@DisabledOnRavenwood(blockedBy = Environment.class) public class EnvironmentTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/android/os/FileBridgeTest.java b/core/tests/coretests/src/android/os/FileBridgeTest.java index 726670b4d625..fa2a5f4d60a5 100644 --- a/core/tests/coretests/src/android/os/FileBridgeTest.java +++ b/core/tests/coretests/src/android/os/FileBridgeTest.java @@ -24,7 +24,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import android.os.FileBridge.FileBridgeOutputStream; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import android.test.MoreAsserts; @@ -46,7 +46,7 @@ import java.nio.charset.StandardCharsets; import java.util.Random; @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = ParcelFileDescriptor.class) +@DisabledOnRavenwood(blockedBy = ParcelFileDescriptor.class) public class FileBridgeTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/android/os/FileObserverTest.java b/core/tests/coretests/src/android/os/FileObserverTest.java index 3cd8045c32cb..6412023301b3 100644 --- a/core/tests/coretests/src/android/os/FileObserverTest.java +++ b/core/tests/coretests/src/android/os/FileObserverTest.java @@ -19,7 +19,7 @@ package android.os; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import android.util.Log; @@ -42,7 +42,7 @@ import java.util.List; import java.util.Map; @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = FileObserver.class) +@DisabledOnRavenwood(blockedBy = FileObserver.class) public class FileObserverTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/android/os/IpcDataCacheTest.java b/core/tests/coretests/src/android/os/IpcDataCacheTest.java index 791ec5d0cea3..2b49b38607d8 100644 --- a/core/tests/coretests/src/android/os/IpcDataCacheTest.java +++ b/core/tests/coretests/src/android/os/IpcDataCacheTest.java @@ -26,7 +26,7 @@ import static org.junit.Assert.fail; import android.app.PropertyInvalidatedCache; import android.app.PropertyInvalidatedCache.Args; import android.multiuser.Flags; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.annotations.RequiresFlagsEnabled; import android.platform.test.flag.junit.CheckFlagsRule; import android.platform.test.flag.junit.DeviceFlagsValueProvider; diff --git a/core/tests/coretests/src/android/os/MemoryFileTest.java b/core/tests/coretests/src/android/os/MemoryFileTest.java index a69542479afc..38ba6396d3b8 100644 --- a/core/tests/coretests/src/android/os/MemoryFileTest.java +++ b/core/tests/coretests/src/android/os/MemoryFileTest.java @@ -19,7 +19,7 @@ package android.os; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.ext.junit.runners.AndroidJUnit4; @@ -40,7 +40,7 @@ import java.util.Arrays; import java.util.List; @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = MemoryFile.class) +@DisabledOnRavenwood(blockedBy = MemoryFile.class) public class MemoryFileTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/android/os/MessengerTest.java b/core/tests/coretests/src/android/os/MessengerTest.java index eb6263fe8053..2014aa795828 100644 --- a/core/tests/coretests/src/android/os/MessengerTest.java +++ b/core/tests/coretests/src/android/os/MessengerTest.java @@ -21,7 +21,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.InstrumentationRegistry; @@ -35,7 +35,7 @@ import org.junit.Test; import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = ActivityManager.class) +@DisabledOnRavenwood(blockedBy = ActivityManager.class) public class MessengerTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/android/os/PerfettoTraceTest.java b/core/tests/coretests/src/android/os/PerfettoTraceTest.java index 790ac4a55dc6..b345315eb8eb 100644 --- a/core/tests/coretests/src/android/os/PerfettoTraceTest.java +++ b/core/tests/coretests/src/android/os/PerfettoTraceTest.java @@ -23,7 +23,7 @@ import static com.google.common.truth.Truth.assertThat; import static perfetto.protos.ChromeLatencyInfoOuterClass.ChromeLatencyInfo.LatencyComponentType.COMPONENT_INPUT_EVENT_LATENCY_BEGIN_RWH; import static perfetto.protos.ChromeLatencyInfoOuterClass.ChromeLatencyInfo.LatencyComponentType.COMPONENT_INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.annotations.RequiresFlagsEnabled; import android.platform.test.flag.junit.CheckFlagsRule; import android.platform.test.flag.junit.DeviceFlagsValueProvider; @@ -68,7 +68,7 @@ import java.util.concurrent.TimeUnit; * while tracing on the emulator and then run traceview to view the trace. */ @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = PerfettoTrace.class) +@DisabledOnRavenwood(blockedBy = PerfettoTrace.class) public class PerfettoTraceTest { @Rule public final CheckFlagsRule mCheckFlagsRule = diff --git a/core/tests/coretests/src/android/os/PerformanceCollectorTest.java b/core/tests/coretests/src/android/os/PerformanceCollectorTest.java index 436720ee1338..c2566804c1f0 100644 --- a/core/tests/coretests/src/android/os/PerformanceCollectorTest.java +++ b/core/tests/coretests/src/android/os/PerformanceCollectorTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import android.os.PerformanceCollector.PerformanceResultsWriter; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.ext.junit.runners.AndroidJUnit4; @@ -40,7 +40,7 @@ import java.util.ArrayList; import java.util.Random; @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = PerformanceCollector.class) +@DisabledOnRavenwood(blockedBy = PerformanceCollector.class) public class PerformanceCollectorTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/android/os/PerformanceHintManagerTest.java b/core/tests/coretests/src/android/os/PerformanceHintManagerTest.java index 4b49fde5e61a..b7c25f2246d9 100644 --- a/core/tests/coretests/src/android/os/PerformanceHintManagerTest.java +++ b/core/tests/coretests/src/android/os/PerformanceHintManagerTest.java @@ -24,7 +24,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeNotNull; import android.os.PerformanceHintManager.Session; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.InstrumentationRegistry; @@ -38,7 +38,7 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = PerformanceHintManager.class) +@DisabledOnRavenwood(blockedBy = PerformanceHintManager.class) public class PerformanceHintManagerTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/android/os/ProcessTest.java b/core/tests/coretests/src/android/os/ProcessTest.java index ea39db7b0057..3d50cfe2fdfb 100644 --- a/core/tests/coretests/src/android/os/ProcessTest.java +++ b/core/tests/coretests/src/android/os/ProcessTest.java @@ -21,7 +21,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import org.junit.Rule; @@ -29,7 +29,7 @@ import org.junit.Test; import java.util.Arrays; -@IgnoreUnderRavenwood(blockedBy = Process.class) +@DisabledOnRavenwood(blockedBy = Process.class) public class ProcessTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/android/os/RedactingFileDescriptorTest.java b/core/tests/coretests/src/android/os/RedactingFileDescriptorTest.java index e22c862764cd..a6160bb5b285 100644 --- a/core/tests/coretests/src/android/os/RedactingFileDescriptorTest.java +++ b/core/tests/coretests/src/android/os/RedactingFileDescriptorTest.java @@ -24,7 +24,7 @@ import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import android.content.Context; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import android.system.Os; @@ -44,7 +44,7 @@ import java.io.FileOutputStream; import java.util.Arrays; @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = RedactingFileDescriptor.class) +@DisabledOnRavenwood(blockedBy = RedactingFileDescriptor.class) public class RedactingFileDescriptorTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/android/os/RemoteCallbackTest.java b/core/tests/coretests/src/android/os/RemoteCallbackTest.java index ddcc380230a9..cbbaa75466be 100644 --- a/core/tests/coretests/src/android/os/RemoteCallbackTest.java +++ b/core/tests/coretests/src/android/os/RemoteCallbackTest.java @@ -19,11 +19,8 @@ package android.os; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import android.platform.test.ravenwood.RavenwoodRule; - import androidx.test.ext.junit.runners.AndroidJUnit4; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,11 +29,6 @@ import java.util.concurrent.TimeUnit; @RunWith(AndroidJUnit4.class) public class RemoteCallbackTest { - @Rule - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - @Test public void testSimple() throws Exception { final CountDownLatch latch = new CountDownLatch(1); diff --git a/core/tests/coretests/src/android/os/ResultReceiverTest.java b/core/tests/coretests/src/android/os/ResultReceiverTest.java index be67825ae4d2..21d40781ea52 100644 --- a/core/tests/coretests/src/android/os/ResultReceiverTest.java +++ b/core/tests/coretests/src/android/os/ResultReceiverTest.java @@ -19,11 +19,8 @@ package android.os; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import android.platform.test.ravenwood.RavenwoodRule; - import androidx.test.ext.junit.runners.AndroidJUnit4; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,11 +29,6 @@ import java.util.concurrent.TimeUnit; @RunWith(AndroidJUnit4.class) public class ResultReceiverTest { - @Rule - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - @Test public void testSimple() throws Exception { final CountDownLatch latch = new CountDownLatch(1); diff --git a/core/tests/coretests/src/android/os/TraceTest.java b/core/tests/coretests/src/android/os/TraceTest.java index 5462f3257189..4117dd68d794 100644 --- a/core/tests/coretests/src/android/os/TraceTest.java +++ b/core/tests/coretests/src/android/os/TraceTest.java @@ -16,7 +16,7 @@ package android.os; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import android.util.Log; @@ -105,7 +105,7 @@ public class TraceTest { @Test @SmallTest - @IgnoreUnderRavenwood(blockedBy = Debug.class) + @DisabledOnRavenwood(blockedBy = Debug.class) public void testNativeTracingFromJava() { long start = System.currentTimeMillis(); @@ -126,7 +126,7 @@ public class TraceTest { // This should not run in the automated suite. @Suppress - @IgnoreUnderRavenwood(blockedBy = Debug.class) + @DisabledOnRavenwood(blockedBy = Debug.class) public void disableTestNativeTracingFromC() { long start = System.currentTimeMillis(); @@ -142,7 +142,7 @@ public class TraceTest { @Test @LargeTest @Suppress // Failing. - @IgnoreUnderRavenwood(blockedBy = Debug.class) + @DisabledOnRavenwood(blockedBy = Debug.class) public void testMethodTracing() { long start = System.currentTimeMillis(); diff --git a/core/tests/coretests/src/android/os/VintfObjectTest.java b/core/tests/coretests/src/android/os/VintfObjectTest.java index f81b31d0bd5a..1b7bb4107bcf 100644 --- a/core/tests/coretests/src/android/os/VintfObjectTest.java +++ b/core/tests/coretests/src/android/os/VintfObjectTest.java @@ -20,7 +20,7 @@ import static com.google.common.truth.Truth.assertThat; import static java.util.stream.Collectors.toList; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import android.util.Pair; @@ -37,7 +37,7 @@ import java.util.stream.Stream; import javax.xml.parsers.DocumentBuilderFactory; @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = VintfObject.class) +@DisabledOnRavenwood(blockedBy = VintfObject.class) public class VintfObjectTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/android/os/WorkSourceParcelTest.java b/core/tests/coretests/src/android/os/WorkSourceParcelTest.java index 5f49186df0f5..0ebf128cafef 100644 --- a/core/tests/coretests/src/android/os/WorkSourceParcelTest.java +++ b/core/tests/coretests/src/android/os/WorkSourceParcelTest.java @@ -18,7 +18,7 @@ package android.os; import static org.junit.Assert.assertEquals; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.ext.junit.runners.AndroidJUnit4; @@ -30,7 +30,7 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @SmallTest -@IgnoreUnderRavenwood(reason = "JNI") +@DisabledOnRavenwood(reason = "JNI") public class WorkSourceParcelTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); @@ -49,7 +49,7 @@ public class WorkSourceParcelTest { String[] names, int parcelEndMarker); static { - if (!RavenwoodRule.isUnderRavenwood()) { + if (!RavenwoodRule.isOnRavenwood()) { System.loadLibrary("worksourceparceltest_jni"); } } diff --git a/core/tests/coretests/src/android/util/ArrayMapTest.java b/core/tests/coretests/src/android/util/ArrayMapTest.java index c7efe6f93f0d..d71a60323311 100644 --- a/core/tests/coretests/src/android/util/ArrayMapTest.java +++ b/core/tests/coretests/src/android/util/ArrayMapTest.java @@ -18,7 +18,7 @@ import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.fail; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.annotations.Presubmit; import android.platform.test.ravenwood.RavenwoodRule; @@ -57,7 +57,7 @@ public class ArrayMapTest { */ @Test @Ignore("Failing; b/399137661") - @IgnoreUnderRavenwood(reason = "Long test runtime") + @DisabledOnRavenwood(reason = "Long test runtime") public void testConcurrentModificationException() throws Exception { final int TEST_LEN_MS = 5000; System.out.println("Starting ArrayMap concurrency test"); diff --git a/core/tests/coretests/src/android/util/CharsetUtilsTest.java b/core/tests/coretests/src/android/util/CharsetUtilsTest.java index 33936e9147bc..cf6e1ebf1bdc 100644 --- a/core/tests/coretests/src/android/util/CharsetUtilsTest.java +++ b/core/tests/coretests/src/android/util/CharsetUtilsTest.java @@ -18,7 +18,7 @@ package android.util; import static org.junit.Assert.assertEquals; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.ext.junit.runners.AndroidJUnit4; @@ -33,7 +33,7 @@ import org.junit.Test; import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = CharsetUtils.class) +@DisabledOnRavenwood(blockedBy = CharsetUtils.class) public class CharsetUtilsTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); @@ -43,7 +43,7 @@ public class CharsetUtilsTest { @Before public void setUp() { - if (!RavenwoodRule.isUnderRavenwood()) { + if (!RavenwoodRule.isOnRavenwood()) { dest = (byte[]) VMRuntime.getRuntime().newNonMovableArray(byte.class, 8); destPtr = VMRuntime.getRuntime().addressOf(dest); } diff --git a/core/tests/coretests/src/android/util/CloseGuardTest.java b/core/tests/coretests/src/android/util/CloseGuardTest.java index 15c57b1aa6f7..c91ef1c751c4 100644 --- a/core/tests/coretests/src/android/util/CloseGuardTest.java +++ b/core/tests/coretests/src/android/util/CloseGuardTest.java @@ -16,7 +16,7 @@ package android.util; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import libcore.dalvik.system.CloseGuardSupport; @@ -26,7 +26,7 @@ import org.junit.Test; import org.junit.rules.TestRule; /** Unit tests for {@link android.util.CloseGuard} */ -@IgnoreUnderRavenwood(blockedBy = CloseGuard.class) +@DisabledOnRavenwood(blockedBy = CloseGuard.class) public class CloseGuardTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); @@ -35,7 +35,7 @@ public class CloseGuardTest { public final TestRule rule; public CloseGuardTest() { - if (!RavenwoodRule.isUnderRavenwood()) { + if (!RavenwoodRule.isOnRavenwood()) { rule = CloseGuardSupport.getRule(); } else { rule = null; diff --git a/core/tests/coretests/src/android/util/HashedStringCacheTest.java b/core/tests/coretests/src/android/util/HashedStringCacheTest.java index 08c85ac5c0d6..c26855bc63a1 100644 --- a/core/tests/coretests/src/android/util/HashedStringCacheTest.java +++ b/core/tests/coretests/src/android/util/HashedStringCacheTest.java @@ -26,7 +26,7 @@ import android.content.Context; import android.content.SharedPreferences; import android.os.Environment; import android.os.storage.StorageManager; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.InstrumentationRegistry; @@ -40,7 +40,7 @@ import java.io.File; /** * Unit tests for {@link HashedStringCache}. */ -@IgnoreUnderRavenwood(blockedBy = HashedStringCache.class) +@DisabledOnRavenwood(blockedBy = HashedStringCache.class) public class HashedStringCacheTest { private static final String TAG = "HashedStringCacheTest"; private Context mContext; @@ -51,7 +51,7 @@ public class HashedStringCacheTest { @Before public void setup() { - if (!RavenwoodRule.isUnderRavenwood()) { + if (!RavenwoodRule.isOnRavenwood()) { mContext = InstrumentationRegistry.getContext(); clearSharedPreferences(); } else { diff --git a/core/tests/coretests/src/android/util/LogNullabilityTest.java b/core/tests/coretests/src/android/util/LogNullabilityTest.java index 5aa2626b6de7..795444d55432 100644 --- a/core/tests/coretests/src/android/util/LogNullabilityTest.java +++ b/core/tests/coretests/src/android/util/LogNullabilityTest.java @@ -37,7 +37,7 @@ public final class LogNullabilityTest { Log.i(null, ""); Log.w(null, ""); Log.e(null, ""); - if (!RavenwoodRule.isUnderRavenwood()) { + if (!RavenwoodRule.isOnRavenwood()) { Log.wtf(null, ""); Log.wtfStack(null, ""); } @@ -53,7 +53,7 @@ public final class LogNullabilityTest { Log.i(null, "", new Throwable()); Log.w(null, "", new Throwable()); Log.e(null, "", new Throwable()); - if (!RavenwoodRule.isUnderRavenwood()) { + if (!RavenwoodRule.isOnRavenwood()) { Log.wtf(null, "", new Throwable()); } Log.printlns(Log.LOG_ID_MAIN, Log.INFO, null, "", new Throwable()); @@ -90,7 +90,7 @@ public final class LogNullabilityTest { } catch (NullPointerException expected) { } - if (!RavenwoodRule.isUnderRavenwood()) { + if (!RavenwoodRule.isOnRavenwood()) { Log.wtf("", (String) null); Log.wtfStack("", (String) null); } @@ -111,7 +111,7 @@ public final class LogNullabilityTest { Log.i("", null, new Throwable()); Log.w("", null, new Throwable()); Log.e("", null, new Throwable()); - if (!RavenwoodRule.isUnderRavenwood()) { + if (!RavenwoodRule.isOnRavenwood()) { Log.wtf("", null, new Throwable()); } Log.printlns(Log.LOG_ID_MAIN, Log.INFO, "", null, new Throwable()); @@ -124,7 +124,7 @@ public final class LogNullabilityTest { Log.i("", "", null); Log.w("", "", null); Log.e("", "", null); - if (!RavenwoodRule.isUnderRavenwood()) { + if (!RavenwoodRule.isOnRavenwood()) { Log.wtf("", "", null); } @@ -136,7 +136,7 @@ public final class LogNullabilityTest { // Implicit assertions of not crashing. // WTF has its own (String, Throwable) overload with different behavior. - if (!RavenwoodRule.isUnderRavenwood()) { + if (!RavenwoodRule.isOnRavenwood()) { try { Log.wtf("", (Throwable) null); fail(); @@ -152,7 +152,7 @@ public final class LogNullabilityTest { Log.i("", null, null); Log.w("", null, null); Log.e("", null, null); - if (!RavenwoodRule.isUnderRavenwood()) { + if (!RavenwoodRule.isOnRavenwood()) { Log.wtf("", null, null); } Log.printlns(Log.LOG_ID_MAIN, Log.INFO, "", null, null); diff --git a/core/tests/coretests/src/android/util/NtpTrustedTimeTest.java b/core/tests/coretests/src/android/util/NtpTrustedTimeTest.java index ce1eabc741a3..32fb3a27459c 100644 --- a/core/tests/coretests/src/android/util/NtpTrustedTimeTest.java +++ b/core/tests/coretests/src/android/util/NtpTrustedTimeTest.java @@ -31,7 +31,7 @@ import static java.lang.String.join; import static java.util.Arrays.asList; import android.net.Network; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.ext.junit.runners.AndroidJUnit4; @@ -56,7 +56,7 @@ import java.util.stream.Stream; @SmallTest @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = NtpTrustedTime.class) +@DisabledOnRavenwood(blockedBy = NtpTrustedTime.class) public class NtpTrustedTimeTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/android/util/apk/SourceStampVerifierTest.java b/core/tests/coretests/src/android/util/apk/SourceStampVerifierTest.java index 48e76f79a928..56d6594a488a 100644 --- a/core/tests/coretests/src/android/util/apk/SourceStampVerifierTest.java +++ b/core/tests/coretests/src/android/util/apk/SourceStampVerifierTest.java @@ -26,7 +26,7 @@ import static org.junit.Assert.assertTrue; import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; import android.content.Context; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.core.app.ApplicationProvider; @@ -52,7 +52,7 @@ import java.util.zip.ZipFile; /** Unit test for {@link android.util.apk.SourceStampVerifier} */ @RunWith(JUnit4.class) -@IgnoreUnderRavenwood(blockedBy = SourceStampVerifier.class) +@DisabledOnRavenwood(blockedBy = SourceStampVerifier.class) public class SourceStampVerifierTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/android/view/InsetsControllerTest.java b/core/tests/coretests/src/android/view/InsetsControllerTest.java index af87af0d243f..79d8bb169a1f 100644 --- a/core/tests/coretests/src/android/view/InsetsControllerTest.java +++ b/core/tests/coretests/src/android/view/InsetsControllerTest.java @@ -1208,8 +1208,9 @@ public class InsetsControllerTest { }); InstrumentationRegistry.getInstrumentation().waitForIdleSync(); - verify(mTestHost, times(1)).updateAnimatingTypes(eq(types)); - verify(mTestHost, times(1)).updateAnimatingTypes(eq(0) /* animatingTypes */); + verify(mTestHost, times(1)).updateAnimatingTypes(eq(types), any() /* statsToken */); + verify(mTestHost, times(1)).updateAnimatingTypes(eq(0) /* animatingTypes */, + any() /* statsToken */); } private void waitUntilNextFrame() throws Exception { diff --git a/core/tests/coretests/src/android/view/ViewRootImplTest.java b/core/tests/coretests/src/android/view/ViewRootImplTest.java index 39f3d3319ad3..5774109e1451 100644 --- a/core/tests/coretests/src/android/view/ViewRootImplTest.java +++ b/core/tests/coretests/src/android/view/ViewRootImplTest.java @@ -1063,7 +1063,7 @@ public class ViewRootImplTest { ViewRootImpl viewRootImpl = mView.getViewRootImpl(); sInstrumentation.runOnMainSync(() -> { mView.invalidate(); - viewRootImpl.updateAnimatingTypes(Type.systemBars()); + viewRootImpl.updateAnimatingTypes(Type.systemBars(), null /* statsToken */); mView.invalidate(); }); sInstrumentation.waitForIdleSync(); diff --git a/core/tests/coretests/src/com/android/internal/os/BackgroundThreadTest.java b/core/tests/coretests/src/com/android/internal/os/BackgroundThreadTest.java index 8bdf4c6192ba..402ba0d9f05e 100644 --- a/core/tests/coretests/src/com/android/internal/os/BackgroundThreadTest.java +++ b/core/tests/coretests/src/com/android/internal/os/BackgroundThreadTest.java @@ -21,19 +21,13 @@ import static com.google.common.truth.Truth.assertThat; import android.os.ConditionVariable; import android.os.Handler; import android.os.Looper; -import android.platform.test.ravenwood.RavenwoodRule; -import org.junit.Rule; import org.junit.Test; import java.util.concurrent.Executor; public class BackgroundThreadTest { - @Rule - public final RavenwoodRule mRavenwood = - new RavenwoodRule.Builder().setProvideMainThread(true).build(); - @Test public void test_get() { BackgroundThread thread = BackgroundThread.get(); diff --git a/core/tests/coretests/src/com/android/internal/os/BinderCallsStatsTest.java b/core/tests/coretests/src/com/android/internal/os/BinderCallsStatsTest.java index 5f8ab283c789..f44aa050619a 100644 --- a/core/tests/coretests/src/com/android/internal/os/BinderCallsStatsTest.java +++ b/core/tests/coretests/src/com/android/internal/os/BinderCallsStatsTest.java @@ -29,7 +29,7 @@ import android.os.Looper; import android.os.Message; import android.os.Process; import android.os.SystemClock; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.annotations.Presubmit; import android.platform.test.ravenwood.RavenwoodRule; import android.util.ArrayMap; @@ -59,7 +59,7 @@ import java.util.Set; @SmallTest @RunWith(AndroidJUnit4.class) @Presubmit -@IgnoreUnderRavenwood(blockedBy = BinderCallsStats.class) +@DisabledOnRavenwood(blockedBy = BinderCallsStats.class) public class BinderCallsStatsTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/com/android/internal/os/BinderLatencyObserverTest.java b/core/tests/coretests/src/com/android/internal/os/BinderLatencyObserverTest.java index 3355cc34ee1c..5c2bf3873679 100644 --- a/core/tests/coretests/src/com/android/internal/os/BinderLatencyObserverTest.java +++ b/core/tests/coretests/src/com/android/internal/os/BinderLatencyObserverTest.java @@ -23,7 +23,7 @@ import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertEquals; import android.os.Binder; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.annotations.Presubmit; import android.platform.test.ravenwood.RavenwoodRule; import android.util.ArrayMap; @@ -50,7 +50,7 @@ import java.util.Random; @SmallTest @RunWith(AndroidJUnit4.class) @Presubmit -@IgnoreUnderRavenwood(blockedBy = BinderLatencyObserver.class) +@DisabledOnRavenwood(blockedBy = BinderLatencyObserver.class) public class BinderLatencyObserverTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/com/android/internal/os/DebugTest.java b/core/tests/coretests/src/com/android/internal/os/DebugTest.java index 4371f2699d4f..e6a0e4a01919 100644 --- a/core/tests/coretests/src/com/android/internal/os/DebugTest.java +++ b/core/tests/coretests/src/com/android/internal/os/DebugTest.java @@ -19,7 +19,7 @@ package com.android.internal.os; import static org.junit.Assert.assertTrue; import android.os.Debug; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.filters.SmallTest; @@ -28,7 +28,7 @@ import org.junit.Rule; import org.junit.Test; @SmallTest -@IgnoreUnderRavenwood(reason = "Requires ART support") +@DisabledOnRavenwood(reason = "Requires ART support") public class DebugTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/com/android/internal/os/KernelCpuProcStringReaderTest.java b/core/tests/coretests/src/com/android/internal/os/KernelCpuProcStringReaderTest.java index 8fd87c01f584..a625317e4424 100644 --- a/core/tests/coretests/src/com/android/internal/os/KernelCpuProcStringReaderTest.java +++ b/core/tests/coretests/src/com/android/internal/os/KernelCpuProcStringReaderTest.java @@ -24,7 +24,7 @@ import static org.junit.Assert.assertTrue; import android.content.Context; import android.os.FileUtils; import android.os.SystemClock; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.InstrumentationRegistry; @@ -60,7 +60,7 @@ import java.util.stream.IntStream; */ @SmallTest @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(reason = "Needs kernel support") +@DisabledOnRavenwood(reason = "Needs kernel support") public class KernelCpuProcStringReaderTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/com/android/internal/os/KernelCpuThreadReaderDiffTest.java b/core/tests/coretests/src/com/android/internal/os/KernelCpuThreadReaderDiffTest.java index 78cf65cd466d..06d75211ddf2 100644 --- a/core/tests/coretests/src/com/android/internal/os/KernelCpuThreadReaderDiffTest.java +++ b/core/tests/coretests/src/com/android/internal/os/KernelCpuThreadReaderDiffTest.java @@ -24,7 +24,7 @@ import static org.testng.Assert.assertThrows; import static java.util.stream.Collectors.toList; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.annotations.Presubmit; import android.platform.test.ravenwood.RavenwoodRule; @@ -47,7 +47,7 @@ import java.util.Collections; @Presubmit @SmallTest @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(reason = "Needs kernel support") +@DisabledOnRavenwood(reason = "Needs kernel support") public class KernelCpuThreadReaderDiffTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/com/android/internal/os/KernelCpuThreadReaderEndToEndTest.java b/core/tests/coretests/src/com/android/internal/os/KernelCpuThreadReaderEndToEndTest.java index 8c5e3d0e0724..bb7a81a81d28 100644 --- a/core/tests/coretests/src/com/android/internal/os/KernelCpuThreadReaderEndToEndTest.java +++ b/core/tests/coretests/src/com/android/internal/os/KernelCpuThreadReaderEndToEndTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertTrue; import android.os.Process; import android.os.SystemClock; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.ext.junit.runners.AndroidJUnit4; @@ -50,7 +50,7 @@ import java.util.stream.Collectors; */ @RunWith(AndroidJUnit4.class) @LargeTest -@IgnoreUnderRavenwood(reason = "Needs kernel support") +@DisabledOnRavenwood(reason = "Needs kernel support") public class KernelCpuThreadReaderEndToEndTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/com/android/internal/os/KernelCpuThreadReaderTest.java b/core/tests/coretests/src/com/android/internal/os/KernelCpuThreadReaderTest.java index c3d4b839b15e..74dd99987d2e 100644 --- a/core/tests/coretests/src/com/android/internal/os/KernelCpuThreadReaderTest.java +++ b/core/tests/coretests/src/com/android/internal/os/KernelCpuThreadReaderTest.java @@ -25,7 +25,7 @@ import static org.testng.Assert.assertThrows; import android.content.Context; import android.os.FileUtils; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.annotations.Presubmit; import android.platform.test.ravenwood.RavenwoodRule; @@ -51,7 +51,7 @@ import java.util.function.Predicate; @Presubmit @SmallTest @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(reason = "Needs kernel support") +@DisabledOnRavenwood(reason = "Needs kernel support") public class KernelCpuThreadReaderTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/com/android/internal/os/KernelCpuUidActiveTimeReaderTest.java b/core/tests/coretests/src/com/android/internal/os/KernelCpuUidActiveTimeReaderTest.java index d35e0fc95aa1..fc090caccae8 100644 --- a/core/tests/coretests/src/com/android/internal/os/KernelCpuUidActiveTimeReaderTest.java +++ b/core/tests/coretests/src/com/android/internal/os/KernelCpuUidActiveTimeReaderTest.java @@ -21,7 +21,7 @@ import static org.junit.Assert.assertTrue; import android.content.Context; import android.os.FileUtils; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import android.util.SparseArray; import android.util.SparseLongArray; @@ -54,7 +54,7 @@ import java.util.Random; */ @SmallTest @RunWith(Parameterized.class) -@IgnoreUnderRavenwood(reason = "Needs kernel support") +@DisabledOnRavenwood(reason = "Needs kernel support") public class KernelCpuUidActiveTimeReaderTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/com/android/internal/os/KernelCpuUidBpfMapReaderTest.java b/core/tests/coretests/src/com/android/internal/os/KernelCpuUidBpfMapReaderTest.java index b75ad7f169cd..5a01175ffedc 100644 --- a/core/tests/coretests/src/com/android/internal/os/KernelCpuUidBpfMapReaderTest.java +++ b/core/tests/coretests/src/com/android/internal/os/KernelCpuUidBpfMapReaderTest.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import android.content.Context; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import android.util.SparseArray; @@ -52,7 +52,7 @@ import java.util.concurrent.TimeUnit; @SmallTest @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(reason = "Needs kernel support") +@DisabledOnRavenwood(reason = "Needs kernel support") public class KernelCpuUidBpfMapReaderTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/com/android/internal/os/KernelCpuUidClusterTimeReaderTest.java b/core/tests/coretests/src/com/android/internal/os/KernelCpuUidClusterTimeReaderTest.java index 8807de089864..bde66c7ba1cf 100644 --- a/core/tests/coretests/src/com/android/internal/os/KernelCpuUidClusterTimeReaderTest.java +++ b/core/tests/coretests/src/com/android/internal/os/KernelCpuUidClusterTimeReaderTest.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertTrue; import android.content.Context; import android.os.FileUtils; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import android.util.SparseArray; @@ -55,7 +55,7 @@ import java.util.Random; */ @SmallTest @RunWith(Parameterized.class) -@IgnoreUnderRavenwood(reason = "Needs kernel support") +@DisabledOnRavenwood(reason = "Needs kernel support") public class KernelCpuUidClusterTimeReaderTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/com/android/internal/os/KernelCpuUidFreqTimeReaderTest.java b/core/tests/coretests/src/com/android/internal/os/KernelCpuUidFreqTimeReaderTest.java index b73034437350..28c340d0122e 100644 --- a/core/tests/coretests/src/com/android/internal/os/KernelCpuUidFreqTimeReaderTest.java +++ b/core/tests/coretests/src/com/android/internal/os/KernelCpuUidFreqTimeReaderTest.java @@ -24,7 +24,7 @@ import static org.mockito.Mockito.when; import android.content.Context; import android.os.FileUtils; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import android.util.SparseArray; @@ -58,7 +58,7 @@ import java.util.Random; */ @SmallTest @RunWith(Parameterized.class) -@IgnoreUnderRavenwood(reason = "Needs kernel support") +@DisabledOnRavenwood(reason = "Needs kernel support") public class KernelCpuUidFreqTimeReaderTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/com/android/internal/os/KernelCpuUidUserSysTimeReaderTest.java b/core/tests/coretests/src/com/android/internal/os/KernelCpuUidUserSysTimeReaderTest.java index 864e1985d2e6..010d3d6ddafa 100644 --- a/core/tests/coretests/src/com/android/internal/os/KernelCpuUidUserSysTimeReaderTest.java +++ b/core/tests/coretests/src/com/android/internal/os/KernelCpuUidUserSysTimeReaderTest.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertTrue; import android.content.Context; import android.os.FileUtils; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import android.util.SparseArray; @@ -52,7 +52,7 @@ import java.util.Random; */ @SmallTest @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(reason = "Needs kernel support") +@DisabledOnRavenwood(reason = "Needs kernel support") public class KernelCpuUidUserSysTimeReaderTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/com/android/internal/os/KernelMemoryBandwidthStatsTest.java b/core/tests/coretests/src/com/android/internal/os/KernelMemoryBandwidthStatsTest.java index a74f339b4f07..2b99a27dcbae 100644 --- a/core/tests/coretests/src/com/android/internal/os/KernelMemoryBandwidthStatsTest.java +++ b/core/tests/coretests/src/com/android/internal/os/KernelMemoryBandwidthStatsTest.java @@ -18,7 +18,7 @@ package com.android.internal.os; import static org.junit.Assert.assertEquals; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import android.util.LongSparseLongArray; @@ -36,7 +36,7 @@ import java.io.BufferedReader; * Tests for KernelMemoryBandwidthStats parsing and delta calculation, based on memory_state_time. */ @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(reason = "Needs kernel support") +@DisabledOnRavenwood(reason = "Needs kernel support") public class KernelMemoryBandwidthStatsTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/com/android/internal/os/KernelSingleProcessCpuThreadReaderTest.java b/core/tests/coretests/src/com/android/internal/os/KernelSingleProcessCpuThreadReaderTest.java index cdfef251e217..a4b44c70ef81 100644 --- a/core/tests/coretests/src/com/android/internal/os/KernelSingleProcessCpuThreadReaderTest.java +++ b/core/tests/coretests/src/com/android/internal/os/KernelSingleProcessCpuThreadReaderTest.java @@ -19,7 +19,7 @@ package com.android.internal.os; import static com.google.common.truth.Truth.assertThat; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.ext.junit.runners.AndroidJUnit4; @@ -35,7 +35,7 @@ import java.util.List; @SmallTest @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(reason = "Needs kernel support") +@DisabledOnRavenwood(reason = "Needs kernel support") public class KernelSingleProcessCpuThreadReaderTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/com/android/internal/os/KernelSingleUidTimeReaderTest.java b/core/tests/coretests/src/com/android/internal/os/KernelSingleUidTimeReaderTest.java index 0ba2d851feb9..262d6a2d6fa7 100644 --- a/core/tests/coretests/src/com/android/internal/os/KernelSingleUidTimeReaderTest.java +++ b/core/tests/coretests/src/com/android/internal/os/KernelSingleUidTimeReaderTest.java @@ -24,7 +24,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import android.annotation.SuppressLint; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import android.util.SparseArray; @@ -47,7 +47,7 @@ import java.util.Collection; @SmallTest @RunWith(Parameterized.class) -@IgnoreUnderRavenwood(reason = "Needs kernel support") +@DisabledOnRavenwood(reason = "Needs kernel support") public class KernelSingleUidTimeReaderTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/com/android/internal/os/ProcTimeInStateReaderTest.java b/core/tests/coretests/src/com/android/internal/os/ProcTimeInStateReaderTest.java index 93dd09db8552..0de5f158c2d4 100644 --- a/core/tests/coretests/src/com/android/internal/os/ProcTimeInStateReaderTest.java +++ b/core/tests/coretests/src/com/android/internal/os/ProcTimeInStateReaderTest.java @@ -21,7 +21,7 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.fail; import android.os.FileUtils; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.ext.junit.runners.AndroidJUnit4; @@ -40,7 +40,7 @@ import java.nio.file.Path; @SmallTest @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = ProcTimeInStateReader.class) +@DisabledOnRavenwood(blockedBy = ProcTimeInStateReader.class) public class ProcTimeInStateReaderTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/com/android/internal/os/ProcessCpuTrackerTest.java b/core/tests/coretests/src/com/android/internal/os/ProcessCpuTrackerTest.java index d11c500b055a..46cb382c30d5 100644 --- a/core/tests/coretests/src/com/android/internal/os/ProcessCpuTrackerTest.java +++ b/core/tests/coretests/src/com/android/internal/os/ProcessCpuTrackerTest.java @@ -18,7 +18,7 @@ package com.android.internal.os; import static com.google.common.truth.Truth.assertThat; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.filters.SmallTest; @@ -30,7 +30,7 @@ import org.junit.runners.JUnit4; @SmallTest @RunWith(JUnit4.class) -@IgnoreUnderRavenwood(reason = "Needs kernel support") +@DisabledOnRavenwood(reason = "Needs kernel support") public class ProcessCpuTrackerTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/com/android/internal/ravenwood/RavenwoodEnvironmentTest.java b/core/tests/coretests/src/com/android/internal/ravenwood/RavenwoodEnvironmentTest.java index d1c066821cff..dad1f136b70c 100644 --- a/core/tests/coretests/src/com/android/internal/ravenwood/RavenwoodEnvironmentTest.java +++ b/core/tests/coretests/src/com/android/internal/ravenwood/RavenwoodEnvironmentTest.java @@ -32,7 +32,7 @@ public class RavenwoodEnvironmentTest { @Test public void testIsRunningOnRavenwood() { - assertEquals(RavenwoodRule.isUnderRavenwood(), + assertEquals(RavenwoodRule.isOnRavenwood(), RavenwoodEnvironment.getInstance().isRunningOnRavenwood()); } } diff --git a/core/tests/coretests/src/com/android/internal/util/ContrastColorUtilTest.java b/core/tests/coretests/src/com/android/internal/util/ContrastColorUtilTest.java index aa59afe6dd7a..28533de4dbab 100644 --- a/core/tests/coretests/src/com/android/internal/util/ContrastColorUtilTest.java +++ b/core/tests/coretests/src/com/android/internal/util/ContrastColorUtilTest.java @@ -23,7 +23,7 @@ import static com.google.common.truth.Truth.assertThat; import android.content.Context; import android.content.res.ColorStateList; import android.graphics.Color; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import android.text.Spannable; import android.text.SpannableString; @@ -43,7 +43,7 @@ import org.junit.Test; import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = Color.class) +@DisabledOnRavenwood(blockedBy = Color.class) public class ContrastColorUtilTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/com/android/internal/util/FakeLatencyTrackerTest.java b/core/tests/coretests/src/com/android/internal/util/FakeLatencyTrackerTest.java index aee352bc3a79..83eb1e64d706 100644 --- a/core/tests/coretests/src/com/android/internal/util/FakeLatencyTrackerTest.java +++ b/core/tests/coretests/src/com/android/internal/util/FakeLatencyTrackerTest.java @@ -24,7 +24,7 @@ import static com.android.internal.util.LatencyTracker.ACTION_SHOW_VOICE_INTERAC import static com.google.common.truth.Truth.assertThat; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import android.provider.DeviceConfig; @@ -45,7 +45,7 @@ import java.util.List; * {@link LatencyTrackerTest} */ @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = DeviceConfig.class) +@DisabledOnRavenwood(blockedBy = DeviceConfig.class) public class FakeLatencyTrackerTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/com/android/internal/util/FastDataTest.java b/core/tests/coretests/src/com/android/internal/util/FastDataTest.java index 316b95ac1b7d..f603fdb6507c 100644 --- a/core/tests/coretests/src/com/android/internal/util/FastDataTest.java +++ b/core/tests/coretests/src/com/android/internal/util/FastDataTest.java @@ -64,7 +64,7 @@ public class FastDataTest { @Parameters(name = "use4ByteSequence={0}") public static Collection<Object[]> data() { - if (RavenwoodRule.isUnderRavenwood()) { + if (RavenwoodRule.isOnRavenwood()) { // TODO: 4-byte sequences are only supported on ART return Arrays.asList(new Object[][]{{false}}); } else { diff --git a/core/tests/coretests/src/com/android/internal/util/LatencyTrackerTest.java b/core/tests/coretests/src/com/android/internal/util/LatencyTrackerTest.java index ce265a3178d3..141565139734 100644 --- a/core/tests/coretests/src/com/android/internal/util/LatencyTrackerTest.java +++ b/core/tests/coretests/src/com/android/internal/util/LatencyTrackerTest.java @@ -25,7 +25,7 @@ import static com.android.internal.util.LatencyTracker.STATSD_ACTION; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import android.provider.DeviceConfig; @@ -51,7 +51,7 @@ import java.util.Map; import java.util.stream.Collectors; @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = DeviceConfig.class) +@DisabledOnRavenwood(blockedBy = DeviceConfig.class) public class LatencyTrackerTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/com/android/internal/util/ProgressReporterTest.java b/core/tests/coretests/src/com/android/internal/util/ProgressReporterTest.java index e0d5499835a8..bb1c9edf9b58 100644 --- a/core/tests/coretests/src/com/android/internal/util/ProgressReporterTest.java +++ b/core/tests/coretests/src/com/android/internal/util/ProgressReporterTest.java @@ -18,7 +18,7 @@ package com.android.internal.util; import static org.junit.Assert.assertEquals; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.ext.junit.runners.AndroidJUnit4; @@ -29,7 +29,7 @@ import org.junit.Test; import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = ProgressReporter.class) +@DisabledOnRavenwood(blockedBy = ProgressReporter.class) public class ProgressReporterTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/coretests/src/com/android/internal/widget/LockPatternUtilsTest.java b/core/tests/coretests/src/com/android/internal/widget/LockPatternUtilsTest.java index d1fbc77cbd46..e0e24e7cabab 100644 --- a/core/tests/coretests/src/com/android/internal/widget/LockPatternUtilsTest.java +++ b/core/tests/coretests/src/com/android/internal/widget/LockPatternUtilsTest.java @@ -53,7 +53,7 @@ import android.os.UserHandle; import android.os.UserManager; import android.platform.test.annotations.DisableFlags; import android.platform.test.annotations.EnableFlags; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.flag.junit.SetFlagsRule; import android.platform.test.ravenwood.RavenwoodRule; import android.provider.Settings; @@ -80,7 +80,7 @@ import java.util.concurrent.CompletableFuture; @RunWith(AndroidJUnit4.class) @SmallTest -@IgnoreUnderRavenwood(blockedBy = LockPatternUtils.class) +@DisabledOnRavenwood(blockedBy = LockPatternUtils.class) public class LockPatternUtilsTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/utiltests/src/android/util/AtomicFileTest.java b/core/tests/utiltests/src/android/util/AtomicFileTest.java index 742307ba8c70..8897f0f05820 100644 --- a/core/tests/utiltests/src/android/util/AtomicFileTest.java +++ b/core/tests/utiltests/src/android/util/AtomicFileTest.java @@ -24,7 +24,7 @@ import static org.mockito.ArgumentMatchers.longThat; import static org.mockito.Mockito.spy; import android.os.SystemClock; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import androidx.annotation.NonNull; @@ -281,7 +281,7 @@ public class AtomicFileTest { } @Test - @IgnoreUnderRavenwood(blockedBy = SystemConfigFileCommitEventLogger.class) + @DisabledOnRavenwood(blockedBy = SystemConfigFileCommitEventLogger.class) public void testTimeLogging() throws Exception { var logger = spy(new SystemConfigFileCommitEventLogger("name")); var file = new AtomicFile(mBaseFile, logger); diff --git a/core/tests/utiltests/src/android/util/EventLogTest.java b/core/tests/utiltests/src/android/util/EventLogTest.java index 0ebf2c163d19..35803e7f698e 100644 --- a/core/tests/utiltests/src/android/util/EventLogTest.java +++ b/core/tests/utiltests/src/android/util/EventLogTest.java @@ -19,7 +19,7 @@ package android.util; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import android.util.EventLog.Event; @@ -51,7 +51,7 @@ public class EventLogTest { } @Test - @IgnoreUnderRavenwood(reason = "Reading not yet supported") + @DisabledOnRavenwood(reason = "Reading not yet supported") public void testWithNewData() throws Throwable { Event event = createEvent(() -> { EventLog.writeEvent(314, 123); diff --git a/core/tests/utiltests/src/android/util/MemoryIntArrayTest.java b/core/tests/utiltests/src/android/util/MemoryIntArrayTest.java index 8093af9bb004..1459212d206e 100644 --- a/core/tests/utiltests/src/android/util/MemoryIntArrayTest.java +++ b/core/tests/utiltests/src/android/util/MemoryIntArrayTest.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import android.os.Parcel; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.runner.AndroidJUnit4; @@ -39,13 +39,13 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = MemoryIntArray.class) +@DisabledOnRavenwood(blockedBy = MemoryIntArray.class) public class MemoryIntArrayTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); static { - if (!RavenwoodRule.isUnderRavenwood()) { + if (!RavenwoodRule.isOnRavenwood()) { System.loadLibrary("cutils"); System.loadLibrary("memoryintarraytest"); } diff --git a/core/tests/utiltests/src/android/util/MetadataReaderTest.java b/core/tests/utiltests/src/android/util/MetadataReaderTest.java index 14feed8b89a1..59815060f09b 100644 --- a/core/tests/utiltests/src/android/util/MetadataReaderTest.java +++ b/core/tests/utiltests/src/android/util/MetadataReaderTest.java @@ -20,7 +20,7 @@ import static org.junit.Assert.assertEquals; import android.media.ExifInterface; import android.os.Bundle; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import android.provider.DocumentsContract; import android.provider.MetadataReader; @@ -41,7 +41,7 @@ import java.io.IOException; import java.io.InputStream; @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = MetadataReader.class) +@DisabledOnRavenwood(blockedBy = MetadataReader.class) public class MetadataReaderTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/utiltests/src/android/util/SystemConfigFileCommitEventLoggerTest.java b/core/tests/utiltests/src/android/util/SystemConfigFileCommitEventLoggerTest.java index 3bb79ec91d09..d64de68aee74 100644 --- a/core/tests/utiltests/src/android/util/SystemConfigFileCommitEventLoggerTest.java +++ b/core/tests/utiltests/src/android/util/SystemConfigFileCommitEventLoggerTest.java @@ -21,7 +21,7 @@ import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import android.os.SystemClock; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.runner.AndroidJUnit4; @@ -32,7 +32,7 @@ import org.junit.runner.RunWith; import org.mockito.Mockito; @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = SystemConfigFileCommitEventLogger.class) +@DisabledOnRavenwood(blockedBy = SystemConfigFileCommitEventLogger.class) public class SystemConfigFileCommitEventLoggerTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/utiltests/src/com/android/internal/util/CharSequencesTest.java b/core/tests/utiltests/src/com/android/internal/util/CharSequencesTest.java index 988854038e53..b86c815bb6ac 100644 --- a/core/tests/utiltests/src/com/android/internal/util/CharSequencesTest.java +++ b/core/tests/utiltests/src/com/android/internal/util/CharSequencesTest.java @@ -21,7 +21,7 @@ import static com.android.internal.util.CharSequences.forAsciiBytes; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.filters.SmallTest; @@ -32,7 +32,7 @@ import org.junit.Test; import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = CharSequences.class) +@DisabledOnRavenwood(blockedBy = CharSequences.class) public class CharSequencesTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/utiltests/src/com/android/internal/util/FastXmlSerializerTest.java b/core/tests/utiltests/src/com/android/internal/util/FastXmlSerializerTest.java index f91172df4f74..259d3945caf8 100644 --- a/core/tests/utiltests/src/com/android/internal/util/FastXmlSerializerTest.java +++ b/core/tests/utiltests/src/com/android/internal/util/FastXmlSerializerTest.java @@ -20,7 +20,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import android.provider.DeviceConfig; import android.util.Log; @@ -145,7 +145,7 @@ public class FastXmlSerializerTest { @Test @LargeTest - @IgnoreUnderRavenwood(reason = "Long test runtime") + @DisabledOnRavenwood(reason = "Long test runtime") public void testAllCharacters() throws Exception { boolean ok = true; for (int i = 0; i < 0xffff; i++) { diff --git a/core/tests/utiltests/src/com/android/internal/util/InlinePresentationStyleUtilsTest.java b/core/tests/utiltests/src/com/android/internal/util/InlinePresentationStyleUtilsTest.java index 7203b8c6a8c8..1af58a344332 100644 --- a/core/tests/utiltests/src/com/android/internal/util/InlinePresentationStyleUtilsTest.java +++ b/core/tests/utiltests/src/com/android/internal/util/InlinePresentationStyleUtilsTest.java @@ -25,7 +25,7 @@ import static org.junit.Assert.assertTrue; import android.graphics.Color; import android.os.Binder; import android.os.Bundle; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.filters.SmallTest; @@ -39,7 +39,7 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @SmallTest -@IgnoreUnderRavenwood(blockedBy = InlinePresentationStyleUtils.class) +@DisabledOnRavenwood(blockedBy = InlinePresentationStyleUtils.class) public class InlinePresentationStyleUtilsTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/utiltests/src/com/android/internal/util/MimeIconUtilsTest.java b/core/tests/utiltests/src/com/android/internal/util/MimeIconUtilsTest.java index 6c3479722526..7e523bb12477 100644 --- a/core/tests/utiltests/src/com/android/internal/util/MimeIconUtilsTest.java +++ b/core/tests/utiltests/src/com/android/internal/util/MimeIconUtilsTest.java @@ -18,7 +18,7 @@ package com.android.internal.util; import static org.junit.Assert.assertEquals; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.runner.AndroidJUnit4; @@ -31,7 +31,7 @@ import org.junit.runner.RunWith; * Tests for {@link MimeIconUtils}. */ @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = MimeIconUtils.class) +@DisabledOnRavenwood(blockedBy = MimeIconUtils.class) public class MimeIconUtilsTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/utiltests/src/com/android/internal/util/ObservableServiceConnectionTest.java b/core/tests/utiltests/src/com/android/internal/util/ObservableServiceConnectionTest.java index c852e9f17bc0..dc353a5f5add 100644 --- a/core/tests/utiltests/src/com/android/internal/util/ObservableServiceConnectionTest.java +++ b/core/tests/utiltests/src/com/android/internal/util/ObservableServiceConnectionTest.java @@ -29,7 +29,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.os.IBinder; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.filters.SmallTest; @@ -52,7 +52,7 @@ import java.util.concurrent.Executor; @SmallTest @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = ObservableServiceConnection.class) +@DisabledOnRavenwood(blockedBy = ObservableServiceConnection.class) public class ObservableServiceConnectionTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/utiltests/src/com/android/internal/util/PersistentServiceConnectionTest.java b/core/tests/utiltests/src/com/android/internal/util/PersistentServiceConnectionTest.java index 096f303247ff..a881873f4075 100644 --- a/core/tests/utiltests/src/com/android/internal/util/PersistentServiceConnectionTest.java +++ b/core/tests/utiltests/src/com/android/internal/util/PersistentServiceConnectionTest.java @@ -30,7 +30,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.os.IBinder; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.runner.AndroidJUnit4; @@ -52,7 +52,7 @@ import java.util.Queue; import java.util.concurrent.Executor; @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = PersistentServiceConnection.class) +@DisabledOnRavenwood(blockedBy = PersistentServiceConnection.class) public class PersistentServiceConnectionTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/core/tests/utiltests/src/com/android/internal/util/WakeupMessageTest.java b/core/tests/utiltests/src/com/android/internal/util/WakeupMessageTest.java index b0db8a1da3a8..c7e0bbd149f5 100644 --- a/core/tests/utiltests/src/com/android/internal/util/WakeupMessageTest.java +++ b/core/tests/utiltests/src/com/android/internal/util/WakeupMessageTest.java @@ -24,8 +24,7 @@ import android.content.Context; import android.os.Handler; import android.os.Looper; import android.os.Message; -import android.platform.test.annotations.IgnoreUnderRavenwood; -import android.platform.test.ravenwood.RavenwoodRule; +import android.platform.test.annotations.DisabledOnRavenwood; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; @@ -47,7 +46,7 @@ import org.mockito.stubbing.Answer; */ @SmallTest @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = WakeupMessage.class) +@DisabledOnRavenwood(blockedBy = WakeupMessage.class) public class WakeupMessageTest { private static final String TEST_CMD_NAME = "TEST cmd Name"; private static final int TEST_CMD = 18; @@ -55,11 +54,6 @@ public class WakeupMessageTest { private static final int TEST_ARG2 = 182; private static final Object TEST_OBJ = "hello"; - @Rule - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - @Mock Context mContext; @Mock AlarmManager mAlarmManager; WakeupMessage mMessage; diff --git a/core/tests/utiltests/src/com/android/internal/util/test/FakeSettingsProviderTest.java b/core/tests/utiltests/src/com/android/internal/util/test/FakeSettingsProviderTest.java index 502d6b6d7270..abedc4d91707 100644 --- a/core/tests/utiltests/src/com/android/internal/util/test/FakeSettingsProviderTest.java +++ b/core/tests/utiltests/src/com/android/internal/util/test/FakeSettingsProviderTest.java @@ -20,7 +20,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import android.content.ContentProvider; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.ravenwood.RavenwoodRule; import android.provider.Settings; import android.test.mock.MockContentResolver; @@ -37,7 +37,7 @@ import org.junit.runner.RunWith; * Unit tests for FakeSettingsProvider. */ @RunWith(AndroidJUnit4.class) -@IgnoreUnderRavenwood(blockedBy = ContentProvider.class) +@DisabledOnRavenwood(blockedBy = ContentProvider.class) public class FakeSettingsProviderTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule(); diff --git a/data/etc/preinstalled-packages-platform.xml b/data/etc/preinstalled-packages-platform.xml index 3b4014867ef7..f25ceb14fb10 100644 --- a/data/etc/preinstalled-packages-platform.xml +++ b/data/etc/preinstalled-packages-platform.xml @@ -139,4 +139,10 @@ to pre-existing users, but cannot uninstall pre-existing system packages from pr <install-in-user-type package="com.android.multiuser"> <install-in user-type="FULL" /> </install-in-user-type> + + <!-- PrivateSpace App, only install in private profile --> + <install-in-user-type package="com.android.privatespace"> + <install-in user-type="android.os.usertype.profile.PRIVATE" /> + </install-in-user-type> + </config> diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java index cd5a54c2fd3f..a4ba2b398deb 100644 --- a/graphics/java/android/graphics/Bitmap.java +++ b/graphics/java/android/graphics/Bitmap.java @@ -755,6 +755,9 @@ public final class Bitmap implements Parcelable { if (b != null) { b.setPremultiplied(mRequestPremultiplied); b.mDensity = mDensity; + if (hasGainmap()) { + b.setGainmap(getGainmap().asShared()); + } } return b; } @@ -767,7 +770,8 @@ public final class Bitmap implements Parcelable { */ @NonNull public Bitmap asShared() { - if (nativeIsBackedByAshmem(mNativePtr) && nativeIsImmutable(mNativePtr)) { + if (nativeIsBackedByAshmem(mNativePtr) && nativeIsImmutable(mNativePtr) + && (!hasGainmap() || getGainmap().asShared() == getGainmap())) { return this; } Bitmap shared = createAshmemBitmap(); @@ -2091,7 +2095,7 @@ public final class Bitmap implements Parcelable { */ public void setGainmap(@Nullable Gainmap gainmap) { checkRecycled("Bitmap is recycled"); - mGainmap = null; + mGainmap = gainmap; nativeSetGainmap(mNativePtr, gainmap == null ? 0 : gainmap.mNativePtr); } diff --git a/graphics/java/android/graphics/Gainmap.java b/graphics/java/android/graphics/Gainmap.java index 7fc13db85659..2417a1270bc5 100644 --- a/graphics/java/android/graphics/Gainmap.java +++ b/graphics/java/android/graphics/Gainmap.java @@ -161,6 +161,18 @@ public final class Gainmap implements Parcelable { } /** + * @hide + */ + public Gainmap asShared() { + final Bitmap sharedContents = mGainmapContents.asShared(); + if (sharedContents == mGainmapContents) { + return this; + } else { + return new Gainmap(sharedContents, nCreateCopy(mNativePtr)); + } + } + + /** * @return Returns the image data of the gainmap represented as a Bitmap. This is represented * as a Bitmap for broad API compatibility, however certain aspects of the Bitmap are ignored * such as {@link Bitmap#getColorSpace()} or {@link Bitmap#getGainmap()} as they are not diff --git a/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu.xml b/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu.xml index ed8b54397076..bfaa40771894 100644 --- a/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu.xml +++ b/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu.xml @@ -43,8 +43,7 @@ android:layout_height="@dimen/desktop_mode_handle_menu_icon_radius" android:layout_marginStart="10dp" android:layout_marginEnd="12dp" - android:contentDescription="@string/app_icon_text" - android:importantForAccessibility="no"/> + android:contentDescription="@string/app_icon_text" /> <com.android.wm.shell.windowdecor.MarqueedTextView android:id="@+id/application_name" @@ -142,7 +141,6 @@ android:contentDescription="@string/screenshot_text" android:text="@string/screenshot_text" android:src="@drawable/desktop_mode_ic_handle_menu_screenshot" - android:importantForAccessibility="no" style="@style/DesktopModeHandleMenuActionButton"/> <com.android.wm.shell.windowdecor.HandleMenuActionButton @@ -150,7 +148,6 @@ android:contentDescription="@string/new_window_text" android:text="@string/new_window_text" android:src="@drawable/desktop_mode_ic_handle_menu_new_window" - android:importantForAccessibility="no" style="@style/DesktopModeHandleMenuActionButton"/> <com.android.wm.shell.windowdecor.HandleMenuActionButton @@ -158,7 +155,6 @@ android:contentDescription="@string/manage_windows_text" android:text="@string/manage_windows_text" android:src="@drawable/desktop_mode_ic_handle_menu_manage_windows" - android:importantForAccessibility="no" style="@style/DesktopModeHandleMenuActionButton"/> <com.android.wm.shell.windowdecor.HandleMenuActionButton @@ -166,7 +162,6 @@ android:contentDescription="@string/change_aspect_ratio_text" android:text="@string/change_aspect_ratio_text" android:src="@drawable/desktop_mode_ic_handle_menu_change_aspect_ratio" - android:importantForAccessibility="no" style="@style/DesktopModeHandleMenuActionButton"/> </LinearLayout> @@ -186,7 +181,6 @@ android:text="@string/open_in_browser_text" android:src="@drawable/desktop_mode_ic_handle_menu_open_in_browser" style="@style/DesktopModeHandleMenuActionButton" - android:importantForAccessibility="no" android:layout_width="0dp" android:layout_weight="1"/> diff --git a/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu_action_button.xml b/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu_action_button.xml index de38e6fc2330..35e7de0e7c1e 100644 --- a/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu_action_button.xml +++ b/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu_action_button.xml @@ -22,8 +22,7 @@ android:layout_height="match_parent" android:gravity="start|center_vertical" android:paddingHorizontal="16dp" - android:clickable="true" - android:focusable="true" + android:importantForAccessibility="yes" android:orientation="horizontal" android:background="?android:attr/selectableItemBackground"> diff --git a/libs/WindowManager/Shell/res/values/styles.xml b/libs/WindowManager/Shell/res/values/styles.xml index 637b47ab3ace..5f1db83d7acb 100644 --- a/libs/WindowManager/Shell/res/values/styles.xml +++ b/libs/WindowManager/Shell/res/values/styles.xml @@ -45,6 +45,7 @@ <item name="android:layout_height">52dp</item> <item name="android:textColor">@androidprv:color/materialColorOnSurface</item> <item name="android:drawableTint">@androidprv:color/materialColorOnSurface</item> + <item name="android:importantForAccessibility">no</item> </style> <style name="DesktopModeHandleMenuActionButtonImage"> diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java index 912de813cf59..60573965208a 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java @@ -2643,9 +2643,9 @@ public class BubbleController implements ConfigurationChangeListener, mBubbleData.setSelectedBubbleAndExpandStack(bubbleToSelect); } - private void moveBubbleToFullscreen(String key) { + private void moveDraggedBubbleToFullscreen(String key, Point dropLocation) { Bubble b = mBubbleData.getBubbleInStackWithKey(key); - mBubbleTransitions.startDraggedBubbleIconToFullscreen(b); + mBubbleTransitions.startDraggedBubbleIconToFullscreen(b, dropLocation); } private boolean isDeviceLocked() { @@ -2936,8 +2936,9 @@ public class BubbleController implements ConfigurationChangeListener, } @Override - public void moveBubbleToFullscreen(String key) { - mMainExecutor.execute(() -> mController.moveBubbleToFullscreen(key)); + public void moveDraggedBubbleToFullscreen(String key, Point dropLocation) { + mMainExecutor.execute( + () -> mController.moveDraggedBubbleToFullscreen(key, dropLocation)); } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleTransitions.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleTransitions.java index c1841c707a2f..728975e8ef9f 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleTransitions.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleTransitions.java @@ -30,6 +30,7 @@ import android.annotation.Nullable; import android.app.ActivityManager; import android.app.TaskInfo; import android.content.Context; +import android.graphics.Point; import android.graphics.PointF; import android.graphics.Rect; import android.os.IBinder; @@ -42,6 +43,11 @@ import android.window.TransitionRequestInfo; import android.window.WindowContainerToken; import android.window.WindowContainerTransaction; +import androidx.core.animation.Animator; +import androidx.core.animation.Animator.AnimatorUpdateListener; +import androidx.core.animation.AnimatorListenerAdapter; +import androidx.core.animation.ValueAnimator; + import com.android.internal.annotations.VisibleForTesting; import com.android.launcher3.icons.BubbleIconFactory; import com.android.wm.shell.ShellTaskOrganizer; @@ -114,8 +120,8 @@ public class BubbleTransitions { } /** Starts a transition that converts a dragged bubble icon to a full screen task. */ - public BubbleTransition startDraggedBubbleIconToFullscreen(Bubble bubble) { - return new DraggedBubbleIconToFullscreen(bubble); + public BubbleTransition startDraggedBubbleIconToFullscreen(Bubble bubble, Point dropLocation) { + return new DraggedBubbleIconToFullscreen(bubble, dropLocation); } /** @@ -673,9 +679,19 @@ public class BubbleTransitions { IBinder mTransition; final Bubble mBubble; + final Point mDropLocation; + final TransactionProvider mTransactionProvider; + + DraggedBubbleIconToFullscreen(Bubble bubble, Point dropLocation) { + this(bubble, dropLocation, SurfaceControl.Transaction::new); + } - DraggedBubbleIconToFullscreen(Bubble bubble) { + @VisibleForTesting + DraggedBubbleIconToFullscreen(Bubble bubble, Point dropLocation, + TransactionProvider transactionProvider) { mBubble = bubble; + mDropLocation = dropLocation; + mTransactionProvider = transactionProvider; bubble.setPreparingTransition(this); WindowContainerToken token = bubble.getTaskView().getTaskInfo().getToken(); WindowContainerTransaction wct = new WindowContainerTransaction(); @@ -723,8 +739,34 @@ public class BubbleTransitions { } mRepository.remove(taskViewTaskController); + final SurfaceControl taskLeash = change.getLeash(); + // set the initial position of the task with 0 scale + startTransaction.setPosition(taskLeash, mDropLocation.x, mDropLocation.y); + startTransaction.setScale(taskLeash, 0, 0); startTransaction.apply(); - finishCallback.onTransitionFinished(null); + + final SurfaceControl.Transaction animT = mTransactionProvider.get(); + ValueAnimator animator = ValueAnimator.ofFloat(0, 1); + animator.setDuration(250); + animator.addUpdateListener(new AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(@NonNull Animator animation) { + float progress = animator.getAnimatedFraction(); + float x = mDropLocation.x * (1 - progress); + float y = mDropLocation.y * (1 - progress); + animT.setPosition(taskLeash, x, y); + animT.setScale(taskLeash, progress, progress); + animT.apply(); + } + }); + animator.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(@NonNull Animator animation) { + animT.close(); + finishCallback.onTransitionFinished(null); + } + }); + animator.start(); taskViewTaskController.notifyTaskRemovalStarted(mBubble.getTaskView().getTaskInfo()); mTaskViewTransitions.onExternalDone(transition); return true; @@ -774,4 +816,8 @@ public class BubbleTransitions { mTaskViewTransitions.onExternalDone(transition); } } + + interface TransactionProvider { + SurfaceControl.Transaction get(); + } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/IBubbles.aidl b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/IBubbles.aidl index 079edb3ea8ec..e2d5d787cf2b 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/IBubbles.aidl +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/IBubbles.aidl @@ -18,6 +18,7 @@ package com.android.wm.shell.bubbles; import android.content.Intent; import android.content.pm.ShortcutInfo; +import android.graphics.Point; import android.graphics.Rect; import android.os.UserHandle; import com.android.wm.shell.bubbles.IBubblesListener; @@ -59,5 +60,5 @@ interface IBubbles { oneway void showDropTarget(in boolean show, in @nullable BubbleBarLocation location) = 15; - oneway void moveBubbleToFullscreen(in String key) = 16; + oneway void moveDraggedBubbleToFullscreen(in String key, in Point dropLocation) = 16; }
\ No newline at end of file diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayImeController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayImeController.java index f73788486d04..bc76a8797f83 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayImeController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayImeController.java @@ -468,10 +468,12 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged } } - private void setAnimating(boolean imeAnimationOngoing) { + private void setAnimating(boolean imeAnimationOngoing, + @Nullable ImeTracker.Token statsToken) { int animatingTypes = imeAnimationOngoing ? WindowInsets.Type.ime() : 0; try { - mWmService.updateDisplayWindowAnimatingTypes(mDisplayId, animatingTypes); + mWmService.updateDisplayWindowAnimatingTypes(mDisplayId, animatingTypes, + statsToken); } catch (RemoteException e) { } } @@ -635,7 +637,9 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged + " showing:" + (mAnimationDirection == DIRECTION_SHOW)); } if (android.view.inputmethod.Flags.reportAnimatingInsetsTypes()) { - setAnimating(true /* imeAnimationOngoing */); + // Updating the animatingTypes when starting the animation is not the + // trigger to show the IME. Thus, not sending the statsToken here. + setAnimating(true /* imeAnimationOngoing */, null /* statsToken */); } int flags = dispatchStartPositioning(mDisplayId, imeTop(hiddenY, defaultY), imeTop(shownY, defaultY), mAnimationDirection == DIRECTION_SHOW, @@ -685,7 +689,8 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged if (!android.view.inputmethod.Flags.refactorInsetsController()) { dispatchEndPositioning(mDisplayId, mCancelled, t); } else if (android.view.inputmethod.Flags.reportAnimatingInsetsTypes()) { - setAnimating(false /* imeAnimationOngoing */); + setAnimating(false /* imeAnimationOngoing */, + mAnimationDirection == DIRECTION_HIDE ? statsToken : null); } if (mAnimationDirection == DIRECTION_HIDE && !mCancelled) { ImeTracker.forLogging().onProgress(mStatsToken, @@ -695,7 +700,12 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged removeImeSurface(mDisplayId); } if (android.view.inputmethod.Flags.refactorInsetsController()) { - setVisibleDirectly(false /* visible */, statsToken); + // Updating the client visibility will not hide the IME, unless it is + // not animating anymore. Thus, not sending a statsToken here, but + // only later when we're updating the animatingTypes. + setVisibleDirectly(false /* visible */, + !android.view.inputmethod.Flags.reportAnimatingInsetsTypes() + ? statsToken : null); } if (!android.view.inputmethod.Flags.refactorInsetsController()) { ImeTracker.forLogging().onHidden(mStatsToken); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopDisplayModeController.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopDisplayModeController.kt index 6dcc0deb1da1..489e4f0aed01 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopDisplayModeController.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopDisplayModeController.kt @@ -114,21 +114,36 @@ class DesktopDisplayModeController( transitions.startTransition(TRANSIT_CHANGE, wct, /* handler= */ null) } + // Do not directly use this method to check the state of desktop-first mode. Check the display + // windowing mode instead. + private fun canDesktopFirstModeBeEnabledOnDefaultDisplay(): Boolean { + if (isDefaultDisplayDesktopEligible()) { + if (isExtendedDisplayEnabled() && hasExternalDisplay()) { + return true + } + if (DesktopExperienceFlags.FORM_FACTOR_BASED_DESKTOP_FIRST_SWITCH.isTrue) { + if (isInClamshellMode()) { + return true + } + } + } + return false + } + @VisibleForTesting fun getTargetWindowingModeForDefaultDisplay(): Int { - if (isExtendedDisplayEnabled() && hasExternalDisplay()) { + if (canDesktopFirstModeBeEnabledOnDefaultDisplay()) { return WINDOWING_MODE_FREEFORM } - if (DesktopExperienceFlags.FORM_FACTOR_BASED_DESKTOP_FIRST_SWITCH.isTrue) { - if (isInClamshellMode()) { - return WINDOWING_MODE_FREEFORM - } - return WINDOWING_MODE_FULLSCREEN - } - // If form factor-based desktop first switch is disabled, use the default display windowing - // mode here to keep the freeform mode for some form factors (e.g., FEATURE_PC). - return windowManager.getWindowingMode(DEFAULT_DISPLAY) + return if (DesktopExperienceFlags.FORM_FACTOR_BASED_DESKTOP_FIRST_SWITCH.isTrue) { + WINDOWING_MODE_FULLSCREEN + } else { + // If form factor-based desktop first switch is disabled, use the default display + // windowing mode here to keep the freeform mode for some form factors (e.g., + // FEATURE_PC). + windowManager.getWindowingMode(DEFAULT_DISPLAY) + } } private fun isExtendedDisplayEnabled(): Boolean { @@ -156,6 +171,13 @@ class DesktopDisplayModeController( private fun isInClamshellMode() = inputManager.isInTabletMode() == InputManager.SWITCH_STATE_OFF + private fun isDefaultDisplayDesktopEligible(): Boolean { + val display = requireNotNull(displayController.getDisplay(DEFAULT_DISPLAY)) { + "Display object of DEFAULT_DISPLAY must be non-null." + } + return DesktopModeStatus.isDesktopModeSupportedOnDisplay(context, display) + } + private fun logV(msg: String, vararg arguments: Any?) { ProtoLog.v(WM_SHELL_DESKTOP_MODE, "%s: $msg", TAG, *arguments) } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt index 50f5beb4166a..cfc1541d6388 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt @@ -886,6 +886,9 @@ class DesktopTasksController( exitResult.asExit()?.runOnTransitionStart?.invoke(transition) desktopExitRunnable?.invoke(transition) } + taskbarDesktopTaskListener?.onTaskbarCornerRoundingUpdate( + doesAnyTaskRequireTaskbarRounding(displayId, taskId) + ) } /** Move a task with given `taskId` to fullscreen */ diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java index 003baae29114..bcf9396ff0c1 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java @@ -553,7 +553,9 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin return; } - if (oldRootView != mResult.mRootView) { + if (DesktopModeFlags.SKIP_DECOR_VIEW_RELAYOUT_WHEN_CLOSING_BUGFIX.isTrue() + ? (oldRootView != mResult.mRootView && taskInfo.isVisibleRequested) + : oldRootView != mResult.mRootView) { disposeStatusBarInputLayer(); mWindowDecorViewHolder = createViewHolder(); // Load these only when first creating the view. diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragResizeInputListener.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragResizeInputListener.java index 7a4a834e9dc2..0b86d1dbbc58 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragResizeInputListener.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragResizeInputListener.java @@ -23,12 +23,12 @@ import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERL import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_CONSUMER; +import static com.android.wm.shell.desktopmode.DesktopModeEventLogger.Companion.ResizeTrigger; import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE; import static com.android.wm.shell.windowdecor.DragPositioningCallback.CTRL_TYPE_BOTTOM; import static com.android.wm.shell.windowdecor.DragPositioningCallback.CTRL_TYPE_LEFT; import static com.android.wm.shell.windowdecor.DragPositioningCallback.CTRL_TYPE_RIGHT; import static com.android.wm.shell.windowdecor.DragPositioningCallback.CTRL_TYPE_TOP; -import static com.android.wm.shell.desktopmode.DesktopModeEventLogger.Companion.ResizeTrigger; import static com.android.wm.shell.windowdecor.DragResizeWindowGeometry.isEdgeResizePermitted; import static com.android.wm.shell.windowdecor.DragResizeWindowGeometry.isEventFromTouchscreen; @@ -127,7 +127,9 @@ class DragResizeInputListener implements AutoCloseable { Supplier<SurfaceControl.Builder> surfaceControlBuilderSupplier, Supplier<SurfaceControl.Transaction> surfaceControlTransactionSupplier, DisplayController displayController, - DesktopModeEventLogger desktopModeEventLogger) { + DesktopModeEventLogger desktopModeEventLogger, + InputChannel inputChannel, + InputChannel sinkInputChannel) { mContext = context; mWindowSession = windowSession; mBgExecutor = bgExecutor; @@ -136,7 +138,11 @@ class DragResizeInputListener implements AutoCloseable { mHandler = handler; mChoreographer = choreographer; mDisplayId = displayId; - mDecorationSurface = decorationSurface; + // Creates a new SurfaceControl pointing the same underlying surface with decorationSurface + // to ensure that mDecorationSurface will not be released while it's used on the background + // thread. Note that the empty name will be overridden by the next copyFrom call. + mDecorationSurface = surfaceControlBuilderSupplier.get().setName("").build(); + mDecorationSurface.copyFrom(decorationSurface, "DragResizeInputListener"); mDragPositioningCallback = callback; mSurfaceControlBuilderSupplier = surfaceControlBuilderSupplier; mSurfaceControlTransactionSupplier = surfaceControlTransactionSupplier; @@ -154,9 +160,13 @@ class DragResizeInputListener implements AutoCloseable { final InputSetUpResult result = setUpInputChannels(mDisplayId, mWindowSession, mDecorationSurface, mClientToken, mSinkClientToken, mSurfaceControlBuilderSupplier, - mSurfaceControlTransactionSupplier); + mSurfaceControlTransactionSupplier, inputChannel, sinkInputChannel); mainExecutor.execute(() -> { if (mClosed) { + result.mInputChannel.dispose(); + result.mSinkInputChannel.dispose(); + mSurfaceControlTransactionSupplier.get().remove( + result.mInputSinkSurface).apply(); return; } mInputSinkSurface = result.mInputSinkSurface; @@ -208,7 +218,7 @@ class DragResizeInputListener implements AutoCloseable { new DefaultTaskResizeInputEventReceiverFactory(), taskInfo, handler, choreographer, displayId, decorationSurface, callback, surfaceControlBuilderSupplier, surfaceControlTransactionSupplier, - displayController, desktopModeEventLogger); + displayController, desktopModeEventLogger, new InputChannel(), new InputChannel()); } DragResizeInputListener( @@ -251,11 +261,11 @@ class DragResizeInputListener implements AutoCloseable { @NonNull IBinder clientToken, @NonNull IBinder sinkClientToken, @NonNull Supplier<SurfaceControl.Builder> surfaceControlBuilderSupplier, - @NonNull Supplier<SurfaceControl.Transaction> surfaceControlTransactionSupplier) { + @NonNull Supplier<SurfaceControl.Transaction> surfaceControlTransactionSupplier, + @NonNull InputChannel inputChannel, + @NonNull InputChannel sinkInputChannel) { Trace.beginSection("DragResizeInputListener#setUpInputChannels"); final InputTransferToken inputTransferToken = new InputTransferToken(); - final InputChannel inputChannel = new InputChannel(); - final InputChannel sinkInputChannel = new InputChannel(); try { windowSession.grantInputChannel( displayId, @@ -421,6 +431,9 @@ class DragResizeInputListener implements AutoCloseable { } catch (RemoteException e) { e.rethrowFromSystemServer(); } + // Removing this surface on the background thread to ensure that mInitInputChannels has + // already been finished. + mSurfaceControlTransactionSupplier.get().remove(mDecorationSurface).apply(); }); } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/HandleMenu.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/HandleMenu.kt index a8a7032d0b86..9cc64ac9c276 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/HandleMenu.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/HandleMenu.kt @@ -109,15 +109,18 @@ class HandleMenu( get() = (DesktopModeFlags.ENABLE_HANDLE_INPUT_FIX.isTrue() && !taskInfo.isFreeform) private val pillTopMargin: Int = loadDimensionPixelSize( - R.dimen.desktop_mode_handle_menu_pill_spacing_margin) + R.dimen.desktop_mode_handle_menu_pill_spacing_margin + ) private val menuWidth = loadDimensionPixelSize(R.dimen.desktop_mode_handle_menu_width) private val menuHeight = getHandleMenuHeight() private val marginMenuTop = loadDimensionPixelSize(R.dimen.desktop_mode_handle_menu_margin_top) private val marginMenuStart = loadDimensionPixelSize( - R.dimen.desktop_mode_handle_menu_margin_start) + R.dimen.desktop_mode_handle_menu_margin_start + ) @VisibleForTesting var handleMenuViewContainer: AdditionalViewContainer? = null + @VisibleForTesting var handleMenuView: HandleMenuView? = null @@ -136,7 +139,7 @@ class HandleMenu( private val shouldShowMoreActionsPill: Boolean get() = SHOULD_SHOW_SCREENSHOT_BUTTON || shouldShowNewWindowButton || - shouldShowManageWindowsButton || shouldShowChangeAspectRatioButton + shouldShowManageWindowsButton || shouldShowChangeAspectRatioButton private var loadAppInfoJob: Job? = null @@ -240,7 +243,8 @@ class HandleMenu( val y = handleMenuPosition.y.toInt() handleMenuViewContainer = if ((!taskInfo.isFreeform && DesktopModeFlags.ENABLE_HANDLE_INPUT_FIX.isTrue()) - || forceShowSystemBars) { + || forceShowSystemBars + ) { AdditionalSystemViewContainer( windowManagerWrapper = windowManagerWrapper, taskId = taskInfo.taskId, @@ -251,7 +255,11 @@ class HandleMenu( flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, view = handleMenuView.rootView, - forciblyShownTypes = if (forceShowSystemBars) { systemBars() } else { 0 }, + forciblyShownTypes = if (forceShowSystemBars) { + systemBars() + } else { + 0 + }, ignoreCutouts = Flags.showAppHandleLargeScreens() || BubbleAnythingFlagHelper.enableBubbleToFullscreen() ) @@ -369,7 +377,8 @@ class HandleMenu( inputPoint.y - globalMenuPosition.y ) if (splitScreenController.getSplitPosition(taskInfo.taskId) - == SplitScreenConstants.SPLIT_POSITION_BOTTOM_OR_RIGHT) { + == SplitScreenConstants.SPLIT_POSITION_BOTTOM_OR_RIGHT + ) { val leftStageBounds = Rect() splitScreenController.getStageBounds(leftStageBounds, Rect()) inputRelativeToMenu.x += leftStageBounds.width().toFloat() @@ -398,7 +407,8 @@ class HandleMenu( var menuHeight = loadDimensionPixelSize(R.dimen.desktop_mode_handle_menu_height) if (!shouldShowWindowingPill) { menuHeight -= loadDimensionPixelSize( - R.dimen.desktop_mode_handle_menu_windowing_pill_height) + R.dimen.desktop_mode_handle_menu_windowing_pill_height + ) menuHeight -= pillTopMargin } if (!SHOULD_SHOW_SCREENSHOT_BUTTON) { @@ -418,14 +428,16 @@ class HandleMenu( } if (!shouldShowChangeAspectRatioButton) { menuHeight -= loadDimensionPixelSize( - R.dimen.desktop_mode_handle_menu_change_aspect_ratio_height) + R.dimen.desktop_mode_handle_menu_change_aspect_ratio_height + ) } if (!shouldShowMoreActionsPill) { menuHeight -= pillTopMargin } if (!shouldShowBrowserPill) { menuHeight -= loadDimensionPixelSize( - R.dimen.desktop_mode_handle_menu_open_in_browser_pill_height) + R.dimen.desktop_mode_handle_menu_open_in_browser_pill_height + ) menuHeight -= pillTopMargin } return menuHeight @@ -468,48 +480,66 @@ class HandleMenu( // Insets for ripple effect of App Info Pill. and Windowing Pill. buttons val iconButtondrawableShiftInset = context.resources.getDimensionPixelSize( - R.dimen.desktop_mode_handle_menu_icon_button_ripple_inset_shift) + R.dimen.desktop_mode_handle_menu_icon_button_ripple_inset_shift + ) val iconButtondrawableBaseInset = context.resources.getDimensionPixelSize( - R.dimen.desktop_mode_handle_menu_icon_button_ripple_inset_base) + R.dimen.desktop_mode_handle_menu_icon_button_ripple_inset_base + ) private val iconButtonRippleRadius = context.resources.getDimensionPixelSize( - R.dimen.desktop_mode_handle_menu_icon_button_ripple_radius) - private val iconButtonDrawableInsetsBase = DrawableInsets(t = iconButtondrawableBaseInset, + R.dimen.desktop_mode_handle_menu_icon_button_ripple_radius + ) + private val iconButtonDrawableInsetsBase = DrawableInsets( + t = iconButtondrawableBaseInset, b = iconButtondrawableBaseInset, l = iconButtondrawableBaseInset, - r = iconButtondrawableBaseInset) - private val iconButtonDrawableInsetsLeft = DrawableInsets(t = iconButtondrawableBaseInset, - b = iconButtondrawableBaseInset, l = iconButtondrawableShiftInset, r = 0) - private val iconButtonDrawableInsetsRight = DrawableInsets(t = iconButtondrawableBaseInset, - b = iconButtondrawableBaseInset, l = 0, r = iconButtondrawableShiftInset) + r = iconButtondrawableBaseInset + ) + private val iconButtonDrawableInsetsLeft = DrawableInsets( + t = iconButtondrawableBaseInset, + b = iconButtondrawableBaseInset, l = iconButtondrawableShiftInset, r = 0 + ) + private val iconButtonDrawableInsetsRight = DrawableInsets( + t = iconButtondrawableBaseInset, + b = iconButtondrawableBaseInset, l = 0, r = iconButtondrawableShiftInset + ) // App Info Pill. private val appInfoPill = rootView.requireViewById<View>(R.id.app_info_pill) private val collapseMenuButton = appInfoPill.requireViewById<HandleMenuImageButton>( - R.id.collapse_menu_button) + R.id.collapse_menu_button + ) + @VisibleForTesting val appIconView = appInfoPill.requireViewById<ImageView>(R.id.application_icon) + @VisibleForTesting val appNameView = appInfoPill.requireViewById<MarqueedTextView>(R.id.application_name) // Windowing Pill. private val windowingPill = rootView.requireViewById<View>(R.id.windowing_pill) private val fullscreenBtn = windowingPill.requireViewById<ImageButton>( - R.id.fullscreen_button) + R.id.fullscreen_button + ) private val splitscreenBtn = windowingPill.requireViewById<ImageButton>( - R.id.split_screen_button) + R.id.split_screen_button + ) private val floatingBtn = windowingPill.requireViewById<ImageButton>(R.id.floating_button) private val floatingBtnSpace = windowingPill.requireViewById<Space>( - R.id.floating_button_space) + R.id.floating_button_space + ) private val desktopBtn = windowingPill.requireViewById<ImageButton>(R.id.desktop_button) private val desktopBtnSpace = windowingPill.requireViewById<Space>( - R.id.desktop_button_space) + R.id.desktop_button_space + ) // More Actions Pill. private val moreActionsPill = rootView.requireViewById<View>(R.id.more_actions_pill) private val screenshotBtn = moreActionsPill.requireViewById<HandleMenuActionButton>( - R.id.screenshot_button) + R.id.screenshot_button + ) private val newWindowBtn = moreActionsPill.requireViewById<HandleMenuActionButton>( - R.id.new_window_button) + R.id.new_window_button + ) private val manageWindowBtn = moreActionsPill .requireViewById<HandleMenuActionButton>(R.id.manage_windows_button) private val changeAspectRatioBtn = moreActionsPill @@ -517,11 +547,14 @@ class HandleMenu( // Open in Browser/App Pill. private val openInAppOrBrowserPill = rootView.requireViewById<View>( - R.id.open_in_app_or_browser_pill) + R.id.open_in_app_or_browser_pill + ) private val openInAppOrBrowserBtn = openInAppOrBrowserPill.requireViewById<View>( - R.id.open_in_app_or_browser_button) + R.id.open_in_app_or_browser_button + ) private val openByDefaultBtn = openInAppOrBrowserPill.requireViewById<ImageButton>( - R.id.open_by_default_button) + R.id.open_by_default_button + ) private val decorThemeUtil = DecorThemeUtil(context) private val animator = HandleMenuAnimator(rootView, menuWidth, captionHeight.toFloat()) @@ -730,9 +763,9 @@ class HandleMenu( desktopBtn.imageTintList = style.windowingButtonColor val startInsets = if (context.isRtl) iconButtonDrawableInsetsRight - else iconButtonDrawableInsetsLeft + else iconButtonDrawableInsetsLeft val endInsets = if (context.isRtl) iconButtonDrawableInsetsLeft - else iconButtonDrawableInsetsRight + else iconButtonDrawableInsetsRight fullscreenBtn.apply { background = createBackgroundDrawable( @@ -804,9 +837,11 @@ class HandleMenu( getString(R.string.open_in_browser_text) } + val buttonRoot = openInAppOrBrowserBtn.requireViewById<LinearLayout>(R.id.action_button) val label = openInAppOrBrowserBtn.requireViewById<MarqueedTextView>(R.id.label) val image = openInAppOrBrowserBtn.requireViewById<ImageView>(R.id.image) openInAppOrBrowserBtn.contentDescription = btnText + buttonRoot.contentDescription = btnText label.apply { text = btnText setTextColor(style.textColor) @@ -837,7 +872,7 @@ class HandleMenu( */ fun shouldShowChangeAspectRatioButton(taskInfo: RunningTaskInfo): Boolean = taskInfo.appCompatTaskInfo.eligibleForUserAspectRatioButton() && - taskInfo.windowingMode == WindowConfiguration.WINDOWING_MODE_FULLSCREEN + taskInfo.windowingMode == WindowConfiguration.WINDOWING_MODE_FULLSCREEN } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/HandleMenuActionButton.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/HandleMenuActionButton.kt index 4b2e473d6ec2..a723a7a4ac20 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/HandleMenuActionButton.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/HandleMenuActionButton.kt @@ -23,9 +23,7 @@ import android.util.AttributeSet import android.view.LayoutInflater import android.widget.ImageView import android.widget.LinearLayout -import android.widget.TextView import androidx.core.content.withStyledAttributes -import androidx.core.view.isGone import com.android.wm.shell.R /** @@ -54,6 +52,7 @@ class HandleMenuActionButton @JvmOverloads constructor( context.withStyledAttributes(attrs, R.styleable.HandleMenuActionButton) { textView.text = getString(R.styleable.HandleMenuActionButton_android_text) + rootElement.contentDescription = getString(R.styleable.HandleMenuActionButton_android_text) textView.setTextColor(getColor(R.styleable.HandleMenuActionButton_android_textColor, 0)) iconView.setImageResource(getResourceId( R.styleable.HandleMenuActionButton_android_src, 0)) diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/BubbleTransitionsTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/BubbleTransitionsTest.java index b136bed3c942..2de77b2132cf 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/BubbleTransitionsTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/BubbleTransitionsTest.java @@ -30,6 +30,7 @@ import static org.mockito.ArgumentMatchers.anyFloat; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isNull; +import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -37,6 +38,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.app.ActivityManager; +import android.graphics.Point; import android.graphics.PointF; import android.graphics.Rect; import android.os.IBinder; @@ -47,7 +49,9 @@ import android.window.TransitionInfo; import android.window.WindowContainerToken; import android.window.WindowContainerTransaction; +import androidx.core.animation.AnimatorTestRule; import androidx.test.filters.SmallTest; +import androidx.test.platform.app.InstrumentationRegistry; import com.android.launcher3.icons.BubbleIconFactory; import com.android.wm.shell.ShellTaskOrganizer; @@ -65,6 +69,7 @@ import com.android.wm.shell.taskview.TaskViewTransitions; import com.android.wm.shell.transition.Transitions; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mock; @@ -76,6 +81,8 @@ import org.mockito.MockitoAnnotations; @SmallTest public class BubbleTransitionsTest extends ShellTestCase { + @Rule public final AnimatorTestRule mAnimatorTestRule = new AnimatorTestRule(); + private static final int FULLSCREEN_TASK_WIDTH = 200; private static final int FULLSCREEN_TASK_HEIGHT = 100; @@ -292,24 +299,37 @@ public class BubbleTransitionsTest extends ShellTestCase { @Test public void convertDraggedBubbleToFullscreen() { ActivityManager.RunningTaskInfo taskInfo = setupBubble(); + SurfaceControl.Transaction animT = mock(SurfaceControl.Transaction.class); + BubbleTransitions.TransactionProvider transactionProvider = () -> animT; final DraggedBubbleIconToFullscreen bt = - (DraggedBubbleIconToFullscreen) mBubbleTransitions - .startDraggedBubbleIconToFullscreen(mBubble); + mBubbleTransitions.new DraggedBubbleIconToFullscreen( + mBubble, new Point(100, 50), transactionProvider); verify(mTransitions).startTransition(anyInt(), any(), eq(bt)); + SurfaceControl taskLeash = new SurfaceControl.Builder().setName("taskLeash").build(); final TransitionInfo info = new TransitionInfo(TRANSIT_TO_FRONT, 0); - final TransitionInfo.Change chg = new TransitionInfo.Change(taskInfo.token, - mock(SurfaceControl.class)); + final TransitionInfo.Change chg = new TransitionInfo.Change(taskInfo.token, taskLeash); chg.setMode(TRANSIT_TO_FRONT); chg.setTaskInfo(taskInfo); info.addChange(chg); info.addRoot(new TransitionInfo.Root(0, mock(SurfaceControl.class), 0, 0)); SurfaceControl.Transaction startT = mock(SurfaceControl.Transaction.class); SurfaceControl.Transaction finishT = mock(SurfaceControl.Transaction.class); - Transitions.TransitionFinishCallback finishCb = wct -> {}; - bt.startAnimation(bt.mTransition, info, startT, finishT, finishCb); + boolean[] transitionFinished = {false}; + Transitions.TransitionFinishCallback finishCb = wct -> transitionFinished[0] = true; + InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> { + bt.startAnimation(bt.mTransition, info, startT, finishT, finishCb); + mAnimatorTestRule.advanceTimeBy(250); + }); + verify(startT).setScale(taskLeash, 0, 0); + verify(startT).setPosition(taskLeash, 100, 50); verify(startT).apply(); + verify(animT).setScale(taskLeash, 1, 1); + verify(animT).setPosition(taskLeash, 0, 0); + verify(animT, atLeastOnce()).apply(); + verify(animT).close(); assertFalse(mTaskViewTransitions.hasPending()); + assertTrue(transitionFinished[0]); } @Test diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopDisplayModeControllerTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopDisplayModeControllerTest.kt index 105941079095..da6a67c679ff 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopDisplayModeControllerTest.kt +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopDisplayModeControllerTest.kt @@ -37,7 +37,6 @@ import android.view.WindowManager.TRANSIT_CHANGE import android.window.DisplayAreaInfo import android.window.WindowContainerTransaction import androidx.test.filters.SmallTest -import com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn import com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession import com.android.dx.mockito.inline.extended.ExtendedMockito.never import com.android.dx.mockito.inline.extended.StaticMockitoSession @@ -102,6 +101,7 @@ class DesktopDisplayModeControllerTest( TestRunningTaskInfoBuilder().setWindowingMode(WINDOWING_MODE_FULLSCREEN).build() private val defaultTDA = DisplayAreaInfo(MockToken().token(), DEFAULT_DISPLAY, 0) private val wallpaperToken = MockToken().token() + private val defaultDisplay = mock<Display>() private val externalDisplay = mock<Display>() private lateinit var extendedDisplaySettingsRestoreSession: @@ -118,7 +118,7 @@ class DesktopDisplayModeControllerTest( mockitoSession = mockitoSession() .strictness(Strictness.LENIENT) - .spyStatic(DesktopModeStatus::class.java) + .mockStatic(DesktopModeStatus::class.java) .startMocking() extendedDisplaySettingsRestoreSession = ExtendedDisplaySettingsRestoreSession(context.contentResolver) @@ -141,8 +141,15 @@ class DesktopDisplayModeControllerTest( runningTasks.add(fullscreenTask) whenever(shellTaskOrganizer.getRunningTasks(anyInt())).thenReturn(ArrayList(runningTasks)) whenever(desktopWallpaperActivityTokenProvider.getToken()).thenReturn(wallpaperToken) + whenever(displayController.getDisplay(DEFAULT_DISPLAY)).thenReturn(defaultDisplay) whenever(displayController.getDisplay(EXTERNAL_DISPLAY_ID)).thenReturn(externalDisplay) setTabletModeStatus(SwitchState.UNKNOWN) + whenever( + DesktopModeStatus.isDesktopModeSupportedOnDisplay( + context, + defaultDisplay + ) + ).thenReturn(true) } @After @@ -210,6 +217,12 @@ class DesktopDisplayModeControllerTest( } setTabletModeStatus(tabletModeStatus) setExtendedMode(param.extendedDisplayEnabled) + whenever( + DesktopModeStatus.isDesktopModeSupportedOnDisplay( + context, + defaultDisplay + ) + ).thenReturn(param.isDefaultDisplayDesktopEligible) assertThat(controller.getTargetWindowingModeForDefaultDisplay()) .isEqualTo(param.expectedWindowingMode) @@ -228,6 +241,12 @@ class DesktopDisplayModeControllerTest( } setTabletModeStatus(param.tabletModeStatus) setExtendedMode(param.extendedDisplayEnabled) + whenever( + DesktopModeStatus.isDesktopModeSupportedOnDisplay( + context, + defaultDisplay + ) + ).thenReturn(param.isDefaultDisplayDesktopEligible) assertThat(controller.getTargetWindowingModeForDefaultDisplay()) .isEqualTo(param.expectedWindowingMode) @@ -287,9 +306,12 @@ class DesktopDisplayModeControllerTest( private fun setExtendedMode(enabled: Boolean) { if (DisplayFlags.enableDisplayContentModeManagement()) { - doReturn(enabled).`when` { - DesktopModeStatus.isDesktopModeSupportedOnDisplay(context, externalDisplay) - } + whenever( + DesktopModeStatus.isDesktopModeSupportedOnDisplay( + context, + externalDisplay + ) + ).thenReturn(enabled) } else { Settings.Global.putInt( context.contentResolver, @@ -334,54 +356,119 @@ class DesktopDisplayModeControllerTest( val defaultWindowingMode: Int, val hasExternalDisplay: Boolean, val extendedDisplayEnabled: Boolean, + val isDefaultDisplayDesktopEligible: Boolean, val expectedWindowingMode: Int, ) { - FREEFORM_EXTERNAL_EXTENDED( + FREEFORM_EXTERNAL_EXTENDED_NO_PROJECTED( defaultWindowingMode = WINDOWING_MODE_FREEFORM, hasExternalDisplay = true, extendedDisplayEnabled = true, + isDefaultDisplayDesktopEligible = true, expectedWindowingMode = WINDOWING_MODE_FREEFORM, ), - FULLSCREEN_EXTERNAL_EXTENDED( + FULLSCREEN_EXTERNAL_EXTENDED_NO_PROJECTED( defaultWindowingMode = WINDOWING_MODE_FULLSCREEN, hasExternalDisplay = true, extendedDisplayEnabled = true, + isDefaultDisplayDesktopEligible = true, expectedWindowingMode = WINDOWING_MODE_FREEFORM, ), - FREEFORM_NO_EXTERNAL_EXTENDED( + FREEFORM_NO_EXTERNAL_EXTENDED_NO_PROJECTED( defaultWindowingMode = WINDOWING_MODE_FREEFORM, hasExternalDisplay = false, extendedDisplayEnabled = true, + isDefaultDisplayDesktopEligible = true, expectedWindowingMode = WINDOWING_MODE_FREEFORM, ), - FULLSCREEN_NO_EXTERNAL_EXTENDED( + FULLSCREEN_NO_EXTERNAL_EXTENDED_NO_PROJECTED( defaultWindowingMode = WINDOWING_MODE_FULLSCREEN, hasExternalDisplay = false, extendedDisplayEnabled = true, + isDefaultDisplayDesktopEligible = true, expectedWindowingMode = WINDOWING_MODE_FULLSCREEN, ), - FREEFORM_EXTERNAL_MIRROR( + FREEFORM_EXTERNAL_MIRROR_NO_PROJECTED( defaultWindowingMode = WINDOWING_MODE_FREEFORM, hasExternalDisplay = true, extendedDisplayEnabled = false, + isDefaultDisplayDesktopEligible = true, expectedWindowingMode = WINDOWING_MODE_FREEFORM, ), - FULLSCREEN_EXTERNAL_MIRROR( + FULLSCREEN_EXTERNAL_MIRROR_NO_PROJECTED( defaultWindowingMode = WINDOWING_MODE_FULLSCREEN, hasExternalDisplay = true, extendedDisplayEnabled = false, + isDefaultDisplayDesktopEligible = true, expectedWindowingMode = WINDOWING_MODE_FULLSCREEN, ), - FREEFORM_NO_EXTERNAL_MIRROR( + FREEFORM_NO_EXTERNAL_MIRROR_NO_PROJECTED( defaultWindowingMode = WINDOWING_MODE_FREEFORM, hasExternalDisplay = false, extendedDisplayEnabled = false, + isDefaultDisplayDesktopEligible = true, expectedWindowingMode = WINDOWING_MODE_FREEFORM, ), - FULLSCREEN_NO_EXTERNAL_MIRROR( + FULLSCREEN_NO_EXTERNAL_MIRROR_NO_PROJECTED( defaultWindowingMode = WINDOWING_MODE_FULLSCREEN, hasExternalDisplay = false, extendedDisplayEnabled = false, + isDefaultDisplayDesktopEligible = true, + expectedWindowingMode = WINDOWING_MODE_FULLSCREEN, + ), + FREEFORM_EXTERNAL_EXTENDED_PROJECTED( + defaultWindowingMode = WINDOWING_MODE_FREEFORM, + hasExternalDisplay = true, + extendedDisplayEnabled = true, + isDefaultDisplayDesktopEligible = false, + expectedWindowingMode = WINDOWING_MODE_FREEFORM, + ), + FULLSCREEN_EXTERNAL_EXTENDED_PROJECTED( + defaultWindowingMode = WINDOWING_MODE_FULLSCREEN, + hasExternalDisplay = true, + extendedDisplayEnabled = true, + isDefaultDisplayDesktopEligible = false, + expectedWindowingMode = WINDOWING_MODE_FULLSCREEN, + ), + FREEFORM_NO_EXTERNAL_EXTENDED_PROJECTED( + defaultWindowingMode = WINDOWING_MODE_FREEFORM, + hasExternalDisplay = false, + extendedDisplayEnabled = true, + isDefaultDisplayDesktopEligible = false, + expectedWindowingMode = WINDOWING_MODE_FREEFORM, + ), + FULLSCREEN_NO_EXTERNAL_EXTENDED_PROJECTED( + defaultWindowingMode = WINDOWING_MODE_FULLSCREEN, + hasExternalDisplay = false, + extendedDisplayEnabled = true, + isDefaultDisplayDesktopEligible = false, + expectedWindowingMode = WINDOWING_MODE_FULLSCREEN, + ), + FREEFORM_EXTERNAL_MIRROR_PROJECTED( + defaultWindowingMode = WINDOWING_MODE_FREEFORM, + hasExternalDisplay = true, + extendedDisplayEnabled = false, + isDefaultDisplayDesktopEligible = false, + expectedWindowingMode = WINDOWING_MODE_FREEFORM, + ), + FULLSCREEN_EXTERNAL_MIRROR_PROJECTED( + defaultWindowingMode = WINDOWING_MODE_FULLSCREEN, + hasExternalDisplay = true, + extendedDisplayEnabled = false, + isDefaultDisplayDesktopEligible = false, + expectedWindowingMode = WINDOWING_MODE_FULLSCREEN, + ), + FREEFORM_NO_EXTERNAL_MIRROR_PROJECTED( + defaultWindowingMode = WINDOWING_MODE_FREEFORM, + hasExternalDisplay = false, + extendedDisplayEnabled = false, + isDefaultDisplayDesktopEligible = false, + expectedWindowingMode = WINDOWING_MODE_FREEFORM, + ), + FULLSCREEN_NO_EXTERNAL_MIRROR_PROJECTED( + defaultWindowingMode = WINDOWING_MODE_FULLSCREEN, + hasExternalDisplay = false, + extendedDisplayEnabled = false, + isDefaultDisplayDesktopEligible = false, expectedWindowingMode = WINDOWING_MODE_FULLSCREEN, ), } @@ -390,78 +477,175 @@ class DesktopDisplayModeControllerTest( val hasExternalDisplay: Boolean, val extendedDisplayEnabled: Boolean, val tabletModeStatus: SwitchState, + val isDefaultDisplayDesktopEligible: Boolean, val expectedWindowingMode: Int, ) { - EXTERNAL_EXTENDED_TABLET( + EXTERNAL_EXTENDED_TABLET_NO_PROJECTED( hasExternalDisplay = true, extendedDisplayEnabled = true, tabletModeStatus = SwitchState.ON, + isDefaultDisplayDesktopEligible = true, expectedWindowingMode = WINDOWING_MODE_FREEFORM, ), - NO_EXTERNAL_EXTENDED_TABLET( + NO_EXTERNAL_EXTENDED_TABLET_NO_PROJECTED( hasExternalDisplay = false, extendedDisplayEnabled = true, tabletModeStatus = SwitchState.ON, + isDefaultDisplayDesktopEligible = true, expectedWindowingMode = WINDOWING_MODE_FULLSCREEN, ), - EXTERNAL_MIRROR_TABLET( + EXTERNAL_MIRROR_TABLET_NO_PROJECTED( hasExternalDisplay = true, extendedDisplayEnabled = false, tabletModeStatus = SwitchState.ON, + isDefaultDisplayDesktopEligible = true, expectedWindowingMode = WINDOWING_MODE_FULLSCREEN, ), - NO_EXTERNAL_MIRROR_TABLET( + NO_EXTERNAL_MIRROR_TABLET_NO_PROJECTED( hasExternalDisplay = false, extendedDisplayEnabled = false, tabletModeStatus = SwitchState.ON, + isDefaultDisplayDesktopEligible = true, expectedWindowingMode = WINDOWING_MODE_FULLSCREEN, ), - EXTERNAL_EXTENDED_CLAMSHELL( + EXTERNAL_EXTENDED_CLAMSHELL_NO_PROJECTED( hasExternalDisplay = true, extendedDisplayEnabled = true, tabletModeStatus = SwitchState.OFF, + isDefaultDisplayDesktopEligible = true, expectedWindowingMode = WINDOWING_MODE_FREEFORM, ), - NO_EXTERNAL_EXTENDED_CLAMSHELL( + NO_EXTERNAL_EXTENDED_CLAMSHELL_NO_PROJECTED( hasExternalDisplay = false, extendedDisplayEnabled = true, tabletModeStatus = SwitchState.OFF, + isDefaultDisplayDesktopEligible = true, expectedWindowingMode = WINDOWING_MODE_FREEFORM, ), - EXTERNAL_MIRROR_CLAMSHELL( + EXTERNAL_MIRROR_CLAMSHELL_NO_PROJECTED( hasExternalDisplay = true, extendedDisplayEnabled = false, tabletModeStatus = SwitchState.OFF, + isDefaultDisplayDesktopEligible = true, expectedWindowingMode = WINDOWING_MODE_FREEFORM, ), - NO_EXTERNAL_MIRROR_CLAMSHELL( + NO_EXTERNAL_MIRROR_CLAMSHELL_NO_PROJECTED( hasExternalDisplay = false, extendedDisplayEnabled = false, tabletModeStatus = SwitchState.OFF, + isDefaultDisplayDesktopEligible = true, expectedWindowingMode = WINDOWING_MODE_FREEFORM, ), - EXTERNAL_EXTENDED_UNKNOWN( + EXTERNAL_EXTENDED_UNKNOWN_NO_PROJECTED( hasExternalDisplay = true, extendedDisplayEnabled = true, tabletModeStatus = SwitchState.UNKNOWN, + isDefaultDisplayDesktopEligible = true, expectedWindowingMode = WINDOWING_MODE_FREEFORM, ), - NO_EXTERNAL_EXTENDED_UNKNOWN( + NO_EXTERNAL_EXTENDED_UNKNOWN_NO_PROJECTED( + hasExternalDisplay = false, + extendedDisplayEnabled = true, + tabletModeStatus = SwitchState.UNKNOWN, + isDefaultDisplayDesktopEligible = true, + expectedWindowingMode = WINDOWING_MODE_FULLSCREEN, + ), + EXTERNAL_MIRROR_UNKNOWN_NO_PROJECTED( + hasExternalDisplay = true, + extendedDisplayEnabled = false, + tabletModeStatus = SwitchState.UNKNOWN, + isDefaultDisplayDesktopEligible = true, + expectedWindowingMode = WINDOWING_MODE_FULLSCREEN, + ), + NO_EXTERNAL_MIRROR_UNKNOWN_NO_PROJECTED( + hasExternalDisplay = false, + extendedDisplayEnabled = false, + tabletModeStatus = SwitchState.UNKNOWN, + isDefaultDisplayDesktopEligible = true, + expectedWindowingMode = WINDOWING_MODE_FULLSCREEN, + ), + EXTERNAL_EXTENDED_TABLET_PROJECTED( + hasExternalDisplay = true, + extendedDisplayEnabled = true, + tabletModeStatus = SwitchState.ON, + isDefaultDisplayDesktopEligible = false, + expectedWindowingMode = WINDOWING_MODE_FULLSCREEN, + ), + NO_EXTERNAL_EXTENDED_TABLET_PROJECTED( + hasExternalDisplay = false, + extendedDisplayEnabled = true, + tabletModeStatus = SwitchState.ON, + isDefaultDisplayDesktopEligible = false, + expectedWindowingMode = WINDOWING_MODE_FULLSCREEN, + ), + EXTERNAL_MIRROR_TABLET_PROJECTED( + hasExternalDisplay = true, + extendedDisplayEnabled = false, + tabletModeStatus = SwitchState.ON, + isDefaultDisplayDesktopEligible = false, + expectedWindowingMode = WINDOWING_MODE_FULLSCREEN, + ), + NO_EXTERNAL_MIRROR_TABLET_PROJECTED( + hasExternalDisplay = false, + extendedDisplayEnabled = false, + tabletModeStatus = SwitchState.ON, + isDefaultDisplayDesktopEligible = false, + expectedWindowingMode = WINDOWING_MODE_FULLSCREEN, + ), + EXTERNAL_EXTENDED_CLAMSHELL_PROJECTED( + hasExternalDisplay = true, + extendedDisplayEnabled = true, + tabletModeStatus = SwitchState.OFF, + isDefaultDisplayDesktopEligible = false, + expectedWindowingMode = WINDOWING_MODE_FULLSCREEN, + ), + NO_EXTERNAL_EXTENDED_CLAMSHELL_PROJECTED( + hasExternalDisplay = false, + extendedDisplayEnabled = true, + tabletModeStatus = SwitchState.OFF, + isDefaultDisplayDesktopEligible = false, + expectedWindowingMode = WINDOWING_MODE_FULLSCREEN, + ), + EXTERNAL_MIRROR_CLAMSHELL_PROJECTED( + hasExternalDisplay = true, + extendedDisplayEnabled = false, + tabletModeStatus = SwitchState.OFF, + isDefaultDisplayDesktopEligible = false, + expectedWindowingMode = WINDOWING_MODE_FULLSCREEN, + ), + NO_EXTERNAL_MIRROR_CLAMSHELL_PROJECTED( + hasExternalDisplay = false, + extendedDisplayEnabled = false, + tabletModeStatus = SwitchState.OFF, + isDefaultDisplayDesktopEligible = false, + expectedWindowingMode = WINDOWING_MODE_FULLSCREEN, + ), + EXTERNAL_EXTENDED_UNKNOWN_PROJECTED( + hasExternalDisplay = true, + extendedDisplayEnabled = true, + tabletModeStatus = SwitchState.UNKNOWN, + isDefaultDisplayDesktopEligible = false, + expectedWindowingMode = WINDOWING_MODE_FULLSCREEN, + ), + NO_EXTERNAL_EXTENDED_UNKNOWN_PROJECTED( hasExternalDisplay = false, extendedDisplayEnabled = true, tabletModeStatus = SwitchState.UNKNOWN, + isDefaultDisplayDesktopEligible = false, expectedWindowingMode = WINDOWING_MODE_FULLSCREEN, ), - EXTERNAL_MIRROR_UNKNOWN( + EXTERNAL_MIRROR_UNKNOWN_PROJECTED( hasExternalDisplay = true, extendedDisplayEnabled = false, tabletModeStatus = SwitchState.UNKNOWN, + isDefaultDisplayDesktopEligible = false, expectedWindowingMode = WINDOWING_MODE_FULLSCREEN, ), - NO_EXTERNAL_MIRROR_UNKNOWN( + NO_EXTERNAL_MIRROR_UNKNOWN_PROJECTED( hasExternalDisplay = false, extendedDisplayEnabled = false, tabletModeStatus = SwitchState.UNKNOWN, + isDefaultDisplayDesktopEligible = false, expectedWindowingMode = WINDOWING_MODE_FULLSCREEN, ), } diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt index 7efcd4fc3c8f..01ea986d3260 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt @@ -3540,6 +3540,19 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() } @Test + @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_PIP) + fun onPipTaskMinimize_autoEnterEnabled_sendsTaskbarRoundingUpdate() { + val task = setUpPipTask(autoEnterEnabled = true) + val handler = mock(TransitionHandler::class.java) + whenever(transitions.dispatchRequest(any(), any(), anyOrNull())) + .thenReturn(android.util.Pair(handler, WindowContainerTransaction())) + + controller.minimizeTask(task, MinimizeReason.MINIMIZE_BUTTON) + + verify(taskbarDesktopTaskListener).onTaskbarCornerRoundingUpdate(anyBoolean()) + } + + @Test @EnableFlags( Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_FOR_SYSTEM_USER, Flags.FLAG_ENABLE_DESKTOP_WINDOWING_PIP, @@ -3841,6 +3854,24 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() } @Test + fun onDesktopWindowMinimize_sendsTaskbarRoundingUpdate() { + val task = setUpFreeformTask(displayId = DEFAULT_DISPLAY) + val transition = Binder() + whenever( + freeformTaskTransitionStarter.startMinimizedModeTransition( + any(), + anyInt(), + anyBoolean(), + ) + ) + .thenReturn(transition) + + controller.minimizeTask(task, MinimizeReason.MINIMIZE_BUTTON) + + verify(taskbarDesktopTaskListener).onTaskbarCornerRoundingUpdate(anyBoolean()) + } + + @Test @EnableFlags(Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND) fun handleRequest_fullscreenTask_switchToDesktop_movesTaskToDesk() { taskRepository.addDesk(displayId = DEFAULT_DISPLAY, deskId = 5) diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/StageCoordinatorTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/StageCoordinatorTests.java index 5dff21860ef4..077b35583e04 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/StageCoordinatorTests.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/StageCoordinatorTests.java @@ -571,7 +571,8 @@ public class StageCoordinatorTests extends ShellTestCase { } @Test - @DisableFlags(Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND) + @DisableFlags({Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND, + Flags.FLAG_ENABLE_INPUT_LAYER_TRANSITION_FIX}) public void testRequestEnterSplit_didNotEnterSplitSelect_doesNotApplyTransaction() { final WindowContainerTransaction wct = new WindowContainerTransaction(); mStageCoordinator.registerSplitSelectListener( @@ -585,7 +586,8 @@ public class StageCoordinatorTests extends ShellTestCase { } @Test - @DisableFlags(Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND) + @DisableFlags({Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND, + Flags.FLAG_ENABLE_INPUT_LAYER_TRANSITION_FIX}) public void testRequestEnterSplit_enteredSplitSelect_appliesTransaction() { final WindowContainerTransaction wct = new WindowContainerTransaction(); mStageCoordinator.registerSplitSelectListener( diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DragResizeInputListenerTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DragResizeInputListenerTest.kt index 7341e098add5..360099777bde 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DragResizeInputListenerTest.kt +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DragResizeInputListenerTest.kt @@ -40,11 +40,13 @@ import com.android.wm.shell.windowdecor.DragResizeInputListener.TaskResizeInputE import com.google.common.truth.Truth.assertThat import java.util.function.Consumer import java.util.function.Supplier +import org.junit.After import org.junit.Test import org.junit.runner.RunWith import org.mockito.ArgumentMatchers.any import org.mockito.ArgumentMatchers.anyInt import org.mockito.kotlin.anyOrNull +import org.mockito.kotlin.argThat import org.mockito.kotlin.mock import org.mockito.kotlin.never import org.mockito.kotlin.verify @@ -63,6 +65,15 @@ class DragResizeInputListenerTest : ShellTestCase() { private val testBgExecutor = TestShellExecutor() private val mockWindowSession = mock<IWindowSession>() private val mockInputEventReceiver = mock<TaskResizeInputEventReceiver>() + private val inputChannel = mock<InputChannel>() + private val sinkInputChannel = mock<InputChannel>() + private val decorationSurface = SurfaceControl.Builder().setName("decoration surface").build() + private val createdSurfaces = ArrayList<SurfaceControl>() + + @After + fun tearDown() { + decorationSurface.release() + } @Test fun testGrantInputChannelOffMainThread() { @@ -73,6 +84,35 @@ class DragResizeInputListenerTest : ShellTestCase() { } @Test + fun testGrantInputChannelAfterDecorSurfaceReleased() { + // Keep tracking the underlying surface that the decorationSurface points to. + val forVerification = SurfaceControl(decorationSurface, "forVerification") + try { + create() + decorationSurface.release() + testBgExecutor.flushAll() + + verify(mockWindowSession) + .grantInputChannel( + anyInt(), + argThat<SurfaceControl> { isValid && isSameSurface(forVerification) }, + any(), + anyOrNull(), + anyInt(), + anyInt(), + anyInt(), + anyInt(), + anyOrNull(), + any(), + any(), + any(), + ) + } finally { + forVerification.release() + } + } + + @Test fun testInitializationCallback_waitsForBgSetup() { val inputListener = create() @@ -143,6 +183,40 @@ class DragResizeInputListenerTest : ShellTestCase() { verify(mockWindowSession).remove(inputListener.mSinkClientToken) } + @Test + fun testClose_afterBgSetup_disposesOfInputChannels() { + val inputListener = create() + testBgExecutor.flushAll() + inputListener.close() + testMainExecutor.flushAll() + verify(inputChannel).dispose() + verify(sinkInputChannel).dispose() + } + + @Test + fun testClose_beforeBgSetup_releaseSurfaces() { + val inputListener = create() + inputListener.close() + testBgExecutor.flushAll() + testMainExecutor.flushAll() + + assertThat(createdSurfaces).hasSize(1) + assertThat(createdSurfaces[0].isValid).isFalse() + } + + @Test + fun testClose_afterBgSetup_releaseSurfaces() { + val inputListener = create() + testBgExecutor.flushAll() + inputListener.close() + testMainExecutor.flushAll() + testBgExecutor.flushAll() + + assertThat(createdSurfaces).hasSize(2) + assertThat(createdSurfaces[0].isValid).isFalse() + assertThat(createdSurfaces[1].isValid).isFalse() + } + private fun verifyNoInputChannelGrantRequests() { verify(mockWindowSession, never()) .grantInputChannel( @@ -172,12 +246,26 @@ class DragResizeInputListenerTest : ShellTestCase() { TestHandler(Looper.getMainLooper()), mock<Choreographer>(), Display.DEFAULT_DISPLAY, - mock<SurfaceControl>(), + decorationSurface, mock<DragPositioningCallback>(), - { SurfaceControl.Builder() }, - { StubTransaction() }, + { + object : SurfaceControl.Builder() { + override fun build(): SurfaceControl { + return super.build().also { createdSurfaces.add(it) } + } + } + }, + { + object : StubTransaction() { + override fun remove(sc: SurfaceControl): SurfaceControl.Transaction { + return super.remove(sc).also { sc.release() } + } + } + }, mock<DisplayController>(), mock<DesktopModeEventLogger>(), + inputChannel, + sinkInputChannel, ) private class TestInitializationCallback : Runnable { diff --git a/libs/androidfw/Asset.cpp b/libs/androidfw/Asset.cpp index 5a4cff0c319e..4e820b6857a1 100644 --- a/libs/androidfw/Asset.cpp +++ b/libs/androidfw/Asset.cpp @@ -453,7 +453,7 @@ status_t _FileAsset::openChunk(incfs::IncFsFileMap&& dataMap, base::unique_fd fd { assert(mFp == NULL); // no reopen assert(!mMap.has_value()); - assert(dataMap != NULL); + assert(dataMap.data()); mMap = std::move(dataMap); mStart = -1; // not used @@ -798,7 +798,7 @@ status_t _CompressedAsset::openChunk(incfs::IncFsFileMap&& dataMap, size_t uncom { assert(mFd < 0); // no re-open assert(!mMap.has_value()); - assert(dataMap != NULL); + assert(dataMap.data()); mMap = std::move(dataMap); mStart = -1; // not used diff --git a/location/java/android/location/flags/location.aconfig b/location/java/android/location/flags/location.aconfig index f8eb41826c6f..f26e72fa79f1 100644 --- a/location/java/android/location/flags/location.aconfig +++ b/location/java/android/location/flags/location.aconfig @@ -167,6 +167,7 @@ flag { namespace: "location" description: "Flag for GNSS assistance interface" bug: "209078566" + is_exported: true } flag { @@ -186,3 +187,21 @@ flag { bug: "398254728" is_fixed_read_only: true } + +flag { + name: "limit_fused_gps" + namespace: "location" + description: "Limits when GPS can be used for fused location requests" + bug: "401885179" + metadata { + purpose: PURPOSE_BUGFIX + } +} + +flag { + name: "gnss_assistance_interface_jni" + namespace: "location" + description: "Flag for GNSS assistance interface JNI" + bug: "209078566" +} + diff --git a/packages/FusedLocation/src/com/android/location/fused/FusedLocationProvider.java b/packages/FusedLocation/src/com/android/location/fused/FusedLocationProvider.java index 8e52a00fe545..a0e008c9437f 100644 --- a/packages/FusedLocation/src/com/android/location/fused/FusedLocationProvider.java +++ b/packages/FusedLocation/src/com/android/location/fused/FusedLocationProvider.java @@ -19,6 +19,7 @@ package com.android.location.fused; import static android.content.Intent.ACTION_USER_SWITCHED; import static android.location.LocationManager.GPS_PROVIDER; import static android.location.LocationManager.NETWORK_PROVIDER; +import static android.location.LocationRequest.QUALITY_HIGH_ACCURACY; import static android.location.LocationRequest.QUALITY_LOW_POWER; import static android.location.provider.ProviderProperties.ACCURACY_FINE; import static android.location.provider.ProviderProperties.POWER_USAGE_LOW; @@ -34,6 +35,7 @@ import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.location.LocationRequest; +import android.location.flags.Flags; import android.location.provider.LocationProviderBase; import android.location.provider.ProviderProperties; import android.location.provider.ProviderRequest; @@ -61,6 +63,9 @@ public class FusedLocationProvider extends LocationProviderBase { .build(); private static final long MAX_LOCATION_COMPARISON_NS = 11 * 1000000000L; // 11 seconds + // Maximum request interval at which we will activate GPS (because GPS sometimes consumes + // excessive power with large intervals). + private static final long MAX_GPS_INTERVAL_MS = 5 * 1000; // 5 seconds private final Object mLock = new Object(); @@ -165,8 +170,13 @@ public class FusedLocationProvider extends LocationProviderBase { mNlpPresent = mLocationManager.hasProvider(NETWORK_PROVIDER); } + boolean requestAllowsGps = + Flags.limitFusedGps() + ? mRequest.getQuality() == QUALITY_HIGH_ACCURACY + && mRequest.getIntervalMillis() <= MAX_GPS_INTERVAL_MS + : !mNlpPresent || mRequest.getQuality() < QUALITY_LOW_POWER; long gpsInterval = - mGpsPresent && (!mNlpPresent || mRequest.getQuality() < QUALITY_LOW_POWER) + mGpsPresent && requestAllowsGps ? mRequest.getIntervalMillis() : INTERVAL_DISABLED; long networkInterval = mNlpPresent ? mRequest.getIntervalMillis() : INTERVAL_DISABLED; diff --git a/packages/PackageInstaller/TEST_MAPPING b/packages/PackageInstaller/TEST_MAPPING index 50331014f926..716845c5b985 100644 --- a/packages/PackageInstaller/TEST_MAPPING +++ b/packages/PackageInstaller/TEST_MAPPING @@ -23,6 +23,28 @@ ] }, { + "name": "CtsPackageInstallerCUJInstallationViaIntentForResultTestCases", + "options":[ + { + "exclude-annotation":"androidx.test.filters.FlakyTest" + }, + { + "exclude-annotation":"org.junit.Ignore" + } + ] + }, + { + "name": "CtsPackageInstallerCUJInstallationViaSessionTestCases", + "options":[ + { + "exclude-annotation":"androidx.test.filters.FlakyTest" + }, + { + "exclude-annotation":"org.junit.Ignore" + } + ] + }, + { "name": "CtsPackageInstallerCUJMultiUsersTestCases", "options":[ { @@ -120,6 +142,28 @@ ] }, { + "name": "CtsPackageInstallerCUJInstallationViaIntentForResultTestCases", + "options":[ + { + "exclude-annotation":"androidx.test.filters.FlakyTest" + }, + { + "exclude-annotation":"org.junit.Ignore" + } + ] + }, + { + "name": "CtsPackageInstallerCUJInstallationViaSessionTestCases", + "options":[ + { + "exclude-annotation":"androidx.test.filters.FlakyTest" + }, + { + "exclude-annotation":"org.junit.Ignore" + } + ] + }, + { "name": "CtsPackageInstallerCUJMultiUsersTestCases", "options":[ { diff --git a/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchBar.java b/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchBar.java index ddd9d2acdab3..9d4c5c2735fc 100644 --- a/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchBar.java +++ b/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchBar.java @@ -112,6 +112,22 @@ public class MainSwitchBar extends LinearLayout implements OnCheckedChangeListen if (mSwitch.getVisibility() == VISIBLE) { mSwitch.setOnCheckedChangeListener(this); } + + if (attrs != null) { + final TypedArray a = context.obtainStyledAttributes(attrs, + androidx.preference.R.styleable.Preference, 0 /*defStyleAttr*/, + 0 /*defStyleRes*/); + final CharSequence title = a.getText( + androidx.preference.R.styleable.Preference_android_title); + setTitle(title); + //TODO(b/369470034): update to next version + if (isExpressive && Build.VERSION.SDK_INT >= VERSION_CODES.VANILLA_ICE_CREAM) { + CharSequence summary = a.getText( + androidx.preference.R.styleable.Preference_android_summary); + setSummary(summary); + } + a.recycle(); + } } @Override diff --git a/packages/SettingsLib/SettingsTheme/res/values/styles_expressive.xml b/packages/SettingsLib/SettingsTheme/res/values/styles_expressive.xml index 686c1488fb62..112a69bb47ec 100644 --- a/packages/SettingsLib/SettingsTheme/res/values/styles_expressive.xml +++ b/packages/SettingsLib/SettingsTheme/res/values/styles_expressive.xml @@ -262,4 +262,30 @@ <item name="android:layout_width">wrap_content</item> <item name="android:layout_height">wrap_content</item> </style> + + <style name="SettingsLibEntityHeaderContent"> + <item name="android:layout_width">match_parent</item> + <item name="android:layout_height">wrap_content</item> + <item name="android:layout_centerHorizontal">true</item> + <item name="android:orientation">vertical</item> + <item name="android:gravity">center_horizontal</item> + </style> + + <style name="SettingsLibEntityHeaderIcon"> + <item name="android:layout_width">@dimen/settingslib_expressive_space_large3</item> + <item name="android:layout_height">@dimen/settingslib_expressive_space_large3</item> + <item name="android:scaleType">fitCenter</item> + <item name="android:antialias">true</item> + </style> + + <style name="SettingsLibEntityHeaderTitle"> + <item name="android:layout_width">wrap_content</item> + <item name="android:layout_height">wrap_content</item> + <item name="android:layout_marginTop">@dimen/settingslib_expressive_space_small1</item> + <item name="android:singleLine">false</item> + <item name="android:gravity">center</item> + <item name="android:ellipsize">marquee</item> + <item name="android:textDirection">locale</item> + <item name="android:textAppearance">@style/TextAppearance.SettingsLib.TitleLarge.Emphasized</item> + </style> </resources>
\ No newline at end of file diff --git a/packages/SettingsLib/SliderPreference/src/com/android/settingslib/widget/SliderPreference.java b/packages/SettingsLib/SliderPreference/src/com/android/settingslib/widget/SliderPreference.java index fe8e8b6f1d46..6d02c5d48715 100644 --- a/packages/SettingsLib/SliderPreference/src/com/android/settingslib/widget/SliderPreference.java +++ b/packages/SettingsLib/SliderPreference/src/com/android/settingslib/widget/SliderPreference.java @@ -16,6 +16,8 @@ package com.android.settingslib.widget; +import static android.view.HapticFeedbackConstants.CLOCK_TICK; + import android.content.Context; import android.content.res.ColorStateList; import android.content.res.Resources; @@ -46,6 +48,9 @@ import com.google.android.material.slider.Slider; */ public class SliderPreference extends Preference { private static final String TAG = "SliderPreference"; + public static final int HAPTIC_FEEDBACK_MODE_NONE = 0; + public static final int HAPTIC_FEEDBACK_MODE_ON_TICKS = 1; + public static final int HAPTIC_FEEDBACK_MODE_ON_ENDS = 2; private final int mTextStartId; private final int mTextEndId; @@ -71,6 +76,8 @@ public class SliderPreference extends Preference { private int mMin; private int mMax; private int mSliderIncrement; + private int mHapticFeedbackMode = HAPTIC_FEEDBACK_MODE_NONE; + private boolean mTickVisible = false; private boolean mAdjustable; private boolean mTrackingTouch; private CharSequence mSliderContentDescription; @@ -265,6 +272,7 @@ public class SliderPreference extends Preference { } if (mSliderIncrement != 0) { mSlider.setStepSize(mSliderIncrement); + mSlider.setTickVisible(mTickVisible); } else { mSliderIncrement = (int) (mSlider.getStepSize()); } @@ -442,6 +450,29 @@ public class SliderPreference extends Preference { } /** + * Sets the haptic feedback mode. HAPTIC_FEEDBACK_MODE_ON_TICKS means to perform haptic feedback + * as the {@link Slider} value is updated; HAPTIC_FEEDBACK_MODE_ON_ENDS means to perform haptic + * feedback as the {@link Slider} value is equal to the min/max value. + * + * @param hapticFeedbackMode The haptic feedback mode. + */ + public void setHapticFeedbackMode(int hapticFeedbackMode) { + mHapticFeedbackMode = hapticFeedbackMode; + } + + /** + * Sets whether the tick marks are visible. Only used when the slider is in discrete mode. + * + * @param tickVisible The visibility of tick marks. + */ + public void setTickVisible(boolean tickVisible) { + if (tickVisible != mTickVisible) { + mTickVisible = tickVisible; + notifyChanged(); + } + } + + /** * Gets whether the current {@link Slider} value is displayed to the user. * * @return Whether the current {@link Slider} value is displayed to the user @@ -519,7 +550,16 @@ public class SliderPreference extends Preference { if (sliderValue != mSliderValue) { if (callChangeListener(sliderValue)) { setValueInternal(sliderValue, false); - // TODO: mHapticFeedbackMode + switch (mHapticFeedbackMode) { + case HAPTIC_FEEDBACK_MODE_ON_TICKS: + slider.performHapticFeedback(CLOCK_TICK); + break; + case HAPTIC_FEEDBACK_MODE_ON_ENDS: + if (mSliderValue == mMax || mSliderValue == mMin) { + slider.performHapticFeedback(CLOCK_TICK); + } + break; + } } else { slider.setValue(mSliderValue); } diff --git a/packages/SettingsLib/res/values/strings.xml b/packages/SettingsLib/res/values/strings.xml index 03cb1ffbdef1..1297aa3ff7d5 100644 --- a/packages/SettingsLib/res/values/strings.xml +++ b/packages/SettingsLib/res/values/strings.xml @@ -1510,6 +1510,9 @@ <!-- Warning message to tell user is have problem during profile connect, it need to turn off device and back on. [CHAR_LIMIT=NONE] --> <string name="profile_connect_timeout_subtext">Problem connecting. Turn device off & back on</string> + <!-- Warning message when the bluetooth key is missing. [CHAR_LIMIT=NONE] --> + <string name="bluetooth_key_missing_subtext">Can’t connect</string> + <!-- Name of the 3.5mm audio device. [CHAR LIMIT=40] --> <string name="media_transfer_wired_device_name">Wired audio device</string> diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java index 5f88bcd8d65d..011b2fc15807 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java @@ -1495,6 +1495,11 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> int leftBattery = -1; int rightBattery = -1; + Integer keyMissingCount = BluetoothUtils.getKeyMissingCount(mDevice); + if (keyMissingCount != null && keyMissingCount > 0) { + return mContext.getString(R.string.bluetooth_key_missing_subtext); + } + if (isProfileConnectedFail() && isConnected()) { return mContext.getString(R.string.profile_connect_timeout_subtext); } diff --git a/packages/SettingsLib/src/com/android/settingslib/notification/data/repository/FakeZenModeRepository.kt b/packages/SettingsLib/src/com/android/settingslib/notification/data/repository/FakeZenModeRepository.kt index 58c7907f77de..086516b24047 100644 --- a/packages/SettingsLib/src/com/android/settingslib/notification/data/repository/FakeZenModeRepository.kt +++ b/packages/SettingsLib/src/com/android/settingslib/notification/data/repository/FakeZenModeRepository.kt @@ -114,14 +114,19 @@ class FakeZenModeRepository : ZenModeRepository { activeModesDurations.remove(id) } - // Update the active state while maintaining the mode's position in the list + /** Updates a [ZenMode]'s active state, preserving its position in the list. */ private fun updateModeActiveState(id: String, isActive: Boolean) { + updateMode(id) { TestModeBuilder(it).setActive(isActive).build() } + } + + /** Updates a [ZenMode], preserving its position in the list. */ + fun updateMode(id: String, update: (original: ZenMode) -> ZenMode) { val modes = mutableModesFlow.value.toMutableList() val index = modes.indexOfFirst { it.id == id } if (index < 0) { throw IllegalArgumentException("mode $id not found") } - modes[index] = TestModeBuilder(modes[index]).setActive(isActive).build() + modes[index] = update(modes[index]) mutableModesFlow.value = modes } } diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml index d929b0de391a..94aa955f0282 100644 --- a/packages/SettingsProvider/res/values/defaults.xml +++ b/packages/SettingsProvider/res/values/defaults.xml @@ -341,4 +341,7 @@ <!-- The default ringer mode. See `AudioManager` for list of valid values. --> <integer name="def_ringer_mode">2</integer> + + <!-- Caps minsum contrast from -1.0 (Material API) to 0.0 (Android Support)--> + <bool name="config_increaseMinContrast">true</bool> </resources> diff --git a/packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java b/packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java index 0121d31b9f35..829d4cb6c772 100644 --- a/packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java +++ b/packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java @@ -300,5 +300,9 @@ public class SecureSettings { Settings.Secure.DUAL_SHADE, Settings.Secure.BROWSER_CONTENT_FILTERS_ENABLED, Settings.Secure.SEARCH_CONTENT_FILTERS_ENABLED, + Settings.Secure.SPELL_CHECKER_ENABLED, + Settings.Secure.SELECTED_SPELL_CHECKER, + // SELECTED_SPELL_CHECKER_SUBTYPE needs to be restored after SELECTED_SPELL_CHECKER + Settings.Secure.SELECTED_SPELL_CHECKER_SUBTYPE, }; } diff --git a/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java b/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java index 5eb6af62d2c3..d0f84627f8d8 100644 --- a/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java +++ b/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java @@ -472,5 +472,8 @@ public class SecureSettingsValidators { VALIDATORS.put(Secure.DUAL_SHADE, BOOLEAN_VALIDATOR); VALIDATORS.put(Secure.BROWSER_CONTENT_FILTERS_ENABLED, BOOLEAN_VALIDATOR); VALIDATORS.put(Secure.SEARCH_CONTENT_FILTERS_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.SPELL_CHECKER_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.SELECTED_SPELL_CHECKER, NULLABLE_COMPONENT_NAME_VALIDATOR); + VALIDATORS.put(Secure.SELECTED_SPELL_CHECKER_SUBTYPE, ANY_INTEGER_VALIDATOR); } } diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java index fc402d45c3ec..37ada933259e 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java @@ -37,10 +37,12 @@ import android.app.backup.BackupDataInput; import android.app.backup.BackupDataOutput; import android.app.backup.BackupRestoreEventLogger; import android.app.backup.FullBackupDataOutput; +import android.content.ComponentName; import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; import android.content.pm.PackageManager; +import android.content.pm.ServiceInfo; import android.database.Cursor; import android.net.NetworkPolicy; import android.net.NetworkPolicyManager; @@ -941,6 +943,7 @@ public class SettingsBackupAgent extends BackupAgentHelper { Set<String> blockedSettings = getBlockedSettings(blockedSettingsArrayId); int restoredSettingsCount = 0; + boolean selectedSpellCheckerRestored = false; for (String key : allowlist.mSettingsAllowlist) { boolean isBlockedBySystem = blockedSettings != null && blockedSettings.contains(key); if (isBlockedBySystem || isBlockedByDynamicList(dynamicBlockList, contentUri, key)) { @@ -1068,6 +1071,25 @@ public class SettingsBackupAgent extends BackupAgentHelper { } continue; } + } else if (Settings.Secure.SELECTED_SPELL_CHECKER.equals(key)) { + ServiceInfo si = getServiceInfoOrNull(value); + if (si == null || si.applicationInfo == null) { + Log.i(TAG, "Skipping restore for setting selected_spell_checker " + + "as it is not installed"); + continue; + } else if (!si.applicationInfo.isSystemApp() + && !si.applicationInfo.isUpdatedSystemApp()) { + Log.i(TAG, "Skipping restore for setting selected_spell_checker " + + "as it is not a system app"); + continue; + } + selectedSpellCheckerRestored = true; + } else if (Settings.Secure.SELECTED_SPELL_CHECKER_SUBTYPE.equals(key)) { + if (!selectedSpellCheckerRestored) { + Log.i(TAG, "Skipping restore for setting selected_spell_checker_subtype " + + "as selected_spell_checker was not restored"); + continue; + } } if (Settings.System.FONT_SCALE.equals(key)) { @@ -1085,6 +1107,21 @@ public class SettingsBackupAgent extends BackupAgentHelper { Log.d(TAG, "Restored font scale from: " + toRestore + " to " + value); } + if (Settings.Secure.CONTRAST_LEVEL.equals(key)) { + boolean increaseMinContrast = getBaseContext().getResources() + .getBoolean(R.bool.config_increaseMinContrast); + + float valueFloat; + try { + valueFloat = Float.parseFloat(value); + } catch (NumberFormatException e) { + valueFloat = 0.0f; + } + + float newValue = Math.max(valueFloat, increaseMinContrast ? 0.0f : -1.0f); + value = String.valueOf(newValue); + } + settingsHelper.restoreValue(this, cr, contentValues, destination, key, value, mRestoredFromSdkInt); @@ -1868,6 +1905,18 @@ public class SettingsBackupAgent extends BackupAgentHelper { return result; } + @Nullable + private ServiceInfo getServiceInfoOrNull(@Nullable String flattenedServiceName) { + if (flattenedServiceName == null) return null; + ComponentName componentName = ComponentName.unflattenFromString(flattenedServiceName); + if (componentName == null) return null; + try { + return getBaseContext().getPackageManager().getServiceInfo(componentName, 0); + } catch (PackageManager.NameNotFoundException e) { + return null; + } + } + /** * Store the allowlist of settings to be backed up and validators for them. */ diff --git a/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java b/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java index 70c042cb8eba..3148f22ab511 100644 --- a/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java +++ b/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java @@ -749,15 +749,12 @@ public class SettingsBackupTest { Settings.Secure.SECURE_FRP_MODE, Settings.Secure.SEARCH_WEB_RESULTS_OVERRIDE_LIMIT, Settings.Secure.SELECTED_INPUT_METHOD_SUBTYPE, - Settings.Secure.SELECTED_SPELL_CHECKER, // Intentionally removed in Q - Settings.Secure.SELECTED_SPELL_CHECKER_SUBTYPE, // Intentionally removed in Q Settings.Secure.SETTINGS_CLASSNAME, Settings.Secure.SHOW_NOTE_ABOUT_NOTIFICATION_HIDING, // candidate? Settings.Secure.SHOW_ROTATION_SUGGESTIONS, Settings.Secure.SKIP_FIRST_USE_HINTS, // candidate? Settings.Secure.SLEEP_TIMEOUT, Settings.Secure.SMS_DEFAULT_APPLICATION, - Settings.Secure.SPELL_CHECKER_ENABLED, // Intentionally removed in Q Settings.Secure.TRUST_AGENTS_INITIALIZED, Settings.Secure.KNOWN_TRUST_AGENTS_INITIALIZED, Settings.Secure.TV_APP_USES_NON_SYSTEM_INPUTS, diff --git a/packages/SettingsProvider/test/src/com/android/providers/settings/SettingsBackupAgentTest.java b/packages/SettingsProvider/test/src/com/android/providers/settings/SettingsBackupAgentTest.java index 48c360b635ea..bc727d33ad4a 100644 --- a/packages/SettingsProvider/test/src/com/android/providers/settings/SettingsBackupAgentTest.java +++ b/packages/SettingsProvider/test/src/com/android/providers/settings/SettingsBackupAgentTest.java @@ -16,15 +16,15 @@ package com.android.providers.settings; -import static com.android.providers.settings.SettingsBackupRestoreKeys.KEY_WIFI_NEW_CONFIG; -import static com.android.providers.settings.SettingsBackupRestoreKeys.KEY_SOFTAP_CONFIG; import static com.android.providers.settings.SettingsBackupRestoreKeys.KEY_SIM_SPECIFIC_SETTINGS_2; +import static com.android.providers.settings.SettingsBackupRestoreKeys.KEY_SOFTAP_CONFIG; +import static com.android.providers.settings.SettingsBackupRestoreKeys.KEY_WIFI_NEW_CONFIG; import static com.android.providers.settings.SettingsBackupRestoreKeys.KEY_WIFI_SETTINGS_BACKUP_DATA; import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertNull; -import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static org.junit.Assert.assertArrayEquals; @@ -35,12 +35,10 @@ import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.when; -import android.annotation.Nullable; import android.app.backup.BackupAnnotations.BackupDestination; import android.app.backup.BackupAnnotations.OperationType; import android.app.backup.BackupDataInput; import android.app.backup.BackupDataOutput; -import android.app.backup.BackupRestoreEventLogger; import android.app.backup.BackupRestoreEventLogger.DataTypeResult; import android.content.ContentResolver; import android.content.ContentValues; @@ -69,13 +67,11 @@ import androidx.test.runner.AndroidJUnit4; import com.android.window.flags.Flags; -import java.util.List; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.Mockito; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; @@ -331,6 +327,47 @@ public class SettingsBackupAgentTest extends BaseSettingsProviderTest { } @Test + public void testOnRestore_minContrastLevelIsRestoredToZero() { + mAgentUnderTest = new TestFriendlySettingsBackupAgent() { + @Override + protected Set<String> getBlockedSettings(int blockedSettingsArrayId) { + return new HashSet<>(); + } + }; + mAgentUnderTest.attach(mContext); + + TestSettingsHelper settingsHelper = new TestSettingsHelper(mContext); + mAgentUnderTest.mSettingsHelper = settingsHelper; + + String contrastLevelValue = "-1.0"; + Map<String, String> settingsToRestore = Map.of(Settings.Secure.CONTRAST_LEVEL, + contrastLevelValue); + + byte[] backupData = generateBackupData(settingsToRestore); + mAgentUnderTest.restoreSettings( + backupData, + /* pos */ 0, + backupData.length, + Settings.Secure.CONTENT_URI, + null, + null, + null, + /* blockedSettingsArrayId */ 0, + Collections.emptySet(), + Collections.emptySet(), + KEY_SECURE); + + // Check that the contrast level has been restored. + assertTrue(settingsHelper.mWrittenValues.containsKey(Settings.Secure.CONTRAST_LEVEL)); + + String restoredContrastLevel = settingsHelper.mWrittenValues.get( + Settings.Secure.CONTRAST_LEVEL); + + float restoredFloat = Float.parseFloat(restoredContrastLevel); + assertEquals(0.0f, restoredFloat, 0.001f); + } + + @Test @DisableFlags(com.android.server.backup.Flags.FLAG_ENABLE_METRICS_SETTINGS_BACKUP_AGENTS) public void onCreate_metricsFlagIsDisabled_areAgentMetricsEnabledIsFalse() { mAgentUnderTest.onCreate(); diff --git a/packages/SystemUI/compose/core/src/com/android/compose/gesture/NestedDraggable.kt b/packages/SystemUI/compose/core/src/com/android/compose/gesture/NestedDraggable.kt index 80cbbea7659f..2ea9c487c27c 100644 --- a/packages/SystemUI/compose/core/src/com/android/compose/gesture/NestedDraggable.kt +++ b/packages/SystemUI/compose/core/src/com/android/compose/gesture/NestedDraggable.kt @@ -112,6 +112,14 @@ interface NestedDraggable { interface Controller { /** + * Whether drags that were started from nested scrolls should be automatically + * [stopped][onDragStopped] as soon as they don't consume the entire `delta` passed to + * [onDrag]. + */ + val autoStopNestedDrags: Boolean + get() = false + + /** * Drag by [delta] pixels. * * @return the consumed [delta]. Any non-consumed delta will be dispatched to the next @@ -609,8 +617,15 @@ private class NestedDraggableNode( } private fun scrollWithOverscroll(controller: NestedScrollController, offset: Offset): Offset { - return scrollWithOverscroll(offset) { - controller.controller.onDrag(it.toFloat()).toOffset() + return scrollWithOverscroll(offset) { delta -> + val available = delta.toFloat() + val consumed = controller.controller.onDrag(available) + if (controller.controller.autoStopNestedDrags && consumed != available) { + controller.ensureOnDragStoppedIsCalled() + this.nestedScrollController = null + } + + consumed.toOffset() } } diff --git a/packages/SystemUI/compose/core/tests/src/com/android/compose/gesture/NestedDraggableTest.kt b/packages/SystemUI/compose/core/tests/src/com/android/compose/gesture/NestedDraggableTest.kt index a03d769c9c36..b247993de4e4 100644 --- a/packages/SystemUI/compose/core/tests/src/com/android/compose/gesture/NestedDraggableTest.kt +++ b/packages/SystemUI/compose/core/tests/src/com/android/compose/gesture/NestedDraggableTest.kt @@ -1000,6 +1000,39 @@ class NestedDraggableTest(override val orientation: Orientation) : OrientationAw assertThat(draggable.onDragStartedCalled).isTrue() } + @Test + fun autoStopNestedDrags() { + var consumeScrolls by mutableStateOf(true) + val draggable = + TestDraggable(autoStopNestedDrags = true, onDrag = { if (consumeScrolls) it else 0f }) + + val touchSlop = + rule.setContentWithTouchSlop { + Box( + Modifier.fillMaxSize() + .nestedDraggable(draggable, orientation) + .scrollable(rememberScrollableState { 0f }, orientation) + ) + } + + rule.onRoot().performTouchInput { + down(center) + moveBy((touchSlop + 1f).toOffset()) + } + + assertThat(draggable.onDragStartedCalled).isTrue() + assertThat(draggable.onDragStoppedCalled).isFalse() + + rule.onRoot().performTouchInput { moveBy(50f.toOffset()) } + + assertThat(draggable.onDragStoppedCalled).isFalse() + + consumeScrolls = false + rule.onRoot().performTouchInput { moveBy(1f.toOffset()) } + + assertThat(draggable.onDragStoppedCalled).isTrue() + } + private fun ComposeContentTestRule.setContentWithTouchSlop( content: @Composable () -> Unit ): Float { @@ -1027,6 +1060,7 @@ class NestedDraggableTest(override val orientation: Orientation) : OrientationAw }, private val shouldConsumeNestedPostScroll: (Float) -> Boolean = { true }, private val shouldConsumeNestedPreScroll: (Float) -> Boolean = { false }, + private val autoStopNestedDrags: Boolean = false, ) : NestedDraggable { var shouldStartDrag = true var onDragStartedCalled = false @@ -1056,6 +1090,8 @@ class NestedDraggableTest(override val orientation: Orientation) : OrientationAw onDragStarted.invoke(position, sign) return object : NestedDraggable.Controller { + override val autoStopNestedDrags: Boolean = this@TestDraggable.autoStopNestedDrags + override fun onDrag(delta: Float): Float { onDragCalled = true onDragDelta += delta diff --git a/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_gesture_dragFullyClose.json b/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_gesture_dragFullyClose.json index 57f67665242c..5dbb01338090 100644 --- a/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_gesture_dragFullyClose.json +++ b/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_gesture_dragFullyClose.json @@ -59,10 +59,7 @@ 896, 912, 928, - 944, - 960, - 976, - 992 + 944 ], "features": [ { @@ -70,256 +67,244 @@ "type": "dpOffset", "data_points": [ { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50.4 + "x": 5.2, + "y": 5.6 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 8.4, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 11.2, + "y": 5.2 }, { - "x": 52.4, - "y": 50 + "x": 13.6, + "y": 5.2 }, { - "x": 56, - "y": 50 + "x": 15.6, + "y": 5.2 }, { - "x": 58.8, - "y": 50 + "x": 16.8, + "y": 5.2 }, { - "x": 60.8, - "y": 50 + "x": 17.6, + "y": 5.2 }, { - "x": 62, - "y": 50 + "x": 18.4, + "y": 5.2 }, { - "x": 62.8, - "y": 50 + "x": 18.8, + "y": 5.2 }, { - "x": 63.6, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 - }, - { - "x": 64, - "y": 50 - }, - { - "x": 64, - "y": 50 - }, - { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 } ] }, @@ -328,255 +313,243 @@ "type": "dpSize", "data_points": [ { - "width": 188, - "height": 400 - }, - { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 393.2 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 393.2 + "width": 150, + "height": 293.2 }, { - "width": 188, - "height": 386 + "width": 150, + "height": 293.2 }, { - "width": 188, - "height": 379.6 + "width": 150, + "height": 286 }, { - "width": 188, - "height": 372.8 + "width": 150, + "height": 279.6 }, { - "width": 188, - "height": 366.8 + "width": 150, + "height": 273.2 }, { - "width": 188, - "height": 360.4 + "width": 150, + "height": 266.8 }, { - "width": 188, - "height": 354 + "width": 150, + "height": 260.4 }, { - "width": 188, - "height": 347.6 + "width": 150, + "height": 254 }, { - "width": 188, - "height": 341.2 + "width": 150, + "height": 247.6 }, { - "width": 188, - "height": 341.2 + "width": 150, + "height": 241.2 }, { - "width": 188, - "height": 334 + "width": 150, + "height": 241.2 }, { - "width": 188, - "height": 328 + "width": 150, + "height": 234.4 }, { - "width": 188, - "height": 321.6 + "width": 150, + "height": 228 }, { - "width": 188, - "height": 315.2 + "width": 150, + "height": 221.6 }, { - "width": 188, - "height": 308.8 + "width": 150, + "height": 215.2 }, { - "width": 188, - "height": 302.4 + "width": 150, + "height": 208.8 }, { - "width": 188, - "height": 296 + "width": 150, + "height": 202 }, { - "width": 188, - "height": 289.6 + "width": 150, + "height": 195.6 }, { - "width": 188, - "height": 289.6 + "width": 150, + "height": 189.2 }, { - "width": 188, - "height": 282.8 + "width": 150, + "height": 189.2 }, { - "width": 188, - "height": 276.4 + "width": 150, + "height": 182.8 }, { - "width": 188, - "height": 270 + "width": 150, + "height": 176.4 }, { - "width": 188, - "height": 263.6 + "width": 150, + "height": 170 }, { - "width": 188, - "height": 257.2 + "width": 150, + "height": 163.6 }, { - "width": 188, - "height": 250.8 + "width": 150, + "height": 157.2 }, { - "width": 188, - "height": 244.4 + "width": 150, + "height": 150.8 }, { - "width": 188, - "height": 238 + "width": 150, + "height": 144.4 }, { - "width": 188, - "height": 238 + "width": 150, + "height": 137.6 }, { - "width": 188, - "height": 231.2 + "width": 150, + "height": 137.6 }, { - "width": 188, - "height": 224.8 + "width": 150, + "height": 131.2 }, { - "width": 188, - "height": 218.4 + "width": 150, + "height": 124.8 }, { - "width": 188, - "height": 212 + "width": 150, + "height": 118.4 }, { - "width": 188, - "height": 212 + "width": 150, + "height": 112 }, { - "width": 188, - "height": 192.4 + "width": 150, + "height": 112 }, { - "width": 188, - "height": 159.6 + "width": 150, + "height": 99.2 }, { - "width": 188, - "height": 124.4 + "width": 150, + "height": 81.2 }, { - "width": 188, - "height": 92.8 + "width": 144, + "height": 62.8 }, { - "width": 183.2, - "height": 66.4 + "width": 138, + "height": 46.4 }, { - "width": 176, - "height": 46 + "width": 133.2, + "height": 32 }, { - "width": 170.4, - "height": 28.8 + "width": 129.6, + "height": 20.4 }, { - "width": 166.8, - "height": 15.2 + "width": 127.2, + "height": 12 }, { - "width": 164, + "width": 125.2, "height": 6.4 }, { - "width": 162.4, - "height": 0.8 + "width": 124, + "height": 2.8 }, { - "width": 161.2, - "height": 0 + "width": 123.2, + "height": 0.4 }, { - "width": 160.4, + "width": 122.4, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, - "height": 0 - }, - { - "width": 160, - "height": 0 - }, - { - "width": 160, + "width": 122, "height": 0 } ] @@ -627,22 +600,19 @@ 1, 1, 1, - 1, - 1, - 0.9808927, - 0.8211168, - 0.61845565, - 0.43834114, - 0.29850912, - 0.19755232, - 0.12793064, - 0.08142871, - 0.051099956, - 0.031684637, - 0.019442618, - 0.011821032, - 0, - 0, + 0.99781144, + 0.87040234, + 0.6695792, + 0.48078007, + 0.33033127, + 0.22004372, + 0.1432175, + 0.09153092, + 0.057634592, + 0.035840213, + 0.022048414, + 0.013435662, + 0.008117795, 0, 0, 0, diff --git a/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_gesture_dragHalfClose.json b/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_gesture_dragHalfClose.json index 01bc852cf7f4..1543d186ea03 100644 --- a/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_gesture_dragHalfClose.json +++ b/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_gesture_dragHalfClose.json @@ -69,252 +69,252 @@ "type": "dpOffset", "data_points": [ { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50.8, - "y": 52 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.6, + "y": 6.8 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 52.4, - "y": 50 + "x": 6.8, + "y": 5.2 }, { - "x": 55.6, - "y": 50 + "x": 10.4, + "y": 5.2 }, { - "x": 58.4, - "y": 50 + "x": 13.2, + "y": 5.2 }, { - "x": 60.4, - "y": 50 + "x": 15.2, + "y": 5.2 }, { - "x": 61.6, - "y": 50 + "x": 16.8, + "y": 5.2 }, { - "x": 62.8, - "y": 50 + "x": 17.6, + "y": 5.2 }, { - "x": 63.2, - "y": 50 + "x": 18.4, + "y": 5.2 }, { - "x": 63.6, - "y": 50 + "x": 18.8, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 } ] }, @@ -323,251 +323,251 @@ "type": "dpSize", "data_points": [ { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 390 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 390 + "width": 150, + "height": 297.6 }, { - "width": 188, - "height": 379.2 + "width": 150, + "height": 294 }, { - "width": 188, - "height": 371.2 + "width": 150, + "height": 287.6 }, { - "width": 188, - "height": 363.2 + "width": 150, + "height": 282.8 }, { - "width": 188, - "height": 355.2 + "width": 150, + "height": 278 }, { - "width": 188, - "height": 347.2 + "width": 150, + "height": 273.2 }, { - "width": 188, - "height": 339.2 + "width": 150, + "height": 268.4 }, { - "width": 188, - "height": 331.2 + "width": 150, + "height": 263.6 }, { - "width": 188, - "height": 323.2 + "width": 150, + "height": 258.8 }, { - "width": 188, - "height": 323.2 + "width": 150, + "height": 258.8 }, { - "width": 188, - "height": 314.8 + "width": 150, + "height": 253.6 }, { - "width": 188, - "height": 306.8 + "width": 150, + "height": 248.8 }, { - "width": 188, - "height": 298.8 + "width": 150, + "height": 244 }, { - "width": 188, - "height": 290.8 + "width": 150, + "height": 239.2 }, { - "width": 188, - "height": 282.8 + "width": 150, + "height": 234.4 }, { - "width": 188, - "height": 274.8 + "width": 150, + "height": 229.6 }, { - "width": 188, - "height": 266.8 + "width": 150, + "height": 224.8 }, { - "width": 188, - "height": 258.8 + "width": 150, + "height": 220 }, { - "width": 188, - "height": 258.8 + "width": 150, + "height": 220 }, { - "width": 188, - "height": 250.4 + "width": 150, + "height": 214.8 }, { - "width": 188, - "height": 242.4 + "width": 150, + "height": 210 }, { - "width": 188, - "height": 234.4 + "width": 150, + "height": 205.2 }, { - "width": 188, - "height": 226.4 + "width": 150, + "height": 200.4 }, { - "width": 188, - "height": 218.4 + "width": 150, + "height": 195.6 }, { - "width": 188, - "height": 210.4 + "width": 150, + "height": 190.8 }, { - "width": 188, - "height": 202.4 + "width": 150, + "height": 186 }, { - "width": 188, - "height": 194.4 + "width": 150, + "height": 181.2 }, { - "width": 188, - "height": 194.4 + "width": 150, + "height": 181.2 }, { - "width": 188, - "height": 185.6 + "width": 150, + "height": 176.4 }, { - "width": 188, - "height": 178 + "width": 150, + "height": 171.6 }, { - "width": 188, - "height": 170 + "width": 150, + "height": 166.8 }, { - "width": 188, + "width": 150, "height": 161.6 }, { - "width": 188, + "width": 150, "height": 161.6 }, { - "width": 188, - "height": 144.8 + "width": 150, + "height": 147.2 }, { - "width": 188, - "height": 118.8 + "width": 150, + "height": 122 }, { - "width": 188, - "height": 92 + "width": 150, + "height": 95.2 }, { - "width": 183.6, - "height": 68 + "width": 146.8, + "height": 70.8 }, { - "width": 176.8, - "height": 48.4 + "width": 139.6, + "height": 50.8 }, { - "width": 171.6, - "height": 32 + "width": 134, + "height": 34 }, { - "width": 167.6, - "height": 18 + "width": 130, + "height": 19.2 }, { - "width": 164.8, - "height": 8.8 + "width": 127.2, + "height": 9.2 }, { - "width": 162.8, + "width": 125.2, "height": 2.8 }, { - "width": 161.6, + "width": 123.6, "height": 0 }, { - "width": 160.8, + "width": 122.8, "height": 0 }, { - "width": 160.4, + "width": 122.4, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 } ] @@ -619,19 +619,19 @@ 1, 1, 1, - 0.9967737, - 0.86538374, - 0.66414475, - 0.47619528, - 0.32686388, - 0.21757984, - 0.14153665, - 0.09041709, - 0.05691254, - 0.035380244, - 0.02175957, - 0.01325649, - 0.008007765, + 0.99979615, + 0.8860379, + 0.6869267, + 0.4955439, + 0.34154767, + 0.22803628, + 0.14868057, + 0.09515619, + 0.059987247, + 0.037340224, + 0.02299112, + 0.01402092, + 0.008477271, 0, 0, 0, diff --git a/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_gesture_dragOpen.json b/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_gesture_dragOpen.json index b6e423afc6c4..13f75d2adfb4 100644 --- a/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_gesture_dragOpen.json +++ b/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_gesture_dragOpen.json @@ -68,200 +68,200 @@ "type": "not_found" }, { - "x": 62.8, - "y": 50 + "x": 18, + "y": 5.2 }, { - "x": 62.8, - "y": 50 + "x": 18, + "y": 5.2 }, { - "x": 61.6, - "y": 50 + "x": 16.8, + "y": 5.2 }, { - "x": 60.8, - "y": 50 + "x": 16, + "y": 5.2 }, { - "x": 59.6, - "y": 50 + "x": 14.8, + "y": 5.2 }, { - "x": 58.4, - "y": 50 + "x": 13.6, + "y": 5.2 }, { - "x": 57.2, - "y": 50 + "x": 12.4, + "y": 5.2 }, { - "x": 56, - "y": 50 + "x": 11.2, + "y": 5.2 }, { - "x": 55.2, - "y": 50 + "x": 10.4, + "y": 5.2 }, { - "x": 54, - "y": 50 + "x": 9.2, + "y": 5.2 }, { - "x": 54, - "y": 50 + "x": 9.2, + "y": 5.2 }, { - "x": 52.8, - "y": 50 + "x": 8, + "y": 5.2 }, { - "x": 51.6, - "y": 50 + "x": 6.8, + "y": 5.2 }, { - "x": 50.4, - "y": 50 + "x": 5.6, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 } ] }, @@ -279,200 +279,200 @@ "type": "not_found" }, { - "width": 162.4, + "width": 124.4, "height": 1.6 }, { - "width": 162.4, + "width": 124.4, "height": 1.6 }, { - "width": 164.8, + "width": 126.8, "height": 3.2 }, { - "width": 166.8, + "width": 128.8, "height": 4.8 }, { - "width": 169.2, + "width": 131.2, "height": 6.4 }, { - "width": 171.6, + "width": 133.6, "height": 8 }, { - "width": 173.6, + "width": 135.6, "height": 9.6 }, { - "width": 176, + "width": 138, "height": 11.2 }, { - "width": 178, + "width": 140, "height": 12.8 }, { - "width": 180.4, + "width": 142.4, "height": 14.4 }, { - "width": 180.4, + "width": 142.4, "height": 14.4 }, { - "width": 182.8, + "width": 144.8, "height": 16.4 }, { - "width": 185.2, + "width": 147.2, "height": 18 }, { - "width": 187.2, + "width": 149.2, "height": 19.6 }, { - "width": 188, + "width": 150, "height": 25.6 }, { - "width": 188, + "width": 150, "height": 36.4 }, { - "width": 188, + "width": 150, "height": 45.6 }, { - "width": 188, + "width": 150, "height": 59.2 }, { - "width": 188, + "width": 150, "height": 72.8 }, { - "width": 188, + "width": 150, "height": 79.6 }, { - "width": 188, + "width": 150, "height": 92.8 }, { - "width": 188, + "width": 150, "height": 104.4 }, { - "width": 188, + "width": 150, "height": 115.2 }, { - "width": 188, + "width": 150, "height": 125.2 }, { - "width": 188, + "width": 150, "height": 134.8 }, { - "width": 188, + "width": 150, "height": 143.2 }, { - "width": 188, + "width": 150, "height": 151.2 }, { - "width": 188, + "width": 150, "height": 158.8 }, { - "width": 188, + "width": 150, "height": 160 }, { - "width": 188, + "width": 150, "height": 167.2 }, { - "width": 188, + "width": 150, "height": 174.4 }, { - "width": 188, + "width": 150, "height": 180.8 }, { - "width": 188, + "width": 150, "height": 187.6 }, { - "width": 188, + "width": 150, "height": 188 }, { - "width": 188, - "height": 207.2 + "width": 150, + "height": 200.4 }, { - "width": 188, - "height": 240 + "width": 150, + "height": 218.4 }, { - "width": 188, - "height": 275.2 + "width": 150, + "height": 236.8 }, { - "width": 188, - "height": 306.8 + "width": 150, + "height": 253.2 }, { - "width": 188, - "height": 333.2 + "width": 150, + "height": 266.8 }, { - "width": 188, - "height": 353.6 + "width": 150, + "height": 277.2 }, { - "width": 188, - "height": 368.8 + "width": 150, + "height": 284.8 }, { - "width": 188, - "height": 380 + "width": 150, + "height": 290 }, { - "width": 188, - "height": 387.6 + "width": 150, + "height": 294 }, { - "width": 188, - "height": 392.4 + "width": 150, + "height": 296.4 }, { - "width": 188, - "height": 395.6 + "width": 150, + "height": 298 }, { - "width": 188, - "height": 398 + "width": 150, + "height": 298.8 }, { - "width": 188, - "height": 398.8 + "width": 150, + "height": 299.6 }, { - "width": 188, - "height": 399.6 + "width": 150, + "height": 299.6 }, { - "width": 188, - "height": 400 + "width": 150, + "height": 300 } ] }, @@ -494,12 +494,12 @@ 0, 0, 0.0067873597, - 0.0612576, - 0.19080025, + 0.06125766, + 0.19080031, 0.39327443, 0.5711931, - 0.70855826, - 0.8074064, + 0.7085583, + 0.8074065, 0.8754226, 0.9207788, 0.95032376, diff --git a/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_gesture_flingClose.json b/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_gesture_flingClose.json index a82db346ed58..115483cf4013 100644 --- a/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_gesture_flingClose.json +++ b/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_gesture_flingClose.json @@ -40,8 +40,7 @@ 592, 608, 624, - 640, - 656 + 640 ], "features": [ { @@ -49,172 +48,168 @@ "type": "dpOffset", "data_points": [ { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50.4, - "y": 50.8 + "x": 5.6, + "y": 6.4 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 6.4, + "y": 5.2 }, { - "x": 51.2, - "y": 50 + "x": 10.4, + "y": 5.2 }, { - "x": 55.6, - "y": 50 + "x": 13.6, + "y": 5.2 }, { - "x": 58.8, - "y": 50 + "x": 15.6, + "y": 5.2 }, { - "x": 60.8, - "y": 50 + "x": 17.2, + "y": 5.2 }, { - "x": 62, - "y": 50 + "x": 18, + "y": 5.2 }, { - "x": 63.2, - "y": 50 + "x": 18.8, + "y": 5.2 }, { - "x": 63.6, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 - }, - { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 } ] }, @@ -223,171 +218,167 @@ "type": "dpSize", "data_points": [ { - "width": 188, - "height": 400 - }, - { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 389.6 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 378.8 + "width": 150, + "height": 290 }, { - "width": 188, - "height": 366 + "width": 150, + "height": 278.8 }, { - "width": 188, - "height": 352 + "width": 150, + "height": 266 }, { - "width": 188, - "height": 352 + "width": 150, + "height": 252 }, { - "width": 188, - "height": 316.8 + "width": 150, + "height": 252 }, { - "width": 188, - "height": 261.2 + "width": 150, + "height": 223.6 }, { - "width": 188, - "height": 202.8 + "width": 150, + "height": 182.8 }, { - "width": 188, - "height": 150.8 + "width": 150, + "height": 141.2 }, { - "width": 188, - "height": 107.6 + "width": 150, + "height": 104 }, { - "width": 186, - "height": 74.4 + "width": 147.6, + "height": 74 }, { - "width": 177.2, - "height": 49.6 + "width": 139.6, + "height": 50.8 }, { - "width": 170.8, - "height": 29.6 + "width": 133.6, + "height": 32 }, { - "width": 166.8, - "height": 12.8 + "width": 129.2, + "height": 15.6 }, { - "width": 164, - "height": 2.4 + "width": 126.4, + "height": 5.2 }, { - "width": 162, + "width": 124.4, "height": 0 }, { - "width": 160.8, + "width": 123.2, "height": 0 }, { - "width": 160.4, + "width": 122.4, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 } ] @@ -418,20 +409,19 @@ 1, 1, 1, - 1, - 0.9833227, - 0.8263634, - 0.623688, - 0.44261706, - 0.3016883, - 0.1997872, - 0.12944388, - 0.08242595, - 0.051743627, - 0.032093227, - 0.019698441, - 0.0119793415, - 0, + 0.99479187, + 0.8575029, + 0.65572864, + 0.4691311, + 0.3215357, + 0.21380007, + 0.13896108, + 0.0887118, + 0.05580789, + 0.03467691, + 0.021318138, + 0.0129826665, + 0.007839739, 0, 0, 0, diff --git a/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_gesture_flingOpen.json b/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_gesture_flingOpen.json index 6dc5a0e79e81..f202fcd5f59c 100644 --- a/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_gesture_flingOpen.json +++ b/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_gesture_flingOpen.json @@ -64,104 +64,104 @@ "type": "not_found" }, { - "x": 62.4, - "y": 50 + "x": 17.6, + "y": 5.2 }, { - "x": 61.2, - "y": 50 + "x": 16.4, + "y": 5.2 }, { - "x": 59.2, - "y": 50 + "x": 14.4, + "y": 5.2 }, { - "x": 57.2, - "y": 50 + "x": 12.4, + "y": 5.2 }, { - "x": 54.8, - "y": 50 + "x": 10, + "y": 5.2 }, { - "x": 52.4, - "y": 50 + "x": 7.6, + "y": 5.2 }, { - "x": 52.4, - "y": 50 + "x": 7.6, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 } ] }, @@ -194,104 +194,104 @@ "type": "not_found" }, { - "width": 163.2, + "width": 125.2, "height": 2 }, { - "width": 166, + "width": 128, "height": 4.4 }, { - "width": 170, + "width": 132, "height": 6.8 }, { - "width": 174, + "width": 136, "height": 10 }, { - "width": 178.4, + "width": 140.4, "height": 13.2 }, { - "width": 183.6, + "width": 145.6, "height": 16.8 }, { - "width": 183.6, + "width": 145.6, "height": 16.8 }, { - "width": 188, - "height": 44.4 + "width": 150, + "height": 36.8 }, { - "width": 188, - "height": 103.6 + "width": 150, + "height": 81.2 }, { - "width": 188, - "height": 166 + "width": 150, + "height": 126.8 }, { - "width": 188, - "height": 222.4 + "width": 150, + "height": 168 }, { - "width": 188, - "height": 270 + "width": 150, + "height": 202.8 }, { - "width": 188, - "height": 307.2 + "width": 150, + "height": 230 }, { - "width": 188, - "height": 335.6 + "width": 150, + "height": 250.8 }, { - "width": 188, - "height": 356.4 + "width": 150, + "height": 266.4 }, { - "width": 188, - "height": 371.2 + "width": 150, + "height": 277.6 }, { - "width": 188, - "height": 381.6 + "width": 150, + "height": 285.2 }, { - "width": 188, - "height": 388.8 + "width": 150, + "height": 290.4 }, { - "width": 188, - "height": 393.2 + "width": 150, + "height": 294 }, { - "width": 188, - "height": 396 + "width": 150, + "height": 296.4 }, { - "width": 188, - "height": 398 + "width": 150, + "height": 298 }, { - "width": 188, - "height": 398.8 + "width": 150, + "height": 298.8 }, { - "width": 188, - "height": 399.2 + "width": 150, + "height": 299.2 }, { - "width": 188, - "height": 399.6 + "width": 150, + "height": 299.6 }, { - "width": 188, - "height": 399.6 + "width": 150, + "height": 299.6 } ] }, diff --git a/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_gesture_magneticDetachAndReattach.json b/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_gesture_magneticDetachAndReattach.json index 1cd971aa2898..4c57bda8fd5a 100644 --- a/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_gesture_magneticDetachAndReattach.json +++ b/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_gesture_magneticDetachAndReattach.json @@ -89,268 +89,268 @@ "type": "not_found" }, { - "x": 62.8, - "y": 50 + "x": 18, + "y": 5.2 }, { - "x": 62, - "y": 50 + "x": 17.2, + "y": 5.2 }, { - "x": 61.2, - "y": 50 + "x": 16.4, + "y": 5.2 }, { - "x": 60.4, - "y": 50 + "x": 15.6, + "y": 5.2 }, { - "x": 59.6, - "y": 50 + "x": 14.8, + "y": 5.2 }, { - "x": 58.8, - "y": 50 + "x": 14, + "y": 5.2 }, { - "x": 58, - "y": 50 + "x": 13.2, + "y": 5.2 }, { - "x": 57.2, - "y": 50 + "x": 12.4, + "y": 5.2 }, { - "x": 56.4, - "y": 50 + "x": 11.6, + "y": 5.2 }, { - "x": 55.6, - "y": 50 + "x": 10.8, + "y": 5.2 }, { - "x": 55.2, - "y": 50 + "x": 10.4, + "y": 5.2 }, { - "x": 54.4, - "y": 50 + "x": 9.6, + "y": 5.2 }, { - "x": 53.6, - "y": 50 + "x": 8.8, + "y": 5.2 }, { - "x": 53.2, - "y": 50 + "x": 8.4, + "y": 5.2 }, { - "x": 52.8, - "y": 50 + "x": 8, + "y": 5.2 }, { - "x": 52, - "y": 50 + "x": 7.2, + "y": 5.2 }, { - "x": 51.6, - "y": 50 + "x": 6.8, + "y": 5.2 }, { - "x": 51.2, - "y": 50 + "x": 6.4, + "y": 5.2 }, { - "x": 50.8, - "y": 50 + "x": 6, + "y": 5.2 }, { - "x": 50.4, - "y": 50 + "x": 5.6, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50.4, - "y": 50 + "x": 5.6, + "y": 5.2 }, { - "x": 50.8, - "y": 50 + "x": 6, + "y": 5.2 }, { - "x": 51.2, - "y": 50 + "x": 6.4, + "y": 5.2 }, { - "x": 51.6, - "y": 50 + "x": 6.8, + "y": 5.2 }, { - "x": 52, - "y": 50 + "x": 7.2, + "y": 5.2 }, { - "x": 52.8, - "y": 50 + "x": 8, + "y": 5.2 }, { - "x": 53.2, - "y": 50 + "x": 8.4, + "y": 5.2 }, { - "x": 53.6, - "y": 50 + "x": 8.8, + "y": 5.2 }, { - "x": 54.4, - "y": 50 + "x": 9.6, + "y": 5.2 }, { - "x": 55.2, - "y": 50 + "x": 10.4, + "y": 5.2 }, { - "x": 55.6, - "y": 50 + "x": 10.8, + "y": 5.2 }, { - "x": 56.4, - "y": 50 + "x": 11.6, + "y": 5.2 }, { - "x": 57.2, - "y": 50 + "x": 12.4, + "y": 5.2 }, { - "x": 58, - "y": 50 + "x": 13.2, + "y": 5.2 }, { - "x": 58.8, - "y": 50 + "x": 14, + "y": 5.2 }, { - "x": 59.6, - "y": 50 + "x": 14.8, + "y": 5.2 }, { - "x": 60.4, - "y": 50 + "x": 15.6, + "y": 5.2 }, { - "x": 61.2, - "y": 50 + "x": 16.4, + "y": 5.2 }, { - "x": 62, - "y": 50 + "x": 17.2, + "y": 5.2 }, { - "x": 62.8, - "y": 50 + "x": 18, + "y": 5.2 }, { - "x": 63.6, - "y": 50 + "x": 18.8, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 } ] }, @@ -371,267 +371,267 @@ "type": "not_found" }, { - "width": 162.4, + "width": 124.4, "height": 1.6 }, { - "width": 164, + "width": 126, "height": 2.8 }, { - "width": 166, + "width": 128, "height": 4 }, { - "width": 167.6, + "width": 129.6, "height": 5.2 }, { - "width": 169.2, + "width": 131.2, "height": 6.4 }, { - "width": 170.8, + "width": 132.8, "height": 7.6 }, { - "width": 172.4, + "width": 134.4, "height": 8.8 }, { - "width": 174, + "width": 136, "height": 10 }, { - "width": 175.2, + "width": 137.2, "height": 10.8 }, { - "width": 176.8, + "width": 138.8, "height": 12 }, { - "width": 178, + "width": 140, "height": 12.8 }, { - "width": 179.2, + "width": 141.2, "height": 13.6 }, { - "width": 180.8, + "width": 142.8, "height": 14.8 }, { - "width": 182, + "width": 144, "height": 15.6 }, { - "width": 182.8, + "width": 144.8, "height": 16.4 }, { - "width": 184, + "width": 146, "height": 17.2 }, { - "width": 184.8, + "width": 146.8, "height": 17.6 }, { - "width": 186, + "width": 148, "height": 18.4 }, { - "width": 186.8, + "width": 148.8, "height": 19.2 }, { - "width": 187.6, + "width": 149.6, "height": 19.6 }, { - "width": 188, + "width": 150, "height": 21.2 }, { - "width": 188, + "width": 150, "height": 24.8 }, { - "width": 188, + "width": 150, "height": 30 }, { - "width": 188, + "width": 150, "height": 38 }, { - "width": 188, + "width": 150, "height": 46 }, { - "width": 188, + "width": 150, "height": 54 }, { - "width": 188, + "width": 150, "height": 61.2 }, { - "width": 188, + "width": 150, "height": 66.8 }, { - "width": 188, + "width": 150, "height": 71.6 }, { - "width": 188, + "width": 150, "height": 75.6 }, { - "width": 188, + "width": 150, "height": 78 }, { - "width": 188, + "width": 150, "height": 79.6 }, { - "width": 188, + "width": 150, "height": 80.8 }, { - "width": 188, + "width": 150, "height": 80.8 }, { - "width": 188, + "width": 150, "height": 80.4 }, { - "width": 188, + "width": 150, "height": 79.6 }, { - "width": 187.6, + "width": 149.6, "height": 78 }, { - "width": 186.8, + "width": 148.8, "height": 76.4 }, { - "width": 186, + "width": 148, "height": 74 }, { - "width": 184.8, + "width": 146.8, "height": 71.6 }, { - "width": 184, + "width": 146, "height": 69.2 }, { - "width": 182.8, + "width": 144.8, "height": 66 }, { - "width": 182, + "width": 144, "height": 62.8 }, { - "width": 180.8, + "width": 142.8, "height": 59.2 }, { - "width": 179.2, + "width": 141.2, "height": 55.6 }, { - "width": 178, + "width": 140, "height": 52 }, { - "width": 176.8, + "width": 138.8, "height": 48 }, { - "width": 175.2, + "width": 137.2, "height": 44 }, { - "width": 174, + "width": 136, "height": 40 }, { - "width": 172.4, + "width": 134.4, "height": 37.6 }, { - "width": 170.8, + "width": 132.8, "height": 38 }, { - "width": 169.2, + "width": 131.2, "height": 30.4 }, { - "width": 167.6, + "width": 129.6, "height": 25.2 }, { - "width": 166, + "width": 128, "height": 20.4 }, { - "width": 164, + "width": 126, "height": 16 }, { - "width": 162.4, + "width": 124.4, "height": 12.4 }, { - "width": 160.8, + "width": 122.8, "height": 9.2 }, { - "width": 160, + "width": 122, "height": 6.8 }, { - "width": 160, + "width": 122, "height": 5.2 }, { - "width": 160, + "width": 122, "height": 3.6 }, { - "width": 160, + "width": 122, "height": 2.4 }, { - "width": 160, + "width": 122, "height": 1.6 }, { - "width": 160, + "width": 122, "height": 0.8 }, { - "width": 160, + "width": 122, "height": 0.4 }, { - "width": 160, + "width": 122, "height": 0.4 }, { - "width": 160, + "width": 122, "height": 0 } ] @@ -658,10 +658,10 @@ 0, 0.012518823, 0.0741024, - 0.2254293, + 0.22542936, 0.42628878, - 0.5976641, - 0.7280312, + 0.5976642, + 0.7280313, 0.82100236, 0.8845844, 0.9267946, @@ -706,17 +706,17 @@ 1, 0.9944124, 0.9417388, - 0.8184184, - 0.6157812, - 0.4361611, - 0.2968906, - 0.19641554, - 0.12716137, - 0.080921985, - 0.050773025, - 0.03147719, - 0.019312752, - 0.011740655, + 0.81841844, + 0.61578125, + 0.43616113, + 0.29689062, + 0.19641556, + 0.12716138, + 0.080922, + 0.050773032, + 0.031477194, + 0.019312754, + 0.011740657, 0 ] } diff --git a/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_triggeredRevealCloseTransition.json b/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_triggeredRevealCloseTransition.json index 1030455e873f..26c80e331f81 100644 --- a/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_triggeredRevealCloseTransition.json +++ b/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_triggeredRevealCloseTransition.json @@ -28,8 +28,7 @@ 400, 416, 432, - 448, - 464 + 448 ], "features": [ { @@ -37,124 +36,120 @@ "type": "dpOffset", "data_points": [ { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 7.2, + "y": 5.2 }, { - "x": 53.2, - "y": 50 + "x": 11.2, + "y": 5.2 }, { - "x": 57.2, - "y": 50 + "x": 14, + "y": 5.2 }, { - "x": 59.6, - "y": 50 + "x": 16, + "y": 5.2 }, { - "x": 61.6, - "y": 50 + "x": 17.6, + "y": 5.2 }, { - "x": 62.8, - "y": 50 + "x": 18.4, + "y": 5.2 }, { - "x": 63.6, - "y": 50 + "x": 18.8, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 64, - "y": 50 - }, - { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 } ] }, @@ -163,123 +158,119 @@ "type": "dpSize", "data_points": [ { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 372 + "width": 150, + "height": 278.8 }, { - "width": 188, - "height": 312.8 + "width": 150, + "height": 234.8 }, { - "width": 188, - "height": 246.8 - }, - { - "width": 188, + "width": 150, "height": 185.2 }, { - "width": 188, - "height": 133.6 + "width": 150, + "height": 138.8 }, { - "width": 188, - "height": 93.2 + "width": 150, + "height": 100.4 }, { - "width": 181.6, - "height": 62.8 + "width": 146.4, + "height": 69.6 }, { - "width": 174, - "height": 40.8 + "width": 138.4, + "height": 46.8 }, { - "width": 168.8, - "height": 22.4 + "width": 132.4, + "height": 28 }, { - "width": 165.2, - "height": 10 + "width": 128.4, + "height": 13.2 }, { - "width": 162.8, - "height": 2.4 + "width": 125.6, + "height": 4 }, { - "width": 161.2, + "width": 124, "height": 0 }, { - "width": 160.4, + "width": 122.8, "height": 0 }, { - "width": 160, + "width": 122.4, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 160, + "width": 122, "height": 0 } ] @@ -298,19 +289,18 @@ 1, 1, 1, - 1, - 0.91758585, - 0.72435355, - 0.52812576, - 0.3665868, - 0.24600428, - 0.16102076, - 0.103373945, - 0.06533456, - 0.04075712, - 0.025142312, - 0.015358448, - 0.0092999935, + 0.9762947, + 0.8118515, + 0.60931784, + 0.43090785, + 0.29299664, + 0.19368339, + 0.12531388, + 0.079705715, + 0.049988627, + 0.030979574, + 0.019001365, + 0.011548042, 0, 0, 0, diff --git a/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_triggeredRevealOpenTransition.json b/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_triggeredRevealOpenTransition.json index 622c29eebfb4..7a02d369c7f2 100644 --- a/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_triggeredRevealOpenTransition.json +++ b/packages/SystemUI/compose/scene/tests/goldens/edge_verticalReveal_triggeredRevealOpenTransition.json @@ -19,9 +19,7 @@ 256, 272, 288, - 304, - 320, - 336 + 304 ], "features": [ { @@ -32,88 +30,80 @@ "type": "not_found" }, { - "x": 64, - "y": 50 + "x": 19.2, + "y": 5.2 }, { - "x": 59.2, - "y": 50 + "x": 15.6, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 8, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 - }, - { - "x": 50, - "y": 50 - }, - { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 } ] }, @@ -125,88 +115,80 @@ "type": "not_found" }, { - "width": 160, + "width": 122, "height": 0 }, { - "width": 169.6, - "height": 6.8 - }, - { - "width": 188, - "height": 26.8 + "width": 129.2, + "height": 5.2 }, { - "width": 188, - "height": 95.6 + "width": 144.4, + "height": 16 }, { - "width": 188, - "height": 163.2 + "width": 150, + "height": 62 }, { - "width": 188, - "height": 222 + "width": 150, + "height": 118.4 }, { - "width": 188, - "height": 269.6 + "width": 150, + "height": 166 }, { - "width": 188, - "height": 307.2 + "width": 150, + "height": 204 }, { - "width": 188, - "height": 335.2 + "width": 150, + "height": 233.2 }, { - "width": 188, - "height": 356 + "width": 150, + "height": 254.4 }, { - "width": 188, - "height": 370.4 + "width": 150, + "height": 270 }, { - "width": 188, - "height": 380.8 + "width": 150, + "height": 280.8 }, { - "width": 188, - "height": 387.6 + "width": 150, + "height": 288 }, { - "width": 188, - "height": 392.4 + "width": 150, + "height": 292.8 }, { - "width": 188, - "height": 395.2 + "width": 150, + "height": 296 }, { - "width": 188, - "height": 397.2 + "width": 150, + "height": 298 }, { - "width": 188, - "height": 398 + "width": 150, + "height": 298.8 }, { - "width": 188, - "height": 398.8 + "width": 150, + "height": 299.2 }, { - "width": 188, - "height": 399.2 + "width": 150, + "height": 299.6 }, { - "width": 188, - "height": 399.2 - }, - { - "width": 188, - "height": 399.6 + "width": 150, + "height": 299.6 } ] }, @@ -218,21 +200,19 @@ "type": "not_found" }, 0, - 0.05698657, - 0.24197984, - 0.44158113, - 0.6097554, - 0.73685503, - 0.8271309, - 0.8886989, - 0.9294886, - 0.9559254, - 0.97276413, - 0.98333716, - 0.98989624, - 1, - 1, - 1, + 0, + 0.0951103, + 0.2911651, + 0.48551244, + 0.6439433, + 0.76157355, + 0.8441935, + 0.9001033, + 0.9369305, + 0.96069145, + 0.97577035, + 0.98520935, + 0.9910494, 1, 1, 1, diff --git a/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_gesture_dragFullyClose.json b/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_gesture_dragFullyClose.json index 59e8b51412b8..f44d4cd7c14e 100644 --- a/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_gesture_dragFullyClose.json +++ b/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_gesture_dragFullyClose.json @@ -55,12 +55,7 @@ 832, 848, 864, - 880, - 896, - 912, - 928, - 944, - 960 + 880 ], "features": [ { @@ -68,248 +63,228 @@ "type": "dpOffset", "data_points": [ { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50.4 + "x": 5.2, + "y": 5.6 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 - }, - { - "x": 50, - "y": 50 - }, - { - "x": 50, - "y": 50 - }, - { - "x": 50, - "y": 50 - }, - { - "x": 50, - "y": 50 - }, - { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 } ] }, @@ -318,247 +293,227 @@ "type": "dpSize", "data_points": [ { - "width": 188, - "height": 400 - }, - { - "width": 188, - "height": 400 - }, - { - "width": 188, - "height": 400 - }, - { - "width": 188, - "height": 393.2 - }, - { - "width": 188, - "height": 393.2 - }, - { - "width": 188, - "height": 386 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 379.6 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 372.8 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 366.8 + "width": 150, + "height": 293.2 }, { - "width": 188, - "height": 360.4 + "width": 150, + "height": 293.2 }, { - "width": 188, - "height": 354 + "width": 150, + "height": 286 }, { - "width": 188, - "height": 347.6 + "width": 150, + "height": 279.6 }, { - "width": 188, - "height": 341.2 + "width": 150, + "height": 273.2 }, { - "width": 188, - "height": 341.2 + "width": 150, + "height": 266.8 }, { - "width": 188, - "height": 334 + "width": 150, + "height": 260.4 }, { - "width": 188, - "height": 328 + "width": 150, + "height": 254 }, { - "width": 188, - "height": 321.6 + "width": 150, + "height": 247.6 }, { - "width": 188, - "height": 315.2 + "width": 150, + "height": 241.2 }, { - "width": 188, - "height": 308.8 + "width": 150, + "height": 241.2 }, { - "width": 188, - "height": 302.4 + "width": 150, + "height": 234.4 }, { - "width": 188, - "height": 296 + "width": 150, + "height": 228 }, { - "width": 188, - "height": 289.6 + "width": 150, + "height": 221.6 }, { - "width": 188, - "height": 289.6 + "width": 150, + "height": 215.2 }, { - "width": 188, - "height": 282.8 + "width": 150, + "height": 208.8 }, { - "width": 188, - "height": 276.4 + "width": 150, + "height": 202 }, { - "width": 188, - "height": 270 + "width": 150, + "height": 195.6 }, { - "width": 188, - "height": 263.6 + "width": 150, + "height": 189.2 }, { - "width": 188, - "height": 257.2 + "width": 150, + "height": 189.2 }, { - "width": 188, - "height": 250.8 + "width": 150, + "height": 182.8 }, { - "width": 188, - "height": 244.4 + "width": 150, + "height": 176.4 }, { - "width": 188, - "height": 238 + "width": 150, + "height": 170 }, { - "width": 188, - "height": 238 + "width": 150, + "height": 163.6 }, { - "width": 188, - "height": 231.2 + "width": 150, + "height": 157.2 }, { - "width": 188, - "height": 224.8 + "width": 150, + "height": 150.8 }, { - "width": 188, - "height": 218.4 + "width": 150, + "height": 144.4 }, { - "width": 188, - "height": 212 + "width": 150, + "height": 137.6 }, { - "width": 188, - "height": 212 + "width": 150, + "height": 137.6 }, { - "width": 188, - "height": 192.4 + "width": 150, + "height": 131.2 }, { - "width": 188, - "height": 159.6 + "width": 150, + "height": 124.8 }, { - "width": 188, - "height": 124.4 + "width": 150, + "height": 118.4 }, { - "width": 188, - "height": 92.8 + "width": 150, + "height": 112 }, { - "width": 188, - "height": 64.8 + "width": 150, + "height": 112 }, { - "width": 188, - "height": 44.4 + "width": 150, + "height": 99.2 }, { - "width": 188, - "height": 29.2 + "width": 150, + "height": 84.4 }, { - "width": 188, - "height": 18.4 + "width": 150, + "height": 70.8 }, { - "width": 188, - "height": 10.8 + "width": 150, + "height": 58 }, { - "width": 188, - "height": 5.6 + "width": 150, + "height": 46.4 }, { - "width": 188, - "height": 2.4 + "width": 150, + "height": 36.4 }, { - "width": 188, - "height": 0.4 + "width": 150, + "height": 28 }, { - "width": 188, - "height": 0 + "width": 150, + "height": 20.8 }, { - "width": 188, - "height": 0 + "width": 150, + "height": 15.6 }, { - "width": 188, - "height": 0 + "width": 150, + "height": 11.2 }, { - "width": 188, - "height": 0 + "width": 150, + "height": 8 }, { - "width": 188, - "height": 0 + "width": 150, + "height": 5.6 }, { - "width": 188, - "height": 0 + "width": 150, + "height": 3.6 }, { - "width": 188, - "height": 0 + "width": 150, + "height": 2.4 }, { - "width": 188, - "height": 0 + "width": 150, + "height": 1.2 }, { - "width": 188, - "height": 0 + "width": 150, + "height": 0.8 }, { - "width": 188, - "height": 0 + "width": 150, + "height": 0.4 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 } ] @@ -609,24 +564,19 @@ 1, 1, 1, - 1, - 1, - 0.9808927, - 0.8211168, - 0.61845565, - 0.43834114, - 0.29850912, - 0.19755232, - 0.12793064, - 0.08142871, - 0.051099956, - 0.031684637, - 0.019442618, - 0.011821032, - 0, - 0, - 0, - 0, + 0.99781144, + 0.87040234, + 0.6695792, + 0.48078007, + 0.33033127, + 0.22004372, + 0.1432175, + 0.09153092, + 0.057634592, + 0.035840213, + 0.022048414, + 0.013435662, + 0.008117795, 0 ] } diff --git a/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_gesture_dragHalfClose.json b/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_gesture_dragHalfClose.json index 210ff0985e78..9b68c71a7a34 100644 --- a/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_gesture_dragHalfClose.json +++ b/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_gesture_dragHalfClose.json @@ -58,7 +58,8 @@ 880, 896, 912, - 928 + 928, + 944 ], "features": [ { @@ -66,240 +67,244 @@ "type": "dpOffset", "data_points": [ { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50.8, - "y": 52 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.6, + "y": 6.8 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 + }, + { + "x": 5.2, + "y": 5.2 } ] }, @@ -308,239 +313,243 @@ "type": "dpSize", "data_points": [ { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 390 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 390 + "width": 150, + "height": 297.6 }, { - "width": 188, - "height": 379.2 + "width": 150, + "height": 294 }, { - "width": 188, - "height": 371.2 + "width": 150, + "height": 287.6 }, { - "width": 188, - "height": 363.2 + "width": 150, + "height": 282.8 }, { - "width": 188, - "height": 355.2 + "width": 150, + "height": 278 }, { - "width": 188, - "height": 347.2 + "width": 150, + "height": 273.2 }, { - "width": 188, - "height": 339.2 + "width": 150, + "height": 268.4 }, { - "width": 188, - "height": 331.2 + "width": 150, + "height": 263.6 }, { - "width": 188, - "height": 323.2 + "width": 150, + "height": 258.8 }, { - "width": 188, - "height": 323.2 + "width": 150, + "height": 258.8 }, { - "width": 188, - "height": 314.8 + "width": 150, + "height": 253.6 }, { - "width": 188, - "height": 306.8 + "width": 150, + "height": 248.8 }, { - "width": 188, - "height": 298.8 + "width": 150, + "height": 244 }, { - "width": 188, - "height": 290.8 + "width": 150, + "height": 239.2 }, { - "width": 188, - "height": 282.8 + "width": 150, + "height": 234.4 }, { - "width": 188, - "height": 274.8 + "width": 150, + "height": 229.6 }, { - "width": 188, - "height": 266.8 + "width": 150, + "height": 224.8 }, { - "width": 188, - "height": 258.8 + "width": 150, + "height": 220 }, { - "width": 188, - "height": 258.8 + "width": 150, + "height": 220 }, { - "width": 188, - "height": 250.4 + "width": 150, + "height": 214.8 }, { - "width": 188, - "height": 242.4 + "width": 150, + "height": 210 }, { - "width": 188, - "height": 234.4 + "width": 150, + "height": 205.2 }, { - "width": 188, - "height": 226.4 + "width": 150, + "height": 200.4 }, { - "width": 188, - "height": 218.4 + "width": 150, + "height": 195.6 }, { - "width": 188, - "height": 210.4 + "width": 150, + "height": 190.8 }, { - "width": 188, - "height": 202.4 + "width": 150, + "height": 186 }, { - "width": 188, - "height": 194.4 + "width": 150, + "height": 181.2 }, { - "width": 188, - "height": 194.4 + "width": 150, + "height": 181.2 }, { - "width": 188, - "height": 185.6 + "width": 150, + "height": 176.4 }, { - "width": 188, - "height": 178 + "width": 150, + "height": 171.6 }, { - "width": 188, - "height": 170 + "width": 150, + "height": 166.8 }, { - "width": 188, + "width": 150, "height": 161.6 }, { - "width": 188, + "width": 150, "height": 161.6 }, { - "width": 188, - "height": 144.8 + "width": 150, + "height": 147.2 }, { - "width": 188, - "height": 118.8 + "width": 150, + "height": 122 }, { - "width": 188, - "height": 92 + "width": 150, + "height": 95.2 }, { - "width": 188, - "height": 68 + "width": 150, + "height": 70.8 }, { - "width": 188, - "height": 49.6 + "width": 150, + "height": 51.6 }, { - "width": 188, - "height": 35.2 + "width": 150, + "height": 36.8 }, { - "width": 188, - "height": 24.4 + "width": 150, + "height": 25.6 }, { - "width": 188, - "height": 16.4 + "width": 150, + "height": 17.2 }, { - "width": 188, - "height": 10.4 + "width": 150, + "height": 11.2 }, { - "width": 188, - "height": 6.4 + "width": 150, + "height": 6.8 }, { - "width": 188, - "height": 3.6 + "width": 150, + "height": 4 }, { - "width": 188, - "height": 1.6 + "width": 150, + "height": 2 }, { - "width": 188, - "height": 0.4 + "width": 150, + "height": 0.8 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, + "height": 0 + }, + { + "width": 150, "height": 0 } ] @@ -592,19 +601,20 @@ 1, 1, 1, - 0.9967737, - 0.86538374, - 0.66414475, - 0.47619528, - 0.32686388, - 0.21757984, - 0.14153665, - 0.09041709, - 0.05691254, - 0.035380244, - 0.02175957, - 0.01325649, - 0.008007765, + 0.99979615, + 0.8860379, + 0.6869267, + 0.4955439, + 0.34154767, + 0.22803628, + 0.14868057, + 0.09515619, + 0.059987247, + 0.037340224, + 0.02299112, + 0.01402092, + 0.008477271, + 0, 0, 0, 0 diff --git a/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_gesture_dragOpen.json b/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_gesture_dragOpen.json index d186df22dda0..1bf6a62d02af 100644 --- a/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_gesture_dragOpen.json +++ b/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_gesture_dragOpen.json @@ -68,200 +68,200 @@ "type": "not_found" }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 } ] }, @@ -279,200 +279,200 @@ "type": "not_found" }, { - "width": 188, + "width": 150, "height": 1.6 }, { - "width": 188, + "width": 150, "height": 1.6 }, { - "width": 188, + "width": 150, "height": 3.2 }, { - "width": 188, + "width": 150, "height": 4.8 }, { - "width": 188, + "width": 150, "height": 6.4 }, { - "width": 188, + "width": 150, "height": 8 }, { - "width": 188, + "width": 150, "height": 9.6 }, { - "width": 188, + "width": 150, "height": 11.2 }, { - "width": 188, + "width": 150, "height": 12.8 }, { - "width": 188, + "width": 150, "height": 14.4 }, { - "width": 188, + "width": 150, "height": 14.4 }, { - "width": 188, + "width": 150, "height": 16.4 }, { - "width": 188, + "width": 150, "height": 18 }, { - "width": 188, + "width": 150, "height": 19.6 }, { - "width": 188, - "height": 21.2 + "width": 150, + "height": 20.8 }, { - "width": 188, + "width": 150, "height": 22.8 }, { - "width": 188, + "width": 150, "height": 24.4 }, { - "width": 188, + "width": 150, "height": 26 }, { - "width": 188, + "width": 150, "height": 27.6 }, { - "width": 188, + "width": 150, "height": 27.6 }, { - "width": 188, + "width": 150, "height": 29.2 }, { - "width": 188, + "width": 150, "height": 30.8 }, { - "width": 188, + "width": 150, "height": 32.4 }, { - "width": 188, + "width": 150, "height": 34 }, { - "width": 188, + "width": 150, "height": 40.4 }, { - "width": 188, + "width": 150, "height": 52.4 }, { - "width": 188, + "width": 150, "height": 64.8 }, { - "width": 188, + "width": 150, "height": 83.2 }, { - "width": 188, + "width": 150, "height": 96 }, { - "width": 188, + "width": 150, "height": 114.8 }, { - "width": 188, + "width": 150, "height": 132 }, { - "width": 188, + "width": 150, "height": 148 }, { - "width": 188, + "width": 150, "height": 162 }, { - "width": 188, + "width": 150, "height": 168.4 }, { - "width": 188, - "height": 192.8 + "width": 150, + "height": 186 }, { - "width": 188, - "height": 229.6 + "width": 150, + "height": 208 }, { - "width": 188, - "height": 268 + "width": 150, + "height": 229.6 }, { - "width": 188, - "height": 302 + "width": 150, + "height": 248.4 }, { - "width": 188, - "height": 330 + "width": 150, + "height": 263.2 }, { - "width": 188, - "height": 351.6 + "width": 150, + "height": 274.8 }, { - "width": 188, - "height": 367.6 + "width": 150, + "height": 283.2 }, { - "width": 188, - "height": 379.2 + "width": 150, + "height": 289.2 }, { - "width": 188, - "height": 387.2 + "width": 150, + "height": 293.6 }, { - "width": 188, - "height": 392.4 + "width": 150, + "height": 296 }, { - "width": 188, - "height": 395.6 + "width": 150, + "height": 298 }, { - "width": 188, - "height": 398 + "width": 150, + "height": 298.8 }, { - "width": 188, - "height": 398.8 + "width": 150, + "height": 299.6 }, { - "width": 188, - "height": 399.6 + "width": 150, + "height": 299.6 }, { - "width": 188, - "height": 400 + "width": 150, + "height": 300 } ] }, @@ -494,12 +494,12 @@ 0, 0, 0.0067873597, - 0.0612576, - 0.19080025, + 0.06125766, + 0.19080031, 0.39327443, 0.5711931, - 0.70855826, - 0.8074064, + 0.7085583, + 0.8074065, 0.8754226, 0.9207788, 0.95032376, diff --git a/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_gesture_flingClose.json b/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_gesture_flingClose.json index a9c24fa87089..86805bd6ff29 100644 --- a/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_gesture_flingClose.json +++ b/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_gesture_flingClose.json @@ -39,9 +39,7 @@ 576, 592, 608, - 624, - 640, - 656 + 624 ], "features": [ { @@ -49,172 +47,164 @@ "type": "dpOffset", "data_points": [ { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50.4, - "y": 50.8 + "x": 5.6, + "y": 6.4 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 - }, - { - "x": 50, - "y": 50 - }, - { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 } ] }, @@ -223,171 +213,163 @@ "type": "dpSize", "data_points": [ { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 389.6 + "width": 150, + "height": 290 }, { - "width": 188, - "height": 378.8 + "width": 150, + "height": 278.8 }, { - "width": 188, - "height": 366 + "width": 150, + "height": 266 }, { - "width": 188, - "height": 352 + "width": 150, + "height": 252 }, { - "width": 188, - "height": 352 + "width": 150, + "height": 252 }, { - "width": 188, - "height": 316.8 + "width": 150, + "height": 223.6 }, { - "width": 188, - "height": 261.2 + "width": 150, + "height": 182.8 }, { - "width": 188, - "height": 202.8 + "width": 150, + "height": 141.2 }, { - "width": 188, - "height": 150.8 + "width": 150, + "height": 104 }, { - "width": 188, - "height": 107.6 + "width": 150, + "height": 72 }, { - "width": 188, - "height": 71.2 + "width": 150, + "height": 46 }, { - "width": 188, - "height": 41.6 + "width": 150, + "height": 28 }, { - "width": 188, - "height": 21.6 + "width": 150, + "height": 15.6 }, { - "width": 188, - "height": 8.4 + "width": 150, + "height": 7.2 }, { - "width": 188, - "height": 0.4 - }, - { - "width": 188, - "height": 0 + "width": 150, + "height": 2 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, - "height": 0 - }, - { - "width": 188, + "width": 150, "height": 0 } ] @@ -418,21 +400,19 @@ 1, 1, 1, - 1, - 0.9833227, - 0.8263634, - 0.623688, - 0.44261706, - 0.3016883, - 0.1997872, - 0.12944388, - 0.08242595, - 0.051743627, - 0.032093227, - 0.019698441, - 0.0119793415, - 0, - 0, + 0.99479187, + 0.8575029, + 0.65572864, + 0.4691311, + 0.3215357, + 0.21380007, + 0.13896108, + 0.0887118, + 0.05580789, + 0.03467691, + 0.021318138, + 0.0129826665, + 0.007839739, 0, 0, 0, diff --git a/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_gesture_flingOpen.json b/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_gesture_flingOpen.json index f9279f1fae5c..98519db9e848 100644 --- a/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_gesture_flingOpen.json +++ b/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_gesture_flingOpen.json @@ -66,112 +66,112 @@ "type": "not_found" }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 } ] }, @@ -204,112 +204,112 @@ "type": "not_found" }, { - "width": 188, + "width": 150, "height": 2 }, { - "width": 188, + "width": 150, "height": 4.4 }, { - "width": 188, + "width": 150, "height": 6.8 }, { - "width": 188, + "width": 150, "height": 10 }, { - "width": 188, + "width": 150, "height": 13.2 }, { - "width": 188, + "width": 150, "height": 16.8 }, { - "width": 188, + "width": 150, "height": 16.8 }, { - "width": 188, - "height": 25.2 + "width": 150, + "height": 23.6 }, { - "width": 188, - "height": 53.2 + "width": 150, + "height": 32.8 }, { - "width": 188, - "height": 119.6 + "width": 150, + "height": 76.8 }, { - "width": 188, - "height": 182 + "width": 150, + "height": 123.6 }, { - "width": 188, - "height": 235.6 + "width": 150, + "height": 164.8 }, { - "width": 188, - "height": 279.2 + "width": 150, + "height": 198.4 }, { - "width": 188, - "height": 313.2 + "width": 150, + "height": 225.6 }, { - "width": 188, - "height": 338.8 + "width": 150, + "height": 246.4 }, { - "width": 188, - "height": 357.6 + "width": 150, + "height": 262 }, { - "width": 188, - "height": 371.2 + "width": 150, + "height": 273.2 }, { - "width": 188, - "height": 380.8 + "width": 150, + "height": 281.6 }, { - "width": 188, - "height": 387.6 + "width": 150, + "height": 287.6 }, { - "width": 188, - "height": 392 + "width": 150, + "height": 292 }, { - "width": 188, - "height": 395.2 + "width": 150, + "height": 294.8 }, { - "width": 188, - "height": 396.8 + "width": 150, + "height": 296.4 }, { - "width": 188, - "height": 398 + "width": 150, + "height": 297.6 }, { - "width": 188, - "height": 398.8 + "width": 150, + "height": 298.4 }, { - "width": 188, - "height": 399.2 + "width": 150, + "height": 299.2 }, { - "width": 188, - "height": 399.6 + "width": 150, + "height": 299.6 }, { - "width": 188, - "height": 399.6 + "width": 150, + "height": 299.6 } ] }, diff --git a/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_gesture_magneticDetachAndReattach.json b/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_gesture_magneticDetachAndReattach.json index 2504e57a927b..850cee9130d0 100644 --- a/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_gesture_magneticDetachAndReattach.json +++ b/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_gesture_magneticDetachAndReattach.json @@ -68,7 +68,10 @@ 1040, 1056, 1072, - 1088 + 1088, + 1104, + 1120, + 1136 ], "features": [ { @@ -85,267 +88,280 @@ "type": "not_found" }, { - "type": "not_found" + "x": 5.2, + "y": 5.2 + }, + { + "x": 5.2, + "y": 5.2 + }, + { + "x": 5.2, + "y": 5.2 + }, + { + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 } ] }, @@ -363,266 +379,279 @@ "type": "not_found" }, { - "type": "not_found" + "width": 150, + "height": 2.8 }, { - "width": 188, - "height": 1.6 + "width": 150, + "height": 4.8 }, { - "width": 188, - "height": 2.8 + "width": 150, + "height": 6.8 }, { - "width": 188, - "height": 4 + "width": 150, + "height": 8.4 }, { - "width": 188, - "height": 5.2 + "width": 150, + "height": 10.4 }, { - "width": 188, - "height": 6.4 + "width": 150, + "height": 12.4 }, { - "width": 188, - "height": 7.6 + "width": 150, + "height": 14 }, { - "width": 188, - "height": 8.8 + "width": 150, + "height": 16 }, { - "width": 188, - "height": 10 + "width": 150, + "height": 17.6 }, { - "width": 188, - "height": 10.8 + "width": 150, + "height": 19.2 }, { - "width": 188, - "height": 12 + "width": 150, + "height": 20.8 }, { - "width": 188, - "height": 12.8 + "width": 150, + "height": 22.4 }, { - "width": 188, - "height": 13.6 + "width": 150, + "height": 24 }, { - "width": 188, - "height": 14.8 + "width": 150, + "height": 25.6 }, { - "width": 188, - "height": 15.6 + "width": 150, + "height": 26.8 }, { - "width": 188, - "height": 16.4 + "width": 150, + "height": 28 }, { - "width": 188, - "height": 17.2 + "width": 150, + "height": 29.2 }, { - "width": 188, - "height": 17.6 + "width": 150, + "height": 30.4 }, { - "width": 188, - "height": 18.4 + "width": 150, + "height": 31.6 }, { - "width": 188, - "height": 19.2 + "width": 150, + "height": 32.4 }, { - "width": 188, - "height": 19.6 + "width": 150, + "height": 33.2 }, { - "width": 188, - "height": 20 + "width": 150, + "height": 34 }, { - "width": 188, - "height": 20.4 + "width": 150, + "height": 36.8 }, { - "width": 188, - "height": 20.8 + "width": 150, + "height": 42.4 }, { - "width": 188, - "height": 21.2 + "width": 150, + "height": 50.8 }, { - "width": 188, - "height": 21.6 + "width": 150, + "height": 64 }, { - "width": 188, - "height": 21.6 + "width": 150, + "height": 78 }, { - "width": 188, - "height": 21.6 + "width": 150, + "height": 91.2 }, { - "width": 188, - "height": 21.6 + "width": 150, + "height": 102.4 }, { - "width": 188, - "height": 21.6 + "width": 150, + "height": 112.4 }, { - "width": 188, - "height": 21.6 + "width": 150, + "height": 120 }, { - "width": 188, - "height": 21.6 + "width": 150, + "height": 126 }, { - "width": 188, - "height": 21.6 + "width": 150, + "height": 130 }, { - "width": 188, - "height": 21.2 + "width": 150, + "height": 132.8 }, { - "width": 188, - "height": 20.8 + "width": 150, + "height": 134 }, { - "width": 188, - "height": 20.4 + "width": 150, + "height": 134 }, { - "width": 188, - "height": 20 + "width": 150, + "height": 133.2 }, { - "width": 188, - "height": 19.6 + "width": 150, + "height": 131.2 }, { - "width": 188, - "height": 19.2 + "width": 150, + "height": 128.8 }, { - "width": 188, - "height": 18.4 + "width": 150, + "height": 125.2 }, { - "width": 188, - "height": 17.6 + "width": 150, + "height": 121.6 }, { - "width": 188, - "height": 17.2 + "width": 150, + "height": 117.6 }, { - "width": 188, - "height": 16.4 + "width": 150, + "height": 112.8 }, { - "width": 188, - "height": 15.6 + "width": 150, + "height": 108 }, { - "width": 188, - "height": 14.8 + "width": 150, + "height": 102.4 }, { - "width": 188, - "height": 13.6 + "width": 150, + "height": 96.4 }, { - "width": 188, - "height": 12.8 + "width": 150, + "height": 91.2 }, { - "width": 188, - "height": 12 + "width": 150, + "height": 88 }, { - "width": 188, - "height": 10.8 + "width": 150, + "height": 81.6 }, { - "width": 188, - "height": 10 + "width": 150, + "height": 70.8 }, { - "width": 188, - "height": 8.8 + "width": 150, + "height": 59.2 }, { - "width": 188, - "height": 7.6 + "width": 150, + "height": 48 }, { - "width": 188, - "height": 6.4 + "width": 150, + "height": 38.4 }, { - "width": 188, - "height": 5.2 + "width": 150, + "height": 30 }, { - "width": 188, - "height": 4 + "width": 150, + "height": 22.8 }, { - "width": 188, - "height": 2.8 + "width": 150, + "height": 17.2 }, { - "width": 188, - "height": 1.6 + "width": 150, + "height": 12.4 }, { - "width": 188, - "height": 0.4 + "width": 150, + "height": 9.2 }, { - "width": 188, - "height": 0 + "width": 150, + "height": 6.4 }, { - "width": 188, - "height": 0 + "width": 150, + "height": 4.4 }, { - "width": 188, - "height": 0 + "width": 150, + "height": 2.8 + }, + { + "width": 150, + "height": 1.6 + }, + { + "width": 150, + "height": 1.2 + }, + { + "width": 150, + "height": 0.4 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 } ] @@ -640,26 +669,27 @@ { "type": "not_found" }, - { - "type": "not_found" - }, - 0, - 0, 0, 0, - 0.012518823, - 0.0741024, - 0.2254293, - 0.42628878, - 0.5976641, - 0.7280312, - 0.82100236, - 0.8845844, - 0.9267946, - 0.95419544, - 0.9716705, - 0.98265487, - 0.98947525, + 0.0066464543, + 0.059778452, + 0.1875459, + 0.39009166, + 0.5686131, + 0.70664865, + 0.8060679, + 0.87451804, + 0.92018366, + 0.94994, + 0.9689752, + 0.9809703, + 0.98843443, + 1, + 1, + 1, + 1, + 1, + 1, 1, 1, 1, @@ -695,19 +725,19 @@ 1, 1, 1, - 0.9944124, - 0.9417388, - 0.8184184, - 0.6157812, - 0.4361611, - 0.2968906, - 0.19641554, - 0.12716137, - 0.080921985, - 0.050773025, - 0.03147719, - 0.019312752, - 0.011740655 + 0.98828065, + 0.9288363, + 0.7806658, + 0.57941735, + 0.40687433, + 0.27529213, + 0.18131107, + 0.11697123, + 0.074225225, + 0.046460062, + 0.028744182, + 0.017604083, + 0.010684598 ] } ] diff --git a/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_triggeredRevealCloseTransition.json b/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_triggeredRevealCloseTransition.json index 86fac739372e..afa005ac421e 100644 --- a/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_triggeredRevealCloseTransition.json +++ b/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_triggeredRevealCloseTransition.json @@ -27,8 +27,7 @@ 384, 400, 416, - 432, - 448 + 432 ], "features": [ { @@ -36,120 +35,116 @@ "type": "dpOffset", "data_points": [ { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 - }, - { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 } ] }, @@ -158,119 +153,115 @@ "type": "dpSize", "data_points": [ { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 400 + "width": 150, + "height": 300 }, { - "width": 188, - "height": 372 + "width": 150, + "height": 278.8 }, { - "width": 188, - "height": 312.8 + "width": 150, + "height": 234.8 }, { - "width": 188, - "height": 246.8 - }, - { - "width": 188, + "width": 150, "height": 185.2 }, { - "width": 188, - "height": 133.6 + "width": 150, + "height": 138.8 }, { - "width": 188, - "height": 93.2 + "width": 150, + "height": 100.4 }, { - "width": 188, - "height": 58.8 + "width": 150, + "height": 66.8 }, { - "width": 188, - "height": 34.4 + "width": 150, + "height": 41.6 }, { - "width": 188, - "height": 18 + "width": 150, + "height": 23.6 }, { - "width": 188, - "height": 7.6 + "width": 150, + "height": 12 }, { - "width": 188, - "height": 0.8 + "width": 150, + "height": 4.4 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, + "width": 150, "height": 0 } ] @@ -289,19 +280,18 @@ 1, 1, 1, - 1, - 0.91758585, - 0.72435355, - 0.52812576, - 0.3665868, - 0.24600428, - 0.16102076, - 0.103373945, - 0.06533456, - 0.04075712, - 0.025142312, - 0.015358448, - 0.0092999935, + 0.9762947, + 0.8118515, + 0.60931784, + 0.43090785, + 0.29299664, + 0.19368339, + 0.12531388, + 0.079705715, + 0.049988627, + 0.030979574, + 0.019001365, + 0.011548042, 0, 0, 0, diff --git a/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_triggeredRevealOpenTransition.json b/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_triggeredRevealOpenTransition.json index ad282f216f8f..317d4804fa52 100644 --- a/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_triggeredRevealOpenTransition.json +++ b/packages/SystemUI/compose/scene/tests/goldens/floating_verticalReveal_triggeredRevealOpenTransition.json @@ -21,7 +21,8 @@ 288, 304, 320, - 336 + 336, + 352 ], "features": [ { @@ -32,88 +33,92 @@ "type": "not_found" }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 }, { - "x": 50, - "y": 50 + "x": 5.2, + "y": 5.2 + }, + { + "x": 5.2, + "y": 5.2 } ] }, @@ -125,88 +130,92 @@ "type": "not_found" }, { - "width": 188, + "width": 150, "height": 0 }, { - "width": 188, - "height": 6.8 + "width": 150, + "height": 5.2 }, { - "width": 188, - "height": 21.6 + "width": 150, + "height": 16 }, { - "width": 188, - "height": 52.8 + "width": 150, + "height": 28.4 }, { - "width": 188, - "height": 129.6 + "width": 150, + "height": 63.6 }, { - "width": 188, - "height": 196.4 + "width": 150, + "height": 116.4 }, { - "width": 188, - "height": 250.4 + "width": 150, + "height": 161.2 }, { - "width": 188, - "height": 293.2 + "width": 150, + "height": 197.2 }, { - "width": 188, - "height": 325.2 + "width": 150, + "height": 225.2 }, { - "width": 188, - "height": 348.8 + "width": 150, + "height": 246.8 }, { - "width": 188, - "height": 365.6 + "width": 150, + "height": 262.4 }, { - "width": 188, - "height": 377.2 + "width": 150, + "height": 274 }, { - "width": 188, - "height": 385.6 + "width": 150, + "height": 282.4 }, { - "width": 188, - "height": 391.2 + "width": 150, + "height": 288.4 }, { - "width": 188, - "height": 394.8 + "width": 150, + "height": 292.4 }, { - "width": 188, - "height": 396.8 + "width": 150, + "height": 294.8 }, { - "width": 188, - "height": 398 + "width": 150, + "height": 296.4 }, { - "width": 188, - "height": 398.8 + "width": 150, + "height": 297.6 }, { - "width": 188, - "height": 399.2 + "width": 150, + "height": 298.4 }, { - "width": 188, - "height": 399.6 + "width": 150, + "height": 299.2 }, { - "width": 188, - "height": 399.6 + "width": 150, + "height": 299.6 + }, + { + "width": 150, + "height": 299.6 } ] }, @@ -218,18 +227,19 @@ "type": "not_found" }, 0, - 0.05698657, - 0.24197984, - 0.44158113, - 0.6097554, - 0.73685503, - 0.8271309, - 0.8886989, - 0.9294886, - 0.9559254, - 0.97276413, - 0.98333716, - 0.98989624, + 0, + 0.0951103, + 0.2911651, + 0.48551244, + 0.6439433, + 0.76157355, + 0.8441935, + 0.9001033, + 0.9369305, + 0.96069145, + 0.97577035, + 0.98520935, + 0.9910494, 1, 1, 1, diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/reveal/ContentRevealTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/reveal/ContentRevealTest.kt index ed73d100dc6b..1bc83e0401bf 100644 --- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/reveal/ContentRevealTest.kt +++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/reveal/ContentRevealTest.kt @@ -111,10 +111,12 @@ class ContentRevealTest(private val isFloating: Boolean) { assertVerticalContainerRevealMotion( GestureRevealMotion(SceneClosed) { val gestureDurationMillis = 1000L + // detach position for the floating container is larger + val gestureHeight = if (isFloating) 160.dp.toPx() else 100.dp.toPx() swipe( curve = { val progress = it / gestureDurationMillis.toFloat() - val y = sin(progress * Math.PI).toFloat() * 100.dp.toPx() + val y = sin(progress * Math.PI).toFloat() * gestureHeight Offset(centerX, y) }, gestureDurationMillis, @@ -159,7 +161,7 @@ class ContentRevealTest(private val isFloating: Boolean) { fun verticalReveal_gesture_dragHalfClose() { assertVerticalContainerRevealMotion( GestureRevealMotion(SceneOpen) { - swipeUp(350.dp.toPx(), 100.dp.toPx(), durationMillis = 500) + swipeUp(250.dp.toPx(), 100.dp.toPx(), durationMillis = 500) }, "verticalReveal_gesture_dragHalfClose", ) @@ -251,9 +253,9 @@ class ContentRevealTest(private val isFloating: Boolean) { SceneTransitionLayoutForTesting( state, modifier = - Modifier.padding(50.dp) + Modifier.padding(5.dp) .background(Color.Yellow) - .size(ContainerSize.width, ContainerSize.height + 200.dp) + .size(ContainerSize.width, ContainerSize.height + 100.dp) .testTag("stl"), ) { scene( @@ -298,7 +300,7 @@ class ContentRevealTest(private val isFloating: Boolean) { companion object { @get:Parameters @JvmStatic val parameterValues = listOf(true, false) - val ContainerSize = DpSize(200.dp, 400.dp) + val ContainerSize = DpSize(150.dp, 300.dp) val FlingVelocity = 1000.dp // dp/sec diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/ActiveUnlockConfigTest.kt b/packages/SystemUI/multivalentTests/src/com/android/keyguard/ActiveUnlockConfigTest.kt index 14d34d79512f..162218d8f071 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/ActiveUnlockConfigTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/keyguard/ActiveUnlockConfigTest.kt @@ -87,7 +87,7 @@ class ActiveUnlockConfigTest : SysuiTestCase() { contentResolver, selectedUserInteractor, lazyKeyguardUpdateMonitor, - dumpManager + dumpManager, ) } @@ -116,9 +116,9 @@ class ActiveUnlockConfigTest : SysuiTestCase() { ) ) assertFalse( - activeUnlockConfig.shouldAllowActiveUnlockFromOrigin( - ActiveUnlockConfig.ActiveUnlockRequestOrigin.UNLOCK_INTENT_LEGACY - ) + activeUnlockConfig.shouldAllowActiveUnlockFromOrigin( + ActiveUnlockConfig.ActiveUnlockRequestOrigin.UNLOCK_INTENT_LEGACY + ) ) assertTrue( activeUnlockConfig.shouldAllowActiveUnlockFromOrigin( @@ -212,7 +212,7 @@ class ActiveUnlockConfigTest : SysuiTestCase() { secureSettings.putStringForUser( ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED, "", - currentUser + currentUser, ) updateSetting( secureSettings.getUriFor(ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED) @@ -285,7 +285,7 @@ class ActiveUnlockConfigTest : SysuiTestCase() { ACTIVE_UNLOCK_ON_FACE_ACQUIRE_INFO, "${BiometricFaceConstants.FACE_ACQUIRED_MOUTH_COVERING_DETECTED}" + "|${BiometricFaceConstants.FACE_ACQUIRED_DARK_GLASSES_DETECTED}", - currentUser + currentUser, ) updateSetting(secureSettings.getUriFor(ACTIVE_UNLOCK_ON_FACE_ACQUIRE_INFO)) @@ -328,7 +328,7 @@ class ActiveUnlockConfigTest : SysuiTestCase() { secureSettings.putStringForUser( ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED, "${ActiveUnlockConfig.BiometricType.NONE.intValue}", - currentUser + currentUser, ) updateSetting( secureSettings.getUriFor(ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED) @@ -358,7 +358,7 @@ class ActiveUnlockConfigTest : SysuiTestCase() { ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED, "${ActiveUnlockConfig.BiometricType.ANY_FACE.intValue}" + "|${ActiveUnlockConfig.BiometricType.ANY_FINGERPRINT.intValue}", - currentUser + currentUser, ) updateSetting( secureSettings.getUriFor(ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED) @@ -397,10 +397,10 @@ class ActiveUnlockConfigTest : SysuiTestCase() { @Test fun isWakeupConsideredUnlockIntent_singleValue() { // GIVEN lift is considered an unlock intent - secureSettings.putIntForUser( + secureSettings.putStringForUser( ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS, - PowerManager.WAKE_REASON_LIFT, - currentUser + PowerManager.WAKE_REASON_LIFT.toString(), + currentUser, ) updateSetting(secureSettings.getUriFor(ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS)) @@ -422,7 +422,7 @@ class ActiveUnlockConfigTest : SysuiTestCase() { PowerManager.WAKE_REASON_LIFT.toString() + "|" + PowerManager.WAKE_REASON_TAP.toString(), - currentUser + currentUser, ) updateSetting(secureSettings.getUriFor(ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS)) @@ -452,7 +452,7 @@ class ActiveUnlockConfigTest : SysuiTestCase() { secureSettings.putStringForUser( ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS, " ", - currentUser + currentUser, ) updateSetting(secureSettings.getUriFor(ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS)) @@ -479,7 +479,7 @@ class ActiveUnlockConfigTest : SysuiTestCase() { secureSettings.putStringForUser( ACTIVE_UNLOCK_WAKEUPS_TO_FORCE_DISMISS_KEYGUARD, PowerManager.WAKE_REASON_LIFT.toString(), - currentUser + currentUser, ) updateSetting(secureSettings.getUriFor(ACTIVE_UNLOCK_WAKEUPS_TO_FORCE_DISMISS_KEYGUARD)) @@ -501,7 +501,7 @@ class ActiveUnlockConfigTest : SysuiTestCase() { secureSettings.putStringForUser( ACTIVE_UNLOCK_WAKEUPS_TO_FORCE_DISMISS_KEYGUARD, " ", - currentUser + currentUser, ) updateSetting(secureSettings.getUriFor(ACTIVE_UNLOCK_WAKEUPS_TO_FORCE_DISMISS_KEYGUARD)) @@ -521,7 +521,7 @@ class ActiveUnlockConfigTest : SysuiTestCase() { PowerManager.WAKE_REASON_LIFT.toString() + "|" + PowerManager.WAKE_REASON_TAP.toString(), - currentUser + currentUser, ) updateSetting(secureSettings.getUriFor(ACTIVE_UNLOCK_WAKEUPS_TO_FORCE_DISMISS_KEYGUARD)) @@ -544,7 +544,7 @@ class ActiveUnlockConfigTest : SysuiTestCase() { secureSettings.putStringForUser( ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED, "-1", - currentUser + currentUser, ) // WHEN the setting updates @@ -581,7 +581,7 @@ class ActiveUnlockConfigTest : SysuiTestCase() { eq(uri), eq(false), capture(settingsObserverCaptor), - eq(UserHandle.USER_ALL) + eq(UserHandle.USER_ALL), ) } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardUnfoldTransitionTest.kt b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardUnfoldTransitionTest.kt index 245388c214a5..b0db8b70d296 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardUnfoldTransitionTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardUnfoldTransitionTest.kt @@ -22,12 +22,12 @@ import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.customization.R as customR import com.android.systemui.keyguard.ui.view.KeyguardRootView -import com.android.systemui.kosmos.Kosmos import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.res.R import com.android.systemui.shade.NotificationShadeWindowView import com.android.systemui.statusbar.StatusBarState.KEYGUARD import com.android.systemui.statusbar.StatusBarState.SHADE +import com.android.systemui.testKosmos import com.android.systemui.unfold.FakeUnfoldTransitionProvider import com.android.systemui.unfold.UnfoldTransitionProgressProvider.TransitionProgressListener import com.android.systemui.unfold.fakeUnfoldTransitionProgressProvider @@ -47,16 +47,14 @@ import org.mockito.kotlin.whenever @RunWith(AndroidJUnit4::class) class KeyguardUnfoldTransitionTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val progressProvider: FakeUnfoldTransitionProvider = kosmos.fakeUnfoldTransitionProgressProvider - @Mock - private lateinit var keyguardRootView: KeyguardRootView + @Mock private lateinit var keyguardRootView: KeyguardRootView - @Mock - private lateinit var notificationShadeWindowView: NotificationShadeWindowView + @Mock private lateinit var notificationShadeWindowView: NotificationShadeWindowView @Mock private lateinit var statusBarStateController: StatusBarStateController @@ -71,10 +69,14 @@ class KeyguardUnfoldTransitionTest : SysuiTestCase() { xTranslationMax = context.resources.getDimensionPixelSize(R.dimen.keyguard_unfold_translation_x).toFloat() - underTest = KeyguardUnfoldTransition( - context, keyguardRootView, notificationShadeWindowView, - statusBarStateController, progressProvider - ) + underTest = + KeyguardUnfoldTransition( + context, + keyguardRootView, + notificationShadeWindowView, + statusBarStateController, + progressProvider, + ) underTest.setup() underTest.statusViewCentered = false @@ -88,9 +90,8 @@ class KeyguardUnfoldTransitionTest : SysuiTestCase() { underTest.statusViewCentered = true val view = View(context) - whenever(keyguardRootView.findViewById<View>(customR.id.lockscreen_clock_view_large)).thenReturn( - view - ) + whenever(keyguardRootView.findViewById<View>(customR.id.lockscreen_clock_view_large)) + .thenReturn(view) progressListener.onTransitionStarted() assertThat(view.translationX).isZero() @@ -110,9 +111,8 @@ class KeyguardUnfoldTransitionTest : SysuiTestCase() { whenever(statusBarStateController.getState()).thenReturn(SHADE) val view = View(context) - whenever(keyguardRootView.findViewById<View>(customR.id.lockscreen_clock_view_large)).thenReturn( - view - ) + whenever(keyguardRootView.findViewById<View>(customR.id.lockscreen_clock_view_large)) + .thenReturn(view) progressListener.onTransitionStarted() assertThat(view.translationX).isZero() @@ -133,9 +133,11 @@ class KeyguardUnfoldTransitionTest : SysuiTestCase() { val view = View(context) whenever( - notificationShadeWindowView - .findViewById<View>(customR.id.lockscreen_clock_view_large) - ).thenReturn(view) + notificationShadeWindowView.findViewById<View>( + customR.id.lockscreen_clock_view_large + ) + ) + .thenReturn(view) progressListener.onTransitionStarted() assertThat(view.translationX).isZero() diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/extradim/ExtraDimDialogDelegateTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/extradim/ExtraDimDialogDelegateTest.kt index cde42bd00ba5..76606230a124 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/extradim/ExtraDimDialogDelegateTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/extradim/ExtraDimDialogDelegateTest.kt @@ -23,7 +23,6 @@ import androidx.test.filters.SmallTest import com.android.internal.accessibility.AccessibilityShortcutController import com.android.internal.accessibility.common.ShortcutConstants import com.android.systemui.SysuiTestCase -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testCase import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope @@ -31,6 +30,7 @@ import com.android.systemui.model.SysUiState import com.android.systemui.res.R import com.android.systemui.settings.UserTracker import com.android.systemui.statusbar.phone.SystemUIDialog +import com.android.systemui.testKosmos import kotlinx.coroutines.test.advanceUntilIdle import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest @@ -58,7 +58,7 @@ class ExtraDimDialogDelegateTest : SysuiTestCase() { private lateinit var extraDimDialogDelegate: ExtraDimDialogDelegate - private val kosmos = Kosmos().also { it.testCase = this } + private val kosmos = testKosmos().also { it.testCase = this } private val testScope = kosmos.testScope @Mock private lateinit var dialog: SystemUIDialog @@ -79,7 +79,7 @@ class ExtraDimDialogDelegateTest : SysuiTestCase() { kosmos.testDispatcher, dialogFactory, accessibilityManager, - userTracker + userTracker, ) } @@ -94,7 +94,7 @@ class ExtraDimDialogDelegateTest : SysuiTestCase() { verify(dialog) .setPositiveButton( eq(R.string.accessibility_deprecate_extra_dim_dialog_button), - clickListener.capture() + clickListener.capture(), ) clickListener.firstValue.onClick(dialog, 0) @@ -110,7 +110,7 @@ class ExtraDimDialogDelegateTest : SysuiTestCase() { .flattenToString() ) ), - anyInt() + anyInt(), ) } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/back/domain/interactor/BackActionInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/back/domain/interactor/BackActionInteractorTest.kt index 8c5fad3906ed..85733124aedb 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/back/domain/interactor/BackActionInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/back/domain/interactor/BackActionInteractorTest.kt @@ -32,7 +32,6 @@ import com.android.internal.statusbar.IStatusBarService import com.android.systemui.Flags import com.android.systemui.SysuiTestCase import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAsleepForTest @@ -50,6 +49,7 @@ import com.android.systemui.statusbar.StatusBarState import com.android.systemui.statusbar.notification.domain.interactor.activeNotificationsInteractor import com.android.systemui.statusbar.notification.headsup.HeadsUpManager import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager +import com.android.systemui.testKosmos import com.android.systemui.util.concurrency.FakeExecutor import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.argumentCaptor @@ -74,7 +74,7 @@ import org.mockito.junit.MockitoJUnit @SmallTest @RunWith(AndroidJUnit4::class) class BackActionInteractorTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testScope = kosmos.testScope private val executor = FakeExecutor(FakeSystemClock()) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/camera/data/repository/CameraAutoRotateRepositoryImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/camera/data/repository/CameraAutoRotateRepositoryImplTest.kt index 648d74d20cc5..29a0b6922b2f 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/camera/data/repository/CameraAutoRotateRepositoryImplTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/camera/data/repository/CameraAutoRotateRepositoryImplTest.kt @@ -22,8 +22,8 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectValues -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope +import com.android.systemui.testKosmos import com.android.systemui.util.settings.fakeSettings import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runCurrent @@ -34,7 +34,7 @@ import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class CameraAutoRotateRepositoryImplTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testScope = kosmos.testScope private val settings = kosmos.fakeSettings private val testUser = UserHandle.of(1) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/camera/data/repository/CameraSensorPrivacyRepositoryImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/camera/data/repository/CameraSensorPrivacyRepositoryImplTest.kt index b73a212c9bd1..2e357d8a8652 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/camera/data/repository/CameraSensorPrivacyRepositoryImplTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/camera/data/repository/CameraSensorPrivacyRepositoryImplTest.kt @@ -22,8 +22,8 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope +import com.android.systemui.testKosmos import com.android.systemui.util.mockito.mock import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runCurrent @@ -38,7 +38,7 @@ import org.mockito.Mockito @RunWith(AndroidJUnit4::class) @android.platform.test.annotations.EnabledOnRavenwood class CameraSensorPrivacyRepositoryImplTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testScope = kosmos.testScope private val testUser = UserHandle.of(1) private val privacyManager = mock<SensorPrivacyManager>() @@ -46,7 +46,7 @@ class CameraSensorPrivacyRepositoryImplTest : SysuiTestCase() { CameraSensorPrivacyRepositoryImpl( testScope.testScheduler, testScope.backgroundScope, - privacyManager + privacyManager, ) @Test @@ -87,7 +87,7 @@ class CameraSensorPrivacyRepositoryImplTest : SysuiTestCase() { .addSensorPrivacyListener( ArgumentMatchers.eq(SensorPrivacyManager.Sensors.CAMERA), ArgumentMatchers.eq(testUser.identifier), - captor.capture() + captor.capture(), ) val sensorPrivacyCallback = captor.value!! diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/camera/data/repository/FakeCameraAutoRotateRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/camera/data/repository/FakeCameraAutoRotateRepositoryTest.kt index 6c8097ed7166..b3d898396497 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/camera/data/repository/FakeCameraAutoRotateRepositoryTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/camera/data/repository/FakeCameraAutoRotateRepositoryTest.kt @@ -21,7 +21,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectValues -import com.android.systemui.kosmos.Kosmos +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest @@ -32,7 +32,7 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) @android.platform.test.annotations.EnabledOnRavenwood class FakeCameraAutoRotateRepositoryTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val underTest = kosmos.fakeCameraAutoRotateRepository private val testUser = UserHandle.of(1) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/camera/data/repository/FakeCameraSensorPrivacyRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/camera/data/repository/FakeCameraSensorPrivacyRepositoryTest.kt index 7161c2c13a60..6b9a7de2e781 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/camera/data/repository/FakeCameraSensorPrivacyRepositoryTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/camera/data/repository/FakeCameraSensorPrivacyRepositoryTest.kt @@ -21,7 +21,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectValues -import com.android.systemui.kosmos.Kosmos +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest @@ -32,7 +32,7 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) @android.platform.test.annotations.EnabledOnRavenwood class FakeCameraSensorPrivacyRepositoryTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val underTest = kosmos.fakeCameraSensorPrivacyRepository private val testUser = UserHandle.of(1) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/widgets/CommunalAppWidgetHostStartableTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/widgets/CommunalAppWidgetHostStartableTest.kt index df10d058c5d1..b08e6761d92f 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/widgets/CommunalAppWidgetHostStartableTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/widgets/CommunalAppWidgetHostStartableTest.kt @@ -16,12 +16,14 @@ package com.android.systemui.communal.widgets +import android.appwidget.AppWidgetProviderInfo import android.content.pm.UserInfo import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.Flags.FLAG_COMMUNAL_HUB import com.android.systemui.SysuiTestCase import com.android.systemui.communal.data.repository.fakeCommunalWidgetRepository +import com.android.systemui.communal.domain.interactor.CommunalInteractor import com.android.systemui.communal.domain.interactor.communalInteractor import com.android.systemui.communal.domain.interactor.communalSettingsInteractor import com.android.systemui.communal.domain.interactor.setCommunalEnabled @@ -49,6 +51,7 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mock import org.mockito.Mockito.never +import org.mockito.Mockito.spy import org.mockito.Mockito.verify import org.mockito.MockitoAnnotations @@ -65,6 +68,7 @@ class CommunalAppWidgetHostStartableTest : SysuiTestCase() { private lateinit var appWidgetIdToRemove: MutableSharedFlow<Int> + private lateinit var communalInteractorSpy: CommunalInteractor private lateinit var underTest: CommunalAppWidgetHostStartable @Before @@ -78,12 +82,13 @@ class CommunalAppWidgetHostStartableTest : SysuiTestCase() { helper = kosmos.fakeGlanceableHubMultiUserHelper appWidgetIdToRemove = MutableSharedFlow() whenever(appWidgetHost.appWidgetIdToRemove).thenReturn(appWidgetIdToRemove) + communalInteractorSpy = spy(kosmos.communalInteractor) underTest = CommunalAppWidgetHostStartable( { appWidgetHost }, { communalWidgetHost }, - { kosmos.communalInteractor }, + { communalInteractorSpy }, { kosmos.communalSettingsInteractor }, { kosmos.keyguardInteractor }, { kosmos.fakeUserTracker }, @@ -259,6 +264,41 @@ class CommunalAppWidgetHostStartableTest : SysuiTestCase() { } @Test + fun removeNotLockscreenWidgets_whenCommunalIsAvailable() = + with(kosmos) { + testScope.runTest { + // Communal is available + setCommunalAvailable(true) + kosmos.fakeUserTracker.set( + userInfos = listOf(MAIN_USER_INFO), + selectedUserIndex = 0, + ) + fakeCommunalWidgetRepository.addWidget( + appWidgetId = 1, + userId = MAIN_USER_INFO.id, + category = AppWidgetProviderInfo.WIDGET_CATEGORY_NOT_KEYGUARD, + ) + fakeCommunalWidgetRepository.addWidget(appWidgetId = 2, userId = MAIN_USER_INFO.id) + fakeCommunalWidgetRepository.addWidget( + appWidgetId = 3, + userId = MAIN_USER_INFO.id, + category = AppWidgetProviderInfo.WIDGET_CATEGORY_NOT_KEYGUARD, + ) + + underTest.start() + runCurrent() + + val communalWidgets by + collectLastValue(fakeCommunalWidgetRepository.communalWidgets) + assertThat(communalWidgets).hasSize(1) + assertThat(communalWidgets!![0].appWidgetId).isEqualTo(2) + + verify(communalInteractorSpy).deleteWidget(1) + verify(communalInteractorSpy).deleteWidget(3) + } + } + + @Test fun onStartHeadlessSystemUser_registerWidgetManager_whenCommunalIsAvailable() = with(kosmos) { testScope.runTest { diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/education/data/repository/ContextualEducationRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/education/data/repository/ContextualEducationRepositoryTest.kt index f2a6c11b872e..722976131caf 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/education/data/repository/ContextualEducationRepositoryTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/education/data/repository/ContextualEducationRepositoryTest.kt @@ -26,9 +26,9 @@ import com.android.systemui.coroutines.collectLastValue import com.android.systemui.education.data.model.EduDeviceConnectionTime import com.android.systemui.education.data.model.GestureEduModel import com.android.systemui.education.domain.interactor.mockEduInputManager -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import java.io.File import javax.inject.Provider @@ -48,7 +48,7 @@ import org.junit.runner.RunWith class ContextualEducationRepositoryTest : SysuiTestCase() { private lateinit var underTest: UserContextualEducationRepository - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testScope = kosmos.testScope private val dsScopeProvider: Provider<CoroutineScope> = Provider { TestScope(kosmos.testDispatcher).backgroundScope @@ -70,7 +70,7 @@ class ContextualEducationRepositoryTest : SysuiTestCase() { testContext, dsScopeProvider, kosmos.mockEduInputManager, - kosmos.testDispatcher + kosmos.testDispatcher, ) underTest.setUser(testUserId) } @@ -109,7 +109,7 @@ class ContextualEducationRepositoryTest : SysuiTestCase() { lastEducationTime = kosmos.fakeEduClock.instant(), usageSessionStartTime = kosmos.fakeEduClock.instant(), userId = testUserId, - gestureType = BACK + gestureType = BACK, ) underTest.updateGestureEduModel(BACK) { newModel } val model by collectLastValue(underTest.readGestureEduModelFlow(BACK)) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/haptics/slider/HapticSliderPluginTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/haptics/slider/HapticSliderPluginTest.kt index 5030d1e49da0..0f75e57ce771 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/haptics/slider/HapticSliderPluginTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/haptics/slider/HapticSliderPluginTest.kt @@ -21,9 +21,9 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.haptics.msdl.msdlPlayer -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.statusbar.VibratorHelper +import com.android.systemui.testKosmos import com.android.systemui.util.mockito.whenever import com.android.systemui.util.time.fakeSystemClock import com.google.common.truth.Truth.assertThat @@ -45,7 +45,7 @@ import org.mockito.junit.MockitoRule @RunWith(AndroidJUnit4::class) class HapticSliderPluginTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() @Rule @JvmField val mMockitoRule: MockitoRule = MockitoJUnit.rule() @Mock private lateinit var vibratorHelper: VibratorHelper diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/inputdevice/data/repository/UserInputDeviceRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/inputdevice/data/repository/UserInputDeviceRepositoryTest.kt index 798c5ab817a5..39b5e81345ee 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/inputdevice/data/repository/UserInputDeviceRepositoryTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/inputdevice/data/repository/UserInputDeviceRepositoryTest.kt @@ -23,9 +23,9 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectValues import com.android.systemui.inputdevice.data.model.UserDeviceConnectionStatus import com.android.systemui.keyboard.data.repository.keyboardRepository -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope +import com.android.systemui.testKosmos import com.android.systemui.touchpad.data.repository.touchpadRepository import com.android.systemui.user.data.repository.fakeUserRepository import com.android.systemui.user.data.repository.userRepository @@ -41,7 +41,7 @@ import org.junit.runner.RunWith class UserInputDeviceRepositoryTest : SysuiTestCase() { private lateinit var underTest: UserInputDeviceRepository - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testScope = kosmos.testScope private val keyboardRepository = kosmos.keyboardRepository private val touchpadRepository = kosmos.touchpadRepository @@ -54,7 +54,7 @@ class UserInputDeviceRepositoryTest : SysuiTestCase() { kosmos.testDispatcher, keyboardRepository, touchpadRepository, - kosmos.userRepository + kosmos.userRepository, ) userRepository.setUserInfos(USER_INFOS) } @@ -72,7 +72,7 @@ class UserInputDeviceRepositoryTest : SysuiTestCase() { assertThat(isAnyKeyboardConnected) .containsExactly( UserDeviceConnectionStatus(isConnected = true, USER_INFOS[0].id), - UserDeviceConnectionStatus(isConnected = true, USER_INFOS[1].id) + UserDeviceConnectionStatus(isConnected = true, USER_INFOS[1].id), ) .inOrder() } @@ -90,16 +90,13 @@ class UserInputDeviceRepositoryTest : SysuiTestCase() { assertThat(isAnyTouchpadConnected) .containsExactly( UserDeviceConnectionStatus(isConnected = true, USER_INFOS[0].id), - UserDeviceConnectionStatus(isConnected = true, USER_INFOS[1].id) + UserDeviceConnectionStatus(isConnected = true, USER_INFOS[1].id), ) .inOrder() } companion object { private val USER_INFOS = - listOf( - UserInfo(100, "First User", 0), - UserInfo(101, "Second User", 0), - ) + listOf(UserInfo(100, "First User", 0), UserInfo(101, "Second User", 0)) } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/inputmethod/data/repository/InputMethodRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/inputmethod/data/repository/InputMethodRepositoryTest.kt index 274880b484cc..6bd0fb0e17a1 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/inputmethod/data/repository/InputMethodRepositoryTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/inputmethod/data/repository/InputMethodRepositoryTest.kt @@ -23,9 +23,9 @@ import android.view.inputmethod.InputMethodSubtype import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope +import com.android.systemui.testKosmos import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.eq import com.android.systemui.util.mockito.mock @@ -47,7 +47,7 @@ class InputMethodRepositoryTest : SysuiTestCase() { @Mock private lateinit var inputMethodManager: InputMethodManager - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testScope = kosmos.testScope private lateinit var underTest: InputMethodRepository @@ -72,7 +72,7 @@ class InputMethodRepositoryTest : SysuiTestCase() { inputMethodManager.getEnabledInputMethodSubtypeListAsUser( any(), anyBoolean(), - eq(USER_HANDLE) + eq(USER_HANDLE), ) ) .thenReturn(listOf()) @@ -97,7 +97,7 @@ class InputMethodRepositoryTest : SysuiTestCase() { inputMethodManager.getEnabledInputMethodSubtypeListAsUser( eq(selectedImiId), anyBoolean(), - eq(USER_HANDLE) + eq(USER_HANDLE), ) ) .thenReturn( @@ -125,7 +125,7 @@ class InputMethodRepositoryTest : SysuiTestCase() { verify(inputMethodManager) .showInputMethodPickerFromSystem( /* showAuxiliarySubtypes = */ eq(true), - /* displayId = */ eq(displayId) + /* displayId = */ eq(displayId), ) } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/inputmethod/domain/interactor/InputMethodInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/inputmethod/domain/interactor/InputMethodInteractorTest.kt index 8e6de2f04279..9e129a43b4cb 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/inputmethod/domain/interactor/InputMethodInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/inputmethod/domain/interactor/InputMethodInteractorTest.kt @@ -22,8 +22,8 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.inputmethod.data.model.InputMethodModel import com.android.systemui.inputmethod.data.repository.fakeInputMethodRepository import com.android.systemui.inputmethod.data.repository.inputMethodRepository -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import java.util.UUID import kotlinx.coroutines.test.runTest @@ -34,7 +34,7 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) class InputMethodInteractorTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testScope = kosmos.testScope private val fakeInputMethodRepository = kosmos.fakeInputMethodRepository @@ -148,7 +148,7 @@ class InputMethodInteractorTest : SysuiTestCase() { subtypes = List(auxiliarySubtypes + nonAuxiliarySubtypes) { InputMethodModel.Subtype(subtypeId = it, isAuxiliary = it < auxiliarySubtypes) - } + }, ) } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/ui/ShortcutHelperDialogStarterTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/ui/ShortcutHelperDialogStarterTest.kt index 1bb4805d4f16..655c646cd34c 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/ui/ShortcutHelperDialogStarterTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/ui/ShortcutHelperDialogStarterTest.kt @@ -34,7 +34,6 @@ import com.android.systemui.keyboard.shortcut.shortcutHelperMultiTaskingShortcut import com.android.systemui.keyboard.shortcut.shortcutHelperSystemShortcutsSource import com.android.systemui.keyboard.shortcut.shortcutHelperTestHelper import com.android.systemui.keyboard.shortcut.shortcutHelperViewModel -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.applicationCoroutineScope import com.android.systemui.kosmos.testCase import com.android.systemui.kosmos.testDispatcher @@ -43,6 +42,7 @@ import com.android.systemui.plugins.activityStarter import com.android.systemui.settings.FakeUserTracker import com.android.systemui.settings.userTracker import com.android.systemui.statusbar.phone.systemUIDialogFactory +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.UnconfinedTestDispatcher import kotlinx.coroutines.test.runTest @@ -60,7 +60,7 @@ class ShortcutHelperDialogStarterTest : SysuiTestCase() { private val fakeMultiTaskingSource = FakeKeyboardShortcutGroupsSource() private val mockUserContext: Context = mock() private val kosmos = - Kosmos().also { + testKosmos().also { it.testCase = this it.testDispatcher = UnconfinedTestDispatcher() it.shortcutHelperSystemShortcutsSource = fakeSystemSource diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/stickykeys/ui/StickyKeysIndicatorCoordinatorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/stickykeys/ui/StickyKeysIndicatorCoordinatorTest.kt index be9e93c64053..ba57ffd37053 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/stickykeys/ui/StickyKeysIndicatorCoordinatorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/stickykeys/ui/StickyKeysIndicatorCoordinatorTest.kt @@ -26,7 +26,7 @@ import com.android.systemui.keyboard.stickykeys.StickyKeysLogger import com.android.systemui.keyboard.stickykeys.shared.model.Locked import com.android.systemui.keyboard.stickykeys.shared.model.ModifierKey.SHIFT import com.android.systemui.keyboard.stickykeys.ui.viewmodel.StickyKeysIndicatorViewModel -import com.android.systemui.kosmos.Kosmos +import com.android.systemui.testKosmos import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.mock import com.android.systemui.util.mockito.whenever @@ -52,19 +52,19 @@ class StickyKeysIndicatorCoordinatorTest : SysuiTestCase() { fun setup() { val dialogFactory = mock<StickyKeyDialogFactory>() whenever(dialogFactory.create(any())).thenReturn(dialog) - val keyboardRepository = Kosmos().keyboardRepository + val keyboardRepository = testKosmos().keyboardRepository val viewModel = StickyKeysIndicatorViewModel( stickyKeysRepository, keyboardRepository, - testScope.backgroundScope + testScope.backgroundScope, ) coordinator = StickyKeysIndicatorCoordinator( testScope.backgroundScope, dialogFactory, viewModel, - mock<StickyKeysLogger>() + mock<StickyKeysLogger>(), ) coordinator.startListening() keyboardRepository.setIsAnyKeyboardConnected(true) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/stickykeys/ui/viewmodel/StickyKeysIndicatorViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/stickykeys/ui/viewmodel/StickyKeysIndicatorViewModelTest.kt index 9daf0ffd34b4..1c0041969504 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/stickykeys/ui/viewmodel/StickyKeysIndicatorViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/stickykeys/ui/viewmodel/StickyKeysIndicatorViewModelTest.kt @@ -33,7 +33,6 @@ import com.android.systemui.keyboard.stickykeys.shared.model.ModifierKey.ALT_GR import com.android.systemui.keyboard.stickykeys.shared.model.ModifierKey.CTRL import com.android.systemui.keyboard.stickykeys.shared.model.ModifierKey.META import com.android.systemui.keyboard.stickykeys.shared.model.ModifierKey.SHIFT -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope import com.android.systemui.testKosmos @@ -64,7 +63,7 @@ class StickyKeysIndicatorViewModelTest : SysuiTestCase() { private val inputManager = mock<InputManager>() private val keyboardRepository = FakeKeyboardRepository() private val secureSettings = kosmos.fakeSettings - private val userRepository = Kosmos().fakeUserRepository + private val userRepository = testKosmos().fakeUserRepository private val captor = ArgumentCaptor.forClass(InputManager.StickyModifierStateListener::class.java) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/KeyguardUnlockAnimationControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/KeyguardUnlockAnimationControllerTest.kt index baf3b5b4430f..3f1cadc5fe76 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/KeyguardUnlockAnimationControllerTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/KeyguardUnlockAnimationControllerTest.kt @@ -23,12 +23,12 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.defaultDeviceState import com.android.systemui.deviceStateManager import com.android.systemui.flags.FeatureFlags -import com.android.systemui.kosmos.Kosmos import com.android.systemui.shared.system.smartspace.ILauncherUnlockAnimationController import com.android.systemui.statusbar.NotificationShadeWindowController import com.android.systemui.statusbar.SysuiStatusBarStateController import com.android.systemui.statusbar.phone.BiometricUnlockController import com.android.systemui.statusbar.policy.KeyguardStateController +import com.android.systemui.testKosmos import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.argThat import java.util.function.Predicate @@ -68,7 +68,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { @Mock private lateinit var notificationShadeWindowController: NotificationShadeWindowController @Mock private lateinit var powerManager: PowerManager @Mock private lateinit var wallpaperManager: WallpaperManager - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val deviceStateManager = kosmos.deviceStateManager @Mock @@ -92,7 +92,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { surfaceControl1, Rect(), mock(ActivityManager.RunningTaskInfo::class.java), - false + false, ) private var surfaceControl2 = mock(SurfaceControl::class.java) @@ -113,7 +113,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { surfaceControl2, Rect(), mock(ActivityManager.RunningTaskInfo::class.java), - false + false, ) private lateinit var remoteAnimationTargets: Array<RemoteAnimationTarget> @@ -135,7 +135,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { surfaceControlWp, Rect(), mock(ActivityManager.RunningTaskInfo::class.java), - false + false, ) private lateinit var wallpaperTargets: Array<RemoteAnimationTarget> @@ -157,7 +157,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { surfaceControlLockWp, Rect(), mock(ActivityManager.RunningTaskInfo::class.java), - false + false, ) private lateinit var lockWallpaperTargets: Array<RemoteAnimationTarget> private var shouldPerformSmartspaceTransition = false @@ -179,14 +179,14 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { notificationShadeWindowController, powerManager, wallpaperManager, - deviceStateManager + deviceStateManager, ) { override fun shouldPerformSmartspaceTransition(): Boolean = shouldPerformSmartspaceTransition } keyguardUnlockAnimationController.setLauncherUnlockController( "", - launcherUnlockAnimationController + launcherUnlockAnimationController, ) whenever(keyguardViewController.viewRootImpl).thenReturn(mock(ViewRootImpl::class.java)) @@ -227,7 +227,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { arrayOf(), arrayOf(), 0 /* startTime */, - false /* requestedShowSurfaceBehindKeyguard */ + false, /* requestedShowSurfaceBehindKeyguard */ ) val captorSb = ArgThatCaptor<SyncRtSurfaceTransactionApplier.SurfaceParams>() @@ -259,7 +259,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { wallpaperTargets, arrayOf(), 0 /* startTime */, - false /* requestedShowSurfaceBehindKeyguard */ + false, /* requestedShowSurfaceBehindKeyguard */ ) // Since the animation is running, we should not have finished the remote animation. @@ -282,7 +282,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { wallpaperTargets, arrayOf(), 0 /* startTime */, - false /* requestedShowSurfaceBehindKeyguard */ + false, /* requestedShowSurfaceBehindKeyguard */ ) verify(listener).onUnlockAnimationStarted(any(), eq(true), any(), any()) @@ -303,7 +303,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { wallpaperTargets, arrayOf(), 0 /* startTime */, - false /* requestedShowSurfaceBehindKeyguard */ + false, /* requestedShowSurfaceBehindKeyguard */ ) verify(listener).onUnlockAnimationStarted(any(), eq(false), any(), any()) @@ -327,7 +327,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { wallpaperTargets, arrayOf(), 0 /* startTime */, - true /* requestedShowSurfaceBehindKeyguard */ + true, /* requestedShowSurfaceBehindKeyguard */ ) assertTrue(keyguardUnlockAnimationController.surfaceBehindAlphaAnimator.isRunning) @@ -351,7 +351,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { wallpaperTargets, arrayOf(), 0 /* startTime */, - true /* requestedShowSurfaceBehindKeyguard */ + true, /* requestedShowSurfaceBehindKeyguard */ ) assertTrue(keyguardUnlockAnimationController.isPlayingCannedUnlockAnimation()) @@ -373,7 +373,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { wallpaperTargets, arrayOf(), 0 /* startTime */, - false /* requestedShowSurfaceBehindKeyguard */ + false, /* requestedShowSurfaceBehindKeyguard */ ) assertTrue(keyguardUnlockAnimationController.isPlayingCannedUnlockAnimation()) @@ -389,7 +389,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { wallpaperTargets, arrayOf(), 0 /* startTime */, - true /* requestedShowSurfaceBehindKeyguard */ + true, /* requestedShowSurfaceBehindKeyguard */ ) assertFalse(keyguardUnlockAnimationController.canPerformInWindowLauncherAnimations()) @@ -406,7 +406,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { wallpaperTargets, arrayOf(), 0 /* startTime */, - false /* requestedShowSurfaceBehindKeyguard */ + false, /* requestedShowSurfaceBehindKeyguard */ ) assertTrue(keyguardUnlockAnimationController.isPlayingCannedUnlockAnimation()) @@ -427,7 +427,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { wallpaperTargets, lockWallpaperTargets, 0 /* startTime */, - false /* requestedShowSurfaceBehindKeyguard */ + false, /* requestedShowSurfaceBehindKeyguard */ ) for (i in 0..10) { @@ -471,7 +471,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { wallpaperTargets, arrayOf(), 0 /* startTime */, - false /* requestedShowSurfaceBehindKeyguard */ + false, /* requestedShowSurfaceBehindKeyguard */ ) // Cancel the animator so we can verify only the setSurfaceBehind call below. @@ -492,7 +492,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { val captorWp = ArgThatCaptor<SyncRtSurfaceTransactionApplier.SurfaceParams>() verify( surfaceTransactionApplier, - times(1).description("WallpaperSurface was expected to receive scheduleApply once") + times(1).description("WallpaperSurface was expected to receive scheduleApply once"), ) .scheduleApply(captorWp.capture { sp -> sp.surface == surfaceControlWp }) @@ -523,7 +523,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { wallpaperTargets, arrayOf(), 0 /* startTime */, - false /* requestedShowSurfaceBehindKeyguard */ + false, /* requestedShowSurfaceBehindKeyguard */ ) // Cancel the animator so we can verify only the setSurfaceBehind call below. @@ -539,7 +539,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { val captorWp = ArgThatCaptor<SyncRtSurfaceTransactionApplier.SurfaceParams>() verify( surfaceTransactionApplier, - atLeastOnce().description("Wallpaper surface has not " + "received scheduleApply") + atLeastOnce().description("Wallpaper surface has not " + "received scheduleApply"), ) .scheduleApply(captorWp.capture { sp -> sp.surface == surfaceControlWp }) @@ -562,7 +562,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { wallpaperTargets, arrayOf(), 0 /* startTime */, - false /* requestedShowSurfaceBehindKeyguard */ + false, /* requestedShowSurfaceBehindKeyguard */ ) // Stop the animator - we just want to test whether the override is not applied. @@ -578,7 +578,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { val captorWp = ArgThatCaptor<SyncRtSurfaceTransactionApplier.SurfaceParams>() verify( surfaceTransactionApplier, - atLeastOnce().description("Wallpaper surface has not " + "received scheduleApply") + atLeastOnce().description("Wallpaper surface has not " + "received scheduleApply"), ) .scheduleApply(captorWp.capture { sp -> sp.surface == surfaceControlWp }) @@ -588,7 +588,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { assertEquals( "Wallpaper surface was expected to have opacity 1", 1f, - captorWp.getLastValue().alpha + captorWp.getLastValue().alpha, ) verifyNoMoreInteractions(surfaceTransactionApplier) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/mediarouter/data/repository/MediaRouterRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/mediarouter/data/repository/MediaRouterRepositoryTest.kt index 6bc8000b0519..04f7fe1a6487 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/mediarouter/data/repository/MediaRouterRepositoryTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/mediarouter/data/repository/MediaRouterRepositoryTest.kt @@ -21,10 +21,10 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.statusbar.policy.CastDevice import com.android.systemui.statusbar.policy.fakeCastController +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlin.test.Test import kotlinx.coroutines.test.runCurrent @@ -34,7 +34,7 @@ import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class MediaRouterRepositoryTest : SysuiTestCase() { - val kosmos = Kosmos() + val kosmos = testKosmos() val testScope = kosmos.testScope val castController = kosmos.fakeCastController diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/UserSettingObserverTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/UserSettingObserverTest.kt index 858ed6a6b54a..473d7b6d0dfa 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/UserSettingObserverTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/UserSettingObserverTest.kt @@ -22,8 +22,8 @@ import android.testing.TestableLooper import androidx.test.filters.SmallTest import com.android.systemui.Flags import com.android.systemui.SysuiTestCase -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope +import com.android.systemui.testKosmos import com.android.systemui.util.settings.SecureSettings import com.android.systemui.util.settings.fakeSettings import com.google.common.truth.Truth.assertThat @@ -64,7 +64,7 @@ class UserSettingObserverTest(flags: FlagsParameterization) : SysuiTestCase() { mSetFlagsRule.setFlagsParameterization(flags) } - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testScope = kosmos.testScope private lateinit var testableLooper: TestableLooper @@ -85,7 +85,7 @@ class UserSettingObserverTest(flags: FlagsParameterization) : SysuiTestCase() { Handler(testableLooper.looper), TEST_SETTING, USER, - DEFAULT_VALUE + DEFAULT_VALUE, ) { override fun handleValueChanged(value: Int, observedChange: Boolean) { callback(value, observedChange) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/domain/autoaddable/WorkTileAutoAddableTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/domain/autoaddable/WorkTileAutoAddableTest.kt index 00490427f80b..a2829b5f42cd 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/domain/autoaddable/WorkTileAutoAddableTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/domain/autoaddable/WorkTileAutoAddableTest.kt @@ -27,7 +27,6 @@ import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectValues -import com.android.systemui.kosmos.Kosmos import com.android.systemui.qs.pipeline.data.model.RestoreData import com.android.systemui.qs.pipeline.data.model.RestoreProcessor import com.android.systemui.qs.pipeline.data.model.workTileRestoreProcessor @@ -36,6 +35,7 @@ import com.android.systemui.qs.pipeline.domain.model.AutoAddTracking import com.android.systemui.qs.pipeline.shared.TileSpec import com.android.systemui.qs.tiles.WorkModeTile import com.android.systemui.settings.FakeUserTracker +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest @@ -47,7 +47,7 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) class WorkTileAutoAddableTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val restoreProcessor: RestoreProcessor get() = kosmos.workTileRestoreProcessor @@ -62,7 +62,7 @@ class WorkTileAutoAddableTest : SysuiTestCase() { FakeUserTracker( _userId = USER_INFO_0.id, _userInfo = USER_INFO_0, - _userProfiles = listOf(USER_INFO_0) + _userProfiles = listOf(USER_INFO_0), ) underTest = WorkTileAutoAddable(userTracker, kosmos.workTileRestoreProcessor) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/domain/interactor/NoLowNumberOfTilesTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/domain/interactor/NoLowNumberOfTilesTest.kt index 3a9c3d066b23..4e0adcab8ea3 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/domain/interactor/NoLowNumberOfTilesTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/domain/interactor/NoLowNumberOfTilesTest.kt @@ -22,7 +22,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.MediumTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.plugins.qs.QSTile import com.android.systemui.qs.FakeQSFactory @@ -39,6 +38,7 @@ import com.android.systemui.qs.pipeline.shared.TileSpec import com.android.systemui.qs.qsTileFactory import com.android.systemui.settings.fakeUserTracker import com.android.systemui.settings.userTracker +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest @@ -55,22 +55,12 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) class NoLowNumberOfTilesTest : SysuiTestCase() { - private val USER_0_INFO = - UserInfo( - 0, - "zero", - "", - UserInfo.FLAG_ADMIN or UserInfo.FLAG_FULL, - ) + private val USER_0_INFO = UserInfo(0, "zero", "", UserInfo.FLAG_ADMIN or UserInfo.FLAG_FULL) - private val defaultTiles = - listOf( - TileSpec.create("internet"), - TileSpec.create("bt"), - ) + private val defaultTiles = listOf(TileSpec.create("internet"), TileSpec.create("bt")) private val kosmos = - Kosmos().apply { + testKosmos().apply { fakeMinimumTilesRepository = MinimumTilesFixedRepository(minNumberOfTiles = 2) fakeUserTracker.set(listOf(USER_0_INFO), 0) qsTileFactory = FakeQSFactory(::tileCreator) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/domain/interactor/WorkProfileAutoAddedAfterRestoreTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/domain/interactor/WorkProfileAutoAddedAfterRestoreTest.kt index 9d9bfda99bd9..77030aceb477 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/domain/interactor/WorkProfileAutoAddedAfterRestoreTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/domain/interactor/WorkProfileAutoAddedAfterRestoreTest.kt @@ -22,7 +22,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.MediumTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.plugins.qs.QSTile import com.android.systemui.qs.FakeQSFactory @@ -34,6 +33,7 @@ import com.android.systemui.qs.pipeline.shared.TileSpec import com.android.systemui.qs.qsTileFactory import com.android.systemui.settings.fakeUserTracker import com.android.systemui.settings.userTracker +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runCurrent @@ -52,7 +52,9 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) class WorkProfileAutoAddedAfterRestoreTest : SysuiTestCase() { - private val kosmos by lazy { Kosmos().apply { fakeUserTracker.set(listOf(USER_0_INFO), 0) } } + private val kosmos by lazy { + testKosmos().apply { fakeUserTracker.set(listOf(USER_0_INFO), 0) } + } // Getter here so it can change when there is a managed profile. private val workTileAvailable: Boolean get() = hasManagedProfile() @@ -143,30 +145,15 @@ class WorkProfileAutoAddedAfterRestoreTest : SysuiTestCase() { } private fun TestScope.createManagedProfileAndAdd() { - kosmos.fakeUserTracker.set( - listOf(USER_0_INFO, MANAGED_USER_INFO), - 0, - ) + kosmos.fakeUserTracker.set(listOf(USER_0_INFO, MANAGED_USER_INFO), 0) runCurrent() } private companion object { val WORK_TILE_SPEC = "work".toTileSpec() - val USER_0_INFO = - UserInfo( - 0, - "zero", - "", - UserInfo.FLAG_ADMIN or UserInfo.FLAG_FULL, - ) + val USER_0_INFO = UserInfo(0, "zero", "", UserInfo.FLAG_ADMIN or UserInfo.FLAG_FULL) val MANAGED_USER_INFO = - UserInfo( - 10, - "ten-managed", - "", - 0, - UserManager.USER_TYPE_PROFILE_MANAGED, - ) + UserInfo(10, "ten-managed", "", 0, UserManager.USER_TYPE_PROFILE_MANAGED) fun String.toTileSpec() = TileSpec.create(this) } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/ModesDndTileTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/ModesDndTileTest.kt index 1adba6fcd45d..4f1b4e56ca30 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/ModesDndTileTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/ModesDndTileTest.kt @@ -184,12 +184,12 @@ class ModesDndTileTest : SysuiTestCase() { state = Tile.STATE_INACTIVE secondaryLabel = "Old secondary label" } - val model = ModesDndTileModel(isActivated = true) + val model = ModesDndTileModel(isActivated = true, extraStatus = "Until 14:30") underTest.handleUpdateState(tileState, model) assertThat(tileState.state).isEqualTo(Tile.STATE_ACTIVE) - assertThat(tileState.secondaryLabel).isEqualTo("On") + assertThat(tileState.secondaryLabel).isEqualTo("Until 14:30") } @Test @@ -206,6 +206,6 @@ class ModesDndTileTest : SysuiTestCase() { underTest.handleUpdateState(tileState, null) assertThat(tileState.state).isEqualTo(Tile.STATE_ACTIVE) - assertThat(tileState.secondaryLabel).isEqualTo("On") + assertThat(tileState.secondaryLabel).isEqualTo(null) // Tile will use default On text } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/AirplaneModeMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/AirplaneModeMapperTest.kt index 557f4ea262a3..311f1f792bba 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/AirplaneModeMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/AirplaneModeMapperTest.kt @@ -23,13 +23,13 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.Icon -import com.android.systemui.kosmos.Kosmos import com.android.systemui.qs.tiles.impl.airplane.domain.AirplaneModeMapper import com.android.systemui.qs.tiles.impl.airplane.domain.model.AirplaneModeTileModel import com.android.systemui.qs.tiles.impl.airplane.qsAirplaneModeTileConfig import com.android.systemui.qs.tiles.impl.custom.QSTileStateSubject import com.android.systemui.qs.tiles.viewmodel.QSTileState import com.android.systemui.res.R +import com.android.systemui.testKosmos import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @@ -37,7 +37,7 @@ import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class AirplaneModeMapperTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val airplaneModeConfig = kosmos.qsAirplaneModeTileConfig private lateinit var mapper: AirplaneModeMapper diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/alarm/domain/AlarmTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/alarm/domain/AlarmTileMapperTest.kt index 24e46686e23d..bb58ecaa2566 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/alarm/domain/AlarmTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/alarm/domain/AlarmTileMapperTest.kt @@ -23,12 +23,12 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.Icon -import com.android.systemui.kosmos.Kosmos import com.android.systemui.qs.tiles.impl.alarm.domain.model.AlarmTileModel import com.android.systemui.qs.tiles.impl.alarm.qsAlarmTileConfig import com.android.systemui.qs.tiles.impl.custom.QSTileStateSubject import com.android.systemui.qs.tiles.viewmodel.QSTileState import com.android.systemui.res.R +import com.android.systemui.testKosmos import com.android.systemui.util.time.FakeSystemClock import java.time.Instant import java.time.LocalDateTime @@ -41,7 +41,7 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) class AlarmTileMapperTest : SysuiTestCase() { private val oneMinute = 60000L - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val alarmTileConfig = kosmos.qsAlarmTileConfig private val fakeClock = FakeSystemClock() // Using lazy (versus =) to make sure we override the right context -- see b/311612168 diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/battery/doman/interactor/BatterySaverTileDataInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/battery/doman/interactor/BatterySaverTileDataInteractorTest.kt index 44c175ab7156..1ef1a72b7483 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/battery/doman/interactor/BatterySaverTileDataInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/battery/doman/interactor/BatterySaverTileDataInteractorTest.kt @@ -23,10 +23,10 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.qs.tiles.base.interactor.DataUpdateTrigger import com.android.systemui.qs.tiles.impl.battery.domain.interactor.BatterySaverTileDataInteractor +import com.android.systemui.testKosmos import com.android.systemui.utils.leaks.FakeBatteryController import com.google.common.truth.Truth import kotlinx.coroutines.flow.flowOf @@ -40,7 +40,7 @@ import org.junit.runner.RunWith @EnabledOnRavenwood @RunWith(AndroidJUnit4::class) class BatterySaverTileDataInteractorTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testScope = kosmos.testScope private val batteryController = FakeBatteryController(LeakCheck()) private val testUser = UserHandle.of(1) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/battery/ui/BatterySaverTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/battery/ui/BatterySaverTileMapperTest.kt index 2ddaddd5ad35..cb50ec9a70f4 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/battery/ui/BatterySaverTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/battery/ui/BatterySaverTileMapperTest.kt @@ -22,12 +22,12 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.Icon -import com.android.systemui.kosmos.Kosmos import com.android.systemui.qs.tiles.impl.battery.domain.model.BatterySaverTileModel import com.android.systemui.qs.tiles.impl.battery.qsBatterySaverTileConfig import com.android.systemui.qs.tiles.impl.custom.QSTileStateSubject import com.android.systemui.qs.tiles.viewmodel.QSTileState import com.android.systemui.res.R +import com.android.systemui.testKosmos import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @@ -35,7 +35,7 @@ import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class BatterySaverTileMapperTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val batterySaverTileConfig = kosmos.qsBatterySaverTileConfig private lateinit var mapper: BatterySaverTileMapper diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/colorcorrection/domain/ColorCorrectionTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/colorcorrection/domain/ColorCorrectionTileMapperTest.kt index a3c159820a94..bcd443cc78e1 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/colorcorrection/domain/ColorCorrectionTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/colorcorrection/domain/ColorCorrectionTileMapperTest.kt @@ -22,19 +22,19 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.Icon -import com.android.systemui.kosmos.Kosmos import com.android.systemui.qs.tiles.impl.colorcorrection.domain.model.ColorCorrectionTileModel import com.android.systemui.qs.tiles.impl.colorcorrection.qsColorCorrectionTileConfig import com.android.systemui.qs.tiles.impl.custom.QSTileStateSubject import com.android.systemui.qs.tiles.viewmodel.QSTileState import com.android.systemui.res.R +import com.android.systemui.testKosmos import org.junit.Test import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class ColorCorrectionTileMapperTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val colorCorrectionTileConfig = kosmos.qsColorCorrectionTileConfig private val subtitleArray by lazy { context.resources.getStringArray(R.array.tile_states_color_correction) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/custom/data/repository/CustomTileRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/custom/data/repository/CustomTileRepositoryTest.kt index 83e61d1b36bf..3c0e7d51b4e8 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/custom/data/repository/CustomTileRepositoryTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/custom/data/repository/CustomTileRepositoryTest.kt @@ -24,7 +24,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectValues -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.qs.external.TileServiceKey import com.android.systemui.qs.pipeline.shared.TileSpec @@ -34,6 +33,7 @@ import com.android.systemui.qs.tiles.impl.custom.customTileSpec import com.android.systemui.qs.tiles.impl.custom.customTileStatePersister import com.android.systemui.qs.tiles.impl.custom.data.entity.CustomTileDefaults import com.android.systemui.qs.tiles.impl.custom.packageManagerAdapterFacade +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.flow.first import kotlinx.coroutines.test.runCurrent @@ -45,7 +45,7 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) class CustomTileRepositoryTest : SysuiTestCase() { - private val kosmos = Kosmos().apply { customTileSpec = TileSpec.create(TEST_COMPONENT) } + private val kosmos = testKosmos().apply { customTileSpec = TileSpec.create(TEST_COMPONENT) } private val underTest: CustomTileRepository = with(kosmos) { CustomTileRepositoryImpl( @@ -213,7 +213,7 @@ class CustomTileRepositoryTest : SysuiTestCase() { underTest.updateWithTile( TEST_USER_1, Tile().apply { subtitle = "test_subtitle" }, - true + true, ) runCurrent() @@ -247,7 +247,7 @@ class CustomTileRepositoryTest : SysuiTestCase() { underTest.updateWithTile( TEST_USER_1, Tile().apply { subtitle = "test_subtitle" }, - true + true, ) runCurrent() diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/flashlight/domain/FlashlightMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/flashlight/domain/FlashlightMapperTest.kt index a115c1235210..2da144e5ee98 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/flashlight/domain/FlashlightMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/flashlight/domain/FlashlightMapperTest.kt @@ -21,11 +21,11 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.Icon -import com.android.systemui.kosmos.Kosmos import com.android.systemui.qs.tiles.impl.flashlight.domain.model.FlashlightTileModel import com.android.systemui.qs.tiles.impl.flashlight.qsFlashlightTileConfig import com.android.systemui.qs.tiles.viewmodel.QSTileState import com.android.systemui.res.R +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import junit.framework.Assert.assertEquals import org.junit.Test @@ -34,7 +34,7 @@ import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class FlashlightMapperTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val qsTileConfig = kosmos.qsFlashlightTileConfig private val mapper by lazy { FlashlightMapper( diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/fontscaling/domain/FontScalingTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/fontscaling/domain/FontScalingTileMapperTest.kt index 8f8f7105415f..45720b86a859 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/fontscaling/domain/FontScalingTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/fontscaling/domain/FontScalingTileMapperTest.kt @@ -22,19 +22,19 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.Icon -import com.android.systemui.kosmos.Kosmos import com.android.systemui.qs.tiles.impl.custom.QSTileStateSubject import com.android.systemui.qs.tiles.impl.fontscaling.domain.model.FontScalingTileModel import com.android.systemui.qs.tiles.impl.fontscaling.qsFontScalingTileConfig import com.android.systemui.qs.tiles.viewmodel.QSTileState import com.android.systemui.res.R +import com.android.systemui.testKosmos import org.junit.Test import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class FontScalingTileMapperTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val fontScalingTileConfig = kosmos.qsFontScalingTileConfig private val mapper by lazy { diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/fontscaling/domain/interactor/FontScalingUserActionInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/fontscaling/domain/interactor/FontScalingUserActionInteractorTest.kt index 9bd4895ac21c..93f2bc34372e 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/fontscaling/domain/interactor/FontScalingUserActionInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/fontscaling/domain/interactor/FontScalingUserActionInteractorTest.kt @@ -26,7 +26,6 @@ import com.android.systemui.accessibility.fontscaling.FontScalingDialogDelegate import com.android.systemui.animation.DialogTransitionAnimator import com.android.systemui.animation.Expandable import com.android.systemui.animation.LaunchableView -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.plugins.ActivityStarter import com.android.systemui.qs.shared.QSSettingsPackageRepository @@ -37,6 +36,7 @@ import com.android.systemui.qs.tiles.base.interactor.QSTileInputTestKtx.click import com.android.systemui.qs.tiles.impl.fontscaling.domain.model.FontScalingTileModel import com.android.systemui.statusbar.phone.FakeKeyguardStateController import com.android.systemui.statusbar.phone.SystemUIDialog +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runTest import org.junit.Before @@ -67,7 +67,7 @@ class FontScalingUserActionInteractorTest : SysuiTestCase() { @Captor private lateinit var argumentCaptor: ArgumentCaptor<Runnable> - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val scope = kosmos.testScope private val qsTileIntentUserActionHandler = FakeQSTileIntentUserInputHandler() private val keyguardStateController = FakeKeyguardStateController() diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/hearingdevices/domain/HearingDevicesTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/hearingdevices/domain/HearingDevicesTileMapperTest.kt index 3d3447da15a1..c41034202c88 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/hearingdevices/domain/HearingDevicesTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/hearingdevices/domain/HearingDevicesTileMapperTest.kt @@ -21,19 +21,19 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.Icon -import com.android.systemui.kosmos.Kosmos import com.android.systemui.qs.tiles.impl.custom.QSTileStateSubject import com.android.systemui.qs.tiles.impl.hearingdevices.domain.model.HearingDevicesTileModel import com.android.systemui.qs.tiles.impl.hearingdevices.qsHearingDevicesTileConfig import com.android.systemui.qs.tiles.viewmodel.QSTileState import com.android.systemui.res.R +import com.android.systemui.testKosmos import org.junit.Test import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class HearingDevicesTileMapperTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val qsTileConfig = kosmos.qsHearingDevicesTileConfig private val mapper by lazy { HearingDevicesTileMapper( diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/hearingdevices/domain/interactor/HearingDevicesTileDataInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/hearingdevices/domain/interactor/HearingDevicesTileDataInteractorTest.kt index 4b9d11d2f706..4d38e7588578 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/hearingdevices/domain/interactor/HearingDevicesTileDataInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/hearingdevices/domain/interactor/HearingDevicesTileDataInteractorTest.kt @@ -24,11 +24,11 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.accessibility.hearingaid.HearingDevicesChecker import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectValues -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.qs.tiles.base.interactor.DataUpdateTrigger import com.android.systemui.qs.tiles.impl.hearingdevices.domain.model.HearingDevicesTileModel import com.android.systemui.statusbar.policy.fakeBluetoothController +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.runCurrent @@ -46,7 +46,7 @@ import org.mockito.kotlin.whenever @EnabledOnRavenwood @RunWith(AndroidJUnit4::class) class HearingDevicesTileDataInteractorTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testScope = kosmos.testScope private val testUser = UserHandle.of(1) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/hearingdevices/domain/interactor/HearingDevicesTileUserActionInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/hearingdevices/domain/interactor/HearingDevicesTileUserActionInteractorTest.kt index 1b497a2b36ed..0ba057b1881b 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/hearingdevices/domain/interactor/HearingDevicesTileUserActionInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/hearingdevices/domain/interactor/HearingDevicesTileUserActionInteractorTest.kt @@ -22,13 +22,13 @@ import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.accessibility.hearingaid.HearingDevicesDialogManager import com.android.systemui.accessibility.hearingaid.HearingDevicesUiEventLogger.Companion.LAUNCH_SOURCE_QS_TILE -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.qs.shared.QSSettingsPackageRepository import com.android.systemui.qs.tiles.base.actions.FakeQSTileIntentUserInputHandler import com.android.systemui.qs.tiles.base.actions.QSTileIntentUserInputHandlerSubject import com.android.systemui.qs.tiles.base.interactor.QSTileInputTestKtx import com.android.systemui.qs.tiles.impl.hearingdevices.domain.model.HearingDevicesTileModel +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runTest import org.junit.Before @@ -47,7 +47,7 @@ import org.mockito.kotlin.whenever @EnabledOnRavenwood @RunWith(AndroidJUnit4::class) class HearingDevicesTileUserActionInteractorTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testScope = kosmos.testScope private val inputHandler = FakeQSTileIntentUserInputHandler() diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapperTest.kt index 54a653df696f..e15664eba6b9 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapperTest.kt @@ -28,7 +28,6 @@ import com.android.systemui.common.shared.model.ContentDescription.Companion.loa import com.android.systemui.common.shared.model.Icon import com.android.systemui.common.shared.model.Text import com.android.systemui.common.shared.model.Text.Companion.loadText -import com.android.systemui.kosmos.Kosmos import com.android.systemui.qs.tiles.impl.custom.QSTileStateSubject import com.android.systemui.qs.tiles.impl.internet.domain.model.InternetTileModel import com.android.systemui.qs.tiles.impl.internet.qsInternetTileConfig @@ -38,13 +37,14 @@ import com.android.systemui.statusbar.connectivity.WifiIcons.WIFI_FULL_ICONS import com.android.systemui.statusbar.pipeline.mobile.domain.model.SignalIconModel import com.android.systemui.statusbar.pipeline.satellite.ui.model.SatelliteIconModel import com.android.systemui.statusbar.pipeline.shared.ui.model.InternetTileIconModel +import com.android.systemui.testKosmos import org.junit.Test import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class InternetTileMapperTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val internetTileConfig = kosmos.qsInternetTileConfig private val handler = kosmos.fakeExecutorHandler private val mapper by lazy { diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileDataInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileDataInteractorTest.kt index 63607f1edd59..45582f017fb0 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileDataInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileDataInteractorTest.kt @@ -29,7 +29,6 @@ import com.android.systemui.common.shared.model.Text.Companion.loadText import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.FakeFeatureFlagsClassic import com.android.systemui.flags.Flags -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.log.table.logcatTableLogBuffer import com.android.systemui.qs.tiles.base.interactor.DataUpdateTrigger @@ -54,6 +53,7 @@ import com.android.systemui.statusbar.pipeline.wifi.shared.model.WifiNetworkMode import com.android.systemui.statusbar.pipeline.wifi.shared.model.WifiScanEntry import com.android.systemui.statusbar.pipeline.wifi.ui.model.WifiIcon import com.android.systemui.statusbar.policy.data.repository.FakeUserSetupRepository +import com.android.systemui.testKosmos import com.android.systemui.util.CarrierConfigTracker import com.android.systemui.util.mockito.mock import com.google.common.truth.Truth.assertThat @@ -67,7 +67,7 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) class InternetTileDataInteractorTest : SysuiTestCase() { private val testUser = UserHandle.of(1) - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testScope = kosmos.testScope private lateinit var underTest: InternetTileDataInteractor diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileUserActionInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileUserActionInteractorTest.kt index 261e3de939f2..d019a456a4f5 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileUserActionInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileUserActionInteractorTest.kt @@ -21,7 +21,6 @@ import android.provider.Settings import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.qs.tiles.base.actions.FakeQSTileIntentUserInputHandler import com.android.systemui.qs.tiles.base.actions.QSTileIntentUserInputHandlerSubject @@ -29,6 +28,7 @@ import com.android.systemui.qs.tiles.base.interactor.QSTileInputTestKtx import com.android.systemui.qs.tiles.dialog.InternetDialogManager import com.android.systemui.qs.tiles.impl.internet.domain.model.InternetTileModel import com.android.systemui.statusbar.connectivity.AccessPointController +import com.android.systemui.testKosmos import com.android.systemui.util.mockito.nullable import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runTest @@ -44,7 +44,7 @@ import org.mockito.kotlin.verify @EnabledOnRavenwood @RunWith(AndroidJUnit4::class) class InternetTileUserActionInteractorTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val inputHandler = FakeQSTileIntentUserInputHandler() private lateinit var underTest: InternetTileUserActionInteractor diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/inversion/domain/ColorInversionTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/inversion/domain/ColorInversionTileMapperTest.kt index 780d58c83e5b..48e114603723 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/inversion/domain/ColorInversionTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/inversion/domain/ColorInversionTileMapperTest.kt @@ -22,20 +22,20 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.Icon -import com.android.systemui.kosmos.Kosmos import com.android.systemui.qs.tileimpl.SubtitleArrayMapping import com.android.systemui.qs.tiles.impl.custom.QSTileStateSubject import com.android.systemui.qs.tiles.impl.inversion.domain.model.ColorInversionTileModel import com.android.systemui.qs.tiles.impl.inversion.qsColorInversionTileConfig import com.android.systemui.qs.tiles.viewmodel.QSTileState import com.android.systemui.res.R +import com.android.systemui.testKosmos import org.junit.Test import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class ColorInversionTileMapperTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val colorInversionTileConfig = kosmos.qsColorInversionTileConfig private val subtitleArrayId = SubtitleArrayMapping.getSubtitleId(colorInversionTileConfig.tileSpec.spec) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/irecording/IssueRecordingDataInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/irecording/IssueRecordingDataInteractorTest.kt index 7562ac00e4a6..57f85bd8c5ac 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/irecording/IssueRecordingDataInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/irecording/IssueRecordingDataInteractorTest.kt @@ -22,13 +22,13 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testCase import com.android.systemui.kosmos.testScope import com.android.systemui.qs.tiles.base.interactor.DataUpdateTrigger import com.android.systemui.recordissue.IssueRecordingState import com.android.systemui.settings.fakeUserFileManager import com.android.systemui.settings.userTracker +import com.android.systemui.testKosmos import com.android.systemui.util.settings.fakeGlobalSettings import com.google.common.truth.Truth import kotlinx.coroutines.flow.flowOf @@ -42,7 +42,7 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) class IssueRecordingDataInteractorTest : SysuiTestCase() { - private val kosmos = Kosmos().also { it.testCase = this } + private val kosmos = testKosmos().also { it.testCase = this } private val userTracker = kosmos.userTracker private val userFileManager = kosmos.fakeUserFileManager private val testUser = UserHandle.of(1) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/irecording/IssueRecordingMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/irecording/IssueRecordingMapperTest.kt index fa6d8bf4a317..0201168181a9 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/irecording/IssueRecordingMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/irecording/IssueRecordingMapperTest.kt @@ -20,7 +20,6 @@ import android.content.res.mainResources import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testCase import com.android.systemui.qs.pipeline.shared.TileSpec import com.android.systemui.qs.qsEventLogger @@ -30,6 +29,7 @@ import com.android.systemui.qs.tiles.viewmodel.QSTileState import com.android.systemui.qs.tiles.viewmodel.QSTileUIConfig import com.android.systemui.recordissue.RecordIssueModule import com.android.systemui.res.R +import com.android.systemui.testKosmos import com.google.common.truth.Truth import org.junit.Test import org.junit.runner.RunWith @@ -37,7 +37,7 @@ import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class IssueRecordingMapperTest : SysuiTestCase() { - private val kosmos = Kosmos().also { it.testCase = this } + private val kosmos = testKosmos().also { it.testCase = this } private val uiConfig = QSTileUIConfig.Resource(R.drawable.qs_record_issue_icon_off, R.string.qs_record_issue_label) private val config = diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/irecording/IssueRecordingUserActionInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/irecording/IssueRecordingUserActionInteractorTest.kt index 9c2be899b8ca..125419ba3bdf 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/irecording/IssueRecordingUserActionInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/irecording/IssueRecordingUserActionInteractorTest.kt @@ -22,7 +22,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.animation.dialogTransitionAnimator -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testCase import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope @@ -39,6 +38,7 @@ import com.android.systemui.settings.userFileManager import com.android.systemui.settings.userTracker import com.android.systemui.statusbar.phone.KeyguardDismissUtil import com.android.systemui.statusbar.policy.keyguardStateController +import com.android.systemui.testKosmos import com.android.systemui.util.settings.fakeGlobalSettings import com.google.common.truth.Truth import kotlinx.coroutines.test.runTest @@ -56,7 +56,7 @@ class IssueRecordingUserActionInteractorTest : SysuiTestCase() { @Mock private lateinit var recordingController: RecordingController val user = UserHandle(1) - val kosmos = Kosmos().also { it.testCase = this } + val kosmos = testKosmos().also { it.testCase = this } private lateinit var userContextProvider: UserContextProvider private lateinit var underTest: IssueRecordingUserActionInteractor diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/location/domain/LocationTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/location/domain/LocationTileMapperTest.kt index 4ebe23dcdef1..a6ad54935f08 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/location/domain/LocationTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/location/domain/LocationTileMapperTest.kt @@ -21,11 +21,11 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.Icon -import com.android.systemui.kosmos.Kosmos import com.android.systemui.qs.tiles.impl.location.domain.model.LocationTileModel import com.android.systemui.qs.tiles.impl.location.qsLocationTileConfig import com.android.systemui.qs.tiles.viewmodel.QSTileState import com.android.systemui.res.R +import com.android.systemui.testKosmos import com.google.common.truth.Truth import junit.framework.Assert import org.junit.Test @@ -34,7 +34,7 @@ import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class LocationTileMapperTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val qsTileConfig = kosmos.qsLocationTileConfig private val mapper by lazy { diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/location/interactor/LocationTileUserActionInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/location/interactor/LocationTileUserActionInteractorTest.kt index 8b21cb4a97d5..435aea07c9a0 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/location/interactor/LocationTileUserActionInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/location/interactor/LocationTileUserActionInteractorTest.kt @@ -21,7 +21,6 @@ import android.provider.Settings import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.plugins.ActivityStarter import com.android.systemui.qs.tiles.base.actions.FakeQSTileIntentUserInputHandler @@ -32,6 +31,7 @@ import com.android.systemui.qs.tiles.impl.location.domain.interactor.LocationTil import com.android.systemui.qs.tiles.impl.location.domain.model.LocationTileModel import com.android.systemui.statusbar.phone.FakeKeyguardStateController import com.android.systemui.statusbar.policy.LocationController +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlin.coroutines.EmptyCoroutineContext import kotlinx.coroutines.test.runTest @@ -58,7 +58,7 @@ class LocationTileUserActionInteractorTest : SysuiTestCase() { @Before fun setup() { MockitoAnnotations.initMocks(this) - val kosmos = Kosmos() + val kosmos = testKosmos() underTest = LocationTileUserActionInteractor( EmptyCoroutineContext, diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/modes/domain/interactor/ModesDndTileUserActionInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/modes/domain/interactor/ModesDndTileUserActionInteractorTest.kt index 0a35b428bbc9..fda62e49ca72 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/modes/domain/interactor/ModesDndTileUserActionInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/modes/domain/interactor/ModesDndTileUserActionInteractorTest.kt @@ -79,7 +79,7 @@ class ModesDndTileUserActionInteractorTest : SysuiTestCase() { zenModeRepository.activateMode(MANUAL_DND) assertThat(dndMode?.isActive).isTrue() - underTest.handleInput(QSTileInputTestKtx.click(data = ModesDndTileModel(true))) + underTest.handleInput(QSTileInputTestKtx.click(data = ModesDndTileModel(true, null))) assertThat(dndMode?.isActive).isFalse() } @@ -90,7 +90,7 @@ class ModesDndTileUserActionInteractorTest : SysuiTestCase() { val dndMode by collectLastValue(zenModeInteractor.dndMode) assertThat(dndMode?.isActive).isFalse() - underTest.handleInput(QSTileInputTestKtx.click(data = ModesDndTileModel(false))) + underTest.handleInput(QSTileInputTestKtx.click(data = ModesDndTileModel(false, null))) assertThat(dndMode?.isActive).isTrue() } @@ -101,7 +101,7 @@ class ModesDndTileUserActionInteractorTest : SysuiTestCase() { zenModeRepository.activateMode(MANUAL_DND) runCurrent() - underTest.handleInput(QSTileInputTestKtx.longClick(ModesDndTileModel(true))) + underTest.handleInput(QSTileInputTestKtx.longClick(ModesDndTileModel(true, null))) QSTileIntentUserInputHandlerSubject.assertThat(inputHandler).handledOneIntentInput { assertThat(it.intent.`package`).isEqualTo(SETTINGS_PACKAGE) @@ -118,7 +118,7 @@ class ModesDndTileUserActionInteractorTest : SysuiTestCase() { zenModeRepository.deactivateMode(MANUAL_DND) runCurrent() - underTest.handleInput(QSTileInputTestKtx.longClick(ModesDndTileModel(false))) + underTest.handleInput(QSTileInputTestKtx.longClick(ModesDndTileModel(false, null))) QSTileIntentUserInputHandlerSubject.assertThat(inputHandler).handledOneIntentInput { assertThat(it.intent.`package`).isEqualTo(SETTINGS_PACKAGE) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/modes/ui/ModesDndTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/modes/ui/ModesDndTileMapperTest.kt index 29f642a4325d..fb48d228746a 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/modes/ui/ModesDndTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/modes/ui/ModesDndTileMapperTest.kt @@ -58,23 +58,36 @@ class ModesDndTileMapperTest : SysuiTestCase() { @Test fun map_inactiveState() { - val model = ModesDndTileModel(isActivated = false) + val model = ModesDndTileModel(isActivated = false, extraStatus = null) val state = underTest.map(config, model) assertThat(state.activationState).isEqualTo(QSTileState.ActivationState.INACTIVE) assertThat((state.icon as Icon.Loaded).res).isEqualTo(R.drawable.qs_dnd_icon_off) - assertThat(state.secondaryLabel).isEqualTo("Off") + assertThat(state.secondaryLabel).isNull() // Will use default label for activationState } @Test fun map_activeState() { - val model = ModesDndTileModel(isActivated = true) + val model = ModesDndTileModel(isActivated = true, extraStatus = null) val state = underTest.map(config, model) assertThat(state.activationState).isEqualTo(QSTileState.ActivationState.ACTIVE) assertThat((state.icon as Icon.Loaded).res).isEqualTo(R.drawable.qs_dnd_icon_on) - assertThat(state.secondaryLabel).isEqualTo("On") + assertThat(state.secondaryLabel).isNull() // Will use default label for activationState + } + + @Test + fun map_activeStateWithExtraStatus() { + val model = ModesDndTileModel(isActivated = true, extraStatus = "Until 14:00") + + val state = underTest.map(config, model) + + assertThat(state.activationState).isEqualTo(QSTileState.ActivationState.ACTIVE) + assertThat((state.icon as Icon.Loaded).res).isEqualTo(R.drawable.qs_dnd_icon_on) + assertThat(state.secondaryLabel).isEqualTo("Until 14:00") + assertThat(state.contentDescription).isEqualTo("Do Not Disturb") + assertThat(state.stateDescription).isEqualTo("Until 14:00") } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/night/domain/interactor/NightDisplayTileDataInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/night/domain/interactor/NightDisplayTileDataInteractorTest.kt index a0aa2d4a9a6c..a5e2922ffb3d 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/night/domain/interactor/NightDisplayTileDataInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/night/domain/interactor/NightDisplayTileDataInteractorTest.kt @@ -26,7 +26,7 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.accessibility.data.repository.NightDisplayRepository import com.android.systemui.coroutines.collectLastValue import com.android.systemui.dagger.NightDisplayListenerModule -import com.android.systemui.kosmos.Kosmos +import com.android.systemui.testKosmos import com.android.systemui.user.utils.UserScopedService import com.android.systemui.util.mockito.eq import com.android.systemui.util.mockito.mock @@ -47,7 +47,7 @@ import org.mockito.ArgumentMatchers.anyInt @SmallTest @RunWith(AndroidJUnit4::class) class NightDisplayTileDataInteractorTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testUser = UserHandle.of(1)!! private val testStartTime = LocalTime.MIDNIGHT private val testEndTime = LocalTime.NOON diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/night/domain/interactor/NightDisplayTileUserActionInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/night/domain/interactor/NightDisplayTileUserActionInteractorTest.kt index adc8bcba5a5c..51975b0508a9 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/night/domain/interactor/NightDisplayTileUserActionInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/night/domain/interactor/NightDisplayTileUserActionInteractorTest.kt @@ -26,12 +26,12 @@ import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.accessibility.data.repository.NightDisplayRepository import com.android.systemui.dagger.NightDisplayListenerModule -import com.android.systemui.kosmos.Kosmos import com.android.systemui.qs.tiles.base.actions.FakeQSTileIntentUserInputHandler import com.android.systemui.qs.tiles.base.actions.intentInputs import com.android.systemui.qs.tiles.base.interactor.QSTileInputTestKtx import com.android.systemui.qs.tiles.impl.custom.qsTileLogger import com.android.systemui.qs.tiles.impl.night.domain.model.NightDisplayTileModel +import com.android.systemui.testKosmos import com.android.systemui.user.utils.UserScopedService import com.android.systemui.util.mockito.eq import com.android.systemui.util.mockito.mock @@ -51,7 +51,7 @@ import org.mockito.Mockito.verify @SmallTest @RunWith(AndroidJUnit4::class) class NightDisplayTileUserActionInteractorTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val qsTileIntentUserActionHandler = FakeQSTileIntentUserInputHandler() private val testUser = UserHandle.of(1) private val colorDisplayManager = @@ -89,7 +89,7 @@ class NightDisplayTileUserActionInteractorTest : SysuiTestCase() { NightDisplayTileUserActionInteractor( nightDisplayRepository, qsTileIntentUserActionHandler, - kosmos.qsTileLogger + kosmos.qsTileLogger, ) @Test @@ -143,7 +143,7 @@ class NightDisplayTileUserActionInteractorTest : SysuiTestCase() { underTest.handleInput( QSTileInputTestKtx.longClick( NightDisplayTileModel.AutoModeOff(enabledState, false), - testUser + testUser, ) ) @@ -163,7 +163,7 @@ class NightDisplayTileUserActionInteractorTest : SysuiTestCase() { underTest.handleInput( QSTileInputTestKtx.longClick( NightDisplayTileModel.AutoModeOff(enabledState, false), - testUser + testUser, ) ) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/night/ui/NightDisplayTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/night/ui/NightDisplayTileMapperTest.kt index 7c853261aa1c..0b0b88e455da 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/night/ui/NightDisplayTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/night/ui/NightDisplayTileMapperTest.kt @@ -24,13 +24,13 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.Icon -import com.android.systemui.kosmos.Kosmos import com.android.systemui.qs.tiles.base.logging.QSTileLogger import com.android.systemui.qs.tiles.impl.custom.QSTileStateSubject import com.android.systemui.qs.tiles.impl.night.domain.model.NightDisplayTileModel import com.android.systemui.qs.tiles.impl.night.qsNightDisplayTileConfig import com.android.systemui.qs.tiles.viewmodel.QSTileState import com.android.systemui.res.R +import com.android.systemui.testKosmos import com.android.systemui.util.mockito.mock import java.time.LocalTime import java.time.format.DateTimeFormatter @@ -41,7 +41,7 @@ import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class NightDisplayTileMapperTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val config = kosmos.qsNightDisplayTileConfig private val testStartTime = LocalTime.MIDNIGHT diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/notes/domain/NotesTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/notes/domain/NotesTileMapperTest.kt index b6caa22a3012..ecf6f2a9cd1d 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/notes/domain/NotesTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/notes/domain/NotesTileMapperTest.kt @@ -22,19 +22,19 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.Icon -import com.android.systemui.kosmos.Kosmos import com.android.systemui.qs.tiles.impl.custom.QSTileStateSubject import com.android.systemui.qs.tiles.impl.notes.domain.model.NotesTileModel import com.android.systemui.qs.tiles.impl.notes.qsNotesTileConfig import com.android.systemui.qs.tiles.viewmodel.QSTileState import com.android.systemui.res.R +import com.android.systemui.testKosmos import kotlin.test.Test import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class NotesTileMapperTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val qsTileConfig = kosmos.qsNotesTileConfig private val mapper by lazy { diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/notes/domain/interactor/NotesTileDataInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/notes/domain/interactor/NotesTileDataInteractorTest.kt index 4786fc40562a..84ab6905a007 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/notes/domain/interactor/NotesTileDataInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/notes/domain/interactor/NotesTileDataInteractorTest.kt @@ -24,9 +24,9 @@ import androidx.test.filters.SmallTest import com.android.systemui.Flags import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.qs.tiles.base.interactor.DataUpdateTrigger +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.toCollection @@ -38,12 +38,11 @@ import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class NotesTileDataInteractorTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testScope = kosmos.testScope private val testUser = UserHandle.of(1) private lateinit var underTest: NotesTileDataInteractor - @EnableFlags(Flags.FLAG_NOTES_ROLE_QS_TILE) @Test fun availability_qsFlagEnabled_notesRoleEnabled_returnTrue() = @@ -92,7 +91,7 @@ class NotesTileDataInteractorTest : SysuiTestCase() { fun tileData_notEmpty() = runTest { underTest = NotesTileDataInteractor(isNoteTaskEnabled = true) val flowValue by - collectLastValue(underTest.tileData(testUser, flowOf(DataUpdateTrigger.InitialRequest))) + collectLastValue(underTest.tileData(testUser, flowOf(DataUpdateTrigger.InitialRequest))) runCurrent() diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/notes/domain/interactor/NotesTileUserActionInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/notes/domain/interactor/NotesTileUserActionInteractorTest.kt index 54911e612291..282af9159e2b 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/notes/domain/interactor/NotesTileUserActionInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/notes/domain/interactor/NotesTileUserActionInteractorTest.kt @@ -20,7 +20,6 @@ import android.content.Intent import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.notetask.NoteTaskController import com.android.systemui.notetask.NoteTaskEntryPoint @@ -29,18 +28,19 @@ import com.android.systemui.qs.tiles.base.actions.FakeQSTileIntentUserInputHandl import com.android.systemui.qs.tiles.base.actions.QSTileIntentUserInputHandlerSubject import com.android.systemui.qs.tiles.base.interactor.QSTileInputTestKtx import com.android.systemui.qs.tiles.impl.notes.domain.model.NotesTileModel +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 -import org.mockito.kotlin.mock import org.mockito.Mockito.verify +import org.mockito.kotlin.mock @SmallTest @RunWith(AndroidJUnit4::class) class NotesTileUserActionInteractorTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testScope = kosmos.testScope private val inputHandler = FakeQSTileIntentUserInputHandler() private val panelInteractor = mock<PanelInteractor>() diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/onehanded/domain/interactor/OneHandedModeTileDataInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/onehanded/domain/interactor/OneHandedModeTileDataInteractorTest.kt index 59eb069a5f3b..16b0caa78cfa 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/onehanded/domain/interactor/OneHandedModeTileDataInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/onehanded/domain/interactor/OneHandedModeTileDataInteractorTest.kt @@ -22,9 +22,9 @@ import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.accessibility.data.repository.oneHandedModeRepository import com.android.systemui.coroutines.collectLastValue -import com.android.systemui.kosmos.Kosmos import com.android.systemui.qs.tiles.base.interactor.DataUpdateTrigger import com.android.systemui.qs.tiles.impl.onehanded.domain.OneHandedModeTileDataInteractor +import com.android.systemui.testKosmos import com.android.wm.shell.onehanded.OneHanded import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.flow.flowOf @@ -37,7 +37,7 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) class OneHandedModeTileDataInteractorTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testUser = UserHandle.of(1)!! private val oneHandedModeRepository = kosmos.oneHandedModeRepository private val underTest: OneHandedModeTileDataInteractor = diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/onehanded/ui/OneHandedModeTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/onehanded/ui/OneHandedModeTileMapperTest.kt index 5b39810e3477..3fba857bae1a 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/onehanded/ui/OneHandedModeTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/onehanded/ui/OneHandedModeTileMapperTest.kt @@ -22,13 +22,13 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.Icon -import com.android.systemui.kosmos.Kosmos import com.android.systemui.qs.tileimpl.SubtitleArrayMapping import com.android.systemui.qs.tiles.impl.custom.QSTileStateSubject import com.android.systemui.qs.tiles.impl.onehanded.domain.model.OneHandedModeTileModel import com.android.systemui.qs.tiles.impl.onehanded.qsOneHandedModeTileConfig import com.android.systemui.qs.tiles.viewmodel.QSTileState import com.android.systemui.res.R +import com.android.systemui.testKosmos import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @@ -36,7 +36,7 @@ import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class OneHandedModeTileMapperTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val config = kosmos.qsOneHandedModeTileConfig private val subtitleArrayId = SubtitleArrayMapping.getSubtitleId(config.tileSpec.spec) private val subtitleArray by lazy { context.resources.getStringArray(subtitleArrayId) } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/qr/domain/interactor/QRCodeScannerTileUserActionInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/qr/domain/interactor/QRCodeScannerTileUserActionInteractorTest.kt index 312f18029570..ef21df6e2636 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/qr/domain/interactor/QRCodeScannerTileUserActionInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/qr/domain/interactor/QRCodeScannerTileUserActionInteractorTest.kt @@ -21,12 +21,12 @@ import android.platform.test.annotations.EnabledOnRavenwood import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase -import com.android.systemui.kosmos.Kosmos import com.android.systemui.qs.tiles.base.actions.QSTileIntentUserInputHandlerSubject import com.android.systemui.qs.tiles.base.actions.qsTileIntentUserInputHandler import com.android.systemui.qs.tiles.base.interactor.QSTileInputTestKtx import com.android.systemui.qs.tiles.impl.qr.domain.model.QRCodeScannerTileModel import com.android.systemui.qs.tiles.impl.qr.qrCodeScannerTileUserActionInteractor +import com.android.systemui.testKosmos import com.android.systemui.util.mockito.mock import kotlinx.coroutines.test.runTest import org.junit.Test @@ -36,7 +36,7 @@ import org.junit.runner.RunWith @EnabledOnRavenwood @RunWith(AndroidJUnit4::class) class QRCodeScannerTileUserActionInteractorTest : SysuiTestCase() { - val kosmos = Kosmos() + val kosmos = testKosmos() private val inputHandler = kosmos.qsTileIntentUserInputHandler private val underTest = kosmos.qrCodeScannerTileUserActionInteractor private val intent = mock<Intent>() diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/qr/ui/QRCodeScannerTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/qr/ui/QRCodeScannerTileMapperTest.kt index c572ff60b61a..9e20aae6103e 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/qr/ui/QRCodeScannerTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/qr/ui/QRCodeScannerTileMapperTest.kt @@ -23,11 +23,11 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.Icon -import com.android.systemui.kosmos.Kosmos import com.android.systemui.qs.tiles.impl.custom.QSTileStateSubject import com.android.systemui.qs.tiles.impl.qr.domain.model.QRCodeScannerTileModel import com.android.systemui.qs.tiles.impl.qr.qsQRCodeScannerTileConfig import com.android.systemui.qs.tiles.viewmodel.QSTileState +import com.android.systemui.testKosmos import com.android.systemui.util.mockito.mock import org.junit.Before import org.junit.Test @@ -36,7 +36,7 @@ import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class QRCodeScannerTileMapperTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val config = kosmos.qsQRCodeScannerTileConfig private lateinit var mapper: QRCodeScannerTileMapper diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/reducebrightness/domain/interactor/ReduceBrightColorsTileDataInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/reducebrightness/domain/interactor/ReduceBrightColorsTileDataInteractorTest.kt index dc3248d42d62..fecb3deaaf36 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/reducebrightness/domain/interactor/ReduceBrightColorsTileDataInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/reducebrightness/domain/interactor/ReduceBrightColorsTileDataInteractorTest.kt @@ -23,10 +23,10 @@ import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.accessibility.reduceBrightColorsController import com.android.systemui.coroutines.collectValues -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.qs.tiles.base.interactor.DataUpdateTrigger import com.android.systemui.qs.tiles.impl.reducebrightness.domain.model.ReduceBrightColorsTileModel +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.runCurrent @@ -40,14 +40,14 @@ import org.junit.runner.RunWith class ReduceBrightColorsTileDataInteractorTest : SysuiTestCase() { private val isAvailable = true - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testScope = kosmos.testScope private val reduceBrightColorsController = kosmos.reduceBrightColorsController private val underTest: ReduceBrightColorsTileDataInteractor = ReduceBrightColorsTileDataInteractor( testScope.testScheduler, isAvailable, - reduceBrightColorsController + reduceBrightColorsController, ) @Test diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/reducebrightness/domain/interactor/ReduceBrightColorsTileUserActionInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/reducebrightness/domain/interactor/ReduceBrightColorsTileUserActionInteractorTest.kt index 75b090c4034b..77321385b09e 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/reducebrightness/domain/interactor/ReduceBrightColorsTileUserActionInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/reducebrightness/domain/interactor/ReduceBrightColorsTileUserActionInteractorTest.kt @@ -28,11 +28,11 @@ import com.android.server.display.feature.flags.Flags import com.android.systemui.SysuiTestCase import com.android.systemui.accessibility.extradim.ExtraDimDialogManager import com.android.systemui.accessibility.reduceBrightColorsController -import com.android.systemui.kosmos.Kosmos import com.android.systemui.qs.tiles.base.actions.FakeQSTileIntentUserInputHandler import com.android.systemui.qs.tiles.base.actions.QSTileIntentUserInputHandlerSubject import com.android.systemui.qs.tiles.base.interactor.QSTileInputTestKtx import com.android.systemui.qs.tiles.impl.reducebrightness.domain.model.ReduceBrightColorsTileModel +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runTest import org.junit.Before @@ -48,7 +48,7 @@ import org.mockito.kotlin.verify @RunWith(AndroidJUnit4::class) class ReduceBrightColorsTileUserActionInteractorTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val inputHandler = FakeQSTileIntentUserInputHandler() private val controller = kosmos.reduceBrightColorsController diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/reducebrightness/ui/ReduceBrightColorsTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/reducebrightness/ui/ReduceBrightColorsTileMapperTest.kt index 00017f9059de..ebf70dad7149 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/reducebrightness/ui/ReduceBrightColorsTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/reducebrightness/ui/ReduceBrightColorsTileMapperTest.kt @@ -23,12 +23,12 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.Icon -import com.android.systemui.kosmos.Kosmos import com.android.systemui.qs.tiles.impl.custom.QSTileStateSubject import com.android.systemui.qs.tiles.impl.reducebrightness.domain.model.ReduceBrightColorsTileModel import com.android.systemui.qs.tiles.impl.reducebrightness.qsReduceBrightColorsTileConfig import com.android.systemui.qs.tiles.viewmodel.QSTileState import com.android.systemui.res.R +import com.android.systemui.testKosmos import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @@ -36,7 +36,7 @@ import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class ReduceBrightColorsTileMapperTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val config = kosmos.qsReduceBrightColorsTileConfig private lateinit var mapper: ReduceBrightColorsTileMapper diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/rotation/domain/interactor/RotationLockTileDataInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/rotation/domain/interactor/RotationLockTileDataInteractorTest.kt index 283fa601f8df..6f05c3178754 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/rotation/domain/interactor/RotationLockTileDataInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/rotation/domain/interactor/RotationLockTileDataInteractorTest.kt @@ -28,9 +28,9 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.camera.data.repository.fakeCameraAutoRotateRepository import com.android.systemui.camera.data.repository.fakeCameraSensorPrivacyRepository import com.android.systemui.coroutines.collectLastValue -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.qs.tiles.base.interactor.DataUpdateTrigger +import com.android.systemui.testKosmos import com.android.systemui.util.mockito.eq import com.android.systemui.util.mockito.whenever import com.android.systemui.utils.leaks.FakeBatteryController @@ -48,7 +48,7 @@ import org.junit.runner.RunWith @EnabledOnRavenwood @RunWith(AndroidJUnit4::class) class RotationLockTileDataInteractorTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testScope = kosmos.testScope private val batteryController = FakeBatteryController(LeakCheck()) private val rotationController = FakeRotationLockController(LeakCheck()) @@ -65,7 +65,7 @@ class RotationLockTileDataInteractorTest : SysuiTestCase() { whenever( packageManager.checkPermission( eq(Manifest.permission.CAMERA), - eq(TEST_PACKAGE_NAME) + eq(TEST_PACKAGE_NAME), ) ) .thenReturn(PackageManager.PERMISSION_GRANTED) @@ -81,7 +81,7 @@ class RotationLockTileDataInteractorTest : SysuiTestCase() { .apply { addOverride(com.android.internal.R.bool.config_allowRotationResolver, true) } - .resources + .resources, ) } @@ -182,7 +182,7 @@ class RotationLockTileDataInteractorTest : SysuiTestCase() { whenever( packageManager.checkPermission( eq(Manifest.permission.CAMERA), - eq(TEST_PACKAGE_NAME) + eq(TEST_PACKAGE_NAME), ) ) .thenReturn(PackageManager.PERMISSION_DENIED) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/rotation/ui/mapper/RotationLockTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/rotation/ui/mapper/RotationLockTileMapperTest.kt index 74010143166b..0e6aaa6320c8 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/rotation/ui/mapper/RotationLockTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/rotation/ui/mapper/RotationLockTileMapperTest.kt @@ -25,7 +25,6 @@ import com.android.systemui.common.shared.model.Icon import com.android.systemui.defaultDeviceState import com.android.systemui.deviceStateManager import com.android.systemui.foldedDeviceStateList -import com.android.systemui.kosmos.Kosmos import com.android.systemui.qs.tiles.impl.custom.QSTileStateSubject import com.android.systemui.qs.tiles.impl.rotation.domain.model.RotationLockTileModel import com.android.systemui.qs.tiles.impl.rotation.qsRotationLockTileConfig @@ -33,6 +32,7 @@ import com.android.systemui.qs.tiles.viewmodel.QSTileState import com.android.systemui.res.R import com.android.systemui.statusbar.policy.DevicePostureController import com.android.systemui.statusbar.policy.devicePostureController +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import org.junit.Before import org.junit.Test @@ -42,7 +42,7 @@ import org.mockito.kotlin.whenever @SmallTest @RunWith(AndroidJUnit4::class) class RotationLockTileMapperTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val rotationLockTileConfig = kosmos.qsRotationLockTileConfig private val devicePostureController = kosmos.devicePostureController private val deviceStateManager = kosmos.deviceStateManager diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/saver/domain/DataSaverTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/saver/domain/DataSaverTileMapperTest.kt index 1fb5048dd4c9..079921640705 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/saver/domain/DataSaverTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/saver/domain/DataSaverTileMapperTest.kt @@ -22,19 +22,19 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.Icon -import com.android.systemui.kosmos.Kosmos import com.android.systemui.qs.tiles.impl.custom.QSTileStateSubject import com.android.systemui.qs.tiles.impl.saver.domain.model.DataSaverTileModel import com.android.systemui.qs.tiles.impl.saver.qsDataSaverTileConfig import com.android.systemui.qs.tiles.viewmodel.QSTileState import com.android.systemui.res.R +import com.android.systemui.testKosmos import org.junit.Test import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class DataSaverTileMapperTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val dataSaverTileConfig = kosmos.qsDataSaverTileConfig // Using lazy (versus =) to make sure we override the right context -- see b/311612168 diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/screenrecord/domain/interactor/ScreenRecordTileDataInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/screenrecord/domain/interactor/ScreenRecordTileDataInteractorTest.kt index 41174e7ca6af..127160d8728d 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/screenrecord/domain/interactor/ScreenRecordTileDataInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/screenrecord/domain/interactor/ScreenRecordTileDataInteractorTest.kt @@ -22,11 +22,11 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.qs.tiles.base.interactor.DataUpdateTrigger import com.android.systemui.screenrecord.data.model.ScreenRecordModel import com.android.systemui.screenrecord.data.repository.screenRecordRepository +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.runCurrent @@ -38,7 +38,7 @@ import org.junit.runner.RunWith @EnabledOnRavenwood @RunWith(AndroidJUnit4::class) class ScreenRecordTileDataInteractorTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testScope = kosmos.testScope private val screenRecordRepo = kosmos.screenRecordRepository private val underTest: ScreenRecordTileDataInteractor = diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/screenrecord/domain/interactor/ScreenRecordTileUserActionInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/screenrecord/domain/interactor/ScreenRecordTileUserActionInteractorTest.kt index 778c73fd8638..f47e0578461a 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/screenrecord/domain/interactor/ScreenRecordTileUserActionInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/screenrecord/domain/interactor/ScreenRecordTileUserActionInteractorTest.kt @@ -26,7 +26,6 @@ import com.android.systemui.animation.DialogTransitionAnimator import com.android.systemui.animation.Expandable import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.keyguard.domain.interactor.keyguardInteractor -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.mediaprojection.MediaProjectionMetricsLogger import com.android.systemui.plugins.ActivityStarter.OnDismissAction @@ -36,6 +35,7 @@ import com.android.systemui.screenrecord.RecordingController import com.android.systemui.screenrecord.data.model.ScreenRecordModel import com.android.systemui.screenrecord.data.repository.ScreenRecordRepositoryImpl import com.android.systemui.statusbar.phone.KeyguardDismissUtil +import com.android.systemui.testKosmos import kotlinx.coroutines.test.runTest import org.junit.Test import org.junit.runner.RunWith @@ -49,7 +49,7 @@ import org.mockito.kotlin.mock @SmallTest @RunWith(AndroidJUnit4::class) class ScreenRecordTileUserActionInteractorTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testScope = kosmos.testScope private val keyguardInteractor = kosmos.keyguardInteractor private val dialogTransitionAnimator = mock<DialogTransitionAnimator>() diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/screenrecord/ui/ScreenRecordTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/screenrecord/ui/ScreenRecordTileMapperTest.kt index 363255695131..d118c096fd16 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/screenrecord/ui/ScreenRecordTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/screenrecord/ui/ScreenRecordTileMapperTest.kt @@ -23,13 +23,13 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.Icon -import com.android.systemui.kosmos.Kosmos import com.android.systemui.qs.tiles.impl.custom.QSTileStateSubject import com.android.systemui.qs.tiles.impl.screenrecord.domain.ui.ScreenRecordTileMapper import com.android.systemui.qs.tiles.impl.screenrecord.qsScreenRecordTileConfig import com.android.systemui.qs.tiles.viewmodel.QSTileState import com.android.systemui.res.R import com.android.systemui.screenrecord.data.model.ScreenRecordModel +import com.android.systemui.testKosmos import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @@ -37,7 +37,7 @@ import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class ScreenRecordTileMapperTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val config = kosmos.qsScreenRecordTileConfig private lateinit var mapper: ScreenRecordTileMapper diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/sensorprivacy/domain/interactor/SensorPrivacyToggleTileDataInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/sensorprivacy/domain/interactor/SensorPrivacyToggleTileDataInteractorTest.kt index 6c7bb1b46c36..4a28fc02042d 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/sensorprivacy/domain/interactor/SensorPrivacyToggleTileDataInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/sensorprivacy/domain/interactor/SensorPrivacyToggleTileDataInteractorTest.kt @@ -23,11 +23,11 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.qs.tiles.base.interactor.DataUpdateTrigger import com.android.systemui.qs.tiles.impl.sensorprivacy.SensorPrivacyToggleTileDataInteractor import com.android.systemui.statusbar.policy.IndividualSensorPrivacyController +import com.android.systemui.testKosmos import com.android.systemui.util.mockito.argumentCaptor import com.android.systemui.util.mockito.mock import com.android.systemui.util.mockito.whenever @@ -44,7 +44,7 @@ import org.mockito.Mockito.verify @SmallTest @RunWith(AndroidJUnit4::class) class SensorPrivacyToggleTileDataInteractorTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testScope = kosmos.testScope private val mockSensorPrivacyController = mock<IndividualSensorPrivacyController> { @@ -55,7 +55,7 @@ class SensorPrivacyToggleTileDataInteractorTest : SysuiTestCase() { SensorPrivacyToggleTileDataInteractor( testScope.testScheduler, mockSensorPrivacyController, - CAMERA + CAMERA, ) @Test diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/sensorprivacy/domain/interactor/SensorPrivacyToggleTileUserActionInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/sensorprivacy/domain/interactor/SensorPrivacyToggleTileUserActionInteractorTest.kt index 562e6ebcc029..7856fcaf4a1b 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/sensorprivacy/domain/interactor/SensorPrivacyToggleTileUserActionInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/sensorprivacy/domain/interactor/SensorPrivacyToggleTileUserActionInteractorTest.kt @@ -26,7 +26,6 @@ import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.keyguard.domain.interactor.keyguardInteractor -import com.android.systemui.kosmos.Kosmos import com.android.systemui.plugins.activityStarter import com.android.systemui.qs.tiles.base.actions.FakeQSTileIntentUserInputHandler import com.android.systemui.qs.tiles.base.actions.QSTileIntentUserInputHandlerSubject @@ -34,6 +33,7 @@ import com.android.systemui.qs.tiles.base.interactor.QSTileInputTestKtx import com.android.systemui.qs.tiles.impl.sensorprivacy.domain.SensorPrivacyToggleTileUserActionInteractor import com.android.systemui.qs.tiles.impl.sensorprivacy.domain.model.SensorPrivacyToggleTileModel import com.android.systemui.statusbar.policy.IndividualSensorPrivacyController +import com.android.systemui.testKosmos import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.mock import com.android.systemui.util.mockito.whenever @@ -48,7 +48,7 @@ import org.mockito.Mockito.verify @SmallTest @RunWith(AndroidJUnit4::class) class SensorPrivacyToggleTileUserActionInteractorTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val inputHandler = FakeQSTileIntentUserInputHandler() private val keyguardInteractor = kosmos.keyguardInteractor // The keyguard repository below is the same one kosmos used to create the interactor above @@ -64,7 +64,7 @@ class SensorPrivacyToggleTileUserActionInteractorTest : SysuiTestCase() { mockActivityStarter, mockSensorPrivacyController, fakeSafetyCenterManager, - CAMERA + CAMERA, ) @Test @@ -79,7 +79,7 @@ class SensorPrivacyToggleTileUserActionInteractorTest : SysuiTestCase() { .setSensorBlocked( eq(SensorPrivacyManager.Sources.QS_TILE), eq(CAMERA), - eq(!originalIsBlocked) + eq(!originalIsBlocked), ) } @@ -95,7 +95,7 @@ class SensorPrivacyToggleTileUserActionInteractorTest : SysuiTestCase() { .setSensorBlocked( eq(SensorPrivacyManager.Sources.QS_TILE), eq(CAMERA), - eq(!originalIsBlocked) + eq(!originalIsBlocked), ) } @@ -114,7 +114,7 @@ class SensorPrivacyToggleTileUserActionInteractorTest : SysuiTestCase() { .setSensorBlocked( eq(SensorPrivacyManager.Sources.QS_TILE), eq(CAMERA), - eq(!originalIsBlocked) + eq(!originalIsBlocked), ) verify(mockActivityStarter).postQSRunnableDismissingKeyguard(any()) } @@ -150,7 +150,7 @@ class SensorPrivacyToggleTileUserActionInteractorTest : SysuiTestCase() { mockActivityStarter, mockSensorPrivacyController, fakeSafetyCenterManager, - MICROPHONE + MICROPHONE, ) micUserActionInteractor.handleInput( diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/sensorprivacy/ui/SensorPrivacyToggleTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/sensorprivacy/ui/SensorPrivacyToggleTileMapperTest.kt index e4cd0e0ec215..3b810dc451f9 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/sensorprivacy/ui/SensorPrivacyToggleTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/sensorprivacy/ui/SensorPrivacyToggleTileMapperTest.kt @@ -24,7 +24,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.Icon -import com.android.systemui.kosmos.Kosmos import com.android.systemui.qs.tiles.impl.custom.QSTileStateSubject import com.android.systemui.qs.tiles.impl.sensorprivacy.domain.model.SensorPrivacyToggleTileModel import com.android.systemui.qs.tiles.impl.sensorprivacy.qsCameraSensorPrivacyToggleTileConfig @@ -33,13 +32,14 @@ import com.android.systemui.qs.tiles.impl.sensorprivacy.ui.SensorPrivacyTileReso import com.android.systemui.qs.tiles.impl.sensorprivacy.ui.SensorPrivacyTileResources.MicrophonePrivacyTileResources import com.android.systemui.qs.tiles.viewmodel.QSTileState import com.android.systemui.res.R +import com.android.systemui.testKosmos import org.junit.Test import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class SensorPrivacyToggleTileMapperTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val cameraConfig = kosmos.qsCameraSensorPrivacyToggleTileConfig private val micConfig = kosmos.qsMicrophoneSensorPrivacyToggleTileConfig diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/uimodenight/domain/UiModeNightTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/uimodenight/domain/UiModeNightTileMapperTest.kt index 8f5f2d3e6689..547bbbc895a6 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/uimodenight/domain/UiModeNightTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/uimodenight/domain/UiModeNightTileMapperTest.kt @@ -25,12 +25,12 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.Icon -import com.android.systemui.kosmos.Kosmos import com.android.systemui.qs.tiles.impl.custom.QSTileStateSubject import com.android.systemui.qs.tiles.impl.uimodenight.UiModeNightTileModelHelper.createModel import com.android.systemui.qs.tiles.impl.uimodenight.qsUiModeNightTileConfig import com.android.systemui.qs.tiles.viewmodel.QSTileState import com.android.systemui.res.R +import com.android.systemui.testKosmos import kotlin.reflect.KClass import org.junit.Test import org.junit.runner.RunWith @@ -38,7 +38,7 @@ import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class UiModeNightTileMapperTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val qsTileConfig = kosmos.qsUiModeNightTileConfig private val mapper by lazy { diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/work/ui/WorkModeTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/work/ui/WorkModeTileMapperTest.kt index 2c81f39a03ec..ed3fc5058c44 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/work/ui/WorkModeTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/work/ui/WorkModeTileMapperTest.kt @@ -26,12 +26,12 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.Icon -import com.android.systemui.kosmos.Kosmos import com.android.systemui.qs.tiles.impl.custom.QSTileStateSubject import com.android.systemui.qs.tiles.impl.work.domain.model.WorkModeTileModel import com.android.systemui.qs.tiles.impl.work.qsWorkModeTileConfig import com.android.systemui.qs.tiles.viewmodel.QSTileState import com.android.systemui.res.R +import com.android.systemui.testKosmos import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.eq import com.android.systemui.util.mockito.mock @@ -43,7 +43,7 @@ import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class WorkModeTileMapperTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val qsTileConfig = kosmos.qsWorkModeTileConfig private val devicePolicyManager = kosmos.devicePolicyManager private val testLabel = context.getString(R.string.quick_settings_work_mode_label) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/ui/adapter/QSSceneAdapterImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/ui/adapter/QSSceneAdapterImplTest.kt index a8b005fb6554..12ed3f0c96fe 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/ui/adapter/QSSceneAdapterImplTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/ui/adapter/QSSceneAdapterImplTest.kt @@ -30,7 +30,6 @@ import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractorI import com.android.systemui.coroutines.collectLastValue import com.android.systemui.display.data.repository.displayStateRepository import com.android.systemui.dump.DumpManager -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testCase import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope @@ -40,6 +39,7 @@ import com.android.systemui.qs.dagger.QSSceneComponent import com.android.systemui.settings.brightness.MirrorController import com.android.systemui.shade.data.repository.fakeShadeRepository import com.android.systemui.shade.domain.interactor.shadeModeInteractor +import com.android.systemui.testKosmos import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.argumentCaptor import com.android.systemui.util.mockito.capture @@ -65,7 +65,7 @@ import org.mockito.Mockito.verify @RunWith(AndroidJUnit4::class) class QSSceneAdapterImplTest : SysuiTestCase() { - private val kosmos = Kosmos().apply { testCase = this@QSSceneAdapterImplTest } + private val kosmos = testKosmos().apply { testCase = this@QSSceneAdapterImplTest } private val testDispatcher = kosmos.testDispatcher private val testScope = kosmos.testScope diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/IssueRecordingServiceSessionTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/IssueRecordingServiceSessionTest.kt index 7bcaeabfee69..390a5d8efff1 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/IssueRecordingServiceSessionTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/IssueRecordingServiceSessionTest.kt @@ -28,12 +28,12 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.animation.DialogTransitionAnimator import com.android.systemui.animation.dialogTransitionAnimator import com.android.systemui.concurrency.fakeExecutor -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testCase import com.android.systemui.qs.pipeline.domain.interactor.PanelInteractor import com.android.systemui.settings.UserContextProvider import com.android.systemui.settings.userFileManager import com.android.systemui.settings.userTracker +import com.android.systemui.testKosmos import com.android.systemui.util.settings.fakeGlobalSettings import com.android.traceur.TraceConfig import com.google.common.truth.Truth @@ -52,7 +52,7 @@ import org.mockito.kotlin.verify @TestableLooper.RunWithLooper(setAsMainLooper = true) class IssueRecordingServiceSessionTest : SysuiTestCase() { - private val kosmos = Kosmos().also { it.testCase = this } + private val kosmos = testKosmos().also { it.testCase = this } private val bgExecutor = kosmos.fakeExecutor private val userContextProvider: UserContextProvider = kosmos.userTracker private val dialogTransitionAnimator: DialogTransitionAnimator = kosmos.dialogTransitionAnimator diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/IssueRecordingStateTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/IssueRecordingStateTest.kt index 83bdcd2161ee..0510e6ca3ced 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/IssueRecordingStateTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/IssueRecordingStateTest.kt @@ -22,9 +22,9 @@ import android.testing.TestableLooper import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase -import com.android.systemui.kosmos.Kosmos import com.android.systemui.settings.userFileManager import com.android.systemui.settings.userTracker +import com.android.systemui.testKosmos import com.android.systemui.util.settings.fakeGlobalSettings import com.google.common.truth.Truth import org.junit.Before @@ -40,7 +40,7 @@ import org.mockito.kotlin.verify @TestableLooper.RunWithLooper(setAsMainLooper = true) class IssueRecordingStateTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private lateinit var underTest: IssueRecordingState @Mock private lateinit var resolver: ContentResolver diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/ScreenRecordingStartTimeStoreTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/ScreenRecordingStartTimeStoreTest.kt index 737b10166199..6f0dd16eacd4 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/ScreenRecordingStartTimeStoreTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/ScreenRecordingStartTimeStoreTest.kt @@ -20,10 +20,10 @@ import android.testing.TestableLooper import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testCase import com.android.systemui.settings.UserTracker import com.android.systemui.settings.userTracker +import com.android.systemui.testKosmos import com.google.common.truth.Truth import org.junit.Before import org.junit.Test @@ -34,7 +34,7 @@ import org.mockito.MockitoAnnotations @RunWith(AndroidJUnit4::class) @TestableLooper.RunWithLooper(setAsMainLooper = true) class ScreenRecordingStartTimeStoreTest : SysuiTestCase() { - private val userTracker: UserTracker = Kosmos().also { it.testCase = this }.userTracker + private val userTracker: UserTracker = testKosmos().also { it.testCase = this }.userTracker private lateinit var underTest: ScreenRecordingStartTimeStore diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/interactor/WindowRootViewVisibilityInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/interactor/WindowRootViewVisibilityInteractorTest.kt index a82a7de75cc0..7e9487b04862 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/interactor/WindowRootViewVisibilityInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/interactor/WindowRootViewVisibilityInteractorTest.kt @@ -25,7 +25,6 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository import com.android.systemui.keyguard.shared.model.StatusBarState -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAsleepForTest import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAwakeForTest @@ -38,6 +37,7 @@ import com.android.systemui.statusbar.notification.domain.interactor.activeNotif import com.android.systemui.statusbar.notification.headsup.HeadsUpManager import com.android.systemui.statusbar.notification.init.NotificationsController import com.android.systemui.statusbar.notification.shared.NotificationsLiveDataStoreRefactor +import com.android.systemui.testKosmos import com.android.systemui.util.concurrency.FakeExecutor import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.argumentCaptor @@ -57,7 +57,7 @@ import org.mockito.Mockito.verify @RunWith(AndroidJUnit4::class) class WindowRootViewVisibilityInteractorTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testScope = kosmos.testScope private val testDispatcher = StandardTestDispatcher() private val iStatusBarService = mock<IStatusBarService>() diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/screenrecord/data/repository/ScreenRecordRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/screenrecord/data/repository/ScreenRecordRepositoryTest.kt index 9724974e3044..bd5416676c8a 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/screenrecord/data/repository/ScreenRecordRepositoryTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/screenrecord/data/repository/ScreenRecordRepositoryTest.kt @@ -21,10 +21,10 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.screenrecord.RecordingController import com.android.systemui.screenrecord.data.model.ScreenRecordModel +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest @@ -39,7 +39,7 @@ import org.mockito.kotlin.whenever @SmallTest @RunWith(AndroidJUnit4::class) class ScreenRecordRepositoryTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testScope = kosmos.testScope private val recordingController = mock<RecordingController>() diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ShadeControllerImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ShadeControllerImplTest.kt index c6ce58185cf0..0c90d077273d 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ShadeControllerImplTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ShadeControllerImplTest.kt @@ -25,7 +25,6 @@ import com.android.internal.statusbar.IStatusBarService import com.android.systemui.SysuiTestCase import com.android.systemui.assist.AssistManager import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.log.LogBuffer import com.android.systemui.plugins.statusbar.StatusBarStateController @@ -43,6 +42,7 @@ import com.android.systemui.statusbar.policy.DeviceProvisionedController import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.statusbar.window.StatusBarWindowController import com.android.systemui.statusbar.window.StatusBarWindowControllerStore +import com.android.systemui.testKosmos import com.android.systemui.util.concurrency.FakeExecutor import com.android.systemui.util.mockito.mock import com.android.systemui.util.mockito.whenever @@ -63,7 +63,7 @@ import org.mockito.MockitoAnnotations @SmallTest class ShadeControllerImplTest : SysuiTestCase() { private val executor = FakeExecutor(FakeSystemClock()) - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testScope = kosmos.testScope @Mock private lateinit var commandQueue: CommandQueue diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ShadeControllerSceneImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ShadeControllerSceneImplTest.kt index 054c1b8207eb..32eec56af8ea 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ShadeControllerSceneImplTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ShadeControllerSceneImplTest.kt @@ -27,7 +27,6 @@ import com.android.systemui.flags.Flags import com.android.systemui.flags.fakeFeatureFlagsClassic import com.android.systemui.keyguard.data.repository.fakeDeviceEntryFingerprintAuthRepository import com.android.systemui.keyguard.shared.model.SuccessFingerprintAuthenticationStatus -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testCase import com.android.systemui.kosmos.testScope import com.android.systemui.scene.domain.interactor.sceneInteractor @@ -35,6 +34,7 @@ import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shade.domain.interactor.ShadeInteractor import com.android.systemui.shade.domain.interactor.shadeInteractor import com.android.systemui.statusbar.CommandQueue +import com.android.systemui.testKosmos import com.android.systemui.util.mockito.mock import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.flow.MutableStateFlow @@ -52,7 +52,7 @@ import org.mockito.Mockito.verify @RunWith(AndroidJUnit4::class) @EnableSceneContainer class ShadeControllerSceneImplTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testScope = kosmos.testScope private val sceneInteractor by lazy { kosmos.sceneInteractor } private val deviceEntryInteractor by lazy { kosmos.deviceEntryInteractor } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/NotificationRemoteInputManagerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/NotificationRemoteInputManagerTest.java index 01046cd10d87..3c19179bc1c2 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/NotificationRemoteInputManagerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/NotificationRemoteInputManagerTest.java @@ -227,7 +227,7 @@ public class NotificationRemoteInputManagerTest extends SysuiTestCase { if (NotificationBundleUi.isEnabled()) { return row.getEntryAdapter().getSbn().getNotification(); } else { - return row.getEntry().getSbn().getNotification(); + return row.getEntryLegacy().getSbn().getNotification(); } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/OperatorNameViewControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/OperatorNameViewControllerTest.kt index 03dee3aeb75c..72d21f1064af 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/OperatorNameViewControllerTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/OperatorNameViewControllerTest.kt @@ -24,13 +24,13 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.keyguard.keyguardUpdateMonitor import com.android.systemui.SysuiTestCase -import com.android.systemui.kosmos.Kosmos import com.android.systemui.plugins.DarkIconDispatcher import com.android.systemui.statusbar.pipeline.airplane.data.repository.FakeAirplaneModeRepository import com.android.systemui.statusbar.pipeline.airplane.domain.interactor.AirplaneModeInteractor import com.android.systemui.statusbar.pipeline.mobile.data.repository.fakeMobileConnectionsRepository import com.android.systemui.statusbar.pipeline.mobile.util.FakeSubscriptionManagerProxy import com.android.systemui.statusbar.pipeline.shared.data.repository.FakeConnectivityRepository +import com.android.systemui.testKosmos import com.android.systemui.tuner.TunerService import com.android.systemui.util.CarrierConfigTracker import com.android.systemui.util.kotlin.JavaAdapter @@ -54,7 +54,7 @@ class OperatorNameViewControllerTest : SysuiTestCase() { private lateinit var underTest: OperatorNameViewController private lateinit var airplaneModeInteractor: AirplaneModeInteractor - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testScope = TestScope() private val view = OperatorNameView(mContext) diff --git a/packages/SystemUI/multivalentTests/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 index 485b9febc284..2fa9a02b9e87 100644 --- a/packages/SystemUI/multivalentTests/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 @@ -17,12 +17,17 @@ package com.android.systemui.statusbar.chips.call.ui.viewmodel import android.app.PendingIntent +import android.content.ComponentName +import android.content.Intent import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import android.platform.test.flag.junit.FlagsParameterization import android.view.View import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase +import com.android.systemui.activity.data.repository.activityManagerRepository +import com.android.systemui.activity.data.repository.fake +import com.android.systemui.animation.ActivityTransitionAnimator import com.android.systemui.animation.Expandable import com.android.systemui.common.shared.model.ContentDescription.Companion.loadContentDescription import com.android.systemui.common.shared.model.Icon @@ -51,6 +56,7 @@ import com.google.common.truth.Truth.assertThat import kotlin.test.Test import org.junit.runner.RunWith import org.mockito.kotlin.any +import org.mockito.kotlin.anyOrNull import org.mockito.kotlin.mock import org.mockito.kotlin.verify import org.mockito.kotlin.whenever @@ -481,6 +487,294 @@ class CallChipViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { verify(kosmos.activityStarter).postStartActivityDismissingKeyguard(pendingIntent, null) } + @Test + @EnableFlags(StatusBarChipsReturnAnimations.FLAG_NAME) + @EnableChipsModernization + fun chipWithReturnAnimation_updatesCorrectly_withStateAndTransitionState() = + kosmos.runTest { + val pendingIntent = mock<PendingIntent>() + val intent = mock<Intent>() + whenever(pendingIntent.intent).thenReturn(intent) + val component = mock<ComponentName>() + whenever(intent.component).thenReturn(component) + + val expandable = mock<Expandable>() + val activityController = mock<ActivityTransitionAnimator.Controller>() + whenever( + expandable.activityTransitionController( + anyOrNull(), + anyOrNull(), + any(), + anyOrNull(), + any(), + ) + ) + .thenReturn(activityController) + + val latest by collectLastValue(underTest.chip) + + // Start off with no call. + removeOngoingCallState(key = NOTIFICATION_KEY) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) + assertThat(latest!!.transitionManager!!.controllerFactory).isNull() + + // Call starts [NoCall -> InCall(isAppVisible=true), NoTransition]. + addOngoingCallState( + key = NOTIFICATION_KEY, + startTimeMs = 345, + contentIntent = pendingIntent, + uid = NOTIFICATION_UID, + isAppVisible = true, + ) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java) + assertThat((latest as OngoingActivityChipModel.Active).isHidden).isTrue() + val factory = latest!!.transitionManager!!.controllerFactory + assertThat(factory!!.component).isEqualTo(component) + + // Request a return transition [InCall(isAppVisible=true), NoTransition -> + // ReturnRequested]. + factory.onCompose(expandable) + var controller = factory.createController(forLaunch = false) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java) + assertThat((latest as OngoingActivityChipModel.Active).isHidden).isFalse() + assertThat(latest!!.transitionManager!!.controllerFactory).isEqualTo(factory) + + // Start the return transition [InCall(isAppVisible=true), ReturnRequested -> + // Returning]. + controller.onTransitionAnimationStart(isExpandingFullyAbove = false) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java) + assertThat((latest as OngoingActivityChipModel.Active).isHidden).isFalse() + assertThat(latest!!.transitionManager!!.controllerFactory).isEqualTo(factory) + + // End the return transition [InCall(isAppVisible=true), Returning -> NoTransition]. + controller.onTransitionAnimationEnd(isExpandingFullyAbove = false) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java) + assertThat((latest as OngoingActivityChipModel.Active).isHidden).isFalse() + assertThat(latest!!.transitionManager!!.controllerFactory).isEqualTo(factory) + + // Settle the return transition [InCall(isAppVisible=true) -> + // InCall(isAppVisible=false), NoTransition]. + kosmos.activityManagerRepository.fake.setIsAppVisible(NOTIFICATION_UID, false) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java) + assertThat((latest as OngoingActivityChipModel.Active).isHidden).isFalse() + assertThat(latest!!.transitionManager!!.controllerFactory).isEqualTo(factory) + + // Trigger a launch transition [InCall(isAppVisible=false) -> InCall(isAppVisible=true), + // NoTransition]. + kosmos.activityManagerRepository.fake.setIsAppVisible(NOTIFICATION_UID, true) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java) + assertThat((latest as OngoingActivityChipModel.Active).isHidden).isFalse() + assertThat(latest!!.transitionManager!!.controllerFactory).isEqualTo(factory) + + // Request the return transition [InCall(isAppVisible=true), NoTransition -> + // LaunchRequested]. + controller = factory.createController(forLaunch = true) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java) + assertThat((latest as OngoingActivityChipModel.Active).isHidden).isFalse() + assertThat(latest!!.transitionManager!!.controllerFactory).isEqualTo(factory) + + // Start the return transition [InCall(isAppVisible=true), LaunchRequested -> + // Launching]. + controller.onTransitionAnimationStart(isExpandingFullyAbove = false) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java) + assertThat((latest as OngoingActivityChipModel.Active).isHidden).isFalse() + assertThat(latest!!.transitionManager!!.controllerFactory).isEqualTo(factory) + + // End the return transition [InCall(isAppVisible=true), Launching -> NoTransition]. + controller.onTransitionAnimationStart(isExpandingFullyAbove = false) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java) + assertThat((latest as OngoingActivityChipModel.Active).isHidden).isFalse() + assertThat(latest!!.transitionManager!!.controllerFactory).isEqualTo(factory) + + // End the call with the app visible [InCall(isAppVisible=true) -> NoCall, + // NoTransition]. + removeOngoingCallState(key = NOTIFICATION_KEY) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) + assertThat(latest!!.transitionManager!!.controllerFactory).isNull() + + // End the call with the app hidden [InCall(isAppVisible=false) -> NoCall, + // NoTransition]. + addOngoingCallState( + key = NOTIFICATION_KEY, + startTimeMs = 345, + contentIntent = pendingIntent, + isAppVisible = false, + ) + removeOngoingCallState(key = NOTIFICATION_KEY) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) + assertThat(latest!!.transitionManager!!.controllerFactory).isNull() + } + + @Test + @DisableFlags(StatusBarChipsReturnAnimations.FLAG_NAME) + fun chipLegacy_hasNoTransitionAnimationInformation() = + kosmos.runTest { + val latest by collectLastValue(underTest.chip) + + // NoCall + removeOngoingCallState(key = NOTIFICATION_KEY) + assertThat(latest!!.transitionManager).isNull() + + // InCall with visible app + addOngoingCallState( + key = NOTIFICATION_KEY, + startTimeMs = 345, + uid = NOTIFICATION_UID, + isAppVisible = true, + ) + assertThat(latest!!.transitionManager).isNull() + + // InCall with hidden app + kosmos.activityManagerRepository.fake.setIsAppVisible(NOTIFICATION_UID, false) + assertThat(latest!!.transitionManager).isNull() + } + + @Test + @EnableFlags(StatusBarChipsReturnAnimations.FLAG_NAME) + @EnableChipsModernization + fun chipWithReturnAnimation_chipDataChangesMidTransition() = + kosmos.runTest { + val pendingIntent = mock<PendingIntent>() + val intent = mock<Intent>() + whenever(pendingIntent.intent).thenReturn(intent) + val component = mock<ComponentName>() + whenever(intent.component).thenReturn(component) + + val expandable = mock<Expandable>() + val activityController = mock<ActivityTransitionAnimator.Controller>() + whenever( + expandable.activityTransitionController( + anyOrNull(), + anyOrNull(), + any(), + anyOrNull(), + any(), + ) + ) + .thenReturn(activityController) + + val latest by collectLastValue(underTest.chip) + + // Start with the app visible and trigger a return animation. + addOngoingCallState( + key = NOTIFICATION_KEY, + startTimeMs = 345, + contentIntent = pendingIntent, + uid = NOTIFICATION_UID, + isAppVisible = true, + ) + var factory = latest!!.transitionManager!!.controllerFactory!! + factory.onCompose(expandable) + var controller = factory.createController(forLaunch = false) + controller.onTransitionAnimationStart(isExpandingFullyAbove = false) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.Timer::class.java) + assertThat((latest as OngoingActivityChipModel.Active).isHidden).isFalse() + + // The chip changes state. + addOngoingCallState( + key = NOTIFICATION_KEY, + startTimeMs = 0, + contentIntent = pendingIntent, + uid = NOTIFICATION_UID, + isAppVisible = true, + ) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.IconOnly::class.java) + assertThat((latest as OngoingActivityChipModel.Active).isHidden).isFalse() + + // Reset the state and trigger a launch animation. + controller.onTransitionAnimationEnd(isExpandingFullyAbove = false) + addOngoingCallState( + key = NOTIFICATION_KEY, + startTimeMs = 345, + contentIntent = pendingIntent, + uid = NOTIFICATION_UID, + isAppVisible = true, + ) + factory = latest!!.transitionManager!!.controllerFactory!! + factory.onCompose(expandable) + controller = factory.createController(forLaunch = true) + controller.onTransitionAnimationStart(isExpandingFullyAbove = false) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.Timer::class.java) + assertThat((latest as OngoingActivityChipModel.Active).isHidden).isFalse() + + // The chip changes state. + addOngoingCallState( + key = NOTIFICATION_KEY, + startTimeMs = -2, + contentIntent = pendingIntent, + uid = NOTIFICATION_UID, + isAppVisible = true, + ) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.IconOnly::class.java) + assertThat((latest as OngoingActivityChipModel.Active).isHidden).isFalse() + } + + @Test + @EnableFlags(StatusBarChipsReturnAnimations.FLAG_NAME) + @EnableChipsModernization + fun chipWithReturnAnimation_chipDisappearsMidTransition() = + kosmos.runTest { + val pendingIntent = mock<PendingIntent>() + val intent = mock<Intent>() + whenever(pendingIntent.intent).thenReturn(intent) + val component = mock<ComponentName>() + whenever(intent.component).thenReturn(component) + + val expandable = mock<Expandable>() + val activityController = mock<ActivityTransitionAnimator.Controller>() + whenever( + expandable.activityTransitionController( + anyOrNull(), + anyOrNull(), + any(), + anyOrNull(), + any(), + ) + ) + .thenReturn(activityController) + + val latest by collectLastValue(underTest.chip) + + // Start with the app visible and trigger a return animation. + addOngoingCallState( + key = NOTIFICATION_KEY, + startTimeMs = 345, + contentIntent = pendingIntent, + uid = NOTIFICATION_UID, + isAppVisible = true, + ) + var factory = latest!!.transitionManager!!.controllerFactory!! + factory.onCompose(expandable) + var controller = factory.createController(forLaunch = false) + controller.onTransitionAnimationStart(isExpandingFullyAbove = false) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.Timer::class.java) + assertThat((latest as OngoingActivityChipModel.Active).isHidden).isFalse() + + // The chip disappears. + removeOngoingCallState(key = NOTIFICATION_KEY) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) + + // Reset the state and trigger a launch animation. + controller.onTransitionAnimationEnd(isExpandingFullyAbove = false) + addOngoingCallState( + key = NOTIFICATION_KEY, + startTimeMs = 345, + contentIntent = pendingIntent, + uid = NOTIFICATION_UID, + isAppVisible = true, + ) + factory = latest!!.transitionManager!!.controllerFactory!! + factory.onCompose(expandable) + controller = factory.createController(forLaunch = true) + controller.onTransitionAnimationStart(isExpandingFullyAbove = false) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.Timer::class.java) + assertThat((latest as OngoingActivityChipModel.Active).isHidden).isFalse() + + // The chip disappears. + removeOngoingCallState(key = NOTIFICATION_KEY) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) + } + companion object { fun createStatusBarIconViewOrNull(): StatusBarIconView? = if (StatusBarConnectedDisplays.isEnabled) { @@ -500,6 +794,8 @@ class CallChipViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { } .build() + private const val NOTIFICATION_KEY = "testKey" + private const val NOTIFICATION_UID = 12345 private const val PROMOTED_BACKGROUND_COLOR = 65 private const val PROMOTED_PRIMARY_TEXT_COLOR = 98 diff --git a/packages/SystemUI/multivalentTests/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 index b2174c1b1d8c..21a4560dafee 100644 --- a/packages/SystemUI/multivalentTests/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 @@ -20,12 +20,12 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.mediarouter.data.repository.fakeMediaRouterRepository import com.android.systemui.statusbar.chips.casttootherdevice.domain.interactor.mediaRouterChipInteractor import com.android.systemui.statusbar.chips.casttootherdevice.domain.model.MediaRouterCastModel import com.android.systemui.statusbar.policy.CastDevice +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlin.test.Test import kotlinx.coroutines.test.runCurrent @@ -35,7 +35,7 @@ import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class MediaRouterChipInteractorTest : SysuiTestCase() { - val kosmos = Kosmos() + val kosmos = testKosmos() val testScope = kosmos.testScope val mediaRouterRepository = kosmos.fakeMediaRouterRepository diff --git a/packages/SystemUI/multivalentTests/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 index 274efbb50788..568129706458 100644 --- a/packages/SystemUI/multivalentTests/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 @@ -30,7 +30,6 @@ import android.view.Window import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testCase import com.android.systemui.kosmos.testScope import com.android.systemui.mediaprojection.data.model.MediaProjectionState @@ -41,6 +40,7 @@ import com.android.systemui.statusbar.chips.mediaprojection.domain.interactor.me import com.android.systemui.statusbar.chips.mediaprojection.domain.model.ProjectionChipModel import com.android.systemui.statusbar.chips.mediaprojection.ui.view.endMediaProjectionDialogHelper import com.android.systemui.statusbar.phone.SystemUIDialog +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlin.test.Test import kotlinx.coroutines.test.runCurrent @@ -57,7 +57,7 @@ import org.mockito.kotlin.whenever @SmallTest @RunWith(AndroidJUnit4::class) class EndCastScreenToOtherDeviceDialogDelegateTest : SysuiTestCase() { - private val kosmos = Kosmos().also { it.testCase = this } + private val kosmos = testKosmos().also { it.testCase = this } private val sysuiDialog = mock<SystemUIDialog>() private lateinit var underTest: EndCastScreenToOtherDeviceDialogDelegate diff --git a/packages/SystemUI/multivalentTests/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 index 88207d1c61d8..30a415cb9906 100644 --- a/packages/SystemUI/multivalentTests/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 @@ -26,7 +26,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testCase import com.android.systemui.kosmos.testScope import com.android.systemui.mediarouter.data.repository.fakeMediaRouterRepository @@ -35,6 +34,7 @@ import com.android.systemui.statusbar.chips.casttootherdevice.domain.interactor. import com.android.systemui.statusbar.chips.mediaprojection.ui.view.endMediaProjectionDialogHelper import com.android.systemui.statusbar.phone.SystemUIDialog import com.android.systemui.statusbar.policy.CastDevice +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlin.test.Test import kotlinx.coroutines.test.runCurrent @@ -51,7 +51,7 @@ import org.mockito.kotlin.whenever @SmallTest @RunWith(AndroidJUnit4::class) class EndGenericCastToOtherDeviceDialogDelegateTest : SysuiTestCase() { - private val kosmos = Kosmos().also { it.testCase = this } + private val kosmos = testKosmos().also { it.testCase = this } private val sysuiDialog = mock<SystemUIDialog>() private lateinit var underTest: EndGenericCastToOtherDeviceDialogDelegate diff --git a/packages/SystemUI/multivalentTests/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 index ccc844ad5837..d921ab3b284d 100644 --- a/packages/SystemUI/multivalentTests/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 @@ -30,7 +30,6 @@ import com.android.systemui.animation.mockDialogTransitionAnimator import com.android.systemui.common.shared.model.ContentDescription import com.android.systemui.common.shared.model.Icon import com.android.systemui.coroutines.collectLastValue -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testCase import com.android.systemui.kosmos.testScope import com.android.systemui.mediaprojection.data.model.MediaProjectionState @@ -52,6 +51,7 @@ import com.android.systemui.statusbar.phone.mockSystemUIDialogFactory import com.android.systemui.statusbar.phone.ongoingcall.DisableChipsModernization import com.android.systemui.statusbar.phone.ongoingcall.EnableChipsModernization import com.android.systemui.statusbar.policy.CastDevice +import com.android.systemui.testKosmos import com.android.systemui.util.time.fakeSystemClock import com.google.common.truth.Truth.assertThat import kotlin.test.Test @@ -69,7 +69,7 @@ import org.mockito.kotlin.whenever @SmallTest @RunWith(AndroidJUnit4::class) class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { - private val kosmos = Kosmos().also { it.testCase = this } + private val kosmos = testKosmos().also { it.testCase = this } private val testScope = kosmos.testScope private val mediaProjectionRepo = kosmos.fakeMediaProjectionRepository private val mediaRouterRepo = kosmos.fakeMediaRouterRepository diff --git a/packages/SystemUI/multivalentTests/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 index 795988f0087f..fac50b38d838 100644 --- a/packages/SystemUI/multivalentTests/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 @@ -24,12 +24,12 @@ import android.content.pm.PackageManager import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testCase import com.android.systemui.mediaprojection.data.model.MediaProjectionState import com.android.systemui.mediaprojection.taskswitcher.FakeActivityTaskManager.Companion.createTask import com.android.systemui.statusbar.phone.SystemUIDialog import com.android.systemui.statusbar.phone.mockSystemUIDialogFactory +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlin.test.Test import org.junit.runner.RunWith @@ -42,7 +42,7 @@ import org.mockito.kotlin.whenever @SmallTest @RunWith(AndroidJUnit4::class) class EndMediaProjectionDialogHelperTest : SysuiTestCase() { - private val kosmos = Kosmos().also { it.testCase = this } + private val kosmos = testKosmos().also { it.testCase = this } private val underTest = kosmos.endMediaProjectionDialogHelper diff --git a/packages/SystemUI/multivalentTests/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 index f560ee7730ae..981c9525f636 100644 --- a/packages/SystemUI/multivalentTests/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 @@ -30,7 +30,6 @@ import android.view.Window import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testCase import com.android.systemui.kosmos.testScope import com.android.systemui.mediaprojection.taskswitcher.FakeActivityTaskManager.Companion.createTask @@ -39,6 +38,7 @@ import com.android.systemui.screenrecord.data.repository.screenRecordRepository import com.android.systemui.statusbar.chips.mediaprojection.ui.view.endMediaProjectionDialogHelper import com.android.systemui.statusbar.chips.screenrecord.domain.interactor.screenRecordChipInteractor import com.android.systemui.statusbar.phone.SystemUIDialog +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlin.test.Test import kotlinx.coroutines.test.runCurrent @@ -55,7 +55,7 @@ import org.mockito.kotlin.whenever @SmallTest @RunWith(AndroidJUnit4::class) class EndScreenRecordingDialogDelegateTest : SysuiTestCase() { - private val kosmos = Kosmos().also { it.testCase = this } + private val kosmos = testKosmos().also { it.testCase = this } private val sysuiDialog = mock<SystemUIDialog>() diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/sharetoapp/ui/view/EndShareScreenToAppDialogDelegateTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/sharetoapp/ui/view/EndShareScreenToAppDialogDelegateTest.kt index 95aa6cd3250b..b2e90ecbeef1 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/sharetoapp/ui/view/EndShareScreenToAppDialogDelegateTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/sharetoapp/ui/view/EndShareScreenToAppDialogDelegateTest.kt @@ -30,7 +30,6 @@ import android.view.Window import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testCase import com.android.systemui.kosmos.testScope import com.android.systemui.mediaprojection.data.model.MediaProjectionState @@ -41,6 +40,7 @@ import com.android.systemui.statusbar.chips.mediaprojection.domain.interactor.me import com.android.systemui.statusbar.chips.mediaprojection.domain.model.ProjectionChipModel import com.android.systemui.statusbar.chips.mediaprojection.ui.view.endMediaProjectionDialogHelper import com.android.systemui.statusbar.phone.SystemUIDialog +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlin.test.Test import kotlinx.coroutines.test.runCurrent @@ -57,7 +57,7 @@ import org.mockito.kotlin.whenever @SmallTest @RunWith(AndroidJUnit4::class) class EndShareScreenToAppDialogDelegateTest : SysuiTestCase() { - private val kosmos = Kosmos().also { it.testCase = this } + private val kosmos = testKosmos().also { it.testCase = this } private val sysuiDialog = mock<SystemUIDialog>() private lateinit var underTest: EndShareScreenToAppDialogDelegate diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/ChipTransitionHelperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/ChipTransitionHelperTest.kt index e3a84fd2c2eb..6d91fb5a10cb 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/ChipTransitionHelperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/ChipTransitionHelperTest.kt @@ -22,12 +22,12 @@ import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.Icon import com.android.systemui.coroutines.collectLastValue -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.applicationCoroutineScope import com.android.systemui.kosmos.testScope import com.android.systemui.res.R import com.android.systemui.statusbar.chips.ui.model.ColorsModel import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlin.test.Test import kotlinx.coroutines.flow.MutableStateFlow @@ -39,7 +39,7 @@ import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class ChipTransitionHelperTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testScope = kosmos.testScope @Test diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/data/repository/StatusBarModeRepositoryImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/data/repository/StatusBarModeRepositoryImplTest.kt index 2f6bedb42e45..ea61b715475d 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/data/repository/StatusBarModeRepositoryImplTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/data/repository/StatusBarModeRepositoryImplTest.kt @@ -29,7 +29,6 @@ import com.android.internal.statusbar.LetterboxDetails import com.android.internal.view.AppearanceRegion import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue -import com.android.systemui.kosmos.Kosmos import com.android.systemui.statusbar.CommandQueue import com.android.systemui.statusbar.data.model.StatusBarMode import com.android.systemui.statusbar.layout.BoundsPair @@ -42,6 +41,7 @@ import com.android.systemui.statusbar.phone.ongoingcall.EnableChipsModernization import com.android.systemui.statusbar.phone.ongoingcall.data.repository.ongoingCallRepository import com.android.systemui.statusbar.phone.ongoingcall.shared.model.OngoingCallModel import com.android.systemui.statusbar.phone.ongoingcall.shared.model.inCallModel +import com.android.systemui.testKosmos import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.argumentCaptor import com.android.systemui.util.mockito.capture @@ -59,7 +59,7 @@ import org.mockito.Mockito.verify @SmallTest @RunWith(AndroidJUnit4::class) class StatusBarModeRepositoryImplTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testScope = TestScope() private val commandQueue = mock<CommandQueue>() private val letterboxAppearanceCalculator = mock<LetterboxAppearanceCalculator>() diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/collection/NotificationEntryTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/collection/NotificationEntryTest.java index 790b2c343a11..bfd700dcc302 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/collection/NotificationEntryTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/collection/NotificationEntryTest.java @@ -58,6 +58,7 @@ import com.android.systemui.res.R; import com.android.systemui.statusbar.RankingBuilder; import com.android.systemui.statusbar.SbnBuilder; import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips; +import com.android.systemui.statusbar.notification.collection.UseElapsedRealtimeForCreationTime; import com.android.systemui.statusbar.notification.promoted.PromotedNotificationUi; import com.android.systemui.util.time.FakeSystemClock; @@ -151,7 +152,8 @@ public class NotificationEntryTest extends SysuiTestCase { .build(); NotificationEntry entry = - new NotificationEntry(sbn, ranking, mClock.uptimeMillis()); + new NotificationEntry(sbn, ranking, + UseElapsedRealtimeForCreationTime.getCurrentTime(mClock)); assertFalse(entry.isBlockable()); } @@ -251,7 +253,8 @@ public class NotificationEntryTest extends SysuiTestCase { .build(); NotificationEntry entry = - new NotificationEntry(sbn, ranking, mClock.uptimeMillis()); + new NotificationEntry(sbn, ranking, + UseElapsedRealtimeForCreationTime.getCurrentTime(mClock)); assertEquals(systemGeneratedSmartActions, entry.getSmartActions()); assertEquals(NOTIFICATION_CHANNEL, entry.getChannel()); @@ -365,7 +368,8 @@ public class NotificationEntryTest extends SysuiTestCase { .setKey(sbn.getKey()) .build(); NotificationEntry entry = - new NotificationEntry(sbn, ranking, mClock.uptimeMillis()); + new NotificationEntry(sbn, ranking, + UseElapsedRealtimeForCreationTime.getCurrentTime(mClock)); assertFalse(entry.isChannelVisibilityPrivate()); } @@ -378,7 +382,8 @@ public class NotificationEntryTest extends SysuiTestCase { .setKey(sbn.getKey()) .build(); NotificationEntry entry = - new NotificationEntry(sbn, ranking, mClock.uptimeMillis()); + new NotificationEntry(sbn, ranking, + UseElapsedRealtimeForCreationTime.getCurrentTime(mClock)); assertFalse(entry.isChannelVisibilityPrivate()); } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/collection/coordinator/VisualStabilityCoordinatorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/collection/coordinator/VisualStabilityCoordinatorTest.kt index ef0a4169d98e..d532010f4c55 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/collection/coordinator/VisualStabilityCoordinatorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/collection/coordinator/VisualStabilityCoordinatorTest.kt @@ -50,6 +50,7 @@ import com.android.systemui.statusbar.notification.collection.GroupEntry import com.android.systemui.statusbar.notification.collection.GroupEntryBuilder import com.android.systemui.statusbar.notification.collection.NotificationEntry import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder +import com.android.systemui.statusbar.notification.collection.UseElapsedRealtimeForCreationTime import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifStabilityManager import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.Pluggable.PluggableListener import com.android.systemui.statusbar.notification.collection.notifPipeline @@ -323,7 +324,10 @@ class VisualStabilityCoordinatorTest(flags: FlagsParameterization) : SysuiTestCa setPulsing(true) // WHEN we temporarily allow section changes for this notification entry - underTest.temporarilyAllowSectionChanges(entry, fakeSystemClock.currentTimeMillis()) + underTest.temporarilyAllowSectionChanges( + entry, + UseElapsedRealtimeForCreationTime.getCurrentTime(fakeSystemClock), + ) // THEN group changes aren't allowed assertThat(notifStabilityManager.isGroupChangeAllowed(entry)).isFalse() @@ -349,7 +353,10 @@ class VisualStabilityCoordinatorTest(flags: FlagsParameterization) : SysuiTestCa setPulsing(false) // WHEN we temporarily allow section changes for this notification entry - underTest.temporarilyAllowSectionChanges(entry, fakeSystemClock.uptimeMillis()) + underTest.temporarilyAllowSectionChanges( + entry, + UseElapsedRealtimeForCreationTime.getCurrentTime(fakeSystemClock), + ) // THEN the notification list is invalidated verifyStabilityManagerWasInvalidated(times(1)) @@ -365,7 +372,10 @@ class VisualStabilityCoordinatorTest(flags: FlagsParameterization) : SysuiTestCa setPulsing(false) // WHEN we temporarily allow section changes for this notification entry - underTest.temporarilyAllowSectionChanges(entry, fakeSystemClock.currentTimeMillis()) + underTest.temporarilyAllowSectionChanges( + entry, + UseElapsedRealtimeForCreationTime.getCurrentTime(fakeSystemClock), + ) // THEN invalidate is not called because this entry was never suppressed from reordering verifyStabilityManagerWasInvalidated(never()) @@ -382,7 +392,10 @@ class VisualStabilityCoordinatorTest(flags: FlagsParameterization) : SysuiTestCa assertThat(notifStabilityManager.isSectionChangeAllowed(entry)).isTrue() // WHEN we temporarily allow section changes for this notification entry - underTest.temporarilyAllowSectionChanges(entry, fakeSystemClock.currentTimeMillis()) + underTest.temporarilyAllowSectionChanges( + entry, + UseElapsedRealtimeForCreationTime.getCurrentTime(fakeSystemClock), + ) // THEN invalidate is not called because this entry was never suppressed from // reordering; @@ -415,7 +428,10 @@ class VisualStabilityCoordinatorTest(flags: FlagsParameterization) : SysuiTestCa setPulsing(true) // WHEN we temporarily allow section changes for this notification entry - underTest.temporarilyAllowSectionChanges(entry, fakeSystemClock.currentTimeMillis()) + underTest.temporarilyAllowSectionChanges( + entry, + UseElapsedRealtimeForCreationTime.getCurrentTime(fakeSystemClock), + ) // can now reorder, so invalidates verifyStabilityManagerWasInvalidated(times(1)) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/NotificationInfoTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/NotificationInfoTest.kt index b5f3269903b8..0ac5fe95957c 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/NotificationInfoTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/NotificationInfoTest.kt @@ -58,7 +58,6 @@ import com.android.internal.logging.metricsLogger import com.android.internal.logging.uiEventLoggerFake import com.android.systemui.Dependency import com.android.systemui.SysuiTestCase -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testCase import com.android.systemui.res.R import com.android.systemui.statusbar.RankingBuilder @@ -70,6 +69,7 @@ import com.android.systemui.statusbar.notification.row.icon.AppIconProvider import com.android.systemui.statusbar.notification.row.icon.NotificationIconStyleProvider import com.android.systemui.statusbar.notification.row.icon.appIconProvider import com.android.systemui.statusbar.notification.row.icon.notificationIconStyleProvider +import com.android.systemui.testKosmos import com.android.telecom.telecomManager import com.google.common.truth.Truth.assertThat import java.util.concurrent.CountDownLatch @@ -91,7 +91,7 @@ import org.mockito.kotlin.whenever @RunWith(AndroidJUnit4::class) @RunWithLooper class NotificationInfoTest : SysuiTestCase() { - private val kosmos = Kosmos().also { it.testCase = this } + private val kosmos = testKosmos().also { it.testCase = this } private lateinit var underTest: NotificationInfo private lateinit var notificationChannel: NotificationChannel diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/shelf/domain/interactor/NotificationShelfInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/shelf/domain/interactor/NotificationShelfInteractorTest.kt index 048028cdc0fa..db0c59f6d602 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/shelf/domain/interactor/NotificationShelfInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/shelf/domain/interactor/NotificationShelfInteractorTest.kt @@ -23,12 +23,12 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.keyguard.data.repository.fakeDeviceEntryFaceAuthRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testCase import com.android.systemui.plugins.statusbar.statusBarStateController import com.android.systemui.power.data.repository.fakePowerRepository import com.android.systemui.statusbar.lockscreenShadeTransitionController import com.android.systemui.statusbar.phone.screenOffAnimationController +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runTest import org.junit.Test @@ -44,7 +44,7 @@ import org.mockito.kotlin.whenever class NotificationShelfInteractorTest : SysuiTestCase() { private val kosmos = - Kosmos().apply { + testKosmos().apply { testCase = this@NotificationShelfInteractorTest lockscreenShadeTransitionController = mock() screenOffAnimationController = mock() diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/shelf/ui/viewmodel/NotificationShelfViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/shelf/ui/viewmodel/NotificationShelfViewModelTest.kt index 6381b4e0fef7..7265262183ca 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/shelf/ui/viewmodel/NotificationShelfViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/shelf/ui/viewmodel/NotificationShelfViewModelTest.kt @@ -24,7 +24,6 @@ import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.keyguard.data.repository.fakeDeviceEntryFaceAuthRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.testCase @@ -35,6 +34,7 @@ import com.android.systemui.shade.domain.interactor.enableSingleShade import com.android.systemui.shade.domain.interactor.enableSplitShade import com.android.systemui.statusbar.lockscreenShadeTransitionController import com.android.systemui.statusbar.phone.screenOffAnimationController +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runTest import org.junit.Test @@ -50,7 +50,7 @@ import org.mockito.kotlin.whenever class NotificationShelfViewModelTest : SysuiTestCase() { private val kosmos = - Kosmos().apply { + testKosmos().apply { testCase = this@NotificationShelfViewModelTest lockscreenShadeTransitionController = mock() screenOffAnimationController = mock() diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/NotificationGroupTestHelper.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/NotificationGroupTestHelper.java index c5abd026b369..19e98387a120 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/NotificationGroupTestHelper.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/NotificationGroupTestHelper.java @@ -106,6 +106,7 @@ public final class NotificationGroupTestHelper { ExpandableNotificationRow row = mock(ExpandableNotificationRow.class); entry.setRow(row); when(row.getEntry()).thenReturn(entry); + when(row.getEntryLegacy()).thenReturn(entry); return entry; } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallControllerTest.kt index eb95ddb39b40..c58b4bc9953c 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallControllerTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallControllerTest.kt @@ -30,7 +30,6 @@ import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.concurrency.fakeExecutor import com.android.systemui.dump.DumpManager -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.log.logcatLogBuffer import com.android.systemui.res.R @@ -48,6 +47,7 @@ import com.android.systemui.statusbar.phone.ongoingcall.data.repository.ongoingC import com.android.systemui.statusbar.phone.ongoingcall.shared.model.OngoingCallModel import com.android.systemui.statusbar.window.StatusBarWindowController import com.android.systemui.statusbar.window.StatusBarWindowControllerStore +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest @@ -70,7 +70,7 @@ import org.mockito.kotlin.whenever @TestableLooper.RunWithLooper @DisableFlags(StatusBarChipsModernization.FLAG_NAME) class OngoingCallControllerTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val mainExecutor = kosmos.fakeExecutor private val testScope = kosmos.testScope diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/ongoingcall/data/repository/OngoingCallRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/ongoingcall/data/repository/OngoingCallRepositoryTest.kt index a44631348796..7de56ddc06c3 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/ongoingcall/data/repository/OngoingCallRepositoryTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/ongoingcall/data/repository/OngoingCallRepositoryTest.kt @@ -19,12 +19,11 @@ package com.android.systemui.statusbar.phone.ongoingcall.data.repository import android.platform.test.annotations.DisableFlags import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest -import com.android.systemui.Flags.FLAG_STATUS_BAR_CHIPS_MODERNIZATION import com.android.systemui.SysuiTestCase -import com.android.systemui.kosmos.Kosmos import com.android.systemui.statusbar.phone.ongoingcall.StatusBarChipsModernization import com.android.systemui.statusbar.phone.ongoingcall.shared.model.OngoingCallModel import com.android.systemui.statusbar.phone.ongoingcall.shared.model.inCallModel +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import org.junit.Test import org.junit.runner.RunWith @@ -33,7 +32,7 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) @DisableFlags(StatusBarChipsModernization.FLAG_NAME) class OngoingCallRepositoryTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val underTest = kosmos.ongoingCallRepository @Test diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/ongoingcall/domain/interactor/OngoingCallInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/ongoingcall/domain/interactor/OngoingCallInteractorTest.kt index f4204af7829b..84f1d5cd4895 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/ongoingcall/domain/interactor/OngoingCallInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/ongoingcall/domain/interactor/OngoingCallInteractorTest.kt @@ -23,7 +23,6 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.activity.data.repository.activityManagerRepository import com.android.systemui.activity.data.repository.fake import com.android.systemui.coroutines.collectLastValue -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.useUnconfinedTestDispatcher @@ -36,6 +35,7 @@ import com.android.systemui.statusbar.phone.ongoingcall.shared.model.OngoingCall import com.android.systemui.statusbar.phone.ongoingcall.shared.model.OngoingCallTestHelper.addOngoingCallState import com.android.systemui.statusbar.phone.ongoingcall.shared.model.OngoingCallTestHelper.removeOngoingCallState import com.android.systemui.statusbar.window.fakeStatusBarWindowControllerStore +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runTest import org.junit.Before @@ -51,7 +51,7 @@ import org.mockito.kotlin.verify @RunWith(AndroidJUnit4::class) @EnableChipsModernization class OngoingCallInteractorTest : SysuiTestCase() { - private val kosmos = Kosmos().useUnconfinedTestDispatcher() + private val kosmos = testKosmos().useUnconfinedTestDispatcher() private val underTest = kosmos.ongoingCallInteractor @Before diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/unfold/DisplaySwitchLatencyTrackerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/unfold/DisplaySwitchLatencyTrackerTest.kt index 92bec70d2c4d..18a124cf362e 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/unfold/DisplaySwitchLatencyTrackerTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/unfold/DisplaySwitchLatencyTrackerTest.kt @@ -38,7 +38,6 @@ import com.android.systemui.display.data.repository.DeviceStateRepository.Device import com.android.systemui.display.data.repository.fakeDeviceStateRepository import com.android.systemui.foldedDeviceStateList import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor -import com.android.systemui.kosmos.Kosmos import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAsleepForTest import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAwakeForTest import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setScreenPowerState @@ -47,6 +46,7 @@ import com.android.systemui.power.shared.model.ScreenPowerState.SCREEN_OFF import com.android.systemui.power.shared.model.ScreenPowerState.SCREEN_ON import com.android.systemui.shared.system.SysUiStatsLog import com.android.systemui.statusbar.policy.FakeConfigurationController +import com.android.systemui.testKosmos import com.android.systemui.unfold.DisplaySwitchLatencyTracker.Companion.COOL_DOWN_DURATION import com.android.systemui.unfold.DisplaySwitchLatencyTracker.Companion.FOLDABLE_DEVICE_STATE_CLOSED import com.android.systemui.unfold.DisplaySwitchLatencyTracker.Companion.FOLDABLE_DEVICE_STATE_HALF_OPEN @@ -89,7 +89,7 @@ class DisplaySwitchLatencyTrackerTest : SysuiTestCase() { private lateinit var displaySwitchLatencyTracker: DisplaySwitchLatencyTracker @Captor private lateinit var loggerArgumentCaptor: ArgumentCaptor<DisplaySwitchLatencyEvent> - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val mockContext = mock<Context>() private val resources = mock<Resources>() private val foldStateRepository = kosmos.fakeDeviceStateRepository diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/unfold/FoldLightRevealOverlayAnimationTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/unfold/FoldLightRevealOverlayAnimationTest.kt index dfc4d0f07df8..98d99f781879 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/unfold/FoldLightRevealOverlayAnimationTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/unfold/FoldLightRevealOverlayAnimationTest.kt @@ -28,7 +28,6 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.animation.AnimatorTestRule import com.android.systemui.display.data.repository.DeviceStateRepository.DeviceState import com.android.systemui.display.data.repository.fakeDeviceStateRepository -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAsleepForTest @@ -36,6 +35,7 @@ import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.se import com.android.systemui.power.domain.interactor.powerInteractor import com.android.systemui.power.shared.model.ScreenPowerState import com.android.systemui.statusbar.LightRevealScrim +import com.android.systemui.testKosmos import com.android.systemui.util.animation.data.repository.fakeAnimationStatusRepository import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.advanceTimeBy @@ -61,7 +61,7 @@ import org.mockito.kotlin.whenever class FoldLightRevealOverlayAnimationTest : SysuiTestCase() { @get:Rule val animatorTestRule = AnimatorTestRule(this) - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val testScope: TestScope = kosmos.testScope private val fakeDeviceStateRepository = kosmos.fakeDeviceStateRepository private val powerInteractor = kosmos.powerInteractor @@ -93,7 +93,7 @@ class FoldLightRevealOverlayAnimationTest : SysuiTestCase() { fakeAnimationStatusRepository, mockControllerFactory, mockFoldLockSettingAvailabilityProvider, - mockJankMonitor + mockJankMonitor, ) foldLightRevealAnimation.init() } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/util/UtilsTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/util/UtilsTest.kt index b4ba41a5c524..a180d51ff0ba 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/util/UtilsTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/util/UtilsTest.kt @@ -27,7 +27,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.deviceStateManager -import com.android.systemui.kosmos.Kosmos +import com.android.systemui.testKosmos import junit.framework.Assert.assertFalse import junit.framework.Assert.assertTrue import org.junit.Before @@ -39,7 +39,7 @@ import org.mockito.kotlin.whenever @RunWith(AndroidJUnit4::class) class UtilsTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private val deviceStateManager = kosmos.deviceStateManager private lateinit var testableResources: TestableResources @@ -53,7 +53,7 @@ class UtilsTest : SysuiTestCase() { fun isFoldableReturnsFalse_overlayConfigurationValues() { testableResources.addOverride( com.android.internal.R.array.config_foldedDeviceStates, - intArrayOf() // empty array <=> device is not foldable + intArrayOf(), // empty array <=> device is not foldable ) whenever(deviceStateManager.supportedDeviceStates).thenReturn(listOf(DEFAULT_DEVICE_STATE)) assertFalse(Utils.isDeviceFoldable(testableResources.resources, deviceStateManager)) @@ -64,7 +64,7 @@ class UtilsTest : SysuiTestCase() { fun isFoldableReturnsFalse_deviceStateManager() { testableResources.addOverride( com.android.internal.R.array.config_foldedDeviceStates, - intArrayOf() // empty array <=> device is not foldable + intArrayOf(), // empty array <=> device is not foldable ) whenever(deviceStateManager.supportedDeviceStates).thenReturn(listOf(DEFAULT_DEVICE_STATE)) assertFalse(Utils.isDeviceFoldable(testableResources.resources, deviceStateManager)) @@ -75,7 +75,7 @@ class UtilsTest : SysuiTestCase() { fun isFoldableReturnsTrue_overlayConfigurationValues() { testableResources.addOverride( com.android.internal.R.array.config_foldedDeviceStates, - intArrayOf(FOLDED_DEVICE_STATE.identifier) + intArrayOf(FOLDED_DEVICE_STATE.identifier), ) whenever(deviceStateManager.supportedDeviceStates) .thenReturn(listOf(FOLDED_DEVICE_STATE, UNFOLDED_DEVICE_STATE)) @@ -87,7 +87,7 @@ class UtilsTest : SysuiTestCase() { fun isFoldableReturnsTrue_deviceStateManager() { testableResources.addOverride( com.android.internal.R.array.config_foldedDeviceStates, - intArrayOf(FOLDED_DEVICE_STATE.identifier) + intArrayOf(FOLDED_DEVICE_STATE.identifier), ) whenever(deviceStateManager.supportedDeviceStates) .thenReturn(listOf(FOLDED_DEVICE_STATE, UNFOLDED_DEVICE_STATE)) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/domain/interactor/ComponentsInteractorImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/domain/interactor/ComponentsInteractorImplTest.kt index f232d52615a4..93e5721e9b27 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/domain/interactor/ComponentsInteractorImplTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/domain/interactor/ComponentsInteractorImplTest.kt @@ -20,8 +20,8 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue -import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope +import com.android.systemui.testKosmos import com.android.systemui.volume.panel.domain.availableCriteria import com.android.systemui.volume.panel.domain.defaultCriteria import com.android.systemui.volume.panel.domain.model.ComponentModel @@ -39,7 +39,7 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) class ComponentsInteractorImplTest : SysuiTestCase() { - private val kosmos = Kosmos() + private val kosmos = testKosmos() private lateinit var underTest: ComponentsInteractor @@ -60,12 +60,7 @@ class ComponentsInteractorImplTest : SysuiTestCase() { fun componentsAvailability_checked() { with(kosmos) { testScope.runTest { - enabledComponents = - setOf( - BOTTOM_BAR, - COMPONENT_1, - COMPONENT_2, - ) + enabledComponents = setOf(BOTTOM_BAR, COMPONENT_1, COMPONENT_2) criteriaByKey = mapOf( BOTTOM_BAR to Provider { availableCriteria }, @@ -90,12 +85,7 @@ class ComponentsInteractorImplTest : SysuiTestCase() { fun noCriteria_fallbackToDefaultCriteria() { with(kosmos) { testScope.runTest { - enabledComponents = - setOf( - BOTTOM_BAR, - COMPONENT_1, - COMPONENT_2, - ) + enabledComponents = setOf(BOTTOM_BAR, COMPONENT_1, COMPONENT_2) criteriaByKey = mapOf( BOTTOM_BAR to Provider { availableCriteria }, diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml index f4c6904028ca..15519ff37d0c 100644 --- a/packages/SystemUI/res/values/colors.xml +++ b/packages/SystemUI/res/values/colors.xml @@ -34,7 +34,7 @@ <!-- Base colors for notification shade/scrim, the alpha component is adjusted programmatically to match the spec --> - <color name="shade_panel_base">@android:color/system_accent1_900</color> + <color name="shade_panel_base">@android:color/system_accent1_100</color> <color name="notification_scrim_base">@android:color/system_accent1_100</color> <!-- Fallback colors for notification shade/scrim --> diff --git a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java index c78f75a334fd..089466707298 100644 --- a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java +++ b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java @@ -894,8 +894,8 @@ public class SwipeHelper implements Gefingerpoken, Dumpable { if (NotificationBundleUi.isEnabled()) { return enr.getEntryAdapter().canDragAndDrop(); } else { - boolean canBubble = enr.getEntry().canBubble(); - Notification notif = enr.getEntry().getSbn().getNotification(); + boolean canBubble = enr.getEntryLegacy().canBubble(); + Notification notif = enr.getEntryLegacy().getSbn().getNotification(); PendingIntent dragIntent = notif.contentIntent != null ? notif.contentIntent : notif.fullScreenIntent; if (dragIntent != null && dragIntent.isActivity() && !canBubble) { diff --git a/packages/SystemUI/src/com/android/systemui/communal/widgets/CommunalAppWidgetHostStartable.kt b/packages/SystemUI/src/com/android/systemui/communal/widgets/CommunalAppWidgetHostStartable.kt index 06a14eaa5c85..440c3001a2f9 100644 --- a/packages/SystemUI/src/com/android/systemui/communal/widgets/CommunalAppWidgetHostStartable.kt +++ b/packages/SystemUI/src/com/android/systemui/communal/widgets/CommunalAppWidgetHostStartable.kt @@ -16,6 +16,7 @@ package com.android.systemui.communal.widgets +import android.appwidget.AppWidgetProviderInfo import com.android.systemui.CoreStartable import com.android.systemui.communal.domain.interactor.CommunalInteractor import com.android.systemui.communal.domain.interactor.CommunalSettingsInteractor @@ -101,6 +102,7 @@ constructor( val (_, isActive) = withPrev // The validation is performed once the hub becomes active. if (isActive) { + removeNotLockscreenWidgets(widgets) validateWidgetsAndDeleteOrphaned(widgets) } } @@ -144,6 +146,19 @@ constructor( } } + private fun removeNotLockscreenWidgets(widgets: List<CommunalWidgetContentModel>) { + widgets + .filter { widget -> + when (widget) { + is CommunalWidgetContentModel.Available -> + widget.providerInfo.widgetCategory and + AppWidgetProviderInfo.WIDGET_CATEGORY_NOT_KEYGUARD != 0 + else -> false + } + } + .onEach { widget -> communalInteractor.deleteWidget(id = widget.appWidgetId) } + } + /** * Ensure the existence of all associated users for widgets, and remove widgets belonging to * users who have been deleted. diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index d8fc21af9724..4755e2845587 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -134,7 +134,6 @@ import com.android.keyguard.ViewMediatorCallback; import com.android.keyguard.mediator.ScreenOnCoordinator; import com.android.systemui.CoreStartable; import com.android.systemui.DejankUtils; -import com.android.systemui.Dumpable; import com.android.systemui.EventLogTags; import com.android.systemui.animation.ActivityTransitionAnimator; import com.android.systemui.animation.TransitionAnimator; @@ -194,7 +193,6 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.Arrays; -import java.util.Iterator; import java.util.List; import java.util.Objects; import java.util.concurrent.Executor; @@ -4129,14 +4127,14 @@ public class KeyguardViewMediator implements CoreStartable, private void notifyLockNowCallback() { List<LockNowCallback> callbacks; + synchronized (mLockNowCallbacks) { - callbacks = new ArrayList<LockNowCallback>(mLockNowCallbacks); + callbacks = new ArrayList<>(mLockNowCallbacks); mLockNowCallbacks.clear(); } - Iterator<LockNowCallback> iter = callbacks.listIterator(); - while (iter.hasNext()) { - LockNowCallback callback = iter.next(); - iter.remove(); + + for (int i = 0; i < callbacks.size(); i++) { + final LockNowCallback callback = callbacks.get(i); if (callback.mUserId != mSelectedUserInteractor.getSelectedUserId()) { Log.i(TAG, "Not notifying lockNowCallback due to user mismatch"); continue; diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardServiceShowLockscreenInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardServiceShowLockscreenInteractor.kt index 07a31e16384c..6c084038f328 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardServiceShowLockscreenInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardServiceShowLockscreenInteractor.kt @@ -139,18 +139,16 @@ constructor( /** Notifies the callbacks that we've either locked, or decided not to lock. */ private fun notifyShowLockscreenCallbacks() { var callbacks: MutableList<ShowLockscreenCallback> + synchronized(repository.showLockscreenCallbacks) { callbacks = ArrayList(repository.showLockscreenCallbacks) repository.showLockscreenCallbacks.clear() } - val iter: MutableIterator<ShowLockscreenCallback> = callbacks.listIterator() - while (iter.hasNext()) { - val callback = iter.next() - iter.remove() + callbacks.forEach { callback -> if (callback.userId != selectedUserInteractor.getSelectedUserId()) { Log.i(TAG, "Not notifying lockNowCallback due to user mismatch") - continue + return } Log.i(TAG, "Notifying lockNowCallback") try { diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarController.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarController.java index 49fa3ba2da61..88f679e73388 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarController.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarController.java @@ -72,4 +72,8 @@ public interface NavigationBarController { /** @return {@link NavigationBar} on the default display. */ @Nullable NavigationBar getDefaultNavigationBar(); + + /** @return {@link NavigationBar} for a specific display, or null if not available. */ + @Nullable + NavigationBar getNavigationBar(int displayId); } diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarControllerEmptyImpl.kt b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarControllerEmptyImpl.kt index 45ff7f4f87ef..f096510fa5dc 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarControllerEmptyImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarControllerEmptyImpl.kt @@ -54,4 +54,6 @@ class NavigationBarControllerEmptyImpl @Inject constructor() : NavigationBarCont override fun isOverviewEnabled(displayId: Int) = false override fun getDefaultNavigationBar(): NavigationBar? = null + + override fun getNavigationBar(displayId: Int): NavigationBar? = null } diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarControllerImpl.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarControllerImpl.java index 50d0a459da66..8fbf8b60af9a 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarControllerImpl.java @@ -469,7 +469,8 @@ public class NavigationBarControllerImpl implements return (navBar == null) ? null : navBar.getView(); } - private @Nullable NavigationBar getNavigationBar(int displayId) { + @Override + public @Nullable NavigationBar getNavigationBar(int displayId) { return mNavigationBars.get(displayId); } diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarModule.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarModule.java index 914e0f74e4a0..58ddbf60e8fb 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarModule.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarModule.java @@ -27,10 +27,13 @@ import android.view.WindowManager; import com.android.app.viewcapture.ViewCapture; import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.systemui.dagger.qualifiers.DisplayId; +import com.android.systemui.display.data.repository.PerDisplayRepository; +import com.android.systemui.model.SysUiState; import com.android.systemui.navigationbar.NavigationBarComponent.NavigationBarScope; import com.android.systemui.navigationbar.views.NavigationBarFrame; import com.android.systemui.navigationbar.views.NavigationBarView; import com.android.systemui.res.R; +import com.android.systemui.shade.shared.flag.ShadeWindowGoesAround; import dagger.Lazy; import dagger.Module; @@ -71,6 +74,20 @@ public interface NavigationBarModule { return context.getSystemService(WindowManager.class); } + /** A SysUiState for the navigation bar display. */ + @Provides + @NavigationBarScope + @DisplayId + static SysUiState provideSysUiState(@DisplayId Context context, + SysUiState defaultState, + PerDisplayRepository<SysUiState> repository) { + if (ShadeWindowGoesAround.isEnabled()) { + return repository.get(context.getDisplayId()); + } else { + return defaultState; + } + } + /** A ViewCaptureAwareWindowManager specific to the display's context. */ @Provides @NavigationBarScope diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/views/NavigationBar.java b/packages/SystemUI/src/com/android/systemui/navigationbar/views/NavigationBar.java index f95f45906b23..8b5b3adeef1f 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/views/NavigationBar.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/views/NavigationBar.java @@ -569,7 +569,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements NavigationModeController navigationModeController, StatusBarStateController statusBarStateController, StatusBarKeyguardViewManager statusBarKeyguardViewManager, - SysUiState sysUiFlagsContainer, + @DisplayId SysUiState sysUiFlagsContainer, UserTracker userTracker, CommandQueue commandQueue, Optional<Pip> pipOptional, @@ -1694,7 +1694,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements (mNavbarFlags & NAVBAR_BACK_DISMISS_IME) != 0) .setFlag(SYSUI_STATE_ALLOW_GESTURE_IGNORING_BAR_VISIBILITY, allowSystemGestureIgnoringBarVisibility()) - .commitUpdate(mDisplayId); + .commitUpdate(); } private void updateAssistantEntrypoints(boolean assistantAvailable, diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/views/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/navigationbar/views/NavigationBarView.java index 36cb8fa374b0..cbc4c26b2f94 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/views/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/views/NavigationBarView.java @@ -740,15 +740,13 @@ public class NavigationBarView extends FrameLayout { /** */ public void updateDisabledSystemUiStateFlags(SysUiState sysUiState) { - int displayId = mContext.getDisplayId(); - sysUiState.setFlag(SYSUI_STATE_OVERVIEW_DISABLED, (mDisabledFlags & View.STATUS_BAR_DISABLE_RECENT) != 0) .setFlag(SYSUI_STATE_HOME_DISABLED, (mDisabledFlags & View.STATUS_BAR_DISABLE_HOME) != 0) .setFlag(SYSUI_STATE_SEARCH_DISABLED, (mDisabledFlags & View.STATUS_BAR_DISABLE_SEARCH) != 0) - .commitUpdate(displayId); + .commitUpdate(); } public void setInScreenPinning(boolean active) { 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 6236ada46374..27e609232a4c 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 @@ -78,8 +78,15 @@ constructor( } val columns = columnsWithMediaViewModel.columns + val largeTiles by iconTilesViewModel.largeTilesState val largeTilesSpan by iconTilesViewModel.largeTilesSpanState - val sizedTiles = tiles.map { SizedTileImpl(it, it.spec.width(largeTilesSpan)) } + // Tiles or largeTiles may be updated while this is composed, so listen to any changes + val sizedTiles = + remember(tiles, largeTiles, largeTilesSpan) { + tiles.map { + SizedTileImpl(it, if (largeTiles.contains(it.spec)) largeTilesSpan else 1) + } + } val bounceables = remember(sizedTiles) { List(sizedTiles.size) { BounceableTileViewModel() } } val squishiness by viewModel.squishinessViewModel.squishiness.collectAsStateWithLifecycle() diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/DynamicIconTilesViewModel.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/DynamicIconTilesViewModel.kt index a9d673aa7400..d6705a68d32c 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/DynamicIconTilesViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/DynamicIconTilesViewModel.kt @@ -35,6 +35,9 @@ constructor( private val hydrator = Hydrator("DynamicIconTilesViewModel") private val interactor = interactorFactory.create() + val largeTilesState = + hydrator.hydratedStateOf(traceName = "largeTiles", source = iconTilesViewModel.largeTiles) + val largeTilesSpanState = hydrator.hydratedStateOf( traceName = "largeTilesSpan", diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/ModesDndTile.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/ModesDndTile.kt index 52b02066c35a..eb53d81b674f 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/ModesDndTile.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/ModesDndTile.kt @@ -121,6 +121,7 @@ constructor( label = tileLabel secondaryLabel = tileState.secondaryLabel contentDescription = tileState.contentDescription + stateDescription = tileState.stateDescription expandedAccessibilityClassName = tileState.expandedAccessibilityClassName } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/domain/interactor/ModesDndTileDataInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/domain/interactor/ModesDndTileDataInteractor.kt index b1ae3ba4381a..e47ae690bc97 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/domain/interactor/ModesDndTileDataInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/domain/interactor/ModesDndTileDataInteractor.kt @@ -18,8 +18,10 @@ package com.android.systemui.qs.tiles.impl.modes.domain.interactor import android.content.Context import android.os.UserHandle +import android.text.TextUtils import com.android.app.tracing.coroutines.flow.flowName import com.android.settingslib.notification.modes.ZenMode +import com.android.settingslib.notification.modes.ZenModeDescriptions import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.modes.shared.ModesUi import com.android.systemui.qs.tiles.base.interactor.DataUpdateTrigger @@ -44,6 +46,8 @@ constructor( @Background val bgDispatcher: CoroutineDispatcher, ) : QSTileDataInteractor<ModesDndTileModel> { + private val zenModeDescriptions = ZenModeDescriptions(context) + override fun tileData( user: UserHandle, triggers: Flow<DataUpdateTrigger>, @@ -65,7 +69,10 @@ constructor( fun getCurrentTileModel() = buildTileData(zenModeInteractor.getDndMode()) private fun buildTileData(dndMode: ZenMode): ModesDndTileModel { - return ModesDndTileModel(isActivated = dndMode.isActive) + return ModesDndTileModel( + isActivated = dndMode.isActive, + extraStatus = TextUtils.nullIfEmpty(zenModeDescriptions.getTriggerDescription(dndMode)), + ) } override fun availability(user: UserHandle): Flow<Boolean> = diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/domain/model/ModesDndTileModel.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/domain/model/ModesDndTileModel.kt index eab798897aa3..e13cc6592e9d 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/domain/model/ModesDndTileModel.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/domain/model/ModesDndTileModel.kt @@ -16,4 +16,4 @@ package com.android.systemui.qs.tiles.impl.modes.domain.model -data class ModesDndTileModel(val isActivated: Boolean) +data class ModesDndTileModel(val isActivated: Boolean, val extraStatus: String?) diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/ui/ModesDndTileMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/ui/ModesDndTileMapper.kt index 4869b6f74554..73a8766ef45e 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/ui/ModesDndTileMapper.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/ui/ModesDndTileMapper.kt @@ -49,11 +49,9 @@ constructor(@ShadeDisplayAware private val resources: Resources, val theme: Reso QSTileState.ActivationState.INACTIVE } label = resources.getString(R.string.quick_settings_dnd_label) - secondaryLabel = - resources.getString( - if (data.isActivated) R.string.zen_mode_on else R.string.zen_mode_off - ) + secondaryLabel = data.extraStatus contentDescription = label + stateDescription = data.extraStatus supportedActions = setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK) expandedAccessibilityClass = Switch::class diff --git a/packages/SystemUI/src/com/android/systemui/recents/LauncherProxyService.java b/packages/SystemUI/src/com/android/systemui/recents/LauncherProxyService.java index 4be35f147c2f..d2639654d206 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/LauncherProxyService.java +++ b/packages/SystemUI/src/com/android/systemui/recents/LauncherProxyService.java @@ -89,6 +89,8 @@ import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.contextualeducation.GestureType; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Main; +import com.android.systemui.display.data.repository.DisplayRepository; +import com.android.systemui.display.data.repository.PerDisplayRepository; import com.android.systemui.dump.DumpManager; import com.android.systemui.keyguard.KeyguardUnlockAnimationController; import com.android.systemui.keyguard.KeyguardWmStateRefactor; @@ -109,6 +111,7 @@ import com.android.systemui.settings.DisplayTracker; import com.android.systemui.settings.UserTracker; import com.android.systemui.shade.ShadeViewController; import com.android.systemui.shade.domain.interactor.ShadeInteractor; +import com.android.systemui.shade.shared.flag.ShadeWindowGoesAround; import com.android.systemui.shared.recents.ILauncherProxy; import com.android.systemui.shared.recents.ISystemUiProxy; import com.android.systemui.shared.system.QuickStepContract; @@ -156,7 +159,9 @@ public class LauncherProxyService implements CallbackController<LauncherProxyLis private final Executor mMainExecutor; private final ShellInterface mShellInterface; private final Lazy<ShadeViewController> mShadeViewControllerLazy; - private SysUiState mSysUiState; + private final PerDisplayRepository<SysUiState> mPerDisplaySysUiStateRepository; + private final DisplayRepository mDisplayRepository; + private SysUiState mDefaultDisplaySysUIState; private final Handler mHandler; private final Lazy<NavigationBarController> mNavBarControllerLazy; private final ScreenPinningRequest mScreenPinningRequest; @@ -586,9 +591,12 @@ public class LauncherProxyService implements CallbackController<LauncherProxyLis // Force-update the systemui state flags updateSystemUiStateFlags(); - // TODO b/398011576 - send the state for all displays. - notifySystemUiStateFlags(mSysUiState.getFlags(), Display.DEFAULT_DISPLAY); - + if (ShadeWindowGoesAround.isEnabled()) { + notifySysUiStateFlagsForAllDisplays(); + } else { + notifySystemUiStateFlags(mDefaultDisplaySysUIState.getFlags(), + Display.DEFAULT_DISPLAY); + } notifyConnectionChanged(); } @@ -614,6 +622,18 @@ public class LauncherProxyService implements CallbackController<LauncherProxyLis } }; + /** Propagates the flags for all displays to be notified to Launcher. */ + @VisibleForTesting + public void notifySysUiStateFlagsForAllDisplays() { + var displays = mDisplayRepository.getDisplayIds().getValue(); + for (int displayId : displays) { + var state = mPerDisplaySysUiStateRepository.get(displayId); + if (state != null) { + notifySystemUiStateFlags(state.getFlags(), displayId); + } + } + } + private final StatusBarWindowCallback mStatusBarWindowCallback = this::onStatusBarStateChanged; // This is the death handler for the binder from the launcher service @@ -671,7 +691,7 @@ public class LauncherProxyService implements CallbackController<LauncherProxyLis ScreenPinningRequest screenPinningRequest, NavigationModeController navModeController, NotificationShadeWindowController statusBarWinController, - SysUiState sysUiState, + PerDisplayRepository<SysUiState> perDisplaySysUiStateRepository, Provider<SceneInteractor> sceneInteractor, Provider<ShadeInteractor> shadeInteractor, UserTracker userTracker, @@ -686,7 +706,8 @@ public class LauncherProxyService implements CallbackController<LauncherProxyLis Optional<UnfoldTransitionProgressForwarder> unfoldTransitionProgressForwarder, BroadcastDispatcher broadcastDispatcher, Optional<BackAnimation> backAnimation, - ProcessWrapper processWrapper + ProcessWrapper processWrapper, + DisplayRepository displayRepository ) { // b/241601880: This component should only be running for primary users or // secondaryUsers when visibleBackgroundUsers are supported. @@ -718,10 +739,10 @@ public class LauncherProxyService implements CallbackController<LauncherProxyLis com.android.internal.R.string.config_recentsComponentName)); mQuickStepIntent = new Intent(ACTION_QUICKSTEP) .setPackage(mRecentsComponentName.getPackageName()); - // TODO b/398011576 - Here we're still only handling the default display state. We should - // have a callback for any sysuiState change. - mSysUiState = sysUiState; - mSysUiState.addCallback(mSysUiStateCallback); + mPerDisplaySysUiStateRepository = perDisplaySysUiStateRepository; + mDisplayRepository = displayRepository; + mDefaultDisplaySysUIState = perDisplaySysUiStateRepository.get(Display.DEFAULT_DISPLAY); + mDefaultDisplaySysUIState.addCallback(mSysUiStateCallback); mUiEventLogger = uiEventLogger; mDisplayTracker = displayTracker; mUnfoldTransitionProgressForwarder = unfoldTransitionProgressForwarder; @@ -770,7 +791,7 @@ public class LauncherProxyService implements CallbackController<LauncherProxyLis if (mLauncherProxy != null) { try { if (DesktopModeStatus.canEnterDesktopMode(mContext) - && (sysUiState.getFlags() + && (mDefaultDisplaySysUIState.getFlags() & SYSUI_STATE_FREEFORM_ACTIVE_IN_DESKTOP_MODE) != 0) { return; } @@ -795,7 +816,7 @@ public class LauncherProxyService implements CallbackController<LauncherProxyLis } public void onVoiceSessionWindowVisibilityChanged(boolean visible) { - mSysUiState.setFlag(SYSUI_STATE_VOICE_INTERACTION_WINDOW_SHOWING, visible) + mDefaultDisplaySysUIState.setFlag(SYSUI_STATE_VOICE_INTERACTION_WINDOW_SHOWING, visible) .commitUpdate(mContext.getDisplayId()); } @@ -804,23 +825,42 @@ public class LauncherProxyService implements CallbackController<LauncherProxyLis startConnectionToCurrentUser(); } - private void updateSystemUiStateFlags() { + private void updateSysUIStateForNavbars() { + if (ShadeWindowGoesAround.isEnabled()) { + var displays = mDisplayRepository.getDisplayIds().getValue(); + for (int displayId : displays) { + updateSysUIStateForNavbarWithDisplayId(displayId); + } + } else { + updateSysUIStateForNavbarWithDisplayId(Display.DEFAULT_DISPLAY); + } + } + + private void updateSysUIStateForNavbarWithDisplayId(int displayId) { final NavigationBar navBarFragment = - mNavBarControllerLazy.get().getDefaultNavigationBar(); + mNavBarControllerLazy.get().getNavigationBar(displayId); final NavigationBarView navBarView = - mNavBarControllerLazy.get().getNavigationBarView(mContext.getDisplayId()); + mNavBarControllerLazy.get().getNavigationBarView(displayId); if (SysUiState.DEBUG) { Log.d(TAG_OPS, "Updating sysui state flags: navBarFragment=" + navBarFragment + " navBarView=" + navBarView + " shadeViewController=" + mShadeViewControllerLazy.get()); } + final SysUiState displaySysuiState = mPerDisplaySysUiStateRepository.get(displayId); + if (displaySysuiState == null) return; + if (navBarFragment != null) { navBarFragment.updateSystemUiStateFlags(); } if (navBarView != null) { - navBarView.updateDisabledSystemUiStateFlags(mSysUiState); + navBarView.updateDisabledSystemUiStateFlags(displaySysuiState); } + } + + /** Force updates SystemUI state flags prior to sending them to Launcher. */ + public void updateSystemUiStateFlags() { + updateSysUIStateForNavbars(); mShadeViewControllerLazy.get().updateSystemUiStateFlags(); if (mStatusBarWinController != null) { mStatusBarWinController.notifyStateChangedCallbacks(); @@ -845,7 +885,7 @@ public class LauncherProxyService implements CallbackController<LauncherProxyLis private void onStatusBarStateChanged(boolean keyguardShowing, boolean keyguardOccluded, boolean keyguardGoingAway, boolean bouncerShowing, boolean isDozing, boolean panelExpanded, boolean isDreaming, boolean communalShowing) { - mSysUiState.setFlag(SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING, + mDefaultDisplaySysUIState.setFlag(SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING, keyguardShowing && !keyguardOccluded) .setFlag(SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING_OCCLUDED, keyguardShowing && keyguardOccluded) @@ -1122,7 +1162,7 @@ public class LauncherProxyService implements CallbackController<LauncherProxyLis new WakefulnessLifecycle.Observer() { @Override public void onStartedWakingUp() { - mSysUiState + mDefaultDisplaySysUIState .setFlag(SYSUI_STATE_AWAKE, true) .setFlag(SYSUI_STATE_WAKEFULNESS_TRANSITION, true) .commitUpdate(mContext.getDisplayId()); @@ -1130,7 +1170,7 @@ public class LauncherProxyService implements CallbackController<LauncherProxyLis @Override public void onFinishedWakingUp() { - mSysUiState + mDefaultDisplaySysUIState .setFlag(SYSUI_STATE_AWAKE, true) .setFlag(SYSUI_STATE_WAKEFULNESS_TRANSITION, false) .commitUpdate(mContext.getDisplayId()); @@ -1138,7 +1178,7 @@ public class LauncherProxyService implements CallbackController<LauncherProxyLis @Override public void onStartedGoingToSleep() { - mSysUiState + mDefaultDisplaySysUIState .setFlag(SYSUI_STATE_AWAKE, false) .setFlag(SYSUI_STATE_WAKEFULNESS_TRANSITION, true) .commitUpdate(mContext.getDisplayId()); @@ -1146,7 +1186,7 @@ public class LauncherProxyService implements CallbackController<LauncherProxyLis @Override public void onFinishedGoingToSleep() { - mSysUiState + mDefaultDisplaySysUIState .setFlag(SYSUI_STATE_AWAKE, false) .setFlag(SYSUI_STATE_WAKEFULNESS_TRANSITION, false) .commitUpdate(mContext.getDisplayId()); @@ -1247,7 +1287,7 @@ public class LauncherProxyService implements CallbackController<LauncherProxyLis pw.print(" mActiveNavBarRegion="); pw.println(mActiveNavBarRegion); pw.print(" mNavBarMode="); pw.println(mNavBarMode); pw.print(" mIsPrevServiceCleanedUp="); pw.println(mIsPrevServiceCleanedUp); - mSysUiState.dump(pw, args); + mDefaultDisplaySysUIState.dump(pw, args); } public interface LauncherProxyListener { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt index 05ef1645c1d6..d2f424a46620 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt @@ -394,7 +394,7 @@ constructor( // Only drag down on sensitive views, otherwise the ExpandHelper will take this return if (NotificationBundleUi.isEnabled) view.entryAdapter?.isSensitive?.value == true - else view.entry.isSensitive.value + else view.entryLegacy.isSensitive.value } } return false @@ -569,7 +569,7 @@ constructor( if (NotificationBundleUi.isEnabled) { userId = expandView.entryAdapter?.sbn?.userId!! } else { - userId = expandView.entry.sbn.userId + userId = expandView.entryLegacy.sbn.userId } } var fullShadeNeedsBouncer = diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java index 339f898be251..9bf3d5dfe4cf 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java @@ -47,7 +47,6 @@ import android.database.ExecutorContentObserver; import android.net.Uri; import android.os.Looper; import android.os.Process; -import android.os.SystemClock; import android.os.UserHandle; import android.os.UserManager; import android.provider.Settings; @@ -78,6 +77,7 @@ import com.android.systemui.scene.shared.flag.SceneContainerFlag; import com.android.systemui.settings.UserTracker; import com.android.systemui.shared.system.SysUiStatsLog; import com.android.systemui.statusbar.notification.collection.NotificationEntry; +import com.android.systemui.statusbar.notification.collection.UseElapsedRealtimeForCreationTime; import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection; import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider; import com.android.systemui.statusbar.notification.row.shared.LockscreenOtpRedaction; @@ -920,7 +920,9 @@ public class NotificationLockscreenUserManagerImpl implements // notification's "when" time, or the notification entry creation time private long getEarliestNotificationTime(NotificationEntry notif) { long notifWhenWallClock = notif.getSbn().getNotification().getWhen(); - long creationTimeDelta = SystemClock.uptimeMillis() - notif.getCreationTime(); + long creationTimeDelta = UseElapsedRealtimeForCreationTime.getCurrentTime() + - notif.getCreationTime(); + long creationTimeWallClock = System.currentTimeMillis() - creationTimeDelta; return Math.min(notifWhenWallClock, creationTimeWallClock); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java index 041ed6504634..485d5b2ab555 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java @@ -169,7 +169,7 @@ public class NotificationRemoteInputManager implements CoreStartable { if (NotificationBundleUi.isEnabled()) { releaseNotificationIfKeptForRemoteInputHistory(row.getEntryAdapter()); } else { - releaseNotificationIfKeptForRemoteInputHistory(row.getEntry()); + releaseNotificationIfKeptForRemoteInputHistory(row.getEntryLegacy()); } } return started; @@ -189,8 +189,8 @@ public class NotificationRemoteInputManager implements CoreStartable { statusBarNotification = row.getEntryAdapter().getSbn(); } } else { - if (row.getEntry() != null) { - statusBarNotification = row.getEntry().getSbn(); + if (row.getEntryLegacy() != null) { + statusBarNotification = row.getEntryLegacy().getSbn(); } } if (statusBarNotification == null) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java index f88c618a9acc..c2a87cddee55 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java @@ -675,7 +675,7 @@ public class NotificationShelf extends ActivatableNotificationView { } StatusBarIconView icon = NotificationBundleUi.isEnabled() ? row.getEntryAdapter().getIcons().getShelfIcon() - : row.getEntry().getIcons().getShelfIcon(); + : row.getEntryLegacy().getIcons().getShelfIcon(); float shelfIconPosition = getTranslationY() + icon.getTop() + icon.getTranslationY(); if (shelfIconPosition < maxTop && !mAmbientState.isFullyHidden()) { int top = (int) (maxTop - shelfIconPosition); @@ -689,7 +689,7 @@ public class NotificationShelf extends ActivatableNotificationView { private void updateContinuousClipping(final ExpandableNotificationRow row) { StatusBarIconView icon = NotificationBundleUi.isEnabled() ? row.getEntryAdapter().getIcons().getShelfIcon() - : row.getEntry().getIcons().getShelfIcon(); + : row.getEntryLegacy().getIcons().getShelfIcon(); boolean needsContinuousClipping = ViewState.isAnimatingY(icon) && !mAmbientState.isDozing(); boolean isContinuousClipping = icon.getTag(TAG_CONTINUOUS_CLIPPING) != null; if (needsContinuousClipping && !isContinuousClipping) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModel.kt index 7e7031200988..03108deb0ecc 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModel.kt @@ -17,10 +17,13 @@ package com.android.systemui.statusbar.chips.call.ui.viewmodel import android.app.PendingIntent +import android.content.ComponentName import android.content.Context import android.view.View import com.android.internal.jank.Cuj import com.android.systemui.animation.ActivityTransitionAnimator +import com.android.systemui.animation.ComposableControllerFactory +import com.android.systemui.animation.DelegateTransitionAnimatorController import com.android.systemui.common.shared.model.ContentDescription import com.android.systemui.common.shared.model.Icon import com.android.systemui.dagger.SysUISingleton @@ -48,7 +51,10 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.flow.combine +import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.map +import kotlinx.coroutines.flow.mapNotNull import kotlinx.coroutines.flow.stateIn /** View model for the ongoing phone call chip shown in the status bar. */ @@ -63,14 +69,62 @@ constructor( private val activityStarter: ActivityStarter, @StatusBarChipsLog private val logger: LogBuffer, ) : OngoingActivityChipViewModel { + /** The transition cookie used to register and unregister launch and return animations. */ + private val cookie = + ActivityTransitionAnimator.TransitionCookie("${CallChipViewModel::class.java}") + + /** + * Used internally to determine when a launch or return animation is in progress, as these + * require special handling. + */ + private val transitionState: MutableStateFlow<TransitionState> = + MutableStateFlow(TransitionState.NoTransition) + + // Since we're combining the chip state and the transition state flows, getting the old value by + // using [pairwise()] would confuse things. This is because if the calculation is triggered by + // a change in transition state, the chip state will still show the previous and current values, + // making it difficult to figure out what actually changed. Instead we cache the old value here, + // so that at each update we can keep track of what actually changed. + private var latestState: OngoingCallModel = OngoingCallModel.NoCall + private var latestTransitionState: TransitionState = TransitionState.NoTransition + private val chipWithReturnAnimation: StateFlow<OngoingActivityChipModel> = if (StatusBarChipsReturnAnimations.isEnabled) { - interactor.ongoingCallState - .map { state -> - when (state) { - is OngoingCallModel.NoCall -> OngoingActivityChipModel.Inactive() + combine(interactor.ongoingCallState, transitionState) { newState, newTransitionState -> + val oldState = latestState + latestState = newState + val oldTransitionState = latestTransitionState + latestTransitionState = newTransitionState + + logger.log( + TAG, + LogLevel.DEBUG, + {}, + { + "Call chip state updated: oldState=$oldState newState=$newState " + + "oldTransitionState=$oldTransitionState " + + "newTransitionState=$newTransitionState" + }, + ) + + when (newState) { + is OngoingCallModel.NoCall -> + OngoingActivityChipModel.Inactive( + transitionManager = getTransitionManager(newState) + ) + is OngoingCallModel.InCall -> - prepareChip(state, systemClock, isHidden = state.isAppVisible) + prepareChip( + newState, + systemClock, + isHidden = + shouldChipBeHidden( + oldState = oldState, + newState = newState, + oldTransitionState = oldTransitionState, + newTransitionState = newTransitionState, + ), + ) } } .stateIn( @@ -112,6 +166,12 @@ constructor( chipLegacy } + /** + * The controller factory that the call chip uses to register and unregister its transition + * animations. + */ + private var transitionControllerFactory: ComposableControllerFactory? = null + /** Builds an [OngoingActivityChipModel.Active] from all the relevant information. */ private fun prepareChip( state: OngoingCallModel.InCall, @@ -149,6 +209,7 @@ constructor( onClickListenerLegacy = getOnClickListener(state.intent), clickBehavior = getClickBehavior(state.intent), isHidden = isHidden, + transitionManager = getTransitionManager(state), ) } else { val startTimeInElapsedRealtime = @@ -161,6 +222,7 @@ constructor( onClickListenerLegacy = getOnClickListener(state.intent), clickBehavior = getClickBehavior(state.intent), isHidden = isHidden, + transitionManager = getTransitionManager(state), ) } } @@ -191,9 +253,21 @@ constructor( onClick = { expandable -> StatusBarChipsModernization.unsafeAssertInNewMode() val animationController = - expandable.activityTransitionController( - Cuj.CUJ_STATUS_BAR_APP_LAUNCH_FROM_CALL_CHIP - ) + if ( + !StatusBarChipsReturnAnimations.isEnabled || + transitionControllerFactory == null + ) { + expandable.activityTransitionController( + Cuj.CUJ_STATUS_BAR_APP_LAUNCH_FROM_CALL_CHIP + ) + } else { + // When return animations are enabled, we use a long-lived registration + // with controllers created on-demand by the animation library instead + // of explicitly creating one at the time of the click. By not passing + // a controller here, we let the framework do its work. Otherwise, the + // explicit controller would take precedence and override the other one. + null + } activityStarter.postStartActivityDismissingKeyguard(intent, animationController) } ) @@ -210,6 +284,120 @@ constructor( ) } + private fun getTransitionManager( + state: OngoingCallModel + ): OngoingActivityChipModel.TransitionManager? { + if (!StatusBarChipsReturnAnimations.isEnabled) return null + return if (state is OngoingCallModel.NoCall) { + OngoingActivityChipModel.TransitionManager( + unregisterTransition = { activityStarter.unregisterTransition(cookie) } + ) + } else { + val component = (state as OngoingCallModel.InCall).intent?.intent?.component + if (component != null) { + val factory = getTransitionControllerFactory(component) + OngoingActivityChipModel.TransitionManager( + factory, + registerTransition = { + activityStarter.registerTransition(cookie, factory, scope) + }, + ) + } else { + // Without a component we can't instantiate a controller factory, and without a + // factory registering an animation is impossible. In this case, the transition + // manager is empty and inert. + OngoingActivityChipModel.TransitionManager() + } + } + } + + private fun getTransitionControllerFactory( + component: ComponentName + ): ComposableControllerFactory { + var factory = transitionControllerFactory + if (factory?.component == component) return factory + + factory = + object : + ComposableControllerFactory( + cookie, + component, + launchCujType = Cuj.CUJ_STATUS_BAR_APP_LAUNCH_FROM_CALL_CHIP, + ) { + override suspend fun createController( + forLaunch: Boolean + ): ActivityTransitionAnimator.Controller { + transitionState.value = + if (forLaunch) { + TransitionState.LaunchRequested + } else { + TransitionState.ReturnRequested + } + + val controller = + expandable + .mapNotNull { + it?.activityTransitionController( + launchCujType, + cookie, + component, + returnCujType, + isEphemeral = false, + ) + } + .first() + + return object : DelegateTransitionAnimatorController(controller) { + override val isLaunching: Boolean + get() = forLaunch + + override fun onTransitionAnimationStart(isExpandingFullyAbove: Boolean) { + delegate.onTransitionAnimationStart(isExpandingFullyAbove) + transitionState.value = + if (isLaunching) { + TransitionState.Launching + } else { + TransitionState.Returning + } + } + + override fun onTransitionAnimationEnd(isExpandingFullyAbove: Boolean) { + delegate.onTransitionAnimationEnd(isExpandingFullyAbove) + transitionState.value = TransitionState.NoTransition + } + + override fun onTransitionAnimationCancelled( + newKeyguardOccludedState: Boolean? + ) { + delegate.onTransitionAnimationCancelled(newKeyguardOccludedState) + transitionState.value = TransitionState.NoTransition + } + } + } + } + + transitionControllerFactory = factory + return factory + } + + /** Define the current state of this chip's transition animation. */ + private sealed interface TransitionState { + /** Idle. */ + data object NoTransition : TransitionState + + /** Launch animation has been requested but hasn't started yet. */ + data object LaunchRequested : TransitionState + + /** Launch animation in progress. */ + data object Launching : TransitionState + + /** Return animation has been requested but hasn't started yet. */ + data object ReturnRequested : TransitionState + + /** Return animation in progress. */ + data object Returning : TransitionState + } + companion object { private val phoneIcon = Icon.Resource( @@ -217,5 +405,42 @@ constructor( ContentDescription.Resource(R.string.ongoing_call_content_description), ) private val TAG = "CallVM".pad() + + /** Determines whether or not an active call chip should be hidden. */ + private fun shouldChipBeHidden( + oldState: OngoingCallModel, + newState: OngoingCallModel.InCall, + oldTransitionState: TransitionState, + newTransitionState: TransitionState, + ): Boolean { + // The app is in the background and no transitions are ongoing (during transitions, + // [isAppVisible] must always be true). Show the chip. + if (!newState.isAppVisible) return false + + // The call has just started and is visible. Hide the chip. + if (oldState is OngoingCallModel.NoCall) return true + + // The state went from the app not being visible to visible. This happens when the chip + // is tapped and a launch animation is about to start. Keep the chip showing. + if (!(oldState as OngoingCallModel.InCall).isAppVisible) return false + + // The app was and remains visible, but the transition state has changed. A launch or + // return animation has been requested or is ongoing. Keep the chip showing. + if ( + newTransitionState is TransitionState.LaunchRequested || + newTransitionState is TransitionState.Launching || + newTransitionState is TransitionState.ReturnRequested || + newTransitionState is TransitionState.Returning + ) { + return false + } + + // The app was and remains visible, so we generally want to hide the chip. The only + // exception is if a return transition has just ended. In this case, the transition + // state changes shortly before the app visibility does. If we hide the chip between + // these two updates, this results in a flicker. We bridge the gap by keeping the chip + // showing. + return oldTransitionState != TransitionState.Returning + } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/compose/OngoingActivityChip.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/compose/OngoingActivityChip.kt index 4edb23dc9f0e..58d38903f7cf 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/compose/OngoingActivityChip.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/compose/OngoingActivityChip.kt @@ -42,6 +42,7 @@ import com.android.systemui.common.ui.compose.Icon import com.android.systemui.common.ui.compose.load import com.android.systemui.res.R import com.android.systemui.statusbar.StatusBarIconView +import com.android.systemui.statusbar.chips.StatusBarChipsReturnAnimations import com.android.systemui.statusbar.chips.ui.model.ColorsModel import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel import com.android.systemui.statusbar.core.StatusBarConnectedDisplays @@ -90,6 +91,8 @@ fun OngoingActivityChip( }, borderStroke = borderStroke, onClick = onClick, + useModifierBasedImplementation = StatusBarChipsReturnAnimations.isEnabled, + transitionControllerFactory = model.transitionManager?.controllerFactory, ) { ChipBody(model, iconViewStore, isClickable = onClick != null) } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/compose/OngoingActivityChips.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/compose/OngoingActivityChips.kt index 407849b9fae0..700e6d93c628 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/compose/OngoingActivityChips.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/compose/OngoingActivityChips.kt @@ -21,12 +21,14 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable +import androidx.compose.runtime.SideEffect import androidx.compose.runtime.key import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.dimensionResource import com.android.systemui.compose.modifiers.sysuiResTag import com.android.systemui.res.R +import com.android.systemui.statusbar.chips.StatusBarChipsReturnAnimations import com.android.systemui.statusbar.chips.ui.model.MultipleOngoingActivityChipsModel import com.android.systemui.statusbar.notification.icon.ui.viewbinder.NotificationIconContainerViewBinder @@ -36,6 +38,18 @@ fun OngoingActivityChips( iconViewStore: NotificationIconContainerViewBinder.IconViewStore?, modifier: Modifier = Modifier, ) { + if (StatusBarChipsReturnAnimations.isEnabled) { + SideEffect { + // Active chips must always be capable of animating to/from activities, even when they + // are hidden. Therefore we always register their transitions. + for (chip in chips.active) chip.transitionManager?.registerTransition?.invoke() + // Inactive chips and chips in the overflow are never shown, so they must not have any + // registered transition. + for (chip in chips.overflow) chip.transitionManager?.unregisterTransition?.invoke() + for (chip in chips.inactive) chip.transitionManager?.unregisterTransition?.invoke() + } + } + val shownChips = chips.active.filter { !it.isHidden } if (shownChips.isNotEmpty()) { Row( diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/model/OngoingActivityChipModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/model/OngoingActivityChipModel.kt index d37a46e58882..3876d9fa77a3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/model/OngoingActivityChipModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/model/OngoingActivityChipModel.kt @@ -20,6 +20,7 @@ import android.annotation.CurrentTimeMillisLong import android.annotation.ElapsedRealtimeLong import android.os.SystemClock import android.view.View +import com.android.systemui.animation.ComposableControllerFactory import com.android.systemui.animation.Expandable import com.android.systemui.common.shared.model.ContentDescription import com.android.systemui.common.shared.model.Icon @@ -33,6 +34,9 @@ sealed class OngoingActivityChipModel { /** Condensed name representing the model, used for logs. */ abstract val logName: String + /** Object used to manage the behavior of this chip during activity launch and returns. */ + abstract val transitionManager: TransitionManager? + /** * This chip shouldn't be shown. * @@ -40,7 +44,10 @@ sealed class OngoingActivityChipModel { * animated, and false if that transition should *not* be animated (i.e. the chip view should * immediately disappear). */ - data class Inactive(val shouldAnimate: Boolean = true) : OngoingActivityChipModel() { + data class Inactive( + val shouldAnimate: Boolean = true, + override val transitionManager: TransitionManager? = null, + ) : OngoingActivityChipModel() { override val logName = "Inactive(anim=$shouldAnimate)" } @@ -61,6 +68,7 @@ sealed class OngoingActivityChipModel { open val onClickListenerLegacy: View.OnClickListener?, /** Data class that determines how clicks on the chip should be handled. */ open val clickBehavior: ClickBehavior, + override val transitionManager: TransitionManager?, /** * Whether this chip should be hidden. This can be the case depending on system states (like * which apps are in the foreground and whether there is an ongoing transition. @@ -77,6 +85,7 @@ sealed class OngoingActivityChipModel { override val colors: ColorsModel, override val onClickListenerLegacy: View.OnClickListener?, override val clickBehavior: ClickBehavior, + override val transitionManager: TransitionManager? = null, override val isHidden: Boolean = false, override val shouldAnimate: Boolean = true, ) : @@ -86,6 +95,7 @@ sealed class OngoingActivityChipModel { colors, onClickListenerLegacy, clickBehavior, + transitionManager, isHidden, shouldAnimate, ) { @@ -122,6 +132,7 @@ sealed class OngoingActivityChipModel { val isEventInFuture: Boolean = false, override val onClickListenerLegacy: View.OnClickListener?, override val clickBehavior: ClickBehavior, + override val transitionManager: TransitionManager? = null, override val isHidden: Boolean = false, override val shouldAnimate: Boolean = true, ) : @@ -131,6 +142,7 @@ sealed class OngoingActivityChipModel { colors, onClickListenerLegacy, clickBehavior, + transitionManager, isHidden, shouldAnimate, ) { @@ -157,6 +169,7 @@ sealed class OngoingActivityChipModel { @CurrentTimeMillisLong val time: Long, override val onClickListenerLegacy: View.OnClickListener?, override val clickBehavior: ClickBehavior, + override val transitionManager: TransitionManager? = null, override val isHidden: Boolean = false, override val shouldAnimate: Boolean = true, ) : @@ -166,6 +179,7 @@ sealed class OngoingActivityChipModel { colors, onClickListenerLegacy, clickBehavior, + transitionManager, isHidden, shouldAnimate, ) { @@ -185,6 +199,7 @@ sealed class OngoingActivityChipModel { override val colors: ColorsModel, /** The number of seconds until an event is started. */ val secondsUntilStarted: Long, + override val transitionManager: TransitionManager? = null, override val isHidden: Boolean = false, override val shouldAnimate: Boolean = true, ) : @@ -194,6 +209,7 @@ sealed class OngoingActivityChipModel { colors, onClickListenerLegacy = null, clickBehavior = ClickBehavior.None, + transitionManager, isHidden, shouldAnimate, ) { @@ -209,6 +225,7 @@ sealed class OngoingActivityChipModel { val text: String, override val onClickListenerLegacy: View.OnClickListener? = null, override val clickBehavior: ClickBehavior, + override val transitionManager: TransitionManager? = null, override val isHidden: Boolean = false, override val shouldAnimate: Boolean = true, ) : @@ -218,6 +235,7 @@ sealed class OngoingActivityChipModel { colors, onClickListenerLegacy, clickBehavior, + transitionManager, isHidden, shouldAnimate, ) { @@ -271,4 +289,17 @@ sealed class OngoingActivityChipModel { /** Clicking the chip will show the heads up notification associated with the chip. */ data class ShowHeadsUpNotification(val onClick: () -> Unit) : ClickBehavior } + + /** Defines the behavior of the chip with respect to activity launch and return transitions. */ + data class TransitionManager( + /** The factory used to create the controllers that animate the chip. */ + val controllerFactory: ComposableControllerFactory? = null, + /** + * Used to create a registration for this chip using [controllerFactory]. Must be + * idempotent. + */ + val registerTransition: () -> Unit = {}, + /** Used to remove the existing registration for this chip, if any. */ + val unregisterTransition: () -> Unit = {}, + ) } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationClicker.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationClicker.java index 8be9e410f8f6..fcdcc3f698de 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationClicker.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationClicker.java @@ -105,7 +105,7 @@ public final class NotificationClicker implements View.OnClickListener { mBubblesOptional.get().collapseStack(); } } else { - if (!row.getEntry().isBubble() && mBubblesOptional.isPresent()) { + if (!row.getEntryLegacy().isBubble() && mBubblesOptional.isPresent()) { mBubblesOptional.get().collapseStack(); } } @@ -130,7 +130,7 @@ public final class NotificationClicker implements View.OnClickListener { } else { row.setBubbleClickListener(v -> mNotificationActivityStarter.onNotificationBubbleIconClicked( - row.getEntry())); + row.getEntryLegacy())); } row.setOnClickListener(this); row.setOnDragSuccessListener(mOnDragSuccessListener); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTransitionAnimatorController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTransitionAnimatorController.kt index 874a059d2323..8163128f762a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTransitionAnimatorController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTransitionAnimatorController.kt @@ -74,7 +74,6 @@ class NotificationTransitionAnimatorController( const val ANIMATION_DURATION_TOP_ROUNDING = 100L } - private val notificationEntry = notification.entry private val notificationKey = notification.key override val isLaunching: Boolean = true @@ -160,7 +159,7 @@ class NotificationTransitionAnimatorController( private val headsUpNotificationRow: ExpandableNotificationRow? get() { val pipelineParent = if (NotificationBundleUi.isEnabled) - notification.entryAdapter?.parent else notificationEntry.parent + notification.entryAdapter?.parent else notification.entryLegacy.parent val summaryEntry = (pipelineParent as? GroupEntry)?.summary return when { headsUpManager.isHeadsUpEntry(notificationKey) -> notification diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ListEntry.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ListEntry.java index caa7abb1aa7a..8f7f61f6be65 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ListEntry.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ListEntry.java @@ -34,7 +34,7 @@ public abstract class ListEntry extends PipelineEntry { } /** - * The SystemClock.uptimeMillis() when this object was created. In general, this means the + * The SystemClock.elapsedRealtime() when this object was created. In general, this means the * moment when NotificationManager notifies our listener about the existence of this entry. * * This value will not change if the notification is updated, although it will change if the @@ -65,13 +65,4 @@ public abstract class ListEntry extends PipelineEntry { @Nullable public PipelineEntry getPreviousParent() { return mPreviousAttachState.getParent(); } - - /** - * Stores the current attach state into {@link #getPreviousAttachState()}} and then starts a - * fresh attach state (all entries will be null/default-initialized). - */ - void beginNewAttachState() { - mPreviousAttachState.clone(mAttachState); - mAttachState.reset(); - } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java index 9795edf3313c..b7fe39e9c757 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java @@ -522,7 +522,7 @@ public class NotifCollection implements Dumpable, PipelineDumpable { } private void onNotificationsInitialized() { - mInitializedTimestamp = mClock.uptimeMillis(); + mInitializedTimestamp = UseElapsedRealtimeForCreationTime.getCurrentTime(mClock); } private void postNotification( @@ -532,7 +532,8 @@ public class NotifCollection implements Dumpable, PipelineDumpable { if (entry == null) { // A new notification! - entry = new NotificationEntry(sbn, ranking, mClock.uptimeMillis()); + entry = new NotificationEntry(sbn, ranking, + UseElapsedRealtimeForCreationTime.getCurrentTime(mClock)); mEventQueue.add(new InitEntryEvent(entry)); mEventQueue.add(new BindEntryEvent(entry, sbn)); mNotificationSet.put(sbn.getKey(), entry); @@ -861,7 +862,7 @@ public class NotifCollection implements Dumpable, PipelineDumpable { // messages from system server. private void crashIfNotInitializing(RuntimeException exception) { final boolean isRecentlyInitialized = mInitializedTimestamp == 0 - || mClock.uptimeMillis() - mInitializedTimestamp + || UseElapsedRealtimeForCreationTime.getCurrentTime(mClock) - mInitializedTimestamp < INITIALIZATION_FORGIVENESS_WINDOW; if (isRecentlyInitialized) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollectionCache.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollectionCache.kt index 1f8d365cfdad..698fed33a408 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollectionCache.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollectionCache.kt @@ -89,9 +89,9 @@ class NotifCollectionCache<V>( return true } - // Using uptimeMillis since it's guaranteed to be monotonic, as we don't want a + // Using elapsedRealtime since it's guaranteed to be monotonic, as we don't want a // timezone/clock change to break us - val now = systemClock.uptimeMillis() + val now = UseElapsedRealtimeForCreationTime.getCurrentTime(systemClock) // Cannot purge the same entry from two threads simultaneously synchronized(key) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java index d031d831bf5a..4558017a98c8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java @@ -251,7 +251,7 @@ public final class NotificationEntry extends ListEntry { /** * @param sbn the StatusBarNotification from system server * @param ranking also from system server - * @param creationTime SystemClock.uptimeMillis of when we were created + * @param creationTime SystemClock.elapsedRealtime of when we were created */ public NotificationEntry( @NonNull StatusBarNotification sbn, @@ -508,7 +508,7 @@ public final class NotificationEntry extends ListEntry { ArrayList<NotificationEntry> children = new ArrayList<>(); for (ExpandableNotificationRow child : rowChildren) { - children.add(child.getEntry()); + children.add(child.getEntryLegacy()); } return children; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/PipelineEntry.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/PipelineEntry.java index 872cd68e1b21..e9c4efc4de64 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/PipelineEntry.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/PipelineEntry.java @@ -101,4 +101,13 @@ public abstract class PipelineEntry { public void setBucket(@PriorityBucket int bucket) { mBucket = bucket; } + + /** + * Stores the current attach state into {@link #getPreviousAttachState()}} and then starts a + * fresh attach state (all entries will be null/default-initialized). + */ + void beginNewAttachState() { + mPreviousAttachState.clone(mAttachState); + mAttachState.reset(); + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilder.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilder.java index 780e8f47a7fe..5cea82140692 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilder.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilder.java @@ -565,6 +565,11 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable { entry.beginNewAttachState(); } + for (BundleEntry be : mIdToBundleEntry.values()) { + be.beginNewAttachState(); + // TODO(b/399736937) Clear bundle children + // BundleEntry has not representative summary so we do not need to clear it here. + } mNotifList.clear(); } @@ -573,7 +578,7 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable { List<PipelineEntry> out, List<NotifFilter> filters) { Trace.beginSection("ShadeListBuilder.filterNotifs"); - final long now = mSystemClock.uptimeMillis(); + final long now = UseElapsedRealtimeForCreationTime.getCurrentTime(mSystemClock); for (PipelineEntry entry : entries) { if (entry instanceof GroupEntry) { final GroupEntry groupEntry = (GroupEntry) entry; @@ -617,7 +622,8 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable { GroupEntry group = mGroups.get(topLevelKey); if (group == null) { - group = new GroupEntry(topLevelKey, mSystemClock.uptimeMillis()); + group = new GroupEntry(topLevelKey, + UseElapsedRealtimeForCreationTime.getCurrentTime(mSystemClock)); mGroups.put(topLevelKey, group); } if (group.getParent() == null) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/UseElapsedRealtimeForCreationTime.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/UseElapsedRealtimeForCreationTime.kt new file mode 100644 index 000000000000..23f90f3694a8 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/UseElapsedRealtimeForCreationTime.kt @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.statusbar.notification.collection + +import android.app.Flags +import com.android.systemui.util.time.SystemClock + +/** A helper class for replacing uptimeMillis with elapsedRealtime for entry creation times */ +public object UseElapsedRealtimeForCreationTime { + @JvmStatic + fun getCurrentTime(clock: SystemClock): Long { + if (Flags.notifEntryCreationTimeUseElapsedRealtime()) { + return clock.elapsedRealtime() + } + return clock.uptimeMillis() + } + + @JvmStatic + fun getCurrentTime(): Long { + if (Flags.notifEntryCreationTimeUseElapsedRealtime()) { + return android.os.SystemClock.elapsedRealtime() + } + return android.os.SystemClock.uptimeMillis() + + } +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coalescer/EventBatch.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coalescer/EventBatch.java index 2eec68b26347..fb7772e26240 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coalescer/EventBatch.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coalescer/EventBatch.java @@ -25,7 +25,7 @@ import java.util.List; * Represents a set of notification post events for a particular notification group. */ public class EventBatch { - /** SystemClock.uptimeMillis() */ + /** SystemClock.elapsedRealtime() */ final long mCreatedTimestamp; /** SBN.getGroupKey -- same for all members */ diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coalescer/GroupCoalescer.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coalescer/GroupCoalescer.java index 96b35428b3ce..944e313d795a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coalescer/GroupCoalescer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coalescer/GroupCoalescer.java @@ -34,6 +34,7 @@ import com.android.systemui.statusbar.NotificationListener; import com.android.systemui.statusbar.NotificationListener.NotificationHandler; import com.android.systemui.statusbar.notification.collection.PipelineDumpable; import com.android.systemui.statusbar.notification.collection.PipelineDumper; +import com.android.systemui.statusbar.notification.collection.UseElapsedRealtimeForCreationTime; import com.android.systemui.util.concurrency.DelayableExecutor; import com.android.systemui.util.time.SystemClock; @@ -182,11 +183,12 @@ public class GroupCoalescer implements Dumpable, PipelineDumpable { private void maybeEmitBatch(StatusBarNotification sbn) { final CoalescedEvent event = mCoalescedEvents.get(sbn.getKey()); final EventBatch batch = mBatches.get(sbn.getGroupKey()); + long now = UseElapsedRealtimeForCreationTime.getCurrentTime(mClock); if (event != null) { mLogger.logEarlyEmit(sbn.getKey(), requireNonNull(event.getBatch()).mGroupKey); emitBatch(requireNonNull(event.getBatch())); } else if (batch != null - && mClock.uptimeMillis() - batch.mCreatedTimestamp >= mMaxGroupLingerDuration) { + && now - batch.mCreatedTimestamp >= mMaxGroupLingerDuration) { mLogger.logMaxBatchTimeout(sbn.getKey(), batch.mGroupKey); emitBatch(batch); } @@ -228,7 +230,8 @@ public class GroupCoalescer implements Dumpable, PipelineDumpable { private EventBatch getOrBuildBatch(final String groupKey) { EventBatch batch = mBatches.get(groupKey); if (batch == null) { - batch = new EventBatch(mClock.uptimeMillis(), groupKey); + batch = new EventBatch(UseElapsedRealtimeForCreationTime.getCurrentTime(mClock), + groupKey); mBatches.put(groupKey, batch); } return batch; @@ -268,7 +271,8 @@ public class GroupCoalescer implements Dumpable, PipelineDumpable { } events.sort(mEventComparator); - long batchAge = mClock.uptimeMillis() - batch.mCreatedTimestamp; + long batchAge = UseElapsedRealtimeForCreationTime.getCurrentTime(mClock) + - batch.mCreatedTimestamp; mLogger.logEmitBatch(batch.mGroupKey, batch.mMembers.size(), batchAge); mHandler.onNotificationBatchPosted(events); @@ -298,7 +302,7 @@ public class GroupCoalescer implements Dumpable, PipelineDumpable { @Override public void dump(@NonNull PrintWriter pw, @NonNull String[] args) { - long now = mClock.uptimeMillis(); + long now = UseElapsedRealtimeForCreationTime.getCurrentTime(mClock); int eventCount = 0; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/PreparationCoordinator.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/PreparationCoordinator.java index b54f21b23bba..1be415d7bf47 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/PreparationCoordinator.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/PreparationCoordinator.java @@ -241,8 +241,7 @@ public class PreparationCoordinator implements Coordinator { isMemberOfDelayedGroup = shouldWaitForGroupToInflate(parent, now); mIsDelayedGroupCache.put(parent, isMemberOfDelayedGroup); } - - return !isInflated(entry) || isMemberOfDelayedGroup; + return !isInflated(entry) || (isMemberOfDelayedGroup != null && isMemberOfDelayedGroup); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/VisualStabilityCoordinator.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/VisualStabilityCoordinator.java index 27765635edcb..0466c0359710 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/VisualStabilityCoordinator.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/VisualStabilityCoordinator.java @@ -501,7 +501,7 @@ public class VisualStabilityCoordinator implements Coordinator, Dumpable { * notification and we are reordering based on the user's change. * * @param entry notification entry that can change sections even if isReorderingAllowed is false - * @param now current time SystemClock.uptimeMillis + * @param now current time SystemClock.elapsedRealtime */ public void temporarilyAllowSectionChanges(@NonNull NotificationEntry entry, long now) { final String entryKey = entry.getKey(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/OnUserInteractionCallbackImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/OnUserInteractionCallbackImpl.java index 07fa6aeb7900..03b4076ba6fb 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/OnUserInteractionCallbackImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/OnUserInteractionCallbackImpl.java @@ -20,7 +20,6 @@ import static android.service.notification.NotificationStats.DISMISS_SENTIMENT_N import static com.android.systemui.statusbar.StatusBarState.KEYGUARD; -import android.os.SystemClock; import android.service.notification.NotificationStats; import androidx.annotation.NonNull; @@ -30,6 +29,7 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.notification.collection.NotifCollection; import com.android.systemui.statusbar.notification.collection.NotifCollection.CancellationReason; import com.android.systemui.statusbar.notification.collection.NotificationEntry; +import com.android.systemui.statusbar.notification.collection.UseElapsedRealtimeForCreationTime; import com.android.systemui.statusbar.notification.collection.coordinator.VisualStabilityCoordinator; import com.android.systemui.statusbar.notification.collection.notifcollection.DismissedByUserStats; import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider; @@ -85,7 +85,7 @@ public class OnUserInteractionCallbackImpl implements OnUserInteractionCallback public void onImportanceChanged(NotificationEntry entry) { mVisualStabilityCoordinator.temporarilyAllowSectionChanges( entry, - SystemClock.uptimeMillis()); + UseElapsedRealtimeForCreationTime.getCurrentTime()); } @NonNull diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/listbuilder/pluggable/NotifFilter.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/listbuilder/pluggable/NotifFilter.java index 776c7d5eb7f6..389bb3129c8d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/listbuilder/pluggable/NotifFilter.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/listbuilder/pluggable/NotifFilter.java @@ -41,8 +41,8 @@ public abstract class NotifFilter extends Pluggable<NotifFilter> { * this entry will not have any grouping nor sorting information. * If this filter is registered via {@link NotifPipeline#addFinalizeFilter}, * this entry will have grouping and sorting information. - * @param now A timestamp in SystemClock.uptimeMillis that represents "now" for the purposes of - * pipeline execution. This value will be the same for all pluggable calls made + * @param now A timestamp in SystemClock.elapsedRealtime that represents "now" for the purposes + * of pipeline execution. This value will be the same for all pluggable calls made * during this pipeline run, giving pluggables a stable concept of "now" to compare * various entries against. * @return True if the notif should be removed from the list diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/domain/interactor/HeadsUpNotificationInteractor.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/domain/interactor/HeadsUpNotificationInteractor.kt index cdbe0fd23a9a..8d1e61123fdd 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/domain/interactor/HeadsUpNotificationInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/domain/interactor/HeadsUpNotificationInteractor.kt @@ -81,7 +81,7 @@ constructor( if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) { flowOf(emptySet()) } else { - activeHeadsUpRows.map { it.map { (repo, _) -> repo }.toSet() } + activeHeadsUpRows.map { it.map { (repo, _) -> repo }.toSet() }.distinctUntilChanged() } } @@ -90,9 +90,9 @@ constructor( if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) { flowOf(emptySet()) } else { - activeHeadsUpRows.map { - it.filter { (_, isPinned) -> isPinned }.map { (repo, _) -> repo }.toSet() - } + activeHeadsUpRows + .map { it.filter { (_, isPinned) -> isPinned }.map { (repo, _) -> repo }.toSet() } + .distinctUntilChanged() // TODO(b/402428276) stop sending duplicate updates instead } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationLogger.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationLogger.java index ec8fbc08de7a..5bdd769dfa03 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationLogger.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationLogger.java @@ -19,7 +19,6 @@ import android.content.Context; import android.os.Handler; import android.os.RemoteException; import android.os.ServiceManager; -import android.os.SystemClock; import android.service.notification.NotificationListenerService; import android.util.ArrayMap; import android.util.ArraySet; @@ -44,6 +43,7 @@ import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.notification.collection.NotifLiveDataStore; import com.android.systemui.statusbar.notification.collection.NotifPipeline; import com.android.systemui.statusbar.notification.collection.NotificationEntry; +import com.android.systemui.statusbar.notification.collection.UseElapsedRealtimeForCreationTime; import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener; import com.android.systemui.statusbar.notification.collection.notifcollection.UpdateSource; import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider; @@ -112,7 +112,7 @@ public class NotificationLogger implements StateListener, CoreStartable, @Override public void run() { - mLastVisibilityReportUptimeMs = SystemClock.uptimeMillis(); + mLastVisibilityReportUptimeMs = UseElapsedRealtimeForCreationTime.getCurrentTime(); // 1. Loop over active entries: // A. Keep list of visible notifications. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java index 76830646587d..3c386a56ab4e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java @@ -41,6 +41,7 @@ import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Canvas; +import android.graphics.Color; import android.graphics.Path; import android.graphics.Point; import android.graphics.Rect; @@ -422,9 +423,10 @@ public class ExpandableNotificationRow extends ActivatableNotificationView } onExpansionChanged(true /* userAction */, wasExpanded); } else { - final boolean wasExpanded = mGroupExpansionManager.isGroupExpanded(mEntry); - boolean nowExpanded = mGroupExpansionManager.toggleGroupExpansion(mEntry); - mOnExpandClickListener.onExpandClicked(mEntry, v, nowExpanded); + final boolean wasExpanded = + mGroupExpansionManager.isGroupExpanded(getEntryLegacy()); + boolean nowExpanded = mGroupExpansionManager.toggleGroupExpansion(getEntryLegacy()); + mOnExpandClickListener.onExpandClicked(getEntryLegacy(), v, nowExpanded); if (shouldLogExpandClickMetric) { mMetricsLogger.action( MetricsEvent.ACTION_NOTIFICATION_GROUP_EXPANDER, nowExpanded); @@ -454,7 +456,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView if (NotificationBundleUi.isEnabled()) { mOnExpandClickListener.onExpandClicked(this, mEntryAdapter, nowExpanded); } else { - mOnExpandClickListener.onExpandClicked(mEntry, v, nowExpanded); + mOnExpandClickListener.onExpandClicked(getEntryLegacy(), v, nowExpanded); } if (shouldLogExpandClickMetric) { mMetricsLogger.action(MetricsEvent.ACTION_NOTIFICATION_EXPANDER, nowExpanded); @@ -559,7 +561,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView if (NotificationBundleUi.isEnabled()) { return mKey; } else { - return mEntry.getKey(); + return getEntryLegacy().getKey(); } } @@ -662,14 +664,14 @@ public class ExpandableNotificationRow extends ActivatableNotificationView */ public boolean getIsNonblockable() { NotificationBundleUi.assertInLegacyMode(); - if (mEntry == null) { + if (getEntryLegacy() == null) { return true; } - return !mEntry.isBlockable(); + return !getEntryLegacy().isBlockable(); } private boolean isConversation() { - return mPeopleNotificationIdentifier.getPeopleNotificationType(mEntry) + return mPeopleNotificationIdentifier.getPeopleNotificationType(getEntry()) != PeopleNotificationIdentifier.TYPE_NON_PERSON; } @@ -680,7 +682,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView Trace.beginSection("ExpNotRow#onNotifUpdated (leaf)"); } for (NotificationContentView l : mLayouts) { - l.onNotificationUpdated(mEntry); + l.onNotificationUpdated(getEntry()); } mShowingPublicInitialized = false; if (mMenuRow != null) { @@ -747,7 +749,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView */ public void updateBubbleButton() { for (NotificationContentView l : mLayouts) { - l.updateBubbleButton(mEntry); + l.updateBubbleButton(getEntry()); } } @@ -778,7 +780,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView return mEntryAdapter.getContrastedColor(mContext, mIsMinimized && !isExpanded(), getBackgroundColorWithoutTint()); } else { - return mEntry.getContrastedColor(mContext, mIsMinimized && !isExpanded(), + return getEntryLegacy().getContrastedColor(mContext, mIsMinimized && !isExpanded(), getBackgroundColorWithoutTint()); } } @@ -886,7 +888,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView if (NotificationBundleUi.isEnabled()) { targetSdk = mEntryAdapter.getTargetSdk(); } else { - targetSdk = mEntry.targetSdk; + targetSdk = getEntryLegacy().targetSdk; } boolean beforeN = targetSdk < Build.VERSION_CODES.N; @@ -902,7 +904,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView if (NotificationBundleUi.isEnabled()) { summarization = mEntryAdapter.getSummarization(); } else { - summarization = mEntry.getRanking().getSummarization(); + summarization = getEntryLegacy().getRanking().getSummarization(); } if (customView && beforeS && !mIsSummaryWithChildren) { @@ -946,7 +948,25 @@ public class ExpandableNotificationRow extends ActivatableNotificationView layout.setHeights(smallHeight, headsUpHeight, maxExpandedHeight); } + /** + * Check {@link NotificationBundleUi#isEnabled()} + * and use {@link #getEntryAdapter()} when true + * and {@link #getEntryLegacy()} when false. + */ + @NonNull + @Deprecated + public NotificationEntry getEntryLegacy() { + NotificationBundleUi.assertInLegacyMode(); + return mEntry; + } + + /** + * Check {@link NotificationBundleUi#isEnabled()} + * and use {@link #getEntryAdapter()} when true + * and {@link #getEntryLegacy()} when false. + */ @NonNull + @Deprecated public NotificationEntry getEntry() { return mEntry; } @@ -1482,8 +1502,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView public void setBubbleClickListener(@Nullable OnClickListener l) { mBubbleClickListener = l; // ensure listener is passed to the content views - mPrivateLayout.updateBubbleButton(mEntry); - mPublicLayout.updateBubbleButton(mEntry); + mPrivateLayout.updateBubbleButton(getEntry()); + mPublicLayout.updateBubbleButton(getEntry()); } /** @@ -1555,7 +1575,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView return initializationTime != -1 && SystemClock.elapsedRealtime() > initializationTime + INITIALIZATION_DELAY; } else { - return getEntry().hasFinishedInitialization(); + return getEntryLegacy().hasFinishedInitialization(); } } @@ -1634,14 +1654,14 @@ public class ExpandableNotificationRow extends ActivatableNotificationView if (NotificationBundleUi.isEnabled()) { mEntryAdapter.prepareForInflation(); } else { - mEntry.getSbn().clearPackageContext(); + getEntryLegacy().getSbn().clearPackageContext(); } // TODO: Move content inflation logic out of this call RowContentBindParams params = mRowContentBindStage.getStageParams(mEntry); params.setNeedsReinflation(true); var rebindEndCallback = mRebindingTracker.trackRebinding(NotificationBundleUi.isEnabled() - ? mEntryAdapter.getKey() : mEntry.getKey()); + ? mEntryAdapter.getKey() : getEntryLegacy().getKey()); mRowContentBindStage.requestRebind(mEntry, (e) -> rebindEndCallback.onFinished()); Trace.endSection(); } @@ -1681,8 +1701,10 @@ public class ExpandableNotificationRow extends ActivatableNotificationView protected void setBackgroundTintColor(int color) { if (notificationRowTransparency()) { boolean isColorized = false; - if (NotificationBundleUi.isEnabled() && mEntryAdapter != null) { - isColorized = mEntryAdapter.isColorized(); + if (NotificationBundleUi.isEnabled()) { + if (mEntryAdapter != null) { + isColorized = mEntryAdapter.isColorized(); + } } else { if (mEntry != null) { isColorized = mEntry.getSbn().getNotification().isColorized(); @@ -1702,7 +1724,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView } } } - super.setBackgroundTintColor(color); NotificationContentView view = getShowingLayout(); if (view != null) { @@ -2325,7 +2346,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView } @VisibleForTesting - protected void setEntry(NotificationEntry entry) { + @Deprecated + protected void setEntryLegacy(NotificationEntry entry) { + NotificationBundleUi.assertInLegacyMode(); mEntry = entry; } @@ -2418,7 +2441,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView if (NotificationBundleUi.isEnabled()) { return traceTag + "(" + getEntryAdapter().getStyle() + ")"; } else { - return traceTag + "(" + getEntry().getNotificationStyle() + ")"; + return traceTag + "(" + getEntryLegacy().getNotificationStyle() + ")"; } } @@ -2923,7 +2946,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView if (NotificationBundleUi.isEnabled()) { return getEntryAdapter().getIcons().getShelfIcon(); } else { - return mEntry.getIcons().getShelfIcon(); + return getEntryLegacy().getIcons().getShelfIcon(); } } @@ -3031,7 +3054,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView mGroupExpansionManager.setGroupExpanded(mEntryAdapter, userExpanded); } } else { - mGroupExpansionManager.setGroupExpanded(mEntry, userExpanded); + mGroupExpansionManager.setGroupExpanded(getEntryLegacy(), userExpanded); } onExpansionChanged(true /* userAction */, wasExpanded); return; @@ -3174,7 +3197,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView public boolean canShowHeadsUp() { boolean canEntryHun = NotificationBundleUi.isEnabled() ? mEntryAdapter.canPeek() - : mEntry.isStickyAndNotDemoted(); + : getEntryLegacy().isStickyAndNotDemoted(); if (mOnKeyguard && !isDozing() && !isBypassEnabled() && (!canEntryHun || (!mIgnoreLockscreenConstraints && mSaveSpaceOnLockscreen))) { @@ -3196,13 +3219,13 @@ public class ExpandableNotificationRow extends ActivatableNotificationView if (NotificationBundleUi.isEnabled()) { return mGroupExpansionManager.isGroupExpanded(mEntryAdapter); } - return mGroupExpansionManager.isGroupExpanded(mEntry); + return mGroupExpansionManager.isGroupExpanded(getEntryLegacy()); } private boolean isGroupRoot() { return NotificationBundleUi.isEnabled() ? mGroupMembershipManager.isGroupRoot(mEntryAdapter) - : mGroupMembershipManager.isGroupSummary(mEntry); + : mGroupMembershipManager.isGroupSummary(getEntryLegacy()); } private void onAttachedChildrenCountChanged() { @@ -3224,7 +3247,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView if (NotificationBundleUi.isEnabled()) { mPublicLayout.setNotificationWhen(mEntryAdapter.getWhen()); } else { - mPublicLayout.setNotificationWhen(mEntry.getSbn().getNotification().getWhen()); + mPublicLayout.setNotificationWhen( + getEntryLegacy().getSbn().getNotification().getWhen()); } } getShowingLayout().updateBackgroundColor(false /* animate */); @@ -3559,7 +3583,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView return mEntryAdapter.isClearable() && (!shouldShowPublic() || !mSensitiveHiddenInGeneral); } else { - return mEntry.isClearable() && (!shouldShowPublic() || !mSensitiveHiddenInGeneral); + return getEntryLegacy().isClearable() + && (!shouldShowPublic() || !mSensitiveHiddenInGeneral); } } @@ -3573,7 +3598,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView if (!NotificationBundleUi.isEnabled()) { // this is only called if row.getParent() instanceof NotificationStackScrollLayout, // so there is never a group to expand - mGroupExpansionManager.setGroupExpanded(mEntry, true); + mGroupExpansionManager.setGroupExpanded(getEntryLegacy(), true); } } notifyHeightChanged(/* needsAnimation= */ false); @@ -3806,7 +3831,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView return true; } } else { - if (getEntry().getSbn().getNotification().isColorized()) { + if (getEntryLegacy().getSbn().getNotification().isColorized()) { return true; } } @@ -3973,12 +3998,18 @@ public class ExpandableNotificationRow extends ActivatableNotificationView } } else if (isChildInGroup()) { final int childColor = getShowingLayout().getBackgroundColorForExpansionState(); - // Only show a background if the group is expanded OR if it is expanding / collapsing - // and has a custom background color. - final boolean showBackground = isGroupExpanded() - || ((mNotificationParent.isGroupExpansionChanging() - || mNotificationParent.isUserLocked()) && childColor != 0); - mShowNoBackground = !showBackground; + if (Flags.notificationRowTransparency() && childColor == Color.TRANSPARENT) { + // If child is not customizing its background color, switch from the parent to + // the child background when the expansion finishes. + mShowNoBackground = !mNotificationParent.mShowNoBackground; + } else { + // Only show a background if the group is expanded OR if it is + // expanding / collapsing and has a custom background color. + final boolean showBackground = isGroupExpanded() + || ((mNotificationParent.isGroupExpansionChanging() + || mNotificationParent.isUserLocked()) && childColor != 0); + mShowNoBackground = !showBackground; + } } else { // Only children or parents ever need no background. mShowNoBackground = false; @@ -4277,7 +4308,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView public boolean isMediaRow() { NotificationBundleUi.assertInLegacyMode(); - return mEntry.getSbn().getNotification().isMediaNotification(); + return getEntryLegacy().getSbn().getNotification().isMediaNotification(); } public void setAboveShelf(boolean aboveShelf) { @@ -4399,11 +4430,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView public void dump(PrintWriter pwOriginal, String[] args) { IndentingPrintWriter pw = DumpUtilsKt.asIndenting(pwOriginal); // Skip super call; dump viewState ourselves - if (NotificationBundleUi.isEnabled()) { - pw.println("Notification: " + mEntryAdapter.getKey()); - } else { - pw.println("Notification: " + mEntry.getKey()); - } + pw.println("Notification: " + getKey()); DumpUtilsKt.withIncreasedIndent(pw, () -> { pw.println(this); pw.print("visibility: " + getVisibility()); @@ -4640,7 +4667,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView if (NotificationBundleUi.isEnabled()) { mLaunchAnimationRunning = launchAnimationRunning; } else { - getEntry().setExpandAnimationRunning(launchAnimationRunning); + getEntryLegacy().setExpandAnimationRunning(launchAnimationRunning); } } @@ -4649,7 +4676,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView if (NotificationBundleUi.isEnabled()) { return mLaunchAnimationRunning; } else { - return getEntry().isExpandAnimationRunning(); + return getEntryLegacy().isExpandAnimationRunning(); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowController.java index ac55930f5c11..7c0ee6685e6b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowController.java @@ -139,7 +139,7 @@ public class ExpandableNotificationRowController implements NotifViewController } final int viewUserId = NotificationBundleUi.isEnabled() ? mView.getEntryAdapter().getSbn().getUserId() - : mView.getEntry().getSbn().getUserId(); + : mView.getEntryLegacy().getSbn().getUserId(); if (viewUserId == UserHandle.USER_ALL || viewUserId == userId) { mView.getPrivateLayout().setBubblesEnabledForUser( BUBBLES_SETTING_ENABLED_VALUE.equals(value)); @@ -395,7 +395,7 @@ public class ExpandableNotificationRowController implements NotifViewController mSettingsController.addCallback(BUBBLES_SETTING_URI, mSettingsListener); } } else { - mView.getEntry().setInitializationTime(mClock.elapsedRealtime()); + mView.getEntryLegacy().setInitializationTime(mClock.elapsedRealtime()); mSettingsController.addCallback(BUBBLES_SETTING_URI, mSettingsListener); } mPluginManager.addPluginListener(mView, @@ -429,7 +429,9 @@ public class ExpandableNotificationRowController implements NotifViewController @Override @NonNull public String getNodeLabel() { - return NotificationBundleUi.isEnabled() ? mView.getLoggingKey() : logKey(mView.getEntry()); + return NotificationBundleUi.isEnabled() + ? mView.getLoggingKey() + : logKey(mView.getEntryLegacy()); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowDragController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowDragController.java index 9ae2eb1b9328..20b826a3ca92 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowDragController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowDragController.java @@ -109,7 +109,7 @@ public class ExpandableNotificationRowDragController { StatusBarNotification sn = NotificationBundleUi.isEnabled() ? enr.getEntryAdapter().getSbn() - : enr.getEntry().getSbn(); + : enr.getEntryLegacy().getSbn(); Notification notification = sn.getNotification(); final PendingIntent contentIntent = notification.contentIntent != null ? notification.contentIntent diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java index ff4b835eb3c0..d97e25fdfa22 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java @@ -473,7 +473,7 @@ public class NotificationContentInflater implements NotificationRowContentBinder result.newPublicView = createSensitiveContentMessageNotification( NotificationBundleUi.isEnabled() ? row.getEntryAdapter().getSbn().getNotification() - : row.getEntry().getSbn().getNotification(), + : row.getEntryLegacy().getSbn().getNotification(), builder.getStyle(), systemUiContext, packageContext).createContentView(); } else { @@ -814,7 +814,7 @@ public class NotificationContentInflater implements NotificationRowContentBinder existingWrapper.onReinflated(); } } catch (Exception e) { - handleInflationError(runningInflations, e, row, callback, logger, + handleInflationError(runningInflations, e, row, entry, callback, logger, "applying view synchronously"); // Add a running inflation to make sure we don't trigger callbacks. // Safe to do because only happens in tests. @@ -836,7 +836,7 @@ public class NotificationContentInflater implements NotificationRowContentBinder String invalidReason = isValidView(v, entry, row.getResources()); if (invalidReason != null) { handleInflationError(runningInflations, new InflationException(invalidReason), - row, callback, logger, "applied invalid view"); + row, entry, callback, logger, "applied invalid view"); runningInflations.remove(inflationId); return; } @@ -873,7 +873,7 @@ public class NotificationContentInflater implements NotificationRowContentBinder onViewApplied(newView); } catch (Exception anotherException) { runningInflations.remove(inflationId); - handleInflationError(runningInflations, e, row, + handleInflationError(runningInflations, e, row, entry, callback, logger, "applying view"); } } @@ -969,13 +969,14 @@ public class NotificationContentInflater implements NotificationRowContentBinder private static void handleInflationError( HashMap<Integer, CancellationSignal> runningInflations, Exception e, - ExpandableNotificationRow row, @Nullable InflationCallback callback, + ExpandableNotificationRow row, NotificationEntry entry, + @Nullable InflationCallback callback, NotificationRowContentBinderLogger logger, String logContext) { Assert.isMainThread(); logger.logAsyncTaskException(row.getLoggingKey(), logContext, e); runningInflations.values().forEach(CancellationSignal::cancel); if (callback != null) { - callback.handleInflationException(row.getEntry(), e); + callback.handleInflationException(entry, e); } } @@ -1443,7 +1444,7 @@ public class NotificationContentInflater implements NotificationRowContentBinder + Integer.toHexString(sbn.getId()); Log.e(CentralSurfaces.TAG, "couldn't inflate view for notification " + ident, e); if (mCallback != null) { - mCallback.handleInflationException(mRow.getEntry(), + mCallback.handleInflationException(mEntry, new InflationException("Couldn't inflate contentViews" + e)); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java index e9993ae31514..26d318bea5cc 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java @@ -601,7 +601,7 @@ public class NotificationContentView extends FrameLayout implements Notification if (NotificationBundleUi.isEnabled()) { return mContainingNotification.getEntryAdapter().getSbn(); } else { - return mContainingNotification.getEntry().getSbn(); + return mContainingNotification.getEntryLegacy().getSbn(); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationRowContentBinderImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationRowContentBinderImpl.kt index 2f94d3220dc8..ae52db88358a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationRowContentBinderImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationRowContentBinderImpl.kt @@ -541,7 +541,7 @@ constructor( val ident: String = (sbn.packageName + "/0x" + Integer.toHexString(sbn.id)) Log.e(TAG, "couldn't inflate view for notification $ident", e) callback?.handleInflationException( - if (NotificationBundleUi.isEnabled) entry else row.entry, + if (NotificationBundleUi.isEnabled) entry else row.entryLegacy, InflationException("Couldn't inflate contentViews$e"), ) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/icon/NotificationRowIconViewInflaterFactory.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/icon/NotificationRowIconViewInflaterFactory.kt index 4082a5b35f1e..2c5b9f44bc58 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/icon/NotificationRowIconViewInflaterFactory.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/icon/NotificationRowIconViewInflaterFactory.kt @@ -61,7 +61,7 @@ constructor( row: ExpandableNotificationRow, context: Context, ): NotificationIconProvider { - val sbn = if (NotificationBundleUi.isEnabled) row.entryAdapter?.sbn else row.entry.sbn + val sbn = if (NotificationBundleUi.isEnabled) row.entryAdapter?.sbn else row.entryLegacy.sbn if (sbn == null) { return object : NotificationIconProvider { override fun shouldShowAppIcon(): Boolean { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationBigPictureTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationBigPictureTemplateViewWrapper.java index f492b259e58d..e266dad63d80 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationBigPictureTemplateViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationBigPictureTemplateViewWrapper.java @@ -50,7 +50,7 @@ public class NotificationBigPictureTemplateViewWrapper extends NotificationTempl resolveViews(); updateImageTag(NotificationBundleUi.isEnabled() ? row.getEntryAdapter().getSbn() - : row.getEntry().getSbn()); + : row.getEntryLegacy().getSbn()); } private void resolveViews() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationBigTextTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationBigTextTemplateViewWrapper.java index dec674c5a0f3..71bb9a2c9e72 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationBigTextTemplateViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationBigTextTemplateViewWrapper.java @@ -47,7 +47,7 @@ public class NotificationBigTextTemplateViewWrapper extends NotificationTemplate // the transformation types and we need to have our values set by then. resolveViews(NotificationBundleUi.isEnabled() ? row.getEntryAdapter().getSbn() - : row.getEntry().getSbn()); + : row.getEntryLegacy().getSbn()); super.onContentUpdated(row); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java index 585051ad26e1..e6dadcd7c8d2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java @@ -225,7 +225,7 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper imple super.onContentUpdated(row); mIsLowPriority = NotificationBundleUi.isEnabled() ? row.getEntryAdapter().isAmbient() - : row.getEntry().isAmbient(); + : row.getEntryLegacy().isAmbient(); mTransformLowPriorityTitle = !row.isChildInGroup() && !row.isSummaryWithChildren(); ArraySet<View> previousViews = mTransformationHelper.getAllTransformingViews(); @@ -236,7 +236,7 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper imple updateCropToPaddingForImageViews(); Notification n = NotificationBundleUi.isEnabled() ? row.getEntryAdapter().getSbn().getNotification() - : row.getEntry().getSbn().getNotification(); + : row.getEntryLegacy().getSbn().getNotification(); mIcon.setTag(ImageTransformState.ICON_TAG, n.getSmallIcon()); // We need to reset all views that are no longer transforming in case a view was previously diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationTemplateViewWrapper.java index 99db1dba7e65..19321dcef5c7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationTemplateViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationTemplateViewWrapper.java @@ -327,7 +327,7 @@ public class NotificationTemplateViewWrapper extends NotificationHeaderViewWrapp // the transformation types and we need to have our values set by then. resolveTemplateViews(NotificationBundleUi.isEnabled() ? row.getEntryAdapter().getSbn() - : row.getEntry().getSbn()); + : row.getEntryLegacy().getSbn()); super.onContentUpdated(row); // With the modern templates, a large icon visually overlaps the header, so we can't // hide the header, we must show it. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java index 64babb2449d7..35e286c18fd8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java @@ -83,7 +83,7 @@ public abstract class NotificationViewWrapper implements TransformableView { if (NotificationBundleUi.isEnabled() ? row.getEntryAdapter().getSbn().getNotification().isStyle( Notification.DecoratedCustomViewStyle.class) - : row.getEntry().getSbn().getNotification().isStyle( + : row.getEntryLegacy().getSbn().getNotification().isStyle( Notification.DecoratedCustomViewStyle.class)) { return new NotificationDecoratedCustomViewWrapper(ctx, v, row); } @@ -141,7 +141,7 @@ public abstract class NotificationViewWrapper implements TransformableView { // Apps targeting Q should fix their dark mode bugs. int targetSdk = NotificationBundleUi.isEnabled() ? mRow.getEntryAdapter().getTargetSdk() - : mRow.getEntry().targetSdk; + : mRow.getEntryLegacy().targetSdk; if (targetSdk >= Build.VERSION_CODES.Q) { return false; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/MagneticNotificationRowManagerImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/MagneticNotificationRowManagerImpl.kt index 9bd5a5bd903f..5a23f7cc2861 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/MagneticNotificationRowManagerImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/MagneticNotificationRowManagerImpl.kt @@ -181,7 +181,7 @@ constructor( it.setMagneticTranslation(targetTranslation) } } - playPullHaptics(mappedTranslation = swipedRowMultiplier * translation, canSwipedBeDismissed) + // TODO(b/399633875): Enable pull haptics after we have a clear and polished haptics design } private fun playPullHaptics(mappedTranslation: Float, canSwipedBeDismissed: Boolean) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java index 315d37e55bc3..f9d8c8e74b5d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java @@ -444,7 +444,7 @@ public class NotificationChildrenContainer extends ViewGroup mIsConversation = isConversation; StatusBarNotification notification = NotificationBundleUi.isEnabled() ? mContainingNotification.getEntryAdapter().getSbn() - : mContainingNotification.getEntry().getSbn(); + : mContainingNotification.getEntryLegacy().getSbn(); if (notification == null) { return; } @@ -615,7 +615,7 @@ public class NotificationChildrenContainer extends ViewGroup RemoteViews header; StatusBarNotification notification = NotificationBundleUi.isEnabled() ? mContainingNotification.getEntryAdapter().getSbn() - : mContainingNotification.getEntry().getSbn(); + : mContainingNotification.getEntryLegacy().getSbn(); if (notification == null) { return; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.kt index 96f0e6f57958..b5562ae15ede 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.kt @@ -167,7 +167,7 @@ internal constructor( view === promoHeaderView -> BUCKET_PROMO view is ExpandableNotificationRow -> if (NotificationBundleUi.isEnabled) view.entryAdapter?.sectionBucket - else view.entry.bucket + else view.entryLegacy.bucket else -> null } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index a5f711050c46..9fea75048e3e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -1039,10 +1039,10 @@ public class NotificationStackScrollLayout } int bucket = NotificationBundleUi.isEnabled() ? row.getEntryAdapter().getSectionBucket() - : row.getEntry().getBucket(); + : row.getEntryLegacy().getBucket(); boolean isAmbient = NotificationBundleUi.isEnabled() ? row.getEntryAdapter().isAmbient() - : row.getEntry().isAmbient(); + : row.getEntryLegacy().isAmbient(); currentIndex++; boolean beforeSpeedBump; if (mHighPriorityBeforeSpeedBump) { @@ -1847,7 +1847,7 @@ public class NotificationStackScrollLayout } else { if (row.isChildInGroup()) { final NotificationEntry groupSummary = - mGroupMembershipManager.getGroupSummary(row.getEntry()); + mGroupMembershipManager.getGroupSummary(row.getEntryLegacy()); if (groupSummary != null) { row = groupSummary.getRow(); } @@ -2000,16 +2000,16 @@ public class NotificationStackScrollLayout if ((bottom - top >= mMinInteractionHeight || !requireMinHeight) && touchY >= top && touchY <= bottom && touchX >= left && touchX <= right) { if (slidingChild instanceof ExpandableNotificationRow row) { - NotificationEntry entry = row.getEntry(); boolean isEntrySummaryForTopHun; if (NotificationBundleUi.isEnabled()) { isEntrySummaryForTopHun = Objects.equals( ((ExpandableNotificationRow) slidingChild).getNotificationParent(), mTopHeadsUpRow); } else { + NotificationEntry entry = row.getEntryLegacy(); isEntrySummaryForTopHun = mTopHeadsUpRow != null && - mGroupMembershipManager.getGroupSummary(mTopHeadsUpRow.getEntry()) - == entry; + mGroupMembershipManager.getGroupSummary( + mTopHeadsUpRow.getEntryLegacy()) == entry; } if (!mIsExpanded && row.isHeadsUp() && row.isPinned() && mTopHeadsUpRow != row @@ -3009,7 +3009,7 @@ public class NotificationStackScrollLayout ExpandableNotificationRow childRow = (ExpandableNotificationRow) child; return NotificationBundleUi.isEnabled() ? mGroupMembershipManager.isChildInGroup(childRow.getEntryAdapter()) - : mGroupMembershipManager.isChildInGroup(childRow.getEntry()); + : mGroupMembershipManager.isChildInGroup(childRow.getEntryLegacy()); } return false; } @@ -6473,7 +6473,7 @@ public class NotificationStackScrollLayout @SelectedRows int selection) { int bucket = NotificationBundleUi.isEnabled() ? row.getEntryAdapter().getSectionBucket() - : row.getEntry().getBucket(); + : row.getEntryLegacy().getBucket(); switch (selection) { case ROWS_ALL: return true; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java index bb3abc1fba38..f3d8ee245540 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java @@ -648,11 +648,11 @@ public class NotificationStackScrollLayoutController implements Dumpable { public void onChildSnappedBack(View animView, float targetLeft) { mView.onSwipeEnd(); if (animView instanceof ExpandableNotificationRow row) { - if (row.isPinned() && !canChildBeDismissed(row) - && NotificationBundleUi.isEnabled() + boolean cannotFullScreen = NotificationBundleUi.isEnabled() ? !row.getEntryAdapter().isFullScreenCapable() - : (row.getEntry().getSbn().getNotification().fullScreenIntent - == null)) { + : (row.getEntryLegacy().getSbn().getNotification().fullScreenIntent + == null); + if (row.isPinned() && !canChildBeDismissed(row) && cannotFullScreen) { mHeadsUpManager.removeNotification( row.getKey(), /* removeImmediately= */ true, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackSizeCalculator.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackSizeCalculator.kt index fcb63df1a528..e5071d9c1e53 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackSizeCalculator.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackSizeCalculator.kt @@ -413,7 +413,7 @@ constructor( (currentNotification as? ExpandableNotificationRow)?.entryAdapter counter.incrementForBucket(entryAdapter?.sectionBucket) } else { - val entry = (currentNotification as? ExpandableNotificationRow)?.entry + val entry = (currentNotification as? ExpandableNotificationRow)?.entryLegacy counter.incrementForBucket(entry?.bucket) } } @@ -470,7 +470,7 @@ constructor( calculateGapAndDividerHeight(stack, previousView, current = view, visibleIndex) val canPeek = view is ExpandableNotificationRow && if (NotificationBundleUi.isEnabled) view.entryAdapter?.canPeek() == true - else view.entry.isStickyAndNotDemoted + else view.entryLegacy.isStickyAndNotDemoted var size = if (onLockscreen) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java index 28218227506c..da1442359071 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java @@ -927,7 +927,7 @@ public class StackScrollAlgorithm { childState.headsUpIsVisible, row.showingPulsing(), ambientState.isOnKeyguard(), NotificationBundleUi.isEnabled() ? row.getEntryAdapter().canPeek() - : row.getEntry().isStickyAndNotDemoted())) { + : row.getEntryLegacy().isStickyAndNotDemoted())) { // the height of this child before clamping it to the top float unmodifiedChildHeight = childState.height; clampHunToTop( @@ -984,7 +984,7 @@ public class StackScrollAlgorithm { childState.headsUpIsVisible, row.showingPulsing(), ambientState.isOnKeyguard(), NotificationBundleUi.isEnabled() ? row.getEntryAdapter().canPeek() - : row.getEntry().isStickyAndNotDemoted())) { + : row.getEntryLegacy().isStickyAndNotDemoted())) { // Ensure that the heads up is always visible even when scrolled off. // NSSL y starts at top of screen in non-split-shade, but below the qs // offset diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/ui/viewbinder/HeadsUpNotificationViewBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/ui/viewbinder/HeadsUpNotificationViewBinder.kt index bc533148f514..afe79718d526 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/ui/viewbinder/HeadsUpNotificationViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/ui/viewbinder/HeadsUpNotificationViewBinder.kt @@ -60,7 +60,7 @@ constructor( if (animationsEnabled) { added.forEach { key -> val row = obtainView(key) - val hasStatusBarChip = statusBarChips.contains(row.entry.key) + val hasStatusBarChip = statusBarChips.contains(row.key) parentView.generateHeadsUpAnimation( row, /* isHeadsUp = */ true, @@ -69,7 +69,7 @@ constructor( } removed.forEach { key -> val row = obtainView(key) - val hasStatusBarChip = statusBarChips.contains(row.entry.key) + val hasStatusBarChip = statusBarChips.contains(row.key) if (!parentView.isBeingDragged()) { parentView.generateHeadsUpAnimation( row, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java index 74a42ef3ff7d..f3d72027238f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java @@ -29,6 +29,7 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ValueAnimator; import android.annotation.IntDef; +import android.content.Context; import android.graphics.Color; import android.os.Handler; import android.util.Log; @@ -226,6 +227,8 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump private ScrimState mState = ScrimState.UNINITIALIZED; + private Context mContext; + private ScrimView mScrimInFront; private ScrimView mNotificationsScrim; private ScrimView mScrimBehind; @@ -365,7 +368,9 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump @Main CoroutineDispatcher mainDispatcher, LargeScreenShadeInterpolator largeScreenShadeInterpolator, BlurConfig blurConfig, + @Main Context context, Lazy<WindowRootViewBlurInteractor> windowRootViewBlurInteractor) { + mContext = context; mScrimStateListener = lightBarController::setScrimState; mLargeScreenShadeInterpolator = largeScreenShadeInterpolator; mBlurConfig = blurConfig; @@ -1627,16 +1632,16 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump private void updateThemeColors() { if (mScrimBehind == null) return; - int background = mScrimBehind.getContext().getColor( + int background = mContext.getColor( com.android.internal.R.color.materialColorSurfaceDim); - int accent = mScrimBehind.getContext().getColor( + int accent = mContext.getColor( com.android.internal.R.color.materialColorPrimary); mColors.setMainColor(background); mColors.setSecondaryColor(accent); final boolean isBackgroundLight = !ContrastColorUtil.isColorDark(background); mColors.setSupportsDarkText(isBackgroundLight); - int surface = mScrimBehind.getContext().getColor( + int surface = mContext.getColor( com.android.internal.R.color.materialColorSurface); for (ScrimState state : ScrimState.values()) { state.setSurfaceColor(surface); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarRemoteInputCallback.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarRemoteInputCallback.java index 05a46cd9fa31..8389aab4aac8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarRemoteInputCallback.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarRemoteInputCallback.java @@ -219,7 +219,7 @@ public class StatusBarRemoteInputCallback implements Callback, Callbacks, if (NotificationBundleUi.isEnabled()) { mGroupExpansionManager.toggleGroupExpansion(row.getEntryAdapter()); } else { - mGroupExpansionManager.toggleGroupExpansion(row.getEntry()); + mGroupExpansionManager.toggleGroupExpansion(row.getEntryLegacy()); } } else if (!row.isChildInGroup()) { final boolean expandNotification; @@ -241,7 +241,7 @@ public class StatusBarRemoteInputCallback implements Callback, Callbacks, if (NotificationBundleUi.isEnabled()) { mGroupExpansionManager.toggleGroupExpansion(row.getEntryAdapter()); } else { - mGroupExpansionManager.toggleGroupExpansion(row.getEntry()); + mGroupExpansionManager.toggleGroupExpansion(row.getEntryLegacy()); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java index f1f2b88e9943..6509a698854d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java @@ -79,6 +79,7 @@ import com.android.internal.logging.UiEvent; import com.android.internal.logging.UiEventLogger; import com.android.internal.util.ContrastColorUtil; import com.android.systemui.Dependency; +import com.android.systemui.Flags; import com.android.systemui.res.R; import com.android.systemui.statusbar.RemoteInputController; import com.android.systemui.statusbar.notification.collection.NotificationEntry; @@ -245,7 +246,9 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene mProgressBar.setProgressTintList(accentColor); mProgressBar.setIndeterminateTintList(accentColor); mProgressBar.setSecondaryProgressTintList(accentColor); - setBackgroundColor(backgroundColor); + if (!Flags.notificationRowTransparency()) { + setBackgroundColor(backgroundColor); + } } @Override @@ -419,10 +422,10 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene // case to prevent flicker. if (!mRemoved) { ViewGroup parent = (ViewGroup) getParent(); + View actionsContainer = getActionsContainerLayout(); if (animate && parent != null) { ViewGroup grandParent = (ViewGroup) parent.getParent(); - View actionsContainer = getActionsContainerLayout(); int actionsContainerHeight = actionsContainer != null ? actionsContainer.getHeight() : 0; @@ -459,6 +462,9 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene if (mWrapper != null) { mWrapper.setRemoteInputVisible(false); } + if (Flags.notificationRowTransparency()) { + if (actionsContainer != null) actionsContainer.setAlpha(1); + } } } unregisterBackCallback(); @@ -823,12 +829,14 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene ObjectAnimator.ofFloat(fadeOutView, View.ALPHA, 1f, 0f); fadeOutViewAlphaAnimator.setDuration(FOCUS_ANIMATION_CROSSFADE_DURATION); fadeOutViewAlphaAnimator.setInterpolator(InterpolatorsAndroidX.LINEAR); - animatorSet.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation, boolean isReverse) { - fadeOutView.setAlpha(1f); - } - }); + if (!Flags.notificationRowTransparency()) { + animatorSet.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation, boolean isReverse) { + fadeOutView.setAlpha(1f); + } + }); + } animatorSet.playTogether(alphaAnimator, scaleAnimator, fadeOutViewAlphaAnimator); } return animatorSet; diff --git a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java index 48d7747d2dc2..bd3feadf4459 100644 --- a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java +++ b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java @@ -988,6 +988,7 @@ public class ThemeOverlayController implements CoreStartable, Dumpable { public void dump(@NonNull PrintWriter pw, @NonNull String[] args) { pw.println("mSystemColors=" + mCurrentColors); pw.println("mMainWallpaperColor=" + Integer.toHexString(mMainWallpaperColor)); + pw.println("mContrast=" + mContrast); pw.println("mSecondaryOverlay=" + mSecondaryOverlay); pw.println("mNeutralOverlay=" + mNeutralOverlay); pw.println("mDynamicOverlay=" + mDynamicOverlay); diff --git a/packages/SystemUI/src/com/android/systemui/unfold/DisplaySwitchLatencyLogger.kt b/packages/SystemUI/src/com/android/systemui/unfold/DisplaySwitchLatencyLogger.kt index 47e27bc59f96..1cc7a3185a5d 100644 --- a/packages/SystemUI/src/com/android/systemui/unfold/DisplaySwitchLatencyLogger.kt +++ b/packages/SystemUI/src/com/android/systemui/unfold/DisplaySwitchLatencyLogger.kt @@ -50,6 +50,7 @@ class DisplaySwitchLatencyLogger { onScreenTurningOnToOnDrawnMs, onDrawnToOnScreenTurnedOnMs, trackingResult, + screenWakelockstatus ) } } diff --git a/packages/SystemUI/src/com/android/systemui/unfold/DisplaySwitchLatencyTracker.kt b/packages/SystemUI/src/com/android/systemui/unfold/DisplaySwitchLatencyTracker.kt index 66de52260b79..5800d5ed41c6 100644 --- a/packages/SystemUI/src/com/android/systemui/unfold/DisplaySwitchLatencyTracker.kt +++ b/packages/SystemUI/src/com/android/systemui/unfold/DisplaySwitchLatencyTracker.kt @@ -344,6 +344,8 @@ constructor( val onDrawnToOnScreenTurnedOnMs: Int = VALUE_UNKNOWN, val trackingResult: Int = SysUiStatsLog.DISPLAY_SWITCH_LATENCY_TRACKED__TRACKING_RESULT__UNKNOWN_RESULT, + val screenWakelockstatus: Int = + SysUiStatsLog.DISPLAY_SWITCH_LATENCY_TRACKED__SCREEN_WAKELOCK_STATUS__SCREEN_WAKELOCK_STATUS_UNKNOWN, ) enum class TrackingResult { diff --git a/packages/SystemUI/src/com/android/systemui/util/kotlin/Flow.kt b/packages/SystemUI/src/com/android/systemui/util/kotlin/Flow.kt index 735da46667c5..cc4307a67268 100644 --- a/packages/SystemUI/src/com/android/systemui/util/kotlin/Flow.kt +++ b/packages/SystemUI/src/com/android/systemui/util/kotlin/Flow.kt @@ -19,8 +19,11 @@ package com.android.systemui.util.kotlin import com.android.app.tracing.coroutines.launchTraced as launch import com.android.systemui.util.time.SystemClock import com.android.systemui.util.time.SystemClockImpl +import java.util.LinkedList import java.util.concurrent.atomic.AtomicReference import kotlin.math.max +import kotlin.time.Duration +import kotlin.time.Duration.Companion.milliseconds import kotlinx.coroutines.CoroutineStart import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -364,3 +367,58 @@ inline fun <T1, T2, T3, T4, T5, T6, T7, T8, T9, R> combine( */ @Suppress("NOTHING_TO_INLINE") inline fun Flow<Unit>.emitOnStart(): Flow<Unit> = onStart { emit(Unit) } + +/** + * Transforms a Flow<T> into a Flow<List<T>> by implementing a sliding window algorithm. + * + * This function creates a sliding window over the input Flow<T>. The window has a specified + * [windowDuration] and slides continuously as time progresses. The emitted List<T> contains all + * items from the input flow that fall within the current window. + * + * The window slides forward by the smallest possible increment to include or exclude *one* event + * based on the time the event was emitted (determined by the System.currentTimeMillis()). This + * means that consecutive emitted lists will have overlapping elements if the elements fall within + * the [windowDuration] + * + * @param windowDuration The duration of the sliding window. + * @return A Flow that emits Lists of elements within the current sliding window. + */ +fun <T> Flow<T>.slidingWindow( + windowDuration: Duration, + clock: SystemClock = SystemClockImpl(), +): Flow<List<T>> = channelFlow { + require(windowDuration.isPositive()) { "Window duration must be positive" } + val buffer = LinkedList<Pair<Duration, T>>() + + coroutineScope { + var windowAdvancementJob: Job? = null + + collect { value -> + windowAdvancementJob?.cancel() + val now = clock.currentTimeMillis().milliseconds + buffer.addLast(now to value) + + while (buffer.isNotEmpty() && buffer.first.first + windowDuration <= now) { + buffer.removeFirst() + } + send(buffer.map { it.second }) + + // Keep the window advancing through time even if the source flow isn't emitting + // anymore. We stop advancing the window as soon as there are no items left in the + // buffer. + windowAdvancementJob = launch { + while (buffer.isNotEmpty()) { + val startOfWindow = clock.currentTimeMillis().milliseconds - windowDuration + // Invariant: At this point, everything in the buffer is guaranteed to be in + // the window, as we removed expired items above. + val timeUntilNextOldest = + (buffer.first.first - startOfWindow).coerceAtLeast(0.milliseconds) + delay(timeUntilNextOldest) + // Remove the oldest item, as it has now fallen out of the window. + buffer.removeFirst() + send(buffer.map { it.second }) + } + } + } + } +} diff --git a/packages/SystemUI/src/com/android/systemui/volume/dialog/sliders/ui/viewmodel/VolumeDialogSliderViewModel.kt b/packages/SystemUI/src/com/android/systemui/volume/dialog/sliders/ui/viewmodel/VolumeDialogSliderViewModel.kt index 1f11f2da8340..f6aa189eb571 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/dialog/sliders/ui/viewmodel/VolumeDialogSliderViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/volume/dialog/sliders/ui/viewmodel/VolumeDialogSliderViewModel.kt @@ -40,7 +40,6 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.combine -import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.flatMapLatest @@ -78,11 +77,16 @@ constructor( private val userVolumeUpdates = MutableStateFlow<VolumeUpdate?>(null) private val model: Flow<VolumeDialogStreamModel> = - interactor.slider - .filter { - val currentVolumeUpdate = userVolumeUpdates.value ?: return@filter true + combine(interactor.slider, userVolumeUpdates) { model, currentVolumeUpdate -> + currentVolumeUpdate ?: return@combine model val lastVolumeUpdateTime = currentVolumeUpdate.timestampMillis - getTimestampMillis() - lastVolumeUpdateTime > VOLUME_UPDATE_GRACE_PERIOD + val shouldIgnoreUpdates = + getTimestampMillis() - lastVolumeUpdateTime < VOLUME_UPDATE_GRACE_PERIOD + if (shouldIgnoreUpdates) { + model.copy(level = currentVolumeUpdate.newVolumeLevel) + } else { + model + } } .stateIn(coroutineScope, SharingStarted.Eagerly, null) .filterNotNull() diff --git a/packages/SystemUI/tests/src/com/android/systemui/recents/LauncherProxyServiceTest.kt b/packages/SystemUI/tests/src/com/android/systemui/recents/LauncherProxyServiceTest.kt index e0118b18ff64..9b03833fd1b8 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/recents/LauncherProxyServiceTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/recents/LauncherProxyServiceTest.kt @@ -22,6 +22,7 @@ import android.content.pm.PackageManager import android.content.pm.ResolveInfo import android.os.PowerManager import android.os.UserManager +import android.platform.test.annotations.EnableFlags import android.testing.TestableContext import android.testing.TestableLooper import android.view.Display @@ -29,17 +30,23 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.internal.app.AssistUtils import com.android.internal.logging.UiEventLogger +import com.android.systemui.Flags import com.android.systemui.SysuiTestCase import com.android.systemui.broadcast.BroadcastDispatcher import com.android.systemui.dagger.qualifiers.Main +import com.android.systemui.display.data.repository.displayRepository import com.android.systemui.dump.DumpManager import com.android.systemui.keyguard.KeyguardUnlockAnimationController import com.android.systemui.keyguard.WakefulnessLifecycle import com.android.systemui.keyguard.ui.view.InWindowLauncherUnlockAnimationManager +import com.android.systemui.kosmos.testScope import com.android.systemui.log.assertLogsWtf +import com.android.systemui.model.fakeSysUIStatePerDisplayRepository import com.android.systemui.model.sysUiState +import com.android.systemui.model.sysUiStateFactory import com.android.systemui.navigationbar.NavigationBarController import com.android.systemui.navigationbar.NavigationModeController +import com.android.systemui.navigationbar.views.NavigationBar import com.android.systemui.process.ProcessWrapper import com.android.systemui.recents.LauncherProxyService.ACTION_QUICKSTEP import com.android.systemui.settings.FakeDisplayTracker @@ -56,18 +63,20 @@ import com.android.systemui.statusbar.NotificationShadeWindowController import com.android.systemui.testKosmos import com.android.systemui.unfold.progress.UnfoldTransitionProgressForwarder import com.android.systemui.util.mockito.mock -import com.android.systemui.util.mockito.whenever import com.android.systemui.util.time.FakeSystemClock import com.android.wm.shell.back.BackAnimation import com.android.wm.shell.sysui.ShellInterface import com.google.common.util.concurrent.MoreExecutors import java.util.Optional import java.util.concurrent.Executor +import kotlinx.coroutines.runBlocking +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.ArgumentMatchers +import org.mockito.ArgumentMatchers.anyLong import org.mockito.ArgumentMatchers.eq import org.mockito.Mock import org.mockito.Mockito.any @@ -81,6 +90,7 @@ import org.mockito.Mockito.times import org.mockito.Mockito.verify import org.mockito.Mockito.`when` import org.mockito.MockitoAnnotations +import org.mockito.kotlin.whenever @SmallTest @RunWith(AndroidJUnit4::class) @@ -96,8 +106,10 @@ class LauncherProxyServiceTest : SysuiTestCase() { private val displayTracker = FakeDisplayTracker(mContext) private val fakeSystemClock = FakeSystemClock() private val sysUiState = kosmos.sysUiState + private val sysUiStateFactory = kosmos.sysUiStateFactory private val wakefulnessLifecycle = WakefulnessLifecycle(mContext, null, fakeSystemClock, dumpManager) + private val sysuiStatePerDisplayRepository = kosmos.fakeSysUIStatePerDisplayRepository @Mock private lateinit var launcherProxy: ILauncherProxy.Stub @Mock private lateinit var packageManager: PackageManager @@ -149,6 +161,8 @@ class LauncherProxyServiceTest : SysuiTestCase() { // return isSystemUser as true by default. `when`(processWrapper.isSystemUser).thenReturn(true) + sysuiStatePerDisplayRepository.add(Display.DEFAULT_DISPLAY, sysUiState) + runBlocking { kosmos.displayRepository.apply { addDisplay(0) } } subject = createLauncherProxyService(context) } @@ -249,6 +263,48 @@ class LauncherProxyServiceTest : SysuiTestCase() { verify(spyContext, times(0)).bindServiceAsUser(any(), any(), anyInt(), any()) } + @Test + fun notifySysUiStateFlagsForAllDisplays_triggersUpdateInAllDisplays() = + kosmos.testScope.runTest { + kosmos.displayRepository.apply { + addDisplay(0) + addDisplay(1) + addDisplay(2) + } + kosmos.fakeSysUIStatePerDisplayRepository.apply { + add(1, sysUiStateFactory.create(1)) + add(2, sysUiStateFactory.create(2)) + } + clearInvocations(launcherProxy) + subject.notifySysUiStateFlagsForAllDisplays() + + verify(launcherProxy).onSystemUiStateChanged(anyLong(), eq(0)) + verify(launcherProxy).onSystemUiStateChanged(anyLong(), eq(1)) + verify(launcherProxy).onSystemUiStateChanged(anyLong(), eq(2)) + } + + @Test + @EnableFlags(Flags.FLAG_SHADE_WINDOW_GOES_AROUND) + fun updateSystemUiStateFlags_updatesAllNavBars() = + kosmos.testScope.runTest { + kosmos.displayRepository.apply { + addDisplay(0) + addDisplay(1) + } + kosmos.fakeSysUIStatePerDisplayRepository.apply { + add(1, sysUiStateFactory.create(1)) + } + val navBar0 = mock<NavigationBar>() + val navBar1 = mock<NavigationBar>() + whenever(navBarController.getNavigationBar(eq(0))).thenReturn(navBar0) + whenever(navBarController.getNavigationBar(eq(1))).thenReturn(navBar1) + + subject.updateSystemUiStateFlags() + + verify(navBar0).updateSystemUiStateFlags() + verify(navBar1).updateSystemUiStateFlags() + } + private fun createLauncherProxyService(ctx: Context): LauncherProxyService { return LauncherProxyService( ctx, @@ -260,7 +316,7 @@ class LauncherProxyServiceTest : SysuiTestCase() { screenPinningRequest, navModeController, statusBarWinController, - sysUiState, + kosmos.fakeSysUIStatePerDisplayRepository, mock(), mock(), userTracker, @@ -276,6 +332,7 @@ class LauncherProxyServiceTest : SysuiTestCase() { broadcastDispatcher, backAnimation, processWrapper, + kosmos.displayRepository, ) } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java index 00ee893e0e4d..2ea4e7f67b3c 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java @@ -180,6 +180,7 @@ public class ExpandableNotificationRowTest extends SysuiTestCase { } @Test + @DisableFlags(NotificationBundleUi.FLAG_NAME) public void testUpdateBackgroundColors_isRecursive() throws Exception { ExpandableNotificationRow group = mNotificationTestHelper.createGroup(); group.setTintColor(Color.RED); @@ -604,14 +605,14 @@ public class ExpandableNotificationRowTest extends SysuiTestCase { public void testGetIsNonblockable() throws Exception { ExpandableNotificationRow row = mNotificationTestHelper.createRow(mNotificationTestHelper.createNotification()); - row.setEntry(null); + row.setEntryLegacy(null); assertTrue(row.getIsNonblockable()); NotificationEntry entry = mock(NotificationEntry.class); Mockito.doReturn(false, true).when(entry).isBlockable(); - row.setEntry(entry); + row.setEntryLegacy(entry); assertTrue(row.getIsNonblockable()); assertFalse(row.getIsNonblockable()); } @@ -946,9 +947,13 @@ public class ExpandableNotificationRowTest extends SysuiTestCase { @Test @EnableFlags({PromotedNotificationUi.FLAG_NAME, PromotedNotificationUiForceExpanded.FLAG_NAME}) + @DisableFlags(NotificationBundleUi.FLAG_NAME) public void isExpanded_sensitivePromotedNotification_notExpanded() throws Exception { // GIVEN final ExpandableNotificationRow row = mNotificationTestHelper.createRow(); + NotificationEntry entry = mock(NotificationEntry.class); + when(entry.isPromotedOngoing()).thenReturn(true); + row.setEntryLegacy(entry); setRowPromotedOngoing(row); row.setSensitive(/* sensitive= */true, /* hideSensitive= */false); row.setHideSensitiveForIntrinsicHeight(/* hideSensitive= */true); @@ -959,9 +964,13 @@ public class ExpandableNotificationRowTest extends SysuiTestCase { @Test @EnableFlags({PromotedNotificationUi.FLAG_NAME, PromotedNotificationUiForceExpanded.FLAG_NAME}) + @DisableFlags(NotificationBundleUi.FLAG_NAME) public void isExpanded_promotedNotificationNotOnKeyguard_expanded() throws Exception { // GIVEN final ExpandableNotificationRow row = mNotificationTestHelper.createRow(); + NotificationEntry entry = mock(NotificationEntry.class); + when(entry.isPromotedOngoing()).thenReturn(true); + row.setEntryLegacy(entry); setRowPromotedOngoing(row); row.setOnKeyguard(false); @@ -971,9 +980,13 @@ public class ExpandableNotificationRowTest extends SysuiTestCase { @Test @EnableFlags({PromotedNotificationUi.FLAG_NAME, PromotedNotificationUiForceExpanded.FLAG_NAME}) + @DisableFlags(NotificationBundleUi.FLAG_NAME) public void isExpanded_promotedNotificationAllowOnKeyguard_expanded() throws Exception { // GIVEN final ExpandableNotificationRow row = mNotificationTestHelper.createRow(); + NotificationEntry entry = mock(NotificationEntry.class); + when(entry.isPromotedOngoing()).thenReturn(true); + row.setEntryLegacy(entry); setRowPromotedOngoing(row); row.setOnKeyguard(true); @@ -983,10 +996,14 @@ public class ExpandableNotificationRowTest extends SysuiTestCase { @Test @EnableFlags({PromotedNotificationUi.FLAG_NAME, PromotedNotificationUiForceExpanded.FLAG_NAME}) + @DisableFlags(NotificationBundleUi.FLAG_NAME) public void isExpanded_promotedNotificationIgnoreLockscreenConstraints_expanded() throws Exception { // GIVEN final ExpandableNotificationRow row = mNotificationTestHelper.createRow(); + NotificationEntry entry = mock(NotificationEntry.class); + when(entry.isPromotedOngoing()).thenReturn(true); + row.setEntryLegacy(entry); setRowPromotedOngoing(row); row.setOnKeyguard(true); row.setIgnoreLockscreenConstraints(true); @@ -1009,16 +1026,20 @@ public class ExpandableNotificationRowTest extends SysuiTestCase { entry); row.setEntryAdapter(entryAdapter); } else { - row.setEntry(entry); + row.setEntryLegacy(entry); } } @Test @EnableFlags({PromotedNotificationUi.FLAG_NAME, PromotedNotificationUiForceExpanded.FLAG_NAME}) + @DisableFlags(NotificationBundleUi.FLAG_NAME) public void isExpanded_promotedNotificationSaveSpaceOnLockScreen_notExpanded() throws Exception { // GIVEN final ExpandableNotificationRow row = mNotificationTestHelper.createRow(); + NotificationEntry entry = mock(NotificationEntry.class); + when(entry.isPromotedOngoing()).thenReturn(true); + row.setEntryLegacy(entry); setRowPromotedOngoing(row); row.setOnKeyguard(true); row.setSaveSpaceOnLockscreen(true); @@ -1029,10 +1050,14 @@ public class ExpandableNotificationRowTest extends SysuiTestCase { @Test @EnableFlags({PromotedNotificationUi.FLAG_NAME, PromotedNotificationUiForceExpanded.FLAG_NAME}) + @DisableFlags(NotificationBundleUi.FLAG_NAME) public void isExpanded_promotedNotificationNotSaveSpaceOnLockScreen_expanded() throws Exception { // GIVEN final ExpandableNotificationRow row = mNotificationTestHelper.createRow(); + NotificationEntry entry = mock(NotificationEntry.class); + when(entry.isPromotedOngoing()).thenReturn(true); + row.setEntryLegacy(entry); setRowPromotedOngoing(row); row.setOnKeyguard(true); row.setSaveSpaceOnLockscreen(false); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentViewTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentViewTest.kt index 5d7b3edc457b..cf8278eb8ac6 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentViewTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentViewTest.kt @@ -89,15 +89,17 @@ class NotificationContentViewTest : SysuiTestCase() { spy( when (NotificationBundleUi.isEnabled) { true -> { - ExpandableNotificationRow(mContext, /* attrs= */ null, UserHandle.CURRENT) - .apply { - entry = mockEntry - entryAdapter = mockEntryAdapter - } + ExpandableNotificationRow( + mContext, + /* attrs= */ null, + UserHandle.CURRENT + ).apply { + entryAdapter = mockEntryAdapter + } } false -> { ExpandableNotificationRow(mContext, /* attrs= */ null, mockEntry).apply { - entry = mockEntry + entryLegacy = mockEntry } } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java index ffb861db182c..063b546cbae9 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java @@ -296,6 +296,7 @@ public class ScrimControllerTest extends SysuiTestCase { mKosmos.getTestDispatcher(), mLinearLargeScreenShadeInterpolator, new BlurConfig(0.0f, 0.0f), + mContext, mKosmos::getWindowRootViewBlurInteractor); mScrimController.setScrimVisibleListener(visible -> mScrimVisibility = visible); mScrimController.attachViews(mScrimBehind, mNotificationsScrim, mScrimInFront); @@ -1247,6 +1248,7 @@ public class ScrimControllerTest extends SysuiTestCase { mKosmos.getTestDispatcher(), mLinearLargeScreenShadeInterpolator, new BlurConfig(0.0f, 0.0f), + mContext, mKosmos::getWindowRootViewBlurInteractor); mScrimController.setScrimVisibleListener(visible -> mScrimVisibility = visible); mScrimController.attachViews(mScrimBehind, mNotificationsScrim, mScrimInFront); diff --git a/packages/SystemUI/tests/src/com/android/systemui/util/kotlin/FlowUtilTests.kt b/packages/SystemUI/tests/src/com/android/systemui/util/kotlin/FlowUtilTests.kt index 9440280649dd..54ac3bf8220a 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/util/kotlin/FlowUtilTests.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/util/kotlin/FlowUtilTests.kt @@ -21,6 +21,7 @@ import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.util.time.FakeSystemClock import com.google.common.truth.Truth.assertThat +import kotlin.time.Duration.Companion.milliseconds import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.delay @@ -33,6 +34,7 @@ import kotlinx.coroutines.flow.filterIsInstance import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.merge +import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.takeWhile import kotlinx.coroutines.flow.toList import kotlinx.coroutines.launch @@ -50,11 +52,7 @@ import org.junit.runner.RunWith class PairwiseFlowTest : SysuiTestCase() { @Test fun simple() = runBlocking { - assertThatFlow((1..3).asFlow().pairwise()) - .emitsExactly( - WithPrev(1, 2), - WithPrev(2, 3), - ) + assertThatFlow((1..3).asFlow().pairwise()).emitsExactly(WithPrev(1, 2), WithPrev(2, 3)) } @Test fun notEnough() = runBlocking { assertThatFlow(flowOf(1).pairwise()).emitsNothing() } @@ -157,48 +155,27 @@ class SetChangesFlowTest : SysuiTestCase() { fun simple() = runBlocking { assertThatFlow(flowOf(setOf(1, 2, 3), setOf(2, 3, 4)).setChanges()) .emitsExactly( - SetChanges( - added = setOf(1, 2, 3), - removed = emptySet(), - ), - SetChanges( - added = setOf(4), - removed = setOf(1), - ), + SetChanges(added = setOf(1, 2, 3), removed = emptySet()), + SetChanges(added = setOf(4), removed = setOf(1)), ) } @Test fun onlyOneEmission() = runBlocking { assertThatFlow(flowOf(setOf(1)).setChanges()) - .emitsExactly( - SetChanges( - added = setOf(1), - removed = emptySet(), - ) - ) + .emitsExactly(SetChanges(added = setOf(1), removed = emptySet())) } @Test fun fromEmptySet() = runBlocking { assertThatFlow(flowOf(emptySet(), setOf(1, 2)).setChanges()) - .emitsExactly( - SetChanges( - removed = emptySet(), - added = setOf(1, 2), - ) - ) + .emitsExactly(SetChanges(removed = emptySet(), added = setOf(1, 2))) } @Test fun dontEmitFirstEvent() = runBlocking { assertThatFlow(flowOf(setOf(1, 2), setOf(2, 3)).setChanges(emitFirstEvent = false)) - .emitsExactly( - SetChanges( - removed = setOf(1), - added = setOf(3), - ) - ) + .emitsExactly(SetChanges(removed = setOf(1), added = setOf(3))) } } @@ -235,11 +212,7 @@ class SampleFlowTest : SysuiTestCase() { emit(4) } assertThatFlow(sampler.sample(samplee) { a, b -> a to b }) - .emitsExactly( - 2 to 1, - 3 to 3, - 4 to 3, - ) + .emitsExactly(2 to 1, 3 to 3, 4 to 3) } } @@ -419,10 +392,262 @@ class ThrottleFlowTest : SysuiTestCase() { } } +@SmallTest +@RunWith(AndroidJUnit4::class) +class SlidingWindowFlowTest : SysuiTestCase() { + + @Test + fun basicWindowing() = runTest { + val choreographer = createChoreographer(this) + val output = mutableListOf<List<Int>>() + val collectJob = + backgroundScope.launch { + (1..5) + .asFlow() + .onEach { delay(100) } + .slidingWindow(300.milliseconds, choreographer.fakeClock) + .toList(output) + } + + choreographer.advanceAndRun(0) + assertThat(output).isEmpty() + + choreographer.advanceAndRun(100) + assertThat(output).containsExactly(listOf(1)) + + choreographer.advanceAndRun(1) + assertThat(output).containsExactly(listOf(1)) + + choreographer.advanceAndRun(99) + assertThat(output).containsExactly(listOf(1), listOf(1, 2)) + + choreographer.advanceAndRun(100) + assertThat(output).containsExactly(listOf(1), listOf(1, 2), listOf(1, 2, 3)) + + choreographer.advanceAndRun(100) + assertThat(output) + .containsExactly(listOf(1), listOf(1, 2), listOf(1, 2, 3), listOf(2, 3, 4)) + + choreographer.advanceAndRun(100) + assertThat(output) + .containsExactly( + listOf(1), + listOf(1, 2), + listOf(1, 2, 3), + listOf(2, 3, 4), + listOf(3, 4, 5), + ) + + choreographer.advanceAndRun(100) + assertThat(output) + .containsExactly( + listOf(1), + listOf(1, 2), + listOf(1, 2, 3), + listOf(2, 3, 4), + listOf(3, 4, 5), + listOf(4, 5), + ) + + choreographer.advanceAndRun(100) + assertThat(output) + .containsExactly( + listOf(1), + listOf(1, 2), + listOf(1, 2, 3), + listOf(2, 3, 4), + listOf(3, 4, 5), + listOf(4, 5), + listOf(5), + ) + + choreographer.advanceAndRun(100) + assertThat(output) + .containsExactly( + listOf(1), + listOf(1, 2), + listOf(1, 2, 3), + listOf(2, 3, 4), + listOf(3, 4, 5), + listOf(4, 5), + listOf(5), + emptyList<Int>(), + ) + + // Verify no more emissions + choreographer.advanceAndRun(9999999999) + assertThat(output) + .containsExactly( + listOf(1), + listOf(1, 2), + listOf(1, 2, 3), + listOf(2, 3, 4), + listOf(3, 4, 5), + listOf(4, 5), + listOf(5), + emptyList<Int>(), + ) + + assertThat(collectJob.isCompleted).isTrue() + } + + @Test + fun initialEmptyFlow() = runTest { + val choreographer = createChoreographer(this) + val output = mutableListOf<List<Int>>() + val collectJob = + backgroundScope.launch { + flow { + delay(200) + emit(1) + } + .slidingWindow(100.milliseconds, choreographer.fakeClock) + .toList(output) + } + + choreographer.advanceAndRun(0) + assertThat(output).isEmpty() + + choreographer.advanceAndRun(200) + assertThat(output).containsExactly(listOf(1)) + + choreographer.advanceAndRun(100) + assertThat(output).containsExactly(listOf(1), emptyList<Int>()) + + assertThat(collectJob.isCompleted).isTrue() + } + + @Test + fun windowLargerThanData() = runTest { + val choreographer = createChoreographer(this) + val output = mutableListOf<List<Int>>() + val collectJob = + backgroundScope.launch { + (1..3) + .asFlow() + .onEach { delay(50) } + .slidingWindow(500.milliseconds, choreographer.fakeClock) + .toList(output) + } + + choreographer.advanceAndRun(0) + assertThat(output).isEmpty() + + choreographer.advanceAndRun(50) + assertThat(output).containsExactly(listOf(1)) + + choreographer.advanceAndRun(50) + assertThat(output).containsExactly(listOf(1), listOf(1, 2)) + + choreographer.advanceAndRun(50) + assertThat(output).containsExactly(listOf(1), listOf(1, 2), listOf(1, 2, 3)) + + // It has been 100ms since the first emission, which means we have 400ms left until the + // first item is evicted from the window. Ensure that we have no evictions until that time. + choreographer.advanceAndRun(399) + assertThat(output).containsExactly(listOf(1), listOf(1, 2), listOf(1, 2, 3)) + + choreographer.advanceAndRun(1) + assertThat(output).containsExactly(listOf(1), listOf(1, 2), listOf(1, 2, 3), listOf(2, 3)) + + choreographer.advanceAndRun(50) + assertThat(output) + .containsExactly(listOf(1), listOf(1, 2), listOf(1, 2, 3), listOf(2, 3), listOf(3)) + + choreographer.advanceAndRun(50) + assertThat(output) + .containsExactly( + listOf(1), + listOf(1, 2), + listOf(1, 2, 3), + listOf(2, 3), + listOf(3), + emptyList<Int>(), + ) + + assertThat(collectJob.isCompleted).isTrue() + } + + @Test + fun dataGapLargerThanWindow() = runTest { + val choreographer = createChoreographer(this) + val output = mutableListOf<List<Int>>() + val collectJob = + backgroundScope.launch { + flow { + emit(1) + delay(200) + emit(2) + delay(500) // Gap larger than window + emit(3) + } + .slidingWindow(300.milliseconds, choreographer.fakeClock) + .toList(output) + } + + choreographer.advanceAndRun(0) + assertThat(output).containsExactly(listOf(1)) + + choreographer.advanceAndRun(200) + assertThat(output).containsExactly(listOf(1), listOf(1, 2)) + + choreographer.advanceAndRun(100) + assertThat(output).containsExactly(listOf(1), listOf(1, 2), listOf(2)) + + choreographer.advanceAndRun(200) + assertThat(output).containsExactly(listOf(1), listOf(1, 2), listOf(2), emptyList<Int>()) + + choreographer.advanceAndRun(200) + assertThat(output) + .containsExactly(listOf(1), listOf(1, 2), listOf(2), emptyList<Int>(), listOf(3)) + + choreographer.advanceAndRun(300) + assertThat(output) + .containsExactly( + listOf(1), + listOf(1, 2), + listOf(2), + emptyList<Int>(), + listOf(3), + emptyList<Int>(), + ) + + assertThat(collectJob.isCompleted).isTrue() + } + + @Test + fun emptyFlow() = runTest { + val choreographer = createChoreographer(this) + val output = mutableListOf<List<Int>>() + + val collectJob = + backgroundScope.launch { + emptyFlow<Int>().slidingWindow(100.milliseconds).toList(output) + } + + choreographer.advanceAndRun(0) + assertThat(output).isEmpty() + + assertThat(collectJob.isCompleted).isTrue() + } + + private fun createChoreographer(testScope: TestScope) = + object { + val fakeClock = FakeSystemClock() + + fun advanceAndRun(millis: Long) { + fakeClock.advanceTime(millis) + testScope.advanceTimeBy(millis) + testScope.runCurrent() + } + } +} + private fun <T> assertThatFlow(flow: Flow<T>) = object { suspend fun emitsExactly(vararg emissions: T) = assertThat(flow.toList()).containsExactly(*emissions).inOrder() + suspend fun emitsNothing() = assertThat(flow.toList()).isEmpty() } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/SysuiTestCase.java b/packages/SystemUI/tests/utils/src/com/android/systemui/SysuiTestCase.java index e550e88b7bc7..15cb95a99967 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/SysuiTestCase.java +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/SysuiTestCase.java @@ -28,7 +28,6 @@ import android.os.MessageQueue; import android.os.ParcelFileDescriptor; import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.flag.junit.SetFlagsRule; -import android.platform.test.ravenwood.RavenwoodClassRule; import android.platform.test.ravenwood.RavenwoodRule; import android.test.mock.MockContext; import android.testing.DexmakerShareClassLoaderRule; @@ -93,23 +92,6 @@ public abstract class SysuiTestCase { public AndroidXAnimatorIsolationRule mAndroidXAnimatorIsolationRule = new AndroidXAnimatorIsolationRule(); - /** - * Rule that respects class-level annotations such as {@code @DisabledOnRavenwood} when tests - * are running on Ravenwood; on all other test environments this rule is a no-op passthrough. - */ - @ClassRule(order = Integer.MIN_VALUE + 1) - public static final RavenwoodClassRule sRavenwood = new RavenwoodClassRule(); - - /** - * Rule that defines and prepares the Ravenwood environment when tests are running on - * Ravenwood; on all other test environments this rule is a no-op passthrough. - */ - @Rule(order = Integer.MIN_VALUE + 1) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProcessApp() - .setProvideMainThread(true) - .build(); - @ClassRule public static final SetFlagsRule.ClassRule mSetFlagsClassRule = new SetFlagsRule.ClassRule( diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/model/SysUiStateKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/model/SysUiStateKosmos.kt index 11bd4c7b7940..54261c7f622b 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/model/SysUiStateKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/model/SysUiStateKosmos.kt @@ -38,7 +38,9 @@ val Kosmos.sysUiStateFactory by Fixture { } } -val Kosmos.fakeSysUIStatePerDisplayRepository by Fixture { FakePerDisplayRepository<SysUiState>() } +val Kosmos.fakeSysUIStatePerDisplayRepository by Fixture { + FakePerDisplayRepository<SysUiState>().apply { add(Display.DEFAULT_DISPLAY, sysUiState) } +} val Kosmos.sysuiStateInteractor by Fixture { SysUIStateDisplaysInteractor(fakeSysUIStatePerDisplayRepository, displayRepository) diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/collection/GroupEntryBuilder.java b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/collection/GroupEntryBuilder.java index 4efcada96a14..215df9d59ec9 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/collection/GroupEntryBuilder.java +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/collection/GroupEntryBuilder.java @@ -58,7 +58,7 @@ public class GroupEntryBuilder { return this; } - /** Sets the creation time. */ + /** Sets the creation time. Should be SystemClock.elapsedRealtime */ public GroupEntryBuilder setCreationTime(long creationTime) { mCreationTime = creationTime; return this; diff --git a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodEnablementChecker.java b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodEnablementChecker.java index 3cb2c67adf09..aa37d1221478 100644 --- a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodEnablementChecker.java +++ b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodEnablementChecker.java @@ -19,7 +19,6 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.annotations.EnabledOnRavenwood; -import android.platform.test.annotations.IgnoreUnderRavenwood; import org.junit.runner.Description; @@ -51,8 +50,6 @@ public class RavenwoodEnablementChecker { result = true; } else if (description.getAnnotation(DisabledOnRavenwood.class) != null) { result = false; - } else if (description.getAnnotation(IgnoreUnderRavenwood.class) != null) { - result = false; } if (result != null) { if (takeIntoAccountRunDisabledTestsFlag @@ -78,8 +75,6 @@ public class RavenwoodEnablementChecker { result = true; } else if (testClass.getAnnotation(DisabledOnRavenwood.class) != null) { result = false; - } else if (testClass.getAnnotation(IgnoreUnderRavenwood.class) != null) { - result = false; } if (!result) { if (takeIntoAccountRunDisabledTestsFlag diff --git a/ravenwood/junit-src/android/platform/test/annotations/IgnoreUnderRavenwood.java b/ravenwood/junit-src/android/platform/test/annotations/IgnoreUnderRavenwood.java deleted file mode 100644 index 1c06829dba06..000000000000 --- a/ravenwood/junit-src/android/platform/test/annotations/IgnoreUnderRavenwood.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2023 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - package android.platform.test.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Test methods marked with this annotation are quietly ignored when running under a Ravenwood test - * environment. The test continues to execute normally under all other non-Ravenwood test - * environments. - * - * This annotation only takes effect when the containing class has a {@code - * RavenwoodRule} configured. Ignoring is accomplished by throwing an {@code org.junit - * .AssumptionViolatedException} which test infrastructure treats as being ignored. - * - * Developers are encouraged to use either the {@code blockedBy} and/or {@code reason} arguments - * to document why a test is being ignored, to aid in future audits of tests that are candidates - * to be enabled. - * - * @hide - * - * @deprecated Use {@link DisabledOnRavenwood} instead. - */ -@Target({ElementType.METHOD, ElementType.TYPE}) -@Retention(RetentionPolicy.RUNTIME) -@Deprecated -public @interface IgnoreUnderRavenwood { - /** - * One or more classes that aren't yet supported by Ravenwood, which this test depends on. - */ - Class<?>[] blockedBy() default {}; - - /** - * General free-form description of why this test is being ignored. - */ - String reason() default ""; - - /** - * Tracking bug number, if any. - */ - long bug() default 0; -} diff --git a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodClassRule.java b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodClassRule.java deleted file mode 100644 index 85297fe96d6a..000000000000 --- a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodClassRule.java +++ /dev/null @@ -1,35 +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 android.platform.test.ravenwood; - -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; - -/** - * No longer needed. - * - * @deprecated this class used to be used to handle the class level annotation, which - * is now done by the test runner, so this class is not needed. - */ -@Deprecated -public class RavenwoodClassRule implements TestRule { - @Override - public Statement apply(Statement base, Description description) { - return base; - } -} diff --git a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java index ffe5f6c8c579..b0b4c68cf9e0 100644 --- a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java +++ b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java @@ -100,38 +100,6 @@ public final class RavenwoodRule implements TestRule { } /** - * @deprecated no longer used. We always use an app UID. - */ - @Deprecated - public Builder setProcessSystem() { - return this; - } - - /** - * @deprecated no longer used. We always use an app UID. - */ - @Deprecated - public Builder setProcessApp() { - return this; - } - - /** - * @deprecated no longer used. - */ - @Deprecated - public Builder setPackageName(@NonNull String packageName) { - return this; - } - - /** - * @deprecated no longer used. Main thread is always available. - */ - @Deprecated - public Builder setProvideMainThread(boolean provideMainThread) { - return this; - } - - /** * Configure the given system property as immutable for the duration of the test. * Read access to the key is allowed, and write access will fail. When {@code value} is * {@code null}, the value is left as undefined. @@ -163,28 +131,12 @@ public final class RavenwoodRule implements TestRule { return this; } - /** - * @deprecated no longer used. All supported services are available. - */ - @Deprecated - public Builder setServicesRequired(@NonNull Class<?>... services) { - return this; - } - public RavenwoodRule build() { return mRule; } } /** - * @deprecated replaced by {@link #isOnRavenwood()} - */ - @Deprecated - public static boolean isUnderRavenwood() { - return IS_ON_RAVENWOOD; - } - - /** * Return if the current process is running on a Ravenwood test environment. */ public static boolean isOnRavenwood() { @@ -197,26 +149,6 @@ public final class RavenwoodRule implements TestRule { } } - /** - * @deprecated Use - * {@code androidx.test.platform.app.InstrumentationRegistry.getInstrumentation().getContext()} - * instead. - */ - @Deprecated - public Context getContext() { - return InstrumentationRegistry.getInstrumentation().getContext(); - } - - /** - * @deprecated Use - * {@code androidx.test.platform.app.InstrumentationRegistry.getInstrumentation()} - * instead. - */ - @Deprecated - public Instrumentation getInstrumentation() { - return InstrumentationRegistry.getInstrumentation(); - } - @Override public Statement apply(Statement base, Description description) { if (!IS_ON_RAVENWOOD) { diff --git a/ravenwood/tests/bivalenttest/test/com/android/ravenwoodtest/bivalenttest/RavenwoodClassRuleDeviceOnlyTest.java b/ravenwood/tests/bivalenttest/test/com/android/ravenwoodtest/bivalenttest/RavenwoodClassRuleDeviceOnlyTest.java index e8f59db86901..da2777803a64 100644 --- a/ravenwood/tests/bivalenttest/test/com/android/ravenwoodtest/bivalenttest/RavenwoodClassRuleDeviceOnlyTest.java +++ b/ravenwood/tests/bivalenttest/test/com/android/ravenwoodtest/bivalenttest/RavenwoodClassRuleDeviceOnlyTest.java @@ -16,13 +16,11 @@ package com.android.ravenwoodtest.bivalenttest; import android.platform.test.annotations.DisabledOnRavenwood; -import android.platform.test.ravenwood.RavenwoodClassRule; import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Assert; -import org.junit.ClassRule; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,9 +31,6 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @DisabledOnRavenwood public class RavenwoodClassRuleDeviceOnlyTest { - @ClassRule - public static final RavenwoodClassRule sRavenwood = new RavenwoodClassRule(); - @Test public void testDeviceOnly() { Assert.assertFalse(RavenwoodRule.isOnRavenwood()); diff --git a/ravenwood/tests/minimum-test/test/com/android/ravenwoodtest/RavenwoodMinimumTest.java b/ravenwood/tests/minimum-test/test/com/android/ravenwoodtest/RavenwoodMinimumTest.java index b1a40f082656..09286259e7d9 100644 --- a/ravenwood/tests/minimum-test/test/com/android/ravenwoodtest/RavenwoodMinimumTest.java +++ b/ravenwood/tests/minimum-test/test/com/android/ravenwoodtest/RavenwoodMinimumTest.java @@ -15,7 +15,7 @@ */ package com.android.ravenwoodtest; -import android.platform.test.annotations.IgnoreUnderRavenwood; +import android.platform.test.annotations.DisabledOnRavenwood; import androidx.test.ext.junit.runners.AndroidJUnit4; @@ -37,7 +37,7 @@ public class RavenwoodMinimumTest { } @Test - @IgnoreUnderRavenwood + @DisabledOnRavenwood public void testIgnored() { throw new RuntimeException("Shouldn't be executed under ravenwood"); } diff --git a/ravenwood/tests/services-test/test/com/android/ravenwoodtest/servicestest/RavenwoodServicesDependenciesTest.java b/ravenwood/tests/services-test/test/com/android/ravenwoodtest/servicestest/RavenwoodServicesDependenciesTest.java index f833782bc8bb..2ff5dabcb277 100644 --- a/ravenwood/tests/services-test/test/com/android/ravenwoodtest/servicestest/RavenwoodServicesDependenciesTest.java +++ b/ravenwood/tests/services-test/test/com/android/ravenwoodtest/servicestest/RavenwoodServicesDependenciesTest.java @@ -18,37 +18,28 @@ package com.android.ravenwoodtest.servicestest; import static org.junit.Assert.assertEquals; -import android.platform.test.ravenwood.RavenwoodRule; import android.ravenwood.example.BlueManager; import android.ravenwood.example.RedManager; import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.platform.app.InstrumentationRegistry; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) public class RavenwoodServicesDependenciesTest { - // NOTE: we carefully only ask for RedManager here, and rely on Ravenwood internals to spin - // up the implicit dependency on BlueManager - @Rule - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProcessSystem() - .setServicesRequired(RedManager.class) - .build(); - @Test public void testDirect() { - final RedManager red = mRavenwood.getContext().getSystemService( - RedManager.class); + final RedManager red = InstrumentationRegistry.getInstrumentation().getContext() + .getSystemService(RedManager.class); assertEquals("blue+red", red.getInterfaceDescriptor()); } @Test public void testIndirect() { - final BlueManager blue = mRavenwood.getContext().getSystemService( - BlueManager.class); + final BlueManager blue = InstrumentationRegistry.getInstrumentation().getContext() + .getSystemService(BlueManager.class); assertEquals("blue", blue.getInterfaceDescriptor()); } } diff --git a/services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickController.java b/services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickController.java index 23166a800245..84158cf911ad 100644 --- a/services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickController.java +++ b/services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickController.java @@ -24,6 +24,7 @@ import static android.view.accessibility.AccessibilityManager.AUTOCLICK_IGNORE_M import static android.view.accessibility.AccessibilityManager.AUTOCLICK_REVERT_TO_LEFT_CLICK_DEFAULT; import static com.android.server.accessibility.autoclick.AutoclickIndicatorView.SHOW_INDICATOR_DELAY_TIME; +import static com.android.server.accessibility.autoclick.AutoclickTypePanel.AUTOCLICK_TYPE_DOUBLE_CLICK; import static com.android.server.accessibility.autoclick.AutoclickTypePanel.AUTOCLICK_TYPE_LEFT_CLICK; import static com.android.server.accessibility.autoclick.AutoclickTypePanel.AUTOCLICK_TYPE_RIGHT_CLICK; import static com.android.server.accessibility.autoclick.AutoclickTypePanel.AUTOCLICK_TYPE_SCROLL; @@ -45,6 +46,7 @@ import android.view.KeyEvent; import android.view.MotionEvent; import android.view.MotionEvent.PointerCoords; import android.view.MotionEvent.PointerProperties; +import android.view.ViewConfiguration; import android.view.WindowManager; import androidx.annotation.VisibleForTesting; @@ -799,7 +801,7 @@ public class AutoclickController extends BaseEventStreamTransformation { final long now = SystemClock.uptimeMillis(); - int actionButton; + int actionButton = BUTTON_PRIMARY; if (mHoveredState) { // Always triggers left-click when the cursor hovers over the autoclick type // panel, to always allow users to change a different click type. Otherwise, if @@ -807,15 +809,32 @@ public class AutoclickController extends BaseEventStreamTransformation { // select other click types. actionButton = BUTTON_PRIMARY; } else { - actionButton = mActiveClickType == AUTOCLICK_TYPE_RIGHT_CLICK - ? BUTTON_SECONDARY - : BUTTON_PRIMARY; + switch (mActiveClickType) { + case AUTOCLICK_TYPE_LEFT_CLICK: + actionButton = BUTTON_PRIMARY; + break; + case AUTOCLICK_TYPE_RIGHT_CLICK: + actionButton = BUTTON_SECONDARY; + break; + case AUTOCLICK_TYPE_DOUBLE_CLICK: + actionButton = BUTTON_PRIMARY; + long doubleTapMinimumTimeout = ViewConfiguration.getDoubleTapMinTime(); + sendMotionEvent(actionButton, now); + sendMotionEvent(actionButton, now + doubleTapMinimumTimeout); + return; + default: + break; + } } + sendMotionEvent(actionButton, now); + } + + private void sendMotionEvent(int actionButton, long eventTime) { MotionEvent downEvent = MotionEvent.obtain( - /* downTime= */ now, - /* eventTime= */ now, + /* downTime= */ eventTime, + /* eventTime= */ eventTime, MotionEvent.ACTION_DOWN, /* pointerCount= */ 1, mTempPointerProperties, diff --git a/services/companion/java/com/android/server/companion/virtual/SensorController.java b/services/companion/java/com/android/server/companion/virtual/SensorController.java index 88b791046c87..6e098d014ee3 100644 --- a/services/companion/java/com/android/server/companion/virtual/SensorController.java +++ b/services/companion/java/com/android/server/companion/virtual/SensorController.java @@ -21,15 +21,18 @@ import android.annotation.Nullable; import android.companion.virtual.IVirtualDevice; import android.companion.virtual.sensor.IVirtualSensorCallback; import android.companion.virtual.sensor.VirtualSensor; +import android.companion.virtual.sensor.VirtualSensorAdditionalInfo; import android.companion.virtual.sensor.VirtualSensorConfig; import android.companion.virtual.sensor.VirtualSensorEvent; import android.content.AttributionSource; +import android.hardware.SensorAdditionalInfo; import android.hardware.SensorDirectChannel; import android.os.Binder; import android.os.IBinder; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.os.SharedMemory; +import android.os.SystemClock; import android.util.ArrayMap; import android.util.Slog; import android.util.SparseArray; @@ -140,7 +143,7 @@ public class SensorController { final IBinder sensorToken = new Binder("android.hardware.sensor.VirtualSensor:" + config.getName()); VirtualSensor sensor = new VirtualSensor(handle, config.getType(), config.getName(), - virtualDevice, sensorToken); + config.getFlags(), virtualDevice, sensorToken); synchronized (mLock) { mSensorDescriptors.put(sensorToken, sensorDescriptor); mVirtualSensors.put(handle, sensor); @@ -164,6 +167,37 @@ public class SensorController { } } + boolean sendSensorAdditionalInfo(@NonNull IBinder token, + @NonNull VirtualSensorAdditionalInfo info) { + Objects.requireNonNull(token); + Objects.requireNonNull(info); + synchronized (mLock) { + final SensorDescriptor sensorDescriptor = mSensorDescriptors.get(token); + long timestamp = SystemClock.elapsedRealtimeNanos(); + if (sensorDescriptor == null) { + throw new IllegalArgumentException("Could not send sensor event for given token"); + } + if (!mSensorManagerInternal.sendSensorAdditionalInfo( + sensorDescriptor.getHandle(), SensorAdditionalInfo.TYPE_FRAME_BEGIN, + /* serial= */ 0, timestamp++, /* values= */ null)) { + return false; + } + for (int i = 0; i < info.getValues().size(); ++i) { + if (!mSensorManagerInternal.sendSensorAdditionalInfo( + sensorDescriptor.getHandle(), info.getType(), /* serial= */ i, + timestamp++, info.getValues().get(i))) { + return false; + } + } + if (!mSensorManagerInternal.sendSensorAdditionalInfo( + sensorDescriptor.getHandle(), SensorAdditionalInfo.TYPE_FRAME_END, + /* serial= */ 0, timestamp, /* values= */ null)) { + return false; + } + } + return true; + } + @Nullable VirtualSensor getSensorByHandle(int handle) { synchronized (mLock) { 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 28efdfc01ee2..0023b6d53837 100644 --- a/services/companion/java/com/android/server/companion/virtual/VirtualDeviceImpl.java +++ b/services/companion/java/com/android/server/companion/virtual/VirtualDeviceImpl.java @@ -55,6 +55,7 @@ import android.companion.virtual.audio.IAudioConfigChangedCallback; import android.companion.virtual.audio.IAudioRoutingCallback; import android.companion.virtual.camera.VirtualCameraConfig; import android.companion.virtual.sensor.VirtualSensor; +import android.companion.virtual.sensor.VirtualSensorAdditionalInfo; import android.companion.virtual.sensor.VirtualSensorEvent; import android.companion.virtualdevice.flags.Flags; import android.compat.annotation.ChangeId; @@ -1294,6 +1295,18 @@ final class VirtualDeviceImpl extends IVirtualDevice.Stub } @Override // Binder call + public boolean sendSensorAdditionalInfo(@NonNull IBinder token, + @NonNull VirtualSensorAdditionalInfo info) { + checkCallerIsDeviceOwner(); + final long ident = Binder.clearCallingIdentity(); + try { + return mSensorController.sendSensorAdditionalInfo(token, info); + } finally { + Binder.restoreCallingIdentity(ident); + } + } + + @Override // Binder call public void registerIntentInterceptor(IVirtualDeviceIntentInterceptor intentInterceptor, IntentFilter filter) { checkCallerIsDeviceOwner(); diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index b75b7ddf8181..76dd6a504d8c 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -2816,10 +2816,11 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { if (!checkNotifyPermission("notifyEmergencyNumberList()")) { return; } - if (!mContext.getPackageManager().hasSystemFeature( - PackageManager.FEATURE_TELEPHONY_CALLING)) { + if (!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY_CALLING) + && !mContext.getPackageManager() + .hasSystemFeature(PackageManager.FEATURE_TELEPHONY_MESSAGING)) { // TelephonyManager.getEmergencyNumberList() throws an exception if - // FEATURE_TELEPHONY_CALLING is not defined. + // FEATURE_TELEPHONY_CALLING or FEATURE_TELEPHONY_MESSAGING is not defined. return; } diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 76ba0054583b..ce5a12179d44 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -2004,7 +2004,7 @@ public class ActivityManagerService extends IActivityManager.Stub new IAppOpsCallback.Stub() { @Override public void opChanged(int op, int uid, String packageName, String persistentDeviceId) { - if (op == AppOpsManager.OP_RUN_IN_BACKGROUND && packageName != null) { + if (op == AppOpsManager.OP_RUN_IN_BACKGROUND && uid >= 0) { if (getAppOpsManager().checkOpNoThrow(op, uid, packageName) != AppOpsManager.MODE_ALLOWED) { runInBackgroundDisabled(uid); diff --git a/services/core/java/com/android/server/am/AppPermissionTracker.java b/services/core/java/com/android/server/am/AppPermissionTracker.java index a47beae1d9cb..800e2b2d9657 100644 --- a/services/core/java/com/android/server/am/AppPermissionTracker.java +++ b/services/core/java/com/android/server/am/AppPermissionTracker.java @@ -394,6 +394,7 @@ final class AppPermissionTracker extends BaseAppStateTracker<AppPermissionPolicy private class MyAppOpsCallback extends IAppOpsCallback.Stub { @Override public void opChanged(int op, int uid, String packageName, String persistentDeviceId) { + if (uid < 0) return; mHandler.obtainMessage(MyHandler.MSG_APPOPS_CHANGED, op, uid, packageName) .sendToTarget(); } diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java index fb33cb1ff8c0..286c4cd709b1 100644 --- a/services/core/java/com/android/server/appop/AppOpsService.java +++ b/services/core/java/com/android/server/appop/AppOpsService.java @@ -822,7 +822,8 @@ public class AppOpsService extends IAppOpsService.Stub { @Override public void onOpModeChanged(int op, int uid, String packageName, String persistentDeviceId) throws RemoteException { - mCallback.opChanged(op, uid, packageName, persistentDeviceId); + mCallback.opChanged(op, uid, packageName != null ? packageName : "", + Objects.requireNonNull(persistentDeviceId)); } } @@ -1059,7 +1060,7 @@ public class AppOpsService extends IAppOpsService.Stub { if (Flags.enableAllSqliteAppopsAccesses()) { mHistoricalRegistry = new HistoricalRegistrySql(context); } else { - mHistoricalRegistry = new HistoricalRegistry(this, context); + mHistoricalRegistry = new LegacyHistoricalRegistry(this, context); } } @@ -7011,7 +7012,8 @@ public class AppOpsService extends IAppOpsService.Stub { mHistoricalRegistry = new HistoricalRegistrySql( (HistoricalRegistrySql) mHistoricalRegistry); } else { - mHistoricalRegistry = new HistoricalRegistry((HistoricalRegistry) mHistoricalRegistry); + mHistoricalRegistry = new LegacyHistoricalRegistry( + (LegacyHistoricalRegistry) mHistoricalRegistry); } mHistoricalRegistry.systemReady(mContext.getContentResolver()); diff --git a/services/core/java/com/android/server/appop/DiscreteOpsRegistry.java b/services/core/java/com/android/server/appop/DiscreteOpsRegistry.java index 70b7016fbb90..3867cbe1e98b 100644 --- a/services/core/java/com/android/server/appop/DiscreteOpsRegistry.java +++ b/services/core/java/com/android/server/appop/DiscreteOpsRegistry.java @@ -82,9 +82,8 @@ import java.util.Set; * INITIALIZATION: We can initialize persistence only after the system is ready * as we need to check the optional configuration override from the settings * database which is not initialized at the time the app ops service is created. This class - * relies on {@link HistoricalRegistry} for controlling that no calls are allowed until then. All - * outside calls are going through {@link HistoricalRegistry}. - * + * relies on {@link LegacyHistoricalRegistry} for controlling that no calls are allowed until then. + * All outside calls are going through {@link LegacyHistoricalRegistry}. */ abstract class DiscreteOpsRegistry { private static final String TAG = DiscreteOpsRegistry.class.getSimpleName(); diff --git a/services/core/java/com/android/server/appop/DiscreteOpsXmlRegistry.java b/services/core/java/com/android/server/appop/DiscreteOpsXmlRegistry.java index 20706b659ffb..771df19ec906 100644 --- a/services/core/java/com/android/server/appop/DiscreteOpsXmlRegistry.java +++ b/services/core/java/com/android/server/appop/DiscreteOpsXmlRegistry.java @@ -81,7 +81,7 @@ import java.util.Set; * THREADING AND LOCKING: * For in-memory transactions this class relies on {@link DiscreteOpsXmlRegistry#mInMemoryLock}. * It is assumed that the same lock is used for in-memory transactions in {@link AppOpsService}, - * {@link HistoricalRegistry}, and {@link DiscreteOpsXmlRegistry }. + * {@link LegacyHistoricalRegistry}, and {@link DiscreteOpsXmlRegistry }. * {@link DiscreteOpsRegistry#recordDiscreteAccess} must only be called while holding this lock. * {@link DiscreteOpsXmlRegistry#mOnDiskLock} is used when disk transactions are performed. * It is very important to release {@link DiscreteOpsXmlRegistry#mInMemoryLock} as soon as diff --git a/services/core/java/com/android/server/appop/HistoricalRegistry.java b/services/core/java/com/android/server/appop/LegacyHistoricalRegistry.java index a8128dd11cfe..f4f5775bbced 100644 --- a/services/core/java/com/android/server/appop/HistoricalRegistry.java +++ b/services/core/java/com/android/server/appop/LegacyHistoricalRegistry.java @@ -128,11 +128,11 @@ import java.util.concurrent.TimeUnit; */ // TODO (bug:122218838): Make sure we handle start of epoch time // TODO (bug:122218838): Validate changed time is handled correctly -final class HistoricalRegistry implements HistoricalRegistryInterface { +final class LegacyHistoricalRegistry implements HistoricalRegistryInterface { private static final boolean DEBUG = false; private static final boolean KEEP_WTF_LOG = Build.IS_DEBUGGABLE; - private static final String LOG_TAG = HistoricalRegistry.class.getSimpleName(); + private static final String LOG_TAG = LegacyHistoricalRegistry.class.getSimpleName(); private static final String PARAMETER_DELIMITER = ","; private static final String PARAMETER_ASSIGNMENT = "="; @@ -200,7 +200,7 @@ final class HistoricalRegistry implements HistoricalRegistryInterface { private final Context mContext; - HistoricalRegistry(@NonNull Object lock, Context context) { + LegacyHistoricalRegistry(@NonNull Object lock, Context context) { mInMemoryLock = lock; mContext = context; if (Flags.enableSqliteAppopsAccesses()) { @@ -210,7 +210,7 @@ final class HistoricalRegistry implements HistoricalRegistryInterface { } } - HistoricalRegistry(@NonNull HistoricalRegistry other) { + LegacyHistoricalRegistry(@NonNull LegacyHistoricalRegistry other) { this(other.mInMemoryLock, other.mContext); mMode = other.mMode; mBaseSnapshotInterval = other.mBaseSnapshotInterval; @@ -313,9 +313,9 @@ final class HistoricalRegistry implements HistoricalRegistryInterface { final int mode = AppOpsManager.parseHistoricalMode(modeValue); final long baseSnapshotInterval = Long.parseLong(baseSnapshotIntervalValue); final int intervalCompressionMultiplier = Integer.parseInt(intervalMultiplierValue); - setHistoryParameters(mode, baseSnapshotInterval,intervalCompressionMultiplier); + setHistoryParameters(mode, baseSnapshotInterval, intervalCompressionMultiplier); return; - } catch (NumberFormatException ignored) {} + } catch (NumberFormatException ignored) { } } Slog.w(LOG_TAG, "Bad value for" + Settings.Global.APPOP_HISTORY_PARAMETERS + "=" + setting + " resetting!"); @@ -805,7 +805,7 @@ final class HistoricalRegistry implements HistoricalRegistryInterface { private void schedulePersistHistoricalOpsMLocked(@NonNull HistoricalOps ops) { final Message message = PooledLambda.obtainMessage( - HistoricalRegistry::persistPendingHistory, HistoricalRegistry.this); + LegacyHistoricalRegistry::persistPendingHistory, LegacyHistoricalRegistry.this); message.what = MSG_WRITE_PENDING_HISTORY; IoThread.getHandler().sendMessage(message); mPendingWrites.offerFirst(ops); @@ -813,7 +813,7 @@ final class HistoricalRegistry implements HistoricalRegistryInterface { private static void makeRelativeToEpochStart(@NonNull HistoricalOps ops, long nowMillis) { ops.setBeginAndEndTime(nowMillis - ops.getEndTimeMillis(), - nowMillis- ops.getBeginTimeMillis()); + nowMillis - ops.getBeginTimeMillis()); } private void pruneFutureOps(@NonNull List<HistoricalOps> ops) { @@ -979,7 +979,7 @@ final class HistoricalRegistry implements HistoricalRegistryInterface { final HistoricalOps readOp = readOps.get(i); currentOps.merge(readOp); } - } + } } private @Nullable LinkedList<HistoricalOps> collectHistoricalOpsBaseDLocked(int filterUid, @@ -1125,7 +1125,7 @@ final class HistoricalRegistry implements HistoricalRegistryInterface { if (existingOpCount > 0) { // Compute elapsed time final long elapsedTimeMillis = passedOps.get(passedOps.size() - 1) - .getEndTimeMillis(); + .getEndTimeMillis(); for (int i = 0; i < existingOpCount; i++) { final HistoricalOps existingOp = existingOps.get(i); existingOp.offsetBeginAndEndTime(elapsedTimeMillis); diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index d917bffa06e9..bf7f1946531c 100644 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -32,7 +32,6 @@ import static android.Manifest.permission.QUERY_AUDIO_STATE; import static android.Manifest.permission.WRITE_SETTINGS; import static android.app.BroadcastOptions.DELIVERY_GROUP_POLICY_MOST_RECENT; import static android.content.Intent.ACTION_PACKAGE_ADDED; -import static android.content.Intent.ACTION_PACKAGE_REMOVED; import static android.content.Intent.EXTRA_ARCHIVAL; import static android.content.Intent.EXTRA_REPLACING; import static android.media.AudioDeviceInfo.TYPE_BLUETOOTH_A2DP; @@ -3336,11 +3335,25 @@ public class AudioService extends IAudioService.Stub } private int rescaleIndex(int index, int srcStream, int dstStream) { - return rescaleIndex(index, - getVssForStreamOrDefault(srcStream).getMinIndex(), - getVssForStreamOrDefault(srcStream).getMaxIndex(), - getVssForStreamOrDefault(dstStream).getMinIndex(), - getVssForStreamOrDefault(dstStream).getMaxIndex()); + final VolumeStreamState srcVss = getVssForStreamOrDefault(srcStream); + final VolumeStreamState dstVss = getVssForStreamOrDefault(dstStream); + int newIndex = rescaleIndex(index, srcVss.getMinIndex(), srcVss.getMaxIndex(), + dstVss.getMinIndex(), dstVss.getMaxIndex()); + // only apply solution for DTMF stream to make sure that it is not muted when + // re-aliasing to voice call stream. With ringMyCar flag enabled this will be + // automatically solved since we are sending the mute state to APM + // TODO(b/402542630): revisit stream aliasing logic with different min index + // values / mute states + if (!ringMyCar() && dstStream == AudioSystem.STREAM_DTMF + && srcStream == AudioSystem.STREAM_VOICE_CALL + && srcVss.getMinIndex() > dstVss.getMinIndex()) { + newIndex += srcVss.getMinIndex() - dstVss.getMinIndex(); + if (newIndex > dstVss.getMaxIndex()) { + newIndex = dstVss.getMaxIndex(); + } + } + + return newIndex; } private int rescaleIndex(int index, int srcMin, int srcMax, int dstMin, int dstMax) { @@ -12929,11 +12942,12 @@ public class AudioService extends IAudioService.Stub ); audioPolicy.registerOnStartTask(() -> { provider.onServiceStart(audioPolicy.getPermissionController()); + sLifecycleLogger.enqueue(new EventLogger.StringEvent( + "Controller start task complete").printLog(ALOGI, TAG)); }); IntentFilter packageUpdateFilter = new IntentFilter(); packageUpdateFilter.addAction(ACTION_PACKAGE_ADDED); - packageUpdateFilter.addAction(ACTION_PACKAGE_REMOVED); packageUpdateFilter.addDataScheme("package"); context.registerReceiverForAllUsers(new BroadcastReceiver() { @@ -12947,9 +12961,6 @@ public class AudioService extends IAudioService.Stub if (ACTION_PACKAGE_ADDED.equals(action)) { audioserverExecutor.execute(() -> provider.onModifyPackageState(uid, pkgName, false /* isRemoved */)); - } else if (ACTION_PACKAGE_REMOVED.equals(action)) { - audioserverExecutor.execute(() -> - provider.onModifyPackageState(uid, pkgName, true /* isRemoved */)); } } }, packageUpdateFilter, null, null); // main thread is fine, since dispatch on executor diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java index ac0892b92646..aa985907071f 100644 --- a/services/core/java/com/android/server/connectivity/Vpn.java +++ b/services/core/java/com/android/server/connectivity/Vpn.java @@ -1113,7 +1113,11 @@ public class Vpn { } // Remove always-on VPN if it's not supported. if (!isAlwaysOnPackageSupported(alwaysOnPackage)) { - setAlwaysOnPackage(null, false, null); + // Do not remove the always-on setting due to the restricted ability in safe mode. + // The always-on VPN can then start after the device reboots to normal mode. + if (!mContext.getPackageManager().isSafeMode()) { + setAlwaysOnPackage(null, false, null); + } return false; } // Skip if the service is already established. This isn't bulletproof: it's not bound 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 7cc178d5ff6c..f5228df3b8b2 100644 --- a/services/core/java/com/android/server/display/feature/DisplayManagerFlags.java +++ b/services/core/java/com/android/server/display/feature/DisplayManagerFlags.java @@ -280,6 +280,11 @@ public class DisplayManagerFlags { Flags::committedStateSeparateEvent ); + private final FlagState mSeparateTimeouts = new FlagState( + Flags.FLAG_SEPARATE_TIMEOUTS, + Flags::separateTimeouts + ); + private final FlagState mDelayImplicitRrRegistrationUntilRrAccessed = new FlagState( Flags.FLAG_DELAY_IMPLICIT_RR_REGISTRATION_UNTIL_RR_ACCESSED, Flags::delayImplicitRrRegistrationUntilRrAccessed @@ -608,6 +613,14 @@ public class DisplayManagerFlags { } /** + * @return {@code true} if the flag for having a separate timeouts for power groups + * is enabled + */ + public boolean isSeparateTimeoutsEnabled() { + return mSeparateTimeouts.isEnabled(); + } + + /** * @return {@code true} if the flag for only explicit subscription for RR changes is enabled */ public boolean isDelayImplicitRrRegistrationUntilRrAccessedEnabled() { @@ -671,6 +684,7 @@ public class DisplayManagerFlags { pw.println(" " + mFramerateOverrideTriggersRrCallbacks); pw.println(" " + mRefreshRateEventForForegroundApps); pw.println(" " + mCommittedStateSeparateEvent); + pw.println(" " + mSeparateTimeouts); pw.println(" " + mDelayImplicitRrRegistrationUntilRrAccessed); } 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 a0064a9f5d1d..007646f6a605 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 @@ -509,6 +509,14 @@ flag { } } + +flag { + name: "separate_timeouts" + namespace: "lse_desktop_experience" + description: "Allow separate timeouts for different power groups" + bug: "402356291" +} + flag { name: "delay_implicit_rr_registration_until_rr_accessed" namespace: "display_manager" diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index 23757757e336..fde9165a84c6 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -5669,11 +5669,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. LocalServices.addService(InputMethodManagerInternal.class, mInputMethodManagerInternal); } - // TODO(b/352228316): Remove it once IMMIProxy is removed. - InputMethodManagerInternal getLocalService(){ - return mInputMethodManagerInternal; - } - private final class LocalServiceImpl extends InputMethodManagerInternal { @ImfLockFree diff --git a/services/core/java/com/android/server/location/gnss/GnssManagerService.java b/services/core/java/com/android/server/location/gnss/GnssManagerService.java index 6a72cc7c7779..7d9f2c29f943 100644 --- a/services/core/java/com/android/server/location/gnss/GnssManagerService.java +++ b/services/core/java/com/android/server/location/gnss/GnssManagerService.java @@ -24,6 +24,7 @@ import android.hardware.location.GeofenceHardware; import android.hardware.location.GeofenceHardwareImpl; import android.location.FusedBatchOptions; import android.location.GnssAntennaInfo; +import android.location.GnssAssistance; import android.location.GnssCapabilities; import android.location.GnssMeasurementCorrections; import android.location.GnssMeasurementRequest; @@ -35,6 +36,8 @@ import android.location.IGnssStatusListener; import android.location.IGpsGeofenceHardware; import android.location.Location; import android.location.LocationManager; +import android.location.flags.Flags; +import android.location.provider.IGnssAssistanceCallback; import android.location.util.identity.CallerIdentity; import android.os.BatteryStats; import android.os.Binder; @@ -47,12 +50,13 @@ import com.android.internal.app.IBatteryStats; import com.android.server.FgThread; import com.android.server.location.gnss.hal.GnssNative; import com.android.server.location.injector.Injector; +import com.android.server.location.provider.proxy.ProxyGnssAssistanceProvider; import java.io.FileDescriptor; import java.util.List; /** Manages Gnss providers and related Gnss functions for LocationManagerService. */ -public class GnssManagerService { +public class GnssManagerService implements GnssNative.GnssAssistanceCallbacks { public static final String TAG = "GnssManager"; public static final boolean D = Log.isLoggable(TAG, Log.DEBUG); @@ -75,6 +79,8 @@ public class GnssManagerService { private final GnssMetrics mGnssMetrics; + private @Nullable ProxyGnssAssistanceProvider mProxyGnssAssistanceProvider = null; + public GnssManagerService(Context context, Injector injector, GnssNative gnssNative) { mContext = context.createAttributionContext(ATTRIBUTION_ID); mGnssNative = gnssNative; @@ -100,6 +106,16 @@ public class GnssManagerService { /** Called when system is ready. */ public void onSystemReady() { mGnssLocationProvider.onSystemReady(); + + if (Flags.gnssAssistanceInterfaceJni()) { + mProxyGnssAssistanceProvider = + ProxyGnssAssistanceProvider.createAndRegister(mContext); + if (mProxyGnssAssistanceProvider == null) { + Log.e(TAG, "no gnss assistance provider found"); + } else { + mGnssNative.setGnssAssistanceCallbacks(this); + } + } } /** Retrieve the GnssLocationProvider. */ @@ -323,6 +339,29 @@ public class GnssManagerService { } } + @Override + public void onRequestGnssAssistanceInject() { + if (!Flags.gnssAssistanceInterfaceJni()) { + return; + } + if (mProxyGnssAssistanceProvider == null) { + Log.e(TAG, "ProxyGnssAssistanceProvider is null"); + return; + } + mProxyGnssAssistanceProvider.request(new IGnssAssistanceCallback.Stub() { + @Override + public void onError() { + Log.e(TAG, "GnssAssistanceCallback.onError"); + } + + @Override + public void onResult(GnssAssistance gnssAssistance) { + Log.d(TAG, "GnssAssistanceCallback.onResult"); + mGnssNative.injectGnssAssistance(gnssAssistance); + } + }); + } + private class GnssCapabilitiesHalModule implements GnssNative.BaseCallbacks { GnssCapabilitiesHalModule(GnssNative gnssNative) { diff --git a/services/core/java/com/android/server/location/gnss/hal/GnssNative.java b/services/core/java/com/android/server/location/gnss/hal/GnssNative.java index c79a21a7eea8..7b4c56334868 100644 --- a/services/core/java/com/android/server/location/gnss/hal/GnssNative.java +++ b/services/core/java/com/android/server/location/gnss/hal/GnssNative.java @@ -23,6 +23,7 @@ import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.location.GnssAntennaInfo; +import android.location.GnssAssistance; import android.location.GnssCapabilities; import android.location.GnssMeasurementCorrections; import android.location.GnssMeasurementsEvent; @@ -30,6 +31,7 @@ import android.location.GnssNavigationMessage; import android.location.GnssSignalType; import android.location.GnssStatus; import android.location.Location; +import android.location.flags.Flags; import android.os.Binder; import android.os.Handler; import android.os.SystemClock; @@ -275,6 +277,12 @@ public class GnssNative { void onRequestPsdsDownload(int psdsType); } + /** Callbacks for HAL requesting GNSS assistance. */ + public interface GnssAssistanceCallbacks { + /** On request GnssAssistance injection. */ + void onRequestGnssAssistanceInject(); + } + /** Callbacks for AGPS functionality. */ public interface AGpsCallbacks { @@ -400,6 +408,7 @@ public class GnssNative { private TimeCallbacks mTimeCallbacks; private LocationRequestCallbacks mLocationRequestCallbacks; private PsdsCallbacks mPsdsCallbacks; + private @Nullable GnssAssistanceCallbacks mGnssAssistanceCallbacks; private AGpsCallbacks mAGpsCallbacks; private NotificationCallbacks mNotificationCallbacks; @@ -504,6 +513,16 @@ public class GnssNative { mNotificationCallbacks = Objects.requireNonNull(callbacks); } + /** Sets GnssAssistanceCallbacks. */ + public void setGnssAssistanceCallbacks(GnssAssistanceCallbacks callbacks) { + if (!Flags.gnssAssistanceInterfaceJni()) { + return; + } + Preconditions.checkState(!mRegistered); + Preconditions.checkState(mGnssAssistanceCallbacks == null); + mGnssAssistanceCallbacks = Objects.requireNonNull(callbacks); + } + /** * Registers with the HAL and allows callbacks to begin. Once registered with the native HAL, * no more callbacks can be added or set. Must only be called once. @@ -1053,6 +1072,17 @@ public class GnssNative { mGnssHal.injectNiSuplMessageData(data, length, slotIndex); } + /** + * Injects GNSS assistance data into the GNSS HAL. + */ + public void injectGnssAssistance(GnssAssistance assistance) { + if (!Flags.gnssAssistanceInterfaceJni()) { + return; + } + Preconditions.checkState(mRegistered); + mGnssHal.injectGnssAssistance(assistance); + } + @NativeEntryPoint void reportGnssServiceDied() { // Not necessary to clear (and restore) binder identity since it runs on another thread. @@ -1269,6 +1299,15 @@ public class GnssNative { } @NativeEntryPoint + void gnssAssistanceInjectRequest() { + if (!Flags.gnssAssistanceInterfaceJni() || mGnssAssistanceCallbacks == null) { + return; + } + Binder.withCleanCallingIdentity( + () -> mGnssAssistanceCallbacks.onRequestGnssAssistanceInject()); + } + + @NativeEntryPoint void reportGeofenceTransition(int geofenceId, Location location, int transition, long transitionTimestamp) { Binder.withCleanCallingIdentity( @@ -1569,6 +1608,10 @@ public class GnssNative { protected void injectNiSuplMessageData(byte[] data, int length, int slotIndex) { native_inject_ni_supl_message_data(data, length, slotIndex); } + + protected void injectGnssAssistance(GnssAssistance gnssAssistance) { + native_inject_gnss_assistance(gnssAssistance); + } } // basic APIs @@ -1718,4 +1761,7 @@ public class GnssNative { private static native boolean native_supports_psds(); private static native void native_inject_psds_data(byte[] data, int length, int psdsType); + + // GNSS Assistance APIs + private static native void native_inject_gnss_assistance(GnssAssistance gnssAssistance); } diff --git a/services/core/java/com/android/server/locksettings/LockSettingsService.java b/services/core/java/com/android/server/locksettings/LockSettingsService.java index 42d0a5c4757a..a8190269450a 100644 --- a/services/core/java/com/android/server/locksettings/LockSettingsService.java +++ b/services/core/java/com/android/server/locksettings/LockSettingsService.java @@ -31,7 +31,6 @@ import static android.content.Intent.ACTION_MAIN_USER_LOCKSCREEN_KNOWLEDGE_FACTO import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.os.UserHandle.USER_ALL; import static android.os.UserHandle.USER_SYSTEM; -import static android.security.Flags.reportPrimaryAuthAttempts; import static com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_NONE; import static com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_PASSWORD_OR_PIN; @@ -2483,11 +2482,8 @@ public class LockSettingsService extends ILockSettings.Stub { requireStrongAuth(STRONG_AUTH_REQUIRED_AFTER_LOCKOUT, userId); } } - if (reportPrimaryAuthAttempts()) { - final boolean success = - response.getResponseCode() == VerifyCredentialResponse.RESPONSE_OK; - notifyLockSettingsStateListeners(success, userId); - } + final boolean success = response.getResponseCode() == VerifyCredentialResponse.RESPONSE_OK; + notifyLockSettingsStateListeners(success, userId); return response; } diff --git a/services/core/java/com/android/server/pm/TEST_MAPPING b/services/core/java/com/android/server/pm/TEST_MAPPING index 1fda4782fc86..92e8eb9cd1bb 100644 --- a/services/core/java/com/android/server/pm/TEST_MAPPING +++ b/services/core/java/com/android/server/pm/TEST_MAPPING @@ -133,6 +133,38 @@ ] }, { + "name": "CtsPackageInstallerCUJInstallationViaIntentForResultTestCases", + "file_patterns": [ + "core/java/.*Install.*", + "services/core/.*Install.*", + "services/core/java/com/android/server/pm/.*" + ], + "options":[ + { + "exclude-annotation":"androidx.test.filters.FlakyTest" + }, + { + "exclude-annotation":"org.junit.Ignore" + } + ] + }, + { + "name": "CtsPackageInstallerCUJInstallationViaSessionTestCases", + "file_patterns": [ + "core/java/.*Install.*", + "services/core/.*Install.*", + "services/core/java/com/android/server/pm/.*" + ], + "options":[ + { + "exclude-annotation":"androidx.test.filters.FlakyTest" + }, + { + "exclude-annotation":"org.junit.Ignore" + } + ] + }, + { "name": "CtsPackageInstallerCUJMultiUsersTestCases", "file_patterns": [ "core/java/.*Install.*", @@ -288,6 +320,38 @@ ] }, { + "name": "CtsPackageInstallerCUJInstallationViaIntentForResultTestCases", + "file_patterns": [ + "core/java/.*Install.*", + "services/core/.*Install.*", + "services/core/java/com/android/server/pm/.*" + ], + "options":[ + { + "exclude-annotation":"androidx.test.filters.FlakyTest" + }, + { + "exclude-annotation":"org.junit.Ignore" + } + ] + }, + { + "name": "CtsPackageInstallerCUJInstallationViaSessionTestCases", + "file_patterns": [ + "core/java/.*Install.*", + "services/core/.*Install.*", + "services/core/java/com/android/server/pm/.*" + ], + "options":[ + { + "exclude-annotation":"androidx.test.filters.FlakyTest" + }, + { + "exclude-annotation":"org.junit.Ignore" + } + ] + }, + { "name": "CtsPackageInstallerCUJMultiUsersTestCases", "file_patterns": [ "core/java/.*Install.*", diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java index 092ec8ef4a8a..233b577e1c61 100644 --- a/services/core/java/com/android/server/pm/UserManagerService.java +++ b/services/core/java/com/android/server/pm/UserManagerService.java @@ -1078,7 +1078,7 @@ public class UserManagerService extends IUserManager.Stub { mUserVisibilityMediator = new UserVisibilityMediator(mHandler); mUserDataPreparer = userDataPreparer; mUserTypes = UserTypeFactory.getUserTypes(); - invalidateOwnerNameIfNecessary(context.getResources(), true /* forceUpdate */); + invalidateOwnerNameIfNecessary(getContextResources(), true /* forceUpdate */); synchronized (mPackagesLock) { mUsersDir = new File(dataDir, USER_INFO_DIR); mUsersDir.mkdirs(); @@ -1184,6 +1184,15 @@ public class UserManagerService extends IUserManager.Stub { && android.multiuser.Flags.enablePrivateSpaceFeatures(); } + private Resources getSystemResources() { + return android.multiuser.Flags.useUnifiedResources() + ? getContextResources() : Resources.getSystem(); + } + + private Resources getContextResources() { + return mContext.getResources(); + } + /** * This method retrieves the {@link UserManagerInternal} only for the purpose of * PackageManagerService construction. @@ -1223,7 +1232,7 @@ public class UserManagerService extends IUserManager.Stub { // Avoid marking pre-created users for removal. return; } - if (ui.lastLoggedInTime == 0 && ui.isGuest() && Resources.getSystem().getBoolean( + if (ui.lastLoggedInTime == 0 && ui.isGuest() && getSystemResources().getBoolean( com.android.internal.R.bool.config_guestUserAutoCreated)) { // Avoid marking auto-created but not-yet-logged-in guest user for removal. Because a // new one will be created anyway, and this one doesn't have any personal data in it yet @@ -1402,7 +1411,7 @@ public class UserManagerService extends IUserManager.Stub { } if (isHeadlessSystemUserMode()) { - final int bootStrategy = mContext.getResources() + final int bootStrategy = getContextResources() .getInteger(com.android.internal.R.integer.config_hsumBootStrategy); switch (bootStrategy) { case BOOT_TO_PREVIOUS_OR_FIRST_SWITCHABLE_USER: @@ -2983,7 +2992,7 @@ public class UserManagerService extends IUserManager.Stub { boolean isUserSwitcherEnabled(@UserIdInt int userId) { boolean multiUserSettingOn = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.USER_SWITCHER_ENABLED, - Resources.getSystem().getBoolean(com.android.internal + getSystemResources().getBoolean(com.android.internal .R.bool.config_showUserSwitcherByDefault) ? 1 : 0) != 0; return UserManager.supportsMultipleUsers() @@ -4672,7 +4681,7 @@ public class UserManagerService extends IUserManager.Stub { UserData userData = getUserDataNoChecks(UserHandle.USER_SYSTEM); if ("Primary".equals(userData.info.name)) { userData.info.name = - mContext.getResources().getString(com.android.internal.R.string.owner_name); + getContextResources().getString(com.android.internal.R.string.owner_name); userIdsToWrite.add(userData.info.id); } userVersion = 1; @@ -5002,7 +5011,7 @@ public class UserManagerService extends IUserManager.Stub { final Bundle restrictions = new Bundle(); try { - final String[] defaultFirstUserRestrictions = mContext.getResources().getStringArray( + final String[] defaultFirstUserRestrictions = getContextResources().getStringArray( com.android.internal.R.array.config_defaultFirstUserRestrictions); for (String userRestriction : defaultFirstUserRestrictions) { if (UserRestrictionsUtils.isValidRestriction(userRestriction)) { @@ -6178,7 +6187,7 @@ public class UserManagerService extends IUserManager.Stub { // If the user switch hasn't been explicitly toggled on or off by the user, turn it on. if (android.provider.Settings.Global.getString(mContext.getContentResolver(), android.provider.Settings.Global.USER_SWITCHER_ENABLED) == null) { - if (Resources.getSystem().getBoolean( + if (getSystemResources().getBoolean( com.android.internal.R.bool.config_enableUserSwitcherUponUserCreation)) { android.provider.Settings.Global.putInt(mContext.getContentResolver(), android.provider.Settings.Global.USER_SWITCHER_ENABLED, 1); @@ -7490,7 +7499,6 @@ public class UserManagerService extends IUserManager.Stub { final long now = System.currentTimeMillis(); final long nowRealtime = SystemClock.elapsedRealtime(); final StringBuilder sb = new StringBuilder(); - final Resources resources = Resources.getSystem(); if (args != null && args.length > 0) { switch (args[0]) { @@ -7573,13 +7581,14 @@ public class UserManagerService extends IUserManager.Stub { pw.println(); int effectiveMaxSupportedUsers = UserManager.getMaxSupportedUsers(); pw.print(" Max users: " + effectiveMaxSupportedUsers); - int defaultMaxSupportedUsers = resources.getInteger(R.integer.config_multiuserMaximumUsers); + int defaultMaxSupportedUsers = getSystemResources() + .getInteger(R.integer.config_multiuserMaximumUsers); if (effectiveMaxSupportedUsers != defaultMaxSupportedUsers) { pw.print(" (built-in value: " + defaultMaxSupportedUsers + ")"); } pw.println(" (limit reached: " + isUserLimitReached() + ")"); pw.println(" Supports switchable users: " + UserManager.supportsMultipleUsers()); - pw.println(" All guests ephemeral: " + resources.getBoolean( + pw.println(" All guests ephemeral: " + getSystemResources().getBoolean( com.android.internal.R.bool.config_guestUserEphemeral)); pw.println(" Force ephemeral users: " + mForceEphemeralUsers); final boolean isHeadlessSystemUserMode = isHeadlessSystemUserMode(); @@ -7594,7 +7603,7 @@ public class UserManagerService extends IUserManager.Stub { } } if (isHeadlessSystemUserMode) { - pw.println(" Can switch to headless system user: " + resources + pw.println(" Can switch to headless system user: " + getSystemResources() .getBoolean(com.android.internal.R.bool.config_canSwitchToHeadlessSystemUser)); } pw.println(" User version: " + mUserVersion); @@ -8536,8 +8545,7 @@ public class UserManagerService extends IUserManager.Stub { * or downgraded to non-admin status. */ public boolean isMainUserPermanentAdmin() { - return Resources.getSystem() - .getBoolean(R.bool.config_isMainUserPermanentAdmin); + return getSystemResources().getBoolean(R.bool.config_isMainUserPermanentAdmin); } /** @@ -8546,8 +8554,7 @@ public class UserManagerService extends IUserManager.Stub { * it is not a full user. */ public boolean canSwitchToHeadlessSystemUser() { - return Resources.getSystem() - .getBoolean(R.bool.config_canSwitchToHeadlessSystemUser); + return getSystemResources().getBoolean(R.bool.config_canSwitchToHeadlessSystemUser); } /** diff --git a/services/core/java/com/android/server/policy/PermissionPolicyService.java b/services/core/java/com/android/server/policy/PermissionPolicyService.java index c31c287017c3..4ffdb1124571 100644 --- a/services/core/java/com/android/server/policy/PermissionPolicyService.java +++ b/services/core/java/com/android/server/policy/PermissionPolicyService.java @@ -235,15 +235,12 @@ public final class PermissionPolicyService extends SystemService { this::synchronizeUidPermissionsAndAppOpsAsync); mAppOpsCallback = new IAppOpsCallback.Stub() { - public void opChanged(int op, int uid, @Nullable String packageName, - String persistentDeviceId) { + public void opChanged(int op, int uid, String packageName, String persistentDeviceId) { if (!Objects.equals(persistentDeviceId, - VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT)) { + VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT) || uid < 0) { return; } - if (packageName != null) { - synchronizeUidPermissionsAndAppOpsAsync(uid); - } + synchronizeUidPermissionsAndAppOpsAsync(uid); resetAppOpPermissionsIfNotRequestedForUidAsync(uid); } }; diff --git a/services/core/java/com/android/server/power/feature/PowerManagerFlags.java b/services/core/java/com/android/server/power/feature/PowerManagerFlags.java index ebc50fd85f24..52d4555248ce 100644 --- a/services/core/java/com/android/server/power/feature/PowerManagerFlags.java +++ b/services/core/java/com/android/server/power/feature/PowerManagerFlags.java @@ -67,6 +67,10 @@ public class PowerManagerFlags { new FlagState(Flags.FLAG_WAKELOCK_ATTRIBUTION_VIA_WORKCHAIN, Flags::wakelockAttributionViaWorkchain); + private final FlagState mDisableFrozenProcessWakelocks = + new FlagState(Flags.FLAG_DISABLE_FROZEN_PROCESS_WAKELOCKS, + Flags::disableFrozenProcessWakelocks); + /** Returns whether early-screen-timeout-detector is enabled on not. */ public boolean isEarlyScreenTimeoutDetectorEnabled() { return mEarlyScreenTimeoutDetectorFlagState.isEnabled(); @@ -121,6 +125,13 @@ public class PowerManagerFlags { } /** + * @return Whether the feature to disable the frozen process wakelocks is enabled + */ + public boolean isDisableFrozenProcessWakelocksEnabled() { + return mDisableFrozenProcessWakelocks.isEnabled(); + } + + /** * dumps all flagstates * @param pw printWriter */ @@ -132,6 +143,7 @@ public class PowerManagerFlags { pw.println(" " + mFrameworkWakelockInfo); pw.println(" " + mMoveWscLoggingToNotifier); pw.println(" " + mWakelockAttributionViaWorkchain); + pw.println(" " + mDisableFrozenProcessWakelocks); } private static class FlagState { diff --git a/services/core/java/com/android/server/power/feature/power_flags.aconfig b/services/core/java/com/android/server/power/feature/power_flags.aconfig index fefe195dc337..ad8ec0354aa6 100644 --- a/services/core/java/com/android/server/power/feature/power_flags.aconfig +++ b/services/core/java/com/android/server/power/feature/power_flags.aconfig @@ -70,3 +70,10 @@ flag { description: "Feature flag to move logging of WakelockStateChanged atoms from BatteryStatsImpl to Notifier." bug: "352602149" } + +flag { + name: "disable_frozen_process_wakelocks" + namespace: "power" + description: "Feature flag to disable/enable wakelocks of a process when it is frozen/unfrozen" + bug: "291115867" +} diff --git a/services/core/java/com/android/server/security/advancedprotection/AdvancedProtectionService.java b/services/core/java/com/android/server/security/advancedprotection/AdvancedProtectionService.java index 93fd2768d13e..6872ca9e46ee 100644 --- a/services/core/java/com/android/server/security/advancedprotection/AdvancedProtectionService.java +++ b/services/core/java/com/android/server/security/advancedprotection/AdvancedProtectionService.java @@ -23,7 +23,9 @@ import android.annotation.EnforcePermission; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; +import android.content.SharedPreferences; import android.os.Binder; +import android.os.Environment; import android.os.Handler; import android.os.IBinder; import android.os.Looper; @@ -32,14 +34,21 @@ import android.os.PermissionEnforcer; import android.os.RemoteException; import android.os.ResultReceiver; import android.os.ShellCallback; +import android.os.UserHandle; import android.provider.Settings; import android.security.advancedprotection.AdvancedProtectionFeature; +import android.security.advancedprotection.AdvancedProtectionManager; +import android.security.advancedprotection.AdvancedProtectionManager.FeatureId; +import android.security.advancedprotection.AdvancedProtectionManager.SupportDialogType; import android.security.advancedprotection.IAdvancedProtectionCallback; import android.security.advancedprotection.IAdvancedProtectionService; +import android.security.advancedprotection.AdvancedProtectionProtoEnums; import android.util.ArrayMap; import android.util.Slog; import com.android.internal.annotations.VisibleForTesting; +import com.android.internal.util.DumpUtils; +import com.android.internal.util.FrameworkStatsLog; import com.android.server.FgThread; import com.android.server.LocalServices; import com.android.server.SystemService; @@ -51,7 +60,9 @@ import com.android.server.security.advancedprotection.features.DisallowInstallUn import com.android.server.security.advancedprotection.features.MemoryTaggingExtensionHook; import com.android.server.security.advancedprotection.features.UsbDataAdvancedProtectionHook; +import java.io.File; import java.io.FileDescriptor; +import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; @@ -61,6 +72,15 @@ public class AdvancedProtectionService extends IAdvancedProtectionService.Stub private static final int MODE_CHANGED = 0; private static final int CALLBACK_ADDED = 1; + // Shared preferences keys + private static final String PREFERENCE = "advanced_protection_preference"; + private static final String ENABLED_CHANGE_TIME = "enabled_change_time"; + private static final String LAST_DIALOG_FEATURE_ID = "last_dialog_feature_id"; + private static final String LAST_DIALOG_TYPE = "last_dialog_type"; + private static final String LAST_DIALOG_HOURS_SINCE_ENABLED = "last_dialog_hours_since_enabled"; + private static final String LAST_DIALOG_LEARN_MORE_CLICKED = "last_dialog_learn_more_clicked"; + private static final long MILLIS_PER_HOUR = 60 * 60 * 1000; + private final Context mContext; private final Handler mHandler; private final AdvancedProtectionStore mStore; @@ -72,6 +92,10 @@ public class AdvancedProtectionService extends IAdvancedProtectionService.Stub // For tracking only - not called on state change private final ArrayList<AdvancedProtectionProvider> mProviders = new ArrayList<>(); + // Used to store logging data + private SharedPreferences mSharedPreferences; + private boolean mEmitLogs = true; + private AdvancedProtectionService(@NonNull Context context) { super(PermissionEnforcer.fromContext(context)); mContext = context; @@ -126,6 +150,8 @@ public class AdvancedProtectionService extends IAdvancedProtectionService.Stub if (provider != null) { mProviders.add(provider); } + + mEmitLogs = false; } @Override @@ -178,7 +204,7 @@ public class AdvancedProtectionService extends IAdvancedProtectionService.Stub if (enabled != isAdvancedProtectionEnabledInternal()) { mStore.store(enabled); sendModeChanged(enabled); - Slog.i(TAG, "Advanced protection is " + (enabled ? "enabled" : "disabled")); + logAdvancedProtectionEnabled(enabled); } } } finally { @@ -188,6 +214,91 @@ public class AdvancedProtectionService extends IAdvancedProtectionService.Stub @Override @EnforcePermission(Manifest.permission.MANAGE_ADVANCED_PROTECTION_MODE) + public void logDialogShown(@FeatureId int featureId, @SupportDialogType int type, + boolean learnMoreClicked) { + logDialogShown_enforcePermission(); + + if (!mEmitLogs) { + return; + } + + int hoursSinceEnabled = hoursSinceLastChange(); + FrameworkStatsLog.write(FrameworkStatsLog.ADVANCED_PROTECTION_SUPPORT_DIALOG_DISPLAYED, + /*feature_id*/ featureIdToLogEnum(featureId), + /*dialogue_type*/ dialogueTypeToLogEnum(type), + /*learn_more_clicked*/ learnMoreClicked, + /*hours_since_last_change*/ hoursSinceEnabled); + + getSharedPreferences().edit() + .putInt(LAST_DIALOG_FEATURE_ID, featureId) + .putInt(LAST_DIALOG_TYPE, type) + .putBoolean(LAST_DIALOG_LEARN_MORE_CLICKED, learnMoreClicked) + .putInt(LAST_DIALOG_HOURS_SINCE_ENABLED, hoursSinceEnabled) + .apply(); + } + + private int featureIdToLogEnum(@FeatureId int featureId) { + switch (featureId) { + case AdvancedProtectionManager.FEATURE_ID_DISALLOW_CELLULAR_2G: + return AdvancedProtectionProtoEnums.FEATURE_ID_DISALLOW_CELLULAR_2G; + case AdvancedProtectionManager.FEATURE_ID_DISALLOW_INSTALL_UNKNOWN_SOURCES: + return AdvancedProtectionProtoEnums.FEATURE_ID_DISALLOW_INSTALL_UNKNOWN_SOURCES; + case AdvancedProtectionManager.FEATURE_ID_DISALLOW_USB: + return AdvancedProtectionProtoEnums.FEATURE_ID_DISALLOW_USB; + case AdvancedProtectionManager.FEATURE_ID_DISALLOW_WEP: + return AdvancedProtectionProtoEnums.FEATURE_ID_DISALLOW_WEP; + case AdvancedProtectionManager.FEATURE_ID_ENABLE_MTE: + return AdvancedProtectionProtoEnums.FEATURE_ID_ENABLE_MTE; + default: + return AdvancedProtectionProtoEnums.FEATURE_ID_UNKNOWN; + } + } + + private int dialogueTypeToLogEnum(@SupportDialogType int type) { + switch (type) { + case AdvancedProtectionManager.SUPPORT_DIALOG_TYPE_UNKNOWN: + return AdvancedProtectionProtoEnums.DIALOGUE_TYPE_UNKNOWN; + case AdvancedProtectionManager.SUPPORT_DIALOG_TYPE_BLOCKED_INTERACTION: + return AdvancedProtectionProtoEnums.DIALOGUE_TYPE_BLOCKED_INTERACTION; + case AdvancedProtectionManager.SUPPORT_DIALOG_TYPE_DISABLED_SETTING: + return AdvancedProtectionProtoEnums.DIALOGUE_TYPE_DISABLED_SETTING; + default: + return AdvancedProtectionProtoEnums.DIALOGUE_TYPE_UNKNOWN; + } + } + + private void logAdvancedProtectionEnabled(boolean enabled) { + if (!mEmitLogs) { + return; + } + + Slog.i(TAG, "Advanced protection has been " + (enabled ? "enabled" : "disabled")); + SharedPreferences prefs = getSharedPreferences(); + FrameworkStatsLog.write(FrameworkStatsLog.ADVANCED_PROTECTION_STATE_CHANGED, + /*enabled*/ enabled, + /*hours_since_enabled*/ hoursSinceLastChange(), + /*last_dialog_feature_id*/ featureIdToLogEnum( + prefs.getInt(LAST_DIALOG_FEATURE_ID, -1)), + /*_type*/ dialogueTypeToLogEnum(prefs.getInt(LAST_DIALOG_TYPE, -1)), + /*_learn_more_clicked*/ prefs.getBoolean(LAST_DIALOG_LEARN_MORE_CLICKED, false), + /*_hours_since_enabled*/ prefs.getInt(LAST_DIALOG_HOURS_SINCE_ENABLED, -1)); + prefs.edit() + .putLong(ENABLED_CHANGE_TIME, System.currentTimeMillis()) + .apply(); + } + + private int hoursSinceLastChange() { + int hoursSinceEnabled = -1; + long lastChangeTimeMillis = getSharedPreferences().getLong(ENABLED_CHANGE_TIME, -1); + if (lastChangeTimeMillis != -1) { + hoursSinceEnabled = (int) + ((System.currentTimeMillis() - lastChangeTimeMillis) / MILLIS_PER_HOUR); + } + return hoursSinceEnabled; + } + + @Override + @EnforcePermission(Manifest.permission.MANAGE_ADVANCED_PROTECTION_MODE) public List<AdvancedProtectionFeature> getAdvancedProtectionFeatures() { getAdvancedProtectionFeatures_enforcePermission(); List<AdvancedProtectionFeature> features = new ArrayList<>(); @@ -213,6 +324,30 @@ public class AdvancedProtectionService extends IAdvancedProtectionService.Stub .exec(this, in, out, err, args, callback, resultReceiver); } + @Override + public void dump(FileDescriptor fd, PrintWriter writer, String[] args) { + if (!DumpUtils.checkDumpPermission(mContext, TAG, writer)) return; + writer.println("AdvancedProtectionService"); + writer.println(" isAdvancedProtectionEnabled: " + isAdvancedProtectionEnabledInternal()); + writer.println(" mHooks.size(): " + mHooks.size()); + writer.println(" mCallbacks.size(): " + mCallbacks.size()); + writer.println(" mProviders.size(): " + mProviders.size()); + + writer.println("Hooks: "); + mHooks.stream().forEach(hook -> { + writer.println(" " + hook.getClass().getSimpleName() + + " available: " + hook.isAvailable()); + }); + writer.println(" Providers: "); + mProviders.stream().forEach(provider -> { + writer.println(" " + provider.getClass().getSimpleName()); + provider.getFeatures().stream().forEach(feature -> { + writer.println(" " + feature.getClass().getSimpleName()); + }); + }); + writer.println(" mSharedPreferences: " + getSharedPreferences().getAll()); + } + void sendModeChanged(boolean enabled) { Message.obtain(mHandler, MODE_CHANGED, /*enabled*/ enabled ? 1 : 0, /*unused */ -1) .sendToTarget(); @@ -224,6 +359,22 @@ public class AdvancedProtectionService extends IAdvancedProtectionService.Stub .sendToTarget(); } + private SharedPreferences getSharedPreferences() { + if (mSharedPreferences == null) { + initSharedPreferences(); + } + return mSharedPreferences; + } + + private synchronized void initSharedPreferences() { + if (mSharedPreferences == null) { + Context deviceContext = mContext.createDeviceProtectedStorageContext(); + File sharedPrefs = new File(Environment.getDataSystemDirectory(), PREFERENCE); + mSharedPreferences = deviceContext.getSharedPreferences(sharedPrefs, + Context.MODE_PRIVATE); + } + } + public static final class Lifecycle extends SystemService { private final AdvancedProtectionService mService; diff --git a/services/core/java/com/android/server/security/advancedprotection/features/DisallowCellular2GAdvancedProtectionHook.java b/services/core/java/com/android/server/security/advancedprotection/features/DisallowCellular2GAdvancedProtectionHook.java index be263346854e..bf464be4a170 100644 --- a/services/core/java/com/android/server/security/advancedprotection/features/DisallowCellular2GAdvancedProtectionHook.java +++ b/services/core/java/com/android/server/security/advancedprotection/features/DisallowCellular2GAdvancedProtectionHook.java @@ -22,16 +22,11 @@ import static android.security.advancedprotection.AdvancedProtectionManager.FEAT import android.annotation.NonNull; import android.app.admin.DevicePolicyManager; import android.content.Context; +import android.content.pm.PackageManager; import android.os.UserManager; import android.security.advancedprotection.AdvancedProtectionFeature; -import android.telephony.SubscriptionInfo; -import android.telephony.SubscriptionManager; -import android.telephony.TelephonyManager; import android.util.Slog; -import java.util.ArrayList; -import java.util.List; - /** @hide */ public final class DisallowCellular2GAdvancedProtectionHook extends AdvancedProtectionHook { private static final String TAG = "AdvancedProtectionDisallowCellular2G"; @@ -39,14 +34,12 @@ public final class DisallowCellular2GAdvancedProtectionHook extends AdvancedProt private final AdvancedProtectionFeature mFeature = new AdvancedProtectionFeature(FEATURE_ID_DISALLOW_CELLULAR_2G); private final DevicePolicyManager mDevicePolicyManager; - private final TelephonyManager mTelephonyManager; - private final SubscriptionManager mSubscriptionManager; + private final PackageManager mPackageManager; public DisallowCellular2GAdvancedProtectionHook(@NonNull Context context, boolean enabled) { super(context, enabled); mDevicePolicyManager = context.getSystemService(DevicePolicyManager.class); - mTelephonyManager = context.getSystemService(TelephonyManager.class); - mSubscriptionManager = context.getSystemService(SubscriptionManager.class); + mPackageManager = context.getPackageManager(); onAdvancedProtectionChanged(enabled); } @@ -57,40 +50,9 @@ public final class DisallowCellular2GAdvancedProtectionHook extends AdvancedProt return mFeature; } - private static boolean isEmbeddedSubscriptionVisible(SubscriptionInfo subInfo) { - if (subInfo.isEmbedded() - && (subInfo.getProfileClass() == SubscriptionManager.PROFILE_CLASS_PROVISIONING - || subInfo.isOnlyNonTerrestrialNetwork())) { - return false; - } - - return true; - } - - private List<TelephonyManager> getActiveTelephonyManagers() { - List<TelephonyManager> telephonyManagers = new ArrayList<>(); - - for (SubscriptionInfo subInfo : mSubscriptionManager.getActiveSubscriptionInfoList()) { - if (isEmbeddedSubscriptionVisible(subInfo)) { - telephonyManagers.add( - mTelephonyManager.createForSubscriptionId(subInfo.getSubscriptionId())); - } - } - - return telephonyManagers; - } - @Override public boolean isAvailable() { - for (TelephonyManager telephonyManager : getActiveTelephonyManagers()) { - if (telephonyManager.isDataCapable() - && telephonyManager.isRadioInterfaceCapabilitySupported( - mTelephonyManager.CAPABILITY_USES_ALLOWED_NETWORK_TYPES_BITMASK)) { - return true; - } - } - - return false; + return mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY); } @Override diff --git a/services/core/java/com/android/server/sensors/OWNERS b/services/core/java/com/android/server/sensors/OWNERS new file mode 100644 index 000000000000..6b2247331a33 --- /dev/null +++ b/services/core/java/com/android/server/sensors/OWNERS @@ -0,0 +1 @@ +include platform/frameworks/native:/services/sensorservice/OWNERS diff --git a/services/core/java/com/android/server/sensors/SensorManagerInternal.java b/services/core/java/com/android/server/sensors/SensorManagerInternal.java index 7ff4ade1101c..9636cc6c77a7 100644 --- a/services/core/java/com/android/server/sensors/SensorManagerInternal.java +++ b/services/core/java/com/android/server/sensors/SensorManagerInternal.java @@ -17,6 +17,7 @@ package com.android.server.sensors; import android.annotation.NonNull; +import android.annotation.Nullable; import android.hardware.SensorDirectChannel; import android.os.ParcelFileDescriptor; @@ -71,7 +72,7 @@ public abstract class SensorManagerInternal { /** * Sends an event for the runtime sensor with the given handle to the framework. * - * Only relevant for sending runtime sensor events. @see #createRuntimeSensor. + * <p>Only relevant for sending runtime sensor events. @see #createRuntimeSensor.</p> * * @param handle The sensor handle. * @param type The type of the sensor. @@ -83,6 +84,21 @@ public abstract class SensorManagerInternal { @NonNull float[] values); /** + * Sends an additional info event for the runtime sensor with the given handle to the framework. + * + * <p>Only relevant for runtime sensors. @see #createRuntimeSensor.</p> + * + * @param handle The sensor handle. + * @param type The type of payload data. + * @param serial The sequence number of this frame for this type. + * @param timestampNanos Timestamp of the event. + * @param values The payload data represented in float values. + * @return Whether the event injection was successful. + */ + public abstract boolean sendSensorAdditionalInfo(int handle, int type, int serial, + long timestampNanos, @Nullable float[] values); + + /** * Listener for proximity sensor state changes. */ public interface ProximityActiveListener { diff --git a/services/core/java/com/android/server/sensors/SensorService.java b/services/core/java/com/android/server/sensors/SensorService.java index 3de191030d71..0d31b22e2020 100644 --- a/services/core/java/com/android/server/sensors/SensorService.java +++ b/services/core/java/com/android/server/sensors/SensorService.java @@ -19,6 +19,7 @@ package com.android.server.sensors; import static com.android.server.sensors.SensorManagerInternal.ProximityActiveListener; import android.annotation.NonNull; +import android.annotation.Nullable; import android.content.Context; import android.util.ArrayMap; @@ -62,6 +63,9 @@ public class SensorService extends SystemService { private static native void unregisterRuntimeSensorNative(long ptr, int handle); private static native boolean sendRuntimeSensorEventNative(long ptr, int handle, int type, long timestampNanos, float[] values); + private static native boolean sendRuntimeSensorAdditionalInfoNative(long ptr, int handle, + int type, int serial, long timestampNanos, float[] values); + public SensorService(Context ctx) { super(ctx); @@ -129,6 +133,18 @@ public class SensorService extends SystemService { } @Override + public boolean sendSensorAdditionalInfo(int handle, int type, int serial, + long timestampNanos, @Nullable float[] values) { + synchronized (mLock) { + if (!mRuntimeSensorHandles.contains(handle)) { + return false; + } + return sendRuntimeSensorAdditionalInfoNative(mPtr, handle, type, serial, + timestampNanos, values); + } + } + + @Override public void addProximityActiveListener(@NonNull Executor executor, @NonNull ProximityActiveListener listener) { Objects.requireNonNull(executor, "executor must not be null"); diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 59a042981375..2f9242fbdfc9 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -7085,12 +7085,13 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp } @Override - public void setAnimatingTypes(@InsetsType int animatingTypes) { + public void setAnimatingTypes(@InsetsType int animatingTypes, + @Nullable ImeTracker.Token statsToken) { if (mAnimatingTypes != animatingTypes) { mAnimatingTypes = animatingTypes; if (android.view.inputmethod.Flags.reportAnimatingInsetsTypes()) { - getInsetsStateController().onAnimatingTypesChanged(this); + getInsetsStateController().onAnimatingTypesChanged(this, statsToken); } } } diff --git a/services/core/java/com/android/server/wm/ImeInsetsSourceProvider.java b/services/core/java/com/android/server/wm/ImeInsetsSourceProvider.java index 040bbe46c3aa..ba75cf229565 100644 --- a/services/core/java/com/android/server/wm/ImeInsetsSourceProvider.java +++ b/services/core/java/com/android/server/wm/ImeInsetsSourceProvider.java @@ -82,6 +82,13 @@ final class ImeInsetsSourceProvider extends InsetsSourceProvider { */ private boolean mGivenInsetsReady = false; + /** + * The last state of the windowContainer. This is used to reset server visibility, in case of + * the IME (temporarily) redrawing (e.g. during a rotation), to dispatch the control with + * leash again after it has finished drawing. + */ + private boolean mLastDrawn = false; + ImeInsetsSourceProvider(@NonNull InsetsSource source, @NonNull InsetsStateController stateController, @NonNull DisplayContent displayContent) { @@ -97,6 +104,7 @@ final class ImeInsetsSourceProvider extends InsetsSourceProvider { final WindowState ws = mWindowContainer != null ? mWindowContainer.asWindowState() : null; final boolean givenInsetsPending = ws != null && ws.mGivenInsetsPending; + mLastDrawn = ws != null && ws.isDrawn(); // isLeashReadyForDispatching (used to dispatch the leash of the control) is // depending on mGivenInsetsReady. Therefore, triggering notifyControlChanged here @@ -158,6 +166,35 @@ final class ImeInsetsSourceProvider extends InsetsSourceProvider { } } + /** + * This is used to determine the desired serverVisibility state. For the IME, just having a + * window state that would be visible by policy is not enough. + */ + @Override + protected boolean isSurfaceVisible() { + final boolean isSurfaceVisible = super.isSurfaceVisible(); + if (android.view.inputmethod.Flags.refactorInsetsController()) { + final WindowState windowState = mWindowContainer.asWindowState(); + if (mControl != null && windowState != null) { + final boolean isDrawn = windowState.isDrawn(); + if (!isServerVisible() && isSurfaceVisible) { + // In case the IME becomes visible, we need to check if it is already drawn and + // does not have given insets pending. If it's not yet drawn, we do not set + // server visibility + return isDrawn && !windowState.mGivenInsetsPending; + } else if (mLastDrawn && !isDrawn) { + // If the IME was drawn before, but is not drawn anymore, we need to reset + // server visibility, which will also reset {@link + // ImeInsetsSourceProvider#mGivenInsetsReady}. Otherwise, the new control + // with leash won't be dispatched after the surface has redrawn. + return false; + } + } + } + return isSurfaceVisible; + } + + @Nullable @Override InsetsSourceControl getControl(InsetsControlTarget target) { @@ -424,7 +461,8 @@ final class ImeInsetsSourceProvider extends InsetsSourceProvider { } @Override - void onAnimatingTypesChanged(InsetsControlTarget caller) { + void onAnimatingTypesChanged(InsetsControlTarget caller, + @Nullable ImeTracker.Token statsToken) { if (Flags.reportAnimatingInsetsTypes()) { final InsetsControlTarget controlTarget = getControlTarget(); // If the IME is not being requested anymore and the animation is finished, we need to @@ -432,8 +470,12 @@ final class ImeInsetsSourceProvider extends InsetsSourceProvider { if (caller != null && caller == controlTarget && !caller.isRequestedVisible( WindowInsets.Type.ime()) && (caller.getAnimatingTypes() & WindowInsets.Type.ime()) == 0) { - // TODO(b/353463205) check statsToken - invokeOnImeRequestedChangedListener(caller, null); + ImeTracker.forLogging().onFailed(statsToken, + ImeTracker.PHASE_WM_NOTIFY_HIDE_ANIMATION_FINISHED); + invokeOnImeRequestedChangedListener(caller, statsToken); + } else { + ImeTracker.forLogging().onCancelled(statsToken, + ImeTracker.PHASE_WM_NOTIFY_HIDE_ANIMATION_FINISHED); } } } @@ -779,6 +821,8 @@ final class ImeInsetsSourceProvider extends InsetsSourceProvider { pw.print(prefix); pw.print("mImeShowing="); pw.print(mImeShowing); + pw.print(" mLastDrawn="); + pw.print(mLastDrawn); if (mImeRequester != null) { pw.print(prefix); pw.print("showImePostLayout pending for mImeRequester="); diff --git a/services/core/java/com/android/server/wm/InsetsControlTarget.java b/services/core/java/com/android/server/wm/InsetsControlTarget.java index 6462a37ae33f..3c248fbc7daa 100644 --- a/services/core/java/com/android/server/wm/InsetsControlTarget.java +++ b/services/core/java/com/android/server/wm/InsetsControlTarget.java @@ -107,8 +107,10 @@ interface InsetsControlTarget extends InsetsTarget { /** * @param animatingTypes the {@link InsetsType}s, that are currently animating + * @param statsToken the token tracking the current IME request or {@code null} otherwise. */ - default void setAnimatingTypes(@InsetsType int animatingTypes) { + default void setAnimatingTypes(@InsetsType int animatingTypes, + @Nullable ImeTracker.Token statsToken) { } /** Returns {@code target.getWindow()}, or null if {@code target} is {@code null}. */ diff --git a/services/core/java/com/android/server/wm/InsetsSourceProvider.java b/services/core/java/com/android/server/wm/InsetsSourceProvider.java index 1b693fc05b21..3b715d652dca 100644 --- a/services/core/java/com/android/server/wm/InsetsSourceProvider.java +++ b/services/core/java/com/android/server/wm/InsetsSourceProvider.java @@ -176,6 +176,16 @@ class InsetsSourceProvider { } /** + * @return Whether the current window container has a visible surface. + */ + protected boolean isSurfaceVisible() { + final WindowState windowState = mWindowContainer.asWindowState(); + return windowState != null + ? windowState.wouldBeVisibleIfPolicyIgnored() && windowState.isVisibleByPolicy() + : mWindowContainer.isVisibleRequested(); + } + + /** * Updates the window container that currently backs this source. * * @param windowContainer The window container that links to this source. @@ -368,20 +378,9 @@ class InsetsSourceProvider { if (mWindowContainer == null) { return; } - WindowState windowState = mWindowContainer.asWindowState(); - boolean isServerVisible = windowState != null - ? windowState.wouldBeVisibleIfPolicyIgnored() && windowState.isVisibleByPolicy() - : mWindowContainer.isVisibleRequested(); + final WindowState windowState = mWindowContainer.asWindowState(); + final boolean isServerVisible = isSurfaceVisible(); - if (android.view.inputmethod.Flags.refactorInsetsController()) { - if (mControl != null && mControl.getType() == WindowInsets.Type.ime() && !mServerVisible - && isServerVisible && windowState != null) { - // in case the IME becomes visible, we need to check if it is already drawn and - // does not have given insets pending. If it's not yet drawn, we do not set - // server visibility - isServerVisible = windowState.isDrawn() && !windowState.mGivenInsetsPending; - } - } final boolean serverVisibleChanged = mServerVisible != isServerVisible; setServerVisible(isServerVisible); if (mControl != null && mControlTarget != null) { @@ -673,7 +672,8 @@ class InsetsSourceProvider { mServerVisible, mClientVisible); } - void onAnimatingTypesChanged(InsetsControlTarget caller) { + void onAnimatingTypesChanged(InsetsControlTarget caller, + @Nullable ImeTracker.Token statsToken) { } protected boolean isLeashReadyForDispatching() { diff --git a/services/core/java/com/android/server/wm/InsetsStateController.java b/services/core/java/com/android/server/wm/InsetsStateController.java index 810e48f492e1..64fe6699a262 100644 --- a/services/core/java/com/android/server/wm/InsetsStateController.java +++ b/services/core/java/com/android/server/wm/InsetsStateController.java @@ -393,10 +393,12 @@ class InsetsStateController { } } - void onAnimatingTypesChanged(InsetsControlTarget target) { + void onAnimatingTypesChanged(InsetsControlTarget target, + @Nullable ImeTracker.Token statsToken) { for (int i = mProviders.size() - 1; i >= 0; i--) { final InsetsSourceProvider provider = mProviders.valueAt(i); - provider.onAnimatingTypesChanged(target); + final boolean isImeProvider = provider.getSource().getType() == WindowInsets.Type.ime(); + provider.onAnimatingTypesChanged(target, isImeProvider ? statsToken : null); } } diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java index 242aea941429..39d10624469c 100644 --- a/services/core/java/com/android/server/wm/RootWindowContainer.java +++ b/services/core/java/com/android/server/wm/RootWindowContainer.java @@ -853,7 +853,8 @@ class RootWindowContainer extends WindowContainer<DisplayContent> // Post these on a handler such that we don't call into power manager service while // holding the window manager lock to avoid lock contention with power manager lock. - mHandler.obtainMessage(SET_SCREEN_BRIGHTNESS_OVERRIDE, mDisplayBrightnessOverrides) + // Send a copy of the brightness overrides as they may be cleared before being sent out. + mHandler.obtainMessage(SET_SCREEN_BRIGHTNESS_OVERRIDE, mDisplayBrightnessOverrides.clone()) .sendToTarget(); mHandler.obtainMessage(SET_USER_ACTIVITY_TIMEOUT, mUserActivityTimeout).sendToTarget(); diff --git a/services/core/java/com/android/server/wm/Session.java b/services/core/java/com/android/server/wm/Session.java index 3ed16db7e204..390132445ba8 100644 --- a/services/core/java/com/android/server/wm/Session.java +++ b/services/core/java/com/android/server/wm/Session.java @@ -738,12 +738,18 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient { } @Override - public void updateAnimatingTypes(IWindow window, @InsetsType int animatingTypes) { + public void updateAnimatingTypes(IWindow window, @InsetsType int animatingTypes, + @Nullable ImeTracker.Token statsToken) { synchronized (mService.mGlobalLock) { final WindowState win = mService.windowForClientLocked(this, window, false /* throwOnError */); if (win != null) { - win.setAnimatingTypes(animatingTypes); + ImeTracker.forLogging().onProgress(statsToken, + ImeTracker.PHASE_WM_UPDATE_ANIMATING_TYPES); + win.setAnimatingTypes(animatingTypes, statsToken); + } else { + ImeTracker.forLogging().onFailed(statsToken, + ImeTracker.PHASE_WM_UPDATE_ANIMATING_TYPES); } } } diff --git a/services/core/java/com/android/server/wm/WallpaperController.java b/services/core/java/com/android/server/wm/WallpaperController.java index e1553cd37d03..b042e111e331 100644 --- a/services/core/java/com/android/server/wm/WallpaperController.java +++ b/services/core/java/com/android/server/wm/WallpaperController.java @@ -117,8 +117,11 @@ class WallpaperController { private boolean mShouldOffsetWallpaperCenter; // This is for WallpaperCropper, which has cropping logic for the default display only. + // This is lazily initialization by getOrCreateDefaultDisplayInfo. DO NOT use this member + // variable directly. // TODO(b/400685784) make the WallpaperCropper operate on every display independently - private final WallpaperDefaultDisplayInfo mDefaultDisplayInfo; + @Nullable + private WallpaperDefaultDisplayInfo mDefaultDisplayInfo = null; private final ToBooleanFunction<WindowState> mFindWallpaperTargetFunction = w -> { final ActivityRecord ar = w.mActivityRecord; @@ -202,14 +205,12 @@ class WallpaperController { WallpaperController(WindowManagerService service, DisplayContent displayContent) { mService = service; mDisplayContent = displayContent; - WindowManager windowManager = service.mContext.getSystemService(WindowManager.class); Resources resources = service.mContext.getResources(); mMinWallpaperScale = resources.getFloat(com.android.internal.R.dimen.config_wallpaperMinScale); mMaxWallpaperScale = resources.getFloat(R.dimen.config_wallpaperMaxScale); mShouldOffsetWallpaperCenter = resources.getBoolean( com.android.internal.R.bool.config_offsetWallpaperToCenterOfLargestDisplay); - mDefaultDisplayInfo = new WallpaperDefaultDisplayInfo(windowManager, resources); } void resetLargestDisplay(Display display) { @@ -358,8 +359,8 @@ class WallpaperController { wallpaperWin.mRequestedWidth, wallpaperWin.mRequestedHeight); SparseArray<Rect> cropHints = token.getCropHints(); wallpaperFrame = bitmapSize.x <= 0 || bitmapSize.y <= 0 ? wallpaperWin.getFrame() - : WallpaperCropper.getCrop(screenSize, mDefaultDisplayInfo, bitmapSize, - cropHints, wallpaperWin.isRtl()); + : WallpaperCropper.getCrop(screenSize, getOrCreateDefaultDisplayInfo(), + bitmapSize, cropHints, wallpaperWin.isRtl()); int frameWidth = wallpaperFrame.width(); int frameHeight = wallpaperFrame.height(); float frameRatio = (float) frameWidth / frameHeight; @@ -506,6 +507,16 @@ class WallpaperController { return changed; } + private WallpaperDefaultDisplayInfo getOrCreateDefaultDisplayInfo() { + if (mDefaultDisplayInfo != null) { + return mDefaultDisplayInfo; + } + WindowManager windowManager = mService.mContext.getSystemService(WindowManager.class); + Resources resources = mService.mContext.getResources(); + mDefaultDisplayInfo = new WallpaperDefaultDisplayInfo(windowManager, resources); + return mDefaultDisplayInfo; + } + /** * Get an extra offset if needed ({@link #mShouldOffsetWallpaperCenter} = true, typically on * multiple display devices) so that the wallpaper in a smaller display ends up centered at the diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index ff43d72c5a07..5878dfe63efe 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -4754,7 +4754,8 @@ public class WindowManagerService extends IWindowManager.Stub @EnforcePermission(android.Manifest.permission.MANAGE_APP_TOKENS) @Override - public void updateDisplayWindowAnimatingTypes(int displayId, @InsetsType int animatingTypes) { + public void updateDisplayWindowAnimatingTypes(int displayId, @InsetsType int animatingTypes, + @Nullable ImeTracker.Token statsToken) { updateDisplayWindowAnimatingTypes_enforcePermission(); if (android.view.inputmethod.Flags.reportAnimatingInsetsTypes()) { final long origId = Binder.clearCallingIdentity(); @@ -4762,9 +4763,13 @@ public class WindowManagerService extends IWindowManager.Stub synchronized (mGlobalLock) { final DisplayContent dc = mRoot.getDisplayContent(displayId); if (dc == null || dc.mRemoteInsetsControlTarget == null) { + ImeTracker.forLogging().onFailed(statsToken, + ImeTracker.PHASE_WM_UPDATE_DISPLAY_WINDOW_ANIMATING_TYPES); return; } - dc.mRemoteInsetsControlTarget.setAnimatingTypes(animatingTypes); + ImeTracker.forLogging().onProgress(statsToken, + ImeTracker.PHASE_WM_UPDATE_DISPLAY_WINDOW_ANIMATING_TYPES); + dc.mRemoteInsetsControlTarget.setAnimatingTypes(animatingTypes, statsToken); } } finally { Binder.restoreCallingIdentity(origId); @@ -7614,6 +7619,26 @@ public class WindowManagerService extends IWindowManager.Stub } @Override + public boolean isEligibleForDesktopMode(int displayId) { + if (!checkCallingPermission(INTERNAL_SYSTEM_WINDOW, "isEligibleForDesktopMode()")) { + throw new SecurityException("Requires INTERNAL_SYSTEM_WINDOW permission"); + } + + synchronized (mGlobalLock) { + final DisplayContent displayContent = mRoot.getDisplayContent(displayId); + if (displayContent == null) { + ProtoLog.e(WM_ERROR, "Attempted to check isEligibleForDesktopMode() " + + "for a display that does not exist: %d", displayId); + return false; + } + if (!displayContent.isSystemDecorationsSupported()) { + return false; + } + return displayContent.isDefaultDisplay || displayContent.allowContentModeSwitch(); + } + } + + @Override public void setShouldShowSystemDecors(int displayId, boolean shouldShow) { if (!checkCallingPermission(INTERNAL_SYSTEM_WINDOW, "setShouldShowSystemDecors()")) { throw new SecurityException("Requires INTERNAL_SYSTEM_WINDOW permission"); diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index a270af56cbcd..af5200102fc0 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -821,7 +821,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP } @Override - public void setAnimatingTypes(@InsetsType int animatingTypes) { + public void setAnimatingTypes(@InsetsType int animatingTypes, + @Nullable ImeTracker.Token statsToken) { if (mAnimatingTypes != animatingTypes) { if (Trace.isTagEnabled(TRACE_TAG_WINDOW_MANAGER)) { Trace.instant(TRACE_TAG_WINDOW_MANAGER, @@ -835,10 +836,15 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP mAnimatingTypes = animatingTypes; if (android.view.inputmethod.Flags.reportAnimatingInsetsTypes()) { + ImeTracker.forLogging().onProgress(statsToken, + ImeTracker.PHASE_WM_WINDOW_ANIMATING_TYPES_CHANGED); final InsetsStateController insetsStateController = getDisplayContent().getInsetsStateController(); - insetsStateController.onAnimatingTypesChanged(this); + insetsStateController.onAnimatingTypesChanged(this, statsToken); } + } else { + ImeTracker.forLogging().onFailed(statsToken, + ImeTracker.PHASE_WM_WINDOW_ANIMATING_TYPES_CHANGED); } } diff --git a/services/core/jni/Android.bp b/services/core/jni/Android.bp index 66d04df8095b..adfabe1e54fd 100644 --- a/services/core/jni/Android.bp +++ b/services/core/jni/Android.bp @@ -169,7 +169,7 @@ cc_defaults { "android.hardware.broadcastradio@1.1", "android.hardware.contexthub@1.0", "android.hardware.common.fmq-V1-ndk", - "android.hardware.gnss-V3-cpp", + "android.hardware.gnss-V5-cpp", "android.hardware.gnss@1.0", "android.hardware.gnss@1.1", "android.hardware.gnss@2.0", @@ -204,6 +204,7 @@ cc_defaults { "android.system.suspend.control-V1-cpp", "android.system.suspend.control.internal-cpp", "android.system.suspend-V1-ndk", + "android_location_flags_c_lib", "server_configurable_flags", "service.incremental", ], diff --git a/services/core/jni/com_android_server_location_GnssLocationProvider.cpp b/services/core/jni/com_android_server_location_GnssLocationProvider.cpp index 9c033e25c04e..93f6e95b6d5c 100644 --- a/services/core/jni/com_android_server_location_GnssLocationProvider.cpp +++ b/services/core/jni/com_android_server_location_GnssLocationProvider.cpp @@ -36,6 +36,7 @@ #include <android/hardware/gnss/BnGnssMeasurementCallback.h> #include <android/hardware/gnss/BnGnssPowerIndicationCallback.h> #include <android/hardware/gnss/BnGnssPsdsCallback.h> +#include <android_location_flags.h> #include <binder/IServiceManager.h> #include <nativehelper/JNIHelp.h> #include <pthread.h> @@ -53,6 +54,8 @@ #include "gnss/Gnss.h" #include "gnss/GnssAntennaInfo.h" #include "gnss/GnssAntennaInfoCallback.h" +#include "gnss/GnssAssistance.h" +#include "gnss/GnssAssistanceCallback.h" #include "gnss/GnssBatching.h" #include "gnss/GnssConfiguration.h" #include "gnss/GnssDebug.h" @@ -114,6 +117,7 @@ using android::hardware::gnss::GnssConstellationType; using android::hardware::gnss::GnssPowerStats; using android::hardware::gnss::IGnssPowerIndication; using android::hardware::gnss::IGnssPowerIndicationCallback; +using android::hardware::gnss::gnss_assistance::IGnssAssistanceCallback; using IGnssAidl = android::hardware::gnss::IGnss; using IGnssBatchingAidl = android::hardware::gnss::IGnssBatching; @@ -140,6 +144,9 @@ std::unique_ptr<android::gnss::GnssPsdsInterface> gnssPsdsIface = nullptr; std::unique_ptr<android::gnss::GnssVisibilityControlInterface> gnssVisibilityControlIface = nullptr; std::unique_ptr<android::gnss::MeasurementCorrectionsInterface> gnssMeasurementCorrectionsIface = nullptr; +std::unique_ptr<android::gnss::GnssAssistanceInterface> gnssAssistanceIface = nullptr; + +namespace location_flags = android::location::flags; namespace android { @@ -229,6 +236,9 @@ static void android_location_gnss_hal_GnssNative_class_init_once(JNIEnv* env, jc gnss::GnssVisibilityControl_class_init_once(env, clazz); gnss::MeasurementCorrections_class_init_once(env, clazz); gnss::MeasurementCorrectionsCallback_class_init_once(env, clazz); + if (location_flags::gnss_assistance_interface_jni()) { + gnss::GnssAssistance_class_init_once(env, clazz); + } gnss::Utils_class_init_once(env); } @@ -266,7 +276,9 @@ static void android_location_gnss_hal_GnssNative_init_once(JNIEnv* env, jobject gnssBatchingIface = gnssHal->getGnssBatchingInterface(); gnssVisibilityControlIface = gnssHal->getGnssVisibilityControlInterface(); gnssPowerIndicationIface = gnssHal->getGnssPowerIndicationInterface(); - + if (location_flags::gnss_assistance_interface_jni()) { + gnssAssistanceIface = gnssHal->getGnssAssistanceInterface(); + } if (mCallbacksObj) { ALOGE("Callbacks already initialized"); } else { @@ -355,13 +367,22 @@ static jboolean android_location_gnss_hal_GnssNative_init(JNIEnv* /* env */, jcl // Set IGnssPowerIndication.hal callback. if (gnssPowerIndicationIface != nullptr) { sp<IGnssPowerIndicationCallback> gnssPowerIndicationCallback = - new GnssPowerIndicationCallback(); + sp<GnssPowerIndicationCallback>::make(); auto status = gnssPowerIndicationIface->setCallback(gnssPowerIndicationCallback); if (!checkAidlStatus(status, "IGnssPowerIndication setCallback() failed.")) { gnssPowerIndicationIface = nullptr; } } + // Set IGnssAssistance callback. + if (gnssAssistanceIface != nullptr) { + sp<IGnssAssistanceCallback> gnssAssistanceCallback = + sp<gnss::GnssAssistanceCallback>::make(); + if (!gnssAssistanceIface->setCallback(gnssAssistanceCallback)) { + ALOGI("IGnssAssistanceInterface setCallback() failed"); + } + } + return JNI_TRUE; } @@ -493,6 +514,15 @@ static void android_location_gnss_hal_GnssNative_inject_psds_data(JNIEnv* env, j gnssPsdsIface->injectPsdsData(data, length, psdsType); } +static void android_location_gnss_hal_GnssNative_inject_gnss_assistance(JNIEnv* env, jclass, + jobject gnssAssistanceObj) { + if (gnssAssistanceIface == nullptr) { + ALOGE("%s: IGnssAssistance interface not available.", __func__); + return; + } + gnssAssistanceIface->injectGnssAssistance(env, gnssAssistanceObj); +} + static void android_location_GnssNetworkConnectivityHandler_agps_data_conn_open( JNIEnv* env, jobject /* obj */, jlong networkHandle, jstring apn, jint apnIpType) { if (apn == nullptr) { @@ -937,6 +967,8 @@ static const JNINativeMethod sLocationProviderMethods[] = { {"native_stop_nmea_message_collection", "()Z", reinterpret_cast<void*>( android_location_gnss_hal_GnssNative_stop_nmea_message_collection)}, + {"native_inject_gnss_assistance", "(Landroid/location/GnssAssistance;)V", + reinterpret_cast<void*>(android_location_gnss_hal_GnssNative_inject_gnss_assistance)}, }; static const JNINativeMethod sBatchingMethods[] = { diff --git a/services/core/jni/com_android_server_sensor_SensorService.cpp b/services/core/jni/com_android_server_sensor_SensorService.cpp index eb729de6afd4..0bee7181c2d5 100644 --- a/services/core/jni/com_android_server_sensor_SensorService.cpp +++ b/services/core/jni/com_android_server_sensor_SensorService.cpp @@ -60,6 +60,8 @@ public: void unregisterRuntimeSensor(jint handle); jboolean sendRuntimeSensorEvent(JNIEnv* env, jint handle, jint type, jlong timestamp, jfloatArray values); + jboolean sendRuntimeSensorAdditionalInfo(JNIEnv* env, jint handle, jint type, jint serial, + jlong timestamp, jfloatArray values); private: sp<SensorService> mService; @@ -172,9 +174,9 @@ jboolean NativeSensorService::sendRuntimeSensorEvent(JNIEnv* env, jint handle, j sensors_event_t event{ .version = sizeof(sensors_event_t), - .timestamp = timestamp, .sensor = handle, .type = type, + .timestamp = timestamp, }; int valuesLength = env->GetArrayLength(values); @@ -234,6 +236,42 @@ jboolean NativeSensorService::sendRuntimeSensorEvent(JNIEnv* env, jint handle, j return err == OK; } +jboolean NativeSensorService::sendRuntimeSensorAdditionalInfo(JNIEnv* env, jint handle, jint type, + jint serial, jlong timestamp, + jfloatArray values) { + if (mService == nullptr) { + ALOGD("Dropping sendRuntimeSensorAdditionalInfo, sensor service not available."); + return false; + } + + sensors_event_t event{ + .version = sizeof(sensors_event_t), + .sensor = handle, + .type = SENSOR_TYPE_ADDITIONAL_INFO, + .timestamp = timestamp, + .additional_info = + (additional_info_event_t){ + .type = type, + .serial = serial, + }, + }; + + if (values != nullptr) { + int valuesLength = env->GetArrayLength(values); + if (valuesLength > 14) { + ALOGD("Dropping sendRuntimeSensorAdditionalInfo, number of values exceeds maximum."); + return false; + } + if (valuesLength > 0) { + jfloat* sensorValues = env->GetFloatArrayElements(values, nullptr); + memcpy(event.additional_info.data_float, sensorValues, valuesLength * sizeof(float)); + } + } + + status_t err = mService->sendRuntimeSensorEvent(event); + return err == OK; +} + NativeSensorService::ProximityActiveListenerDelegate::ProximityActiveListenerDelegate( JNIEnv* env, jobject listener) : mListener(env->NewGlobalRef(listener)) {} @@ -326,6 +364,13 @@ static jboolean sendRuntimeSensorEventNative(JNIEnv* env, jclass, jlong ptr, jin return service->sendRuntimeSensorEvent(env, handle, type, timestamp, values); } +static jboolean sendRuntimeSensorAdditionalInfoNative(JNIEnv* env, jclass, jlong ptr, jint handle, + jint type, jint serial, jlong timestamp, + jfloatArray values) { + auto* service = reinterpret_cast<NativeSensorService*>(ptr); + return service->sendRuntimeSensorAdditionalInfo(env, handle, type, serial, timestamp, values); +} + static const JNINativeMethod methods[] = { {"startSensorServiceNative", "(L" PROXIMITY_ACTIVE_CLASS ";)J", reinterpret_cast<void*>(startSensorServiceNative)}, @@ -340,6 +385,8 @@ static const JNINativeMethod methods[] = { reinterpret_cast<void*>(unregisterRuntimeSensorNative)}, {"sendRuntimeSensorEventNative", "(JIIJ[F)Z", reinterpret_cast<void*>(sendRuntimeSensorEventNative)}, + {"sendRuntimeSensorAdditionalInfoNative", "(JIIIJ[F)Z", + reinterpret_cast<void*>(sendRuntimeSensorAdditionalInfoNative)}, }; int register_android_server_sensor_SensorService(JavaVM* vm, JNIEnv* env) { diff --git a/services/core/jni/gnss/Android.bp b/services/core/jni/gnss/Android.bp index e72259f094bc..562e82f90bfa 100644 --- a/services/core/jni/gnss/Android.bp +++ b/services/core/jni/gnss/Android.bp @@ -17,7 +17,6 @@ cc_library_shared { "-Werror", "-Wno-unused-parameter", "-Wthread-safety", - "-DEGL_EGLEXT_PROTOTYPES", "-DGL_GLEXT_PROTOTYPES", ], @@ -41,6 +40,8 @@ cc_library_shared { "GnssMeasurementCallback.cpp", "GnssNavigationMessage.cpp", "GnssNavigationMessageCallback.cpp", + "GnssAssistance.cpp", + "GnssAssistanceCallback.cpp", "GnssPsds.cpp", "GnssPsdsCallback.cpp", "GnssVisibilityControl.cpp", @@ -61,7 +62,7 @@ cc_defaults { "libnativehelper", "libhardware_legacy", "libutils", - "android.hardware.gnss-V3-cpp", + "android.hardware.gnss-V5-cpp", "android.hardware.gnss@1.0", "android.hardware.gnss@1.1", "android.hardware.gnss@2.0", diff --git a/services/core/jni/gnss/Gnss.cpp b/services/core/jni/gnss/Gnss.cpp index da8928b5f97f..a3fd9aa79cfb 100644 --- a/services/core/jni/gnss/Gnss.cpp +++ b/services/core/jni/gnss/Gnss.cpp @@ -765,4 +765,15 @@ sp<hardware::gnss::V1_0::IGnssNi> GnssHal::getGnssNiInterface() { return nullptr; } +std::unique_ptr<GnssAssistanceInterface> GnssHal::getGnssAssistanceInterface() { + if (gnssHalAidl != nullptr) { + sp<hardware::gnss::gnss_assistance::IGnssAssistanceInterface> gnssAssistance; + auto status = gnssHalAidl->getExtensionGnssAssistanceInterface(&gnssAssistance); + if (checkAidlStatus(status, "Unable to get a handle to GnssAssistance")) { + return std::make_unique<GnssAssistanceInterface>(gnssAssistance); + } + } + return nullptr; +} + } // namespace android::gnss diff --git a/services/core/jni/gnss/Gnss.h b/services/core/jni/gnss/Gnss.h index 458da8a6e514..2b6b7513a231 100644 --- a/services/core/jni/gnss/Gnss.h +++ b/services/core/jni/gnss/Gnss.h @@ -34,6 +34,7 @@ #include "AGnss.h" #include "AGnssRil.h" #include "GnssAntennaInfo.h" +#include "GnssAssistance.h" #include "GnssBatching.h" #include "GnssCallback.h" #include "GnssConfiguration.h" @@ -115,6 +116,7 @@ public: std::unique_ptr<GnssVisibilityControlInterface> getGnssVisibilityControlInterface(); std::unique_ptr<GnssAntennaInfoInterface> getGnssAntennaInfoInterface(); std::unique_ptr<GnssPsdsInterface> getGnssPsdsInterface(); + std::unique_ptr<GnssAssistanceInterface> getGnssAssistanceInterface(); sp<hardware::gnss::IGnssPowerIndication> getGnssPowerIndicationInterface(); sp<hardware::gnss::V1_0::IGnssNi> getGnssNiInterface(); diff --git a/services/core/jni/gnss/GnssAssistance.cpp b/services/core/jni/gnss/GnssAssistance.cpp new file mode 100644 index 000000000000..fff396ea126a --- /dev/null +++ b/services/core/jni/gnss/GnssAssistance.cpp @@ -0,0 +1,2047 @@ +/* + * 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. + */ + +// Define LOG_TAG before <log/log.h> to overwrite the default value. + +#define LOG_TAG "GnssAssistanceJni" + +#include "GnssAssistance.h" + +#include <utils/String16.h> + +#include "GnssAssistanceCallback.h" +#include "Utils.h" + +namespace android::gnss { + +using GnssConstellationType = android::hardware::gnss::GnssConstellationType; +using GnssCorrectionComponent = android::hardware::gnss::gnss_assistance::GnssCorrectionComponent; +using GnssInterval = + android::hardware::gnss::gnss_assistance::GnssCorrectionComponent::GnssInterval; +using GnssSatelliteAlmanac = + android::hardware::gnss::gnss_assistance::GnssAlmanac::GnssSatelliteAlmanac; +using IonosphericCorrection = android::hardware::gnss::gnss_assistance::IonosphericCorrection; +using PseudorangeCorrection = + android::hardware::gnss::gnss_assistance::GnssCorrectionComponent::PseudorangeCorrection; +using GalileoSatelliteClockModel = android::hardware::gnss::gnss_assistance:: + GalileoSatelliteEphemeris::GalileoSatelliteClockModel; +using GalileoSvHealth = + android::hardware::gnss::gnss_assistance::GalileoSatelliteEphemeris::GalileoSvHealth; +using GlonassSatelliteAlmanac = + android::hardware::gnss::gnss_assistance::GlonassAlmanac::GlonassSatelliteAlmanac; +using GlonassSatelliteClockModel = android::hardware::gnss::gnss_assistance:: + GlonassSatelliteEphemeris::GlonassSatelliteClockModel; +using GlonassSatelliteOrbitModel = android::hardware::gnss::gnss_assistance:: + GlonassSatelliteEphemeris::GlonassSatelliteOrbitModel; +using GnssSignalType = hardware::gnss::GnssSignalType; +using GnssConstellationType = hardware::gnss::GnssConstellationType; +using BeidouB1CSatelliteOrbitType = + android::hardware::gnss::gnss_assistance::AuxiliaryInformation::BeidouB1CSatelliteOrbitType; +using QzssSatelliteEphemeris = android::hardware::gnss::gnss_assistance::QzssSatelliteEphemeris; + +// Implementation of GnssAssistance (AIDL HAL) + +namespace { +jmethodID method_gnssAssistanceGetGpsAssistance; +jmethodID method_gnssAssistanceGetGlonassAssistance; +jmethodID method_gnssAssistanceGetGalileoAssistance; +jmethodID method_gnssAssistanceGetBeidouAssistance; +jmethodID method_gnssAssistanceGetQzssAssistance; + +jmethodID method_listSize; +jmethodID method_listGet; + +jmethodID method_gnssAlmanacGetIssueDateMillis; +jmethodID method_gnssAlmanacGetIoda; +jmethodID method_gnssAlmanacGetWeekNumber; +jmethodID method_gnssAlmanacGetToaSeconds; +jmethodID method_gnssAlmanacGetSatelliteAlmanacs; +jmethodID method_gnssAlmanacIsCompleteAlmanacProvided; +jmethodID method_satelliteAlmanacGetSvid; +jmethodID method_satelliteAlmanacGetSvHealth; +jmethodID method_satelliteAlmanacGetAf0; +jmethodID method_satelliteAlmanacGetAf1; +jmethodID method_satelliteAlmanacGetEccentricity; +jmethodID method_satelliteAlmanacGetInclination; +jmethodID method_satelliteAlmanacGetM0; +jmethodID method_satelliteAlmanacGetOmega; +jmethodID method_satelliteAlmanacGetOmega0; +jmethodID method_satelliteAlmanacGetOmegaDot; +jmethodID method_satelliteAlmanacGetRootA; + +jmethodID method_satelliteEphemerisTimeGetIode; +jmethodID method_satelliteEphemerisTimeGetToeSeconds; +jmethodID method_satelliteEphemerisTimeGetWeekNumber; + +jmethodID method_keplerianOrbitModelGetDeltaN; +jmethodID method_keplerianOrbitModelGetEccentricity; +jmethodID method_keplerianOrbitModelGetI0; +jmethodID method_keplerianOrbitModelGetIDot; +jmethodID method_keplerianOrbitModelGetM0; +jmethodID method_keplerianOrbitModelGetOmega; +jmethodID method_keplerianOrbitModelGetOmega0; +jmethodID method_keplerianOrbitModelGetOmegaDot; +jmethodID method_keplerianOrbitModelGetRootA; +jmethodID method_keplerianOrbitModelGetSecondOrderHarmonicPerturbation; +jmethodID method_secondOrderHarmonicPerturbationGetCic; +jmethodID method_secondOrderHarmonicPerturbationGetCis; +jmethodID method_secondOrderHarmonicPerturbationGetCrc; +jmethodID method_secondOrderHarmonicPerturbationGetCrs; +jmethodID method_secondOrderHarmonicPerturbationGetCuc; +jmethodID method_secondOrderHarmonicPerturbationGetCus; + +jmethodID method_klobucharIonosphericModelGetAlpha0; +jmethodID method_klobucharIonosphericModelGetAlpha1; +jmethodID method_klobucharIonosphericModelGetAlpha2; +jmethodID method_klobucharIonosphericModelGetAlpha3; +jmethodID method_klobucharIonosphericModelGetBeta0; +jmethodID method_klobucharIonosphericModelGetBeta1; +jmethodID method_klobucharIonosphericModelGetBeta2; +jmethodID method_klobucharIonosphericModelGetBeta3; + +jmethodID method_utcModelGetA0; +jmethodID method_utcModelGetA1; +jmethodID method_utcModelGetTimeOfWeek; +jmethodID method_utcModelGetWeekNumber; + +jmethodID method_leapSecondsModelGetDayNumberLeapSecondsFuture; +jmethodID method_leapSecondsModelGetLeapSeconds; +jmethodID method_leapSecondsModelGetLeapSecondsFuture; +jmethodID method_leapSecondsModelGetWeekNumberLeapSecondsFuture; + +jmethodID method_timeModelsGetTimeOfWeek; +jmethodID method_timeModelsGetToGnss; +jmethodID method_timeModelsGetWeekNumber; +jmethodID method_timeModelsGetA0; +jmethodID method_timeModelsGetA1; + +jmethodID method_realTimeIntegrityModelGetBadSvid; +jmethodID method_realTimeIntegrityModelGetBadSignalTypes; +jmethodID method_realTimeIntegrityModelGetStartDateSeconds; +jmethodID method_realTimeIntegrityModelGetEndDateSeconds; +jmethodID method_realTimeIntegrityModelGetPublishDateSeconds; +jmethodID method_realTimeIntegrityModelGetAdvisoryNumber; +jmethodID method_realTimeIntegrityModelGetAdvisoryType; + +jmethodID method_gnssSignalTypeGetConstellationType; +jmethodID method_gnssSignalTypeGetCarrierFrequencyHz; +jmethodID method_gnssSignalTypeGetCodeType; + +jmethodID method_auxiliaryInformationGetSvid; +jmethodID method_auxiliaryInformationGetAvailableSignalTypes; +jmethodID method_auxiliaryInformationGetFrequencyChannelNumber; +jmethodID method_auxiliaryInformationGetSatType; + +jmethodID method_satelliteCorrectionGetSvid; +jmethodID method_satelliteCorrectionGetIonosphericCorrections; +jmethodID method_ionosphericCorrectionGetCarrierFrequencyHz; +jmethodID method_ionosphericCorrectionGetIonosphericCorrection; +jmethodID method_gnssCorrectionComponentGetPseudorangeCorrection; +jmethodID method_gnssCorrectionComponentGetSourceKey; +jmethodID method_gnssCorrectionComponentGetValidityInterval; +jmethodID method_pseudorangeCorrectionGetCorrectionMeters; +jmethodID method_pseudorangeCorrectionGetCorrectionUncertaintyMeters; +jmethodID method_pseudorangeCorrectionGetCorrectionRateMetersPerSecond; +jmethodID method_gnssIntervalGetStartMillisSinceGpsEpoch; +jmethodID method_gnssIntervalGetEndMillisSinceGpsEpoch; + +jmethodID method_gpsAssistanceGetAlmanac; +jmethodID method_gpsAssistanceGetIonosphericModel; +jmethodID method_gpsAssistanceGetUtcModel; +jmethodID method_gpsAssistanceGetLeapSecondsModel; +jmethodID method_gpsAssistanceGetTimeModels; +jmethodID method_gpsAssistanceGetSatelliteEphemeris; +jmethodID method_gpsAssistanceGetRealTimeIntegrityModels; +jmethodID method_gpsAssistanceGetSatelliteCorrections; +jmethodID method_gpsSatelliteEphemerisGetSvid; +jmethodID method_gpsSatelliteEphemerisGetGpsL2Params; +jmethodID method_gpsSatelliteEphemerisGetSatelliteClockModel; +jmethodID method_gpsSatelliteEphemerisGetSatelliteOrbitModel; +jmethodID method_gpsSatelliteEphemerisGetSatelliteHealth; +jmethodID method_gpsSatelliteEphemerisGetSatelliteEphemerisTime; +jmethodID method_gpsL2ParamsGetL2Code; +jmethodID method_gpsL2ParamsGetL2Flag; +jmethodID method_gpsSatelliteClockModelGetAf0; +jmethodID method_gpsSatelliteClockModelGetAf1; +jmethodID method_gpsSatelliteClockModelGetAf2; +jmethodID method_gpsSatelliteClockModelGetTgd; +jmethodID method_gpsSatelliteClockModelGetIodc; +jmethodID method_gpsSatelliteClockModelGetTimeOfClockSeconds; +jmethodID method_gpsSatelliteHealthGetFitInt; +jmethodID method_gpsSatelliteHealthGetSvAccur; +jmethodID method_gpsSatelliteHealthGetSvHealth; + +jmethodID method_beidouAssistanceGetAlmanac; +jmethodID method_beidouAssistanceGetIonosphericModel; +jmethodID method_beidouAssistanceGetUtcModel; +jmethodID method_beidouAssistanceGetLeapSecondsModel; +jmethodID method_beidouAssistanceGetTimeModels; +jmethodID method_beidouAssistanceGetSatelliteEphemeris; +jmethodID method_beidouAssistanceGetSatelliteCorrections; +jmethodID method_beidouAssistanceGetRealTimeIntegrityModels; +jmethodID method_beidouSatelliteEphemerisGetSvid; +jmethodID method_beidouSatelliteEphemerisGetSatelliteClockModel; +jmethodID method_beidouSatelliteEphemerisGetSatelliteOrbitModel; +jmethodID method_beidouSatelliteEphemerisGetSatelliteHealth; +jmethodID method_beidouSatelliteEphemerisGetSatelliteEphemerisTime; +jmethodID method_beidouSatelliteClockModelGetAf0; +jmethodID method_beidouSatelliteClockModelGetAf1; +jmethodID method_beidouSatelliteClockModelGetAf2; +jmethodID method_beidouSatelliteClockModelGetAodc; +jmethodID method_beidouSatelliteClockModelGetTgd1; +jmethodID method_beidouSatelliteClockModelGetTgd2; +jmethodID method_beidouSatelliteClockModelGetTimeOfClockSeconds; +jmethodID method_beidouSatelliteHealthGetSatH1; +jmethodID method_beidouSatelliteHealthGetSvAccur; +jmethodID method_beidouSatelliteEphemerisTimeGetIode; +jmethodID method_beidouSatelliteEphemerisTimeGetBeidouWeekNumber; +jmethodID method_beidouSatelliteEphemerisTimeGetToeSeconds; + +jmethodID method_galileoAssistanceGetAlmanac; +jmethodID method_galileoAssistanceGetIonosphericModel; +jmethodID method_galileoAssistanceGetUtcModel; +jmethodID method_galileoAssistanceGetLeapSecondsModel; +jmethodID method_galileoAssistanceGetTimeModels; +jmethodID method_galileoAssistanceGetSatelliteEphemeris; +jmethodID method_galileoAssistanceGetSatelliteCorrections; +jmethodID method_galileoAssistanceGetRealTimeIntegrityModels; +jmethodID method_galileoSatelliteEphemerisGetSvid; +jmethodID method_galileoSatelliteEphemerisGetSatelliteClockModels; +jmethodID method_galileoSatelliteEphemerisGetSatelliteOrbitModel; +jmethodID method_galileoSatelliteEphemerisGetSatelliteHealth; +jmethodID method_galileoSatelliteEphemerisGetSatelliteEphemerisTime; +jmethodID method_galileoSatelliteClockModelGetAf0; +jmethodID method_galileoSatelliteClockModelGetAf1; +jmethodID method_galileoSatelliteClockModelGetAf2; +jmethodID method_galileoSatelliteClockModelGetBgdSeconds; +jmethodID method_galileoSatelliteClockModelGetSatelliteClockType; +jmethodID method_galileoSatelliteClockModelGetSisaMeters; +jmethodID method_galileoSatelliteClockModelGetTimeOfClockSeconds; +jmethodID method_galileoSvHealthGetDataValidityStatusE1b; +jmethodID method_galileoSvHealthGetDataValidityStatusE5a; +jmethodID method_galileoSvHealthGetDataValidityStatusE5b; +jmethodID method_galileoSvHealthGetSignalHealthStatusE1b; +jmethodID method_galileoSvHealthGetSignalHealthStatusE5a; +jmethodID method_galileoSvHealthGetSignalHealthStatusE5b; +jmethodID method_galileoIonosphericModelGetAi0; +jmethodID method_galileoIonosphericModelGetAi1; +jmethodID method_galileoIonosphericModelGetAi2; + +jmethodID method_glonassAssistanceGetAlmanac; +jmethodID method_glonassAssistanceGetUtcModel; +jmethodID method_glonassAssistanceGetTimeModels; +jmethodID method_glonassAssistanceGetSatelliteEphemeris; +jmethodID method_glonassAssistanceGetSatelliteCorrections; +jmethodID method_glonassAlmanacGetIssueDateMillis; +jmethodID method_glonassAlmanacGetSatelliteAlmanacs; +jmethodID method_glonassSatelliteAlmanacGetDeltaI; +jmethodID method_glonassSatelliteAlmanacGetDeltaT; +jmethodID method_glonassSatelliteAlmanacGetDeltaTDot; +jmethodID method_glonassSatelliteAlmanacGetEccentricity; +jmethodID method_glonassSatelliteAlmanacGetFrequencyChannelNumber; +jmethodID method_glonassSatelliteAlmanacGetLambda; +jmethodID method_glonassSatelliteAlmanacGetOmega; +jmethodID method_glonassSatelliteAlmanacGetSlotNumber; +jmethodID method_glonassSatelliteAlmanacGetHealthState; +jmethodID method_glonassSatelliteAlmanacGetTLambda; +jmethodID method_glonassSatelliteAlmanacGetTau; +jmethodID method_glonassSatelliteAlmanacGetIsGlonassM; +jmethodID method_glonassSatelliteAlmanacGetCalendarDayNumber; +jmethodID method_glonassSatelliteEphemerisGetAgeInDays; +jmethodID method_glonassSatelliteEphemerisGetSatelliteClockModel; +jmethodID method_glonassSatelliteEphemerisGetSatelliteOrbitModel; +jmethodID method_glonassSatelliteEphemerisGetHealthState; +jmethodID method_glonassSatelliteEphemerisGetSlotNumber; +jmethodID method_glonassSatelliteEphemerisGetFrameTimeSeconds; +jmethodID method_glonassSatelliteEphemerisGetUpdateIntervalMinutes; +jmethodID method_glonassSatelliteEphemerisGetIsGlonassM; +jmethodID method_glonassSatelliteEphemerisGetIsUpdateIntervalOdd; + +jmethodID method_glonassSatelliteOrbitModelGetX; +jmethodID method_glonassSatelliteOrbitModelGetY; +jmethodID method_glonassSatelliteOrbitModelGetZ; +jmethodID method_glonassSatelliteOrbitModelGetXAccel; +jmethodID method_glonassSatelliteOrbitModelGetYAccel; +jmethodID method_glonassSatelliteOrbitModelGetZAccel; +jmethodID method_glonassSatelliteOrbitModelGetXDot; +jmethodID method_glonassSatelliteOrbitModelGetYDot; +jmethodID method_glonassSatelliteOrbitModelGetZDot; +jmethodID method_glonassSatelliteClockModelGetClockBias; +jmethodID method_glonassSatelliteClockModelGetFrequencyBias; +jmethodID method_glonassSatelliteClockModelGetFrequencyChannelNumber; +jmethodID method_glonassSatelliteClockModelGetTimeOfClockSeconds; + +jmethodID method_qzssAssistanceGetAlmanac; +jmethodID method_qzssAssistanceGetIonosphericModel; +jmethodID method_qzssAssistanceGetUtcModel; +jmethodID method_qzssAssistanceGetLeapSecondsModel; +jmethodID method_qzssAssistanceGetTimeModels; +jmethodID method_qzssAssistanceGetSatelliteEphemeris; +jmethodID method_qzssAssistanceGetSatelliteCorrections; +jmethodID method_qzssAssistanceGetRealTimeIntegrityModels; +jmethodID method_qzssSatelliteEphemerisGetSvid; +jmethodID method_qzssSatelliteEphemerisGetGpsL2Params; +jmethodID method_qzssSatelliteEphemerisGetSatelliteClockModel; +jmethodID method_qzssSatelliteEphemerisGetSatelliteOrbitModel; +jmethodID method_qzssSatelliteEphemerisGetSatelliteHealth; +jmethodID method_qzssSatelliteEphemerisGetSatelliteEphemerisTime; +jmethodID method_qzssSatelliteClockModelGetAf0; +jmethodID method_qzssSatelliteClockModelGetAf1; +jmethodID method_qzssSatelliteClockModelGetAf2; +jmethodID method_qzssSatelliteClockModelGetAodc; +jmethodID method_qzssSatelliteClockModelGetTgd1; +jmethodID method_qzssSatelliteClockModelGetTgd2; +jmethodID method_qzssSatelliteClockModelGetTimeOfClockSeconds; +} // namespace + +void GnssAssistance_class_init_once(JNIEnv* env, jclass clazz) { + // Get the methods of GnssAssistance class. + jclass gnssAssistanceClass = env->FindClass("android/location/GnssAssistance"); + + method_gnssAssistanceGetGpsAssistance = + env->GetMethodID(gnssAssistanceClass, "getGpsAssistance", + "()Landroid/location/GpsAssistance;"); + method_gnssAssistanceGetGlonassAssistance = + env->GetMethodID(gnssAssistanceClass, "getGlonassAssistance", + "()Landroid/location/GlonassAssistance;"); + method_gnssAssistanceGetGalileoAssistance = + env->GetMethodID(gnssAssistanceClass, "getGalileoAssistance", + "()Landroid/location/GalileoAssistance;"); + method_gnssAssistanceGetBeidouAssistance = + env->GetMethodID(gnssAssistanceClass, "getBeidouAssistance", + "()Landroid/location/BeidouAssistance;"); + method_gnssAssistanceGetQzssAssistance = + env->GetMethodID(gnssAssistanceClass, "getQzssAssistance", + "()Landroid/location/QzssAssistance;"); + + // Get the methods of List class. + jclass listClass = env->FindClass("java/util/List"); + + method_listSize = env->GetMethodID(listClass, "size", "()I"); + method_listGet = env->GetMethodID(listClass, "get", "(I)Ljava/lang/Object;"); + + // Get the methods of GnssAlmanac class. + jclass gnssAlmanacClass = env->FindClass("android/location/GnssAlmanac"); + + method_gnssAlmanacGetIssueDateMillis = + env->GetMethodID(gnssAlmanacClass, "getIssueDateMillis", "()J"); + method_gnssAlmanacGetIoda = env->GetMethodID(gnssAlmanacClass, "getIoda", "()I"); + method_gnssAlmanacGetWeekNumber = env->GetMethodID(gnssAlmanacClass, "getWeekNumber", "()I"); + method_gnssAlmanacGetToaSeconds = env->GetMethodID(gnssAlmanacClass, "getToaSeconds", "()I"); + method_gnssAlmanacGetSatelliteAlmanacs = + env->GetMethodID(gnssAlmanacClass, "getGnssSatelliteAlmanacs", "()Ljava/util/List;"); + method_gnssAlmanacIsCompleteAlmanacProvided = + env->GetMethodID(gnssAlmanacClass, "isCompleteAlmanacProvided", "()Z"); + + // Get the methods of SatelliteAlmanac class. + jclass satelliteAlmanacClass = + env->FindClass("android/location/GnssAlmanac$GnssSatelliteAlmanac"); + + method_satelliteAlmanacGetSvid = env->GetMethodID(satelliteAlmanacClass, "getSvid", "()I"); + method_satelliteAlmanacGetSvHealth = + env->GetMethodID(satelliteAlmanacClass, "getSvHealth", "()I"); + method_satelliteAlmanacGetAf0 = env->GetMethodID(satelliteAlmanacClass, "getAf0", "()D"); + method_satelliteAlmanacGetAf1 = env->GetMethodID(satelliteAlmanacClass, "getAf1", "()D"); + method_satelliteAlmanacGetEccentricity = + env->GetMethodID(satelliteAlmanacClass, "getEccentricity", "()D"); + method_satelliteAlmanacGetInclination = + env->GetMethodID(satelliteAlmanacClass, "getInclination", "()D"); + method_satelliteAlmanacGetM0 = env->GetMethodID(satelliteAlmanacClass, "getM0", "()D"); + method_satelliteAlmanacGetOmega = env->GetMethodID(satelliteAlmanacClass, "getOmega", "()D"); + method_satelliteAlmanacGetOmega0 = env->GetMethodID(satelliteAlmanacClass, "getOmega0", "()D"); + method_satelliteAlmanacGetOmegaDot = + env->GetMethodID(satelliteAlmanacClass, "getOmegaDot", "()D"); + method_satelliteAlmanacGetRootA = env->GetMethodID(satelliteAlmanacClass, "getRootA", "()D"); + + // Get the mothods of SatelliteEphemerisTime class. + jclass satelliteEphemerisTimeClass = env->FindClass("android/location/SatelliteEphemerisTime"); + + method_satelliteEphemerisTimeGetIode = + env->GetMethodID(satelliteEphemerisTimeClass, "getIode", "()I"); + method_satelliteEphemerisTimeGetToeSeconds = + env->GetMethodID(satelliteEphemerisTimeClass, "getToeSeconds", "()I"); + method_satelliteEphemerisTimeGetWeekNumber = + env->GetMethodID(satelliteEphemerisTimeClass, "getWeekNumber", "()I"); + + // Get the mothods of KeplerianOrbitModel class. + jclass keplerianOrbitModelClass = env->FindClass("android/location/KeplerianOrbitModel"); + + method_keplerianOrbitModelGetDeltaN = + env->GetMethodID(keplerianOrbitModelClass, "getDeltaN", "()D"); + method_keplerianOrbitModelGetEccentricity = + env->GetMethodID(keplerianOrbitModelClass, "getEccentricity", "()D"); + method_keplerianOrbitModelGetI0 = env->GetMethodID(keplerianOrbitModelClass, "getI0", "()D"); + method_keplerianOrbitModelGetIDot = + env->GetMethodID(keplerianOrbitModelClass, "getIDot", "()D"); + method_keplerianOrbitModelGetM0 = env->GetMethodID(keplerianOrbitModelClass, "getM0", "()D"); + method_keplerianOrbitModelGetOmega = + env->GetMethodID(keplerianOrbitModelClass, "getOmega", "()D"); + method_keplerianOrbitModelGetOmega0 = + env->GetMethodID(keplerianOrbitModelClass, "getOmega0", "()D"); + method_keplerianOrbitModelGetOmegaDot = + env->GetMethodID(keplerianOrbitModelClass, "getOmegaDot", "()D"); + method_keplerianOrbitModelGetRootA = + env->GetMethodID(keplerianOrbitModelClass, "getRootA", "()D"); + method_keplerianOrbitModelGetSecondOrderHarmonicPerturbation = + env->GetMethodID(keplerianOrbitModelClass, "getSecondOrderHarmonicPerturbation", + "()Landroid/location/" + "KeplerianOrbitModel$SecondOrderHarmonicPerturbation;"); + + // Get the methods of SecondOrderHarmonicPerturbation class. + jclass secondOrderHarmonicPerturbationClass = + env->FindClass("android/location/KeplerianOrbitModel$SecondOrderHarmonicPerturbation"); + + method_secondOrderHarmonicPerturbationGetCic = + env->GetMethodID(secondOrderHarmonicPerturbationClass, "getCic", "()D"); + method_secondOrderHarmonicPerturbationGetCis = + env->GetMethodID(secondOrderHarmonicPerturbationClass, "getCis", "()D"); + method_secondOrderHarmonicPerturbationGetCrc = + env->GetMethodID(secondOrderHarmonicPerturbationClass, "getCrc", "()D"); + method_secondOrderHarmonicPerturbationGetCrs = + env->GetMethodID(secondOrderHarmonicPerturbationClass, "getCrs", "()D"); + method_secondOrderHarmonicPerturbationGetCuc = + env->GetMethodID(secondOrderHarmonicPerturbationClass, "getCuc", "()D"); + method_secondOrderHarmonicPerturbationGetCus = + env->GetMethodID(secondOrderHarmonicPerturbationClass, "getCus", "()D"); + + // Get the methods of KlobucharIonosphericModel class. + jclass klobucharIonosphericModelClass = + env->FindClass("android/location/KlobucharIonosphericModel"); + + method_klobucharIonosphericModelGetAlpha0 = + env->GetMethodID(klobucharIonosphericModelClass, "getAlpha0", "()D"); + method_klobucharIonosphericModelGetAlpha1 = + env->GetMethodID(klobucharIonosphericModelClass, "getAlpha1", "()D"); + method_klobucharIonosphericModelGetAlpha2 = + env->GetMethodID(klobucharIonosphericModelClass, "getAlpha2", "()D"); + method_klobucharIonosphericModelGetAlpha3 = + env->GetMethodID(klobucharIonosphericModelClass, "getAlpha3", "()D"); + method_klobucharIonosphericModelGetBeta0 = + env->GetMethodID(klobucharIonosphericModelClass, "getBeta0", "()D"); + method_klobucharIonosphericModelGetBeta1 = + env->GetMethodID(klobucharIonosphericModelClass, "getBeta1", "()D"); + method_klobucharIonosphericModelGetBeta2 = + env->GetMethodID(klobucharIonosphericModelClass, "getBeta2", "()D"); + method_klobucharIonosphericModelGetBeta3 = + env->GetMethodID(klobucharIonosphericModelClass, "getBeta3", "()D"); + + // Get the methods of UtcModel class. + jclass utcModelClass = env->FindClass("android/location/UtcModel"); + + method_utcModelGetA0 = env->GetMethodID(utcModelClass, "getA0", "()D"); + method_utcModelGetA1 = env->GetMethodID(utcModelClass, "getA1", "()D"); + method_utcModelGetTimeOfWeek = env->GetMethodID(utcModelClass, "getTimeOfWeek", "()I"); + method_utcModelGetWeekNumber = env->GetMethodID(utcModelClass, "getWeekNumber", "()I"); + + // Get the methods of LeapSecondsModel class. + jclass leapSecondsModelClass = env->FindClass("android/location/LeapSecondsModel"); + + method_leapSecondsModelGetDayNumberLeapSecondsFuture = + env->GetMethodID(leapSecondsModelClass, "getDayNumberLeapSecondsFuture", "()I"); + method_leapSecondsModelGetLeapSeconds = + env->GetMethodID(leapSecondsModelClass, "getLeapSeconds", "()I"); + method_leapSecondsModelGetLeapSecondsFuture = + env->GetMethodID(leapSecondsModelClass, "getLeapSecondsFuture", "()I"); + method_leapSecondsModelGetWeekNumberLeapSecondsFuture = + env->GetMethodID(leapSecondsModelClass, "getWeekNumberLeapSecondsFuture", "()I"); + + // Get the methods of TimeModel class. + jclass timeModelsClass = env->FindClass("android/location/TimeModel"); + + method_timeModelsGetTimeOfWeek = env->GetMethodID(timeModelsClass, "getTimeOfWeek", "()I"); + method_timeModelsGetToGnss = env->GetMethodID(timeModelsClass, "getToGnss", "()I"); + method_timeModelsGetWeekNumber = env->GetMethodID(timeModelsClass, "getWeekNumber", "()I"); + method_timeModelsGetA0 = env->GetMethodID(timeModelsClass, "getA0", "()D"); + method_timeModelsGetA1 = env->GetMethodID(timeModelsClass, "getA1", "()D"); + + // Get the methods of AuxiliaryInformation class. + jclass auxiliaryInformationClass = env->FindClass("android/location/AuxiliaryInformation"); + + method_auxiliaryInformationGetSvid = + env->GetMethodID(auxiliaryInformationClass, "getSvid", "()I"); + method_auxiliaryInformationGetAvailableSignalTypes = + env->GetMethodID(auxiliaryInformationClass, "getAvailableSignalTypes", + "()Ljava/util/List;"); + method_auxiliaryInformationGetFrequencyChannelNumber = + env->GetMethodID(auxiliaryInformationClass, "getFrequencyChannelNumber", "()I"); + method_auxiliaryInformationGetSatType = + env->GetMethodID(auxiliaryInformationClass, "getSatType", "()I"); + + // Get the methods of RealTimeIntegrityModel + jclass realTimeIntegrityModelClass = env->FindClass("android/location/RealTimeIntegrityModel"); + + method_realTimeIntegrityModelGetBadSvid = + env->GetMethodID(realTimeIntegrityModelClass, "getBadSvid", "()I"); + method_realTimeIntegrityModelGetBadSignalTypes = + env->GetMethodID(realTimeIntegrityModelClass, "getBadSignalTypes", + "()Ljava/util/List;"); + method_realTimeIntegrityModelGetStartDateSeconds = + env->GetMethodID(realTimeIntegrityModelClass, "getStartDateSeconds", "()J"); + method_realTimeIntegrityModelGetEndDateSeconds = + env->GetMethodID(realTimeIntegrityModelClass, "getEndDateSeconds", "()J"); + method_realTimeIntegrityModelGetPublishDateSeconds = + env->GetMethodID(realTimeIntegrityModelClass, "getPublishDateSeconds", "()J"); + method_realTimeIntegrityModelGetAdvisoryNumber = + env->GetMethodID(realTimeIntegrityModelClass, "getAdvisoryNumber", + "()Ljava/lang/String;"); + method_realTimeIntegrityModelGetAdvisoryType = + env->GetMethodID(realTimeIntegrityModelClass, "getAdvisoryType", + "()Ljava/lang/String;"); + + // Get the methods of GnssSignalType class. + jclass gnssSignalTypeClass = env->FindClass("android/location/GnssSignalType"); + + method_gnssSignalTypeGetConstellationType = + env->GetMethodID(gnssSignalTypeClass, "getConstellationType", "()I"); + method_gnssSignalTypeGetCarrierFrequencyHz = + env->GetMethodID(gnssSignalTypeClass, "getCarrierFrequencyHz", "()D"); + method_gnssSignalTypeGetCodeType = + env->GetMethodID(gnssSignalTypeClass, "getCodeType", "()Ljava/lang/String;"); + + // Get the methods of SatelliteCorrection class. + jclass satelliteCorrectionClass = + env->FindClass("android/location/GnssAssistance$GnssSatelliteCorrections"); + + method_satelliteCorrectionGetSvid = + env->GetMethodID(satelliteCorrectionClass, "getSvid", "()I"); + method_satelliteCorrectionGetIonosphericCorrections = + env->GetMethodID(satelliteCorrectionClass, "getIonosphericCorrections", + "()Ljava/util/List;"); + + // Get the methods of IonosphericCorrection class. + jclass ionosphericCorrectionClass = env->FindClass("android/location/IonosphericCorrection"); + + method_ionosphericCorrectionGetCarrierFrequencyHz = + env->GetMethodID(ionosphericCorrectionClass, "getCarrierFrequencyHz", "()J"); + method_ionosphericCorrectionGetIonosphericCorrection = + env->GetMethodID(ionosphericCorrectionClass, "getIonosphericCorrection", + "()Landroid/location/GnssCorrectionComponent;"); + + // Get the methods of GnssCorrectionComponent class. + jclass gnssCorrectionComponentClass = + env->FindClass("android/location/GnssCorrectionComponent"); + + method_gnssCorrectionComponentGetPseudorangeCorrection = + env->GetMethodID(gnssCorrectionComponentClass, "getPseudorangeCorrection", + "()Landroid/location/GnssCorrectionComponent$PseudorangeCorrection;"); + method_gnssCorrectionComponentGetSourceKey = + env->GetMethodID(gnssCorrectionComponentClass, "getSourceKey", "()Ljava/lang/String;"); + method_gnssCorrectionComponentGetValidityInterval = + env->GetMethodID(gnssCorrectionComponentClass, "getValidityInterval", + "()Landroid/location/GnssCorrectionComponent$GnssInterval;"); + + // Get the methods of PseudorangeCorrection class. + jclass pseudorangeCorrectionClass = + env->FindClass("android/location/GnssCorrectionComponent$PseudorangeCorrection"); + + method_pseudorangeCorrectionGetCorrectionMeters = + env->GetMethodID(pseudorangeCorrectionClass, "getCorrectionMeters", "()D"); + method_pseudorangeCorrectionGetCorrectionRateMetersPerSecond = + env->GetMethodID(pseudorangeCorrectionClass, "getCorrectionRateMetersPerSecond", "()D"); + method_pseudorangeCorrectionGetCorrectionUncertaintyMeters = + env->GetMethodID(pseudorangeCorrectionClass, "getCorrectionUncertaintyMeters", "()D"); + + // Get the methods of GnssInterval class. + jclass gnssIntervalClass = + env->FindClass("android/location/GnssCorrectionComponent$GnssInterval"); + + method_gnssIntervalGetStartMillisSinceGpsEpoch = + env->GetMethodID(gnssIntervalClass, "getStartMillisSinceGpsEpoch", "()J"); + method_gnssIntervalGetEndMillisSinceGpsEpoch = + env->GetMethodID(gnssIntervalClass, "getEndMillisSinceGpsEpoch", "()J"); + + // Get the methods of GpsAssistance class. + jclass gpsAssistanceClass = env->FindClass("android/location/GpsAssistance"); + + method_gpsAssistanceGetAlmanac = + env->GetMethodID(gpsAssistanceClass, "getAlmanac", "()Landroid/location/GnssAlmanac;"); + method_gpsAssistanceGetIonosphericModel = + env->GetMethodID(gpsAssistanceClass, "getIonosphericModel", + "()Landroid/location/KlobucharIonosphericModel;"); + method_gpsAssistanceGetUtcModel = + env->GetMethodID(gpsAssistanceClass, "getUtcModel", "()Landroid/location/UtcModel;"); + method_gpsAssistanceGetLeapSecondsModel = + env->GetMethodID(gpsAssistanceClass, "getLeapSecondsModel", + "()Landroid/location/LeapSecondsModel;"); + method_gpsAssistanceGetTimeModels = + env->GetMethodID(gpsAssistanceClass, "getTimeModels", "()Ljava/util/List;"); + method_gpsAssistanceGetSatelliteEphemeris = + env->GetMethodID(gpsAssistanceClass, "getSatelliteEphemeris", "()Ljava/util/List;"); + method_gpsAssistanceGetRealTimeIntegrityModels = + env->GetMethodID(gpsAssistanceClass, "getRealTimeIntegrityModels", + "()Ljava/util/List;"); + method_gpsAssistanceGetSatelliteCorrections = + env->GetMethodID(gpsAssistanceClass, "getSatelliteCorrections", "()Ljava/util/List;"); + + // Get the methods of GpsSatelliteEphemeris class. + jclass gpsSatelliteEphemerisClass = env->FindClass("android/location/GpsSatelliteEphemeris"); + + method_gpsSatelliteEphemerisGetSvid = + env->GetMethodID(gpsSatelliteEphemerisClass, "getSvid", "()I"); + method_gpsSatelliteEphemerisGetGpsL2Params = + env->GetMethodID(gpsSatelliteEphemerisClass, "getGpsL2Params", + "()Landroid/location/GpsSatelliteEphemeris$GpsL2Params;"); + method_gpsSatelliteEphemerisGetSatelliteClockModel = + env->GetMethodID(gpsSatelliteEphemerisClass, "getSatelliteClockModel", + "()Landroid/location/GpsSatelliteEphemeris$GpsSatelliteClockModel;"); + method_gpsSatelliteEphemerisGetSatelliteOrbitModel = + env->GetMethodID(gpsSatelliteEphemerisClass, "getSatelliteOrbitModel", + "()Landroid/location/KeplerianOrbitModel;"); + method_gpsSatelliteEphemerisGetSatelliteHealth = + env->GetMethodID(gpsSatelliteEphemerisClass, "getSatelliteHealth", + "()Landroid/location/GpsSatelliteEphemeris$GpsSatelliteHealth;"); + method_gpsSatelliteEphemerisGetSatelliteEphemerisTime = + env->GetMethodID(gpsSatelliteEphemerisClass, "getSatelliteEphemerisTime", + "()Landroid/location/SatelliteEphemerisTime;"); + + // Get the methods of GpsL2Params class. + jclass gpsL2ParamsClass = env->FindClass("android/location/GpsSatelliteEphemeris$GpsL2Params"); + method_gpsL2ParamsGetL2Code = env->GetMethodID(gpsL2ParamsClass, "getL2Code", "()I"); + method_gpsL2ParamsGetL2Flag = env->GetMethodID(gpsL2ParamsClass, "getL2Flag", "()I"); + + // Get the methods of GpsSatelliteClockModel class. + jclass gpsSatelliteClockModelClass = + env->FindClass("android/location/GpsSatelliteEphemeris$GpsSatelliteClockModel"); + method_gpsSatelliteClockModelGetAf0 = + env->GetMethodID(gpsSatelliteClockModelClass, "getAf0", "()D"); + method_gpsSatelliteClockModelGetAf1 = + env->GetMethodID(gpsSatelliteClockModelClass, "getAf1", "()D"); + method_gpsSatelliteClockModelGetAf2 = + env->GetMethodID(gpsSatelliteClockModelClass, "getAf2", "()D"); + method_gpsSatelliteClockModelGetTgd = + env->GetMethodID(gpsSatelliteClockModelClass, "getTgd", "()D"); + method_gpsSatelliteClockModelGetIodc = + env->GetMethodID(gpsSatelliteClockModelClass, "getIodc", "()I"); + method_gpsSatelliteClockModelGetTimeOfClockSeconds = + env->GetMethodID(gpsSatelliteClockModelClass, "getTimeOfClockSeconds", "()J"); + + // Get the methods of GpsSatelliteHealth class. + jclass gpsSatelliteHealthClass = + env->FindClass("android/location/GpsSatelliteEphemeris$GpsSatelliteHealth"); + method_gpsSatelliteHealthGetFitInt = + env->GetMethodID(gpsSatelliteHealthClass, "getFitInt", "()D"); + method_gpsSatelliteHealthGetSvAccur = + env->GetMethodID(gpsSatelliteHealthClass, "getSvAccur", "()D"); + method_gpsSatelliteHealthGetSvHealth = + env->GetMethodID(gpsSatelliteHealthClass, "getSvHealth", "()I"); + + // Get the methods of BeidouAssistance class. + jclass beidouAssistanceClass = env->FindClass("android/location/BeidouAssistance"); + method_beidouAssistanceGetAlmanac = env->GetMethodID(beidouAssistanceClass, "getAlmanac", + "()Landroid/location/GnssAlmanac;"); + method_beidouAssistanceGetIonosphericModel = + env->GetMethodID(beidouAssistanceClass, "getIonosphericModel", + "()Landroid/location/KlobucharIonosphericModel;"); + method_beidouAssistanceGetUtcModel = + env->GetMethodID(beidouAssistanceClass, "getUtcModel", "()Landroid/location/UtcModel;"); + method_beidouAssistanceGetLeapSecondsModel = + env->GetMethodID(beidouAssistanceClass, "getLeapSecondsModel", + "()Landroid/location/LeapSecondsModel;"); + method_beidouAssistanceGetTimeModels = + env->GetMethodID(beidouAssistanceClass, "getTimeModels", "()Ljava/util/List;"); + method_beidouAssistanceGetSatelliteEphemeris = + env->GetMethodID(beidouAssistanceClass, "getSatelliteEphemeris", "()Ljava/util/List;"); + method_beidouAssistanceGetSatelliteCorrections = + env->GetMethodID(beidouAssistanceClass, "getSatelliteCorrections", + "()Ljava/util/List;"); + method_beidouAssistanceGetRealTimeIntegrityModels = + env->GetMethodID(beidouAssistanceClass, "getRealTimeIntegrityModels", + "()Ljava/util/List;"); + + // Get the methods of BeidouSatelliteEphemeris class. + jclass beidouSatelliteEphemerisClass = + env->FindClass("android/location/BeidouSatelliteEphemeris"); + method_beidouSatelliteEphemerisGetSvid = + env->GetMethodID(beidouSatelliteEphemerisClass, "getSvid", "()I"); + method_beidouSatelliteEphemerisGetSatelliteClockModel = + env->GetMethodID(beidouSatelliteEphemerisClass, "getSatelliteClockModel", + "()Landroid/location/" + "BeidouSatelliteEphemeris$BeidouSatelliteClockModel;"); + method_beidouSatelliteEphemerisGetSatelliteOrbitModel = + env->GetMethodID(beidouSatelliteEphemerisClass, "getSatelliteOrbitModel", + "()Landroid/location/KeplerianOrbitModel;"); + method_beidouSatelliteEphemerisGetSatelliteHealth = + env->GetMethodID(beidouSatelliteEphemerisClass, "getSatelliteHealth", + "()Landroid/location/BeidouSatelliteEphemeris$BeidouSatelliteHealth;"); + method_beidouSatelliteEphemerisGetSatelliteEphemerisTime = + env->GetMethodID(beidouSatelliteEphemerisClass, "getSatelliteEphemerisTime", + "()Landroid/location/" + "BeidouSatelliteEphemeris$BeidouSatelliteEphemerisTime;"); + + // Get the methods of BeidouSatelliteClockModel + jclass beidouSatelliteClockModelClass = + env->FindClass("android/location/BeidouSatelliteEphemeris$BeidouSatelliteClockModel"); + method_beidouSatelliteClockModelGetAf0 = + env->GetMethodID(beidouSatelliteClockModelClass, "getAf0", "()D"); + method_beidouSatelliteClockModelGetAf1 = + env->GetMethodID(beidouSatelliteClockModelClass, "getAf1", "()D"); + method_beidouSatelliteClockModelGetAf2 = + env->GetMethodID(beidouSatelliteClockModelClass, "getAf2", "()D"); + method_beidouSatelliteClockModelGetAodc = + env->GetMethodID(beidouSatelliteClockModelClass, "getAodc", "()I"); + method_beidouSatelliteClockModelGetTgd1 = + env->GetMethodID(beidouSatelliteClockModelClass, "getTgd1", "()D"); + method_beidouSatelliteClockModelGetTgd2 = + env->GetMethodID(beidouSatelliteClockModelClass, "getTgd2", "()D"); + method_beidouSatelliteClockModelGetTimeOfClockSeconds = + env->GetMethodID(beidouSatelliteClockModelClass, "getTimeOfClockSeconds", "()J"); + + // Get the methods of BeidouSatelliteHealth + jclass beidouSatelliteHealthClass = + env->FindClass("android/location/BeidouSatelliteEphemeris$BeidouSatelliteHealth"); + method_beidouSatelliteHealthGetSatH1 = + env->GetMethodID(beidouSatelliteHealthClass, "getSatH1", "()I"); + method_beidouSatelliteHealthGetSvAccur = + env->GetMethodID(beidouSatelliteHealthClass, "getSvAccur", "()D"); + + // Get the methods of BeidouSatelliteEphemerisTime + jclass beidouSatelliteEphemerisTimeClass = env->FindClass( + "android/location/BeidouSatelliteEphemeris$BeidouSatelliteEphemerisTime"); + method_beidouSatelliteEphemerisTimeGetIode = + env->GetMethodID(beidouSatelliteEphemerisTimeClass, "getIode", "()I"); + method_beidouSatelliteEphemerisTimeGetBeidouWeekNumber = + env->GetMethodID(beidouSatelliteEphemerisTimeClass, "getBeidouWeekNumber", "()I"); + method_beidouSatelliteEphemerisTimeGetToeSeconds = + env->GetMethodID(beidouSatelliteEphemerisTimeClass, "getToeSeconds", "()I"); + + // Get the methods of GalileoAssistance class. + jclass galileoAssistanceClass = env->FindClass("android/location/GalileoAssistance"); + method_galileoAssistanceGetAlmanac = env->GetMethodID(galileoAssistanceClass, "getAlmanac", + "()Landroid/location/GnssAlmanac;"); + method_galileoAssistanceGetIonosphericModel = + env->GetMethodID(galileoAssistanceClass, "getIonosphericModel", + "()Landroid/location/KlobucharIonosphericModel;"); + method_galileoAssistanceGetUtcModel = env->GetMethodID(galileoAssistanceClass, "getUtcModel", + "()Landroid/location/UtcModel;"); + method_galileoAssistanceGetLeapSecondsModel = + env->GetMethodID(galileoAssistanceClass, "getLeapSecondsModel", + "()Landroid/location/LeapSecondsModel;"); + method_galileoAssistanceGetTimeModels = + env->GetMethodID(galileoAssistanceClass, "getTimeModels", "()Ljava/util/List;"); + method_galileoAssistanceGetSatelliteEphemeris = + env->GetMethodID(galileoAssistanceClass, "getSatelliteEphemeris", "()Ljava/util/List;"); + method_galileoAssistanceGetSatelliteCorrections = + env->GetMethodID(galileoAssistanceClass, "getSatelliteCorrections", + "()Ljava/util/List;"); + method_galileoAssistanceGetRealTimeIntegrityModels = + env->GetMethodID(galileoAssistanceClass, "getRealTimeIntegrityModels", + "()Ljava/util/List;"); + + // Get the methods of GalileoSatelliteEphemeris class + jclass galileoSatelliteEphemerisClass = + env->FindClass("android/location/GalileoSatelliteEphemeris"); + method_galileoSatelliteEphemerisGetSatelliteClockModels = + env->GetMethodID(galileoSatelliteEphemerisClass, "getSatelliteClockModels", + "()Ljava/util/List;"); + method_galileoSatelliteEphemerisGetSvid = + env->GetMethodID(galileoSatelliteEphemerisClass, "getSvid", "()I"); + method_galileoSatelliteEphemerisGetSatelliteEphemerisTime = + env->GetMethodID(galileoSatelliteEphemerisClass, "getSatelliteEphemerisTime", + "()Landroid/location/SatelliteEphemerisTime;"); + method_galileoSatelliteEphemerisGetSatelliteHealth = + env->GetMethodID(galileoSatelliteEphemerisClass, "getSatelliteHealth", + "()Landroid/location/GalileoSatelliteEphemeris$GalileoSvHealth;"); + method_galileoSatelliteEphemerisGetSatelliteOrbitModel = + env->GetMethodID(galileoSatelliteEphemerisClass, "getSatelliteOrbitModel", + "()Landroid/location/KeplerianOrbitModel;"); + + // Get the methods of GalileoSatelliteClockModel class. + jclass galileoSatelliteClockModelClass = + env->FindClass("android/location/GalileoSatelliteEphemeris$GalileoSatelliteClockModel"); + method_galileoSatelliteClockModelGetAf0 = + env->GetMethodID(galileoSatelliteClockModelClass, "getAf0", "()D"); + method_galileoSatelliteClockModelGetAf1 = + env->GetMethodID(galileoSatelliteClockModelClass, "getAf1", "()D"); + method_galileoSatelliteClockModelGetAf2 = + env->GetMethodID(galileoSatelliteClockModelClass, "getAf2", "()D"); + method_galileoSatelliteClockModelGetBgdSeconds = + env->GetMethodID(galileoSatelliteClockModelClass, "getBgdSeconds", "()D"); + method_galileoSatelliteClockModelGetSatelliteClockType = + env->GetMethodID(galileoSatelliteClockModelClass, "getSatelliteClockType", "()I"); + method_galileoSatelliteClockModelGetSisaMeters = + env->GetMethodID(galileoSatelliteClockModelClass, "getSisaMeters", "()D"); + method_galileoSatelliteClockModelGetTimeOfClockSeconds = + env->GetMethodID(galileoSatelliteClockModelClass, "getTimeOfClockSeconds", "()J"); + + // Get the methods of GalileoSvHealth class. + jclass galileoSvHealthClass = + env->FindClass("android/location/GalileoSatelliteEphemeris$GalileoSvHealth"); + method_galileoSvHealthGetDataValidityStatusE1b = + env->GetMethodID(galileoSvHealthClass, "getDataValidityStatusE1b", "()I"); + method_galileoSvHealthGetDataValidityStatusE5a = + env->GetMethodID(galileoSvHealthClass, "getDataValidityStatusE5a", "()I"); + method_galileoSvHealthGetDataValidityStatusE5b = + env->GetMethodID(galileoSvHealthClass, "getDataValidityStatusE5b", "()I"); + method_galileoSvHealthGetSignalHealthStatusE1b = + env->GetMethodID(galileoSvHealthClass, "getSignalHealthStatusE1b", "()I"); + method_galileoSvHealthGetSignalHealthStatusE5a = + env->GetMethodID(galileoSvHealthClass, "getSignalHealthStatusE5a", "()I"); + method_galileoSvHealthGetSignalHealthStatusE5b = + env->GetMethodID(galileoSvHealthClass, "getSignalHealthStatusE5b", "()I"); + + // Get the methods of GalileoIonosphericModel class. + jclass galileoIonosphericModelClass = + env->FindClass("android/location/GalileoIonosphericModel"); + method_galileoIonosphericModelGetAi0 = + env->GetMethodID(galileoIonosphericModelClass, "getAi0", "()D"); + method_galileoIonosphericModelGetAi1 = + env->GetMethodID(galileoIonosphericModelClass, "getAi1", "()D"); + method_galileoIonosphericModelGetAi2 = + env->GetMethodID(galileoIonosphericModelClass, "getAi2", "()D"); + + // Get the methods of GlonassAssistance class. + jclass glonassAssistanceClass = env->FindClass("android/location/GlonassAssistance"); + method_glonassAssistanceGetAlmanac = env->GetMethodID(glonassAssistanceClass, "getAlmanac", + "()Landroid/location/GlonassAlmanac;"); + method_glonassAssistanceGetUtcModel = env->GetMethodID(glonassAssistanceClass, "getUtcModel", + "()Landroid/location/UtcModel;"); + method_glonassAssistanceGetTimeModels = + env->GetMethodID(glonassAssistanceClass, "getTimeModels", "()Ljava/util/List;"); + method_glonassAssistanceGetSatelliteEphemeris = + env->GetMethodID(glonassAssistanceClass, "getSatelliteEphemeris", "()Ljava/util/List;"); + method_glonassAssistanceGetSatelliteCorrections = + env->GetMethodID(glonassAssistanceClass, "getSatelliteCorrections", + "()Ljava/util/List;"); + + // Get the methods of GlonassAlmanac class. + jclass glonassAlmanacClass = env->FindClass("android/location/GlonassAlmanac"); + method_glonassAlmanacGetIssueDateMillis = + env->GetMethodID(glonassAlmanacClass, "getIssueDateMillis", "()J"); + method_glonassAlmanacGetSatelliteAlmanacs = + env->GetMethodID(glonassAlmanacClass, "getSatelliteAlmanacs", "()Ljava/util/List;"); + + // Get the methods of GlonassSatelliteAlmanac class + jclass glonassSatelliteAlmanacClass = + env->FindClass("android/location/GlonassAlmanac$GlonassSatelliteAlmanac"); + method_glonassSatelliteAlmanacGetDeltaI = + env->GetMethodID(glonassSatelliteAlmanacClass, "getDeltaI", "()D"); + method_glonassSatelliteAlmanacGetDeltaT = + env->GetMethodID(glonassSatelliteAlmanacClass, "getDeltaT", "()D"); + method_glonassSatelliteAlmanacGetDeltaTDot = + env->GetMethodID(glonassSatelliteAlmanacClass, "getDeltaTDot", "()D"); + method_glonassSatelliteAlmanacGetEccentricity = + env->GetMethodID(glonassSatelliteAlmanacClass, "getEccentricity", "()D"); + method_glonassSatelliteAlmanacGetFrequencyChannelNumber = + env->GetMethodID(glonassSatelliteAlmanacClass, "getFrequencyChannelNumber", "()I"); + method_glonassSatelliteAlmanacGetLambda = + env->GetMethodID(glonassSatelliteAlmanacClass, "getLambda", "()D"); + method_glonassSatelliteAlmanacGetOmega = + env->GetMethodID(glonassSatelliteAlmanacClass, "getOmega", "()D"); + method_glonassSatelliteAlmanacGetSlotNumber = + env->GetMethodID(glonassSatelliteAlmanacClass, "getSlotNumber", "()I"); + method_glonassSatelliteAlmanacGetHealthState = + env->GetMethodID(glonassSatelliteAlmanacClass, "getHealthState", "()I"); + method_glonassSatelliteAlmanacGetTLambda = + env->GetMethodID(glonassSatelliteAlmanacClass, "getTLambda", "()D"); + method_glonassSatelliteAlmanacGetTau = + env->GetMethodID(glonassSatelliteAlmanacClass, "getTau", "()D"); + method_glonassSatelliteAlmanacGetCalendarDayNumber = + env->GetMethodID(glonassSatelliteAlmanacClass, "getCalendarDayNumber", "()I"); + method_glonassSatelliteAlmanacGetIsGlonassM = + env->GetMethodID(glonassSatelliteAlmanacClass, "isGlonassM", "()Z"); + + // Get the methods of GlonassSatelliteEphemeris + jclass glonassSatelliteEphemerisClass = + env->FindClass("android/location/GlonassSatelliteEphemeris"); + method_glonassSatelliteEphemerisGetAgeInDays = + env->GetMethodID(glonassSatelliteEphemerisClass, "getAgeInDays", "()I"); + method_glonassSatelliteEphemerisGetFrameTimeSeconds = + env->GetMethodID(glonassSatelliteEphemerisClass, "getFrameTimeSeconds", "()D"); + method_glonassSatelliteEphemerisGetHealthState = + env->GetMethodID(glonassSatelliteEphemerisClass, "getHealthState", "()I"); + method_glonassSatelliteEphemerisGetSlotNumber = + env->GetMethodID(glonassSatelliteEphemerisClass, "getSlotNumber", "()I"); + method_glonassSatelliteEphemerisGetSatelliteClockModel = + env->GetMethodID(glonassSatelliteEphemerisClass, "getSatelliteClockModel", + "()Landroid/location/" + "GlonassSatelliteEphemeris$GlonassSatelliteClockModel;"); + method_glonassSatelliteEphemerisGetSatelliteOrbitModel = + env->GetMethodID(glonassSatelliteEphemerisClass, "getSatelliteOrbitModel", + "()Landroid/location/" + "GlonassSatelliteEphemeris$GlonassSatelliteOrbitModel;"); + method_glonassSatelliteEphemerisGetUpdateIntervalMinutes = + env->GetMethodID(glonassSatelliteEphemerisClass, "getUpdateIntervalMinutes", "()I"); + method_glonassSatelliteEphemerisGetIsGlonassM = + env->GetMethodID(glonassSatelliteEphemerisClass, "isGlonassM", "()Z"); + method_glonassSatelliteEphemerisGetIsUpdateIntervalOdd = + env->GetMethodID(glonassSatelliteEphemerisClass, "isUpdateIntervalOdd", "()Z"); + + // Get the methods of GlonassSatelliteOrbitModel + jclass glonassSatelliteOrbitModelClass = + env->FindClass("android/location/GlonassSatelliteEphemeris$GlonassSatelliteOrbitModel"); + method_glonassSatelliteOrbitModelGetX = + env->GetMethodID(glonassSatelliteOrbitModelClass, "getX", "()D"); + method_glonassSatelliteOrbitModelGetXAccel = + env->GetMethodID(glonassSatelliteOrbitModelClass, "getXAccel", "()D"); + method_glonassSatelliteOrbitModelGetXDot = + env->GetMethodID(glonassSatelliteOrbitModelClass, "getXDot", "()D"); + method_glonassSatelliteOrbitModelGetY = + env->GetMethodID(glonassSatelliteOrbitModelClass, "getY", "()D"); + method_glonassSatelliteOrbitModelGetYAccel = + env->GetMethodID(glonassSatelliteOrbitModelClass, "getYAccel", "()D"); + method_glonassSatelliteOrbitModelGetYDot = + env->GetMethodID(glonassSatelliteOrbitModelClass, "getYDot", "()D"); + method_glonassSatelliteOrbitModelGetZ = + env->GetMethodID(glonassSatelliteOrbitModelClass, "getZ", "()D"); + method_glonassSatelliteOrbitModelGetZAccel = + env->GetMethodID(glonassSatelliteOrbitModelClass, "getZAccel", "()D"); + method_glonassSatelliteOrbitModelGetZDot = + env->GetMethodID(glonassSatelliteOrbitModelClass, "getZDot", "()D"); + + // Get the methods of GlonassSatelliteClockModel + jclass glonassSatelliteClockModelClass = + env->FindClass("android/location/GlonassSatelliteEphemeris$GlonassSatelliteClockModel"); + method_glonassSatelliteClockModelGetClockBias = + env->GetMethodID(glonassSatelliteClockModelClass, "getClockBias", "()D"); + method_glonassSatelliteClockModelGetFrequencyBias = + env->GetMethodID(glonassSatelliteClockModelClass, "getFrequencyBias", "()D"); + method_glonassSatelliteClockModelGetFrequencyChannelNumber = + env->GetMethodID(glonassSatelliteClockModelClass, "getFrequencyChannelNumber", "()I"); + method_glonassSatelliteClockModelGetTimeOfClockSeconds = + env->GetMethodID(glonassSatelliteClockModelClass, "getTimeOfClockSeconds", "()J"); + + // Get the methods of QzssAssistance class. + jclass qzssAssistanceClass = env->FindClass("android/location/QzssAssistance"); + method_qzssAssistanceGetAlmanac = + env->GetMethodID(qzssAssistanceClass, "getAlmanac", "()Landroid/location/GnssAlmanac;"); + method_qzssAssistanceGetIonosphericModel = + env->GetMethodID(qzssAssistanceClass, "getIonosphericModel", + "()Landroid/location/KlobucharIonosphericModel;"); + method_qzssAssistanceGetUtcModel = + env->GetMethodID(qzssAssistanceClass, "getUtcModel", "()Landroid/location/UtcModel;"); + method_qzssAssistanceGetLeapSecondsModel = + env->GetMethodID(qzssAssistanceClass, "getLeapSecondsModel", + "()Landroid/location/LeapSecondsModel;"); + method_qzssAssistanceGetTimeModels = + env->GetMethodID(qzssAssistanceClass, "getTimeModels", "()Ljava/util/List;"); + method_qzssAssistanceGetSatelliteEphemeris = + env->GetMethodID(qzssAssistanceClass, "getSatelliteEphemeris", "()Ljava/util/List;"); + method_qzssAssistanceGetSatelliteCorrections = + env->GetMethodID(qzssAssistanceClass, "getSatelliteCorrections", "()Ljava/util/List;"); + + // Get the methods of QzssSatelliteEphemeris class. + jclass qzssSatelliteEphemerisClass = env->FindClass("android/location/QzssSatelliteEphemeris"); + method_qzssSatelliteEphemerisGetSvid = + env->GetMethodID(qzssSatelliteEphemerisClass, "getSvid", "()I"); + method_qzssSatelliteEphemerisGetGpsL2Params = + env->GetMethodID(qzssSatelliteEphemerisClass, "getGpsL2Params", + "()Landroid/location/GpsSatelliteEphemeris$GpsL2Params;"); + method_qzssSatelliteEphemerisGetSatelliteEphemerisTime = + env->GetMethodID(qzssSatelliteEphemerisClass, "getSatelliteEphemerisTime", + "()Landroid/location/SatelliteEphemerisTime;"); + method_qzssSatelliteEphemerisGetSatelliteHealth = + env->GetMethodID(qzssSatelliteEphemerisClass, "getSatelliteHealth", + "()Landroid/location/GpsSatelliteEphemeris$GpsSatelliteHealth;"); + method_qzssSatelliteEphemerisGetSatelliteOrbitModel = + env->GetMethodID(qzssSatelliteEphemerisClass, "getSatelliteOrbitModel", + "()Landroid/location/KeplerianOrbitModel;"); +} + +GnssAssistanceInterface::GnssAssistanceInterface( + const sp<IGnssAssistanceInterface>& iGnssAssistance) + : mGnssAssistanceInterface(iGnssAssistance) { + assert(mGnssAssistanceInterface != nullptr); +} + +jboolean GnssAssistanceInterface::injectGnssAssistance(JNIEnv* env, jobject gnssAssistanceObj) { + GnssAssistance gnssAssistance; + GnssAssistanceUtil::setGnssAssistance(env, gnssAssistanceObj, gnssAssistance); + auto status = mGnssAssistanceInterface->injectGnssAssistance(gnssAssistance); + return checkAidlStatus(status, "IGnssAssistanceInterface injectGnssAssistance() failed."); +} + +jboolean GnssAssistanceInterface::setCallback(const sp<IGnssAssistanceCallback>& callback) { + auto status = mGnssAssistanceInterface->setCallback(callback); + return checkAidlStatus(status, "IGnssAssistanceInterface setCallback() failed."); +} + +void GnssAssistanceUtil::setGnssAssistance(JNIEnv* env, jobject gnssAssistanceObj, + GnssAssistance& gnssAssistance) { + jobject gpsAssistanceObj = + env->CallObjectMethod(gnssAssistanceObj, method_gnssAssistanceGetGpsAssistance); + jobject glonassAssistanceObj = + env->CallObjectMethod(gnssAssistanceObj, method_gnssAssistanceGetGlonassAssistance); + jobject qzssAssistanceObj = + env->CallObjectMethod(gnssAssistanceObj, method_gnssAssistanceGetQzssAssistance); + jobject galileoAssistanceObj = + env->CallObjectMethod(gnssAssistanceObj, method_gnssAssistanceGetGalileoAssistance); + jobject beidouAssistanceObj = + env->CallObjectMethod(gnssAssistanceObj, method_gnssAssistanceGetBeidouAssistance); + GnssAssistanceUtil::setGpsAssistance(env, gpsAssistanceObj, gnssAssistance.gpsAssistance); + GnssAssistanceUtil::setGlonassAssistance(env, glonassAssistanceObj, + gnssAssistance.glonassAssistance); + GnssAssistanceUtil::setQzssAssistance(env, qzssAssistanceObj, gnssAssistance.qzssAssistance); + GnssAssistanceUtil::setGalileoAssistance(env, galileoAssistanceObj, + gnssAssistance.galileoAssistance); + GnssAssistanceUtil::setBeidouAssistance(env, beidouAssistanceObj, + gnssAssistance.beidouAssistance); + env->DeleteLocalRef(gpsAssistanceObj); + env->DeleteLocalRef(glonassAssistanceObj); + env->DeleteLocalRef(qzssAssistanceObj); + env->DeleteLocalRef(galileoAssistanceObj); + env->DeleteLocalRef(beidouAssistanceObj); +} + +void GnssAssistanceUtil::setQzssAssistance(JNIEnv* env, jobject qzssAssistanceObj, + QzssAssistance& qzssAssistance) { + jobject qzssAlmanacObj = + env->CallObjectMethod(qzssAssistanceObj, method_qzssAssistanceGetAlmanac); + jobject qzssIonosphericModelObj = + env->CallObjectMethod(qzssAssistanceObj, method_qzssAssistanceGetIonosphericModel); + jobject qzssUtcModelObj = + env->CallObjectMethod(qzssAssistanceObj, method_qzssAssistanceGetUtcModel); + jobject qzssLeapSecondsModelObj = + env->CallObjectMethod(qzssAssistanceObj, method_qzssAssistanceGetLeapSecondsModel); + jobject qzssTimeModelsObj = + env->CallObjectMethod(qzssAssistanceObj, method_qzssAssistanceGetTimeModels); + jobject qzssSatelliteEphemerisObj = + env->CallObjectMethod(qzssAssistanceObj, method_qzssAssistanceGetSatelliteEphemeris); + jobject qzssSatelliteCorrectionsObj = + env->CallObjectMethod(qzssAssistanceObj, method_qzssAssistanceGetSatelliteCorrections); + setGnssAlmanac(env, qzssAlmanacObj, qzssAssistance.almanac); + setKlobucharIonosphericModel(env, qzssIonosphericModelObj, qzssAssistance.ionosphericModel); + setUtcModel(env, qzssUtcModelObj, qzssAssistance.utcModel); + setLeapSecondsModel(env, qzssLeapSecondsModelObj, qzssAssistance.leapSecondsModel); + setTimeModels(env, qzssTimeModelsObj, qzssAssistance.timeModels); + setGpsOrQzssSatelliteEphemeris<QzssSatelliteEphemeris>(env, qzssSatelliteEphemerisObj, + qzssAssistance.satelliteEphemeris); + setSatelliteCorrections(env, qzssSatelliteCorrectionsObj, qzssAssistance.satelliteCorrections); + env->DeleteLocalRef(qzssAlmanacObj); + env->DeleteLocalRef(qzssIonosphericModelObj); + env->DeleteLocalRef(qzssUtcModelObj); + env->DeleteLocalRef(qzssLeapSecondsModelObj); + env->DeleteLocalRef(qzssTimeModelsObj); + env->DeleteLocalRef(qzssSatelliteEphemerisObj); + env->DeleteLocalRef(qzssSatelliteCorrectionsObj); +} + +void GnssAssistanceUtil::setGlonassAssistance(JNIEnv* env, jobject glonassAssistanceObj, + GlonassAssistance& galileoAssistance) { + jobject glonassAlmanacObj = + env->CallObjectMethod(glonassAssistanceObj, method_glonassAssistanceGetAlmanac); + jobject utcModelObj = + env->CallObjectMethod(glonassAssistanceObj, method_glonassAssistanceGetUtcModel); + jobject timeModelsObj = + env->CallObjectMethod(glonassAssistanceObj, method_glonassAssistanceGetTimeModels); + jobject satelliteEphemerisObj = + env->CallObjectMethod(glonassAssistanceObj, + method_glonassAssistanceGetSatelliteEphemeris); + jobject satelliteCorrectionsObj = + env->CallObjectMethod(glonassAssistanceObj, + method_glonassAssistanceGetSatelliteCorrections); + setGlonassAlmanac(env, glonassAlmanacObj, galileoAssistance.almanac); + setUtcModel(env, utcModelObj, galileoAssistance.utcModel); + setTimeModels(env, timeModelsObj, galileoAssistance.timeModels); + setGlonassSatelliteEphemeris(env, satelliteEphemerisObj, galileoAssistance.satelliteEphemeris); + setSatelliteCorrections(env, satelliteCorrectionsObj, galileoAssistance.satelliteCorrections); + env->DeleteLocalRef(glonassAlmanacObj); + env->DeleteLocalRef(utcModelObj); + env->DeleteLocalRef(timeModelsObj); + env->DeleteLocalRef(satelliteEphemerisObj); + env->DeleteLocalRef(satelliteCorrectionsObj); +} + +void GnssAssistanceUtil::setGlonassAlmanac(JNIEnv* env, jobject glonassAlmanacObj, + GlonassAlmanac& glonassAlmanac) { + if (glonassAlmanacObj == nullptr) { + glonassAlmanac.issueDateMs = -1; + return; + } + jlong issueDateMillis = + env->CallLongMethod(glonassAlmanacObj, method_glonassAlmanacGetIssueDateMillis); + glonassAlmanac.issueDateMs = issueDateMillis; + jobject satelliteAlmanacsObj = + env->CallObjectMethod(glonassAlmanacObj, method_glonassAlmanacGetSatelliteAlmanacs); + if (satelliteAlmanacsObj == nullptr) return; + auto len = env->CallIntMethod(satelliteAlmanacsObj, method_listSize); + for (uint16_t i = 0; i < len; ++i) { + jobject glonassSatelliteAlmanacObj = + env->CallObjectMethod(satelliteAlmanacsObj, method_listGet, i); + if (glonassSatelliteAlmanacObj == nullptr) continue; + GlonassSatelliteAlmanac glonassSatelliteAlmanac; + jdouble deltaI = env->CallDoubleMethod(glonassSatelliteAlmanacObj, + method_glonassSatelliteAlmanacGetDeltaI); + glonassSatelliteAlmanac.deltaI = deltaI; + jdouble deltaT = env->CallDoubleMethod(glonassSatelliteAlmanacObj, + method_glonassSatelliteAlmanacGetDeltaT); + glonassSatelliteAlmanac.deltaT = deltaT; + jdouble deltaTDot = env->CallDoubleMethod(glonassSatelliteAlmanacObj, + method_glonassSatelliteAlmanacGetDeltaTDot); + glonassSatelliteAlmanac.deltaTDot = deltaTDot; + jdouble eccentricity = env->CallDoubleMethod(glonassSatelliteAlmanacObj, + method_glonassSatelliteAlmanacGetEccentricity); + glonassSatelliteAlmanac.eccentricity = eccentricity; + jint frequencyChannelNumber = + env->CallIntMethod(glonassSatelliteAlmanacObj, + method_glonassSatelliteAlmanacGetFrequencyChannelNumber); + glonassSatelliteAlmanac.frequencyChannelNumber = + static_cast<int32_t>(frequencyChannelNumber); + jdouble lambda = env->CallDoubleMethod(glonassSatelliteAlmanacObj, + method_glonassSatelliteAlmanacGetLambda); + glonassSatelliteAlmanac.lambda = lambda; + jdouble omega = env->CallDoubleMethod(glonassSatelliteAlmanacObj, + method_glonassSatelliteAlmanacGetOmega); + glonassSatelliteAlmanac.omega = omega; + jint slotNumber = env->CallIntMethod(glonassSatelliteAlmanacObj, + method_glonassSatelliteAlmanacGetSlotNumber); + glonassSatelliteAlmanac.slotNumber = static_cast<int32_t>(slotNumber); + jint healthState = env->CallIntMethod(glonassSatelliteAlmanacObj, + method_glonassSatelliteAlmanacGetHealthState); + glonassSatelliteAlmanac.svHealth = static_cast<int32_t>(healthState); + jdouble tLambda = env->CallDoubleMethod(glonassSatelliteAlmanacObj, + method_glonassSatelliteAlmanacGetTLambda); + glonassSatelliteAlmanac.tLambda = tLambda; + jdouble tau = env->CallDoubleMethod(glonassSatelliteAlmanacObj, + method_glonassSatelliteAlmanacGetTau); + glonassSatelliteAlmanac.tau = tau; + jboolean isGlonassM = env->CallBooleanMethod(glonassSatelliteAlmanacObj, + method_glonassSatelliteAlmanacGetIsGlonassM); + glonassSatelliteAlmanac.isGlonassM = isGlonassM; + jint calendarDayNumber = + env->CallIntMethod(glonassSatelliteAlmanacObj, + method_glonassSatelliteAlmanacGetCalendarDayNumber); + glonassSatelliteAlmanac.calendarDayNumber = static_cast<int32_t>(calendarDayNumber); + glonassAlmanac.satelliteAlmanacs.push_back(glonassSatelliteAlmanac); + env->DeleteLocalRef(glonassSatelliteAlmanacObj); + } + env->DeleteLocalRef(satelliteAlmanacsObj); +} + +void GnssAssistanceUtil::setGlonassSatelliteEphemeris( + JNIEnv* env, jobject glonassSatelliteEphemerisListObj, + std::vector<GlonassSatelliteEphemeris>& glonassSatelliteEphemerisList) { + if (glonassSatelliteEphemerisListObj == nullptr) return; + auto len = env->CallIntMethod(glonassSatelliteEphemerisListObj, method_listSize); + for (uint16_t i = 0; i < len; ++i) { + jobject glonassSatelliteEphemerisObj = + env->CallObjectMethod(glonassSatelliteEphemerisListObj, method_listGet, i); + if (glonassSatelliteEphemerisObj == nullptr) continue; + GlonassSatelliteEphemeris glonassSatelliteEphemeris; + jdouble ageInDays = env->CallDoubleMethod(glonassSatelliteEphemerisObj, + method_glonassSatelliteEphemerisGetAgeInDays); + glonassSatelliteEphemeris.ageInDays = ageInDays; + + // Set the GlonassSatelliteClockModel. + jobject glonassSatelliteClockModelObj = + env->CallObjectMethod(glonassSatelliteEphemerisObj, + method_glonassSatelliteEphemerisGetSatelliteClockModel); + GlonassSatelliteClockModel glonassSatelliteClockModel; + jdouble clockBias = env->CallDoubleMethod(glonassSatelliteClockModelObj, + method_glonassSatelliteClockModelGetClockBias); + glonassSatelliteClockModel.clockBias = clockBias; + jdouble frequencyBias = + env->CallDoubleMethod(glonassSatelliteClockModelObj, + method_glonassSatelliteClockModelGetFrequencyBias); + glonassSatelliteClockModel.frequencyBias = frequencyBias; + jint frequencyChannelNumber = + env->CallIntMethod(glonassSatelliteClockModelObj, + method_glonassSatelliteClockModelGetFrequencyChannelNumber); + glonassSatelliteClockModel.frequencyChannelNumber = + static_cast<int32_t>(frequencyChannelNumber); + jdouble timeOfClockSeconds = + env->CallDoubleMethod(glonassSatelliteClockModelObj, + method_glonassSatelliteClockModelGetTimeOfClockSeconds); + glonassSatelliteClockModel.timeOfClockSeconds = timeOfClockSeconds; + glonassSatelliteEphemeris.satelliteClockModel = glonassSatelliteClockModel; + env->DeleteLocalRef(glonassSatelliteClockModelObj); + + // Set the GlonassSatelliteOrbitModel. + jobject glonassSatelliteOrbitModelObj = + env->CallObjectMethod(glonassSatelliteEphemerisObj, + method_glonassSatelliteEphemerisGetSatelliteOrbitModel); + GlonassSatelliteOrbitModel glonassSatelliteOrbitModel; + jdouble x = env->CallDoubleMethod(glonassSatelliteOrbitModelObj, + method_glonassSatelliteOrbitModelGetX); + glonassSatelliteOrbitModel.x = x; + jdouble y = env->CallDoubleMethod(glonassSatelliteOrbitModelObj, + method_glonassSatelliteOrbitModelGetY); + glonassSatelliteOrbitModel.y = y; + jdouble z = env->CallDoubleMethod(glonassSatelliteOrbitModelObj, + method_glonassSatelliteOrbitModelGetZ); + glonassSatelliteOrbitModel.z = z; + jdouble xAccel = env->CallDoubleMethod(glonassSatelliteOrbitModelObj, + method_glonassSatelliteOrbitModelGetXAccel); + glonassSatelliteOrbitModel.xAccel = xAccel; + jdouble yAccel = env->CallDoubleMethod(glonassSatelliteOrbitModelObj, + method_glonassSatelliteOrbitModelGetYAccel); + glonassSatelliteOrbitModel.yAccel = yAccel; + jdouble zAccel = env->CallDoubleMethod(glonassSatelliteOrbitModelObj, + method_glonassSatelliteOrbitModelGetZAccel); + glonassSatelliteOrbitModel.zAccel = zAccel; + jdouble xDot = env->CallDoubleMethod(glonassSatelliteOrbitModelObj, + method_glonassSatelliteOrbitModelGetXDot); + glonassSatelliteOrbitModel.xDot = xDot; + jdouble yDot = env->CallDoubleMethod(glonassSatelliteOrbitModelObj, + method_glonassSatelliteOrbitModelGetYDot); + glonassSatelliteOrbitModel.yDot = yDot; + jdouble zDot = env->CallDoubleMethod(glonassSatelliteOrbitModelObj, + method_glonassSatelliteOrbitModelGetZDot); + glonassSatelliteOrbitModel.zDot = zDot; + glonassSatelliteEphemeris.satelliteOrbitModel = glonassSatelliteOrbitModel; + env->DeleteLocalRef(glonassSatelliteOrbitModelObj); + + jint healthState = env->CallIntMethod(glonassSatelliteEphemerisObj, + method_glonassSatelliteEphemerisGetHealthState); + glonassSatelliteEphemeris.svHealth = static_cast<int32_t>(healthState); + jint slotNumber = env->CallIntMethod(glonassSatelliteEphemerisObj, + method_glonassSatelliteEphemerisGetSlotNumber); + glonassSatelliteEphemeris.slotNumber = static_cast<int32_t>(slotNumber); + jdouble frameTimeSeconds = + env->CallDoubleMethod(glonassSatelliteEphemerisObj, + method_glonassSatelliteEphemerisGetFrameTimeSeconds); + glonassSatelliteEphemeris.frameTimeSeconds = frameTimeSeconds; + jint updateIntervalMinutes = + env->CallIntMethod(glonassSatelliteEphemerisObj, + method_glonassSatelliteEphemerisGetUpdateIntervalMinutes); + glonassSatelliteEphemeris.updateIntervalMinutes = + static_cast<int32_t>(updateIntervalMinutes); + jboolean isGlonassM = env->CallBooleanMethod(glonassSatelliteEphemerisObj, + method_glonassSatelliteEphemerisGetIsGlonassM); + glonassSatelliteEphemeris.isGlonassM = isGlonassM; + jboolean isUpdateIntervalOdd = + env->CallBooleanMethod(glonassSatelliteEphemerisObj, + method_glonassSatelliteEphemerisGetIsUpdateIntervalOdd); + glonassSatelliteEphemeris.isOddUpdateInterval = isUpdateIntervalOdd; + glonassSatelliteEphemerisList.push_back(glonassSatelliteEphemeris); + env->DeleteLocalRef(glonassSatelliteEphemerisObj); + } +} + +void GnssAssistanceUtil::setGalileoAssistance(JNIEnv* env, jobject galileoAssistanceObj, + GalileoAssistance& galileoAssistance) { + jobject galileoAlmanacObj = + env->CallObjectMethod(galileoAssistanceObj, method_galileoAssistanceGetAlmanac); + jobject ionosphericModelObj = + env->CallObjectMethod(galileoAssistanceObj, + method_galileoAssistanceGetIonosphericModel); + jobject utcModelObj = + env->CallObjectMethod(galileoAssistanceObj, method_galileoAssistanceGetUtcModel); + jobject leapSecondsModelObj = + env->CallObjectMethod(galileoAssistanceObj, + method_galileoAssistanceGetLeapSecondsModel); + jobject timeModelsObj = + env->CallObjectMethod(galileoAssistanceObj, method_galileoAssistanceGetTimeModels); + jobject satelliteEphemerisObj = + env->CallObjectMethod(galileoAssistanceObj, + method_galileoAssistanceGetSatelliteEphemeris); + jobject realTimeIntegrityModelsObj = + env->CallObjectMethod(galileoAssistanceObj, + method_galileoAssistanceGetRealTimeIntegrityModels); + jobject satelliteCorrectionsObj = + env->CallObjectMethod(galileoAssistanceObj, + method_galileoAssistanceGetSatelliteCorrections); + setGnssAlmanac(env, galileoAlmanacObj, galileoAssistance.almanac); + setGaliloKlobucharIonosphericModel(env, ionosphericModelObj, + galileoAssistance.ionosphericModel); + setUtcModel(env, utcModelObj, galileoAssistance.utcModel); + setLeapSecondsModel(env, leapSecondsModelObj, galileoAssistance.leapSecondsModel); + setTimeModels(env, timeModelsObj, galileoAssistance.timeModels); + setGalileoSatelliteEphemeris(env, satelliteEphemerisObj, galileoAssistance.satelliteEphemeris); + setRealTimeIntegrityModels(env, realTimeIntegrityModelsObj, + galileoAssistance.realTimeIntegrityModels); + setSatelliteCorrections(env, satelliteCorrectionsObj, galileoAssistance.satelliteCorrections); + env->DeleteLocalRef(galileoAlmanacObj); + env->DeleteLocalRef(ionosphericModelObj); + env->DeleteLocalRef(utcModelObj); + env->DeleteLocalRef(leapSecondsModelObj); + env->DeleteLocalRef(timeModelsObj); + env->DeleteLocalRef(satelliteEphemerisObj); + env->DeleteLocalRef(realTimeIntegrityModelsObj); + env->DeleteLocalRef(satelliteCorrectionsObj); +} + +void GnssAssistanceUtil::setGaliloKlobucharIonosphericModel( + JNIEnv* env, jobject galileoIonosphericModelObj, + GalileoIonosphericModel& ionosphericModel) { + if (galileoIonosphericModelObj == nullptr) return; + jdouble ai0 = + env->CallDoubleMethod(galileoIonosphericModelObj, method_galileoIonosphericModelGetAi0); + ionosphericModel.ai0 = ai0; + jdouble ai1 = + env->CallDoubleMethod(galileoIonosphericModelObj, method_galileoIonosphericModelGetAi1); + ionosphericModel.ai1 = ai1; + jdouble ai2 = + env->CallDoubleMethod(galileoIonosphericModelObj, method_galileoIonosphericModelGetAi2); + ionosphericModel.ai2 = ai2; +} + +void GnssAssistanceUtil::setGalileoSatelliteEphemeris( + JNIEnv* env, jobject galileoSatelliteEphemerisListObj, + std::vector<GalileoSatelliteEphemeris>& galileoSatelliteEphemerisList) { + if (galileoSatelliteEphemerisListObj == nullptr) return; + auto len = env->CallIntMethod(galileoSatelliteEphemerisListObj, method_listSize); + for (uint16_t i = 0; i < len; ++i) { + jobject galileoSatelliteEphemerisObj = + env->CallObjectMethod(galileoSatelliteEphemerisListObj, method_listGet, i); + GalileoSatelliteEphemeris galileoSatelliteEphemeris; + GalileoSvHealth galileoSvHealth; + // Set the svid of the satellite. + jint svid = env->CallLongMethod(galileoSatelliteEphemerisObj, + method_galileoSatelliteEphemerisGetSvid); + galileoSatelliteEphemeris.svid = svid; + + // Set the satellite clock models. + jobject galileoSatelliteClockModelListObj = + env->CallObjectMethod(galileoSatelliteEphemerisObj, + method_galileoSatelliteEphemerisGetSatelliteClockModels); + auto size = env->CallIntMethod(galileoSatelliteClockModelListObj, method_listSize); + for (uint16_t j = 0; j < size; ++j) { + jobject galileoSatelliteClockModelObj = + env->CallObjectMethod(galileoSatelliteClockModelListObj, method_listGet, j); + if (galileoSatelliteClockModelObj == nullptr) continue; + GalileoSatelliteClockModel galileoSatelliteClockModel; + jdouble af0 = env->CallDoubleMethod(galileoSatelliteClockModelObj, + method_galileoSatelliteClockModelGetAf0); + galileoSatelliteClockModel.af0 = af0; + jdouble af1 = env->CallDoubleMethod(galileoSatelliteClockModelObj, + method_galileoSatelliteClockModelGetAf1); + galileoSatelliteClockModel.af1 = af1; + jdouble af2 = env->CallDoubleMethod(galileoSatelliteClockModelObj, + method_galileoSatelliteClockModelGetAf2); + galileoSatelliteClockModel.af2 = af2; + jdouble bgdSeconds = + env->CallDoubleMethod(galileoSatelliteClockModelObj, + method_galileoSatelliteClockModelGetBgdSeconds); + galileoSatelliteClockModel.bgdSeconds = bgdSeconds; + jint satelliteClockType = + env->CallIntMethod(galileoSatelliteClockModelObj, + method_galileoSatelliteClockModelGetSatelliteClockType); + galileoSatelliteClockModel.satelliteClockType = + static_cast<GalileoSatelliteClockModel::SatelliteClockType>(satelliteClockType); + jdouble sisaMeters = + env->CallDoubleMethod(galileoSatelliteClockModelObj, + method_galileoSatelliteClockModelGetSisaMeters); + galileoSatelliteClockModel.sisaMeters = sisaMeters; + jdouble timeOfClockSeconds = + env->CallDoubleMethod(galileoSatelliteClockModelObj, + method_galileoSatelliteClockModelGetTimeOfClockSeconds); + galileoSatelliteClockModel.timeOfClockSeconds = timeOfClockSeconds; + galileoSatelliteEphemeris.satelliteClockModel.push_back(galileoSatelliteClockModel); + env->DeleteLocalRef(galileoSatelliteClockModelObj); + } + env->DeleteLocalRef(galileoSatelliteClockModelListObj); + + // Set the satelliteOrbitModel of the satellite. + jobject satelliteOrbitModelObj = + env->CallObjectMethod(galileoSatelliteEphemerisObj, + method_galileoSatelliteEphemerisGetSatelliteOrbitModel); + GnssAssistanceUtil::setKeplerianOrbitModel(env, satelliteOrbitModelObj, + galileoSatelliteEphemeris.satelliteOrbitModel); + env->DeleteLocalRef(satelliteOrbitModelObj); + + // Set the satellite health of the satellite clock model. + jobject galileoSvHealthObj = + env->CallObjectMethod(galileoSatelliteEphemerisObj, + method_galileoSatelliteEphemerisGetSatelliteHealth); + jint dataValidityStatusE1b = + env->CallIntMethod(galileoSvHealthObj, + method_galileoSvHealthGetDataValidityStatusE1b); + galileoSvHealth.dataValidityStatusE1b = + static_cast<GalileoSvHealth::GalileoHealthDataVaidityType>(dataValidityStatusE1b); + jint dataValidityStatusE5a = + env->CallIntMethod(galileoSvHealthObj, + method_galileoSvHealthGetDataValidityStatusE5a); + galileoSvHealth.dataValidityStatusE5a = + static_cast<GalileoSvHealth::GalileoHealthDataVaidityType>(dataValidityStatusE5a); + jint dataValidityStatusE5b = + env->CallIntMethod(galileoSvHealthObj, + method_galileoSvHealthGetDataValidityStatusE5b); + galileoSvHealth.dataValidityStatusE5b = + static_cast<GalileoSvHealth::GalileoHealthDataVaidityType>(dataValidityStatusE5b); + jint signalHealthStatusE1b = + env->CallIntMethod(galileoSvHealthObj, + method_galileoSvHealthGetSignalHealthStatusE1b); + galileoSvHealth.signalHealthStatusE1b = + static_cast<GalileoSvHealth::GalileoHealthStatusType>(signalHealthStatusE1b); + jint signalHealthStatusE5a = + env->CallIntMethod(galileoSvHealthObj, + method_galileoSvHealthGetSignalHealthStatusE5a); + galileoSvHealth.signalHealthStatusE5a = + static_cast<GalileoSvHealth::GalileoHealthStatusType>(signalHealthStatusE5a); + jint signalHealthStatusE5b = + env->CallIntMethod(galileoSvHealthObj, + method_galileoSvHealthGetSignalHealthStatusE5b); + galileoSvHealth.signalHealthStatusE5b = + static_cast<GalileoSvHealth::GalileoHealthStatusType>(signalHealthStatusE5b); + galileoSatelliteEphemeris.svHealth = galileoSvHealth; + env->DeleteLocalRef(galileoSvHealthObj); + + // Set the satelliteEphemerisTime of the satellite. + jobject satelliteEphemerisTimeObj = + env->CallObjectMethod(galileoSatelliteEphemerisObj, + method_galileoSatelliteEphemerisGetSatelliteEphemerisTime); + GnssAssistanceUtil::setSatelliteEphemerisTime(env, satelliteEphemerisTimeObj, + galileoSatelliteEphemeris + .satelliteEphemerisTime); + env->DeleteLocalRef(satelliteEphemerisTimeObj); + + galileoSatelliteEphemerisList.push_back(galileoSatelliteEphemeris); + env->DeleteLocalRef(galileoSatelliteEphemerisObj); + } +} + +void GnssAssistanceUtil::setBeidouAssistance(JNIEnv* env, jobject beidouAssistanceObj, + BeidouAssistance& beidouAssistance) { + jobject beidouAlmanacObj = + env->CallObjectMethod(beidouAssistanceObj, method_beidouAssistanceGetAlmanac); + jobject ionosphericModelObj = + env->CallObjectMethod(beidouAssistanceObj, method_beidouAssistanceGetIonosphericModel); + jobject utcModelObj = + env->CallObjectMethod(beidouAssistanceObj, method_beidouAssistanceGetUtcModel); + jobject leapSecondsModelObj = + env->CallObjectMethod(beidouAssistanceObj, method_beidouAssistanceGetLeapSecondsModel); + jobject timeModelsObj = + env->CallObjectMethod(beidouAssistanceObj, method_beidouAssistanceGetTimeModels); + jobject satelliteEphemerisObj = + env->CallObjectMethod(beidouAssistanceObj, + method_beidouAssistanceGetSatelliteEphemeris); + jobject realTimeIntegrityModelsObj = + env->CallObjectMethod(beidouAssistanceObj, + method_beidouAssistanceGetRealTimeIntegrityModels); + jobject satelliteCorrectionsObj = + env->CallObjectMethod(beidouAssistanceObj, + method_beidouAssistanceGetSatelliteCorrections); + setGnssAlmanac(env, beidouAlmanacObj, beidouAssistance.almanac); + setKlobucharIonosphericModel(env, ionosphericModelObj, beidouAssistance.ionosphericModel); + setUtcModel(env, utcModelObj, beidouAssistance.utcModel); + setLeapSecondsModel(env, leapSecondsModelObj, beidouAssistance.leapSecondsModel); + setTimeModels(env, timeModelsObj, beidouAssistance.timeModels); + setBeidouSatelliteEphemeris(env, satelliteEphemerisObj, beidouAssistance.satelliteEphemeris); + setRealTimeIntegrityModels(env, realTimeIntegrityModelsObj, + beidouAssistance.realTimeIntegrityModels); + setSatelliteCorrections(env, satelliteCorrectionsObj, beidouAssistance.satelliteCorrections); + env->DeleteLocalRef(beidouAlmanacObj); + env->DeleteLocalRef(ionosphericModelObj); + env->DeleteLocalRef(utcModelObj); + env->DeleteLocalRef(leapSecondsModelObj); + env->DeleteLocalRef(timeModelsObj); + env->DeleteLocalRef(satelliteEphemerisObj); + env->DeleteLocalRef(realTimeIntegrityModelsObj); + env->DeleteLocalRef(satelliteCorrectionsObj); +} + +void GnssAssistanceUtil::setBeidouSatelliteEphemeris( + JNIEnv* env, jobject beidouSatelliteEphemerisListObj, + std::vector<BeidouSatelliteEphemeris>& beidouSatelliteEphemerisList) { + if (beidouSatelliteEphemerisListObj == nullptr) return; + auto len = env->CallIntMethod(beidouSatelliteEphemerisListObj, method_listSize); + for (uint16_t i = 0; i < len; ++i) { + jobject beidouSatelliteEphemerisObj = + env->CallObjectMethod(beidouSatelliteEphemerisListObj, method_listGet, i); + if (beidouSatelliteEphemerisObj == nullptr) continue; + BeidouSatelliteEphemeris beidouSatelliteEphemeris; + + // Set the svid of the satellite. + jint svid = env->CallIntMethod(beidouSatelliteEphemerisObj, + method_beidouSatelliteEphemerisGetSvid); + beidouSatelliteEphemeris.svid = static_cast<int32_t>(svid); + + // Set the satelliteClockModel of the satellite. + jobject satelliteClockModelObj = + env->CallObjectMethod(beidouSatelliteEphemerisObj, + method_beidouSatelliteEphemerisGetSatelliteClockModel); + jdouble af0 = env->CallDoubleMethod(satelliteClockModelObj, + method_beidouSatelliteClockModelGetAf0); + jdouble af1 = env->CallDoubleMethod(satelliteClockModelObj, + method_beidouSatelliteClockModelGetAf1); + jdouble af2 = env->CallDoubleMethod(satelliteClockModelObj, + method_beidouSatelliteClockModelGetAf2); + jdouble tgd1 = env->CallDoubleMethod(satelliteClockModelObj, + method_beidouSatelliteClockModelGetTgd1); + jdouble tgd2 = env->CallDoubleMethod(satelliteClockModelObj, + method_beidouSatelliteClockModelGetTgd2); + jdouble aodc = env->CallDoubleMethod(satelliteClockModelObj, + method_beidouSatelliteClockModelGetAodc); + jlong timeOfClockSeconds = + env->CallLongMethod(satelliteClockModelObj, + method_beidouSatelliteClockModelGetTimeOfClockSeconds); + beidouSatelliteEphemeris.satelliteClockModel.af0 = af0; + beidouSatelliteEphemeris.satelliteClockModel.af1 = af1; + beidouSatelliteEphemeris.satelliteClockModel.af2 = af2; + beidouSatelliteEphemeris.satelliteClockModel.tgd1 = tgd1; + beidouSatelliteEphemeris.satelliteClockModel.tgd2 = tgd2; + beidouSatelliteEphemeris.satelliteClockModel.aodc = aodc; + beidouSatelliteEphemeris.satelliteClockModel.timeOfClockSeconds = timeOfClockSeconds; + env->DeleteLocalRef(satelliteClockModelObj); + + // Set the satelliteOrbitModel of the satellite. + jobject satelliteOrbitModelObj = + env->CallObjectMethod(beidouSatelliteEphemerisObj, + method_beidouSatelliteEphemerisGetSatelliteOrbitModel); + GnssAssistanceUtil::setKeplerianOrbitModel(env, satelliteOrbitModelObj, + beidouSatelliteEphemeris.satelliteOrbitModel); + env->DeleteLocalRef(satelliteOrbitModelObj); + + // Set the satelliteHealth of the satellite. + jobject satelliteHealthObj = + env->CallObjectMethod(beidouSatelliteEphemerisObj, + method_beidouSatelliteEphemerisGetSatelliteHealth); + jint satH1 = env->CallIntMethod(satelliteHealthObj, method_beidouSatelliteHealthGetSatH1); + jint svAccur = + env->CallIntMethod(satelliteHealthObj, method_beidouSatelliteHealthGetSvAccur); + beidouSatelliteEphemeris.satelliteHealth.satH1 = static_cast<int32_t>(satH1); + beidouSatelliteEphemeris.satelliteHealth.svAccur = static_cast<int32_t>(svAccur); + env->DeleteLocalRef(satelliteHealthObj); + + // Set the satelliteEphemerisTime of the satellite. + jobject satelliteEphemerisTimeObj = + env->CallObjectMethod(beidouSatelliteEphemerisObj, + method_beidouSatelliteEphemerisGetSatelliteEphemerisTime); + jint iode = env->CallIntMethod(satelliteEphemerisTimeObj, + method_beidouSatelliteEphemerisTimeGetIode); + jint beidouWeekNumber = + env->CallIntMethod(satelliteEphemerisTimeObj, + method_beidouSatelliteEphemerisTimeGetBeidouWeekNumber); + jint toeSeconds = env->CallDoubleMethod(satelliteEphemerisTimeObj, + method_beidouSatelliteEphemerisTimeGetToeSeconds); + beidouSatelliteEphemeris.satelliteEphemerisTime.aode = static_cast<int32_t>(iode); + beidouSatelliteEphemeris.satelliteEphemerisTime.weekNumber = + static_cast<int32_t>(beidouWeekNumber); + beidouSatelliteEphemeris.satelliteEphemerisTime.toeSeconds = + static_cast<int32_t>(toeSeconds); + env->DeleteLocalRef(satelliteEphemerisTimeObj); + + beidouSatelliteEphemerisList.push_back(beidouSatelliteEphemeris); + env->DeleteLocalRef(beidouSatelliteEphemerisObj); + } +} + +void GnssAssistanceUtil::setGpsAssistance(JNIEnv* env, jobject gpsAssistanceObj, + GpsAssistance& gpsAssistance) { + jobject gnssAlmanacObj = + env->CallObjectMethod(gpsAssistanceObj, method_gpsAssistanceGetAlmanac); + jobject ionosphericModelObj = + env->CallObjectMethod(gpsAssistanceObj, method_gpsAssistanceGetIonosphericModel); + jobject utcModelObj = env->CallObjectMethod(gpsAssistanceObj, method_gpsAssistanceGetUtcModel); + jobject leapSecondsModelObj = + env->CallObjectMethod(gpsAssistanceObj, method_gpsAssistanceGetLeapSecondsModel); + jobject timeModelsObj = + env->CallObjectMethod(gpsAssistanceObj, method_gpsAssistanceGetTimeModels); + jobject satelliteEphemerisObj = + env->CallObjectMethod(gpsAssistanceObj, method_gpsAssistanceGetSatelliteEphemeris); + jobject realTimeIntegrityModelsObj = + env->CallObjectMethod(gpsAssistanceObj, method_gpsAssistanceGetRealTimeIntegrityModels); + jobject satelliteCorrectionsObj = + env->CallObjectMethod(gpsAssistanceObj, method_gpsAssistanceGetSatelliteCorrections); + + setGnssAlmanac(env, gnssAlmanacObj, gpsAssistance.almanac); + setKlobucharIonosphericModel(env, ionosphericModelObj, gpsAssistance.ionosphericModel); + setUtcModel(env, utcModelObj, gpsAssistance.utcModel); + setLeapSecondsModel(env, leapSecondsModelObj, gpsAssistance.leapSecondsModel); + setTimeModels(env, timeModelsObj, gpsAssistance.timeModels); + setGpsOrQzssSatelliteEphemeris<GpsSatelliteEphemeris>(env, satelliteEphemerisObj, + gpsAssistance.satelliteEphemeris); + setRealTimeIntegrityModels(env, realTimeIntegrityModelsObj, + gpsAssistance.realTimeIntegrityModels); + setSatelliteCorrections(env, satelliteCorrectionsObj, gpsAssistance.satelliteCorrections); + env->DeleteLocalRef(gnssAlmanacObj); + env->DeleteLocalRef(ionosphericModelObj); + env->DeleteLocalRef(utcModelObj); + env->DeleteLocalRef(leapSecondsModelObj); + env->DeleteLocalRef(timeModelsObj); + env->DeleteLocalRef(satelliteEphemerisObj); + env->DeleteLocalRef(realTimeIntegrityModelsObj); + env->DeleteLocalRef(satelliteCorrectionsObj); +} + +/** Set the GPS/QZSS satellite ephemeris list. */ +template <class T> +void GnssAssistanceUtil::setGpsOrQzssSatelliteEphemeris(JNIEnv* env, + jobject satelliteEphemerisListObj, + std::vector<T>& satelliteEphemerisList) { + if (satelliteEphemerisListObj == nullptr) return; + auto len = env->CallIntMethod(satelliteEphemerisListObj, method_listSize); + for (uint16_t i = 0; i < len; ++i) { + jobject satelliteEphemerisObj = + env->CallObjectMethod(satelliteEphemerisListObj, method_listGet, i); + if (satelliteEphemerisObj == nullptr) continue; + T satelliteEphemeris; + // Set the svid of the satellite. + jint svid = env->CallIntMethod(satelliteEphemerisObj, method_gpsSatelliteEphemerisGetSvid); + satelliteEphemeris.svid = static_cast<int32_t>(svid); + + // Set the gpsL2Params of the satellite. + jobject gpsL2ParamsObj = env->CallObjectMethod(satelliteEphemerisObj, + method_gpsSatelliteEphemerisGetGpsL2Params); + jint l2Code = env->CallIntMethod(gpsL2ParamsObj, method_gpsL2ParamsGetL2Code); + jint l2Flag = env->CallIntMethod(gpsL2ParamsObj, method_gpsL2ParamsGetL2Flag); + satelliteEphemeris.gpsL2Params.l2Code = static_cast<int32_t>(l2Code); + satelliteEphemeris.gpsL2Params.l2Flag = static_cast<int32_t>(l2Flag); + env->DeleteLocalRef(gpsL2ParamsObj); + + // Set the satelliteClockModel of the satellite. + jobject satelliteClockModelObj = + env->CallObjectMethod(satelliteEphemerisObj, + method_gpsSatelliteEphemerisGetSatelliteClockModel); + jdouble af0 = + env->CallDoubleMethod(satelliteClockModelObj, method_gpsSatelliteClockModelGetAf0); + jdouble af1 = + env->CallDoubleMethod(satelliteClockModelObj, method_gpsSatelliteClockModelGetAf1); + jdouble af2 = + env->CallDoubleMethod(satelliteClockModelObj, method_gpsSatelliteClockModelGetAf2); + jdouble tgd = + env->CallDoubleMethod(satelliteClockModelObj, method_gpsSatelliteClockModelGetTgd); + jint iodc = + env->CallDoubleMethod(satelliteClockModelObj, method_gpsSatelliteClockModelGetIodc); + jlong timeOfClockSeconds = + env->CallLongMethod(satelliteClockModelObj, + method_gpsSatelliteClockModelGetTimeOfClockSeconds); + satelliteEphemeris.satelliteClockModel.af0 = af0; + satelliteEphemeris.satelliteClockModel.af1 = af1; + satelliteEphemeris.satelliteClockModel.af2 = af2; + satelliteEphemeris.satelliteClockModel.tgd = tgd; + satelliteEphemeris.satelliteClockModel.iodc = static_cast<int32_t>(iodc); + satelliteEphemeris.satelliteClockModel.timeOfClockSeconds = timeOfClockSeconds; + env->DeleteLocalRef(satelliteClockModelObj); + + // Set the satelliteOrbitModel of the satellite. + jobject satelliteOrbitModelObj = + env->CallObjectMethod(satelliteEphemerisObj, + method_gpsSatelliteEphemerisGetSatelliteOrbitModel); + GnssAssistanceUtil::setKeplerianOrbitModel(env, satelliteOrbitModelObj, + satelliteEphemeris.satelliteOrbitModel); + env->DeleteLocalRef(satelliteOrbitModelObj); + + // Set the satelliteHealth of the satellite. + jobject satelliteHealthObj = + env->CallObjectMethod(satelliteEphemerisObj, + method_gpsSatelliteEphemerisGetSatelliteHealth); + jint svHealth = + env->CallIntMethod(satelliteHealthObj, method_gpsSatelliteHealthGetSvHealth); + jdouble svAccur = + env->CallDoubleMethod(satelliteHealthObj, method_gpsSatelliteHealthGetSvAccur); + jdouble fitInt = env->CallIntMethod(satelliteHealthObj, method_gpsSatelliteHealthGetFitInt); + satelliteEphemeris.satelliteHealth.svHealth = static_cast<int32_t>(svHealth); + satelliteEphemeris.satelliteHealth.svAccur = svAccur; + satelliteEphemeris.satelliteHealth.fitInt = fitInt; + env->DeleteLocalRef(satelliteHealthObj); + + // Set the satelliteEphemerisTime of the satellite. + jobject satelliteEphemerisTimeObj = + env->CallObjectMethod(satelliteEphemerisObj, + method_gpsSatelliteEphemerisGetSatelliteEphemerisTime); + GnssAssistanceUtil::setSatelliteEphemerisTime(env, satelliteEphemerisTimeObj, + satelliteEphemeris.satelliteEphemerisTime); + env->DeleteLocalRef(satelliteEphemerisTimeObj); + + satelliteEphemerisList.push_back(satelliteEphemeris); + env->DeleteLocalRef(satelliteEphemerisObj); + } +} + +void GnssAssistanceUtil::setSatelliteCorrections( + JNIEnv* env, jobject satelliteCorrectionsObj, + std::vector<GnssSatelliteCorrections>& gnssSatelliteCorrectionsList) { + if (satelliteCorrectionsObj == nullptr) return; + auto len = env->CallIntMethod(satelliteCorrectionsObj, method_listSize); + for (uint16_t i = 0; i < len; ++i) { + GnssSatelliteCorrections gnssSatelliteCorrections; + jobject satelliteCorrectionObj = + env->CallObjectMethod(satelliteCorrectionsObj, method_listGet, i); + if (satelliteCorrectionObj == nullptr) continue; + jint svid = env->CallIntMethod(satelliteCorrectionObj, method_satelliteCorrectionGetSvid); + gnssSatelliteCorrections.svid = svid; + jobject ionosphericCorrectionsObj = + env->CallObjectMethod(satelliteCorrectionObj, + method_satelliteCorrectionGetIonosphericCorrections); + env->DeleteLocalRef(satelliteCorrectionObj); + auto size = env->CallIntMethod(ionosphericCorrectionsObj, method_listSize); + for (uint16_t j = 0; j < size; ++j) { + jobject ionosphericCorrectionObj = + env->CallObjectMethod(ionosphericCorrectionsObj, method_listGet, j); + if (ionosphericCorrectionObj == nullptr) continue; + IonosphericCorrection ionosphericCorrection; + jlong carrierFrequencyHz = + env->CallLongMethod(ionosphericCorrectionObj, + method_ionosphericCorrectionGetCarrierFrequencyHz); + ionosphericCorrection.carrierFrequencyHz = carrierFrequencyHz; + + jobject gnssCorrectionComponentObj = + env->CallObjectMethod(ionosphericCorrectionObj, + method_ionosphericCorrectionGetIonosphericCorrection); + env->DeleteLocalRef(ionosphericCorrectionObj); + + jstring sourceKey = static_cast<jstring>( + env->CallObjectMethod(gnssCorrectionComponentObj, + method_gnssCorrectionComponentGetSourceKey)); + ScopedJniString jniSourceKey{env, sourceKey}; + ionosphericCorrection.ionosphericCorrectionComponent.sourceKey = + android::String16(jniSourceKey.c_str()); + + jobject pseudorangeCorrectionObj = + env->CallObjectMethod(gnssCorrectionComponentObj, + method_gnssCorrectionComponentGetPseudorangeCorrection); + jdouble correctionMeters = + env->CallDoubleMethod(pseudorangeCorrectionObj, + method_pseudorangeCorrectionGetCorrectionMeters); + jdouble correctionUncertaintyMeters = env->CallDoubleMethod( + pseudorangeCorrectionObj, + method_pseudorangeCorrectionGetCorrectionUncertaintyMeters); + jdouble correctionRateMetersPerSecond = env->CallDoubleMethod( + pseudorangeCorrectionObj, + method_pseudorangeCorrectionGetCorrectionRateMetersPerSecond); + ionosphericCorrection.ionosphericCorrectionComponent.pseudorangeCorrection + .correctionMeters = correctionMeters; + ionosphericCorrection.ionosphericCorrectionComponent.pseudorangeCorrection + .correctionUncertaintyMeters = correctionUncertaintyMeters; + ionosphericCorrection.ionosphericCorrectionComponent.pseudorangeCorrection + .correctionRateMetersPerSecond = correctionRateMetersPerSecond; + env->DeleteLocalRef(pseudorangeCorrectionObj); + + jobject gnssIntervalObj = + env->CallObjectMethod(gnssCorrectionComponentObj, + method_gnssCorrectionComponentGetValidityInterval); + jdouble startMillisSinceGpsEpoch = + env->CallDoubleMethod(gnssIntervalObj, + method_gnssIntervalGetStartMillisSinceGpsEpoch); + jdouble endMillisSinceGpsEpoch = + env->CallDoubleMethod(gnssIntervalObj, + method_gnssIntervalGetEndMillisSinceGpsEpoch); + ionosphericCorrection.ionosphericCorrectionComponent.validityInterval + .startMillisSinceGpsEpoch = startMillisSinceGpsEpoch; + ionosphericCorrection.ionosphericCorrectionComponent.validityInterval + .endMillisSinceGpsEpoch = endMillisSinceGpsEpoch; + env->DeleteLocalRef(gnssIntervalObj); + + env->DeleteLocalRef(gnssCorrectionComponentObj); + gnssSatelliteCorrections.ionosphericCorrections.push_back(ionosphericCorrection); + } + gnssSatelliteCorrectionsList.push_back(gnssSatelliteCorrections); + env->DeleteLocalRef(ionosphericCorrectionsObj); + } +} + +void GnssAssistanceUtil::setRealTimeIntegrityModels( + JNIEnv* env, jobject realTimeIntegrityModelsObj, + std::vector<RealTimeIntegrityModel>& realTimeIntegrityModels) { + if (realTimeIntegrityModelsObj == nullptr) return; + auto len = env->CallIntMethod(realTimeIntegrityModelsObj, method_listSize); + for (uint16_t i = 0; i < len; ++i) { + jobject realTimeIntegrityModelObj = + env->CallObjectMethod(realTimeIntegrityModelsObj, method_listGet, i); + if (realTimeIntegrityModelObj == nullptr) continue; + RealTimeIntegrityModel realTimeIntegrityModel; + jint badSvid = env->CallIntMethod(realTimeIntegrityModelObj, + method_realTimeIntegrityModelGetBadSvid); + jobject badSignalTypesObj = + env->CallObjectMethod(realTimeIntegrityModelObj, + method_realTimeIntegrityModelGetBadSignalTypes); + auto badSignalTypesSize = env->CallIntMethod(badSignalTypesObj, method_listSize); + for (uint16_t j = 0; j < badSignalTypesSize; ++j) { + GnssSignalType badSignalType; + jobject badSignalTypeObj = env->CallObjectMethod(badSignalTypesObj, method_listGet, j); + if (badSignalTypeObj != nullptr) { + setGnssSignalType(env, badSignalTypeObj, badSignalType); + realTimeIntegrityModel.badSignalTypes.push_back(badSignalType); + env->DeleteLocalRef(badSignalTypeObj); + } + } + + jlong startDateSeconds = + env->CallLongMethod(realTimeIntegrityModelObj, + method_realTimeIntegrityModelGetStartDateSeconds); + jlong endDateSeconds = env->CallLongMethod(realTimeIntegrityModelObj, + method_realTimeIntegrityModelGetEndDateSeconds); + jlong publishDateSeconds = + env->CallLongMethod(realTimeIntegrityModelObj, + method_realTimeIntegrityModelGetPublishDateSeconds); + jstring advisoryNumber = static_cast<jstring>( + env->CallObjectMethod(realTimeIntegrityModelObj, + method_realTimeIntegrityModelGetAdvisoryNumber)); + ScopedJniString jniAdvisoryNumber{env, advisoryNumber}; + jstring advisoryType = static_cast<jstring>( + env->CallObjectMethod(realTimeIntegrityModelObj, + method_realTimeIntegrityModelGetAdvisoryType)); + ScopedJniString jniAdvisoryType{env, advisoryType}; + + realTimeIntegrityModel.badSvid = badSvid; + realTimeIntegrityModel.startDateSeconds = startDateSeconds; + realTimeIntegrityModel.endDateSeconds = endDateSeconds; + realTimeIntegrityModel.publishDateSeconds = publishDateSeconds; + realTimeIntegrityModel.advisoryNumber = android::String16(jniAdvisoryNumber.c_str()); + realTimeIntegrityModel.advisoryType = android::String16(jniAdvisoryType.c_str()); + realTimeIntegrityModels.push_back(realTimeIntegrityModel); + env->DeleteLocalRef(badSignalTypesObj); + env->DeleteLocalRef(realTimeIntegrityModelObj); + } +} + +void GnssAssistanceUtil::setGnssSignalType(JNIEnv* env, jobject gnssSignalTypeObj, + GnssSignalType& gnssSignalType) { + if (gnssSignalTypeObj == nullptr) { + ALOGE("gnssSignalTypeObj is null"); + return; + } + jint constellationType = + env->CallIntMethod(gnssSignalTypeObj, method_gnssSignalTypeGetConstellationType); + jdouble carrierFrequencyHz = + env->CallIntMethod(gnssSignalTypeObj, method_gnssSignalTypeGetCarrierFrequencyHz); + jstring codeType = static_cast<jstring>( + env->CallObjectMethod(gnssSignalTypeObj, method_gnssSignalTypeGetCodeType)); + ScopedJniString jniCodeType{env, codeType}; + + gnssSignalType.constellation = static_cast<GnssConstellationType>(constellationType); + gnssSignalType.carrierFrequencyHz = static_cast<int32_t>(carrierFrequencyHz); + gnssSignalType.codeType = std::string(jniCodeType.c_str()); +} + +void GnssAssistanceUtil::setTimeModels(JNIEnv* env, jobject timeModelsObj, + std::vector<TimeModel>& timeModels) { + if (timeModelsObj == nullptr) return; + auto len = env->CallIntMethod(timeModelsObj, method_listSize); + for (uint16_t i = 0; i < len; ++i) { + jobject timeModelObj = env->CallObjectMethod(timeModelsObj, method_listGet, i); + TimeModel timeModel; + jint toGnss = env->CallIntMethod(timeModelObj, method_timeModelsGetToGnss); + jlong timeOfWeek = env->CallLongMethod(timeModelObj, method_timeModelsGetTimeOfWeek); + jint weekNumber = env->CallIntMethod(timeModelObj, method_timeModelsGetWeekNumber); + jdouble a0 = env->CallDoubleMethod(timeModelObj, method_timeModelsGetA0); + jdouble a1 = env->CallDoubleMethod(timeModelObj, method_timeModelsGetA1); + timeModel.toGnss = static_cast<GnssConstellationType>(toGnss); + timeModel.timeOfWeek = timeOfWeek; + timeModel.weekNumber = static_cast<int32_t>(weekNumber); + timeModel.a0 = a0; + timeModel.a1 = a1; + timeModels.push_back(timeModel); + env->DeleteLocalRef(timeModelObj); + } +} + +void GnssAssistanceUtil::setLeapSecondsModel(JNIEnv* env, jobject leapSecondsModelObj, + LeapSecondsModel& leapSecondsModel) { + if (leapSecondsModelObj == nullptr) { + leapSecondsModel.leapSeconds = -1; + return; + } + jint dayNumberLeapSecondsFuture = + env->CallIntMethod(leapSecondsModelObj, + method_leapSecondsModelGetDayNumberLeapSecondsFuture); + jint leapSeconds = + env->CallIntMethod(leapSecondsModelObj, method_leapSecondsModelGetLeapSeconds); + jint leapSecondsFuture = + env->CallIntMethod(leapSecondsModelObj, method_leapSecondsModelGetLeapSecondsFuture); + jint weekNumberLeapSecondsFuture = + env->CallIntMethod(leapSecondsModelObj, + method_leapSecondsModelGetWeekNumberLeapSecondsFuture); + leapSecondsModel.dayNumberLeapSecondsFuture = static_cast<int32_t>(dayNumberLeapSecondsFuture); + leapSecondsModel.leapSeconds = static_cast<int32_t>(leapSeconds); + leapSecondsModel.leapSecondsFuture = static_cast<int32_t>(leapSecondsFuture); + leapSecondsModel.weekNumberLeapSecondsFuture = + static_cast<int32_t>(weekNumberLeapSecondsFuture); +} + +void GnssAssistanceUtil::setSatelliteEphemerisTime(JNIEnv* env, jobject satelliteEphemerisTimeObj, + SatelliteEphemerisTime& satelliteEphemerisTime) { + if (satelliteEphemerisTimeObj == nullptr) return; + jdouble iode = + env->CallDoubleMethod(satelliteEphemerisTimeObj, method_satelliteEphemerisTimeGetIode); + jdouble toeSeconds = env->CallDoubleMethod(satelliteEphemerisTimeObj, + method_satelliteEphemerisTimeGetToeSeconds); + jint weekNumber = env->CallIntMethod(satelliteEphemerisTimeObj, + method_satelliteEphemerisTimeGetWeekNumber); + satelliteEphemerisTime.iode = iode; + satelliteEphemerisTime.toeSeconds = toeSeconds; + satelliteEphemerisTime.weekNumber = weekNumber; +} + +void GnssAssistanceUtil::setKeplerianOrbitModel(JNIEnv* env, jobject keplerianOrbitModelObj, + KeplerianOrbitModel& keplerianOrbitModel) { + if (keplerianOrbitModelObj == nullptr) return; + jdouble rootA = + env->CallDoubleMethod(keplerianOrbitModelObj, method_keplerianOrbitModelGetRootA); + jdouble eccentricity = env->CallDoubleMethod(keplerianOrbitModelObj, + method_keplerianOrbitModelGetEccentricity); + jdouble m0 = env->CallDoubleMethod(keplerianOrbitModelObj, method_keplerianOrbitModelGetM0); + jdouble omega = + env->CallDoubleMethod(keplerianOrbitModelObj, method_keplerianOrbitModelGetOmega); + jdouble omegaDot = + env->CallDoubleMethod(keplerianOrbitModelObj, method_keplerianOrbitModelGetOmegaDot); + jdouble deltaN = + env->CallDoubleMethod(keplerianOrbitModelObj, method_keplerianOrbitModelGetDeltaN); + jdouble iDot = env->CallDoubleMethod(keplerianOrbitModelObj, method_keplerianOrbitModelGetIDot); + jobject secondOrderHarmonicPerturbationObj = + env->CallObjectMethod(keplerianOrbitModelObj, + method_keplerianOrbitModelGetSecondOrderHarmonicPerturbation); + jdouble cic = env->CallDoubleMethod(secondOrderHarmonicPerturbationObj, + method_secondOrderHarmonicPerturbationGetCic); + jdouble cis = env->CallDoubleMethod(secondOrderHarmonicPerturbationObj, + method_secondOrderHarmonicPerturbationGetCis); + jdouble crs = env->CallDoubleMethod(secondOrderHarmonicPerturbationObj, + method_secondOrderHarmonicPerturbationGetCrs); + jdouble crc = env->CallDoubleMethod(secondOrderHarmonicPerturbationObj, + method_secondOrderHarmonicPerturbationGetCrc); + jdouble cuc = env->CallDoubleMethod(secondOrderHarmonicPerturbationObj, + method_secondOrderHarmonicPerturbationGetCuc); + jdouble cus = env->CallDoubleMethod(secondOrderHarmonicPerturbationObj, + method_secondOrderHarmonicPerturbationGetCus); + keplerianOrbitModel.rootA = rootA; + keplerianOrbitModel.eccentricity = eccentricity; + keplerianOrbitModel.m0 = m0; + keplerianOrbitModel.omega = omega; + keplerianOrbitModel.omegaDot = omegaDot; + keplerianOrbitModel.deltaN = deltaN; + keplerianOrbitModel.iDot = iDot; + keplerianOrbitModel.secondOrderHarmonicPerturbation.cic = cic; + keplerianOrbitModel.secondOrderHarmonicPerturbation.cis = cis; + keplerianOrbitModel.secondOrderHarmonicPerturbation.crs = crs; + keplerianOrbitModel.secondOrderHarmonicPerturbation.crc = crc; + keplerianOrbitModel.secondOrderHarmonicPerturbation.cuc = cuc; + keplerianOrbitModel.secondOrderHarmonicPerturbation.cus = cus; + env->DeleteLocalRef(secondOrderHarmonicPerturbationObj); +} + +void GnssAssistanceUtil::setKlobucharIonosphericModel( + JNIEnv* env, jobject klobucharIonosphericModelObj, + KlobucharIonosphericModel& klobucharIonosphericModel) { + if (klobucharIonosphericModelObj == nullptr) return; + jdouble alpha0 = env->CallDoubleMethod(klobucharIonosphericModelObj, + method_klobucharIonosphericModelGetAlpha0); + jdouble alpha1 = env->CallDoubleMethod(klobucharIonosphericModelObj, + method_klobucharIonosphericModelGetAlpha1); + jdouble alpha2 = env->CallDoubleMethod(klobucharIonosphericModelObj, + method_klobucharIonosphericModelGetAlpha2); + jdouble alpha3 = env->CallDoubleMethod(klobucharIonosphericModelObj, + method_klobucharIonosphericModelGetAlpha3); + jdouble beta0 = env->CallDoubleMethod(klobucharIonosphericModelObj, + method_klobucharIonosphericModelGetBeta0); + jdouble beta1 = env->CallDoubleMethod(klobucharIonosphericModelObj, + method_klobucharIonosphericModelGetBeta1); + jdouble beta2 = env->CallDoubleMethod(klobucharIonosphericModelObj, + method_klobucharIonosphericModelGetBeta2); + jdouble beta3 = env->CallDoubleMethod(klobucharIonosphericModelObj, + method_klobucharIonosphericModelGetBeta3); + klobucharIonosphericModel.alpha0 = alpha0; + klobucharIonosphericModel.alpha1 = alpha1; + klobucharIonosphericModel.alpha2 = alpha2; + klobucharIonosphericModel.alpha3 = alpha3; + klobucharIonosphericModel.beta0 = beta0; + klobucharIonosphericModel.beta1 = beta1; + klobucharIonosphericModel.beta2 = beta2; + klobucharIonosphericModel.beta3 = beta3; +} + +void GnssAssistanceUtil::setUtcModel(JNIEnv* env, jobject utcModelObj, UtcModel& utcModel) { + if (utcModelObj == nullptr) { + utcModel.weekNumber = -1; + return; + } + jdouble a0 = env->CallDoubleMethod(utcModelObj, method_utcModelGetA0); + jdouble a1 = env->CallDoubleMethod(utcModelObj, method_utcModelGetA1); + jlong timeOfWeek = env->CallLongMethod(utcModelObj, method_utcModelGetTimeOfWeek); + jint weekNumber = env->CallIntMethod(utcModelObj, method_utcModelGetWeekNumber); + utcModel.a0 = a0; + utcModel.a1 = a1; + utcModel.timeOfWeek = timeOfWeek; + utcModel.weekNumber = static_cast<int32_t>(weekNumber); +} + +void GnssAssistanceUtil::setGnssAlmanac(JNIEnv* env, jobject gnssAlmanacObj, + GnssAlmanac& gnssAlmanac) { + if (gnssAlmanacObj == nullptr) { + gnssAlmanac.weekNumber = -1; + return; + } + jlong issueDateMillis = + env->CallLongMethod(gnssAlmanacObj, method_gnssAlmanacGetIssueDateMillis); + jint ioda = env->CallIntMethod(gnssAlmanacObj, method_gnssAlmanacGetIoda); + jint weekNumber = env->CallIntMethod(gnssAlmanacObj, method_gnssAlmanacGetWeekNumber); + jlong toaSeconds = env->CallLongMethod(gnssAlmanacObj, method_gnssAlmanacGetToaSeconds); + jboolean isCompleteAlmanacProvided = + env->CallBooleanMethod(gnssAlmanacObj, method_gnssAlmanacIsCompleteAlmanacProvided); + gnssAlmanac.issueDateMs = issueDateMillis; + gnssAlmanac.ioda = ioda; + gnssAlmanac.weekNumber = weekNumber; + gnssAlmanac.toaSeconds = toaSeconds; + gnssAlmanac.isCompleteAlmanacProvided = isCompleteAlmanacProvided; + + jobject satelliteAlmanacsListObj = + env->CallObjectMethod(gnssAlmanacObj, method_gnssAlmanacGetSatelliteAlmanacs); + auto len = env->CallIntMethod(satelliteAlmanacsListObj, method_listSize); + std::vector<GnssSatelliteAlmanac> list(len); + for (uint16_t i = 0; i < len; ++i) { + jobject gnssSatelliteAlmanacObj = + env->CallObjectMethod(satelliteAlmanacsListObj, method_listGet, i); + if (gnssSatelliteAlmanacObj == nullptr) continue; + GnssSatelliteAlmanac gnssSatelliteAlmanac; + jint svid = env->CallIntMethod(gnssSatelliteAlmanacObj, method_satelliteAlmanacGetSvid); + jint svHealth = + env->CallIntMethod(gnssSatelliteAlmanacObj, method_satelliteAlmanacGetSvHealth); + jdouble af0 = env->CallDoubleMethod(gnssSatelliteAlmanacObj, method_satelliteAlmanacGetAf0); + jdouble af1 = env->CallDoubleMethod(gnssSatelliteAlmanacObj, method_satelliteAlmanacGetAf1); + jdouble eccentricity = env->CallDoubleMethod(gnssSatelliteAlmanacObj, + method_satelliteAlmanacGetEccentricity); + jdouble inclination = env->CallDoubleMethod(gnssSatelliteAlmanacObj, + method_satelliteAlmanacGetInclination); + jdouble m0 = env->CallDoubleMethod(gnssSatelliteAlmanacObj, method_satelliteAlmanacGetM0); + jdouble omega = + env->CallDoubleMethod(gnssSatelliteAlmanacObj, method_satelliteAlmanacGetOmega); + jdouble omega0 = + env->CallDoubleMethod(gnssSatelliteAlmanacObj, method_satelliteAlmanacGetOmega0); + jdouble omegaDot = + env->CallDoubleMethod(gnssSatelliteAlmanacObj, method_satelliteAlmanacGetOmegaDot); + jdouble rootA = + env->CallDoubleMethod(gnssSatelliteAlmanacObj, method_satelliteAlmanacGetRootA); + gnssSatelliteAlmanac.svid = static_cast<int32_t>(svid); + gnssSatelliteAlmanac.svHealth = static_cast<int32_t>(svHealth); + gnssSatelliteAlmanac.af0 = af0; + gnssSatelliteAlmanac.af1 = af1; + gnssSatelliteAlmanac.eccentricity = eccentricity; + gnssSatelliteAlmanac.inclination = inclination; + gnssSatelliteAlmanac.m0 = m0; + gnssSatelliteAlmanac.omega = omega; + gnssSatelliteAlmanac.omega0 = omega0; + gnssSatelliteAlmanac.omegaDot = omegaDot; + gnssSatelliteAlmanac.rootA = rootA; + list.at(i) = gnssSatelliteAlmanac; + env->DeleteLocalRef(gnssSatelliteAlmanacObj); + } + gnssAlmanac.satelliteAlmanacs = list; + env->DeleteLocalRef(satelliteAlmanacsListObj); +} + +void GnssAssistanceUtil::setAuxiliaryInformation(JNIEnv* env, jobject auxiliaryInformationObj, + AuxiliaryInformation& auxiliaryInformation) { + if (auxiliaryInformationObj == nullptr) { + auxiliaryInformation.svid = -1; + return; + } + jint svid = env->CallIntMethod(auxiliaryInformationObj, method_auxiliaryInformationGetSvid); + jobject availableSignalTypesObj = + env->CallObjectMethod(auxiliaryInformationObj, + method_auxiliaryInformationGetAvailableSignalTypes); + auto size = env->CallIntMethod(availableSignalTypesObj, method_listSize); + std::vector<GnssSignalType> availableSignalTypes(size); + for (uint16_t i = 0; i < size; ++i) { + jobject availableSignalTypeObj = + env->CallObjectMethod(availableSignalTypesObj, method_listGet, i); + GnssSignalType availableSignalType; + setGnssSignalType(env, availableSignalTypeObj, availableSignalType); + availableSignalTypes.at(i) = availableSignalType; + env->DeleteLocalRef(availableSignalTypeObj); + } + jint frequencyChannelNumber = + env->CallIntMethod(auxiliaryInformationObj, + method_auxiliaryInformationGetFrequencyChannelNumber); + jint satType = + env->CallIntMethod(auxiliaryInformationObj, method_auxiliaryInformationGetSatType); + auxiliaryInformation.svid = static_cast<int32_t>(svid); + auxiliaryInformation.availableSignalTypes = availableSignalTypes; + auxiliaryInformation.frequencyChannelNumber = static_cast<int32_t>(frequencyChannelNumber); + auxiliaryInformation.satType = static_cast<BeidouB1CSatelliteOrbitType>(satType); + env->DeleteLocalRef(availableSignalTypesObj); +} + +} // namespace android::gnss diff --git a/services/core/jni/gnss/GnssAssistance.h b/services/core/jni/gnss/GnssAssistance.h new file mode 100644 index 000000000000..ee97e19371f8 --- /dev/null +++ b/services/core/jni/gnss/GnssAssistance.h @@ -0,0 +1,135 @@ +/* + * 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. + */ + +#ifndef _ANDROID_SERVER_GNSSASSITANCE_H +#define _ANDROID_SERVER_GNSSASSITANCE_H + +#include <sys/stat.h> +#pragma once + +#ifndef LOG_TAG +#error LOG_TAG must be defined before including this file. +#endif + +#include <android/hardware/gnss/gnss_assistance/BnGnssAssistanceInterface.h> +#include <log/log.h> + +#include "GnssAssistanceCallback.h" +#include "jni.h" + +namespace android::gnss { + +using IGnssAssistanceInterface = android::hardware::gnss::gnss_assistance::IGnssAssistanceInterface; +using IGnssAssistanceCallback = android::hardware::gnss::gnss_assistance::IGnssAssistanceCallback; +using BeidouAssistance = android::hardware::gnss::gnss_assistance::GnssAssistance::BeidouAssistance; +using BeidouSatelliteEphemeris = android::hardware::gnss::gnss_assistance::BeidouSatelliteEphemeris; +using GalileoAssistance = + android::hardware::gnss::gnss_assistance::GnssAssistance::GalileoAssistance; +using GalileoSatelliteEphemeris = + android::hardware::gnss::gnss_assistance::GalileoSatelliteEphemeris; +using GalileoIonosphericModel = android::hardware::gnss::gnss_assistance::GalileoIonosphericModel; +using GlonassAssistance = + android::hardware::gnss::gnss_assistance::GnssAssistance::GlonassAssistance; +using GlonassAlmanac = android::hardware::gnss::gnss_assistance::GlonassAlmanac; +using GlonassSatelliteEphemeris = + android::hardware::gnss::gnss_assistance::GlonassSatelliteEphemeris; +using GnssAssistance = android::hardware::gnss::gnss_assistance::GnssAssistance; +using GnssSignalType = android::hardware::gnss::GnssSignalType; +using GpsAssistance = android::hardware::gnss::gnss_assistance::GnssAssistance::GpsAssistance; +using QzssAssistance = android::hardware::gnss::gnss_assistance::GnssAssistance::QzssAssistance; +using GnssAlmanac = android::hardware::gnss::gnss_assistance::GnssAlmanac; +using GnssSatelliteCorrections = + android::hardware::gnss::gnss_assistance::GnssAssistance::GnssSatelliteCorrections; +using GpsSatelliteEphemeris = android::hardware::gnss::gnss_assistance::GpsSatelliteEphemeris; +using SatelliteEphemerisTime = android::hardware::gnss::gnss_assistance::SatelliteEphemerisTime; +using UtcModel = android::hardware::gnss::gnss_assistance::UtcModel; +using LeapSecondsModel = android::hardware::gnss::gnss_assistance::LeapSecondsModel; +using KeplerianOrbitModel = android::hardware::gnss::gnss_assistance::KeplerianOrbitModel; +using KlobucharIonosphericModel = + android::hardware::gnss::gnss_assistance::KlobucharIonosphericModel; +using TimeModel = android::hardware::gnss::gnss_assistance::TimeModel; +using RealTimeIntegrityModel = android::hardware::gnss::gnss_assistance::RealTimeIntegrityModel; +using AuxiliaryInformation = android::hardware::gnss::gnss_assistance::AuxiliaryInformation; + +void GnssAssistance_class_init_once(JNIEnv* env, jclass clazz); + +class GnssAssistanceInterface { +public: + GnssAssistanceInterface(const sp<IGnssAssistanceInterface>& iGnssAssistance); + jboolean injectGnssAssistance(JNIEnv* env, jobject gnssAssistanceObj); + jboolean setCallback(const sp<IGnssAssistanceCallback>& callback); + +private: + const sp<IGnssAssistanceInterface> mGnssAssistanceInterface; +}; + +struct GnssAssistanceUtil { + static void setGlonassAssistance(JNIEnv* env, jobject glonassAssistanceObj, + GlonassAssistance& galileoAssistance); + static void setGlonassSatelliteEphemeris( + JNIEnv* env, jobject glonassSatelliteEphemerisObj, + std::vector<GlonassSatelliteEphemeris>& glonassSatelliteEphemerisList); + static void setGlonassAlmanac(JNIEnv* env, jobject glonassAlmanacObj, + GlonassAlmanac& glonassAlmanac); + static void setBeidouAssistance(JNIEnv* env, jobject beidouAssistanceObj, + BeidouAssistance& beidouAssistance); + static void setBeidouSatelliteEphemeris( + JNIEnv* env, jobject beidouSatelliteEphemerisObj, + std::vector<BeidouSatelliteEphemeris>& beidouSatelliteEphemerisList); + static void setGalileoAssistance(JNIEnv* env, jobject galileoAssistanceObj, + GalileoAssistance& galileoAssistance); + static void setGalileoSatelliteEphemeris( + JNIEnv* env, jobject galileoSatelliteEphemerisObj, + std::vector<GalileoSatelliteEphemeris>& galileoSatelliteEphemerisList); + static void setGaliloKlobucharIonosphericModel(JNIEnv* env, jobject galileoIonosphericModelObj, + GalileoIonosphericModel& ionosphericModel); + static void setGnssAssistance(JNIEnv* env, jobject gnssAssistanceObj, + GnssAssistance& gnssAssistance); + static void setGpsAssistance(JNIEnv* env, jobject gpsAssistanceObj, + GpsAssistance& gpsAssistance); + template <class T> + static void setGpsOrQzssSatelliteEphemeris(JNIEnv* env, jobject satelliteEphemerisObj, + std::vector<T>& satelliteEphemeris); + static void setQzssAssistance(JNIEnv* env, jobject qzssAssistanceObj, + QzssAssistance& qzssAssistance); + static void setGnssAlmanac(JNIEnv* env, jobject gnssAlmanacObj, GnssAlmanac& gnssAlmanac); + static void setGnssSignalType(JNIEnv* env, jobject gnssSignalTypeObj, + GnssSignalType& gnssSignalType); + static void setKeplerianOrbitModel(JNIEnv* env, jobject keplerianOrbitModelObj, + KeplerianOrbitModel& keplerianOrbitModel); + static void setKlobucharIonosphericModel(JNIEnv* env, jobject klobucharIonosphericModelObj, + KlobucharIonosphericModel& klobucharIonosphericModel); + static void setTimeModels(JNIEnv* env, jobject timeModelsObj, + std::vector<TimeModel>& timeModels); + static void setLeapSecondsModel(JNIEnv* env, jobject leapSecondsModelObj, + LeapSecondsModel& leapSecondsModel); + static void setRealTimeIntegrityModels( + JNIEnv* env, jobject realTimeIntegrityModelsObj, + std::vector<RealTimeIntegrityModel>& realTimeIntegrityModels); + + static void setSatelliteEphemerisTime(JNIEnv* env, jobject satelliteEphemerisTimeObj, + SatelliteEphemerisTime& satelliteEphemerisTime); + static void setUtcModel(JNIEnv* env, jobject utcModelObj, UtcModel& utcModel); + static void setSatelliteCorrections( + JNIEnv* env, jobject satelliteCorrectionsObj, + std::vector<GnssSatelliteCorrections>& satelliteCorrections); + static void setAuxiliaryInformation(JNIEnv* env, jobject auxiliaryInformationObj, + AuxiliaryInformation& auxiliaryInformation); +}; + +} // namespace android::gnss + +#endif // _ANDROID_SERVER_GNSSASSITANCE__H diff --git a/services/core/jni/gnss/GnssAssistanceCallback.cpp b/services/core/jni/gnss/GnssAssistanceCallback.cpp new file mode 100644 index 000000000000..dbb27d72663e --- /dev/null +++ b/services/core/jni/gnss/GnssAssistanceCallback.cpp @@ -0,0 +1,48 @@ +/* + * 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. + */ + +#define LOG_TAG "GnssAssistanceCbJni" + +#include "GnssAssistanceCallback.h" + +#include "Utils.h" + +namespace { +jmethodID method_gnssAssistanceInjectRequest; +} // anonymous namespace + +namespace android::gnss { + +using binder::Status; +using hardware::Return; +using hardware::Void; + +void GnssAssistanceCallback_class_init_once(JNIEnv* env, jclass clazz) { + method_gnssAssistanceInjectRequest = + env->GetStaticMethodID(clazz, "gnssAssistanceInjectRequest", "()V"); +} + +// Implementation of android::hardware::gnss::gnss_assistance::GnssAssistanceCallback. + +Status GnssAssistanceCallback::injectRequestCb() { + ALOGD("%s.", __func__); + JNIEnv* env = getJniEnv(); + env->CallVoidMethod(mCallbacksObj, method_gnssAssistanceInjectRequest); + checkAndClearExceptionFromCallback(env, __FUNCTION__); + return Status::ok(); +} + +} // namespace android::gnss diff --git a/services/core/jni/gnss/GnssAssistanceCallback.h b/services/core/jni/gnss/GnssAssistanceCallback.h new file mode 100644 index 000000000000..4c8c5fc06730 --- /dev/null +++ b/services/core/jni/gnss/GnssAssistanceCallback.h @@ -0,0 +1,48 @@ +/* + * 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. + */ + +#ifndef _ANDROID_SERVER_GNSS_GNSSASSITANCECALLBACK_H +#define _ANDROID_SERVER_GNSS_GNSSASSITANCECALLBACK_H + +#pragma once + +#ifndef LOG_TAG +#error LOG_TAG must be defined before including this file. +#endif + +#include <android/hardware/gnss/gnss_assistance/BnGnssAssistanceCallback.h> +#include <log/log.h> + +#include "Utils.h" +#include "jni.h" + +namespace android::gnss { + +void GnssAssistanceCallback_class_init_once(JNIEnv* env, jclass clazz); + +/* + * GnssAssistanceCallback class implements the callback methods required by the + * android::hardware::gnss::gnss_assistance::IGnssAssistanceCallback interface. + */ +class GnssAssistanceCallback : public hardware::gnss::gnss_assistance::BnGnssAssistanceCallback { +public: + GnssAssistanceCallback() {} + binder::Status injectRequestCb() override; +}; + +} // namespace android::gnss + +#endif // _ANDROID_SERVER_GNSS_GNSSASSITANCECALLBACK_H diff --git a/services/credentials/java/com/android/server/credentials/CredentialManagerService.java b/services/credentials/java/com/android/server/credentials/CredentialManagerService.java index 42e457c97fd4..bc5c427e3ccb 100644 --- a/services/credentials/java/com/android/server/credentials/CredentialManagerService.java +++ b/services/credentials/java/com/android/server/credentials/CredentialManagerService.java @@ -51,7 +51,6 @@ import android.credentials.ISetEnabledProvidersCallback; import android.credentials.PrepareGetCredentialResponseInternal; import android.credentials.RegisterCredentialDescriptionRequest; import android.credentials.UnregisterCredentialDescriptionRequest; -import android.credentials.flags.Flags; import android.os.Binder; import android.os.CancellationSignal; import android.os.IBinder; @@ -538,34 +537,31 @@ public final class CredentialManagerService final int userId = UserHandle.getCallingUserId(); final int callingUid = Binder.getCallingUid(); - if (Flags.safeguardCandidateCredentialsApiCaller()) { - try { - String credentialManagerAutofillCompName = mContext.getResources().getString( - R.string.config_defaultCredentialManagerAutofillService); - ComponentName componentName = ComponentName.unflattenFromString( - credentialManagerAutofillCompName); - if (componentName == null) { - throw new SecurityException( - "Credential Autofill service does not exist on this device."); - } - PackageManager pm = mContext.createContextAsUser( - UserHandle.getUserHandleForUid(callingUid), 0).getPackageManager(); - String callingProcessPackage = pm.getNameForUid(callingUid); - if (callingProcessPackage == null) { - throw new SecurityException( - "Couldn't determine the identity of the caller."); - } - if (!Objects.equals(componentName.getPackageName(), callingProcessPackage)) { - throw new SecurityException(callingProcessPackage - + " is not the device's credential autofill package."); - } - } catch (Resources.NotFoundException e) { + try { + String credentialManagerAutofillCompName = mContext.getResources().getString( + R.string.config_defaultCredentialManagerAutofillService); + ComponentName componentName = ComponentName.unflattenFromString( + credentialManagerAutofillCompName); + if (componentName == null) { throw new SecurityException( "Credential Autofill service does not exist on this device."); } + PackageManager pm = mContext.createContextAsUser( + UserHandle.getUserHandleForUid(callingUid), 0).getPackageManager(); + String callingProcessPackage = pm.getNameForUid(callingUid); + if (callingProcessPackage == null) { + throw new SecurityException( + "Couldn't determine the identity of the caller."); + } + if (!Objects.equals(componentName.getPackageName(), callingProcessPackage)) { + throw new SecurityException(callingProcessPackage + + " is not the device's credential autofill package."); + } + } catch (Resources.NotFoundException e) { + throw new SecurityException( + "Credential Autofill service does not exist on this device."); } - // New request session, scoped for this request only. final GetCandidateRequestSession session = new GetCandidateRequestSession( diff --git a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/UserDataRepositoryTest.java b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/UserDataRepositoryTest.java index 6adb01ccf11f..e898c833b321 100644 --- a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/UserDataRepositoryTest.java +++ b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/UserDataRepositoryTest.java @@ -18,7 +18,6 @@ package com.android.server.inputmethod; import static com.google.common.truth.Truth.assertThat; -import android.platform.test.ravenwood.RavenwoodRule; import android.view.WindowManager; import androidx.annotation.NonNull; @@ -28,7 +27,6 @@ import com.android.server.wm.WindowManagerInternal; import org.junit.After; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -42,10 +40,6 @@ public final class UserDataRepositoryTest { private static final int ANY_USER_ID = 1; - @Rule - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true).build(); - @Mock private InputMethodManagerService mMockInputMethodManagerService; diff --git a/services/tests/VpnTests/java/com/android/server/connectivity/VpnTest.java b/services/tests/VpnTests/java/com/android/server/connectivity/VpnTest.java index 9117cc8e5ab8..a38ecc8523b1 100644 --- a/services/tests/VpnTests/java/com/android/server/connectivity/VpnTest.java +++ b/services/tests/VpnTests/java/com/android/server/connectivity/VpnTest.java @@ -3186,6 +3186,32 @@ public class VpnTest extends VpnTestBase { assertEquals(profile, ikev2VpnProfile.toVpnProfile()); } + @Test + public void testStartAlwaysOnVpnOnSafeMode() throws Exception { + final Vpn vpn = createVpn(PRIMARY_USER.id); + setMockedUsers(PRIMARY_USER); + + // UID checks must return a different UID; otherwise it'll be treated as already prepared. + final int uid = Process.myUid() + 1; + when(mPackageManager.getPackageUidAsUser(eq(TEST_VPN_PKG), anyInt())) + .thenReturn(uid); + when(mVpnProfileStore.get(vpn.getProfileNameForPackage(TEST_VPN_PKG))) + .thenReturn(mVpnProfile.encode()); + + setAndVerifyAlwaysOnPackage(vpn, uid, false); + assertTrue(vpn.startAlwaysOnVpn()); + assertEquals(TEST_VPN_PKG, vpn.getAlwaysOnPackage()); + + // Simulate safe mode and restart the always-on VPN to verify the always-on package is not + // reset. + doReturn(null).when(mVpnProfileStore).get(vpn.getProfileNameForPackage(TEST_VPN_PKG)); + doReturn(null).when(mPackageManager).queryIntentServicesAsUser( + any(), any(), eq(PRIMARY_USER.id)); + doReturn(true).when(mPackageManager).isSafeMode(); + assertFalse(vpn.startAlwaysOnVpn()); + assertEquals(TEST_VPN_PKG, vpn.getAlwaysOnPackage()); + } + // Make it public and un-final so as to spy it public class TestDeps extends Vpn.Dependencies { TestDeps() {} diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/AmbientDisplayPowerCalculatorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/AmbientDisplayPowerCalculatorTest.java index 4b91d8418fc3..28d39fd8cea2 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/AmbientDisplayPowerCalculatorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/AmbientDisplayPowerCalculatorTest.java @@ -21,7 +21,6 @@ import static com.android.internal.os.PowerProfile.POWER_GROUP_DISPLAY_AMBIENT; import static com.google.common.truth.Truth.assertThat; import android.os.BatteryConsumer; -import android.platform.test.ravenwood.RavenwoodRule; import android.view.Display; import androidx.test.filters.SmallTest; @@ -35,15 +34,10 @@ import org.junit.runner.RunWith; @SmallTest @SuppressWarnings("GuardedBy") public class AmbientDisplayPowerCalculatorTest { - @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private static final double PRECISION = 0.00001; private static final long MINUTE_IN_MS = 60 * 1000; - @Rule(order = 1) + @Rule(order = 0) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule() .setAveragePowerForOrdinal(POWER_GROUP_DISPLAY_AMBIENT, 0, 10.0) .setNumDisplays(1); diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/AudioPowerCalculatorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/AudioPowerCalculatorTest.java index ce451c2a842a..7f03953204d0 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/AudioPowerCalculatorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/AudioPowerCalculatorTest.java @@ -21,7 +21,6 @@ import static com.google.common.truth.Truth.assertThat; import android.os.BatteryConsumer; import android.os.Process; import android.os.UidBatteryConsumer; -import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; @@ -35,16 +34,11 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @SmallTest public class AudioPowerCalculatorTest { - @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private static final double PRECISION = 0.00001; private static final int APP_UID = Process.FIRST_APPLICATION_UID + 42; - @Rule(order = 1) + @Rule(order = 0) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule() .setAveragePower(PowerProfile.POWER_AUDIO, 360.0); diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryChargeCalculatorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryChargeCalculatorTest.java index ec8ede06099f..7faa29572b18 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryChargeCalculatorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryChargeCalculatorTest.java @@ -23,7 +23,6 @@ import static org.mockito.Mockito.mock; import android.content.Context; import android.os.BatteryManager; import android.os.BatteryUsageStats; -import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; @@ -38,14 +37,9 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @SmallTest public class BatteryChargeCalculatorTest { - @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private static final double PRECISION = 0.00001; - @Rule(order = 1) + @Rule(order = 0) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule() .setAveragePower(PowerProfile.POWER_BATTERY_CAPACITY, 4000.0); diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsBackgroundStatsTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsBackgroundStatsTest.java index ad05b5124955..8791c2f93ab8 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsBackgroundStatsTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsBackgroundStatsTest.java @@ -25,13 +25,11 @@ import static org.junit.Assert.assertTrue; import android.app.ActivityManager; import android.os.BatteryStats; import android.os.WorkSource; -import android.platform.test.ravenwood.RavenwoodRule; import android.util.ArrayMap; import android.view.Display; import androidx.test.filters.SmallTest; -import org.junit.Rule; import org.junit.Test; /** @@ -39,11 +37,6 @@ import org.junit.Test; */ public class BatteryStatsBackgroundStatsTest { - @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private static final int UID = 10500; /** Test that BatteryStatsImpl.Uid.mOnBatteryBackgroundTimeBase works correctly. */ diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsBinderCallStatsTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsBinderCallStatsTest.java index 4dfc3fcec916..c0d33cb7134a 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsBinderCallStatsTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsBinderCallStatsTest.java @@ -20,7 +20,6 @@ import static org.junit.Assert.assertEquals; import android.os.Binder; import android.os.Process; -import android.platform.test.ravenwood.RavenwoodRule; import android.util.ArraySet; import androidx.test.filters.SmallTest; @@ -28,7 +27,6 @@ import androidx.test.filters.SmallTest; import com.android.internal.os.BinderCallsStats; import com.android.internal.os.BinderTransactionNameResolver; -import org.junit.Rule; import org.junit.Test; import java.util.ArrayList; @@ -41,11 +39,6 @@ import java.util.Collection; @android.platform.test.annotations.DisabledOnRavenwood(blockedBy = BinderCallsStats.class) public class BatteryStatsBinderCallStatsTest { - @Rule - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private static final int TRANSACTION_CODE1 = 100; private static final int TRANSACTION_CODE2 = 101; diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsCpuTimesTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsCpuTimesTest.java index eff1b7b852d9..b73895c6e42f 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsCpuTimesTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsCpuTimesTest.java @@ -40,7 +40,6 @@ import android.os.BatteryStats; import android.os.Handler; import android.os.Looper; import android.os.UserHandle; -import android.platform.test.ravenwood.RavenwoodRule; import android.util.SparseArray; import android.util.SparseLongArray; import android.view.Display; @@ -57,7 +56,6 @@ import com.android.internal.os.KernelCpuUidTimeReader.KernelCpuUidUserSysTimeRea import com.android.internal.util.ArrayUtils; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; @@ -88,11 +86,6 @@ import java.util.Arrays; @RunWith(AndroidJUnit4.class) @SuppressWarnings("SynchronizeOnNonFinalField") public class BatteryStatsCpuTimesTest { - @Rule - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - @Mock KernelCpuUidUserSysTimeReader mCpuUidUserSysTimeReader; @Mock diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsHistoryIteratorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsHistoryIteratorTest.java index 7e40e6b4f71f..503e23347cf6 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsHistoryIteratorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsHistoryIteratorTest.java @@ -22,7 +22,6 @@ import static com.google.common.truth.Truth.assertWithMessage; import android.os.BatteryManager; import android.os.BatteryStats; import android.os.Process; -import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; @@ -31,7 +30,6 @@ import com.android.internal.os.BatteryStatsHistoryIterator; import com.android.internal.os.MonotonicClock; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -44,11 +42,6 @@ import java.util.Random; @SmallTest @SuppressWarnings("GuardedBy") public class BatteryStatsHistoryIteratorTest { - @Rule - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private static final int APP_UID = Process.FIRST_APPLICATION_UID + 42; private final MockClock mMockClock = new MockClock(); diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsImplTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsImplTest.java index db3268729f1e..17440930d077 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsImplTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsImplTest.java @@ -92,7 +92,6 @@ import java.util.List; public class BatteryStatsImplTest { @Rule(order = 0) public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) .setSystemPropertyImmutable("persist.sys.com.android.server.power.feature.flags." + "framework_wakelock_info-override", null) .build(); @@ -150,7 +149,7 @@ public class BatteryStatsImplTest { File systemDir = Files.createTempDirectory("BatteryStatsHistoryTest").toFile(); Context context; - if (RavenwoodRule.isUnderRavenwood()) { + if (RavenwoodRule.isOnRavenwood()) { context = mock(Context.class); SensorManager sensorManager = mock(SensorManager.class); when(sensorManager.getSensorList(anyInt())).thenReturn(List.of()); @@ -856,7 +855,7 @@ public class BatteryStatsImplTest { } private UidTraffic createUidTraffic(int appUid, long rxBytes, long txBytes) { - if (RavenwoodRule.isUnderRavenwood()) { + if (RavenwoodRule.isOnRavenwood()) { UidTraffic uidTraffic = mock(UidTraffic.class); when(uidTraffic.getUid()).thenReturn(appUid); when(uidTraffic.getRxBytes()).thenReturn(rxBytes); @@ -881,7 +880,7 @@ public class BatteryStatsImplTest { long controllerIdleTimeMs, long controllerEnergyUsed, UidTraffic... uidTraffic) { - if (RavenwoodRule.isUnderRavenwood()) { + if (RavenwoodRule.isOnRavenwood()) { BluetoothActivityEnergyInfo info = mock(BluetoothActivityEnergyInfo.class); when(info.getTimestampMillis()).thenReturn(timestamp); when(info.getControllerTxTimeMillis()).thenReturn(controllerTxTimeMs); diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsNoteTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsNoteTest.java index 30ff8005563a..ffb309a211f9 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsNoteTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsNoteTest.java @@ -91,7 +91,6 @@ public class BatteryStatsNoteTest { @Rule public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) .setSystemPropertyImmutable( "persist.sys.com.android.server.power.feature.flags." + "framework_wakelock_info-override", diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsResetTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsResetTest.java index b6d49d0ade0a..550df3ae1fa7 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsResetTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsResetTest.java @@ -23,7 +23,6 @@ import static org.mockito.Mockito.when; import android.content.Context; import android.os.BatteryManager; -import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; @@ -40,11 +39,6 @@ import java.io.IOException; public class BatteryStatsResetTest { @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - - @Rule(order = 1) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule() .createTempDirectory(); diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsSensorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsSensorTest.java index 96780c322445..018e8c2dbb08 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsSensorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsSensorTest.java @@ -22,12 +22,10 @@ import static org.junit.Assert.assertNull; import android.app.ActivityManager; import android.os.BatteryStats; -import android.platform.test.ravenwood.RavenwoodRule; import android.view.Display; import androidx.test.filters.SmallTest; -import org.junit.Rule; import org.junit.Test; /** @@ -36,11 +34,6 @@ import org.junit.Test; @SmallTest public class BatteryStatsSensorTest { - @Rule - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private static final int UID = 10500; private static final int UID_2 = 10501; // second uid for testing pool usage private static final int SENSOR_ID = -10000; diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsServTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsServTest.java index 6f683ae5e0c0..882e48da5273 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsServTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryStatsServTest.java @@ -18,13 +18,11 @@ package com.android.server.power.stats; import android.os.BatteryStats; import android.os.Parcel; -import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.filters.SmallTest; import junit.framework.Assert; -import org.junit.Rule; import org.junit.Test; /** @@ -32,11 +30,6 @@ import org.junit.Test; */ @SmallTest public class BatteryStatsServTest { - @Rule - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private static final String TAG = "BatteryStatsServTest"; public static class TestServ extends BatteryStatsImpl.Uid.Pkg.Serv { diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryUsageStatsProviderTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryUsageStatsProviderTest.java index 93fe8d330d5b..8a1d37b55255 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryUsageStatsProviderTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryUsageStatsProviderTest.java @@ -68,18 +68,13 @@ import java.util.concurrent.TimeUnit; @RunWith(AndroidJUnit4.class) public class BatteryUsageStatsProviderTest { @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - - @Rule(order = 1) public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); private static final int APP_UID = Process.FIRST_APPLICATION_UID + 42; private static final long MINUTE_IN_MS = 60 * 1000; private static final double PRECISION = 0.00001; - @Rule(order = 2) + @Rule(order = 1) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule(12345) .createTempDirectory() @@ -94,7 +89,7 @@ public class BatteryUsageStatsProviderTest { @Before public void setup() throws IOException { - if (RavenwoodRule.isUnderRavenwood()) { + if (RavenwoodRule.isOnRavenwood()) { mContext = mock(Context.class); SensorManager sensorManager = mock(SensorManager.class); when(mContext.getSystemService(SensorManager.class)).thenReturn(sensorManager); @@ -420,7 +415,7 @@ public class BatteryUsageStatsProviderTest { Parcel parcel = Parcel.obtain(); parcel.writeParcelable(batteryUsageStats, 0); - if (!RavenwoodRule.isUnderRavenwood()) { + if (!RavenwoodRule.isOnRavenwood()) { assertThat(parcel.dataSize()).isAtMost(128_000); } @@ -579,7 +574,7 @@ public class BatteryUsageStatsProviderTest { MockBatteryStatsImpl batteryStats = mStatsRule.getBatteryStats(); accumulateBatteryUsageStats(batteryStats, 10000000, 0); // Accumulate every 200 bytes of battery history - accumulateBatteryUsageStats(batteryStats, 200, 2); + accumulateBatteryUsageStats(batteryStats, 200, 1); accumulateBatteryUsageStats(batteryStats, 50, 5); // Accumulate on every invocation of accumulateBatteryUsageStats accumulateBatteryUsageStats(batteryStats, 0, 7); diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryUsageStatsTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryUsageStatsTest.java index 097a60ed52c5..dc1c3b4e2b23 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryUsageStatsTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryUsageStatsTest.java @@ -37,7 +37,6 @@ import android.os.BatteryUsageStats; import android.os.Parcel; import android.os.UidBatteryConsumer; import android.os.UserBatteryConsumer; -import android.platform.test.ravenwood.RavenwoodRule; import android.util.Xml; import androidx.test.filters.SmallTest; @@ -46,7 +45,6 @@ import androidx.test.runner.AndroidJUnit4; import com.android.modules.utils.TypedXmlPullParser; import com.android.modules.utils.TypedXmlSerializer; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -64,11 +62,6 @@ import java.util.stream.Collectors; @SmallTest @RunWith(AndroidJUnit4.class) public class BatteryUsageStatsTest { - @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private static final int USER_ID = 42; private static final int APP_UID1 = 271; private static final int APP_UID2 = 314; diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/BluetoothPowerCalculatorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/BluetoothPowerCalculatorTest.java index c9cb0dfa98e4..9552808f0733 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/BluetoothPowerCalculatorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/BluetoothPowerCalculatorTest.java @@ -50,15 +50,10 @@ import java.util.List; @SmallTest @SuppressWarnings("GuardedBy") public class BluetoothPowerCalculatorTest { - @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private static final double PRECISION = 0.00001; private static final int APP_UID = Process.FIRST_APPLICATION_UID + 42; - @Rule(order = 1) + @Rule(order = 0) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule() .setAveragePower(PowerProfile.POWER_BLUETOOTH_CONTROLLER_IDLE, 10.0) .setAveragePower(PowerProfile.POWER_BLUETOOTH_CONTROLLER_RX, 50.0) @@ -335,7 +330,7 @@ public class BluetoothPowerCalculatorTest { } private UidTraffic createUidTraffic(int appUid, long rxBytes, long txBytes) { - if (RavenwoodRule.isUnderRavenwood()) { + if (RavenwoodRule.isOnRavenwood()) { UidTraffic uidTraffic = mock(UidTraffic.class); when(uidTraffic.getUid()).thenReturn(appUid); when(uidTraffic.getRxBytes()).thenReturn(rxBytes); @@ -356,7 +351,7 @@ public class BluetoothPowerCalculatorTest { private BluetoothActivityEnergyInfo createBtEnergyInfo(long timestamp, int stackState, long txTime, long rxTime, long idleTime, long energyUsed, List<UidTraffic> traffic) { - if (RavenwoodRule.isUnderRavenwood()) { + if (RavenwoodRule.isOnRavenwood()) { BluetoothActivityEnergyInfo info = mock(BluetoothActivityEnergyInfo.class); when(info.getTimestampMillis()).thenReturn(timestamp); when(info.getBluetoothStackState()).thenReturn(stackState); diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/BluetoothPowerStatsCollectorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/BluetoothPowerStatsCollectorTest.java index 3895cb480847..98ec6de916ec 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/BluetoothPowerStatsCollectorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/BluetoothPowerStatsCollectorTest.java @@ -57,11 +57,6 @@ public class BluetoothPowerStatsCollectorTest { private static final int ISOLATED_UID = 99123; @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - - @Rule(order = 1) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule() .setPowerStatsThrottlePeriodMillis(BatteryConsumer.POWER_COMPONENT_BLUETOOTH, 1000); diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/CameraPowerCalculatorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/CameraPowerCalculatorTest.java index 4cd3857a80bb..6745ffd2700b 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/CameraPowerCalculatorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/CameraPowerCalculatorTest.java @@ -21,7 +21,6 @@ import static com.google.common.truth.Truth.assertThat; import android.os.BatteryConsumer; import android.os.Process; import android.os.UidBatteryConsumer; -import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; @@ -35,17 +34,12 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @SmallTest public class CameraPowerCalculatorTest { - @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private static final double PRECISION = 0.00001; private static final int APP1_UID = Process.FIRST_APPLICATION_UID + 42; private static final int APP2_UID = Process.FIRST_APPLICATION_UID + 43; - @Rule(order = 1) + @Rule(order = 0) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule() .setAveragePower(PowerProfile.POWER_CAMERA, 360.0) .initMeasuredEnergyStatsLocked(); diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/CpuPowerCalculatorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/CpuPowerCalculatorTest.java index 527db67a84ae..ee58d7ef5778 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/CpuPowerCalculatorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/CpuPowerCalculatorTest.java @@ -32,7 +32,6 @@ import android.os.BatteryStats; import android.os.BatteryUsageStatsQuery; import android.os.Process; import android.os.UidBatteryConsumer; -import android.platform.test.ravenwood.RavenwoodRule; import android.util.SparseArray; import androidx.test.filters.SmallTest; @@ -56,11 +55,6 @@ import org.mockito.MockitoAnnotations; @SmallTest @SuppressWarnings("GuardedBy") public class CpuPowerCalculatorTest { - @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private static final double PRECISION = 0.00001; private static final int APP_UID1 = Process.FIRST_APPLICATION_UID + 42; @@ -68,7 +62,7 @@ public class CpuPowerCalculatorTest { private static final int NUM_CPU_FREQS = 2 + 2; // 2 clusters * 2 freqs each - @Rule(order = 1) + @Rule(order = 0) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule() .setAveragePower(PowerProfile.POWER_CPU_ACTIVE, 720) .setCpuScalingPolicy(0, new int[]{0, 1}, new int[]{100, 200}) diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/CpuPowerStatsCollectorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/CpuPowerStatsCollectorTest.java index 1fea46256b12..70f03701f935 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/CpuPowerStatsCollectorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/CpuPowerStatsCollectorTest.java @@ -32,7 +32,6 @@ import android.os.BatteryConsumer; import android.os.ConditionVariable; import android.os.Handler; import android.os.HandlerThread; -import android.platform.test.ravenwood.RavenwoodRule; import android.util.IndentingPrintWriter; import android.util.SparseArray; @@ -46,7 +45,6 @@ import com.android.internal.os.PowerStats; import com.android.server.power.stats.format.CpuPowerStatsLayout; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; @@ -60,11 +58,6 @@ import java.io.StringWriter; @SmallTest public class CpuPowerStatsCollectorTest { - @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private static final int ISOLATED_UID = 99123; private static final int UID_1 = 42; private static final int UID_2 = 99; diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/CustomEnergyConsumerPowerCalculatorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/CustomEnergyConsumerPowerCalculatorTest.java index 56362429e1f5..b89310f050b4 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/CustomEnergyConsumerPowerCalculatorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/CustomEnergyConsumerPowerCalculatorTest.java @@ -21,7 +21,6 @@ import static com.google.common.truth.Truth.assertThat; import android.os.BatteryConsumer; import android.os.Process; import android.os.UidBatteryConsumer; -import android.platform.test.ravenwood.RavenwoodRule; import android.util.SparseLongArray; import androidx.test.filters.SmallTest; @@ -35,16 +34,11 @@ import org.junit.runner.RunWith; @SmallTest @SuppressWarnings("GuardedBy") public class CustomEnergyConsumerPowerCalculatorTest { - @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private static final double PRECISION = 0.00001; private static final int APP_UID = Process.FIRST_APPLICATION_UID + 42; - @Rule(order = 1) + @Rule(order = 0) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule() .initMeasuredEnergyStatsLocked(new String[]{"CUSTOM_COMPONENT1", "CUSTOM_COMPONENT2"}); diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/FlashlightPowerCalculatorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/FlashlightPowerCalculatorTest.java index 757025ecc6f8..0d21349db7e6 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/FlashlightPowerCalculatorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/FlashlightPowerCalculatorTest.java @@ -21,7 +21,6 @@ import static com.google.common.truth.Truth.assertThat; import android.os.BatteryConsumer; import android.os.Process; import android.os.UidBatteryConsumer; -import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; @@ -35,16 +34,11 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @SmallTest public class FlashlightPowerCalculatorTest { - @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private static final double PRECISION = 0.00001; private static final int APP_UID = Process.FIRST_APPLICATION_UID + 42; - @Rule(order = 1) + @Rule(order = 0) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule() .setAveragePower(PowerProfile.POWER_FLASHLIGHT, 360.0); diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/GnssPowerCalculatorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/GnssPowerCalculatorTest.java index 506bab4b3600..b7a0d3d50ddc 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/GnssPowerCalculatorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/GnssPowerCalculatorTest.java @@ -21,7 +21,6 @@ import static com.google.common.truth.Truth.assertThat; import android.os.BatteryConsumer; import android.os.Process; import android.os.UidBatteryConsumer; -import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; @@ -36,16 +35,12 @@ import org.junit.runner.RunWith; @SmallTest @SuppressWarnings("GuardedBy") public class GnssPowerCalculatorTest { - @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); private static final double PRECISION = 0.00001; private static final int APP_UID = Process.FIRST_APPLICATION_UID + 42; private static final int APP_UID2 = Process.FIRST_APPLICATION_UID + 222; - @Rule(order = 1) + @Rule(order = 0) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule() .setAveragePower(PowerProfile.POWER_GPS_ON, 360.0) .setAveragePower(PowerProfile.POWER_GPS_SIGNAL_QUALITY_BASED, diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/IdlePowerCalculatorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/IdlePowerCalculatorTest.java index 487d86446a19..f9f2119b4762 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/IdlePowerCalculatorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/IdlePowerCalculatorTest.java @@ -19,7 +19,6 @@ package com.android.server.power.stats; import static com.google.common.truth.Truth.assertThat; import android.os.BatteryConsumer; -import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; @@ -33,14 +32,9 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @SmallTest public class IdlePowerCalculatorTest { - @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private static final double PRECISION = 0.00001; - @Rule(order = 1) + @Rule(order = 0) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule() .setAveragePower(PowerProfile.POWER_CPU_IDLE, 720.0) .setAveragePower(PowerProfile.POWER_CPU_SUSPEND, 360.0); diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/MemoryPowerCalculatorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/MemoryPowerCalculatorTest.java index 3a27188e2643..fc0ddeb85684 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/MemoryPowerCalculatorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/MemoryPowerCalculatorTest.java @@ -19,7 +19,6 @@ package com.android.server.power.stats; import static com.google.common.truth.Truth.assertThat; import android.os.BatteryConsumer; -import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; @@ -33,14 +32,9 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @SmallTest public class MemoryPowerCalculatorTest { - @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private static final double PRECISION = 0.00001; - @Rule(order = 1) + @Rule(order = 0) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule() .setAveragePower(PowerProfile.POWER_MEMORY, new double[] {360.0, 720.0, 1080.0}); diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/MobileRadioPowerCalculatorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/MobileRadioPowerCalculatorTest.java index eba820e95783..b95ff4c590fc 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/MobileRadioPowerCalculatorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/MobileRadioPowerCalculatorTest.java @@ -62,18 +62,13 @@ import java.util.List; @SmallTest @SuppressWarnings("GuardedBy") public class MobileRadioPowerCalculatorTest { - @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private static final double PRECISION = 0.00001; private static final int APP_UID = Process.FIRST_APPLICATION_UID + 42; private static final int APP_UID2 = Process.FIRST_APPLICATION_UID + 101; @Mock NetworkStatsManager mNetworkStatsManager; - @Rule(order = 1) + @Rule(order = 0) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule(); @Test diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/MobileRadioPowerStatsCollectorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/MobileRadioPowerStatsCollectorTest.java index cd3683ba0ca8..645411cf628a 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/MobileRadioPowerStatsCollectorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/MobileRadioPowerStatsCollectorTest.java @@ -75,11 +75,6 @@ public class MobileRadioPowerStatsCollectorTest { private static final int ISOLATED_UID = 99123; @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - - @Rule(order = 1) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule().setPowerStatsThrottlePeriodMillis( BatteryConsumer.POWER_COMPONENT_MOBILE_RADIO, 10000); diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/PowerStatsCollectorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/PowerStatsCollectorTest.java index a04f7212204d..8e7e4371bd13 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/PowerStatsCollectorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/PowerStatsCollectorTest.java @@ -32,7 +32,6 @@ import android.os.Handler; import android.os.HandlerThread; import android.os.PersistableBundle; import android.platform.test.annotations.DisabledOnRavenwood; -import android.platform.test.ravenwood.RavenwoodRule; import android.power.PowerStatsInternal; import androidx.test.filters.SmallTest; @@ -41,7 +40,6 @@ import androidx.test.runner.AndroidJUnit4; import com.android.internal.os.PowerStats; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -51,11 +49,6 @@ import java.util.concurrent.TimeUnit; @RunWith(AndroidJUnit4.class) @SmallTest public class PowerStatsCollectorTest { - @Rule - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private final MockClock mMockClock = new MockClock(); private final HandlerThread mHandlerThread = new HandlerThread("test"); private Handler mHandler; diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/PowerStatsSchedulerTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/PowerStatsSchedulerTest.java index 143d046add32..23787159d5de 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/PowerStatsSchedulerTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/PowerStatsSchedulerTest.java @@ -18,11 +18,8 @@ package com.android.server.power.stats; import static com.google.common.truth.Truth.assertThat; -import android.platform.test.ravenwood.RavenwoodRule; - import androidx.test.runner.AndroidJUnit4; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,11 +30,6 @@ import java.util.concurrent.TimeUnit; @RunWith(AndroidJUnit4.class) public class PowerStatsSchedulerTest { - @Rule - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - @Test public void alignToWallClock() { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/PowerStatsStoreTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/PowerStatsStoreTest.java index dc8d92032b57..064d999b35ec 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/PowerStatsStoreTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/PowerStatsStoreTest.java @@ -21,7 +21,6 @@ import static com.google.common.truth.Truth.assertThat; import android.os.Handler; import android.os.Looper; import android.os.Message; -import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.runner.AndroidJUnit4; @@ -29,7 +28,6 @@ import com.android.modules.utils.TypedXmlPullParser; import com.android.modules.utils.TypedXmlSerializer; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.xmlpull.v1.XmlPullParser; @@ -45,11 +43,6 @@ import java.util.List; public class PowerStatsStoreTest { private static final long MAX_BATTERY_STATS_SNAPSHOT_STORAGE_BYTES = 2 * 1024; - @Rule - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private PowerStatsStore mPowerStatsStore; private File mStoreDirectory; diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/ScreenPowerCalculatorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/ScreenPowerCalculatorTest.java index 7f20035253f0..101c362fead4 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/ScreenPowerCalculatorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/ScreenPowerCalculatorTest.java @@ -25,7 +25,6 @@ import android.app.ActivityManager; import android.os.BatteryConsumer; import android.os.Process; import android.os.UidBatteryConsumer; -import android.platform.test.ravenwood.RavenwoodRule; import android.view.Display; import androidx.test.filters.SmallTest; @@ -39,18 +38,13 @@ import org.junit.runner.RunWith; @SmallTest @SuppressWarnings("GuardedBy") public class ScreenPowerCalculatorTest { - @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private static final double PRECISION = 0.00001; private static final int APP_UID1 = Process.FIRST_APPLICATION_UID + 42; private static final int APP_UID2 = Process.FIRST_APPLICATION_UID + 43; private static final long MINUTE_IN_MS = 60 * 1000; private static final long MINUTE_IN_US = 60 * 1000 * 1000; - @Rule(order = 1) + @Rule(order = 0) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule() .setAveragePowerForOrdinal(POWER_GROUP_DISPLAY_SCREEN_ON, 0, 36.0) .setAveragePowerForOrdinal(POWER_GROUP_DISPLAY_SCREEN_FULL, 0, 48.0) diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/ScreenPowerStatsCollectorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/ScreenPowerStatsCollectorTest.java index 8c09d1dbfc9d..c87f04d53af8 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/ScreenPowerStatsCollectorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/ScreenPowerStatsCollectorTest.java @@ -28,7 +28,6 @@ import android.hardware.power.stats.EnergyConsumerType; import android.os.BatteryConsumer; import android.os.BatteryStats; import android.os.Handler; -import android.platform.test.ravenwood.RavenwoodRule; import com.android.internal.os.Clock; import com.android.internal.os.PowerStats; @@ -47,11 +46,6 @@ public class ScreenPowerStatsCollectorTest { private static final int ISOLATED_UID = 99123; @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - - @Rule(order = 1) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule() .setPowerStatsThrottlePeriodMillis(BatteryConsumer.POWER_COMPONENT_SCREEN, 1000); diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/SensorPowerCalculatorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/SensorPowerCalculatorTest.java index c01f05f43c04..0a42170beffd 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/SensorPowerCalculatorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/SensorPowerCalculatorTest.java @@ -41,11 +41,6 @@ import java.util.List; @RunWith(AndroidJUnit4.class) @SmallTest public class SensorPowerCalculatorTest { - @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private static final double PRECISION = 0.00001; private static final int SENSOR_HANDLE_1 = 1; @@ -53,7 +48,7 @@ public class SensorPowerCalculatorTest { private static final int APP_UID = Process.FIRST_APPLICATION_UID + 42; - @Rule(order = 1) + @Rule(order = 0) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule(); @Test @@ -93,7 +88,7 @@ public class SensorPowerCalculatorTest { } private Sensor createSensor(int handle, int type, float power) { - if (RavenwoodRule.isUnderRavenwood()) { + if (RavenwoodRule.isOnRavenwood()) { Sensor sensor = mock(Sensor.class); when(sensor.getHandle()).thenReturn(handle); diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/VideoPowerCalculatorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/VideoPowerCalculatorTest.java index b9b710118cc7..e70f7df92981 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/VideoPowerCalculatorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/VideoPowerCalculatorTest.java @@ -21,7 +21,6 @@ import static com.google.common.truth.Truth.assertThat; import android.os.BatteryConsumer; import android.os.Process; import android.os.UidBatteryConsumer; -import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; @@ -35,16 +34,11 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @SmallTest public class VideoPowerCalculatorTest { - @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private static final double PRECISION = 0.00001; private static final int APP_UID = Process.FIRST_APPLICATION_UID + 42; - @Rule(order = 1) + @Rule(order = 0) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule() .setAveragePower(PowerProfile.POWER_VIDEO, 360.0); diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/WakelockPowerCalculatorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/WakelockPowerCalculatorTest.java index 9645e9088bbb..cfae6b19752d 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/WakelockPowerCalculatorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/WakelockPowerCalculatorTest.java @@ -43,7 +43,6 @@ public class WakelockPowerCalculatorTest { @Rule(order = 0) public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) .setSystemPropertyImmutable( "persist.sys.com.android.server.power.feature.flags." + "framework_wakelock_info-override", diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/WifiPowerCalculatorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/WifiPowerCalculatorTest.java index 827d2f8f04c8..0ec0575a20a1 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/WifiPowerCalculatorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/WifiPowerCalculatorTest.java @@ -54,11 +54,6 @@ import java.util.List; @SmallTest @SuppressWarnings("GuardedBy") public class WifiPowerCalculatorTest { - @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private static final double PRECISION = 0.00001; private static final int APP_UID = Process.FIRST_APPLICATION_UID + 42; @@ -66,7 +61,7 @@ public class WifiPowerCalculatorTest { @Mock NetworkStatsManager mNetworkStatsManager; - @Rule(order = 1) + @Rule(order = 0) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule() .setAveragePower(PowerProfile.POWER_WIFI_CONTROLLER_IDLE, 360.0) .setAveragePower(PowerProfile.POWER_WIFI_CONTROLLER_RX, 480.0) @@ -92,7 +87,7 @@ public class WifiPowerCalculatorTest { private NetworkStats buildNetworkStats(long elapsedRealtime, long rxBytes, long rxPackets, long txBytes, long txPackets) { - if (RavenwoodRule.isUnderRavenwood()) { + if (RavenwoodRule.isOnRavenwood()) { NetworkStats stats = mock(NetworkStats.class); // when(stats.getElapsedRealtime()).thenReturn(elapsedRealtime); @@ -358,7 +353,7 @@ public class WifiPowerCalculatorTest { private WifiActivityEnergyInfo buildWifiActivityEnergyInfo(long timeSinceBoot, int stackState, long txDuration, long rxDuration, long scanDuration, long idleDuration) { - if (RavenwoodRule.isUnderRavenwood()) { + if (RavenwoodRule.isOnRavenwood()) { WifiActivityEnergyInfo info = mock(WifiActivityEnergyInfo.class); when(info.getTimeSinceBootMillis()).thenReturn(timeSinceBoot); when(info.getStackState()).thenReturn(stackState); diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/WifiPowerStatsCollectorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/WifiPowerStatsCollectorTest.java index a26b2c955380..3e15c0e2131e 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/WifiPowerStatsCollectorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/WifiPowerStatsCollectorTest.java @@ -68,11 +68,6 @@ public class WifiPowerStatsCollectorTest { private static final int ISOLATED_UID = 99123; @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - - @Rule(order = 1) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule() .setPowerStatsThrottlePeriodMillis(BatteryConsumer.POWER_COMPONENT_WIFI, 1000); diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/AmbientDisplayPowerStatsProcessorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/AmbientDisplayPowerStatsProcessorTest.java index 58e9d1e26f2c..7ca3a9d42e80 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/AmbientDisplayPowerStatsProcessorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/AmbientDisplayPowerStatsProcessorTest.java @@ -31,7 +31,6 @@ import android.annotation.SuppressLint; import android.hardware.power.stats.EnergyConsumerType; import android.os.BatteryConsumer; import android.os.Handler; -import android.platform.test.ravenwood.RavenwoodRule; import com.android.internal.os.Clock; import com.android.internal.os.PowerProfile; @@ -52,11 +51,6 @@ import org.mockito.MockitoAnnotations; public class AmbientDisplayPowerStatsProcessorTest { @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - - @Rule(order = 1) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule() .setNumDisplays(2) .setAveragePowerForOrdinal(PowerProfile.POWER_GROUP_DISPLAY_AMBIENT, 0, 180.0) diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/BinaryStatePowerStatsProcessorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/BinaryStatePowerStatsProcessorTest.java index e6e7f6e105b7..10d5e800a799 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/BinaryStatePowerStatsProcessorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/BinaryStatePowerStatsProcessorTest.java @@ -35,7 +35,6 @@ import android.os.BatteryConsumer; import android.os.BatteryStats; import android.os.PersistableBundle; import android.os.Process; -import android.platform.test.ravenwood.RavenwoodRule; import androidx.annotation.NonNull; @@ -44,17 +43,11 @@ import com.android.internal.os.PowerStats; import com.android.server.power.stats.MockClock; import com.android.server.power.stats.format.BinaryStatePowerStatsLayout; -import org.junit.Rule; import org.junit.Test; import java.util.function.Supplier; public class BinaryStatePowerStatsProcessorTest { - @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private static final double PRECISION = 0.00001; private static final int APP_UID1 = Process.FIRST_APPLICATION_UID + 42; private static final int APP_UID2 = Process.FIRST_APPLICATION_UID + 101; diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/BluetoothPowerStatsProcessorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/BluetoothPowerStatsProcessorTest.java index 6d7119dc1f0e..d8328bf5b1e7 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/BluetoothPowerStatsProcessorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/BluetoothPowerStatsProcessorTest.java @@ -69,18 +69,13 @@ import java.util.function.Supplier; public class BluetoothPowerStatsProcessorTest { - @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private static final double PRECISION = 0.00001; private static final int APP_UID1 = Process.FIRST_APPLICATION_UID + 42; private static final int APP_UID2 = Process.FIRST_APPLICATION_UID + 101; private static final int BLUETOOTH_ENERGY_CONSUMER_ID = 1; private static final int VOLTAGE_MV = 3500; - @Rule(order = 1) + @Rule(order = 0) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule() .setAveragePower(PowerProfile.POWER_BLUETOOTH_CONTROLLER_RX, 50.0) .setAveragePower(PowerProfile.POWER_BLUETOOTH_CONTROLLER_TX, 100.0) diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/CameraPowerStatsTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/CameraPowerStatsTest.java index a95963242d8f..2244b734937f 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/CameraPowerStatsTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/CameraPowerStatsTest.java @@ -40,7 +40,6 @@ import android.os.BatteryConsumer; import android.os.BatteryStats; import android.os.Handler; import android.os.Process; -import android.platform.test.ravenwood.RavenwoodRule; import com.android.internal.os.Clock; import com.android.internal.os.MonotonicClock; @@ -63,11 +62,6 @@ import java.util.function.Supplier; public class CameraPowerStatsTest { @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - - @Rule(order = 1) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule() .setAveragePower(PowerProfile.POWER_CAMERA, 100.0) .initMeasuredEnergyStatsLocked(); diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/CpuPowerStatsProcessorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/CpuPowerStatsProcessorTest.java index dcddf06f01fb..3bc97bdaf7e1 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/CpuPowerStatsProcessorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/CpuPowerStatsProcessorTest.java @@ -33,7 +33,6 @@ import static org.junit.Assert.fail; import android.os.BatteryConsumer; import android.os.PersistableBundle; -import android.platform.test.ravenwood.RavenwoodRule; import android.util.IntArray; import android.util.LongArray; @@ -60,11 +59,6 @@ import java.util.Map; @SmallTest public class CpuPowerStatsProcessorTest { @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - - @Rule(order = 1) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule() .setAveragePower(PowerProfile.POWER_CPU_ACTIVE, 720) .setCpuScalingPolicy(0, new int[]{0, 1}, new int[]{100, 200}) diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/CustomEnergyConsumerPowerStatsTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/CustomEnergyConsumerPowerStatsTest.java index a421675f1896..c18bc3e5befa 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/CustomEnergyConsumerPowerStatsTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/CustomEnergyConsumerPowerStatsTest.java @@ -39,7 +39,6 @@ import android.hardware.power.stats.EnergyConsumerResult; import android.hardware.power.stats.EnergyConsumerType; import android.os.Handler; import android.os.Process; -import android.platform.test.ravenwood.RavenwoodRule; import com.android.internal.os.Clock; import com.android.internal.os.PowerStats; @@ -64,11 +63,6 @@ import java.util.function.Consumer; public class CustomEnergyConsumerPowerStatsTest { @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - - @Rule(order = 1) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule(); public static final int ENERGY_CONSUMER_ID1 = 77; diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/GnssPowerStatsTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/GnssPowerStatsTest.java index b4f21133f621..9071389c9004 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/GnssPowerStatsTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/GnssPowerStatsTest.java @@ -41,7 +41,6 @@ import android.os.BatteryConsumer; import android.os.BatteryStats; import android.os.Handler; import android.os.Process; -import android.platform.test.ravenwood.RavenwoodRule; import com.android.internal.os.Clock; import com.android.internal.os.MonotonicClock; @@ -64,11 +63,6 @@ import java.util.function.Supplier; public class GnssPowerStatsTest { @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - - @Rule(order = 1) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule() .setAveragePower(PowerProfile.POWER_GPS_ON, 100.0) .setAveragePower(PowerProfile.POWER_GPS_SIGNAL_QUALITY_BASED, new double[]{1000, 100}) diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/MobileRadioPowerStatsProcessorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/MobileRadioPowerStatsProcessorTest.java index 3dc401769e7d..95bf93139ef2 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/MobileRadioPowerStatsProcessorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/MobileRadioPowerStatsProcessorTest.java @@ -73,18 +73,13 @@ import java.util.function.LongSupplier; import java.util.function.Supplier; public class MobileRadioPowerStatsProcessorTest { - @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private static final double PRECISION = 0.00001; private static final int APP_UID = Process.FIRST_APPLICATION_UID + 42; private static final int APP_UID2 = Process.FIRST_APPLICATION_UID + 101; private static final int MOBILE_RADIO_ENERGY_CONSUMER_ID = 1; private static final int VOLTAGE_MV = 3500; - @Rule(order = 1) + @Rule(order = 0) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule(); @Mock private Context mContext; diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/MultiStatePowerAttributorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/MultiStatePowerAttributorTest.java index 704ee62f764f..14dd975b5526 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/MultiStatePowerAttributorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/MultiStatePowerAttributorTest.java @@ -27,7 +27,6 @@ import static org.mockito.Mockito.verify; import android.os.ConditionVariable; import android.os.Handler; import android.os.HandlerThread; -import android.platform.test.ravenwood.RavenwoodRule; import com.android.internal.os.BatteryStatsHistory; import com.android.internal.os.MonotonicClock; @@ -37,7 +36,6 @@ import com.android.server.power.stats.PowerStatsSpan; import com.android.server.power.stats.PowerStatsStore; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import java.io.IOException; @@ -52,11 +50,6 @@ import java.util.function.Consumer; public class MultiStatePowerAttributorTest { - @Rule - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private PowerStatsStore mPowerStatsStore; private Handler mHandler; private final MockClock mClock = new MockClock(); diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/PhoneCallPowerStatsProcessorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/PhoneCallPowerStatsProcessorTest.java index 2f742d74d8e6..742f250398cc 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/PhoneCallPowerStatsProcessorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/PhoneCallPowerStatsProcessorTest.java @@ -37,7 +37,6 @@ import android.net.NetworkStats; import android.os.BatteryConsumer; import android.os.Handler; import android.os.OutcomeReceiver; -import android.platform.test.ravenwood.RavenwoodRule; import android.telephony.ModemActivityInfo; import android.telephony.TelephonyManager; @@ -59,15 +58,10 @@ import java.util.function.LongSupplier; import java.util.function.Supplier; public class PhoneCallPowerStatsProcessorTest { - @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private static final double PRECISION = 0.00001; private static final int VOLTAGE_MV = 3500; - @Rule(order = 1) + @Rule(order = 0) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule(); @Mock private Context mContext; diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/PowerStatsExporterTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/PowerStatsExporterTest.java index 9ef58cc28a69..a5a29f5883b1 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/PowerStatsExporterTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/PowerStatsExporterTest.java @@ -33,7 +33,6 @@ import android.os.Message; import android.os.Parcel; import android.os.PersistableBundle; import android.os.UidBatteryConsumer; -import android.platform.test.ravenwood.RavenwoodRule; import androidx.test.runner.AndroidJUnit4; @@ -67,11 +66,6 @@ public class PowerStatsExporterTest { private static final double TOLERANCE = 0.01; @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - - @Rule(order = 1) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule() .setAveragePower(PowerProfile.POWER_CPU_ACTIVE, 720) .setCpuScalingPolicy(0, new int[]{0}, new int[]{100}) diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/ScreenPowerStatsProcessorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/ScreenPowerStatsProcessorTest.java index 31456a1574d0..1ca62b46b8e7 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/ScreenPowerStatsProcessorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/ScreenPowerStatsProcessorTest.java @@ -36,7 +36,6 @@ import android.os.BatteryConsumer; import android.os.BatteryStats; import android.os.Handler; import android.os.Process; -import android.platform.test.ravenwood.RavenwoodRule; import com.android.internal.os.Clock; import com.android.internal.os.PowerProfile; @@ -59,11 +58,6 @@ import java.util.function.Supplier; public class ScreenPowerStatsProcessorTest { @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - - @Rule(order = 1) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule() .setNumDisplays(2) .setAveragePowerForOrdinal(PowerProfile.POWER_GROUP_DISPLAY_AMBIENT, 0, 180.0) diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/SensorPowerStatsProcessorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/SensorPowerStatsProcessorTest.java index c2f01d1fa65c..3c8a58095a60 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/SensorPowerStatsProcessorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/SensorPowerStatsProcessorTest.java @@ -58,11 +58,6 @@ import java.util.function.Supplier; public class SensorPowerStatsProcessorTest { @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - - @Rule(order = 1) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule() .initMeasuredEnergyStatsLocked(); diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/WifiPowerStatsProcessorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/WifiPowerStatsProcessorTest.java index e36056a98c85..d4e6810c706d 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/WifiPowerStatsProcessorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/WifiPowerStatsProcessorTest.java @@ -74,18 +74,13 @@ import java.util.List; import java.util.function.Supplier; public class WifiPowerStatsProcessorTest { - @Rule(order = 0) - public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() - .setProvideMainThread(true) - .build(); - private static final double PRECISION = 0.00001; private static final int APP_UID1 = Process.FIRST_APPLICATION_UID + 42; private static final int APP_UID2 = Process.FIRST_APPLICATION_UID + 101; private static final int WIFI_ENERGY_CONSUMER_ID = 1; private static final int VOLTAGE_MV = 3500; - @Rule(order = 1) + @Rule(order = 0) public final BatteryUsageStatsRule mStatsRule = new BatteryUsageStatsRule() .setAveragePower(PowerProfile.POWER_WIFI_CONTROLLER_IDLE, 360.0) .setAveragePower(PowerProfile.POWER_WIFI_CONTROLLER_RX, 480.0) diff --git a/services/tests/servicestests/src/com/android/server/accessibility/autoclick/AutoclickControllerTest.java b/services/tests/servicestests/src/com/android/server/accessibility/autoclick/AutoclickControllerTest.java index a0482382fb41..99c922ca30c4 100644 --- a/services/tests/servicestests/src/com/android/server/accessibility/autoclick/AutoclickControllerTest.java +++ b/services/tests/servicestests/src/com/android/server/accessibility/autoclick/AutoclickControllerTest.java @@ -75,12 +75,13 @@ public class AutoclickControllerTest { private static class MotionEventCaptor extends BaseEventStreamTransformation { public MotionEvent downEvent; - + public int eventCount = 0; @Override public void onMotionEvent(MotionEvent event, MotionEvent rawEvent, int policyFlags) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: downEvent = event; + eventCount++; break; } } @@ -922,6 +923,41 @@ public class AutoclickControllerTest { mController.onKeyEvent(keyEvent, /* policyFlags= */ 0); } + @Test + @EnableFlags(com.android.server.accessibility.Flags.FLAG_ENABLE_AUTOCLICK_INDICATOR) + public void sendClick_clickType_doubleclick_triggerClickTwice() { + MotionEventCaptor motionEventCaptor = new MotionEventCaptor(); + mController.setNext(motionEventCaptor); + + injectFakeMouseActionHoverMoveEvent(); + // Set delay to zero so click is scheduled to run immediately. + mController.mClickScheduler.updateDelay(0); + + // Set click type to double click. + mController.clickPanelController.handleAutoclickTypeChange( + AutoclickTypePanel.AUTOCLICK_TYPE_DOUBLE_CLICK); + AutoclickTypePanel mockAutoclickTypePanel = mock(AutoclickTypePanel.class); + mController.mAutoclickTypePanel = mockAutoclickTypePanel; + + // Send hover move event. + MotionEvent hoverMove = MotionEvent.obtain( + /* downTime= */ 0, + /* eventTime= */ 100, + /* action= */ MotionEvent.ACTION_HOVER_MOVE, + /* x= */ 30f, + /* y= */ 0f, + /* metaState= */ 0); + hoverMove.setSource(InputDevice.SOURCE_MOUSE); + mController.onMotionEvent(hoverMove, hoverMove, /* policyFlags= */ 0); + mTestableLooper.processAllMessages(); + + // Verify left click sent. + assertThat(motionEventCaptor.downEvent).isNotNull(); + assertThat(motionEventCaptor.downEvent.getButtonState()).isEqualTo( + MotionEvent.BUTTON_PRIMARY); + assertThat(motionEventCaptor.eventCount).isEqualTo(2); + } + private MotionEvent getFakeMotionHoverMoveEvent() { return MotionEvent.obtain( /* downTime= */ 0, diff --git a/services/tests/servicestests/src/com/android/server/companion/virtual/SensorControllerTest.java b/services/tests/servicestests/src/com/android/server/companion/virtual/SensorControllerTest.java index 67fc564fa778..2e07cd8ae698 100644 --- a/services/tests/servicestests/src/com/android/server/companion/virtual/SensorControllerTest.java +++ b/services/tests/servicestests/src/com/android/server/companion/virtual/SensorControllerTest.java @@ -22,18 +22,25 @@ import static org.junit.Assert.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyFloat; import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import android.companion.virtual.IVirtualDevice; import android.companion.virtual.sensor.IVirtualSensorCallback; import android.companion.virtual.sensor.VirtualSensor; +import android.companion.virtual.sensor.VirtualSensorAdditionalInfo; import android.companion.virtual.sensor.VirtualSensorConfig; import android.companion.virtual.sensor.VirtualSensorEvent; import android.content.AttributionSource; import android.hardware.Sensor; +import android.hardware.SensorAdditionalInfo; import android.os.Binder; import android.os.IBinder; import android.os.RemoteException; @@ -49,6 +56,7 @@ import com.google.common.collect.Iterables; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -65,6 +73,9 @@ public class SensorControllerTest { private static final int VIRTUAL_SENSOR_TYPE = Sensor.TYPE_ACCELEROMETER; + private static final float[] ADDITIONAL_INFO_VALUES_1 = new float[] {1.2f, 3.4f}; + private static final float[] ADDITIONAL_INFO_VALUES_2 = new float[] {5.6f, 7.8f}; + @Mock private SensorManagerInternal mSensorManagerInternalMock; @Mock @@ -155,6 +166,53 @@ public class SensorControllerTest { } @Test + public void sendSensorAdditionalInfo_invalidToken_throwsException() throws Exception { + SensorController sensorController = doCreateSensorSuccessfully(); + + final VirtualSensorAdditionalInfo info = + new VirtualSensorAdditionalInfo.Builder(SensorAdditionalInfo.TYPE_UNTRACKED_DELAY) + .addValues(ADDITIONAL_INFO_VALUES_1) + .addValues(ADDITIONAL_INFO_VALUES_2) + .build(); + assertThrows( + IllegalArgumentException.class, + () -> sensorController.sendSensorAdditionalInfo( + new Binder("invalidSensorToken"), info)); + } + + @Test + public void sendSensorAdditionalInfo_success() throws Exception { + SensorController sensorController = doCreateSensorSuccessfully(); + + clearInvocations(mSensorManagerInternalMock); + when(mSensorManagerInternalMock.sendSensorAdditionalInfo( + anyInt(), anyInt(), anyInt(), anyLong(), any())) + .thenReturn(true); + IBinder token = Iterables.getOnlyElement(sensorController.getSensorDescriptors().keySet()); + + final VirtualSensorAdditionalInfo info = + new VirtualSensorAdditionalInfo.Builder(SensorAdditionalInfo.TYPE_UNTRACKED_DELAY) + .addValues(ADDITIONAL_INFO_VALUES_1) + .addValues(ADDITIONAL_INFO_VALUES_2) + .build(); + sensorController.sendSensorAdditionalInfo(token, info); + + InOrder inOrder = inOrder(mSensorManagerInternalMock); + inOrder.verify(mSensorManagerInternalMock).sendSensorAdditionalInfo( + eq(SENSOR_HANDLE), eq(SensorAdditionalInfo.TYPE_FRAME_BEGIN), + /*serial=*/ eq(0), /* timestamp= */ anyLong(), /*values=*/ isNull()); + inOrder.verify(mSensorManagerInternalMock).sendSensorAdditionalInfo( + eq(SENSOR_HANDLE), eq(SensorAdditionalInfo.TYPE_UNTRACKED_DELAY), + /*serial=*/ eq(0), /* timestamp= */ anyLong(), eq(ADDITIONAL_INFO_VALUES_1)); + inOrder.verify(mSensorManagerInternalMock).sendSensorAdditionalInfo( + eq(SENSOR_HANDLE), eq(SensorAdditionalInfo.TYPE_UNTRACKED_DELAY), + /*serial=*/ eq(1), /* timestamp= */ anyLong(), eq(ADDITIONAL_INFO_VALUES_2)); + inOrder.verify(mSensorManagerInternalMock).sendSensorAdditionalInfo( + eq(SENSOR_HANDLE), eq(SensorAdditionalInfo.TYPE_FRAME_END), + /*serial=*/ eq(0), /* timestamp= */ anyLong(), /*values=*/ isNull()); + } + + @Test public void close_unregistersSensors() throws Exception { SensorController sensorController = doCreateSensorSuccessfully(); diff --git a/services/tests/servicestests/src/com/android/server/locksettings/LockSettingsServiceTests.java b/services/tests/servicestests/src/com/android/server/locksettings/LockSettingsServiceTests.java index 2868e559e02f..125791acc61a 100644 --- a/services/tests/servicestests/src/com/android/server/locksettings/LockSettingsServiceTests.java +++ b/services/tests/servicestests/src/com/android/server/locksettings/LockSettingsServiceTests.java @@ -18,7 +18,6 @@ package com.android.server.locksettings; import static android.Manifest.permission.CONFIGURE_FACTORY_RESET_PROTECTION; import static android.security.Flags.FLAG_CLEAR_STRONG_AUTH_ON_ADD_PRIMARY_CREDENTIAL; -import static android.security.Flags.FLAG_REPORT_PRIMARY_AUTH_ATTEMPTS; import static com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_NONE; import static com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_PASSWORD; @@ -558,7 +557,6 @@ public class LockSettingsServiceTests extends BaseLockSettingsServiceTests { @Test public void testVerifyCredential_notifyLockSettingsStateListeners_whenGoodPassword() throws Exception { - mSetFlagsRule.enableFlags(FLAG_REPORT_PRIMARY_AUTH_ATTEMPTS); final LockscreenCredential password = newPassword("password"); setCredential(PRIMARY_USER_ID, password); final LockSettingsStateListener listener = mock(LockSettingsStateListener.class); @@ -574,7 +572,6 @@ public class LockSettingsServiceTests extends BaseLockSettingsServiceTests { @Test public void testVerifyCredential_notifyLockSettingsStateListeners_whenBadPassword() throws Exception { - mSetFlagsRule.enableFlags(FLAG_REPORT_PRIMARY_AUTH_ATTEMPTS); final LockscreenCredential password = newPassword("password"); setCredential(PRIMARY_USER_ID, password); final LockscreenCredential badPassword = newPassword("badPassword"); @@ -590,7 +587,6 @@ public class LockSettingsServiceTests extends BaseLockSettingsServiceTests { @Test public void testLockSettingsStateListener_registeredThenUnregistered() throws Exception { - mSetFlagsRule.enableFlags(FLAG_REPORT_PRIMARY_AUTH_ATTEMPTS); final LockscreenCredential password = newPassword("password"); setCredential(PRIMARY_USER_ID, password); final LockscreenCredential badPassword = newPassword("badPassword"); diff --git a/services/tests/servicestests/src/com/android/server/security/authenticationpolicy/AuthenticationPolicyServiceTest.java b/services/tests/servicestests/src/com/android/server/security/authenticationpolicy/AuthenticationPolicyServiceTest.java index b76e0bc8cd14..c107bd4e62e8 100644 --- a/services/tests/servicestests/src/com/android/server/security/authenticationpolicy/AuthenticationPolicyServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/security/authenticationpolicy/AuthenticationPolicyServiceTest.java @@ -18,7 +18,6 @@ package com.android.server.security.authenticationpolicy; import static android.adaptiveauth.Flags.FLAG_ENABLE_ADAPTIVE_AUTH; import static android.adaptiveauth.Flags.FLAG_REPORT_BIOMETRIC_AUTH_ATTEMPTS; -import static android.security.Flags.FLAG_REPORT_PRIMARY_AUTH_ATTEMPTS; import static android.security.authenticationpolicy.AuthenticationPolicyManager.ERROR_UNSUPPORTED; import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_ADAPTIVE_AUTH_REQUEST; @@ -112,7 +111,6 @@ public class AuthenticationPolicyServiceTest { MockitoAnnotations.initMocks(this); mSetFlagsRule.enableFlags(FLAG_ENABLE_ADAPTIVE_AUTH); - mSetFlagsRule.enableFlags(FLAG_REPORT_PRIMARY_AUTH_ATTEMPTS); mSetFlagsRule.enableFlags(FLAG_REPORT_BIOMETRIC_AUTH_ATTEMPTS); mContext = spy(ApplicationProvider.getApplicationContext()); diff --git a/services/tests/wmtests/src/com/android/server/wm/ImeInsetsSourceProviderTest.java b/services/tests/wmtests/src/com/android/server/wm/ImeInsetsSourceProviderTest.java index eb6d5cf8bb14..e293c2fbbfb1 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ImeInsetsSourceProviderTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/ImeInsetsSourceProviderTest.java @@ -19,6 +19,9 @@ package com.android.server.wm; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; +import static com.android.server.wm.WindowStateAnimator.HAS_DRAWN; +import static com.android.server.wm.WindowStateAnimator.NO_SURFACE; + import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; @@ -244,4 +247,33 @@ public class ImeInsetsSourceProviderTest extends WindowTestsBase { verify(displayWindowInsetsController, times(1)).setImeInputTargetRequestedVisibility( eq(true), any()); } + + @Test + @RequiresFlagsEnabled(Flags.FLAG_REFACTOR_INSETS_CONTROLLER) + public void testOnPostLayout_resetServerVisibilityWhenImeIsNotDrawn() { + final WindowState ime = newWindowBuilder("ime", TYPE_INPUT_METHOD).build(); + final WindowState inputTarget = newWindowBuilder("app", TYPE_APPLICATION).build(); + makeWindowVisibleAndDrawn(ime); + mImeProvider.setWindowContainer(ime, null, null); + mImeProvider.setServerVisible(true); + mImeProvider.setClientVisible(true); + mImeProvider.updateVisibility(); + mImeProvider.updateControlForTarget(inputTarget, true /* force */, null /* statsToken */); + + // Calling onPostLayout, as the drawn state is initially false. + mImeProvider.onPostLayout(); + assertTrue(mImeProvider.isSurfaceVisible()); + + // Reset window's drawn state + ime.mWinAnimator.mDrawState = NO_SURFACE; + mImeProvider.onPostLayout(); + assertFalse(mImeProvider.isServerVisible()); + assertFalse(mImeProvider.isSurfaceVisible()); + + // Set it back to drawn + ime.mWinAnimator.mDrawState = HAS_DRAWN; + mImeProvider.onPostLayout(); + assertTrue(mImeProvider.isServerVisible()); + assertTrue(mImeProvider.isSurfaceVisible()); + } } diff --git a/services/tests/wmtests/src/com/android/server/wm/RefreshRatePolicyTest.java b/services/tests/wmtests/src/com/android/server/wm/RefreshRatePolicyTest.java index d3f3269392d8..0101c3cd630d 100644 --- a/services/tests/wmtests/src/com/android/server/wm/RefreshRatePolicyTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/RefreshRatePolicyTest.java @@ -284,7 +284,7 @@ public class RefreshRatePolicyTest extends WindowTestsBase { assertEquals(0, mPolicy.getPreferredMinRefreshRate(overrideWindow), FLOAT_TOLERANCE); assertEquals(0, mPolicy.getPreferredMaxRefreshRate(overrideWindow), FLOAT_TOLERANCE); - overrideWindow.setAnimatingTypes(WindowInsets.Type.statusBars()); + overrideWindow.setAnimatingTypes(WindowInsets.Type.statusBars(), null /* statsToken */); assertEquals(LOW_MODE_ID, mPolicy.getPreferredModeId(overrideWindow)); assertTrue(mPolicy.updateFrameRateVote(overrideWindow)); assertEquals(FRAME_RATE_VOTE_NONE, overrideWindow.mFrameRateVote); @@ -304,7 +304,7 @@ public class RefreshRatePolicyTest extends WindowTestsBase { assertEquals(0, mPolicy.getPreferredMinRefreshRate(overrideWindow), FLOAT_TOLERANCE); assertEquals(0, mPolicy.getPreferredMaxRefreshRate(overrideWindow), FLOAT_TOLERANCE); - overrideWindow.setAnimatingTypes(WindowInsets.Type.statusBars()); + overrideWindow.setAnimatingTypes(WindowInsets.Type.statusBars(), null /* statsToken */); assertEquals(0, mPolicy.getPreferredModeId(overrideWindow)); assertTrue(mPolicy.updateFrameRateVote(overrideWindow)); assertEquals(FRAME_RATE_VOTE_NONE, overrideWindow.mFrameRateVote); diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java index 50c5a6b68c7b..14915109999c 100644 --- a/telephony/java/android/telephony/CarrierConfigManager.java +++ b/telephony/java/android/telephony/CarrierConfigManager.java @@ -3918,6 +3918,22 @@ public class CarrierConfigManager { "5g_icon_display_secondary_grace_period_string"; /** + * When an NR advanced connection is lost and a Physical Cell ID (PCI) change occurs within + * the primary timer{@link #KEY_5G_ICON_DISPLAY_GRACE_PERIOD_STRING}, delay updating the network + * icon. + * + * <p>This delay is implemented because a rapid PCI change often indicates the device is + * switching to a nearby cell tower to quickly restore the NR advanced connection. Displaying + * an intermediate network icon (like 4G/LTE) might be misleading if the 5G connection is + * restored shortly after. This value sets the delay in seconds; 0 disables the feature.</p> + * + * @hide + */ + public static final String KEY_NR_ADVANCED_PCI_CHANGE_SECONDARY_TIMER_SECONDS_INT = + "nr_advanced_pci_change_secondary_timer_seconds_int"; + + + /** * The secondary grace periods in seconds to use if NR advanced icon was shown due to connecting * to bands specified in {@link #KEY_ADDITIONAL_NR_ADVANCED_BANDS_INT_ARRAY}. * @@ -11222,6 +11238,7 @@ public class CarrierConfigManager { + "not_restricted_rrc_con:5G"); sDefaults.putString(KEY_5G_ICON_DISPLAY_GRACE_PERIOD_STRING, ""); sDefaults.putString(KEY_5G_ICON_DISPLAY_SECONDARY_GRACE_PERIOD_STRING, ""); + sDefaults.putInt(KEY_NR_ADVANCED_PCI_CHANGE_SECONDARY_TIMER_SECONDS_INT, 0); sDefaults.putInt(KEY_NR_ADVANCED_BANDS_SECONDARY_TIMER_SECONDS_INT, 0); sDefaults.putBoolean(KEY_NR_TIMERS_RESET_IF_NON_ENDC_AND_RRC_IDLE_BOOL, false); sDefaults.putBoolean(KEY_NR_TIMERS_RESET_ON_VOICE_QOS_BOOL, false); diff --git a/telephony/java/android/telephony/CellSignalStrengthLte.java b/telephony/java/android/telephony/CellSignalStrengthLte.java index f5282639ae6c..6e23edf936c7 100644 --- a/telephony/java/android/telephony/CellSignalStrengthLte.java +++ b/telephony/java/android/telephony/CellSignalStrengthLte.java @@ -614,7 +614,7 @@ public final class CellSignalStrengthLte extends CellSignalStrength implements P /** @hide */ public static int convertRssiAsuToDBm(int rssiAsu) { - if (rssiAsu == SIGNAL_STRENGTH_LTE_RSSI_ASU_UNKNOWN) { + if (rssiAsu == SIGNAL_STRENGTH_LTE_RSSI_ASU_UNKNOWN || rssiAsu == Integer.MAX_VALUE) { return CellInfo.UNAVAILABLE; } if ((rssiAsu < SIGNAL_STRENGTH_LTE_RSSI_VALID_ASU_MIN_VALUE diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 2983e4442a78..7b2e6c2013cf 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -15347,11 +15347,15 @@ public class TelephonyManager { * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} * * @throws UnsupportedOperationException If the device does not have - * {@link PackageManager#FEATURE_TELEPHONY_CALLING}. + * {@link PackageManager#FEATURE_TELEPHONY_CALLING} or + * {@link PackageManager#FEATURE_TELEPHONY_MESSAGING}. * @hide */ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) - @RequiresFeature(PackageManager.FEATURE_TELEPHONY_CALLING) + @RequiresFeature(anyOf = { + PackageManager.FEATURE_TELEPHONY_CALLING, + PackageManager.FEATURE_TELEPHONY_MESSAGING + }) @SystemApi public void notifyOtaEmergencyNumberDbInstalled() { try { @@ -15376,11 +15380,15 @@ public class TelephonyManager { * {@link android.Manifest.permission#READ_ACTIVE_EMERGENCY_SESSION} * * @throws UnsupportedOperationException If the device does not have - * {@link PackageManager#FEATURE_TELEPHONY_CALLING}. + * {@link PackageManager#FEATURE_TELEPHONY_CALLING} or + * {@link PackageManager#FEATURE_TELEPHONY_MESSAGING}. * @hide */ @RequiresPermission(android.Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION) - @RequiresFeature(PackageManager.FEATURE_TELEPHONY_CALLING) + @RequiresFeature(anyOf = { + PackageManager.FEATURE_TELEPHONY_CALLING, + PackageManager.FEATURE_TELEPHONY_MESSAGING + }) @SystemApi public void updateOtaEmergencyNumberDbFilePath( @NonNull ParcelFileDescriptor otaParcelFileDescriptor) { @@ -15404,11 +15412,15 @@ public class TelephonyManager { * {@link android.Manifest.permission#READ_ACTIVE_EMERGENCY_SESSION} * * @throws UnsupportedOperationException If the device does not have - * {@link PackageManager#FEATURE_TELEPHONY_CALLING}. + * {@link PackageManager#FEATURE_TELEPHONY_CALLING} or + * {@link PackageManager#FEATURE_TELEPHONY_MESSAGING}. * @hide */ @RequiresPermission(android.Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION) - @RequiresFeature(PackageManager.FEATURE_TELEPHONY_CALLING) + @RequiresFeature(anyOf = { + PackageManager.FEATURE_TELEPHONY_CALLING, + PackageManager.FEATURE_TELEPHONY_MESSAGING + }) @SystemApi public void resetOtaEmergencyNumberDbFilePath() { try { @@ -15490,11 +15502,15 @@ public class TelephonyManager { * or throw a SecurityException if the caller does not have the permission. * * @throws UnsupportedOperationException If the device does not have - * {@link PackageManager#FEATURE_TELEPHONY_CALLING}. + * {@link PackageManager#FEATURE_TELEPHONY_CALLING} or + * {@link PackageManager#FEATURE_TELEPHONY_MESSAGING}. */ @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) @NonNull - @RequiresFeature(PackageManager.FEATURE_TELEPHONY_CALLING) + @RequiresFeature(anyOf = { + PackageManager.FEATURE_TELEPHONY_CALLING, + PackageManager.FEATURE_TELEPHONY_MESSAGING + }) public Map<Integer, List<EmergencyNumber>> getEmergencyNumberList() { Map<Integer, List<EmergencyNumber>> emergencyNumberList = new HashMap<>(); try { @@ -15548,11 +15564,15 @@ public class TelephonyManager { * or throw a SecurityException if the caller does not have the permission. * @throws IllegalStateException if the Telephony process is not currently available. * @throws UnsupportedOperationException If the device does not have - * {@link PackageManager#FEATURE_TELEPHONY_CALLING}. + * {@link PackageManager#FEATURE_TELEPHONY_CALLING} or + * {@link PackageManager#FEATURE_TELEPHONY_MESSAGING}. */ @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) @NonNull - @RequiresFeature(PackageManager.FEATURE_TELEPHONY_CALLING) + @RequiresFeature(anyOf = { + PackageManager.FEATURE_TELEPHONY_CALLING, + PackageManager.FEATURE_TELEPHONY_MESSAGING + }) public Map<Integer, List<EmergencyNumber>> getEmergencyNumberList( @EmergencyServiceCategories int categories) { Map<Integer, List<EmergencyNumber>> emergencyNumberListForCategories = new HashMap<>(); @@ -15618,9 +15638,13 @@ public class TelephonyManager { * SIM card(s), Android database, modem, network or defaults; {@code false} otherwise. * @throws IllegalStateException if the Telephony process is not currently available. * @throws UnsupportedOperationException If the device does not have - * {@link PackageManager#FEATURE_TELEPHONY_CALLING}. + * {@link PackageManager#FEATURE_TELEPHONY_CALLING} or + * {@link PackageManager#FEATURE_TELEPHONY_MESSAGING}. */ - @RequiresFeature(PackageManager.FEATURE_TELEPHONY_CALLING) + @RequiresFeature(anyOf = { + PackageManager.FEATURE_TELEPHONY_CALLING, + PackageManager.FEATURE_TELEPHONY_MESSAGING + }) public boolean isEmergencyNumber(@NonNull String number) { try { ITelephony telephony = getITelephony(); @@ -15657,7 +15681,8 @@ public class TelephonyManager { * have the required permission/privileges * @throws IllegalStateException if the Telephony process is not currently available. * @throws UnsupportedOperationException If the device does not have - * {@link PackageManager#FEATURE_TELEPHONY_CALLING}. + * {@link PackageManager#FEATURE_TELEPHONY_CALLING} or + * {@link PackageManager#FEATURE_TELEPHONY_MESSAGING}. * * @deprecated Please use {@link TelephonyManager#isEmergencyNumber(String)} instead. * @hide @@ -15665,7 +15690,10 @@ public class TelephonyManager { @Deprecated @SystemApi @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) - @RequiresFeature(PackageManager.FEATURE_TELEPHONY_CALLING) + @RequiresFeature(anyOf = { + PackageManager.FEATURE_TELEPHONY_CALLING, + PackageManager.FEATURE_TELEPHONY_MESSAGING + }) public boolean isPotentialEmergencyNumber(@NonNull String number) { try { ITelephony telephony = getITelephony(); @@ -15685,15 +15713,19 @@ public class TelephonyManager { * Returns the emergency number database version. * * <p>Requires Permission: - * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE READ_PRIVILEGED_PHONE_STATE} + * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE} * * @throws UnsupportedOperationException If the device does not have - * {@link PackageManager#FEATURE_TELEPHONY_CALLING}. + * {@link PackageManager#FEATURE_TELEPHONY_CALLING} or + * {@link PackageManager#FEATURE_TELEPHONY_MESSAGING}. * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) - @RequiresFeature(PackageManager.FEATURE_TELEPHONY_CALLING) + @RequiresFeature(anyOf = { + PackageManager.FEATURE_TELEPHONY_CALLING, + PackageManager.FEATURE_TELEPHONY_MESSAGING + }) public int getEmergencyNumberDbVersion() { try { ITelephony telephony = getITelephony(); diff --git a/tests/FsVerityTest/src/com/android/fsverity/FsVerityHostTest.java b/tests/FsVerityTest/src/com/android/fsverity/FsVerityHostTest.java index 1b0279273dc7..b1d6e96dca9b 100644 --- a/tests/FsVerityTest/src/com/android/fsverity/FsVerityHostTest.java +++ b/tests/FsVerityTest/src/com/android/fsverity/FsVerityHostTest.java @@ -18,11 +18,7 @@ package com.android.fsverity; import static com.google.common.truth.Truth.assertThat; -import android.platform.test.annotations.RequiresFlagsEnabled; import android.platform.test.annotations.RootPermissionTest; -import android.platform.test.flag.junit.CheckFlagsRule; -import android.platform.test.flag.junit.host.HostFlagsValueProvider; -import android.security.Flags; import com.android.blockdevicewriter.BlockDeviceWriter; import com.android.tradefed.device.DeviceNotAvailableException; @@ -31,7 +27,6 @@ import com.android.tradefed.testtype.DeviceJUnit4ClassRunner; import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test; import com.android.tradefed.testtype.junit4.DeviceTestRunOptions; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -48,16 +43,11 @@ import org.junit.runner.RunWith; */ @RootPermissionTest @RunWith(DeviceJUnit4ClassRunner.class) -@RequiresFlagsEnabled(Flags.FLAG_FSVERITY_API) public class FsVerityHostTest extends BaseHostJUnit4Test { private static final String TARGET_PACKAGE = "com.android.fsverity"; private static final String BASENAME = "test.file"; - @Rule - public final CheckFlagsRule mCheckFlagsRule = - HostFlagsValueProvider.createCheckFlagsRule(this::getDevice); - @Test public void testFsVeritySmallFile() throws Exception { prepareTest(10000); |