diff options
275 files changed, 5540 insertions, 2670 deletions
diff --git a/.prebuilt_info/OWNERS b/.prebuilt_info/OWNERS new file mode 100644 index 000000000000..eb8b89b10e83 --- /dev/null +++ b/.prebuilt_info/OWNERS @@ -0,0 +1 @@ +per-file prebuilt_info_packages_CtsShim_*.asciipb = file:/packages/CtsShim/OWNERS diff --git a/Android.bp b/Android.bp index c5980b911b17..622b2c6120bd 100644 --- a/Android.bp +++ b/Android.bp @@ -584,7 +584,7 @@ java_library { "android.hardware.vibrator-V2-java", "android.security.apc-java", "android.security.authorization-java", - "android.security.usermanager-java", + "android.security.maintenance-java", "android.security.vpnprofilestore-java", "android.system.keystore2-V1-java", "android.system.suspend.control.internal-java", diff --git a/TEST_MAPPING b/TEST_MAPPING index d08c52782fb3..9ceef6bbe8a3 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -82,5 +82,65 @@ { "name": "ManagedProfileLifecycleStressTest" } - ] + ], + "auto-postsubmit": [ + // Test tag for automotive targets. These are only running in postsubmit so as to harden the + // automotive targets to avoid introducing additional test flake and build time. The plan for + // presubmit testing for auto is to augment the existing tests to cover auto use cases as well. + // Additionally, this tag is used in targeted test suites to limit resource usage on the test + // infra during the hardening phase. + // TODO: this tag to be removed once the above is no longer an issue. + { + "name": "FrameworksUiServicesTests", + "options": [ + { + "exclude-annotation": "androidx.test.filters.FlakyTest" + } + ] + }, + { + "name": "ExtServicesUnitTests", + "options": [ + { + "exclude-annotation": "androidx.test.filters.FlakyTest" + } + ] + }, + { + "name": "TestablesTests", + "options": [ + { + "exclude-annotation": "androidx.test.filters.FlakyTest" + } + ] + }, + { + "name": "FrameworksCoreTests", + "options": [ + { + "include-annotation": "android.platform.test.annotations.Presubmit" + }, + { + "exclude-annotation": "androidx.test.filters.FlakyTest" + }, + { + "exclude-annotation": "org.junit.Ignore" + } + ] + }, + { + "name": "FrameworksServicesTests", + "options": [ + { + "include-annotation": "android.platform.test.annotations.Presubmit" + }, + { + "exclude-annotation": "androidx.test.filters.FlakyTest" + }, + { + "exclude-annotation": "org.junit.Ignore" + } + ] + } + ] } diff --git a/apex/jobscheduler/framework/java/android/app/job/JobInfo.java b/apex/jobscheduler/framework/java/android/app/job/JobInfo.java index b7a3f1083176..6967d819a448 100644 --- a/apex/jobscheduler/framework/java/android/app/job/JobInfo.java +++ b/apex/jobscheduler/framework/java/android/app/job/JobInfo.java @@ -59,6 +59,9 @@ import java.util.Objects; * constraint on the JobInfo object that you are creating. Otherwise, the builder would throw an * exception when building. From Android version {@link Build.VERSION_CODES#Q} and onwards, it is * valid to schedule jobs with no constraints. + * <p> Prior to Android version {@link Build.VERSION_CODES#S}, jobs could only have a maximum of 100 + * jobs scheduled at a time. Starting with Android version {@link Build.VERSION_CODES#S}, that limit + * has been increased to 150. Expedited jobs also count towards the limit. * <p> In Android version {@link Build.VERSION_CODES#LOLLIPOP}, jobs had a maximum execution time * of one minute. Starting with Android version {@link Build.VERSION_CODES#M} and ending with * Android version {@link Build.VERSION_CODES#R}, jobs had a maximum execution time of 10 minutes. diff --git a/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java b/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java index 515cb747a99e..82f2f69bbde5 100644 --- a/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java +++ b/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java @@ -147,10 +147,8 @@ public class JobSchedulerService extends com.android.server.SystemService /** The maximum number of concurrent jobs we run at one time. */ static final int MAX_JOB_CONTEXTS_COUNT = 16; - /** Enforce a per-app limit on scheduled jobs? */ - private static final boolean ENFORCE_MAX_JOBS = true; - /** The maximum number of jobs that we allow an unprivileged app to schedule */ - private static final int MAX_JOBS_PER_APP = 100; + /** The maximum number of jobs that we allow an app to schedule */ + private static final int MAX_JOBS_PER_APP = 150; /** The number of the most recently completed jobs to keep track of for debugging purposes. */ private static final int NUM_COMPLETED_JOB_HISTORY = 20; @@ -1011,7 +1009,7 @@ public class JobSchedulerService extends com.android.server.SystemService if (DEBUG) Slog.d(TAG, "SCHEDULE: " + jobStatus.toShortString()); // Jobs on behalf of others don't apply to the per-app job cap - if (ENFORCE_MAX_JOBS && packageName == null) { + if (packageName == null) { if (mJobs.countJobsForUid(uId) > MAX_JOBS_PER_APP) { Slog.w(TAG, "Too many jobs for uid " + uId); throw new IllegalStateException("Apps may not schedule more than " diff --git a/api/Android.bp b/api/Android.bp index 1d4698e7c512..1fdf1771bb13 100644 --- a/api/Android.bp +++ b/api/Android.bp @@ -347,3 +347,49 @@ genrule { out: ["combined-removed-dex.txt"], cmd: "$(location gen_combined_removed_dex.sh) $(location metalava) $(genDir) $(in) > $(out)", } + +genrule { + name: "services-system-server-current.txt", + srcs: [ + ":service-permission{.system-server.api.txt}", + ":non-updatable-system-server-current.txt", + ], + out: ["system-server-current.txt"], + tools: ["metalava"], + cmd: "$(location metalava) --no-banner --format=v2 $(in) --api $(out)", + dists: [ + { + targets: ["droidcore"], + dir: "api", + dest: "system-server-current.txt", + }, + { + targets: ["sdk", "win_sdk"], + dir: "apistubs/android/system-server/api", + dest: "merge-android.txt", + }, + ], +} + +genrule { + name: "services-system-server-removed.txt", + srcs: [ + ":service-permission{.system-server.removed-api.txt}", + ":non-updatable-system-server-removed.txt", + ], + out: ["system-server-removed.txt"], + tools: ["metalava"], + cmd: "$(location metalava) --no-banner --format=v2 $(in) --api $(out)", + dists: [ + { + targets: ["droidcore"], + dir: "api", + dest: "system-server-removed.txt", + }, + { + targets: ["sdk", "win_sdk"], + dir: "apistubs/android/system-server/api", + dest: "merge-removed.txt", + }, + ], +} diff --git a/core/api/current.txt b/core/api/current.txt index 7aa6adf7af5f..ba98ed659536 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -506,7 +506,7 @@ package android { field public static final int dashGap = 16843175; // 0x10101a7 field public static final int dashWidth = 16843174; // 0x10101a6 field public static final int data = 16842798; // 0x101002e - field public static final int dataExtractionRules = 16844350; // 0x101063e + field public static final int dataExtractionRules = 16844349; // 0x101063d field public static final int datePickerDialogTheme = 16843948; // 0x10104ac field public static final int datePickerMode = 16843955; // 0x10104b3 field public static final int datePickerStyle = 16843612; // 0x101035c @@ -528,8 +528,8 @@ package android { field public static final int detailSocialSummary = 16843428; // 0x10102a4 field public static final int detailsElementBackground = 16843598; // 0x101034e field public static final int dial = 16843010; // 0x1010102 - field public static final int dialTint = 16844342; // 0x1010636 - field public static final int dialTintMode = 16844343; // 0x1010637 + field public static final int dialTint = 16844341; // 0x1010635 + field public static final int dialTintMode = 16844342; // 0x1010636 field public static final int dialogCornerRadius = 16844145; // 0x1010571 field public static final int dialogIcon = 16843252; // 0x10101f4 field public static final int dialogLayout = 16843255; // 0x10101f7 @@ -727,14 +727,14 @@ package android { field public static final int groupIndicator = 16843019; // 0x101010b field public static final int gwpAsanMode = 16844310; // 0x1010616 field public static final int hand_hour = 16843011; // 0x1010103 - field public static final int hand_hourTint = 16844344; // 0x1010638 - field public static final int hand_hourTintMode = 16844345; // 0x1010639 + field public static final int hand_hourTint = 16844343; // 0x1010637 + field public static final int hand_hourTintMode = 16844344; // 0x1010638 field public static final int hand_minute = 16843012; // 0x1010104 - field public static final int hand_minuteTint = 16844346; // 0x101063a - field public static final int hand_minuteTintMode = 16844347; // 0x101063b + field public static final int hand_minuteTint = 16844345; // 0x1010639 + field public static final int hand_minuteTintMode = 16844346; // 0x101063a field public static final int hand_second = 16844323; // 0x1010623 - field public static final int hand_secondTint = 16844348; // 0x101063c - field public static final int hand_secondTintMode = 16844349; // 0x101063d + field public static final int hand_secondTint = 16844347; // 0x101063b + field public static final int hand_secondTintMode = 16844348; // 0x101063c field public static final int handle = 16843354; // 0x101025a field public static final int handleProfiling = 16842786; // 0x1010022 field public static final int hapticFeedbackEnabled = 16843358; // 0x101025e @@ -818,7 +818,7 @@ package android { field public static final int installLocation = 16843447; // 0x10102b7 field public static final int interactiveUiTimeout = 16844181; // 0x1010595 field public static final int interpolator = 16843073; // 0x1010141 - field public static final int isAccessibilityTool = 16844353; // 0x1010641 + field public static final int isAccessibilityTool = 16844352; // 0x1010640 field public static final int isAlwaysSyncable = 16843571; // 0x1010333 field public static final int isAsciiCapable = 16843753; // 0x10103e9 field public static final int isAuxiliary = 16843647; // 0x101037f @@ -970,8 +970,8 @@ package android { field public static final int maxLines = 16843091; // 0x1010153 field public static final int maxLongVersionCode = 16844163; // 0x1010583 field public static final int maxRecents = 16843846; // 0x1010446 - field public static final int maxResizeHeight = 16844339; // 0x1010633 - field public static final int maxResizeWidth = 16844338; // 0x1010632 + field public static final int maxResizeHeight = 16844338; // 0x1010632 + field public static final int maxResizeWidth = 16844337; // 0x1010631 field public static final int maxRows = 16843059; // 0x1010133 field public static final int maxSdkVersion = 16843377; // 0x1010271 field public static final int maxWidth = 16843039; // 0x101011f @@ -1074,7 +1074,7 @@ package android { field public static final int panelTextAppearance = 16842850; // 0x1010062 field public static final int parentActivityName = 16843687; // 0x10103a7 field @Deprecated public static final int password = 16843100; // 0x101015c - field public static final int passwordsActivity = 16844351; // 0x101063f + field public static final int passwordsActivity = 16844350; // 0x101063e field public static final int path = 16842794; // 0x101002a field public static final int pathAdvancedPattern = 16844320; // 0x1010620 field public static final int pathData = 16843781; // 0x1010405 @@ -1199,7 +1199,6 @@ package android { field public static final int right = 16843183; // 0x10101af field public static final int ringtonePreferenceStyle = 16842899; // 0x1010093 field public static final int ringtoneType = 16843257; // 0x10101f9 - field public static final int rippleStyle = 16844337; // 0x1010631 field public static final int rollbackDataPolicy = 16844311; // 0x1010617 field public static final int rotation = 16843558; // 0x1010326 field public static final int rotationAnimation = 16844090; // 0x101053a @@ -1261,7 +1260,7 @@ package android { field public static final int segmentedButtonStyle = 16843568; // 0x1010330 field public static final int selectAllOnFocus = 16843102; // 0x101015e field public static final int selectable = 16843238; // 0x10101e6 - field public static final int selectableAsDefault = 16844352; // 0x1010640 + field public static final int selectableAsDefault = 16844351; // 0x101063f field public static final int selectableItemBackground = 16843534; // 0x101030e field public static final int selectableItemBackgroundBorderless = 16843868; // 0x101045c field @Deprecated public static final int selectedDateVerticalBar = 16843591; // 0x1010347 @@ -1408,8 +1407,8 @@ package android { field public static final int tabWidgetStyle = 16842883; // 0x1010083 field public static final int tag = 16842961; // 0x10100d1 field public static final int targetActivity = 16843266; // 0x1010202 - field public static final int targetCellHeight = 16844341; // 0x1010635 - field public static final int targetCellWidth = 16844340; // 0x1010634 + field public static final int targetCellHeight = 16844340; // 0x1010634 + field public static final int targetCellWidth = 16844339; // 0x1010633 field public static final int targetClass = 16842799; // 0x101002f field @Deprecated public static final int targetDescriptions = 16843680; // 0x10103a0 field public static final int targetId = 16843740; // 0x10103dc @@ -16687,13 +16686,9 @@ package android.graphics.drawable { public class RippleDrawable extends android.graphics.drawable.LayerDrawable { ctor public RippleDrawable(@NonNull android.content.res.ColorStateList, @Nullable android.graphics.drawable.Drawable, @Nullable android.graphics.drawable.Drawable); method public int getRadius(); - method public int getRippleStyle(); method public void setColor(android.content.res.ColorStateList); method public void setRadius(int); - method public void setRippleStyle(int) throws java.lang.IllegalArgumentException; field public static final int RADIUS_AUTO = -1; // 0xffffffff - field public static final int STYLE_PATTERNED = 1; // 0x1 - field public static final int STYLE_SOLID = 0; // 0x0 } public class RotateDrawable extends android.graphics.drawable.DrawableWrapper { @@ -35651,721 +35646,721 @@ package android.provider { package android.renderscript { - public class Allocation extends android.renderscript.BaseObj { - method public void copy1DRangeFrom(int, int, Object); - method public void copy1DRangeFrom(int, int, int[]); - method public void copy1DRangeFrom(int, int, short[]); - method public void copy1DRangeFrom(int, int, byte[]); - method public void copy1DRangeFrom(int, int, float[]); - method public void copy1DRangeFrom(int, int, android.renderscript.Allocation, int); - method public void copy1DRangeFromUnchecked(int, int, Object); - method public void copy1DRangeFromUnchecked(int, int, int[]); - method public void copy1DRangeFromUnchecked(int, int, short[]); - method public void copy1DRangeFromUnchecked(int, int, byte[]); - method public void copy1DRangeFromUnchecked(int, int, float[]); - method public void copy1DRangeTo(int, int, Object); - method public void copy1DRangeTo(int, int, int[]); - method public void copy1DRangeTo(int, int, short[]); - method public void copy1DRangeTo(int, int, byte[]); - method public void copy1DRangeTo(int, int, float[]); - method public void copy1DRangeToUnchecked(int, int, Object); - method public void copy1DRangeToUnchecked(int, int, int[]); - method public void copy1DRangeToUnchecked(int, int, short[]); - method public void copy1DRangeToUnchecked(int, int, byte[]); - method public void copy1DRangeToUnchecked(int, int, float[]); - method public void copy2DRangeFrom(int, int, int, int, Object); - method public void copy2DRangeFrom(int, int, int, int, byte[]); - method public void copy2DRangeFrom(int, int, int, int, short[]); - method public void copy2DRangeFrom(int, int, int, int, int[]); - method public void copy2DRangeFrom(int, int, int, int, float[]); - method public void copy2DRangeFrom(int, int, int, int, android.renderscript.Allocation, int, int); - method public void copy2DRangeFrom(int, int, android.graphics.Bitmap); - method public void copy2DRangeTo(int, int, int, int, Object); - method public void copy2DRangeTo(int, int, int, int, byte[]); - method public void copy2DRangeTo(int, int, int, int, short[]); - method public void copy2DRangeTo(int, int, int, int, int[]); - method public void copy2DRangeTo(int, int, int, int, float[]); - method public void copy3DRangeFrom(int, int, int, int, int, int, Object); - method public void copy3DRangeFrom(int, int, int, int, int, int, android.renderscript.Allocation, int, int, int); - method public void copy3DRangeTo(int, int, int, int, int, int, Object); - method public void copyFrom(android.renderscript.BaseObj[]); - method public void copyFrom(Object); - method public void copyFrom(int[]); - method public void copyFrom(short[]); - method public void copyFrom(byte[]); - method public void copyFrom(float[]); - method public void copyFrom(android.graphics.Bitmap); - method public void copyFrom(android.renderscript.Allocation); - method public void copyFromUnchecked(Object); - method public void copyFromUnchecked(int[]); - method public void copyFromUnchecked(short[]); - method public void copyFromUnchecked(byte[]); - method public void copyFromUnchecked(float[]); - method public void copyTo(android.graphics.Bitmap); - method public void copyTo(Object); - method public void copyTo(byte[]); - method public void copyTo(short[]); - method public void copyTo(int[]); - method public void copyTo(float[]); - method public static android.renderscript.Allocation[] createAllocations(android.renderscript.RenderScript, android.renderscript.Type, int, int); - method public static android.renderscript.Allocation createCubemapFromBitmap(android.renderscript.RenderScript, android.graphics.Bitmap, android.renderscript.Allocation.MipmapControl, int); - method public static android.renderscript.Allocation createCubemapFromBitmap(android.renderscript.RenderScript, android.graphics.Bitmap); - method public static android.renderscript.Allocation createCubemapFromCubeFaces(android.renderscript.RenderScript, android.graphics.Bitmap, android.graphics.Bitmap, android.graphics.Bitmap, android.graphics.Bitmap, android.graphics.Bitmap, android.graphics.Bitmap, android.renderscript.Allocation.MipmapControl, int); - method public static android.renderscript.Allocation createCubemapFromCubeFaces(android.renderscript.RenderScript, android.graphics.Bitmap, android.graphics.Bitmap, android.graphics.Bitmap, android.graphics.Bitmap, android.graphics.Bitmap, android.graphics.Bitmap); - method public static android.renderscript.Allocation createFromBitmap(android.renderscript.RenderScript, android.graphics.Bitmap, android.renderscript.Allocation.MipmapControl, int); - method public static android.renderscript.Allocation createFromBitmap(android.renderscript.RenderScript, android.graphics.Bitmap); - method public static android.renderscript.Allocation createFromBitmapResource(android.renderscript.RenderScript, android.content.res.Resources, int, android.renderscript.Allocation.MipmapControl, int); - method public static android.renderscript.Allocation createFromBitmapResource(android.renderscript.RenderScript, android.content.res.Resources, int); - method public static android.renderscript.Allocation createFromString(android.renderscript.RenderScript, String, int); - method public static android.renderscript.Allocation createSized(android.renderscript.RenderScript, android.renderscript.Element, int, int); - method public static android.renderscript.Allocation createSized(android.renderscript.RenderScript, android.renderscript.Element, int); - method public static android.renderscript.Allocation createTyped(android.renderscript.RenderScript, android.renderscript.Type, android.renderscript.Allocation.MipmapControl, int); - method public static android.renderscript.Allocation createTyped(android.renderscript.RenderScript, android.renderscript.Type, int); - method public static android.renderscript.Allocation createTyped(android.renderscript.RenderScript, android.renderscript.Type); - method public void generateMipmaps(); - method public java.nio.ByteBuffer getByteBuffer(); - method public int getBytesSize(); - method public android.renderscript.Element getElement(); - method public long getStride(); - method public android.view.Surface getSurface(); - method public long getTimeStamp(); - method public android.renderscript.Type getType(); - method public int getUsage(); - method public void ioReceive(); - method public void ioSend(); + @Deprecated public class Allocation extends android.renderscript.BaseObj { + method @Deprecated public void copy1DRangeFrom(int, int, Object); + method @Deprecated public void copy1DRangeFrom(int, int, int[]); + method @Deprecated public void copy1DRangeFrom(int, int, short[]); + method @Deprecated public void copy1DRangeFrom(int, int, byte[]); + method @Deprecated public void copy1DRangeFrom(int, int, float[]); + method @Deprecated public void copy1DRangeFrom(int, int, android.renderscript.Allocation, int); + method @Deprecated public void copy1DRangeFromUnchecked(int, int, Object); + method @Deprecated public void copy1DRangeFromUnchecked(int, int, int[]); + method @Deprecated public void copy1DRangeFromUnchecked(int, int, short[]); + method @Deprecated public void copy1DRangeFromUnchecked(int, int, byte[]); + method @Deprecated public void copy1DRangeFromUnchecked(int, int, float[]); + method @Deprecated public void copy1DRangeTo(int, int, Object); + method @Deprecated public void copy1DRangeTo(int, int, int[]); + method @Deprecated public void copy1DRangeTo(int, int, short[]); + method @Deprecated public void copy1DRangeTo(int, int, byte[]); + method @Deprecated public void copy1DRangeTo(int, int, float[]); + method @Deprecated public void copy1DRangeToUnchecked(int, int, Object); + method @Deprecated public void copy1DRangeToUnchecked(int, int, int[]); + method @Deprecated public void copy1DRangeToUnchecked(int, int, short[]); + method @Deprecated public void copy1DRangeToUnchecked(int, int, byte[]); + method @Deprecated public void copy1DRangeToUnchecked(int, int, float[]); + method @Deprecated public void copy2DRangeFrom(int, int, int, int, Object); + method @Deprecated public void copy2DRangeFrom(int, int, int, int, byte[]); + method @Deprecated public void copy2DRangeFrom(int, int, int, int, short[]); + method @Deprecated public void copy2DRangeFrom(int, int, int, int, int[]); + method @Deprecated public void copy2DRangeFrom(int, int, int, int, float[]); + method @Deprecated public void copy2DRangeFrom(int, int, int, int, android.renderscript.Allocation, int, int); + method @Deprecated public void copy2DRangeFrom(int, int, android.graphics.Bitmap); + method @Deprecated public void copy2DRangeTo(int, int, int, int, Object); + method @Deprecated public void copy2DRangeTo(int, int, int, int, byte[]); + method @Deprecated public void copy2DRangeTo(int, int, int, int, short[]); + method @Deprecated public void copy2DRangeTo(int, int, int, int, int[]); + method @Deprecated public void copy2DRangeTo(int, int, int, int, float[]); + method @Deprecated public void copy3DRangeFrom(int, int, int, int, int, int, Object); + method @Deprecated public void copy3DRangeFrom(int, int, int, int, int, int, android.renderscript.Allocation, int, int, int); + method @Deprecated public void copy3DRangeTo(int, int, int, int, int, int, Object); + method @Deprecated public void copyFrom(android.renderscript.BaseObj[]); + method @Deprecated public void copyFrom(Object); + method @Deprecated public void copyFrom(int[]); + method @Deprecated public void copyFrom(short[]); + method @Deprecated public void copyFrom(byte[]); + method @Deprecated public void copyFrom(float[]); + method @Deprecated public void copyFrom(android.graphics.Bitmap); + method @Deprecated public void copyFrom(android.renderscript.Allocation); + method @Deprecated public void copyFromUnchecked(Object); + method @Deprecated public void copyFromUnchecked(int[]); + method @Deprecated public void copyFromUnchecked(short[]); + method @Deprecated public void copyFromUnchecked(byte[]); + method @Deprecated public void copyFromUnchecked(float[]); + method @Deprecated public void copyTo(android.graphics.Bitmap); + method @Deprecated public void copyTo(Object); + method @Deprecated public void copyTo(byte[]); + method @Deprecated public void copyTo(short[]); + method @Deprecated public void copyTo(int[]); + method @Deprecated public void copyTo(float[]); + method @Deprecated public static android.renderscript.Allocation[] createAllocations(android.renderscript.RenderScript, android.renderscript.Type, int, int); + method @Deprecated public static android.renderscript.Allocation createCubemapFromBitmap(android.renderscript.RenderScript, android.graphics.Bitmap, android.renderscript.Allocation.MipmapControl, int); + method @Deprecated public static android.renderscript.Allocation createCubemapFromBitmap(android.renderscript.RenderScript, android.graphics.Bitmap); + method @Deprecated public static android.renderscript.Allocation createCubemapFromCubeFaces(android.renderscript.RenderScript, android.graphics.Bitmap, android.graphics.Bitmap, android.graphics.Bitmap, android.graphics.Bitmap, android.graphics.Bitmap, android.graphics.Bitmap, android.renderscript.Allocation.MipmapControl, int); + method @Deprecated public static android.renderscript.Allocation createCubemapFromCubeFaces(android.renderscript.RenderScript, android.graphics.Bitmap, android.graphics.Bitmap, android.graphics.Bitmap, android.graphics.Bitmap, android.graphics.Bitmap, android.graphics.Bitmap); + method @Deprecated public static android.renderscript.Allocation createFromBitmap(android.renderscript.RenderScript, android.graphics.Bitmap, android.renderscript.Allocation.MipmapControl, int); + method @Deprecated public static android.renderscript.Allocation createFromBitmap(android.renderscript.RenderScript, android.graphics.Bitmap); + method @Deprecated public static android.renderscript.Allocation createFromBitmapResource(android.renderscript.RenderScript, android.content.res.Resources, int, android.renderscript.Allocation.MipmapControl, int); + method @Deprecated public static android.renderscript.Allocation createFromBitmapResource(android.renderscript.RenderScript, android.content.res.Resources, int); + method @Deprecated public static android.renderscript.Allocation createFromString(android.renderscript.RenderScript, String, int); + method @Deprecated public static android.renderscript.Allocation createSized(android.renderscript.RenderScript, android.renderscript.Element, int, int); + method @Deprecated public static android.renderscript.Allocation createSized(android.renderscript.RenderScript, android.renderscript.Element, int); + method @Deprecated public static android.renderscript.Allocation createTyped(android.renderscript.RenderScript, android.renderscript.Type, android.renderscript.Allocation.MipmapControl, int); + method @Deprecated public static android.renderscript.Allocation createTyped(android.renderscript.RenderScript, android.renderscript.Type, int); + method @Deprecated public static android.renderscript.Allocation createTyped(android.renderscript.RenderScript, android.renderscript.Type); + method @Deprecated public void generateMipmaps(); + method @Deprecated public java.nio.ByteBuffer getByteBuffer(); + method @Deprecated public int getBytesSize(); + method @Deprecated public android.renderscript.Element getElement(); + method @Deprecated public long getStride(); + method @Deprecated public android.view.Surface getSurface(); + method @Deprecated public long getTimeStamp(); + method @Deprecated public android.renderscript.Type getType(); + method @Deprecated public int getUsage(); + method @Deprecated public void ioReceive(); + method @Deprecated public void ioSend(); method @Deprecated public void resize(int); - method public void setAutoPadding(boolean); - method public void setFromFieldPacker(int, android.renderscript.FieldPacker); - method public void setFromFieldPacker(int, int, android.renderscript.FieldPacker); - method public void setFromFieldPacker(int, int, int, int, android.renderscript.FieldPacker); - method public void setOnBufferAvailableListener(android.renderscript.Allocation.OnBufferAvailableListener); - method public void setSurface(android.view.Surface); - method public void syncAll(int); - field public static final int USAGE_GRAPHICS_CONSTANTS = 8; // 0x8 - field public static final int USAGE_GRAPHICS_RENDER_TARGET = 16; // 0x10 - field public static final int USAGE_GRAPHICS_TEXTURE = 2; // 0x2 - field public static final int USAGE_GRAPHICS_VERTEX = 4; // 0x4 - field public static final int USAGE_IO_INPUT = 32; // 0x20 - field public static final int USAGE_IO_OUTPUT = 64; // 0x40 - field public static final int USAGE_SCRIPT = 1; // 0x1 - field public static final int USAGE_SHARED = 128; // 0x80 - } - - public enum Allocation.MipmapControl { - enum_constant public static final android.renderscript.Allocation.MipmapControl MIPMAP_FULL; - enum_constant public static final android.renderscript.Allocation.MipmapControl MIPMAP_NONE; - enum_constant public static final android.renderscript.Allocation.MipmapControl MIPMAP_ON_SYNC_TO_TEXTURE; - } - - public static interface Allocation.OnBufferAvailableListener { - method public void onBufferAvailable(android.renderscript.Allocation); - } - - public class AllocationAdapter extends android.renderscript.Allocation { - method public static android.renderscript.AllocationAdapter create1D(android.renderscript.RenderScript, android.renderscript.Allocation); - method public static android.renderscript.AllocationAdapter create2D(android.renderscript.RenderScript, android.renderscript.Allocation); - method public static android.renderscript.AllocationAdapter createTyped(android.renderscript.RenderScript, android.renderscript.Allocation, android.renderscript.Type); - method public void resize(int); - method public void setFace(android.renderscript.Type.CubemapFace); - method public void setLOD(int); - method public void setX(int); - method public void setY(int); - method public void setZ(int); - } - - public class BaseObj { - method public void destroy(); - method public String getName(); - method public void setName(String); + method @Deprecated public void setAutoPadding(boolean); + method @Deprecated public void setFromFieldPacker(int, android.renderscript.FieldPacker); + method @Deprecated public void setFromFieldPacker(int, int, android.renderscript.FieldPacker); + method @Deprecated public void setFromFieldPacker(int, int, int, int, android.renderscript.FieldPacker); + method @Deprecated public void setOnBufferAvailableListener(android.renderscript.Allocation.OnBufferAvailableListener); + method @Deprecated public void setSurface(android.view.Surface); + method @Deprecated public void syncAll(int); + field @Deprecated public static final int USAGE_GRAPHICS_CONSTANTS = 8; // 0x8 + field @Deprecated public static final int USAGE_GRAPHICS_RENDER_TARGET = 16; // 0x10 + field @Deprecated public static final int USAGE_GRAPHICS_TEXTURE = 2; // 0x2 + field @Deprecated public static final int USAGE_GRAPHICS_VERTEX = 4; // 0x4 + field @Deprecated public static final int USAGE_IO_INPUT = 32; // 0x20 + field @Deprecated public static final int USAGE_IO_OUTPUT = 64; // 0x40 + field @Deprecated public static final int USAGE_SCRIPT = 1; // 0x1 + field @Deprecated public static final int USAGE_SHARED = 128; // 0x80 + } + + @Deprecated public enum Allocation.MipmapControl { + enum_constant @Deprecated public static final android.renderscript.Allocation.MipmapControl MIPMAP_FULL; + enum_constant @Deprecated public static final android.renderscript.Allocation.MipmapControl MIPMAP_NONE; + enum_constant @Deprecated public static final android.renderscript.Allocation.MipmapControl MIPMAP_ON_SYNC_TO_TEXTURE; + } + + @Deprecated public static interface Allocation.OnBufferAvailableListener { + method @Deprecated public void onBufferAvailable(android.renderscript.Allocation); + } + + @Deprecated public class AllocationAdapter extends android.renderscript.Allocation { + method @Deprecated public static android.renderscript.AllocationAdapter create1D(android.renderscript.RenderScript, android.renderscript.Allocation); + method @Deprecated public static android.renderscript.AllocationAdapter create2D(android.renderscript.RenderScript, android.renderscript.Allocation); + method @Deprecated public static android.renderscript.AllocationAdapter createTyped(android.renderscript.RenderScript, android.renderscript.Allocation, android.renderscript.Type); + method @Deprecated public void resize(int); + method @Deprecated public void setFace(android.renderscript.Type.CubemapFace); + method @Deprecated public void setLOD(int); + method @Deprecated public void setX(int); + method @Deprecated public void setY(int); + method @Deprecated public void setZ(int); } - public class Byte2 { - ctor public Byte2(); - ctor public Byte2(byte, byte); - field public byte x; - field public byte y; - } - - public class Byte3 { - ctor public Byte3(); - ctor public Byte3(byte, byte, byte); - field public byte x; - field public byte y; - field public byte z; - } - - public class Byte4 { - ctor public Byte4(); - ctor public Byte4(byte, byte, byte, byte); - field public byte w; - field public byte x; - field public byte y; - field public byte z; - } - - public class Double2 { - ctor public Double2(); - ctor public Double2(double, double); - field public double x; - field public double y; - } - - public class Double3 { - ctor public Double3(); - ctor public Double3(double, double, double); - field public double x; - field public double y; - field public double z; - } - - public class Double4 { - ctor public Double4(); - ctor public Double4(double, double, double, double); - field public double w; - field public double x; - field public double y; - field public double z; - } - - public class Element extends android.renderscript.BaseObj { - method public static android.renderscript.Element ALLOCATION(android.renderscript.RenderScript); - method public static android.renderscript.Element A_8(android.renderscript.RenderScript); - method public static android.renderscript.Element BOOLEAN(android.renderscript.RenderScript); - method public static android.renderscript.Element ELEMENT(android.renderscript.RenderScript); - method public static android.renderscript.Element F16(android.renderscript.RenderScript); - method public static android.renderscript.Element F16_2(android.renderscript.RenderScript); - method public static android.renderscript.Element F16_3(android.renderscript.RenderScript); - method public static android.renderscript.Element F16_4(android.renderscript.RenderScript); - method public static android.renderscript.Element F32(android.renderscript.RenderScript); - method public static android.renderscript.Element F32_2(android.renderscript.RenderScript); - method public static android.renderscript.Element F32_3(android.renderscript.RenderScript); - method public static android.renderscript.Element F32_4(android.renderscript.RenderScript); - method public static android.renderscript.Element F64(android.renderscript.RenderScript); - method public static android.renderscript.Element F64_2(android.renderscript.RenderScript); - method public static android.renderscript.Element F64_3(android.renderscript.RenderScript); - method public static android.renderscript.Element F64_4(android.renderscript.RenderScript); - method public static android.renderscript.Element FONT(android.renderscript.RenderScript); - method public static android.renderscript.Element I16(android.renderscript.RenderScript); - method public static android.renderscript.Element I16_2(android.renderscript.RenderScript); - method public static android.renderscript.Element I16_3(android.renderscript.RenderScript); - method public static android.renderscript.Element I16_4(android.renderscript.RenderScript); - method public static android.renderscript.Element I32(android.renderscript.RenderScript); - method public static android.renderscript.Element I32_2(android.renderscript.RenderScript); - method public static android.renderscript.Element I32_3(android.renderscript.RenderScript); - method public static android.renderscript.Element I32_4(android.renderscript.RenderScript); - method public static android.renderscript.Element I64(android.renderscript.RenderScript); - method public static android.renderscript.Element I64_2(android.renderscript.RenderScript); - method public static android.renderscript.Element I64_3(android.renderscript.RenderScript); - method public static android.renderscript.Element I64_4(android.renderscript.RenderScript); - method public static android.renderscript.Element I8(android.renderscript.RenderScript); - method public static android.renderscript.Element I8_2(android.renderscript.RenderScript); - method public static android.renderscript.Element I8_3(android.renderscript.RenderScript); - method public static android.renderscript.Element I8_4(android.renderscript.RenderScript); + @Deprecated public class BaseObj { + method @Deprecated public void destroy(); + method @Deprecated public String getName(); + method @Deprecated public void setName(String); + } + + @Deprecated public class Byte2 { + ctor @Deprecated public Byte2(); + ctor @Deprecated public Byte2(byte, byte); + field @Deprecated public byte x; + field @Deprecated public byte y; + } + + @Deprecated public class Byte3 { + ctor @Deprecated public Byte3(); + ctor @Deprecated public Byte3(byte, byte, byte); + field @Deprecated public byte x; + field @Deprecated public byte y; + field @Deprecated public byte z; + } + + @Deprecated public class Byte4 { + ctor @Deprecated public Byte4(); + ctor @Deprecated public Byte4(byte, byte, byte, byte); + field @Deprecated public byte w; + field @Deprecated public byte x; + field @Deprecated public byte y; + field @Deprecated public byte z; + } + + @Deprecated public class Double2 { + ctor @Deprecated public Double2(); + ctor @Deprecated public Double2(double, double); + field @Deprecated public double x; + field @Deprecated public double y; + } + + @Deprecated public class Double3 { + ctor @Deprecated public Double3(); + ctor @Deprecated public Double3(double, double, double); + field @Deprecated public double x; + field @Deprecated public double y; + field @Deprecated public double z; + } + + @Deprecated public class Double4 { + ctor @Deprecated public Double4(); + ctor @Deprecated public Double4(double, double, double, double); + field @Deprecated public double w; + field @Deprecated public double x; + field @Deprecated public double y; + field @Deprecated public double z; + } + + @Deprecated public class Element extends android.renderscript.BaseObj { + method @Deprecated public static android.renderscript.Element ALLOCATION(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element A_8(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element BOOLEAN(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element ELEMENT(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element F16(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element F16_2(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element F16_3(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element F16_4(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element F32(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element F32_2(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element F32_3(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element F32_4(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element F64(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element F64_2(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element F64_3(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element F64_4(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element FONT(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element I16(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element I16_2(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element I16_3(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element I16_4(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element I32(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element I32_2(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element I32_3(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element I32_4(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element I64(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element I64_2(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element I64_3(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element I64_4(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element I8(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element I8_2(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element I8_3(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element I8_4(android.renderscript.RenderScript); method @Deprecated public static android.renderscript.Element MATRIX4X4(android.renderscript.RenderScript); - method public static android.renderscript.Element MATRIX_2X2(android.renderscript.RenderScript); - method public static android.renderscript.Element MATRIX_3X3(android.renderscript.RenderScript); - method public static android.renderscript.Element MATRIX_4X4(android.renderscript.RenderScript); - method public static android.renderscript.Element MESH(android.renderscript.RenderScript); - method public static android.renderscript.Element PROGRAM_FRAGMENT(android.renderscript.RenderScript); - method public static android.renderscript.Element PROGRAM_RASTER(android.renderscript.RenderScript); - method public static android.renderscript.Element PROGRAM_STORE(android.renderscript.RenderScript); - method public static android.renderscript.Element PROGRAM_VERTEX(android.renderscript.RenderScript); - method public static android.renderscript.Element RGBA_4444(android.renderscript.RenderScript); - method public static android.renderscript.Element RGBA_5551(android.renderscript.RenderScript); - method public static android.renderscript.Element RGBA_8888(android.renderscript.RenderScript); - method public static android.renderscript.Element RGB_565(android.renderscript.RenderScript); - method public static android.renderscript.Element RGB_888(android.renderscript.RenderScript); - method public static android.renderscript.Element SAMPLER(android.renderscript.RenderScript); - method public static android.renderscript.Element SCRIPT(android.renderscript.RenderScript); - method public static android.renderscript.Element TYPE(android.renderscript.RenderScript); - method public static android.renderscript.Element U16(android.renderscript.RenderScript); - method public static android.renderscript.Element U16_2(android.renderscript.RenderScript); - method public static android.renderscript.Element U16_3(android.renderscript.RenderScript); - method public static android.renderscript.Element U16_4(android.renderscript.RenderScript); - method public static android.renderscript.Element U32(android.renderscript.RenderScript); - method public static android.renderscript.Element U32_2(android.renderscript.RenderScript); - method public static android.renderscript.Element U32_3(android.renderscript.RenderScript); - method public static android.renderscript.Element U32_4(android.renderscript.RenderScript); - method public static android.renderscript.Element U64(android.renderscript.RenderScript); - method public static android.renderscript.Element U64_2(android.renderscript.RenderScript); - method public static android.renderscript.Element U64_3(android.renderscript.RenderScript); - method public static android.renderscript.Element U64_4(android.renderscript.RenderScript); - method public static android.renderscript.Element U8(android.renderscript.RenderScript); - method public static android.renderscript.Element U8_2(android.renderscript.RenderScript); - method public static android.renderscript.Element U8_3(android.renderscript.RenderScript); - method public static android.renderscript.Element U8_4(android.renderscript.RenderScript); - method public static android.renderscript.Element YUV(android.renderscript.RenderScript); - method public static android.renderscript.Element createPixel(android.renderscript.RenderScript, android.renderscript.Element.DataType, android.renderscript.Element.DataKind); - method public static android.renderscript.Element createVector(android.renderscript.RenderScript, android.renderscript.Element.DataType, int); - method public int getBytesSize(); - method public android.renderscript.Element.DataKind getDataKind(); - method public android.renderscript.Element.DataType getDataType(); - method public android.renderscript.Element getSubElement(int); - method public int getSubElementArraySize(int); - method public int getSubElementCount(); - method public String getSubElementName(int); - method public int getSubElementOffsetBytes(int); - method public int getVectorSize(); - method public boolean isCompatible(android.renderscript.Element); - method public boolean isComplex(); - } - - public static class Element.Builder { - ctor public Element.Builder(android.renderscript.RenderScript); - method public android.renderscript.Element.Builder add(android.renderscript.Element, String, int); - method public android.renderscript.Element.Builder add(android.renderscript.Element, String); - method public android.renderscript.Element create(); - } - - public enum Element.DataKind { - enum_constant public static final android.renderscript.Element.DataKind PIXEL_A; - enum_constant public static final android.renderscript.Element.DataKind PIXEL_DEPTH; - enum_constant public static final android.renderscript.Element.DataKind PIXEL_L; - enum_constant public static final android.renderscript.Element.DataKind PIXEL_LA; - enum_constant public static final android.renderscript.Element.DataKind PIXEL_RGB; - enum_constant public static final android.renderscript.Element.DataKind PIXEL_RGBA; - enum_constant public static final android.renderscript.Element.DataKind PIXEL_YUV; - enum_constant public static final android.renderscript.Element.DataKind USER; - } - - public enum Element.DataType { - enum_constant public static final android.renderscript.Element.DataType BOOLEAN; - enum_constant public static final android.renderscript.Element.DataType FLOAT_16; - enum_constant public static final android.renderscript.Element.DataType FLOAT_32; - enum_constant public static final android.renderscript.Element.DataType FLOAT_64; - enum_constant public static final android.renderscript.Element.DataType MATRIX_2X2; - enum_constant public static final android.renderscript.Element.DataType MATRIX_3X3; - enum_constant public static final android.renderscript.Element.DataType MATRIX_4X4; - enum_constant public static final android.renderscript.Element.DataType NONE; - enum_constant public static final android.renderscript.Element.DataType RS_ALLOCATION; - enum_constant public static final android.renderscript.Element.DataType RS_ELEMENT; - enum_constant public static final android.renderscript.Element.DataType RS_FONT; - enum_constant public static final android.renderscript.Element.DataType RS_MESH; - enum_constant public static final android.renderscript.Element.DataType RS_PROGRAM_FRAGMENT; - enum_constant public static final android.renderscript.Element.DataType RS_PROGRAM_RASTER; - enum_constant public static final android.renderscript.Element.DataType RS_PROGRAM_STORE; - enum_constant public static final android.renderscript.Element.DataType RS_PROGRAM_VERTEX; - enum_constant public static final android.renderscript.Element.DataType RS_SAMPLER; - enum_constant public static final android.renderscript.Element.DataType RS_SCRIPT; - enum_constant public static final android.renderscript.Element.DataType RS_TYPE; - enum_constant public static final android.renderscript.Element.DataType SIGNED_16; - enum_constant public static final android.renderscript.Element.DataType SIGNED_32; - enum_constant public static final android.renderscript.Element.DataType SIGNED_64; - enum_constant public static final android.renderscript.Element.DataType SIGNED_8; - enum_constant public static final android.renderscript.Element.DataType UNSIGNED_16; - enum_constant public static final android.renderscript.Element.DataType UNSIGNED_32; - enum_constant public static final android.renderscript.Element.DataType UNSIGNED_4_4_4_4; - enum_constant public static final android.renderscript.Element.DataType UNSIGNED_5_5_5_1; - enum_constant public static final android.renderscript.Element.DataType UNSIGNED_5_6_5; - enum_constant public static final android.renderscript.Element.DataType UNSIGNED_64; - enum_constant public static final android.renderscript.Element.DataType UNSIGNED_8; - } - - public class FieldPacker { - ctor public FieldPacker(int); - ctor public FieldPacker(byte[]); - method public void addBoolean(boolean); - method public void addF32(float); - method public void addF32(android.renderscript.Float2); - method public void addF32(android.renderscript.Float3); - method public void addF32(android.renderscript.Float4); - method public void addF64(double); - method public void addF64(android.renderscript.Double2); - method public void addF64(android.renderscript.Double3); - method public void addF64(android.renderscript.Double4); - method public void addI16(short); - method public void addI16(android.renderscript.Short2); - method public void addI16(android.renderscript.Short3); - method public void addI16(android.renderscript.Short4); - method public void addI32(int); - method public void addI32(android.renderscript.Int2); - method public void addI32(android.renderscript.Int3); - method public void addI32(android.renderscript.Int4); - method public void addI64(long); - method public void addI64(android.renderscript.Long2); - method public void addI64(android.renderscript.Long3); - method public void addI64(android.renderscript.Long4); - method public void addI8(byte); - method public void addI8(android.renderscript.Byte2); - method public void addI8(android.renderscript.Byte3); - method public void addI8(android.renderscript.Byte4); - method public void addMatrix(android.renderscript.Matrix4f); - method public void addMatrix(android.renderscript.Matrix3f); - method public void addMatrix(android.renderscript.Matrix2f); - method public void addObj(android.renderscript.BaseObj); - method public void addU16(int); - method public void addU16(android.renderscript.Int2); - method public void addU16(android.renderscript.Int3); - method public void addU16(android.renderscript.Int4); - method public void addU32(long); - method public void addU32(android.renderscript.Long2); - method public void addU32(android.renderscript.Long3); - method public void addU32(android.renderscript.Long4); - method public void addU64(long); - method public void addU64(android.renderscript.Long2); - method public void addU64(android.renderscript.Long3); - method public void addU64(android.renderscript.Long4); - method public void addU8(short); - method public void addU8(android.renderscript.Short2); - method public void addU8(android.renderscript.Short3); - method public void addU8(android.renderscript.Short4); - method public void align(int); - method public final byte[] getData(); - method public void reset(); - method public void reset(int); - method public void skip(int); - method public boolean subBoolean(); - method public android.renderscript.Byte2 subByte2(); - method public android.renderscript.Byte3 subByte3(); - method public android.renderscript.Byte4 subByte4(); - method public android.renderscript.Double2 subDouble2(); - method public android.renderscript.Double3 subDouble3(); - method public android.renderscript.Double4 subDouble4(); - method public float subF32(); - method public double subF64(); - method public android.renderscript.Float2 subFloat2(); - method public android.renderscript.Float3 subFloat3(); - method public android.renderscript.Float4 subFloat4(); - method public short subI16(); - method public int subI32(); - method public long subI64(); - method public byte subI8(); - method public android.renderscript.Int2 subInt2(); - method public android.renderscript.Int3 subInt3(); - method public android.renderscript.Int4 subInt4(); - method public android.renderscript.Long2 subLong2(); - method public android.renderscript.Long3 subLong3(); - method public android.renderscript.Long4 subLong4(); - method public android.renderscript.Matrix2f subMatrix2f(); - method public android.renderscript.Matrix3f subMatrix3f(); - method public android.renderscript.Matrix4f subMatrix4f(); - method public android.renderscript.Short2 subShort2(); - method public android.renderscript.Short3 subShort3(); - method public android.renderscript.Short4 subShort4(); - method public void subalign(int); - } - - public class Float2 { - ctor public Float2(); - ctor public Float2(float, float); - field public float x; - field public float y; - } - - public class Float3 { - ctor public Float3(); - ctor public Float3(float, float, float); - field public float x; - field public float y; - field public float z; - } - - public class Float4 { - ctor public Float4(); - ctor public Float4(float, float, float, float); - field public float w; - field public float x; - field public float y; - field public float z; - } - - public class Int2 { - ctor public Int2(); - ctor public Int2(int, int); - field public int x; - field public int y; - } - - public class Int3 { - ctor public Int3(); - ctor public Int3(int, int, int); - field public int x; - field public int y; - field public int z; - } - - public class Int4 { - ctor public Int4(); - ctor public Int4(int, int, int, int); - field public int w; - field public int x; - field public int y; - field public int z; - } - - public class Long2 { - ctor public Long2(); - ctor public Long2(long, long); - field public long x; - field public long y; - } - - public class Long3 { - ctor public Long3(); - ctor public Long3(long, long, long); - field public long x; - field public long y; - field public long z; - } - - public class Long4 { - ctor public Long4(); - ctor public Long4(long, long, long, long); - field public long w; - field public long x; - field public long y; - field public long z; - } - - public class Matrix2f { - ctor public Matrix2f(); - ctor public Matrix2f(float[]); - method public float get(int, int); - method public float[] getArray(); - method public void load(android.renderscript.Matrix2f); - method public void loadIdentity(); - method public void loadMultiply(android.renderscript.Matrix2f, android.renderscript.Matrix2f); - method public void loadRotate(float); - method public void loadScale(float, float); - method public void multiply(android.renderscript.Matrix2f); - method public void rotate(float); - method public void scale(float, float); - method public void set(int, int, float); - method public void transpose(); - } - - public class Matrix3f { - ctor public Matrix3f(); - ctor public Matrix3f(float[]); - method public float get(int, int); - method public float[] getArray(); - method public void load(android.renderscript.Matrix3f); - method public void loadIdentity(); - method public void loadMultiply(android.renderscript.Matrix3f, android.renderscript.Matrix3f); - method public void loadRotate(float, float, float, float); - method public void loadRotate(float); - method public void loadScale(float, float); - method public void loadScale(float, float, float); - method public void loadTranslate(float, float); - method public void multiply(android.renderscript.Matrix3f); - method public void rotate(float, float, float, float); - method public void rotate(float); - method public void scale(float, float); - method public void scale(float, float, float); - method public void set(int, int, float); - method public void translate(float, float); - method public void transpose(); - } - - public class Matrix4f { - ctor public Matrix4f(); - ctor public Matrix4f(float[]); - method public float get(int, int); - method public float[] getArray(); - method public boolean inverse(); - method public boolean inverseTranspose(); - method public void load(android.renderscript.Matrix4f); - method public void loadFrustum(float, float, float, float, float, float); - method public void loadIdentity(); - method public void loadMultiply(android.renderscript.Matrix4f, android.renderscript.Matrix4f); - method public void loadOrtho(float, float, float, float, float, float); - method public void loadOrthoWindow(int, int); - method public void loadPerspective(float, float, float, float); - method public void loadProjectionNormalized(int, int); - method public void loadRotate(float, float, float, float); - method public void loadScale(float, float, float); - method public void loadTranslate(float, float, float); - method public void multiply(android.renderscript.Matrix4f); - method public void rotate(float, float, float, float); - method public void scale(float, float, float); - method public void set(int, int, float); - method public void translate(float, float, float); - method public void transpose(); - } - - public class RSDriverException extends android.renderscript.RSRuntimeException { - ctor public RSDriverException(String); - } - - public class RSIllegalArgumentException extends android.renderscript.RSRuntimeException { - ctor public RSIllegalArgumentException(String); - } - - public class RSInvalidStateException extends android.renderscript.RSRuntimeException { - ctor public RSInvalidStateException(String); - } - - public class RSRuntimeException extends java.lang.RuntimeException { - ctor public RSRuntimeException(String); - } - - public class RenderScript { - method public void contextDump(); - method public static android.renderscript.RenderScript create(android.content.Context); - method public static android.renderscript.RenderScript create(android.content.Context, android.renderscript.RenderScript.ContextType); - method public static android.renderscript.RenderScript create(android.content.Context, android.renderscript.RenderScript.ContextType, int); - method public static android.renderscript.RenderScript createMultiContext(android.content.Context, android.renderscript.RenderScript.ContextType, int, int); - method public void destroy(); - method public void finish(); - method public final android.content.Context getApplicationContext(); - method public android.renderscript.RenderScript.RSErrorHandler getErrorHandler(); - method public android.renderscript.RenderScript.RSMessageHandler getMessageHandler(); - method public static long getMinorVersion(); - method public static void releaseAllContexts(); - method public void sendMessage(int, int[]); - method public void setErrorHandler(android.renderscript.RenderScript.RSErrorHandler); - method public void setMessageHandler(android.renderscript.RenderScript.RSMessageHandler); - method public void setPriority(android.renderscript.RenderScript.Priority); - field public static final int CREATE_FLAG_LOW_LATENCY = 2; // 0x2 - field public static final int CREATE_FLAG_LOW_POWER = 4; // 0x4 - field public static final int CREATE_FLAG_NONE = 0; // 0x0 - } - - public enum RenderScript.ContextType { - enum_constant public static final android.renderscript.RenderScript.ContextType DEBUG; - enum_constant public static final android.renderscript.RenderScript.ContextType NORMAL; - enum_constant public static final android.renderscript.RenderScript.ContextType PROFILE; - } - - public enum RenderScript.Priority { - enum_constant public static final android.renderscript.RenderScript.Priority LOW; - enum_constant public static final android.renderscript.RenderScript.Priority NORMAL; - } - - public static class RenderScript.RSErrorHandler implements java.lang.Runnable { - ctor public RenderScript.RSErrorHandler(); - method public void run(); - field protected String mErrorMessage; - field protected int mErrorNum; - } - - public static class RenderScript.RSMessageHandler implements java.lang.Runnable { - ctor public RenderScript.RSMessageHandler(); - method public void run(); - field protected int[] mData; - field protected int mID; - field protected int mLength; - } - - public class Sampler extends android.renderscript.BaseObj { - method public static android.renderscript.Sampler CLAMP_LINEAR(android.renderscript.RenderScript); - method public static android.renderscript.Sampler CLAMP_LINEAR_MIP_LINEAR(android.renderscript.RenderScript); - method public static android.renderscript.Sampler CLAMP_NEAREST(android.renderscript.RenderScript); - method public static android.renderscript.Sampler MIRRORED_REPEAT_LINEAR(android.renderscript.RenderScript); - method public static android.renderscript.Sampler MIRRORED_REPEAT_LINEAR_MIP_LINEAR(android.renderscript.RenderScript); - method public static android.renderscript.Sampler MIRRORED_REPEAT_NEAREST(android.renderscript.RenderScript); - method public static android.renderscript.Sampler WRAP_LINEAR(android.renderscript.RenderScript); - method public static android.renderscript.Sampler WRAP_LINEAR_MIP_LINEAR(android.renderscript.RenderScript); - method public static android.renderscript.Sampler WRAP_NEAREST(android.renderscript.RenderScript); - method public float getAnisotropy(); - method public android.renderscript.Sampler.Value getMagnification(); - method public android.renderscript.Sampler.Value getMinification(); - method public android.renderscript.Sampler.Value getWrapS(); - method public android.renderscript.Sampler.Value getWrapT(); - } - - public static class Sampler.Builder { - ctor public Sampler.Builder(android.renderscript.RenderScript); - method public android.renderscript.Sampler create(); - method public void setAnisotropy(float); - method public void setMagnification(android.renderscript.Sampler.Value); - method public void setMinification(android.renderscript.Sampler.Value); - method public void setWrapS(android.renderscript.Sampler.Value); - method public void setWrapT(android.renderscript.Sampler.Value); - } - - public enum Sampler.Value { - enum_constant public static final android.renderscript.Sampler.Value CLAMP; - enum_constant public static final android.renderscript.Sampler.Value LINEAR; - enum_constant public static final android.renderscript.Sampler.Value LINEAR_MIP_LINEAR; - enum_constant public static final android.renderscript.Sampler.Value LINEAR_MIP_NEAREST; - enum_constant public static final android.renderscript.Sampler.Value MIRRORED_REPEAT; - enum_constant public static final android.renderscript.Sampler.Value NEAREST; - enum_constant public static final android.renderscript.Sampler.Value WRAP; - } - - public class Script extends android.renderscript.BaseObj { - method public void bindAllocation(android.renderscript.Allocation, int); - method protected android.renderscript.Script.FieldID createFieldID(int, android.renderscript.Element); - method protected android.renderscript.Script.InvokeID createInvokeID(int); - method protected android.renderscript.Script.KernelID createKernelID(int, int, android.renderscript.Element, android.renderscript.Element); - method protected void forEach(int, android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.FieldPacker); - method protected void forEach(int, android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.FieldPacker, android.renderscript.Script.LaunchOptions); - method protected void forEach(int, android.renderscript.Allocation[], android.renderscript.Allocation, android.renderscript.FieldPacker); - method protected void forEach(int, android.renderscript.Allocation[], android.renderscript.Allocation, android.renderscript.FieldPacker, android.renderscript.Script.LaunchOptions); - method public boolean getVarB(int); - method public double getVarD(int); - method public float getVarF(int); - method public int getVarI(int); - method public long getVarJ(int); - method public void getVarV(int, android.renderscript.FieldPacker); - method protected void invoke(int); - method protected void invoke(int, android.renderscript.FieldPacker); - method protected void reduce(int, android.renderscript.Allocation[], android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); - method public void setTimeZone(String); - method public void setVar(int, float); - method public void setVar(int, double); - method public void setVar(int, int); - method public void setVar(int, long); - method public void setVar(int, boolean); - method public void setVar(int, android.renderscript.BaseObj); - method public void setVar(int, android.renderscript.FieldPacker); - method public void setVar(int, android.renderscript.FieldPacker, android.renderscript.Element, int[]); - } - - public static class Script.Builder { - } - - public static class Script.FieldBase { - ctor protected Script.FieldBase(); - method public android.renderscript.Allocation getAllocation(); - method public android.renderscript.Element getElement(); - method public android.renderscript.Type getType(); - method protected void init(android.renderscript.RenderScript, int); - method protected void init(android.renderscript.RenderScript, int, int); - method public void updateAllocation(); - field protected android.renderscript.Allocation mAllocation; - field protected android.renderscript.Element mElement; - } - - public static final class Script.FieldID extends android.renderscript.BaseObj { - } - - public static final class Script.InvokeID extends android.renderscript.BaseObj { - } - - public static final class Script.KernelID extends android.renderscript.BaseObj { + method @Deprecated public static android.renderscript.Element MATRIX_2X2(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element MATRIX_3X3(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element MATRIX_4X4(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element MESH(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element PROGRAM_FRAGMENT(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element PROGRAM_RASTER(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element PROGRAM_STORE(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element PROGRAM_VERTEX(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element RGBA_4444(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element RGBA_5551(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element RGBA_8888(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element RGB_565(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element RGB_888(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element SAMPLER(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element SCRIPT(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element TYPE(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element U16(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element U16_2(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element U16_3(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element U16_4(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element U32(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element U32_2(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element U32_3(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element U32_4(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element U64(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element U64_2(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element U64_3(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element U64_4(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element U8(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element U8_2(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element U8_3(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element U8_4(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element YUV(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Element createPixel(android.renderscript.RenderScript, android.renderscript.Element.DataType, android.renderscript.Element.DataKind); + method @Deprecated public static android.renderscript.Element createVector(android.renderscript.RenderScript, android.renderscript.Element.DataType, int); + method @Deprecated public int getBytesSize(); + method @Deprecated public android.renderscript.Element.DataKind getDataKind(); + method @Deprecated public android.renderscript.Element.DataType getDataType(); + method @Deprecated public android.renderscript.Element getSubElement(int); + method @Deprecated public int getSubElementArraySize(int); + method @Deprecated public int getSubElementCount(); + method @Deprecated public String getSubElementName(int); + method @Deprecated public int getSubElementOffsetBytes(int); + method @Deprecated public int getVectorSize(); + method @Deprecated public boolean isCompatible(android.renderscript.Element); + method @Deprecated public boolean isComplex(); + } + + @Deprecated public static class Element.Builder { + ctor @Deprecated public Element.Builder(android.renderscript.RenderScript); + method @Deprecated public android.renderscript.Element.Builder add(android.renderscript.Element, String, int); + method @Deprecated public android.renderscript.Element.Builder add(android.renderscript.Element, String); + method @Deprecated public android.renderscript.Element create(); + } + + @Deprecated public enum Element.DataKind { + enum_constant @Deprecated public static final android.renderscript.Element.DataKind PIXEL_A; + enum_constant @Deprecated public static final android.renderscript.Element.DataKind PIXEL_DEPTH; + enum_constant @Deprecated public static final android.renderscript.Element.DataKind PIXEL_L; + enum_constant @Deprecated public static final android.renderscript.Element.DataKind PIXEL_LA; + enum_constant @Deprecated public static final android.renderscript.Element.DataKind PIXEL_RGB; + enum_constant @Deprecated public static final android.renderscript.Element.DataKind PIXEL_RGBA; + enum_constant @Deprecated public static final android.renderscript.Element.DataKind PIXEL_YUV; + enum_constant @Deprecated public static final android.renderscript.Element.DataKind USER; + } + + @Deprecated public enum Element.DataType { + enum_constant @Deprecated public static final android.renderscript.Element.DataType BOOLEAN; + enum_constant @Deprecated public static final android.renderscript.Element.DataType FLOAT_16; + enum_constant @Deprecated public static final android.renderscript.Element.DataType FLOAT_32; + enum_constant @Deprecated public static final android.renderscript.Element.DataType FLOAT_64; + enum_constant @Deprecated public static final android.renderscript.Element.DataType MATRIX_2X2; + enum_constant @Deprecated public static final android.renderscript.Element.DataType MATRIX_3X3; + enum_constant @Deprecated public static final android.renderscript.Element.DataType MATRIX_4X4; + enum_constant @Deprecated public static final android.renderscript.Element.DataType NONE; + enum_constant @Deprecated public static final android.renderscript.Element.DataType RS_ALLOCATION; + enum_constant @Deprecated public static final android.renderscript.Element.DataType RS_ELEMENT; + enum_constant @Deprecated public static final android.renderscript.Element.DataType RS_FONT; + enum_constant @Deprecated public static final android.renderscript.Element.DataType RS_MESH; + enum_constant @Deprecated public static final android.renderscript.Element.DataType RS_PROGRAM_FRAGMENT; + enum_constant @Deprecated public static final android.renderscript.Element.DataType RS_PROGRAM_RASTER; + enum_constant @Deprecated public static final android.renderscript.Element.DataType RS_PROGRAM_STORE; + enum_constant @Deprecated public static final android.renderscript.Element.DataType RS_PROGRAM_VERTEX; + enum_constant @Deprecated public static final android.renderscript.Element.DataType RS_SAMPLER; + enum_constant @Deprecated public static final android.renderscript.Element.DataType RS_SCRIPT; + enum_constant @Deprecated public static final android.renderscript.Element.DataType RS_TYPE; + enum_constant @Deprecated public static final android.renderscript.Element.DataType SIGNED_16; + enum_constant @Deprecated public static final android.renderscript.Element.DataType SIGNED_32; + enum_constant @Deprecated public static final android.renderscript.Element.DataType SIGNED_64; + enum_constant @Deprecated public static final android.renderscript.Element.DataType SIGNED_8; + enum_constant @Deprecated public static final android.renderscript.Element.DataType UNSIGNED_16; + enum_constant @Deprecated public static final android.renderscript.Element.DataType UNSIGNED_32; + enum_constant @Deprecated public static final android.renderscript.Element.DataType UNSIGNED_4_4_4_4; + enum_constant @Deprecated public static final android.renderscript.Element.DataType UNSIGNED_5_5_5_1; + enum_constant @Deprecated public static final android.renderscript.Element.DataType UNSIGNED_5_6_5; + enum_constant @Deprecated public static final android.renderscript.Element.DataType UNSIGNED_64; + enum_constant @Deprecated public static final android.renderscript.Element.DataType UNSIGNED_8; + } + + @Deprecated public class FieldPacker { + ctor @Deprecated public FieldPacker(int); + ctor @Deprecated public FieldPacker(byte[]); + method @Deprecated public void addBoolean(boolean); + method @Deprecated public void addF32(float); + method @Deprecated public void addF32(android.renderscript.Float2); + method @Deprecated public void addF32(android.renderscript.Float3); + method @Deprecated public void addF32(android.renderscript.Float4); + method @Deprecated public void addF64(double); + method @Deprecated public void addF64(android.renderscript.Double2); + method @Deprecated public void addF64(android.renderscript.Double3); + method @Deprecated public void addF64(android.renderscript.Double4); + method @Deprecated public void addI16(short); + method @Deprecated public void addI16(android.renderscript.Short2); + method @Deprecated public void addI16(android.renderscript.Short3); + method @Deprecated public void addI16(android.renderscript.Short4); + method @Deprecated public void addI32(int); + method @Deprecated public void addI32(android.renderscript.Int2); + method @Deprecated public void addI32(android.renderscript.Int3); + method @Deprecated public void addI32(android.renderscript.Int4); + method @Deprecated public void addI64(long); + method @Deprecated public void addI64(android.renderscript.Long2); + method @Deprecated public void addI64(android.renderscript.Long3); + method @Deprecated public void addI64(android.renderscript.Long4); + method @Deprecated public void addI8(byte); + method @Deprecated public void addI8(android.renderscript.Byte2); + method @Deprecated public void addI8(android.renderscript.Byte3); + method @Deprecated public void addI8(android.renderscript.Byte4); + method @Deprecated public void addMatrix(android.renderscript.Matrix4f); + method @Deprecated public void addMatrix(android.renderscript.Matrix3f); + method @Deprecated public void addMatrix(android.renderscript.Matrix2f); + method @Deprecated public void addObj(android.renderscript.BaseObj); + method @Deprecated public void addU16(int); + method @Deprecated public void addU16(android.renderscript.Int2); + method @Deprecated public void addU16(android.renderscript.Int3); + method @Deprecated public void addU16(android.renderscript.Int4); + method @Deprecated public void addU32(long); + method @Deprecated public void addU32(android.renderscript.Long2); + method @Deprecated public void addU32(android.renderscript.Long3); + method @Deprecated public void addU32(android.renderscript.Long4); + method @Deprecated public void addU64(long); + method @Deprecated public void addU64(android.renderscript.Long2); + method @Deprecated public void addU64(android.renderscript.Long3); + method @Deprecated public void addU64(android.renderscript.Long4); + method @Deprecated public void addU8(short); + method @Deprecated public void addU8(android.renderscript.Short2); + method @Deprecated public void addU8(android.renderscript.Short3); + method @Deprecated public void addU8(android.renderscript.Short4); + method @Deprecated public void align(int); + method @Deprecated public final byte[] getData(); + method @Deprecated public void reset(); + method @Deprecated public void reset(int); + method @Deprecated public void skip(int); + method @Deprecated public boolean subBoolean(); + method @Deprecated public android.renderscript.Byte2 subByte2(); + method @Deprecated public android.renderscript.Byte3 subByte3(); + method @Deprecated public android.renderscript.Byte4 subByte4(); + method @Deprecated public android.renderscript.Double2 subDouble2(); + method @Deprecated public android.renderscript.Double3 subDouble3(); + method @Deprecated public android.renderscript.Double4 subDouble4(); + method @Deprecated public float subF32(); + method @Deprecated public double subF64(); + method @Deprecated public android.renderscript.Float2 subFloat2(); + method @Deprecated public android.renderscript.Float3 subFloat3(); + method @Deprecated public android.renderscript.Float4 subFloat4(); + method @Deprecated public short subI16(); + method @Deprecated public int subI32(); + method @Deprecated public long subI64(); + method @Deprecated public byte subI8(); + method @Deprecated public android.renderscript.Int2 subInt2(); + method @Deprecated public android.renderscript.Int3 subInt3(); + method @Deprecated public android.renderscript.Int4 subInt4(); + method @Deprecated public android.renderscript.Long2 subLong2(); + method @Deprecated public android.renderscript.Long3 subLong3(); + method @Deprecated public android.renderscript.Long4 subLong4(); + method @Deprecated public android.renderscript.Matrix2f subMatrix2f(); + method @Deprecated public android.renderscript.Matrix3f subMatrix3f(); + method @Deprecated public android.renderscript.Matrix4f subMatrix4f(); + method @Deprecated public android.renderscript.Short2 subShort2(); + method @Deprecated public android.renderscript.Short3 subShort3(); + method @Deprecated public android.renderscript.Short4 subShort4(); + method @Deprecated public void subalign(int); + } + + @Deprecated public class Float2 { + ctor @Deprecated public Float2(); + ctor @Deprecated public Float2(float, float); + field @Deprecated public float x; + field @Deprecated public float y; + } + + @Deprecated public class Float3 { + ctor @Deprecated public Float3(); + ctor @Deprecated public Float3(float, float, float); + field @Deprecated public float x; + field @Deprecated public float y; + field @Deprecated public float z; + } + + @Deprecated public class Float4 { + ctor @Deprecated public Float4(); + ctor @Deprecated public Float4(float, float, float, float); + field @Deprecated public float w; + field @Deprecated public float x; + field @Deprecated public float y; + field @Deprecated public float z; + } + + @Deprecated public class Int2 { + ctor @Deprecated public Int2(); + ctor @Deprecated public Int2(int, int); + field @Deprecated public int x; + field @Deprecated public int y; } - public static final class Script.LaunchOptions { - ctor public Script.LaunchOptions(); - method public int getXEnd(); - method public int getXStart(); - method public int getYEnd(); - method public int getYStart(); - method public int getZEnd(); - method public int getZStart(); - method public android.renderscript.Script.LaunchOptions setX(int, int); - method public android.renderscript.Script.LaunchOptions setY(int, int); - method public android.renderscript.Script.LaunchOptions setZ(int, int); + @Deprecated public class Int3 { + ctor @Deprecated public Int3(); + ctor @Deprecated public Int3(int, int, int); + field @Deprecated public int x; + field @Deprecated public int y; + field @Deprecated public int z; } - public class ScriptC extends android.renderscript.Script { - ctor protected ScriptC(int, android.renderscript.RenderScript); - ctor protected ScriptC(long, android.renderscript.RenderScript); - ctor protected ScriptC(android.renderscript.RenderScript, android.content.res.Resources, int); - ctor protected ScriptC(android.renderscript.RenderScript, String, byte[], byte[]); + @Deprecated public class Int4 { + ctor @Deprecated public Int4(); + ctor @Deprecated public Int4(int, int, int, int); + field @Deprecated public int w; + field @Deprecated public int x; + field @Deprecated public int y; + field @Deprecated public int z; + } + + @Deprecated public class Long2 { + ctor @Deprecated public Long2(); + ctor @Deprecated public Long2(long, long); + field @Deprecated public long x; + field @Deprecated public long y; + } + + @Deprecated public class Long3 { + ctor @Deprecated public Long3(); + ctor @Deprecated public Long3(long, long, long); + field @Deprecated public long x; + field @Deprecated public long y; + field @Deprecated public long z; + } + + @Deprecated public class Long4 { + ctor @Deprecated public Long4(); + ctor @Deprecated public Long4(long, long, long, long); + field @Deprecated public long w; + field @Deprecated public long x; + field @Deprecated public long y; + field @Deprecated public long z; + } + + @Deprecated public class Matrix2f { + ctor @Deprecated public Matrix2f(); + ctor @Deprecated public Matrix2f(float[]); + method @Deprecated public float get(int, int); + method @Deprecated public float[] getArray(); + method @Deprecated public void load(android.renderscript.Matrix2f); + method @Deprecated public void loadIdentity(); + method @Deprecated public void loadMultiply(android.renderscript.Matrix2f, android.renderscript.Matrix2f); + method @Deprecated public void loadRotate(float); + method @Deprecated public void loadScale(float, float); + method @Deprecated public void multiply(android.renderscript.Matrix2f); + method @Deprecated public void rotate(float); + method @Deprecated public void scale(float, float); + method @Deprecated public void set(int, int, float); + method @Deprecated public void transpose(); + } + + @Deprecated public class Matrix3f { + ctor @Deprecated public Matrix3f(); + ctor @Deprecated public Matrix3f(float[]); + method @Deprecated public float get(int, int); + method @Deprecated public float[] getArray(); + method @Deprecated public void load(android.renderscript.Matrix3f); + method @Deprecated public void loadIdentity(); + method @Deprecated public void loadMultiply(android.renderscript.Matrix3f, android.renderscript.Matrix3f); + method @Deprecated public void loadRotate(float, float, float, float); + method @Deprecated public void loadRotate(float); + method @Deprecated public void loadScale(float, float); + method @Deprecated public void loadScale(float, float, float); + method @Deprecated public void loadTranslate(float, float); + method @Deprecated public void multiply(android.renderscript.Matrix3f); + method @Deprecated public void rotate(float, float, float, float); + method @Deprecated public void rotate(float); + method @Deprecated public void scale(float, float); + method @Deprecated public void scale(float, float, float); + method @Deprecated public void set(int, int, float); + method @Deprecated public void translate(float, float); + method @Deprecated public void transpose(); + } + + @Deprecated public class Matrix4f { + ctor @Deprecated public Matrix4f(); + ctor @Deprecated public Matrix4f(float[]); + method @Deprecated public float get(int, int); + method @Deprecated public float[] getArray(); + method @Deprecated public boolean inverse(); + method @Deprecated public boolean inverseTranspose(); + method @Deprecated public void load(android.renderscript.Matrix4f); + method @Deprecated public void loadFrustum(float, float, float, float, float, float); + method @Deprecated public void loadIdentity(); + method @Deprecated public void loadMultiply(android.renderscript.Matrix4f, android.renderscript.Matrix4f); + method @Deprecated public void loadOrtho(float, float, float, float, float, float); + method @Deprecated public void loadOrthoWindow(int, int); + method @Deprecated public void loadPerspective(float, float, float, float); + method @Deprecated public void loadProjectionNormalized(int, int); + method @Deprecated public void loadRotate(float, float, float, float); + method @Deprecated public void loadScale(float, float, float); + method @Deprecated public void loadTranslate(float, float, float); + method @Deprecated public void multiply(android.renderscript.Matrix4f); + method @Deprecated public void rotate(float, float, float, float); + method @Deprecated public void scale(float, float, float); + method @Deprecated public void set(int, int, float); + method @Deprecated public void translate(float, float, float); + method @Deprecated public void transpose(); + } + + @Deprecated public class RSDriverException extends android.renderscript.RSRuntimeException { + ctor @Deprecated public RSDriverException(String); + } + + @Deprecated public class RSIllegalArgumentException extends android.renderscript.RSRuntimeException { + ctor @Deprecated public RSIllegalArgumentException(String); + } + + @Deprecated public class RSInvalidStateException extends android.renderscript.RSRuntimeException { + ctor @Deprecated public RSInvalidStateException(String); + } + + @Deprecated public class RSRuntimeException extends java.lang.RuntimeException { + ctor @Deprecated public RSRuntimeException(String); + } + + @Deprecated public class RenderScript { + method @Deprecated public void contextDump(); + method @Deprecated public static android.renderscript.RenderScript create(android.content.Context); + method @Deprecated public static android.renderscript.RenderScript create(android.content.Context, android.renderscript.RenderScript.ContextType); + method @Deprecated public static android.renderscript.RenderScript create(android.content.Context, android.renderscript.RenderScript.ContextType, int); + method @Deprecated public static android.renderscript.RenderScript createMultiContext(android.content.Context, android.renderscript.RenderScript.ContextType, int, int); + method @Deprecated public void destroy(); + method @Deprecated public void finish(); + method @Deprecated public final android.content.Context getApplicationContext(); + method @Deprecated public android.renderscript.RenderScript.RSErrorHandler getErrorHandler(); + method @Deprecated public android.renderscript.RenderScript.RSMessageHandler getMessageHandler(); + method @Deprecated public static long getMinorVersion(); + method @Deprecated public static void releaseAllContexts(); + method @Deprecated public void sendMessage(int, int[]); + method @Deprecated public void setErrorHandler(android.renderscript.RenderScript.RSErrorHandler); + method @Deprecated public void setMessageHandler(android.renderscript.RenderScript.RSMessageHandler); + method @Deprecated public void setPriority(android.renderscript.RenderScript.Priority); + field @Deprecated public static final int CREATE_FLAG_LOW_LATENCY = 2; // 0x2 + field @Deprecated public static final int CREATE_FLAG_LOW_POWER = 4; // 0x4 + field @Deprecated public static final int CREATE_FLAG_NONE = 0; // 0x0 + } + + @Deprecated public enum RenderScript.ContextType { + enum_constant @Deprecated public static final android.renderscript.RenderScript.ContextType DEBUG; + enum_constant @Deprecated public static final android.renderscript.RenderScript.ContextType NORMAL; + enum_constant @Deprecated public static final android.renderscript.RenderScript.ContextType PROFILE; + } + + @Deprecated public enum RenderScript.Priority { + enum_constant @Deprecated public static final android.renderscript.RenderScript.Priority LOW; + enum_constant @Deprecated public static final android.renderscript.RenderScript.Priority NORMAL; + } + + @Deprecated public static class RenderScript.RSErrorHandler implements java.lang.Runnable { + ctor @Deprecated public RenderScript.RSErrorHandler(); + method @Deprecated public void run(); + field @Deprecated protected String mErrorMessage; + field @Deprecated protected int mErrorNum; } - public final class ScriptGroup extends android.renderscript.BaseObj { - method public Object[] execute(java.lang.Object...); + @Deprecated public static class RenderScript.RSMessageHandler implements java.lang.Runnable { + ctor @Deprecated public RenderScript.RSMessageHandler(); + method @Deprecated public void run(); + field @Deprecated protected int[] mData; + field @Deprecated protected int mID; + field @Deprecated protected int mLength; + } + + @Deprecated public class Sampler extends android.renderscript.BaseObj { + method @Deprecated public static android.renderscript.Sampler CLAMP_LINEAR(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Sampler CLAMP_LINEAR_MIP_LINEAR(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Sampler CLAMP_NEAREST(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Sampler MIRRORED_REPEAT_LINEAR(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Sampler MIRRORED_REPEAT_LINEAR_MIP_LINEAR(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Sampler MIRRORED_REPEAT_NEAREST(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Sampler WRAP_LINEAR(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Sampler WRAP_LINEAR_MIP_LINEAR(android.renderscript.RenderScript); + method @Deprecated public static android.renderscript.Sampler WRAP_NEAREST(android.renderscript.RenderScript); + method @Deprecated public float getAnisotropy(); + method @Deprecated public android.renderscript.Sampler.Value getMagnification(); + method @Deprecated public android.renderscript.Sampler.Value getMinification(); + method @Deprecated public android.renderscript.Sampler.Value getWrapS(); + method @Deprecated public android.renderscript.Sampler.Value getWrapT(); + } + + @Deprecated public static class Sampler.Builder { + ctor @Deprecated public Sampler.Builder(android.renderscript.RenderScript); + method @Deprecated public android.renderscript.Sampler create(); + method @Deprecated public void setAnisotropy(float); + method @Deprecated public void setMagnification(android.renderscript.Sampler.Value); + method @Deprecated public void setMinification(android.renderscript.Sampler.Value); + method @Deprecated public void setWrapS(android.renderscript.Sampler.Value); + method @Deprecated public void setWrapT(android.renderscript.Sampler.Value); + } + + @Deprecated public enum Sampler.Value { + enum_constant @Deprecated public static final android.renderscript.Sampler.Value CLAMP; + enum_constant @Deprecated public static final android.renderscript.Sampler.Value LINEAR; + enum_constant @Deprecated public static final android.renderscript.Sampler.Value LINEAR_MIP_LINEAR; + enum_constant @Deprecated public static final android.renderscript.Sampler.Value LINEAR_MIP_NEAREST; + enum_constant @Deprecated public static final android.renderscript.Sampler.Value MIRRORED_REPEAT; + enum_constant @Deprecated public static final android.renderscript.Sampler.Value NEAREST; + enum_constant @Deprecated public static final android.renderscript.Sampler.Value WRAP; + } + + @Deprecated public class Script extends android.renderscript.BaseObj { + method @Deprecated public void bindAllocation(android.renderscript.Allocation, int); + method @Deprecated protected android.renderscript.Script.FieldID createFieldID(int, android.renderscript.Element); + method @Deprecated protected android.renderscript.Script.InvokeID createInvokeID(int); + method @Deprecated protected android.renderscript.Script.KernelID createKernelID(int, int, android.renderscript.Element, android.renderscript.Element); + method @Deprecated protected void forEach(int, android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.FieldPacker); + method @Deprecated protected void forEach(int, android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.FieldPacker, android.renderscript.Script.LaunchOptions); + method @Deprecated protected void forEach(int, android.renderscript.Allocation[], android.renderscript.Allocation, android.renderscript.FieldPacker); + method @Deprecated protected void forEach(int, android.renderscript.Allocation[], android.renderscript.Allocation, android.renderscript.FieldPacker, android.renderscript.Script.LaunchOptions); + method @Deprecated public boolean getVarB(int); + method @Deprecated public double getVarD(int); + method @Deprecated public float getVarF(int); + method @Deprecated public int getVarI(int); + method @Deprecated public long getVarJ(int); + method @Deprecated public void getVarV(int, android.renderscript.FieldPacker); + method @Deprecated protected void invoke(int); + method @Deprecated protected void invoke(int, android.renderscript.FieldPacker); + method @Deprecated protected void reduce(int, android.renderscript.Allocation[], android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); + method @Deprecated public void setTimeZone(String); + method @Deprecated public void setVar(int, float); + method @Deprecated public void setVar(int, double); + method @Deprecated public void setVar(int, int); + method @Deprecated public void setVar(int, long); + method @Deprecated public void setVar(int, boolean); + method @Deprecated public void setVar(int, android.renderscript.BaseObj); + method @Deprecated public void setVar(int, android.renderscript.FieldPacker); + method @Deprecated public void setVar(int, android.renderscript.FieldPacker, android.renderscript.Element, int[]); + } + + @Deprecated public static class Script.Builder { + } + + @Deprecated public static class Script.FieldBase { + ctor @Deprecated protected Script.FieldBase(); + method @Deprecated public android.renderscript.Allocation getAllocation(); + method @Deprecated public android.renderscript.Element getElement(); + method @Deprecated public android.renderscript.Type getType(); + method @Deprecated protected void init(android.renderscript.RenderScript, int); + method @Deprecated protected void init(android.renderscript.RenderScript, int, int); + method @Deprecated public void updateAllocation(); + field @Deprecated protected android.renderscript.Allocation mAllocation; + field @Deprecated protected android.renderscript.Element mElement; + } + + @Deprecated public static final class Script.FieldID extends android.renderscript.BaseObj { + } + + @Deprecated public static final class Script.InvokeID extends android.renderscript.BaseObj { + } + + @Deprecated public static final class Script.KernelID extends android.renderscript.BaseObj { + } + + @Deprecated public static final class Script.LaunchOptions { + ctor @Deprecated public Script.LaunchOptions(); + method @Deprecated public int getXEnd(); + method @Deprecated public int getXStart(); + method @Deprecated public int getYEnd(); + method @Deprecated public int getYStart(); + method @Deprecated public int getZEnd(); + method @Deprecated public int getZStart(); + method @Deprecated public android.renderscript.Script.LaunchOptions setX(int, int); + method @Deprecated public android.renderscript.Script.LaunchOptions setY(int, int); + method @Deprecated public android.renderscript.Script.LaunchOptions setZ(int, int); + } + + @Deprecated public class ScriptC extends android.renderscript.Script { + ctor @Deprecated protected ScriptC(int, android.renderscript.RenderScript); + ctor @Deprecated protected ScriptC(long, android.renderscript.RenderScript); + ctor @Deprecated protected ScriptC(android.renderscript.RenderScript, android.content.res.Resources, int); + ctor @Deprecated protected ScriptC(android.renderscript.RenderScript, String, byte[], byte[]); + } + + @Deprecated public final class ScriptGroup extends android.renderscript.BaseObj { + method @Deprecated public Object[] execute(java.lang.Object...); method @Deprecated public void execute(); method @Deprecated public void setInput(android.renderscript.Script.KernelID, android.renderscript.Allocation); method @Deprecated public void setOutput(android.renderscript.Script.KernelID, android.renderscript.Allocation); } - public static final class ScriptGroup.Binding { - ctor public ScriptGroup.Binding(android.renderscript.Script.FieldID, Object); + @Deprecated public static final class ScriptGroup.Binding { + ctor @Deprecated public ScriptGroup.Binding(android.renderscript.Script.FieldID, Object); } @Deprecated public static final class ScriptGroup.Builder { @@ -36376,336 +36371,336 @@ package android.renderscript { method @Deprecated public android.renderscript.ScriptGroup create(); } - public static final class ScriptGroup.Builder2 { - ctor public ScriptGroup.Builder2(android.renderscript.RenderScript); - method public android.renderscript.ScriptGroup.Input addInput(); - method public android.renderscript.ScriptGroup.Closure addInvoke(android.renderscript.Script.InvokeID, java.lang.Object...); - method public android.renderscript.ScriptGroup.Closure addKernel(android.renderscript.Script.KernelID, android.renderscript.Type, java.lang.Object...); - method public android.renderscript.ScriptGroup create(String, android.renderscript.ScriptGroup.Future...); - } - - public static final class ScriptGroup.Closure extends android.renderscript.BaseObj { - method public android.renderscript.ScriptGroup.Future getGlobal(android.renderscript.Script.FieldID); - method public android.renderscript.ScriptGroup.Future getReturn(); - } - - public static final class ScriptGroup.Future { - } - - public static final class ScriptGroup.Input { - } - - public abstract class ScriptIntrinsic extends android.renderscript.Script { - } - - public final class ScriptIntrinsic3DLUT extends android.renderscript.ScriptIntrinsic { - method public static android.renderscript.ScriptIntrinsic3DLUT create(android.renderscript.RenderScript, android.renderscript.Element); - method public void forEach(android.renderscript.Allocation, android.renderscript.Allocation); - method public void forEach(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); - method public android.renderscript.Script.KernelID getKernelID(); - method public void setLUT(android.renderscript.Allocation); - } - - public final class ScriptIntrinsicBLAS extends android.renderscript.ScriptIntrinsic { - method public void BNNM(android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation, int, int); - method public void CGBMV(int, int, int, android.renderscript.Float2, android.renderscript.Allocation, android.renderscript.Allocation, int, android.renderscript.Float2, android.renderscript.Allocation, int); - method public void CGEMM(int, int, android.renderscript.Float2, android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Float2, android.renderscript.Allocation); - method public void CGEMV(int, android.renderscript.Float2, android.renderscript.Allocation, android.renderscript.Allocation, int, android.renderscript.Float2, android.renderscript.Allocation, int); - method public void CGERC(android.renderscript.Float2, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); - method public void CGERU(android.renderscript.Float2, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); - method public void CHBMV(int, int, android.renderscript.Float2, android.renderscript.Allocation, android.renderscript.Allocation, int, android.renderscript.Float2, android.renderscript.Allocation, int); - method public void CHEMM(int, int, android.renderscript.Float2, android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Float2, android.renderscript.Allocation); - method public void CHEMV(int, android.renderscript.Float2, android.renderscript.Allocation, android.renderscript.Allocation, int, android.renderscript.Float2, android.renderscript.Allocation, int); - method public void CHER(int, float, android.renderscript.Allocation, int, android.renderscript.Allocation); - method public void CHER2(int, android.renderscript.Float2, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); - method public void CHER2K(int, int, android.renderscript.Float2, android.renderscript.Allocation, android.renderscript.Allocation, float, android.renderscript.Allocation); - method public void CHERK(int, int, float, android.renderscript.Allocation, float, android.renderscript.Allocation); - method public void CHPMV(int, android.renderscript.Float2, android.renderscript.Allocation, android.renderscript.Allocation, int, android.renderscript.Float2, android.renderscript.Allocation, int); - method public void CHPR(int, float, android.renderscript.Allocation, int, android.renderscript.Allocation); - method public void CHPR2(int, android.renderscript.Float2, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); - method public void CSYMM(int, int, android.renderscript.Float2, android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Float2, android.renderscript.Allocation); - method public void CSYR2K(int, int, android.renderscript.Float2, android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Float2, android.renderscript.Allocation); - method public void CSYRK(int, int, android.renderscript.Float2, android.renderscript.Allocation, android.renderscript.Float2, android.renderscript.Allocation); - method public void CTBMV(int, int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); - method public void CTBSV(int, int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); - method public void CTPMV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); - method public void CTPSV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); - method public void CTRMM(int, int, int, int, android.renderscript.Float2, android.renderscript.Allocation, android.renderscript.Allocation); - method public void CTRMV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); - method public void CTRSM(int, int, int, int, android.renderscript.Float2, android.renderscript.Allocation, android.renderscript.Allocation); - method public void CTRSV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); - method public void DGBMV(int, int, int, double, android.renderscript.Allocation, android.renderscript.Allocation, int, double, android.renderscript.Allocation, int); - method public void DGEMM(int, int, double, android.renderscript.Allocation, android.renderscript.Allocation, double, android.renderscript.Allocation); - method public void DGEMV(int, double, android.renderscript.Allocation, android.renderscript.Allocation, int, double, android.renderscript.Allocation, int); - method public void DGER(double, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); - method public void DSBMV(int, int, double, android.renderscript.Allocation, android.renderscript.Allocation, int, double, android.renderscript.Allocation, int); - method public void DSPMV(int, double, android.renderscript.Allocation, android.renderscript.Allocation, int, double, android.renderscript.Allocation, int); - method public void DSPR(int, double, android.renderscript.Allocation, int, android.renderscript.Allocation); - method public void DSPR2(int, double, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); - method public void DSYMM(int, int, double, android.renderscript.Allocation, android.renderscript.Allocation, double, android.renderscript.Allocation); - method public void DSYMV(int, double, android.renderscript.Allocation, android.renderscript.Allocation, int, double, android.renderscript.Allocation, int); - method public void DSYR(int, double, android.renderscript.Allocation, int, android.renderscript.Allocation); - method public void DSYR2(int, double, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); - method public void DSYR2K(int, int, double, android.renderscript.Allocation, android.renderscript.Allocation, double, android.renderscript.Allocation); - method public void DSYRK(int, int, double, android.renderscript.Allocation, double, android.renderscript.Allocation); - method public void DTBMV(int, int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); - method public void DTBSV(int, int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); - method public void DTPMV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); - method public void DTPSV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); - method public void DTRMM(int, int, int, int, double, android.renderscript.Allocation, android.renderscript.Allocation); - method public void DTRMV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); - method public void DTRSM(int, int, int, int, double, android.renderscript.Allocation, android.renderscript.Allocation); - method public void DTRSV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); - method public void SGBMV(int, int, int, float, android.renderscript.Allocation, android.renderscript.Allocation, int, float, android.renderscript.Allocation, int); - method public void SGEMM(int, int, float, android.renderscript.Allocation, android.renderscript.Allocation, float, android.renderscript.Allocation); - method public void SGEMV(int, float, android.renderscript.Allocation, android.renderscript.Allocation, int, float, android.renderscript.Allocation, int); - method public void SGER(float, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); - method public void SSBMV(int, int, float, android.renderscript.Allocation, android.renderscript.Allocation, int, float, android.renderscript.Allocation, int); - method public void SSPMV(int, float, android.renderscript.Allocation, android.renderscript.Allocation, int, float, android.renderscript.Allocation, int); - method public void SSPR(int, float, android.renderscript.Allocation, int, android.renderscript.Allocation); - method public void SSPR2(int, float, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); - method public void SSYMM(int, int, float, android.renderscript.Allocation, android.renderscript.Allocation, float, android.renderscript.Allocation); - method public void SSYMV(int, float, android.renderscript.Allocation, android.renderscript.Allocation, int, float, android.renderscript.Allocation, int); - method public void SSYR(int, float, android.renderscript.Allocation, int, android.renderscript.Allocation); - method public void SSYR2(int, float, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); - method public void SSYR2K(int, int, float, android.renderscript.Allocation, android.renderscript.Allocation, float, android.renderscript.Allocation); - method public void SSYRK(int, int, float, android.renderscript.Allocation, float, android.renderscript.Allocation); - method public void STBMV(int, int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); - method public void STBSV(int, int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); - method public void STPMV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); - method public void STPSV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); - method public void STRMM(int, int, int, int, float, android.renderscript.Allocation, android.renderscript.Allocation); - method public void STRMV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); - method public void STRSM(int, int, int, int, float, android.renderscript.Allocation, android.renderscript.Allocation); - method public void STRSV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); - method public void ZGBMV(int, int, int, android.renderscript.Double2, android.renderscript.Allocation, android.renderscript.Allocation, int, android.renderscript.Double2, android.renderscript.Allocation, int); - method public void ZGEMM(int, int, android.renderscript.Double2, android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Double2, android.renderscript.Allocation); - method public void ZGEMV(int, android.renderscript.Double2, android.renderscript.Allocation, android.renderscript.Allocation, int, android.renderscript.Double2, android.renderscript.Allocation, int); - method public void ZGERC(android.renderscript.Double2, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); - method public void ZGERU(android.renderscript.Double2, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); - method public void ZHBMV(int, int, android.renderscript.Double2, android.renderscript.Allocation, android.renderscript.Allocation, int, android.renderscript.Double2, android.renderscript.Allocation, int); - method public void ZHEMM(int, int, android.renderscript.Double2, android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Double2, android.renderscript.Allocation); - method public void ZHEMV(int, android.renderscript.Double2, android.renderscript.Allocation, android.renderscript.Allocation, int, android.renderscript.Double2, android.renderscript.Allocation, int); - method public void ZHER(int, double, android.renderscript.Allocation, int, android.renderscript.Allocation); - method public void ZHER2(int, android.renderscript.Double2, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); - method public void ZHER2K(int, int, android.renderscript.Double2, android.renderscript.Allocation, android.renderscript.Allocation, double, android.renderscript.Allocation); - method public void ZHERK(int, int, double, android.renderscript.Allocation, double, android.renderscript.Allocation); - method public void ZHPMV(int, android.renderscript.Double2, android.renderscript.Allocation, android.renderscript.Allocation, int, android.renderscript.Double2, android.renderscript.Allocation, int); - method public void ZHPR(int, double, android.renderscript.Allocation, int, android.renderscript.Allocation); - method public void ZHPR2(int, android.renderscript.Double2, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); - method public void ZSYMM(int, int, android.renderscript.Double2, android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Double2, android.renderscript.Allocation); - method public void ZSYR2K(int, int, android.renderscript.Double2, android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Double2, android.renderscript.Allocation); - method public void ZSYRK(int, int, android.renderscript.Double2, android.renderscript.Allocation, android.renderscript.Double2, android.renderscript.Allocation); - method public void ZTBMV(int, int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); - method public void ZTBSV(int, int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); - method public void ZTPMV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); - method public void ZTPSV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); - method public void ZTRMM(int, int, int, int, android.renderscript.Double2, android.renderscript.Allocation, android.renderscript.Allocation); - method public void ZTRMV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); - method public void ZTRSM(int, int, int, int, android.renderscript.Double2, android.renderscript.Allocation, android.renderscript.Allocation); - method public void ZTRSV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); - method public static android.renderscript.ScriptIntrinsicBLAS create(android.renderscript.RenderScript); - field public static final int CONJ_TRANSPOSE = 113; // 0x71 - field public static final int LEFT = 141; // 0x8d - field public static final int LOWER = 122; // 0x7a - field public static final int NON_UNIT = 131; // 0x83 - field public static final int NO_TRANSPOSE = 111; // 0x6f - field public static final int RIGHT = 142; // 0x8e - field public static final int TRANSPOSE = 112; // 0x70 - field public static final int UNIT = 132; // 0x84 - field public static final int UPPER = 121; // 0x79 - } - - public class ScriptIntrinsicBlend extends android.renderscript.ScriptIntrinsic { - method public static android.renderscript.ScriptIntrinsicBlend create(android.renderscript.RenderScript, android.renderscript.Element); - method public void forEachAdd(android.renderscript.Allocation, android.renderscript.Allocation); - method public void forEachAdd(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); - method public void forEachClear(android.renderscript.Allocation, android.renderscript.Allocation); - method public void forEachClear(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); - method public void forEachDst(android.renderscript.Allocation, android.renderscript.Allocation); - method public void forEachDst(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); - method public void forEachDstAtop(android.renderscript.Allocation, android.renderscript.Allocation); - method public void forEachDstAtop(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); - method public void forEachDstIn(android.renderscript.Allocation, android.renderscript.Allocation); - method public void forEachDstIn(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); - method public void forEachDstOut(android.renderscript.Allocation, android.renderscript.Allocation); - method public void forEachDstOut(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); - method public void forEachDstOver(android.renderscript.Allocation, android.renderscript.Allocation); - method public void forEachDstOver(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); - method public void forEachMultiply(android.renderscript.Allocation, android.renderscript.Allocation); - method public void forEachMultiply(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); - method public void forEachSrc(android.renderscript.Allocation, android.renderscript.Allocation); - method public void forEachSrc(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); - method public void forEachSrcAtop(android.renderscript.Allocation, android.renderscript.Allocation); - method public void forEachSrcAtop(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); - method public void forEachSrcIn(android.renderscript.Allocation, android.renderscript.Allocation); - method public void forEachSrcIn(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); - method public void forEachSrcOut(android.renderscript.Allocation, android.renderscript.Allocation); - method public void forEachSrcOut(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); - method public void forEachSrcOver(android.renderscript.Allocation, android.renderscript.Allocation); - method public void forEachSrcOver(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); - method public void forEachSubtract(android.renderscript.Allocation, android.renderscript.Allocation); - method public void forEachSubtract(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); - method public void forEachXor(android.renderscript.Allocation, android.renderscript.Allocation); - method public void forEachXor(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); - method public android.renderscript.Script.KernelID getKernelIDAdd(); - method public android.renderscript.Script.KernelID getKernelIDClear(); - method public android.renderscript.Script.KernelID getKernelIDDst(); - method public android.renderscript.Script.KernelID getKernelIDDstAtop(); - method public android.renderscript.Script.KernelID getKernelIDDstIn(); - method public android.renderscript.Script.KernelID getKernelIDDstOut(); - method public android.renderscript.Script.KernelID getKernelIDDstOver(); - method public android.renderscript.Script.KernelID getKernelIDMultiply(); - method public android.renderscript.Script.KernelID getKernelIDSrc(); - method public android.renderscript.Script.KernelID getKernelIDSrcAtop(); - method public android.renderscript.Script.KernelID getKernelIDSrcIn(); - method public android.renderscript.Script.KernelID getKernelIDSrcOut(); - method public android.renderscript.Script.KernelID getKernelIDSrcOver(); - method public android.renderscript.Script.KernelID getKernelIDSubtract(); - method public android.renderscript.Script.KernelID getKernelIDXor(); - } - - public final class ScriptIntrinsicBlur extends android.renderscript.ScriptIntrinsic { - method public static android.renderscript.ScriptIntrinsicBlur create(android.renderscript.RenderScript, android.renderscript.Element); - method public void forEach(android.renderscript.Allocation); - method public void forEach(android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); - method public android.renderscript.Script.FieldID getFieldID_Input(); - method public android.renderscript.Script.KernelID getKernelID(); - method public void setInput(android.renderscript.Allocation); - method public void setRadius(float); - } - - public final class ScriptIntrinsicColorMatrix extends android.renderscript.ScriptIntrinsic { + @Deprecated public static final class ScriptGroup.Builder2 { + ctor @Deprecated public ScriptGroup.Builder2(android.renderscript.RenderScript); + method @Deprecated public android.renderscript.ScriptGroup.Input addInput(); + method @Deprecated public android.renderscript.ScriptGroup.Closure addInvoke(android.renderscript.Script.InvokeID, java.lang.Object...); + method @Deprecated public android.renderscript.ScriptGroup.Closure addKernel(android.renderscript.Script.KernelID, android.renderscript.Type, java.lang.Object...); + method @Deprecated public android.renderscript.ScriptGroup create(String, android.renderscript.ScriptGroup.Future...); + } + + @Deprecated public static final class ScriptGroup.Closure extends android.renderscript.BaseObj { + method @Deprecated public android.renderscript.ScriptGroup.Future getGlobal(android.renderscript.Script.FieldID); + method @Deprecated public android.renderscript.ScriptGroup.Future getReturn(); + } + + @Deprecated public static final class ScriptGroup.Future { + } + + @Deprecated public static final class ScriptGroup.Input { + } + + @Deprecated public abstract class ScriptIntrinsic extends android.renderscript.Script { + } + + @Deprecated public final class ScriptIntrinsic3DLUT extends android.renderscript.ScriptIntrinsic { + method @Deprecated public static android.renderscript.ScriptIntrinsic3DLUT create(android.renderscript.RenderScript, android.renderscript.Element); + method @Deprecated public void forEach(android.renderscript.Allocation, android.renderscript.Allocation); + method @Deprecated public void forEach(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); + method @Deprecated public android.renderscript.Script.KernelID getKernelID(); + method @Deprecated public void setLUT(android.renderscript.Allocation); + } + + @Deprecated public final class ScriptIntrinsicBLAS extends android.renderscript.ScriptIntrinsic { + method @Deprecated public void BNNM(android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation, int, int); + method @Deprecated public void CGBMV(int, int, int, android.renderscript.Float2, android.renderscript.Allocation, android.renderscript.Allocation, int, android.renderscript.Float2, android.renderscript.Allocation, int); + method @Deprecated public void CGEMM(int, int, android.renderscript.Float2, android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Float2, android.renderscript.Allocation); + method @Deprecated public void CGEMV(int, android.renderscript.Float2, android.renderscript.Allocation, android.renderscript.Allocation, int, android.renderscript.Float2, android.renderscript.Allocation, int); + method @Deprecated public void CGERC(android.renderscript.Float2, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); + method @Deprecated public void CGERU(android.renderscript.Float2, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); + method @Deprecated public void CHBMV(int, int, android.renderscript.Float2, android.renderscript.Allocation, android.renderscript.Allocation, int, android.renderscript.Float2, android.renderscript.Allocation, int); + method @Deprecated public void CHEMM(int, int, android.renderscript.Float2, android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Float2, android.renderscript.Allocation); + method @Deprecated public void CHEMV(int, android.renderscript.Float2, android.renderscript.Allocation, android.renderscript.Allocation, int, android.renderscript.Float2, android.renderscript.Allocation, int); + method @Deprecated public void CHER(int, float, android.renderscript.Allocation, int, android.renderscript.Allocation); + method @Deprecated public void CHER2(int, android.renderscript.Float2, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); + method @Deprecated public void CHER2K(int, int, android.renderscript.Float2, android.renderscript.Allocation, android.renderscript.Allocation, float, android.renderscript.Allocation); + method @Deprecated public void CHERK(int, int, float, android.renderscript.Allocation, float, android.renderscript.Allocation); + method @Deprecated public void CHPMV(int, android.renderscript.Float2, android.renderscript.Allocation, android.renderscript.Allocation, int, android.renderscript.Float2, android.renderscript.Allocation, int); + method @Deprecated public void CHPR(int, float, android.renderscript.Allocation, int, android.renderscript.Allocation); + method @Deprecated public void CHPR2(int, android.renderscript.Float2, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); + method @Deprecated public void CSYMM(int, int, android.renderscript.Float2, android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Float2, android.renderscript.Allocation); + method @Deprecated public void CSYR2K(int, int, android.renderscript.Float2, android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Float2, android.renderscript.Allocation); + method @Deprecated public void CSYRK(int, int, android.renderscript.Float2, android.renderscript.Allocation, android.renderscript.Float2, android.renderscript.Allocation); + method @Deprecated public void CTBMV(int, int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); + method @Deprecated public void CTBSV(int, int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); + method @Deprecated public void CTPMV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); + method @Deprecated public void CTPSV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); + method @Deprecated public void CTRMM(int, int, int, int, android.renderscript.Float2, android.renderscript.Allocation, android.renderscript.Allocation); + method @Deprecated public void CTRMV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); + method @Deprecated public void CTRSM(int, int, int, int, android.renderscript.Float2, android.renderscript.Allocation, android.renderscript.Allocation); + method @Deprecated public void CTRSV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); + method @Deprecated public void DGBMV(int, int, int, double, android.renderscript.Allocation, android.renderscript.Allocation, int, double, android.renderscript.Allocation, int); + method @Deprecated public void DGEMM(int, int, double, android.renderscript.Allocation, android.renderscript.Allocation, double, android.renderscript.Allocation); + method @Deprecated public void DGEMV(int, double, android.renderscript.Allocation, android.renderscript.Allocation, int, double, android.renderscript.Allocation, int); + method @Deprecated public void DGER(double, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); + method @Deprecated public void DSBMV(int, int, double, android.renderscript.Allocation, android.renderscript.Allocation, int, double, android.renderscript.Allocation, int); + method @Deprecated public void DSPMV(int, double, android.renderscript.Allocation, android.renderscript.Allocation, int, double, android.renderscript.Allocation, int); + method @Deprecated public void DSPR(int, double, android.renderscript.Allocation, int, android.renderscript.Allocation); + method @Deprecated public void DSPR2(int, double, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); + method @Deprecated public void DSYMM(int, int, double, android.renderscript.Allocation, android.renderscript.Allocation, double, android.renderscript.Allocation); + method @Deprecated public void DSYMV(int, double, android.renderscript.Allocation, android.renderscript.Allocation, int, double, android.renderscript.Allocation, int); + method @Deprecated public void DSYR(int, double, android.renderscript.Allocation, int, android.renderscript.Allocation); + method @Deprecated public void DSYR2(int, double, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); + method @Deprecated public void DSYR2K(int, int, double, android.renderscript.Allocation, android.renderscript.Allocation, double, android.renderscript.Allocation); + method @Deprecated public void DSYRK(int, int, double, android.renderscript.Allocation, double, android.renderscript.Allocation); + method @Deprecated public void DTBMV(int, int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); + method @Deprecated public void DTBSV(int, int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); + method @Deprecated public void DTPMV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); + method @Deprecated public void DTPSV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); + method @Deprecated public void DTRMM(int, int, int, int, double, android.renderscript.Allocation, android.renderscript.Allocation); + method @Deprecated public void DTRMV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); + method @Deprecated public void DTRSM(int, int, int, int, double, android.renderscript.Allocation, android.renderscript.Allocation); + method @Deprecated public void DTRSV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); + method @Deprecated public void SGBMV(int, int, int, float, android.renderscript.Allocation, android.renderscript.Allocation, int, float, android.renderscript.Allocation, int); + method @Deprecated public void SGEMM(int, int, float, android.renderscript.Allocation, android.renderscript.Allocation, float, android.renderscript.Allocation); + method @Deprecated public void SGEMV(int, float, android.renderscript.Allocation, android.renderscript.Allocation, int, float, android.renderscript.Allocation, int); + method @Deprecated public void SGER(float, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); + method @Deprecated public void SSBMV(int, int, float, android.renderscript.Allocation, android.renderscript.Allocation, int, float, android.renderscript.Allocation, int); + method @Deprecated public void SSPMV(int, float, android.renderscript.Allocation, android.renderscript.Allocation, int, float, android.renderscript.Allocation, int); + method @Deprecated public void SSPR(int, float, android.renderscript.Allocation, int, android.renderscript.Allocation); + method @Deprecated public void SSPR2(int, float, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); + method @Deprecated public void SSYMM(int, int, float, android.renderscript.Allocation, android.renderscript.Allocation, float, android.renderscript.Allocation); + method @Deprecated public void SSYMV(int, float, android.renderscript.Allocation, android.renderscript.Allocation, int, float, android.renderscript.Allocation, int); + method @Deprecated public void SSYR(int, float, android.renderscript.Allocation, int, android.renderscript.Allocation); + method @Deprecated public void SSYR2(int, float, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); + method @Deprecated public void SSYR2K(int, int, float, android.renderscript.Allocation, android.renderscript.Allocation, float, android.renderscript.Allocation); + method @Deprecated public void SSYRK(int, int, float, android.renderscript.Allocation, float, android.renderscript.Allocation); + method @Deprecated public void STBMV(int, int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); + method @Deprecated public void STBSV(int, int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); + method @Deprecated public void STPMV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); + method @Deprecated public void STPSV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); + method @Deprecated public void STRMM(int, int, int, int, float, android.renderscript.Allocation, android.renderscript.Allocation); + method @Deprecated public void STRMV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); + method @Deprecated public void STRSM(int, int, int, int, float, android.renderscript.Allocation, android.renderscript.Allocation); + method @Deprecated public void STRSV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); + method @Deprecated public void ZGBMV(int, int, int, android.renderscript.Double2, android.renderscript.Allocation, android.renderscript.Allocation, int, android.renderscript.Double2, android.renderscript.Allocation, int); + method @Deprecated public void ZGEMM(int, int, android.renderscript.Double2, android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Double2, android.renderscript.Allocation); + method @Deprecated public void ZGEMV(int, android.renderscript.Double2, android.renderscript.Allocation, android.renderscript.Allocation, int, android.renderscript.Double2, android.renderscript.Allocation, int); + method @Deprecated public void ZGERC(android.renderscript.Double2, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); + method @Deprecated public void ZGERU(android.renderscript.Double2, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); + method @Deprecated public void ZHBMV(int, int, android.renderscript.Double2, android.renderscript.Allocation, android.renderscript.Allocation, int, android.renderscript.Double2, android.renderscript.Allocation, int); + method @Deprecated public void ZHEMM(int, int, android.renderscript.Double2, android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Double2, android.renderscript.Allocation); + method @Deprecated public void ZHEMV(int, android.renderscript.Double2, android.renderscript.Allocation, android.renderscript.Allocation, int, android.renderscript.Double2, android.renderscript.Allocation, int); + method @Deprecated public void ZHER(int, double, android.renderscript.Allocation, int, android.renderscript.Allocation); + method @Deprecated public void ZHER2(int, android.renderscript.Double2, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); + method @Deprecated public void ZHER2K(int, int, android.renderscript.Double2, android.renderscript.Allocation, android.renderscript.Allocation, double, android.renderscript.Allocation); + method @Deprecated public void ZHERK(int, int, double, android.renderscript.Allocation, double, android.renderscript.Allocation); + method @Deprecated public void ZHPMV(int, android.renderscript.Double2, android.renderscript.Allocation, android.renderscript.Allocation, int, android.renderscript.Double2, android.renderscript.Allocation, int); + method @Deprecated public void ZHPR(int, double, android.renderscript.Allocation, int, android.renderscript.Allocation); + method @Deprecated public void ZHPR2(int, android.renderscript.Double2, android.renderscript.Allocation, int, android.renderscript.Allocation, int, android.renderscript.Allocation); + method @Deprecated public void ZSYMM(int, int, android.renderscript.Double2, android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Double2, android.renderscript.Allocation); + method @Deprecated public void ZSYR2K(int, int, android.renderscript.Double2, android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Double2, android.renderscript.Allocation); + method @Deprecated public void ZSYRK(int, int, android.renderscript.Double2, android.renderscript.Allocation, android.renderscript.Double2, android.renderscript.Allocation); + method @Deprecated public void ZTBMV(int, int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); + method @Deprecated public void ZTBSV(int, int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); + method @Deprecated public void ZTPMV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); + method @Deprecated public void ZTPSV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); + method @Deprecated public void ZTRMM(int, int, int, int, android.renderscript.Double2, android.renderscript.Allocation, android.renderscript.Allocation); + method @Deprecated public void ZTRMV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); + method @Deprecated public void ZTRSM(int, int, int, int, android.renderscript.Double2, android.renderscript.Allocation, android.renderscript.Allocation); + method @Deprecated public void ZTRSV(int, int, int, android.renderscript.Allocation, android.renderscript.Allocation, int); + method @Deprecated public static android.renderscript.ScriptIntrinsicBLAS create(android.renderscript.RenderScript); + field @Deprecated public static final int CONJ_TRANSPOSE = 113; // 0x71 + field @Deprecated public static final int LEFT = 141; // 0x8d + field @Deprecated public static final int LOWER = 122; // 0x7a + field @Deprecated public static final int NON_UNIT = 131; // 0x83 + field @Deprecated public static final int NO_TRANSPOSE = 111; // 0x6f + field @Deprecated public static final int RIGHT = 142; // 0x8e + field @Deprecated public static final int TRANSPOSE = 112; // 0x70 + field @Deprecated public static final int UNIT = 132; // 0x84 + field @Deprecated public static final int UPPER = 121; // 0x79 + } + + @Deprecated public class ScriptIntrinsicBlend extends android.renderscript.ScriptIntrinsic { + method @Deprecated public static android.renderscript.ScriptIntrinsicBlend create(android.renderscript.RenderScript, android.renderscript.Element); + method @Deprecated public void forEachAdd(android.renderscript.Allocation, android.renderscript.Allocation); + method @Deprecated public void forEachAdd(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); + method @Deprecated public void forEachClear(android.renderscript.Allocation, android.renderscript.Allocation); + method @Deprecated public void forEachClear(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); + method @Deprecated public void forEachDst(android.renderscript.Allocation, android.renderscript.Allocation); + method @Deprecated public void forEachDst(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); + method @Deprecated public void forEachDstAtop(android.renderscript.Allocation, android.renderscript.Allocation); + method @Deprecated public void forEachDstAtop(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); + method @Deprecated public void forEachDstIn(android.renderscript.Allocation, android.renderscript.Allocation); + method @Deprecated public void forEachDstIn(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); + method @Deprecated public void forEachDstOut(android.renderscript.Allocation, android.renderscript.Allocation); + method @Deprecated public void forEachDstOut(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); + method @Deprecated public void forEachDstOver(android.renderscript.Allocation, android.renderscript.Allocation); + method @Deprecated public void forEachDstOver(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); + method @Deprecated public void forEachMultiply(android.renderscript.Allocation, android.renderscript.Allocation); + method @Deprecated public void forEachMultiply(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); + method @Deprecated public void forEachSrc(android.renderscript.Allocation, android.renderscript.Allocation); + method @Deprecated public void forEachSrc(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); + method @Deprecated public void forEachSrcAtop(android.renderscript.Allocation, android.renderscript.Allocation); + method @Deprecated public void forEachSrcAtop(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); + method @Deprecated public void forEachSrcIn(android.renderscript.Allocation, android.renderscript.Allocation); + method @Deprecated public void forEachSrcIn(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); + method @Deprecated public void forEachSrcOut(android.renderscript.Allocation, android.renderscript.Allocation); + method @Deprecated public void forEachSrcOut(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); + method @Deprecated public void forEachSrcOver(android.renderscript.Allocation, android.renderscript.Allocation); + method @Deprecated public void forEachSrcOver(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); + method @Deprecated public void forEachSubtract(android.renderscript.Allocation, android.renderscript.Allocation); + method @Deprecated public void forEachSubtract(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); + method @Deprecated public void forEachXor(android.renderscript.Allocation, android.renderscript.Allocation); + method @Deprecated public void forEachXor(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); + method @Deprecated public android.renderscript.Script.KernelID getKernelIDAdd(); + method @Deprecated public android.renderscript.Script.KernelID getKernelIDClear(); + method @Deprecated public android.renderscript.Script.KernelID getKernelIDDst(); + method @Deprecated public android.renderscript.Script.KernelID getKernelIDDstAtop(); + method @Deprecated public android.renderscript.Script.KernelID getKernelIDDstIn(); + method @Deprecated public android.renderscript.Script.KernelID getKernelIDDstOut(); + method @Deprecated public android.renderscript.Script.KernelID getKernelIDDstOver(); + method @Deprecated public android.renderscript.Script.KernelID getKernelIDMultiply(); + method @Deprecated public android.renderscript.Script.KernelID getKernelIDSrc(); + method @Deprecated public android.renderscript.Script.KernelID getKernelIDSrcAtop(); + method @Deprecated public android.renderscript.Script.KernelID getKernelIDSrcIn(); + method @Deprecated public android.renderscript.Script.KernelID getKernelIDSrcOut(); + method @Deprecated public android.renderscript.Script.KernelID getKernelIDSrcOver(); + method @Deprecated public android.renderscript.Script.KernelID getKernelIDSubtract(); + method @Deprecated public android.renderscript.Script.KernelID getKernelIDXor(); + } + + @Deprecated public final class ScriptIntrinsicBlur extends android.renderscript.ScriptIntrinsic { + method @Deprecated public static android.renderscript.ScriptIntrinsicBlur create(android.renderscript.RenderScript, android.renderscript.Element); + method @Deprecated public void forEach(android.renderscript.Allocation); + method @Deprecated public void forEach(android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); + method @Deprecated public android.renderscript.Script.FieldID getFieldID_Input(); + method @Deprecated public android.renderscript.Script.KernelID getKernelID(); + method @Deprecated public void setInput(android.renderscript.Allocation); + method @Deprecated public void setRadius(float); + } + + @Deprecated public final class ScriptIntrinsicColorMatrix extends android.renderscript.ScriptIntrinsic { method @Deprecated public static android.renderscript.ScriptIntrinsicColorMatrix create(android.renderscript.RenderScript, android.renderscript.Element); - method public static android.renderscript.ScriptIntrinsicColorMatrix create(android.renderscript.RenderScript); - method public void forEach(android.renderscript.Allocation, android.renderscript.Allocation); - method public void forEach(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); - method public android.renderscript.Script.KernelID getKernelID(); - method public void setAdd(android.renderscript.Float4); - method public void setAdd(float, float, float, float); - method public void setColorMatrix(android.renderscript.Matrix4f); - method public void setColorMatrix(android.renderscript.Matrix3f); - method public void setGreyscale(); - method public void setRGBtoYUV(); - method public void setYUVtoRGB(); - } - - public final class ScriptIntrinsicConvolve3x3 extends android.renderscript.ScriptIntrinsic { - method public static android.renderscript.ScriptIntrinsicConvolve3x3 create(android.renderscript.RenderScript, android.renderscript.Element); - method public void forEach(android.renderscript.Allocation); - method public void forEach(android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); - method public android.renderscript.Script.FieldID getFieldID_Input(); - method public android.renderscript.Script.KernelID getKernelID(); - method public void setCoefficients(float[]); - method public void setInput(android.renderscript.Allocation); - } - - public final class ScriptIntrinsicConvolve5x5 extends android.renderscript.ScriptIntrinsic { - method public static android.renderscript.ScriptIntrinsicConvolve5x5 create(android.renderscript.RenderScript, android.renderscript.Element); - method public void forEach(android.renderscript.Allocation); - method public void forEach(android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); - method public android.renderscript.Script.FieldID getFieldID_Input(); - method public android.renderscript.Script.KernelID getKernelID(); - method public void setCoefficients(float[]); - method public void setInput(android.renderscript.Allocation); - } - - public final class ScriptIntrinsicHistogram extends android.renderscript.ScriptIntrinsic { - method public static android.renderscript.ScriptIntrinsicHistogram create(android.renderscript.RenderScript, android.renderscript.Element); - method public void forEach(android.renderscript.Allocation); - method public void forEach(android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); - method public void forEach_Dot(android.renderscript.Allocation); - method public void forEach_Dot(android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); - method public android.renderscript.Script.FieldID getFieldID_Input(); - method public android.renderscript.Script.KernelID getKernelID_Separate(); - method public void setDotCoefficients(float, float, float, float); - method public void setOutput(android.renderscript.Allocation); - } - - public final class ScriptIntrinsicLUT extends android.renderscript.ScriptIntrinsic { - method public static android.renderscript.ScriptIntrinsicLUT create(android.renderscript.RenderScript, android.renderscript.Element); - method public void forEach(android.renderscript.Allocation, android.renderscript.Allocation); - method public void forEach(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); - method public android.renderscript.Script.KernelID getKernelID(); - method public void setAlpha(int, int); - method public void setBlue(int, int); - method public void setGreen(int, int); - method public void setRed(int, int); - } - - public final class ScriptIntrinsicResize extends android.renderscript.ScriptIntrinsic { - method public static android.renderscript.ScriptIntrinsicResize create(android.renderscript.RenderScript); - method public void forEach_bicubic(android.renderscript.Allocation); - method public void forEach_bicubic(android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); - method public android.renderscript.Script.FieldID getFieldID_Input(); - method public android.renderscript.Script.KernelID getKernelID_bicubic(); - method public void setInput(android.renderscript.Allocation); - } - - public final class ScriptIntrinsicYuvToRGB extends android.renderscript.ScriptIntrinsic { - method public static android.renderscript.ScriptIntrinsicYuvToRGB create(android.renderscript.RenderScript, android.renderscript.Element); - method public void forEach(android.renderscript.Allocation); - method public android.renderscript.Script.FieldID getFieldID_Input(); - method public android.renderscript.Script.KernelID getKernelID(); - method public void setInput(android.renderscript.Allocation); - } - - public class Short2 { - ctor public Short2(); - ctor public Short2(short, short); - field public short x; - field public short y; - } - - public class Short3 { - ctor public Short3(); - ctor public Short3(short, short, short); - field public short x; - field public short y; - field public short z; - } - - public class Short4 { - ctor public Short4(); - ctor public Short4(short, short, short, short); - field public short w; - field public short x; - field public short y; - field public short z; - } - - public class Type extends android.renderscript.BaseObj { - method public static android.renderscript.Type createX(android.renderscript.RenderScript, android.renderscript.Element, int); - method public static android.renderscript.Type createXY(android.renderscript.RenderScript, android.renderscript.Element, int, int); - method public static android.renderscript.Type createXYZ(android.renderscript.RenderScript, android.renderscript.Element, int, int, int); - method public int getCount(); - method public android.renderscript.Element getElement(); - method public int getX(); - method public int getY(); - method public int getYuv(); - method public int getZ(); - method public boolean hasFaces(); - method public boolean hasMipmaps(); - } - - public static class Type.Builder { - ctor public Type.Builder(android.renderscript.RenderScript, android.renderscript.Element); - method public android.renderscript.Type create(); - method public android.renderscript.Type.Builder setFaces(boolean); - method public android.renderscript.Type.Builder setMipmaps(boolean); - method public android.renderscript.Type.Builder setX(int); - method public android.renderscript.Type.Builder setY(int); - method public android.renderscript.Type.Builder setYuvFormat(int); - method public android.renderscript.Type.Builder setZ(int); - } - - public enum Type.CubemapFace { - enum_constant public static final android.renderscript.Type.CubemapFace NEGATIVE_X; - enum_constant public static final android.renderscript.Type.CubemapFace NEGATIVE_Y; - enum_constant public static final android.renderscript.Type.CubemapFace NEGATIVE_Z; - enum_constant public static final android.renderscript.Type.CubemapFace POSITIVE_X; - enum_constant public static final android.renderscript.Type.CubemapFace POSITIVE_Y; - enum_constant public static final android.renderscript.Type.CubemapFace POSITIVE_Z; + method @Deprecated public static android.renderscript.ScriptIntrinsicColorMatrix create(android.renderscript.RenderScript); + method @Deprecated public void forEach(android.renderscript.Allocation, android.renderscript.Allocation); + method @Deprecated public void forEach(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); + method @Deprecated public android.renderscript.Script.KernelID getKernelID(); + method @Deprecated public void setAdd(android.renderscript.Float4); + method @Deprecated public void setAdd(float, float, float, float); + method @Deprecated public void setColorMatrix(android.renderscript.Matrix4f); + method @Deprecated public void setColorMatrix(android.renderscript.Matrix3f); + method @Deprecated public void setGreyscale(); + method @Deprecated public void setRGBtoYUV(); + method @Deprecated public void setYUVtoRGB(); + } + + @Deprecated public final class ScriptIntrinsicConvolve3x3 extends android.renderscript.ScriptIntrinsic { + method @Deprecated public static android.renderscript.ScriptIntrinsicConvolve3x3 create(android.renderscript.RenderScript, android.renderscript.Element); + method @Deprecated public void forEach(android.renderscript.Allocation); + method @Deprecated public void forEach(android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); + method @Deprecated public android.renderscript.Script.FieldID getFieldID_Input(); + method @Deprecated public android.renderscript.Script.KernelID getKernelID(); + method @Deprecated public void setCoefficients(float[]); + method @Deprecated public void setInput(android.renderscript.Allocation); + } + + @Deprecated public final class ScriptIntrinsicConvolve5x5 extends android.renderscript.ScriptIntrinsic { + method @Deprecated public static android.renderscript.ScriptIntrinsicConvolve5x5 create(android.renderscript.RenderScript, android.renderscript.Element); + method @Deprecated public void forEach(android.renderscript.Allocation); + method @Deprecated public void forEach(android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); + method @Deprecated public android.renderscript.Script.FieldID getFieldID_Input(); + method @Deprecated public android.renderscript.Script.KernelID getKernelID(); + method @Deprecated public void setCoefficients(float[]); + method @Deprecated public void setInput(android.renderscript.Allocation); + } + + @Deprecated public final class ScriptIntrinsicHistogram extends android.renderscript.ScriptIntrinsic { + method @Deprecated public static android.renderscript.ScriptIntrinsicHistogram create(android.renderscript.RenderScript, android.renderscript.Element); + method @Deprecated public void forEach(android.renderscript.Allocation); + method @Deprecated public void forEach(android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); + method @Deprecated public void forEach_Dot(android.renderscript.Allocation); + method @Deprecated public void forEach_Dot(android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); + method @Deprecated public android.renderscript.Script.FieldID getFieldID_Input(); + method @Deprecated public android.renderscript.Script.KernelID getKernelID_Separate(); + method @Deprecated public void setDotCoefficients(float, float, float, float); + method @Deprecated public void setOutput(android.renderscript.Allocation); + } + + @Deprecated public final class ScriptIntrinsicLUT extends android.renderscript.ScriptIntrinsic { + method @Deprecated public static android.renderscript.ScriptIntrinsicLUT create(android.renderscript.RenderScript, android.renderscript.Element); + method @Deprecated public void forEach(android.renderscript.Allocation, android.renderscript.Allocation); + method @Deprecated public void forEach(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); + method @Deprecated public android.renderscript.Script.KernelID getKernelID(); + method @Deprecated public void setAlpha(int, int); + method @Deprecated public void setBlue(int, int); + method @Deprecated public void setGreen(int, int); + method @Deprecated public void setRed(int, int); + } + + @Deprecated public final class ScriptIntrinsicResize extends android.renderscript.ScriptIntrinsic { + method @Deprecated public static android.renderscript.ScriptIntrinsicResize create(android.renderscript.RenderScript); + method @Deprecated public void forEach_bicubic(android.renderscript.Allocation); + method @Deprecated public void forEach_bicubic(android.renderscript.Allocation, android.renderscript.Script.LaunchOptions); + method @Deprecated public android.renderscript.Script.FieldID getFieldID_Input(); + method @Deprecated public android.renderscript.Script.KernelID getKernelID_bicubic(); + method @Deprecated public void setInput(android.renderscript.Allocation); + } + + @Deprecated public final class ScriptIntrinsicYuvToRGB extends android.renderscript.ScriptIntrinsic { + method @Deprecated public static android.renderscript.ScriptIntrinsicYuvToRGB create(android.renderscript.RenderScript, android.renderscript.Element); + method @Deprecated public void forEach(android.renderscript.Allocation); + method @Deprecated public android.renderscript.Script.FieldID getFieldID_Input(); + method @Deprecated public android.renderscript.Script.KernelID getKernelID(); + method @Deprecated public void setInput(android.renderscript.Allocation); + } + + @Deprecated public class Short2 { + ctor @Deprecated public Short2(); + ctor @Deprecated public Short2(short, short); + field @Deprecated public short x; + field @Deprecated public short y; + } + + @Deprecated public class Short3 { + ctor @Deprecated public Short3(); + ctor @Deprecated public Short3(short, short, short); + field @Deprecated public short x; + field @Deprecated public short y; + field @Deprecated public short z; + } + + @Deprecated public class Short4 { + ctor @Deprecated public Short4(); + ctor @Deprecated public Short4(short, short, short, short); + field @Deprecated public short w; + field @Deprecated public short x; + field @Deprecated public short y; + field @Deprecated public short z; + } + + @Deprecated public class Type extends android.renderscript.BaseObj { + method @Deprecated public static android.renderscript.Type createX(android.renderscript.RenderScript, android.renderscript.Element, int); + method @Deprecated public static android.renderscript.Type createXY(android.renderscript.RenderScript, android.renderscript.Element, int, int); + method @Deprecated public static android.renderscript.Type createXYZ(android.renderscript.RenderScript, android.renderscript.Element, int, int, int); + method @Deprecated public int getCount(); + method @Deprecated public android.renderscript.Element getElement(); + method @Deprecated public int getX(); + method @Deprecated public int getY(); + method @Deprecated public int getYuv(); + method @Deprecated public int getZ(); + method @Deprecated public boolean hasFaces(); + method @Deprecated public boolean hasMipmaps(); + } + + @Deprecated public static class Type.Builder { + ctor @Deprecated public Type.Builder(android.renderscript.RenderScript, android.renderscript.Element); + method @Deprecated public android.renderscript.Type create(); + method @Deprecated public android.renderscript.Type.Builder setFaces(boolean); + method @Deprecated public android.renderscript.Type.Builder setMipmaps(boolean); + method @Deprecated public android.renderscript.Type.Builder setX(int); + method @Deprecated public android.renderscript.Type.Builder setY(int); + method @Deprecated public android.renderscript.Type.Builder setYuvFormat(int); + method @Deprecated public android.renderscript.Type.Builder setZ(int); + } + + @Deprecated public enum Type.CubemapFace { + enum_constant @Deprecated public static final android.renderscript.Type.CubemapFace NEGATIVE_X; + enum_constant @Deprecated public static final android.renderscript.Type.CubemapFace NEGATIVE_Y; + enum_constant @Deprecated public static final android.renderscript.Type.CubemapFace NEGATIVE_Z; + enum_constant @Deprecated public static final android.renderscript.Type.CubemapFace POSITIVE_X; + enum_constant @Deprecated public static final android.renderscript.Type.CubemapFace POSITIVE_Y; + enum_constant @Deprecated public static final android.renderscript.Type.CubemapFace POSITIVE_Z; enum_constant @Deprecated public static final android.renderscript.Type.CubemapFace POSITVE_X; enum_constant @Deprecated public static final android.renderscript.Type.CubemapFace POSITVE_Y; enum_constant @Deprecated public static final android.renderscript.Type.CubemapFace POSITVE_Z; diff --git a/core/api/module-lib-current.txt b/core/api/module-lib-current.txt index c7d40585dd00..057e16c8de5c 100644 --- a/core/api/module-lib-current.txt +++ b/core/api/module-lib-current.txt @@ -213,6 +213,13 @@ package android.net { field @NonNull public final java.util.List<java.lang.String> underlyingIfaces; } + public class VpnManager { + field @Deprecated public static final int TYPE_VPN_LEGACY = 3; // 0x3 + field public static final int TYPE_VPN_NONE = -1; // 0xffffffff + field public static final int TYPE_VPN_PLATFORM = 2; // 0x2 + field public static final int TYPE_VPN_SERVICE = 1; // 0x1 + } + } package android.os { diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 59c2bd52ca36..6c120d1ac9ca 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -147,6 +147,7 @@ package android { field public static final String MANAGE_SENSOR_PRIVACY = "android.permission.MANAGE_SENSOR_PRIVACY"; field public static final String MANAGE_SMARTSPACE = "android.permission.MANAGE_SMARTSPACE"; field public static final String MANAGE_SOUND_TRIGGER = "android.permission.MANAGE_SOUND_TRIGGER"; + field public static final String MANAGE_SPEECH_RECOGNITION = "android.permission.MANAGE_SPEECH_RECOGNITION"; field public static final String MANAGE_SUBSCRIPTION_PLANS = "android.permission.MANAGE_SUBSCRIPTION_PLANS"; field public static final String MANAGE_TEST_NETWORKS = "android.permission.MANAGE_TEST_NETWORKS"; field public static final String MANAGE_TIME_AND_ZONE_DETECTION = "android.permission.MANAGE_TIME_AND_ZONE_DETECTION"; @@ -359,6 +360,7 @@ package android { field public static final int config_systemGallery = 17039399; // 0x1040027 field public static final int config_systemShell = 17039402; // 0x104002a field public static final int config_systemSpeechRecognizer = 17039406; // 0x104002e + field public static final int config_systemTelevisionNotificationHandler = 17039409; // 0x1040031 field public static final int config_systemWellbeing = 17039408; // 0x1040030 field public static final int config_systemWifiCoexManager = 17039407; // 0x104002f } @@ -3102,6 +3104,7 @@ package android.hardware.hdmi { method @NonNull public java.util.List<android.hardware.hdmi.HdmiDeviceInfo> getConnectedDevices(); method @NonNull @RequiresPermission(android.Manifest.permission.HDMI_CEC) public int getHdmiCecEnabled(); method @NonNull @RequiresPermission(android.Manifest.permission.HDMI_CEC) public int getHdmiCecVersion(); + method @RequiresPermission(android.Manifest.permission.HDMI_CEC) public int getHdmiCecVolumeControlEnabled(); method public int getPhysicalAddress(); method @Nullable public android.hardware.hdmi.HdmiPlaybackClient getPlaybackClient(); method @NonNull @RequiresPermission(android.Manifest.permission.HDMI_CEC) public String getPowerControlMode(); @@ -3109,6 +3112,8 @@ package android.hardware.hdmi { method @Nullable public android.hardware.hdmi.HdmiSwitchClient getSwitchClient(); method @NonNull @RequiresPermission(android.Manifest.permission.HDMI_CEC) public int getSystemAudioModeMuting(); method @Nullable public android.hardware.hdmi.HdmiTvClient getTvClient(); + method @NonNull @RequiresPermission(android.Manifest.permission.HDMI_CEC) public int getTvSendStandbyOnSleep(); + method @NonNull @RequiresPermission(android.Manifest.permission.HDMI_CEC) public int getTvWakeOnOneTouchPlay(); method @NonNull @RequiresPermission(android.Manifest.permission.HDMI_CEC) public java.util.List<java.lang.String> getUserCecSettings(); method public boolean isDeviceConnected(@NonNull android.hardware.hdmi.HdmiDeviceInfo); method public void powerOffDevice(@NonNull android.hardware.hdmi.HdmiDeviceInfo); @@ -3117,10 +3122,13 @@ package android.hardware.hdmi { method public void setActiveSource(@NonNull android.hardware.hdmi.HdmiDeviceInfo); method @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setHdmiCecEnabled(@NonNull int); method @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setHdmiCecVersion(@NonNull int); + method @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setHdmiCecVolumeControlEnabled(int); method @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setPowerControlMode(@NonNull String); method @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setPowerStateChangeOnActiveSourceLost(@NonNull String); method @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setStandbyMode(boolean); method @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setSystemAudioModeMuting(@NonNull int); + method @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setTvSendStandbyOnSleep(@NonNull int); + method @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setTvWakeOnOneTouchPlay(@NonNull int); field public static final String ACTION_OSD_MESSAGE = "android.hardware.hdmi.action.OSD_MESSAGE"; field public static final int AVR_VOLUME_MUTED = 101; // 0x65 field public static final String CEC_SETTING_NAME_HDMI_CEC_ENABLED = "hdmi_cec_enabled"; @@ -3128,6 +3136,9 @@ package android.hardware.hdmi { field public static final String CEC_SETTING_NAME_POWER_CONTROL_MODE = "send_standby_on_sleep"; field public static final String CEC_SETTING_NAME_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST = "power_state_change_on_active_source_lost"; field public static final String CEC_SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING = "system_audio_mode_muting"; + field public static final String CEC_SETTING_NAME_TV_SEND_STANDBY_ON_SLEEP = "tv_send_standby_on_sleep"; + field public static final String CEC_SETTING_NAME_TV_WAKE_ON_ONE_TOUCH_PLAY = "tv_wake_on_one_touch_play"; + field public static final String CEC_SETTING_NAME_VOLUME_CONTROL_MODE = "volume_control_enabled"; field public static final int CLEAR_TIMER_STATUS_CEC_DISABLE = 162; // 0xa2 field public static final int CLEAR_TIMER_STATUS_CHECK_RECORDER_CONNECTION = 160; // 0xa0 field public static final int CLEAR_TIMER_STATUS_FAIL_TO_CLEAR_SELECTED_SOURCE = 161; // 0xa1 @@ -3223,6 +3234,12 @@ package android.hardware.hdmi { field public static final int TIMER_STATUS_PROGRAMMED_INFO_MIGHT_NOT_ENOUGH_SPACE = 11; // 0xb field public static final int TIMER_STATUS_PROGRAMMED_INFO_NOT_ENOUGH_SPACE = 9; // 0x9 field public static final int TIMER_STATUS_PROGRAMMED_INFO_NO_MEDIA_INFO = 10; // 0xa + field public static final int TV_SEND_STANDBY_ON_SLEEP_DISABLED = 0; // 0x0 + field public static final int TV_SEND_STANDBY_ON_SLEEP_ENABLED = 1; // 0x1 + field public static final int TV_WAKE_ON_ONE_TOUCH_PLAY_DISABLED = 0; // 0x0 + field public static final int TV_WAKE_ON_ONE_TOUCH_PLAY_ENABLED = 1; // 0x1 + field public static final int VOLUME_CONTROL_DISABLED = 0; // 0x0 + field public static final int VOLUME_CONTROL_ENABLED = 1; // 0x1 } public static interface HdmiControlManager.CecSettingChangeListener { @@ -11621,7 +11638,7 @@ package android.telephony { method @NonNull @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public android.telephony.PinResult setIccLockEnabled(boolean, @NonNull String); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setMobileDataPolicyEnabled(int, boolean); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setMultiSimCarrierRestriction(boolean); - method public int setNrDualConnectivityState(int); + method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setNrDualConnectivityState(int); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setOpportunisticNetworkState(boolean); method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setPreferredNetworkTypeBitmask(long); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setRadio(boolean); diff --git a/core/api/test-current.txt b/core/api/test-current.txt index 86949e05ba71..72d39764bfc1 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -2125,6 +2125,14 @@ package android.service.watchdog { } +package android.speech { + + public class SpeechRecognizer { + method public void setTemporaryOnDeviceRecognizer(@Nullable android.content.ComponentName); + } + +} + package android.telecom { public static class Call.Details { diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 0b5958695dff..8977ba774d0b 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -5775,11 +5775,14 @@ public final class ActivityThread extends ClientTransactionHandler // ResourcesImpl constructions. final int diff = activity.mCurrentConfig.diffPublicOnly(newConfig); - if (diff == 0 && !shouldUpdateWindowMetricsBounds(activity.mCurrentConfig, newConfig) - && !movedToDifferentDisplay && mResourcesManager.isSameResourcesOverrideConfig( - activityToken, amOverrideConfig)) { - // Nothing significant, don't proceed with updating and reporting. - return null; + if (diff == 0) { + if (!shouldUpdateWindowMetricsBounds(activity.mCurrentConfig, newConfig) + && !movedToDifferentDisplay + && mResourcesManager.isSameResourcesOverrideConfig( + activityToken, amOverrideConfig)) { + // Nothing significant, don't proceed with updating and reporting. + return null; + } } else if ((~activity.mActivityInfo.getRealConfigChanged() & diff) == 0) { // If this activity doesn't handle any of the config changes, then don't bother // calling onConfigurationChanged. Otherwise, report to the activity for the diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 5d416128e094..2b45723dae55 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -5803,11 +5803,11 @@ public class Notification implements Parcelable if (mContext.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.S) { return true; } - // If the big content view has no content, we can exempt the app from having to show it. + // Notifications with contentView and without a bigContentView, style, or actions would + // not have an expanded state before S, so showing the standard template expanded state + // usually looks wrong, so we keep it simple and don't show the expanded state. boolean exempt = mN.contentView != null && mN.bigContentView == null - && mStyle == null && mActions.size() == 0 - && mN.extras.getCharSequence(EXTRA_TITLE) == null - && mN.extras.getCharSequence(EXTRA_TEXT) == null; + && mStyle == null && mActions.size() == 0; return !exempt; } diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index ccf41e5f3063..30fb858b4bbc 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -987,7 +987,8 @@ public class DevicePolicyManager { * The default for this extra is {@code false} - by default, the admin of a fully-managed * device has the ability to grant sensors-related permissions. * - * <p>Use with {@link #ACTION_PROVISION_MANAGED_DEVICE} only. + * <p>Use only for device owner provisioning. + * @see #ACTION_GET_PROVISIONING_MODE */ public static final String EXTRA_PROVISIONING_PERMISSION_GRANT_OPT_OUT = "android.app.extra.PROVISIONING_PERMISSION_GRANT_OPT_OUT"; @@ -11838,7 +11839,7 @@ public class DevicePolicyManager { /** * @hide - * Force update user setup completed status. This API has no effect on user build. + * Force update user setup completed status. * @throws {@link SecurityException} if the caller has no * {@code android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS} or the caller is * not {@link UserHandle#SYSTEM_USER} diff --git a/core/java/android/hardware/display/AmbientDisplayConfiguration.java b/core/java/android/hardware/display/AmbientDisplayConfiguration.java index 7dc1eaabdc9c..93e5a0ea18f3 100644 --- a/core/java/android/hardware/display/AmbientDisplayConfiguration.java +++ b/core/java/android/hardware/display/AmbientDisplayConfiguration.java @@ -52,7 +52,8 @@ public class AmbientDisplayConfiguration { || wakeDisplayGestureEnabled(user) || pickupGestureEnabled(user) || tapGestureEnabled(user) - || doubleTapGestureEnabled(user); + || doubleTapGestureEnabled(user) + || quickPickupSensorEnabled(user); } /** {@hide} */ @@ -100,6 +101,13 @@ public class AmbientDisplayConfiguration { } /** {@hide} */ + public boolean quickPickupSensorEnabled(int user) { + return boolSettingDefaultOff(Settings.Secure.DOZE_QUICK_PICKUP_GESTURE, user) + && !TextUtils.isEmpty(quickPickupSensorType()) + && !alwaysOnEnabled(user); + } + + /** {@hide} */ public boolean wakeScreenGestureAvailable() { return mContext.getResources() .getBoolean(R.bool.config_dozeWakeLockScreenSensorAvailable); @@ -143,6 +151,11 @@ public class AmbientDisplayConfiguration { } /** {@hide} */ + public String quickPickupSensorType() { + return mContext.getResources().getString(R.string.config_quickPickupSensorType); + } + + /** {@hide} */ public boolean pulseOnLongPressEnabled(int user) { return pulseOnLongPressAvailable() && boolSettingDefaultOff( Settings.Secure.DOZE_PULSE_ON_LONG_PRESS, user); diff --git a/core/java/android/hardware/face/FaceManager.java b/core/java/android/hardware/face/FaceManager.java index 0256b7bc6de0..8dc8d5b60943 100644 --- a/core/java/android/hardware/face/FaceManager.java +++ b/core/java/android/hardware/face/FaceManager.java @@ -475,28 +475,11 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan * @hide */ @RequiresPermission(MANAGE_BIOMETRIC) - public void revokeChallenge() { - final List<FaceSensorPropertiesInternal> faceSensorProperties = - getSensorPropertiesInternal(); - if (faceSensorProperties.isEmpty()) { - Slog.e(TAG, "No sensors during revokeChallenge"); - } - revokeChallenge(faceSensorProperties.get(0).sensorId); - } - - /** - * Invalidates the current challenge. - * - * TODO(b/171335732): should take userId and challenge - * - * @hide - */ - @RequiresPermission(MANAGE_BIOMETRIC) - public void revokeChallenge(int sensorId) { + public void revokeChallenge(int sensorId, int userId, long challenge) { if (mService != null) { try { - mService.revokeChallenge(mToken, sensorId, 0 /* userId */, - mContext.getOpPackageName(), 0 /* challenge */); + mService.revokeChallenge(mToken, sensorId, userId, + mContext.getOpPackageName(), challenge); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } diff --git a/core/java/android/hardware/fingerprint/FingerprintManager.java b/core/java/android/hardware/fingerprint/FingerprintManager.java index fc795d8a0488..1c33b26dfa18 100644 --- a/core/java/android/hardware/fingerprint/FingerprintManager.java +++ b/core/java/android/hardware/fingerprint/FingerprintManager.java @@ -686,17 +686,6 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing } /** - * Revokes the current challenge. - * @hide - */ - @RequiresPermission(MANAGE_FINGERPRINT) - public void revokeChallenge(int userId) { - // On HALs with only single in-flight challenge such as IBiometricsFingerprint@2.1, - // this parameter is ignored. - revokeChallenge(userId, 0L); - } - - /** * Revokes the specified challenge. * @hide */ diff --git a/core/java/android/hardware/hdmi/HdmiControlManager.java b/core/java/android/hardware/hdmi/HdmiControlManager.java index b90c72832d36..ad71f15f6e26 100644 --- a/core/java/android/hardware/hdmi/HdmiControlManager.java +++ b/core/java/android/hardware/hdmi/HdmiControlManager.java @@ -461,6 +461,7 @@ public final class HdmiControlManager { * @see HdmiControlManager#CEC_SETTING_NAME_VOLUME_CONTROL_MODE * @hide */ + @SystemApi public static final int VOLUME_CONTROL_ENABLED = 1; /** * HDMI CEC disabled. @@ -468,6 +469,7 @@ public final class HdmiControlManager { * @see HdmiControlManager#CEC_SETTING_NAME_VOLUME_CONTROL_MODE * @hide */ + @SystemApi public static final int VOLUME_CONTROL_DISABLED = 0; /** * @see HdmiControlManager#CEC_SETTING_NAME_VOLUME_CONTROL_MODE @@ -486,12 +488,14 @@ public final class HdmiControlManager { * * @hide */ + @SystemApi public static final int TV_WAKE_ON_ONE_TOUCH_PLAY_ENABLED = 1; /** * TV Wake on One Touch Play disabled. * * @hide */ + @SystemApi public static final int TV_WAKE_ON_ONE_TOUCH_PLAY_DISABLED = 0; /** * @hide @@ -509,12 +513,14 @@ public final class HdmiControlManager { * * @hide */ + @SystemApi public static final int TV_SEND_STANDBY_ON_SLEEP_ENABLED = 1; /** * Not sending <Standby> on sleep. * * @hide */ + @SystemApi public static final int TV_SEND_STANDBY_ON_SLEEP_DISABLED = 0; /** * @hide @@ -759,6 +765,7 @@ public final class HdmiControlManager { * @hide * @see android.hardware.hdmi.HdmiControlManager#setHdmiCecVolumeControlEnabled(int) */ + @SystemApi public static final String CEC_SETTING_NAME_VOLUME_CONTROL_MODE = "volume_control_enabled"; /** @@ -767,6 +774,7 @@ public final class HdmiControlManager { * * @hide */ + @SystemApi public static final String CEC_SETTING_NAME_TV_WAKE_ON_ONE_TOUCH_PLAY = "tv_wake_on_one_touch_play"; /** @@ -775,6 +783,7 @@ public final class HdmiControlManager { * * @hide */ + @SystemApi public static final String CEC_SETTING_NAME_TV_SEND_STANDBY_ON_SLEEP = "tv_send_standby_on_sleep"; /** @@ -1259,6 +1268,7 @@ public final class HdmiControlManager { * @see HdmiControlManager#CEC_SETTING_NAME_VOLUME_CONTROL_MODE * @hide */ + @SystemApi @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setHdmiCecVolumeControlEnabled( @VolumeControl int hdmiCecVolumeControlEnabled) { @@ -1274,6 +1284,7 @@ public final class HdmiControlManager { * Returns whether volume changes via HDMI CEC are enabled. * @hide */ + @SystemApi @RequiresPermission(android.Manifest.permission.HDMI_CEC) @VolumeControl public int getHdmiCecVolumeControlEnabled() { @@ -2155,6 +2166,7 @@ public final class HdmiControlManager { * * @hide */ + @SystemApi @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setTvWakeOnOneTouchPlay(@NonNull @TvWakeOnOneTouchPlay int value) { if (mService == null) { @@ -2176,6 +2188,7 @@ public final class HdmiControlManager { * * @hide */ + @SystemApi @NonNull @TvWakeOnOneTouchPlay @RequiresPermission(android.Manifest.permission.HDMI_CEC) @@ -2199,6 +2212,7 @@ public final class HdmiControlManager { * * @hide */ + @SystemApi @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setTvSendStandbyOnSleep(@NonNull @TvSendStandbyOnSleep int value) { if (mService == null) { @@ -2220,6 +2234,7 @@ public final class HdmiControlManager { * * @hide */ + @SystemApi @NonNull @TvSendStandbyOnSleep @RequiresPermission(android.Manifest.permission.HDMI_CEC) diff --git a/core/java/android/net/VpnManager.java b/core/java/android/net/VpnManager.java index f472ed4381d1..77754d1256a7 100644 --- a/core/java/android/net/VpnManager.java +++ b/core/java/android/net/VpnManager.java @@ -16,12 +16,15 @@ package android.net; +import static android.annotation.SystemApi.Client.MODULE_LIBRARIES; + import static com.android.internal.util.Preconditions.checkNotNull; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.RequiresPermission; +import android.annotation.SystemApi; import android.annotation.UserIdInt; import android.app.Activity; import android.content.ComponentName; @@ -56,18 +59,21 @@ import java.util.List; */ public class VpnManager { /** Type representing a lack of VPN @hide */ + @SystemApi(client = MODULE_LIBRARIES) public static final int TYPE_VPN_NONE = -1; /** * A VPN created by an app using the {@link VpnService} API. * @hide */ + @SystemApi(client = MODULE_LIBRARIES) public static final int TYPE_VPN_SERVICE = 1; /** * A VPN created using a {@link VpnManager} API such as {@link #startProvisionedVpnProfile}. * @hide */ + @SystemApi(client = MODULE_LIBRARIES) public static final int TYPE_VPN_PLATFORM = 2; /** @@ -76,6 +82,7 @@ public class VpnManager { * @hide */ @Deprecated + @SystemApi(client = MODULE_LIBRARIES) public static final int TYPE_VPN_LEGACY = 3; /** diff --git a/core/java/android/os/FileUtils.java b/core/java/android/os/FileUtils.java index a46af9754f32..b12dad038ce3 100644 --- a/core/java/android/os/FileUtils.java +++ b/core/java/android/os/FileUtils.java @@ -1247,9 +1247,9 @@ public final class FileUtils { } /** - * Creates a directory with name {@code name} under an existing directory {@code baseDir}. - * Returns a {@code File} object representing the directory on success, {@code null} on - * failure. + * Creates a directory with name {@code name} under an existing directory {@code baseDir} if it + * doesn't exist already. Returns a {@code File} object representing the directory if it exists + * and {@code null} if not. * * @hide */ @@ -1259,13 +1259,23 @@ public final class FileUtils { return createDir(dir) ? dir : null; } - /** @hide */ + /** + * Ensure the given directory exists, creating it if needed. This method is threadsafe. + * + * @return false if the directory doesn't exist and couldn't be created + * + * @hide + */ public static boolean createDir(File dir) { + if (dir.mkdir()) { + return true; + } + if (dir.exists()) { return dir.isDirectory(); } - return dir.mkdir(); + return false; } /** diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java index 786a7d08047e..a19728c5c498 100644 --- a/core/java/android/os/PowerManager.java +++ b/core/java/android/os/PowerManager.java @@ -323,6 +323,13 @@ public final class PowerManager { public static final int USER_ACTIVITY_EVENT_ATTENTION = 4; /** + * User activity event type: {@link com.android.server.power.FaceDownDetector} taking action + * on behalf of user. + * @hide + */ + public static final int USER_ACTIVITY_EVENT_FACE_DOWN = 5; + + /** * User activity flag: If already dimmed, extend the dim timeout * but do not brighten. This flag is useful for keeping the screen on * a little longer without causing a visible change such as when diff --git a/core/java/android/os/incremental/IncrementalFileStorages.java b/core/java/android/os/incremental/IncrementalFileStorages.java index 73520e07d118..2a42b981ac26 100644 --- a/core/java/android/os/incremental/IncrementalFileStorages.java +++ b/core/java/android/os/incremental/IncrementalFileStorages.java @@ -51,6 +51,8 @@ import java.util.UUID; public final class IncrementalFileStorages { private static final String TAG = "IncrementalFileStorages"; + private static final String SYSTEM_DATA_LOADER_PACKAGE = "android"; + private @NonNull final IncrementalManager mIncrementalManager; private @NonNull final File mStageDir; private @Nullable IncrementalStorage mInheritedStorage; @@ -116,7 +118,10 @@ public final class IncrementalFileStorages { mInheritedStorage = mIncrementalManager.openStorage( inheritedDir.getAbsolutePath()); if (mInheritedStorage != null) { - if (!mInheritedStorage.isFullyLoaded()) { + boolean systemDataLoader = SYSTEM_DATA_LOADER_PACKAGE.equals( + dataLoaderParams.getComponentName().getPackageName()); + if (systemDataLoader && !mInheritedStorage.isFullyLoaded()) { + // System data loader does not support incomplete storages. throw new IOException("Inherited storage has missing pages."); } diff --git a/core/java/android/os/storage/StorageManagerInternal.java b/core/java/android/os/storage/StorageManagerInternal.java index 396ba2d3cea5..82c4c715f4b0 100644 --- a/core/java/android/os/storage/StorageManagerInternal.java +++ b/core/java/android/os/storage/StorageManagerInternal.java @@ -52,6 +52,11 @@ public abstract class StorageManagerInternal { } /** + * Return true if fuse is mounted. + */ + public abstract boolean isFuseMounted(int userId); + + /** * Create storage directories if it does not exist. * Return true if the directories were setup correctly, otherwise false. */ diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 4dfbb6fa2d05..6865041a5037 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -8369,6 +8369,14 @@ public final class Settings { public static final String DOZE_WAKE_DISPLAY_GESTURE = "doze_wake_display_gesture"; /** + * Gesture that wakes up the display on quick pickup, toggling between + * {@link Display.STATE_OFF} and {@link Display.STATE_DOZE}. + * @hide + */ + @Readable + public static final String DOZE_QUICK_PICKUP_GESTURE = "doze_quick_pickup_gesture"; + + /** * Whether the device should suppress the current doze configuration and disable dozing. * @hide */ diff --git a/core/java/android/speech/IRecognitionServiceManager.aidl b/core/java/android/speech/IRecognitionServiceManager.aidl index 8e5292d1ddf1..ad402262878d 100644 --- a/core/java/android/speech/IRecognitionServiceManager.aidl +++ b/core/java/android/speech/IRecognitionServiceManager.aidl @@ -31,4 +31,6 @@ oneway interface IRecognitionServiceManager { in IBinder clientToken, boolean onDevice, in IRecognitionServiceManagerCallback callback); + + void setTemporaryComponent(in ComponentName componentName); } diff --git a/core/java/android/speech/SpeechRecognizer.java b/core/java/android/speech/SpeechRecognizer.java index 850f997a2d2f..9b93a64e48a3 100644 --- a/core/java/android/speech/SpeechRecognizer.java +++ b/core/java/android/speech/SpeechRecognizer.java @@ -17,6 +17,8 @@ package android.speech; import android.annotation.NonNull; +import android.annotation.Nullable; +import android.annotation.TestApi; import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -35,6 +37,8 @@ import android.util.Log; import android.util.Slog; import java.util.List; +import java.util.Queue; +import java.util.concurrent.LinkedBlockingQueue; /** * This class provides access to the speech recognition service. This service allows access to the @@ -52,7 +56,7 @@ import java.util.List; */ public class SpeechRecognizer { /** DEBUG value to enable verbose debug prints */ - private final static boolean DBG = false; + private static final boolean DBG = false; /** Log messages identifier */ private static final String TAG = "SpeechRecognizer"; @@ -113,10 +117,11 @@ public class SpeechRecognizer { public static final int ERROR_SERVER_DISCONNECTED = 11; /** action codes */ - private final static int MSG_START = 1; - private final static int MSG_STOP = 2; - private final static int MSG_CANCEL = 3; - private final static int MSG_CHANGE_LISTENER = 4; + private static final int MSG_START = 1; + private static final int MSG_STOP = 2; + private static final int MSG_CANCEL = 3; + private static final int MSG_CHANGE_LISTENER = 4; + private static final int MSG_SET_TEMPORARY_ON_DEVICE_COMPONENT = 5; /** The actual RecognitionService endpoint */ private IRecognitionService mService; @@ -134,6 +139,7 @@ public class SpeechRecognizer { /** Handler that will execute the main tasks */ private Handler mHandler = new Handler(Looper.getMainLooper()) { + @Override public void handleMessage(Message msg) { switch (msg.what) { @@ -149,10 +155,19 @@ public class SpeechRecognizer { case MSG_CHANGE_LISTENER: handleChangeListener((RecognitionListener) msg.obj); break; + case MSG_SET_TEMPORARY_ON_DEVICE_COMPONENT: + handleSetTemporaryComponent((ComponentName) msg.obj); + break; } } }; + /** + * Temporary queue, saving the messages until the connection will be established, afterwards, + * only mHandler will receive the messages + */ + private final Queue<Message> mPendingTasks = new LinkedBlockingQueue<>(); + /** The Listener that will receive all the callbacks */ private final InternalListener mListener = new InternalListener(); @@ -287,11 +302,9 @@ public class SpeechRecognizer { if (mService == null) { // First time connection: first establish a connection, then dispatch #startListening. - connectToSystemService( - () -> putMessage(Message.obtain(mHandler, MSG_START, recognizerIntent))); - } else { - putMessage(Message.obtain(mHandler, MSG_START, recognizerIntent)); + connectToSystemService(); } + putMessage(Message.obtain(mHandler, MSG_START, recognizerIntent)); } /** @@ -336,6 +349,22 @@ public class SpeechRecognizer { putMessage(Message.obtain(mHandler, MSG_CANCEL)); } + /** + * Sets a temporary component to power on-device speech recognizer. + * + * <p>This is only expected to be called in tests, system would reject calls from client apps. + * + * @param componentName name of the component to set temporary replace speech recognizer. {@code + * null} value resets the recognizer to default. + * + * @hide + */ + @TestApi + public void setTemporaryOnDeviceRecognizer(@Nullable ComponentName componentName) { + mHandler.sendMessage( + Message.obtain(mHandler, MSG_SET_TEMPORARY_ON_DEVICE_COMPONENT, componentName)); + } + private static void checkIsCalledFromMainThread() { if (Looper.myLooper() != Looper.getMainLooper()) { throw new RuntimeException( @@ -344,7 +373,11 @@ public class SpeechRecognizer { } private void putMessage(Message msg) { - mHandler.sendMessage(msg); + if (mService == null) { + mPendingTasks.offer(msg); + } else { + mHandler.sendMessage(msg); + } } /** sends the actual message to the service */ @@ -395,6 +428,22 @@ public class SpeechRecognizer { } } + private void handleSetTemporaryComponent(ComponentName componentName) { + if (DBG) { + Log.d(TAG, "handleSetTemporaryComponent, componentName=" + componentName); + } + + if (!maybeInitializeManagerService()) { + return; + } + + try { + mManagerService.setTemporaryComponent(componentName); + } catch (final RemoteException e) { + e.rethrowFromSystemServer(); + } + } + private boolean checkOpenConnection() { if (mService != null) { return true; @@ -422,16 +471,13 @@ public class SpeechRecognizer { } mService = null; + mPendingTasks.clear(); mListener.mInternalListener = null; } /** Establishes a connection to system server proxy and initializes the session. */ - private void connectToSystemService(Runnable onSuccess) { - mManagerService = IRecognitionServiceManager.Stub.asInterface( - ServiceManager.getService(Context.SPEECH_RECOGNITION_SERVICE)); - - if (mManagerService == null) { - mListener.onError(ERROR_CLIENT); + private void connectToSystemService() { + if (!maybeInitializeManagerService()) { return; } @@ -450,13 +496,19 @@ public class SpeechRecognizer { new IRecognitionServiceManagerCallback.Stub(){ @Override public void onSuccess(IRecognitionService service) throws RemoteException { + if (DBG) { + Log.i(TAG, "Connected to speech recognition service"); + } mService = service; - onSuccess.run(); + while (!mPendingTasks.isEmpty()) { + mHandler.sendMessage(mPendingTasks.poll()); + } } @Override public void onError(int errorCode) throws RemoteException { - Log.e(TAG, "Bind to system recognition service failed"); + Log.e(TAG, "Bind to system recognition service failed with error " + + errorCode); mListener.onError(errorCode); } }); @@ -465,6 +517,21 @@ public class SpeechRecognizer { } } + private boolean maybeInitializeManagerService() { + if (mManagerService != null) { + return true; + } + + mManagerService = IRecognitionServiceManager.Stub.asInterface( + ServiceManager.getService(Context.SPEECH_RECOGNITION_SERVICE)); + + if (mManagerService == null && mListener != null) { + mListener.onError(ERROR_CLIENT); + return false; + } + return true; + } + /** * Returns the component name to be used for establishing a connection, based on the parameters * used during initialization. @@ -505,15 +572,15 @@ public class SpeechRecognizer { private static class InternalListener extends IRecognitionListener.Stub { private RecognitionListener mInternalListener; - private final static int MSG_BEGINNING_OF_SPEECH = 1; - private final static int MSG_BUFFER_RECEIVED = 2; - private final static int MSG_END_OF_SPEECH = 3; - private final static int MSG_ERROR = 4; - private final static int MSG_READY_FOR_SPEECH = 5; - private final static int MSG_RESULTS = 6; - private final static int MSG_PARTIAL_RESULTS = 7; - private final static int MSG_RMS_CHANGED = 8; - private final static int MSG_ON_EVENT = 9; + private static final int MSG_BEGINNING_OF_SPEECH = 1; + private static final int MSG_BUFFER_RECEIVED = 2; + private static final int MSG_END_OF_SPEECH = 3; + private static final int MSG_ERROR = 4; + private static final int MSG_READY_FOR_SPEECH = 5; + private static final int MSG_RESULTS = 6; + private static final int MSG_PARTIAL_RESULTS = 7; + private static final int MSG_RMS_CHANGED = 8; + private static final int MSG_ON_EVENT = 9; private final Handler mInternalHandler = new Handler(Looper.getMainLooper()) { @Override diff --git a/core/java/android/view/InputEventReceiver.java b/core/java/android/view/InputEventReceiver.java index 79d8c14aa0df..5e0579d8a672 100644 --- a/core/java/android/view/InputEventReceiver.java +++ b/core/java/android/view/InputEventReceiver.java @@ -159,6 +159,16 @@ public abstract class InputEventReceiver { } /** + * Called when a drag event is received, from native code. + * + * @param isExiting if false, the window associated with this input channel has just received + * drag + * if true, the window associated with this input channel has just lost drag + */ + public void onDragEvent(boolean isExiting, float x, float y) { + } + + /** * Called when a batched input event is pending. * * The batched input event will continue to accumulate additional movement diff --git a/core/java/android/view/contentcapture/ContentCaptureManager.java b/core/java/android/view/contentcapture/ContentCaptureManager.java index 9523bcdb8e39..ed840ce3061b 100644 --- a/core/java/android/view/contentcapture/ContentCaptureManager.java +++ b/core/java/android/view/contentcapture/ContentCaptureManager.java @@ -70,7 +70,7 @@ import java.util.function.Consumer; * <p>Content capture provides real-time, continuous capture of application activity, display and * events to an intelligence service that is provided by the Android system. The intelligence * service then uses that info to mediate and speed user journey through different apps. For - * example, when the user receives a restaurant address in a chat app and switchs to a map app + * example, when the user receives a restaurant address in a chat app and switches to a map app * to search for that restaurant, the intelligence service could offer an autofill dialog to * let the user automatically select its address. * diff --git a/core/java/android/view/translation/UiTranslationController.java b/core/java/android/view/translation/UiTranslationController.java index cf3358b0dfbb..9f90b3bf1322 100644 --- a/core/java/android/view/translation/UiTranslationController.java +++ b/core/java/android/view/translation/UiTranslationController.java @@ -25,6 +25,7 @@ import android.annotation.NonNull; import android.annotation.WorkerThread; import android.app.Activity; import android.content.Context; +import android.os.Build; import android.os.Handler; import android.os.HandlerThread; import android.os.Process; @@ -54,6 +55,11 @@ import java.util.function.Consumer; */ public class UiTranslationController { + // TODO(b/182433547): remove Build.IS_DEBUGGABLE before ship. Enable the logging in debug build + // to help the debug during the development phase + public static final boolean DEBUG = Log.isLoggable(UiTranslationManager.LOG_TAG, Log.DEBUG) + || Build.IS_DEBUGGABLE; + private static final String TAG = "UiTranslationController"; @NonNull private final Activity mActivity; @@ -93,6 +99,8 @@ public class UiTranslationController { if (!mActivity.isResumed()) { return; } + Log.i(TAG, "updateUiTranslationState state: " + stateToString(state) + + (DEBUG ? ", views: " + views : "")); switch (state) { case STATE_UI_TRANSLATION_STARTED: final Pair<TranslationSpec, TranslationSpec> specs = @@ -149,8 +157,69 @@ public class UiTranslationController { translator.dump(outerPrefix, pw); pw.println(); } + synchronized (mLock) { + final int viewSize = mViews.size(); + pw.print(outerPrefix); pw.print("number views: "); pw.println(viewSize); + for (int i = 0; i < viewSize; i++) { + pw.print(outerPrefix); pw.print("#"); pw.println(i); + final AutofillId autofillId = mViews.keyAt(i); + final View view = mViews.valueAt(i).get(); + pw.print(pfx); pw.print("autofillId: "); pw.println(autofillId); + pw.print(pfx); pw.print("view:"); pw.println(view); + } + } + // TODO(b/182433547): we will remove debug rom condition before S release then we change + // change this back to "DEBUG" + if (Log.isLoggable(UiTranslationManager.LOG_TAG, Log.DEBUG)) { + dumpViewByTraversal(outerPrefix, pw); + } + } + + private void dumpViewByTraversal(String outerPrefix, PrintWriter pw) { + final ArrayList<ViewRootImpl> roots = + WindowManagerGlobal.getInstance().getRootViews(mActivity.getActivityToken()); + pw.print(outerPrefix); pw.println("Dump views:"); + for (int rootNum = 0; rootNum < roots.size(); rootNum++) { + final View rootView = roots.get(rootNum).getView(); + if (rootView instanceof ViewGroup) { + dumpChildren((ViewGroup) rootView, outerPrefix, pw); + } else { + dumpViewInfo(rootView, outerPrefix, pw); + } + } + } + + private void dumpChildren(ViewGroup viewGroup, String outerPrefix, PrintWriter pw) { + final int childCount = viewGroup.getChildCount(); + for (int i = 0; i < childCount; ++i) { + final View child = viewGroup.getChildAt(i); + if (child instanceof ViewGroup) { + pw.print(outerPrefix); pw.println("Children: "); + pw.print(outerPrefix); pw.print(outerPrefix); pw.println(child); + dumpChildren((ViewGroup) child, outerPrefix, pw); + } else { + pw.print(outerPrefix); pw.println("End Children: "); + pw.print(outerPrefix); pw.print(outerPrefix); pw.print(child); + dumpViewInfo(child, outerPrefix, pw); + } + } } + private void dumpViewInfo(View view, String outerPrefix, PrintWriter pw) { + final AutofillId autofillId = view.getAutofillId(); + pw.print(outerPrefix); pw.print("autofillId: "); pw.print(autofillId); + // TODO: print TranslationTransformation + boolean isContainsView = false; + synchronized (mLock) { + final WeakReference<View> viewRef = mViews.get(autofillId); + if (viewRef != null && viewRef.get() != null) { + isContainsView = true; + } + } + pw.print(outerPrefix); pw.print("isContainsView: "); pw.println(isContainsView); + } + + /** * The method is used by {@link Translator}, it will be called when the translation is done. The * translation result can be get from here. @@ -171,6 +240,9 @@ public class UiTranslationController { return; } final int resultCount = translatedResult.size(); + if (DEBUG) { + Log.v(TAG, "onTranslationCompleted: receive " + resultCount + " responses."); + } synchronized (mLock) { for (int i = 0; i < resultCount; i++) { final ViewTranslationResponse response = translatedResult.get(i); @@ -180,7 +252,7 @@ public class UiTranslationController { } final View view = mViews.get(autofillId).get(); if (view == null) { - Log.w(TAG, "onTranslationCompleted: the Veiew for autofill id " + autofillId + Log.w(TAG, "onTranslationCompleted: the view for autofill id " + autofillId + " may be gone."); continue; } @@ -208,6 +280,10 @@ public class UiTranslationController { @WorkerThread private void sendTranslationRequest(Translator translator, List<ViewTranslationRequest> requests) { + if (requests.size() == 0) { + Log.wtf(TAG, "No ViewTranslationRequest was collected."); + return; + } final TranslationRequest request = new TranslationRequest.Builder() .setViewTranslationRequests(requests) .build(); @@ -233,7 +309,8 @@ public class UiTranslationController { requests.add(request); } if (currentCount == (foundViews.size() - 1)) { - Log.v(TAG, "onUiTranslationStarted: send " + requests.size() + " request."); + Log.v(TAG, "onUiTranslationStarted: collect " + requests.size() + + " requests."); mWorkerHandler.sendMessage(PooledLambda.obtainMessage( UiTranslationController::sendTranslationRequest, UiTranslationController.this, translator, requests)); @@ -287,6 +364,9 @@ public class UiTranslationController { for (int i = 0; i < viewCounts; i++) { final View view = views.valueAt(i).get(); if (view == null) { + if (DEBUG) { + Log.d(TAG, "View was gone for autofillid = " + views.keyAt(i)); + } continue; } action.accept(view); diff --git a/core/java/android/view/translation/UiTranslationManager.java b/core/java/android/view/translation/UiTranslationManager.java index a3a6a2e52138..7c73e701b7c8 100644 --- a/core/java/android/view/translation/UiTranslationManager.java +++ b/core/java/android/view/translation/UiTranslationManager.java @@ -43,6 +43,14 @@ public final class UiTranslationManager { private static final String TAG = "UiTranslationManager"; /** + * The tag which uses for enabling debug log dump. To enable it, we can use command "adb shell + * setprop log.tag.UiTranslation DEBUG". + * + * @hide + */ + public static final String LOG_TAG = "UiTranslation"; + + /** * The state caller request to disable utranslation,, it is no longer need to ui translation. * * @hide diff --git a/core/java/android/widget/EdgeEffect.java b/core/java/android/widget/EdgeEffect.java index beafcc8740f7..45352e4d5ba2 100644 --- a/core/java/android/widget/EdgeEffect.java +++ b/core/java/android/widget/EdgeEffect.java @@ -102,6 +102,28 @@ public class EdgeEffect { */ public static final int TYPE_STRETCH = 1; + /** + * The velocity threshold before the spring animation is considered settled. + * The idea here is that velocity should be less than 1 pixel per frame (~16ms). + */ + private static final double VELOCITY_THRESHOLD = 1.0 / 0.016; + + /** + * The value threshold before the spring animation is considered close enough to + * the destination to be settled. This should be around 1 pixel. + */ + private static final double VALUE_THRESHOLD = 1; + + /** + * The natural frequency of the stretch spring. + */ + private static final double NATURAL_FREQUENCY = 14.4222; + + /** + * The damping ratio of the stretch spring. + */ + private static final double DAMPING_RATIO = 0.875; + /** @hide */ @IntDef({TYPE_GLOW, TYPE_STRETCH}) @Retention(RetentionPolicy.SOURCE) @@ -145,13 +167,12 @@ public class EdgeEffect { @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) private float mGlowScaleY; private float mDistance; + private float mVelocity; // only for stretch animations private float mGlowAlphaStart; private float mGlowAlphaFinish; private float mGlowScaleYStart; private float mGlowScaleYFinish; - private float mDistanceStart; - private float mDistanceFinish; private long mStartTime; private float mDuration; @@ -273,6 +294,8 @@ public class EdgeEffect { */ public void finish() { mState = STATE_IDLE; + mDistance = 0; + mVelocity = 0; } /** @@ -327,7 +350,8 @@ public class EdgeEffect { mDuration = PULL_TIME; mPullDistance += deltaDistance; - mDistanceStart = mDistanceFinish = mDistance = Math.max(0f, mPullDistance); + mDistance = Math.max(0f, mPullDistance); + mVelocity = 0; final float absdd = Math.abs(deltaDistance); mGlowAlpha = mGlowAlphaStart = Math.min(MAX_ALPHA, @@ -421,11 +445,10 @@ public class EdgeEffect { mState = STATE_RECEDE; mGlowAlphaStart = mGlowAlpha; mGlowScaleYStart = mGlowScaleY; - mDistanceStart = mDistance; mGlowAlphaFinish = 0.f; mGlowScaleYFinish = 0.f; - mDistanceFinish = 0.f; + mVelocity = 0.f; mStartTime = AnimationUtils.currentAnimationTimeMillis(); mDuration = RECEDE_TIME; @@ -442,30 +465,36 @@ public class EdgeEffect { * @param velocity Velocity at impact in pixels per second. */ public void onAbsorb(int velocity) { - mState = STATE_ABSORB; - velocity = Math.min(Math.max(MIN_VELOCITY, Math.abs(velocity)), MAX_VELOCITY); - - mStartTime = AnimationUtils.currentAnimationTimeMillis(); - mDuration = 0.15f + (velocity * 0.02f); - - // The glow depends more on the velocity, and therefore starts out - // nearly invisible. - mGlowAlphaStart = GLOW_ALPHA_START; - mGlowScaleYStart = Math.max(mGlowScaleY, 0.f); - mDistanceStart = mDistance; - - // Growth for the size of the glow should be quadratic to properly - // respond - // to a user's scrolling speed. The faster the scrolling speed, the more - // intense the effect should be for both the size and the saturation. - mGlowScaleYFinish = Math.min(0.025f + (velocity * (velocity / 100) * 0.00015f) / 2, 1.f); - // Alpha should change for the glow as well as size. - mGlowAlphaFinish = Math.max( - mGlowAlphaStart, Math.min(velocity * VELOCITY_GLOW_FACTOR * .00001f, MAX_ALPHA)); - mTargetDisplacement = 0.5f; - - // Use glow values to estimate the absorption for stretch distance. - mDistanceFinish = calculateDistanceFromGlowValues(mGlowScaleYFinish, mGlowAlphaFinish); + if (mEdgeEffectType == TYPE_STRETCH) { + mState = STATE_RECEDE; + mVelocity = velocity / mHeight; + mDistance = 0; + mStartTime = AnimationUtils.currentAnimationTimeMillis(); + } else { + mState = STATE_ABSORB; + mVelocity = 0; + velocity = Math.min(Math.max(MIN_VELOCITY, Math.abs(velocity)), MAX_VELOCITY); + + mStartTime = AnimationUtils.currentAnimationTimeMillis(); + mDuration = 0.15f + (velocity * 0.02f); + + // The glow depends more on the velocity, and therefore starts out + // nearly invisible. + mGlowAlphaStart = GLOW_ALPHA_START; + mGlowScaleYStart = Math.max(mGlowScaleY, 0.f); + + // Growth for the size of the glow should be quadratic to properly + // respond + // to a user's scrolling speed. The faster the scrolling speed, the more + // intense the effect should be for both the size and the saturation. + mGlowScaleYFinish = Math.min(0.025f + (velocity * (velocity / 100) * 0.00015f) / 2, + 1.f); + // Alpha should change for the glow as well as size. + mGlowAlphaFinish = Math.max( + mGlowAlphaStart, + Math.min(velocity * VELOCITY_GLOW_FACTOR * .00001f, MAX_ALPHA)); + mTargetDisplacement = 0.5f; + } } /** @@ -573,8 +602,8 @@ public class EdgeEffect { canvas.drawCircle(centerX, centerY, mRadius, mPaint); canvas.restoreToCount(count); } else if (canvas instanceof RecordingCanvas) { - if (mState != STATE_PULL) { - update(); + if (mState == STATE_RECEDE) { + updateSpring(); } RecordingCanvas recordingCanvas = (RecordingCanvas) canvas; if (mTmpMatrix == null) { @@ -631,7 +660,7 @@ public class EdgeEffect { } boolean oneLastFrame = false; - if (mState == STATE_RECEDE && mDistance == 0) { + if (mState == STATE_RECEDE && mDistance == 0 && mVelocity == 0) { mState = STATE_IDLE; oneLastFrame = true; } @@ -668,7 +697,7 @@ public class EdgeEffect { mGlowAlpha = mGlowAlphaStart + (mGlowAlphaFinish - mGlowAlphaStart) * interp; mGlowScaleY = mGlowScaleYStart + (mGlowScaleYFinish - mGlowScaleYStart) * interp; - mDistance = mDistanceStart + (mDistanceFinish - mDistanceStart) * interp; + mDistance = calculateDistanceFromGlowValues(mGlowScaleY, mGlowAlpha); mDisplacement = (mDisplacement + mTargetDisplacement) / 2; if (t >= 1.f - EPSILON) { @@ -680,12 +709,10 @@ public class EdgeEffect { mGlowAlphaStart = mGlowAlpha; mGlowScaleYStart = mGlowScaleY; - mDistanceStart = mDistance; // After absorb, the glow should fade to nothing. mGlowAlphaFinish = 0.f; mGlowScaleYFinish = 0.f; - mDistanceFinish = 0.f; break; case STATE_PULL: mState = STATE_PULL_DECAY; @@ -694,12 +721,10 @@ public class EdgeEffect { mGlowAlphaStart = mGlowAlpha; mGlowScaleYStart = mGlowScaleY; - mDistanceStart = mDistance; // After pull, the glow should fade to nothing. mGlowAlphaFinish = 0.f; mGlowScaleYFinish = 0.f; - mDistanceFinish = 0.f; break; case STATE_PULL_DECAY: mState = STATE_RECEDE; @@ -711,6 +736,35 @@ public class EdgeEffect { } } + private void updateSpring() { + final long time = AnimationUtils.currentAnimationTimeMillis(); + final float deltaT = (time - mStartTime) / 1000f; // Convert from millis to seconds + if (deltaT < 0.001f) { + return; // Must have at least 1 ms difference + } + final double mDampedFreq = NATURAL_FREQUENCY * Math.sqrt(1 - DAMPING_RATIO * DAMPING_RATIO); + + // We're always underdamped, so we can use only those equations: + double cosCoeff = mDistance; + double sinCoeff = (1 / mDampedFreq) * (DAMPING_RATIO * NATURAL_FREQUENCY + * mDistance + mVelocity); + double distance = Math.pow(Math.E, -DAMPING_RATIO * NATURAL_FREQUENCY * deltaT) + * (cosCoeff * Math.cos(mDampedFreq * deltaT) + + sinCoeff * Math.sin(mDampedFreq * deltaT)); + double velocity = distance * (-NATURAL_FREQUENCY) * DAMPING_RATIO + + Math.pow(Math.E, -DAMPING_RATIO * NATURAL_FREQUENCY * deltaT) + * (-mDampedFreq * cosCoeff * Math.sin(mDampedFreq * deltaT) + + mDampedFreq * sinCoeff * Math.cos(mDampedFreq * deltaT)); + mDistance = (float) distance; + mVelocity = (float) velocity; + mStartTime = time; + if (isAtEquilibrium()) { + mState = STATE_IDLE; + mDistance = 0; + mVelocity = 0; + } + } + /** * @return The estimated pull distance as calculated from mGlowScaleY. */ @@ -726,4 +780,15 @@ public class EdgeEffect { } return alpha / PULL_DISTANCE_ALPHA_GLOW_FACTOR; } + + /** + * @return true if the spring used for calculating the stretch animation is + * considered at rest or false if it is still animating. + */ + private boolean isAtEquilibrium() { + double velocity = mVelocity * mHeight; // in pixels/second + double displacement = mDistance * mHeight; // in pixels + return Math.abs(velocity) < VELOCITY_THRESHOLD + && Math.abs(displacement) < VALUE_THRESHOLD; + } } diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index fdc66fcb81d8..9e97f9aaed42 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -195,6 +195,7 @@ import android.view.textclassifier.TextLinks; import android.view.textservice.SpellCheckerSubtype; import android.view.textservice.TextServicesManager; import android.view.translation.TranslationRequestValue; +import android.view.translation.UiTranslationController; import android.view.translation.ViewTranslationRequest; import android.view.translation.ViewTranslationResponse; import android.widget.RemoteViews.RemoteView; @@ -13835,6 +13836,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener @Override public ViewTranslationRequest onCreateTranslationRequest() { if (mText == null || mText.length() == 0) { + // TODO(b/182433547): remove before S release + if (UiTranslationController.DEBUG) { + Log.w(LOG_TAG, "Cannot create translation request for the empty text."); + } return null; } // Not translate password, editable text and not important for translation @@ -13842,6 +13847,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // text selection apis, not support in S. boolean isPassword = isAnyPasswordInputType() || hasPasswordTransformationMethod(); if (isTextEditable() || isPassword || isTextSelectable()) { + // TODO(b/182433547): remove before S release + if (UiTranslationController.DEBUG) { + Log.w(LOG_TAG, "Cannot create translation request. editable = " + isTextEditable() + + ", isPassword = " + isPassword + ", selectable = " + isTextSelectable()); + } return null; } // TODO(b/176488462): apply the view's important for translation property @@ -13870,6 +13880,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // Restore to original text content. if (mTranslationTransformation != null) { setTransformationMethod(mTranslationTransformation.getOriginalTransformationMethod()); + } else { + // TODO(b/182433547): remove before S release + Log.w(LOG_TAG, "onPauseUiTranslation(): no translated text."); } } @@ -13889,7 +13902,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if (mTranslationTransformation != null) { setTransformationMethod(mTranslationTransformation); } else { - Log.w(LOG_TAG, "onResumeTranslatedText(): no translated text."); + // TODO(b/182433547): remove before S release + Log.w(LOG_TAG, "onRestoreUiTranslation(): no translated text."); } } @@ -13910,6 +13924,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if (mTranslationTransformation != null) { setTransformationMethod(mTranslationTransformation.getOriginalTransformationMethod()); mTranslationTransformation = null; + } else { + // TODO(b/182433547): remove before S release + Log.w(LOG_TAG, "onFinishUiTranslation(): no translated text."); } } diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java index 6cfd49888fac..d4d853624700 100644 --- a/core/java/com/android/internal/app/ChooserActivity.java +++ b/core/java/com/android/internal/app/ChooserActivity.java @@ -1119,7 +1119,7 @@ public class ChooserActivity extends ResolverActivity implements ClipboardManager clipboardManager = (ClipboardManager) getSystemService( Context.CLIPBOARD_SERVICE); - clipboardManager.setPrimaryClip(clipData); + clipboardManager.setPrimaryClipAsPackage(clipData, getReferrerPackageName()); Toast.makeText(getApplicationContext(), R.string.copied, Toast.LENGTH_SHORT).show(); // Log share completion via copy diff --git a/core/java/com/android/internal/jank/FrameTracker.java b/core/java/com/android/internal/jank/FrameTracker.java index 5829047ad642..7f0178e29d85 100644 --- a/core/java/com/android/internal/jank/FrameTracker.java +++ b/core/java/com/android/internal/jank/FrameTracker.java @@ -206,9 +206,8 @@ public class FrameTracker extends SurfaceControl.OnJankDataListener * Cancel the trace session of the CUJ. */ public synchronized void cancel() { - // The session is ongoing, end the trace session. - // That means the cancel call is from external invocation, not from end(). - if (mBeginVsyncId != INVALID_ID && mEndVsyncId == INVALID_ID) { + // We don't need to end the trace section if it never begun. + if (mBeginVsyncId != INVALID_ID) { Trace.endAsyncSection(mSession.getName(), (int) mBeginVsyncId); } mCancelled = true; diff --git a/core/java/com/android/internal/os/SelectedProcessCpuThreadReader.java b/core/java/com/android/internal/os/SelectedProcessCpuThreadReader.java new file mode 100644 index 000000000000..2ffff73f18cf --- /dev/null +++ b/core/java/com/android/internal/os/SelectedProcessCpuThreadReader.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2021 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.os; + +import android.annotation.Nullable; +import android.os.Process; + +/** + * Reads CPU usage statistics about a selected process identified by its cmdline. + * + * Handles finding the pid for the process and delegates CPU usage reading from the eBPF map to + * KernelSingleProcessCpuThreadReader. Exactly one long-lived instance of the process is expected. + * Otherwise, no statistics are returned. + * + * See also SystemServerCpuThreadReader. + */ +public final class SelectedProcessCpuThreadReader { + private final String[] mCmdline; + + private int mPid; + private KernelSingleProcessCpuThreadReader mKernelCpuThreadReader; + + public SelectedProcessCpuThreadReader(String cmdline) { + mCmdline = new String[] { cmdline }; + } + + /** Returns CPU times, per thread group, since tracking started. */ + @Nullable + public KernelSingleProcessCpuThreadReader.ProcessCpuUsage readAbsolute() { + int[] pids = Process.getPidsForCommands(mCmdline); + if (pids == null || pids.length != 1) { + return null; + } + int pid = pids[0]; + if (mPid == pid) { + return mKernelCpuThreadReader.getProcessCpuUsage(); + } + mPid = pid; + mKernelCpuThreadReader = KernelSingleProcessCpuThreadReader.create(mPid); + mKernelCpuThreadReader.startTrackingThreadCpuTimes(); + return null; + } +} diff --git a/core/java/com/android/internal/util/LatencyTracker.java b/core/java/com/android/internal/util/LatencyTracker.java index dc6880e4f997..90c728293eb0 100644 --- a/core/java/com/android/internal/util/LatencyTracker.java +++ b/core/java/com/android/internal/util/LatencyTracker.java @@ -175,7 +175,7 @@ public class LatencyTracker { mEnabled = properties.getBoolean(SETTINGS_ENABLED_KEY, DEFAULT_ENABLED); for (int action : ACTIONS_ALL) { mTraceThresholdPerAction[action] = - properties.getInt(getTraceTriggerNameForAction(action), -1); + properties.getInt(getNameOfAction(STATSD_ACTION[action]), -1); } } } diff --git a/core/jni/android_media_AudioSystem.cpp b/core/jni/android_media_AudioSystem.cpp index 94bd28a59e7c..f102edc79e7f 100644 --- a/core/jni/android_media_AudioSystem.cpp +++ b/core/jni/android_media_AudioSystem.cpp @@ -2204,13 +2204,11 @@ android_media_AudioSystem_getHwOffloadEncodingFormatsSupportedForA2DP( return jStatus; } -static jint -android_media_AudioSystem_getSurroundFormats(JNIEnv *env, jobject thiz, - jobject jSurroundFormats, jboolean reported) -{ +static jint android_media_AudioSystem_getSurroundFormats(JNIEnv *env, jobject thiz, + jobject jSurroundFormats) { ALOGV("getSurroundFormats"); - if (jSurroundFormats == NULL) { + if (jSurroundFormats == nullptr) { ALOGE("jSurroundFormats is NULL"); return (jint)AUDIO_JAVA_BAD_VALUE; } @@ -2221,10 +2219,10 @@ android_media_AudioSystem_getSurroundFormats(JNIEnv *env, jobject thiz, jint jStatus; unsigned int numSurroundFormats = 0; - audio_format_t *surroundFormats = NULL; - bool *surroundFormatsEnabled = NULL; - status_t status = AudioSystem::getSurroundFormats( - &numSurroundFormats, surroundFormats, surroundFormatsEnabled, reported); + audio_format_t *surroundFormats = nullptr; + bool *surroundFormatsEnabled = nullptr; + status_t status = AudioSystem::getSurroundFormats(&numSurroundFormats, surroundFormats, + surroundFormatsEnabled); if (status != NO_ERROR) { ALOGE_IF(status != NO_ERROR, "AudioSystem::getSurroundFormats error %d", status); jStatus = nativeToJavaStatus(status); @@ -2236,8 +2234,8 @@ android_media_AudioSystem_getSurroundFormats(JNIEnv *env, jobject thiz, } surroundFormats = (audio_format_t *)calloc(numSurroundFormats, sizeof(audio_format_t)); surroundFormatsEnabled = (bool *)calloc(numSurroundFormats, sizeof(bool)); - status = AudioSystem::getSurroundFormats( - &numSurroundFormats, surroundFormats, surroundFormatsEnabled, reported); + status = AudioSystem::getSurroundFormats(&numSurroundFormats, surroundFormats, + surroundFormatsEnabled); jStatus = nativeToJavaStatus(status); if (status != NO_ERROR) { ALOGE_IF(status != NO_ERROR, "AudioSystem::getSurroundFormats error %d", status); @@ -2258,6 +2256,50 @@ exit: return jStatus; } +static jint android_media_AudioSystem_getReportedSurroundFormats(JNIEnv *env, jobject thiz, + jobject jSurroundFormats) { + ALOGV("getReportedSurroundFormats"); + + if (jSurroundFormats == nullptr) { + ALOGE("jSurroundFormats is NULL"); + return (jint)AUDIO_JAVA_BAD_VALUE; + } + if (!env->IsInstanceOf(jSurroundFormats, gArrayListClass)) { + ALOGE("jSurroundFormats not an arraylist"); + return (jint)AUDIO_JAVA_BAD_VALUE; + } + jint jStatus; + unsigned int numSurroundFormats = 0; + audio_format_t *surroundFormats = nullptr; + status_t status = AudioSystem::getReportedSurroundFormats(&numSurroundFormats, surroundFormats); + if (status != NO_ERROR) { + ALOGE_IF(status != NO_ERROR, "AudioSystem::getReportedSurroundFormats error %d", status); + jStatus = nativeToJavaStatus(status); + goto exit; + } + if (numSurroundFormats == 0) { + jStatus = (jint)AUDIO_JAVA_SUCCESS; + goto exit; + } + surroundFormats = (audio_format_t *)calloc(numSurroundFormats, sizeof(audio_format_t)); + status = AudioSystem::getReportedSurroundFormats(&numSurroundFormats, surroundFormats); + jStatus = nativeToJavaStatus(status); + if (status != NO_ERROR) { + ALOGE_IF(status != NO_ERROR, "AudioSystem::getReportedSurroundFormats error %d", status); + goto exit; + } + for (size_t i = 0; i < numSurroundFormats; i++) { + jobject surroundFormat = env->NewObject(gIntegerClass, gIntegerCstor, + audioFormatFromNative(surroundFormats[i])); + env->CallObjectMethod(jSurroundFormats, gArrayListMethods.add, surroundFormat); + env->DeleteLocalRef(surroundFormat); + } + +exit: + free(surroundFormats); + return jStatus; +} + static jint android_media_AudioSystem_setSurroundFormatEnabled(JNIEnv *env, jobject thiz, jint audioFormat, jboolean enabled) @@ -2619,8 +2661,10 @@ static const JNINativeMethod gMethods[] = (void *)android_media_AudioSystem_getOffloadSupport}, {"getMicrophones", "(Ljava/util/ArrayList;)I", (void *)android_media_AudioSystem_getMicrophones}, - {"getSurroundFormats", "(Ljava/util/Map;Z)I", + {"getSurroundFormats", "(Ljava/util/Map;)I", (void *)android_media_AudioSystem_getSurroundFormats}, + {"getReportedSurroundFormats", "(Ljava/util/ArrayList;)I", + (void *)android_media_AudioSystem_getReportedSurroundFormats}, {"setSurroundFormatEnabled", "(IZ)I", (void *)android_media_AudioSystem_setSurroundFormatEnabled}, {"setAssistantUid", "(I)I", (void *)android_media_AudioSystem_setAssistantUid}, diff --git a/core/jni/android_view_InputEventReceiver.cpp b/core/jni/android_view_InputEventReceiver.cpp index 5e142fd10de0..ab6633f395a8 100644 --- a/core/jni/android_view_InputEventReceiver.cpp +++ b/core/jni/android_view_InputEventReceiver.cpp @@ -57,6 +57,7 @@ static struct { jmethodID dispatchInputEvent; jmethodID onFocusEvent; jmethodID onPointerCaptureEvent; + jmethodID onDragEvent; jmethodID onBatchedInputEventPending; } gInputEventReceiverClassInfo; @@ -400,6 +401,18 @@ status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env, finishInputEvent(seq, true /* handled */); continue; } + case AINPUT_EVENT_TYPE_DRAG: { + const DragEvent* dragEvent = static_cast<DragEvent*>(inputEvent); + if (kDebugDispatchCycle) { + ALOGD("channel '%s' ~ Received drag event: isExiting=%s", + getInputChannelName().c_str(), toString(dragEvent->isExiting())); + } + env->CallVoidMethod(receiverObj.get(), gInputEventReceiverClassInfo.onDragEvent, + jboolean(dragEvent->isExiting()), dragEvent->getX(), + dragEvent->getY()); + finishInputEvent(seq, true /* handled */); + continue; + } default: assert(false); // InputConsumer should prevent this from ever happening @@ -547,6 +560,8 @@ int register_android_view_InputEventReceiver(JNIEnv* env) { gInputEventReceiverClassInfo.onPointerCaptureEvent = GetMethodIDOrDie(env, gInputEventReceiverClassInfo.clazz, "onPointerCaptureEvent", "(Z)V"); + gInputEventReceiverClassInfo.onDragEvent = + GetMethodIDOrDie(env, gInputEventReceiverClassInfo.clazz, "onDragEvent", "(ZFF)V"); gInputEventReceiverClassInfo.onBatchedInputEventPending = GetMethodIDOrDie(env, gInputEventReceiverClassInfo.clazz, "onBatchedInputEventPending", "(I)V"); diff --git a/core/jni/com_android_internal_os_KernelCpuBpfTracking.cpp b/core/jni/com_android_internal_os_KernelCpuBpfTracking.cpp index 6b41b2ec8f93..d644e3709045 100644 --- a/core/jni/com_android_internal_os_KernelCpuBpfTracking.cpp +++ b/core/jni/com_android_internal_os_KernelCpuBpfTracking.cpp @@ -30,13 +30,13 @@ static jboolean KernelCpuBpfTracking_startTrackingInternal(JNIEnv *, jobject) { static jlongArray KernelCpuBpfTracking_getFreqsInternal(JNIEnv *env, jobject) { auto freqs = android::bpf::getCpuFreqs(); - if (!freqs) return NULL; + if (!freqs) return nullptr; std::vector<uint64_t> allFreqs; for (const auto &vec : *freqs) std::copy(vec.begin(), vec.end(), std::back_inserter(allFreqs)); auto ar = env->NewLongArray(allFreqs.size()); - if (ar != NULL) { + if (ar != nullptr) { env->SetLongArrayRegion(ar, 0, allFreqs.size(), reinterpret_cast<const jlong *>(allFreqs.data())); } @@ -45,7 +45,7 @@ static jlongArray KernelCpuBpfTracking_getFreqsInternal(JNIEnv *env, jobject) { static jintArray KernelCpuBpfTracking_getFreqsClustersInternal(JNIEnv *env, jobject) { auto freqs = android::bpf::getCpuFreqs(); - if (!freqs) return NULL; + if (!freqs) return nullptr; std::vector<uint32_t> freqsClusters; uint32_t clusters = freqs->size(); @@ -54,7 +54,7 @@ static jintArray KernelCpuBpfTracking_getFreqsClustersInternal(JNIEnv *env, jobj } auto ar = env->NewIntArray(freqsClusters.size()); - if (ar != NULL) { + if (ar != nullptr) { env->SetIntArrayRegion(ar, 0, freqsClusters.size(), reinterpret_cast<const jint *>(freqsClusters.data())); } diff --git a/core/jni/com_android_internal_os_KernelCpuTotalBpfMapReader.cpp b/core/jni/com_android_internal_os_KernelCpuTotalBpfMapReader.cpp index ad43014d321f..472bd23c0f8d 100644 --- a/core/jni/com_android_internal_os_KernelCpuTotalBpfMapReader.cpp +++ b/core/jni/com_android_internal_os_KernelCpuTotalBpfMapReader.cpp @@ -22,7 +22,7 @@ namespace android { static jlongArray KernelCpuTotalBpfMapReader_readInternal(JNIEnv *env, jobject) { auto freqTimes = android::bpf::getTotalCpuFreqTimes(); - if (!freqTimes) return JNI_FALSE; + if (!freqTimes) return nullptr; std::vector<uint64_t> allTimes; for (const auto &vec : *freqTimes) { @@ -32,7 +32,7 @@ static jlongArray KernelCpuTotalBpfMapReader_readInternal(JNIEnv *env, jobject) } auto ar = env->NewLongArray(allTimes.size()); - if (ar != NULL) { + if (ar != nullptr) { env->SetLongArrayRegion(ar, 0, allTimes.size(), reinterpret_cast<const jlong *>(allTimes.data())); } diff --git a/core/jni/com_android_internal_os_KernelCpuUidBpfMapReader.cpp b/core/jni/com_android_internal_os_KernelCpuUidBpfMapReader.cpp index 7900d301dbb0..098a4d868269 100644 --- a/core/jni/com_android_internal_os_KernelCpuUidBpfMapReader.cpp +++ b/core/jni/com_android_internal_os_KernelCpuUidBpfMapReader.cpp @@ -37,7 +37,7 @@ static jlongArray getUidArray(JNIEnv *env, jobject sparseAr, uint32_t uid, jsize jlongArray ar = (jlongArray)env->CallObjectMethod(sparseAr, gSparseArrayClassInfo.get, uid); if (!ar) { ar = env->NewLongArray(sz); - if (ar == NULL) return ar; + if (ar == nullptr) return ar; env->CallVoidMethod(sparseAr, gSparseArrayClassInfo.put, uid, ar); } return ar; @@ -65,7 +65,7 @@ static jboolean KernelCpuUidFreqTimeBpfMapReader_readBpfData(JNIEnv *env, jobjec static uint64_t lastUpdate = 0; uint64_t newLastUpdate = lastUpdate; auto sparseAr = env->GetObjectField(thiz, gmData); - if (sparseAr == NULL) return false; + if (sparseAr == nullptr) return false; auto data = android::bpf::getUidsUpdatedCpuFreqTimes(&newLastUpdate); if (!data.has_value()) return false; @@ -75,7 +75,7 @@ static jboolean KernelCpuUidFreqTimeBpfMapReader_readBpfData(JNIEnv *env, jobjec for (const auto &subVec : times) s += subVec.size(); } jlongArray ar = getUidArray(env, sparseAr, uid, s); - if (ar == NULL) return false; + if (ar == nullptr) return false; copy2DVecToArray(env, ar, times); } lastUpdate = newLastUpdate; @@ -91,7 +91,7 @@ static jboolean KernelCpuUidActiveTimeBpfMapReader_readBpfData(JNIEnv *env, jobj static uint64_t lastUpdate = 0; uint64_t newLastUpdate = lastUpdate; auto sparseAr = env->GetObjectField(thiz, gmData); - if (sparseAr == NULL) return false; + if (sparseAr == nullptr) return false; auto data = android::bpf::getUidsUpdatedConcurrentTimes(&newLastUpdate); if (!data.has_value()) return false; @@ -99,7 +99,7 @@ static jboolean KernelCpuUidActiveTimeBpfMapReader_readBpfData(JNIEnv *env, jobj // TODO: revise calling code so we can divide by NSEC_PER_MSEC here instead for (auto &time : times.active) time /= NSEC_PER_MSEC; jlongArray ar = getUidArray(env, sparseAr, uid, times.active.size()); - if (ar == NULL) return false; + if (ar == nullptr) return false; env->SetLongArrayRegion(ar, 0, times.active.size(), reinterpret_cast<const jlong *>(times.active.data())); } @@ -111,7 +111,7 @@ static jlongArray KernelCpuUidActiveTimeBpfMapReader_getDataDimensions(JNIEnv *e jlong nCpus = get_nprocs_conf(); auto ar = env->NewLongArray(1); - if (ar != NULL) env->SetLongArrayRegion(ar, 0, 1, &nCpus); + if (ar != nullptr) env->SetLongArrayRegion(ar, 0, 1, &nCpus); return ar; } @@ -124,7 +124,7 @@ static jboolean KernelCpuUidClusterTimeBpfMapReader_readBpfData(JNIEnv *env, job static uint64_t lastUpdate = 0; uint64_t newLastUpdate = lastUpdate; auto sparseAr = env->GetObjectField(thiz, gmData); - if (sparseAr == NULL) return false; + if (sparseAr == nullptr) return false; auto data = android::bpf::getUidsUpdatedConcurrentTimes(&newLastUpdate); if (!data.has_value()) return false; @@ -134,7 +134,7 @@ static jboolean KernelCpuUidClusterTimeBpfMapReader_readBpfData(JNIEnv *env, job for (const auto &subVec : times.policy) s += subVec.size(); } jlongArray ar = getUidArray(env, sparseAr, uid, s); - if (ar == NULL) return false; + if (ar == nullptr) return false; copy2DVecToArray(env, ar, times.policy); } lastUpdate = newLastUpdate; @@ -143,12 +143,12 @@ static jboolean KernelCpuUidClusterTimeBpfMapReader_readBpfData(JNIEnv *env, job static jlongArray KernelCpuUidClusterTimeBpfMapReader_getDataDimensions(JNIEnv *env, jobject) { auto times = android::bpf::getUidConcurrentTimes(0); - if (!times.has_value()) return NULL; + if (!times.has_value()) return nullptr; std::vector<jlong> clusterCores; for (const auto &vec : times->policy) clusterCores.push_back(vec.size()); auto ar = env->NewLongArray(clusterCores.size()); - if (ar != NULL) env->SetLongArrayRegion(ar, 0, clusterCores.size(), clusterCores.data()); + if (ar != nullptr) env->SetLongArrayRegion(ar, 0, clusterCores.size(), clusterCores.data()); return ar; } diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp index 836074f1d5f7..cf96fe63f82c 100644 --- a/core/jni/com_android_internal_os_Zygote.cpp +++ b/core/jni/com_android_internal_os_Zygote.cpp @@ -184,6 +184,17 @@ static constexpr int PROCESS_PRIORITY_MIN = 19; /** The numeric value for the normal priority a process should have. */ static constexpr int PROCESS_PRIORITY_DEFAULT = 0; +/** Exponential back off parameters for storage dir check. */ +static constexpr unsigned int STORAGE_DIR_CHECK_RETRY_MULTIPLIER = 2; +static constexpr unsigned int STORAGE_DIR_CHECK_INIT_INTERVAL_US = 50; +static constexpr unsigned int STORAGE_DIR_CHECK_MAX_INTERVAL_US = 1000; +/** + * Lower bound time we allow storage dir check to sleep. + * If it exceeds 2s, PROC_START_TIMEOUT_MSG will kill the starting app anyway, + * so it's fine to assume max retries is 5 mins. + */ +static constexpr int STORAGE_DIR_CHECK_TIMEOUT_US = 1000 * 60 * 5; + /** * A helper class containing accounting information for USAPs. */ @@ -1458,6 +1469,31 @@ static void isolateJitProfile(JNIEnv* env, jobjectArray pkg_data_info_list, } } +static void WaitUntilDirReady(const std::string& target, fail_fn_t fail_fn) { + unsigned int sleepIntervalUs = STORAGE_DIR_CHECK_INIT_INTERVAL_US; + + // This is just an approximate value as it doesn't need to be very accurate. + unsigned int sleepTotalUs = 0; + + const char* dir_path = target.c_str(); + while (sleepTotalUs < STORAGE_DIR_CHECK_TIMEOUT_US) { + if (access(dir_path, F_OK) == 0) { + return; + } + // Failed, so we add exponential backoff and retry + usleep(sleepIntervalUs); + sleepTotalUs += sleepIntervalUs; + sleepIntervalUs = std::min<unsigned int>( + sleepIntervalUs * STORAGE_DIR_CHECK_RETRY_MULTIPLIER, + STORAGE_DIR_CHECK_MAX_INTERVAL_US); + } + // Last chance and get the latest errno if it fails. + if (access(dir_path, F_OK) == 0) { + return; + } + fail_fn(CREATE_ERROR("Error dir is not ready %s: %s", dir_path, strerror(errno))); +} + static void BindMountStorageToLowerFs(const userid_t user_id, const uid_t uid, const char* dir_name, const char* package, fail_fn_t fail_fn) { bool hasSdcardFs = IsSdcardfsUsed(); @@ -1468,6 +1504,10 @@ static void BindMountStorageToLowerFs(const userid_t user_id, const uid_t uid, source = StringPrintf("/mnt/pass_through/%d/emulated/%d/%s/%s", user_id, user_id, dir_name, package); } + + // Directory might be not ready, as prepareStorageDirs() is running asynchronously in ProcessList, + // so wait until dir is created. + WaitUntilDirReady(source, fail_fn); std::string target = StringPrintf("/storage/emulated/%d/%s/%s", user_id, dir_name, package); // As the parent is mounted as tmpfs, we need to create the target dir here. diff --git a/core/proto/android/app/OWNERS b/core/proto/android/app/OWNERS index 296abd18aadc..cc479e61b855 100644 --- a/core/proto/android/app/OWNERS +++ b/core/proto/android/app/OWNERS @@ -1 +1 @@ -per-file location_time_zone_manager.proto = nfuller@google.com, mingaleev@google.com +per-file location_time_zone_manager.proto, time_zone_detector.proto = nfuller@google.com, mingaleev@google.com diff --git a/core/proto/android/app/location_time_zone_manager.proto b/core/proto/android/app/location_time_zone_manager.proto index f44d5495f132..891e9fca36aa 100644 --- a/core/proto/android/app/location_time_zone_manager.proto +++ b/core/proto/android/app/location_time_zone_manager.proto @@ -17,6 +17,7 @@ syntax = "proto2"; package android.app.time; +import "frameworks/base/core/proto/android/app/time_zone_detector.proto"; import "frameworks/base/core/proto/android/privacy.proto"; option java_multiple_files = true; @@ -31,15 +32,6 @@ message LocationTimeZoneManagerServiceStateProto { repeated TimeZoneProviderStateProto secondary_provider_states = 3; } -// Represents a GeolocationTimeZoneSuggestion that can be / has been passed to the time zone -// detector. -message GeolocationTimeZoneSuggestionProto { - option (android.msg_privacy).dest = DEST_AUTOMATIC; - - repeated string zone_ids = 1; - repeated string debug_info = 2; -} - // The state tracked for a LocationTimeZoneProvider. message TimeZoneProviderStateProto { option (android.msg_privacy).dest = DEST_AUTOMATIC; diff --git a/core/proto/android/app/time_zone_detector.proto b/core/proto/android/app/time_zone_detector.proto new file mode 100644 index 000000000000..b33ca1d4f476 --- /dev/null +++ b/core/proto/android/app/time_zone_detector.proto @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2021 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. + */ + +syntax = "proto2"; +package android.app.time; + +import "frameworks/base/core/proto/android/privacy.proto"; + +option java_multiple_files = true; +option java_outer_classname = "TimeZoneDetectorProto"; + +// Represents a GeolocationTimeZoneSuggestion that can be / has been passed to the time zone +// detector. +message GeolocationTimeZoneSuggestionProto { + option (android.msg_privacy).dest = DEST_AUTOMATIC; + + repeated string zone_ids = 1; + repeated string debug_info = 2; +} + +/* + * An obfuscated and simplified time zone suggestion for metrics use. + * + * The suggestion's time zone IDs (which relate to location) are obfuscated by + * mapping them to an ordinal. When the ordinal is assigned consistently across + * several objects (i.e. so the same time zone ID is always mapped to the same + * ordinal), this allows comparisons between those objects. For example, we can + * answer "did these two suggestions agree?", "does the suggestion match the + * device's current time zone?", without leaking knowledge of location. Ordinals + * are also significantly more compact than full IANA TZDB IDs, albeit highly + * unstable and of limited use. + */ +message MetricsTimeZoneSuggestion { + option (android.msg_privacy).dest = DEST_AUTOMATIC; + + enum Type { + CERTAIN = 1; + UNCERTAIN = 2; + } + optional Type type = 1; + + // The ordinals for time zone(s) in the suggestion. Always empty for + // UNCERTAIN, and can be empty for CERTAIN, for example when the device is in + // a disputed area / on an ocean. + repeated uint32 time_zone_ordinals = 2; +} diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index f7eb3648dfc0..99ad6d100e55 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -506,6 +506,8 @@ <protected-broadcast android:name="android.app.action.ACTION_PASSWORD_FAILED" /> <protected-broadcast android:name="android.app.action.ACTION_PASSWORD_SUCCEEDED" /> <protected-broadcast android:name="com.android.server.ACTION_EXPIRED_PASSWORD_NOTIFICATION" /> + <protected-broadcast android:name="com.android.server.ACTION_PROFILE_OFF_DEADLINE" /> + <protected-broadcast android:name="com.android.server.ACTION_TURN_PROFILE_ON_NOTIFICATION" /> <protected-broadcast android:name="android.intent.action.MANAGED_PROFILE_ADDED" /> <protected-broadcast android:name="android.intent.action.MANAGED_PROFILE_UNLOCKED" /> @@ -5257,15 +5259,20 @@ <permission android:name="android.permission.MANAGE_MUSIC_RECOGNITION" android:protectionLevel="signature|privileged" /> + <!-- @SystemApi Allows an application to manage speech recognition service. + @hide <p>Not for use by third-party applications.</p> --> + <permission android:name="android.permission.MANAGE_SPEECH_RECOGNITION" + android:protectionLevel="signature" /> + <!-- @SystemApi Allows an application to manage the content suggestions service. @hide <p>Not for use by third-party applications.</p> --> <permission android:name="android.permission.MANAGE_CONTENT_SUGGESTIONS" - android:protectionLevel="signature" /> + android:protectionLevel="signature" /> <!-- @SystemApi Allows an application to manage the app predictions service. @hide <p>Not for use by third-party applications.</p> --> <permission android:name="android.permission.MANAGE_APP_PREDICTIONS" - android:protectionLevel="signature|appPredictor" /> + android:protectionLevel="signature|appPredictor" /> <!-- @SystemApi Allows an application to manage the search ui service. @hide <p>Not for use by third-party applications.</p> --> diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 8bc3a52fa17b..397c6467f020 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -1961,6 +1961,8 @@ <string name="config_systemWifiCoexManager" translateable="false"></string> <!-- The name of the package that will hold the wellbeing role. --> <string name="config_systemWellbeing" translatable="false"></string> + <!-- The name of the package that will hold the television notification handler role --> + <string name="config_systemTelevisionNotificationHandler" translatable="false"></string> <!-- The name of the package that will be allowed to change its components' label/icon. --> <string name="config_overrideComponentUiPackage" translatable="false"></string> @@ -2270,6 +2272,9 @@ <bool name="config_dozeWakeLockScreenSensorAvailable">false</bool> <integer name="config_dozeWakeLockScreenDebounce">300</integer> + <!-- Type of the quick pickup sensor. Empty if quick pickup is not supported. --> + <string name="config_quickPickupSensorType" translatable="false"></string> + <!-- Control whether the always on display mode is available. This should only be enabled on devices where the display has been tuned to be power efficient in DOZE and/or DOZE_SUSPEND states. --> diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index 293018d881d8..e0a728c233b2 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -3071,7 +3071,6 @@ <public name="windowSplashScreenAnimationDuration"/> <public name="windowSplashScreenBrandingImage"/> <public name="splashScreenTheme" /> - <public name="rippleStyle" /> <public name="maxResizeWidth" /> <public name="maxResizeHeight" /> <public name="targetCellWidth" /> @@ -3175,6 +3174,8 @@ <public name="config_systemWifiCoexManager" /> <!-- @hide @SystemApi --> <public name="config_systemWellbeing" /> + <!-- @hide @SystemApi --> + <public name="config_systemTelevisionNotificationHandler" /> </public-group> <public-group type="id" first-id="0x01020055"> diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 2ffa29b53331..4af561b947cd 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -1532,6 +1532,8 @@ <string name="biometric_dialog_default_title">Verify it\u2019s you</string> <!-- Subtitle shown on the system-provided biometric dialog, asking the user to authenticate with a biometric (e.g. fingerprint or face). [CHAR LIMIT=70] --> <string name="biometric_dialog_default_subtitle">Use your biometric to continue</string> + <!-- Subtitle shown on the system-provided biometric dialog, asking the user to authenticate with a biometric (e.g. fingerprint or face) or their screen lock credential (i.e. PIN, pattern, or password). [CHAR LIMIT=90] --> + <string name="biometric_or_screen_lock_dialog_default_subtitle">Use your biometric or screen lock to continue</string> <!-- Message shown when biometric hardware is not available [CHAR LIMIT=50] --> <string name="biometric_error_hw_unavailable">Biometric hardware unavailable</string> @@ -1604,6 +1606,8 @@ <string name="fingerprint_or_screen_lock_app_setting_name">Use fingerprint or screen lock</string> <!-- Subtitle shown on the system-provided biometric dialog, asking the user to authenticate with their fingerprint. [CHAR LIMIT=70] --> <string name="fingerprint_dialog_default_subtitle">Use your fingerprint to continue</string> + <!-- Subtitle shown on the system-provided biometric dialog, asking the user to authenticate with their fingerprint or screen lock credential (i.e. PIN, pattern, or password). [CHAR LIMIT=90] --> + <string name="fingerprint_or_screen_lock_dialog_default_subtitle">Use your fingerprint or screen lock to continue</string> <!-- Array containing custom error messages from vendor. Vendor is expected to add and translate these strings --> <string-array name="fingerprint_error_vendor"> @@ -1704,6 +1708,8 @@ <string name="face_or_screen_lock_app_setting_name">Use face or screen lock</string> <!-- Subtitle shown on the system-provided biometric dialog, asking the user to authenticate with their face. [CHAR LIMIT=70] --> <string name="face_dialog_default_subtitle">Use face unlock to continue</string> + <!-- Subtitle shown on the system-provided biometric dialog, asking the user to authenticate with their face or screen lock credential (i.e. PIN, pattern, or password). [CHAR LIMIT=90] --> + <string name="face_or_screen_lock_dialog_default_subtitle">Use your face or screen lock to continue</string> <!-- Array containing custom error messages from vendor. Vendor is expected to add and translate these strings --> <string-array name="face_error_vendor"> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 07938fd3a324..3db3d1657a55 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -2473,6 +2473,7 @@ <java-symbol type="string" name="biometric_or_screen_lock_app_setting_name" /> <java-symbol type="string" name="biometric_dialog_default_title" /> <java-symbol type="string" name="biometric_dialog_default_subtitle" /> + <java-symbol type="string" name="biometric_or_screen_lock_dialog_default_subtitle" /> <java-symbol type="string" name="biometric_error_hw_unavailable" /> <java-symbol type="string" name="biometric_error_user_canceled" /> <java-symbol type="string" name="biometric_not_recognized" /> @@ -2504,6 +2505,7 @@ <java-symbol type="string" name="fingerprint_app_setting_name" /> <java-symbol type="string" name="fingerprint_or_screen_lock_app_setting_name" /> <java-symbol type="string" name="fingerprint_dialog_default_subtitle" /> + <java-symbol type="string" name="fingerprint_or_screen_lock_dialog_default_subtitle" /> <java-symbol type="string" name="fingerprint_authenticated" /> <java-symbol type="string" name="fingerprint_error_no_fingerprints" /> <java-symbol type="string" name="fingerprint_error_hw_not_present" /> @@ -2553,6 +2555,7 @@ <java-symbol type="string" name="face_app_setting_name" /> <java-symbol type="string" name="face_or_screen_lock_app_setting_name" /> <java-symbol type="string" name="face_dialog_default_subtitle" /> + <java-symbol type="string" name="face_or_screen_lock_dialog_default_subtitle" /> <java-symbol type="string" name="face_authenticated_no_confirmation_required" /> <java-symbol type="string" name="face_authenticated_confirmation_required" /> <java-symbol type="string" name="face_error_security_update_required" /> @@ -3592,6 +3595,7 @@ <java-symbol type="string" name="config_dozeUdfpsLongPressSensorType" /> <java-symbol type="bool" name="config_dozeWakeLockScreenSensorAvailable" /> <java-symbol type="integer" name="config_dozeWakeLockScreenDebounce" /> + <java-symbol type="string" name="config_quickPickupSensorType" /> <java-symbol type="array" name="config_allowedGlobalInstantAppSettings" /> <java-symbol type="array" name="config_allowedSystemInstantAppSettings" /> diff --git a/core/tests/coretests/src/android/view/inputmethod/InputMethodSubtypeTest.java b/core/tests/coretests/src/android/view/inputmethod/InputMethodSubtypeTest.java index 1e0e1235161c..f5fcb03bb816 100644 --- a/core/tests/coretests/src/android/view/inputmethod/InputMethodSubtypeTest.java +++ b/core/tests/coretests/src/android/view/inputmethod/InputMethodSubtypeTest.java @@ -125,7 +125,7 @@ public class InputMethodSubtypeTest { assertEquals("he", clonedSubtypeHe.getLocale()); } - private static final InputMethodSubtype cloneViaParcel(final InputMethodSubtype original) { + private static InputMethodSubtype cloneViaParcel(final InputMethodSubtype original) { Parcel parcel = null; try { parcel = Parcel.obtain(); @@ -157,4 +157,4 @@ public class InputMethodSubtypeTest { .setIsAsciiCapable(true) .build(); } -}
\ No newline at end of file +} diff --git a/core/tests/coretests/src/android/view/inputmethod/SparseRectFArrayTest.java b/core/tests/coretests/src/android/view/inputmethod/SparseRectFArrayTest.java index 453ad72b64dc..f264cc630dc5 100644 --- a/core/tests/coretests/src/android/view/inputmethod/SparseRectFArrayTest.java +++ b/core/tests/coretests/src/android/view/inputmethod/SparseRectFArrayTest.java @@ -62,20 +62,20 @@ public class SparseRectFArrayTest { @Test public void testBuilder() throws Exception { - final RectF TEMP_RECT = new RectF(10.0f, 20.0f, 30.0f, 40.0f); - final int TEMP_FLAGS = 0x1234; + final RectF testRect = new RectF(10.0f, 20.0f, 30.0f, 40.0f); + final int testFlags = 0x1234; final SparseRectFArrayBuilder builder = new SparseRectFArrayBuilder(); - builder.append(100, TEMP_RECT.left, TEMP_RECT.top, TEMP_RECT.right, TEMP_RECT.bottom, - TEMP_FLAGS); + builder.append(100, testRect.left, testRect.top, testRect.right, testRect.bottom, + testFlags); assertNull(builder.build().get(-1)); assertNull(builder.build().get(0)); assertNull(builder.build().get(99)); assertEquals(0, builder.build().getFlags(99, 0 /* valueIfKeyNotFound */)); assertEquals(1, builder.build().getFlags(99, 1 /* valueIfKeyNotFound */)); - assertEquals(TEMP_RECT, builder.build().get(100)); - assertEquals(TEMP_FLAGS, builder.build().getFlags(100, 0 /* valueIfKeyNotFound */)); - assertEquals(TEMP_FLAGS, builder.build().getFlags(100, 1 /* valueIfKeyNotFound */)); + assertEquals(testRect, builder.build().get(100)); + assertEquals(testFlags, builder.build().getFlags(100, 0 /* valueIfKeyNotFound */)); + assertEquals(testFlags, builder.build().getFlags(100, 1 /* valueIfKeyNotFound */)); assertNull(builder.build().get(101)); assertEquals(0, builder.build().getFlags(101, 0 /* valueIfKeyNotFound */)); assertEquals(1, builder.build().getFlags(101, 1 /* valueIfKeyNotFound */)); diff --git a/core/tests/coretests/src/com/android/internal/os/LooperStatsTest.java b/core/tests/coretests/src/com/android/internal/os/LooperStatsTest.java index d50bb05c3588..b89e8bce5fc9 100644 --- a/core/tests/coretests/src/com/android/internal/os/LooperStatsTest.java +++ b/core/tests/coretests/src/com/android/internal/os/LooperStatsTest.java @@ -232,7 +232,7 @@ public final class LooperStatsTest { assertThat(entry3.handlerClassName).isEqualTo( "com.android.internal.os.LooperStatsTest$TestHandlerSecond"); assertThat(entry3.messageName).startsWith( - "com.android.internal.os.LooperStatsTest-$$ExternalSyntheticLambda"); + "com.android.internal.os.LooperStatsTest$$ExternalSyntheticLambda4"); assertThat(entry3.messageCount).isEqualTo(1); assertThat(entry3.recordedMessageCount).isEqualTo(1); assertThat(entry3.exceptionCount).isEqualTo(0); diff --git a/data/etc/services.core.protolog.json b/data/etc/services.core.protolog.json index 43d56626ed1a..4a3bd99b8f7c 100644 --- a/data/etc/services.core.protolog.json +++ b/data/etc/services.core.protolog.json @@ -307,6 +307,12 @@ "group": "WM_DEBUG_STARTING_WINDOW", "at": "com\/android\/server\/wm\/ActivityRecord.java" }, + "-1777196134": { + "message": "goodToGo(): No apps to animate, mPendingAnimations=%d", + "level": "DEBUG", + "group": "WM_DEBUG_REMOTE_ANIMATIONS", + "at": "com\/android\/server\/wm\/RemoteAnimationController.java" + }, "-1770075711": { "message": "Adding window client %s that is dead, aborting.", "level": "WARN", @@ -1987,12 +1993,6 @@ "group": "WM_DEBUG_STATES", "at": "com\/android\/server\/wm\/ActivityRecord.java" }, - "194124419": { - "message": "goodToGo(): Animation finished already, canceled=%s mPendingAnimations=%d", - "level": "DEBUG", - "group": "WM_DEBUG_REMOTE_ANIMATIONS", - "at": "com\/android\/server\/wm\/RemoteAnimationController.java" - }, "200829729": { "message": "ScreenRotationAnimation onAnimationEnd", "level": "DEBUG", @@ -2089,6 +2089,12 @@ "group": "WM_DEBUG_ORIENTATION", "at": "com\/android\/server\/wm\/DragState.java" }, + "269976641": { + "message": "goodToGo(): Animation canceled already", + "level": "DEBUG", + "group": "WM_DEBUG_REMOTE_ANIMATIONS", + "at": "com\/android\/server\/wm\/RemoteAnimationController.java" + }, "274773837": { "message": "applyAnimation: anim=%s nextAppTransition=ANIM_CLIP_REVEAL transit=%s Callers=%s", "level": "VERBOSE", diff --git a/data/keyboards/Vendor_0957_Product_0001.idc b/data/keyboards/Vendor_0957_Product_0001.idc index e1f4346369f3..39479ce725e1 100644 --- a/data/keyboards/Vendor_0957_Product_0001.idc +++ b/data/keyboards/Vendor_0957_Product_0001.idc @@ -19,5 +19,4 @@ # Basic Parameters keyboard.layout = Vendor_0957_Product_0001 -keyboard.characterMap = Vendor_0957_Product_0001 audio.mic = 1
\ No newline at end of file diff --git a/data/keyboards/Vendor_248a_Product_8266.idc b/data/keyboards/Vendor_248a_Product_8266.idc new file mode 100644 index 000000000000..3021655c286e --- /dev/null +++ b/data/keyboards/Vendor_248a_Product_8266.idc @@ -0,0 +1,24 @@ +# Copyright (C) 2021 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. + +# +# Input Device Configuration file for Google Reference RCU Remote. +# +# + +# Basic Parameters +# Due to a memory error on early prototypes of the reference remote control +# the VID/PID is mapped to 248a/8266 instead of 0957/0001 +keyboard.layout = Vendor_0957_Product_0001 +audio.mic = 1
\ No newline at end of file diff --git a/graphics/java/android/graphics/drawable/RippleDrawable.java b/graphics/java/android/graphics/drawable/RippleDrawable.java index 7fd3cdc39cc7..d6bbee90d73b 100644 --- a/graphics/java/android/graphics/drawable/RippleDrawable.java +++ b/graphics/java/android/graphics/drawable/RippleDrawable.java @@ -110,17 +110,6 @@ import java.util.Arrays; * </pre> * * @attr ref android.R.styleable#RippleDrawable_color - * - * To change the ripple style, assign the value of "solid" or "patterned" to the android:rippleStyle - * attribute. - * - * <pre> - * <code><!-- A red ripple masked against an opaque rectangle. --/> - * <ripple android:rippleStyle="patterned"> - * </ripple></code> - * </pre> - * - * @attr ref android.R.styleable#RippleDrawable_rippleStyle */ public class RippleDrawable extends LayerDrawable { /** @@ -132,12 +121,14 @@ public class RippleDrawable extends LayerDrawable { /** * Ripple style where a solid circle is drawn. This is also the default style * @see #setRippleStyle(int) + * @hide */ public static final int STYLE_SOLID = 0; /** * Ripple style where a circle shape with a patterned, * noisy interior expands from the hotspot to the bounds". * @see #setRippleStyle(int) + * @hide */ public static final int STYLE_PATTERNED = 1; @@ -1248,6 +1239,7 @@ public class RippleDrawable extends LayerDrawable { * @see #STYLE_PATTERNED * * @param style The style of the ripple + * @hide */ public void setRippleStyle(@RippleStyle int style) throws IllegalArgumentException { if (style == STYLE_SOLID || style == STYLE_PATTERNED) { @@ -1260,6 +1252,7 @@ public class RippleDrawable extends LayerDrawable { /** * Get the current ripple style * @return Ripple style + * @hide */ public @RippleStyle int getRippleStyle() { return mState.mRippleStyle; diff --git a/keystore/java/android/security/AndroidKeyStoreMaintenance.java b/keystore/java/android/security/AndroidKeyStoreMaintenance.java index ed789f03f9ba..55015696ff47 100644 --- a/keystore/java/android/security/AndroidKeyStoreMaintenance.java +++ b/keystore/java/android/security/AndroidKeyStoreMaintenance.java @@ -20,7 +20,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.os.ServiceManager; import android.os.ServiceSpecificException; -import android.security.usermanager.IKeystoreUserManager; +import android.security.maintenance.IKeystoreMaintenance; import android.system.keystore2.Domain; import android.system.keystore2.ResponseCode; import android.util.Log; @@ -34,9 +34,9 @@ public class AndroidKeyStoreMaintenance { public static final int SYSTEM_ERROR = ResponseCode.SYSTEM_ERROR; - private static IKeystoreUserManager getService() { - return IKeystoreUserManager.Stub.asInterface( - ServiceManager.checkService("android.security.usermanager")); + private static IKeystoreMaintenance getService() { + return IKeystoreMaintenance.Stub.asInterface( + ServiceManager.checkService("android.security.maintenance")); } /** diff --git a/keystore/java/android/security/keystore/AttestationUtils.java b/keystore/java/android/security/keystore/AttestationUtils.java index f48da74eb397..cd77d9c2723f 100644 --- a/keystore/java/android/security/keystore/AttestationUtils.java +++ b/keystore/java/android/security/keystore/AttestationUtils.java @@ -22,7 +22,6 @@ import android.annotation.RequiresPermission; import android.annotation.SystemApi; import android.content.Context; import android.os.Build; -import android.security.KeyStore; import android.security.keymaster.KeymasterArguments; import android.security.keymaster.KeymasterCertificateChain; import android.security.keymaster.KeymasterDefs; @@ -32,9 +31,14 @@ import android.util.ArraySet; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.nio.charset.StandardCharsets; +import java.security.KeyPairGenerator; +import java.security.KeyStore; +import java.security.SecureRandom; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; +import java.security.spec.ECGenParameterSpec; import java.util.Collection; +import java.util.Random; import java.util.Set; /** @@ -223,22 +227,47 @@ public abstract class AttestationUtils { @NonNull public static X509Certificate[] attestDeviceIds(Context context, @NonNull int[] idTypes, @NonNull byte[] attestationChallenge) throws DeviceIdAttestationException { - final KeymasterArguments attestArgs = prepareAttestationArgumentsForDeviceId( - context, idTypes, attestationChallenge); - - // Perform attestation. - final KeymasterCertificateChain outChain = new KeymasterCertificateChain(); - final int errorCode = KeyStore.getInstance().attestDeviceIds(attestArgs, outChain); - if (errorCode != KeyStore.NO_ERROR) { - throw new DeviceIdAttestationException("Unable to perform attestation", - KeyStore.getKeyStoreException(errorCode)); + String keystoreAlias = generateRandomAlias(); + KeyGenParameterSpec.Builder builder = + new KeyGenParameterSpec.Builder(keystoreAlias, KeyProperties.PURPOSE_SIGN) + .setAlgorithmParameterSpec(new ECGenParameterSpec("secp256r1")) + .setDigests(KeyProperties.DIGEST_SHA256) + .setAttestationChallenge(attestationChallenge); + + if (idTypes != null) { + builder.setAttestationIds(idTypes); + builder.setDevicePropertiesAttestationIncluded(true); } try { - return parseCertificateChain(outChain); - } catch (KeyAttestationException e) { - throw new DeviceIdAttestationException(e.getMessage(), e); + KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance( + KeyProperties.KEY_ALGORITHM_EC, "AndroidKeyStore"); + keyPairGenerator.initialize(builder.build()); + keyPairGenerator.generateKeyPair(); + + KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore"); + keyStore.load(null); + + X509Certificate[] certificateChain = + (X509Certificate[]) keyStore.getCertificateChain(keystoreAlias); + + keyStore.deleteEntry(keystoreAlias); + + return certificateChain; + } catch (Exception e) { + throw new DeviceIdAttestationException("Unable to perform attestation", e); + } + } + + private static String generateRandomAlias() { + Random random = new SecureRandom(); + StringBuilder builder = new StringBuilder(); + // Pick random uppercase letters, A-Z. 20 of them gives us ~94 bits of entropy, which + // should prevent any conflicts with app-selected aliases, even for very unlucky users. + for (int i = 0; i < 20; ++i) { + builder.append(random.nextInt(26) + 'A'); } + return builder.toString(); } /** diff --git a/keystore/java/android/security/keystore/KeyGenParameterSpec.java b/keystore/java/android/security/keystore/KeyGenParameterSpec.java index 72735a787b7f..5cb2c3b41517 100644 --- a/keystore/java/android/security/keystore/KeyGenParameterSpec.java +++ b/keystore/java/android/security/keystore/KeyGenParameterSpec.java @@ -467,8 +467,8 @@ public final class KeyGenParameterSpec implements AlgorithmParameterSpec, UserAu * * @return The numeric namespace as configured in the keystore2_key_contexts files of Android's * SEPolicy. - * TODO b/171806779 link to public Keystore 2.0 documentation. - * See bug for more details for now. + * See <a href="https://source.android.com/security/keystore#access-control"> + * Keystore 2.0 access control</a> * @hide */ @SystemApi @@ -1042,9 +1042,9 @@ public final class KeyGenParameterSpec implements AlgorithmParameterSpec, UserAu * keys between system and vendor components, e.g., WIFI settings and WPA supplicant. * * @param namespace Numeric SELinux namespace as configured in keystore2_key_contexts - * of Android's SEPolicy. - * TODO b/171806779 link to public Keystore 2.0 documentation. - * See bug for more details for now. + * of Android's SEPolicy. + * See <a href="https://source.android.com/security/keystore#access-control"> + * Keystore 2.0 access control</a> * @return this Builder object. * * @hide diff --git a/keystore/java/android/security/keystore2/AndroidKeyStoreProvider.java b/keystore/java/android/security/keystore2/AndroidKeyStoreProvider.java index d36695b9b410..fa852e33a1d8 100644 --- a/keystore/java/android/security/keystore2/AndroidKeyStoreProvider.java +++ b/keystore/java/android/security/keystore2/AndroidKeyStoreProvider.java @@ -340,11 +340,11 @@ public class AndroidKeyStoreProvider extends Provider { * @param keyStore The keystore2 backend. * @param alias The alias of the key in the Keystore database. * @param namespace The a Keystore namespace. This is used by system api only to request - * Android system specific keystore namespace, which can be configured - * in the device's SEPolicy. Third party apps and most system components - * set this parameter to -1 to indicate their application specific namespace. - * TODO b/171806779 link to public Keystore 2.0 documentation. - * See bug for more details for now. + * Android system specific keystore namespace, which can be configured + * in the device's SEPolicy. Third party apps and most system components + * set this parameter to -1 to indicate their application specific namespace. + * See <a href="https://source.android.com/security/keystore#access-control"> + * Keystore 2.0 access control</a> * @hide **/ @NonNull diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java index 725f87d93e4e..580861cf4974 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java @@ -121,6 +121,19 @@ public class PhonePipMenuController implements PipMenuController { } }; + private final float[] mTmpValues = new float[9]; + private final Runnable mUpdateEmbeddedMatrix = () -> { + if (mPipMenuView == null || mPipMenuView.getViewRootImpl() == null) { + return; + } + mMoveTransform.getValues(mTmpValues); + try { + mPipMenuView.getViewRootImpl().getAccessibilityEmbeddedConnection() + .setScreenMatrix(mTmpValues); + } catch (RemoteException e) { + } + }; + public PhonePipMenuController(Context context, PipMediaController mediaController, SystemWindows systemWindows, ShellExecutor mainExecutor, Handler mainHandler) { @@ -306,6 +319,11 @@ public class PhonePipMenuController implements PipMenuController { } else { mApplier.scheduleApply(params); } + + if (mPipMenuView.getViewRootImpl() != null) { + mPipMenuView.getHandler().removeCallbacks(mUpdateEmbeddedMatrix); + mPipMenuView.getHandler().post(mUpdateEmbeddedMatrix); + } } /** diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/PipAppHelper.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/PipAppHelper.kt index ecc066be734f..5a96a7c8cbd9 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/PipAppHelper.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/PipAppHelper.kt @@ -17,7 +17,6 @@ package com.android.wm.shell.flicker.helpers import android.app.Instrumentation -import android.graphics.Point import android.media.session.MediaController import android.media.session.MediaSessionManager import android.os.SystemClock @@ -135,11 +134,8 @@ class PipAppHelper(instrumentation: Instrumentation) : BaseAppHelper( expandPipWindow(wmHelper) val exitPipObject = uiDevice.findObject(By.res(SYSTEMUI_PACKAGE, "dismiss")) requireNotNull(exitPipObject) { "PIP window dismiss button not found" } - val coordinatesInWindow = exitPipObject.visibleBounds - val windowOffset = wmHelper.getWindowRegion(component).bounds - val newCoordinates = Point(windowOffset.left + coordinatesInWindow.centerX(), - windowOffset.top + coordinatesInWindow.centerY()) - uiDevice.click(newCoordinates.x, newCoordinates.y) + val dismissButtonBounds = exitPipObject.visibleBounds + uiDevice.click(dismissButtonBounds.centerX(), dismissButtonBounds.centerY()) } // Wait for animation to complete. diff --git a/libs/hwui/utils/PaintUtils.h b/libs/hwui/utils/PaintUtils.h index 09c6a4fdf50d..a8f2d9a28d67 100644 --- a/libs/hwui/utils/PaintUtils.h +++ b/libs/hwui/utils/PaintUtils.h @@ -52,18 +52,10 @@ public: return mode == SkBlendMode::kSrcOver || mode == SkBlendMode::kSrc; } - static bool isBlendedShader(const SkShader* shader) { - if (shader == nullptr) { - return false; - } - return !shader->isOpaque(); - } + static bool isBlendedShader(const SkShader* shader) { return shader && !shader->isOpaque(); } static bool isBlendedColorFilter(const SkColorFilter* filter) { - if (filter == nullptr) { - return false; - } - return (filter->getFlags() & SkColorFilter::kAlphaUnchanged_Flag) == 0; + return filter && !filter->isAlphaUnchanged(); } static inline SkBlendMode getBlendModeDirect(const SkPaint* paint) { diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java index 1cef0922a48e..e8e263147c6e 100644 --- a/media/java/android/media/AudioManager.java +++ b/media/java/android/media/AudioManager.java @@ -6729,7 +6729,7 @@ public class AudioManager { */ public Map<Integer, Boolean> getSurroundFormats() { Map<Integer, Boolean> surroundFormats = new HashMap<>(); - int status = AudioSystem.getSurroundFormats(surroundFormats, false); + int status = AudioSystem.getSurroundFormats(surroundFormats); if (status != AudioManager.SUCCESS) { // fail and bail! Log.e(TAG, "getSurroundFormats failed:" + status); @@ -6762,20 +6762,17 @@ public class AudioManager { /** * @hide * Returns all surround formats that are reported by the connected HDMI device. - * The keys are not affected by calling setSurroundFormatEnabled(), and the values - * are not affected by calling setSurroundFormatEnabled() when in AUTO mode. - * This information can used to show the AUTO setting for SurroundSound. + * The return values are not affected by calling setSurroundFormatEnabled. * - * @return a map where the key is a surround format and - * the value indicates the surround format is enabled or not + * @return a list of surround formats */ - public Map<Integer, Boolean> getReportedSurroundFormats() { - Map<Integer, Boolean> reportedSurroundFormats = new HashMap<>(); - int status = AudioSystem.getSurroundFormats(reportedSurroundFormats, true); + public ArrayList<Integer> getReportedSurroundFormats() { + ArrayList<Integer> reportedSurroundFormats = new ArrayList<>(); + int status = AudioSystem.getReportedSurroundFormats(reportedSurroundFormats); if (status != AudioManager.SUCCESS) { // fail and bail! Log.e(TAG, "getReportedSurroundFormats failed:" + status); - return new HashMap<Integer, Boolean>(); // Always return a map. + return new ArrayList<Integer>(); // Always return a list. } return reportedSurroundFormats; } @@ -7087,26 +7084,22 @@ public class AudioManager { * <pre class="prettyprint"> * // Get an AudioManager instance * AudioManager audioManager = Context.getSystemService(AudioManager.class); - * try { - * AudioDeviceInfo speakerDevice = null; - * List<AudioDeviceInfo> devices = audioManager.getAvailableCommunicationDevices(); - * for (AudioDeviceInfo device : devices) { - * if (device.getType() == AudioDeviceInfo.TYPE_BUILTIN_SPEAKER) { - * speakerDevice = device; - * break; - * } + * AudioDeviceInfo speakerDevice = null; + * List<AudioDeviceInfo> devices = audioManager.getAvailableCommunicationDevices(); + * for (AudioDeviceInfo device : devices) { + * if (device.getType() == AudioDeviceInfo.TYPE_BUILTIN_SPEAKER) { + * speakerDevice = device; + * break; * } - * if (speakerDevice != null) { - * // Turn speakerphone ON. - * boolean result = audioManager.setCommunicationDevice(speakerDevice); - * if (!result) { - * // Handle error. - * } - * // Turn speakerphone OFF. - * audioManager.clearCommunicationDevice(); + * } + * if (speakerDevice != null) { + * // Turn speakerphone ON. + * boolean result = audioManager.setCommunicationDevice(speakerDevice); + * if (!result) { + * // Handle error. * } - * } catch (IllegalArgumentException e) { - * // Handle exception. + * // Turn speakerphone OFF. + * audioManager.clearCommunicationDevice(); * } * </pre> * @param device the requested audio device. diff --git a/media/java/android/media/AudioSystem.java b/media/java/android/media/AudioSystem.java index f1f6cb1f42be..8134d6f8352d 100644 --- a/media/java/android/media/AudioSystem.java +++ b/media/java/android/media/AudioSystem.java @@ -1699,8 +1699,10 @@ public class AudioSystem public static native int getMicrophones(ArrayList<MicrophoneInfo> microphonesInfo); /** @hide */ - public static native int getSurroundFormats(Map<Integer, Boolean> surroundFormats, - boolean reported); + public static native int getSurroundFormats(Map<Integer, Boolean> surroundFormats); + + /** @hide */ + public static native int getReportedSurroundFormats(ArrayList<Integer> surroundFormats); /** * @hide diff --git a/media/java/android/media/MediaRouter2.java b/media/java/android/media/MediaRouter2.java index dc9c58ebf18c..b4db3055e58c 100644 --- a/media/java/android/media/MediaRouter2.java +++ b/media/java/android/media/MediaRouter2.java @@ -60,6 +60,7 @@ import java.util.stream.Collectors; public final class MediaRouter2 { private static final String TAG = "MR2"; private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); + private static final Object sSystemRouterLock = new Object(); private static final Object sRouterLock = new Object(); // The maximum time for the old routing controller available after transfer. @@ -67,8 +68,8 @@ public final class MediaRouter2 { // The manager request ID representing that no manager is involved. private static final long MANAGER_REQUEST_ID_NONE = MediaRoute2ProviderService.REQUEST_ID_NONE; - @GuardedBy("sRouterLock") - private static Map<String, MediaRouter2> sMediaRouter2Map = new ArrayMap<>(); + @GuardedBy("sSystemRouterLock") + private static Map<String, MediaRouter2> sSystemMediaRouter2Map = new ArrayMap<>(); private static MediaRouter2Manager sManager; @GuardedBy("sRouterLock") @@ -76,6 +77,7 @@ public final class MediaRouter2 { private final Context mContext; private final IMediaRouterService mMediaRouterService; + private final Object mLock = new Object(); private final CopyOnWriteArrayList<RouteCallbackRecord> mRouteCallbackRecords = new CopyOnWriteArrayList<>(); @@ -88,27 +90,29 @@ public final class MediaRouter2 { new CopyOnWriteArrayList<>(); private final String mClientPackageName; + private final ManagerCallback mManagerCallback; + private final String mPackageName; - @GuardedBy("sRouterLock") + @GuardedBy("mLock") final Map<String, MediaRoute2Info> mRoutes = new ArrayMap<>(); final RoutingController mSystemController; - @GuardedBy("sRouterLock") + @GuardedBy("mLock") private RouteDiscoveryPreference mDiscoveryPreference = RouteDiscoveryPreference.EMPTY; // TODO: Make MediaRouter2 is always connected to the MediaRouterService. - @GuardedBy("sRouterLock") + @GuardedBy("mLock") MediaRouter2Stub mStub; - @GuardedBy("sRouterLock") + @GuardedBy("mLock") private final Map<String, RoutingController> mNonSystemRoutingControllers = new ArrayMap<>(); private final AtomicInteger mNextRequestId = new AtomicInteger(1); final Handler mHandler; - @GuardedBy("sRouterLock") + @GuardedBy("mLock") private boolean mShouldUpdateRoutes = true; private volatile List<MediaRoute2Info> mFilteredRoutes = Collections.emptyList(); private volatile OnGetControllerHintsListener mOnGetControllerHintsListener; @@ -130,6 +134,11 @@ public final class MediaRouter2 { /** * Gets an instance of the media router which controls the app's media routing. * Returns {@code null} if the given package name is invalid. + * <p> + * Note: For media routers created with this method, the discovery preference passed to + * {@link #registerRouteCallback} will have no effect. The callback will be called accordingly + * with the client app's discovery preference. Therefore, it is recommended to pass + * {@link RouteDiscoveryPreference#EMPTY} there. * * @param clientPackageName the package name of the app to control * @hide @@ -149,15 +158,17 @@ public final class MediaRouter2 { return null; } - synchronized (sRouterLock) { - MediaRouter2 instance = sMediaRouter2Map.get(clientPackageName); + synchronized (sSystemRouterLock) { + MediaRouter2 instance = sSystemMediaRouter2Map.get(clientPackageName); if (instance == null) { // TODO: Add permission check here using MODIFY_AUDIO_ROUTING. if (sManager == null) { sManager = MediaRouter2Manager.getInstance(context.getApplicationContext()); } instance = new MediaRouter2(context, clientPackageName); - sMediaRouter2Map.put(clientPackageName, instance); + sSystemMediaRouter2Map.put(clientPackageName, instance); + // TODO: Remove router instance once it is not needed. + instance.registerManagerCallback(); } return instance; } @@ -192,11 +203,14 @@ public final class MediaRouter2 { } mSystemController = new SystemRoutingController(currentSystemSessionInfo); + // Only used by system MediaRouter2. mClientPackageName = null; + mManagerCallback = null; } private MediaRouter2(Context context, String clientPackageName) { mClientPackageName = clientPackageName; + mManagerCallback = new ManagerCallback(); mContext = context; mMediaRouterService = null; mPackageName = null; @@ -220,8 +234,8 @@ public final class MediaRouter2 { } /** - * Gets the target package name of the app which this media router controls. - * This is only non-null when the router instance is created with the target package name. + * Gets the client package name of the app which this media router controls. + * This is only non-null when the router instance is created with the client package name. * * @see #getInstance(Context, String) * @hide @@ -245,6 +259,9 @@ public final class MediaRouter2 { Objects.requireNonNull(executor, "executor must not be null"); Objects.requireNonNull(routeCallback, "callback must not be null"); Objects.requireNonNull(preference, "preference must not be null"); + if (isSystemRouter()) { + preference = RouteDiscoveryPreference.EMPTY; + } RouteCallbackRecord record = new RouteCallbackRecord(executor, routeCallback, preference); @@ -253,7 +270,11 @@ public final class MediaRouter2 { // is happening but it's okay because either this or the other registration should be done. mRouteCallbackRecords.addIfAbsent(record); - synchronized (sRouterLock) { + if (isSystemRouter()) { + return; + } + + synchronized (mLock) { if (mStub == null) { MediaRouter2Stub stub = new MediaRouter2Stub(); try { @@ -289,7 +310,11 @@ public final class MediaRouter2 { return; } - synchronized (sRouterLock) { + if (isSystemRouter()) { + return; + } + + synchronized (mLock) { if (mStub == null) { return; } @@ -326,22 +351,37 @@ public final class MediaRouter2 { } /** + * Gets the list of all discovered routes. + * This list includes the routes that are not related to the client app. + * <p> + * This will return an empty list for non-system media routers. + * + * @hide + */ + //@SystemApi + public List<MediaRoute2Info> getAllRoutes() { + if (isSystemRouter()) { + return sManager.getAllRoutes(); + } + return Collections.emptyList(); + } + + /** * Gets the unmodifiable list of {@link MediaRoute2Info routes} currently * known to the media router. * <p> * Please note that the list can be changed before callbacks are invoked. * </p> - * * @return the list of routes that contains at least one of the route features in discovery * preferences registered by the application */ @NonNull public List<MediaRoute2Info> getRoutes() { - if (mClientPackageName != null) { + if (isSystemRouter()) { return sManager.getAvailableRoutes(mClientPackageName); } - synchronized (sRouterLock) { + synchronized (mLock) { if (mShouldUpdateRoutes) { mShouldUpdateRoutes = false; @@ -449,7 +489,7 @@ public final class MediaRouter2 { * @see TransferCallback#onTransferFailure */ public void transferTo(@NonNull MediaRoute2Info route) { - if (mClientPackageName != null) { + if (isSystemRouter()) { sManager.selectRoute(mClientPackageName, route); return; } @@ -464,7 +504,7 @@ public final class MediaRouter2 { * controls the media routing, this method is a no-op. */ public void stop() { - if (mClientPackageName != null) { + if (isSystemRouter()) { List<RoutingSessionInfo> sessionInfos = sManager.getRoutingSessions(mClientPackageName); RoutingSessionInfo sessionToRelease = sessionInfos.get(sessionInfos.size() - 1); sManager.releaseSession(sessionToRelease); @@ -481,7 +521,7 @@ public final class MediaRouter2 { */ //@SystemApi public void transfer(@NonNull RoutingController controller, @NonNull MediaRoute2Info route) { - if (mClientPackageName != null) { + if (isSystemRouter()) { sManager.transfer(controller.getRoutingSessionInfo(), route); return; } @@ -490,7 +530,7 @@ public final class MediaRouter2 { Objects.requireNonNull(route, "route must not be null"); boolean routeFound; - synchronized (sRouterLock) { + synchronized (mLock) { // TODO: Check thread-safety routeFound = mRoutes.containsKey(route.getId()); } @@ -526,7 +566,7 @@ public final class MediaRouter2 { } MediaRouter2Stub stub; - synchronized (sRouterLock) { + synchronized (mLock) { stub = mStub; } if (stub != null) { @@ -576,7 +616,7 @@ public final class MediaRouter2 { public List<RoutingController> getControllers() { // TODO: Do not create the controller instances every time, // Instead, update the list using the sessions' ID and session related callbacks. - if (mClientPackageName != null) { + if (isSystemRouter()) { return sManager.getRoutingSessions(mClientPackageName).stream() .map(info -> new RoutingController(info)) .collect(Collectors.toList()); @@ -584,7 +624,7 @@ public final class MediaRouter2 { List<RoutingController> result = new ArrayList<>(); result.add(0, mSystemController); - synchronized (sRouterLock) { + synchronized (mLock) { result.addAll(mNonSystemRoutingControllers.values()); } return result; @@ -603,7 +643,7 @@ public final class MediaRouter2 { Objects.requireNonNull(route, "route must not be null"); MediaRouter2Stub stub; - synchronized (sRouterLock) { + synchronized (mLock) { stub = mStub; } if (stub != null) { @@ -627,7 +667,7 @@ public final class MediaRouter2 { List<MediaRoute2Info> removedRoutes = new ArrayList<>(); List<MediaRoute2Info> changedRoutes = new ArrayList<>(); - synchronized (sRouterLock) { + synchronized (mLock) { List<String> currentRoutesIds = currentRoutes.stream().map(MediaRoute2Info::getId) .collect(Collectors.toList()); @@ -685,7 +725,7 @@ public final class MediaRouter2 { void addRoutesOnHandler(List<MediaRoute2Info> routes) { List<MediaRoute2Info> addedRoutes = new ArrayList<>(); - synchronized (sRouterLock) { + synchronized (mLock) { for (MediaRoute2Info route : routes) { mRoutes.put(route.getId(), route); if (route.hasAnyFeatures(mDiscoveryPreference.getPreferredFeatures())) { @@ -701,7 +741,7 @@ public final class MediaRouter2 { void removeRoutesOnHandler(List<MediaRoute2Info> routes) { List<MediaRoute2Info> removedRoutes = new ArrayList<>(); - synchronized (sRouterLock) { + synchronized (mLock) { for (MediaRoute2Info route : routes) { mRoutes.remove(route.getId()); if (route.hasAnyFeatures(mDiscoveryPreference.getPreferredFeatures())) { @@ -717,7 +757,7 @@ public final class MediaRouter2 { void changeRoutesOnHandler(List<MediaRoute2Info> routes) { List<MediaRoute2Info> changedRoutes = new ArrayList<>(); - synchronized (sRouterLock) { + synchronized (mLock) { for (MediaRoute2Info route : routes) { mRoutes.put(route.getId(), route); if (route.hasAnyFeatures(mDiscoveryPreference.getPreferredFeatures())) { @@ -789,7 +829,7 @@ public final class MediaRouter2 { newController.setRoutingSessionInfo(sessionInfo); } else { newController = new RoutingController(sessionInfo); - synchronized (sRouterLock) { + synchronized (mLock) { mNonSystemRoutingControllers.put(newController.getId(), newController); } } @@ -812,7 +852,7 @@ public final class MediaRouter2 { } RoutingController matchingController; - synchronized (sRouterLock) { + synchronized (mLock) { matchingController = mNonSystemRoutingControllers.get(sessionInfo.getId()); } @@ -840,7 +880,7 @@ public final class MediaRouter2 { } RoutingController matchingController; - synchronized (sRouterLock) { + synchronized (mLock) { matchingController = mNonSystemRoutingControllers.get(sessionInfo.getId()); } @@ -868,7 +908,7 @@ public final class MediaRouter2 { if (oldSession.isSystemSession()) { controller = getSystemController(); } else { - synchronized (sRouterLock) { + synchronized (mLock) { controller = mNonSystemRoutingControllers.get(oldSession.getId()); } } @@ -878,6 +918,22 @@ public final class MediaRouter2 { requestCreateController(controller, route, managerRequestId); } + /** + * Returns whether this router is created with {@link #getInstance(Context, String)}. + * This kind of router can control the target app's media routing. + */ + private boolean isSystemRouter() { + return mClientPackageName != null; + } + + /** + * Registers {@link MediaRouter2Manager.Callback} for getting events. + */ + private void registerManagerCallback() { + // Using direct executor here, since MediaRouter2Manager also posts to the main handler. + sManager.registerCallback(Runnable::run, mManagerCallback); + } + private List<MediaRoute2Info> filterRoutes(List<MediaRoute2Info> routes, RouteDiscoveryPreference discoveryRequest) { return routes.stream() @@ -1236,7 +1292,7 @@ public final class MediaRouter2 { } MediaRouter2Stub stub; - synchronized (sRouterLock) { + synchronized (mLock) { stub = mStub; } if (stub != null) { @@ -1283,7 +1339,7 @@ public final class MediaRouter2 { } MediaRouter2Stub stub; - synchronized (sRouterLock) { + synchronized (mLock) { stub = mStub; } if (stub != null) { @@ -1318,7 +1374,7 @@ public final class MediaRouter2 { } MediaRouter2Stub stub; - synchronized (sRouterLock) { + synchronized (mLock) { stub = mStub; } if (stub != null) { @@ -1352,7 +1408,7 @@ public final class MediaRouter2 { return; } MediaRouter2Stub stub; - synchronized (sRouterLock) { + synchronized (mLock) { stub = mStub; } if (stub != null) { @@ -1386,7 +1442,7 @@ public final class MediaRouter2 { mState = CONTROLLER_STATE_RELEASING; } - synchronized (sRouterLock) { + synchronized (mLock) { // It could happen if the controller is released by the another thread // in between two locks if (!mNonSystemRoutingControllers.remove(getId(), this)) { @@ -1415,7 +1471,7 @@ public final class MediaRouter2 { mState = CONTROLLER_STATE_RELEASED; } - synchronized (sRouterLock) { + synchronized (mLock) { mNonSystemRoutingControllers.remove(getId(), this); if (shouldReleaseSession && mStub != null) { @@ -1483,7 +1539,7 @@ public final class MediaRouter2 { } private List<MediaRoute2Info> getRoutesWithIds(List<String> routeIds) { - synchronized (sRouterLock) { + synchronized (mLock) { return routeIds.stream().map(mRoutes::get) .filter(Objects::nonNull) .collect(Collectors.toList()); @@ -1665,4 +1721,79 @@ public final class MediaRouter2 { MediaRouter2.this, oldSession, route, managerRequestId)); } } + + class ManagerCallback implements MediaRouter2Manager.Callback { + + @Override + public void onRoutesAdded(@NonNull List<MediaRoute2Info> routes) { + List<MediaRoute2Info> filteredRoutes = + sManager.filterRoutesForPackage(routes, mClientPackageName); + if (filteredRoutes.isEmpty()) { + return; + } + for (RouteCallbackRecord record: mRouteCallbackRecords) { + record.mExecutor.execute( + () -> record.mRouteCallback.onRoutesAdded(filteredRoutes)); + } + } + + @Override + public void onRoutesRemoved(@NonNull List<MediaRoute2Info> routes) { + List<MediaRoute2Info> filteredRoutes = + sManager.filterRoutesForPackage(routes, mClientPackageName); + if (filteredRoutes.isEmpty()) { + return; + } + for (RouteCallbackRecord record: mRouteCallbackRecords) { + record.mExecutor.execute( + () -> record.mRouteCallback.onRoutesRemoved(filteredRoutes)); + } + } + + @Override + public void onRoutesChanged(@NonNull List<MediaRoute2Info> routes) { + List<MediaRoute2Info> filteredRoutes = + sManager.filterRoutesForPackage(routes, mClientPackageName); + if (filteredRoutes.isEmpty()) { + return; + } + for (RouteCallbackRecord record: mRouteCallbackRecords) { + record.mExecutor.execute( + () -> record.mRouteCallback.onRoutesChanged(filteredRoutes)); + } + } + + @Override + public void onSessionUpdated(@NonNull RoutingSessionInfo session) { + // TODO: Call ControllerCallback.onControllerUpdated + } + + @Override + public void onTransferred(@NonNull RoutingSessionInfo oldSession, + @Nullable RoutingSessionInfo newSession) { + // TODO: Call TransferCallback.onTransfer + } + + @Override + public void onTransferFailed(@NonNull RoutingSessionInfo session, + @NonNull MediaRoute2Info route) { + // TODO: Call TransferCallback.onTransferFailure + } + + @Override + public void onSessionReleased(@NonNull RoutingSessionInfo session) { + // TODO: Call TransferCallback.onStop() + } + + @Override + public void onPreferredFeaturesChanged(@NonNull String packageName, + @NonNull List<String> preferredFeatures) { + // Does nothing. + } + + @Override + public void onRequestFailed(int reason) { + // Does nothing. + } + } } diff --git a/media/java/android/media/MediaRouter2Manager.java b/media/java/android/media/MediaRouter2Manager.java index 5e732f9be68f..ca619d4072c3 100644 --- a/media/java/android/media/MediaRouter2Manager.java +++ b/media/java/android/media/MediaRouter2Manager.java @@ -237,6 +237,36 @@ public final class MediaRouter2Manager { } /** + * Returns a list of routes which are related to the given package name in the given route list. + */ + @NonNull + public List<MediaRoute2Info> filterRoutesForPackage(@NonNull List<MediaRoute2Info> routes, + @NonNull String packageName) { + Objects.requireNonNull(routes, "routes must not be null"); + Objects.requireNonNull(packageName, "packageName must not be null"); + + List<RoutingSessionInfo> sessions = getRoutingSessions(packageName); + RoutingSessionInfo sessionInfo = sessions.get(sessions.size() - 1); + + List<MediaRoute2Info> result = new ArrayList<>(); + List<String> preferredFeatures = mPreferredFeaturesMap.get(packageName); + if (preferredFeatures == null) { + preferredFeatures = Collections.emptyList(); + } + + synchronized (mRoutesLock) { + for (MediaRoute2Info route : routes) { + if (route.hasAnyFeatures(preferredFeatures) + || sessionInfo.getSelectedRoutes().contains(route.getId()) + || sessionInfo.getTransferableRoutes().contains(route.getId())) { + result.add(route); + } + } + } + return result; + } + + /** * Gets the system routing session associated with no specific application. */ @NonNull diff --git a/media/java/android/media/metrics/NetworkEvent.java b/media/java/android/media/metrics/NetworkEvent.java index 098885cc9bdd..186606825104 100644 --- a/media/java/android/media/metrics/NetworkEvent.java +++ b/media/java/android/media/metrics/NetworkEvent.java @@ -113,10 +113,11 @@ public final class NetworkEvent extends Event implements Parcelable { * * @hide */ - public NetworkEvent(@NetworkType int type, long timeSinceCreatedMillis, Bundle extras) { + public NetworkEvent(@NetworkType int type, long timeSinceCreatedMillis, + @Nullable Bundle extras) { this.mNetworkType = type; this.mTimeSinceCreatedMillis = timeSinceCreatedMillis; - this.mExtras = extras.deepCopy(); + this.mExtras = extras == null ? null : extras.deepCopy(); } /** diff --git a/media/java/android/media/metrics/PlaybackErrorEvent.java b/media/java/android/media/metrics/PlaybackErrorEvent.java index b23b4d2728b4..ccf848b50a36 100644 --- a/media/java/android/media/metrics/PlaybackErrorEvent.java +++ b/media/java/android/media/metrics/PlaybackErrorEvent.java @@ -65,12 +65,12 @@ public final class PlaybackErrorEvent extends Event implements Parcelable { int errorCode, int subErrorCode, long timeSinceCreatedMillis, - Bundle extras) { + @Nullable Bundle extras) { this.mExceptionStack = exceptionStack; this.mErrorCode = errorCode; this.mSubErrorCode = subErrorCode; this.mTimeSinceCreatedMillis = timeSinceCreatedMillis; - this.mExtras = extras.deepCopy(); + this.mExtras = extras == null ? null : extras.deepCopy(); } /** @hide */ diff --git a/media/java/android/media/metrics/PlaybackMetrics.java b/media/java/android/media/metrics/PlaybackMetrics.java index 7e7f44a97b9c..3ffd10f4ea8c 100644 --- a/media/java/android/media/metrics/PlaybackMetrics.java +++ b/media/java/android/media/metrics/PlaybackMetrics.java @@ -194,7 +194,7 @@ public final class PlaybackMetrics implements Parcelable { long localBytesRead, long networkTransferDurationMillis, byte[] drmSessionId, - Bundle extras) { + @Nullable Bundle extras) { this.mMediaDurationMillis = mediaDurationMillis; this.mStreamSource = streamSource; this.mStreamType = streamType; @@ -212,7 +212,7 @@ public final class PlaybackMetrics implements Parcelable { this.mLocalBytesRead = localBytesRead; this.mNetworkTransferDurationMillis = networkTransferDurationMillis; this.mDrmSessionId = drmSessionId; - this.mExtras = extras.deepCopy(); + this.mExtras = extras == null ? null : extras.deepCopy(); } /** diff --git a/media/java/android/media/metrics/PlaybackStateEvent.java b/media/java/android/media/metrics/PlaybackStateEvent.java index dea8c1db71de..2bab5c9bc3dc 100644 --- a/media/java/android/media/metrics/PlaybackStateEvent.java +++ b/media/java/android/media/metrics/PlaybackStateEvent.java @@ -138,10 +138,10 @@ public final class PlaybackStateEvent extends Event implements Parcelable { public PlaybackStateEvent( int state, long timeSinceCreatedMillis, - Bundle extras) { + @Nullable Bundle extras) { this.mTimeSinceCreatedMillis = timeSinceCreatedMillis; this.mState = state; - this.mExtras = extras.deepCopy(); + this.mExtras = extras == null ? null : extras.deepCopy(); } /** diff --git a/media/java/android/media/metrics/TrackChangeEvent.java b/media/java/android/media/metrics/TrackChangeEvent.java index aa519782ec80..a3eb4adfeb8d 100644 --- a/media/java/android/media/metrics/TrackChangeEvent.java +++ b/media/java/android/media/metrics/TrackChangeEvent.java @@ -167,7 +167,7 @@ public final class TrackChangeEvent extends Event implements Parcelable { this.mWidth = width; this.mHeight = height; this.mVideoFrameRate = videoFrameRate; - this.mExtras = extras.deepCopy(); + this.mExtras = extras == null ? null : extras.deepCopy(); } /** diff --git a/packages/Connectivity/service/Android.bp b/packages/Connectivity/service/Android.bp index 2fb9f72feab7..856f3b85333a 100644 --- a/packages/Connectivity/service/Android.bp +++ b/packages/Connectivity/service/Android.bp @@ -66,6 +66,7 @@ java_library { "net-utils-device-common", "net-utils-framework-common", "netd-client", + "PlatformProperties", ], apex_available: [ "//apex_available:platform", @@ -76,7 +77,7 @@ java_library { java_library { name: "service-connectivity", installable: true, - static_libs:[ + static_libs: [ "service-connectivity-pre-jarjar", ], jarjar_rules: "jarjar-rules.txt", diff --git a/packages/Connectivity/service/jarjar-rules.txt b/packages/Connectivity/service/jarjar-rules.txt index d8c60a428ef6..a7b419b020b5 100644 --- a/packages/Connectivity/service/jarjar-rules.txt +++ b/packages/Connectivity/service/jarjar-rules.txt @@ -1,3 +1,4 @@ +rule android.sysprop.** com.android.connectivity.sysprop.@1 rule com.android.net.module.util.** com.android.connectivity.net-utils.@1 rule com.android.modules.utils.** com.android.connectivity.modules-utils.@1 diff --git a/packages/DynamicSystemInstallationService/src/com/android/dynsystem/InstallationAsyncTask.java b/packages/DynamicSystemInstallationService/src/com/android/dynsystem/InstallationAsyncTask.java index 4ef5e2b4f090..59ea9f0150bf 100644 --- a/packages/DynamicSystemInstallationService/src/com/android/dynsystem/InstallationAsyncTask.java +++ b/packages/DynamicSystemInstallationService/src/com/android/dynsystem/InstallationAsyncTask.java @@ -320,7 +320,7 @@ class InstallationAsyncTask extends AsyncTask<String, InstallationAsyncTask.Prog } } - private void installScratch() throws IOException, InterruptedException { + private void installScratch() throws IOException { final long scratchSize = mDynSystem.suggestScratchSize(); Thread thread = new Thread() { @Override @@ -347,7 +347,11 @@ class InstallationAsyncTask extends AsyncTask<String, InstallationAsyncTask.Prog publishProgress(progress); } - Thread.sleep(100); + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // Ignore the error. + } } if (mInstallationSession == null) { @@ -361,7 +365,7 @@ class InstallationAsyncTask extends AsyncTask<String, InstallationAsyncTask.Prog } } - private void installUserdata() throws IOException, InterruptedException { + private void installUserdata() throws IOException { Thread thread = new Thread(() -> { mInstallationSession = mDynSystem.createPartition("userdata", mUserdataSize, false); }); @@ -383,7 +387,11 @@ class InstallationAsyncTask extends AsyncTask<String, InstallationAsyncTask.Prog publishProgress(progress); } - Thread.sleep(100); + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // Ignore the error. + } } if (mInstallationSession == null) { @@ -397,8 +405,7 @@ class InstallationAsyncTask extends AsyncTask<String, InstallationAsyncTask.Prog } } - private void installImages() - throws IOException, InterruptedException, ImageValidationException { + private void installImages() throws IOException, ImageValidationException { if (mStream != null) { if (mIsZip) { installStreamingZipUpdate(); @@ -410,14 +417,12 @@ class InstallationAsyncTask extends AsyncTask<String, InstallationAsyncTask.Prog } } - private void installStreamingGzUpdate() - throws IOException, InterruptedException, ImageValidationException { + private void installStreamingGzUpdate() throws IOException, ImageValidationException { Log.d(TAG, "To install a streaming GZ update"); installImage("system", mSystemSize, new GZIPInputStream(mStream)); } - private void installStreamingZipUpdate() - throws IOException, InterruptedException, ImageValidationException { + private void installStreamingZipUpdate() throws IOException, ImageValidationException { Log.d(TAG, "To install a streaming ZIP update"); ZipInputStream zis = new ZipInputStream(mStream); @@ -432,8 +437,7 @@ class InstallationAsyncTask extends AsyncTask<String, InstallationAsyncTask.Prog } } - private void installLocalZipUpdate() - throws IOException, InterruptedException, ImageValidationException { + private void installLocalZipUpdate() throws IOException, ImageValidationException { Log.d(TAG, "To install a local ZIP update"); Enumeration<? extends ZipEntry> entries = mZipFile.entries(); @@ -449,7 +453,7 @@ class InstallationAsyncTask extends AsyncTask<String, InstallationAsyncTask.Prog } private boolean installImageFromAnEntry(ZipEntry entry, InputStream is) - throws IOException, InterruptedException, ImageValidationException { + throws IOException, ImageValidationException { String name = entry.getName(); Log.d(TAG, "ZipEntry: " + name); @@ -473,7 +477,7 @@ class InstallationAsyncTask extends AsyncTask<String, InstallationAsyncTask.Prog } private void installImage(String partitionName, long uncompressedSize, InputStream is) - throws IOException, InterruptedException, ImageValidationException { + throws IOException, ImageValidationException { SparseInputStream sis = new SparseInputStream(new BufferedInputStream(is)); @@ -504,7 +508,11 @@ class InstallationAsyncTask extends AsyncTask<String, InstallationAsyncTask.Prog return; } - Thread.sleep(100); + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // Ignore the error. + } } if (mInstallationSession == null) { diff --git a/packages/SettingsLib/CollapsingToolbarBaseActivity/Android.bp b/packages/SettingsLib/CollapsingToolbarBaseActivity/Android.bp index ed49bf4d5385..231babea97c2 100644 --- a/packages/SettingsLib/CollapsingToolbarBaseActivity/Android.bp +++ b/packages/SettingsLib/CollapsingToolbarBaseActivity/Android.bp @@ -20,4 +20,8 @@ android_library { ], sdk_version: "system_current", min_sdk_version: "21", + apex_available: [ + "//apex_available:platform", + "com.android.cellbroadcast", + ], } diff --git a/packages/SettingsLib/SettingsSpinner/res/drawable/arrow_drop_down_24dp.xml b/packages/SettingsLib/SettingsSpinner/res/drawable/arrow_drop_down.xml index 827d0b583388..054452629c88 100644 --- a/packages/SettingsLib/SettingsSpinner/res/drawable/arrow_drop_down_24dp.xml +++ b/packages/SettingsLib/SettingsSpinner/res/drawable/arrow_drop_down.xml @@ -16,11 +16,11 @@ --> <vector xmlns:android="http://schemas.android.com/apk/res/android" - android:viewportWidth="24" - android:viewportHeight="24" + android:viewportWidth="18" + android:viewportHeight="18" android:width="24dp" android:height="24dp"> <path android:pathData="M7 10l5 5 5 -5z" - android:fillColor="?android:attr/textColorPrimary"/> -</vector>
\ No newline at end of file + android:fillColor="@android:color/black"/> +</vector> diff --git a/packages/SettingsLib/SettingsSpinner/res/drawable/settings_spinner_background.xml b/packages/SettingsLib/SettingsSpinner/res/drawable/settings_spinner_background.xml index 263c16b0749c..b38e3e3e89c1 100644 --- a/packages/SettingsLib/SettingsSpinner/res/drawable/settings_spinner_background.xml +++ b/packages/SettingsLib/SettingsSpinner/res/drawable/settings_spinner_background.xml @@ -24,21 +24,21 @@ android:bottom="8dp"> <shape> <corners - android:radius="20dp"/> + android:radius="28dp"/> <solid - android:color="?android:attr/colorPrimary"/> + android:color="?android:attr/colorAccent"/> <stroke - android:color="#1f000000" + android:color="?android:attr/colorPrimary" android:width="1dp"/> <size - android:height="32dp"/> + android:height="@dimen/spinner_height"/> </shape> </item> <item android:gravity="center|end" - android:width="24dp" - android:height="24dp" - android:end="4dp" - android:drawable="@drawable/arrow_drop_down_24dp"/> + android:width="18dp" + android:height="18dp" + android:end="8dp" + android:drawable="@drawable/arrow_drop_down"/> </layer-list>
\ No newline at end of file diff --git a/packages/SettingsLib/SettingsSpinner/res/drawable/settings_spinner_dropdown_background.xml b/packages/SettingsLib/SettingsSpinner/res/drawable/settings_spinner_dropdown_background.xml new file mode 100644 index 000000000000..8cac988632bc --- /dev/null +++ b/packages/SettingsLib/SettingsSpinner/res/drawable/settings_spinner_dropdown_background.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2021 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --> + +<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> + + <item> + <shape> + <solid + android:color="?android:attr/colorAccent"/> + </shape> + </item> + + <item> + <shape> + <solid android:color="#BBFFFFFF"/> + </shape> + </item> + +</layer-list> diff --git a/packages/SettingsLib/SettingsSpinner/res/layout/settings_spinner_dropdown_view.xml b/packages/SettingsLib/SettingsSpinner/res/layout/settings_spinner_dropdown_view.xml new file mode 100644 index 000000000000..a342c840cfbe --- /dev/null +++ b/packages/SettingsLib/SettingsSpinner/res/layout/settings_spinner_dropdown_view.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2021 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. +--> + +<TextView + xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@android:id/text1" + style="@style/SettingsSpinnerTitleBar" + android:gravity="center_vertical" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="@drawable/settings_spinner_dropdown_background"/> diff --git a/packages/SettingsLib/SettingsSpinner/res/layout/settings_spinner_view.xml b/packages/SettingsLib/SettingsSpinner/res/layout/settings_spinner_view.xml index bdd370fe04ee..75de34e86bc4 100644 --- a/packages/SettingsLib/SettingsSpinner/res/layout/settings_spinner_view.xml +++ b/packages/SettingsLib/SettingsSpinner/res/layout/settings_spinner_view.xml @@ -19,7 +19,5 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/text1" style="@style/SettingsSpinnerTitleBar" - android:maxLines="1" android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:ellipsize="marquee"/> + android:layout_height="wrap_content"/> diff --git a/packages/SystemUI/res/drawable/controls_dialog_bg.xml b/packages/SettingsLib/SettingsSpinner/res/values/dimens.xml index 1ccb176b8689..d526df6bedd4 100644 --- a/packages/SystemUI/res/drawable/controls_dialog_bg.xml +++ b/packages/SettingsLib/SettingsSpinner/res/values/dimens.xml @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- - Copyright (C) 2021 The Android Open Source Project +<!-- Copyright (C) 2021 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. @@ -14,8 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. --> -<shape xmlns:android="http://schemas.android.com/apk/res/android" - android:shape="rectangle"> - <solid android:color="?android:attr/colorBackground" /> - <corners android:radius="@dimen/notification_corner_radius" /> -</shape> + +<resources> + <dimen name="spinner_height">36dp</dimen> + <dimen name="spinner_padding_top_or_bottom">8dp</dimen> +</resources> diff --git a/packages/SettingsLib/SettingsSpinner/res/values/styles.xml b/packages/SettingsLib/SettingsSpinner/res/values/styles.xml index 8af20e20ede9..f665f3836002 100644 --- a/packages/SettingsLib/SettingsSpinner/res/values/styles.xml +++ b/packages/SettingsLib/SettingsSpinner/res/values/styles.xml @@ -18,9 +18,13 @@ <resources> <style name="SettingsSpinnerTitleBar"> <item name="android:textAppearance">?android:attr/textAppearanceButton</item> + <item name="android:textColor">@android:color/black</item> + <item name="android:maxLines">1</item> + <item name="android:ellipsize">marquee</item> + <item name="android:minHeight">@dimen/spinner_height</item> <item name="android:paddingStart">16dp</item> <item name="android:paddingEnd">36dp</item> - <item name="android:paddingTop">8dp</item> - <item name="android:paddingBottom">8dp</item> + <item name="android:paddingTop">@dimen/spinner_padding_top_or_bottom</item> + <item name="android:paddingBottom">@dimen/spinner_padding_top_or_bottom</item> </style> -</resources>
\ No newline at end of file +</resources> diff --git a/packages/SettingsLib/SettingsSpinner/src/com/android/settingslib/widget/settingsspinner/SettingsSpinner.java b/packages/SettingsLib/SettingsSpinner/src/com/android/settingslib/widget/settingsspinner/SettingsSpinner.java index 5ef8f7ac792b..0be80a9fd466 100644 --- a/packages/SettingsLib/SettingsSpinner/src/com/android/settingslib/widget/settingsspinner/SettingsSpinner.java +++ b/packages/SettingsLib/SettingsSpinner/src/com/android/settingslib/widget/settingsspinner/SettingsSpinner.java @@ -121,4 +121,11 @@ public class SettingsSpinner extends Spinner { int mode) { super(context, attrs, defStyleAttr, defStyleRes, mode, null); } -}
\ No newline at end of file + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + setDropDownVerticalOffset(getMeasuredHeight() - (int) getContext().getResources() + .getDimension(R.dimen.spinner_padding_top_or_bottom)); + } +} diff --git a/packages/SettingsLib/SettingsSpinner/src/com/android/settingslib/widget/settingsspinner/SettingsSpinnerAdapter.java b/packages/SettingsLib/SettingsSpinner/src/com/android/settingslib/widget/settingsspinner/SettingsSpinnerAdapter.java index a8ca0d8664f3..83da512ce879 100644 --- a/packages/SettingsLib/SettingsSpinner/src/com/android/settingslib/widget/settingsspinner/SettingsSpinnerAdapter.java +++ b/packages/SettingsLib/SettingsSpinner/src/com/android/settingslib/widget/settingsspinner/SettingsSpinnerAdapter.java @@ -30,8 +30,7 @@ import com.android.settingslib.widget.R; public class SettingsSpinnerAdapter<T> extends ArrayAdapter<T> { private static final int DEFAULT_RESOURCE = R.layout.settings_spinner_view; - private static final int DFAULT_DROPDOWN_RESOURCE = - android.R.layout.simple_spinner_dropdown_item; + private static final int DFAULT_DROPDOWN_RESOURCE = R.layout.settings_spinner_dropdown_view; private final LayoutInflater mDefaultInflater; /** diff --git a/packages/SettingsLib/SettingsTheme/Android.bp b/packages/SettingsLib/SettingsTheme/Android.bp index bda863a71453..73459c277df1 100644 --- a/packages/SettingsLib/SettingsTheme/Android.bp +++ b/packages/SettingsLib/SettingsTheme/Android.bp @@ -18,4 +18,8 @@ android_library { sdk_version: "system_current", min_sdk_version: "21", + apex_available: [ + "//apex_available:platform", + "com.android.cellbroadcast", + ], } diff --git a/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java b/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java index ed2b6c92530b..e8e10a4def3e 100644 --- a/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java +++ b/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java @@ -153,6 +153,7 @@ public class SecureSettingsValidators { VALIDATORS.put(Secure.DOZE_TAP_SCREEN_GESTURE, BOOLEAN_VALIDATOR); VALIDATORS.put(Secure.DOZE_WAKE_LOCK_SCREEN_GESTURE, BOOLEAN_VALIDATOR); VALIDATORS.put(Secure.DOZE_WAKE_DISPLAY_GESTURE, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.DOZE_QUICK_PICKUP_GESTURE, BOOLEAN_VALIDATOR); VALIDATORS.put(Secure.NFC_PAYMENT_DEFAULT_COMPONENT, COMPONENT_NAME_VALIDATOR); VALIDATORS.put( Secure.AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN, NON_NEGATIVE_INTEGER_VALIDATOR); diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java index e427981b87d7..400742ba7d78 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java @@ -1937,8 +1937,11 @@ public class SettingsProvider extends ContentProvider { if (UserHandle.getAppId(Binder.getCallingUid()) < Process.FIRST_APPLICATION_UID) { return; } - checkReadableAnnotation(settingsType, settingName); ApplicationInfo ai = getCallingApplicationInfoOrThrow(); + if (ai.isSystemApp() || ai.isSignedWithPlatformKey()) { + return; + } + checkReadableAnnotation(settingsType, settingName); if (!ai.isInstantApp()) { return; } diff --git a/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java b/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java index 4dc6d1475c4a..c520568a78e5 100644 --- a/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java +++ b/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java @@ -745,6 +745,7 @@ public class SettingsBackupTest { Settings.Secure.SILENCE_GESTURE, Settings.Secure.DOZE_WAKE_LOCK_SCREEN_GESTURE, Settings.Secure.DOZE_WAKE_DISPLAY_GESTURE, + Settings.Secure.DOZE_QUICK_PICKUP_GESTURE, Settings.Secure.FACE_UNLOCK_RE_ENROLL, Settings.Secure.TAP_GESTURE, Settings.Secure.NEARBY_SHARING_COMPONENT, // not user configurable diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml index b6d942a29d49..e0097df62078 100644 --- a/packages/SystemUI/AndroidManifest.xml +++ b/packages/SystemUI/AndroidManifest.xml @@ -578,7 +578,7 @@ <!-- People Space UI Screen --> <activity android:name=".people.PeopleSpaceActivity" - android:label="People" + android:label="@string/people_tile_title" android:enabled="true" android:exported="true" android:theme="@android:style/Theme.Material.NoActionBar"> @@ -592,7 +592,7 @@ <!-- People Space Widget --> <receiver android:name=".people.widget.PeopleSpaceWidgetProvider" - android:label="People Space" + android:label="@string/people_tile_title" android:enabled="true" android:exported="true"> <intent-filter> @@ -751,6 +751,17 @@ android:visibleToInstantApps="true"> </activity> + <activity android:name=".controls.ui.ControlsActivity" + android:label="@string/quick_controls_title" + android:theme="@style/Theme.ControlsActivity" + android:excludeFromRecents="true" + android:showWhenLocked="true" + android:showForAllUsers="true" + android:launchMode="singleInstance" + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation|keyboard|keyboardHidden" + android:visibleToInstantApps="true"> + </activity> + <receiver android:name=".controls.management.ControlsRequestReceiver" android:exported="true"> <intent-filter> diff --git a/packages/SystemUI/res/layout/controls_detail_dialog.xml b/packages/SystemUI/res/layout/controls_detail_dialog.xml index ee5315ad782f..28fc86372092 100644 --- a/packages/SystemUI/res/layout/controls_detail_dialog.xml +++ b/packages/SystemUI/res/layout/controls_detail_dialog.xml @@ -20,8 +20,8 @@ android:id="@+id/control_detail_root" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_marginTop="@dimen/controls_activity_view_top_offset" - android:orientation="vertical"> + android:orientation="vertical" + android:background="@android:color/black"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" @@ -30,7 +30,7 @@ <ImageView android:id="@+id/control_detail_close" android:contentDescription="@string/accessibility_desc_close" - android:src="@drawable/ic_close" + android:src="@drawable/ic_arrow_back" android:background="?android:attr/selectableItemBackgroundBorderless" android:tint="@color/control_primary_text" android:layout_width="48dp" @@ -56,7 +56,6 @@ android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" - android:background="@android:color/black" android:orientation="vertical" /> </LinearLayout> diff --git a/packages/SystemUI/res/layout/controls_in_dialog.xml b/packages/SystemUI/res/layout/controls_fullscreen.xml index 983999f9a5f8..1b2d2e2e9c89 100644 --- a/packages/SystemUI/res/layout/controls_in_dialog.xml +++ b/packages/SystemUI/res/layout/controls_fullscreen.xml @@ -20,11 +20,8 @@ android:id="@+id/control_detail_root" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_marginVertical="@dimen/controls_activity_view_top_offset" - android:layout_marginHorizontal="@dimen/controls_activity_view_side_offset" - android:padding="8dp" android:orientation="vertical" - android:background="@drawable/controls_dialog_bg"> + android:background="@android:color/black"> <com.android.systemui.globalactions.MinHeightScrollView android:layout_width="match_parent" diff --git a/packages/SystemUI/res/layout/controls_with_favorites.xml b/packages/SystemUI/res/layout/controls_with_favorites.xml index b060afdc18e3..9d011482d011 100644 --- a/packages/SystemUI/res/layout/controls_with_favorites.xml +++ b/packages/SystemUI/res/layout/controls_with_favorites.xml @@ -25,8 +25,21 @@ <!-- make sure the header stays centered in the layout by adding a spacer --> <Space + android:id="@+id/controls_spacer" android:layout_width="@dimen/controls_header_menu_size" - android:layout_height="1dp" /> + android:layout_height="1dp" + android:visibility="gone" /> + + <ImageView + android:id="@+id/controls_close" + android:contentDescription="@string/accessibility_desc_close" + android:src="@drawable/ic_close" + android:background="?android:attr/selectableItemBackgroundBorderless" + android:tint="@color/control_primary_text" + android:layout_width="@dimen/controls_header_menu_size" + android:layout_height="@dimen/controls_header_menu_size" + android:padding="12dp" + android:visibility="gone" /> <!-- need to keep this outer view in order to have a correctly sized anchor for the dropdown menu, as well as dropdown background in the right place --> <LinearLayout diff --git a/packages/SystemUI/res/layout/people_space_activity.xml b/packages/SystemUI/res/layout/people_space_activity.xml index 07af01b0db72..1784cae816ce 100644 --- a/packages/SystemUI/res/layout/people_space_activity.xml +++ b/packages/SystemUI/res/layout/people_space_activity.xml @@ -25,19 +25,30 @@ android:layout_height="wrap_content" android:layout_marginTop="16dp" android:orientation="vertical" - android:padding="16dp" + android:padding="24dp" android:clipChildren="false" android:clipToPadding="false"> <TextView + android:id="@+id/select_conversation_title" + android:gravity="center" + android:text="@string/select_conversation_title" + android:layout_width="wrap_content" + android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem" + android:textSize="24sp" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal"/> + + <TextView android:id="@+id/select_conversation" + android:gravity="center" android:text="@string/select_conversation_text" android:layout_width="match_parent" android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem" - android:textSize="24sp" + android:textSize="16sp" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" - android:paddingBottom="16dp" /> + android:padding="24dp" /> </LinearLayout> </androidx.core.widget.NestedScrollView>
\ No newline at end of file diff --git a/packages/SystemUI/res/layout/people_space_placeholder_layout.xml b/packages/SystemUI/res/layout/people_space_placeholder_layout.xml new file mode 100644 index 000000000000..3ced1ff6c74b --- /dev/null +++ b/packages/SystemUI/res/layout/people_space_placeholder_layout.xml @@ -0,0 +1,75 @@ +<!-- + ~ Copyright (C) 2021 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + <LinearLayout + android:background="@drawable/people_space_tile_view_card" + android:id="@+id/item" + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <LinearLayout + android:orientation="horizontal" + android:gravity="center" + android:paddingVertical="2dp" + android:paddingHorizontal="8dp" + android:layout_width="match_parent" + android:layout_height="match_parent"> + <ImageView + android:background="@drawable/ic_person" + android:id="@+id/person_icon_only" + android:layout_width="60dp" + android:layout_height="60dp"/> + + <LinearLayout + android:orientation="vertical" + android:paddingStart="8dp" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <ImageView + android:id="@+id/availability" + android:layout_width="10dp" + android:layout_height="10dp" + android:background="@drawable/circle_green_10dp"/> + <TextView + android:id="@+id/name" + android:text="@string/empty_user_name" + android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem" + android:textColor="?android:attr/textColorPrimary" + android:textSize="14sp" + android:maxLines="1" + android:ellipsize="end" + android:layout_width="wrap_content" + android:layout_height="wrap_content"/> + + <TextView + android:id="@+id/last_interaction" + android:text="@string/empty_status" + android:textColor="?android:attr/textColorSecondary" + android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem" + android:textSize="12sp" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:maxLines="3" + android:ellipsize="end"/> + </LinearLayout> + </LinearLayout> + </LinearLayout> +</LinearLayout>
\ No newline at end of file diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml index da58a3442e6f..19ca2f408fab 100644 --- a/packages/SystemUI/res/values/config.xml +++ b/packages/SystemUI/res/values/config.xml @@ -180,6 +180,9 @@ <!-- Doze: duration to avoid false pickup gestures triggered by notification vibrations --> <integer name="doze_pickup_vibration_threshold">2000</integer> + <!-- Doze: quick pickup duration to stay in AOD until the next gesture is triggered --> + <integer name="doze_quick_pickup_aod_duration">5000</integer> + <!-- Type of a sensor that provides a low-power estimate of the desired display brightness, suitable to listen to while the device is asleep (e.g. during always-on display) --> diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index fcda80dd5f15..6207449d63e6 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -2811,44 +2811,44 @@ <!-- Text to display when copying the build number off QS [CHAR LIMIT=NONE]--> <string name="build_number_copy_toast">Build number copied to clipboard.</string> - <!-- Status for last interaction with exact time [CHAR LIMIT=120] --> - <string name="last_interaction_status" translatable="false">Last chatted <xliff:g id="duration" example="5 hours">%1$s</xliff:g> ago</string> - <!-- Status for last interaction when less than a certain time window [CHAR LIMIT=120] --> - <string name="last_interaction_status_less_than" translatable="false">Last chatted less than <xliff:g id="duration" example="5 hours">%1$s</xliff:g> ago</string> - <!-- Status for last interaction when over a certain time window [CHAR LIMIT=120] --> - <string name="last_interaction_status_over" translatable="false">Last chatted over <xliff:g id="duration" example="1 week">%1$s</xliff:g> ago</string> - <!-- Status for conversation without interaction data [CHAR LIMIT=120] --> - <string name="basic_status" translatable="false">Open conversation</string> - <!-- Status for conversation without interaction data [CHAR LIMIT=120] --> - <string name="select_conversation_text" translatable="false">Select one conversation to show in your widget:</string> - <!-- Timestamp for notification with exact time [CHAR LIMIT=120] --> - <string name="timestamp" translatable="false"><xliff:g id="duration" example="5 hours">%1$s</xliff:g> ago</string> - <!-- Timestamp for notification when less than a certain time window [CHAR LIMIT=120] --> - <string name="less_than_timestamp" translatable="false">Less than <xliff:g id="duration" example="5 hours">%1$s</xliff:g> ago</string> - <!-- Timestamp for notification when over a certain time window [CHAR LIMIT=120] --> - <string name="over_timestamp" translatable="false">Over <xliff:g id="duration" example="1 week">%1$s</xliff:g> ago</string> - <!-- Status text for a birthday today [CHAR LIMIT=30] --> - <string name="birthday_status" translatable="false">Birthday</string> - <!-- Status text for an upcoming birthday [CHAR LIMIT=30] --> - <string name="upcoming_birthday_status" translatable="false">Birthday soon</string> - <!-- Status text for an anniversary [CHAR LIMIT=30] --> - <string name="anniversary_status" translatable="false">Anniversary</string> - <!-- Status text for sharing location [CHAR LIMIT=30] --> - <string name="location_status" translatable="false">Sharing location</string> - <!-- Status text for a new story posted [CHAR LIMIT=30] --> - <string name="new_story_status" translatable="false">New story</string> - <!-- Status text for watching a video [CHAR LIMIT=30] --> - <string name="video_status" translatable="false">Watching</string> - <!-- Status text for listening to audio [CHAR LIMIT=30] --> - <string name="audio_status" translatable="false">Listening</string> - <!-- Status text for playing a game [CHAR LIMIT=30] --> - <string name="game_status" translatable="false">Playing</string> - <!-- Empty user name before user has selected a friend [CHAR LIMIT=30] --> - <string name="empty_user_name" translatable="false">Your friend</string> - <!-- Empty status shown before user has selected a friend [CHAR LIMIT=30] --> - <string name="empty_status" translatable="false">Their status</string> - <!-- Default text for missed call notifications [CHAR LIMIT=30] --> - <string name="missed_call" translatable="false">Missed call</string> + <!-- Status for conversation without interaction data [CHAR LIMIT=120] --> + <string name="basic_status">Open conversation</string> + <!--Title text for Conversation widget set up screen [CHAR LIMIT=180] --> + <string name="select_conversation_title">Conversation widgets</string> + <!--Text explaining to tap a conversation to select it show in their Conversation widget [CHAR LIMIT=180] --> + <string name="select_conversation_text">Tap a conversation to add it to your Home screen</string> + <!-- Timestamp for notification with exact time [CHAR LIMIT=25] --> + <string name="timestamp"><xliff:g id="duration" example="5 hours">%1$s</xliff:g> ago</string> + <!-- Timestamp for notification when less than a certain time window [CHAR LIMIT=25] --> + <string name="less_than_timestamp">Less than <xliff:g id="duration" example="5 hours">%1$s</xliff:g> ago</string> + <!-- Timestamp for notification when over a certain time window [CHAR LIMIT=25] --> + <string name="over_timestamp">Over <xliff:g id="duration" example="1 week">%1$s</xliff:g> ago</string> + <!-- Status text on the Conversation widget for a birthday today [CHAR LIMIT=20] --> + <string name="birthday_status">Birthday</string> + <!-- Status text on the Conversation widget for an upcoming birthday [CHAR LIMIT=20] --> + <string name="upcoming_birthday_status">Birthday soon</string> + <!-- Status text on the Conversation widget for an anniversary [CHAR LIMIT=20] --> + <string name="anniversary_status">Anniversary</string> + <!-- Status text on the Conversation widget for sharing location [CHAR LIMIT=20] --> + <string name="location_status">Sharing location</string> + <!-- Status text on the Conversation widget for a new story posted [CHAR LIMIT=20] --> + <string name="new_story_status">New story</string> + <!-- Status text on the Conversation widget for watching a video [CHAR LIMIT=20] --> + <string name="video_status">Watching</string> + <!-- Status text on the Conversation widget for listening to audio [CHAR LIMIT=20] --> + <string name="audio_status">Listening</string> + <!-- Status text on the Conversation widget for playing a game [CHAR LIMIT=20] --> + <string name="game_status">Playing</string> + <!-- Empty user name before user has selected a friend for their Conversation widget [CHAR LIMIT=20] --> + <string name="empty_user_name">Friends</string> + <!-- Empty status shown before user has selected a friend for their Conversation widget [CHAR LIMIT=20] --> + <string name="empty_status">Let’s chat tonight!</string> + <!-- Default text for missed call notifications on their Conversation widget [CHAR LIMIT=20] --> + <string name="missed_call">Missed call</string> + <!-- Description text for adding a Conversation widget [CHAR LIMIT=100] --> + <string name="people_tile_description">See recent messages, missed calls, and status updates</string> + <!-- Title text displayed for the Conversation widget [CHAR LIMIT=50] --> + <string name="people_tile_title">Conversation</string> <!-- Title to display in a notification when ACTION_BATTERY_CHANGED.EXTRA_PRESENT field is false [CHAR LIMIT=NONE] --> diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml index 3c48548cc0fe..fb885cb3fdbe 100644 --- a/packages/SystemUI/res/values/styles.xml +++ b/packages/SystemUI/res/values/styles.xml @@ -649,6 +649,16 @@ <item name="wallpaperTextColor">@*android:color/primary_text_material_dark</item> </style> + <style name="Theme.ControlsActivity" parent="@android:style/Theme.DeviceDefault.NoActionBar"> + <item name="android:windowActivityTransitions">true</item> + <item name="android:windowContentTransitions">false</item> + <item name="android:windowIsTranslucent">false</item> + <item name="android:windowBackground">@android:color/transparent</item> + <item name="android:windowAnimationStyle">@null</item> + <item name="android:statusBarColor">@*android:color/transparent</item> + <item name="wallpaperTextColor">@*android:color/primary_text_material_dark</item> + </style> + <style name="Theme.CreateUser" parent="@style/Theme.SystemUI"> <item name="android:windowIsTranslucent">true</item> <item name="android:windowBackground">#33000000</item> @@ -660,30 +670,12 @@ <item name="android:fontFamily">@*android:string/config_bodyFontFamily</item> </style> - <style name="Theme.SystemUI.Dialog.Control.DetailPanel" parent="@android:style/Theme.DeviceDefault.Dialog.NoActionBar"> - <item name="android:windowAnimationStyle">@style/Animation.Bottomsheet</item> - <item name="android:windowFullscreen">true</item> - <item name="android:windowIsFloating">false</item> - <item name="android:windowBackground">@null</item> - <item name="android:backgroundDimEnabled">true</item> - </style> - - <style name="Animation.Bottomsheet"> - <item name="android:windowEnterAnimation">@anim/bottomsheet_in</item> - <item name="android:windowExitAnimation">@anim/bottomsheet_out</item> - </style> - - <style name="Theme.SystemUI.Dialog.Control.LockScreen" parent="@android:style/Theme.DeviceDefault.Dialog.NoActionBar"> - <item name="android:windowAnimationStyle">@style/Animation.ControlDialog</item> - <item name="android:windowFullscreen">true</item> + <style name="Theme.SystemUI.Dialog.Control.DetailPanel" parent="@android:style/Theme.DeviceDefault.Dialog.NoActionBar"> + <item name="android:windowFullscreen">false</item> <item name="android:windowIsFloating">false</item> - <item name="android:windowBackground">@null</item> - <item name="android:backgroundDimEnabled">true</item> - </style> - - <style name="Animation.ControlDialog"> - <item name="android:windowEnterAnimation">@*android:anim/dialog_enter</item> - <item name="android:windowExitAnimation">@*android:anim/dialog_exit</item> + <item name="android:windowBackground">@android:color/black</item> + <item name="android:backgroundDimEnabled">false</item> + <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item> </style> <style name="Control" /> diff --git a/packages/SystemUI/res/xml/people_space_widget_info.xml b/packages/SystemUI/res/xml/people_space_widget_info.xml index fbdac5e1789b..35188d8e11ad 100644 --- a/packages/SystemUI/res/xml/people_space_widget_info.xml +++ b/packages/SystemUI/res/xml/people_space_widget_info.xml @@ -20,8 +20,9 @@ android:minResizeWidth="110dp" android:minResizeHeight="55dp" android:updatePeriodMillis="60000" - android:previewImage="@drawable/ic_person" + android:description="@string/people_tile_description" + android:previewLayout="@layout/people_space_placeholder_layout" android:resizeMode="horizontal|vertical" android:configure="com.android.systemui.people.PeopleSpaceActivity" - android:initialLayout="@layout/people_space_widget"> + android:initialLayout="@layout/people_space_placeholder_layout"> </appwidget-provider> diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollHelper.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollHelper.java index 14eca1b1cb2c..667b7a7cf0a3 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollHelper.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollHelper.java @@ -122,6 +122,8 @@ public class UdfpsEnrollHelper { @NonNull PointF getNextGuidedEnrollmentPoint() { final int index = mLocationsEnrolled - NUM_CENTER_TOUCHES; - return mGuidedEnrollmentPoints.get(index % mGuidedEnrollmentPoints.size()); + final PointF originalPoint = mGuidedEnrollmentPoints + .get(index % mGuidedEnrollmentPoints.size()); + return new PointF(originalPoint.x * 0.5f, originalPoint.y * 0.5f); } } diff --git a/packages/SystemUI/src/com/android/systemui/controls/dagger/ControlsModule.kt b/packages/SystemUI/src/com/android/systemui/controls/dagger/ControlsModule.kt index fbdeb30d3911..ed625de9dce8 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/dagger/ControlsModule.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/dagger/ControlsModule.kt @@ -31,6 +31,7 @@ import com.android.systemui.controls.management.ControlsProviderSelectorActivity import com.android.systemui.controls.management.ControlsRequestDialog import com.android.systemui.controls.ui.ControlActionCoordinator import com.android.systemui.controls.ui.ControlActionCoordinatorImpl +import com.android.systemui.controls.ui.ControlsActivity import com.android.systemui.controls.ui.ControlsUiController import com.android.systemui.controls.ui.ControlsUiControllerImpl import com.android.systemui.dagger.SysUISingleton @@ -113,4 +114,9 @@ abstract class ControlsModule { abstract fun provideControlsRequestDialog( activity: ControlsRequestDialog ): Activity + + @Binds + @IntoMap + @ClassKey(ControlsActivity::class) + abstract fun provideControlsActivity(activity: ControlsActivity): Activity } diff --git a/packages/SystemUI/src/com/android/systemui/controls/management/ControlsEditingActivity.kt b/packages/SystemUI/src/com/android/systemui/controls/management/ControlsEditingActivity.kt index fc89783018bc..7dd1d28170b2 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/management/ControlsEditingActivity.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/management/ControlsEditingActivity.kt @@ -32,7 +32,7 @@ import com.android.systemui.broadcast.BroadcastDispatcher import com.android.systemui.controls.CustomIconCache import com.android.systemui.controls.controller.ControlsControllerImpl import com.android.systemui.controls.controller.StructureInfo -import com.android.systemui.controls.ui.ControlsDialog +import com.android.systemui.controls.ui.ControlsActivity import com.android.systemui.controls.ui.ControlsUiController import com.android.systemui.globalactions.GlobalActionsComponent import com.android.systemui.settings.CurrentUserTracker @@ -112,7 +112,11 @@ class ControlsEditingActivity @Inject constructor( if (backToGlobalActions) { globalActionsComponent.handleShowGlobalActionsMenu() } else { - ControlsDialog(applicationContext, broadcastDispatcher).show(uiController) + val i = Intent().apply { + component = ComponentName(applicationContext, ControlsActivity::class.java) + addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK) + } + startActivity(i) } animateExitAndFinish() } diff --git a/packages/SystemUI/src/com/android/systemui/controls/management/ControlsFavoritingActivity.kt b/packages/SystemUI/src/com/android/systemui/controls/management/ControlsFavoritingActivity.kt index 2d647a907b17..309901443393 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/management/ControlsFavoritingActivity.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/management/ControlsFavoritingActivity.kt @@ -40,7 +40,7 @@ import com.android.systemui.controls.ControlsServiceInfo import com.android.systemui.controls.TooltipManager import com.android.systemui.controls.controller.ControlsControllerImpl import com.android.systemui.controls.controller.StructureInfo -import com.android.systemui.controls.ui.ControlsDialog +import com.android.systemui.controls.ui.ControlsActivity import com.android.systemui.controls.ui.ControlsUiController import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.globalactions.GlobalActionsComponent @@ -352,7 +352,11 @@ class ControlsFavoritingActivity @Inject constructor( if (backToGlobalActions) { globalActionsComponent.handleShowGlobalActionsMenu() } else { - ControlsDialog(applicationContext, broadcastDispatcher).show(uiController) + val i = Intent().apply { + component = ComponentName(applicationContext, ControlsActivity::class.java) + addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK) + } + startActivity(i) } } diff --git a/packages/SystemUI/src/com/android/systemui/controls/management/ControlsProviderSelectorActivity.kt b/packages/SystemUI/src/com/android/systemui/controls/management/ControlsProviderSelectorActivity.kt index d5e41d031eac..fa1c41f01e6c 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/management/ControlsProviderSelectorActivity.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/management/ControlsProviderSelectorActivity.kt @@ -32,7 +32,7 @@ import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver import com.android.systemui.R import com.android.systemui.broadcast.BroadcastDispatcher import com.android.systemui.controls.controller.ControlsController -import com.android.systemui.controls.ui.ControlsDialog +import com.android.systemui.controls.ui.ControlsActivity import com.android.systemui.controls.ui.ControlsUiController import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Main @@ -116,7 +116,11 @@ class ControlsProviderSelectorActivity @Inject constructor( if (backToGlobalActions) { globalActionsComponent.handleShowGlobalActionsMenu() } else { - ControlsDialog(applicationContext, broadcastDispatcher).show(uiController) + val i = Intent().apply { + component = ComponentName(applicationContext, ControlsActivity::class.java) + addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK) + } + startActivity(i) } animateExitAndFinish() } diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinator.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinator.kt index d06568a7caf9..0db15e83fc93 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinator.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinator.kt @@ -16,6 +16,7 @@ package com.android.systemui.controls.ui +import android.content.Context import android.service.controls.Control /** @@ -24,8 +25,8 @@ import android.service.controls.Control */ interface ControlActionCoordinator { - // Handle actions launched from GlobalActionsDialog or ControlDialog - var startedFromGlobalActions: Boolean + // If launched from an Activity, continue within this stack + var activityContext: Context? /** * Close any dialogs which may have been open diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt index 6b300f4e07e4..58a5981845c7 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt @@ -18,6 +18,7 @@ package com.android.systemui.controls.ui import android.annotation.MainThread import android.app.Dialog +import android.content.ComponentName import android.content.Context import android.content.Intent import android.content.pm.PackageManager @@ -60,7 +61,7 @@ class ControlActionCoordinatorImpl @Inject constructor( private var pendingAction: Action? = null private var actionsInProgress = mutableSetOf<String>() - override var startedFromGlobalActions: Boolean = true + override var activityContext: Context? = null companion object { private const val RESPONSE_TIMEOUT_IN_MILLIS = 3000L @@ -83,7 +84,7 @@ class ControlActionCoordinatorImpl @Inject constructor( bouncerOrRun(createAction(cvh.cws.ci.controlId, { cvh.layout.performHapticFeedback(HapticFeedbackConstants.CONTEXT_CLICK) if (cvh.usePanel()) { - showDialog(cvh, control.getAppIntent().getIntent()) + showDetail(cvh, control.getAppIntent().getIntent()) } else { cvh.action(CommandAction(templateId)) } @@ -109,7 +110,7 @@ class ControlActionCoordinatorImpl @Inject constructor( // Long press snould only be called when there is valid control state, otherwise ignore cvh.cws.control?.let { cvh.layout.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS) - showDialog(cvh, it.getAppIntent().getIntent()) + showDetail(cvh, it.getAppIntent().getIntent()) } }, false /* blockable */)) } @@ -151,10 +152,16 @@ class ControlActionCoordinatorImpl @Inject constructor( activityStarter.dismissKeyguardThenExecute({ Log.d(ControlsUiController.TAG, "Device unlocked, invoking controls action") if (closeDialog) { - if (startedFromGlobalActions) { + activityContext?.let { + val i = Intent().apply { + component = ComponentName(context, ControlsActivity::class.java) + addFlags( + Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK) + putExtra(ControlsUiController.BACK_TO_GLOBAL_ACTIONS, false) + } + it.startActivity(i) + } ?: run { globalActionsComponent.handleShowGlobalActionsMenu() - } else { - ControlsDialog(context, broadcastDispatcher).show(lazyUiController.get()) } } else { action.invoke() @@ -170,9 +177,9 @@ class ControlActionCoordinatorImpl @Inject constructor( bgExecutor.execute { vibrator.vibrate(effect) } } - private fun showDialog(cvh: ControlViewHolder, intent: Intent) { + private fun showDetail(cvh: ControlViewHolder, intent: Intent) { bgExecutor.execute { - val activities: List<ResolveInfo> = cvh.context.packageManager.queryIntentActivities( + val activities: List<ResolveInfo> = context.packageManager.queryIntentActivities( intent, PackageManager.MATCH_DEFAULT_ONLY ) @@ -180,8 +187,8 @@ class ControlActionCoordinatorImpl @Inject constructor( uiExecutor.execute { // make sure the intent is valid before attempting to open the dialog if (activities.isNotEmpty() && taskViewFactory.isPresent) { - taskViewFactory.get().create(cvh.context, uiExecutor, { - dialog = DetailDialog(cvh, it, intent).also { + taskViewFactory.get().create(context, uiExecutor, { + dialog = DetailDialog(activityContext, it, intent, cvh).also { it.setOnDismissListener { _ -> dialog = null } it.show() } diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsActivity.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsActivity.kt new file mode 100644 index 000000000000..a35b792ac7f1 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsActivity.kt @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2021 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.controls.ui + +import android.os.Bundle +import android.view.View +import android.view.ViewGroup +import android.view.WindowInsets +import android.view.WindowInsets.Type + +import com.android.systemui.R +import com.android.systemui.controls.management.ControlsAnimations +import com.android.systemui.util.LifecycleActivity +import javax.inject.Inject + +/** + * Displays Device Controls inside an activity + */ +class ControlsActivity @Inject constructor( + private val uiController: ControlsUiController +) : LifecycleActivity() { + + private lateinit var parent: ViewGroup + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + setContentView(R.layout.controls_fullscreen) + + requireViewById<ViewGroup>(R.id.control_detail_root).apply { + setOnApplyWindowInsetsListener { + v: View, insets: WindowInsets -> + v.apply { + val l = getPaddingLeft() + val t = getPaddingTop() + val r = getPaddingRight() + setPadding(l, t, r, insets.getInsets(Type.systemBars()).bottom) + } + + WindowInsets.CONSUMED + } + } + } + + override fun onStart() { + super.onStart() + + parent = requireViewById<ViewGroup>(R.id.global_actions_controls) + parent.alpha = 0f + uiController.show(parent, { animateExitAndFinish() }, this) + } + + override fun onResume() { + super.onResume() + + ControlsAnimations.enterAnimation(parent).start() + } + + override fun onBackPressed() { + animateExitAndFinish() + } + + override fun onStop() { + super.onStop() + + uiController.hide() + } + + private fun animateExitAndFinish() { + ControlsAnimations.exitAnimation(parent, { finish() }).start() + } +} diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsDialog.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsDialog.kt deleted file mode 100644 index 537334aeb2f7..000000000000 --- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsDialog.kt +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2021 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.controls.ui - -import android.app.Dialog -import android.content.BroadcastReceiver -import android.content.Context -import android.content.Intent -import android.content.IntentFilter -import android.view.View -import android.view.ViewGroup -import android.view.WindowManager - -import com.android.systemui.Interpolators -import com.android.systemui.R -import com.android.systemui.broadcast.BroadcastDispatcher -import javax.inject.Inject - -/** - * Show the controls space inside a dialog, as from the lock screen. - */ -class ControlsDialog @Inject constructor( - thisContext: Context, - val broadcastDispatcher: BroadcastDispatcher -) : Dialog(thisContext, R.style.Theme_SystemUI_Dialog_Control_LockScreen) { - - private val receiver = object : BroadcastReceiver() { - override fun onReceive(context: Context, intent: Intent) { - val action = intent.getAction() - if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) { - dismiss() - } - } - } - - init { - window.setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG) - window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM - or WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED) - - setContentView(R.layout.controls_in_dialog) - - requireViewById<ViewGroup>(R.id.control_detail_root).apply { - setOnClickListener { dismiss() } - (getParent() as View).setOnClickListener { dismiss() } - } - } - - fun show( - controller: ControlsUiController - ): ControlsDialog { - super.show() - - val vg = requireViewById<ViewGroup>(com.android.systemui.R.id.global_actions_controls) - vg.alpha = 0f - controller.show(vg, { dismiss() }, false /* startedFromGlobalActions */) - - vg.animate() - .alpha(1f) - .setInterpolator(Interpolators.LINEAR_OUT_SLOW_IN) - .setDuration(300) - - val filter = IntentFilter() - filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS) - broadcastDispatcher.registerReceiver(receiver, filter) - - return this - } - - override fun dismiss() { - broadcastDispatcher.unregisterReceiver(receiver) - - if (!isShowing()) return - - super.dismiss() - } -} diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiController.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiController.kt index 20bdf609357e..f86948ee8957 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiController.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiController.kt @@ -17,6 +17,7 @@ package com.android.systemui.controls.ui import android.content.ComponentName +import android.content.Context import android.service.controls.Control import android.service.controls.actions.ControlAction import android.view.ViewGroup @@ -30,7 +31,7 @@ interface ControlsUiController { public const val BACK_TO_GLOBAL_ACTIONS = "back_to_global_actions" } - fun show(parent: ViewGroup, onDismiss: Runnable, startedFromGlobalActions: Boolean) + fun show(parent: ViewGroup, onDismiss: Runnable, activityContext: Context?) fun hide() /** diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt index c94d85aa58c4..0f7f48ff951a 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt @@ -148,7 +148,7 @@ class ControlsUiControllerImpl @Inject constructor ( override fun show( parent: ViewGroup, onDismiss: Runnable, - startedFromGlobalActions: Boolean + activityContext: Context? ) { Log.d(ControlsUiController.TAG, "show()") this.parent = parent @@ -156,7 +156,7 @@ class ControlsUiControllerImpl @Inject constructor ( hidden = false retainCache = false - controlActionCoordinator.startedFromGlobalActions = startedFromGlobalActions + controlActionCoordinator.activityContext = activityContext allStructures = controlsController.get().getFavorites() selectedStructure = loadPreference(allStructures) @@ -193,7 +193,7 @@ class ControlsUiControllerImpl @Inject constructor ( controlViewsById.clear() controlsById.clear() - show(parent, onDismiss, controlActionCoordinator.startedFromGlobalActions) + show(parent, onDismiss, controlActionCoordinator.activityContext) val showAnim = ObjectAnimator.ofFloat(parent, "alpha", 0.0f, 1.0f) showAnim.setInterpolator(DecelerateInterpolator(1.0f)) showAnim.setDuration(FADE_IN_MILLIS) @@ -268,7 +268,7 @@ class ControlsUiControllerImpl @Inject constructor ( intent.putExtra(ControlsUiController.EXTRA_ANIMATE, true) intent.putExtra( ControlsUiController.BACK_TO_GLOBAL_ACTIONS, - controlActionCoordinator.startedFromGlobalActions + controlActionCoordinator.activityContext == null ) onDismiss.run() @@ -392,6 +392,17 @@ class ControlsUiControllerImpl @Inject constructor ( val inflater = LayoutInflater.from(context) inflater.inflate(R.layout.controls_with_favorites, parent, true) + if (controlActionCoordinator.activityContext == null) { + parent.requireViewById<View>(R.id.controls_spacer).apply { + visibility = View.VISIBLE + } + } else { + parent.requireViewById<ImageView>(R.id.controls_close).apply { + setOnClickListener { _: View -> onDismiss.run() } + visibility = View.VISIBLE + } + } + val maxColumns = findMaxColumns() val listView = parent.requireViewById(R.id.global_actions_controls_list) as ViewGroup @@ -502,6 +513,8 @@ class ControlsUiControllerImpl @Inject constructor ( override fun hide() { hidden = true + controlActionCoordinator.activityContext = null + closeDialogs(true) controlsController.get().unsubscribe() diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/DetailDialog.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/DetailDialog.kt index 020694d89fce..9c788df362de 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/ui/DetailDialog.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/ui/DetailDialog.kt @@ -22,8 +22,8 @@ import android.app.ActivityTaskManager.INVALID_TASK_ID import android.app.Dialog import android.app.PendingIntent import android.content.ComponentName +import android.content.Context import android.content.Intent -import android.provider.Settings import android.view.View import android.view.ViewGroup import android.view.WindowInsets @@ -35,18 +35,20 @@ import com.android.systemui.R import com.android.wm.shell.TaskView /** - * A dialog that provides an {@link ActivityView}, allowing the application to provide + * A dialog that provides an {@link TaskView}, allowing the application to provide * additional information and actions pertaining to a {@link android.service.controls.Control}. * The activity being launched is specified by {@link android.service.controls.Control#getAppIntent}. */ class DetailDialog( - val cvh: ControlViewHolder, - val activityView: TaskView, - val intent: Intent -) : Dialog(cvh.context, R.style.Theme_SystemUI_Dialog_Control_DetailPanel) { - + val activityContext: Context?, + val taskView: TaskView, + val intent: Intent, + val cvh: ControlViewHolder +) : Dialog( + activityContext ?: cvh.context, + R.style.Theme_SystemUI_Dialog_Control_DetailPanel +) { companion object { - private const val PANEL_TOP_OFFSET = "systemui.controls_panel_top_offset" /* * Indicate to the activity that it is being rendered in a bottomsheet, and they * should optimize the layout for a smaller space. @@ -71,10 +73,19 @@ class DetailDialog( launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT) launchIntent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK) - activityView.startActivity( - PendingIntent.getActivity(context, 0, launchIntent, - PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE), - null, ActivityOptions.makeBasic()) + val options = activityContext?.let { + ActivityOptions.makeCustomAnimation( + it, + 0 /* enterResId */, + 0 /* exitResId */ + ) + } ?: ActivityOptions.makeBasic() + taskView.startActivity( + PendingIntent.getActivity(context, 0, launchIntent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE), + null, + options + ) } override fun onTaskRemovalStarted(taskId: Int) { @@ -92,7 +103,10 @@ class DetailDialog( } init { - window.setType(WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY) + if (activityContext == null) { + window.setType(WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY) + } + // To pass touches to the task inside TaskView. window.addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL) window.addPrivateFlags(WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY) @@ -100,7 +114,7 @@ class DetailDialog( setContentView(R.layout.controls_detail_dialog) requireViewById<ViewGroup>(R.id.controls_activity_view).apply { - addView(activityView) + addView(taskView) } requireViewById<ImageView>(R.id.control_detail_close).apply { @@ -120,48 +134,34 @@ class DetailDialog( // consume all insets to achieve slide under effect window.getDecorView().setOnApplyWindowInsetsListener { - _: View, insets: WindowInsets -> - activityView.apply { + v: View, insets: WindowInsets -> + taskView.apply { val l = getPaddingLeft() val t = getPaddingTop() val r = getPaddingRight() setPadding(l, t, r, insets.getInsets(Type.systemBars()).bottom) } - WindowInsets.CONSUMED - } - - requireViewById<ViewGroup>(R.id.control_detail_root).apply { - // use flag only temporarily for testing - val resolver = cvh.context.contentResolver - val defaultOffsetInPx = cvh.context.resources - .getDimensionPixelSize(R.dimen.controls_activity_view_top_offset) - val offsetInPx = Settings.Secure.getInt(resolver, PANEL_TOP_OFFSET, defaultOffsetInPx) - - val lp = getLayoutParams() as ViewGroup.MarginLayoutParams - lp.topMargin = offsetInPx - setLayoutParams(lp) + val l = v.getPaddingLeft() + val b = v.getPaddingBottom() + val r = v.getPaddingRight() + v.setPadding(l, insets.getInsets(Type.systemBars()).top, r, b) - setOnClickListener { dismiss() } - (getParent() as View).setOnClickListener { dismiss() } + WindowInsets.CONSUMED } if (ScreenDecorationsUtils.supportsRoundedCornersOnWindows(context.getResources())) { val cornerRadius = context.resources .getDimensionPixelSize(R.dimen.controls_activity_view_corner_radius) - activityView.setCornerRadius(cornerRadius.toFloat()) + taskView.setCornerRadius(cornerRadius.toFloat()) } - } - - override fun show() { - activityView.setListener(cvh.uiExecutor, stateCallback) - super.show() + taskView.setListener(cvh.uiExecutor, stateCallback) } override fun dismiss() { if (!isShowing()) return - activityView.release() + taskView.release() super.dismiss() } diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java b/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java index c26cc4466c6d..d8ade2bdd21f 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java @@ -225,8 +225,8 @@ public class DozeLog implements Dumpable { * Appends wake-display event to the logs. * @param wake if we're waking up or sleeping. */ - public void traceWakeDisplay(boolean wake) { - mLogger.logWakeDisplay(wake); + public void traceWakeDisplay(boolean wake, @Reason int reason) { + mLogger.logWakeDisplay(wake, reason); } /** @@ -380,6 +380,7 @@ public class DozeLog implements Dumpable { case REASON_SENSOR_WAKE_UP: return "wakeup"; case REASON_SENSOR_TAP: return "tap"; case REASON_SENSOR_UDFPS_LONG_PRESS: return "udfps"; + case REASON_SENSOR_QUICK_PICKUP: return "quickPickup"; default: throw new IllegalArgumentException("invalid reason: " + pulseReason); } } @@ -389,7 +390,7 @@ public class DozeLog implements Dumpable { PULSE_REASON_SENSOR_SIGMOTION, REASON_SENSOR_PICKUP, REASON_SENSOR_DOUBLE_TAP, PULSE_REASON_SENSOR_LONG_PRESS, PULSE_REASON_DOCKING, REASON_SENSOR_WAKE_UP, PULSE_REASON_SENSOR_WAKE_LOCK_SCREEN, REASON_SENSOR_TAP, - REASON_SENSOR_UDFPS_LONG_PRESS}) + REASON_SENSOR_UDFPS_LONG_PRESS, REASON_SENSOR_QUICK_PICKUP}) public @interface Reason {} public static final int PULSE_REASON_NONE = -1; public static final int PULSE_REASON_INTENT = 0; @@ -403,6 +404,7 @@ public class DozeLog implements Dumpable { public static final int PULSE_REASON_SENSOR_WAKE_LOCK_SCREEN = 8; public static final int REASON_SENSOR_TAP = 9; public static final int REASON_SENSOR_UDFPS_LONG_PRESS = 10; + public static final int REASON_SENSOR_QUICK_PICKUP = 11; - public static final int TOTAL_REASONS = 11; + public static final int TOTAL_REASONS = 12; } diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeLogger.kt b/packages/SystemUI/src/com/android/systemui/doze/DozeLogger.kt index fddefae6f5b6..9bc74be9b9c3 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeLogger.kt +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeLogger.kt @@ -16,6 +16,7 @@ package com.android.systemui.doze +import android.view.Display import com.android.systemui.doze.DozeLog.Reason import com.android.systemui.doze.DozeLog.reasonToString import com.android.systemui.log.LogBuffer @@ -161,17 +162,18 @@ class DozeLogger @Inject constructor( fun logDisplayStateChanged(displayState: Int) { buffer.log(TAG, INFO, { - int1 = displayState + str1 = Display.stateToString(displayState) }, { - "Display state changed to $int1" + "Display state changed to $str1" }) } - fun logWakeDisplay(isAwake: Boolean) { + fun logWakeDisplay(isAwake: Boolean, @Reason reason: Int) { buffer.log(TAG, DEBUG, { bool1 = isAwake + int1 = reason }, { - "Display wakefulness changed, isAwake=$bool1" + "Display wakefulness changed, isAwake=$bool1, reason=${reasonToString(int1)}" }) } diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeSensors.java b/packages/SystemUI/src/com/android/systemui/doze/DozeSensors.java index c542e5b07d9b..52c9f164a16e 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeSensors.java +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeSensors.java @@ -113,6 +113,8 @@ public class DozeSensors { mCallback = callback; mProximitySensor = proximitySensor; + boolean udfpsEnrolled = + authController.isUdfpsEnrolled(KeyguardUpdateMonitor.getCurrentUser()); boolean alwaysOn = mConfig.alwaysOnEnabled(UserHandle.USER_CURRENT); mSensors = new TriggerSensor[] { new TriggerSensor( @@ -159,7 +161,7 @@ public class DozeSensors { findSensorWithType(config.udfpsLongPressSensorType()), "doze_pulse_on_auth", true /* settingDef */, - authController.isUdfpsEnrolled(KeyguardUpdateMonitor.getCurrentUser()), + udfpsEnrolled, DozeLog.REASON_SENSOR_UDFPS_LONG_PRESS, true /* reports touch coordinates */, true /* touchscreen */, @@ -181,6 +183,15 @@ public class DozeSensors { false /* touchscreen */, mConfig.getWakeLockScreenDebounce(), dozeLog), + new TriggerSensor( + findSensorWithType(config.quickPickupSensorType()), + Settings.Secure.DOZE_QUICK_PICKUP_GESTURE, + false /* setting default */, + config.quickPickupSensorEnabled(KeyguardUpdateMonitor.getCurrentUser()) + && udfpsEnrolled, + DozeLog.REASON_SENSOR_QUICK_PICKUP, + false /* touchCoords */, + false /* touchscreen */, dozeLog), }; setProxListening(false); // Don't immediately start listening when we register. diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeTriggers.java b/packages/SystemUI/src/com/android/systemui/doze/DozeTriggers.java index c617f3d751d0..04b46705226f 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeTriggers.java +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeTriggers.java @@ -42,10 +42,13 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.systemui.Dependency; import com.android.systemui.biometrics.AuthController; import com.android.systemui.broadcast.BroadcastDispatcher; +import com.android.systemui.dagger.qualifiers.Background; +import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dock.DockManager; import com.android.systemui.doze.dagger.DozeScope; import com.android.systemui.statusbar.phone.DozeParameters; import com.android.systemui.util.Assert; +import com.android.systemui.util.concurrency.DelayableExecutor; import com.android.systemui.util.sensors.AsyncSensorManager; import com.android.systemui.util.sensors.ProximitySensor; import com.android.systemui.util.settings.SecureSettings; @@ -76,6 +79,7 @@ public class DozeTriggers implements DozeMachine.Part { * Assuming that the screen should start on. */ private static boolean sWakeDisplaySensorState = true; + private Runnable mQuickPickupDozeCancellable; private static final int PROXIMITY_TIMEOUT_DELAY_MS = 500; @@ -96,6 +100,8 @@ public class DozeTriggers implements DozeMachine.Part { private final ProximitySensor.ProximityCheck mProxCheck; private final BroadcastDispatcher mBroadcastDispatcher; private final AuthController mAuthController; + private final DelayableExecutor mMainExecutor; + private final DelayableExecutor mBgExecutor; private long mNotificationPulseTime; private boolean mPulsePending; @@ -135,7 +141,10 @@ public class DozeTriggers implements DozeMachine.Part { DOZING_UPDATE_SENSOR_TAP(441), @UiEvent(doc = "Dozing updated because on display auth was triggered from AOD.") - DOZING_UPDATE_AUTH_TRIGGERED(657); + DOZING_UPDATE_AUTH_TRIGGERED(657), + + @UiEvent(doc = "Dozing updated because quick pickup sensor woke up.") + DOZING_UPDATE_QUICK_PICKUP(708); private final int mId; @@ -160,6 +169,7 @@ public class DozeTriggers implements DozeMachine.Part { case 8: return DOZING_UPDATE_SENSOR_WAKE_LOCKSCREEN; case 9: return DOZING_UPDATE_SENSOR_TAP; case 10: return DOZING_UPDATE_AUTH_TRIGGERED; + case 11: return DOZING_UPDATE_QUICK_PICKUP; default: return null; } } @@ -172,7 +182,8 @@ public class DozeTriggers implements DozeMachine.Part { WakeLock wakeLock, DockManager dockManager, ProximitySensor proximitySensor, ProximitySensor.ProximityCheck proxCheck, DozeLog dozeLog, BroadcastDispatcher broadcastDispatcher, - SecureSettings secureSettings, AuthController authController) { + SecureSettings secureSettings, AuthController authController, + @Main DelayableExecutor mainExecutor, @Background DelayableExecutor bgExecutor) { mContext = context; mDozeHost = dozeHost; mConfig = config; @@ -189,6 +200,8 @@ public class DozeTriggers implements DozeMachine.Part { mDozeLog = dozeLog; mBroadcastDispatcher = broadcastDispatcher; mAuthController = authController; + mMainExecutor = mainExecutor; + mBgExecutor = bgExecutor; } @Override @@ -262,18 +275,22 @@ public class DozeTriggers implements DozeMachine.Part { boolean isTap = pulseReason == DozeLog.REASON_SENSOR_TAP; boolean isPickup = pulseReason == DozeLog.REASON_SENSOR_PICKUP; boolean isLongPress = pulseReason == DozeLog.PULSE_REASON_SENSOR_LONG_PRESS; - boolean isWakeDisplay = pulseReason == DozeLog.REASON_SENSOR_WAKE_UP; - boolean isWakeLockScreen = pulseReason == DozeLog.PULSE_REASON_SENSOR_WAKE_LOCK_SCREEN; + boolean isWakeOnPresence = pulseReason == DozeLog.REASON_SENSOR_WAKE_UP; + boolean isWakeOnReach = pulseReason == DozeLog.PULSE_REASON_SENSOR_WAKE_LOCK_SCREEN; boolean isUdfpsLongPress = pulseReason == DozeLog.REASON_SENSOR_UDFPS_LONG_PRESS; - boolean wakeEvent = rawValues != null && rawValues.length > 0 && rawValues[0] != 0; - - if (isWakeDisplay) { - onWakeScreen(wakeEvent, mMachine.isExecutingTransition() ? null : mMachine.getState()); + boolean isQuickPickup = pulseReason == DozeLog.REASON_SENSOR_QUICK_PICKUP; + boolean isWakeDisplayEvent = isQuickPickup || ((isWakeOnPresence || isWakeOnReach) + && rawValues != null && rawValues.length > 0 && rawValues[0] != 0); + + if (isWakeOnPresence || isQuickPickup) { + onWakeScreen(isQuickPickup || isWakeDisplayEvent, + mMachine.isExecutingTransition() ? null : mMachine.getState(), + pulseReason); } else if (isLongPress) { requestPulse(pulseReason, true /* alreadyPerformedProxCheck */, null /* onPulseSuppressedListener */); - } else if (isWakeLockScreen) { - if (wakeEvent) { + } else if (isWakeOnReach) { + if (isWakeDisplayEvent) { requestPulse(pulseReason, true /* alreadyPerformedProxCheck */, null /* onPulseSuppressedListener */); } @@ -370,13 +387,17 @@ public class DozeTriggers implements DozeMachine.Part { * @param state The current state, or null if the state could not be determined due to enqueued * transitions. */ - private void onWakeScreen(boolean wake, @Nullable DozeMachine.State state) { - mDozeLog.traceWakeDisplay(wake); - sWakeDisplaySensorState = wake; + private void onWakeScreen(boolean wake, @Nullable DozeMachine.State state, int reason) { + mDozeLog.traceWakeDisplay(wake, reason); + final boolean isWakeOnPresence = reason == DozeLog.REASON_SENSOR_WAKE_UP; + final boolean isQuickPickup = reason == DozeLog.REASON_SENSOR_QUICK_PICKUP; + if (isWakeOnPresence) { + sWakeDisplaySensorState = wake; + } if (wake) { proximityCheckThenCall((result) -> { - if (result != null && result) { + if (result != null && result) { // In pocket, drop event. return; } @@ -385,26 +406,51 @@ public class DozeTriggers implements DozeMachine.Part { // Logs AOD open due to sensor wake up. mMetricsLogger.write(new LogMaker(MetricsEvent.DOZING) .setType(MetricsEvent.TYPE_OPEN) - .setSubtype(DozeLog.REASON_SENSOR_WAKE_UP)); + .setSubtype(reason)); + + if (isQuickPickup) { + // schedule runnable to go back to DOZE + onQuickPickup(); + } + } else if (state == DozeMachine.State.DOZE_AOD && isQuickPickup) { + // elongate time in DOZE_AOD, schedule new runnable to go back to DOZE + onQuickPickup(); } - }, true /* alreadyPerformedProxCheck */, DozeLog.REASON_SENSOR_WAKE_UP); + }, isQuickPickup /* alreadyPerformedProxCheck */, reason); } else { boolean paused = (state == DozeMachine.State.DOZE_AOD_PAUSED); boolean pausing = (state == DozeMachine.State.DOZE_AOD_PAUSING); + boolean pulse = (state == DozeMachine.State.DOZE_REQUEST_PULSE) + || (state == DozeMachine.State.DOZE_PULSING) + || (state == DozeMachine.State.DOZE_PULSING_BRIGHT); + boolean docked = (state == DozeMachine.State.DOZE_AOD_DOCKED); if (!pausing && !paused) { + if (isQuickPickup && (pulse || docked)) { + return; + } mMachine.requestState(DozeMachine.State.DOZE); // Logs AOD close due to sensor wake up. mMetricsLogger.write(new LogMaker(MetricsEvent.DOZING) .setType(MetricsEvent.TYPE_CLOSE) - .setSubtype(DozeLog.REASON_SENSOR_WAKE_UP)); + .setSubtype(reason)); } } } + private void onQuickPickup() { + cancelQuickPickupDelayableDoze(); + mQuickPickupDozeCancellable = mMainExecutor.executeDelayed(() -> { + onWakeScreen(false, + mMachine.isExecutingTransition() ? null : mMachine.getState(), + DozeLog.REASON_SENSOR_QUICK_PICKUP); + }, mDozeParameters.getQuickPickupAodDuration()); + } + @Override public void transitionTo(DozeMachine.State oldState, DozeMachine.State newState) { switch (newState) { case INITIALIZED: + sWakeDisplaySensorState = true; mBroadcastReceiver.register(mBroadcastDispatcher); mDozeHost.addCallback(mHostCallback); mDockManager.addListener(mDockEventListener); @@ -417,7 +463,7 @@ public class DozeTriggers implements DozeMachine.Part { mWantSensors = true; mWantTouchScreenSensors = true; if (newState == DozeMachine.State.DOZE_AOD && !sWakeDisplaySensorState) { - onWakeScreen(false, newState); + onWakeScreen(false, newState, DozeLog.REASON_SENSOR_WAKE_UP); } break; case DOZE_AOD_PAUSED: @@ -437,6 +483,7 @@ public class DozeTriggers implements DozeMachine.Part { mDozeSensors.requestTemporaryDisable(); break; case FINISH: + cancelQuickPickupDelayableDoze(); mBroadcastReceiver.unregister(mBroadcastDispatcher); mDozeHost.removeCallback(mHostCallback); mDockManager.removeListener(mDockEventListener); @@ -460,6 +507,17 @@ public class DozeTriggers implements DozeMachine.Part { mDozeSensors.setListening(mWantSensors, mWantTouchScreenSensors); } + /** + * Cancels last scheduled Runnable that transitions to STATE_DOZE (blank screen) after + * going into STATE_AOD (AOD screen) from the quick pickup gesture. + */ + private void cancelQuickPickupDelayableDoze() { + if (mQuickPickupDozeCancellable != null) { + mQuickPickupDozeCancellable.run(); + mQuickPickupDozeCancellable = null; + } + } + private void checkTriggersAtInit() { if (mUiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_CAR || mDozeHost.isBlockingDoze() diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java index 1f67276bfbae..461a7303c184 100644 --- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java +++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java @@ -2220,7 +2220,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, private void showControls(ControlsUiController controller) { mControlsUiController = controller; mControlsUiController.show(mControlsView, this::dismissForControlsActivity, - true /* startedFromGlobalActions */); + null /* activityContext */); } private boolean isWalletViewAvailable() { @@ -2449,7 +2449,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, }); if (mControlsUiController != null) { mControlsUiController.show(mControlsView, this::dismissForControlsActivity, - true /* startedFromGlobalActions */); + null /* activityContext */); } mBackgroundDrawable.setAlpha(0); @@ -2625,7 +2625,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, mGlobalActionsLayout.updateList(); if (mControlsUiController != null) { mControlsUiController.show(mControlsView, this::dismissForControlsActivity, - true /* startedFromGlobalActions */); + null /* activityContext */); } } diff --git a/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceActivity.java b/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceActivity.java index a69ec278be91..378e49deb699 100644 --- a/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceActivity.java +++ b/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceActivity.java @@ -35,6 +35,7 @@ import android.view.ViewGroup; import com.android.systemui.R; import com.android.systemui.people.widget.PeopleSpaceWidgetManager; +import com.android.systemui.people.widget.PeopleTileKey; import com.android.systemui.statusbar.notification.NotificationEntryManager; import java.util.List; @@ -117,7 +118,7 @@ public class PeopleSpaceActivity extends Activity { String pkg = tile.getPackageName(); String status = PeopleSpaceUtils.getLastInteractionString(mContext, - tile.getLastInteractionTimestamp(), true); + tile.getLastInteractionTimestamp()); tileView.setStatus(status); tileView.setName(tile.getUserName().toString()); @@ -138,7 +139,9 @@ public class PeopleSpaceActivity extends Activity { + mAppWidgetId); } } - mPeopleSpaceWidgetManager.addNewWidget(tile, mAppWidgetId); + PeopleTileKey key = new PeopleTileKey( + tile.getId(), tile.getUserHandle().getIdentifier(), tile.getPackageName()); + mPeopleSpaceWidgetManager.addNewWidget(mAppWidgetId, key); finishActivity(); } diff --git a/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceUtils.java b/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceUtils.java index 502c95c47d03..aa45178b6439 100644 --- a/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceUtils.java +++ b/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceUtils.java @@ -52,9 +52,7 @@ import android.icu.text.MeasureFormat; import android.icu.util.Measure; import android.icu.util.MeasureUnit; import android.net.Uri; -import android.os.Bundle; import android.os.Parcelable; -import android.os.ServiceManager; import android.provider.ContactsContract; import android.provider.Settings; import android.service.notification.ConversationChannelWrapper; @@ -71,10 +69,11 @@ import com.android.internal.logging.UiEvent; import com.android.internal.logging.UiEventLogger; import com.android.internal.util.ArrayUtils; import com.android.settingslib.utils.ThreadUtils; -import com.android.systemui.Dependency; import com.android.systemui.R; +import com.android.systemui.people.widget.AppWidgetOptionsHelper; import com.android.systemui.people.widget.LaunchConversationActivity; import com.android.systemui.people.widget.PeopleSpaceWidgetProvider; +import com.android.systemui.people.widget.PeopleTileKey; import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.collection.NotificationEntry; @@ -106,7 +105,6 @@ public class PeopleSpaceUtils { private static final int DAYS_IN_A_WEEK = 7; private static final int MIN_HOUR = 1; private static final int ONE_DAY = 1; - public static final String OPTIONS_PEOPLE_SPACE_TILE = "options_people_space_tile"; public static final String PACKAGE_NAME = "package_name"; public static final String USER_ID = "user_id"; public static final String SHORTCUT_ID = "shortcut_id"; @@ -115,6 +113,9 @@ public class PeopleSpaceUtils { public static final int INVALID_WIDGET_ID = -1; public static final int INVALID_USER_ID = -1; + public static final PeopleTileKey EMPTY_KEY = + new PeopleTileKey(EMPTY_STRING, INVALID_USER_ID, EMPTY_STRING); + private static final Pattern DOUBLE_EXCLAMATION_PATTERN = Pattern.compile("[!][!]+"); private static final Pattern DOUBLE_QUESTION_PATTERN = Pattern.compile("[?][?]+"); private static final Pattern ANY_DOUBLE_MARK_PATTERN = Pattern.compile("[!?][!?]+"); @@ -200,67 +201,76 @@ public class PeopleSpaceUtils { AppWidgetManager appWidgetManager, IPeopleManager peopleManager) { Map<Integer, PeopleSpaceTile> widgetIdToTile = new HashMap<>(); for (int appWidgetId : appWidgetIds) { - PeopleSpaceTile tile = getPeopleSpaceTile(peopleManager, appWidgetManager, context, - appWidgetId); + PeopleSpaceTile tile = getPeopleSpaceTile( + context, appWidgetId, appWidgetManager, peopleManager); if (tile == null) { if (DEBUG) Log.d(TAG, "Matching conversation not found for shortcut ID"); //TODO: Delete app widget id when crash is fixed (b/172932636) continue; } - - if (DEBUG) Log.d(TAG, "Widget: " + appWidgetId + ", " + tile.getUserName()); - RemoteViews views = createRemoteViews(context, tile, appWidgetId); - - // Tell the AppWidgetManager to perform an update on the current app widget. - appWidgetManager.updateAppWidget(appWidgetId, views); - + updateAppWidgetOptionsAndView(appWidgetManager, context, appWidgetId, tile); widgetIdToTile.put(appWidgetId, tile); } getBirthdaysOnBackgroundThread(context, appWidgetManager, widgetIdToTile, appWidgetIds); } + /** + * Returns a {@link PeopleSpaceTile} based on the {@code appWidgetId}. If the PeopleSpaceTile + * isn't cached, store it in AppWidgetOptions. + */ @Nullable - public static PeopleSpaceTile getPeopleSpaceTile(IPeopleManager peopleManager, - AppWidgetManager appWidgetManager, - Context context, int appWidgetId) { - try { - // Migrate storage for existing users. - SharedPreferences widgetSp = context.getSharedPreferences(String.valueOf(appWidgetId), - Context.MODE_PRIVATE); - String pkg = widgetSp.getString(PACKAGE_NAME, EMPTY_STRING); - int userId = widgetSp.getInt(USER_ID, INVALID_USER_ID); - String shortcutId = widgetSp.getString(SHORTCUT_ID, EMPTY_STRING); - if (!validKey(shortcutId, pkg, userId)) { - SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); - shortcutId = sp.getString(String.valueOf(appWidgetId), null); - if (shortcutId == null) { - Log.e(TAG, "Cannot restore widget"); - return null; - } - migrateExistingUsersToNewStorage(context, shortcutId, appWidgetId); - pkg = widgetSp.getString(PACKAGE_NAME, EMPTY_STRING); - userId = widgetSp.getInt(USER_ID, INVALID_USER_ID); - } + public static PeopleSpaceTile getPeopleSpaceTile(Context context, int appWidgetId, + AppWidgetManager appWidgetManager, IPeopleManager peopleManager) { + // First, check if tile is cached in AppWidgetOptions. + PeopleSpaceTile tile = AppWidgetOptionsHelper.getPeopleTile(appWidgetManager, appWidgetId); + if (tile != null) { + if (DEBUG) Log.d(TAG, "People Tile is cached for widget: " + appWidgetId); + return tile; + } - // Check if tile is cached. - Bundle options = appWidgetManager.getAppWidgetOptions(appWidgetId); - PeopleSpaceTile tile = options.getParcelable(OPTIONS_PEOPLE_SPACE_TILE); - if (tile != null) { - return tile; - } + // If not, we get the PeopleTileKey from SharedPreferences, retrieve the Conversation from + // persisted storage, and cache it in AppWidgetOptions. + SharedPreferences widgetSp = context.getSharedPreferences( + String.valueOf(appWidgetId), + Context.MODE_PRIVATE); + PeopleTileKey sharedPreferencesKey = new PeopleTileKey( + widgetSp.getString(SHORTCUT_ID, EMPTY_STRING), + widgetSp.getInt(USER_ID, INVALID_USER_ID), + widgetSp.getString(PACKAGE_NAME, EMPTY_STRING)); - // If tile is null, we need to retrieve from persisted storage. - if (DEBUG) { - Log.d(TAG, - "Retrieving from storage after reboots: " + shortcutId + " user: " + userId - + " pkg: " + pkg); - } + if (!sharedPreferencesKey.isValid()) { + Log.e(TAG, "Cannot find shortcut info for widgetId: " + appWidgetId); + return null; + } + + if (DEBUG) Log.d(TAG, "PeopleTile key is present in sharedPreferences: " + appWidgetId); + // If tile is null, we need to retrieve from persisted storage. + return getPeopleTileFromPersistentStorage(context, sharedPreferencesKey, peopleManager); + } + + /** + * Returns a {@link PeopleSpaceTile} based on {@link ConversationChannel} returned by + * {@link IPeopleManager}. + */ + public static PeopleSpaceTile getPeopleTileFromPersistentStorage(Context context, + PeopleTileKey peopleTileKey, IPeopleManager peopleManager) { + try { + if (DEBUG) Log.d(TAG, "Retrieving Tile from storage: " + peopleTileKey.toString()); LauncherApps launcherApps = context.getSystemService(LauncherApps.class); - ConversationChannel channel = peopleManager.getConversation(pkg, userId, shortcutId); + if (launcherApps == null) { + Log.d(TAG, "LauncherApps is null"); + return null; + } + + ConversationChannel channel = peopleManager.getConversation( + peopleTileKey.getPackageName(), + peopleTileKey.getUserId(), + peopleTileKey.getShortcutId()); if (channel == null) { Log.d(TAG, "Could not retrieve conversation from storage"); return null; } + return new PeopleSpaceTile.Builder(channel, launcherApps).build(); } catch (Exception e) { Log.e(TAG, "Failed to retrieve conversation for tile: " + e); @@ -269,79 +279,46 @@ public class PeopleSpaceUtils { } /** Returns stored widgets for the conversation specified. */ - public static Set<String> getStoredWidgetIds(SharedPreferences sp, String shortcutId, - String packageName, int userId) { - if (shortcutId == null || packageName == null) { + public static Set<String> getStoredWidgetIds(SharedPreferences sp, PeopleTileKey key) { + if (!key.isValid()) { return new HashSet<>(); } - String key = PeopleSpaceUtils.getKey(shortcutId, packageName, userId); - return new HashSet<>(sp.getStringSet(key, new HashSet<>())); - } - - - /** Best-effort attempts to migrate existing users to the new storage format. */ - // TODO: Remove after sufficient time. Temporary migration storage for existing users. - private static void migrateExistingUsersToNewStorage(Context context, String shortcutId, - int appWidgetId) { - try { - List<PeopleSpaceTile> tiles = - PeopleSpaceUtils.getTiles(context, INotificationManager.Stub.asInterface( - ServiceManager.getService(Context.NOTIFICATION_SERVICE)), - IPeopleManager.Stub.asInterface( - ServiceManager.getService(Context.PEOPLE_SERVICE)), - context.getSystemService(LauncherApps.class), - Dependency.get(NotificationEntryManager.class)); - Optional<PeopleSpaceTile> entry = tiles.stream().filter( - e -> e.getId().equals(shortcutId)).findFirst(); - if (entry.isPresent()) { - if (DEBUG) Log.d(TAG, "Migrate storage for " + entry.get().getUserName()); - setStorageForTile(context, entry.get(), appWidgetId); - } else { - Log.e(TAG, "Could not migrate user. Delete old storage"); - SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); - SharedPreferences.Editor editor = sp.edit(); - editor.remove(String.valueOf(appWidgetId)); - editor.apply(); - } - } catch (Exception e) { - Log.e(TAG, "Could not query conversations"); - } + return new HashSet<>(sp.getStringSet(key.toString(), new HashSet<>())); } /** Sets all relevant storage for {@code appWidgetId} association to {@code tile}. */ - public static void setStorageForTile(Context context, PeopleSpaceTile tile, int appWidgetId) { + public static void setSharedPreferencesStorageForTile(Context context, PeopleTileKey key, + int appWidgetId) { // Write relevant persisted storage. SharedPreferences widgetSp = context.getSharedPreferences(String.valueOf(appWidgetId), Context.MODE_PRIVATE); SharedPreferences.Editor widgetEditor = widgetSp.edit(); - widgetEditor.putString(PeopleSpaceUtils.PACKAGE_NAME, tile.getPackageName()); - widgetEditor.putString(PeopleSpaceUtils.SHORTCUT_ID, tile.getId()); - int userId = getUserId(tile); - widgetEditor.putInt(PeopleSpaceUtils.USER_ID, userId); + widgetEditor.putString(PeopleSpaceUtils.PACKAGE_NAME, key.getPackageName()); + widgetEditor.putString(PeopleSpaceUtils.SHORTCUT_ID, key.getShortcutId()); + widgetEditor.putInt(PeopleSpaceUtils.USER_ID, key.getUserId()); widgetEditor.apply(); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = sp.edit(); - editor.putString(String.valueOf(appWidgetId), tile.getId()); - String key = PeopleSpaceUtils.getKey(tile.getId(), tile.getPackageName(), userId); + editor.putString(String.valueOf(appWidgetId), key.getShortcutId()); + // Don't overwrite existing widgets with the same key. - Set<String> storedWidgetIds = new HashSet<>(sp.getStringSet(key, new HashSet<>())); + Set<String> storedWidgetIds = new HashSet<>( + sp.getStringSet(key.toString(), new HashSet<>())); storedWidgetIds.add(String.valueOf(appWidgetId)); - editor.putStringSet(key, storedWidgetIds); + editor.putStringSet(key.toString(), storedWidgetIds); editor.apply(); - - // Write cached storage. - updateAppWidgetOptionsAndView(AppWidgetManager.getInstance(context), context, appWidgetId, - tile); } /** Removes stored data when tile is deleted. */ - public static void removeStorageForTile(Context context, String key, int widgetId) { + public static void removeSharedPreferencesStorageForTile(Context context, PeopleTileKey key, + int widgetId) { // Delete widgetId mapping to key. SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = sp.edit(); - Set<String> storedWidgetIds = new HashSet<>(sp.getStringSet(key, new HashSet<>())); + Set<String> storedWidgetIds = new HashSet<>( + sp.getStringSet(key.toString(), new HashSet<>())); storedWidgetIds.remove(String.valueOf(widgetId)); - editor.putStringSet(key, storedWidgetIds); + editor.putStringSet(key.toString(), storedWidgetIds); editor.remove(String.valueOf(widgetId)); editor.apply(); @@ -361,12 +338,12 @@ public class PeopleSpaceUtils { Log.w(TAG, "NotificationEntryManager is null"); return tiles; } - Map<String, NotificationEntry> visibleNotifications = notificationEntryManager + Map<PeopleTileKey, NotificationEntry> visibleNotifications = notificationEntryManager .getVisibleNotifications() .stream() .filter(entry -> entry.getRanking() != null && entry.getRanking().getConversationShortcutInfo() != null) - .collect(Collectors.toMap(PeopleSpaceUtils::getKey, e -> e)); + .collect(Collectors.toMap(PeopleTileKey::new, e -> e)); if (DEBUG) { Log.d(TAG, "Number of visible notifications:" + visibleNotifications.size()); } @@ -378,16 +355,15 @@ public class PeopleSpaceUtils { } static PeopleSpaceTile augmentTileFromVisibleNotifications(Context context, - PeopleSpaceTile tile, Map<String, NotificationEntry> visibleNotifications) { - String shortcutId = tile.getId(); - String packageName = tile.getPackageName(); - int userId = getUserId(tile); - String key = getKey(shortcutId, packageName, userId); + PeopleSpaceTile tile, Map<PeopleTileKey, NotificationEntry> visibleNotifications) { + PeopleTileKey key = new PeopleTileKey( + tile.getId(), getUserId(tile), tile.getPackageName()); + if (!visibleNotifications.containsKey(key)) { - if (DEBUG) Log.d(TAG, "No existing notifications for key:" + key); + if (DEBUG) Log.d(TAG, "No existing notifications for key:" + key.toString()); return tile; } - if (DEBUG) Log.d(TAG, "Augmenting tile from visible notifications, key:" + key); + if (DEBUG) Log.d(TAG, "Augmenting tile from visible notifications, key:" + key.toString()); return augmentTileFromNotification(context, tile, visibleNotifications.get(key).getSbn()); } @@ -423,17 +399,6 @@ public class PeopleSpaceUtils { .build(); } - private static void updateAppWidgetOptions(AppWidgetManager appWidgetManager, int appWidgetId, - PeopleSpaceTile tile) { - if (tile == null) { - if (DEBUG) Log.d(TAG, "Requested to store null tile"); - return; - } - Bundle newOptions = new Bundle(); - newOptions.putParcelable(OPTIONS_PEOPLE_SPACE_TILE, tile); - appWidgetManager.updateAppWidgetOptions(appWidgetId, newOptions); - } - /** Creates a {@link RemoteViews} for {@code tile}. */ public static RemoteViews createRemoteViews(Context context, PeopleSpaceTile tile, int appWidgetId) { @@ -653,7 +618,7 @@ public class PeopleSpaceUtils { } // TODO: Set subtext as Group Sender name once storing the name in PeopleSpaceTile. views.setTextViewText(R.id.subtext, PeopleSpaceUtils.getLastInteractionString( - context, tile.getLastInteractionTimestamp(), false)); + context, tile.getLastInteractionTimestamp())); return views; } @@ -662,7 +627,7 @@ public class PeopleSpaceUtils { RemoteViews views = new RemoteViews( context.getPackageName(), R.layout.people_space_large_avatar_tile); String status = PeopleSpaceUtils.getLastInteractionString( - context, tile.getLastInteractionTimestamp(), true); + context, tile.getLastInteractionTimestamp()); views.setTextViewText(R.id.last_interaction, status); return views; } @@ -808,8 +773,7 @@ public class PeopleSpaceUtils { } /** Returns a readable status describing the {@code lastInteraction}. */ - public static String getLastInteractionString(Context context, long lastInteraction, - boolean includeLastChatted) { + public static String getLastInteractionString(Context context, long lastInteraction) { if (lastInteraction == 0L) { Log.e(TAG, "Could not get valid last interaction"); return context.getString(R.string.basic_status); @@ -818,41 +782,20 @@ public class PeopleSpaceUtils { Duration durationSinceLastInteraction = Duration.ofMillis(now - lastInteraction); MeasureFormat formatter = MeasureFormat.getInstance(Locale.getDefault(), MeasureFormat.FormatWidth.WIDE); - MeasureFormat shortFormatter = MeasureFormat.getInstance(Locale.getDefault(), - MeasureFormat.FormatWidth.SHORT); if (durationSinceLastInteraction.toHours() < MIN_HOUR) { - if (includeLastChatted) { - return context.getString(R.string.last_interaction_status_less_than, - formatter.formatMeasures(new Measure(MIN_HOUR, MeasureUnit.HOUR))); - } - return context.getString(R.string.timestamp, shortFormatter.formatMeasures( + return context.getString(R.string.timestamp, formatter.formatMeasures( new Measure(durationSinceLastInteraction.toMinutes(), MeasureUnit.MINUTE))); } else if (durationSinceLastInteraction.toDays() < ONE_DAY) { - if (includeLastChatted) { - return context.getString(R.string.last_interaction_status, - formatter.formatMeasures( - new Measure(durationSinceLastInteraction.toHours(), - MeasureUnit.HOUR))); - } - return context.getString(R.string.timestamp, shortFormatter.formatMeasures( + return context.getString(R.string.timestamp, formatter.formatMeasures( new Measure(durationSinceLastInteraction.toHours(), MeasureUnit.HOUR))); } else if (durationSinceLastInteraction.toDays() < DAYS_IN_A_WEEK) { - if (includeLastChatted) { - return context.getString(R.string.last_interaction_status, - formatter.formatMeasures( - new Measure(durationSinceLastInteraction.toDays(), - MeasureUnit.DAY))); - } - return context.getString(R.string.timestamp, shortFormatter.formatMeasures( + return context.getString(R.string.timestamp, formatter.formatMeasures( new Measure(durationSinceLastInteraction.toHours(), MeasureUnit.DAY))); } else { return context.getString(durationSinceLastInteraction.toDays() == DAYS_IN_A_WEEK - ? (includeLastChatted ? R.string.last_interaction_status : - R.string.timestamp) : - (includeLastChatted ? R.string.last_interaction_status_over - : R.string.over_timestamp), + ? R.string.timestamp : R.string.over_timestamp, formatter.formatMeasures( new Measure(durationSinceLastInteraction.toDays() / DAYS_IN_A_WEEK, MeasureUnit.WEEK))); @@ -957,11 +900,15 @@ public class PeopleSpaceUtils { removeBirthdayStatusIfPresent(appWidgetManager, context, storedTile, appWidgetId); } - /** Update app widget options and the current view. */ + /** Updates tile in app widget options and the current view. */ public static void updateAppWidgetOptionsAndView(AppWidgetManager appWidgetManager, Context context, int appWidgetId, PeopleSpaceTile tile) { - updateAppWidgetOptions(appWidgetManager, appWidgetId, tile); + AppWidgetOptionsHelper.setPeopleTile(appWidgetManager, appWidgetId, tile); + + if (DEBUG) Log.d(TAG, "Widget: " + appWidgetId + ", " + tile.getUserName()); RemoteViews views = createRemoteViews(context, tile, appWidgetId); + + // Tell the AppWidgetManager to perform an update on the current app widget. appWidgetManager.updateAppWidget(appWidgetId, views); } @@ -1006,44 +953,6 @@ public class PeopleSpaceUtils { return lookupKeysWithBirthdaysToday; } - static String getKey(NotificationEntry entry) { - if (entry.getRanking() == null || entry.getRanking().getConversationShortcutInfo() == null - || entry.getSbn() == null || entry.getSbn().getUser() == null) { - return null; - } - return getKey(entry.getRanking().getConversationShortcutInfo().getId(), - entry.getSbn().getPackageName(), - entry.getSbn().getUser().getIdentifier()); - } - - /** - * Returns the uniquely identifying key for the conversation. - * - * <p>{@code userId} will always be a number, so we put user ID as the - * delimiter between the app-provided strings of shortcut ID and package name. - * - * <p>There aren't restrictions on shortcut ID characters, but there are restrictions requiring - * a {@code packageName} to always start with a letter. This restriction means we are - * guaranteed to avoid cases like "a/b/0/0/package.name" having two potential keys, as the first - * case is impossible given the package name restrictions: - * <ul> - * <li>"a/b" + "/" + 0 + "/" + "0/packageName"</li> - * <li>"a/b/0" + "/" + 0 + "/" + "packageName"</li> - * </ul> - */ - @Nullable - public static String getKey(String shortcutId, String packageName, int userId) { - if (!validKey(shortcutId, packageName, userId)) { - return null; - } - return shortcutId + "/" + userId + "/" + packageName; - } - - /** Returns whether the key is valid. */ - public static boolean validKey(String shortcutId, String packageName, int userId) { - return !TextUtils.isEmpty(shortcutId) && !TextUtils.isEmpty(packageName) && userId >= 0; - } - /** Returns the userId associated with a {@link PeopleSpaceTile} */ public static int getUserId(PeopleSpaceTile tile) { return tile.getUserHandle().getIdentifier(); diff --git a/packages/SystemUI/src/com/android/systemui/people/widget/AppWidgetOptionsHelper.java b/packages/SystemUI/src/com/android/systemui/people/widget/AppWidgetOptionsHelper.java new file mode 100644 index 000000000000..df08ee4a42bf --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/people/widget/AppWidgetOptionsHelper.java @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2021 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.people.widget; + +import static com.android.systemui.people.PeopleSpaceUtils.DEBUG; +import static com.android.systemui.people.PeopleSpaceUtils.EMPTY_KEY; +import static com.android.systemui.people.PeopleSpaceUtils.EMPTY_STRING; +import static com.android.systemui.people.PeopleSpaceUtils.INVALID_USER_ID; +import static com.android.systemui.people.PeopleSpaceUtils.PACKAGE_NAME; +import static com.android.systemui.people.PeopleSpaceUtils.SHORTCUT_ID; +import static com.android.systemui.people.PeopleSpaceUtils.USER_ID; + +import android.app.people.PeopleSpaceTile; +import android.appwidget.AppWidgetManager; +import android.os.Bundle; +import android.util.Log; + +/** Helper class encapsulating AppWidgetOptions for People Tile. */ +public class AppWidgetOptionsHelper { + private static final String TAG = "AppWidgetOptionsHelper"; + + /** Key to store {@link PeopleSpaceTile} in AppWidgetOptions Bundle. */ + public static final String OPTIONS_PEOPLE_TILE = "options_people_tile"; + + /** Sets {@link PeopleSpaceTile} in AppWidgetOptions. */ + public static void setPeopleTile(AppWidgetManager appWidgetManager, int appWidgetId, + PeopleSpaceTile tile) { + if (tile == null) { + if (DEBUG) Log.d(TAG, "Requested to store null tile"); + return; + } + Bundle options = appWidgetManager.getAppWidgetOptions(appWidgetId); + options.putParcelable(OPTIONS_PEOPLE_TILE, tile); + appWidgetManager.updateAppWidgetOptions(appWidgetId, options); + } + + /** Gets {@link PeopleSpaceTile} from AppWidgetOptions. */ + public static PeopleSpaceTile getPeopleTile(AppWidgetManager appWidgetManager, + int appWidgetId) { + Bundle options = appWidgetManager.getAppWidgetOptions(appWidgetId); + return options != null ? options.getParcelable(OPTIONS_PEOPLE_TILE) : null; + } + + /** Sets {@link PeopleTileKey} in AppWidgetOptions. */ + public static void setPeopleTileKey(AppWidgetManager appWidgetManager, int appWidgetId, + PeopleTileKey key) { + Bundle options = appWidgetManager.getAppWidgetOptions(appWidgetId); + options.putString(SHORTCUT_ID, key.getShortcutId()); + options.putInt(USER_ID, key.getUserId()); + options.putString(PACKAGE_NAME, key.getPackageName()); + appWidgetManager.updateAppWidgetOptions(appWidgetId, options); + } + + /** Gets {@link PeopleTileKey} from AppWidgetOptions. */ + public static PeopleTileKey getPeopleTileKey(AppWidgetManager appWidgetManager, + int appWidgetId) { + Bundle options = appWidgetManager.getAppWidgetOptions(appWidgetId); + if (options == null) { + return EMPTY_KEY; + } + return getPeopleTileKeyFromBundle(options); + } + + /** Gets {@link PeopleTileKey} from Bundle {@code options}. */ + public static PeopleTileKey getPeopleTileKeyFromBundle(Bundle options) { + String pkg = options.getString(PACKAGE_NAME, EMPTY_STRING); + int userId = options.getInt(USER_ID, INVALID_USER_ID); + String shortcutId = options.getString(SHORTCUT_ID, EMPTY_STRING); + return new PeopleTileKey(shortcutId, userId, pkg); + } + + /** Removes {@link PeopleTileKey} from AppWidgetOptions. */ + public static void removePeopleTileKey(AppWidgetManager appWidgetManager, + int appWidgetId) { + setPeopleTileKey(appWidgetManager, appWidgetId, EMPTY_KEY); + } +} diff --git a/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetManager.java b/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetManager.java index 22ee9e89d0a0..7da9a80ca287 100644 --- a/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetManager.java +++ b/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetManager.java @@ -16,6 +16,7 @@ package com.android.systemui.people.widget; +import static com.android.systemui.people.PeopleSpaceUtils.EMPTY_STRING; import static com.android.systemui.people.PeopleSpaceUtils.INVALID_USER_ID; import static com.android.systemui.people.PeopleSpaceUtils.PACKAGE_NAME; import static com.android.systemui.people.PeopleSpaceUtils.SHORTCUT_ID; @@ -38,6 +39,7 @@ import android.content.SharedPreferences; import android.content.pm.LauncherApps; import android.content.pm.ShortcutInfo; import android.net.Uri; +import android.os.Bundle; import android.os.ServiceManager; import android.os.UserHandle; import android.preference.PreferenceManager; @@ -78,8 +80,8 @@ public class PeopleSpaceWidgetManager { private PeopleManager mPeopleManager; public UiEventLogger mUiEventLogger = new UiEventLoggerImpl(); @GuardedBy("mLock") - public static Map<String, PeopleSpaceWidgetProvider.TileConversationListener> mListeners = - new HashMap<>(); + public static Map<PeopleTileKey, PeopleSpaceWidgetProvider.TileConversationListener> + mListeners = new HashMap<>(); @Inject public PeopleSpaceWidgetManager(Context context) { @@ -122,8 +124,8 @@ public class PeopleSpaceWidgetManager { Settings.Global.PEOPLE_SPACE_CONVERSATION_TYPE, 0) == 0; if (showSingleConversation) { synchronized (mLock) { - PeopleSpaceUtils.updateSingleConversationWidgets(mContext, widgetIds, - mAppWidgetManager, mIPeopleManager); + PeopleSpaceUtils.updateSingleConversationWidgets( + mContext, widgetIds, mAppWidgetManager, mIPeopleManager); } } } catch (Exception e) { @@ -157,9 +159,11 @@ public class PeopleSpaceWidgetManager { return; } synchronized (mLock) { - Set<String> storedWidgetIds = getStoredWidgetIds(mSharedPrefs, sbnShortcutId, - sbn.getPackageName(), - UserHandle.getUserHandleForUid(sbn.getUid()).getIdentifier()); + PeopleTileKey key = new PeopleTileKey( + sbnShortcutId, + UserHandle.getUserHandleForUid(sbn.getUid()).getIdentifier(), + sbn.getPackageName()); + Set<String> storedWidgetIds = getStoredWidgetIds(mSharedPrefs, key); for (String widgetIdString : storedWidgetIds) { int widgetId = Integer.parseInt(widgetIdString); if (DEBUG) Log.d(TAG, "Storing notification change, key:" + sbn.getKey()); @@ -177,9 +181,9 @@ public class PeopleSpaceWidgetManager { public void updateWidgetsWithConversationChanged(ConversationChannel conversation) { ShortcutInfo info = conversation.getShortcutInfo(); synchronized (mLock) { - Set<String> storedWidgetIds = getStoredWidgetIds(mSharedPrefs, info.getId(), - info.getPackage(), - info.getUserId()); + PeopleTileKey key = new PeopleTileKey( + info.getId(), info.getUserId(), info.getPackage()); + Set<String> storedWidgetIds = getStoredWidgetIds(mSharedPrefs, key); for (String widgetIdString : storedWidgetIds) { if (DEBUG) { Log.d(TAG, @@ -197,9 +201,8 @@ public class PeopleSpaceWidgetManager { */ private void updateStorageAndViewWithConversationData(ConversationChannel conversation, int appWidgetId) { - PeopleSpaceTile storedTile = getPeopleSpaceTile(mIPeopleManager, mAppWidgetManager, - mContext, - appWidgetId); + PeopleSpaceTile storedTile = getPeopleSpaceTile( + mContext, appWidgetId, mAppWidgetManager, mIPeopleManager); if (storedTile == null) { if (DEBUG) Log.d(TAG, "Could not find stored tile to add conversation to"); return; @@ -232,9 +235,8 @@ public class PeopleSpaceWidgetManager { StatusBarNotification sbn, PeopleSpaceUtils.NotificationAction notificationAction, int appWidgetId) { - PeopleSpaceTile storedTile = getPeopleSpaceTile(mIPeopleManager, mAppWidgetManager, - mContext, - appWidgetId); + PeopleSpaceTile storedTile = getPeopleSpaceTile( + mContext, appWidgetId, mAppWidgetManager, mIPeopleManager); if (storedTile == null) { if (DEBUG) Log.d(TAG, "Could not find stored tile to add notification to"); return; @@ -312,18 +314,39 @@ public class PeopleSpaceWidgetManager { } }; - /** Adds {@code tile} mapped to {@code appWidgetId}. */ - public void addNewWidget(PeopleSpaceTile tile, int appWidgetId) { + /** + * Checks if this widget has been added externally, and this the first time we are learning + * about the widget. If so, the widget adder should have populated options with PeopleTileKey + * arguments. + */ + public void onAppWidgetOptionsChanged(int appWidgetId, Bundle newOptions) { + // Check if this widget has been added externally, and this the first time we are + // learning about the widget. If so, the widget adder should have populated options with + // PeopleTileKey arguments. + if (DEBUG) Log.d(TAG, "onAppWidgetOptionsChanged called for widget: " + appWidgetId); + PeopleTileKey optionsKey = AppWidgetOptionsHelper.getPeopleTileKeyFromBundle(newOptions); + if (optionsKey.isValid()) { + if (DEBUG) { + Log.d(TAG, "PeopleTileKey was present in Options, shortcutId: " + + optionsKey.getShortcutId()); + } + addNewWidget(appWidgetId, optionsKey); + AppWidgetOptionsHelper.removePeopleTileKey(mAppWidgetManager, appWidgetId); + } + } + + /** Adds{@code tile} mapped to {@code appWidgetId}. */ + public void addNewWidget(int appWidgetId, PeopleTileKey key) { mUiEventLogger.log(PeopleSpaceUtils.PeopleSpaceWidgetEvent.PEOPLE_SPACE_WIDGET_ADDED); synchronized (mLock) { - if (DEBUG) Log.d(TAG, "Add storage for : " + tile.getUserName()); - PeopleSpaceUtils.setStorageForTile(mContext, tile, appWidgetId); + if (DEBUG) Log.d(TAG, "Add storage for : " + key.getShortcutId()); + PeopleSpaceUtils.setSharedPreferencesStorageForTile(mContext, key, appWidgetId); } try { - if (DEBUG) Log.d(TAG, "Caching shortcut for PeopleTile: " + tile.getId()); - mLauncherApps.cacheShortcuts(tile.getPackageName(), - Collections.singletonList(tile.getId()), - tile.getUserHandle(), LauncherApps.FLAG_CACHE_PEOPLE_TILE_SHORTCUTS); + if (DEBUG) Log.d(TAG, "Caching shortcut for PeopleTile: " + key.getShortcutId()); + mLauncherApps.cacheShortcuts(key.getPackageName(), + Collections.singletonList(key.getShortcutId()), + UserHandle.of(key.getUserId()), LauncherApps.FLAG_CACHE_PEOPLE_TILE_SHORTCUTS); } catch (Exception e) { Log.w(TAG, "Exception caching shortcut:" + e); } @@ -335,19 +358,16 @@ public class PeopleSpaceWidgetManager { public void registerConversationListenerIfNeeded(int widgetId, PeopleSpaceWidgetProvider.TileConversationListener newListener) { // Retrieve storage needed for registration. - String packageName; - String shortcutId; - int userId; - String key; + PeopleTileKey key; synchronized (mLock) { SharedPreferences widgetSp = mContext.getSharedPreferences(String.valueOf(widgetId), Context.MODE_PRIVATE); - packageName = widgetSp.getString(PACKAGE_NAME, null); - shortcutId = widgetSp.getString(SHORTCUT_ID, null); - userId = widgetSp.getInt(USER_ID, INVALID_USER_ID); - key = PeopleSpaceUtils.getKey(shortcutId, packageName, userId); - if (key == null) { - if (DEBUG) Log.e(TAG, "Could not register " + widgetId); + key = new PeopleTileKey( + widgetSp.getString(SHORTCUT_ID, EMPTY_STRING), + widgetSp.getInt(USER_ID, INVALID_USER_ID), + widgetSp.getString(PACKAGE_NAME, EMPTY_STRING)); + if (!key.isValid()) { + if (DEBUG) Log.w(TAG, "Could not register listener for widget: " + widgetId); return; } } @@ -359,9 +379,9 @@ public class PeopleSpaceWidgetManager { if (DEBUG) Log.d(TAG, "Register listener for " + widgetId + " with " + key); mListeners.put(key, newListener); } - mPeopleManager.registerConversationListener(packageName, - userId, - shortcutId, newListener, + mPeopleManager.registerConversationListener(key.getPackageName(), + key.getUserId(), + key.getShortcutId(), newListener, mContext.getMainExecutor()); } @@ -371,27 +391,24 @@ public class PeopleSpaceWidgetManager { if (DEBUG) Log.d(TAG, "Widget removed: " + widgetId); mUiEventLogger.log(PeopleSpaceUtils.PeopleSpaceWidgetEvent.PEOPLE_SPACE_WIDGET_DELETED); // Retrieve storage needed for widget deletion. - String packageName; - String shortcutId; - int userId; - String key; + PeopleTileKey key; Set<String> storedWidgetIdsForKey; synchronized (mLock) { SharedPreferences widgetSp = mContext.getSharedPreferences(String.valueOf(widgetId), Context.MODE_PRIVATE); - packageName = widgetSp.getString(PACKAGE_NAME, null); - shortcutId = widgetSp.getString(SHORTCUT_ID, null); - userId = widgetSp.getInt(USER_ID, INVALID_USER_ID); - key = PeopleSpaceUtils.getKey(shortcutId, packageName, userId); - if (key == null) { + key = new PeopleTileKey( + widgetSp.getString(SHORTCUT_ID, null), + widgetSp.getInt(USER_ID, INVALID_USER_ID), + widgetSp.getString(PACKAGE_NAME, null)); + if (!key.isValid()) { if (DEBUG) Log.e(TAG, "Could not delete " + widgetId); return; } storedWidgetIdsForKey = new HashSet<>( - mSharedPrefs.getStringSet(key, new HashSet<>())); + mSharedPrefs.getStringSet(key.toString(), new HashSet<>())); } synchronized (mLock) { - PeopleSpaceUtils.removeStorageForTile(mContext, key, widgetId); + PeopleSpaceUtils.removeSharedPreferencesStorageForTile(mContext, key, widgetId); } // If another tile with the conversation is still stored, we need to keep the listener. if (DEBUG) Log.d(TAG, "Stored widget IDs: " + storedWidgetIdsForKey.toString()); @@ -399,13 +416,13 @@ public class PeopleSpaceWidgetManager { && storedWidgetIdsForKey.size() == 1) { if (DEBUG) Log.d(TAG, "Remove caching and listener"); unregisterConversationListener(key, widgetId); - uncacheConversationShortcut(shortcutId, packageName, userId); + uncacheConversationShortcut(key); } } } /** Unregisters the conversation listener for {@code appWidgetId}. */ - private void unregisterConversationListener(String key, int appWidgetId) { + private void unregisterConversationListener(PeopleTileKey key, int appWidgetId) { PeopleSpaceWidgetProvider.TileConversationListener registeredListener; synchronized (mListeners) { registeredListener = mListeners.get(key); @@ -420,12 +437,12 @@ public class PeopleSpaceWidgetManager { } /** Uncaches the conversation shortcut. */ - private void uncacheConversationShortcut(String shortcutId, String packageName, int userId) { + private void uncacheConversationShortcut(PeopleTileKey key) { try { - if (DEBUG) Log.d(TAG, "Uncaching shortcut for PeopleTile: " + shortcutId); - mLauncherApps.uncacheShortcuts(packageName, - Collections.singletonList(shortcutId), - UserHandle.of(userId), + if (DEBUG) Log.d(TAG, "Uncaching shortcut for PeopleTile: " + key.getShortcutId()); + mLauncherApps.uncacheShortcuts(key.getPackageName(), + Collections.singletonList(key.getShortcutId()), + UserHandle.of(key.getUserId()), LauncherApps.FLAG_CACHE_PEOPLE_TILE_SHORTCUTS); } catch (Exception e) { Log.d(TAG, "Exception uncaching shortcut:" + e); diff --git a/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetProvider.java b/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetProvider.java index cccf7aa13028..3bc5b29bd05d 100644 --- a/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetProvider.java +++ b/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetProvider.java @@ -22,6 +22,7 @@ import android.app.people.PeopleManager; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProvider; import android.content.Context; +import android.os.Bundle; import android.util.Log; import com.android.internal.annotations.VisibleForTesting; @@ -67,18 +68,21 @@ public class PeopleSpaceWidgetProvider extends AppWidgetProvider { ensurePeopleSpaceWidgetManagerInitialized(context); peopleSpaceWidgetManager.updateWidgets(appWidgetIds); for (int appWidgetId : appWidgetIds) { + if (DEBUG) Log.d(TAG, "Ensure listener is registered for widget: " + appWidgetId); PeopleSpaceWidgetProvider.TileConversationListener newListener = new PeopleSpaceWidgetProvider.TileConversationListener(); peopleSpaceWidgetManager.registerConversationListenerIfNeeded(appWidgetId, newListener); } - return; } - private void ensurePeopleSpaceWidgetManagerInitialized(Context context) { - if (peopleSpaceWidgetManager == null) { - peopleSpaceWidgetManager = new PeopleSpaceWidgetManager(context); - } + /** Called when widget updates. */ + @Override + public void onAppWidgetOptionsChanged(Context context, AppWidgetManager appWidgetManager, + int appWidgetId, Bundle newOptions) { + super.onAppWidgetOptionsChanged(context, appWidgetManager, appWidgetId, newOptions); + ensurePeopleSpaceWidgetManagerInitialized(context); + peopleSpaceWidgetManager.onAppWidgetOptionsChanged(appWidgetId, newOptions); } @Override @@ -88,6 +92,12 @@ public class PeopleSpaceWidgetProvider extends AppWidgetProvider { peopleSpaceWidgetManager.deleteWidgets(appWidgetIds); } + private void ensurePeopleSpaceWidgetManagerInitialized(Context context) { + if (peopleSpaceWidgetManager == null) { + peopleSpaceWidgetManager = new PeopleSpaceWidgetManager(context); + } + } + @VisibleForTesting public void setPeopleSpaceWidgetManager(PeopleSpaceWidgetManager manager) { peopleSpaceWidgetManager = manager; diff --git a/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetRemoteViewsFactory.java b/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetRemoteViewsFactory.java index 050352292b38..87b2a15d1c55 100644 --- a/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetRemoteViewsFactory.java +++ b/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetRemoteViewsFactory.java @@ -106,7 +106,7 @@ public class PeopleSpaceWidgetRemoteViewsFactory implements RemoteViewsService.R PeopleSpaceTile tile = mTiles.get(i); String status = PeopleSpaceUtils.getLastInteractionString(mContext, - tile.getLastInteractionTimestamp(), true); + tile.getLastInteractionTimestamp()); personView.setTextViewText(R.id.status, status); personView.setTextViewText(R.id.name, tile.getUserName().toString()); diff --git a/packages/SystemUI/src/com/android/systemui/people/widget/PeopleTileKey.java b/packages/SystemUI/src/com/android/systemui/people/widget/PeopleTileKey.java new file mode 100644 index 000000000000..ac42cb08090a --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/people/widget/PeopleTileKey.java @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2021 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.people.widget; + +import static com.android.systemui.people.PeopleSpaceUtils.EMPTY_STRING; +import static com.android.systemui.people.PeopleSpaceUtils.INVALID_USER_ID; + +import android.text.TextUtils; + +import com.android.systemui.statusbar.notification.collection.NotificationEntry; + +import java.util.Objects; + +/** Class that encapsulates fields identifying a Conversation. */ +public class PeopleTileKey { + private String mShortcutId; + private int mUserId; + private String mPackageName; + + public PeopleTileKey(String shortcutId, int userId, String packageName) { + mShortcutId = shortcutId; + mUserId = userId; + mPackageName = packageName; + } + + public PeopleTileKey(NotificationEntry entry) { + mShortcutId = entry.getRanking() != null + && entry.getRanking().getConversationShortcutInfo() != null + ? entry.getRanking().getConversationShortcutInfo().getId() + : EMPTY_STRING; + mUserId = entry.getSbn().getUser() != null + ? entry.getSbn().getUser().getIdentifier() : INVALID_USER_ID; + mPackageName = entry.getSbn().getPackageName(); + } + + public String getShortcutId() { + return mShortcutId; + } + + public int getUserId() { + return mUserId; + } + + public String getPackageName() { + return mPackageName; + } + + /** Returns whether PeopleTileKey is valid/well-formed. */ + public boolean isValid() { + return !TextUtils.isEmpty(mShortcutId) && !TextUtils.isEmpty(mPackageName) && mUserId >= 0; + } + + /** + * Returns the uniquely identifying key for the conversation. + * + * <p>{@code userId} will always be a number, so we put user ID as the + * delimiter between the app-provided strings of shortcut ID and package name. + * + * <p>There aren't restrictions on shortcut ID characters, but there are restrictions requiring + * a {@code packageName} to always start with a letter. This restriction means we are + * guaranteed to avoid cases like "a/b/0/0/package.name" having two potential keys, as the first + * case is impossible given the package name restrictions: + * <ul> + * <li>"a/b" + "/" + 0 + "/" + "0/packageName"</li> + * <li>"a/b/0" + "/" + 0 + "/" + "packageName"</li> + * </ul> + */ + @Override + public String toString() { + if (!isValid()) return null; + return mShortcutId + "/" + mUserId + "/" + mPackageName; + } + + @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + if (!(other instanceof PeopleTileKey)) { + return false; + } + final PeopleTileKey o = (PeopleTileKey) other; + return Objects.equals(o.toString(), this.toString()); + } + + @Override + public int hashCode() { + return mPackageName.hashCode() + Integer.valueOf(mUserId).hashCode() + + mShortcutId.hashCode(); + } +} diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/DeviceControlsTile.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/DeviceControlsTile.kt index 3b9f5dc8ea03..257d6a7abda1 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/DeviceControlsTile.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/DeviceControlsTile.kt @@ -16,6 +16,7 @@ package com.android.systemui.qs.tiles +import android.content.ComponentName import android.content.Intent import android.os.Handler import android.os.Looper @@ -27,7 +28,8 @@ import com.android.systemui.controls.ControlsServiceInfo import com.android.systemui.controls.dagger.ControlsComponent import com.android.systemui.controls.dagger.ControlsComponent.Visibility.AVAILABLE import com.android.systemui.controls.management.ControlsListingController -import com.android.systemui.controls.ui.ControlsDialog +import com.android.systemui.controls.ui.ControlsActivity +import com.android.systemui.controls.ui.ControlsUiController import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.plugins.ActivityStarter @@ -40,7 +42,6 @@ import com.android.systemui.statusbar.FeatureFlags import com.android.systemui.util.settings.GlobalSettings import java.util.concurrent.atomic.AtomicBoolean import javax.inject.Inject -import javax.inject.Provider class DeviceControlsTile @Inject constructor( host: QSHost, @@ -52,7 +53,6 @@ class DeviceControlsTile @Inject constructor( qsLogger: QSLogger, private val controlsComponent: ControlsComponent, private val featureFlags: FeatureFlags, - private val dialogProvider: Provider<ControlsDialog>, globalSettings: GlobalSettings ) : QSTileImpl<QSTile.State>( host, @@ -72,7 +72,6 @@ class DeviceControlsTile @Inject constructor( private var hasControlsApps = AtomicBoolean(false) private val intent = Intent(Settings.ACTION_DEVICE_CONTROLS_SETTINGS) - private var controlsDialog: ControlsDialog? = null private val icon = ResourceIcon.get(R.drawable.ic_device_light) private val listingCallback = object : ControlsListingController.ControlsListingCallback { @@ -102,27 +101,19 @@ class DeviceControlsTile @Inject constructor( } override fun handleDestroy() { - dismissDialog() super.handleDestroy() } - private fun createDialog() { - if (controlsDialog?.isShowing != true) { - controlsDialog = dialogProvider.get() - } - } - - private fun dismissDialog() { - controlsDialog?.dismiss()?.also { - controlsDialog = null - } - } - override fun handleClick() { if (state.state == Tile.STATE_ACTIVE) { mUiHandler.post { - createDialog() - controlsDialog?.show(controlsComponent.getControlsUiController().get()) + mHost.collapsePanels() + val i = Intent().apply { + component = ComponentName(mContext, ControlsActivity::class.java) + addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK) + putExtra(ControlsUiController.BACK_TO_GLOBAL_ACTIONS, false) + } + mContext.startActivity(i) } } } @@ -133,9 +124,6 @@ class DeviceControlsTile @Inject constructor( state.contentDescription = state.label state.icon = icon if (controlsComponent.isEnabled() && hasControlsApps.get()) { - if (controlsDialog == null) { - mUiHandler.post(this::createDialog) - } if (controlsComponent.getVisibility() == AVAILABLE) { state.state = Tile.STATE_ACTIVE state.secondaryLabel = "" @@ -146,7 +134,6 @@ class DeviceControlsTile @Inject constructor( state.stateDescription = state.secondaryLabel } else { state.state = Tile.STATE_UNAVAILABLE - dismissDialog() } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/ActivityLaunchAnimator.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/ActivityLaunchAnimator.java index d08f9736adf6..85a1aed68559 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/ActivityLaunchAnimator.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/ActivityLaunchAnimator.java @@ -146,17 +146,19 @@ public class ActivityLaunchAnimator { private final ExpandableNotificationRow mSourceNotification; private final ExpandAnimationParameters mParams; private final Rect mWindowCrop = new Rect(); - private final float mNotificationCornerRadius; - private float mCornerRadius; private boolean mIsFullScreenLaunch = true; private final SyncRtSurfaceTransactionApplier mSyncRtTransactionApplier; - public AnimationRunner(ExpandableNotificationRow sourceNofitication) { - mSourceNotification = sourceNofitication; + private final float mNotificationStartTopCornerRadius; + private final float mNotificationStartBottomCornerRadius; + + AnimationRunner(ExpandableNotificationRow sourceNotification) { + mSourceNotification = sourceNotification; mParams = new ExpandAnimationParameters(); mSyncRtTransactionApplier = new SyncRtSurfaceTransactionApplier(mSourceNotification); - mNotificationCornerRadius = Math.max(mSourceNotification.getCurrentTopRoundness(), - mSourceNotification.getCurrentBottomRoundness()); + mNotificationStartTopCornerRadius = mSourceNotification.getCurrentBackgroundRadiusTop(); + mNotificationStartBottomCornerRadius = + mSourceNotification.getCurrentBackgroundRadiusBottom(); } @Override @@ -224,7 +226,10 @@ public class ActivityLaunchAnimator { + notificationHeight, primary.position.y + primary.sourceContainerBounds.bottom, progress); - mCornerRadius = MathUtils.lerp(mNotificationCornerRadius, + mParams.topCornerRadius = MathUtils.lerp(mNotificationStartTopCornerRadius, + mWindowCornerRadius, progress); + mParams.bottomCornerRadius = MathUtils.lerp( + mNotificationStartBottomCornerRadius, mWindowCornerRadius, progress); applyParamsToWindow(primary); applyParamsToNotification(mParams); @@ -309,12 +314,13 @@ public class ActivityLaunchAnimator { Matrix m = new Matrix(); m.postTranslate(0, (float) (mParams.top - app.position.y)); mWindowCrop.set(mParams.left, 0, mParams.right, mParams.getHeight()); + float cornerRadius = Math.min(mParams.topCornerRadius, mParams.bottomCornerRadius); SurfaceParams params = new SurfaceParams.Builder(app.leash) .withAlpha(1f) .withMatrix(m) .withWindowCrop(mWindowCrop) .withLayer(app.prefixOrderIndex) - .withCornerRadius(mCornerRadius) + .withCornerRadius(cornerRadius) .withVisibility(true) .build(); mSyncRtTransactionApplier.scheduleApply(params); @@ -339,6 +345,8 @@ public class ActivityLaunchAnimator { int bottom; int startClipTopAmount; int parentStartClipTopAmount; + float topCornerRadius; + float bottomCornerRadius; public ExpandAnimationParameters() { } @@ -389,6 +397,14 @@ public class ActivityLaunchAnimator { public float getStartTranslationZ() { return startTranslationZ; } + + public float getTopCornerRadius() { + return topCornerRadius; + } + + public float getBottomCornerRadius() { + return bottomCornerRadius; + } } public interface Callback { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java index 31d052d75998..18e5ead7fbb8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java @@ -883,8 +883,8 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView } private void applyBackgroundRoundness(float topRadius, float bottomRadius) { - mBackgroundDimmed.setRoundness(topRadius, bottomRadius); - mBackgroundNormal.setRoundness(topRadius, bottomRadius); + mBackgroundDimmed.setRadius(topRadius, bottomRadius); + mBackgroundNormal.setRadius(topRadius, bottomRadius); } @Override 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 cde9f38d0074..046fbd5b616b 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 @@ -346,6 +346,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView private SystemNotificationAsyncTask mSystemNotificationAsyncTask = new SystemNotificationAsyncTask(); + private float mTopRoundnessDuringExpandAnimation; + private float mBottomRoundnessDuringExpandAnimation; + /** * Returns whether the given {@code statusBarNotification} is a system notification. * <b>Note</b>, this should be run in the background thread if possible as it makes multiple IPC @@ -2009,6 +2012,24 @@ public class ExpandableNotificationRow extends ActivatableNotificationView return false; } + @Override + public float getCurrentTopRoundness() { + if (mExpandAnimationRunning) { + return mTopRoundnessDuringExpandAnimation; + } + + return super.getCurrentTopRoundness(); + } + + @Override + public float getCurrentBottomRoundness() { + if (mExpandAnimationRunning) { + return mBottomRoundnessDuringExpandAnimation; + } + + return super.getCurrentBottomRoundness(); + } + public void applyExpandAnimationParams(ExpandAnimationParameters params) { if (params == null) { return; @@ -2024,17 +2045,22 @@ public class ExpandableNotificationRow extends ActivatableNotificationView int top = params.getTop(); float interpolation = Interpolators.FAST_OUT_SLOW_IN.getInterpolation(params.getProgress()); int startClipTopAmount = params.getStartClipTopAmount(); + int clipTopAmount = (int) MathUtils.lerp(startClipTopAmount, 0, interpolation); if (mNotificationParent != null) { float parentY = mNotificationParent.getTranslationY(); top -= parentY; mNotificationParent.setTranslationZ(translationZ); + + // When the expanding notification is below its parent, the parent must be clipped + // exactly how it was clipped before the animation. When the expanding notification is + // on or above its parent (top <= 0), then the parent must be clipped exactly 'top' + // pixels to show the expanding notification, while still taking the decreasing + // notification clipTopAmount into consideration, so 'top + clipTopAmount'. int parentStartClipTopAmount = params.getParentStartClipTopAmount(); - if (startClipTopAmount != 0) { - int clipTopAmount = (int) MathUtils.lerp(parentStartClipTopAmount, - parentStartClipTopAmount - startClipTopAmount, - interpolation); - mNotificationParent.setClipTopAmount(clipTopAmount); - } + int parentClipTopAmount = Math.min(parentStartClipTopAmount, + top + clipTopAmount); + mNotificationParent.setClipTopAmount(parentClipTopAmount); + mNotificationParent.setExtraWidthForClipping(extraWidthForClipping); float clipBottom = Math.max(params.getBottom(), parentY + mNotificationParent.getActualHeight() @@ -2043,12 +2069,15 @@ public class ExpandableNotificationRow extends ActivatableNotificationView int minimumHeightForClipping = (int) (clipBottom - clipTop); mNotificationParent.setMinimumHeightForClipping(minimumHeightForClipping); } else if (startClipTopAmount != 0) { - int clipTopAmount = (int) MathUtils.lerp(startClipTopAmount, 0, interpolation); setClipTopAmount(clipTopAmount); } setTranslationY(top); setActualHeight(params.getHeight()); + mTopRoundnessDuringExpandAnimation = params.getTopCornerRadius() / mOutlineRadius; + mBottomRoundnessDuringExpandAnimation = params.getBottomCornerRadius() / mOutlineRadius; + invalidateOutline(); + mBackgroundNormal.setExpandAnimationParams(params); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableOutlineView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableOutlineView.java index 85f556fa733c..3728388f63b2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableOutlineView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableOutlineView.java @@ -27,7 +27,6 @@ import android.util.AttributeSet; import android.view.View; import android.view.ViewOutlineProvider; -import com.android.settingslib.Utils; import com.android.systemui.R; import com.android.systemui.statusbar.notification.AnimatableProperty; import com.android.systemui.statusbar.notification.PropertyAnimator; @@ -83,8 +82,8 @@ public abstract class ExpandableOutlineView extends ExpandableView { private final ViewOutlineProvider mProvider = new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { - if (!mCustomOutline && mCurrentTopRoundness == 0.0f - && mCurrentBottomRoundness == 0.0f && !mAlwaysRoundBothCorners + if (!mCustomOutline && getCurrentTopRoundness() == 0.0f + && getCurrentBottomRoundness() == 0.0f && !mAlwaysRoundBothCorners && !mTopAmountRounded) { int translation = mShouldTranslateContents ? (int) getTranslation() : 0; int left = Math.max(translation, 0); @@ -135,10 +134,12 @@ public abstract class ExpandableOutlineView extends ExpandableView { ? mOutlineRadius : getCurrentBackgroundRadiusBottom(); if (topRoundness + bottomRoundness > height) { float overShoot = topRoundness + bottomRoundness - height; - topRoundness -= overShoot * mCurrentTopRoundness - / (mCurrentTopRoundness + mCurrentBottomRoundness); - bottomRoundness -= overShoot * mCurrentBottomRoundness - / (mCurrentTopRoundness + mCurrentBottomRoundness); + float currentTopRoundness = getCurrentTopRoundness(); + float currentBottomRoundness = getCurrentBottomRoundness(); + topRoundness -= overShoot * currentTopRoundness + / (currentTopRoundness + currentBottomRoundness); + bottomRoundness -= overShoot * currentBottomRoundness + / (currentTopRoundness + currentBottomRoundness); } getRoundedRectPath(left, top, right, bottom, topRoundness, bottomRoundness, mTmpPath); return mTmpPath; @@ -267,7 +268,7 @@ public abstract class ExpandableOutlineView extends ExpandableView { if (mTopAmountRounded) { return mOutlineRadius; } - return mCurrentTopRoundness * mOutlineRadius; + return getCurrentTopRoundness() * mOutlineRadius; } public float getCurrentTopRoundness() { @@ -278,8 +279,8 @@ public abstract class ExpandableOutlineView extends ExpandableView { return mCurrentBottomRoundness; } - protected float getCurrentBackgroundRadiusBottom() { - return mCurrentBottomRoundness * mOutlineRadius; + public float getCurrentBackgroundRadiusBottom() { + return getCurrentBottomRoundness() * mOutlineRadius; } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBackgroundView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBackgroundView.java index 62d596b60a89..95885633a3e8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBackgroundView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBackgroundView.java @@ -224,10 +224,9 @@ public class NotificationBackgroundView extends View { } /** - * Sets the current top and bottom roundness amounts for this background, between 0.0 (not - * rounded) and 1.0 (maximally rounded). + * Sets the current top and bottom radius for this background. */ - public void setRoundness(float topRoundness, float bottomRoundness) { + public void setRadius(float topRoundness, float bottomRoundness) { if (topRoundness == mCornerRadii[0] && bottomRoundness == mCornerRadii[4]) { return; } 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 d8ee102064e1..2b194ba15816 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 @@ -34,7 +34,6 @@ import android.widget.RemoteViews; import android.widget.TextView; import com.android.internal.annotations.VisibleForTesting; -import com.android.internal.widget.CachingIconView; import com.android.internal.widget.NotificationExpandButton; import com.android.systemui.R; import com.android.systemui.statusbar.CrossFadeHelper; @@ -638,10 +637,6 @@ public class NotificationChildrenContainer extends ViewGroup { childState.location = parentState.location; childState.inShelf = parentState.inShelf; yPosition += intrinsicHeight; - if (child.isExpandAnimationRunning()) { - launchTransitionCompensation = -ambientState.getExpandAnimationTopChange(); - } - } if (mOverflowNumber != null) { ExpandableNotificationRow overflowView = mAttachedChildren.get(Math.min( 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 6c8cdf67d974..b06f7d25db16 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 @@ -318,9 +318,6 @@ class NotificationSectionsManager @Inject internal constructor( (child == null || row != null && nextBucket != row.entry.bucket) if (isSectionBoundary && showHeaders) { when (nextBucket) { - BUCKET_HEADS_UP -> incomingState?.targetPosition = i + 1 - BUCKET_PEOPLE -> peopleState?.targetPosition = i + 1 - BUCKET_ALERTING -> alertingState?.targetPosition = i + 1 BUCKET_SILENT -> gentleState?.targetPosition = i + 1 } } 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 5d2203b57991..d7a98bdf2715 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 @@ -28,14 +28,12 @@ import android.view.ViewGroup; import com.android.systemui.R; import com.android.systemui.statusbar.EmptyShadeView; import com.android.systemui.statusbar.NotificationShelf; -import com.android.systemui.statusbar.notification.NotificationUtils; import com.android.systemui.statusbar.notification.row.ActivatableNotificationView; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.notification.row.ExpandableView; import com.android.systemui.statusbar.notification.row.FooterView; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; /** @@ -156,7 +154,7 @@ public class StackScrollAlgorithm { private void updateClipping(StackScrollAlgorithmState algorithmState, AmbientState ambientState) { float drawStart = !ambientState.isOnKeyguard() ? ambientState.getTopPadding() - + ambientState.getStackTranslation() + ambientState.getExpandAnimationTopChange() + + ambientState.getStackTranslation() : 0; float clipStart = 0; int childCount = algorithmState.visibleChildren.size(); @@ -329,9 +327,6 @@ public class StackScrollAlgorithm { childViewState.location = ExpandableViewState.LOCATION_MAIN_AREA; float inset = ambientState.getTopPadding() + ambientState.getStackTranslation() + ambientState.getSectionPadding(); - if (i <= algorithmState.getIndexOfExpandingNotification()) { - inset += ambientState.getExpandAnimationTopChange(); - } if (child.mustStayOnScreen() && childViewState.yTranslation >= 0) { // Even if we're not scrolled away we're in view and we're also not in the // shelf. We can relax the constraints and let us scroll off the top! diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java index 85d8df8e6057..c23f1ad6f9c9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java @@ -148,6 +148,11 @@ public class DozeParameters implements TunerService.Tunable, return getInt("doze.pickup.vibration.threshold", R.integer.doze_pickup_vibration_threshold); } + public int getQuickPickupAodDuration() { + return getInt("doze.gesture.quickpickup.duration", + R.integer.doze_quick_pickup_aod_duration); + } + /** * For how long a wallpaper can be visible in AoD before it fades aways. * @return duration in millis. @@ -175,6 +180,10 @@ public class DozeParameters implements TunerService.Tunable, return mDozeAlwaysOn && !mBatteryController.isAodPowerSave(); } + public boolean isQuickPickupEnabled() { + return mAmbientDisplayConfiguration.quickPickupSensorEnabled(UserHandle.USER_CURRENT); + } + /** * Some screens need to be completely black before changing the display power mode, * unexpected behavior might happen if this parameter isn't respected. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java index 19b98953325f..626162dc03ae 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -439,7 +439,6 @@ public class NotificationPanelViewController extends PanelViewController { private LockscreenGestureLogger mLockscreenGestureLogger = new LockscreenGestureLogger(); private boolean mUserSetupComplete; private int mQsNotificationTopPadding; - private float mExpandOffset; private boolean mHideIconsDuringNotificationLaunch = true; private int mStackScrollerMeasuringPass; private ArrayList<Consumer<ExpandableNotificationRow>> @@ -2444,8 +2443,7 @@ public class NotificationPanelViewController extends PanelViewController { } startHeight = -mQs.getQsMinExpansionHeight(); } - float translation = MathUtils.lerp(startHeight, 0, Math.min(1.0f, appearAmount)) - + mExpandOffset; + float translation = MathUtils.lerp(startHeight, 0, Math.min(1.0f, appearAmount)); return Math.min(0, translation); } @@ -3185,16 +3183,16 @@ public class NotificationPanelViewController extends PanelViewController { } public void applyExpandAnimationParams(ExpandAnimationParameters params) { - mExpandOffset = params != null ? params.getTopChange() : 0; - updateQsExpansion(); - if (params != null) { - boolean hideIcons = params.getProgress( - ActivityLaunchAnimator.ANIMATION_DELAY_ICON_FADE_IN, 100) == 0.0f; - if (hideIcons != mHideIconsDuringNotificationLaunch) { - mHideIconsDuringNotificationLaunch = hideIcons; - if (!hideIcons) { - mCommandQueue.recomputeDisableFlags(mDisplayId, true /* animate */); - } + if (params == null) { + return; + } + + boolean hideIcons = params.getProgress( + ActivityLaunchAnimator.ANIMATION_DELAY_ICON_FADE_IN, 100) == 0.0f; + if (hideIcons != mHideIconsDuringNotificationLaunch) { + mHideIconsDuringNotificationLaunch = hideIcons; + if (!hideIcons) { + mCommandQueue.recomputeDisableFlags(mDisplayId, true /* animate */); } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationsQuickSettingsContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationsQuickSettingsContainer.java index 0c9ed661925c..1cb0be0efc90 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationsQuickSettingsContainer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationsQuickSettingsContainer.java @@ -89,30 +89,22 @@ public class NotificationsQuickSettingsContainer extends ConstraintLayout @Override protected void dispatchDraw(Canvas canvas) { - // Invert the order of the scroll view and user switcher such that the notifications receive - // touches first but the panel gets drawn above. mDrawingOrderedChildren.clear(); mLayoutDrawingOrder.clear(); if (mKeyguardStatusBar.getVisibility() == View.VISIBLE) { mDrawingOrderedChildren.add(mKeyguardStatusBar); mLayoutDrawingOrder.add(mKeyguardStatusBar); } - if (mStackScroller.getVisibility() == View.VISIBLE) { - mDrawingOrderedChildren.add(mStackScroller); - mLayoutDrawingOrder.add(mStackScroller); - } if (mQsFrame.getVisibility() == View.VISIBLE) { mDrawingOrderedChildren.add(mQsFrame); mLayoutDrawingOrder.add(mQsFrame); } - - if (mHasViewsAboveShelf) { - // StackScroller needs to be on top - mDrawingOrderedChildren.remove(mStackScroller); + if (mStackScroller.getVisibility() == View.VISIBLE) { mDrawingOrderedChildren.add(mStackScroller); + mLayoutDrawingOrder.add(mStackScroller); } - // Let's now find the order that the view has when drawing regulary by sorting + // Let's now find the order that the view has when drawing regularly by sorting mLayoutDrawingOrder.sort(mIndexComparator); super.dispatchDraw(canvas); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java index 48c97a2fd79c..9b8b7160c95c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java @@ -140,11 +140,13 @@ public enum ScrimState { @Override public void prepare(ScrimState previousState) { final boolean alwaysOnEnabled = mDozeParameters.getAlwaysOn(); + final boolean quickPickupEnabled = mDozeParameters.isQuickPickupEnabled(); final boolean isDocked = mDockManager.isDocked(); mBlankScreen = mDisplayRequiresBlanking; mFrontTint = Color.BLACK; - mFrontAlpha = (alwaysOnEnabled || isDocked) ? mAodFrontScrimAlpha : 1f; + mFrontAlpha = (alwaysOnEnabled || isDocked || quickPickupEnabled) + ? mAodFrontScrimAlpha : 1f; mBehindTint = Color.BLACK; mBehindAlpha = ScrimController.TRANSPARENT; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java index 34673f2503ce..801ac964777b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java @@ -356,9 +356,6 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit if (isActivityIntent || canBubble) { mAssistManagerLazy.get().hideAssist(); } - if (shouldCollapse()) { - collapseOnMainThread(); - } NotificationVisibility.NotificationLocation location = NotificationLogger.getNotificationLocation(entry); @@ -408,6 +405,12 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit mMainThreadHandler.post( () -> mBubblesManagerOptional.get().expandStackAndSelectBubble(entry)); } + + // expandStackAndSelectBubble won't affect shouldCollapse, so we can collapse directly even + // if we are not on the main thread. + if (shouldCollapse()) { + collapseOnMainThread(); + } } private void startNotificationIntent( @@ -438,6 +441,9 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit null, null, options); mMainThreadHandler.post(() -> { mActivityLaunchAnimator.setLaunchResult(launchResult, isActivityIntent); + if (shouldCollapse()) { + collapseOnMainThread(); + } }); } catch (RemoteException | PendingIntent.CanceledException e) { // the stack trace isn't very helpful here. @@ -465,11 +471,11 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit mActivityLaunchAnimator.setLaunchResult(launchResult, true /* isActivityIntent */); removeHUN(row); + if (shouldCollapse()) { + mCommandQueue.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, + true /* force */); + } }); - if (shouldCollapse()) { - mMainThreadHandler.post(() -> mCommandQueue.animateCollapsePanels( - CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true /* force */)); - } }); return true; }, null, false /* afterKeyguardGone */); diff --git a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeConfigurationUtil.java b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeConfigurationUtil.java index 9fd9b470a83b..1aeb0d8a5361 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeConfigurationUtil.java +++ b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeConfigurationUtil.java @@ -60,6 +60,7 @@ public class DozeConfigurationUtil { when(config.tapSensorType()).thenReturn(null); when(config.longPressSensorType()).thenReturn(null); when(config.udfpsLongPressSensorType()).thenReturn(null); + when(config.quickPickupSensorType()).thenReturn(null); when(config.tapGestureEnabled(anyInt())).thenReturn(true); when(config.tapSensorAvailable()).thenReturn(true); @@ -67,6 +68,7 @@ public class DozeConfigurationUtil { when(config.dozePickupSensorAvailable()).thenReturn(false); when(config.wakeScreenGestureAvailable()).thenReturn(false); + when(config.quickPickupSensorEnabled(anyInt())).thenReturn(false); doneHolder[0] = true; return config; diff --git a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeTriggersTest.java b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeTriggersTest.java index 27187a85c040..1817fdfd4cdc 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeTriggersTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeTriggersTest.java @@ -104,7 +104,7 @@ public class DozeTriggersTest extends SysuiTestCase { mTriggers = new DozeTriggers(mContext, mHost, mAlarmManager, config, parameters, asyncSensorManager, wakeLock, mDockManager, mProximitySensor, mProximityCheck, mock(DozeLog.class), mBroadcastDispatcher, new FakeSettings(), - mAuthController); + mAuthController, mExecutor, mExecutor); mTriggers.setDozeMachine(mMachine); waitForSensorManager(); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/people/PeopleSpaceUtilsTest.java b/packages/SystemUI/tests/src/com/android/systemui/people/PeopleSpaceUtilsTest.java index 2a4b41cbfe32..3fed07472c35 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/people/PeopleSpaceUtilsTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/people/PeopleSpaceUtilsTest.java @@ -22,8 +22,9 @@ import static android.app.people.ConversationStatus.ACTIVITY_GAME; import static android.app.people.ConversationStatus.ACTIVITY_NEW_STORY; import static android.app.people.ConversationStatus.AVAILABILITY_AVAILABLE; -import static com.android.systemui.people.PeopleSpaceUtils.OPTIONS_PEOPLE_SPACE_TILE; import static com.android.systemui.people.PeopleSpaceUtils.PACKAGE_NAME; +import static com.android.systemui.people.PeopleSpaceUtils.getPeopleTileFromPersistentStorage; +import static com.android.systemui.people.widget.AppWidgetOptionsHelper.OPTIONS_PEOPLE_TILE; import static com.google.common.truth.Truth.assertThat; @@ -76,6 +77,7 @@ import android.widget.TextView; import com.android.internal.appwidget.IAppWidgetService; import com.android.systemui.R; import com.android.systemui.SysuiTestCase; +import com.android.systemui.people.widget.PeopleTileKey; import com.android.systemui.statusbar.NotificationListener; import com.android.systemui.statusbar.SbnBuilder; import com.android.systemui.statusbar.notification.NotificationEntryManager; @@ -232,7 +234,7 @@ public class PeopleSpaceUtilsTest extends SysuiTestCase { int[] widgetIdsArray = {WIDGET_ID_WITH_SHORTCUT, WIDGET_ID_WITHOUT_SHORTCUT}; Bundle options = new Bundle(); - options.putParcelable(OPTIONS_PEOPLE_SPACE_TILE, PERSON_TILE); + options.putParcelable(OPTIONS_PEOPLE_TILE, PERSON_TILE); when(mIAppWidgetService.getAppWidgetIds(any())).thenReturn(widgetIdsArray); when(mAppWidgetManager.getAppWidgetOptions(eq(WIDGET_ID_WITH_SHORTCUT))) @@ -500,7 +502,7 @@ public class PeopleSpaceUtilsTest extends SysuiTestCase { .build(); PeopleSpaceTile actual = PeopleSpaceUtils .augmentTileFromVisibleNotifications(mContext, tile, - Map.of(PeopleSpaceUtils.getKey(mNotificationEntry1), mNotificationEntry1)); + Map.of(new PeopleTileKey(mNotificationEntry1), mNotificationEntry1)); assertThat(actual.getNotificationContent().toString()).isEqualTo(NOTIFICATION_TEXT_2); } @@ -515,7 +517,7 @@ public class PeopleSpaceUtilsTest extends SysuiTestCase { .build(); PeopleSpaceTile actual = PeopleSpaceUtils .augmentTileFromVisibleNotifications(mContext, tile, - Map.of(PeopleSpaceUtils.getKey(mNotificationEntry1), mNotificationEntry1)); + Map.of(new PeopleTileKey(mNotificationEntry1), mNotificationEntry1)); assertThat(actual.getNotificationContent()).isEqualTo(null); } @@ -818,6 +820,23 @@ public class PeopleSpaceUtilsTest extends SysuiTestCase { assertEquals(statusContent.getText(), NOTIFICATION_CONTENT); } + @Test + public void testGetPeopleTileFromPersistentStorageExistingConversation() + throws Exception { + when(mPeopleManager.getConversation(PACKAGE_NAME, 0, SHORTCUT_ID_1)).thenReturn( + getConversationChannelWithoutTimestamp(SHORTCUT_ID_1)); + PeopleTileKey key = new PeopleTileKey(SHORTCUT_ID_1, 0, PACKAGE_NAME); + PeopleSpaceTile tile = getPeopleTileFromPersistentStorage(mContext, key, mPeopleManager); + assertThat(tile.getId()).isEqualTo(key.getShortcutId()); + } + + @Test + public void testGetPeopleTileFromPersistentStorageNoConversation() { + PeopleTileKey key = new PeopleTileKey(SHORTCUT_ID_2, 0, PACKAGE_NAME); + PeopleSpaceTile tile = getPeopleTileFromPersistentStorage(mContext, key, mPeopleManager); + assertThat(tile).isNull(); + } + private ConversationChannelWrapper getConversationChannelWrapper(String shortcutId, boolean importantConversation, long lastInteractionTimestamp) throws Exception { ConversationChannelWrapper convo = new ConversationChannelWrapper(); @@ -843,4 +862,13 @@ public class PeopleSpaceUtilsTest extends SysuiTestCase { eq(shortcutId))).thenReturn(lastInteractionTimestamp); return convo; } + + private ConversationChannel getConversationChannelWithoutTimestamp(String shortcutId) + throws Exception { + ShortcutInfo shortcutInfo = new ShortcutInfo.Builder(mContext, shortcutId).setLongLabel( + "name").build(); + ConversationChannel convo = new ConversationChannel(shortcutInfo, 0, null, null, + 0L, false); + return convo; + } }
\ No newline at end of file diff --git a/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleSpaceWidgetManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleSpaceWidgetManagerTest.java index f60fa099feaa..aef75beb3d56 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleSpaceWidgetManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleSpaceWidgetManagerTest.java @@ -23,10 +23,11 @@ import static android.app.people.ConversationStatus.ACTIVITY_ANNIVERSARY; import static android.app.people.ConversationStatus.ACTIVITY_BIRTHDAY; import static android.app.people.ConversationStatus.ACTIVITY_GAME; +import static com.android.systemui.people.PeopleSpaceUtils.EMPTY_STRING; import static com.android.systemui.people.PeopleSpaceUtils.INVALID_USER_ID; -import static com.android.systemui.people.PeopleSpaceUtils.OPTIONS_PEOPLE_SPACE_TILE; import static com.android.systemui.people.PeopleSpaceUtils.PACKAGE_NAME; import static com.android.systemui.people.PeopleSpaceUtils.USER_ID; +import static com.android.systemui.people.widget.AppWidgetOptionsHelper.OPTIONS_PEOPLE_TILE; import static com.google.common.truth.Truth.assertThat; @@ -104,13 +105,14 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { private static final int WIDGET_ID_WITH_SHORTCUT = 1; private static final int SECOND_WIDGET_ID_WITH_SHORTCUT = 3; private static final int WIDGET_ID_WITHOUT_SHORTCUT = 2; + private static final int WIDGET_ID_WITH_KEY_IN_OPTIONS = 4; private static final String SHORTCUT_ID = "101"; private static final String OTHER_SHORTCUT_ID = "102"; private static final String NOTIFICATION_KEY = "0|com.android.systemui.tests|0|null|0"; private static final String NOTIFICATION_CONTENT = "message text"; private static final Uri URI = Uri.parse("fake_uri"); private static final Icon ICON = Icon.createWithResource("package", R.drawable.ic_android); - private static final String KEY = PeopleSpaceUtils.getKey(SHORTCUT_ID, TEST_PACKAGE_A, 0); + private static final PeopleTileKey KEY = new PeopleTileKey(SHORTCUT_ID, 0, TEST_PACKAGE_A); private static final Person PERSON = new Person.Builder() .setName("name") .setKey("abc") @@ -172,10 +174,11 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.PEOPLE_SPACE_CONVERSATION_TYPE, 0); + clearStorage(); setStorageForTile(SHORTCUT_ID, TEST_PACKAGE_A, WIDGET_ID_WITH_SHORTCUT); Bundle options = new Bundle(); - options.putParcelable(PeopleSpaceUtils.OPTIONS_PEOPLE_SPACE_TILE, PERSON_TILE); + options.putParcelable(OPTIONS_PEOPLE_TILE, PERSON_TILE); when(mAppWidgetManager.getAppWidgetOptions(eq(WIDGET_ID_WITH_SHORTCUT))) .thenReturn(options); when(mAppWidgetManager.getAppWidgetOptions(eq(WIDGET_ID_WITHOUT_SHORTCUT))) @@ -395,7 +398,7 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { .updateAppWidgetOptions(eq(WIDGET_ID_WITH_SHORTCUT), mBundleArgumentCaptor.capture()); Bundle bundle = mBundleArgumentCaptor.getValue(); - PeopleSpaceTile tile = bundle.getParcelable(OPTIONS_PEOPLE_SPACE_TILE); + PeopleSpaceTile tile = bundle.getParcelable(OPTIONS_PEOPLE_TILE); assertThat(tile.getStatuses()).containsExactly(status); verify(mAppWidgetManager, times(1)).updateAppWidget(eq(WIDGET_ID_WITH_SHORTCUT), any()); @@ -439,7 +442,7 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { .updateAppWidgetOptions(eq(WIDGET_ID_WITH_SHORTCUT), mBundleArgumentCaptor.capture()); Bundle bundle = mBundleArgumentCaptor.getValue(); - PeopleSpaceTile tile = bundle.getParcelable(OPTIONS_PEOPLE_SPACE_TILE); + PeopleSpaceTile tile = bundle.getParcelable(OPTIONS_PEOPLE_TILE); assertThat(tile.getNotificationKey()).isEqualTo(NOTIFICATION_KEY); assertThat(tile.getNotificationContent()).isEqualTo(NOTIFICATION_CONTENT); verify(mAppWidgetManager, times(1)).updateAppWidget(eq(WIDGET_ID_WITH_SHORTCUT), @@ -473,7 +476,8 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { throws Exception { addSecondWidgetForPersonTile(); - PeopleSpaceUtils.removeStorageForTile(mContext, KEY, SECOND_WIDGET_ID_WITH_SHORTCUT); + PeopleSpaceUtils.removeSharedPreferencesStorageForTile( + mContext, KEY, SECOND_WIDGET_ID_WITH_SHORTCUT); NotifEvent notif1 = mNoMan.postNotif(new NotificationEntryBuilder() .setSbn(createNotification( SHORTCUT_ID, /* isMessagingStyle = */ true, /* isMissedCall = */ false)) @@ -510,7 +514,7 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { mBundleArgumentCaptor.capture()); Bundle bundle = requireNonNull(mBundleArgumentCaptor.getValue()); - PeopleSpaceTile tile = bundle.getParcelable(OPTIONS_PEOPLE_SPACE_TILE); + PeopleSpaceTile tile = bundle.getParcelable(OPTIONS_PEOPLE_TILE); assertThat(tile.getNotificationKey()).isEqualTo(NOTIFICATION_KEY); assertThat(tile.getNotificationContent()) .isEqualTo(mContext.getString(R.string.missed_call)); @@ -536,7 +540,7 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { mBundleArgumentCaptor.capture()); Bundle bundle = requireNonNull(mBundleArgumentCaptor.getValue()); - PeopleSpaceTile tile = bundle.getParcelable(OPTIONS_PEOPLE_SPACE_TILE); + PeopleSpaceTile tile = bundle.getParcelable(OPTIONS_PEOPLE_TILE); assertThat(tile.getNotificationKey()).isEqualTo(NOTIFICATION_KEY); assertThat(tile.getNotificationContent()).isEqualTo(NOTIFICATION_CONTENT); verify(mAppWidgetManager, times(1)).updateAppWidget(eq(WIDGET_ID_WITH_SHORTCUT), @@ -547,6 +551,7 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { public void testUpdateNotificationRemovedIfExistingTile() throws Exception { int[] widgetIdsArray = {WIDGET_ID_WITH_SHORTCUT, WIDGET_ID_WITHOUT_SHORTCUT}; when(mAppWidgetManager.getAppWidgetIds(any())).thenReturn(widgetIdsArray); + setStorageForTile(SHORTCUT_ID, TEST_PACKAGE_A, WIDGET_ID_WITH_SHORTCUT); StatusBarNotification sbn = createNotification( SHORTCUT_ID, /* isMessagingStyle = */ true, /* isMissedCall = */ false); @@ -560,11 +565,11 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { verify(mAppWidgetManager, times(2)).updateAppWidgetOptions(eq(WIDGET_ID_WITH_SHORTCUT), mBundleArgumentCaptor.capture()); Bundle bundle = mBundleArgumentCaptor.getValue(); - PeopleSpaceTile tile = bundle.getParcelable(OPTIONS_PEOPLE_SPACE_TILE); + PeopleSpaceTile tile = bundle.getParcelable(OPTIONS_PEOPLE_TILE); assertThat(tile.getNotificationKey()).isEqualTo(null); assertThat(tile.getNotificationContent()).isEqualTo(null); assertThat(tile.getNotificationDataUri()).isEqualTo(null); - verify(mAppWidgetManager, times(2)).updateAppWidget(anyInt(), + verify(mAppWidgetManager, times(2)).updateAppWidget(eq(WIDGET_ID_WITH_SHORTCUT), any()); } @@ -585,7 +590,7 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { assertThat(widgetSp.getString(SHORTCUT_ID, null)).isNull(); assertThat(widgetSp.getInt(USER_ID, INVALID_USER_ID)).isEqualTo(INVALID_USER_ID); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext); - assertThat(sp.getStringSet(KEY, new HashSet<>())).containsExactly( + assertThat(sp.getStringSet(KEY.toString(), new HashSet<>())).containsExactly( String.valueOf(SECOND_WIDGET_ID_WITH_SHORTCUT)); // Check listener & shortcut caching remain for other widget. verify(mPeopleManager, never()).unregisterConversationListener(any()); @@ -603,7 +608,7 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { assertThat(secondWidgetSp.getString(PACKAGE_NAME, null)).isNull(); assertThat(secondWidgetSp.getString(SHORTCUT_ID, null)).isNull(); assertThat(secondWidgetSp.getInt(USER_ID, INVALID_USER_ID)).isEqualTo(INVALID_USER_ID); - assertThat(sp.getStringSet(KEY, new HashSet<>())).isEmpty(); + assertThat(sp.getStringSet(KEY.toString(), new HashSet<>())).isEmpty(); // Check listener is removed and shortcut is uncached. verify(mPeopleManager, times(1)).unregisterConversationListener(any()); verify(mLauncherApps, times(1)).uncacheShortcuts(eq(TEST_PACKAGE_A), @@ -611,13 +616,96 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { eq(LauncherApps.FLAG_CACHE_PEOPLE_TILE_SHORTCUTS)); } + @Test + public void testUpdateWidgetsWithEmptyOptionsAddsPeopleTileToOptions() throws Exception { + int[] widgetIdsArray = {WIDGET_ID_WITH_SHORTCUT}; + when(mAppWidgetManager.getAppWidgetIds(any())).thenReturn(widgetIdsArray); + when(mAppWidgetManager.getAppWidgetOptions(eq(WIDGET_ID_WITH_SHORTCUT))) + .thenReturn(new Bundle()); + + mManager.updateWidgets(widgetIdsArray); + mClock.advanceTime(MIN_LINGER_DURATION); + + // If we had to fetch Tile from persistent storage, we want to make sure we write it to + // options. + verify(mAppWidgetManager, times(1)) + .updateAppWidgetOptions(eq(WIDGET_ID_WITH_SHORTCUT), + mBundleArgumentCaptor.capture()); + Bundle bundle = mBundleArgumentCaptor.getValue(); + PeopleSpaceTile tile = bundle.getParcelable(OPTIONS_PEOPLE_TILE); + assertThat(tile.getId()).isEqualTo(SHORTCUT_ID); + verify(mAppWidgetManager, times(1)).updateAppWidget(eq(WIDGET_ID_WITH_SHORTCUT), + any()); + } + + @Test + public void testOnAppWidgetOptionsChangedNoWidgetAdded() { + Bundle newOptions = new Bundle(); + newOptions.putParcelable(OPTIONS_PEOPLE_TILE, PERSON_TILE); + mManager.onAppWidgetOptionsChanged(SECOND_WIDGET_ID_WITH_SHORTCUT, newOptions); + + + // Check that options is not modified + verify(mAppWidgetManager, never()).updateAppWidgetOptions( + eq(SECOND_WIDGET_ID_WITH_SHORTCUT), any()); + // Check listener is not added and shortcut is not cached. + verify(mPeopleManager, never()).registerConversationListener(any(), anyInt(), any(), any(), + any()); + verify(mLauncherApps, never()).cacheShortcuts(any(), any(), any(), anyInt()); + // Check no added storage. + SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext); + assertThat(sp.getStringSet(KEY.toString(), new HashSet<>())) + .doesNotContain(SECOND_WIDGET_ID_WITH_SHORTCUT); + SharedPreferences widgetSp = mContext.getSharedPreferences( + String.valueOf(SECOND_WIDGET_ID_WITH_SHORTCUT), + Context.MODE_PRIVATE); + assertThat(widgetSp.getString(PACKAGE_NAME, EMPTY_STRING)).isEqualTo(EMPTY_STRING); + assertThat(widgetSp.getString(SHORTCUT_ID, EMPTY_STRING)).isEqualTo(EMPTY_STRING); + assertThat(widgetSp.getInt(USER_ID, INVALID_USER_ID)).isEqualTo(INVALID_USER_ID); + + } + + @Test + public void testOnAppWidgetOptionsChangedWidgetAdded() { + Bundle newOptions = new Bundle(); + newOptions.putString(PeopleSpaceUtils.SHORTCUT_ID, SHORTCUT_ID); + newOptions.putInt(USER_ID, 0); + newOptions.putString(PACKAGE_NAME, TEST_PACKAGE_A); + when(mAppWidgetManager.getAppWidgetOptions(eq(SECOND_WIDGET_ID_WITH_SHORTCUT))) + .thenReturn(newOptions); + + mManager.onAppWidgetOptionsChanged(SECOND_WIDGET_ID_WITH_SHORTCUT, newOptions); + + verify(mAppWidgetManager, times(1)).updateAppWidgetOptions( + eq(SECOND_WIDGET_ID_WITH_SHORTCUT), mBundleArgumentCaptor.capture()); + Bundle bundle = mBundleArgumentCaptor.getValue(); + assertThat(bundle.getString(PeopleSpaceUtils.SHORTCUT_ID, EMPTY_STRING)) + .isEqualTo(EMPTY_STRING); + assertThat(bundle.getInt(USER_ID, INVALID_USER_ID)).isEqualTo(INVALID_USER_ID); + assertThat(bundle.getString(PACKAGE_NAME, EMPTY_STRING)).isEqualTo(EMPTY_STRING); + verify(mLauncherApps, times(1)).cacheShortcuts(eq(TEST_PACKAGE_A), + eq(Arrays.asList(SHORTCUT_ID)), eq(UserHandle.of(0)), + eq(LauncherApps.FLAG_CACHE_PEOPLE_TILE_SHORTCUTS)); + + SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext); + assertThat(sp.getStringSet(KEY.toString(), new HashSet<>())).contains( + String.valueOf(SECOND_WIDGET_ID_WITH_SHORTCUT)); + SharedPreferences widgetSp = mContext.getSharedPreferences( + String.valueOf(SECOND_WIDGET_ID_WITH_SHORTCUT), + Context.MODE_PRIVATE); + assertThat(widgetSp.getString(PACKAGE_NAME, EMPTY_STRING)).isEqualTo(TEST_PACKAGE_A); + assertThat(widgetSp.getString(PeopleSpaceUtils.SHORTCUT_ID, EMPTY_STRING)) + .isEqualTo(SHORTCUT_ID); + assertThat(widgetSp.getInt(USER_ID, INVALID_USER_ID)).isEqualTo(0); + } + /** * Adds another widget for {@code PERSON_TILE} with widget ID: {@code * SECOND_WIDGET_ID_WITH_SHORTCUT}. */ private void addSecondWidgetForPersonTile() { Bundle options = new Bundle(); - options.putParcelable(PeopleSpaceUtils.OPTIONS_PEOPLE_SPACE_TILE, PERSON_TILE); + options.putParcelable(OPTIONS_PEOPLE_TILE, PERSON_TILE); when(mAppWidgetManager.getAppWidgetOptions(eq(SECOND_WIDGET_ID_WITH_SHORTCUT))) .thenReturn(options); // Set the same Person associated on another People Tile widget ID. @@ -676,6 +764,27 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { .build(); } + private void clearStorage() { + SharedPreferences widgetSp1 = mContext.getSharedPreferences( + String.valueOf(WIDGET_ID_WITH_SHORTCUT), + Context.MODE_PRIVATE); + widgetSp1.edit().clear().commit(); + SharedPreferences widgetSp2 = mContext.getSharedPreferences( + String.valueOf(WIDGET_ID_WITHOUT_SHORTCUT), + Context.MODE_PRIVATE); + widgetSp2.edit().clear().commit(); + SharedPreferences widgetSp3 = mContext.getSharedPreferences( + String.valueOf(SECOND_WIDGET_ID_WITH_SHORTCUT), + Context.MODE_PRIVATE); + widgetSp3.edit().clear().commit(); + SharedPreferences widgetSp4 = mContext.getSharedPreferences( + String.valueOf(WIDGET_ID_WITH_KEY_IN_OPTIONS), + Context.MODE_PRIVATE); + widgetSp4.edit().clear().commit(); + SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext); + sp.edit().clear().commit(); + } + private void setStorageForTile(String shortcutId, String packageName, int widgetId) { SharedPreferences widgetSp = mContext.getSharedPreferences( String.valueOf(widgetId), @@ -689,7 +798,7 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext); SharedPreferences.Editor editor = sp.edit(); editor.putString(String.valueOf(widgetId), shortcutId); - String key = PeopleSpaceUtils.getKey(shortcutId, packageName, 0); + String key = new PeopleTileKey(shortcutId, 0, packageName).toString(); Set<String> storedWidgetIds = new HashSet<>(sp.getStringSet(key, new HashSet<>())); storedWidgetIds.add(String.valueOf(widgetId)); editor.putStringSet(key, storedWidgetIds); diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DeviceControlsTileTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DeviceControlsTileTest.kt index ccd9548b269f..9363b24817e6 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DeviceControlsTileTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DeviceControlsTileTest.kt @@ -17,6 +17,8 @@ package com.android.systemui.qs.tiles import android.os.Handler +import android.content.Context +import android.content.Intent import android.provider.Settings import android.service.quicksettings.Tile import android.testing.AndroidTestingRunner @@ -30,7 +32,6 @@ import com.android.systemui.controls.ControlsServiceInfo import com.android.systemui.controls.controller.ControlsController import com.android.systemui.controls.dagger.ControlsComponent import com.android.systemui.controls.management.ControlsListingController -import com.android.systemui.controls.ui.ControlsDialog import com.android.systemui.controls.ui.ControlsUiController import com.android.systemui.plugins.ActivityStarter import com.android.systemui.plugins.statusbar.StatusBarStateController @@ -50,7 +51,9 @@ import org.mockito.ArgumentCaptor import org.mockito.Captor import org.mockito.Mock import org.mockito.Mockito.`when` +import org.mockito.Mockito.doNothing import org.mockito.Mockito.never +import org.mockito.Mockito.spy import org.mockito.Mockito.verify import org.mockito.MockitoAnnotations import java.util.Optional @@ -80,8 +83,6 @@ class DeviceControlsTileTest : SysuiTestCase() { private lateinit var controlsController: ControlsController @Mock private lateinit var featureFlags: FeatureFlags - @Mock - private lateinit var controlsDialog: ControlsDialog private lateinit var globalSettings: GlobalSettings @Mock private lateinit var serviceInfo: ControlsServiceInfo @@ -95,6 +96,7 @@ class DeviceControlsTileTest : SysuiTestCase() { private lateinit var tile: DeviceControlsTile private lateinit var secureSettings: SecureSettings + private lateinit var spiedContext: Context private var featureEnabled = true @Before @@ -103,7 +105,9 @@ class DeviceControlsTileTest : SysuiTestCase() { testableLooper = TestableLooper.get(this) secureSettings = FakeSettings() - `when`(qsHost.context).thenReturn(mContext) + spiedContext = spy(mContext) + doNothing().`when`(spiedContext).startActivity(any(Intent::class.java)) + `when`(qsHost.context).thenReturn(spiedContext) `when`(qsHost.uiEventLogger).thenReturn(uiEventLogger) `when`(controlsController.available).thenReturn(true) `when`(controlsComponent.isEnabled()).thenReturn(true) @@ -276,7 +280,7 @@ class DeviceControlsTileTest : SysuiTestCase() { tile.click() testableLooper.processAllMessages() - verify(controlsDialog, never()).show(any(ControlsUiController::class.java)) + verify(spiedContext, never()).startActivity(any(Intent::class.java)) } @Test @@ -293,7 +297,7 @@ class DeviceControlsTileTest : SysuiTestCase() { tile.click() testableLooper.processAllMessages() - verify(controlsDialog).show(controlsUiController) + verify(spiedContext).startActivity(any(Intent::class.java)) } @Test @@ -311,25 +315,7 @@ class DeviceControlsTileTest : SysuiTestCase() { tile.click() testableLooper.processAllMessages() - verify(controlsDialog, never()).show(any(ControlsUiController::class.java)) - } - - @Test - fun testDialogDismissedOnDestroy() { - verify(controlsListingController).observe( - any(LifecycleOwner::class.java), - capture(listingCallbackCaptor) - ) - - listingCallbackCaptor.value.onServicesUpdated(listOf(serviceInfo)) - testableLooper.processAllMessages() - - tile.click() - testableLooper.processAllMessages() - - tile.destroy() - testableLooper.processAllMessages() - verify(controlsDialog).dismiss() + verify(spiedContext, never()).startActivity(any(Intent::class.java)) } private fun createTile(): DeviceControlsTile { @@ -343,7 +329,6 @@ class DeviceControlsTileTest : SysuiTestCase() { qsLogger, controlsComponent, featureFlags, - { controlsDialog }, globalSettings ) } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManagerTest.java index 8cd71031a8f8..c1d2ea88a1b1 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManagerTest.java @@ -322,23 +322,7 @@ public class NotificationSectionsManagerTest extends SysuiTestCase { } @Test - public void testPeopleFiltering_addHeadersFromShowingOnlyGentle() { - enablePeopleFiltering(); - - setStackState( - GENTLE_HEADER, - PERSON, - ALERTING, - GENTLE); - mSectionsManager.updateSectionBoundaries(); - - verify(mNssl).changeViewPosition(mSectionsManager.getSilentHeaderView(), 2); - verify(mNssl).addView(mSectionsManager.getAlertingHeaderView(), 1); - verify(mNssl).addView(mSectionsManager.getPeopleHeaderView(), 0); - } - - @Test - public void testPeopleFiltering_addAllHeaders() { + public void testPeopleFiltering_onlyAddSilentHeader() { enablePeopleFiltering(); setStackState( @@ -348,26 +332,6 @@ public class NotificationSectionsManagerTest extends SysuiTestCase { mSectionsManager.updateSectionBoundaries(); verify(mNssl).addView(mSectionsManager.getSilentHeaderView(), 2); - verify(mNssl).addView(mSectionsManager.getAlertingHeaderView(), 1); - verify(mNssl).addView(mSectionsManager.getPeopleHeaderView(), 0); - } - - @Test - public void testPeopleFiltering_moveAllHeaders() { - enablePeopleFiltering(); - - setStackState( - PEOPLE_HEADER, - ALERTING_HEADER, - GENTLE_HEADER, - PERSON, - ALERTING, - GENTLE); - mSectionsManager.updateSectionBoundaries(); - - verify(mNssl).changeViewPosition(mSectionsManager.getSilentHeaderView(), 4); - verify(mNssl).changeViewPosition(mSectionsManager.getAlertingHeaderView(), 2); - verify(mNssl).changeViewPosition(mSectionsManager.getPeopleHeaderView(), 0); } @Test @@ -385,9 +349,7 @@ public class NotificationSectionsManagerTest extends SysuiTestCase { mSectionsManager.updateSectionBoundaries(); verifyMockStack( - ChildType.INCOMING_HEADER, ChildType.HEADS_UP, - ChildType.PEOPLE_HEADER, ChildType.PERSON, ChildType.GENTLE_HEADER, ChildType.GENTLE @@ -408,10 +370,8 @@ public class NotificationSectionsManagerTest extends SysuiTestCase { mSectionsManager.updateSectionBoundaries(); verifyMockStack( - ChildType.INCOMING_HEADER, ChildType.HEADS_UP, ChildType.HEADS_UP, - ChildType.PEOPLE_HEADER, ChildType.PERSON ); } @@ -428,7 +388,6 @@ public class NotificationSectionsManagerTest extends SysuiTestCase { mSectionsManager.updateSectionBoundaries(); verifyMockStack( - ChildType.PEOPLE_HEADER, ChildType.PERSON, ChildType.PERSON ); @@ -444,9 +403,7 @@ public class NotificationSectionsManagerTest extends SysuiTestCase { ); mSectionsManager.updateSectionBoundaries(); verifyMockStack( - ChildType.INCOMING_HEADER, ChildType.HEADS_UP, - ChildType.PEOPLE_HEADER, ChildType.PERSON ); } @@ -467,12 +424,9 @@ public class NotificationSectionsManagerTest extends SysuiTestCase { mSectionsManager.updateSectionBoundaries(); verifyMockStack( - ChildType.INCOMING_HEADER, ChildType.HEADS_UP, ChildType.FSN, - ChildType.PEOPLE_HEADER, ChildType.PERSON, - ChildType.ALERTING_HEADER, ChildType.ALERTING, ChildType.GENTLE_HEADER, ChildType.GENTLE @@ -517,7 +471,7 @@ public class NotificationSectionsManagerTest extends SysuiTestCase { } @Test - public void testRemoveIncomingHeader() { + public void testRemoveNonSilentHeader() { enablePeopleFiltering(); enableMediaControls(); @@ -539,9 +493,7 @@ public class NotificationSectionsManagerTest extends SysuiTestCase { verifyMockStack( ChildType.MEDIA_CONTROLS, - ChildType.PEOPLE_HEADER, ChildType.PERSON, - ChildType.ALERTING_HEADER, ChildType.ALERTING, ChildType.ALERTING, ChildType.ALERTING, @@ -569,13 +521,10 @@ public class NotificationSectionsManagerTest extends SysuiTestCase { mSectionsManager.updateSectionBoundaries(); verifyMockStack( - ChildType.INCOMING_HEADER, ChildType.HEADS_UP, ChildType.HEADS_UP, ChildType.HEADS_UP, - ChildType.PEOPLE_HEADER, ChildType.PERSON, - ChildType.ALERTING_HEADER, ChildType.ALERTING ); } @@ -593,7 +542,6 @@ public class NotificationSectionsManagerTest extends SysuiTestCase { mSectionsManager.updateSectionBoundaries(); verifyMockStack( - ChildType.ALERTING_HEADER, ChildType.PERSON, ChildType.ALERTING, ChildType.GENTLE_HEADER, diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java index bdde82289e86..8b5ba3848500 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java @@ -174,6 +174,7 @@ public class DozeServiceHostTest extends SysuiTestCase { DozeLog.PULSE_REASON_SENSOR_LONG_PRESS, DozeLog.PULSE_REASON_DOCKING, DozeLog.REASON_SENSOR_WAKE_UP, + DozeLog.REASON_SENSOR_QUICK_PICKUP, DozeLog.REASON_SENSOR_TAP)); HashSet<Integer> reasonsThatDontPulse = new HashSet<>( Arrays.asList(DozeLog.REASON_SENSOR_PICKUP, diff --git a/rs/java/android/renderscript/Allocation.java b/rs/java/android/renderscript/Allocation.java index 238bf0f5a335..d420bd4bdb66 100644 --- a/rs/java/android/renderscript/Allocation.java +++ b/rs/java/android/renderscript/Allocation.java @@ -52,8 +52,12 @@ import android.view.Surface; * <p>For more information about creating an application that uses RenderScript, read the * <a href="{@docRoot}guide/topics/renderscript/index.html">RenderScript</a> developer guide.</p> * </div> + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ - +@Deprecated public class Allocation extends BaseObj { private static final int MAX_NUMBER_IO_INPUT_ALLOC = 16; diff --git a/rs/java/android/renderscript/AllocationAdapter.java b/rs/java/android/renderscript/AllocationAdapter.java index 6d7e97ebb0fe..17bc23421894 100644 --- a/rs/java/android/renderscript/AllocationAdapter.java +++ b/rs/java/android/renderscript/AllocationAdapter.java @@ -19,7 +19,11 @@ package android.renderscript; /** * Only intended for use by generated reflected code. * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public class AllocationAdapter extends Allocation { Type mWindow; diff --git a/rs/java/android/renderscript/BaseObj.java b/rs/java/android/renderscript/BaseObj.java index 7b5514b8a0d1..ea8535d6d621 100644 --- a/rs/java/android/renderscript/BaseObj.java +++ b/rs/java/android/renderscript/BaseObj.java @@ -27,7 +27,11 @@ import java.util.concurrent.locks.ReentrantReadWriteLock; * It is responsible for lifetime management and resource tracking. This class * should not be used by a user application. * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public class BaseObj { BaseObj(long id, RenderScript rs) { rs.validate(); diff --git a/rs/java/android/renderscript/Byte2.java b/rs/java/android/renderscript/Byte2.java index 3ad79e400c91..cb5cc473a48e 100644 --- a/rs/java/android/renderscript/Byte2.java +++ b/rs/java/android/renderscript/Byte2.java @@ -20,7 +20,11 @@ package android.renderscript; /** * Class for exposing the native RenderScript byte2 type back to the Android system. * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public class Byte2 { public byte x; public byte y; diff --git a/rs/java/android/renderscript/Byte3.java b/rs/java/android/renderscript/Byte3.java index a138313321d0..aca4e645f102 100644 --- a/rs/java/android/renderscript/Byte3.java +++ b/rs/java/android/renderscript/Byte3.java @@ -20,7 +20,11 @@ package android.renderscript; /** * Class for exposing the native RenderScript byte3 type back to the Android system. * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public class Byte3 { public byte x; public byte y; diff --git a/rs/java/android/renderscript/Byte4.java b/rs/java/android/renderscript/Byte4.java index fa4c13d79714..b30b6ed00d09 100644 --- a/rs/java/android/renderscript/Byte4.java +++ b/rs/java/android/renderscript/Byte4.java @@ -20,7 +20,11 @@ package android.renderscript; /** * Class for exposing the native RenderScript byte4 type back to the Android system. * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public class Byte4 { public byte x; public byte y; diff --git a/rs/java/android/renderscript/Double2.java b/rs/java/android/renderscript/Double2.java index 4c7319d5a4b0..e14228a6f785 100644 --- a/rs/java/android/renderscript/Double2.java +++ b/rs/java/android/renderscript/Double2.java @@ -19,7 +19,12 @@ package android.renderscript; /** * Vector version of the basic double type. * Provides two double fields packed. + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. */ +@Deprecated public class Double2 { public double x; public double y; diff --git a/rs/java/android/renderscript/Double3.java b/rs/java/android/renderscript/Double3.java index b819716017e9..e52c902a27fa 100644 --- a/rs/java/android/renderscript/Double3.java +++ b/rs/java/android/renderscript/Double3.java @@ -19,7 +19,12 @@ package android.renderscript; /** * Vector version of the basic double type. * Provides three double fields packed. + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. */ +@Deprecated public class Double3 { public double x; public double y; diff --git a/rs/java/android/renderscript/Double4.java b/rs/java/android/renderscript/Double4.java index e4829f7426ae..a3e4a94af8f2 100644 --- a/rs/java/android/renderscript/Double4.java +++ b/rs/java/android/renderscript/Double4.java @@ -19,7 +19,12 @@ package android.renderscript; /** * Vector version of the basic double type. * Provides four double fields packed. + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. */ +@Deprecated public class Double4 { public double x; public double y; diff --git a/rs/java/android/renderscript/Element.java b/rs/java/android/renderscript/Element.java index 0941907d35f8..f671953f4704 100644 --- a/rs/java/android/renderscript/Element.java +++ b/rs/java/android/renderscript/Element.java @@ -51,7 +51,12 @@ import android.compat.annotation.UnsupportedAppUsage; * <p>For more information about creating an application that uses RenderScript, read the * <a href="{@docRoot}guide/topics/renderscript/index.html">RenderScript</a> developer guide.</p> * </div> + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public class Element extends BaseObj { int mSize; Element[] mElements; diff --git a/rs/java/android/renderscript/FieldPacker.java b/rs/java/android/renderscript/FieldPacker.java index de1c49730aaa..aaa0fe8d7e95 100644 --- a/rs/java/android/renderscript/FieldPacker.java +++ b/rs/java/android/renderscript/FieldPacker.java @@ -26,7 +26,11 @@ import java.util.BitSet; * reflected code generated by the RS tool chain. It should not * be called directly. * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public class FieldPacker { public FieldPacker(int len) { mPos = 0; diff --git a/rs/java/android/renderscript/FileA3D.java b/rs/java/android/renderscript/FileA3D.java index 7cc2825ae565..f0a9fa718a6f 100644 --- a/rs/java/android/renderscript/FileA3D.java +++ b/rs/java/android/renderscript/FileA3D.java @@ -36,6 +36,7 @@ import java.io.InputStream; * index entries for all the objects stored inside it. * **/ +@Deprecated public class FileA3D extends BaseObj { /** diff --git a/rs/java/android/renderscript/Float2.java b/rs/java/android/renderscript/Float2.java index e9f8ca7737ce..1f6038c9bfca 100644 --- a/rs/java/android/renderscript/Float2.java +++ b/rs/java/android/renderscript/Float2.java @@ -19,7 +19,12 @@ package android.renderscript; /** * Vector version of the basic float type. * Provides two float fields packed. + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. */ +@Deprecated public class Float2 { public float x; public float y; diff --git a/rs/java/android/renderscript/Float3.java b/rs/java/android/renderscript/Float3.java index 555bdf6d6e4e..5f4571643daf 100644 --- a/rs/java/android/renderscript/Float3.java +++ b/rs/java/android/renderscript/Float3.java @@ -19,7 +19,12 @@ package android.renderscript; /** * Vector version of the basic float type. * Provides three float fields packed. + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. */ +@Deprecated public class Float3 { public float x; public float y; diff --git a/rs/java/android/renderscript/Float4.java b/rs/java/android/renderscript/Float4.java index 6541b2ec7264..7f3ba2c5fc33 100644 --- a/rs/java/android/renderscript/Float4.java +++ b/rs/java/android/renderscript/Float4.java @@ -19,7 +19,12 @@ package android.renderscript; /** * Vector version of the basic float type. * Provides four float fields packed. + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. */ +@Deprecated public class Float4 { public float x; public float y; diff --git a/rs/java/android/renderscript/Font.java b/rs/java/android/renderscript/Font.java index e47ec4b31700..6f6f341d78a6 100644 --- a/rs/java/android/renderscript/Font.java +++ b/rs/java/android/renderscript/Font.java @@ -45,6 +45,7 @@ import java.util.Map; * them in the script to suit the user's rendering needs. Font colors work as a state machine. * Every new call to draw text uses the last color set in the script.</p> **/ +@Deprecated public class Font extends BaseObj { //These help us create a font by family name diff --git a/rs/java/android/renderscript/Int2.java b/rs/java/android/renderscript/Int2.java index 120957bcd726..be0639f7137d 100644 --- a/rs/java/android/renderscript/Int2.java +++ b/rs/java/android/renderscript/Int2.java @@ -19,7 +19,12 @@ package android.renderscript; /** * Vector version of the basic int type. * Provides two int fields packed. + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. */ +@Deprecated public class Int2 { public int x; public int y; diff --git a/rs/java/android/renderscript/Int3.java b/rs/java/android/renderscript/Int3.java index 5431b9a75ba7..38a602d6bb4e 100644 --- a/rs/java/android/renderscript/Int3.java +++ b/rs/java/android/renderscript/Int3.java @@ -19,7 +19,12 @@ package android.renderscript; /** * Vector version of the basic int type. * Provides three int fields packed. + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. */ +@Deprecated public class Int3 { public int x; public int y; diff --git a/rs/java/android/renderscript/Int4.java b/rs/java/android/renderscript/Int4.java index 1c0e2e2621aa..52f7bb2c2461 100644 --- a/rs/java/android/renderscript/Int4.java +++ b/rs/java/android/renderscript/Int4.java @@ -19,7 +19,12 @@ package android.renderscript; /** * Vector version of the basic int type. * Provides four int fields packed. + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. */ +@Deprecated public class Int4 { public int x; public int y; diff --git a/rs/java/android/renderscript/Long2.java b/rs/java/android/renderscript/Long2.java index fabf2046a48c..1b3955b04798 100644 --- a/rs/java/android/renderscript/Long2.java +++ b/rs/java/android/renderscript/Long2.java @@ -19,7 +19,12 @@ package android.renderscript; /** * Vector version of the basic long type. * Provides two long fields packed. + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. */ +@Deprecated public class Long2 { public long x; public long y; diff --git a/rs/java/android/renderscript/Long3.java b/rs/java/android/renderscript/Long3.java index 8e243cce647f..8be9c1cf2774 100644 --- a/rs/java/android/renderscript/Long3.java +++ b/rs/java/android/renderscript/Long3.java @@ -19,7 +19,12 @@ package android.renderscript; /** * Vector version of the basic long type. * Provides three long fields packed. + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. */ +@Deprecated public class Long3 { public long x; public long y; diff --git a/rs/java/android/renderscript/Long4.java b/rs/java/android/renderscript/Long4.java index 1a1ad748e462..75db51b1237a 100644 --- a/rs/java/android/renderscript/Long4.java +++ b/rs/java/android/renderscript/Long4.java @@ -19,7 +19,12 @@ package android.renderscript; /** * Vector version of the basic long type. * Provides four long fields packed. + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. */ +@Deprecated public class Long4 { public long x; public long y; diff --git a/rs/java/android/renderscript/Matrix2f.java b/rs/java/android/renderscript/Matrix2f.java index 048262dc7eba..5f5e709d2c99 100644 --- a/rs/java/android/renderscript/Matrix2f.java +++ b/rs/java/android/renderscript/Matrix2f.java @@ -20,7 +20,11 @@ package android.renderscript; /** * Class for exposing the native RenderScript rs_matrix2x2 type back to the Android system. * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public class Matrix2f { /** diff --git a/rs/java/android/renderscript/Matrix3f.java b/rs/java/android/renderscript/Matrix3f.java index 9a4af777583c..b620eaf1415d 100644 --- a/rs/java/android/renderscript/Matrix3f.java +++ b/rs/java/android/renderscript/Matrix3f.java @@ -20,7 +20,11 @@ package android.renderscript; /** * Class for exposing the native RenderScript rs_matrix3x3 type back to the Android system. * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public class Matrix3f { /** diff --git a/rs/java/android/renderscript/Matrix4f.java b/rs/java/android/renderscript/Matrix4f.java index a9469c979494..cdf06a63c59f 100644 --- a/rs/java/android/renderscript/Matrix4f.java +++ b/rs/java/android/renderscript/Matrix4f.java @@ -22,7 +22,11 @@ import android.compat.annotation.UnsupportedAppUsage; /** * Class for exposing the native RenderScript rs_matrix4x4 type back to the Android system. * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public class Matrix4f { /** diff --git a/rs/java/android/renderscript/Mesh.java b/rs/java/android/renderscript/Mesh.java index 1a4d1fd5afbb..f2fd5a92afe8 100644 --- a/rs/java/android/renderscript/Mesh.java +++ b/rs/java/android/renderscript/Mesh.java @@ -40,6 +40,7 @@ import java.util.Vector; * index sets or primitive types. * </p> **/ +@Deprecated public class Mesh extends BaseObj { /** diff --git a/rs/java/android/renderscript/Program.java b/rs/java/android/renderscript/Program.java index ff072183e927..3cadc935e67c 100644 --- a/rs/java/android/renderscript/Program.java +++ b/rs/java/android/renderscript/Program.java @@ -32,7 +32,11 @@ import java.io.UnsupportedEncodingException; * Program is a base class for all the objects that modify * various stages of the graphics pipeline * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public class Program extends BaseObj { static final int MAX_INPUT = 8; static final int MAX_OUTPUT = 8; diff --git a/rs/java/android/renderscript/ProgramFragment.java b/rs/java/android/renderscript/ProgramFragment.java index 880531207b4d..e2879d8a0d54 100644 --- a/rs/java/android/renderscript/ProgramFragment.java +++ b/rs/java/android/renderscript/ProgramFragment.java @@ -37,6 +37,7 @@ import android.compat.annotation.UnsupportedAppUsage; * </p> * **/ +@Deprecated public class ProgramFragment extends Program { ProgramFragment(long id, RenderScript rs) { super(id, rs); diff --git a/rs/java/android/renderscript/ProgramFragmentFixedFunction.java b/rs/java/android/renderscript/ProgramFragmentFixedFunction.java index c741ce6e77ed..8dbf6f44f137 100644 --- a/rs/java/android/renderscript/ProgramFragmentFixedFunction.java +++ b/rs/java/android/renderscript/ProgramFragmentFixedFunction.java @@ -29,6 +29,7 @@ import android.compat.annotation.UnsupportedAppUsage; * blended with results of up to two texture lookups.</p * **/ +@Deprecated public class ProgramFragmentFixedFunction extends ProgramFragment { ProgramFragmentFixedFunction(long id, RenderScript rs) { super(id, rs); diff --git a/rs/java/android/renderscript/ProgramRaster.java b/rs/java/android/renderscript/ProgramRaster.java index a21696c82161..8b53828918a8 100644 --- a/rs/java/android/renderscript/ProgramRaster.java +++ b/rs/java/android/renderscript/ProgramRaster.java @@ -25,6 +25,7 @@ import android.compat.annotation.UnsupportedAppUsage; * Program raster is primarily used to specify whether point sprites are enabled and to control * the culling mode. By default, back faces are culled. **/ +@Deprecated public class ProgramRaster extends BaseObj { /** diff --git a/rs/java/android/renderscript/ProgramStore.java b/rs/java/android/renderscript/ProgramStore.java index 1952b8860033..c94d2534dad6 100644 --- a/rs/java/android/renderscript/ProgramStore.java +++ b/rs/java/android/renderscript/ProgramStore.java @@ -34,7 +34,11 @@ import android.os.Build; * framebuffer</li> * </ul> * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public class ProgramStore extends BaseObj { /** * Specifies the function used to determine whether a fragment diff --git a/rs/java/android/renderscript/ProgramVertex.java b/rs/java/android/renderscript/ProgramVertex.java index 9257234de42c..ecd8a31ed130 100644 --- a/rs/java/android/renderscript/ProgramVertex.java +++ b/rs/java/android/renderscript/ProgramVertex.java @@ -34,7 +34,6 @@ * The signatures don't have to be exact or in any strict order. As long as the input name in the shader * matches a channel name and size available on the mesh, the runtime takes care of connecting the * two. Unlike OpenGL, there is no need to link the vertex and fragment programs.</p> - * **/ package android.renderscript; @@ -49,6 +48,7 @@ import android.compat.annotation.UnsupportedAppUsage; * geometric data in a user-defined way. * **/ +@Deprecated public class ProgramVertex extends Program { ProgramVertex(long id, RenderScript rs) { diff --git a/rs/java/android/renderscript/ProgramVertexFixedFunction.java b/rs/java/android/renderscript/ProgramVertexFixedFunction.java index 03c2eaf91242..4cf2f4c8174f 100644 --- a/rs/java/android/renderscript/ProgramVertexFixedFunction.java +++ b/rs/java/android/renderscript/ProgramVertexFixedFunction.java @@ -27,6 +27,7 @@ import android.compat.annotation.UnsupportedAppUsage; * without writing any GLSL code. * **/ +@Deprecated public class ProgramVertexFixedFunction extends ProgramVertex { ProgramVertexFixedFunction(long id, RenderScript rs) { diff --git a/rs/java/android/renderscript/RSDriverException.java b/rs/java/android/renderscript/RSDriverException.java index 9e6507f517ed..3d0f0bfadbd0 100644 --- a/rs/java/android/renderscript/RSDriverException.java +++ b/rs/java/android/renderscript/RSDriverException.java @@ -20,7 +20,12 @@ package android.renderscript; /** * Base class for all exceptions thrown by the Android * RenderScript + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. */ +@Deprecated public class RSDriverException extends RSRuntimeException { public RSDriverException(String string) { super(string); diff --git a/rs/java/android/renderscript/RSIllegalArgumentException.java b/rs/java/android/renderscript/RSIllegalArgumentException.java index 5c68594f33a2..d0ac5b681f2f 100644 --- a/rs/java/android/renderscript/RSIllegalArgumentException.java +++ b/rs/java/android/renderscript/RSIllegalArgumentException.java @@ -20,7 +20,12 @@ package android.renderscript; /** * Base class for all exceptions thrown by the Android * RenderScript + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. */ +@Deprecated public class RSIllegalArgumentException extends RSRuntimeException { public RSIllegalArgumentException(String string) { super(string); diff --git a/rs/java/android/renderscript/RSInvalidStateException.java b/rs/java/android/renderscript/RSInvalidStateException.java index c881898dab3d..5eea41997f35 100644 --- a/rs/java/android/renderscript/RSInvalidStateException.java +++ b/rs/java/android/renderscript/RSInvalidStateException.java @@ -20,7 +20,12 @@ package android.renderscript; /** * Base class for all exceptions thrown by the Android * RenderScript + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. */ +@Deprecated public class RSInvalidStateException extends RSRuntimeException { public RSInvalidStateException(String string) { super(string); diff --git a/rs/java/android/renderscript/RSRuntimeException.java b/rs/java/android/renderscript/RSRuntimeException.java index b4b629e14184..d52a1c10add0 100644 --- a/rs/java/android/renderscript/RSRuntimeException.java +++ b/rs/java/android/renderscript/RSRuntimeException.java @@ -20,7 +20,12 @@ package android.renderscript; /** * Base class for all exceptions thrown by the Android * RenderScript + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. */ +@Deprecated public class RSRuntimeException extends java.lang.RuntimeException { public RSRuntimeException(String string) { diff --git a/rs/java/android/renderscript/RSSurfaceView.java b/rs/java/android/renderscript/RSSurfaceView.java index 6bdde387b334..05c0112f1bb7 100644 --- a/rs/java/android/renderscript/RSSurfaceView.java +++ b/rs/java/android/renderscript/RSSurfaceView.java @@ -33,6 +33,7 @@ import android.view.SurfaceView; * <a href="{@docRoot}guide/topics/renderscript/index.html">RenderScript</a> developer guide.</p> * </div> */ +@Deprecated public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback { private SurfaceHolder mSurfaceHolder; private RenderScriptGL mRS; diff --git a/rs/java/android/renderscript/RSTextureView.java b/rs/java/android/renderscript/RSTextureView.java index af3258a7090d..ed68fc39ddce 100644 --- a/rs/java/android/renderscript/RSTextureView.java +++ b/rs/java/android/renderscript/RSTextureView.java @@ -28,6 +28,7 @@ import android.view.TextureView; * to draw on. * */ +@Deprecated public class RSTextureView extends TextureView implements TextureView.SurfaceTextureListener { private RenderScriptGL mRS; private SurfaceTexture mSurfaceTexture; diff --git a/rs/java/android/renderscript/RenderScript.java b/rs/java/android/renderscript/RenderScript.java index 806a25a748e2..855cfdcbdf7b 100644 --- a/rs/java/android/renderscript/RenderScript.java +++ b/rs/java/android/renderscript/RenderScript.java @@ -44,7 +44,12 @@ import java.util.concurrent.locks.ReentrantReadWriteLock; * <p>For more information about creating an application that uses RenderScript, read the * <a href="{@docRoot}guide/topics/renderscript/index.html">RenderScript</a> developer guide.</p> * </div> + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public class RenderScript { static final long TRACE_TAG = Trace.TRACE_TAG_RS; diff --git a/rs/java/android/renderscript/RenderScriptCacheDir.java b/rs/java/android/renderscript/RenderScriptCacheDir.java index 862d032d6987..cd6e8b14a793 100644 --- a/rs/java/android/renderscript/RenderScriptCacheDir.java +++ b/rs/java/android/renderscript/RenderScriptCacheDir.java @@ -23,7 +23,11 @@ import java.io.File; /** * Used only for tracking the RenderScript cache directory. * @hide + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. */ +@Deprecated public class RenderScriptCacheDir { /** * Sets the directory to use as a persistent storage for the diff --git a/rs/java/android/renderscript/RenderScriptGL.java b/rs/java/android/renderscript/RenderScriptGL.java index dafaf367364d..d46dbf68291b 100644 --- a/rs/java/android/renderscript/RenderScriptGL.java +++ b/rs/java/android/renderscript/RenderScriptGL.java @@ -37,6 +37,7 @@ import android.view.SurfaceHolder; * <a href="{@docRoot}guide/topics/renderscript/index.html">RenderScript</a> developer guide.</p> * </div> **/ +@Deprecated public class RenderScriptGL extends RenderScript { int mWidth; int mHeight; diff --git a/rs/java/android/renderscript/Sampler.java b/rs/java/android/renderscript/Sampler.java index 70e88bc51f79..06f036db3aa5 100644 --- a/rs/java/android/renderscript/Sampler.java +++ b/rs/java/android/renderscript/Sampler.java @@ -25,7 +25,12 @@ package android.renderscript; * android.renderscript.Allocation#USAGE_GRAPHICS_TEXTURE}; using a Sampler on * an {@link android.renderscript.Allocation} that was not created with {@link * android.renderscript.Allocation#USAGE_GRAPHICS_TEXTURE} is undefined. + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public class Sampler extends BaseObj { public enum Value { NEAREST (0), diff --git a/rs/java/android/renderscript/Script.java b/rs/java/android/renderscript/Script.java index d1d3a7642382..f32a2f7ef482 100644 --- a/rs/java/android/renderscript/Script.java +++ b/rs/java/android/renderscript/Script.java @@ -22,7 +22,12 @@ import android.util.SparseArray; /** * The parent class for all executable scripts. This should not be used by * applications. + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public class Script extends BaseObj { /** diff --git a/rs/java/android/renderscript/ScriptC.java b/rs/java/android/renderscript/ScriptC.java index 00ebe5756589..1866a9983495 100644 --- a/rs/java/android/renderscript/ScriptC.java +++ b/rs/java/android/renderscript/ScriptC.java @@ -25,7 +25,12 @@ import java.io.InputStream; /** * The superclass for all user-defined scripts. This is only * intended to be used by the generated derived classes. + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public class ScriptC extends Script { private static final String TAG = "ScriptC"; diff --git a/rs/java/android/renderscript/ScriptGroup.java b/rs/java/android/renderscript/ScriptGroup.java index e0bdbfcdfed5..5cdb9cf3b8be 100644 --- a/rs/java/android/renderscript/ScriptGroup.java +++ b/rs/java/android/renderscript/ScriptGroup.java @@ -37,7 +37,12 @@ import java.util.Map; * Grouping kernels together allows for more efficient execution. For example, * runtime and compiler optimization can be applied to reduce computation and * communication overhead, and to make better use of the CPU and the GPU. + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public final class ScriptGroup extends BaseObj { private static final String TAG = "ScriptGroup"; IO mOutputs[]; diff --git a/rs/java/android/renderscript/ScriptIntrinsic.java b/rs/java/android/renderscript/ScriptIntrinsic.java index 61211a25f8af..8d654221b4a8 100644 --- a/rs/java/android/renderscript/ScriptIntrinsic.java +++ b/rs/java/android/renderscript/ScriptIntrinsic.java @@ -23,7 +23,12 @@ package android.renderscript; * operations. * * Not intended for direct use. + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public abstract class ScriptIntrinsic extends Script { ScriptIntrinsic(long id, RenderScript rs) { super(id, rs); diff --git a/rs/java/android/renderscript/ScriptIntrinsic3DLUT.java b/rs/java/android/renderscript/ScriptIntrinsic3DLUT.java index ce149d9a103a..7a2847e3bfcc 100644 --- a/rs/java/android/renderscript/ScriptIntrinsic3DLUT.java +++ b/rs/java/android/renderscript/ScriptIntrinsic3DLUT.java @@ -23,7 +23,11 @@ package android.renderscript; * allocation. The 8 nearest values are sampled and linearly interpolated. The * result is placed in the output. * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public final class ScriptIntrinsic3DLUT extends ScriptIntrinsic { private Allocation mLUT; private Element mElement; diff --git a/rs/java/android/renderscript/ScriptIntrinsicBLAS.java b/rs/java/android/renderscript/ScriptIntrinsicBLAS.java index 49a71b430ac6..16cc79930b76 100644 --- a/rs/java/android/renderscript/ScriptIntrinsicBLAS.java +++ b/rs/java/android/renderscript/ScriptIntrinsicBLAS.java @@ -29,7 +29,11 @@ import java.lang.annotation.RetentionPolicy; * * For detailed description of BLAS, please refer to http://www.netlib.org/blas/ * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public final class ScriptIntrinsicBLAS extends ScriptIntrinsic { private Allocation mLUT; diff --git a/rs/java/android/renderscript/ScriptIntrinsicBlend.java b/rs/java/android/renderscript/ScriptIntrinsicBlend.java index fdcd61b04eca..a1c79ef938c4 100644 --- a/rs/java/android/renderscript/ScriptIntrinsicBlend.java +++ b/rs/java/android/renderscript/ScriptIntrinsicBlend.java @@ -19,7 +19,12 @@ package android.renderscript; /** * Intrinsic kernels for blending two {@link android.renderscript.Allocation} objects. + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public class ScriptIntrinsicBlend extends ScriptIntrinsic { ScriptIntrinsicBlend(long id, RenderScript rs) { super(id, rs); diff --git a/rs/java/android/renderscript/ScriptIntrinsicBlur.java b/rs/java/android/renderscript/ScriptIntrinsicBlur.java index 0891d5142022..68cbc3f3eaad 100644 --- a/rs/java/android/renderscript/ScriptIntrinsicBlur.java +++ b/rs/java/android/renderscript/ScriptIntrinsicBlur.java @@ -20,8 +20,11 @@ package android.renderscript; * Intrinsic Gausian blur filter. Applies a gaussian blur of the * specified radius to all elements of an allocation. * - * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public final class ScriptIntrinsicBlur extends ScriptIntrinsic { private final float[] mValues = new float[9]; private Allocation mInput; diff --git a/rs/java/android/renderscript/ScriptIntrinsicColorMatrix.java b/rs/java/android/renderscript/ScriptIntrinsicColorMatrix.java index e8a299c28c51..4a05cf54e13f 100644 --- a/rs/java/android/renderscript/ScriptIntrinsicColorMatrix.java +++ b/rs/java/android/renderscript/ScriptIntrinsicColorMatrix.java @@ -36,7 +36,12 @@ package android.renderscript; * Element#U8_2}, {@link Element#U8_3}, {@link Element#U8_4}, * {@link Element#F32}, {@link Element#F32_2}, {@link * Element#F32_3}, and {@link Element#F32_4}. + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public final class ScriptIntrinsicColorMatrix extends ScriptIntrinsic { private final Matrix4f mMatrix = new Matrix4f(); private final Float4 mAdd = new Float4(); diff --git a/rs/java/android/renderscript/ScriptIntrinsicConvolve3x3.java b/rs/java/android/renderscript/ScriptIntrinsicConvolve3x3.java index 9fe7b2d8f0ef..4b9dff18f62e 100644 --- a/rs/java/android/renderscript/ScriptIntrinsicConvolve3x3.java +++ b/rs/java/android/renderscript/ScriptIntrinsicConvolve3x3.java @@ -19,7 +19,11 @@ package android.renderscript; /** * Intrinsic for applying a 3x3 convolve to an allocation. * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public final class ScriptIntrinsicConvolve3x3 extends ScriptIntrinsic { private final float[] mValues = new float[9]; private Allocation mInput; diff --git a/rs/java/android/renderscript/ScriptIntrinsicConvolve5x5.java b/rs/java/android/renderscript/ScriptIntrinsicConvolve5x5.java index 8518bb27379d..ed93c7eda0a8 100644 --- a/rs/java/android/renderscript/ScriptIntrinsicConvolve5x5.java +++ b/rs/java/android/renderscript/ScriptIntrinsicConvolve5x5.java @@ -19,7 +19,11 @@ package android.renderscript; /** * Intrinsic for applying a 5x5 convolve to an allocation. * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public final class ScriptIntrinsicConvolve5x5 extends ScriptIntrinsic { private final float[] mValues = new float[25]; private Allocation mInput; diff --git a/rs/java/android/renderscript/ScriptIntrinsicHistogram.java b/rs/java/android/renderscript/ScriptIntrinsicHistogram.java index 0e8b36c11952..4a71bc8c41ca 100644 --- a/rs/java/android/renderscript/ScriptIntrinsicHistogram.java +++ b/rs/java/android/renderscript/ScriptIntrinsicHistogram.java @@ -19,8 +19,11 @@ package android.renderscript; /** * Intrinsic Histogram filter. * - * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public final class ScriptIntrinsicHistogram extends ScriptIntrinsic { private Allocation mOut; diff --git a/rs/java/android/renderscript/ScriptIntrinsicLUT.java b/rs/java/android/renderscript/ScriptIntrinsicLUT.java index e90462d11124..7d5b09fb41aa 100644 --- a/rs/java/android/renderscript/ScriptIntrinsicLUT.java +++ b/rs/java/android/renderscript/ScriptIntrinsicLUT.java @@ -21,7 +21,12 @@ package android.renderscript; * channel of the input has an independant lookup table. The * tables are 256 entries in size and can cover the full value * range of {@link Element#U8_4}. + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public final class ScriptIntrinsicLUT extends ScriptIntrinsic { private final Matrix4f mMatrix = new Matrix4f(); private Allocation mTables; diff --git a/rs/java/android/renderscript/ScriptIntrinsicResize.java b/rs/java/android/renderscript/ScriptIntrinsicResize.java index 45b0a646b924..a87fe95e2225 100644 --- a/rs/java/android/renderscript/ScriptIntrinsicResize.java +++ b/rs/java/android/renderscript/ScriptIntrinsicResize.java @@ -18,7 +18,12 @@ package android.renderscript; /** * Intrinsic for performing a resize of a 2D allocation. + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. */ +@Deprecated public final class ScriptIntrinsicResize extends ScriptIntrinsic { private Allocation mInput; diff --git a/rs/java/android/renderscript/ScriptIntrinsicYuvToRGB.java b/rs/java/android/renderscript/ScriptIntrinsicYuvToRGB.java index e64c91103c8f..a94f9167d953 100644 --- a/rs/java/android/renderscript/ScriptIntrinsicYuvToRGB.java +++ b/rs/java/android/renderscript/ScriptIntrinsicYuvToRGB.java @@ -23,7 +23,12 @@ package android.renderscript; * The input allocation should be supplied in a supported YUV format * as a YUV element Allocation. The output is RGBA; the alpha channel * will be set to 255. + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. */ +@Deprecated public final class ScriptIntrinsicYuvToRGB extends ScriptIntrinsic { private Allocation mInput; diff --git a/rs/java/android/renderscript/Short2.java b/rs/java/android/renderscript/Short2.java index 24809f739159..4565eb4c11d4 100644 --- a/rs/java/android/renderscript/Short2.java +++ b/rs/java/android/renderscript/Short2.java @@ -22,7 +22,12 @@ package android.renderscript; * * Vector version of the basic short type. * Provides two short fields packed. + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. */ +@Deprecated public class Short2 { public short x; public short y; diff --git a/rs/java/android/renderscript/Short3.java b/rs/java/android/renderscript/Short3.java index 661db0a89f3d..3d70f078e483 100644 --- a/rs/java/android/renderscript/Short3.java +++ b/rs/java/android/renderscript/Short3.java @@ -19,7 +19,12 @@ package android.renderscript; /** * Vector version of the basic short type. * Provides three short fields packed. + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. */ +@Deprecated public class Short3 { public short x; public short y; diff --git a/rs/java/android/renderscript/Short4.java b/rs/java/android/renderscript/Short4.java index a2d74f2ccf94..c90d64876e32 100644 --- a/rs/java/android/renderscript/Short4.java +++ b/rs/java/android/renderscript/Short4.java @@ -19,7 +19,12 @@ package android.renderscript; /** * Vector version of the basic short type. * Provides four short fields packed. + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. */ +@Deprecated public class Short4 { public short x; public short y; diff --git a/rs/java/android/renderscript/Type.java b/rs/java/android/renderscript/Type.java index dc2378596d00..021fd06b3535 100644 --- a/rs/java/android/renderscript/Type.java +++ b/rs/java/android/renderscript/Type.java @@ -42,7 +42,12 @@ package android.renderscript; * <p>For more information about creating an application that uses RenderScript, read the * <a href="{@docRoot}guide/topics/renderscript/index.html">RenderScript</a> developer guide.</p> * </div> + * + * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a + * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration + * guide</a> for the proposed alternatives. **/ +@Deprecated public class Type extends BaseObj { int mDimX; int mDimY; diff --git a/rs/jni/Android.mk b/rs/jni/Android.mk index e41073bcdb76..0caba421dca8 100644 --- a/rs/jni/Android.mk +++ b/rs/jni/Android.mk @@ -25,7 +25,7 @@ LOCAL_C_INCLUDES += \ frameworks/rs LOCAL_CFLAGS += -Wno-unused-parameter -LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code -Wno-deprecated-declarations LOCAL_MODULE:= librs_jni LOCAL_LICENSE_KINDS:= SPDX-license-identifier-Apache-2.0 diff --git a/services/api/Android.bp b/services/api/Android.bp index e69de29bb2d1..b8ca5488c5cd 100644 --- a/services/api/Android.bp +++ b/services/api/Android.bp @@ -0,0 +1,29 @@ +// Copyright (C) 2021 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 { + default_visibility: ["//visibility:private"], +} + +filegroup { + name: "non-updatable-system-server-current.txt", + srcs: ["non-updatable-current.txt"], + visibility: ["//frameworks/base/api"], +} + +filegroup { + name: "non-updatable-system-server-removed.txt", + srcs: ["non-updatable-removed.txt"], + visibility: ["//frameworks/base/api"], +}
\ No newline at end of file diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index 07b473caa9cc..78853c777254 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -175,6 +175,7 @@ import android.os.SystemProperties; import android.os.UserHandle; import android.os.UserManager; import android.provider.Settings; +import android.sysprop.NetworkProperties; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.ArrayMap; @@ -189,7 +190,6 @@ import com.android.connectivity.aidl.INetworkAgent; import com.android.internal.R; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; -import com.android.internal.app.IBatteryStats; import com.android.internal.util.AsyncChannel; import com.android.internal.util.IndentingPrintWriter; import com.android.internal.util.LocationPermissionChecker; @@ -201,7 +201,6 @@ import com.android.net.module.util.LinkPropertiesUtils.CompareOrUpdateResult; import com.android.net.module.util.LinkPropertiesUtils.CompareResult; import com.android.net.module.util.NetworkCapabilitiesUtils; import com.android.net.module.util.PermissionUtils; -import com.android.server.am.BatteryStatsService; import com.android.server.connectivity.AutodestructReference; import com.android.server.connectivity.DnsManager; import com.android.server.connectivity.DnsManager.PrivateDnsValidationUpdate; @@ -217,7 +216,6 @@ import com.android.server.connectivity.PermissionMonitor; import com.android.server.connectivity.ProxyTracker; import com.android.server.connectivity.QosCallbackTracker; import com.android.server.net.NetworkPolicyManagerInternal; -import com.android.server.utils.PriorityDump; import libcore.io.IoUtils; @@ -884,27 +882,59 @@ public class ConnectivityService extends IConnectivityManager.Stub } private final LegacyTypeTracker mLegacyTypeTracker = new LegacyTypeTracker(this); + final LocalPriorityDump mPriorityDumper = new LocalPriorityDump(); /** * Helper class which parses out priority arguments and dumps sections according to their * priority. If priority arguments are omitted, function calls the legacy dump command. */ - private final PriorityDump.PriorityDumper mPriorityDumper = new PriorityDump.PriorityDumper() { - @Override - public void dumpHigh(FileDescriptor fd, PrintWriter pw, String[] args, boolean asProto) { - doDump(fd, pw, new String[] {DIAG_ARG}, asProto); - doDump(fd, pw, new String[] {SHORT_ARG}, asProto); + private class LocalPriorityDump { + private static final String PRIORITY_ARG = "--dump-priority"; + private static final String PRIORITY_ARG_HIGH = "HIGH"; + private static final String PRIORITY_ARG_NORMAL = "NORMAL"; + + LocalPriorityDump() {} + + private void dumpHigh(FileDescriptor fd, PrintWriter pw) { + doDump(fd, pw, new String[] {DIAG_ARG}); + doDump(fd, pw, new String[] {SHORT_ARG}); } - @Override - public void dumpNormal(FileDescriptor fd, PrintWriter pw, String[] args, boolean asProto) { - doDump(fd, pw, args, asProto); + private void dumpNormal(FileDescriptor fd, PrintWriter pw, String[] args) { + doDump(fd, pw, args); } - @Override - public void dump(FileDescriptor fd, PrintWriter pw, String[] args, boolean asProto) { - doDump(fd, pw, args, asProto); + public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { + if (args == null) { + dumpNormal(fd, pw, args); + return; + } + + String priority = null; + for (int argIndex = 0; argIndex < args.length; argIndex++) { + if (args[argIndex].equals(PRIORITY_ARG) && argIndex + 1 < args.length) { + argIndex++; + priority = args[argIndex]; + } + } + + if (PRIORITY_ARG_HIGH.equals(priority)) { + dumpHigh(fd, pw); + } else if (PRIORITY_ARG_NORMAL.equals(priority)) { + dumpNormal(fd, pw, args); + } else { + // ConnectivityService publishes binder service using publishBinderService() with + // no priority assigned will be treated as NORMAL priority. Dumpsys does not send + // "--dump-priority" arguments to the service. Thus, dump both NORMAL and HIGH to + // align the legacy design. + // TODO: Integrate into signal dump. + dumpNormal(fd, pw, args); + pw.println(); + pw.println("DUMP OF SERVICE HIGH connectivity"); + pw.println(); + dumpHigh(fd, pw); + } } - }; + } /** * Keeps track of the number of requests made under different uids. @@ -1035,19 +1065,19 @@ public class ConnectivityService extends IConnectivityManager.Stub return new MultinetworkPolicyTracker(c, h, r); } - public IBatteryStats getBatteryStatsService() { - return BatteryStatsService.getService(); - } - /** * @see BatteryStatsManager */ public void reportNetworkInterfaceForTransports(Context context, String iface, int[] transportTypes) { - final BatteryStatsManager batteryStats = + final BatteryStatsManager batteryStats = context.getSystemService(BatteryStatsManager.class); batteryStats.reportNetworkInterfaceForTransports(iface, transportTypes); } + + public boolean getCellular464XlatEnabled() { + return NetworkProperties.isCellular464XlatEnabled().orElse(true); + } } public ConnectivityService(Context context) { @@ -1246,8 +1276,7 @@ public class ConnectivityService extends IConnectivityManager.Stub new NetworkInfo(TYPE_NONE, 0, "", ""), new LinkProperties(), new NetworkCapabilities(), 0, mContext, null, new NetworkAgentConfig(), this, null, - null, 0, INVALID_UID, - mQosCallbackTracker); + null, 0, INVALID_UID, mQosCallbackTracker, mDeps); } private static NetworkCapabilities createDefaultNetworkCapabilitiesForUid(int uid) { @@ -1489,11 +1518,11 @@ public class ConnectivityService extends IConnectivityManager.Stub // but only exists if an app asks about them or requests them. Ensure the requesting app // gets the type it asks for. filtered.setType(type); - final DetailedState state = isNetworkWithCapabilitiesBlocked(nc, uid, ignoreBlocked) - ? DetailedState.BLOCKED - : filtered.getDetailedState(); - filtered.setDetailedState(getLegacyLockdownState(state), - "" /* reason */, null /* extraInfo */); + if (isNetworkWithCapabilitiesBlocked(nc, uid, ignoreBlocked)) { + filtered.setDetailedState(DetailedState.BLOCKED, null /* reason */, + null /* extraInfo */); + } + filterForLegacyLockdown(filtered); return filtered; } @@ -1569,8 +1598,8 @@ public class ConnectivityService extends IConnectivityManager.Stub final DetailedState state = isNetworkWithCapabilitiesBlocked(nc, uid, false) ? DetailedState.BLOCKED : DetailedState.DISCONNECTED; - info.setDetailedState(getLegacyLockdownState(state), - "" /* reason */, null /* extraInfo */); + info.setDetailedState(state, null /* reason */, null /* extraInfo */); + filterForLegacyLockdown(info); return info; } @@ -2364,9 +2393,7 @@ public class ConnectivityService extends IConnectivityManager.Stub mContext.enforceCallingOrSelfPermission(KeepaliveTracker.PERMISSION, "ConnectivityService"); } - // Public because it's used by mLockdownTracker. - public void sendConnectedBroadcast(NetworkInfo info) { - PermissionUtils.enforceNetworkStackPermission(mContext); + private void sendConnectedBroadcast(NetworkInfo info) { sendGeneralBroadcast(info, CONNECTIVITY_ACTION); } @@ -2603,7 +2630,7 @@ public class ConnectivityService extends IConnectivityManager.Stub @Override protected void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter writer, @Nullable String[] args) { - PriorityDump.dump(mPriorityDumper, fd, writer, args); + mPriorityDumper.dump(fd, writer, args); } private boolean checkDumpPermission(Context context, String tag, PrintWriter pw) { @@ -2618,10 +2645,9 @@ public class ConnectivityService extends IConnectivityManager.Stub } } - private void doDump(FileDescriptor fd, PrintWriter writer, String[] args, boolean asProto) { + private void doDump(FileDescriptor fd, PrintWriter writer, String[] args) { final IndentingPrintWriter pw = new IndentingPrintWriter(writer, " "); if (!checkDumpPermission(mContext, TAG, pw)) return; - if (asProto) return; if (CollectionUtils.contains(args, DIAG_ARG)) { dumpNetworkDiagnostics(pw); @@ -5012,8 +5038,8 @@ public class ConnectivityService extends IConnectivityManager.Stub // The legacy lockdown VPN always uses the default network. // If the VPN's underlying network is no longer the current default network, it means that // the default network has just switched, and the VPN is about to disconnect. - // Report that the VPN is not connected, so when the state of NetworkInfo objects - // overwritten by getLegacyLockdownState will be set to CONNECTING and not CONNECTED. + // Report that the VPN is not connected, so the state of NetworkInfo objects overwritten + // by filterForLegacyLockdown will be set to CONNECTING and not CONNECTED. final NetworkAgentInfo defaultNetwork = getDefaultNetwork(); if (defaultNetwork == null || !defaultNetwork.network.equals(underlying[0])) { return null; @@ -5022,6 +5048,9 @@ public class ConnectivityService extends IConnectivityManager.Stub return nai; }; + // TODO: move all callers to filterForLegacyLockdown and delete this method. + // This likely requires making sendLegacyNetworkBroadcast take a NetworkInfo object instead of + // just a DetailedState object. private DetailedState getLegacyLockdownState(DetailedState origState) { if (origState != DetailedState.CONNECTED) { return origState; @@ -5031,6 +5060,23 @@ public class ConnectivityService extends IConnectivityManager.Stub : DetailedState.CONNECTED; } + private void filterForLegacyLockdown(NetworkInfo ni) { + if (!mLockdownEnabled || !ni.isConnected()) return; + // The legacy lockdown VPN replaces the state of every network in CONNECTED state with the + // state of its VPN. This is to ensure that when an underlying network connects, apps will + // not see a CONNECTIVITY_ACTION broadcast for a network in state CONNECTED until the VPN + // comes up, at which point there is a new CONNECTIVITY_ACTION broadcast for the underlying + // network, this time with a state of CONNECTED. + // + // Now that the legacy lockdown code lives in ConnectivityService, and no longer has access + // to the internal state of the Vpn object, always replace the state with CONNECTING. This + // is not too far off the truth, since an always-on VPN, when not connected, is always + // trying to reconnect. + if (getLegacyLockdownNai() == null) { + ni.setDetailedState(DetailedState.CONNECTING, "", null); + } + } + @Override public void setProvisioningNotificationVisible(boolean visible, int networkType, String action) { @@ -6106,7 +6152,7 @@ public class ConnectivityService extends IConnectivityManager.Stub final NetworkAgentInfo nai = new NetworkAgentInfo(na, new Network(mNetIdManager.reserveNetId()), new NetworkInfo(networkInfo), lp, nc, currentScore, mContext, mTrackerHandler, new NetworkAgentConfig(networkAgentConfig), - this, mNetd, mDnsResolver, providerId, uid, mQosCallbackTracker); + this, mNetd, mDnsResolver, providerId, uid, mQosCallbackTracker, mDeps); // Make sure the LinkProperties and NetworkCapabilities reflect what the agent info says. processCapabilitiesFromAgent(nai, nc); @@ -7914,6 +7960,7 @@ public class ConnectivityService extends IConnectivityManager.Stub // and is still connected. NetworkInfo info = new NetworkInfo(nai.networkInfo); info.setType(type); + filterForLegacyLockdown(info); if (state != DetailedState.DISCONNECTED) { info.setDetailedState(state, null, info.getExtraInfo()); sendConnectedBroadcast(info); diff --git a/services/core/java/com/android/server/ConnectivityServiceInitializer.java b/services/core/java/com/android/server/ConnectivityServiceInitializer.java index b9922087109f..2465479aadd8 100644 --- a/services/core/java/com/android/server/ConnectivityServiceInitializer.java +++ b/services/core/java/com/android/server/ConnectivityServiceInitializer.java @@ -16,9 +16,6 @@ package com.android.server; -import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_HIGH; -import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_NORMAL; - import android.content.Context; import android.util.Log; @@ -42,6 +39,6 @@ public final class ConnectivityServiceInitializer extends SystemService { public void onStart() { Log.i(TAG, "Registering " + Context.CONNECTIVITY_SERVICE); publishBinderService(Context.CONNECTIVITY_SERVICE, mConnectivity, - /* allowIsolated= */ false, DUMP_FLAG_PRIORITY_HIGH | DUMP_FLAG_PRIORITY_NORMAL); + /* allowIsolated= */ false); } } diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java index 27b648e53a38..740a1c16a486 100644 --- a/services/core/java/com/android/server/StorageManagerService.java +++ b/services/core/java/com/android/server/StorageManagerService.java @@ -4553,6 +4553,13 @@ class StorageManagerService extends IStorageManager.Stub private final List<StorageManagerInternal.ResetListener> mResetListeners = new ArrayList<>(); + @Override + public boolean isFuseMounted(int userId) { + synchronized (mLock) { + return mFuseMountedUser.contains(userId); + } + } + /** * Check if fuse is running in target user, if it's running then setup its storage dirs. * Return true if storage dirs are mounted. diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java index f768db1d0821..68c4a7336745 100644 --- a/services/core/java/com/android/server/am/ActiveServices.java +++ b/services/core/java/com/android/server/am/ActiveServices.java @@ -20,7 +20,6 @@ import static android.Manifest.permission.START_ACTIVITIES_FROM_BACKGROUND; import static android.Manifest.permission.START_FOREGROUND_SERVICES_FROM_BACKGROUND; import static android.Manifest.permission.SYSTEM_ALERT_WINDOW; import static android.app.ActivityManager.PROCESS_STATE_HEAVY_WEIGHT; -import static android.app.ActivityManager.PROCESS_STATE_PERSISTENT; import static android.app.ActivityManager.PROCESS_STATE_RECEIVER; import static android.app.ActivityManager.PROCESS_STATE_TOP; import static android.content.pm.PackageManager.PERMISSION_GRANTED; @@ -75,7 +74,6 @@ import android.app.ActivityManagerInternal; import android.app.ActivityThread; import android.app.AppGlobals; import android.app.AppOpsManager; -import android.app.BroadcastOptions; import android.app.ForegroundServiceStartNotAllowedException; import android.app.IApplicationThread; import android.app.IServiceConnection; @@ -1217,7 +1215,18 @@ public final class ActiveServices { void killMisbehavingService(ServiceRecord r, int appUid, int appPid, String localPackageName) { synchronized (mAm) { - stopServiceLocked(r, false); + if (!r.destroying) { + // This service is still alive, stop it. + stopServiceLocked(r, false); + } else { + // Check if there is another instance of it being started in parallel, + // if so, stop that too to avoid spamming the system. + final ServiceMap smap = getServiceMapLocked(r.userId); + final ServiceRecord found = smap.mServicesByInstanceName.remove(r.instanceName); + if (found != null) { + stopServiceLocked(found, false); + } + } mAm.crashApplication(appUid, appPid, localPackageName, -1, "Bad notification for startForeground", true /*force*/); } diff --git a/services/core/java/com/android/server/am/ProcessList.java b/services/core/java/com/android/server/am/ProcessList.java index 38330fe770fb..ed8d696f98c4 100644 --- a/services/core/java/com/android/server/am/ProcessList.java +++ b/services/core/java/com/android/server/am/ProcessList.java @@ -2315,11 +2315,12 @@ public final class ProcessList { StorageManagerInternal storageManagerInternal = LocalServices.getService( StorageManagerInternal.class); if (needsStorageDataIsolation(storageManagerInternal, app)) { - bindMountAppStorageDirs = true; - if (pkgDataInfoMap == null || - !storageManagerInternal.prepareStorageDirs(userId, pkgDataInfoMap.keySet(), - app.processName)) { - // Cannot prepare Android/app and Android/obb directory or inode == 0, + // We will run prepareStorageDirs() after we trigger zygote fork, so it won't + // slow down app starting speed as those dirs might not be cached. + if (pkgDataInfoMap != null && storageManagerInternal.isFuseMounted(userId)) { + bindMountAppStorageDirs = true; + } else { + // Fuse is not mounted or inode == 0, // so we won't mount it in zygote, but resume the mount after unlocking device. app.setBindMountPending(true); bindMountAppStorageDirs = false; @@ -2367,6 +2368,13 @@ public final class ProcessList { allowlistedAppDataInfoMap, bindMountAppsData, bindMountAppStorageDirs, new String[]{PROC_START_SEQ_IDENT + app.getStartSeq()}); } + // This runs after Process.start() as this method may block app process starting time + // if dir is not cached. Running this method after Process.start() can make it + // cache the dir asynchronously, so zygote can use it without waiting for it. + if (bindMountAppStorageDirs) { + storageManagerInternal.prepareStorageDirs(userId, pkgDataInfoMap.keySet(), + app.processName); + } checkSlow(startTime, "startProcess: returned from zygote!"); return startResult; } finally { diff --git a/services/core/java/com/android/server/biometrics/AuthService.java b/services/core/java/com/android/server/biometrics/AuthService.java index 050b28b363d2..285f3185abc2 100644 --- a/services/core/java/com/android/server/biometrics/AuthService.java +++ b/services/core/java/com/android/server/biometrics/AuthService.java @@ -406,26 +406,49 @@ public class AuthService extends SystemService { mBiometricService.getCurrentModality( opPackageName, userId, callingUserId, authenticators); + final boolean isCredentialAllowed = Utils.isCredentialRequested(authenticators); + final String result; switch (getCredentialBackupModality(modality)) { case BiometricAuthenticator.TYPE_NONE: result = null; break; + case BiometricAuthenticator.TYPE_CREDENTIAL: result = getContext().getString( R.string.screen_lock_dialog_default_subtitle); break; + case BiometricAuthenticator.TYPE_FINGERPRINT: - result = getContext().getString( - R.string.fingerprint_dialog_default_subtitle); + if (isCredentialAllowed) { + result = getContext().getString( + R.string.fingerprint_or_screen_lock_dialog_default_subtitle); + } else { + result = getContext().getString( + R.string.fingerprint_dialog_default_subtitle); + } break; + case BiometricAuthenticator.TYPE_FACE: - result = getContext().getString(R.string.face_dialog_default_subtitle); + if (isCredentialAllowed) { + result = getContext().getString( + R.string.face_or_screen_lock_dialog_default_subtitle); + } else { + result = getContext().getString(R.string.face_dialog_default_subtitle); + } break; + default: - result = getContext().getString(R.string.biometric_dialog_default_subtitle); + if (isCredentialAllowed) { + result = getContext().getString( + R.string.biometric_or_screen_lock_dialog_default_subtitle); + } else { + result = getContext().getString( + R.string.biometric_dialog_default_subtitle); + } break; } + return result; } finally { Binder.restoreCallingIdentity(identity); diff --git a/services/core/java/com/android/server/clipboard/ClipboardService.java b/services/core/java/com/android/server/clipboard/ClipboardService.java index 5020917f8eb1..e0d1375b4069 100644 --- a/services/core/java/com/android/server/clipboard/ClipboardService.java +++ b/services/core/java/com/android/server/clipboard/ClipboardService.java @@ -57,6 +57,7 @@ import android.provider.Settings; import android.text.TextUtils; import android.util.Slog; import android.util.SparseArray; +import android.util.SparseBooleanArray; import android.view.autofill.AutofillManagerInternal; import android.widget.Toast; @@ -274,6 +275,9 @@ public class ClipboardService extends SystemService { /** Package of the app that set {@link #primaryClip}. */ String mPrimaryClipPackage; + /** Uids that have already triggered a toast notification for {@link #primaryClip} */ + final SparseBooleanArray mNotifiedUids = new SparseBooleanArray(); + final HashSet<String> activePermissionOwners = new HashSet<String>(); @@ -649,6 +653,7 @@ public class ClipboardService extends SystemService { return; } clipboard.primaryClip = clip; + clipboard.mNotifiedUids.clear(); if (clip != null) { clipboard.primaryClipUid = uid; clipboard.mPrimaryClipPackage = sourcePackage; @@ -939,6 +944,11 @@ public class ClipboardService extends SystemService { && mAutofillInternal.isAugmentedAutofillServiceForUser(uid, userId)) { return; } + // Don't notify if already notified for this uid and clip. + if (clipboard.mNotifiedUids.get(uid)) { + return; + } + clipboard.mNotifiedUids.put(uid, true); // Retrieve the app label of the source of the clip data CharSequence sourceAppLabel = null; diff --git a/services/core/java/com/android/server/connectivity/Nat464Xlat.java b/services/core/java/com/android/server/connectivity/Nat464Xlat.java index fa80b25f9026..c66a280f2b02 100644 --- a/services/core/java/com/android/server/connectivity/Nat464Xlat.java +++ b/services/core/java/com/android/server/connectivity/Nat464Xlat.java @@ -16,6 +16,8 @@ package com.android.server.connectivity; +import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR; + import static com.android.net.module.util.CollectionUtils.contains; import android.annotation.NonNull; @@ -35,6 +37,7 @@ import android.util.Log; import com.android.internal.annotations.VisibleForTesting; import com.android.net.module.util.NetworkStackConstants; +import com.android.server.ConnectivityService; import java.net.Inet6Address; import java.util.Objects; @@ -94,12 +97,15 @@ public class Nat464Xlat { private Inet6Address mIPv6Address; private State mState = State.IDLE; + private boolean mEnableClatOnCellular; private boolean mPrefixDiscoveryRunning; - public Nat464Xlat(NetworkAgentInfo nai, INetd netd, IDnsResolver dnsResolver) { + public Nat464Xlat(NetworkAgentInfo nai, INetd netd, IDnsResolver dnsResolver, + ConnectivityService.Dependencies deps) { mDnsResolver = dnsResolver; mNetd = netd; mNetwork = nai; + mEnableClatOnCellular = deps.getCellular464XlatEnabled(); } /** @@ -111,7 +117,7 @@ public class Nat464Xlat { * @return true if the network requires clat, false otherwise. */ @VisibleForTesting - protected static boolean requiresClat(NetworkAgentInfo nai) { + protected boolean requiresClat(NetworkAgentInfo nai) { // TODO: migrate to NetworkCapabilities.TRANSPORT_*. final boolean supported = contains(NETWORK_TYPES, nai.networkInfo.getType()); final boolean connected = contains(NETWORK_STATES, nai.networkInfo.getState()); @@ -126,7 +132,9 @@ public class Nat464Xlat { final boolean skip464xlat = (nai.netAgentConfig() != null) && nai.netAgentConfig().skip464xlat; - return supported && connected && isIpv6OnlyNetwork && !skip464xlat; + return supported && connected && isIpv6OnlyNetwork && !skip464xlat + && (nai.networkCapabilities.hasTransport(TRANSPORT_CELLULAR) + ? isCellular464XlatEnabled() : true); } /** @@ -137,7 +145,7 @@ public class Nat464Xlat { * @return true if the network should start clat, false otherwise. */ @VisibleForTesting - protected static boolean shouldStartClat(NetworkAgentInfo nai) { + protected boolean shouldStartClat(NetworkAgentInfo nai) { LinkProperties lp = nai.linkProperties; return requiresClat(nai) && lp != null && lp.getNat64Prefix() != null; } @@ -507,4 +515,9 @@ public class Nat464Xlat { protected int getNetId() { return mNetwork.network.getNetId(); } + + @VisibleForTesting + protected boolean isCellular464XlatEnabled() { + return mEnableClatOnCellular; + } } diff --git a/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java b/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java index 1d0e11569c80..803cc9d31c35 100644 --- a/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java +++ b/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java @@ -341,7 +341,7 @@ public class NetworkAgentInfo implements Comparable<NetworkAgentInfo> { @NonNull LinkProperties lp, @NonNull NetworkCapabilities nc, int score, Context context, Handler handler, NetworkAgentConfig config, ConnectivityService connService, INetd netd, IDnsResolver dnsResolver, int factorySerialNumber, int creatorUid, - QosCallbackTracker qosCallbackTracker) { + QosCallbackTracker qosCallbackTracker, ConnectivityService.Dependencies deps) { Objects.requireNonNull(net); Objects.requireNonNull(info); Objects.requireNonNull(lp); @@ -355,7 +355,7 @@ public class NetworkAgentInfo implements Comparable<NetworkAgentInfo> { linkProperties = lp; networkCapabilities = nc; mScore = score; - clatd = new Nat464Xlat(this, netd, dnsResolver); + clatd = new Nat464Xlat(this, netd, dnsResolver, deps); mConnService = connService; mContext = context; mHandler = handler; diff --git a/services/core/java/com/android/server/hdmi/SystemAudioAutoInitiationAction.java b/services/core/java/com/android/server/hdmi/SystemAudioAutoInitiationAction.java index f7e871d0b645..56e538b1abfa 100644 --- a/services/core/java/com/android/server/hdmi/SystemAudioAutoInitiationAction.java +++ b/services/core/java/com/android/server/hdmi/SystemAudioAutoInitiationAction.java @@ -17,6 +17,8 @@ package com.android.server.hdmi; import android.hardware.tv.cec.V1_0.SendMessageResult; + +import com.android.internal.annotations.VisibleForTesting; import com.android.server.hdmi.HdmiControlService.SendMessageCallback; /** @@ -30,6 +32,14 @@ final class SystemAudioAutoInitiationAction extends HdmiCecFeatureAction { // <Give System Audio Mode Status> to AV Receiver. private static final int STATE_WAITING_FOR_SYSTEM_AUDIO_MODE_STATUS = 1; + @VisibleForTesting + static final int RETRIES_ON_TIMEOUT = 1; + + // On some audio devices the <System Audio Mode Status> message can be delayed as the device + // is just waking up. Retry the <Give System Audio Mode Status> message to ensure we properly + // initialize system audio. + private int mRetriesOnTimeOut = RETRIES_ON_TIMEOUT; + SystemAudioAutoInitiationAction(HdmiCecLocalDevice source, int avrAddress) { super(source); mAvrAddress = avrAddress; @@ -100,6 +110,13 @@ final class SystemAudioAutoInitiationAction extends HdmiCecFeatureAction { switch (mState) { case STATE_WAITING_FOR_SYSTEM_AUDIO_MODE_STATUS: + if (mRetriesOnTimeOut > 0) { + mRetriesOnTimeOut--; + addTimer(mState, HdmiConfig.TIMEOUT_MS); + sendGiveSystemAudioModeStatus(); + return; + } + handleSystemAudioModeStatusTimeout(); break; } diff --git a/services/core/java/com/android/server/input/InputManagerService.java b/services/core/java/com/android/server/input/InputManagerService.java index edb5d97f1a5a..7dc9a0b2a364 100644 --- a/services/core/java/com/android/server/input/InputManagerService.java +++ b/services/core/java/com/android/server/input/InputManagerService.java @@ -586,18 +586,13 @@ public class InputManagerService extends IInputManager.Stub private void setDisplayViewportsInternal(List<DisplayViewport> viewports) { final DisplayViewport[] vArray = new DisplayViewport[viewports.size()]; if (ENABLE_PER_WINDOW_INPUT_ROTATION) { - // Remove all viewport operations. They will be built-into the window transforms. + // Remove display projection information from DisplayViewport, leaving only the + // orientation. The display projection will be built-into the window transforms. for (int i = viewports.size() - 1; i >= 0; --i) { final DisplayViewport v = vArray[i] = viewports.get(i).makeCopy(); - // deviceWidth/Height are apparently in "rotated" space, so flip them if needed. - if (v.orientation % 2 != 0) { - final int dw = v.deviceWidth; - v.deviceWidth = v.deviceHeight; - v.deviceHeight = dw; - } + // Note: the deviceWidth/Height are in rotated with the orientation. v.logicalFrame.set(0, 0, v.deviceWidth, v.deviceHeight); v.physicalFrame.set(0, 0, v.deviceWidth, v.deviceHeight); - v.orientation = 0; } } else { for (int i = viewports.size() - 1; i >= 0; --i) { diff --git a/services/core/java/com/android/server/locksettings/BiometricDeferredQueue.java b/services/core/java/com/android/server/locksettings/BiometricDeferredQueue.java index 82b0f9c05b6b..6d250ecb9fa4 100644 --- a/services/core/java/com/android/server/locksettings/BiometricDeferredQueue.java +++ b/services/core/java/com/android/server/locksettings/BiometricDeferredQueue.java @@ -135,7 +135,11 @@ public class BiometricDeferredQueue { } sensorIds.remove(sensorId); - faceManager.revokeChallenge(sensorId); + // Challenge is only required for IBiometricsFace@1.0 (and not IFace AIDL). The + // IBiometricsFace@1.0 HAL does not require userId to revokeChallenge, so passing + // in 0 is OK. + final int userId = 0; + faceManager.revokeChallenge(sensorId, userId, challenge); if (sensorIds.isEmpty()) { Slog.d(TAG, "Done requesting resetLockout for all face sensors"); diff --git a/services/core/java/com/android/server/locksettings/RebootEscrowManager.java b/services/core/java/com/android/server/locksettings/RebootEscrowManager.java index 48382a946d4b..240464a560af 100644 --- a/services/core/java/com/android/server/locksettings/RebootEscrowManager.java +++ b/services/core/java/com/android/server/locksettings/RebootEscrowManager.java @@ -251,6 +251,8 @@ class RebootEscrowManager { } if (rebootEscrowUsers.isEmpty()) { + Slog.i(TAG, "No reboot escrow data found for users," + + " skipping loading escrow data"); return; } diff --git a/services/core/java/com/android/server/locksettings/recoverablekeystore/PlatformDecryptionKey.java b/services/core/java/com/android/server/locksettings/recoverablekeystore/PlatformDecryptionKey.java index 35571f1f2728..e75aae1f99aa 100644 --- a/services/core/java/com/android/server/locksettings/recoverablekeystore/PlatformDecryptionKey.java +++ b/services/core/java/com/android/server/locksettings/recoverablekeystore/PlatformDecryptionKey.java @@ -16,7 +16,7 @@ package com.android.server.locksettings.recoverablekeystore; -import android.security.keystore.AndroidKeyStoreSecretKey; +import javax.crypto.SecretKey; /** * Used to unwrap recoverable keys before syncing them with remote storage. @@ -30,7 +30,7 @@ import android.security.keystore.AndroidKeyStoreSecretKey; public class PlatformDecryptionKey { private final int mGenerationId; - private final AndroidKeyStoreSecretKey mKey; + private final SecretKey mKey; /** * A new instance. @@ -40,7 +40,7 @@ public class PlatformDecryptionKey { * * @hide */ - public PlatformDecryptionKey(int generationId, AndroidKeyStoreSecretKey key) { + public PlatformDecryptionKey(int generationId, SecretKey key) { mGenerationId = generationId; mKey = key; } @@ -59,7 +59,7 @@ public class PlatformDecryptionKey { * * @hide */ - public AndroidKeyStoreSecretKey getKey() { + public SecretKey getKey() { return mKey; } } diff --git a/services/core/java/com/android/server/locksettings/recoverablekeystore/PlatformEncryptionKey.java b/services/core/java/com/android/server/locksettings/recoverablekeystore/PlatformEncryptionKey.java index 38f5b45ea190..ee334462f7be 100644 --- a/services/core/java/com/android/server/locksettings/recoverablekeystore/PlatformEncryptionKey.java +++ b/services/core/java/com/android/server/locksettings/recoverablekeystore/PlatformEncryptionKey.java @@ -16,7 +16,7 @@ package com.android.server.locksettings.recoverablekeystore; -import android.security.keystore.AndroidKeyStoreSecretKey; +import javax.crypto.SecretKey; /** * Private key stored in AndroidKeyStore. Used to wrap recoverable keys before writing them to disk. @@ -33,7 +33,7 @@ import android.security.keystore.AndroidKeyStoreSecretKey; public class PlatformEncryptionKey { private final int mGenerationId; - private final AndroidKeyStoreSecretKey mKey; + private final SecretKey mKey; /** * A new instance. @@ -41,7 +41,7 @@ public class PlatformEncryptionKey { * @param generationId The generation ID of the key. * @param key The secret key handle. Can be used to encrypt WITHOUT requiring screen unlock. */ - public PlatformEncryptionKey(int generationId, AndroidKeyStoreSecretKey key) { + public PlatformEncryptionKey(int generationId, SecretKey key) { mGenerationId = generationId; mKey = key; } @@ -56,7 +56,7 @@ public class PlatformEncryptionKey { /** * Returns the actual key, which can only be used to encrypt. */ - public AndroidKeyStoreSecretKey getKey() { + public SecretKey getKey() { return mKey; } } diff --git a/services/core/java/com/android/server/locksettings/recoverablekeystore/PlatformKeyManager.java b/services/core/java/com/android/server/locksettings/recoverablekeystore/PlatformKeyManager.java index f448a6ef8c0b..f32af5434c43 100644 --- a/services/core/java/com/android/server/locksettings/recoverablekeystore/PlatformKeyManager.java +++ b/services/core/java/com/android/server/locksettings/recoverablekeystore/PlatformKeyManager.java @@ -21,7 +21,6 @@ import android.content.Context; import android.os.RemoteException; import android.os.UserHandle; import android.security.GateKeeper; -import android.security.keystore.AndroidKeyStoreSecretKey; import android.security.keystore.KeyPermanentlyInvalidatedException; import android.security.keystore.KeyProperties; import android.security.keystore.KeyProtection; @@ -237,7 +236,7 @@ public class PlatformKeyManager { if (!isKeyLoaded(userId, generationId)) { throw new UnrecoverableKeyException("KeyStore doesn't contain key " + alias); } - AndroidKeyStoreSecretKey key = (AndroidKeyStoreSecretKey) mKeyStore.getKey( + SecretKey key = (SecretKey) mKeyStore.getKey( alias, /*password=*/ null); return new PlatformEncryptionKey(generationId, key); } @@ -289,7 +288,7 @@ public class PlatformKeyManager { if (!isKeyLoaded(userId, generationId)) { throw new UnrecoverableKeyException("KeyStore doesn't contain key " + alias); } - AndroidKeyStoreSecretKey key = (AndroidKeyStoreSecretKey) mKeyStore.getKey( + SecretKey key = (SecretKey) mKeyStore.getKey( alias, /*password=*/ null); return new PlatformDecryptionKey(generationId, key); } diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 50dfac88c411..ff87f1c4b4ca 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -1979,6 +1979,8 @@ public class PackageManagerService extends IPackageManager.Stub @Nullable ComponentName component, @ComponentType int componentType, int userId); boolean shouldFilterApplicationLocked(@Nullable PackageSetting ps, int callingUid, int userId); + boolean shouldFilterApplicationLocked(@NonNull SharedUserSetting sus, int callingUid, + int userId); int bestDomainVerificationStatus(int status1, int status2); int checkUidPermission(String permName, int uid); int getPackageUidInternal(String packageName, int flags, int userId, int callingUid); @@ -4143,6 +4145,19 @@ public class PackageManagerService extends IPackageManager.Stub } /** + * @see #shouldFilterApplicationLocked(PackageSetting, int, ComponentName, int, int) + */ + public boolean shouldFilterApplicationLocked(@NonNull SharedUserSetting sus, int callingUid, + int userId) { + boolean filterApp = true; + for (int index = sus.packages.size() - 1; index >= 0 && filterApp; index--) { + filterApp &= shouldFilterApplicationLocked(sus.packages.valueAt(index), + callingUid, /* component */ null, TYPE_UNKNOWN, userId); + } + return filterApp; + } + + /** * Verification statuses are ordered from the worse to the best, except for * INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER, which is the worse. */ @@ -7904,6 +7919,15 @@ public class PackageManagerService extends IPackageManager.Stub ps, callingUid, userId); } + /** + * @see #shouldFilterApplicationLocked(PackageSetting, int, ComponentName, int, int) + */ + @GuardedBy("mLock") + private boolean shouldFilterApplicationLocked(@NonNull SharedUserSetting sus, int callingUid, + int userId) { + return liveComputer().shouldFilterApplicationLocked(sus, callingUid, userId); + } + @GuardedBy("mLock") private boolean filterSharedLibPackageLPr(@Nullable PackageSetting ps, int uid, int userId, int flags) { @@ -8970,7 +8994,6 @@ public class PackageManagerService extends IPackageManager.Stub public int checkUidSignatures(int uid1, int uid2) { final int callingUid = Binder.getCallingUid(); final int callingUserId = UserHandle.getUserId(callingUid); - final boolean isCallerInstantApp = getInstantAppPackageName(callingUid) != null; // Map to base uids. final int appId1 = UserHandle.getAppId(uid1); final int appId2 = UserHandle.getAppId(uid2); @@ -8981,10 +9004,11 @@ public class PackageManagerService extends IPackageManager.Stub Object obj = mSettings.getSettingLPr(appId1); if (obj != null) { if (obj instanceof SharedUserSetting) { - if (isCallerInstantApp) { + final SharedUserSetting sus = (SharedUserSetting) obj; + if (shouldFilterApplicationLocked(sus, callingUid, callingUserId)) { return PackageManager.SIGNATURE_UNKNOWN_PACKAGE; } - p1SigningDetails = ((SharedUserSetting) obj).signatures.mSigningDetails; + p1SigningDetails = sus.signatures.mSigningDetails; } else if (obj instanceof PackageSetting) { final PackageSetting ps = (PackageSetting) obj; if (shouldFilterApplicationLocked(ps, callingUid, callingUserId)) { @@ -9000,10 +9024,11 @@ public class PackageManagerService extends IPackageManager.Stub obj = mSettings.getSettingLPr(appId2); if (obj != null) { if (obj instanceof SharedUserSetting) { - if (isCallerInstantApp) { + final SharedUserSetting sus = (SharedUserSetting) obj; + if (shouldFilterApplicationLocked(sus, callingUid, callingUserId)) { return PackageManager.SIGNATURE_UNKNOWN_PACKAGE; } - p2SigningDetails = ((SharedUserSetting) obj).signatures.mSigningDetails; + p2SigningDetails = sus.signatures.mSigningDetails; } else if (obj instanceof PackageSetting) { final PackageSetting ps = (PackageSetting) obj; if (shouldFilterApplicationLocked(ps, callingUid, callingUserId)) { @@ -9092,11 +9117,11 @@ public class PackageManagerService extends IPackageManager.Stub final Object obj = mSettings.getSettingLPr(appId); if (obj != null) { if (obj instanceof SharedUserSetting) { - final boolean isCallerInstantApp = getInstantAppPackageName(callingUid) != null; - if (isCallerInstantApp) { + final SharedUserSetting sus = (SharedUserSetting) obj; + if (shouldFilterApplicationLocked(sus, callingUid, callingUserId)) { return false; } - signingDetails = ((SharedUserSetting)obj).signatures.mSigningDetails; + signingDetails = sus.signatures.mSigningDetails; } else if (obj instanceof PackageSetting) { final PackageSetting ps = (PackageSetting) obj; if (shouldFilterApplicationLocked(ps, callingUid, callingUserId)) { @@ -9221,16 +9246,19 @@ public class PackageManagerService extends IPackageManager.Stub if (getInstantAppPackageName(callingUid) != null) { return null; } + final int callingUserId = UserHandle.getUserId(callingUid); final int appId = UserHandle.getAppId(uid); synchronized (mLock) { final Object obj = mSettings.getSettingLPr(appId); if (obj instanceof SharedUserSetting) { final SharedUserSetting sus = (SharedUserSetting) obj; + if (shouldFilterApplicationLocked(sus, callingUid, callingUserId)) { + return null; + } return sus.name + ":" + sus.userId; } else if (obj instanceof PackageSetting) { final PackageSetting ps = (PackageSetting) obj; - if (shouldFilterApplicationLocked( - ps, callingUid, UserHandle.getUserId(callingUid))) { + if (shouldFilterApplicationLocked(ps, callingUid, callingUserId)) { return null; } return ps.name; @@ -9248,6 +9276,7 @@ public class PackageManagerService extends IPackageManager.Stub if (getInstantAppPackageName(callingUid) != null) { return null; } + final int callingUserId = UserHandle.getUserId(callingUid); final String[] names = new String[uids.length]; synchronized (mLock) { for (int i = uids.length - 1; i >= 0; i--) { @@ -9255,11 +9284,14 @@ public class PackageManagerService extends IPackageManager.Stub final Object obj = mSettings.getSettingLPr(appId); if (obj instanceof SharedUserSetting) { final SharedUserSetting sus = (SharedUserSetting) obj; - names[i] = "shared:" + sus.name; + if (shouldFilterApplicationLocked(sus, callingUid, callingUserId)) { + names[i] = null; + } else { + names[i] = "shared:" + sus.name; + } } else if (obj instanceof PackageSetting) { final PackageSetting ps = (PackageSetting) obj; - if (shouldFilterApplicationLocked( - ps, callingUid, UserHandle.getUserId(callingUid))) { + if (shouldFilterApplicationLocked(ps, callingUid, callingUserId)) { names[i] = null; } else { names[i] = ps.name; @@ -9301,16 +9333,19 @@ public class PackageManagerService extends IPackageManager.Stub if (getInstantAppPackageName(callingUid) != null) { return 0; } + final int callingUserId = UserHandle.getUserId(callingUid); final int appId = UserHandle.getAppId(uid); synchronized (mLock) { final Object obj = mSettings.getSettingLPr(appId); if (obj instanceof SharedUserSetting) { final SharedUserSetting sus = (SharedUserSetting) obj; + if (shouldFilterApplicationLocked(sus, callingUid, callingUserId)) { + return 0; + } return sus.pkgFlags; } else if (obj instanceof PackageSetting) { final PackageSetting ps = (PackageSetting) obj; - if (shouldFilterApplicationLocked( - ps, callingUid, UserHandle.getUserId(callingUid))) { + if (shouldFilterApplicationLocked(ps, callingUid, callingUserId)) { return 0; } return ps.pkgFlags; @@ -9325,16 +9360,19 @@ public class PackageManagerService extends IPackageManager.Stub if (getInstantAppPackageName(callingUid) != null) { return 0; } + final int callingUserId = UserHandle.getUserId(callingUid); final int appId = UserHandle.getAppId(uid); synchronized (mLock) { final Object obj = mSettings.getSettingLPr(appId); if (obj instanceof SharedUserSetting) { final SharedUserSetting sus = (SharedUserSetting) obj; + if (shouldFilterApplicationLocked(sus, callingUid, callingUserId)) { + return 0; + } return sus.pkgPrivateFlags; } else if (obj instanceof PackageSetting) { final PackageSetting ps = (PackageSetting) obj; - if (shouldFilterApplicationLocked( - ps, callingUid, UserHandle.getUserId(callingUid))) { + if (shouldFilterApplicationLocked(ps, callingUid, callingUserId)) { return 0; } return ps.pkgPrivateFlags; diff --git a/services/core/java/com/android/server/pm/ShortcutService.java b/services/core/java/com/android/server/pm/ShortcutService.java index d1cf55de7254..38cba4ca9e20 100644 --- a/services/core/java/com/android/server/pm/ShortcutService.java +++ b/services/core/java/com/android/server/pm/ShortcutService.java @@ -1889,231 +1889,248 @@ public class ShortcutService extends IShortcutService.Stub { @Override public void setDynamicShortcuts(String packageName, ParceledListSlice shortcutInfoList, @UserIdInt int userId, @NonNull AndroidFuture callback) { - verifyCaller(packageName, userId); + try { + verifyCaller(packageName, userId); - final List<ShortcutInfo> newShortcuts = (List<ShortcutInfo>) shortcutInfoList.getList(); - verifyShortcutInfoPackages(packageName, newShortcuts); - final int size = newShortcuts.size(); + final List<ShortcutInfo> newShortcuts = (List<ShortcutInfo>) shortcutInfoList.getList(); + verifyShortcutInfoPackages(packageName, newShortcuts); + final int size = newShortcuts.size(); - final boolean unlimited = injectHasUnlimitedShortcutsApiCallsPermission( - injectBinderCallingPid(), injectBinderCallingUid()); + final boolean unlimited = injectHasUnlimitedShortcutsApiCallsPermission( + injectBinderCallingPid(), injectBinderCallingUid()); - List<ShortcutInfo> changedShortcuts = null; - List<ShortcutInfo> removedShortcuts = null; + List<ShortcutInfo> changedShortcuts = null; + List<ShortcutInfo> removedShortcuts = null; - synchronized (mLock) { - throwIfUserLockedL(userId); + synchronized (mLock) { + throwIfUserLockedL(userId); - final ShortcutPackage ps = getPackageShortcutsForPublisherLocked(packageName, userId); + final ShortcutPackage ps = getPackageShortcutsForPublisherLocked(packageName, + userId); - ps.ensureImmutableShortcutsNotIncluded(newShortcuts, /*ignoreInvisible=*/ true); - ps.ensureNoBitmapIconIfShortcutIsLongLived(newShortcuts); + ps.ensureImmutableShortcutsNotIncluded(newShortcuts, /*ignoreInvisible=*/ true); + ps.ensureNoBitmapIconIfShortcutIsLongLived(newShortcuts); - fillInDefaultActivity(newShortcuts); + fillInDefaultActivity(newShortcuts); - ps.enforceShortcutCountsBeforeOperation(newShortcuts, OPERATION_SET); + ps.enforceShortcutCountsBeforeOperation(newShortcuts, OPERATION_SET); - // Throttling. - if (!ps.tryApiCall(unlimited)) { - callback.complete(false); - } + // Throttling. + if (!ps.tryApiCall(unlimited)) { + callback.complete(false); + return; + } - // Initialize the implicit ranks for ShortcutPackage.adjustRanks(). - ps.clearAllImplicitRanks(); - assignImplicitRanks(newShortcuts); + // Initialize the implicit ranks for ShortcutPackage.adjustRanks(). + ps.clearAllImplicitRanks(); + assignImplicitRanks(newShortcuts); - for (int i = 0; i < size; i++) { - fixUpIncomingShortcutInfo(newShortcuts.get(i), /* forUpdate= */ false); - } + for (int i = 0; i < size; i++) { + fixUpIncomingShortcutInfo(newShortcuts.get(i), /* forUpdate= */ false); + } - ArrayList<ShortcutInfo> cachedOrPinned = new ArrayList<>(); - ps.findAll(cachedOrPinned, (ShortcutInfo si) -> si.isVisibleToPublisher() - && si.isDynamic() && (si.isCached() || si.isPinned()), - ShortcutInfo.CLONE_REMOVE_NON_KEY_INFO); + ArrayList<ShortcutInfo> cachedOrPinned = new ArrayList<>(); + ps.findAll(cachedOrPinned, (ShortcutInfo si) -> si.isVisibleToPublisher() + && si.isDynamic() && (si.isCached() || si.isPinned()), + ShortcutInfo.CLONE_REMOVE_NON_KEY_INFO); - // First, remove all un-pinned and non-cached; dynamic shortcuts - removedShortcuts = ps.deleteAllDynamicShortcuts(/*ignoreInvisible=*/ true); + // First, remove all un-pinned and non-cached; dynamic shortcuts + removedShortcuts = ps.deleteAllDynamicShortcuts(/*ignoreInvisible=*/ true); - // Then, add/update all. We need to make sure to take over "pinned" flag. - for (int i = 0; i < size; i++) { - final ShortcutInfo newShortcut = newShortcuts.get(i); - ps.addOrReplaceDynamicShortcut(newShortcut); - } + // Then, add/update all. We need to make sure to take over "pinned" flag. + for (int i = 0; i < size; i++) { + final ShortcutInfo newShortcut = newShortcuts.get(i); + ps.addOrReplaceDynamicShortcut(newShortcut); + } - // Lastly, adjust the ranks. - ps.adjustRanks(); + // Lastly, adjust the ranks. + ps.adjustRanks(); - changedShortcuts = prepareChangedShortcuts( - cachedOrPinned, newShortcuts, removedShortcuts, ps); - } + changedShortcuts = prepareChangedShortcuts( + cachedOrPinned, newShortcuts, removedShortcuts, ps); + } - packageShortcutsChanged(packageName, userId, changedShortcuts, removedShortcuts); + packageShortcutsChanged(packageName, userId, changedShortcuts, removedShortcuts); - verifyStates(); + verifyStates(); - callback.complete(true); + callback.complete(true); + } catch (Exception e) { + callback.completeExceptionally(e); + } } @Override public void updateShortcuts(String packageName, ParceledListSlice shortcutInfoList, @UserIdInt int userId, AndroidFuture callback) { - verifyCaller(packageName, userId); + try { + verifyCaller(packageName, userId); - final List<ShortcutInfo> newShortcuts = (List<ShortcutInfo>) shortcutInfoList.getList(); - verifyShortcutInfoPackages(packageName, newShortcuts); - final int size = newShortcuts.size(); + final List<ShortcutInfo> newShortcuts = (List<ShortcutInfo>) shortcutInfoList.getList(); + verifyShortcutInfoPackages(packageName, newShortcuts); + final int size = newShortcuts.size(); - final boolean unlimited = injectHasUnlimitedShortcutsApiCallsPermission( - injectBinderCallingPid(), injectBinderCallingUid()); + final boolean unlimited = injectHasUnlimitedShortcutsApiCallsPermission( + injectBinderCallingPid(), injectBinderCallingUid()); - final List<ShortcutInfo> changedShortcuts = new ArrayList<>(1); + final List<ShortcutInfo> changedShortcuts = new ArrayList<>(1); - synchronized (mLock) { - throwIfUserLockedL(userId); + synchronized (mLock) { + throwIfUserLockedL(userId); - final ShortcutPackage ps = getPackageShortcutsForPublisherLocked(packageName, userId); + final ShortcutPackage ps = getPackageShortcutsForPublisherLocked(packageName, + userId); - ps.ensureImmutableShortcutsNotIncluded(newShortcuts, /*ignoreInvisible=*/ true); - ps.ensureNoBitmapIconIfShortcutIsLongLived(newShortcuts); + ps.ensureImmutableShortcutsNotIncluded(newShortcuts, /*ignoreInvisible=*/ true); + ps.ensureNoBitmapIconIfShortcutIsLongLived(newShortcuts); - // For update, don't fill in the default activity. Having null activity means - // "don't update the activity" here. + // For update, don't fill in the default activity. Having null activity means + // "don't update the activity" here. - ps.enforceShortcutCountsBeforeOperation(newShortcuts, OPERATION_UPDATE); + ps.enforceShortcutCountsBeforeOperation(newShortcuts, OPERATION_UPDATE); - // Throttling. - if (!ps.tryApiCall(unlimited)) { - callback.complete(false); - return; - } + // Throttling. + if (!ps.tryApiCall(unlimited)) { + callback.complete(false); + return; + } - // Initialize the implicit ranks for ShortcutPackage.adjustRanks(). - ps.clearAllImplicitRanks(); - assignImplicitRanks(newShortcuts); + // Initialize the implicit ranks for ShortcutPackage.adjustRanks(). + ps.clearAllImplicitRanks(); + assignImplicitRanks(newShortcuts); - for (int i = 0; i < size; i++) { - final ShortcutInfo source = newShortcuts.get(i); - fixUpIncomingShortcutInfo(source, /* forUpdate= */ true); + for (int i = 0; i < size; i++) { + final ShortcutInfo source = newShortcuts.get(i); + fixUpIncomingShortcutInfo(source, /* forUpdate= */ true); - ps.mutateShortcut(source.getId(), null, target -> { - // Invisible shortcuts can't be updated. - if (target == null || !target.isVisibleToPublisher()) { - return; - } + ps.mutateShortcut(source.getId(), null, target -> { + // Invisible shortcuts can't be updated. + if (target == null || !target.isVisibleToPublisher()) { + return; + } - if (target.isEnabled() != source.isEnabled()) { - Slog.w(TAG, - "ShortcutInfo.enabled cannot be changed with updateShortcuts()"); - } + if (target.isEnabled() != source.isEnabled()) { + Slog.w(TAG, "ShortcutInfo.enabled cannot be changed with" + + " updateShortcuts()"); + } - if (target.isLongLived() != source.isLongLived()) { - Slog.w(TAG, - "ShortcutInfo.longLived cannot be changed with updateShortcuts()"); - } + if (target.isLongLived() != source.isLongLived()) { + Slog.w(TAG, + "ShortcutInfo.longLived cannot be changed with" + + " updateShortcuts()"); + } - // When updating the rank, we need to insert between existing ranks, so set - // this setRankChanged, and also copy the implicit rank fo adjustRanks(). - if (source.hasRank()) { - target.setRankChanged(); - target.setImplicitRank(source.getImplicitRank()); - } + // When updating the rank, we need to insert between existing ranks, so set + // this setRankChanged, and also copy the implicit rank fo adjustRanks(). + if (source.hasRank()) { + target.setRankChanged(); + target.setImplicitRank(source.getImplicitRank()); + } - final boolean replacingIcon = (source.getIcon() != null); - if (replacingIcon) { - removeIconLocked(target); - } + final boolean replacingIcon = (source.getIcon() != null); + if (replacingIcon) { + removeIconLocked(target); + } - // Note copyNonNullFieldsFrom() does the "updatable with?" check too. - target.copyNonNullFieldsFrom(source); - target.setTimestamp(injectCurrentTimeMillis()); + // Note copyNonNullFieldsFrom() does the "updatable with?" check too. + target.copyNonNullFieldsFrom(source); + target.setTimestamp(injectCurrentTimeMillis()); - if (replacingIcon) { - saveIconAndFixUpShortcutLocked(target); - } + if (replacingIcon) { + saveIconAndFixUpShortcutLocked(target); + } - // When we're updating any resource related fields, re-extract the res names and - // the values. - if (replacingIcon || source.hasStringResources()) { - fixUpShortcutResourceNamesAndValues(target); - } + // When we're updating any resource related fields, re-extract the res + // names and the values. + if (replacingIcon || source.hasStringResources()) { + fixUpShortcutResourceNamesAndValues(target); + } - changedShortcuts.add(target); - }); - } + changedShortcuts.add(target); + }); + } - // Lastly, adjust the ranks. - ps.adjustRanks(); - } - packageShortcutsChanged(packageName, userId, - changedShortcuts.isEmpty() ? null : changedShortcuts, null); + // Lastly, adjust the ranks. + ps.adjustRanks(); + } + packageShortcutsChanged(packageName, userId, + changedShortcuts.isEmpty() ? null : changedShortcuts, null); - verifyStates(); + verifyStates(); - callback.complete(true); + callback.complete(true); + } catch (Exception e) { + callback.completeExceptionally(e); + } } @Override public void addDynamicShortcuts(String packageName, ParceledListSlice shortcutInfoList, @UserIdInt int userId, AndroidFuture callback) { - verifyCaller(packageName, userId); + try { + verifyCaller(packageName, userId); - final List<ShortcutInfo> newShortcuts = (List<ShortcutInfo>) shortcutInfoList.getList(); - verifyShortcutInfoPackages(packageName, newShortcuts); - final int size = newShortcuts.size(); + final List<ShortcutInfo> newShortcuts = (List<ShortcutInfo>) shortcutInfoList.getList(); + verifyShortcutInfoPackages(packageName, newShortcuts); + final int size = newShortcuts.size(); - final boolean unlimited = injectHasUnlimitedShortcutsApiCallsPermission( - injectBinderCallingPid(), injectBinderCallingUid()); + final boolean unlimited = injectHasUnlimitedShortcutsApiCallsPermission( + injectBinderCallingPid(), injectBinderCallingUid()); - List<ShortcutInfo> changedShortcuts = null; + List<ShortcutInfo> changedShortcuts = null; - synchronized (mLock) { - throwIfUserLockedL(userId); + synchronized (mLock) { + throwIfUserLockedL(userId); - final ShortcutPackage ps = getPackageShortcutsForPublisherLocked(packageName, userId); + final ShortcutPackage ps = getPackageShortcutsForPublisherLocked(packageName, + userId); - ps.ensureImmutableShortcutsNotIncluded(newShortcuts, /*ignoreInvisible=*/ true); - ps.ensureNoBitmapIconIfShortcutIsLongLived(newShortcuts); + ps.ensureImmutableShortcutsNotIncluded(newShortcuts, /*ignoreInvisible=*/ true); + ps.ensureNoBitmapIconIfShortcutIsLongLived(newShortcuts); - fillInDefaultActivity(newShortcuts); + fillInDefaultActivity(newShortcuts); - ps.enforceShortcutCountsBeforeOperation(newShortcuts, OPERATION_ADD); + ps.enforceShortcutCountsBeforeOperation(newShortcuts, OPERATION_ADD); - // Initialize the implicit ranks for ShortcutPackage.adjustRanks(). - ps.clearAllImplicitRanks(); - assignImplicitRanks(newShortcuts); + // Initialize the implicit ranks for ShortcutPackage.adjustRanks(). + ps.clearAllImplicitRanks(); + assignImplicitRanks(newShortcuts); - // Throttling. - if (!ps.tryApiCall(unlimited)) { - callback.complete(false); - return; - } - for (int i = 0; i < size; i++) { - final ShortcutInfo newShortcut = newShortcuts.get(i); + // Throttling. + if (!ps.tryApiCall(unlimited)) { + callback.complete(false); + return; + } + for (int i = 0; i < size; i++) { + final ShortcutInfo newShortcut = newShortcuts.get(i); - // Validate the shortcut. - fixUpIncomingShortcutInfo(newShortcut, /* forUpdate= */ false); + // Validate the shortcut. + fixUpIncomingShortcutInfo(newShortcut, /* forUpdate= */ false); - // When ranks are changing, we need to insert between ranks, so set the - // "rank changed" flag. - newShortcut.setRankChanged(); + // When ranks are changing, we need to insert between ranks, so set the + // "rank changed" flag. + newShortcut.setRankChanged(); - // Add it. - ps.addOrReplaceDynamicShortcut(newShortcut); + // Add it. + ps.addOrReplaceDynamicShortcut(newShortcut); - if (changedShortcuts == null) { - changedShortcuts = new ArrayList<>(1); + if (changedShortcuts == null) { + changedShortcuts = new ArrayList<>(1); + } + changedShortcuts.add(newShortcut); } - changedShortcuts.add(newShortcut); - } - // Lastly, adjust the ranks. - ps.adjustRanks(); - } - packageShortcutsChanged(packageName, userId, changedShortcuts, null); + // Lastly, adjust the ranks. + ps.adjustRanks(); + } + packageShortcutsChanged(packageName, userId, changedShortcuts, null); - verifyStates(); + verifyStates(); - callback.complete(true); + callback.complete(true); + } catch (Exception e) { + callback.completeExceptionally(e); + } } @Override @@ -2180,31 +2197,40 @@ public class ShortcutService extends IShortcutService.Stub { @Override public void requestPinShortcut(String packageName, ShortcutInfo shortcut, IntentSender resultIntent, int userId, AndroidFuture callback) { - Objects.requireNonNull(shortcut); - Objects.requireNonNull(callback); - Preconditions.checkArgument(shortcut.isEnabled(), "Shortcut must be enabled"); - callback.complete(requestPinItem(packageName, userId, shortcut, null, null, resultIntent)); + try { + Objects.requireNonNull(shortcut); + Objects.requireNonNull(callback); + Preconditions.checkArgument(shortcut.isEnabled(), "Shortcut must be enabled"); + callback.complete( + requestPinItem(packageName, userId, shortcut, null, null, resultIntent)); + } catch (Exception e) { + callback.completeExceptionally(e); + } } @Override public void createShortcutResultIntent(String packageName, ShortcutInfo shortcut, int userId, AndroidFuture callback) throws RemoteException { - Objects.requireNonNull(shortcut); - Preconditions.checkArgument(shortcut.isEnabled(), "Shortcut must be enabled"); - verifyCaller(packageName, userId); - verifyShortcutInfoPackage(packageName, shortcut); + try { + Objects.requireNonNull(shortcut); + Preconditions.checkArgument(shortcut.isEnabled(), "Shortcut must be enabled"); + verifyCaller(packageName, userId); + verifyShortcutInfoPackage(packageName, shortcut); - final Intent ret; - synchronized (mLock) { - throwIfUserLockedL(userId); + final Intent ret; + synchronized (mLock) { + throwIfUserLockedL(userId); - // Send request to the launcher, if supported. - ret = mShortcutRequestPinProcessor.createShortcutResultIntent(shortcut, userId); - } + // Send request to the launcher, if supported. + ret = mShortcutRequestPinProcessor.createShortcutResultIntent(shortcut, userId); + } - verifyStates(); - callback.complete(ret); + verifyStates(); + callback.complete(ret); + } catch (Exception e) { + callback.completeExceptionally(e); + } } /** @@ -2464,47 +2490,57 @@ public class ShortcutService extends IShortcutService.Stub { public void getShortcuts(String packageName, @ShortcutManager.ShortcutMatchFlags int matchFlags, @UserIdInt int userId, AndroidFuture<ParceledListSlice<ShortcutInfo>> callback) { - verifyCaller(packageName, userId); - - synchronized (mLock) { - throwIfUserLockedL(userId); - - final boolean matchDynamic = (matchFlags & ShortcutManager.FLAG_MATCH_DYNAMIC) != 0; - final boolean matchPinned = (matchFlags & ShortcutManager.FLAG_MATCH_PINNED) != 0; - final boolean matchManifest = (matchFlags & ShortcutManager.FLAG_MATCH_MANIFEST) != 0; - final boolean matchCached = (matchFlags & ShortcutManager.FLAG_MATCH_CACHED) != 0; + try { + verifyCaller(packageName, userId); - final int shortcutFlags = (matchDynamic ? ShortcutInfo.FLAG_DYNAMIC : 0) - | (matchPinned ? ShortcutInfo.FLAG_PINNED : 0) - | (matchManifest ? ShortcutInfo.FLAG_MANIFEST : 0) - | (matchCached ? ShortcutInfo.FLAG_CACHED_ALL : 0); + synchronized (mLock) { + throwIfUserLockedL(userId); - callback.complete(getShortcutsWithQueryLocked( - packageName, userId, ShortcutInfo.CLONE_REMOVE_FOR_CREATOR, - (ShortcutInfo si) -> - si.isVisibleToPublisher() && (si.getFlags() & shortcutFlags) != 0)); + final boolean matchDynamic = (matchFlags & ShortcutManager.FLAG_MATCH_DYNAMIC) != 0; + final boolean matchPinned = (matchFlags & ShortcutManager.FLAG_MATCH_PINNED) != 0; + final boolean matchManifest = + (matchFlags & ShortcutManager.FLAG_MATCH_MANIFEST) != 0; + final boolean matchCached = (matchFlags & ShortcutManager.FLAG_MATCH_CACHED) != 0; + + final int shortcutFlags = (matchDynamic ? ShortcutInfo.FLAG_DYNAMIC : 0) + | (matchPinned ? ShortcutInfo.FLAG_PINNED : 0) + | (matchManifest ? ShortcutInfo.FLAG_MANIFEST : 0) + | (matchCached ? ShortcutInfo.FLAG_CACHED_ALL : 0); + + callback.complete(getShortcutsWithQueryLocked( + packageName, userId, ShortcutInfo.CLONE_REMOVE_FOR_CREATOR, + (ShortcutInfo si) -> + si.isVisibleToPublisher() && (si.getFlags() & shortcutFlags) != 0)); + } + } catch (Exception e) { + callback.completeExceptionally(e); } } @Override public void getShareTargets(String packageName, IntentFilter filter, @UserIdInt int userId, AndroidFuture<ParceledListSlice> callback) { - Preconditions.checkStringNotEmpty(packageName, "packageName"); - Objects.requireNonNull(filter, "intentFilter"); + try { + Preconditions.checkStringNotEmpty(packageName, "packageName"); + Objects.requireNonNull(filter, "intentFilter"); - verifyCaller(packageName, userId); - enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_APP_PREDICTIONS, - "getShareTargets"); + verifyCaller(packageName, userId); + enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_APP_PREDICTIONS, + "getShareTargets"); - synchronized (mLock) { - throwIfUserLockedL(userId); + synchronized (mLock) { + throwIfUserLockedL(userId); - final List<ShortcutManager.ShareShortcutInfo> shortcutInfoList = new ArrayList<>(); + final List<ShortcutManager.ShareShortcutInfo> shortcutInfoList = new ArrayList<>(); - final ShortcutUser user = getUserShortcutsLocked(userId); - user.forAllPackages(p -> shortcutInfoList.addAll(p.getMatchingShareTargets(filter))); + final ShortcutUser user = getUserShortcutsLocked(userId); + user.forAllPackages( + p -> shortcutInfoList.addAll(p.getMatchingShareTargets(filter))); - callback.complete(new ParceledListSlice<>(shortcutInfoList)); + callback.complete(new ParceledListSlice<>(shortcutInfoList)); + } + } catch (Exception e) { + callback.completeExceptionally(e); } } diff --git a/services/core/java/com/android/server/power/FaceDownDetector.java b/services/core/java/com/android/server/power/FaceDownDetector.java index fe9663aaabe5..676181dcfb67 100644 --- a/services/core/java/com/android/server/power/FaceDownDetector.java +++ b/services/core/java/com/android/server/power/FaceDownDetector.java @@ -291,8 +291,10 @@ public class FaceDownDetector implements SensorEventListener { * The user interacted with the screen while face down, indicated the phone is in use. * We log this event and temporarily make this detector inactive. */ - public void userActivity() { - mHandler.post(mUserActivityRunnable); + public void userActivity(int event) { + if (event != PowerManager.USER_ACTIVITY_EVENT_FACE_DOWN) { + mHandler.post(mUserActivityRunnable); + } } private void exitFaceDown(int resultType, long millisSinceFlip) { diff --git a/services/core/java/com/android/server/power/Notifier.java b/services/core/java/com/android/server/power/Notifier.java index f49e2f1631b9..7555a7f2920b 100644 --- a/services/core/java/com/android/server/power/Notifier.java +++ b/services/core/java/com/android/server/power/Notifier.java @@ -549,6 +549,7 @@ public class Notifier { if (!mUserActivityPending) { mUserActivityPending = true; Message msg = mHandler.obtainMessage(MSG_USER_ACTIVITY); + msg.arg1 = event; msg.setAsynchronous(true); mHandler.sendMessage(msg); } @@ -647,7 +648,7 @@ public class Notifier { mSuspendBlocker.release(); } - private void sendUserActivity() { + private void sendUserActivity(int event) { synchronized (mLock) { if (!mUserActivityPending) { return; @@ -657,7 +658,7 @@ public class Notifier { TelephonyManager tm = mContext.getSystemService(TelephonyManager.class); tm.notifyUserActivity(); mPolicy.userActivity(); - mFaceDownDetector.userActivity(); + mFaceDownDetector.userActivity(event); } void postEnhancedDischargePredictionBroadcast(long delayMs) { @@ -833,7 +834,7 @@ public class Notifier { public void handleMessage(Message msg) { switch (msg.what) { case MSG_USER_ACTIVITY: - sendUserActivity(); + sendUserActivity(msg.arg1); break; case MSG_BROADCAST: sendNextBroadcast(); diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java index 29adde37ab3b..d2a4cd604c01 100644 --- a/services/core/java/com/android/server/power/PowerManagerService.java +++ b/services/core/java/com/android/server/power/PowerManagerService.java @@ -180,8 +180,6 @@ public final class PowerManagerService extends SystemService private static final int DIRTY_VR_MODE_CHANGED = 1 << 13; // Dirty bit: attentive timer may have timed out private static final int DIRTY_ATTENTIVE = 1 << 14; - // Dirty bit: phone flipped to face down - private static final int DIRTY_FACE_DOWN = 1 << 15; // Dirty bit: display group power state has changed private static final int DIRTY_DISPLAY_GROUP_POWER_UPDATED = 1 << 16; @@ -1069,8 +1067,9 @@ public final class PowerManagerService extends SystemService final long screenOffTimeout = getScreenOffTimeoutLocked(sleepTimeout, -1L); millisUntilNormalTimeout = mLastUserActivityTime + screenOffTimeout - mClock.uptimeMillis(); - mDirty |= DIRTY_FACE_DOWN; - updatePowerStateLocked(); + userActivityInternal(mClock.uptimeMillis(), + PowerManager.USER_ACTIVITY_EVENT_FACE_DOWN, /* flags= */0, + Process.SYSTEM_UID); } } if (isFaceDown) { diff --git a/services/core/java/com/android/server/speech/SpeechRecognitionManagerService.java b/services/core/java/com/android/server/speech/SpeechRecognitionManagerService.java index dbe73546d748..52c1467bd5d0 100644 --- a/services/core/java/com/android/server/speech/SpeechRecognitionManagerService.java +++ b/services/core/java/com/android/server/speech/SpeechRecognitionManagerService.java @@ -16,6 +16,8 @@ package com.android.server.speech; +import static android.Manifest.permission.MANAGE_SPEECH_RECOGNITION; + import android.annotation.NonNull; import android.annotation.UserIdInt; import android.content.ComponentName; @@ -24,6 +26,7 @@ import android.os.IBinder; import android.os.UserHandle; import android.speech.IRecognitionServiceManager; import android.speech.IRecognitionServiceManagerCallback; +import android.util.Slog; import com.android.internal.R; import com.android.server.infra.AbstractMasterSystemService; @@ -42,6 +45,8 @@ public final class SpeechRecognitionManagerService extends SpeechRecognitionManagerServiceImpl> { private static final String TAG = SpeechRecognitionManagerService.class.getSimpleName(); + private static final int MAX_TEMP_SERVICE_SUBSTITUTION_DURATION_MS = 60_000; + public SpeechRecognitionManagerService(@NonNull Context context) { super(context, // TODO(b/176578753): think if we want to favor the particular service here. @@ -58,6 +63,16 @@ public final class SpeechRecognitionManagerService extends } @Override + protected void enforceCallingPermissionForManagement() { + getContext().enforceCallingPermission(MANAGE_SPEECH_RECOGNITION, TAG); + } + + @Override + protected int getMaximumTemporaryServiceDurationMs() { + return MAX_TEMP_SERVICE_SUBSTITUTION_DURATION_MS; + } + + @Override protected SpeechRecognitionManagerServiceImpl newServiceLocked( @UserIdInt int resolvedUserId, boolean disabled) { return new SpeechRecognitionManagerServiceImpl(this, mLock, resolvedUserId, disabled); @@ -77,5 +92,21 @@ public final class SpeechRecognitionManagerService extends service.createSessionLocked(componentName, clientToken, onDevice, callback); } } + + @Override + public void setTemporaryComponent(ComponentName componentName) { + int userId = UserHandle.getCallingUserId(); + if (componentName == null) { + resetTemporaryService(userId); + Slog.i(TAG, "Reset temporary service for user " + userId); + return; + } + setTemporaryService( + userId, + componentName.flattenToString(), + MAX_TEMP_SERVICE_SUBSTITUTION_DURATION_MS); + Slog.i(TAG, "SpeechRecognition temporarily set to " + componentName + " for " + + MAX_TEMP_SERVICE_SUBSTITUTION_DURATION_MS + "ms"); + } } } diff --git a/services/core/java/com/android/server/speech/SpeechRecognitionManagerServiceImpl.java b/services/core/java/com/android/server/speech/SpeechRecognitionManagerServiceImpl.java index 2656a3d32555..769e049c8d0e 100644 --- a/services/core/java/com/android/server/speech/SpeechRecognitionManagerServiceImpl.java +++ b/services/core/java/com/android/server/speech/SpeechRecognitionManagerServiceImpl.java @@ -100,6 +100,9 @@ final class SpeechRecognitionManagerServiceImpl extends } if (serviceComponent == null) { + if (mMaster.debug) { + Slog.i(TAG, "Service component is undefined, responding with error."); + } tryRespondWithError(callback, SpeechRecognizer.ERROR_CLIENT); return; } @@ -213,6 +216,10 @@ final class SpeechRecognitionManagerServiceImpl extends @Nullable private ComponentName getOnDeviceComponentNameLocked() { final String serviceName = getComponentNameLocked(); + if (mMaster.debug) { + Slog.i(TAG, "Resolved component name: " + serviceName); + } + if (serviceName == null) { if (mMaster.verbose) { Slog.v(TAG, "ensureRemoteServiceLocked(): no service component name."); @@ -241,6 +248,11 @@ final class SpeechRecognitionManagerServiceImpl extends service.getServiceComponentName().equals(serviceComponent)) .findFirst(); if (existingService.isPresent()) { + + if (mMaster.debug) { + Slog.i(TAG, "Reused existing connection to " + serviceComponent); + } + return existingService.get(); } } @@ -253,6 +265,10 @@ final class SpeechRecognitionManagerServiceImpl extends mRemoteServicesByUid.computeIfAbsent(callingUid, key -> new HashSet<>()); valuesByCaller.add(service); + if (mMaster.debug) { + Slog.i(TAG, "Creating a new connection to " + serviceComponent); + } + return service; } } diff --git a/services/core/java/com/android/server/stats/OWNERS b/services/core/java/com/android/server/stats/OWNERS index fc7fd220b26a..174ad3ad2e25 100644 --- a/services/core/java/com/android/server/stats/OWNERS +++ b/services/core/java/com/android/server/stats/OWNERS @@ -1,7 +1,10 @@ jeffreyhuang@google.com joeo@google.com +jtnguyen@google.com muhammadq@google.com +rslawik@google.com ruchirr@google.com +sharaienko@google.com singhtejinder@google.com tsaichristine@google.com yaochen@google.com diff --git a/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java b/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java index 7ed7a592a972..8023fd42edfa 100644 --- a/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java +++ b/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java @@ -148,11 +148,13 @@ import com.android.internal.os.KernelCpuUidTimeReader.KernelCpuUidActiveTimeRead import com.android.internal.os.KernelCpuUidTimeReader.KernelCpuUidClusterTimeReader; import com.android.internal.os.KernelCpuUidTimeReader.KernelCpuUidFreqTimeReader; import com.android.internal.os.KernelCpuUidTimeReader.KernelCpuUidUserSysTimeReader; +import com.android.internal.os.KernelSingleProcessCpuThreadReader.ProcessCpuUsage; import com.android.internal.os.KernelWakelockReader; import com.android.internal.os.KernelWakelockStats; import com.android.internal.os.LooperStats; import com.android.internal.os.PowerProfile; import com.android.internal.os.ProcessCpuTracker; +import com.android.internal.os.SelectedProcessCpuThreadReader; import com.android.internal.os.StoragedUidIoStatsReader; import com.android.internal.os.SystemServerCpuThreadReader.SystemServiceCpuThreadTimes; import com.android.internal.util.CollectionUtils; @@ -351,6 +353,8 @@ public class StatsPullAtomService extends SystemService { @GuardedBy("mDataBytesTransferLock") private final ArrayList<SubInfo> mHistoricalSubs = new ArrayList<>(); + private SelectedProcessCpuThreadReader mSurfaceFlingerProcessCpuThreadReader; + // Puller locks private final Object mDataBytesTransferLock = new Object(); private final Object mBluetoothBytesTransferLock = new Object(); @@ -753,6 +757,9 @@ public class StatsPullAtomService extends SystemService { } } } + + mSurfaceFlingerProcessCpuThreadReader = + new SelectedProcessCpuThreadReader("/system/bin/surfaceflinger"); } void registerEventListeners() { @@ -1479,7 +1486,7 @@ public class StatsPullAtomService extends SystemService { } for (int freqIndex = 0; freqIndex < timesMs.length; ++freqIndex) { int cluster = freqsClusters[freqIndex]; - long freq = freqs[freqIndex]; + int freq = (int) freqs[freqIndex]; long timeMs = timesMs[freqIndex]; pulledData.add(FrameworkStatsLog.buildStatsEvent(atomTag, cluster, freq, timeMs)); } @@ -1678,6 +1685,18 @@ public class StatsPullAtomService extends SystemService { FrameworkStatsLog.CPU_CYCLES_PER_THREAD_GROUP_CLUSTER__THREAD_GROUP__SYSTEM_SERVER_BINDER, times.binderThreadCpuTimesUs); + ProcessCpuUsage surfaceFlingerTimes = mSurfaceFlingerProcessCpuThreadReader.readAbsolute(); + if (surfaceFlingerTimes != null && surfaceFlingerTimes.threadCpuTimesMillis != null) { + long[] surfaceFlingerTimesUs = + new long[surfaceFlingerTimes.threadCpuTimesMillis.length]; + for (int i = 0; i < surfaceFlingerTimesUs.length; ++i) { + surfaceFlingerTimesUs[i] = surfaceFlingerTimes.threadCpuTimesMillis[i] * 1_000; + } + addCpuCyclesPerThreadGroupClusterAtoms(atomTag, pulledData, + FrameworkStatsLog.CPU_CYCLES_PER_THREAD_GROUP_CLUSTER__THREAD_GROUP__SURFACE_FLINGER, + surfaceFlingerTimesUs); + } + return StatsManager.PULL_SUCCESS; } diff --git a/services/core/java/com/android/server/timezonedetector/location/BinderLocationTimeZoneProvider.java b/services/core/java/com/android/server/timezonedetector/location/BinderLocationTimeZoneProvider.java index c0c9e6d58622..8e4a18243a00 100644 --- a/services/core/java/com/android/server/timezonedetector/location/BinderLocationTimeZoneProvider.java +++ b/services/core/java/com/android/server/timezonedetector/location/BinderLocationTimeZoneProvider.java @@ -47,7 +47,7 @@ class BinderLocationTimeZoneProvider extends LocationTimeZoneProvider { @NonNull ThreadingDomain threadingDomain, @NonNull String providerName, @NonNull LocationTimeZoneProviderProxy proxy) { - super(threadingDomain, providerName); + super(threadingDomain, providerName, new ZoneInfoDbTimeZoneIdValidator()); mProxy = Objects.requireNonNull(proxy); } diff --git a/services/core/java/com/android/server/timezonedetector/location/LocationTimeZoneManagerService.java b/services/core/java/com/android/server/timezonedetector/location/LocationTimeZoneManagerService.java index 0d1692a8781d..588382158bc9 100644 --- a/services/core/java/com/android/server/timezonedetector/location/LocationTimeZoneManagerService.java +++ b/services/core/java/com/android/server/timezonedetector/location/LocationTimeZoneManagerService.java @@ -520,6 +520,12 @@ public class LocationTimeZoneManagerService extends Binder { } } + static void infoLog(String msg) { + if (Log.isLoggable(TAG, Log.INFO)) { + Slog.i(TAG, msg); + } + } + static void warnLog(String msg) { warnLog(msg, null); } diff --git a/services/core/java/com/android/server/timezonedetector/location/LocationTimeZoneProvider.java b/services/core/java/com/android/server/timezonedetector/location/LocationTimeZoneProvider.java index ef2f357b8c3e..b97c838017eb 100644 --- a/services/core/java/com/android/server/timezonedetector/location/LocationTimeZoneProvider.java +++ b/services/core/java/com/android/server/timezonedetector/location/LocationTimeZoneProvider.java @@ -20,6 +20,7 @@ import static android.service.timezone.TimeZoneProviderService.TEST_COMMAND_RESU import static android.service.timezone.TimeZoneProviderService.TEST_COMMAND_RESULT_SUCCESS_KEY; import static com.android.server.timezonedetector.location.LocationTimeZoneManagerService.debugLog; +import static com.android.server.timezonedetector.location.LocationTimeZoneManagerService.infoLog; import static com.android.server.timezonedetector.location.LocationTimeZoneManagerService.warnLog; import static com.android.server.timezonedetector.location.LocationTimeZoneProvider.ProviderState.PROVIDER_STATE_DESTROYED; import static com.android.server.timezonedetector.location.LocationTimeZoneProvider.ProviderState.PROVIDER_STATE_PERM_FAILED; @@ -85,6 +86,18 @@ abstract class LocationTimeZoneProvider implements Dumpable { } /** + * Used by {@link LocationTimeZoneProvider} to check if time zone IDs are understood + * by the platform. + */ + interface TimeZoneIdValidator { + + /** + * Returns whether {@code timeZoneId} is supported by the platform or not. + */ + boolean isValid(@NonNull String timeZoneId); + } + + /** * Information about the provider's current state. */ static class ProviderState { @@ -364,13 +377,17 @@ abstract class LocationTimeZoneProvider implements Dumpable { // Non-null and effectively final after initialize() is called. ProviderListener mProviderListener; + @NonNull private TimeZoneIdValidator mTimeZoneIdValidator; + /** Creates the instance. */ LocationTimeZoneProvider(@NonNull ThreadingDomain threadingDomain, - @NonNull String providerName) { + @NonNull String providerName, + @NonNull TimeZoneIdValidator timeZoneIdValidator) { mThreadingDomain = Objects.requireNonNull(threadingDomain); mInitializationTimeoutQueue = threadingDomain.createSingleRunnableQueue(); mSharedLock = threadingDomain.getLockObject(); mProviderName = Objects.requireNonNull(providerName); + mTimeZoneIdValidator = Objects.requireNonNull(timeZoneIdValidator); } /** @@ -610,6 +627,25 @@ abstract class LocationTimeZoneProvider implements Dumpable { mThreadingDomain.assertCurrentThread(); Objects.requireNonNull(timeZoneProviderEvent); + // If the provider has made a suggestion with unknown time zone IDs it cannot be used to set + // the device's time zone. This logic prevents bad time zone IDs entering the time zone + // detection logic from third party code. + // + // An event containing an unknown time zone ID could occur if the provider is using a + // different TZDB version than the device. Provider developers are expected to take steps to + // avoid version skew problem, e.g. by ensuring atomic updates with the platform time zone + // rules, or providing IDs based on the device's TZDB version, so this is not considered a + // common case. + // + // Treating a suggestion containing unknown time zone IDs as "uncertain" in the primary + // enables immediate failover to a secondary provider, one that might provide valid IDs for + // the same location, which should provide better behavior than just ignoring the event. + if (hasInvalidTimeZones(timeZoneProviderEvent)) { + infoLog("event=" + timeZoneProviderEvent + " has unsupported time zones. " + + "Replacing it with uncertain event."); + timeZoneProviderEvent = TimeZoneProviderEvent.createUncertainEvent(); + } + synchronized (mSharedLock) { debugLog("handleTimeZoneProviderEvent: mProviderName=" + mProviderName + ", timeZoneProviderEvent=" + timeZoneProviderEvent); @@ -707,6 +743,20 @@ abstract class LocationTimeZoneProvider implements Dumpable { } } + private boolean hasInvalidTimeZones(@NonNull TimeZoneProviderEvent event) { + if (event.getSuggestion() == null) { + return false; + } + + for (String timeZone : event.getSuggestion().getTimeZoneIds()) { + if (!mTimeZoneIdValidator.isValid(timeZone)) { + return true; + } + } + + return false; + } + @GuardedBy("mSharedLock") private void assertIsStarted() { ProviderState currentState = mCurrentState.get(); diff --git a/services/core/java/com/android/server/timezonedetector/location/ZoneInfoDbTimeZoneIdValidator.java b/services/core/java/com/android/server/timezonedetector/location/ZoneInfoDbTimeZoneIdValidator.java new file mode 100644 index 000000000000..cab5ad25c54e --- /dev/null +++ b/services/core/java/com/android/server/timezonedetector/location/ZoneInfoDbTimeZoneIdValidator.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.timezonedetector.location; + +import android.annotation.NonNull; + +import com.android.i18n.timezone.ZoneInfoDb; + +class ZoneInfoDbTimeZoneIdValidator implements + LocationTimeZoneProvider.TimeZoneIdValidator { + + @Override + public boolean isValid(@NonNull String timeZoneId) { + return ZoneInfoDb.getInstance().hasTimeZone(timeZoneId); + } +} diff --git a/services/core/java/com/android/server/vcn/UnderlyingNetworkTracker.java b/services/core/java/com/android/server/vcn/UnderlyingNetworkTracker.java index b2db9f5af07e..8dcc547508ec 100644 --- a/services/core/java/com/android/server/vcn/UnderlyingNetworkTracker.java +++ b/services/core/java/com/android/server/vcn/UnderlyingNetworkTracker.java @@ -23,7 +23,6 @@ import android.net.ConnectivityManager.NetworkCallback; import android.net.LinkProperties; import android.net.Network; import android.net.NetworkCapabilities; -import android.net.NetworkCapabilities.NetCapability; import android.net.NetworkRequest; import android.net.TelephonyNetworkSpecifier; import android.os.Handler; @@ -115,33 +114,61 @@ public class UnderlyingNetworkTracker { getWifiNetworkRequest(), mHandler, mWifiBringupCallback); updateSubIdsAndCellularRequests(); - // register Network-selection request used to decide selected underlying Network + // Register Network-selection request used to decide selected underlying Network. All + // underlying networks must be VCN managed in order to be used. mConnectivityManager.requestBackgroundNetwork( - getNetworkRequestBase().build(), mHandler, mRouteSelectionCallback); + getBaseNetworkRequest(true /* requireVcnManaged */).build(), + mHandler, + mRouteSelectionCallback); } private NetworkRequest getWifiNetworkRequest() { - return getNetworkRequestBase().addTransportType(NetworkCapabilities.TRANSPORT_WIFI).build(); + // Request exclusively VCN managed networks to ensure that we only ever keep carrier wifi + // alive. + return getBaseNetworkRequest(true /* requireVcnManaged */) + .addTransportType(NetworkCapabilities.TRANSPORT_WIFI) + .build(); } private NetworkRequest getCellNetworkRequestForSubId(int subId) { - return getNetworkRequestBase() + // Do not request NOT_VCN_MANAGED to ensure that the TelephonyNetworkFactory has a + // fulfillable request to bring up underlying cellular Networks even if the VCN is already + // connected. + return getBaseNetworkRequest(false /* requireVcnManaged */) .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR) .setNetworkSpecifier(new TelephonyNetworkSpecifier(subId)) .build(); } - private NetworkRequest.Builder getNetworkRequestBase() { - NetworkRequest.Builder requestBase = new NetworkRequest.Builder(); - for (@NetCapability int capability : mRequiredUnderlyingNetworkCapabilities) { + /** + * Builds and returns a NetworkRequest builder common to all Underlying Network requests + * + * <p>A NetworkRequest may either (1) Require the presence of a capability by using + * addCapability(), (2) require the absence of a capability using unwanted capabilities, or (3) + * allow any state. Underlying networks are never desired to have the NOT_VCN_MANAGED + * capability, and only cases (2) and (3) are used. + * + * @param requireVcnManaged whether the underlying network is required to be VCN managed to + * match this request. If {@code true}, the NOT_VCN_MANAGED capability will be set as + * unwanted. Else, the NOT_VCN_MANAGED capability will be removed, and any state is + * acceptable. + */ + private NetworkRequest.Builder getBaseNetworkRequest(boolean requireVcnManaged) { + NetworkRequest.Builder requestBase = + new NetworkRequest.Builder() + .removeCapability(NetworkCapabilities.NET_CAPABILITY_TRUSTED) + .removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED) + .removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED); + + for (int capability : mRequiredUnderlyingNetworkCapabilities) { requestBase.addCapability(capability); } - return requestBase - .removeCapability(NetworkCapabilities.NET_CAPABILITY_TRUSTED) - .removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED) - .removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED) - .addUnwantedCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED); + if (requireVcnManaged) { + requestBase.addUnwantedCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED); + } + + return requestBase; } /** diff --git a/services/core/java/com/android/server/vcn/Vcn.java b/services/core/java/com/android/server/vcn/Vcn.java index c55913e2e547..3f74938005a7 100644 --- a/services/core/java/com/android/server/vcn/Vcn.java +++ b/services/core/java/com/android/server/vcn/Vcn.java @@ -299,9 +299,7 @@ public class Vcn extends Handler { for (VcnGatewayConnectionConfig gatewayConnectionConfig : mConfig.getGatewayConnectionConfigs()) { if (isRequestSatisfiedByGatewayConnectionConfig(request, gatewayConnectionConfig)) { - Slog.v( - getLogTag(), - "Bringing up new VcnGatewayConnection for request " + request.requestId); + Slog.v(getLogTag(), "Bringing up new VcnGatewayConnection for request " + request); final VcnGatewayConnection vcnGatewayConnection = mDeps.newVcnGatewayConnection( diff --git a/services/core/java/com/android/server/vcn/VcnGatewayConnection.java b/services/core/java/com/android/server/vcn/VcnGatewayConnection.java index 15429f455d6e..69a153f79a1b 100644 --- a/services/core/java/com/android/server/vcn/VcnGatewayConnection.java +++ b/services/core/java/com/android/server/vcn/VcnGatewayConnection.java @@ -20,6 +20,7 @@ import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_CONGESTED; import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_METERED; import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING; import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_SUSPENDED; +import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED; import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR; import static android.net.NetworkCapabilities.TRANSPORT_WIFI; import static android.net.vcn.VcnManager.VCN_ERROR_CODE_CONFIG_ERROR; @@ -59,6 +60,7 @@ import android.net.ipsec.ike.exceptions.AuthenticationFailedException; import android.net.ipsec.ike.exceptions.IkeException; import android.net.ipsec.ike.exceptions.IkeInternalException; import android.net.ipsec.ike.exceptions.IkeProtocolException; +import android.net.vcn.VcnControlPlaneIkeConfig; import android.net.vcn.VcnGatewayConnectionConfig; import android.net.vcn.VcnTransportInfo; import android.net.wifi.WifiInfo; @@ -1348,7 +1350,7 @@ public class VcnGatewayConnection extends StateMachine { mIkeSession = null; } - mIkeSession = buildIkeSession(); + mIkeSession = buildIkeSession(mUnderlying.network); } @Override @@ -1726,6 +1728,7 @@ public class VcnGatewayConnection extends StateMachine { final NetworkCapabilities.Builder builder = new NetworkCapabilities.Builder(); builder.addTransportType(TRANSPORT_CELLULAR); + builder.addCapability(NET_CAPABILITY_NOT_VCN_MANAGED); builder.addCapability(NET_CAPABILITY_NOT_CONGESTED); builder.addCapability(NET_CAPABILITY_NOT_SUSPENDED); @@ -1939,23 +1942,29 @@ public class VcnGatewayConnection extends StateMachine { new EventDisconnectRequestedInfo(reason, shouldQuit)); } - private IkeSessionParams buildIkeParams() { - // TODO: Implement this once IkeSessionParams is persisted - return null; + private IkeSessionParams buildIkeParams(@NonNull Network network) { + final VcnControlPlaneIkeConfig controlPlaneConfig = + (VcnControlPlaneIkeConfig) mConnectionConfig.getControlPlaneConfig(); + final IkeSessionParams.Builder builder = + new IkeSessionParams.Builder(controlPlaneConfig.getIkeSessionParams()); + builder.setConfiguredNetwork(network); + + return builder.build(); } private ChildSessionParams buildChildParams() { - // TODO: Implement this once IkeSessionParams is persisted - return null; + final VcnControlPlaneIkeConfig controlPlaneConfig = + (VcnControlPlaneIkeConfig) mConnectionConfig.getControlPlaneConfig(); + return controlPlaneConfig.getChildSessionParams(); } @VisibleForTesting(visibility = Visibility.PRIVATE) - VcnIkeSession buildIkeSession() { + VcnIkeSession buildIkeSession(@NonNull Network network) { final int token = ++mCurrentToken; return mDeps.newIkeSession( mVcnContext, - buildIkeParams(), + buildIkeParams(network), buildChildParams(), new IkeSessionCallbackImpl(token), new VcnChildSessionCallback(token)); diff --git a/services/core/java/com/android/server/wm/RemoteAnimationController.java b/services/core/java/com/android/server/wm/RemoteAnimationController.java index 42cb96f65738..6fc585e473a9 100644 --- a/services/core/java/com/android/server/wm/RemoteAnimationController.java +++ b/services/core/java/com/android/server/wm/RemoteAnimationController.java @@ -104,11 +104,11 @@ class RemoteAnimationController implements DeathRecipient { */ void goodToGo(@WindowManager.TransitionOldType int transit) { ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "goodToGo()"); - if (mPendingAnimations.isEmpty() || mCanceled) { + if (mCanceled) { ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, - "goodToGo(): Animation finished already, canceled=%s mPendingAnimations=%d", - mCanceled, mPendingAnimations.size()); + "goodToGo(): Animation canceled already"); onAnimationFinished(); + invokeAnimationCancelled(); return; } @@ -120,8 +120,11 @@ class RemoteAnimationController implements DeathRecipient { // Create the app targets final RemoteAnimationTarget[] appTargets = createAppAnimations(); if (appTargets.length == 0) { - ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "goodToGo(): No apps to animate"); + ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, + "goodToGo(): No apps to animate, mPendingAnimations=%d", + mPendingAnimations.size()); onAnimationFinished(); + invokeAnimationCancelled(); return; } diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index d992a4591a22..04a254c2aabf 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -5245,17 +5245,29 @@ class Task extends WindowContainer<WindowContainer> { if (mForceHiddenFlags == newFlags) { return false; } + final boolean wasHidden = isForceHidden(); + final boolean wasVisible = isVisible(); mForceHiddenFlags = newFlags; - if (wasHidden != isForceHidden() && isTopActivityFocusable()) { - // The change in force-hidden state will change visibility without triggering a root - // task order change, so we should reset the preferred top focusable root task to ensure - // it's not used if a new activity is started from this task. - getDisplayArea().resetPreferredTopFocusableRootTaskIfNeeded(this); + final boolean nowHidden = isForceHidden(); + if (wasHidden != nowHidden) { + final String reason = "setForceHidden"; + if (wasVisible && nowHidden) { + // Move this visible task to back when the task is forced hidden + moveToBack(reason, null); + } else if (isAlwaysOnTop()) { + // Move this always-on-top task to front when no longer hidden + moveToFront(reason); + } } return true; } + @Override + public boolean isAlwaysOnTop() { + return !isForceHidden() && super.isAlwaysOnTop(); + } + /** * Returns whether this task is currently forced to be hidden for any reason. */ @@ -7482,17 +7494,22 @@ class Task extends WindowContainer<WindowContainer> { } public void setAlwaysOnTop(boolean alwaysOnTop) { - if (isAlwaysOnTop() == alwaysOnTop) { + // {@link #isAwaysonTop} overrides the original behavior which also evaluates if this + // task is force hidden, so super.isAlwaysOnTop() is used here to see whether the + // alwaysOnTop attributes should be updated. + if (super.isAlwaysOnTop() == alwaysOnTop) { return; } super.setAlwaysOnTop(alwaysOnTop); - final TaskDisplayArea taskDisplayArea = getDisplayArea(); // positionChildAtTop() must be called even when always on top gets turned off because we // need to make sure that the root task is moved from among always on top windows to // below other always on top windows. Since the position the root task should be inserted // into is calculated properly in {@link DisplayContent#getTopInsertPosition()} in both // cases, we can just request that the root task is put at top here. - taskDisplayArea.positionChildAt(POSITION_TOP, this, false /* includingParents */); + // Don't bother moving task to top if this task is force hidden and invisible to user. + if (!isForceHidden()) { + getDisplayArea().positionChildAt(POSITION_TOP, this, false /* includingParents */); + } } void dismissPip() { diff --git a/services/core/java/com/android/server/wm/TaskDisplayArea.java b/services/core/java/com/android/server/wm/TaskDisplayArea.java index ed92fd08bef5..91aa48effe84 100644 --- a/services/core/java/com/android/server/wm/TaskDisplayArea.java +++ b/services/core/java/com/android/server/wm/TaskDisplayArea.java @@ -393,7 +393,7 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> { final boolean moveToBottom = position <= 0; final int oldPosition = mChildren.indexOf(child); - if (child.getWindowConfiguration().isAlwaysOnTop() && !moveToTop) { + if (child.isAlwaysOnTop() && !moveToTop) { // This root task is always-on-top, override the default behavior. Slog.w(TAG_WM, "Ignoring move of always-on-top root task=" + this + " to bottom"); @@ -974,14 +974,6 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> { onRootTaskOrderChanged(rootTask); } - /** Reset the mPreferredTopFocusableRootTask if it is or below the given task. */ - void resetPreferredTopFocusableRootTaskIfNeeded(Task task) { - if (mPreferredTopFocusableRootTask != null - && mPreferredTopFocusableRootTask.compareTo(task) <= 0) { - mPreferredTopFocusableRootTask = null; - } - } - /** * Moves/reparents `task` to the back of whatever container the root home task is in. This is * for when we just want to move a task to "the back" vs. a specific place. The primary use-case diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index a3dadd835202..c2e10cb9b010 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -473,7 +473,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { // to decide whether an existing policy in the {@link #DEVICE_POLICIES_XML} needs to // be upgraded. See {@link PolicyVersionUpgrader} on instructions how to add an upgrade // step. - static final int DPMS_VERSION = 1; + static final int DPMS_VERSION = 2; static { SECURE_SETTINGS_ALLOWLIST = new ArraySet<>(); @@ -2969,8 +2969,9 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { private class DpmsUpgradeDataProvider implements PolicyUpgraderDataProvider { @Override - public boolean isUserDeviceOwner(int userId) { - return mOwners.isDeviceOwnerUserId(userId); + public boolean isUserDeviceOwner(int userId, ComponentName who) { + return mOwners.isDeviceOwnerUserId(userId) + && mOwners.getDeviceOwnerComponent().equals(who); } @Override @@ -14214,10 +14215,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { hasCallingOrSelfPermission(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS)); enforceCallerSystemUserHandle(); - // no effect if it's called from user build - if (!mInjector.isBuildDebuggable()) { - return; - } final int userId = UserHandle.USER_SYSTEM; boolean isUserCompleted = mInjector.settingsSecureGetIntForUser( Settings.Secure.USER_SETUP_COMPLETE, 0, userId) != 0; diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/PolicyUpgraderDataProvider.java b/services/devicepolicy/java/com/android/server/devicepolicy/PolicyUpgraderDataProvider.java index b6420f8ff4bc..c20d0f5f5f5f 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/PolicyUpgraderDataProvider.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/PolicyUpgraderDataProvider.java @@ -33,7 +33,7 @@ public interface PolicyUpgraderDataProvider { * Returns true if the provided {@code userId} is a device owner. May affect some policy * defaults. */ - boolean isUserDeviceOwner(int userId); + boolean isUserDeviceOwner(int userId, ComponentName who); /** * Returns true if the storage manager indicates file-based encryption is enabled. diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/PolicyVersionUpgrader.java b/services/devicepolicy/java/com/android/server/devicepolicy/PolicyVersionUpgrader.java index cea08634910c..2ab4b66a6831 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/PolicyVersionUpgrader.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/PolicyVersionUpgrader.java @@ -83,6 +83,27 @@ public class PolicyVersionUpgrader { currentVersion = 1; } + if (currentVersion == 1) { + Slog.i(LOG_TAG, String.format("Upgrading from version %d", currentVersion)); + // This upgrade step is for Device Owner scenario only: For devices upgrading to S, + // if there is a device owner, it retains the ability to control sensors-related + // permission grants. + for (int userId : allUsers) { + DevicePolicyData userData = allUsersData.get(userId); + if (userData == null) { + continue; + } + for (ActiveAdmin admin : userData.mAdminList) { + if (mProvider.isUserDeviceOwner(userId, admin.info.getComponent())) { + Slog.i(LOG_TAG, String.format( + "Marking Device Owner in user %d for permission grant ", userId)); + admin.mAdminCanGrantSensorsPermissions = true; + } + } + } + currentVersion = 2; + } + writePoliciesAndVersion(allUsers, allUsersData, currentVersion); } diff --git a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java index 87100a63e35e..89435e9a8862 100644 --- a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java +++ b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java @@ -3875,7 +3875,7 @@ public class DevicePolicyManagerTest extends DpmTestBase { } @Test - public void testForceUpdateUserSetupComplete_userbuild() { + public void testForceUpdateUserSetupComplete_forcesUpdate() { mContext.callerPermissions.add(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS); mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID; @@ -3888,34 +3888,6 @@ public class DevicePolicyManagerTest extends DpmTestBase { userData.mUserSetupComplete = true; dpms.mUserData.put(UserHandle.USER_SYSTEM, userData); - // GIVEN it's user build - getServices().buildMock.isDebuggable = false; - - assertThat(dpms.hasUserSetupCompleted()).isTrue(); - - dpm.forceUpdateUserSetupComplete(); - - // THEN the state in dpms is not changed - assertThat(dpms.hasUserSetupCompleted()).isTrue(); - } - - @Test - public void testForceUpdateUserSetupComplete_userDebugbuild() { - mContext.callerPermissions.add(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS); - mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID; - - final int userId = UserHandle.USER_SYSTEM; - // GIVEN userComplete is false in SettingsProvider - setUserSetupCompleteForUser(false, userId); - - // GIVEN userComplete is true in DPM - DevicePolicyData userData = new DevicePolicyData(userId); - userData.mUserSetupComplete = true; - dpms.mUserData.put(UserHandle.USER_SYSTEM, userData); - - // GIVEN it's userdebug build - getServices().buildMock.isDebuggable = true; - assertThat(dpms.hasUserSetupCompleted()).isTrue(); dpm.forceUpdateUserSetupComplete(); diff --git a/services/tests/servicestests/src/com/android/server/devicepolicy/PolicyVersionUpgraderTest.java b/services/tests/servicestests/src/com/android/server/devicepolicy/PolicyVersionUpgraderTest.java index f94b800afbef..2fe47d3ff184 100644 --- a/services/tests/servicestests/src/com/android/server/devicepolicy/PolicyVersionUpgraderTest.java +++ b/services/tests/servicestests/src/com/android/server/devicepolicy/PolicyVersionUpgraderTest.java @@ -21,6 +21,11 @@ import static com.google.common.truth.Truth.assertThat; import android.app.admin.DeviceAdminInfo; import android.content.ComponentName; import android.content.Context; +import android.content.pm.ActivityInfo; +import android.content.pm.ApplicationInfo; +import android.os.Parcel; +import android.util.TypedXmlPullParser; +import android.util.Xml; import androidx.test.InstrumentationRegistry; @@ -32,9 +37,14 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; import java.io.IOException; +import java.io.InputStream; import java.nio.charset.Charset; import java.util.HashMap; import java.util.Map; @@ -44,18 +54,21 @@ import java.util.function.Function; public class PolicyVersionUpgraderTest { // NOTE: Only change this value if the corresponding CL also adds a test to test the upgrade // to the new version. - private static final int LATEST_TESTED_VERSION = 1; + private static final int LATEST_TESTED_VERSION = 2; + public static final String PERMISSIONS_TAG = "admin-can-grant-sensors-permissions"; + private ComponentName mFakeAdmin; private static class FakePolicyUpgraderDataProvider implements PolicyUpgraderDataProvider { int mDeviceOwnerUserId; + ComponentName mDeviceOwnerComponent = new ComponentName("", ""); boolean mIsFileBasedEncryptionEnabled; Map<Integer, ComponentName> mUserToComponent = new HashMap<>(); - Map<ComponentName, DeviceAdminInfo> mComponentToDeviceAdminInfo; + Map<ComponentName, DeviceAdminInfo> mComponentToDeviceAdminInfo = new HashMap<>(); File mDataDir; @Override - public boolean isUserDeviceOwner(int userId) { - return userId == mDeviceOwnerUserId; + public boolean isUserDeviceOwner(int userId, ComponentName who) { + return userId == mDeviceOwnerUserId && mDeviceOwnerComponent.equals(who); } @Override @@ -105,7 +118,14 @@ public class PolicyVersionUpgraderTest { mUpgrader = new PolicyVersionUpgrader(mProvider); mDataDir = new File(mRealTestContext.getCacheDir(), "test-data"); mDataDir.getParentFile().mkdirs(); + // Prepare provider. mProvider.mDataDir = mDataDir; + mFakeAdmin = new ComponentName( + "com.android.frameworks.servicestests", + "com.android.server.devicepolicy.DummyDeviceAdmins$Admin1"); + ActivityInfo activityInfo = createActivityInfo(mFakeAdmin); + DeviceAdminInfo dai = createDeviceAdminInfo(activityInfo); + mProvider.mComponentToDeviceAdminInfo.put(mFakeAdmin, dai); } @Test @@ -122,21 +142,43 @@ public class PolicyVersionUpgraderTest { } @Test - public void testUpgrade0To1RemovesPasswordMetrics() throws IOException { + public void testUpgrade0To1RemovesPasswordMetrics() throws IOException, XmlPullParserException { + final String activePasswordTag = "active-password"; int[] users = new int[] {0, 10}; writeVersionToXml(0); for (int userId : users) { preparePoliciesFile(userId); } - - String oldContents = readPoliciesFile(0); - assertThat(oldContents).contains("active-password"); + // Validate test set-up. + assertThat(isTagPresent(readPoliciesFileToStream(0), activePasswordTag)).isTrue(); mUpgrader.upgradePolicy(users, 1); - assertThat(readVersionFromXml()).isEqualTo(1); - assertThat(readPoliciesFile(users[0])).doesNotContain("active-password"); - assertThat(readPoliciesFile(users[1])).doesNotContain("active-password"); + assertThat(readVersionFromXml()).isGreaterThan(1); + for (int user: users) { + assertThat(isTagPresent(readPoliciesFileToStream(user), activePasswordTag)).isFalse(); + } + } + + @Test + public void testUpgrade1To2MarksDoForPermissionControl() + throws IOException, XmlPullParserException { + int[] users = new int[] {0, 10}; + writeVersionToXml(1); + for (int userId : users) { + preparePoliciesFile(userId); + } + mProvider.mDeviceOwnerUserId = 10; + mProvider.mDeviceOwnerComponent = mFakeAdmin; + mProvider.mUserToComponent.put(10, mFakeAdmin); + + mUpgrader.upgradePolicy(users, 2); + + assertThat(readVersionFromXml()).isEqualTo(2); + assertThat(getBooleanValueTag(readPoliciesFileToStream(users[0]), + PERMISSIONS_TAG)).isFalse(); + assertThat(getBooleanValueTag(readPoliciesFileToStream(users[1]), + PERMISSIONS_TAG)).isTrue(); } @Test @@ -169,6 +211,70 @@ public class PolicyVersionUpgraderTest { private String readPoliciesFile(int userId) throws IOException { File policiesFile = mProvider.makeDevicePoliciesJournaledFile(userId).chooseForRead(); - return new String(Files.asByteSource(policiesFile).read()); + FileReader reader = new FileReader(policiesFile); + return new String(Files.asByteSource(policiesFile).read(), Charset.defaultCharset()); + } + + private InputStream readPoliciesFileToStream(int userId) throws IOException { + File policiesFile = mProvider.makeDevicePoliciesJournaledFile(userId).chooseForRead(); + return new FileInputStream(policiesFile); + } + + private boolean getBooleanValueTag(InputStream inputXml, String tagName) + throws IOException, XmlPullParserException { + TypedXmlPullParser parser = Xml.resolvePullParser(inputXml); + + int eventType = parser.getEventType(); + while (eventType != XmlPullParser.END_DOCUMENT) { + if (eventType == XmlPullParser.START_TAG) { + String tag = parser.getName(); + if (tagName.equals(tag)) { + String res = parser.getAttributeValue(null, "value"); + return Boolean.parseBoolean(res); + } + } + eventType = parser.next(); + } + + throw new IllegalStateException("Could not find " + tagName); + } + + private boolean isTagPresent(InputStream inputXml, String tagName) + throws IOException, XmlPullParserException { + TypedXmlPullParser parser = Xml.resolvePullParser(inputXml); + + int eventType = parser.getEventType(); + while (eventType != XmlPullParser.END_DOCUMENT) { + if (eventType == XmlPullParser.START_TAG) { + String tag = parser.getName(); + if (tagName.equals(tag)) { + return true; + } + } + eventType = parser.next(); + } + + return false; + } + + private ActivityInfo createActivityInfo(ComponentName admin) { + ActivityInfo ai = new ActivityInfo(); + ApplicationInfo applicationInfo = new ApplicationInfo(); + applicationInfo.className = admin.getClassName(); + applicationInfo.uid = 2222; + ai.applicationInfo = applicationInfo; + ai.name = admin.getClassName(); + ai.packageName = admin.getPackageName(); + return ai; + } + + private DeviceAdminInfo createDeviceAdminInfo(ActivityInfo activityInfo) { + Parcel parcel = Parcel.obtain(); + activityInfo.writeToParcel(parcel, 0); + parcel.writeInt(0); + parcel.writeBoolean(true); + parcel.setDataPosition(0); + + return DeviceAdminInfo.CREATOR.createFromParcel(parcel); } } diff --git a/services/tests/servicestests/src/com/android/server/hdmi/SystemAudioAutoInitiationActionTest.java b/services/tests/servicestests/src/com/android/server/hdmi/SystemAudioAutoInitiationActionTest.java new file mode 100644 index 000000000000..865eb7a3b56d --- /dev/null +++ b/services/tests/servicestests/src/com/android/server/hdmi/SystemAudioAutoInitiationActionTest.java @@ -0,0 +1,343 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.hdmi; + + +import static com.android.server.hdmi.Constants.ADDR_AUDIO_SYSTEM; +import static com.android.server.hdmi.HdmiControlService.INITIATED_BY_ENABLE_CEC; +import static com.android.server.hdmi.SystemAudioAutoInitiationAction.RETRIES_ON_TIMEOUT; + +import static com.google.common.truth.Truth.assertThat; + +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.when; + +import android.content.Context; +import android.content.ContextWrapper; +import android.hardware.hdmi.HdmiPortInfo; +import android.media.AudioManager; +import android.os.Handler; +import android.os.IPowerManager; +import android.os.IThermalService; +import android.os.Looper; +import android.os.PowerManager; +import android.os.test.TestLooper; + +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.SmallTest; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import java.util.ArrayList; + +/** + * Test for {@link SystemAudioAutoInitiationAction}. + */ +@SmallTest +@RunWith(JUnit4.class) +public class SystemAudioAutoInitiationActionTest { + + private Context mContextSpy; + private HdmiControlService mHdmiControlService; + private FakeNativeWrapper mNativeWrapper; + + private HdmiCecLocalDeviceTv mHdmiCecLocalDeviceTv; + + private TestLooper mTestLooper = new TestLooper(); + private ArrayList<HdmiCecLocalDevice> mLocalDevices = new ArrayList<>(); + private int mPhysicalAddress; + + @Mock + private IPowerManager mIPowerManagerMock; + @Mock + private IThermalService mIThermalServiceMock; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + + mContextSpy = spy(new ContextWrapper(InstrumentationRegistry.getTargetContext())); + + Looper myLooper = mTestLooper.getLooper(); + PowerManager powerManager = new PowerManager(mContextSpy, mIPowerManagerMock, + mIThermalServiceMock, new Handler(myLooper)); + when(mContextSpy.getSystemService(Context.POWER_SERVICE)).thenReturn(powerManager); + when(mContextSpy.getSystemService(PowerManager.class)).thenReturn(powerManager); + when(mIPowerManagerMock.isInteractive()).thenReturn(true); + + mHdmiControlService = new HdmiControlService(mContextSpy) { + @Override + AudioManager getAudioManager() { + return new AudioManager() { + @Override + public void setWiredDeviceConnectionState( + int type, int state, String address, String name) { + // Do nothing. + } + }; + } + + @Override + void wakeUp() { + } + + @Override + boolean isPowerStandby() { + return false; + } + + @Override + protected PowerManager getPowerManager() { + return powerManager; + } + + @Override + protected void writeStringSystemProperty(String key, String value) { + // do nothing + } + }; + + mHdmiCecLocalDeviceTv = new HdmiCecLocalDeviceTv(mHdmiControlService); + mHdmiCecLocalDeviceTv.init(); + mHdmiControlService.setIoLooper(myLooper); + mNativeWrapper = new FakeNativeWrapper(); + HdmiCecController hdmiCecController = HdmiCecController.createWithNativeWrapper( + mHdmiControlService, mNativeWrapper, mHdmiControlService.getAtomWriter()); + mHdmiControlService.setCecController(hdmiCecController); + mHdmiControlService.setHdmiMhlController(HdmiMhlControllerStub.create(mHdmiControlService)); + mHdmiControlService.setMessageValidator(new HdmiCecMessageValidator(mHdmiControlService)); + mLocalDevices.add(mHdmiCecLocalDeviceTv); + HdmiPortInfo[] hdmiPortInfos = new HdmiPortInfo[2]; + hdmiPortInfos[0] = + new HdmiPortInfo(1, HdmiPortInfo.PORT_INPUT, 0x1000, true, false, false); + hdmiPortInfos[1] = + new HdmiPortInfo(2, HdmiPortInfo.PORT_INPUT, 0x2000, true, false, true); + mNativeWrapper.setPortInfo(hdmiPortInfos); + mHdmiControlService.initService(); + mHdmiControlService.allocateLogicalAddress(mLocalDevices, INITIATED_BY_ENABLE_CEC); + mPhysicalAddress = 0x0000; + mNativeWrapper.setPhysicalAddress(mPhysicalAddress); + mTestLooper.dispatchAll(); + mPhysicalAddress = mHdmiCecLocalDeviceTv.getDeviceInfo().getLogicalAddress(); + mNativeWrapper.clearResultMessages(); + } + + private void setSystemAudioSetting(boolean on) { + mHdmiCecLocalDeviceTv.setSystemAudioControlFeatureEnabled(on); + } + + private void setTvHasSystemAudioChangeAction() { + mHdmiCecLocalDeviceTv.addAndStartAction( + new SystemAudioActionFromTv(mHdmiCecLocalDeviceTv, Constants.ADDR_AUDIO_SYSTEM, + true, null)); + } + + @Test + public void testReceiveSystemAudioMode_systemAudioOn() { + // Record that previous system audio mode is on. + setSystemAudioSetting(true); + + HdmiCecFeatureAction action = new SystemAudioAutoInitiationAction(mHdmiCecLocalDeviceTv, + ADDR_AUDIO_SYSTEM); + mHdmiCecLocalDeviceTv.addAndStartAction(action); + mTestLooper.dispatchAll(); + + HdmiCecMessage giveSystemAudioModeStatus = + HdmiCecMessageBuilder.buildGiveSystemAudioModeStatus( + mHdmiCecLocalDeviceTv.mAddress, ADDR_AUDIO_SYSTEM); + + assertThat(mNativeWrapper.getResultMessages()).contains(giveSystemAudioModeStatus); + + HdmiCecMessage reportSystemAudioMode = HdmiCecMessageBuilder.buildReportSystemAudioMode( + ADDR_AUDIO_SYSTEM, mHdmiCecLocalDeviceTv.mAddress, true); + mHdmiControlService.handleCecCommand(reportSystemAudioMode); + mTestLooper.dispatchAll(); + + assertThat(mHdmiControlService.isSystemAudioActivated()).isTrue(); + } + + @Test + public void testReceiveSystemAudioMode_systemAudioOnAndImpossibleToChangeSystemAudio() { + // Turn on system audio. + setSystemAudioSetting(true); + // Impossible to change system audio mode while SystemAudioActionFromTv is in progress. + setTvHasSystemAudioChangeAction(); + + HdmiCecFeatureAction action = new SystemAudioAutoInitiationAction(mHdmiCecLocalDeviceTv, + ADDR_AUDIO_SYSTEM); + mHdmiCecLocalDeviceTv.addAndStartAction(action); + mTestLooper.dispatchAll(); + + HdmiCecMessage giveSystemAudioModeStatus = + HdmiCecMessageBuilder.buildGiveSystemAudioModeStatus( + mHdmiCecLocalDeviceTv.mAddress, ADDR_AUDIO_SYSTEM); + + assertThat(mNativeWrapper.getResultMessages()).contains(giveSystemAudioModeStatus); + + HdmiCecMessage reportSystemAudioMode = HdmiCecMessageBuilder.buildReportSystemAudioMode( + ADDR_AUDIO_SYSTEM, mHdmiCecLocalDeviceTv.mAddress, true); + mHdmiControlService.handleCecCommand(reportSystemAudioMode); + mTestLooper.dispatchAll(); + + assertThat(mHdmiControlService.isSystemAudioActivated()).isFalse(); + } + + @Test + public void testReceiveSystemAudioMode_systemAudioOnAndResponseOff() { + // Record that previous system audio mode is on. + setSystemAudioSetting(true); + + HdmiCecFeatureAction action = new SystemAudioAutoInitiationAction(mHdmiCecLocalDeviceTv, + ADDR_AUDIO_SYSTEM); + mHdmiCecLocalDeviceTv.addAndStartAction(action); + mTestLooper.dispatchAll(); + + HdmiCecMessage giveSystemAudioModeStatus = + HdmiCecMessageBuilder.buildGiveSystemAudioModeStatus( + mHdmiCecLocalDeviceTv.mAddress, ADDR_AUDIO_SYSTEM); + + assertThat(mNativeWrapper.getResultMessages()).contains(giveSystemAudioModeStatus); + + HdmiCecMessage reportSystemAudioMode = HdmiCecMessageBuilder.buildReportSystemAudioMode( + ADDR_AUDIO_SYSTEM, mHdmiCecLocalDeviceTv.mAddress, false); + mHdmiControlService.handleCecCommand(reportSystemAudioMode); + mTestLooper.dispatchAll(); + + assertThat(mHdmiCecLocalDeviceTv.getActions(SystemAudioActionFromTv.class)).isNotEmpty(); + SystemAudioActionFromTv resultingAction = mHdmiCecLocalDeviceTv.getActions( + SystemAudioActionFromTv.class).get(0); + assertThat(resultingAction.mTargetAudioStatus).isTrue(); + } + + @Test + public void testReceiveSystemAudioMode_settingOffAndResponseOn() { + // Turn off system audio. + setSystemAudioSetting(false); + + HdmiCecFeatureAction action = new SystemAudioAutoInitiationAction(mHdmiCecLocalDeviceTv, + ADDR_AUDIO_SYSTEM); + mHdmiCecLocalDeviceTv.addAndStartAction(action); + mTestLooper.dispatchAll(); + + HdmiCecMessage giveSystemAudioModeStatus = + HdmiCecMessageBuilder.buildGiveSystemAudioModeStatus( + mHdmiCecLocalDeviceTv.mAddress, ADDR_AUDIO_SYSTEM); + + assertThat(mNativeWrapper.getResultMessages()).contains(giveSystemAudioModeStatus); + + HdmiCecMessage reportSystemAudioMode = HdmiCecMessageBuilder.buildReportSystemAudioMode( + ADDR_AUDIO_SYSTEM, mHdmiCecLocalDeviceTv.mAddress, true); + mHdmiControlService.handleCecCommand(reportSystemAudioMode); + mTestLooper.dispatchAll(); + + assertThat(mHdmiCecLocalDeviceTv.getActions(SystemAudioActionFromTv.class)).isNotEmpty(); + SystemAudioActionFromTv resultingAction = mHdmiCecLocalDeviceTv.getActions( + SystemAudioActionFromTv.class).get(0); + assertThat(resultingAction.mTargetAudioStatus).isFalse(); + } + + @Test + public void testReceiveSystemAudioMode_settingOffAndResponseOff() { + // Turn off system audio. + setSystemAudioSetting(false); + + HdmiCecFeatureAction action = new SystemAudioAutoInitiationAction(mHdmiCecLocalDeviceTv, + ADDR_AUDIO_SYSTEM); + mHdmiCecLocalDeviceTv.addAndStartAction(action); + mTestLooper.dispatchAll(); + + HdmiCecMessage giveSystemAudioModeStatus = + HdmiCecMessageBuilder.buildGiveSystemAudioModeStatus( + mHdmiCecLocalDeviceTv.mAddress, ADDR_AUDIO_SYSTEM); + + assertThat(mNativeWrapper.getResultMessages()).contains(giveSystemAudioModeStatus); + + HdmiCecMessage reportSystemAudioMode = HdmiCecMessageBuilder.buildReportSystemAudioMode( + ADDR_AUDIO_SYSTEM, mHdmiCecLocalDeviceTv.mAddress, false); + mHdmiControlService.handleCecCommand(reportSystemAudioMode); + mTestLooper.dispatchAll(); + + assertThat(mHdmiCecLocalDeviceTv.getActions(SystemAudioActionFromTv.class)).isEmpty(); + assertThat(mHdmiControlService.isSystemAudioActivated()).isFalse(); + } + + @Test + public void testTimeout_systemAudioOn_retries() { + // Turn on system audio. + setSystemAudioSetting(true); + + HdmiCecFeatureAction action = new SystemAudioAutoInitiationAction(mHdmiCecLocalDeviceTv, + ADDR_AUDIO_SYSTEM); + mHdmiCecLocalDeviceTv.addAndStartAction(action); + mTestLooper.dispatchAll(); + + HdmiCecMessage giveSystemAudioModeStatus = + HdmiCecMessageBuilder.buildGiveSystemAudioModeStatus( + mHdmiCecLocalDeviceTv.mAddress, ADDR_AUDIO_SYSTEM); + + assertThat(mNativeWrapper.getResultMessages()).contains(giveSystemAudioModeStatus); + mNativeWrapper.clearResultMessages(); + + mTestLooper.moveTimeForward(HdmiConfig.TIMEOUT_MS); + mTestLooper.dispatchAll(); + + // Retry sends <Give System Audio Mode Status> again + assertThat(mNativeWrapper.getResultMessages()).contains(giveSystemAudioModeStatus); + } + + @Test + public void testTimeout_systemAudioOn_allRetriesFail() { + boolean targetStatus = true; + // Turn on system audio. + setSystemAudioSetting(targetStatus); + + HdmiCecFeatureAction action = new SystemAudioAutoInitiationAction(mHdmiCecLocalDeviceTv, + ADDR_AUDIO_SYSTEM); + mHdmiCecLocalDeviceTv.addAndStartAction(action); + mTestLooper.dispatchAll(); + + HdmiCecMessage giveSystemAudioModeStatus = + HdmiCecMessageBuilder.buildGiveSystemAudioModeStatus( + mHdmiCecLocalDeviceTv.mAddress, ADDR_AUDIO_SYSTEM); + assertThat(mNativeWrapper.getResultMessages()).contains(giveSystemAudioModeStatus); + + for (int i = 0; i < RETRIES_ON_TIMEOUT; i++) { + mNativeWrapper.clearResultMessages(); + + // Target device doesn't respond within timeout + mTestLooper.moveTimeForward(HdmiConfig.TIMEOUT_MS); + mTestLooper.dispatchAll(); + + // Retry sends <Give System Audio Mode Status> again + assertThat(mNativeWrapper.getResultMessages()).contains(giveSystemAudioModeStatus); + } + + // Target device doesn't respond within timeouts + mTestLooper.moveTimeForward(HdmiConfig.TIMEOUT_MS); + mTestLooper.dispatchAll(); + + assertThat(mHdmiCecLocalDeviceTv.getActions(SystemAudioActionFromTv.class)).isNotEmpty(); + SystemAudioActionFromTv resultingAction = mHdmiCecLocalDeviceTv.getActions( + SystemAudioActionFromTv.class).get(0); + assertThat(resultingAction.mTargetAudioStatus).isEqualTo(targetStatus); + } +} diff --git a/services/tests/servicestests/src/com/android/server/inputmethod/InputMethodManagerServiceTests.java b/services/tests/servicestests/src/com/android/server/inputmethod/InputMethodManagerServiceTests.java index 1db5544871bf..d07831dd7929 100644 --- a/services/tests/servicestests/src/com/android/server/inputmethod/InputMethodManagerServiceTests.java +++ b/services/tests/servicestests/src/com/android/server/inputmethod/InputMethodManagerServiceTests.java @@ -11,15 +11,15 @@ * 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 + * limitations under the License. */ package com.android.server.inputmethod; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.INVALID_DISPLAY; -import static android.view.WindowManager.DISPLAY_IME_POLICY_LOCAL; import static android.view.WindowManager.DISPLAY_IME_POLICY_FALLBACK_DISPLAY; +import static android.view.WindowManager.DISPLAY_IME_POLICY_LOCAL; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; diff --git a/services/tests/servicestests/src/com/android/server/inputmethod/InputMethodSubtypeSwitchingControllerTest.java b/services/tests/servicestests/src/com/android/server/inputmethod/InputMethodSubtypeSwitchingControllerTest.java index 6ab48e53648c..9092ec325946 100644 --- a/services/tests/servicestests/src/com/android/server/inputmethod/InputMethodSubtypeSwitchingControllerTest.java +++ b/services/tests/servicestests/src/com/android/server/inputmethod/InputMethodSubtypeSwitchingControllerTest.java @@ -177,10 +177,10 @@ public class InputMethodSubtypeSwitchingControllerTest { private void assertRotationOrder(final ControllerImpl controller, final boolean onlyCurrentIme, final ImeSubtypeListItem... expectedRotationOrderOfImeSubtypeList) { - final int N = expectedRotationOrderOfImeSubtypeList.length; - for (int i = 0; i < N; i++) { + final int numItems = expectedRotationOrderOfImeSubtypeList.length; + for (int i = 0; i < numItems; i++) { final int currentIndex = i; - final int nextIndex = (currentIndex + 1) % N; + final int nextIndex = (currentIndex + 1) % numItems; final ImeSubtypeListItem currentItem = expectedRotationOrderOfImeSubtypeList[currentIndex]; final ImeSubtypeListItem nextItem = expectedRotationOrderOfImeSubtypeList[nextIndex]; @@ -200,47 +200,47 @@ public class InputMethodSubtypeSwitchingControllerTest { @Test public void testControllerImpl() throws Exception { final List<ImeSubtypeListItem> disabledItems = createDisabledImeSubtypes(); - final ImeSubtypeListItem disabledIme_en_US = disabledItems.get(0); + final ImeSubtypeListItem disabledIme_en_us = disabledItems.get(0); final ImeSubtypeListItem disabledIme_hi = disabledItems.get(1); final ImeSubtypeListItem disabledSwitchingUnawareIme = disabledItems.get(2); final ImeSubtypeListItem disabledSubtypeUnawareIme = disabledItems.get(3); final List<ImeSubtypeListItem> enabledItems = createEnabledImeSubtypes(); - final ImeSubtypeListItem latinIme_en_US = enabledItems.get(0); + final ImeSubtypeListItem latinIme_en_us = enabledItems.get(0); final ImeSubtypeListItem latinIme_fr = enabledItems.get(1); - final ImeSubtypeListItem switchingUnawarelatinIme_en_UK = enabledItems.get(2); - final ImeSubtypeListItem switchingUnawarelatinIme_hi = enabledItems.get(3); + final ImeSubtypeListItem switchingUnawareLatinIme_en_uk = enabledItems.get(2); + final ImeSubtypeListItem switchingUnawareLatinIme_hi = enabledItems.get(3); final ImeSubtypeListItem subtypeUnawareIme = enabledItems.get(4); - final ImeSubtypeListItem japaneseIme_ja_JP = enabledItems.get(5); - final ImeSubtypeListItem switchUnawareJapaneseIme_ja_JP = enabledItems.get(6); + final ImeSubtypeListItem japaneseIme_ja_jp = enabledItems.get(5); + final ImeSubtypeListItem switchUnawareJapaneseIme_ja_jp = enabledItems.get(6); final ControllerImpl controller = ControllerImpl.createFrom( null /* currentInstance */, enabledItems); // switching-aware loop assertRotationOrder(controller, false /* onlyCurrentIme */, - latinIme_en_US, latinIme_fr, japaneseIme_ja_JP); + latinIme_en_us, latinIme_fr, japaneseIme_ja_jp); // switching-unaware loop assertRotationOrder(controller, false /* onlyCurrentIme */, - switchingUnawarelatinIme_en_UK, switchingUnawarelatinIme_hi, subtypeUnawareIme, - switchUnawareJapaneseIme_ja_JP); + switchingUnawareLatinIme_en_uk, switchingUnawareLatinIme_hi, subtypeUnawareIme, + switchUnawareJapaneseIme_ja_jp); // test onlyCurrentIme == true assertRotationOrder(controller, true /* onlyCurrentIme */, - latinIme_en_US, latinIme_fr); + latinIme_en_us, latinIme_fr); assertRotationOrder(controller, true /* onlyCurrentIme */, - switchingUnawarelatinIme_en_UK, switchingUnawarelatinIme_hi); + switchingUnawareLatinIme_en_uk, switchingUnawareLatinIme_hi); assertNextInputMethod(controller, true /* onlyCurrentIme */, subtypeUnawareIme, null); assertNextInputMethod(controller, true /* onlyCurrentIme */, - japaneseIme_ja_JP, null); + japaneseIme_ja_jp, null); assertNextInputMethod(controller, true /* onlyCurrentIme */, - switchUnawareJapaneseIme_ja_JP, null); + switchUnawareJapaneseIme_ja_jp, null); // Make sure that disabled IMEs are not accepted. assertNextInputMethod(controller, false /* onlyCurrentIme */, - disabledIme_en_US, null); + disabledIme_en_us, null); assertNextInputMethod(controller, false /* onlyCurrentIme */, disabledIme_hi, null); assertNextInputMethod(controller, false /* onlyCurrentIme */, @@ -248,7 +248,7 @@ public class InputMethodSubtypeSwitchingControllerTest { assertNextInputMethod(controller, false /* onlyCurrentIme */, disabledSubtypeUnawareIme, null); assertNextInputMethod(controller, true /* onlyCurrentIme */, - disabledIme_en_US, null); + disabledIme_en_us, null); assertNextInputMethod(controller, true /* onlyCurrentIme */, disabledIme_hi, null); assertNextInputMethod(controller, true /* onlyCurrentIme */, @@ -260,82 +260,82 @@ public class InputMethodSubtypeSwitchingControllerTest { @Test public void testControllerImplWithUserAction() throws Exception { final List<ImeSubtypeListItem> enabledItems = createEnabledImeSubtypes(); - final ImeSubtypeListItem latinIme_en_US = enabledItems.get(0); + final ImeSubtypeListItem latinIme_en_us = enabledItems.get(0); final ImeSubtypeListItem latinIme_fr = enabledItems.get(1); - final ImeSubtypeListItem switchingUnawarelatinIme_en_UK = enabledItems.get(2); + final ImeSubtypeListItem switchingUnawarelatinIme_en_uk = enabledItems.get(2); final ImeSubtypeListItem switchingUnawarelatinIme_hi = enabledItems.get(3); final ImeSubtypeListItem subtypeUnawareIme = enabledItems.get(4); - final ImeSubtypeListItem japaneseIme_ja_JP = enabledItems.get(5); - final ImeSubtypeListItem switchUnawareJapaneseIme_ja_JP = enabledItems.get(6); + final ImeSubtypeListItem japaneseIme_ja_jp = enabledItems.get(5); + final ImeSubtypeListItem switchUnawareJapaneseIme_ja_jp = enabledItems.get(6); final ControllerImpl controller = ControllerImpl.createFrom( null /* currentInstance */, enabledItems); // === switching-aware loop === assertRotationOrder(controller, false /* onlyCurrentIme */, - latinIme_en_US, latinIme_fr, japaneseIme_ja_JP); + latinIme_en_us, latinIme_fr, japaneseIme_ja_jp); // Then notify that a user did something for latinIme_fr. onUserAction(controller, latinIme_fr); assertRotationOrder(controller, false /* onlyCurrentIme */, - latinIme_fr, latinIme_en_US, japaneseIme_ja_JP); + latinIme_fr, latinIme_en_us, japaneseIme_ja_jp); // Then notify that a user did something for latinIme_fr again. onUserAction(controller, latinIme_fr); assertRotationOrder(controller, false /* onlyCurrentIme */, - latinIme_fr, latinIme_en_US, japaneseIme_ja_JP); + latinIme_fr, latinIme_en_us, japaneseIme_ja_jp); // Then notify that a user did something for japaneseIme_ja_JP. onUserAction(controller, latinIme_fr); assertRotationOrder(controller, false /* onlyCurrentIme */, - japaneseIme_ja_JP, latinIme_fr, latinIme_en_US); + japaneseIme_ja_jp, latinIme_fr, latinIme_en_us); // Check onlyCurrentIme == true. assertNextInputMethod(controller, true /* onlyCurrentIme */, - japaneseIme_ja_JP, null); + japaneseIme_ja_jp, null); assertRotationOrder(controller, true /* onlyCurrentIme */, - latinIme_fr, latinIme_en_US); + latinIme_fr, latinIme_en_us); assertRotationOrder(controller, true /* onlyCurrentIme */, - latinIme_en_US, latinIme_fr); + latinIme_en_us, latinIme_fr); // === switching-unaware loop === assertRotationOrder(controller, false /* onlyCurrentIme */, - switchingUnawarelatinIme_en_UK, switchingUnawarelatinIme_hi, subtypeUnawareIme, - switchUnawareJapaneseIme_ja_JP); + switchingUnawarelatinIme_en_uk, switchingUnawarelatinIme_hi, subtypeUnawareIme, + switchUnawareJapaneseIme_ja_jp); // User action should be ignored for switching unaware IMEs. onUserAction(controller, switchingUnawarelatinIme_hi); assertRotationOrder(controller, false /* onlyCurrentIme */, - switchingUnawarelatinIme_en_UK, switchingUnawarelatinIme_hi, subtypeUnawareIme, - switchUnawareJapaneseIme_ja_JP); + switchingUnawarelatinIme_en_uk, switchingUnawarelatinIme_hi, subtypeUnawareIme, + switchUnawareJapaneseIme_ja_jp); // User action should be ignored for switching unaware IMEs. - onUserAction(controller, switchUnawareJapaneseIme_ja_JP); + onUserAction(controller, switchUnawareJapaneseIme_ja_jp); assertRotationOrder(controller, false /* onlyCurrentIme */, - switchingUnawarelatinIme_en_UK, switchingUnawarelatinIme_hi, subtypeUnawareIme, - switchUnawareJapaneseIme_ja_JP); + switchingUnawarelatinIme_en_uk, switchingUnawarelatinIme_hi, subtypeUnawareIme, + switchUnawareJapaneseIme_ja_jp); // Check onlyCurrentIme == true. assertRotationOrder(controller, true /* onlyCurrentIme */, - switchingUnawarelatinIme_en_UK, switchingUnawarelatinIme_hi); + switchingUnawarelatinIme_en_uk, switchingUnawarelatinIme_hi); assertNextInputMethod(controller, true /* onlyCurrentIme */, subtypeUnawareIme, null); assertNextInputMethod(controller, true /* onlyCurrentIme */, - switchUnawareJapaneseIme_ja_JP, null); + switchUnawareJapaneseIme_ja_jp, null); // Rotation order should be preserved when created with the same subtype list. final List<ImeSubtypeListItem> sameEnabledItems = createEnabledImeSubtypes(); final ControllerImpl newController = ControllerImpl.createFrom(controller, sameEnabledItems); assertRotationOrder(newController, false /* onlyCurrentIme */, - japaneseIme_ja_JP, latinIme_fr, latinIme_en_US); + japaneseIme_ja_jp, latinIme_fr, latinIme_en_us); assertRotationOrder(newController, false /* onlyCurrentIme */, - switchingUnawarelatinIme_en_UK, switchingUnawarelatinIme_hi, subtypeUnawareIme, - switchUnawareJapaneseIme_ja_JP); + switchingUnawarelatinIme_en_uk, switchingUnawarelatinIme_hi, subtypeUnawareIme, + switchUnawareJapaneseIme_ja_jp); // Rotation order should be initialized when created with a different subtype list. final List<ImeSubtypeListItem> differentEnabledItems = Arrays.asList( - latinIme_en_US, latinIme_fr, switchingUnawarelatinIme_en_UK, - switchUnawareJapaneseIme_ja_JP); + latinIme_en_us, latinIme_fr, switchingUnawarelatinIme_en_uk, + switchUnawareJapaneseIme_ja_jp); final ControllerImpl anotherController = ControllerImpl.createFrom(controller, differentEnabledItems); assertRotationOrder(anotherController, false /* onlyCurrentIme */, - latinIme_en_US, latinIme_fr); + latinIme_en_us, latinIme_fr); assertRotationOrder(anotherController, false /* onlyCurrentIme */, - switchingUnawarelatinIme_en_UK, switchUnawareJapaneseIme_ja_JP); + switchingUnawarelatinIme_en_uk, switchUnawareJapaneseIme_ja_jp); } @Test @@ -344,27 +344,27 @@ public class InputMethodSubtypeSwitchingControllerTest { addDummyImeSubtypeListItems(items, "LatinIme", "LatinIme", Arrays.asList("en_US", "fr", "en", "en_uk", "enn", "e", "EN_US"), true /* supportsSwitchingToNextInputMethod*/); - final ImeSubtypeListItem item_en_US = items.get(0); + final ImeSubtypeListItem item_en_us = items.get(0); final ImeSubtypeListItem item_fr = items.get(1); final ImeSubtypeListItem item_en = items.get(2); final ImeSubtypeListItem item_enn = items.get(3); final ImeSubtypeListItem item_e = items.get(4); - final ImeSubtypeListItem item_EN_US = items.get(5); + final ImeSubtypeListItem item_en_us_allcaps = items.get(5); - assertTrue(item_en_US.mIsSystemLocale); + assertTrue(item_en_us.mIsSystemLocale); assertFalse(item_fr.mIsSystemLocale); assertFalse(item_en.mIsSystemLocale); assertFalse(item_en.mIsSystemLocale); assertFalse(item_enn.mIsSystemLocale); assertFalse(item_e.mIsSystemLocale); - assertFalse(item_EN_US.mIsSystemLocale); + assertFalse(item_en_us_allcaps.mIsSystemLocale); - assertTrue(item_en_US.mIsSystemLanguage); + assertTrue(item_en_us.mIsSystemLanguage); assertFalse(item_fr.mIsSystemLanguage); assertTrue(item_en.mIsSystemLanguage); assertFalse(item_enn.mIsSystemLocale); assertFalse(item_e.mIsSystemLocale); - assertFalse(item_EN_US.mIsSystemLocale); + assertFalse(item_en_us_allcaps.mIsSystemLocale); } @Test diff --git a/services/tests/servicestests/src/com/android/server/inputmethod/InputMethodUtilsTest.java b/services/tests/servicestests/src/com/android/server/inputmethod/InputMethodUtilsTest.java index 1d914ec083fa..eebc25aab279 100644 --- a/services/tests/servicestests/src/com/android/server/inputmethod/InputMethodUtilsTest.java +++ b/services/tests/servicestests/src/com/android/server/inputmethod/InputMethodUtilsTest.java @@ -60,6 +60,7 @@ public class InputMethodUtilsTest { private static final boolean IS_OVERRIDES_IMPLICITLY_ENABLED_SUBTYPE = true; private static final boolean IS_ASCII_CAPABLE = true; private static final boolean IS_ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE = true; + private static final boolean CHECK_COUNTRY = true; private static final Locale LOCALE_EN = new Locale("en"); private static final Locale LOCALE_EN_US = new Locale("en", "US"); private static final Locale LOCALE_EN_GB = new Locale("en", "GB"); @@ -668,8 +669,6 @@ public class InputMethodUtilsTest { SUBTYPE_MODE_KEYBOARD, !IS_AUX, !IS_OVERRIDES_IMPLICITLY_ENABLED_SUBTYPE, IS_ASCII_CAPABLE, IS_ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE); - final boolean CHECK_COUNTRY = true; - { final ArrayList<InputMethodSubtype> subtypes = new ArrayList<>(); subtypes.add(nonAutoEnUS); diff --git a/services/tests/servicestests/src/com/android/server/locksettings/recoverablekeystore/PlatformKeyManagerTest.java b/services/tests/servicestests/src/com/android/server/locksettings/recoverablekeystore/PlatformKeyManagerTest.java index dd3054f6543c..3fd2c97075ac 100644 --- a/services/tests/servicestests/src/com/android/server/locksettings/recoverablekeystore/PlatformKeyManagerTest.java +++ b/services/tests/servicestests/src/com/android/server/locksettings/recoverablekeystore/PlatformKeyManagerTest.java @@ -32,7 +32,6 @@ import android.app.KeyguardManager; import android.content.Context; import android.os.RemoteException; import android.security.GateKeeper; -import android.security.keystore.AndroidKeyStoreSecretKey; import android.security.keystore.KeyGenParameterSpec; import android.security.keystore.KeyProperties; import android.security.keystore.KeyProtection; @@ -59,6 +58,7 @@ import java.security.UnrecoverableKeyException; import java.util.List; import javax.crypto.KeyGenerator; +import javax.crypto.SecretKey; @SmallTest @RunWith(AndroidJUnit4.class) @@ -575,7 +575,7 @@ public class PlatformKeyManagerTest { return (KeyProtection) mProtectionParameterCaptor.getValue(); } - private AndroidKeyStoreSecretKey generateAndroidKeyStoreKey() throws Exception { + private SecretKey generateAndroidKeyStoreKey() throws Exception { KeyGenerator keyGenerator = KeyGenerator.getInstance( KEY_ALGORITHM, ANDROID_KEY_STORE_PROVIDER); @@ -584,7 +584,7 @@ public class PlatformKeyManagerTest { .setBlockModes(KeyProperties.BLOCK_MODE_GCM) .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE) .build()); - return (AndroidKeyStoreSecretKey) keyGenerator.generateKey(); + return keyGenerator.generateKey(); } class PlatformKeyManagerTestable extends PlatformKeyManager { diff --git a/services/tests/servicestests/src/com/android/server/timedetector/TimeDetectorServiceTest.java b/services/tests/servicestests/src/com/android/server/timedetector/TimeDetectorServiceTest.java index 5f86d282406a..bbf11fd557a3 100644 --- a/services/tests/servicestests/src/com/android/server/timedetector/TimeDetectorServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/timedetector/TimeDetectorServiceTest.java @@ -209,7 +209,7 @@ public class TimeDetectorServiceTest { @Test(expected = SecurityException.class) public void testSuggestExternalTime_withoutPermission() { doThrow(new SecurityException("Mock")) - .when(mMockContext).enforceCallingOrSelfPermission(anyString(), any()); + .when(mMockContext).enforceCallingPermission(anyString(), any()); ExternalTimeSuggestion externalTimeSuggestion = createExternalTimeSuggestion(); try { diff --git a/services/tests/servicestests/src/com/android/server/timezonedetector/location/ControllerImplTest.java b/services/tests/servicestests/src/com/android/server/timezonedetector/location/ControllerImplTest.java index 4284240c72b4..3daa7f0483c6 100644 --- a/services/tests/servicestests/src/com/android/server/timezonedetector/location/ControllerImplTest.java +++ b/services/tests/servicestests/src/com/android/server/timezonedetector/location/ControllerImplTest.java @@ -72,6 +72,7 @@ public class ControllerImplTest { private TestCallback mTestCallback; private TestLocationTimeZoneProvider mTestPrimaryLocationTimeZoneProvider; private TestLocationTimeZoneProvider mTestSecondaryLocationTimeZoneProvider; + private FakeTimeZoneIdValidator mTimeZoneAvailabilityChecker; @Before public void setUp() { @@ -80,10 +81,13 @@ public class ControllerImplTest { // will never get a chance to execute. mTestThreadingDomain = new TestThreadingDomain(); mTestCallback = new TestCallback(mTestThreadingDomain); + mTimeZoneAvailabilityChecker = new FakeTimeZoneIdValidator(); mTestPrimaryLocationTimeZoneProvider = - new TestLocationTimeZoneProvider(mTestThreadingDomain, "primary"); + new TestLocationTimeZoneProvider( + mTestThreadingDomain, "primary", mTimeZoneAvailabilityChecker); mTestSecondaryLocationTimeZoneProvider = - new TestLocationTimeZoneProvider(mTestThreadingDomain, "secondary"); + new TestLocationTimeZoneProvider( + mTestThreadingDomain, "secondary", mTimeZoneAvailabilityChecker); } @Test @@ -1177,8 +1181,10 @@ public class ControllerImplTest { /** * Creates the instance. */ - TestLocationTimeZoneProvider(ThreadingDomain threadingDomain, String providerName) { - super(threadingDomain, providerName); + TestLocationTimeZoneProvider(ThreadingDomain threadingDomain, + String providerName, + TimeZoneIdValidator timeZoneIdValidator) { + super(threadingDomain, providerName, timeZoneIdValidator); } public void setFailDuringInitialization(boolean failInitialization) { @@ -1311,4 +1317,14 @@ public class ControllerImplTest { mTestProviderState.commitLatest(); } } + + private static final class FakeTimeZoneIdValidator + implements LocationTimeZoneProvider.TimeZoneIdValidator { + + @Override + public boolean isValid(@NonNull String timeZoneId) { + return true; + } + + } } diff --git a/services/tests/servicestests/src/com/android/server/timezonedetector/location/LocationTimeZoneProviderTest.java b/services/tests/servicestests/src/com/android/server/timezonedetector/location/LocationTimeZoneProviderTest.java index 095c868fc74c..278fdaff260f 100644 --- a/services/tests/servicestests/src/com/android/server/timezonedetector/location/LocationTimeZoneProviderTest.java +++ b/services/tests/servicestests/src/com/android/server/timezonedetector/location/LocationTimeZoneProviderTest.java @@ -32,6 +32,8 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; +import static java.util.Arrays.asList; + import android.annotation.NonNull; import android.annotation.Nullable; import android.os.Bundle; @@ -50,7 +52,9 @@ import org.junit.Test; import java.time.Duration; import java.util.Arrays; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.atomic.AtomicReference; /** @@ -62,20 +66,25 @@ public class LocationTimeZoneProviderTest { private static final long ARBITRARY_ELAPSED_REALTIME_MILLIS = 123456789L; private TestThreadingDomain mTestThreadingDomain; - private TestProviderListener mProviderListener; + private FakeTimeZoneIdValidator mTimeZoneAvailabilityChecker; @Before public void setUp() { mTestThreadingDomain = new TestThreadingDomain(); mProviderListener = new TestProviderListener(); + mTimeZoneAvailabilityChecker = new FakeTimeZoneIdValidator(); } @Test public void lifecycle() { String providerName = "arbitrary"; TestLocationTimeZoneProvider provider = - new TestLocationTimeZoneProvider(mTestThreadingDomain, providerName); + new TestLocationTimeZoneProvider( + mTestThreadingDomain, + providerName, + mTimeZoneAvailabilityChecker); + mTimeZoneAvailabilityChecker.validIds("Europe/London"); // initialize() provider.initialize(mProviderListener); @@ -163,7 +172,10 @@ public class LocationTimeZoneProviderTest { public void defaultHandleTestCommandImpl() { String providerName = "primary"; TestLocationTimeZoneProvider provider = - new TestLocationTimeZoneProvider(mTestThreadingDomain, providerName); + new TestLocationTimeZoneProvider( + mTestThreadingDomain, + providerName, + mTimeZoneAvailabilityChecker); TestCommand testCommand = TestCommand.createForTests("test", new Bundle()); AtomicReference<Bundle> resultReference = new AtomicReference<>(); @@ -180,8 +192,12 @@ public class LocationTimeZoneProviderTest { public void stateRecording() { String providerName = "primary"; TestLocationTimeZoneProvider provider = - new TestLocationTimeZoneProvider(mTestThreadingDomain, providerName); + new TestLocationTimeZoneProvider( + mTestThreadingDomain, + providerName, + mTimeZoneAvailabilityChecker); provider.setStateChangeRecordingEnabled(true); + mTimeZoneAvailabilityChecker.validIds("Europe/London"); // initialize() provider.initialize(mProviderListener); @@ -218,6 +234,34 @@ public class LocationTimeZoneProviderTest { provider.assertLatestRecordedState(PROVIDER_STATE_DESTROYED); } + @Test + public void considerSuggestionWithInvalidTimeZoneIdsAsUncertain() { + String providerName = "primary"; + TestLocationTimeZoneProvider provider = + new TestLocationTimeZoneProvider( + mTestThreadingDomain, + providerName, + mTimeZoneAvailabilityChecker); + provider.setStateChangeRecordingEnabled(true); + provider.initialize(mProviderListener); + + ConfigurationInternal config = USER1_CONFIG_GEO_DETECTION_ENABLED; + Duration arbitraryInitializationTimeout = Duration.ofMinutes(5); + Duration arbitraryInitializationTimeoutFuzz = Duration.ofMinutes(2); + provider.startUpdates(config, arbitraryInitializationTimeout, + arbitraryInitializationTimeoutFuzz); + + List<String> invalidTimeZoneIds = asList("Atlantic/Atlantis"); + TimeZoneProviderSuggestion invalidIdSuggestion = new TimeZoneProviderSuggestion.Builder() + .setElapsedRealtimeMillis(ARBITRARY_ELAPSED_REALTIME_MILLIS) + .setTimeZoneIds(invalidTimeZoneIds) + .build(); + TimeZoneProviderEvent event = + TimeZoneProviderEvent.createSuggestionEvent(invalidIdSuggestion); + provider.simulateProviderEventReceived(event); + provider.assertLatestRecordedState(PROVIDER_STATE_STARTED_UNCERTAIN); + } + /** A test stand-in for the real {@link LocationTimeZoneProviderController}'s listener. */ private static class TestProviderListener implements ProviderListener { @@ -251,8 +295,9 @@ public class LocationTimeZoneProviderTest { /** Creates the instance. */ TestLocationTimeZoneProvider(@NonNull ThreadingDomain threadingDomain, - @NonNull String providerName) { - super(threadingDomain, providerName); + @NonNull String providerName, + @NonNull TimeZoneIdValidator timeZoneIdValidator) { + super(threadingDomain, providerName, timeZoneIdValidator); } @Override @@ -308,4 +353,19 @@ public class LocationTimeZoneProviderTest { recordedStates.get(recordedStates.size() - 1).stateEnum); } } + + private static final class FakeTimeZoneIdValidator + implements LocationTimeZoneProvider.TimeZoneIdValidator { + private final Set<String> mValidTimeZoneIds = new HashSet<>(); + + @Override + public boolean isValid(@NonNull String timeZoneId) { + return mValidTimeZoneIds.contains(timeZoneId); + } + + public void validIds(String... timeZoneIdss) { + mValidTimeZoneIds.addAll(asList(timeZoneIdss)); + } + + } } diff --git a/services/tests/servicestests/src/com/android/server/timezonedetector/location/ZoneInfoDbTimeZoneIdValidatorTest.java b/services/tests/servicestests/src/com/android/server/timezonedetector/location/ZoneInfoDbTimeZoneIdValidatorTest.java new file mode 100644 index 000000000000..5561b2c6a7aa --- /dev/null +++ b/services/tests/servicestests/src/com/android/server/timezonedetector/location/ZoneInfoDbTimeZoneIdValidatorTest.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.timezonedetector.location; + +import static com.google.common.truth.Truth.assertWithMessage; + +import android.platform.test.annotations.Presubmit; + +import org.junit.Test; + +import java.util.Arrays; +import java.util.List; +import java.util.TimeZone; + +@Presubmit +public class ZoneInfoDbTimeZoneIdValidatorTest { + private final LocationTimeZoneProvider.TimeZoneIdValidator mTzChecker = + new ZoneInfoDbTimeZoneIdValidator(); + + @Test + public void timeZoneIdsFromZoneInfoDbAreValid() { + for (String timeZone : TimeZone.getAvailableIDs()) { + assertWithMessage("Time zone %s should be supported", timeZone) + .that(mTzChecker.isValid(timeZone)).isTrue(); + } + } + + @Test + public void nonExistingZones_areNotSupported() { + List<String> nonExistingTimeZones = Arrays.asList( + "SystemV/HST10", "Atlantic/Atlantis", "EUROPE/LONDON", "Etc/GMT-5:30" + ); + + for (String timeZone : nonExistingTimeZones) { + assertWithMessage(timeZone + " is not a valid time zone") + .that(mTzChecker.isValid(timeZone)) + .isFalse(); + } + } +} diff --git a/services/tests/servicestests/test-apps/SimpleServiceTestApp/OWNERS b/services/tests/servicestests/test-apps/SimpleServiceTestApp/OWNERS new file mode 100644 index 000000000000..72c0a9e6e90c --- /dev/null +++ b/services/tests/servicestests/test-apps/SimpleServiceTestApp/OWNERS @@ -0,0 +1 @@ +include /services/core/java/com/android/server/am/OWNERS diff --git a/services/tests/shortcutmanagerutils/src/com/android/server/pm/shortcutmanagertest/ShortcutManagerTestUtils.java b/services/tests/shortcutmanagerutils/src/com/android/server/pm/shortcutmanagertest/ShortcutManagerTestUtils.java index 5182b3b69655..b921838e0bfc 100644 --- a/services/tests/shortcutmanagerutils/src/com/android/server/pm/shortcutmanagertest/ShortcutManagerTestUtils.java +++ b/services/tests/shortcutmanagerutils/src/com/android/server/pm/shortcutmanagertest/ShortcutManagerTestUtils.java @@ -243,10 +243,18 @@ public class ShortcutManagerTestUtils { final UserHandle user = getParentUser(context); List<String> roleHolders = callWithShellPermissionIdentity( () -> roleManager.getRoleHoldersAsUser(RoleManager.ROLE_HOME, user)); - if (roleHolders.size() == 1) { + int size = roleHolders.size(); + if (size == 1) { return roleHolders.get(0); } - fail("Failed to get the default launcher for user " + context.getUserId()); + + if (size > 1) { + fail("Too many launchers for user " + user.getIdentifier() + " using role " + + RoleManager.ROLE_HOME + ": " + roleHolders); + } else { + fail("No default launcher for user " + user.getIdentifier() + " using role " + + RoleManager.ROLE_HOME); + } return null; } diff --git a/services/tests/wmtests/src/com/android/server/wm/RemoteAnimationControllerTest.java b/services/tests/wmtests/src/com/android/server/wm/RemoteAnimationControllerTest.java index 2fdd63ed93d5..c98e013479f4 100644 --- a/services/tests/wmtests/src/com/android/server/wm/RemoteAnimationControllerTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/RemoteAnimationControllerTest.java @@ -36,6 +36,8 @@ import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_WINDOW_ANIMAT import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; @@ -208,18 +210,20 @@ public class RemoteAnimationControllerTest extends WindowTestsBase { } @Test - public void testZeroAnimations() { + public void testZeroAnimations() throws Exception { mController.goodToGo(TRANSIT_OLD_NONE); - verifyNoMoreInteractionsExceptAsBinder(mMockRunner); + verify(mMockRunner, never()).onAnimationStart(anyInt(), any(), any(), any(), any()); + verify(mMockRunner).onAnimationCancelled(); } @Test - public void testNotReallyStarted() { + public void testNotReallyStarted() throws Exception { final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin"); mController.createRemoteAnimationRecord(win.mActivityRecord, new Point(50, 100), null, new Rect(50, 100, 150, 150), null); mController.goodToGo(TRANSIT_OLD_ACTIVITY_OPEN); - verifyNoMoreInteractionsExceptAsBinder(mMockRunner); + verify(mMockRunner, never()).onAnimationStart(anyInt(), any(), any(), any(), any()); + verify(mMockRunner).onAnimationCancelled(); } @Test @@ -250,7 +254,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase { } @Test - public void testRemovedBeforeStarted() { + public void testRemovedBeforeStarted() throws Exception { final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin"); final AnimationAdapter adapter = mController.createRemoteAnimationRecord(win.mActivityRecord, new Point(50, 100), null, new Rect(50, 100, 150, 150), null).mAdapter; @@ -258,7 +262,8 @@ public class RemoteAnimationControllerTest extends WindowTestsBase { mFinishedCallback); win.mActivityRecord.removeImmediately(); mController.goodToGo(TRANSIT_OLD_ACTIVITY_OPEN); - verifyNoMoreInteractionsExceptAsBinder(mMockRunner); + verify(mMockRunner, never()).onAnimationStart(anyInt(), any(), any(), any(), any()); + verify(mMockRunner).onAnimationCancelled(); verify(mFinishedCallback).onAnimationFinished(eq(ANIMATION_TYPE_APP_TRANSITION), eq(adapter)); } diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java index ecb8b607a106..dca6b089d66b 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java @@ -26,6 +26,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.times; import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify; +import static com.android.server.wm.Task.FLAG_FORCE_HIDDEN_FOR_TASK_ORG; import static com.google.common.truth.Truth.assertThat; @@ -277,4 +278,15 @@ public class TaskTests extends WindowTestsBase { // Orientation request from standard activity in multi window will not be handled. assertFalse(leafTask2.handlesOrientationChangeFromDescendant()); } + + @Test + public void testAlwaysOnTop() { + final Task task = createTaskStackOnDisplay(mDisplayContent); + task.setAlwaysOnTop(true); + task.setWindowingMode(WINDOWING_MODE_MULTI_WINDOW); + assertTrue(task.isAlwaysOnTop()); + + task.setForceHidden(FLAG_FORCE_HIDDEN_FOR_TASK_ORG, true /* set */); + assertFalse(task.isAlwaysOnTop()); + } } diff --git a/telephony/java/android/telephony/CarrierBandwidth.java b/telephony/java/android/telephony/CarrierBandwidth.java index b153fefce6e3..9e1dee0162b9 100644 --- a/telephony/java/android/telephony/CarrierBandwidth.java +++ b/telephony/java/android/telephony/CarrierBandwidth.java @@ -101,7 +101,7 @@ public final class CarrierBandwidth implements Parcelable { } /** - * Retrieves the upstream bandwidth for the primary network in Kbps. This always only refers to + * Retrieves the upstream bandwidth for the primary network in kbps. This always only refers to * the estimated first hop transport bandwidth. * This will be {@link #INVALID} if the network is not connected * @@ -112,7 +112,7 @@ public final class CarrierBandwidth implements Parcelable { } /** - * Retrieves the downstream bandwidth for the primary network in Kbps. This always only refers + * Retrieves the downstream bandwidth for the primary network in kbps. This always only refers * to the estimated first hop transport bandwidth. * This will be {@link #INVALID} if the network is not connected * @@ -123,7 +123,7 @@ public final class CarrierBandwidth implements Parcelable { } /** - * Retrieves the upstream bandwidth for the secondary network in Kbps. This always only refers + * Retrieves the upstream bandwidth for the secondary network in kbps. This always only refers * to the estimated first hop transport bandwidth. * <p/> * This will be {@link #INVALID} if either are the case: @@ -143,7 +143,7 @@ public final class CarrierBandwidth implements Parcelable { } /** - * Retrieves the downstream bandwidth for the secondary network in Kbps. This always only + * Retrieves the downstream bandwidth for the secondary network in kbps. This always only * refers to the estimated first hop transport bandwidth. * <p/> * This will be {@link #INVALID} if either are the case: diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index c48bd211fac2..3cb72b5e0c0d 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -14618,12 +14618,11 @@ public class TelephonyManager { * {@link #NR_DUAL_CONNECTIVITY_DISABLE_IMMEDIATE} * </ol> * @return operation result. - * <p>Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} * @throws IllegalStateException if the Telephony process is not currently available. * @hide */ @SystemApi + @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public @EnableNrDualConnectivityResult int setNrDualConnectivityState( @NrDualConnectivityState int nrDualConnectivityState) { try { diff --git a/telephony/java/android/telephony/data/DataServiceCallback.java b/telephony/java/android/telephony/data/DataServiceCallback.java index ca1f861f9808..363e47a6d242 100644 --- a/telephony/java/android/telephony/data/DataServiceCallback.java +++ b/telephony/java/android/telephony/data/DataServiceCallback.java @@ -254,15 +254,15 @@ public class DataServiceCallback { } /** - * The APN is throttled for the duration specified in - * {@link DataCallResponse#getRetryDurationMillis}. Calling this method unthrottles that - * APN. + * Unthrottles the APN on the current transport. There is no matching "APN throttle" method. + * Instead, the APN is throttled for the time specified in + * {@link DataCallResponse#getRetryDurationMillis}. * <p/> * see: {@link DataCallResponse#getRetryDurationMillis} * * @param apn Access Point Name defined by the carrier. */ - public void onApnUnthrottled(@NonNull String apn) { + public void onApnUnthrottled(final @NonNull String apn) { if (mCallback != null) { try { if (DBG) Rlog.d(TAG, "onApnUnthrottled"); diff --git a/tests/net/common/java/android/net/NetworkCapabilitiesTest.java b/tests/net/common/java/android/net/NetworkCapabilitiesTest.java index ddc31bfc20b8..e84b992a1379 100644 --- a/tests/net/common/java/android/net/NetworkCapabilitiesTest.java +++ b/tests/net/common/java/android/net/NetworkCapabilitiesTest.java @@ -68,6 +68,7 @@ import android.util.ArraySet; import androidx.test.runner.AndroidJUnit4; import com.android.modules.utils.build.SdkLevel; +import com.android.testutils.CompatUtil; import com.android.testutils.DevSdkIgnoreRule; import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo; @@ -211,7 +212,7 @@ public class NetworkCapabilitiesTest { nc1 = new NetworkCapabilities().addTransportType(TRANSPORT_WIFI); nc2 = new NetworkCapabilities() .addTransportType(TRANSPORT_WIFI) - .setNetworkSpecifier(new EthernetNetworkSpecifier("eth42")); + .setNetworkSpecifier(CompatUtil.makeEthernetNetworkSpecifier("eth42")); assertNotEquals("", nc1.describeImmutableDifferences(nc2)); assertEquals("", nc1.describeImmutableDifferences(nc1)); } @@ -671,7 +672,7 @@ public class NetworkCapabilitiesTest { NetworkCapabilities nc1 = new NetworkCapabilities(); nc1.addTransportType(TRANSPORT_CELLULAR).addTransportType(TRANSPORT_WIFI); try { - nc1.setNetworkSpecifier(new EthernetNetworkSpecifier("eth0")); + nc1.setNetworkSpecifier(CompatUtil.makeEthernetNetworkSpecifier("eth0")); fail("Cannot set NetworkSpecifier on a NetworkCapability with multiple transports!"); } catch (IllegalStateException expected) { // empty @@ -680,7 +681,7 @@ public class NetworkCapabilitiesTest { // Sequence 2: Transport + NetworkSpecifier + Transport NetworkCapabilities nc2 = new NetworkCapabilities(); nc2.addTransportType(TRANSPORT_CELLULAR).setNetworkSpecifier( - new EthernetNetworkSpecifier("testtap3")); + CompatUtil.makeEthernetNetworkSpecifier("testtap3")); try { nc2.addTransportType(TRANSPORT_WIFI); fail("Cannot set a second TransportType of a network which has a NetworkSpecifier!"); diff --git a/tests/net/common/java/android/net/NetworkProviderTest.kt b/tests/net/common/java/android/net/NetworkProviderTest.kt index 71a7a7c4ebd9..340e6f963137 100644 --- a/tests/net/common/java/android/net/NetworkProviderTest.kt +++ b/tests/net/common/java/android/net/NetworkProviderTest.kt @@ -27,6 +27,7 @@ import android.os.HandlerThread import android.os.Looper import androidx.test.InstrumentationRegistry import com.android.net.module.util.ArrayTrackRecord +import com.android.testutils.CompatUtil import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo import com.android.testutils.DevSdkIgnoreRunner import com.android.testutils.isDevSdkInRange @@ -102,7 +103,8 @@ class NetworkProviderTest { mCm.registerNetworkProvider(provider) assertNotEquals(provider.getProviderId(), NetworkProvider.ID_NONE) - val specifier = EthernetNetworkSpecifier(UUID.randomUUID().toString()) + val specifier = CompatUtil.makeTestNetworkSpecifier( + UUID.randomUUID().toString()) val nr: NetworkRequest = NetworkRequest.Builder() .addTransportType(TRANSPORT_TEST) .setNetworkSpecifier(specifier) @@ -183,7 +185,8 @@ class NetworkProviderTest { mCm.registerNetworkProvider(provider) - val specifier = EthernetNetworkSpecifier(UUID.randomUUID().toString()) + val specifier = CompatUtil.makeTestNetworkSpecifier( + UUID.randomUUID().toString()) val nr: NetworkRequest = NetworkRequest.Builder() .addTransportType(TRANSPORT_TEST) .setNetworkSpecifier(specifier) diff --git a/tests/net/integration/util/com/android/server/NetworkAgentWrapper.java b/tests/net/integration/util/com/android/server/NetworkAgentWrapper.java index e1da3d0ae2b3..01d8186c7d1b 100644 --- a/tests/net/integration/util/com/android/server/NetworkAgentWrapper.java +++ b/tests/net/integration/util/com/android/server/NetworkAgentWrapper.java @@ -64,6 +64,7 @@ public class NetworkAgentWrapper implements TestableNetworkCallback.HasNetwork { private final HandlerThread mHandlerThread; private final Context mContext; private final String mLogTag; + private final NetworkAgentConfig mNetworkAgentConfig; private final ConditionVariable mDisconnected = new ConditionVariable(); private final ConditionVariable mPreventReconnectReceived = new ConditionVariable(); @@ -115,13 +116,19 @@ public class NetworkAgentWrapper implements TestableNetworkCallback.HasNetwork { mHandlerThread = new HandlerThread(mLogTag); mHandlerThread.start(); - mNetworkAgent = makeNetworkAgent(linkProperties, type, typeName); + // extraInfo is set to "" by default in NetworkAgentConfig. + final String extraInfo = (transport == TRANSPORT_CELLULAR) ? "internet.apn" : ""; + mNetworkAgentConfig = new NetworkAgentConfig.Builder() + .setLegacyType(type) + .setLegacyTypeName(typeName) + .setLegacyExtraInfo(extraInfo) + .build(); + mNetworkAgent = makeNetworkAgent(linkProperties, mNetworkAgentConfig); } protected InstrumentedNetworkAgent makeNetworkAgent(LinkProperties linkProperties, - final int type, final String typeName) - throws Exception { - return new InstrumentedNetworkAgent(this, linkProperties, type, typeName); + final NetworkAgentConfig nac) throws Exception { + return new InstrumentedNetworkAgent(this, linkProperties, nac); } public static class InstrumentedNetworkAgent extends NetworkAgent { @@ -129,11 +136,9 @@ public class NetworkAgentWrapper implements TestableNetworkCallback.HasNetwork { private static final String PROVIDER_NAME = "InstrumentedNetworkAgentProvider"; public InstrumentedNetworkAgent(NetworkAgentWrapper wrapper, LinkProperties lp, - final int type, final String typeName) { + NetworkAgentConfig nac) { super(wrapper.mContext, wrapper.mHandlerThread.getLooper(), wrapper.mLogTag, - wrapper.mNetworkCapabilities, lp, wrapper.mScore, - new NetworkAgentConfig.Builder() - .setLegacyType(type).setLegacyTypeName(typeName).build(), + wrapper.mNetworkCapabilities, lp, wrapper.mScore, nac, new NetworkProvider(wrapper.mContext, wrapper.mHandlerThread.getLooper(), PROVIDER_NAME)); mWrapper = wrapper; @@ -301,6 +306,14 @@ public class NetworkAgentWrapper implements TestableNetworkCallback.HasNetwork { return mNetworkCapabilities; } + public int getLegacyType() { + return mNetworkAgentConfig.getLegacyType(); + } + + public String getExtraInfo() { + return mNetworkAgentConfig.getLegacyExtraInfo(); + } + public @NonNull ArrayTrackRecord<CallbackType>.ReadHead getCallbackHistory() { return mCallbackHistory; } diff --git a/tests/net/java/com/android/server/ConnectivityServiceTest.java b/tests/net/java/com/android/server/ConnectivityServiceTest.java index 2c6a21ad7570..3102b9917fe7 100644 --- a/tests/net/java/com/android/server/ConnectivityServiceTest.java +++ b/tests/net/java/com/android/server/ConnectivityServiceTest.java @@ -266,7 +266,6 @@ import androidx.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; -import com.android.internal.app.IBatteryStats; import com.android.internal.net.VpnConfig; import com.android.internal.net.VpnProfile; import com.android.internal.util.ArrayUtils; @@ -428,7 +427,6 @@ public class ConnectivityServiceTest { @Mock DeviceIdleInternal mDeviceIdleInternal; @Mock INetworkManagementService mNetworkManagementService; @Mock NetworkStatsManager mStatsManager; - @Mock IBatteryStats mBatteryStatsService; @Mock IDnsResolver mMockDnsResolver; @Mock INetd mMockNetd; @Mock NetworkStackClient mNetworkStack; @@ -720,7 +718,7 @@ public class ConnectivityServiceTest { @Override protected InstrumentedNetworkAgent makeNetworkAgent(LinkProperties linkProperties, - final int type, final String typeName) throws Exception { + NetworkAgentConfig nac) throws Exception { mNetworkMonitor = mock(INetworkMonitor.class); final Answer validateAnswer = inv -> { @@ -739,8 +737,8 @@ public class ConnectivityServiceTest { any() /* name */, nmCbCaptor.capture()); - final InstrumentedNetworkAgent na = new InstrumentedNetworkAgent(this, linkProperties, - type, typeName) { + final InstrumentedNetworkAgent na = + new InstrumentedNetworkAgent(this, linkProperties, nac) { @Override public void networkStatus(int status, String redirectUrl) { mRedirectUrl = redirectUrl; @@ -1527,12 +1525,12 @@ public class ConnectivityServiceTest { doReturn(mSystemProperties).when(deps).getSystemProperties(); doReturn(mock(ProxyTracker.class)).when(deps).makeProxyTracker(any(), any()); doReturn(true).when(deps).queryUserAccess(anyInt(), anyInt()); - doReturn(mBatteryStatsService).when(deps).getBatteryStatsService(); doAnswer(inv -> { mPolicyTracker = new WrappedMultinetworkPolicyTracker( inv.getArgument(0), inv.getArgument(1), inv.getArgument(2)); return mPolicyTracker; }).when(deps).makeMultinetworkPolicyTracker(any(), any(), any()); + doReturn(true).when(deps).getCellular464XlatEnabled(); return deps; } @@ -1743,11 +1741,29 @@ public class ConnectivityServiceTest { return expected; } + private boolean extraInfoInBroadcastHasExpectedNullness(NetworkInfo ni) { + final DetailedState state = ni.getDetailedState(); + if (state == DetailedState.CONNECTED && ni.getExtraInfo() == null) return false; + // Expect a null extraInfo if the network is CONNECTING, because a CONNECTIVITY_ACTION + // broadcast with a state of CONNECTING only happens due to legacy VPN lockdown, which also + // nulls out extraInfo. + if (state == DetailedState.CONNECTING && ni.getExtraInfo() != null) return false; + // Can't make any assertions about DISCONNECTED broadcasts. When a network actually + // disconnects, disconnectAndDestroyNetwork sets its state to DISCONNECTED and its extraInfo + // to null. But if the DISCONNECTED broadcast is just simulated by LegacyTypeTracker due to + // a network switch, extraInfo will likely be populated. + // This is likely a bug in CS, but likely not one we can fix without impacting apps. + return true; + } + private ExpectedBroadcast expectConnectivityAction(int type, NetworkInfo.DetailedState state) { - return registerConnectivityBroadcastThat(1, intent -> - type == intent.getIntExtra(EXTRA_NETWORK_TYPE, -1) && state.equals( - ((NetworkInfo) intent.getParcelableExtra(EXTRA_NETWORK_INFO)) - .getDetailedState())); + return registerConnectivityBroadcastThat(1, intent -> { + final int actualType = intent.getIntExtra(EXTRA_NETWORK_TYPE, -1); + final NetworkInfo ni = intent.getParcelableExtra(EXTRA_NETWORK_INFO); + return type == actualType + && state == ni.getDetailedState() + && extraInfoInBroadcastHasExpectedNullness(ni); + }); } @Test @@ -7185,12 +7201,14 @@ public class ConnectivityServiceTest { assertEquals(mCellNetworkAgent.getNetwork(), mCm.getActiveNetwork()); assertActiveNetworkInfo(TYPE_MOBILE, DetailedState.CONNECTED); assertNetworkInfo(TYPE_MOBILE, DetailedState.CONNECTED); + assertExtraInfoFromCmPresent(mCellNetworkAgent); setUidRulesChanged(RULE_REJECT_ALL); cellNetworkCallback.expectBlockedStatusCallback(true, mCellNetworkAgent); assertNull(mCm.getActiveNetwork()); assertActiveNetworkInfo(TYPE_MOBILE, DetailedState.BLOCKED); assertNetworkInfo(TYPE_MOBILE, DetailedState.BLOCKED); + assertExtraInfoFromCmBlocked(mCellNetworkAgent); // ConnectivityService should cache it not to invoke the callback again. setUidRulesChanged(RULE_REJECT_METERED); @@ -7201,12 +7219,14 @@ public class ConnectivityServiceTest { assertEquals(mCellNetworkAgent.getNetwork(), mCm.getActiveNetwork()); assertActiveNetworkInfo(TYPE_MOBILE, DetailedState.CONNECTED); assertNetworkInfo(TYPE_MOBILE, DetailedState.CONNECTED); + assertExtraInfoFromCmPresent(mCellNetworkAgent); setUidRulesChanged(RULE_REJECT_METERED); cellNetworkCallback.expectBlockedStatusCallback(true, mCellNetworkAgent); assertNull(mCm.getActiveNetwork()); assertActiveNetworkInfo(TYPE_MOBILE, DetailedState.BLOCKED); assertNetworkInfo(TYPE_MOBILE, DetailedState.BLOCKED); + assertExtraInfoFromCmBlocked(mCellNetworkAgent); // Restrict the network based on UID rule and NOT_METERED capability change. mCellNetworkAgent.addCapability(NET_CAPABILITY_NOT_METERED); @@ -7215,6 +7235,7 @@ public class ConnectivityServiceTest { assertEquals(mCellNetworkAgent.getNetwork(), mCm.getActiveNetwork()); assertActiveNetworkInfo(TYPE_MOBILE, DetailedState.CONNECTED); assertNetworkInfo(TYPE_MOBILE, DetailedState.CONNECTED); + assertExtraInfoFromCmPresent(mCellNetworkAgent); mCellNetworkAgent.removeCapability(NET_CAPABILITY_NOT_METERED); cellNetworkCallback.expectCapabilitiesWithout(NET_CAPABILITY_NOT_METERED, @@ -7223,12 +7244,14 @@ public class ConnectivityServiceTest { assertNull(mCm.getActiveNetwork()); assertActiveNetworkInfo(TYPE_MOBILE, DetailedState.BLOCKED); assertNetworkInfo(TYPE_MOBILE, DetailedState.BLOCKED); + assertExtraInfoFromCmBlocked(mCellNetworkAgent); setUidRulesChanged(RULE_ALLOW_METERED); cellNetworkCallback.expectBlockedStatusCallback(false, mCellNetworkAgent); assertEquals(mCellNetworkAgent.getNetwork(), mCm.getActiveNetwork()); assertActiveNetworkInfo(TYPE_MOBILE, DetailedState.CONNECTED); assertNetworkInfo(TYPE_MOBILE, DetailedState.CONNECTED); + assertExtraInfoFromCmPresent(mCellNetworkAgent); setUidRulesChanged(RULE_NONE); cellNetworkCallback.assertNoCallback(); @@ -7239,6 +7262,7 @@ public class ConnectivityServiceTest { assertNull(mCm.getActiveNetwork()); assertActiveNetworkInfo(TYPE_MOBILE, DetailedState.BLOCKED); assertNetworkInfo(TYPE_MOBILE, DetailedState.BLOCKED); + assertExtraInfoFromCmBlocked(mCellNetworkAgent); setRestrictBackgroundChanged(true); cellNetworkCallback.assertNoCallback(); @@ -7246,12 +7270,14 @@ public class ConnectivityServiceTest { cellNetworkCallback.expectBlockedStatusCallback(false, mCellNetworkAgent); assertActiveNetworkInfo(TYPE_MOBILE, DetailedState.CONNECTED); assertNetworkInfo(TYPE_MOBILE, DetailedState.CONNECTED); + assertExtraInfoFromCmPresent(mCellNetworkAgent); setRestrictBackgroundChanged(false); cellNetworkCallback.assertNoCallback(); assertEquals(mCellNetworkAgent.getNetwork(), mCm.getActiveNetwork()); assertActiveNetworkInfo(TYPE_MOBILE, DetailedState.CONNECTED); assertNetworkInfo(TYPE_MOBILE, DetailedState.CONNECTED); + assertExtraInfoFromCmPresent(mCellNetworkAgent); mCm.unregisterNetworkCallback(cellNetworkCallback); } @@ -7310,6 +7336,15 @@ public class ConnectivityServiceTest { assertNotNull(ni); assertEquals(type, ni.getType()); assertEquals(ConnectivityManager.getNetworkTypeName(type), state, ni.getDetailedState()); + if (state == DetailedState.CONNECTED || state == DetailedState.SUSPENDED) { + assertNotNull(ni.getExtraInfo()); + } else { + // Technically speaking, a network that's in CONNECTING state will generally have a + // non-null extraInfo. This doesn't actually happen in this test because it never calls + // a legacy API while a network is connecting. When a network is in CONNECTING state + // because of legacy lockdown VPN, its extraInfo is always null. + assertNull(ni.getExtraInfo()); + } } private void assertActiveNetworkInfo(int type, DetailedState state) { @@ -7319,6 +7354,26 @@ public class ConnectivityServiceTest { checkNetworkInfo(mCm.getNetworkInfo(type), type, state); } + private void assertExtraInfoFromCm(TestNetworkAgentWrapper network, boolean present) { + final NetworkInfo niForNetwork = mCm.getNetworkInfo(network.getNetwork()); + final NetworkInfo niForType = mCm.getNetworkInfo(network.getLegacyType()); + if (present) { + assertEquals(network.getExtraInfo(), niForNetwork.getExtraInfo()); + assertEquals(network.getExtraInfo(), niForType.getExtraInfo()); + } else { + assertNull(niForNetwork.getExtraInfo()); + assertNull(niForType.getExtraInfo()); + } + } + + private void assertExtraInfoFromCmBlocked(TestNetworkAgentWrapper network) { + assertExtraInfoFromCm(network, false); + } + + private void assertExtraInfoFromCmPresent(TestNetworkAgentWrapper network) { + assertExtraInfoFromCm(network, true); + } + // Checks that each of the |agents| receive a blocked status change callback with the specified // |blocked| value, in any order. This is needed because when an event affects multiple // networks, ConnectivityService does not guarantee the order in which callbacks are fired. @@ -7633,6 +7688,7 @@ public class ConnectivityServiceTest { assertNetworkInfo(TYPE_MOBILE, DetailedState.BLOCKED); assertNetworkInfo(TYPE_WIFI, DetailedState.BLOCKED); assertNetworkInfo(TYPE_VPN, DetailedState.BLOCKED); + assertExtraInfoFromCmBlocked(mCellNetworkAgent); // TODO: it would be nice if we could simply rely on the production code here, and have // LockdownVpnTracker start the VPN, have the VPN code register its NetworkAgent with @@ -7661,6 +7717,7 @@ public class ConnectivityServiceTest { assertNetworkInfo(TYPE_MOBILE, DetailedState.CONNECTED); assertNetworkInfo(TYPE_WIFI, DetailedState.DISCONNECTED); assertNetworkInfo(TYPE_VPN, DetailedState.CONNECTED); + assertExtraInfoFromCmPresent(mCellNetworkAgent); assertTrue(vpnNc.hasTransport(TRANSPORT_VPN)); assertTrue(vpnNc.hasTransport(TRANSPORT_CELLULAR)); assertFalse(vpnNc.hasTransport(TRANSPORT_WIFI)); @@ -7703,6 +7760,7 @@ public class ConnectivityServiceTest { assertNetworkInfo(TYPE_MOBILE, DetailedState.BLOCKED); assertNetworkInfo(TYPE_WIFI, DetailedState.BLOCKED); assertNetworkInfo(TYPE_VPN, DetailedState.BLOCKED); + assertExtraInfoFromCmBlocked(mWiFiNetworkAgent); // The VPN comes up again on wifi. b1 = expectConnectivityAction(TYPE_VPN, DetailedState.CONNECTED); @@ -7717,6 +7775,7 @@ public class ConnectivityServiceTest { assertNetworkInfo(TYPE_MOBILE, DetailedState.DISCONNECTED); assertNetworkInfo(TYPE_WIFI, DetailedState.CONNECTED); assertNetworkInfo(TYPE_VPN, DetailedState.CONNECTED); + assertExtraInfoFromCmPresent(mWiFiNetworkAgent); vpnNc = mCm.getNetworkCapabilities(mMockVpn.getNetwork()); assertTrue(vpnNc.hasTransport(TRANSPORT_VPN)); assertTrue(vpnNc.hasTransport(TRANSPORT_WIFI)); @@ -7733,6 +7792,7 @@ public class ConnectivityServiceTest { assertNetworkInfo(TYPE_MOBILE, DetailedState.DISCONNECTED); assertNetworkInfo(TYPE_WIFI, DetailedState.CONNECTED); assertNetworkInfo(TYPE_VPN, DetailedState.CONNECTED); + assertExtraInfoFromCmPresent(mWiFiNetworkAgent); b1 = expectConnectivityAction(TYPE_WIFI, DetailedState.DISCONNECTED); mWiFiNetworkAgent.disconnect(); @@ -7812,7 +7872,6 @@ public class ConnectivityServiceTest { verify(mDeps).reportNetworkInterfaceForTransports(mServiceContext, cellLp.getInterfaceName(), new int[] { TRANSPORT_CELLULAR }); - reset(mBatteryStatsService); final LinkProperties wifiLp = new LinkProperties(); wifiLp.setInterfaceName("wifi0"); @@ -7822,7 +7881,6 @@ public class ConnectivityServiceTest { verify(mDeps).reportNetworkInterfaceForTransports(mServiceContext, wifiLp.getInterfaceName(), new int[] { TRANSPORT_WIFI }); - reset(mBatteryStatsService); mCellNetworkAgent.disconnect(); mWiFiNetworkAgent.disconnect(); @@ -7905,7 +7963,6 @@ public class ConnectivityServiceTest { mCellNetworkAgent = new TestNetworkAgentWrapper(TRANSPORT_CELLULAR, cellLp); reset(mMockDnsResolver); reset(mMockNetd); - reset(mBatteryStatsService); // Connect with ipv6 link properties. Expect prefix discovery to be started. mCellNetworkAgent.connect(true); @@ -8268,6 +8325,45 @@ public class ConnectivityServiceTest { } @Test + public void testWith464XlatDisable() throws Exception { + doReturn(false).when(mDeps).getCellular464XlatEnabled(); + + final TestNetworkCallback callback = new TestNetworkCallback(); + final TestNetworkCallback defaultCallback = new TestNetworkCallback(); + final NetworkRequest networkRequest = new NetworkRequest.Builder() + .addCapability(NET_CAPABILITY_INTERNET) + .build(); + mCm.registerNetworkCallback(networkRequest, callback); + mCm.registerDefaultNetworkCallback(defaultCallback); + + // Bring up validated cell. + final LinkProperties cellLp = new LinkProperties(); + cellLp.setInterfaceName(MOBILE_IFNAME); + cellLp.addLinkAddress(new LinkAddress("2001:db8:1::1/64")); + cellLp.addRoute(new RouteInfo(new IpPrefix("::/0"), null, MOBILE_IFNAME)); + mCellNetworkAgent = new TestNetworkAgentWrapper(TRANSPORT_CELLULAR); + + mCellNetworkAgent.sendLinkProperties(cellLp); + mCellNetworkAgent.connect(true); + callback.expectAvailableThenValidatedCallbacks(mCellNetworkAgent); + defaultCallback.expectAvailableThenValidatedCallbacks(mCellNetworkAgent); + final int cellNetId = mCellNetworkAgent.getNetwork().netId; + waitForIdle(); + + verify(mMockDnsResolver, never()).startPrefix64Discovery(cellNetId); + Nat464Xlat clat = getNat464Xlat(mCellNetworkAgent); + assertTrue("Nat464Xlat was not IDLE", !clat.isStarted()); + + // This cannot happen because prefix discovery cannot succeed if it is never started. + mService.mResolverUnsolEventCallback.onNat64PrefixEvent( + makeNat64PrefixEvent(cellNetId, PREFIX_OPERATION_ADDED, "64:ff9b::", 96)); + + // ... but still, check that even if it did, clatd would not be started. + verify(mMockNetd, never()).clatdStart(anyString(), anyString()); + assertTrue("Nat464Xlat was not IDLE", !clat.isStarted()); + } + + @Test public void testDataActivityTracking() throws Exception { final TestNetworkCallback networkCallback = new TestNetworkCallback(); final NetworkRequest networkRequest = new NetworkRequest.Builder() @@ -8973,7 +9069,7 @@ public class ConnectivityServiceTest { TelephonyManager.getNetworkTypeName(TelephonyManager.NETWORK_TYPE_LTE)); return new NetworkAgentInfo(null, new Network(NET_ID), info, new LinkProperties(), nc, 0, mServiceContext, null, new NetworkAgentConfig(), mService, null, null, 0, - INVALID_UID, mQosCallbackTracker); + INVALID_UID, mQosCallbackTracker, new ConnectivityService.Dependencies()); } @Test @@ -10930,4 +11026,4 @@ public class ConnectivityServiceTest { verifyNoNetwork(); mCm.unregisterNetworkCallback(cellCb); } -} +}
\ No newline at end of file diff --git a/tests/net/java/com/android/server/connectivity/LingerMonitorTest.java b/tests/net/java/com/android/server/connectivity/LingerMonitorTest.java index a913673c2a1e..1c0ba4f8d8f5 100644 --- a/tests/net/java/com/android/server/connectivity/LingerMonitorTest.java +++ b/tests/net/java/com/android/server/connectivity/LingerMonitorTest.java @@ -357,7 +357,7 @@ public class LingerMonitorTest { NetworkAgentInfo nai = new NetworkAgentInfo(null, new Network(netId), info, new LinkProperties(), caps, 50, mCtx, null, new NetworkAgentConfig() /* config */, mConnService, mNetd, mDnsResolver, NetworkProvider.ID_NONE, Binder.getCallingUid(), - mQosCallbackTracker); + mQosCallbackTracker, new ConnectivityService.Dependencies()); nai.everValidated = true; return nai; } diff --git a/tests/net/java/com/android/server/connectivity/Nat464XlatTest.java b/tests/net/java/com/android/server/connectivity/Nat464XlatTest.java index 5f56e25356c2..9b2a638f8b39 100644 --- a/tests/net/java/com/android/server/connectivity/Nat464XlatTest.java +++ b/tests/net/java/com/android/server/connectivity/Nat464XlatTest.java @@ -16,11 +16,15 @@ package com.android.server.connectivity; +import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.anyString; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.inOrder; +import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; @@ -34,6 +38,7 @@ import android.net.IpPrefix; import android.net.LinkAddress; import android.net.LinkProperties; import android.net.NetworkAgentConfig; +import android.net.NetworkCapabilities; import android.net.NetworkInfo; import android.os.Handler; import android.os.test.TestLooper; @@ -72,11 +77,15 @@ public class Nat464XlatTest { Handler mHandler; NetworkAgentConfig mAgentConfig = new NetworkAgentConfig(); - Nat464Xlat makeNat464Xlat() { - return new Nat464Xlat(mNai, mNetd, mDnsResolver) { + Nat464Xlat makeNat464Xlat(boolean isCellular464XlatEnabled) { + return new Nat464Xlat(mNai, mNetd, mDnsResolver, new ConnectivityService.Dependencies()) { @Override protected int getNetId() { return NETID; } + + @Override protected boolean isCellular464XlatEnabled() { + return isCellular464XlatEnabled; + } }; } @@ -99,6 +108,7 @@ public class Nat464XlatTest { mNai.linkProperties.setInterfaceName(BASE_IFACE); mNai.networkInfo = new NetworkInfo(null); mNai.networkInfo.setType(ConnectivityManager.TYPE_WIFI); + mNai.networkCapabilities = new NetworkCapabilities(); markNetworkConnected(); when(mNai.connService()).thenReturn(mConnectivity); when(mNai.netAgentConfig()).thenReturn(mAgentConfig); @@ -110,21 +120,23 @@ public class Nat464XlatTest { } private void assertRequiresClat(boolean expected, NetworkAgentInfo nai) { + Nat464Xlat nat = makeNat464Xlat(true); String msg = String.format("requiresClat expected %b for type=%d state=%s skip=%b " + "nat64Prefix=%s addresses=%s", expected, nai.networkInfo.getType(), nai.networkInfo.getDetailedState(), mAgentConfig.skip464xlat, nai.linkProperties.getNat64Prefix(), nai.linkProperties.getLinkAddresses()); - assertEquals(msg, expected, Nat464Xlat.requiresClat(nai)); + assertEquals(msg, expected, nat.requiresClat(nai)); } private void assertShouldStartClat(boolean expected, NetworkAgentInfo nai) { + Nat464Xlat nat = makeNat464Xlat(true); String msg = String.format("shouldStartClat expected %b for type=%d state=%s skip=%b " + "nat64Prefix=%s addresses=%s", expected, nai.networkInfo.getType(), nai.networkInfo.getDetailedState(), mAgentConfig.skip464xlat, nai.linkProperties.getNat64Prefix(), nai.linkProperties.getLinkAddresses()); - assertEquals(msg, expected, Nat464Xlat.shouldStartClat(nai)); + assertEquals(msg, expected, nat.shouldStartClat(nai)); } @Test @@ -194,7 +206,7 @@ public class Nat464XlatTest { } private void checkNormalStartAndStop(boolean dueToDisconnect) throws Exception { - Nat464Xlat nat = makeNat464Xlat(); + Nat464Xlat nat = makeNat464Xlat(true); ArgumentCaptor<LinkProperties> c = ArgumentCaptor.forClass(LinkProperties.class); mNai.linkProperties.addLinkAddress(V6ADDR); @@ -245,7 +257,7 @@ public class Nat464XlatTest { } private void checkStartStopStart(boolean interfaceRemovedFirst) throws Exception { - Nat464Xlat nat = makeNat464Xlat(); + Nat464Xlat nat = makeNat464Xlat(true); ArgumentCaptor<LinkProperties> c = ArgumentCaptor.forClass(LinkProperties.class); InOrder inOrder = inOrder(mNetd, mConnectivity); @@ -335,7 +347,7 @@ public class Nat464XlatTest { @Test public void testClatdCrashWhileRunning() throws Exception { - Nat464Xlat nat = makeNat464Xlat(); + Nat464Xlat nat = makeNat464Xlat(true); ArgumentCaptor<LinkProperties> c = ArgumentCaptor.forClass(LinkProperties.class); nat.setNat64PrefixFromDns(new IpPrefix(NAT64_PREFIX)); @@ -372,7 +384,7 @@ public class Nat464XlatTest { } private void checkStopBeforeClatdStarts(boolean dueToDisconnect) throws Exception { - Nat464Xlat nat = makeNat464Xlat(); + Nat464Xlat nat = makeNat464Xlat(true); mNai.linkProperties.addLinkAddress(new LinkAddress("2001:db8::1/64")); @@ -414,7 +426,7 @@ public class Nat464XlatTest { } private void checkStopAndClatdNeverStarts(boolean dueToDisconnect) throws Exception { - Nat464Xlat nat = makeNat464Xlat(); + Nat464Xlat nat = makeNat464Xlat(true); mNai.linkProperties.addLinkAddress(new LinkAddress("2001:db8::1/64")); @@ -450,7 +462,7 @@ public class Nat464XlatTest { final IpPrefix prefixFromDns = new IpPrefix(NAT64_PREFIX); final IpPrefix prefixFromRa = new IpPrefix(OTHER_NAT64_PREFIX); - Nat464Xlat nat = makeNat464Xlat(); + Nat464Xlat nat = makeNat464Xlat(true); final LinkProperties emptyLp = new LinkProperties(); LinkProperties fixedupLp; @@ -486,10 +498,57 @@ public class Nat464XlatTest { assertEquals(null, fixedupLp.getNat64Prefix()); } + private void checkClatDisabledOnCellular(boolean onCellular) throws Exception { + // Disable 464xlat on cellular networks. + Nat464Xlat nat = makeNat464Xlat(false); + mNai.linkProperties.addLinkAddress(V6ADDR); + mNai.networkCapabilities.setTransportType(TRANSPORT_CELLULAR, onCellular); + nat.update(); + + final IpPrefix nat64Prefix = new IpPrefix(NAT64_PREFIX); + if (onCellular) { + // Prefix discovery is never started. + verify(mDnsResolver, never()).startPrefix64Discovery(eq(NETID)); + assertIdle(nat); + + // If a NAT64 prefix comes in from an RA, clat is not started either. + mNai.linkProperties.setNat64Prefix(nat64Prefix); + nat.setNat64PrefixFromRa(nat64Prefix); + nat.update(); + verify(mNetd, never()).clatdStart(anyString(), anyString()); + assertIdle(nat); + } else { + // Prefix discovery is started. + verify(mDnsResolver).startPrefix64Discovery(eq(NETID)); + assertIdle(nat); + + // If a NAT64 prefix comes in from an RA, clat is started. + mNai.linkProperties.setNat64Prefix(nat64Prefix); + nat.setNat64PrefixFromRa(nat64Prefix); + nat.update(); + verify(mNetd).clatdStart(BASE_IFACE, NAT64_PREFIX); + assertStarting(nat); + } + } + + @Test + public void testClatDisabledOnCellular() throws Exception { + checkClatDisabledOnCellular(true); + } + + @Test + public void testClatDisabledOnNonCellular() throws Exception { + checkClatDisabledOnCellular(false); + } + static void assertIdle(Nat464Xlat nat) { assertTrue("Nat464Xlat was not IDLE", !nat.isStarted()); } + static void assertStarting(Nat464Xlat nat) { + assertTrue("Nat464Xlat was not STARTING", nat.isStarting()); + } + static void assertRunning(Nat464Xlat nat) { assertTrue("Nat464Xlat was not RUNNING", nat.isRunning()); } diff --git a/tests/vcn/java/com/android/server/vcn/UnderlyingNetworkTrackerTest.java b/tests/vcn/java/com/android/server/vcn/UnderlyingNetworkTrackerTest.java index 1d459a347526..1ef1a61f17ea 100644 --- a/tests/vcn/java/com/android/server/vcn/UnderlyingNetworkTrackerTest.java +++ b/tests/vcn/java/com/android/server/vcn/UnderlyingNetworkTrackerTest.java @@ -194,29 +194,35 @@ public class UnderlyingNetworkTrackerTest { } private NetworkRequest getWifiRequest() { - return getExpectedRequestBase() + return getExpectedRequestBase(true) .addTransportType(NetworkCapabilities.TRANSPORT_WIFI) .build(); } private NetworkRequest getCellRequestForSubId(int subId) { - return getExpectedRequestBase() + return getExpectedRequestBase(false) .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR) .setNetworkSpecifier(new TelephonyNetworkSpecifier(subId)) .build(); } private NetworkRequest getRouteSelectionRequest() { - return getExpectedRequestBase().build(); + return getExpectedRequestBase(true).build(); } - private NetworkRequest.Builder getExpectedRequestBase() { - return new NetworkRequest.Builder() - .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) - .removeCapability(NetworkCapabilities.NET_CAPABILITY_TRUSTED) - .removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED) - .removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED) - .addUnwantedCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED); + private NetworkRequest.Builder getExpectedRequestBase(boolean requireVcnManaged) { + final NetworkRequest.Builder builder = + new NetworkRequest.Builder() + .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) + .removeCapability(NetworkCapabilities.NET_CAPABILITY_TRUSTED) + .removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED) + .removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED); + + if (requireVcnManaged) { + builder.addUnwantedCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED); + } + + return builder; } @Test diff --git a/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionConnectedStateTest.java b/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionConnectedStateTest.java index 4bf849111a5d..0e5f5e43f282 100644 --- a/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionConnectedStateTest.java +++ b/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionConnectedStateTest.java @@ -73,7 +73,7 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection mGatewayConnection.setUnderlyingNetwork(TEST_UNDERLYING_NETWORK_RECORD_1); - mIkeSession = mGatewayConnection.buildIkeSession(); + mIkeSession = mGatewayConnection.buildIkeSession(TEST_UNDERLYING_NETWORK_RECORD_1.network); mGatewayConnection.setIkeSession(mIkeSession); mGatewayConnection.transitionTo(mGatewayConnection.mConnectedState); diff --git a/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionConnectingStateTest.java b/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionConnectingStateTest.java index d07d2cf4f1bb..7afa4494ee8b 100644 --- a/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionConnectingStateTest.java +++ b/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionConnectingStateTest.java @@ -25,12 +25,15 @@ import static org.mockito.Matchers.any; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; +import android.net.ipsec.ike.IkeSessionParams; + import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; /** Tests for VcnGatewayConnection.ConnectingState */ @RunWith(AndroidJUnit4.class) @@ -51,7 +54,12 @@ public class VcnGatewayConnectionConnectingStateTest extends VcnGatewayConnectio @Test public void testEnterStateCreatesNewIkeSession() throws Exception { - verify(mDeps).newIkeSession(any(), any(), any(), any(), any()); + final ArgumentCaptor<IkeSessionParams> paramsCaptor = + ArgumentCaptor.forClass(IkeSessionParams.class); + verify(mDeps).newIkeSession(any(), paramsCaptor.capture(), any(), any(), any()); + assertEquals( + TEST_UNDERLYING_NETWORK_RECORD_1.network, + paramsCaptor.getValue().getConfiguredNetwork()); } @Test diff --git a/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionDisconnectingStateTest.java b/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionDisconnectingStateTest.java index 661e03af4f84..99feffdebc8e 100644 --- a/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionDisconnectingStateTest.java +++ b/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionDisconnectingStateTest.java @@ -38,7 +38,8 @@ public class VcnGatewayConnectionDisconnectingStateTest extends VcnGatewayConnec public void setUp() throws Exception { super.setUp(); - mGatewayConnection.setIkeSession(mGatewayConnection.buildIkeSession()); + mGatewayConnection.setIkeSession( + mGatewayConnection.buildIkeSession(TEST_UNDERLYING_NETWORK_RECORD_2.network)); // ensure that mGatewayConnection has an underlying Network before entering // DisconnectingState diff --git a/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionTest.java b/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionTest.java index 748c7924685d..d08af9dd3370 100644 --- a/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionTest.java +++ b/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionTest.java @@ -18,6 +18,7 @@ package com.android.server.vcn; import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_METERED; import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING; +import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED; import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR; import static android.net.NetworkCapabilities.TRANSPORT_WIFI; @@ -87,6 +88,7 @@ public class VcnGatewayConnectionTest extends VcnGatewayConnectionTestBase { private void verifyBuildNetworkCapabilitiesCommon(int transportType) { final NetworkCapabilities underlyingCaps = new NetworkCapabilities(); underlyingCaps.addTransportType(transportType); + underlyingCaps.addCapability(NET_CAPABILITY_NOT_VCN_MANAGED); underlyingCaps.addCapability(NET_CAPABILITY_NOT_METERED); underlyingCaps.addCapability(NET_CAPABILITY_NOT_ROAMING); |