diff options
53 files changed, 895 insertions, 499 deletions
diff --git a/api/api.go b/api/api.go index 94bccaaa8250..9aac879b4eae 100644 --- a/api/api.go +++ b/api/api.go @@ -27,6 +27,7 @@ import ( const art = "art.module.public.api" const conscrypt = "conscrypt.module.public.api" const i18n = "i18n.module.public.api" + var core_libraries_modules = []string{art, conscrypt, i18n} // The intention behind this soong plugin is to generate a number of "merged" @@ -92,6 +93,8 @@ type fgProps struct { type MergedTxtDefinition struct { // "current.txt" or "removed.txt" TxtFilename string + // Filename in the new dist dir. "android.txt" or "android-removed.txt" + DistFilename string // The module for the non-updatable / non-module part of the api. BaseTxt string // The list of modules that are relevant for this merged txt. @@ -112,7 +115,6 @@ func createMergedTxt(ctx android.LoadHookContext, txt MergedTxtDefinition) { if txt.Scope != "public" { filename = txt.Scope + "-" + filename } - props := genruleProps{} props.Name = proptools.StringPtr(ctx.ModuleName() + "-" + filename) props.Tools = []string{"metalava"} @@ -126,9 +128,9 @@ func createMergedTxt(ctx android.LoadHookContext, txt MergedTxtDefinition) { Dest: proptools.StringPtr(filename), }, { - Targets: []string{"sdk"}, + Targets: []string{"api_txt", "sdk"}, Dir: proptools.StringPtr("apistubs/android/" + txt.Scope + "/api"), - Dest: proptools.StringPtr(txt.TxtFilename), + Dest: proptools.StringPtr(txt.DistFilename), }, } props.Visibility = []string{"//visibility:public"} @@ -240,34 +242,39 @@ func createMergedTxts(ctx android.LoadHookContext, bootclasspath, system_server_ var textFiles []MergedTxtDefinition tagSuffix := []string{".api.txt}", ".removed-api.txt}"} + distFilename := []string{"android.txt", "android-removed.txt"} for i, f := range []string{"current.txt", "removed.txt"} { textFiles = append(textFiles, MergedTxtDefinition{ - TxtFilename: f, - BaseTxt: ":non-updatable-" + f, - Modules: bootclasspath, - ModuleTag: "{.public" + tagSuffix[i], - Scope: "public", + TxtFilename: f, + DistFilename: distFilename[i], + BaseTxt: ":non-updatable-" + f, + Modules: bootclasspath, + ModuleTag: "{.public" + tagSuffix[i], + Scope: "public", }) textFiles = append(textFiles, MergedTxtDefinition{ - TxtFilename: f, - BaseTxt: ":non-updatable-system-" + f, - Modules: bootclasspath, - ModuleTag: "{.system" + tagSuffix[i], - Scope: "system", + TxtFilename: f, + DistFilename: distFilename[i], + BaseTxt: ":non-updatable-system-" + f, + Modules: bootclasspath, + ModuleTag: "{.system" + tagSuffix[i], + Scope: "system", }) textFiles = append(textFiles, MergedTxtDefinition{ - TxtFilename: f, - BaseTxt: ":non-updatable-module-lib-" + f, - Modules: bootclasspath, - ModuleTag: "{.module-lib" + tagSuffix[i], - Scope: "module-lib", + TxtFilename: f, + DistFilename: distFilename[i], + BaseTxt: ":non-updatable-module-lib-" + f, + Modules: bootclasspath, + ModuleTag: "{.module-lib" + tagSuffix[i], + Scope: "module-lib", }) textFiles = append(textFiles, MergedTxtDefinition{ - TxtFilename: f, - BaseTxt: ":non-updatable-system-server-" + f, - Modules: system_server_classpath, - ModuleTag: "{.system-server" + tagSuffix[i], - Scope: "system-server", + TxtFilename: f, + DistFilename: distFilename[i], + BaseTxt: ":non-updatable-system-server-" + f, + Modules: system_server_classpath, + ModuleTag: "{.system-server" + tagSuffix[i], + Scope: "system-server", }) } for _, txt := range textFiles { diff --git a/core/api/current.txt b/core/api/current.txt index b08ffc90a00d..2a6536ed218f 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -52021,7 +52021,6 @@ package android.view.accessibility { method public boolean isSelected(); method @Deprecated public static android.view.accessibility.AccessibilityNodeInfo.CollectionItemInfo obtain(int, int, int, int, boolean); method @Deprecated public static android.view.accessibility.AccessibilityNodeInfo.CollectionItemInfo obtain(int, int, int, int, boolean, boolean); - method @Deprecated @NonNull public static android.view.accessibility.AccessibilityNodeInfo.CollectionItemInfo obtain(@Nullable String, int, int, @Nullable String, int, int, boolean, boolean); } public static final class AccessibilityNodeInfo.CollectionItemInfo.Builder { diff --git a/core/api/removed.txt b/core/api/removed.txt index 608a9a4efeca..1fa1e89fb46e 100644 --- a/core/api/removed.txt +++ b/core/api/removed.txt @@ -525,6 +525,14 @@ package android.view { } +package android.view.accessibility { + + public static final class AccessibilityNodeInfo.CollectionItemInfo { + method @Deprecated @NonNull public static android.view.accessibility.AccessibilityNodeInfo.CollectionItemInfo obtain(@Nullable String, int, int, @Nullable String, int, int, boolean, boolean); + } + +} + package android.view.translation { public final class TranslationManager { diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 650de2e00c3b..66af50c24db2 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -762,7 +762,7 @@ package android.app { method public void clearRequireCompatChange(); method public boolean isPendingIntentBackgroundActivityLaunchAllowed(); method public static android.app.BroadcastOptions makeBasic(); - method @RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS) public void recordResponseEventWhileInBackground(@IntRange(from=0) long); + method @RequiresPermission(android.Manifest.permission.ACCESS_BROADCAST_RESPONSE_STATS) public void recordResponseEventWhileInBackground(@IntRange(from=0) long); method @RequiresPermission(android.Manifest.permission.START_ACTIVITIES_FROM_BACKGROUND) public void setBackgroundActivityStartsAllowed(boolean); method public void setDontSendToRestrictedApps(boolean); method public void setPendingIntentBackgroundActivityLaunchAllowed(boolean); diff --git a/core/java/android/app/BroadcastOptions.java b/core/java/android/app/BroadcastOptions.java index 8b3c9fa73798..56f8760f6059 100644 --- a/core/java/android/app/BroadcastOptions.java +++ b/core/java/android/app/BroadcastOptions.java @@ -532,7 +532,7 @@ public class BroadcastOptions extends ComponentOptions { * @hide */ @SystemApi - @RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS) + @RequiresPermission(android.Manifest.permission.ACCESS_BROADCAST_RESPONSE_STATS) public void recordResponseEventWhileInBackground(@IntRange(from = 0) long id) { mIdForResponseEvent = id; } diff --git a/core/java/android/content/pm/TEST_MAPPING b/core/java/android/content/pm/TEST_MAPPING index dea083422612..cc62d5337c02 100644 --- a/core/java/android/content/pm/TEST_MAPPING +++ b/core/java/android/content/pm/TEST_MAPPING @@ -180,7 +180,7 @@ "name": "CtsAppSecurityHostTestCases", "options": [ { - "include-filter": "com.android.cts.splitapp.SplitAppTest" + "include-filter": "android.appsecurity.cts.SplitTests" }, { "include-filter": "android.appsecurity.cts.EphemeralTest" @@ -199,14 +199,6 @@ "name": "CtsRollbackManagerHostTestCases" }, { - "name": "CtsOsHostTestCases", - "options": [ - { - "include-filter": "com.android.server.pm.PackageParserTest" - } - ] - }, - { "name": "CtsContentTestCases", "options": [ { diff --git a/core/java/android/hardware/camera2/CaptureRequest.java b/core/java/android/hardware/camera2/CaptureRequest.java index d94ad3aa1732..9884c382cd7c 100644 --- a/core/java/android/hardware/camera2/CaptureRequest.java +++ b/core/java/android/hardware/camera2/CaptureRequest.java @@ -1387,6 +1387,14 @@ public final class CaptureRequest extends CameraMetadata<CaptureRequest.Key<?>> * region and output only the intersection rectangle as the metering region in the result * metadata. If the region is entirely outside the crop region, it will be ignored and * not reported in the result metadata.</p> + * <p>When setting the AE metering regions, the application must consider the additional + * crop resulted from the aspect ratio differences between the preview stream and + * {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion}. For example, if the {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion} is the full + * active array size with 4:3 aspect ratio, and the preview stream is 16:9, + * the boundary of AE regions will be [0, y_crop] and + * [active_width, active_height - 2 * y_crop] rather than [0, 0] and + * [active_width, active_height], where y_crop is the additional crop due to aspect ratio + * mismatch.</p> * <p>Starting from API level 30, the coordinate system of activeArraySize or * preCorrectionActiveArraySize is used to represent post-zoomRatio field of view, not * pre-zoom field of view. This means that the same aeRegions values at different @@ -1609,6 +1617,14 @@ public final class CaptureRequest extends CameraMetadata<CaptureRequest.Key<?>> * region and output only the intersection rectangle as the metering region in the result * metadata. If the region is entirely outside the crop region, it will be ignored and * not reported in the result metadata.</p> + * <p>When setting the AF metering regions, the application must consider the additional + * crop resulted from the aspect ratio differences between the preview stream and + * {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion}. For example, if the {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion} is the full + * active array size with 4:3 aspect ratio, and the preview stream is 16:9, + * the boundary of AF regions will be [0, y_crop] and + * [active_width, active_height - 2 * y_crop] rather than [0, 0] and + * [active_width, active_height], where y_crop is the additional crop due to aspect ratio + * mismatch.</p> * <p>Starting from API level 30, the coordinate system of activeArraySize or * preCorrectionActiveArraySize is used to represent post-zoomRatio field of view, not * pre-zoom field of view. This means that the same afRegions values at different @@ -1823,6 +1839,14 @@ public final class CaptureRequest extends CameraMetadata<CaptureRequest.Key<?>> * region and output only the intersection rectangle as the metering region in the result * metadata. If the region is entirely outside the crop region, it will be ignored and * not reported in the result metadata.</p> + * <p>When setting the AWB metering regions, the application must consider the additional + * crop resulted from the aspect ratio differences between the preview stream and + * {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion}. For example, if the {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion} is the full + * active array size with 4:3 aspect ratio, and the preview stream is 16:9, + * the boundary of AWB regions will be [0, y_crop] and + * [active_width, active_height - 2 * y_crop] rather than [0, 0] and + * [active_width, active_height], where y_crop is the additional crop due to aspect ratio + * mismatch.</p> * <p>Starting from API level 30, the coordinate system of activeArraySize or * preCorrectionActiveArraySize is used to represent post-zoomRatio field of view, not * pre-zoom field of view. This means that the same awbRegions values at different diff --git a/core/java/android/hardware/camera2/CaptureResult.java b/core/java/android/hardware/camera2/CaptureResult.java index 60d5e9eba3e0..1faec5b76524 100644 --- a/core/java/android/hardware/camera2/CaptureResult.java +++ b/core/java/android/hardware/camera2/CaptureResult.java @@ -829,6 +829,14 @@ public class CaptureResult extends CameraMetadata<CaptureResult.Key<?>> { * region and output only the intersection rectangle as the metering region in the result * metadata. If the region is entirely outside the crop region, it will be ignored and * not reported in the result metadata.</p> + * <p>When setting the AE metering regions, the application must consider the additional + * crop resulted from the aspect ratio differences between the preview stream and + * {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion}. For example, if the {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion} is the full + * active array size with 4:3 aspect ratio, and the preview stream is 16:9, + * the boundary of AE regions will be [0, y_crop] and + * [active_width, active_height - 2 * y_crop] rather than [0, 0] and + * [active_width, active_height], where y_crop is the additional crop due to aspect ratio + * mismatch.</p> * <p>Starting from API level 30, the coordinate system of activeArraySize or * preCorrectionActiveArraySize is used to represent post-zoomRatio field of view, not * pre-zoom field of view. This means that the same aeRegions values at different @@ -1301,6 +1309,14 @@ public class CaptureResult extends CameraMetadata<CaptureResult.Key<?>> { * region and output only the intersection rectangle as the metering region in the result * metadata. If the region is entirely outside the crop region, it will be ignored and * not reported in the result metadata.</p> + * <p>When setting the AF metering regions, the application must consider the additional + * crop resulted from the aspect ratio differences between the preview stream and + * {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion}. For example, if the {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion} is the full + * active array size with 4:3 aspect ratio, and the preview stream is 16:9, + * the boundary of AF regions will be [0, y_crop] and + * [active_width, active_height - 2 * y_crop] rather than [0, 0] and + * [active_width, active_height], where y_crop is the additional crop due to aspect ratio + * mismatch.</p> * <p>Starting from API level 30, the coordinate system of activeArraySize or * preCorrectionActiveArraySize is used to represent post-zoomRatio field of view, not * pre-zoom field of view. This means that the same afRegions values at different @@ -1926,6 +1942,14 @@ public class CaptureResult extends CameraMetadata<CaptureResult.Key<?>> { * region and output only the intersection rectangle as the metering region in the result * metadata. If the region is entirely outside the crop region, it will be ignored and * not reported in the result metadata.</p> + * <p>When setting the AWB metering regions, the application must consider the additional + * crop resulted from the aspect ratio differences between the preview stream and + * {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion}. For example, if the {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion} is the full + * active array size with 4:3 aspect ratio, and the preview stream is 16:9, + * the boundary of AWB regions will be [0, y_crop] and + * [active_width, active_height - 2 * y_crop] rather than [0, 0] and + * [active_width, active_height], where y_crop is the additional crop due to aspect ratio + * mismatch.</p> * <p>Starting from API level 30, the coordinate system of activeArraySize or * preCorrectionActiveArraySize is used to represent post-zoomRatio field of view, not * pre-zoom field of view. This means that the same awbRegions values at different diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index 8e9f9d9fb4f3..cfe44bbbf3c6 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -3590,12 +3590,13 @@ public interface WindowManager extends ViewManager { /** * If specified, the insets provided by this window will be our window frame minus the - * insets specified by providedInternalInsets. This should not be used together with - * {@link WindowState#mGivenContentInsets}. If both of them are set, both will be applied. + * insets specified by providedInternalInsets for each type. This should not be used + * together with {@link WindowState#mGivenContentInsets}. If both of them are set, both will + * be applied. * * @hide */ - public Insets providedInternalInsets = Insets.NONE; + public Insets[] providedInternalInsets; /** * If specified, the insets provided by this window for the IME will be our window frame @@ -3603,7 +3604,7 @@ public interface WindowManager extends ViewManager { * * @hide */ - public Insets providedInternalImeInsets = Insets.NONE; + public Insets[] providedInternalImeInsets; /** * If specified, the frame that used to calculate relative {@link RoundedCorner} will be @@ -3989,8 +3990,18 @@ public interface WindowManager extends ViewManager { } else { out.writeInt(0); } - providedInternalInsets.writeToParcel(out, 0 /* parcelableFlags */); - providedInternalImeInsets.writeToParcel(out, 0 /* parcelableFlags */); + if (providedInternalInsets != null) { + out.writeInt(providedInternalInsets.length); + out.writeTypedArray(providedInternalInsets, 0 /* parcelableFlags */); + } else { + out.writeInt(0); + } + if (providedInternalImeInsets != null) { + out.writeInt(providedInternalImeInsets.length); + out.writeTypedArray(providedInternalImeInsets, 0 /* parcelableFlags */); + } else { + out.writeInt(0); + } out.writeBoolean(insetsRoundedCornerFrame); if (paramsForRotation != null) { checkNonRecursiveParams(); @@ -4070,8 +4081,16 @@ public interface WindowManager extends ViewManager { providesInsetsTypes = new int[insetsTypesLength]; in.readIntArray(providesInsetsTypes); } - providedInternalInsets = Insets.CREATOR.createFromParcel(in); - providedInternalImeInsets = Insets.CREATOR.createFromParcel(in); + int providedInternalInsetsLength = in.readInt(); + if (providedInternalInsetsLength > 0) { + providedInternalInsets = new Insets[providedInternalInsetsLength]; + in.readTypedArray(providedInternalInsets, Insets.CREATOR); + } + int providedInternalImeInsetsLength = in.readInt(); + if (providedInternalImeInsetsLength > 0) { + providedInternalImeInsets = new Insets[providedInternalImeInsetsLength]; + in.readTypedArray(providedInternalImeInsets, Insets.CREATOR); + } insetsRoundedCornerFrame = in.readBoolean(); int paramsForRotationLength = in.readInt(); if (paramsForRotationLength > 0) { @@ -4374,12 +4393,12 @@ public interface WindowManager extends ViewManager { changes |= LAYOUT_CHANGED; } - if (!providedInternalInsets.equals(o.providedInternalInsets)) { + if (!Arrays.equals(providedInternalInsets, o.providedInternalInsets)) { providedInternalInsets = o.providedInternalInsets; changes |= LAYOUT_CHANGED; } - if (!providedInternalImeInsets.equals(o.providedInternalImeInsets)) { + if (!Arrays.equals(providedInternalImeInsets, o.providedInternalImeInsets)) { providedInternalImeInsets = o.providedInternalImeInsets; changes |= LAYOUT_CHANGED; } @@ -4590,13 +4609,21 @@ public interface WindowManager extends ViewManager { sb.append(InsetsState.typeToString(providesInsetsTypes[i])); } } - if (!providedInternalInsets.equals(Insets.NONE)) { + if (providedInternalInsets != null) { + sb.append(System.lineSeparator()); sb.append(" providedInternalInsets="); - sb.append(providedInternalInsets); + for (int i = 0; i < providedInternalInsets.length; ++i) { + if (i > 0) sb.append(' '); + sb.append((providedInternalInsets[i])); + } } - if (!providedInternalImeInsets.equals(Insets.NONE)) { + if (providedInternalImeInsets != null) { + sb.append(System.lineSeparator()); sb.append(" providedInternalImeInsets="); - sb.append(providedInternalImeInsets); + for (int i = 0; i < providedInternalImeInsets.length; ++i) { + if (i > 0) sb.append(' '); + sb.append((providedInternalImeInsets[i])); + } } if (insetsRoundedCornerFrame) { sb.append(" insetsRoundedCornerFrame="); diff --git a/core/java/android/view/accessibility/AccessibilityNodeInfo.java b/core/java/android/view/accessibility/AccessibilityNodeInfo.java index 0008aa64efa4..90e349864092 100644 --- a/core/java/android/view/accessibility/AccessibilityNodeInfo.java +++ b/core/java/android/view/accessibility/AccessibilityNodeInfo.java @@ -5682,6 +5682,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @param heading Whether the item is a heading. (Prefer * {@link AccessibilityNodeInfo#setHeading(boolean)}) * @param selected Whether the item is selected. + * @removed */ @Deprecated @NonNull diff --git a/core/jni/android_util_Process.cpp b/core/jni/android_util_Process.cpp index a6fbf094a030..b9d5ee4b3015 100644 --- a/core/jni/android_util_Process.cpp +++ b/core/jni/android_util_Process.cpp @@ -913,7 +913,7 @@ jboolean android_os_Process_parseProcLineArray(JNIEnv* env, jobject clazz, end = i; i++; } else if ((mode&PROC_QUOTES) != 0) { - while (buffer[i] != '"' && i < endIndex) { + while (i < endIndex && buffer[i] != '"') { i++; } end = i; diff --git a/data/keyboards/Vendor_0e6f_Product_f501.kl b/data/keyboards/Vendor_0e6f_Product_f501.kl new file mode 100644 index 000000000000..b46c005353b1 --- /dev/null +++ b/data/keyboards/Vendor_0e6f_Product_f501.kl @@ -0,0 +1,55 @@ +# Copyright (C) 2022 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. + +# +# XBox-compatible USB Controller +# + +key 304 BUTTON_A +key 305 BUTTON_B +key 307 BUTTON_X +key 308 BUTTON_Y +key 310 BUTTON_L1 +key 311 BUTTON_R1 + +key 317 BUTTON_THUMBL +key 318 BUTTON_THUMBR + +# Left and right stick. +# The reported value for flat is 128 out of a range from -32767 to 32768, which is absurd. +# This confuses applications that rely on the flat value because the joystick actually +# settles in a flat range of +/- 4096 or so. +axis 0x00 X flat 4096 +axis 0x01 Y flat 4096 +axis 0x03 Z flat 4096 +axis 0x04 RZ flat 4096 + +# Triggers. +axis 0x02 LTRIGGER +axis 0x05 RTRIGGER + +# Hat. +axis 0x10 HAT_X +axis 0x11 HAT_Y + +# Mapping according to https://www.kernel.org/doc/Documentation/input/gamepad.txt + +# Button labeled as "BACK" (left-pointing triangle) +key 314 BUTTON_SELECT + +# The branded "X" button in the center of the controller +key 316 BUTTON_MODE + +# Button labeled as "START" (right-pointing triangle) +key 315 BUTTON_START diff --git a/graphics/java/android/graphics/BLASTBufferQueue.java b/graphics/java/android/graphics/BLASTBufferQueue.java index 7f70e1cce6f5..4b723d1569c9 100644 --- a/graphics/java/android/graphics/BLASTBufferQueue.java +++ b/graphics/java/android/graphics/BLASTBufferQueue.java @@ -47,7 +47,7 @@ public final class BLASTBufferQueue { /** Create a new connection with the surface flinger. */ public BLASTBufferQueue(String name, SurfaceControl sc, int width, int height, @PixelFormat.Format int format) { - this(name, false /* updateDestinationFrame */); + this(name, true /* updateDestinationFrame */); update(sc, width, height, format); } diff --git a/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp b/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp index ab00dd5a487c..dc72aead4873 100644 --- a/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp +++ b/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp @@ -61,6 +61,17 @@ void GLFunctorDrawable::onDraw(SkCanvas* canvas) { return; } + // canvas may be an AlphaFilterCanvas, which is intended to draw with a + // modified alpha. We do not have a way to do this without drawing into an + // extra layer, which would have a performance cost. Draw directly into the + // underlying gpu canvas. This matches prior behavior and the behavior in + // Vulkan. + { + auto* gpuCanvas = SkAndroidFrameworkUtils::getBaseWrappedCanvas(canvas); + LOG_ALWAYS_FATAL_IF(!gpuCanvas, "GLFunctorDrawable::onDraw is using an invalid canvas!"); + canvas = gpuCanvas; + } + // flush will create a GrRenderTarget if not already present. canvas->flush(); diff --git a/omapi/java/android/se/omapi/SEService.java b/omapi/java/android/se/omapi/SEService.java index f42ca364b6d9..306c09afeaeb 100644 --- a/omapi/java/android/se/omapi/SEService.java +++ b/omapi/java/android/se/omapi/SEService.java @@ -118,6 +118,16 @@ public final class SEService { }); } } + + @Override + public String getInterfaceHash() { + return ISecureElementListener.HASH; + } + + @Override + public int getInterfaceVersion() { + return ISecureElementListener.VERSION; + } } private SEListener mSEListener = new SEListener(); diff --git a/packages/SettingsLib/CollapsingToolbarBaseActivity/src/com/android/settingslib/collapsingtoolbar/widget/CollapsingCoordinatorLayout.java b/packages/SettingsLib/CollapsingToolbarBaseActivity/src/com/android/settingslib/collapsingtoolbar/widget/CollapsingCoordinatorLayout.java index eec73ff37775..72383fe59e7e 100644 --- a/packages/SettingsLib/CollapsingToolbarBaseActivity/src/com/android/settingslib/collapsingtoolbar/widget/CollapsingCoordinatorLayout.java +++ b/packages/SettingsLib/CollapsingToolbarBaseActivity/src/com/android/settingslib/collapsingtoolbar/widget/CollapsingCoordinatorLayout.java @@ -122,15 +122,66 @@ public class CollapsingCoordinatorLayout extends CoordinatorLayout { } if (activity instanceof AppCompatActivity) { - initSupportToolbar((AppCompatActivity) activity); + initSettingsStyleToolBar((SupportActionBarHost) + toolBar -> { + AppCompatActivity appCompatActivity = (AppCompatActivity) activity; + appCompatActivity.setSupportActionBar(toolBar); + return appCompatActivity.getSupportActionBar(); + }); + } else { + initSettingsStyleToolBar((ActionBarHost) + toolBar -> { + activity.setActionBar(toolBar); + return activity.getActionBar(); + }); + } + } + + /** + * Initialize some attributes of {@link ActionBar}. + * + * @param actionBarHost Host Activity that is not AppCompat. + */ + public void initSettingsStyleToolBar(ActionBarHost actionBarHost) { + if (actionBarHost == null) { + Log.w(TAG, "initSettingsStyleToolBar: actionBarHost is null"); return; } final Toolbar toolbar = findViewById(R.id.action_bar); - activity.setActionBar(toolbar); + final ActionBar actionBar = actionBarHost.setupActionBar(toolbar); + + // Enable title and home button by default + if (actionBar != null) { + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setHomeButtonEnabled(true); + actionBar.setDisplayShowTitleEnabled(true); + } + } + + /** + * Initialize some attributes of {@link ActionBar}. + * + * @param supportActionBarHost Host Activity that is AppCompat. + */ + public void initSettingsStyleToolBar(SupportActionBarHost supportActionBarHost) { + if (supportActionBarHost == null) { + Log.w(TAG, "initSettingsStyleToolBar: supportActionBarHost is null"); + return; + } + if (mCollapsingToolbarLayout == null) { + return; + } + + mCollapsingToolbarLayout.removeAllViews(); + inflate(getContext(), R.layout.support_toolbar, mCollapsingToolbarLayout); + final androidx.appcompat.widget.Toolbar supportToolbar = + mCollapsingToolbarLayout.findViewById(R.id.support_action_bar); + + final androidx.appcompat.app.ActionBar actionBar = + supportActionBarHost.setupSupportActionBar(supportToolbar); // Enable title and home button by default - final ActionBar actionBar = activity.getActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); @@ -156,20 +207,27 @@ public class CollapsingCoordinatorLayout extends CoordinatorLayout { } } - /** - * Returns an instance of collapsing toolbar. - */ + /** Returns an instance of collapsing toolbar. */ public CollapsingToolbarLayout getCollapsingToolbarLayout() { return mCollapsingToolbarLayout; } - /** - * Return an instance of app bar. - */ + /** Return an instance of app bar. */ public AppBarLayout getAppBarLayout() { return mAppBarLayout; } + /** Returns the content frame layout. */ + public View getContentFrameLayout() { + return findViewById(R.id.content_frame); + } + + /** Returns the AppCompat Toolbar. */ + public androidx.appcompat.widget.Toolbar getSupportToolbar() { + return (androidx.appcompat.widget.Toolbar) + mCollapsingToolbarLayout.findViewById(R.id.support_action_bar); + } + private void disableCollapsingToolbarLayoutScrollingBehavior() { if (mAppBarLayout == null) { return; @@ -187,25 +245,22 @@ public class CollapsingCoordinatorLayout extends CoordinatorLayout { params.setBehavior(behavior); } - // This API is for supportActionBar of {@link AppCompatActivity} - private void initSupportToolbar(AppCompatActivity appCompatActivity) { - if (mCollapsingToolbarLayout == null) { - return; - } - - mCollapsingToolbarLayout.removeAllViews(); - inflate(getContext(), R.layout.support_toolbar, mCollapsingToolbarLayout); - final androidx.appcompat.widget.Toolbar supportToolbar = - mCollapsingToolbarLayout.findViewById(R.id.support_action_bar); - - appCompatActivity.setSupportActionBar(supportToolbar); + /** Interface to be implemented by a host Activity that is not AppCompat. */ + public interface ActionBarHost { + /** + * Sets a Toolbar as an actionBar and optionally returns an ActionBar represented by + * this toolbar if it should be used. + */ + @Nullable ActionBar setupActionBar(Toolbar toolbar); + } - // Enable title and home button by default - final androidx.appcompat.app.ActionBar actionBar = appCompatActivity.getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setHomeButtonEnabled(true); - actionBar.setDisplayShowTitleEnabled(true); - } + /** Interface to be implemented by a host Activity that is AppCompat. */ + public interface SupportActionBarHost { + /** + * Sets a Toolbar as an actionBar and optionally returns an ActionBar represented by + * this toolbar if it should be used. + */ + @Nullable androidx.appcompat.app.ActionBar setupSupportActionBar( + androidx.appcompat.widget.Toolbar toolbar); } } diff --git a/packages/SystemUI/res/drawable/overlay_button_background.xml b/packages/SystemUI/res/drawable/overlay_button_background.xml index 0e8438c8a11d..c045048802f7 100644 --- a/packages/SystemUI/res/drawable/overlay_button_background.xml +++ b/packages/SystemUI/res/drawable/overlay_button_background.xml @@ -18,7 +18,7 @@ (clipboard text editor, long screenshots) --> <ripple xmlns:android="http://schemas.android.com/apk/res/android" xmlns:androidprv="http://schemas.android.com/apk/prv/res/android" - android:color="?android:textColorPrimary"> + android:color="@color/overlay_button_ripple"> <item android:id="@android:id/background"> <inset android:insetTop="4dp" android:insetBottom="4dp"> <shape android:shape="rectangle"> diff --git a/packages/SystemUI/res/values-night/colors.xml b/packages/SystemUI/res/values-night/colors.xml index 3a638b1e5098..dc2bee56373c 100644 --- a/packages/SystemUI/res/values-night/colors.xml +++ b/packages/SystemUI/res/values-night/colors.xml @@ -59,7 +59,6 @@ <color name="global_actions_alert_text">@color/GM2_red_300</color> <!-- Floating overlay actions --> - <color name="overlay_button_ripple">#42FFFFFF</color> <color name="overlay_background_protection_start">#80000000</color> <!-- 50% black --> <!-- Media --> diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/WindowManagerWrapper.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/WindowManagerWrapper.java index 32299f5643db..5bd81a42a814 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/WindowManagerWrapper.java +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/WindowManagerWrapper.java @@ -86,6 +86,7 @@ public class WindowManagerWrapper { public static final int ITYPE_RIGHT_TAPPABLE_ELEMENT = InsetsState.ITYPE_RIGHT_TAPPABLE_ELEMENT; public static final int ITYPE_BOTTOM_TAPPABLE_ELEMENT = InsetsState.ITYPE_BOTTOM_TAPPABLE_ELEMENT; + public static final int ITYPE_SIZE = InsetsState.SIZE; public static final int ANIMATION_DURATION_RESIZE = InsetsController.ANIMATION_DURATION_RESIZE; public static final Interpolator RESIZE_INTERPOLATOR = InsetsController.RESIZE_INTERPOLATOR; diff --git a/packages/SystemUI/src/com/android/keyguard/BouncerPanelExpansionCalculator.kt b/packages/SystemUI/src/com/android/keyguard/BouncerPanelExpansionCalculator.kt index 1b2ea3b257ab..a08c9000355f 100644 --- a/packages/SystemUI/src/com/android/keyguard/BouncerPanelExpansionCalculator.kt +++ b/packages/SystemUI/src/com/android/keyguard/BouncerPanelExpansionCalculator.kt @@ -23,7 +23,7 @@ object BouncerPanelExpansionCalculator { * Scale the alpha/position of the host view. */ @JvmStatic - fun getHostViewScaledExpansion(fraction: Float): Float { + fun showBouncerProgress(fraction: Float): Float { return when { fraction >= 0.9f -> 1f fraction < 0.6 -> 0f @@ -35,7 +35,7 @@ object BouncerPanelExpansionCalculator { * Scale the alpha/tint of the back scrim. */ @JvmStatic - fun getBackScrimScaledExpansion(fraction: Float): Float { + fun aboutToShowBouncerProgress(fraction: Float): Float { return MathUtils.constrain((fraction - 0.9f) / 0.1f, 0f, 1f) } diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java index 8c3e066849b9..239b478949d2 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java @@ -327,7 +327,7 @@ public class KeyguardHostViewController extends ViewController<KeyguardHostView> * @param fraction amount of the screen that should show. */ public void setExpansion(float fraction) { - float scaledFraction = BouncerPanelExpansionCalculator.getHostViewScaledExpansion(fraction); + float scaledFraction = BouncerPanelExpansionCalculator.showBouncerProgress(fraction); mView.setAlpha(MathUtils.constrain(1 - scaledFraction, 0f, 1f)); mView.setTranslationY(scaledFraction * mTranslationY); } diff --git a/packages/SystemUI/src/com/android/systemui/Prefs.java b/packages/SystemUI/src/com/android/systemui/Prefs.java index ff5715c606b6..9aa5fae1044d 100644 --- a/packages/SystemUI/src/com/android/systemui/Prefs.java +++ b/packages/SystemUI/src/com/android/systemui/Prefs.java @@ -63,7 +63,6 @@ public final class Prefs { Key.QS_WORK_ADDED, Key.QS_NIGHTDISPLAY_ADDED, Key.QS_LONG_PRESS_TOOLTIP_SHOWN_COUNT, - Key.SEEN_MULTI_USER, Key.SEEN_RINGER_GUIDANCE_COUNT, Key.QS_HAS_TURNED_OFF_MOBILE_DATA, Key.TOUCHED_RINGER_TOGGLE, @@ -106,7 +105,6 @@ public final class Prefs { * Settings panel. */ String QS_LONG_PRESS_TOOLTIP_SHOWN_COUNT = "QsLongPressTooltipShownCount"; - String SEEN_MULTI_USER = "HasSeenMultiUser"; String SEEN_RINGER_GUIDANCE_COUNT = "RingerGuidanceCount"; String QS_TILE_SPECS_REVEALED = "QsTileSpecsRevealed"; String QS_HAS_TURNED_OFF_MOBILE_DATA = "QsHasTurnedOffMobileData"; diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt b/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt index 33126b3887da..76c1dbcaf20c 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt @@ -145,6 +145,7 @@ class AuthRippleController @Inject constructor( val lightRevealScrim = centralSurfaces.lightRevealScrim if (statusBarStateController.isDozing || biometricUnlockController.isWakeAndUnlock) { circleReveal?.let { + lightRevealScrim?.revealAmount = 0f lightRevealScrim?.revealEffect = it startLightRevealScrimOnKeyguardFadingAway = true } @@ -168,7 +169,8 @@ class AuthRippleController @Inject constructor( startDelay = keyguardStateController.keyguardFadingAwayDelay addUpdateListener { animator -> if (lightRevealScrim.revealEffect != circleReveal) { - // if something else took over the reveal, let's do nothing. + // if something else took over the reveal, let's cancel ourselves + cancel() return@addUpdateListener } lightRevealScrim.revealAmount = animator.animatedValue as Float diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.java index 5d131f2a0046..f5f07c8ca989 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.java @@ -25,6 +25,7 @@ import android.util.Log; import android.util.MathUtils; import android.view.MotionEvent; +import com.android.keyguard.BouncerPanelExpansionCalculator; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.systemui.R; import com.android.systemui.animation.ActivityLaunchAnimator; @@ -71,7 +72,7 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud private float mTransitionToFullShadeProgress; private float mLastDozeAmount; private long mLastUdfpsBouncerShowTime = -1; - private float mStatusBarExpansion; + private float mPanelExpansionFraction; private boolean mLaunchTransitionFadingAway; private boolean mIsLaunchingActivity; private float mActivityLaunchProgress; @@ -188,7 +189,7 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud pw.println("mQsExpanded=" + mQsExpanded); pw.println("mIsBouncerVisible=" + mIsBouncerVisible); pw.println("mInputBouncerHiddenAmount=" + mInputBouncerHiddenAmount); - pw.println("mStatusBarExpansion=" + mStatusBarExpansion); + pw.println("mPanelExpansionFraction=" + mPanelExpansionFraction); pw.println("unpausedAlpha=" + mView.getUnpausedAlpha()); pw.println("mUdfpsRequested=" + mUdfpsRequested); pw.println("mView.mUdfpsRequested=" + mView.mUdfpsRequested); @@ -324,14 +325,16 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud */ @Override public void updateAlpha() { - // fade icon on transitions to showing the status bar, but if mUdfpsRequested, then - // the keyguard is occluded by some application - so instead use the input bouncer - // hidden amount to determine the fade - float expansion = mUdfpsRequested ? mInputBouncerHiddenAmount : mStatusBarExpansion; + // Fade icon on transitions to showing the status bar or bouncer, but if mUdfpsRequested, + // then the keyguard is occluded by some application - so instead use the input bouncer + // hidden amount to determine the fade. + float expansion = mUdfpsRequested ? mInputBouncerHiddenAmount : mPanelExpansionFraction; + int alpha = mShowingUdfpsBouncer ? 255 : (int) MathUtils.constrain( MathUtils.map(.5f, .9f, 0f, 255f, expansion), 0f, 255f); + if (!mShowingUdfpsBouncer) { alpha *= (1.0f - mTransitionToFullShadeProgress); @@ -471,7 +474,9 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud @Override public void onPanelExpansionChanged( float fraction, boolean expanded, boolean tracking) { - mStatusBarExpansion = fraction; + mPanelExpansionFraction = + mKeyguardViewManager.bouncerIsInTransit() ? BouncerPanelExpansionCalculator + .aboutToShowBouncerProgress(fraction) : fraction; updateAlpha(); } }; diff --git a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayContainerViewController.java b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayContainerViewController.java index fb1af8b66b91..74949d094e33 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayContainerViewController.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayContainerViewController.java @@ -16,7 +16,7 @@ package com.android.systemui.dreams; -import static com.android.keyguard.BouncerPanelExpansionCalculator.getBackScrimScaledExpansion; +import static com.android.keyguard.BouncerPanelExpansionCalculator.aboutToShowBouncerProgress; import static com.android.keyguard.BouncerPanelExpansionCalculator.getDreamAlphaScaledExpansion; import static com.android.keyguard.BouncerPanelExpansionCalculator.getDreamYPositionScaledExpansion; import static com.android.systemui.doze.util.BurnInHelperKt.getBurnInOffset; @@ -217,19 +217,19 @@ public class DreamOverlayContainerViewController extends ViewController<DreamOve mBlurUtils.applyBlur(mView.getViewRootImpl(), (int) mBlurUtils.blurRadiusOfRatio( - 1 - getBackScrimScaledExpansion(bouncerHideAmount)), false); + 1 - aboutToShowBouncerProgress(bouncerHideAmount)), false); } private static float getAlpha(int position, float expansion) { return Interpolators.LINEAR_OUT_SLOW_IN.getInterpolation( position == POSITION_TOP ? getDreamAlphaScaledExpansion(expansion) - : getBackScrimScaledExpansion(expansion + 0.03f)); + : aboutToShowBouncerProgress(expansion + 0.03f)); } private float getTranslationY(int position, float expansion) { final float fraction = Interpolators.LINEAR_OUT_SLOW_IN.getInterpolation( position == POSITION_TOP ? getDreamYPositionScaledExpansion(expansion) - : getBackScrimScaledExpansion(expansion + 0.03f)); + : aboutToShowBouncerProgress(expansion + 0.03f)); return MathUtils.lerp(-mDreamOverlayMaxTranslationY, 0, fraction); } } diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java index 0f45a7562d0c..72488f3dc823 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java @@ -83,6 +83,7 @@ import android.util.Log; import android.view.Display; import android.view.Gravity; import android.view.HapticFeedbackConstants; +import android.view.InsetsState; import android.view.InsetsState.InternalInsetsType; import android.view.InsetsVisibilities; import android.view.KeyEvent; @@ -1558,10 +1559,12 @@ public class NavigationBar extends ViewController<NavigationBarView> implements | WindowManager.LayoutParams.FLAG_SLIPPERY, PixelFormat.TRANSLUCENT); lp.gravity = gravity; + lp.providedInternalInsets = new Insets[InsetsState.SIZE]; if (insetsHeight != -1) { - lp.providedInternalInsets = Insets.of(0, height - insetsHeight, 0, 0); + lp.providedInternalInsets[ITYPE_NAVIGATION_BAR] = + Insets.of(0, height - insetsHeight, 0, 0); } else { - lp.providedInternalInsets = Insets.NONE; + lp.providedInternalInsets[ITYPE_NAVIGATION_BAR] = null; } lp.token = new Binder(); lp.accessibilityTitle = mContext.getString(R.string.nav_bar); diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java b/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java index f87f81e40e2c..a64b67023da8 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java @@ -610,7 +610,7 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca view.setVisibility((View.VISIBLE)); } float alpha = mQSPanelController.bouncerInTransit() - ? BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(progress) + ? BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(progress) : ShadeInterpolation.getContentAlpha(progress); view.setAlpha(alpha); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/LightRevealScrim.kt b/packages/SystemUI/src/com/android/systemui/statusbar/LightRevealScrim.kt index 9a932bae833e..270bdc785178 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/LightRevealScrim.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/LightRevealScrim.kt @@ -11,6 +11,7 @@ import android.graphics.PorterDuffColorFilter import android.graphics.PorterDuffXfermode import android.graphics.RadialGradient import android.graphics.Shader +import android.os.Trace import android.util.AttributeSet import android.util.MathUtils.lerp import android.view.View @@ -222,6 +223,8 @@ class LightRevealScrim(context: Context?, attrs: AttributeSet?) : View(context, revealEffect.setRevealAmountOnScrim(value, this) updateScrimOpaque() + Trace.traceCounter(Trace.TRACE_TAG_APP, "light_reveal_amount", + (field * 100).toInt()) invalidate() } } @@ -355,8 +358,8 @@ class LightRevealScrim(context: Context?, attrs: AttributeSet?) : View(context, } override fun onDraw(canvas: Canvas?) { - if (canvas == null || revealGradientWidth <= 0 || revealGradientHeight <= 0 - || revealAmount == 0f) { + if (canvas == null || revealGradientWidth <= 0 || revealGradientHeight <= 0 || + revealAmount == 0f) { if (revealAmount < 1f) { canvas?.drawColor(revealGradientEndColor) } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java index c77b0d6721fb..5e81b5da2455 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java @@ -4404,8 +4404,7 @@ public class CentralSurfaces extends CoreStartable implements @Override public void onDozeAmountChanged(float linear, float eased) { if (mFeatureFlags.isEnabled(Flags.LOCKSCREEN_ANIMATIONS) - && !(mLightRevealScrim.getRevealEffect() instanceof CircleReveal) - && !mBiometricUnlockController.isWakeAndUnlock()) { + && !(mLightRevealScrim.getRevealEffect() instanceof CircleReveal)) { mLightRevealScrim.setRevealAmount(1f - linear); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java index 518a9181ec98..d492c57dfa0c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java @@ -797,7 +797,7 @@ public abstract class PanelViewController { mExpandedFraction = Math.min(1f, maxPanelHeight == 0 ? 0 : mExpandedHeight / maxPanelHeight); mAmbientState.setExpansionFraction(mStatusBarKeyguardViewManager.bouncerIsInTransit() - ? BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(mExpandedFraction) + ? BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(mExpandedFraction) : mExpandedFraction); onHeightUpdated(mExpandedHeight); updatePanelExpansionAndVisibility(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java index fd6503a53208..cc2ff3fb4388 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java @@ -790,7 +790,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump if (mBouncerHiddenFraction != KeyguardBouncer.EXPANSION_HIDDEN) { final float interpolatedFraction = - BouncerPanelExpansionCalculator.getBackScrimScaledExpansion( + BouncerPanelExpansionCalculator.aboutToShowBouncerProgress( mBouncerHiddenFraction); mBehindAlpha = MathUtils.lerp(mDefaultScrimAlpha, mBehindAlpha, interpolatedFraction); @@ -1076,7 +1076,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump private float getInterpolatedFraction() { if (mStatusBarKeyguardViewManager.bouncerIsInTransit()) { return BouncerPanelExpansionCalculator - .getBackScrimScaledExpansion(mPanelExpansionFraction); + .aboutToShowBouncerProgress(mPanelExpansionFraction); } return ShadeInterpolation.getNotificationScrimAlpha(mPanelExpansionFraction); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt index ea935be334c1..935f87dc8221 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt @@ -17,6 +17,7 @@ import com.android.systemui.animation.Interpolators import com.android.systemui.dagger.SysUISingleton import com.android.systemui.keyguard.KeyguardViewMediator import com.android.systemui.keyguard.WakefulnessLifecycle +import com.android.systemui.statusbar.CircleReveal import com.android.systemui.statusbar.LightRevealScrim import com.android.systemui.statusbar.StatusBarState import com.android.systemui.statusbar.StatusBarStateControllerImpl @@ -85,7 +86,9 @@ class UnlockedScreenOffAnimationController @Inject constructor( duration = LIGHT_REVEAL_ANIMATION_DURATION interpolator = Interpolators.LINEAR addUpdateListener { - lightRevealScrim.revealAmount = it.animatedValue as Float + if (lightRevealScrim.revealEffect !is CircleReveal) { + lightRevealScrim.revealAmount = it.animatedValue as Float + } if (lightRevealScrim.isScrimAlmostOccludes && interactionJankMonitor.isInstrumenting(CUJ_SCREEN_OFF)) { // ends the instrument when the scrim almost occludes the screen. @@ -95,9 +98,9 @@ class UnlockedScreenOffAnimationController @Inject constructor( } addListener(object : AnimatorListenerAdapter() { override fun onAnimationCancel(animation: Animator?) { - lightRevealScrim.revealAmount = 1f - lightRevealAnimationPlaying = false - interactionJankMonitor.cancel(CUJ_SCREEN_OFF) + if (lightRevealScrim.revealEffect !is CircleReveal) { + lightRevealScrim.revealAmount = 1f + } } override fun onAnimationEnd(animation: Animator?) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java index 846e07fa0bad..a3f01c21d137 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java @@ -64,8 +64,6 @@ import com.android.settingslib.users.UserCreatingDialog; import com.android.settingslib.utils.ThreadUtils; import com.android.systemui.Dumpable; import com.android.systemui.GuestResumeSessionReceiver; -import com.android.systemui.Prefs; -import com.android.systemui.Prefs.Key; import com.android.systemui.R; import com.android.systemui.SystemUISecondaryUserService; import com.android.systemui.animation.DialogLaunchAnimator; @@ -84,6 +82,7 @@ import com.android.systemui.settings.UserTracker; import com.android.systemui.statusbar.phone.SystemUIDialog; import com.android.systemui.telephony.TelephonyListenerManager; import com.android.systemui.user.CreateUserActivity; +import com.android.systemui.util.settings.GlobalSettings; import com.android.systemui.util.settings.SecureSettings; import java.io.PrintWriter; @@ -144,6 +143,7 @@ public class UserSwitcherController implements Dumpable { // When false, there won't be any visual affordance to add a new user from the keyguard even if // the user is unlocked private boolean mAddUsersFromLockScreen; + private boolean mUserSwitcherEnabled; @VisibleForTesting boolean mPauseRefreshUsers; private int mSecondaryUser = UserHandle.USER_NULL; @@ -160,6 +160,7 @@ public class UserSwitcherController implements Dumpable { private FalsingManager mFalsingManager; private View mView; private String mCreateSupervisedUserPackage; + private GlobalSettings mGlobalSettings; @Inject public UserSwitcherController(Context context, @@ -177,6 +178,7 @@ public class UserSwitcherController implements Dumpable { FalsingManager falsingManager, TelephonyListenerManager telephonyListenerManager, SecureSettings secureSettings, + GlobalSettings globalSettings, @Background Executor bgExecutor, @LongRunning Executor longRunningExecutor, @Main Executor uiExecutor, @@ -194,6 +196,7 @@ public class UserSwitcherController implements Dumpable { mFalsingManager = falsingManager; mInteractionJankMonitor = interactionJankMonitor; mLatencyTracker = latencyTracker; + mGlobalSettings = globalSettings; mGuestResumeSessionReceiver = new GuestResumeSessionReceiver( this, mUserTracker, mUiEventLogger, secureSettings); mBgExecutor = bgExecutor; @@ -237,8 +240,10 @@ public class UserSwitcherController implements Dumpable { @Override public void onChange(boolean selfChange) { mSimpleUserSwitcher = shouldUseSimpleUserSwitcher(); - mAddUsersFromLockScreen = Settings.Global.getInt(mContext.getContentResolver(), - Settings.Global.ADD_USERS_WHEN_LOCKED, 0) != 0; + mAddUsersFromLockScreen = mGlobalSettings.getIntForUser( + Settings.Global.ADD_USERS_WHEN_LOCKED, 0, UserHandle.USER_SYSTEM) != 0; + mUserSwitcherEnabled = mGlobalSettings.getIntForUser( + Settings.Global.USER_SWITCHER_ENABLED, 0, UserHandle.USER_SYSTEM) != 0; refreshUsers(UserHandle.USER_NULL); }; }; @@ -246,6 +251,9 @@ public class UserSwitcherController implements Dumpable { Settings.Global.getUriFor(SIMPLE_USER_SWITCHER_GLOBAL_SETTING), true, mSettingsObserver); mContext.getContentResolver().registerContentObserver( + Settings.Global.getUriFor(Settings.Global.USER_SWITCHER_ENABLED), true, + mSettingsObserver); + mContext.getContentResolver().registerContentObserver( Settings.Global.getUriFor(Settings.Global.ADD_USERS_WHEN_LOCKED), true, mSettingsObserver); mContext.getContentResolver().registerContentObserver( @@ -314,6 +322,10 @@ public class UserSwitcherController implements Dumpable { for (UserInfo info : infos) { boolean isCurrent = currentId == info.id; boolean switchToEnabled = canSwitchUsers || isCurrent; + if (!mUserSwitcherEnabled && !info.isPrimary()) { + continue; + } + if (info.isEnabled()) { if (info.isGuest()) { // Tapping guest icon triggers remove and a user switch therefore @@ -340,9 +352,6 @@ public class UserSwitcherController implements Dumpable { } } } - if (records.size() > 1 || guestRecord != null) { - Prefs.putBoolean(mContext, Key.SEEN_MULTI_USER, true); - } if (guestRecord == null) { if (mGuestUserAutoCreated) { @@ -411,12 +420,14 @@ public class UserSwitcherController implements Dumpable { } boolean canCreateGuest(boolean hasExistingGuest) { - return (currentUserCanCreateUsers() || anyoneCanCreateUsers()) + return mUserSwitcherEnabled + && (currentUserCanCreateUsers() || anyoneCanCreateUsers()) && !hasExistingGuest; } boolean canCreateUser() { - return (currentUserCanCreateUsers() || anyoneCanCreateUsers()) + return mUserSwitcherEnabled + && (currentUserCanCreateUsers() || anyoneCanCreateUsers()) && mUserManager.canAddMoreUsers(UserManager.USER_TYPE_FULL_SECONDARY); } @@ -1034,8 +1045,8 @@ public class UserSwitcherController implements Dumpable { private boolean shouldUseSimpleUserSwitcher() { int defaultSimpleUserSwitcher = mContext.getResources().getBoolean( com.android.internal.R.bool.config_expandLockScreenUserSwitcher) ? 1 : 0; - return Settings.Global.getInt(mContext.getContentResolver(), - SIMPLE_USER_SWITCHER_GLOBAL_SETTING, defaultSimpleUserSwitcher) != 0; + return mGlobalSettings.getIntForUser(SIMPLE_USER_SWITCHER_GLOBAL_SETTING, + defaultSimpleUserSwitcher, UserHandle.USER_SYSTEM) != 0; } public void startActivity(Intent intent) { diff --git a/packages/SystemUI/tests/src/com/android/keyguard/BouncerPanelExpansionCalculatorTest.kt b/packages/SystemUI/tests/src/com/android/keyguard/BouncerPanelExpansionCalculatorTest.kt index 6266bf146f5b..f8fdd8d33a57 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/BouncerPanelExpansionCalculatorTest.kt +++ b/packages/SystemUI/tests/src/com/android/keyguard/BouncerPanelExpansionCalculatorTest.kt @@ -29,29 +29,29 @@ import org.junit.runner.RunWith class BouncerPanelExpansionCalculatorTest : SysuiTestCase() { @Test fun testGetHostViewScaledExpansion() { - assertThat(BouncerPanelExpansionCalculator.getHostViewScaledExpansion(1f)) + assertThat(BouncerPanelExpansionCalculator.showBouncerProgress(1f)) .isEqualTo(1f) - assertThat(BouncerPanelExpansionCalculator.getHostViewScaledExpansion(0.9f)) + assertThat(BouncerPanelExpansionCalculator.showBouncerProgress(0.9f)) .isEqualTo(1f) - assertThat(BouncerPanelExpansionCalculator.getHostViewScaledExpansion(0.59f)) + assertThat(BouncerPanelExpansionCalculator.showBouncerProgress(0.59f)) .isEqualTo(0f) - assertThat(BouncerPanelExpansionCalculator.getHostViewScaledExpansion(0f)) + assertThat(BouncerPanelExpansionCalculator.showBouncerProgress(0f)) .isEqualTo(0f) assertEquals(BouncerPanelExpansionCalculator - .getHostViewScaledExpansion(0.8f), 2f / 3f, 0.01f) + .showBouncerProgress(0.8f), 2f / 3f, 0.01f) } @Test fun testGetBackScrimScaledExpansion() { - assertThat(BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(1f)) + assertThat(BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(1f)) .isEqualTo(1f) assertEquals(BouncerPanelExpansionCalculator - .getBackScrimScaledExpansion(0.95f), 1f / 2f, 0.01f) - assertThat(BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(0.9f)) + .aboutToShowBouncerProgress(0.95f), 1f / 2f, 0.01f) + assertThat(BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(0.9f)) .isEqualTo(0f) - assertThat(BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(0.5f)) + assertThat(BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(0.5f)) .isEqualTo(0f) - assertThat(BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(0f)) + assertThat(BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(0f)) .isEqualTo(0f) } @@ -63,9 +63,9 @@ class BouncerPanelExpansionCalculatorTest : SysuiTestCase() { .getKeyguardClockScaledExpansion(0.8f), 1f / 3f, 0.01f) assertThat(BouncerPanelExpansionCalculator.getKeyguardClockScaledExpansion(0.7f)) .isEqualTo(0f) - assertThat(BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(0.5f)) + assertThat(BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(0.5f)) .isEqualTo(0f) - assertThat(BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(0f)) + assertThat(BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(0f)) .isEqualTo(0f) } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayContainerViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayContainerViewControllerTest.java index 6453c204342c..d70467ddeebe 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayContainerViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayContainerViewControllerTest.java @@ -177,7 +177,7 @@ public class DreamOverlayContainerViewControllerTest extends SysuiTestCase { final float bouncerHideAmount = 0.05f; final float scaledFraction = - BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(bouncerHideAmount); + BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(bouncerHideAmount); bouncerExpansionCaptor.getValue().onExpansionChanged(bouncerHideAmount); verify(mBlurUtils).blurRadiusOfRatio(1 - scaledFraction); diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java index 829445eb92be..f5d19e24bfa6 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java @@ -214,7 +214,7 @@ public class QSFragmentTest extends SysuiBaseFragmentTest { assertThat(mQsFragmentView.getAlpha()) .isEqualTo( - BouncerPanelExpansionCalculator.getBackScrimScaledExpansion( + BouncerPanelExpansionCalculator.aboutToShowBouncerProgress( transitionProgress)); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java index 509fa3b01b0a..69d7932a81fb 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java @@ -1244,11 +1244,11 @@ public class ScrimControllerTest extends SysuiTestCase { float expansion = 0.8f; float expectedAlpha = - BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(expansion); + BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(expansion); assertAlphaAfterExpansion(mNotificationsScrim, expectedAlpha, expansion); expansion = 0.2f; - expectedAlpha = BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(expansion); + expectedAlpha = BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(expansion); assertAlphaAfterExpansion(mNotificationsScrim, expectedAlpha, expansion); } @@ -1284,7 +1284,7 @@ public class ScrimControllerTest extends SysuiTestCase { // Verify normal behavior after mScrimController.setUnocclusionAnimationRunning(false); float expansion = 0.4f; - float alpha = 1 - BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(expansion); + float alpha = 1 - BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(expansion); assertAlphaAfterExpansion(mNotificationsScrim, alpha, expansion); } @@ -1316,15 +1316,15 @@ public class ScrimControllerTest extends SysuiTestCase { mScrimController.transitionTo(ScrimState.KEYGUARD); float expansion = 0.8f; - float alpha = 1 - BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(expansion); + float alpha = 1 - BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(expansion); assertAlphaAfterExpansion(mNotificationsScrim, alpha, expansion); expansion = 0.4f; - alpha = 1 - BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(expansion); + alpha = 1 - BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(expansion); assertAlphaAfterExpansion(mNotificationsScrim, alpha, expansion); expansion = 0.2f; - alpha = 1 - BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(expansion); + alpha = 1 - BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(expansion); assertAlphaAfterExpansion(mNotificationsScrim, alpha, expansion); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/UserSwitcherControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/UserSwitcherControllerTest.kt index 799dafcd01b8..e3d2a2951c97 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/UserSwitcherControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/UserSwitcherControllerTest.kt @@ -28,6 +28,7 @@ import android.hardware.fingerprint.FingerprintManager import android.os.Handler import android.os.UserHandle import android.os.UserManager +import android.provider.Settings import android.testing.AndroidTestingRunner import android.testing.TestableLooper import android.view.ThreadedRenderer @@ -51,6 +52,7 @@ import com.android.systemui.settings.UserTracker import com.android.systemui.statusbar.phone.NotificationShadeWindowView import com.android.systemui.telephony.TelephonyListenerManager import com.android.systemui.util.concurrency.FakeExecutor +import com.android.systemui.util.settings.GlobalSettings import com.android.systemui.util.settings.SecureSettings import com.android.systemui.util.time.FakeSystemClock import org.junit.Assert.assertEquals @@ -67,6 +69,7 @@ import org.mockito.Mockito.`when` import org.mockito.Mockito.any import org.mockito.Mockito.doNothing import org.mockito.Mockito.doReturn +import org.mockito.Mockito.eq import org.mockito.Mockito.mock import org.mockito.Mockito.verify import org.mockito.MockitoAnnotations @@ -95,6 +98,7 @@ class UserSwitcherControllerTest : SysuiTestCase() { @Mock private lateinit var notificationShadeWindowView: NotificationShadeWindowView @Mock private lateinit var threadedRenderer: ThreadedRenderer @Mock private lateinit var dialogLaunchAnimator: DialogLaunchAnimator + @Mock private lateinit var globalSettings: GlobalSettings private lateinit var testableLooper: TestableLooper private lateinit var bgExecutor: FakeExecutor private lateinit var longRunningExecutor: FakeExecutor @@ -148,6 +152,22 @@ class UserSwitcherControllerTest : SysuiTestCase() { `when`(userTracker.userId).thenReturn(ownerId) `when`(userTracker.userInfo).thenReturn(ownerInfo) + `when`( + globalSettings.getIntForUser( + eq(Settings.Global.ADD_USERS_WHEN_LOCKED), + anyInt(), + eq(UserHandle.USER_SYSTEM) + ) + ).thenReturn(0) + + `when`( + globalSettings.getIntForUser( + eq(Settings.Global.USER_SWITCHER_ENABLED), + anyInt(), + eq(UserHandle.USER_SYSTEM) + ) + ).thenReturn(1) + setupController() } @@ -168,6 +188,7 @@ class UserSwitcherControllerTest : SysuiTestCase() { falsingManager, telephonyListenerManager, secureSettings, + globalSettings, bgExecutor, longRunningExecutor, uiExecutor, @@ -469,4 +490,43 @@ class UserSwitcherControllerTest : SysuiTestCase() { // THEN a supervised user can NOT be constructed assertFalse(userSwitcherController.canCreateSupervisedUser()) } + + @Test + fun testCannotCreateUserWhenUserSwitcherDisabled() { + `when`( + globalSettings.getIntForUser( + eq(Settings.Global.USER_SWITCHER_ENABLED), + anyInt(), + eq(UserHandle.USER_SYSTEM) + ) + ).thenReturn(0) + setupController() + assertFalse(userSwitcherController.canCreateUser()) + } + + @Test + fun testCannotCreateGuestUserWhenUserSwitcherDisabled() { + `when`( + globalSettings.getIntForUser( + eq(Settings.Global.USER_SWITCHER_ENABLED), + anyInt(), + eq(UserHandle.USER_SYSTEM) + ) + ).thenReturn(0) + setupController() + assertFalse(userSwitcherController.canCreateGuest(false)) + } + + @Test + fun testCannotCreateSupervisedUserWhenUserSwitcherDisabled() { + `when`( + globalSettings.getIntForUser( + eq(Settings.Global.USER_SWITCHER_ENABLED), + anyInt(), + eq(UserHandle.USER_SYSTEM) + ) + ).thenReturn(0) + setupController() + assertFalse(userSwitcherController.canCreateSupervisedUser()) + } } diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index 465e5e9d8453..b1b5d3ffb2c7 100644 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -9712,7 +9712,7 @@ public class AudioService extends IAudioService.Stub //========================================================================================== static final int LOG_NB_EVENTS_LIFECYCLE = 20; static final int LOG_NB_EVENTS_PHONE_STATE = 20; - static final int LOG_NB_EVENTS_DEVICE_CONNECTION = 30; + static final int LOG_NB_EVENTS_DEVICE_CONNECTION = 50; static final int LOG_NB_EVENTS_FORCE_USE = 20; static final int LOG_NB_EVENTS_VOLUME = 40; static final int LOG_NB_EVENTS_DYN_POLICY = 10; diff --git a/services/core/java/com/android/server/health/HealthRegCallbackAidl.java b/services/core/java/com/android/server/health/HealthRegCallbackAidl.java index 629011a86bb4..90a2f480643d 100644 --- a/services/core/java/com/android/server/health/HealthRegCallbackAidl.java +++ b/services/core/java/com/android/server/health/HealthRegCallbackAidl.java @@ -115,5 +115,13 @@ public class HealthRegCallbackAidl { public void healthInfoChanged(HealthInfo healthInfo) throws RemoteException { mServiceInfoCallback.update(healthInfo); } + @Override + public String getInterfaceHash() { + return IHealthInfoCallback.HASH; + } + @Override + public int getInterfaceVersion() { + return IHealthInfoCallback.VERSION; + } } } diff --git a/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java b/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java index a1ee46b4c943..acc0746764c5 100644 --- a/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java +++ b/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java @@ -389,6 +389,15 @@ public abstract class IContextHubWrapper { mCallback.handleTransactionResult(transactionId, success); }); } + @Override + public String getInterfaceHash() { + return android.hardware.contexthub.IContextHubCallback.HASH; + } + + @Override + public int getInterfaceVersion() { + return android.hardware.contexthub.IContextHubCallback.VERSION; + } } ContextHubWrapperAidl(android.hardware.contexthub.IContextHub hub) { diff --git a/services/core/java/com/android/server/notification/PermissionHelper.java b/services/core/java/com/android/server/notification/PermissionHelper.java index b4230c11bcab..a09aa7cea0a4 100644 --- a/services/core/java/com/android/server/notification/PermissionHelper.java +++ b/services/core/java/com/android/server/notification/PermissionHelper.java @@ -55,8 +55,10 @@ public final class PermissionHelper { private final PermissionManagerServiceInternal mPmi; private final IPackageManager mPackageManager; private final IPermissionManager mPermManager; - // TODO (b/194833441): Remove when the migration is enabled + // TODO (b/194833441): Remove this boolean (but keep the isMigrationEnabled() method) + // when the migration is enabled private final boolean mMigrationEnabled; + private final boolean mIsTv; private final boolean mForceUserSetOnUpgrade; public PermissionHelper(PermissionManagerServiceInternal pmi, IPackageManager packageManager, @@ -67,10 +69,17 @@ public final class PermissionHelper { mPermManager = permManager; mMigrationEnabled = migrationEnabled; mForceUserSetOnUpgrade = forceUserSetOnUpgrade; + boolean isTv; + try { + isTv = mPackageManager.hasSystemFeature(PackageManager.FEATURE_LEANBACK, 0); + } catch (RemoteException e) { + isTv = false; + } + mIsTv = isTv; } public boolean isMigrationEnabled() { - return mMigrationEnabled; + return mMigrationEnabled && !mIsTv; } /** diff --git a/services/core/java/com/android/server/pm/AppsFilterImpl.java b/services/core/java/com/android/server/pm/AppsFilterImpl.java index 5865adb96333..b4ddda551c76 100644 --- a/services/core/java/com/android/server/pm/AppsFilterImpl.java +++ b/services/core/java/com/android/server/pm/AppsFilterImpl.java @@ -76,6 +76,7 @@ import com.android.server.utils.Watcher; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.List; import java.util.Objects; import java.util.Set; @@ -102,6 +103,7 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable * application B is implicitly allowed to query for application A; regardless of any manifest * entries. */ + @GuardedBy("mLock") @Watched private final WatchedSparseSetArray<Integer> mImplicitlyQueryable; private final SnapshotCache<WatchedSparseSetArray<Integer>> mImplicitQueryableSnapshot; @@ -111,6 +113,7 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable * interacted with it, but could keep across package updates. For example, if application A * grants persistable uri permission to application B; regardless of any manifest entries. */ + @GuardedBy("mLock") @Watched private final WatchedSparseSetArray<Integer> mRetainedImplicitlyQueryable; private final SnapshotCache<WatchedSparseSetArray<Integer>> @@ -120,6 +123,7 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable * A mapping from the set of App IDs that query other App IDs via package name to the * list of packages that they can see. */ + @GuardedBy("mLock") @Watched private final WatchedSparseSetArray<Integer> mQueriesViaPackage; private final SnapshotCache<WatchedSparseSetArray<Integer>> mQueriesViaPackageSnapshot; @@ -128,6 +132,7 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable * A mapping from the set of App IDs that query others via component match to the list * of packages that the they resolve to. */ + @GuardedBy("mLock") @Watched private final WatchedSparseSetArray<Integer> mQueriesViaComponent; private final SnapshotCache<WatchedSparseSetArray<Integer>> mQueriesViaComponentSnapshot; @@ -136,6 +141,7 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable * A mapping from the set of App IDs that query other App IDs via library name to the * list of packages that they can see. */ + @GuardedBy("mLock") @Watched private final WatchedSparseSetArray<Integer> mQueryableViaUsesLibrary; private final SnapshotCache<WatchedSparseSetArray<Integer>> mQueryableViaUsesLibrarySnapshot; @@ -158,6 +164,7 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable * A set of App IDs that are always queryable by any package, regardless of their manifest * content. */ + @GuardedBy("mLock") @Watched private final WatchedArraySet<Integer> mForceQueryable; private final SnapshotCache<WatchedArraySet<Integer>> mForceQueryableSnapshot; @@ -173,9 +180,9 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable private final FeatureConfig mFeatureConfig; private final OverlayReferenceMapper mOverlayReferenceMapper; private final StateProvider mStateProvider; - private final PackageManagerInternal mPmInternal; private SigningDetails mSystemSigningDetails; + @GuardedBy("mLock") @Watched private final WatchedArrayList<String> mProtectedBroadcasts; private final SnapshotCache<WatchedArrayList<String>> mProtectedBroadcastsSnapshot; @@ -197,6 +204,11 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable private volatile boolean mSystemReady = false; /** + * Guards the accesses for the list/set fields except for {@link #mShouldFilterCache} + */ + private final Object mLock = new Object(); + + /** * A cached snapshot. */ private final SnapshotCache<AppsFilterImpl> mSnapshot; @@ -284,15 +296,13 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable String[] forceQueryableList, boolean systemAppsQueryable, @Nullable OverlayReferenceMapper.Provider overlayProvider, - Executor backgroundExecutor, - PackageManagerInternal pmInternal) { + Executor backgroundExecutor) { mFeatureConfig = featureConfig; mForceQueryableByDevicePackageNames = forceQueryableList; mSystemAppsQueryable = systemAppsQueryable; mOverlayReferenceMapper = new OverlayReferenceMapper(true /*deferRebuild*/, overlayProvider); mStateProvider = stateProvider; - mPmInternal = pmInternal; mBackgroundExecutor = backgroundExecutor; mShouldFilterCache = new WatchedSparseBooleanMatrix(); mShouldFilterCacheSnapshot = new SnapshotCache.Auto<>( @@ -330,20 +340,22 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable * The copy constructor is used by PackageManagerService to construct a snapshot. */ private AppsFilterImpl(AppsFilterImpl orig) { - mImplicitlyQueryable = orig.mImplicitQueryableSnapshot.snapshot(); - mImplicitQueryableSnapshot = new SnapshotCache.Sealed<>(); - mRetainedImplicitlyQueryable = orig.mRetainedImplicitlyQueryableSnapshot.snapshot(); - mRetainedImplicitlyQueryableSnapshot = new SnapshotCache.Sealed<>(); - mQueriesViaPackage = orig.mQueriesViaPackageSnapshot.snapshot(); - mQueriesViaPackageSnapshot = new SnapshotCache.Sealed<>(); - mQueriesViaComponent = orig.mQueriesViaComponentSnapshot.snapshot(); - mQueriesViaComponentSnapshot = new SnapshotCache.Sealed<>(); - mQueryableViaUsesLibrary = orig.mQueryableViaUsesLibrarySnapshot.snapshot(); - mQueryableViaUsesLibrarySnapshot = new SnapshotCache.Sealed<>(); - mForceQueryable = orig.mForceQueryableSnapshot.snapshot(); - mForceQueryableSnapshot = new SnapshotCache.Sealed<>(); - mProtectedBroadcasts = orig.mProtectedBroadcastsSnapshot.snapshot(); - mProtectedBroadcastsSnapshot = new SnapshotCache.Sealed<>(); + synchronized (orig.mLock) { + mImplicitlyQueryable = orig.mImplicitQueryableSnapshot.snapshot(); + mImplicitQueryableSnapshot = new SnapshotCache.Sealed<>(); + mRetainedImplicitlyQueryable = orig.mRetainedImplicitlyQueryableSnapshot.snapshot(); + mRetainedImplicitlyQueryableSnapshot = new SnapshotCache.Sealed<>(); + mQueriesViaPackage = orig.mQueriesViaPackageSnapshot.snapshot(); + mQueriesViaPackageSnapshot = new SnapshotCache.Sealed<>(); + mQueriesViaComponent = orig.mQueriesViaComponentSnapshot.snapshot(); + mQueriesViaComponentSnapshot = new SnapshotCache.Sealed<>(); + mQueryableViaUsesLibrary = orig.mQueryableViaUsesLibrarySnapshot.snapshot(); + mQueryableViaUsesLibrarySnapshot = new SnapshotCache.Sealed<>(); + mForceQueryable = orig.mForceQueryableSnapshot.snapshot(); + mForceQueryableSnapshot = new SnapshotCache.Sealed<>(); + mProtectedBroadcasts = orig.mProtectedBroadcastsSnapshot.snapshot(); + mProtectedBroadcastsSnapshot = new SnapshotCache.Sealed<>(); + } mQueriesViaComponentRequireRecompute = orig.mQueriesViaComponentRequireRecompute; mForceQueryableByDevicePackageNames = Arrays.copyOf(orig.mForceQueryableByDevicePackageNames, @@ -359,7 +371,6 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable } mBackgroundExecutor = null; - mPmInternal = null; mSnapshot = new SnapshotCache.Sealed<>(); mSystemReady = true; } @@ -397,6 +408,7 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable interface CurrentStateCallback { void currentState(ArrayMap<String, ? extends PackageStateInternal> settings, + Collection<SharedUserSetting> sharedUserSettings, UserInfo[] users); } } @@ -588,12 +600,13 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable final StateProvider stateProvider = command -> { synchronized (injector.getLock()) { command.currentState(injector.getSettings().getPackagesLocked().untrackedStorage(), + injector.getSettings().getAllSharedUsersLPw(), injector.getUserManagerInternal().getUserInfos()); } }; AppsFilterImpl appsFilter = new AppsFilterImpl(stateProvider, featureConfig, forcedQueryablePackageNames, forceSystemAppsQueryable, null, - injector.getBackgroundExecutor(), pmInt); + injector.getBackgroundExecutor()); featureConfig.setAppsFilter(appsFilter); return appsFilter; } @@ -743,9 +756,11 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable return false; } final boolean changed; - changed = retainOnUpdate - ? mRetainedImplicitlyQueryable.add(recipientUid, visibleUid) - : mImplicitlyQueryable.add(recipientUid, visibleUid); + synchronized (mLock) { + changed = retainOnUpdate + ? mRetainedImplicitlyQueryable.add(recipientUid, visibleUid) + : mImplicitlyQueryable.add(recipientUid, visibleUid); + } if (changed && DEBUG_LOGGING) { Slog.i(TAG, (retainOnUpdate ? "retained " : "") + "implicit access granted: " + recipientUid + " -> " + visibleUid); @@ -788,7 +803,7 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable // let's first remove any prior rules for this package removePackage(newPkgSetting, true /*isReplace*/); } - mStateProvider.runWithState((settings, users) -> { + mStateProvider.runWithState((settings, sharedUserSettings, users) -> { ArraySet<String> additionalChangedPackages = addPackageInternal(newPkgSetting, settings); if (mSystemReady) { @@ -806,9 +821,8 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable continue; } - updateShouldFilterCacheForPackage(null, - changedPkgSetting, settings, users, USER_ALL, - settings.size()); + updateShouldFilterCacheForPackage(null, changedPkgSetting, + settings, users, USER_ALL, settings.size()); } } } // else, rebuild entire cache when system is ready @@ -835,7 +849,9 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable // packages for signature matches for (PackageStateInternal setting : existingSettings.values()) { if (isSystemSigned(mSystemSigningDetails, setting)) { - mForceQueryable.add(setting.getAppId()); + synchronized (mLock) { + mForceQueryable.add(setting.getAppId()); + } } } } @@ -845,75 +861,76 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable return null; } - if (mProtectedBroadcasts.addAll(newPkg.getProtectedBroadcasts())) { - mQueriesViaComponentRequireRecompute = true; - } - - final boolean newIsForceQueryable = - mForceQueryable.contains(newPkgSetting.getAppId()) - /* shared user that is already force queryable */ - || newPkgSetting.isForceQueryableOverride() /* adb override */ - || (newPkgSetting.isSystem() && (mSystemAppsQueryable - || newPkg.isForceQueryable() - || ArrayUtils.contains(mForceQueryableByDevicePackageNames, - newPkg.getPackageName()))); - if (newIsForceQueryable - || (mSystemSigningDetails != null - && isSystemSigned(mSystemSigningDetails, newPkgSetting))) { - mForceQueryable.add(newPkgSetting.getAppId()); - } + synchronized (mLock) { + if (mProtectedBroadcasts.addAll(newPkg.getProtectedBroadcasts())) { + mQueriesViaComponentRequireRecompute = true; + } - for (int i = existingSettings.size() - 1; i >= 0; i--) { - final PackageStateInternal existingSetting = existingSettings.valueAt(i); - if (existingSetting.getAppId() == newPkgSetting.getAppId() - || existingSetting.getPkg() - == null) { - continue; + final boolean newIsForceQueryable = + mForceQueryable.contains(newPkgSetting.getAppId()) + /* shared user that is already force queryable */ + || newPkgSetting.isForceQueryableOverride() /* adb override */ + || (newPkgSetting.isSystem() && (mSystemAppsQueryable + || newPkg.isForceQueryable() + || ArrayUtils.contains(mForceQueryableByDevicePackageNames, + newPkg.getPackageName()))); + if (newIsForceQueryable + || (mSystemSigningDetails != null + && isSystemSigned(mSystemSigningDetails, newPkgSetting))) { + mForceQueryable.add(newPkgSetting.getAppId()); } - final AndroidPackage existingPkg = existingSetting.getPkg(); - // let's evaluate the ability of already added packages to see this new package - if (!newIsForceQueryable) { - if (!mQueriesViaComponentRequireRecompute && canQueryViaComponents(existingPkg, - newPkg, mProtectedBroadcasts)) { - mQueriesViaComponent.add(existingSetting.getAppId(), - newPkgSetting.getAppId()); - } - if (canQueryViaPackage(existingPkg, newPkg) - || canQueryAsInstaller(existingSetting, newPkg)) { - mQueriesViaPackage.add(existingSetting.getAppId(), - newPkgSetting.getAppId()); - } - if (canQueryViaUsesLibrary(existingPkg, newPkg)) { - mQueryableViaUsesLibrary.add(existingSetting.getAppId(), - newPkgSetting.getAppId()); + + for (int i = existingSettings.size() - 1; i >= 0; i--) { + final PackageStateInternal existingSetting = existingSettings.valueAt(i); + if (existingSetting.getAppId() == newPkgSetting.getAppId() + || existingSetting.getPkg() + == null) { + continue; } - } - // now we'll evaluate our new package's ability to see existing packages - if (!mForceQueryable.contains(existingSetting.getAppId())) { - if (!mQueriesViaComponentRequireRecompute && canQueryViaComponents(newPkg, - existingPkg, mProtectedBroadcasts)) { - mQueriesViaComponent.add(newPkgSetting.getAppId(), - existingSetting.getAppId()); + final AndroidPackage existingPkg = existingSetting.getPkg(); + // let's evaluate the ability of already added packages to see this new package + if (!newIsForceQueryable) { + if (!mQueriesViaComponentRequireRecompute && canQueryViaComponents(existingPkg, + newPkg, mProtectedBroadcasts)) { + mQueriesViaComponent.add(existingSetting.getAppId(), + newPkgSetting.getAppId()); + } + if (canQueryViaPackage(existingPkg, newPkg) + || canQueryAsInstaller(existingSetting, newPkg)) { + mQueriesViaPackage.add(existingSetting.getAppId(), + newPkgSetting.getAppId()); + } + if (canQueryViaUsesLibrary(existingPkg, newPkg)) { + mQueryableViaUsesLibrary.add(existingSetting.getAppId(), + newPkgSetting.getAppId()); + } } - if (canQueryViaPackage(newPkg, existingPkg) - || canQueryAsInstaller(newPkgSetting, existingPkg)) { - mQueriesViaPackage.add(newPkgSetting.getAppId(), - existingSetting.getAppId()); + // now we'll evaluate our new package's ability to see existing packages + if (!mForceQueryable.contains(existingSetting.getAppId())) { + if (!mQueriesViaComponentRequireRecompute && canQueryViaComponents(newPkg, + existingPkg, mProtectedBroadcasts)) { + mQueriesViaComponent.add(newPkgSetting.getAppId(), + existingSetting.getAppId()); + } + if (canQueryViaPackage(newPkg, existingPkg) + || canQueryAsInstaller(newPkgSetting, existingPkg)) { + mQueriesViaPackage.add(newPkgSetting.getAppId(), + existingSetting.getAppId()); + } + if (canQueryViaUsesLibrary(newPkg, existingPkg)) { + mQueryableViaUsesLibrary.add(newPkgSetting.getAppId(), + existingSetting.getAppId()); + } } - if (canQueryViaUsesLibrary(newPkg, existingPkg)) { - mQueryableViaUsesLibrary.add(newPkgSetting.getAppId(), - existingSetting.getAppId()); + // if either package instruments the other, mark both as visible to one another + if (newPkgSetting.getPkg() != null && existingSetting.getPkg() != null + && (pkgInstruments(newPkgSetting.getPkg(), existingSetting.getPkg()) + || pkgInstruments(existingSetting.getPkg(), newPkgSetting.getPkg()))) { + mQueriesViaPackage.add(newPkgSetting.getAppId(), existingSetting.getAppId()); + mQueriesViaPackage.add(existingSetting.getAppId(), newPkgSetting.getAppId()); } } - // if either package instruments the other, mark both as visible to one another - if (newPkgSetting.getPkg() != null && existingSetting.getPkg() != null - && (pkgInstruments(newPkgSetting.getPkg(), existingSetting.getPkg()) - || pkgInstruments(existingSetting.getPkg(), newPkgSetting.getPkg()))) { - mQueriesViaPackage.add(newPkgSetting.getAppId(), existingSetting.getAppId()); - mQueriesViaPackage.add(existingSetting.getAppId(), newPkgSetting.getAppId()); - } } - int existingSize = existingSettings.size(); ArrayMap<String, AndroidPackage> existingPkgs = new ArrayMap<>(existingSize); for (int index = 0; index < existingSize; index++) { @@ -954,7 +971,7 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable } private void updateEntireShouldFilterCache(int subjectUserId) { - mStateProvider.runWithState((settings, users) -> { + mStateProvider.runWithState((settings, sharedUserSettings, users) -> { int userId = USER_NULL; for (int u = 0; u < users.length; u++) { if (subjectUserId == users[u].id) { @@ -972,7 +989,8 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable } private void updateEntireShouldFilterCacheInner( - ArrayMap<String, ? extends PackageStateInternal> settings, UserInfo[] users, + ArrayMap<String, ? extends PackageStateInternal> settings, + UserInfo[] users, int subjectUserId) { synchronized (mCacheLock) { if (subjectUserId == USER_ALL) { @@ -982,16 +1000,19 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable } for (int i = settings.size() - 1; i >= 0; i--) { updateShouldFilterCacheForPackage( - null /*skipPackage*/, settings.valueAt(i), settings, users, subjectUserId, i); + null /*skipPackage*/, settings.valueAt(i), settings, users, + subjectUserId, i); } } private void updateEntireShouldFilterCacheAsync() { mBackgroundExecutor.execute(() -> { final ArrayMap<String, PackageStateInternal> settingsCopy = new ArrayMap<>(); + final Collection<SharedUserSetting> sharedUserSettingsCopy = + new ArraySet<SharedUserSetting>(); final ArrayMap<String, AndroidPackage> packagesCache = new ArrayMap<>(); final UserInfo[][] usersRef = new UserInfo[1][]; - mStateProvider.runWithState((settings, users) -> { + mStateProvider.runWithState((settings, sharedUserSettings, users) -> { packagesCache.ensureCapacity(settings.size()); settingsCopy.putAll(settings); usersRef[0] = users; @@ -1001,11 +1022,12 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable final AndroidPackage pkg = settings.valueAt(i).getPkg(); packagesCache.put(settings.keyAt(i), pkg); } + sharedUserSettingsCopy.addAll(sharedUserSettings); }); boolean[] changed = new boolean[1]; // We have a cache, let's make sure the world hasn't changed out from under us. - mStateProvider.runWithState((settings, users) -> { + mStateProvider.runWithState((settings, sharedUserSettings, users) -> { if (settings.size() != settingsCopy.size()) { changed[0] = true; return; @@ -1025,7 +1047,8 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable Slog.i(TAG, "Rebuilding cache with lock due to package change."); } } else { - updateEntireShouldFilterCacheInner(settingsCopy, usersRef[0], USER_ALL); + updateEntireShouldFilterCacheInner(settingsCopy, + usersRef[0], USER_ALL); } }); } @@ -1047,7 +1070,7 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable } private void updateShouldFilterCacheForPackage(String packageName) { - mStateProvider.runWithState((settings, users) -> { + mStateProvider.runWithState((settings, sharedUserSettings, users) -> { if (!mSystemReady) { return; } @@ -1134,16 +1157,18 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable private void collectProtectedBroadcasts( ArrayMap<String, ? extends PackageStateInternal> existingSettings, @Nullable String excludePackage) { - mProtectedBroadcasts.clear(); - for (int i = existingSettings.size() - 1; i >= 0; i--) { - PackageStateInternal setting = existingSettings.valueAt(i); - if (setting.getPkg() == null || setting.getPkg().getPackageName().equals( - excludePackage)) { - continue; - } - final List<String> protectedBroadcasts = setting.getPkg().getProtectedBroadcasts(); - if (!protectedBroadcasts.isEmpty()) { - mProtectedBroadcasts.addAll(protectedBroadcasts); + synchronized (mLock) { + mProtectedBroadcasts.clear(); + for (int i = existingSettings.size() - 1; i >= 0; i--) { + PackageStateInternal setting = existingSettings.valueAt(i); + if (setting.getPkg() == null || setting.getPkg().getPackageName().equals( + excludePackage)) { + continue; + } + final List<String> protectedBroadcasts = setting.getPkg().getProtectedBroadcasts(); + if (!protectedBroadcasts.isEmpty()) { + mProtectedBroadcasts.addAll(protectedBroadcasts); + } } } } @@ -1154,24 +1179,26 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable */ private void recomputeComponentVisibility( ArrayMap<String, ? extends PackageStateInternal> existingSettings) { - mQueriesViaComponent.clear(); - for (int i = existingSettings.size() - 1; i >= 0; i--) { - PackageStateInternal setting = existingSettings.valueAt(i); - if (setting.getPkg() == null || requestsQueryAllPackages(setting.getPkg())) { - continue; - } - for (int j = existingSettings.size() - 1; j >= 0; j--) { - if (i == j) { - continue; - } - final PackageStateInternal otherSetting = existingSettings.valueAt(j); - if (otherSetting.getPkg() == null || mForceQueryable.contains( - otherSetting.getAppId())) { + synchronized (mLock) { + mQueriesViaComponent.clear(); + for (int i = existingSettings.size() - 1; i >= 0; i--) { + PackageStateInternal setting = existingSettings.valueAt(i); + if (setting.getPkg() == null || requestsQueryAllPackages(setting.getPkg())) { continue; } - if (canQueryViaComponents(setting.getPkg(), otherSetting.getPkg(), - mProtectedBroadcasts)) { - mQueriesViaComponent.add(setting.getAppId(), otherSetting.getAppId()); + for (int j = existingSettings.size() - 1; j >= 0; j--) { + if (i == j) { + continue; + } + final PackageStateInternal otherSetting = existingSettings.valueAt(j); + if (otherSetting.getPkg() == null || mForceQueryable.contains( + otherSetting.getAppId())) { + continue; + } + if (canQueryViaComponents(setting.getPkg(), otherSetting.getPkg(), + mProtectedBroadcasts)) { + mQueriesViaComponent.add(setting.getAppId(), otherSetting.getAppId()); + } } } } @@ -1185,8 +1212,10 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable @Nullable public SparseArray<int[]> getVisibilityAllowList(PackageStateInternal setting, int[] users, ArrayMap<String, ? extends PackageStateInternal> existingSettings) { - if (mForceQueryable.contains(setting.getAppId())) { - return null; + synchronized (mLock) { + if (mForceQueryable.contains(setting.getAppId())) { + return null; + } } // let's reserve max memory to limit the number of allocations SparseArray<int[]> result = new SparseArray<>(users.length); @@ -1249,57 +1278,59 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable * @param isReplace if the package is being replaced. */ public void removePackage(PackageStateInternal setting, boolean isReplace) { - mStateProvider.runWithState((settings, users) -> { + mStateProvider.runWithState((settings, sharedUserSettings, users) -> { final ArraySet<String> additionalChangedPackages; final int userCount = users.length; - for (int u = 0; u < userCount; u++) { - final int userId = users[u].id; - final int removingUid = UserHandle.getUid(userId, setting.getAppId()); - mImplicitlyQueryable.remove(removingUid); - for (int i = mImplicitlyQueryable.size() - 1; i >= 0; i--) { - mImplicitlyQueryable.remove(mImplicitlyQueryable.keyAt(i), - removingUid); - } + synchronized (mLock) { + for (int u = 0; u < userCount; u++) { + final int userId = users[u].id; + final int removingUid = UserHandle.getUid(userId, setting.getAppId()); + mImplicitlyQueryable.remove(removingUid); + for (int i = mImplicitlyQueryable.size() - 1; i >= 0; i--) { + mImplicitlyQueryable.remove(mImplicitlyQueryable.keyAt(i), + removingUid); + } - if (isReplace) { - continue; - } + if (isReplace) { + continue; + } - mRetainedImplicitlyQueryable.remove(removingUid); - for (int i = mRetainedImplicitlyQueryable.size() - 1; i >= 0; i--) { - mRetainedImplicitlyQueryable.remove( - mRetainedImplicitlyQueryable.keyAt(i), removingUid); + mRetainedImplicitlyQueryable.remove(removingUid); + for (int i = mRetainedImplicitlyQueryable.size() - 1; i >= 0; i--) { + mRetainedImplicitlyQueryable.remove( + mRetainedImplicitlyQueryable.keyAt(i), removingUid); + } } - } - if (!mQueriesViaComponentRequireRecompute) { - mQueriesViaComponent.remove(setting.getAppId()); - for (int i = mQueriesViaComponent.size() - 1; i >= 0; i--) { - mQueriesViaComponent.remove(mQueriesViaComponent.keyAt(i), + if (!mQueriesViaComponentRequireRecompute) { + mQueriesViaComponent.remove(setting.getAppId()); + for (int i = mQueriesViaComponent.size() - 1; i >= 0; i--) { + mQueriesViaComponent.remove(mQueriesViaComponent.keyAt(i), + setting.getAppId()); + } + } + mQueriesViaPackage.remove(setting.getAppId()); + for (int i = mQueriesViaPackage.size() - 1; i >= 0; i--) { + mQueriesViaPackage.remove(mQueriesViaPackage.keyAt(i), + setting.getAppId()); + } + mQueryableViaUsesLibrary.remove(setting.getAppId()); + for (int i = mQueryableViaUsesLibrary.size() - 1; i >= 0; i--) { + mQueryableViaUsesLibrary.remove(mQueryableViaUsesLibrary.keyAt(i), setting.getAppId()); } - } - mQueriesViaPackage.remove(setting.getAppId()); - for (int i = mQueriesViaPackage.size() - 1; i >= 0; i--) { - mQueriesViaPackage.remove(mQueriesViaPackage.keyAt(i), - setting.getAppId()); - } - mQueryableViaUsesLibrary.remove(setting.getAppId()); - for (int i = mQueryableViaUsesLibrary.size() - 1; i >= 0; i--) { - mQueryableViaUsesLibrary.remove(mQueryableViaUsesLibrary.keyAt(i), - setting.getAppId()); - } - mForceQueryable.remove(setting.getAppId()); + mForceQueryable.remove(setting.getAppId()); - if (setting.getPkg() != null - && !setting.getPkg().getProtectedBroadcasts().isEmpty()) { - final String removingPackageName = setting.getPkg().getPackageName(); - final ArrayList<String> protectedBroadcasts = new ArrayList<>(); - protectedBroadcasts.addAll(mProtectedBroadcasts.untrackedStorage()); - collectProtectedBroadcasts(settings, removingPackageName); - if (!mProtectedBroadcasts.containsAll(protectedBroadcasts)) { - mQueriesViaComponentRequireRecompute = true; + if (setting.getPkg() != null + && !setting.getPkg().getProtectedBroadcasts().isEmpty()) { + final String removingPackageName = setting.getPkg().getPackageName(); + final ArrayList<String> protectedBroadcasts = new ArrayList<>(); + protectedBroadcasts.addAll(mProtectedBroadcasts.untrackedStorage()); + collectProtectedBroadcasts(settings, removingPackageName); + if (!mProtectedBroadcasts.containsAll(protectedBroadcasts)) { + mQueriesViaComponentRequireRecompute = true; + } } } @@ -1314,8 +1345,8 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable // update the // cache if (setting.hasSharedUser()) { - final ArraySet<PackageStateInternal> sharedUserPackages = - mPmInternal.getSharedUserPackages(setting.getSharedUserAppId()); + final ArraySet<? extends PackageStateInternal> sharedUserPackages = + getSharedUserPackages(setting.getSharedUserAppId(), sharedUserSettings); for (int i = sharedUserPackages.size() - 1; i >= 0; i--) { if (sharedUserPackages.valueAt(i) == setting) { continue; @@ -1327,8 +1358,8 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable removeAppIdFromVisibilityCache(setting.getAppId()); if (mSystemReady && setting.hasSharedUser()) { - final ArraySet<PackageStateInternal> sharedUserPackages = - mPmInternal.getSharedUserPackages(setting.getSharedUserAppId()); + final ArraySet<? extends PackageStateInternal> sharedUserPackages = + getSharedUserPackages(setting.getSharedUserAppId(), sharedUserSettings); for (int i = sharedUserPackages.size() - 1; i >= 0; i--) { PackageStateInternal siblingSetting = sharedUserPackages.valueAt(i); @@ -1336,8 +1367,8 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable continue; } updateShouldFilterCacheForPackage( - setting.getPackageName(), siblingSetting, settings, users, - USER_ALL, settings.size()); + setting.getPackageName(), siblingSetting, settings, + users, USER_ALL, settings.size()); } } @@ -1353,8 +1384,8 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable continue; } - updateShouldFilterCacheForPackage(null, - changedPkgSetting, settings, users, USER_ALL, settings.size()); + updateShouldFilterCacheForPackage(null, changedPkgSetting, + settings, users, USER_ALL, settings.size()); } } } @@ -1363,6 +1394,17 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable }); } + private ArraySet<? extends PackageStateInternal> getSharedUserPackages(int sharedUserAppId, + Collection<SharedUserSetting> sharedUserSettings) { + for (SharedUserSetting setting : sharedUserSettings) { + if (setting.mAppId != sharedUserAppId) { + continue; + } + return setting.getPackageStates(); + } + return new ArraySet<>(); + } + /** * See * {@link AppsFilterSnapshot#shouldFilterApplication(int, Object, PackageStateInternal, @@ -1441,23 +1483,25 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable return true; } final PackageStateInternal callingPkgSetting; - final ArraySet<? extends PackageStateInternal> callingSharedPkgSettings; if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "callingSetting instanceof"); } + final ArraySet<PackageStateInternal> callingSharedPkgSettings = new ArraySet<>(); + if (callingSetting instanceof PackageStateInternal) { final PackageStateInternal packageState = (PackageStateInternal) callingSetting; if (packageState.hasSharedUser()) { callingPkgSetting = null; - callingSharedPkgSettings = mPmInternal.getSharedUserPackages( - packageState.getSharedUserAppId()); + mStateProvider.runWithState((settings, sharedUserSettings, users) -> + callingSharedPkgSettings.addAll(getSharedUserPackages( + packageState.getSharedUserAppId(), sharedUserSettings))); } else { callingPkgSetting = packageState; - callingSharedPkgSettings = null; } } else { callingPkgSetting = null; - callingSharedPkgSettings = ((SharedUserSetting) callingSetting).getPackageStates(); + callingSharedPkgSettings.addAll( + ((SharedUserSetting) callingSetting).getPackageStates()); } if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); @@ -1545,11 +1589,13 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mForceQueryable"); } - if (mForceQueryable.contains(targetAppId)) { - if (DEBUG_LOGGING) { - log(callingSetting, targetPkgSetting, "force queryable"); + synchronized (mLock) { + if (mForceQueryable.contains(targetAppId)) { + if (DEBUG_LOGGING) { + log(callingSetting, targetPkgSetting, "force queryable"); + } + return false; } - return false; } } finally { if (DEBUG_TRACING) { @@ -1560,11 +1606,13 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mQueriesViaPackage"); } - if (mQueriesViaPackage.contains(callingAppId, targetAppId)) { - if (DEBUG_LOGGING) { - log(callingSetting, targetPkgSetting, "queries package"); + synchronized (mLock) { + if (mQueriesViaPackage.contains(callingAppId, targetAppId)) { + if (DEBUG_LOGGING) { + log(callingSetting, targetPkgSetting, "queries package"); + } + return false; } - return false; } } finally { if (DEBUG_TRACING) { @@ -1576,15 +1624,17 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mQueriesViaComponent"); } if (mQueriesViaComponentRequireRecompute) { - mStateProvider.runWithState((settings, users) -> { + mStateProvider.runWithState((settings, sharedUserSettings, users) -> { recomputeComponentVisibility(settings); }); } - if (mQueriesViaComponent.contains(callingAppId, targetAppId)) { - if (DEBUG_LOGGING) { - log(callingSetting, targetPkgSetting, "queries component"); + synchronized (mLock) { + if (mQueriesViaComponent.contains(callingAppId, targetAppId)) { + if (DEBUG_LOGGING) { + log(callingSetting, targetPkgSetting, "queries component"); + } + return false; } - return false; } } finally { if (DEBUG_TRACING) { @@ -1597,11 +1647,13 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mImplicitlyQueryable"); } final int targetUid = UserHandle.getUid(targetUserId, targetAppId); - if (mImplicitlyQueryable.contains(callingUid, targetUid)) { - if (DEBUG_LOGGING) { - log(callingSetting, targetPkgSetting, "implicitly queryable for user"); + synchronized (mLock) { + if (mImplicitlyQueryable.contains(callingUid, targetUid)) { + if (DEBUG_LOGGING) { + log(callingSetting, targetPkgSetting, "implicitly queryable for user"); + } + return false; } - return false; } } finally { if (DEBUG_TRACING) { @@ -1614,12 +1666,14 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mRetainedImplicitlyQueryable"); } final int targetUid = UserHandle.getUid(targetUserId, targetAppId); - if (mRetainedImplicitlyQueryable.contains(callingUid, targetUid)) { - if (DEBUG_LOGGING) { - log(callingSetting, targetPkgSetting, - "retained implicitly queryable for user"); + synchronized (mLock) { + if (mRetainedImplicitlyQueryable.contains(callingUid, targetUid)) { + if (DEBUG_LOGGING) { + log(callingSetting, targetPkgSetting, + "retained implicitly queryable for user"); + } + return false; } - return false; } } finally { if (DEBUG_TRACING) { @@ -1632,7 +1686,7 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mOverlayReferenceMapper"); } final String targetName = targetPkg.getPackageName(); - if (callingSharedPkgSettings != null) { + if (!callingSharedPkgSettings.isEmpty()) { int size = callingSharedPkgSettings.size(); for (int index = 0; index < size; index++) { PackageStateInternal pkgSetting = callingSharedPkgSettings.valueAt(index); @@ -1665,11 +1719,13 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mQueryableViaUsesLibrary"); } - if (mQueryableViaUsesLibrary.contains(callingAppId, targetAppId)) { - if (DEBUG_LOGGING) { - log(callingSetting, targetPkgSetting, "queryable for library users"); + synchronized (mLock) { + if (mQueryableViaUsesLibrary.contains(callingAppId, targetAppId)) { + if (DEBUG_LOGGING) { + log(callingSetting, targetPkgSetting, "queryable for library users"); + } + return false; } - return false; } } finally { if (DEBUG_TRACING) { @@ -1785,23 +1841,25 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable pw.println(" system apps queryable: " + mSystemAppsQueryable); dumpPackageSet(pw, filteringAppId, mForceQueryable.untrackedStorage(), "forceQueryable", " ", expandPackages); - pw.println(" queries via package name:"); - dumpQueriesMap(pw, filteringAppId, mQueriesViaPackage, " ", expandPackages); - pw.println(" queries via component:"); - dumpQueriesMap(pw, filteringAppId, mQueriesViaComponent, " ", expandPackages); - pw.println(" queryable via interaction:"); - for (int user : users) { - pw.append(" User ").append(Integer.toString(user)).println(":"); - dumpQueriesMap(pw, - filteringAppId == null ? null : UserHandle.getUid(user, filteringAppId), - mImplicitlyQueryable, " ", expandPackages); - dumpQueriesMap(pw, - filteringAppId == null ? null : UserHandle.getUid(user, filteringAppId), - mRetainedImplicitlyQueryable, " ", expandPackages); - } - pw.println(" queryable via uses-library:"); - dumpQueriesMap(pw, filteringAppId, mQueryableViaUsesLibrary, " ", - expandPackages); + synchronized (mLock) { + pw.println(" queries via package name:"); + dumpQueriesMap(pw, filteringAppId, mQueriesViaPackage, " ", expandPackages); + pw.println(" queries via component:"); + dumpQueriesMap(pw, filteringAppId, mQueriesViaComponent, " ", expandPackages); + pw.println(" queryable via interaction:"); + for (int user : users) { + pw.append(" User ").append(Integer.toString(user)).println(":"); + dumpQueriesMap(pw, + filteringAppId == null ? null : UserHandle.getUid(user, filteringAppId), + mImplicitlyQueryable, " ", expandPackages); + dumpQueriesMap(pw, + filteringAppId == null ? null : UserHandle.getUid(user, filteringAppId), + mRetainedImplicitlyQueryable, " ", expandPackages); + } + pw.println(" queryable via uses-library:"); + dumpQueriesMap(pw, filteringAppId, mQueryableViaUsesLibrary, " ", + expandPackages); + } } private static void dumpQueriesMap(PrintWriter pw, @Nullable Integer filteringId, diff --git a/services/core/java/com/android/server/pm/permission/PermissionManagerServiceImpl.java b/services/core/java/com/android/server/pm/permission/PermissionManagerServiceImpl.java index c524fb7ae9e5..d11ea532f140 100644 --- a/services/core/java/com/android/server/pm/permission/PermissionManagerServiceImpl.java +++ b/services/core/java/com/android/server/pm/permission/PermissionManagerServiceImpl.java @@ -297,6 +297,8 @@ public class PermissionManagerServiceImpl implements PermissionManagerServiceInt .OnRuntimePermissionStateChangedListener> mRuntimePermissionStateChangedListeners = new ArrayList<>(); + private final boolean mIsLeanback; + @NonNull private final OnPermissionChangeListeners mOnPermissionChangeListeners; @@ -380,6 +382,7 @@ public class PermissionManagerServiceImpl implements PermissionManagerServiceInt mContext = context; mPackageManagerInt = LocalServices.getService(PackageManagerInternal.class); mUserManagerInt = LocalServices.getService(UserManagerInternal.class); + mIsLeanback = availableFeatures.containsKey(PackageManager.FEATURE_LEANBACK); mPrivilegedPermissionAllowlistSourcePackageNames.add(PLATFORM_PACKAGE_NAME); // PackageManager.hasSystemFeature() is not used here because PackageManagerService @@ -2822,6 +2825,14 @@ public class PermissionManagerServiceImpl implements PermissionManagerServiceInt } } } + if (mIsLeanback && NOTIFICATION_PERMISSIONS.contains(permName)) { + uidState.grantPermission(bp); + if (origPermState == null || !origPermState.isGranted()) { + if (uidState.grantPermission(bp)) { + wasChanged = true; + } + } + } } else { if (origPermState == null) { // New permission diff --git a/services/core/java/com/android/server/vibrator/VibrationSettings.java b/services/core/java/com/android/server/vibrator/VibrationSettings.java index 18e9904142eb..ac635a0746c5 100644 --- a/services/core/java/com/android/server/vibrator/VibrationSettings.java +++ b/services/core/java/com/android/server/vibrator/VibrationSettings.java @@ -238,8 +238,6 @@ final class VibrationSettings { // Listen to all settings that might affect the result of Vibrator.getVibrationIntensity. registerSettingsObserver(Settings.System.getUriFor(Settings.System.VIBRATE_INPUT_DEVICES)); registerSettingsObserver(Settings.System.getUriFor(Settings.System.VIBRATE_ON)); - registerSettingsObserver(Settings.System.getUriFor(Settings.System.VIBRATE_WHEN_RINGING)); - registerSettingsObserver(Settings.System.getUriFor(Settings.System.APPLY_RAMPING_RINGER)); registerSettingsObserver(Settings.System.getUriFor( Settings.System.HAPTIC_FEEDBACK_ENABLED)); registerSettingsObserver( @@ -449,19 +447,12 @@ final class VibrationSettings { mCurrentVibrationIntensities.put(USAGE_NOTIFICATION, notificationIntensity); mCurrentVibrationIntensities.put(USAGE_MEDIA, mediaIntensity); mCurrentVibrationIntensities.put(USAGE_UNKNOWN, mediaIntensity); + mCurrentVibrationIntensities.put(USAGE_RINGTONE, ringIntensity); // Communication request is not disabled by the notification setting. mCurrentVibrationIntensities.put(USAGE_COMMUNICATION_REQUEST, positiveNotificationIntensity); - if (!loadBooleanSetting(Settings.System.VIBRATE_WHEN_RINGING) - && !loadBooleanSetting(Settings.System.APPLY_RAMPING_RINGER)) { - // Make sure deprecated boolean setting still disables ringtone vibrations. - mCurrentVibrationIntensities.put(USAGE_RINGTONE, Vibrator.VIBRATION_INTENSITY_OFF); - } else { - mCurrentVibrationIntensities.put(USAGE_RINGTONE, ringIntensity); - } - // This should adapt the behavior preceding the introduction of this new setting // key, which is to apply HAPTIC_FEEDBACK_INTENSITY, unless it's disabled. mCurrentVibrationIntensities.put(USAGE_HARDWARE_FEEDBACK, hardwareFeedbackIntensity); diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index c5251296b91e..dc4e1174edf3 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -6300,7 +6300,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // starting window is drawn, the transition can start earlier. Exclude finishing and bubble // because it may be a trampoline. if (!wasTaskVisible && mStartingData != null && !finishing && !mLaunchedFromBubble - && !mDisplayContent.mAppTransition.isReady() + && mVisibleRequested && !mDisplayContent.mAppTransition.isReady() && !mDisplayContent.mAppTransition.isRunning() && mDisplayContent.isNextTransitionForward()) { // The pending transition state will be cleared after the transition is started, so diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index 566ed6076526..eaf82b625f71 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -1146,8 +1146,13 @@ public class DisplayPolicy { mDisplayContent.setInsetProvider(ITYPE_NAVIGATION_BAR, win, (displayFrames, windowContainer, inOutFrame) -> { if (!mNavButtonForcedVisible) { - inOutFrame.inset(win.getLayoutingAttrs( - displayFrames.mRotation).providedInternalInsets); + final Insets[] providedInternalInsets = win.getLayoutingAttrs( + displayFrames.mRotation).providedInternalInsets; + if (providedInternalInsets != null + && providedInternalInsets.length > ITYPE_NAVIGATION_BAR + && providedInternalInsets[ITYPE_NAVIGATION_BAR] != null) { + inOutFrame.inset(providedInternalInsets[ITYPE_NAVIGATION_BAR]); + } inOutFrame.inset(win.mGivenContentInsets); } }, @@ -1193,13 +1198,16 @@ public class DisplayPolicy { if (attrs.providesInsetsTypes != null) { for (@InternalInsetsType int insetsType : attrs.providesInsetsTypes) { final TriConsumer<DisplayFrames, WindowContainer, Rect> imeFrameProvider = - !attrs.providedInternalImeInsets.equals(Insets.NONE) - ? (displayFrames, windowContainer, inOutFrame) -> { - inOutFrame.inset(win.getLayoutingAttrs( - displayFrames.mRotation) - .providedInternalImeInsets); - } - : null; + (displayFrames, windowContainer, inOutFrame) -> { + final Insets[] providedInternalImeInsets = + win.getLayoutingAttrs(displayFrames.mRotation) + .providedInternalImeInsets; + if (providedInternalImeInsets != null + && providedInternalImeInsets.length > insetsType + && providedInternalImeInsets[insetsType] != null) { + inOutFrame.inset(providedInternalImeInsets[insetsType]); + } + }; switch (insetsType) { case ITYPE_STATUS_BAR: mStatusBarAlt = win; @@ -1220,8 +1228,13 @@ public class DisplayPolicy { } mDisplayContent.setInsetProvider(insetsType, win, (displayFrames, windowContainer, inOutFrame) -> { - inOutFrame.inset(win.getLayoutingAttrs( - displayFrames.mRotation).providedInternalInsets); + final Insets[] providedInternalInsets = win.getLayoutingAttrs( + displayFrames.mRotation).providedInternalInsets; + if (providedInternalInsets != null + && providedInternalInsets.length > insetsType + && providedInternalInsets[insetsType] != null) { + inOutFrame.inset(providedInternalInsets[insetsType]); + } inOutFrame.inset(win.mGivenContentInsets); }, imeFrameProvider); mInsetsSourceWindowsExceptIme.add(win); @@ -1937,15 +1950,23 @@ public class DisplayPolicy { && lp.paramsForRotation[rotation] != null) { lp = lp.paramsForRotation[rotation]; } + final Insets providedInternalInsets; + if (lp.providedInternalInsets != null + && lp.providedInternalInsets.length > ITYPE_NAVIGATION_BAR + && lp.providedInternalInsets[ITYPE_NAVIGATION_BAR] != null) { + providedInternalInsets = lp.providedInternalInsets[ITYPE_NAVIGATION_BAR]; + } else { + providedInternalInsets = Insets.NONE; + } if (position == NAV_BAR_LEFT) { - if (lp.width > lp.providedInternalInsets.right) { - return lp.width - lp.providedInternalInsets.right; + if (lp.width > providedInternalInsets.right) { + return lp.width - providedInternalInsets.right; } else { return 0; } } else if (position == NAV_BAR_RIGHT) { - if (lp.width > lp.providedInternalInsets.left) { - return lp.width - lp.providedInternalInsets.left; + if (lp.width > providedInternalInsets.left) { + return lp.width - providedInternalInsets.left; } else { return 0; } @@ -1994,10 +2015,18 @@ public class DisplayPolicy { return 0; } LayoutParams lp = mNavigationBar.getLayoutingAttrs(rotation); - if (lp.height < lp.providedInternalInsets.top) { + final Insets providedInternalInsets; + if (lp.providedInternalInsets != null + && lp.providedInternalInsets.length > ITYPE_NAVIGATION_BAR + && lp.providedInternalInsets[ITYPE_NAVIGATION_BAR] != null) { + providedInternalInsets = lp.providedInternalInsets[ITYPE_NAVIGATION_BAR]; + } else { + providedInternalInsets = Insets.NONE; + } + if (lp.height < providedInternalInsets.top) { return 0; } - return lp.height - lp.providedInternalInsets.top; + return lp.height - providedInternalInsets.top; } /** diff --git a/services/tests/servicestests/src/com/android/server/pm/AppsFilterImplTest.java b/services/tests/servicestests/src/com/android/server/pm/AppsFilterImplTest.java index d8f4349b95bf..3be2aacc75cb 100644 --- a/services/tests/servicestests/src/com/android/server/pm/AppsFilterImplTest.java +++ b/services/tests/servicestests/src/com/android/server/pm/AppsFilterImplTest.java @@ -30,7 +30,6 @@ import android.annotation.Nullable; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManagerInternal; import android.content.pm.Signature; import android.content.pm.SigningDetails; import android.content.pm.UserInfo; @@ -48,7 +47,6 @@ import com.android.server.om.OverlayReferenceMapper; import com.android.server.pm.parsing.pkg.AndroidPackage; import com.android.server.pm.parsing.pkg.PackageImpl; import com.android.server.pm.parsing.pkg.ParsedPackage; -import com.android.server.pm.pkg.PackageStateInternal; import com.android.server.pm.pkg.component.ParsedActivity; import com.android.server.pm.pkg.component.ParsedActivityImpl; import com.android.server.pm.pkg.component.ParsedInstrumentationImpl; @@ -69,6 +67,7 @@ import org.mockito.stubbing.Answer; import java.security.cert.CertificateException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; @@ -103,10 +102,9 @@ public class AppsFilterImplTest { AppsFilterImpl.StateProvider mStateProvider; @Mock Executor mMockExecutor; - @Mock - PackageManagerInternal mMockPmInternal; private ArrayMap<String, PackageSetting> mExisting = new ArrayMap<>(); + private Collection<SharedUserSetting> mSharedUserSettings = new ArraySet<>(); private static ParsingPackage pkg(String packageName) { return PackageImpl.forTesting(packageName) @@ -205,7 +203,7 @@ public class AppsFilterImplTest { MockitoAnnotations.initMocks(this); doAnswer(invocation -> { ((AppsFilterImpl.StateProvider.CurrentStateCallback) invocation.getArgument(0)) - .currentState(mExisting, USER_INFO_LIST); + .currentState(mExisting, mSharedUserSettings, USER_INFO_LIST); return new Object(); }).when(mStateProvider) .runWithState(any(AppsFilterImpl.StateProvider.CurrentStateCallback.class)); @@ -226,7 +224,7 @@ public class AppsFilterImplTest { public void testSystemReadyPropogates() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); final WatchableTester watcher = new WatchableTester(appsFilter, "onChange"); watcher.register(); appsFilter.onSystemReady(); @@ -238,7 +236,7 @@ public class AppsFilterImplTest { public void testQueriesAction_FilterMatches() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); final WatchableTester watcher = new WatchableTester(appsFilter, "onChange"); watcher.register(); simulateAddBasicAndroid(appsFilter); @@ -261,7 +259,7 @@ public class AppsFilterImplTest { public void testQueriesProtectedAction_FilterDoesNotMatch() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); final WatchableTester watcher = new WatchableTester(appsFilter, "onChange"); watcher.register(); final Signature frameworkSignature = Mockito.mock(Signature.class); @@ -310,7 +308,7 @@ public class AppsFilterImplTest { public void testQueriesProvider_FilterMatches() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); final WatchableTester watcher = new WatchableTester(appsFilter, "onChange"); watcher.register(); simulateAddBasicAndroid(appsFilter); @@ -335,7 +333,7 @@ public class AppsFilterImplTest { public void testOnUserUpdated_FilterMatches() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); simulateAddBasicAndroid(appsFilter); appsFilter.onSystemReady(); @@ -357,7 +355,7 @@ public class AppsFilterImplTest { // adds new user doAnswer(invocation -> { ((AppsFilterImpl.StateProvider.CurrentStateCallback) invocation.getArgument(0)) - .currentState(mExisting, USER_INFO_LIST_WITH_ADDED); + .currentState(mExisting, mSharedUserSettings, USER_INFO_LIST_WITH_ADDED); return new Object(); }).when(mStateProvider) .runWithState(any(AppsFilterImpl.StateProvider.CurrentStateCallback.class)); @@ -374,7 +372,7 @@ public class AppsFilterImplTest { // delete user doAnswer(invocation -> { ((AppsFilterImpl.StateProvider.CurrentStateCallback) invocation.getArgument(0)) - .currentState(mExisting, USER_INFO_LIST); + .currentState(mExisting, mSharedUserSettings, USER_INFO_LIST); return new Object(); }).when(mStateProvider) .runWithState(any(AppsFilterImpl.StateProvider.CurrentStateCallback.class)); @@ -393,7 +391,7 @@ public class AppsFilterImplTest { public void testQueriesDifferentProvider_Filters() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); final WatchableTester watcher = new WatchableTester(appsFilter, "onChange"); watcher.register(); simulateAddBasicAndroid(appsFilter); @@ -418,7 +416,7 @@ public class AppsFilterImplTest { public void testQueriesProviderWithSemiColon_FilterMatches() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); simulateAddBasicAndroid(appsFilter); appsFilter.onSystemReady(); @@ -437,7 +435,7 @@ public class AppsFilterImplTest { public void testQueriesAction_NoMatchingAction_Filters() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); simulateAddBasicAndroid(appsFilter); appsFilter.onSystemReady(); @@ -454,7 +452,7 @@ public class AppsFilterImplTest { public void testQueriesAction_NoMatchingActionFilterLowSdk_DoesntFilter() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); simulateAddBasicAndroid(appsFilter); appsFilter.onSystemReady(); @@ -475,7 +473,7 @@ public class AppsFilterImplTest { public void testNoQueries_Filters() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); simulateAddBasicAndroid(appsFilter); appsFilter.onSystemReady(); @@ -492,7 +490,7 @@ public class AppsFilterImplTest { public void testNoUsesLibrary_Filters() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, /* systemAppsQueryable */ false, /* overlayProvider */ null, - mMockExecutor, mMockPmInternal); + mMockExecutor); simulateAddBasicAndroid(appsFilter); appsFilter.onSystemReady(); @@ -518,7 +516,7 @@ public class AppsFilterImplTest { public void testUsesLibrary_DoesntFilter() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, /* systemAppsQueryable */ false, /* overlayProvider */ null, - mMockExecutor, mMockPmInternal); + mMockExecutor); simulateAddBasicAndroid(appsFilter); appsFilter.onSystemReady(); @@ -545,7 +543,7 @@ public class AppsFilterImplTest { public void testUsesOptionalLibrary_DoesntFilter() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, /* systemAppsQueryable */ false, /* overlayProvider */ null, - mMockExecutor, mMockPmInternal); + mMockExecutor); simulateAddBasicAndroid(appsFilter); appsFilter.onSystemReady(); @@ -572,7 +570,7 @@ public class AppsFilterImplTest { public void testUsesLibrary_ShareUid_DoesntFilter() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, /* systemAppsQueryable */ false, /* overlayProvider */ null, - mMockExecutor, mMockPmInternal); + mMockExecutor); simulateAddBasicAndroid(appsFilter); appsFilter.onSystemReady(); @@ -604,7 +602,7 @@ public class AppsFilterImplTest { public void testForceQueryable_SystemDoesntFilter() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); simulateAddBasicAndroid(appsFilter); appsFilter.onSystemReady(); @@ -623,7 +621,7 @@ public class AppsFilterImplTest { public void testForceQueryable_NonSystemFilters() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); simulateAddBasicAndroid(appsFilter); appsFilter.onSystemReady(); @@ -641,7 +639,7 @@ public class AppsFilterImplTest { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{"com.some.package"}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); simulateAddBasicAndroid(appsFilter); appsFilter.onSystemReady(); @@ -660,7 +658,7 @@ public class AppsFilterImplTest { public void testSystemSignedTarget_DoesntFilter() throws CertificateException { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); appsFilter.onSystemReady(); final Signature frameworkSignature = Mockito.mock(Signature.class); @@ -690,7 +688,7 @@ public class AppsFilterImplTest { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{"com.some.package"}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); simulateAddBasicAndroid(appsFilter); appsFilter.onSystemReady(); @@ -708,8 +706,7 @@ public class AppsFilterImplTest { public void testSystemQueryable_DoesntFilter() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, - true /* system force queryable */, null, mMockExecutor, - mMockPmInternal); + true /* system force queryable */, null, mMockExecutor); simulateAddBasicAndroid(appsFilter); appsFilter.onSystemReady(); @@ -727,7 +724,7 @@ public class AppsFilterImplTest { public void testQueriesPackage_DoesntFilter() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); simulateAddBasicAndroid(appsFilter); appsFilter.onSystemReady(); @@ -746,7 +743,7 @@ public class AppsFilterImplTest { .thenReturn(false); final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); simulateAddBasicAndroid(appsFilter); appsFilter.onSystemReady(); @@ -763,7 +760,7 @@ public class AppsFilterImplTest { public void testSystemUid_DoesntFilter() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); simulateAddBasicAndroid(appsFilter); appsFilter.onSystemReady(); @@ -779,7 +776,7 @@ public class AppsFilterImplTest { public void testSystemUidSecondaryUser_DoesntFilter() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); simulateAddBasicAndroid(appsFilter); appsFilter.onSystemReady(); @@ -796,7 +793,7 @@ public class AppsFilterImplTest { public void testNonSystemUid_NoCallingSetting_Filters() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); simulateAddBasicAndroid(appsFilter); appsFilter.onSystemReady(); @@ -811,7 +808,7 @@ public class AppsFilterImplTest { public void testNoTargetPackage_filters() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); simulateAddBasicAndroid(appsFilter); appsFilter.onSystemReady(); @@ -869,7 +866,7 @@ public class AppsFilterImplTest { return Collections.emptyMap(); } }, - mMockExecutor, mMockPmInternal); + mMockExecutor); simulateAddBasicAndroid(appsFilter); appsFilter.onSystemReady(); @@ -925,16 +922,11 @@ public class AppsFilterImplTest { .setOverlayTargetOverlayableName("overlayableName"); ParsingPackage actorOne = pkg("com.some.package.actor.one"); ParsingPackage actorTwo = pkg("com.some.package.actor.two"); - ArraySet<PackageStateInternal> actorSharedSettingPackages = new ArraySet<>(); PackageSetting ps1 = getPackageSettingFromParsingPackage(actorOne, DUMMY_ACTOR_APPID, null /*settingBuilder*/); PackageSetting ps2 = getPackageSettingFromParsingPackage(actorTwo, DUMMY_ACTOR_APPID, null /*settingBuilder*/); - actorSharedSettingPackages.add(ps1); - actorSharedSettingPackages.add(ps2); - when(mMockPmInternal.getSharedUserPackages(any(Integer.class))).thenReturn( - actorSharedSettingPackages - ); + final AppsFilterImpl appsFilter = new AppsFilterImpl( mStateProvider, mFeatureConfigMock, @@ -965,7 +957,7 @@ public class AppsFilterImplTest { return Collections.emptyMap(); } }, - mMockExecutor, mMockPmInternal); + mMockExecutor); simulateAddBasicAndroid(appsFilter); appsFilter.onSystemReady(); @@ -989,7 +981,7 @@ public class AppsFilterImplTest { public void testInitiatingApp_DoesntFilter() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); simulateAddBasicAndroid(appsFilter); appsFilter.onSystemReady(); @@ -1007,7 +999,7 @@ public class AppsFilterImplTest { public void testUninstalledInitiatingApp_Filters() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); simulateAddBasicAndroid(appsFilter); appsFilter.onSystemReady(); @@ -1025,7 +1017,7 @@ public class AppsFilterImplTest { public void testOriginatingApp_Filters() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); final WatchableTester watcher = new WatchableTester(appsFilter, "onChange"); watcher.register(); simulateAddBasicAndroid(appsFilter); @@ -1050,7 +1042,7 @@ public class AppsFilterImplTest { public void testInstallingApp_DoesntFilter() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); final WatchableTester watcher = new WatchableTester(appsFilter, "onChange"); watcher.register(); simulateAddBasicAndroid(appsFilter); @@ -1075,7 +1067,7 @@ public class AppsFilterImplTest { public void testInstrumentation_DoesntFilter() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); final WatchableTester watcher = new WatchableTester(appsFilter, "onChange"); watcher.register(); simulateAddBasicAndroid(appsFilter); @@ -1104,7 +1096,7 @@ public class AppsFilterImplTest { public void testWhoCanSee() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); final WatchableTester watcher = new WatchableTester(appsFilter, "onChange"); watcher.register(); simulateAddBasicAndroid(appsFilter); @@ -1177,7 +1169,7 @@ public class AppsFilterImplTest { public void testOnChangeReport() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); final WatchableTester watcher = new WatchableTester(appsFilter, "onChange"); watcher.register(); simulateAddBasicAndroid(appsFilter); @@ -1250,7 +1242,7 @@ public class AppsFilterImplTest { public void testOnChangeReportedFilter() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); simulateAddBasicAndroid(appsFilter); appsFilter.onSystemReady(); final WatchableTester watcher = new WatchableTester(appsFilter, "onChange filter"); @@ -1276,7 +1268,7 @@ public class AppsFilterImplTest { public void testAppsFilterRead() throws Exception { final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null, - mMockExecutor, mMockPmInternal); + mMockExecutor); simulateAddBasicAndroid(appsFilter); appsFilter.onSystemReady(); @@ -1379,6 +1371,7 @@ public class AppsFilterImplTest { if (sharedUserSetting != null) { sharedUserSetting.addPackage(setting); setting.setSharedUserAppId(sharedUserSetting.mAppId); + mSharedUserSettings.add(sharedUserSetting); } filter.addPackage(setting); } diff --git a/services/tests/servicestests/src/com/android/server/vibrator/VibrationSettingsTest.java b/services/tests/servicestests/src/com/android/server/vibrator/VibrationSettingsTest.java index 0c28d8c761ab..0a50e790215f 100644 --- a/services/tests/servicestests/src/com/android/server/vibrator/VibrationSettingsTest.java +++ b/services/tests/servicestests/src/com/android/server/vibrator/VibrationSettingsTest.java @@ -193,7 +193,7 @@ public class VibrationSettingsTest { public void removeListener_noMoreCallbacksToListener() { mVibrationSettings.addListener(mListenerMock); - setUserSetting(Settings.System.VIBRATE_WHEN_RINGING, 0); + setUserSetting(Settings.System.RING_VIBRATION_INTENSITY, 0); verify(mListenerMock).onChange(); mVibrationSettings.removeListener(mListenerMock); @@ -291,8 +291,6 @@ public class VibrationSettingsTest { public void shouldIgnoreVibration_withRingerModeSilent_ignoresRingtoneAndNotification() { // Vibrating settings on are overruled by ringer mode. setUserSetting(Settings.System.HAPTIC_FEEDBACK_ENABLED, 1); - setUserSetting(Settings.System.VIBRATE_WHEN_RINGING, 1); - setUserSetting(Settings.System.APPLY_RAMPING_RINGER, 1); setRingerMode(AudioManager.RINGER_MODE_SILENT); for (int usage : ALL_USAGES) { @@ -360,44 +358,25 @@ public class VibrationSettingsTest { assertVibrationNotIgnoredForUsage(usage); } } + @Test - public void shouldIgnoreVibration_withRingSettingsOff_disableRingtoneVibrations() { + public void shouldIgnoreVibration_withRingSettingsOff_allowsAllVibrations() { + // VIBRATE_WHEN_RINGING is deprecated and should have no effect on the ring vibration + // setting. The ramping ringer is also independent now, instead of a 3-state setting. setUserSetting(Settings.System.VIBRATE_WHEN_RINGING, 0); setUserSetting(Settings.System.APPLY_RAMPING_RINGER, 0); for (int usage : ALL_USAGES) { - if (usage == USAGE_RINGTONE) { - assertVibrationIgnoredForUsage(usage, Vibration.Status.IGNORED_FOR_SETTINGS); - } else { - assertVibrationNotIgnoredForUsage(usage); - } + assertVibrationNotIgnoredForUsage(usage); assertVibrationNotIgnoredForUsageAndFlags(usage, VibrationAttributes.FLAG_BYPASS_USER_VIBRATION_INTENSITY_OFF); } } @Test - public void shouldIgnoreVibration_withRingSettingsOn_allowsAllVibrations() { - setUserSetting(Settings.System.VIBRATE_WHEN_RINGING, 1); - setUserSetting(Settings.System.APPLY_RAMPING_RINGER, 0); - - for (int usage : ALL_USAGES) { - assertVibrationNotIgnoredForUsage(usage); - } - } - - @Test - public void shouldIgnoreVibration_withRampingRingerOn_allowsAllVibrations() { - setUserSetting(Settings.System.VIBRATE_WHEN_RINGING, 0); - setUserSetting(Settings.System.APPLY_RAMPING_RINGER, 1); - - for (int usage : ALL_USAGES) { - assertVibrationNotIgnoredForUsage(usage); - } - } - - @Test public void shouldIgnoreVibration_withHapticFeedbackDisabled_ignoresTouchVibration() { + // HAPTIC_FEEDBACK_ENABLED is deprecated but it was the only setting used to disable touch + // feedback vibrations. Continue to apply this on top of the intensity setting. setUserSetting(Settings.System.HAPTIC_FEEDBACK_ENABLED, 0); for (int usage : ALL_USAGES) { @@ -459,8 +438,6 @@ public class VibrationSettingsTest { @Test public void shouldIgnoreVibration_withRingSettingsOff_ignoresRingtoneVibrations() { // Vibrating settings on are overruled by ring intensity setting. - setUserSetting(Settings.System.VIBRATE_WHEN_RINGING, 1); - setUserSetting(Settings.System.APPLY_RAMPING_RINGER, 1); setRingerMode(AudioManager.RINGER_MODE_VIBRATE); setUserSetting(Settings.System.RING_VIBRATION_INTENSITY, VIBRATION_INTENSITY_OFF); @@ -479,7 +456,6 @@ public class VibrationSettingsTest { public void shouldIgnoreVibration_updateTriggeredAfterInternalRingerModeChanged() { // Vibrating settings on are overruled by ringer mode. setUserSetting(Settings.System.HAPTIC_FEEDBACK_ENABLED, 1); - setUserSetting(Settings.System.VIBRATE_WHEN_RINGING, 1); setUserSetting(Settings.System.APPLY_RAMPING_RINGER, 1); setRingerMode(AudioManager.RINGER_MODE_NORMAL); diff --git a/services/tests/servicestests/src/com/android/server/vibrator/VibratorManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/vibrator/VibratorManagerServiceTest.java index 4fbf0065f78d..c735bb7add0a 100644 --- a/services/tests/servicestests/src/com/android/server/vibrator/VibratorManagerServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/vibrator/VibratorManagerServiceTest.java @@ -559,30 +559,26 @@ public class VibratorManagerServiceTest { } @Test - public void vibrate_withRingtone_usesRingtoneSettings() throws Exception { + public void vibrate_withRingtone_usesRingerModeSettings() throws Exception { mockVibrators(1); FakeVibratorControllerProvider fakeVibrator = mVibratorProviders.get(1); fakeVibrator.setSupportedEffects(VibrationEffect.EFFECT_CLICK, VibrationEffect.EFFECT_HEAVY_CLICK, VibrationEffect.EFFECT_DOUBLE_CLICK); - setRingerMode(AudioManager.RINGER_MODE_NORMAL); - setUserSetting(Settings.System.VIBRATE_WHEN_RINGING, 0); - setUserSetting(Settings.System.APPLY_RAMPING_RINGER, 0); + setRingerMode(AudioManager.RINGER_MODE_SILENT); VibratorManagerService service = createSystemReadyService(); vibrate(service, VibrationEffect.get(VibrationEffect.EFFECT_CLICK), RINGTONE_ATTRS); // Wait before checking it never played. assertFalse(waitUntil(s -> !fakeVibrator.getAllEffectSegments().isEmpty(), service, /* timeout= */ 50)); - setUserSetting(Settings.System.VIBRATE_WHEN_RINGING, 0); - setUserSetting(Settings.System.APPLY_RAMPING_RINGER, 1); + setRingerMode(AudioManager.RINGER_MODE_NORMAL); service = createSystemReadyService(); vibrate(service, VibrationEffect.get(VibrationEffect.EFFECT_HEAVY_CLICK), RINGTONE_ATTRS); assertTrue(waitUntil(s -> fakeVibrator.getAllEffectSegments().size() == 1, service, TEST_TIMEOUT_MILLIS)); - setUserSetting(Settings.System.VIBRATE_WHEN_RINGING, 1); - setUserSetting(Settings.System.APPLY_RAMPING_RINGER, 0); + setRingerMode(AudioManager.RINGER_MODE_VIBRATE); service = createSystemReadyService(); vibrate(service, VibrationEffect.get(VibrationEffect.EFFECT_DOUBLE_CLICK), RINGTONE_ATTRS); assertTrue(waitUntil(s -> fakeVibrator.getAllEffectSegments().size() == 2, @@ -1225,7 +1221,6 @@ public class VibratorManagerServiceTest { mockVibrators(1); mVibratorProviders.get(1).setCapabilities(IVibrator.CAP_EXTERNAL_CONTROL); setRingerMode(AudioManager.RINGER_MODE_NORMAL); - setUserSetting(Settings.System.VIBRATE_WHEN_RINGING, 1); createSystemReadyService(); IBinder firstToken = mock(IBinder.class); @@ -1296,21 +1291,17 @@ public class VibratorManagerServiceTest { ExternalVibration externalVibration = new ExternalVibration(UID, PACKAGE_NAME, audioAttrs, mock(IExternalVibrationController.class)); - setRingerMode(AudioManager.RINGER_MODE_NORMAL); - setUserSetting(Settings.System.VIBRATE_WHEN_RINGING, 0); - setUserSetting(Settings.System.APPLY_RAMPING_RINGER, 0); + setRingerMode(AudioManager.RINGER_MODE_SILENT); createSystemReadyService(); int scale = mExternalVibratorService.onExternalVibrationStart(externalVibration); assertEquals(IExternalVibratorService.SCALE_MUTE, scale); - setUserSetting(Settings.System.VIBRATE_WHEN_RINGING, 0); - setUserSetting(Settings.System.APPLY_RAMPING_RINGER, 1); + setRingerMode(AudioManager.RINGER_MODE_NORMAL); createSystemReadyService(); scale = mExternalVibratorService.onExternalVibrationStart(externalVibration); assertNotEquals(IExternalVibratorService.SCALE_MUTE, scale); - setUserSetting(Settings.System.VIBRATE_WHEN_RINGING, 1); - setUserSetting(Settings.System.APPLY_RAMPING_RINGER, 0); + setRingerMode(AudioManager.RINGER_MODE_VIBRATE); createSystemReadyService(); scale = mExternalVibratorService.onExternalVibrationStart(externalVibration); assertNotEquals(IExternalVibratorService.SCALE_MUTE, scale); diff --git a/services/usb/java/com/android/server/usb/hal/port/UsbPortAidl.java b/services/usb/java/com/android/server/usb/hal/port/UsbPortAidl.java index 600fc27f5103..94273a37abcd 100644 --- a/services/usb/java/com/android/server/usb/hal/port/UsbPortAidl.java +++ b/services/usb/java/com/android/server/usb/hal/port/UsbPortAidl.java @@ -725,5 +725,15 @@ public final class UsbPortAidl implements UsbPortHal { e); } } + + @Override + public String getInterfaceHash() { + return IUsbCallback.HASH; + } + + @Override + public int getInterfaceVersion() { + return IUsbCallback.VERSION; + } } } diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java index 8d4a0176e3be..5b6e6863c0df 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java @@ -39,10 +39,13 @@ import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTOR_EVENT import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__DETECTOR_TYPE__NORMAL_DETECTOR; import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__DETECTOR_TYPE__TRUSTED_DETECTOR_DSP; import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__DETECTED; -import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__DETECT_EXCEPTION; +import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__DETECT_SECURITY_EXCEPTION; import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__DETECT_TIMEOUT; +import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__DETECT_UNEXPECTED_CALLBACK; import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__KEYPHRASE_TRIGGER; import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__REJECTED; +import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__REJECTED_FROM_RESTART; +import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__REJECT_UNEXPECTED_CALLBACK; import static com.android.server.voiceinteraction.SoundTriggerSessionPermissionsDecorator.enforcePermissionForPreflight; import android.annotation.NonNull; @@ -133,6 +136,13 @@ final class HotwordDetectionConnection { private static final int METRICS_INIT_CALLBACK_STATE_SUCCESS = HOTWORD_DETECTION_SERVICE_INIT_RESULT_REPORTED__RESULT__CALLBACK_INIT_STATE_SUCCESS; + private static final int METRICS_KEYPHRASE_TRIGGERED_DETECT_SECURITY_EXCEPTION = + HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__DETECT_SECURITY_EXCEPTION; + private static final int METRICS_KEYPHRASE_TRIGGERED_DETECT_UNEXPECTED_CALLBACK = + HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__DETECT_UNEXPECTED_CALLBACK; + private static final int METRICS_KEYPHRASE_TRIGGERED_REJECT_UNEXPECTED_CALLBACK = + HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__REJECT_UNEXPECTED_CALLBACK; + private final Executor mAudioCopyExecutor = Executors.newCachedThreadPool(); // TODO: This may need to be a Handler(looper) private final ScheduledExecutorService mScheduledExecutorService = @@ -575,7 +585,7 @@ final class HotwordDetectionConnection { Slog.i(TAG, "Ignoring #onDetected due to a process restart"); HotwordMetricsLogger.writeKeyphraseTriggerEvent( mDetectorType, - HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__DETECT_EXCEPTION); + METRICS_KEYPHRASE_TRIGGERED_DETECT_UNEXPECTED_CALLBACK); return; } mValidatingDspTrigger = false; @@ -584,7 +594,7 @@ final class HotwordDetectionConnection { } catch (SecurityException e) { HotwordMetricsLogger.writeKeyphraseTriggerEvent( mDetectorType, - HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__DETECT_EXCEPTION); + METRICS_KEYPHRASE_TRIGGERED_DETECT_SECURITY_EXCEPTION); throw e; } externalCallback.onKeyphraseDetected(recognitionEvent, result); @@ -614,7 +624,7 @@ final class HotwordDetectionConnection { Slog.i(TAG, "Ignoring #onRejected due to a process restart"); HotwordMetricsLogger.writeKeyphraseTriggerEvent( mDetectorType, - HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__DETECT_EXCEPTION); + METRICS_KEYPHRASE_TRIGGERED_REJECT_UNEXPECTED_CALLBACK); return; } mValidatingDspTrigger = false; @@ -687,6 +697,9 @@ final class HotwordDetectionConnection { // rejection. This also allows the Interactor to startReco again try { mCallback.onRejected(new HotwordRejectedResult.Builder().build()); + HotwordMetricsLogger.writeKeyphraseTriggerEvent( + mDetectorType, + HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__REJECTED_FROM_RESTART); } catch (RemoteException e) { Slog.w(TAG, "Failed to call #rejected"); } diff --git a/tools/apilint/deprecated_at_birth.py b/tools/apilint/deprecated_at_birth.py index da9f19f19505..d53c12734d23 100755 --- a/tools/apilint/deprecated_at_birth.py +++ b/tools/apilint/deprecated_at_birth.py @@ -44,6 +44,7 @@ def ident(raw): can be used to identify members across API levels.""" raw = raw.replace(" deprecated ", " ") raw = raw.replace(" synchronized ", " ") + raw = raw.replace(" abstract ", " ") raw = raw.replace(" final ", " ") raw = re.sub("<.+?>", "", raw) raw = re.sub("@[A-Za-z]+ ", "", raw) |