diff options
Diffstat (limited to 'core/java/android')
26 files changed, 312 insertions, 54 deletions
diff --git a/core/java/android/accessibilityservice/AccessibilityServiceInfo.java b/core/java/android/accessibilityservice/AccessibilityServiceInfo.java index 38d378169ec9..3e21e149b3b6 100644 --- a/core/java/android/accessibilityservice/AccessibilityServiceInfo.java +++ b/core/java/android/accessibilityservice/AccessibilityServiceInfo.java @@ -364,6 +364,18 @@ public class AccessibilityServiceInfo implements Parcelable { */ public static final int FLAG_REQUEST_MULTI_FINGER_GESTURES = 0x0001000; + /** + * This flag requests that when when {@link #FLAG_REQUEST_MULTI_FINGER_GESTURES} is enabled, + * two-finger passthrough gestures are re-enabled. Two-finger swipe gestures are not detected, + * but instead passed through as one-finger gestures. In addition, three-finger swipes from the + * bottom of the screen are not detected, and instead are passed through unchanged. If {@link + * #FLAG_REQUEST_MULTI_FINGER_GESTURES} is disabled this flag has no effect. + * + * @see #FLAG_REQUEST_TOUCH_EXPLORATION_MODE + * @hide + */ + public static final int FLAG_REQUEST_2_FINGER_PASSTHROUGH = 0x0002000; + /** {@hide} */ public static final int FLAG_FORCE_DIRECT_BOOT_AWARE = 0x00010000; @@ -1261,6 +1273,8 @@ public class AccessibilityServiceInfo implements Parcelable { return "FLAG_SERVICE_HANDLES_DOUBLE_TAP"; case FLAG_REQUEST_MULTI_FINGER_GESTURES: return "FLAG_REQUEST_MULTI_FINGER_GESTURES"; + case FLAG_REQUEST_2_FINGER_PASSTHROUGH: + return "FLAG_REQUEST_2_FINGER_PASSTHROUGH"; case FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY: return "FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY"; case FLAG_REPORT_VIEW_IDS: diff --git a/core/java/android/app/ActivityOptions.java b/core/java/android/app/ActivityOptions.java index 80d2e6c60f69..4aedfeefb72b 100644 --- a/core/java/android/app/ActivityOptions.java +++ b/core/java/android/app/ActivityOptions.java @@ -1275,10 +1275,10 @@ public class ActivityOptions { } /** - * Sets the id of the display where activity should be launched. - * An app can launch activities on public displays or private displays that are owned by the app - * or where an app already has activities. Otherwise, trying to launch on a private display - * or providing an invalid display id will result in an exception. + * Sets the id of the display where the activity should be launched. + * An app can launch activities on public displays or displays where the app already has + * activities. Otherwise, trying to launch on a private display or providing an invalid display + * id will result in an exception. * <p> * Setting launch display id will be ignored on devices that don't have * {@link android.content.pm.PackageManager#FEATURE_ACTIVITIES_ON_SECONDARY_DISPLAYS}. diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index 797253af394b..5873d207cf03 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -31,8 +31,10 @@ import android.compat.Compatibility; import android.compat.annotation.ChangeId; import android.compat.annotation.EnabledAfter; import android.compat.annotation.UnsupportedAppUsage; +import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; +import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.ParceledListSlice; import android.database.DatabaseUtils; @@ -52,6 +54,7 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; import android.os.UserManager; +import android.provider.Settings; import android.util.ArrayMap; import android.util.ArraySet; import android.util.LongSparseArray; @@ -7632,8 +7635,9 @@ public class AppOpsManager { collectNotedOpForSelf(op, proxiedAttributionTag); } else if (collectionMode == COLLECT_SYNC // Only collect app-ops when the proxy is trusted - && mContext.checkPermission(Manifest.permission.UPDATE_APP_OPS_STATS, -1, - myUid) == PackageManager.PERMISSION_GRANTED) { + && (mContext.checkPermission(Manifest.permission.UPDATE_APP_OPS_STATS, -1, + myUid) == PackageManager.PERMISSION_GRANTED + || isTrustedVoiceServiceProxy(mContext, mContext.getOpPackageName(), op))) { collectNotedOpSync(op, proxiedAttributionTag); } } @@ -7645,6 +7649,43 @@ public class AppOpsManager { } /** + * Checks if the voice recognition service is a trust proxy. + * + * @return {@code true} if the package is a trust voice recognition service proxy + * @hide + */ + public static boolean isTrustedVoiceServiceProxy(Context context, String packageName, + int code) { + // This is a workaround for R QPR, new API change is not allowed. We only allow the current + // voice recognizer is also the voice interactor to noteproxy op. + if (code != OP_RECORD_AUDIO) { + return false; + } + final String voiceRecognitionComponent = Settings.Secure.getString( + context.getContentResolver(), Settings.Secure.VOICE_RECOGNITION_SERVICE); + + final String voiceRecognitionServicePackageName = + getComponentPackageNameFromString(voiceRecognitionComponent); + return (Objects.equals(packageName, voiceRecognitionServicePackageName)) + && isPackagePreInstalled(context, packageName); + } + + private static String getComponentPackageNameFromString(String from) { + ComponentName componentName = from != null ? ComponentName.unflattenFromString(from) : null; + return componentName != null ? componentName.getPackageName() : ""; + } + + private static boolean isPackagePreInstalled(Context context, String packageName) { + try { + final PackageManager pm = context.getPackageManager(); + final ApplicationInfo info = pm.getApplicationInfo(packageName, 0); + return ((info.flags & ApplicationInfo.FLAG_SYSTEM) != 0); + } catch (PackageManager.NameNotFoundException e) { + return false; + } + } + + /** * Do a quick check for whether an application might be able to perform an operation. * This is <em>not</em> a security check; you must use {@link #noteOp(String, int, String, * String, String)} or {@link #startOp(int, int, String, boolean, String, String)} for your diff --git a/core/java/android/app/LoadedApk.java b/core/java/android/app/LoadedApk.java index 7be661b957c0..b45f3893db8c 100644 --- a/core/java/android/app/LoadedApk.java +++ b/core/java/android/app/LoadedApk.java @@ -286,7 +286,7 @@ public final class LoadedApk { return mSecurityViolation; } - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) public CompatibilityInfo getCompatibilityInfo() { return mDisplayAdjustments.getCompatibilityInfo(); } diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index 69d387994568..750a891a3b5d 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -4263,6 +4263,9 @@ public class DevicePolicyManager { * This method can be called on the {@link DevicePolicyManager} instance returned by * {@link #getParentProfileInstance(ComponentName)} in order to lock the parent profile. * <p> + * NOTE: on {@link android.content.pm.PackageManager#FEATURE_AUTOMOTIVE automotive builds}, this + * method doesn't turn off the screen as it would be a driving safety distraction. + * <p> * Equivalent to calling {@link #lockNow(int)} with no flags. * * @throws SecurityException if the calling application does not own an active administrator @@ -4306,6 +4309,9 @@ public class DevicePolicyManager { * Calling the method twice in this order ensures that all users are locked and does not * stop the device admin on the managed profile from issuing a second call to lock its own * profile. + * <p> + * NOTE: on {@link android.content.pm.PackageManager#FEATURE_AUTOMOTIVE automotive builds}, this + * method doesn't turn off the screen as it would be a driving safety distraction. * * @param flags May be 0 or {@link #FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY}. * @throws SecurityException if the calling application does not own an active administrator diff --git a/core/java/android/app/admin/DevicePolicyManagerInternal.java b/core/java/android/app/admin/DevicePolicyManagerInternal.java index ffa537e0617e..ec17e4497ba4 100644 --- a/core/java/android/app/admin/DevicePolicyManagerInternal.java +++ b/core/java/android/app/admin/DevicePolicyManagerInternal.java @@ -242,4 +242,16 @@ public abstract class DevicePolicyManagerInternal { * Returns the profile owner component for the given user, or {@code null} if there is not one. */ public abstract ComponentName getProfileOwnerAsUser(int userHandle); + + /** + * Returns whether this class supports being deferred the responsibility for resetting the given + * op. + */ + public abstract boolean supportsResetOp(int op); + + /** + * Resets the given op across the profile group of the given user for the given package. Assumes + * {@link #supportsResetOp(int)} is true. + */ + public abstract void resetOp(int op, String packageName, @UserIdInt int userId); } diff --git a/core/java/android/app/backup/BackupManager.java b/core/java/android/app/backup/BackupManager.java index e199cbe2d875..a4543fbbbde2 100644 --- a/core/java/android/app/backup/BackupManager.java +++ b/core/java/android/app/backup/BackupManager.java @@ -20,10 +20,14 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.SystemApi; +import android.app.compat.CompatChanges; +import android.compat.annotation.ChangeId; +import android.compat.annotation.EnabledAfter; import android.compat.annotation.UnsupportedAppUsage; import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Message; @@ -390,6 +394,17 @@ public class BackupManager { return false; } + + /** + * If this change is enabled, the {@code BACKUP} permission needed for + * {@code isBackupServiceActive()} will be enforced on the service end + * rather than client-side in {@link BackupManager}. + * @hide + */ + @ChangeId + @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.R) + public static final long IS_BACKUP_SERVICE_ACTIVE_ENFORCE_PERMISSION_IN_SERVICE = 158482162; + /** * Report whether the backup mechanism is currently active. * When it is inactive, the device will not perform any backup operations, nor will it @@ -400,8 +415,11 @@ public class BackupManager { @SystemApi @RequiresPermission(android.Manifest.permission.BACKUP) public boolean isBackupServiceActive(UserHandle user) { - mContext.enforceCallingOrSelfPermission(android.Manifest.permission.BACKUP, - "isBackupServiceActive"); + if (!CompatChanges.isChangeEnabled( + IS_BACKUP_SERVICE_ACTIVE_ENFORCE_PERMISSION_IN_SERVICE)) { + mContext.enforceCallingOrSelfPermission(android.Manifest.permission.BACKUP, + "isBackupServiceActive"); + } checkServiceBinder(); if (sService != null) { try { diff --git a/core/java/android/bluetooth/BluetoothCodecStatus.java b/core/java/android/bluetooth/BluetoothCodecStatus.java index 7b567b4098e7..f43a9e8cab9d 100644 --- a/core/java/android/bluetooth/BluetoothCodecStatus.java +++ b/core/java/android/bluetooth/BluetoothCodecStatus.java @@ -18,6 +18,7 @@ package android.bluetooth; import android.annotation.Nullable; import android.compat.annotation.UnsupportedAppUsage; +import android.os.Build; import android.os.Parcel; import android.os.Parcelable; @@ -39,7 +40,7 @@ public final class BluetoothCodecStatus implements Parcelable { * This extra represents the current codec status of the A2DP * profile. */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) public static final String EXTRA_CODEC_STATUS = "android.bluetooth.extra.CODEC_STATUS"; @@ -198,7 +199,7 @@ public final class BluetoothCodecStatus implements Parcelable { * * @return the current codec configuration */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) public @Nullable BluetoothCodecConfig getCodecConfig() { return mCodecConfig; } @@ -208,7 +209,7 @@ public final class BluetoothCodecStatus implements Parcelable { * * @return an array with the codecs local capabilities */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) public @Nullable BluetoothCodecConfig[] getCodecsLocalCapabilities() { return mCodecsLocalCapabilities; } @@ -218,7 +219,7 @@ public final class BluetoothCodecStatus implements Parcelable { * * @return an array with the codecs selectable capabilities */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) public @Nullable BluetoothCodecConfig[] getCodecsSelectableCapabilities() { return mCodecsSelectableCapabilities; } diff --git a/core/java/android/companion/AssociationRequest.java b/core/java/android/companion/AssociationRequest.java index 7733dc14ace4..903d1296fb87 100644 --- a/core/java/android/companion/AssociationRequest.java +++ b/core/java/android/companion/AssociationRequest.java @@ -47,6 +47,7 @@ public final class AssociationRequest implements Parcelable { private final boolean mSingleDevice; private final List<DeviceFilter<?>> mDeviceFilters; + private String mCallingPackage; private AssociationRequest( boolean singleDevice, @Nullable List<DeviceFilter<?>> deviceFilters) { @@ -58,6 +59,7 @@ public final class AssociationRequest implements Parcelable { this( in.readByte() != 0, in.readParcelableList(new ArrayList<>(), AssociationRequest.class.getClassLoader())); + setCallingPackage(in.readString()); } /** @hide */ @@ -73,32 +75,45 @@ public final class AssociationRequest implements Parcelable { return mDeviceFilters; } + /** @hide */ + public String getCallingPackage() { + return mCallingPackage; + } + + /** @hide */ + public void setCallingPackage(String pkg) { + mCallingPackage = pkg; + } + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; AssociationRequest that = (AssociationRequest) o; - return mSingleDevice == that.mSingleDevice && - Objects.equals(mDeviceFilters, that.mDeviceFilters); + return mSingleDevice == that.mSingleDevice + && Objects.equals(mDeviceFilters, that.mDeviceFilters) + && Objects.equals(mCallingPackage, that.mCallingPackage); } @Override public int hashCode() { - return Objects.hash(mSingleDevice, mDeviceFilters); + return Objects.hash(mSingleDevice, mDeviceFilters, mCallingPackage); } @Override public String toString() { - return "AssociationRequest{" + - "mSingleDevice=" + mSingleDevice + - ", mDeviceFilters=" + mDeviceFilters + - '}'; + return "AssociationRequest{" + + "mSingleDevice=" + mSingleDevice + + ", mDeviceFilters=" + mDeviceFilters + + ", mCallingPackage=" + mCallingPackage + + '}'; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeByte((byte) (mSingleDevice ? 1 : 0)); dest.writeParcelableList(mDeviceFilters, flags); + dest.writeString(mCallingPackage); } @Override diff --git a/core/java/android/content/pm/CrossProfileApps.java b/core/java/android/content/pm/CrossProfileApps.java index 8b411d5fe031..b290679c9fcc 100644 --- a/core/java/android/content/pm/CrossProfileApps.java +++ b/core/java/android/content/pm/CrossProfileApps.java @@ -119,8 +119,9 @@ public class CrossProfileApps { * {@link #getTargetUserProfiles()} if different to the calling user, otherwise a * {@link SecurityException} will be thrown. * @param callingActivity The activity to start the new activity from for the purposes of - * deciding which task the new activity should belong to. If {@code null}, the activity - * will always be started in a new task. + * passing back any result and deciding which task the new activity should belong to. If + * {@code null}, the activity will always be started in a new task and no result will be + * returned. */ @RequiresPermission(anyOf = { android.Manifest.permission.INTERACT_ACROSS_PROFILES, @@ -146,8 +147,9 @@ public class CrossProfileApps { * {@link #getTargetUserProfiles()} if different to the calling user, otherwise a * {@link SecurityException} will be thrown. * @param callingActivity The activity to start the new activity from for the purposes of - * deciding which task the new activity should belong to. If {@code null}, the activity - * will always be started in a new task. + * passing back any result and deciding which task the new activity should belong to. If + * {@code null}, the activity will always be started in a new task and no result will be + * returned. * @param options The activity options or {@code null}. See {@link android.app.ActivityOptions}. */ @RequiresPermission(anyOf = { diff --git a/core/java/android/content/pm/CrossProfileAppsInternal.java b/core/java/android/content/pm/CrossProfileAppsInternal.java index 16a749fa360a..255aeac06cae 100644 --- a/core/java/android/content/pm/CrossProfileAppsInternal.java +++ b/core/java/android/content/pm/CrossProfileAppsInternal.java @@ -17,6 +17,7 @@ package android.content.pm; import android.annotation.UserIdInt; +import android.app.AppOpsManager.Mode; import android.os.UserHandle; import java.util.List; @@ -62,4 +63,14 @@ public abstract class CrossProfileAppsInternal { */ public abstract List<UserHandle> getTargetUserProfiles( String packageName, @UserIdInt int userId); + + /** + * Sets the app-op for {@link android.Manifest.permission#INTERACT_ACROSS_PROFILES} that is + * configurable by users in Settings. This configures it for the profile group of the given + * user. + * + * @see CrossProfileApps#setInteractAcrossProfilesAppOp(String, int) + */ + public abstract void setInteractAcrossProfilesAppOp( + String packageName, @Mode int newMode, @UserIdInt int userId); } diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java index 443ae358b8cd..e699ee475279 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -99,6 +99,11 @@ import java.util.Set; * packages that are currently installed on the device. * * You can find this class through {@link Context#getPackageManager}. + * + * <p class="note"><strong>Note: </strong>If your app targets Android 11 (API level 30) or + * higher, the methods in this class each return a filtered list of apps. Learn more about how to + * <a href="/training/basics/intents/package-visibility">manage package visibility</a>. + * </p> */ public abstract class PackageManager { private static final String TAG = "PackageManager"; @@ -1742,6 +1747,15 @@ public abstract class PackageManager { public static final int DELETE_FAILED_USED_SHARED_LIBRARY = -6; /** + * Deletion failed return code: this is passed to the + * {@link IPackageDeleteObserver} if the system failed to delete the package + * because there is an app pinned. + * + * @hide + */ + public static final int DELETE_FAILED_APP_PINNED = -7; + + /** * Return code that is passed to the {@link IPackageMoveObserver} when the * package has been successfully moved by the system. * @@ -7782,6 +7796,7 @@ public abstract class PackageManager { case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED"; case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED"; case DELETE_FAILED_USED_SHARED_LIBRARY: return "DELETE_FAILED_USED_SHARED_LIBRARY"; + case DELETE_FAILED_APP_PINNED: return "DELETE_FAILED_APP_PINNED"; default: return Integer.toString(status); } } @@ -7796,6 +7811,7 @@ public abstract class PackageManager { case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED; case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; case DELETE_FAILED_USED_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_CONFLICT; + case DELETE_FAILED_APP_PINNED: return PackageInstaller.STATUS_FAILURE_BLOCKED; default: return PackageInstaller.STATUS_FAILURE; } } diff --git a/core/java/android/hardware/camera2/CameraCharacteristics.java b/core/java/android/hardware/camera2/CameraCharacteristics.java index 4f3c0cb029b8..32aa1c2ed7aa 100644 --- a/core/java/android/hardware/camera2/CameraCharacteristics.java +++ b/core/java/android/hardware/camera2/CameraCharacteristics.java @@ -2772,7 +2772,9 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri * </ol> * </li> * <li>Setting {@link CaptureRequest#CONTROL_ZOOM_RATIO android.control.zoomRatio} to values different than 1.0 and - * {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion} to be windowboxing at the same time is undefined behavior.</li> + * {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion} to be windowboxing at the same time are not supported. In this + * case, the camera framework will override the {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion} to be the active + * array.</li> * </ul> * <p>LEGACY capability devices will only support CENTER_ONLY cropping.</p> * <p><b>Possible values:</b> diff --git a/core/java/android/hardware/camera2/CameraDevice.java b/core/java/android/hardware/camera2/CameraDevice.java index cd137078818c..37e12809467d 100644 --- a/core/java/android/hardware/camera2/CameraDevice.java +++ b/core/java/android/hardware/camera2/CameraDevice.java @@ -234,7 +234,7 @@ public abstract class CameraDevice implements AutoCloseable { * @see StreamConfigurationMap#getOutputFormats() * @see StreamConfigurationMap#getOutputSizes(int) * @see StreamConfigurationMap#getOutputSizes(Class) - * @deprecated Please use @{link + * @deprecated Please use {@link * #createCaptureSession(android.hardware.camera2.params.SessionConfiguration)} for the * full set of configuration options available. */ @@ -249,7 +249,7 @@ public abstract class CameraDevice implements AutoCloseable { * * @see #createCaptureSession * @see OutputConfiguration - * @deprecated Please use @{link + * @deprecated Please use {@link * #createCaptureSession(android.hardware.camera2.params.SessionConfiguration)} for the * full set of configuration options available. */ @@ -285,7 +285,7 @@ public abstract class CameraDevice implements AutoCloseable { * @see StreamConfigurationMap#getOutputSizes * @see android.media.ImageWriter * @see android.media.ImageReader - * @deprecated Please use @{link + * @deprecated Please use {@link * #createCaptureSession(android.hardware.camera2.params.SessionConfiguration)} for the * full set of configuration options available. */ @@ -302,7 +302,7 @@ public abstract class CameraDevice implements AutoCloseable { * * @see #createReprocessableCaptureSession * @see OutputConfiguration - * @deprecated Please use @{link + * @deprecated Please use {@link * #createCaptureSession(android.hardware.camera2.params.SessionConfiguration)} for the * full set of configuration options available. */ @@ -340,7 +340,7 @@ public abstract class CameraDevice implements AutoCloseable { * @see CameraCaptureSession#captureBurst * @see CameraCaptureSession#setRepeatingBurst * @see CameraConstrainedHighSpeedCaptureSession#createHighSpeedRequestList - * @deprecated Please use @{link + * @deprecated Please use {@link * #createCaptureSession(android.hardware.camera2.params.SessionConfiguration)} for the * full set of configuration options available. */ @@ -413,7 +413,7 @@ public abstract class CameraDevice implements AutoCloseable { * @see #createReprocessableCaptureSession * @see CameraCaptureSession * @see OutputConfiguration - * @deprecated Please use @{link + * @deprecated Please use {@link * #createCaptureSession(android.hardware.camera2.params.SessionConfiguration)} for the * full set of configuration options available. * @hide diff --git a/core/java/android/hardware/camera2/CaptureRequest.java b/core/java/android/hardware/camera2/CaptureRequest.java index 2b633b5c5643..66e78bbc2f22 100644 --- a/core/java/android/hardware/camera2/CaptureRequest.java +++ b/core/java/android/hardware/camera2/CaptureRequest.java @@ -2243,7 +2243,10 @@ public final class CaptureRequest extends CameraMetadata<CaptureRequest.Key<?>> * explicitly set {@link CaptureRequest#CONTROL_ZOOM_RATIO android.control.zoomRatio}, its value defaults to 1.0.</p> * <p>One limitation of controlling zoom using zoomRatio is that the {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion} * must only be used for letterboxing or pillarboxing of the sensor active array, and no - * FREEFORM cropping can be used with {@link CaptureRequest#CONTROL_ZOOM_RATIO android.control.zoomRatio} other than 1.0.</p> + * FREEFORM cropping can be used with {@link CaptureRequest#CONTROL_ZOOM_RATIO android.control.zoomRatio} other than 1.0. If + * {@link CaptureRequest#CONTROL_ZOOM_RATIO android.control.zoomRatio} is not 1.0, and {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion} is set to be + * windowboxing, the camera framework will override the {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion} to be + * the active array.</p> * <p><b>Range of valid values:</b><br> * {@link CameraCharacteristics#CONTROL_ZOOM_RATIO_RANGE android.control.zoomRatioRange}</p> * <p><b>Optional</b> - The value for this key may be {@code null} on some devices.</p> diff --git a/core/java/android/hardware/camera2/CaptureResult.java b/core/java/android/hardware/camera2/CaptureResult.java index 41f4df7dbc99..ded7c8a8777e 100644 --- a/core/java/android/hardware/camera2/CaptureResult.java +++ b/core/java/android/hardware/camera2/CaptureResult.java @@ -2473,7 +2473,10 @@ public class CaptureResult extends CameraMetadata<CaptureResult.Key<?>> { * explicitly set {@link CaptureRequest#CONTROL_ZOOM_RATIO android.control.zoomRatio}, its value defaults to 1.0.</p> * <p>One limitation of controlling zoom using zoomRatio is that the {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion} * must only be used for letterboxing or pillarboxing of the sensor active array, and no - * FREEFORM cropping can be used with {@link CaptureRequest#CONTROL_ZOOM_RATIO android.control.zoomRatio} other than 1.0.</p> + * FREEFORM cropping can be used with {@link CaptureRequest#CONTROL_ZOOM_RATIO android.control.zoomRatio} other than 1.0. If + * {@link CaptureRequest#CONTROL_ZOOM_RATIO android.control.zoomRatio} is not 1.0, and {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion} is set to be + * windowboxing, the camera framework will override the {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion} to be + * the active array.</p> * <p><b>Range of valid values:</b><br> * {@link CameraCharacteristics#CONTROL_ZOOM_RATIO_RANGE android.control.zoomRatioRange}</p> * <p><b>Optional</b> - The value for this key may be {@code null} on some devices.</p> diff --git a/core/java/android/hardware/camera2/impl/CameraMetadataNative.java b/core/java/android/hardware/camera2/impl/CameraMetadataNative.java index a00ff8e8d39e..5cc7bf8cefed 100644 --- a/core/java/android/hardware/camera2/impl/CameraMetadataNative.java +++ b/core/java/android/hardware/camera2/impl/CameraMetadataNative.java @@ -73,6 +73,7 @@ import android.util.Range; import android.util.Size; import dalvik.annotation.optimization.FastNative; +import dalvik.system.VMRuntime; import java.io.IOException; import java.nio.ByteBuffer; @@ -352,6 +353,7 @@ public class CameraMetadataNative implements Parcelable { if (mMetadataPtr == 0) { throw new OutOfMemoryError("Failed to allocate native CameraMetadata"); } + updateNativeAllocation(); } /** @@ -363,6 +365,7 @@ public class CameraMetadataNative implements Parcelable { if (mMetadataPtr == 0) { throw new OutOfMemoryError("Failed to allocate native CameraMetadata"); } + updateNativeAllocation(); } /** @@ -444,6 +447,7 @@ public class CameraMetadataNative implements Parcelable { public void readFromParcel(Parcel in) { nativeReadFromParcel(in, mMetadataPtr); + updateNativeAllocation(); } /** @@ -534,6 +538,11 @@ public class CameraMetadataNative implements Parcelable { // Delete native pointer, but does not clear it nativeClose(mMetadataPtr); mMetadataPtr = 0; + + if (mBufferSize > 0) { + VMRuntime.getRuntime().registerNativeFree(mBufferSize); + } + mBufferSize = 0; } private <T> T getBase(CameraCharacteristics.Key<T> key) { @@ -1646,9 +1655,26 @@ public class CameraMetadataNative implements Parcelable { return true; } + private void updateNativeAllocation() { + long currentBufferSize = nativeGetBufferSize(mMetadataPtr); + + if (currentBufferSize != mBufferSize) { + if (mBufferSize > 0) { + VMRuntime.getRuntime().registerNativeFree(mBufferSize); + } + + mBufferSize = currentBufferSize; + + if (mBufferSize > 0) { + VMRuntime.getRuntime().registerNativeAllocation(mBufferSize); + } + } + } + private int mCameraId = -1; private boolean mHasMandatoryConcurrentStreams = false; private Size mDisplaySize = new Size(0, 0); + private long mBufferSize = 0; /** * Set the current camera Id. @@ -1700,6 +1726,7 @@ public class CameraMetadataNative implements Parcelable { private static synchronized native void nativeClose(long ptr); private static synchronized native boolean nativeIsEmpty(long ptr); private static synchronized native int nativeGetEntryCount(long ptr); + private static synchronized native long nativeGetBufferSize(long ptr); @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) private static synchronized native byte[] nativeReadValues(int tag, long ptr); @@ -1734,6 +1761,8 @@ public class CameraMetadataNative implements Parcelable { mCameraId = other.mCameraId; mHasMandatoryConcurrentStreams = other.mHasMandatoryConcurrentStreams; mDisplaySize = other.mDisplaySize; + updateNativeAllocation(); + other.updateNativeAllocation(); } /** diff --git a/core/java/android/hardware/display/DisplayManager.java b/core/java/android/hardware/display/DisplayManager.java index 9271d0e05fa0..7a383d993389 100644 --- a/core/java/android/hardware/display/DisplayManager.java +++ b/core/java/android/hardware/display/DisplayManager.java @@ -870,38 +870,77 @@ public final class DisplayManager { public interface DeviceConfig { /** - * Key for refresh rate in the zone defined by thresholds. + * Key for refresh rate in the low zone defined by thresholds. * + * Note that the name and value don't match because they were added before we had a high + * zone to consider. * @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER * @see android.R.integer#config_defaultZoneBehavior */ - String KEY_REFRESH_RATE_IN_ZONE = "refresh_rate_in_zone"; + String KEY_REFRESH_RATE_IN_LOW_ZONE = "refresh_rate_in_zone"; /** - * Key for accessing the display brightness thresholds for the configured refresh rate zone. + * Key for accessing the low display brightness thresholds for the configured refresh + * rate zone. * The value will be a pair of comma separated integers representing the minimum and maximum * thresholds of the zone, respectively, in display backlight units (i.e. [0, 255]). * + * Note that the name and value don't match because they were added before we had a high + * zone to consider. + * * @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER * @see android.R.array#config_brightnessThresholdsOfPeakRefreshRate * @hide */ - String KEY_PEAK_REFRESH_RATE_DISPLAY_BRIGHTNESS_THRESHOLDS = + String KEY_FIXED_REFRESH_RATE_LOW_DISPLAY_BRIGHTNESS_THRESHOLDS = "peak_refresh_rate_brightness_thresholds"; /** - * Key for accessing the ambient brightness thresholds for the configured refresh rate zone. - * The value will be a pair of comma separated integers representing the minimum and maximum - * thresholds of the zone, respectively, in lux. + * Key for accessing the low ambient brightness thresholds for the configured refresh + * rate zone. The value will be a pair of comma separated integers representing the minimum + * and maximum thresholds of the zone, respectively, in lux. + * + * Note that the name and value don't match because they were added before we had a high + * zone to consider. * * @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER * @see android.R.array#config_ambientThresholdsOfPeakRefreshRate * @hide */ - String KEY_PEAK_REFRESH_RATE_AMBIENT_BRIGHTNESS_THRESHOLDS = + String KEY_FIXED_REFRESH_RATE_LOW_AMBIENT_BRIGHTNESS_THRESHOLDS = "peak_refresh_rate_ambient_thresholds"; + /** + * Key for refresh rate in the high zone defined by thresholds. + * + * @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER + * @see android.R.integer#config_fixedRefreshRateInHighZone + */ + String KEY_REFRESH_RATE_IN_HIGH_ZONE = "refresh_rate_in_high_zone"; /** + * Key for accessing the display brightness thresholds for the configured refresh rate zone. + * The value will be a pair of comma separated integers representing the minimum and maximum + * thresholds of the zone, respectively, in display backlight units (i.e. [0, 255]). + * + * @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER + * @see android.R.array#config_brightnessHighThresholdsOfFixedRefreshRate + * @hide + */ + String KEY_FIXED_REFRESH_RATE_HIGH_DISPLAY_BRIGHTNESS_THRESHOLDS = + "fixed_refresh_rate_high_display_brightness_thresholds"; + + /** + * Key for accessing the ambient brightness thresholds for the configured refresh rate zone. + * The value will be a pair of comma separated integers representing the minimum and maximum + * thresholds of the zone, respectively, in lux. + * + * @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER + * @see android.R.array#config_ambientHighThresholdsOfFixedRefreshRate + * @hide + */ + String KEY_FIXED_REFRESH_RATE_HIGH_AMBIENT_BRIGHTNESS_THRESHOLDS = + "fixed_refresh_rate_high_ambient_brightness_thresholds"; + /** * Key for default peak refresh rate * * @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index 0924e9f5eb7c..40c3d87e4f36 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -71,6 +71,7 @@ import android.view.ViewTreeObserver; import android.view.Window; import android.view.WindowInsets; import android.view.WindowInsets.Side; +import android.view.WindowInsets.Type; import android.view.WindowManager; import android.view.animation.AnimationUtils; import android.view.inputmethod.CompletionInfo; @@ -104,7 +105,7 @@ import java.io.FileDescriptor; import java.io.PrintWriter; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import java.util.Collections; +import java.util.ArrayList; /** * InputMethodService provides a standard implementation of an InputMethod, @@ -850,10 +851,19 @@ public class InputMethodService extends AbstractInputMethodService { /** Set region of the keyboard to be avoided from back gesture */ private void setImeExclusionRect(int visibleTopInsets) { - View inputFrameRootView = mInputFrame.getRootView(); - Rect r = new Rect(0, visibleTopInsets, inputFrameRootView.getWidth(), - inputFrameRootView.getHeight()); - inputFrameRootView.setSystemGestureExclusionRects(Collections.singletonList(r)); + View rootView = mInputFrame.getRootView(); + android.graphics.Insets systemGesture = + rootView.getRootWindowInsets().getInsetsIgnoringVisibility(Type.systemGestures()); + ArrayList<Rect> exclusionRects = new ArrayList<>(); + exclusionRects.add(new Rect(0, + visibleTopInsets, + systemGesture.left, + rootView.getHeight())); + exclusionRects.add(new Rect(rootView.getWidth() - systemGesture.right, + visibleTopInsets, + rootView.getWidth(), + rootView.getHeight())); + rootView.setSystemGestureExclusionRects(exclusionRects); } /** @@ -1205,7 +1215,6 @@ public class InputMethodService extends AbstractInputMethodService { WindowManager.LayoutParams.TYPE_INPUT_METHOD, Gravity.BOTTOM, false); mWindow.getWindow().getAttributes().setFitInsetsTypes(statusBars() | navigationBars()); mWindow.getWindow().getAttributes().setFitInsetsSides(Side.all() & ~Side.BOTTOM); - mWindow.getWindow().getAttributes().setFitInsetsIgnoringVisibility(true); // IME layout should always be inset by navigation bar, no matter its current visibility, // unless automotive requests it. Automotive devices may request the navigation bar to be diff --git a/core/java/android/os/IPowerManager.aidl b/core/java/android/os/IPowerManager.aidl index d23d2eca7603..dfc9d5dc0deb 100644 --- a/core/java/android/os/IPowerManager.aidl +++ b/core/java/android/os/IPowerManager.aidl @@ -94,6 +94,8 @@ interface IPowerManager boolean isAmbientDisplaySuppressedForToken(String token); // returns whether ambient display is suppressed by any app with any token. boolean isAmbientDisplaySuppressed(); + // returns whether ambient display is suppressed by the given app with the given token. + boolean isAmbientDisplaySuppressedForTokenByApp(String token, int appUid); // Forces the system to suspend even if there are held wakelocks. boolean forceSuspend(); diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java index 49b4e0024fc2..bfbdf62d39bb 100644 --- a/core/java/android/os/PowerManager.java +++ b/core/java/android/os/PowerManager.java @@ -2121,6 +2121,27 @@ public final class PowerManager { } /** + * Returns true if ambient display is suppressed by the given {@code appUid} with the given + * {@code token}. + * + * <p>This method will return false if {@link #isAmbientDisplayAvailable()} is false. + * + * @param token The identifier of the ambient display suppression. + * @param appUid The uid of the app that suppressed ambient display. + * @hide + */ + @RequiresPermission(allOf = { + android.Manifest.permission.READ_DREAM_STATE, + android.Manifest.permission.READ_DREAM_SUPPRESSION }) + public boolean isAmbientDisplaySuppressedForTokenByApp(@NonNull String token, int appUid) { + try { + return mService.isAmbientDisplaySuppressedForTokenByApp(token, appUid); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** * Returns the reason the phone was last shutdown. Calling app must have the * {@link android.Manifest.permission#DEVICE_POWER} permission to request this information. * @return Reason for shutdown as an int, {@link #SHUTDOWN_REASON_UNKNOWN} if the file could diff --git a/core/java/android/os/UserHandle.java b/core/java/android/os/UserHandle.java index 3d539a604b46..7b62e6652a04 100644 --- a/core/java/android/os/UserHandle.java +++ b/core/java/android/os/UserHandle.java @@ -220,6 +220,14 @@ public final class UserHandle implements Parcelable { } /** + * Whether a UID belongs to a shared app gid. + * @hide + */ + public static boolean isSharedAppGid(int uid) { + return getAppIdFromSharedAppGid(uid) != -1; + } + + /** * Returns the user for a given uid. * @param uid A uid for an application running in a particular user. * @return A {@link UserHandle} for that user. diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 0f7365dcfd90..cfb18ad24faf 100755 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -7898,6 +7898,12 @@ public final class Settings { public static final String UI_NIGHT_MODE_OVERRIDE_ON = "ui_night_mode_override_on"; /** + * The last computed night mode bool the last time the phone was on + * @hide + */ + public static final String UI_NIGHT_MODE_LAST_COMPUTED = "ui_night_mode_last_computed"; + + /** * The current night mode that has been overridden to turn off by the system. Owned * and controlled by UiModeManagerService. Constants are as per * UiModeManager. diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 819462190d9c..81e6d42ec056 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -3268,8 +3268,8 @@ public final class ViewRootImpl implements ViewParent, // Note: must be done after the focus change callbacks, // so all of the view state is set up correctly. - mImeFocusController.onPostWindowFocus(mView.findFocus(), hasWindowFocus, - mWindowAttributes); + mImeFocusController.onPostWindowFocus(mView != null ? mView.findFocus() : null, + hasWindowFocus, mWindowAttributes); if (hasWindowFocus) { // Clear the forward bit. We can just do this directly, since diff --git a/core/java/android/view/accessibility/AccessibilityEvent.java b/core/java/android/view/accessibility/AccessibilityEvent.java index 3b8368380dda..9d66a21848db 100644 --- a/core/java/android/view/accessibility/AccessibilityEvent.java +++ b/core/java/android/view/accessibility/AccessibilityEvent.java @@ -199,7 +199,7 @@ import java.util.List; * <b>Window state changed</b> - represents the event of a change to a section of * the user interface that is visually distinct. Should be sent from either the * root view of a window or from a view that is marked as a pane - * {@link android.view.View#setAccessibilityPaneTitle(CharSequence)}. Not that changes + * {@link android.view.View#setAccessibilityPaneTitle(CharSequence)}. Note that changes * to true windows are represented by {@link #TYPE_WINDOWS_CHANGED}.</br> * <em>Type:</em> {@link #TYPE_WINDOW_STATE_CHANGED}</br> * <em>Properties:</em></br> diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index deed219135ad..22b8ffbd28e3 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -11009,12 +11009,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener MotionEvent.actionToString(event.getActionMasked()), event.getX(), event.getY()); } - if (!isFromPrimePointer(event, false)) { - return true; - } - final int action = event.getActionMasked(); if (mEditor != null) { + if (!isFromPrimePointer(event, false)) { + return true; + } + mEditor.onTouchEvent(event); if (mEditor.mInsertionPointCursorController != null |
