diff options
author | Xin Li <delphij@google.com> | 2021-02-21 09:39:53 -0800 |
---|---|---|
committer | Xin Li <delphij@google.com> | 2021-02-21 09:39:53 -0800 |
commit | be473bf819b8570945b0d238beaaa2fa63e60c02 (patch) | |
tree | addad6a0ab92967c35ca90cf4056940be91be73a /core/java | |
parent | 6cc86364fb326b3fead32008e076147e57755e98 (diff) | |
parent | 3078660c4eb37fb00ad1e69cc695bd20f1ee7440 (diff) |
Merge ab/7061308 into stage.
Bug: 180401296
Merged-In: I4bf82035631ccff6d5a6144d6d9b1d203b076851
Change-Id: I1b5f3a672a55eaabba0f5389bab110b395553559
Diffstat (limited to 'core/java')
32 files changed, 366 insertions, 120 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 diff --git a/core/java/com/android/internal/app/AppPredictionServiceResolverComparator.java b/core/java/com/android/internal/app/AppPredictionServiceResolverComparator.java index 0d16cc49ea3c..26af61520593 100644 --- a/core/java/com/android/internal/app/AppPredictionServiceResolverComparator.java +++ b/core/java/com/android/internal/app/AppPredictionServiceResolverComparator.java @@ -188,7 +188,7 @@ class AppPredictionServiceResolverComparator extends AbstractResolverComparator } Integer rank = mTargetRanks.get(name); if (rank == null) { - Log.w(TAG, "Score requested for unknown component."); + Log.w(TAG, "Score requested for unknown component. Did you call compute yet?"); return 0f; } int consecutiveSumOfRanks = (mTargetRanks.size() - 1) * (mTargetRanks.size()) / 2; diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java index ac8f9e8424b7..18091896cc28 100644 --- a/core/java/com/android/internal/app/ChooserActivity.java +++ b/core/java/com/android/internal/app/ChooserActivity.java @@ -162,6 +162,9 @@ public class ChooserActivity extends ResolverActivity implements private AppPredictor mWorkAppPredictor; private boolean mShouldDisplayLandscape; + private static final int MAX_TARGETS_PER_ROW_PORTRAIT = 4; + private static final int MAX_TARGETS_PER_ROW_LANDSCAPE = 8; + @UnsupportedAppUsage public ChooserActivity() { } @@ -823,8 +826,6 @@ public class ChooserActivity extends ResolverActivity implements queryDirectShareTargets(chooserListAdapter, true); return; } - final List<DisplayResolveInfo> driList = - getDisplayResolveInfos(chooserListAdapter); final List<ShortcutManager.ShareShortcutInfo> shareShortcutInfos = new ArrayList<>(); @@ -852,7 +853,7 @@ public class ChooserActivity extends ResolverActivity implements new ComponentName( appTarget.getPackageName(), appTarget.getClassName()))); } - sendShareShortcutInfoList(shareShortcutInfos, driList, resultList, + sendShareShortcutInfoList(shareShortcutInfos, chooserListAdapter, resultList, chooserListAdapter.getUserHandle()); }; } @@ -904,7 +905,7 @@ public class ChooserActivity extends ResolverActivity implements adapter, getPersonalProfileUserHandle(), /* workProfileUserHandle= */ null, - isSendAction(getTargetIntent())); + isSendAction(getTargetIntent()), getMaxTargetsPerRow()); } private ChooserMultiProfilePagerAdapter createChooserMultiProfilePagerAdapterForTwoProfiles( @@ -933,7 +934,7 @@ public class ChooserActivity extends ResolverActivity implements selectedProfile, getPersonalProfileUserHandle(), getWorkProfileUserHandle(), - isSendAction(getTargetIntent())); + isSendAction(getTargetIntent()), getMaxTargetsPerRow()); } private int findSelectedProfile() { @@ -1761,7 +1762,7 @@ public class ChooserActivity extends ResolverActivity implements case ChooserListAdapter.TARGET_CALLER: case ChooserListAdapter.TARGET_STANDARD: cat = MetricsEvent.ACTION_ACTIVITY_CHOOSER_PICKED_APP_TARGET; - value -= currentListAdapter.getSelectableServiceTargetCount(); + value -= currentListAdapter.getSurfacedTargetInfo().size(); numCallerProvided = currentListAdapter.getCallerTargetCount(); getChooserActivityLogger().logShareTargetSelected( SELECTION_TYPE_APP, @@ -1971,32 +1972,6 @@ public class ChooserActivity extends ResolverActivity implements } } - private List<DisplayResolveInfo> getDisplayResolveInfos(ChooserListAdapter adapter) { - // Need to keep the original DisplayResolveInfos to be able to reconstruct ServiceResultInfo - // and use the old code path. This Ugliness should go away when Sharesheet is refactored. - List<DisplayResolveInfo> driList = new ArrayList<>(); - int targetsToQuery = 0; - for (int i = 0, n = adapter.getDisplayResolveInfoCount(); i < n; i++) { - final DisplayResolveInfo dri = adapter.getDisplayResolveInfo(i); - if (adapter.getScore(dri) == 0) { - // A score of 0 means the app hasn't been used in some time; - // don't query it as it's not likely to be relevant. - continue; - } - driList.add(dri); - targetsToQuery++; - // TODO(b/121287224): Do we need this here? (similar to queryTargetServices) - if (targetsToQuery >= SHARE_TARGET_QUERY_PACKAGE_LIMIT) { - if (DEBUG) { - Log.d(TAG, "queryTargets hit query target limit " - + SHARE_TARGET_QUERY_PACKAGE_LIMIT); - } - break; - } - } - return driList; - } - @VisibleForTesting protected void queryDirectShareTargets( ChooserListAdapter adapter, boolean skipAppPredictionService) { @@ -2014,14 +1989,13 @@ public class ChooserActivity extends ResolverActivity implements if (filter == null) { return; } - final List<DisplayResolveInfo> driList = getDisplayResolveInfos(adapter); AsyncTask.execute(() -> { Context selectedProfileContext = createContextAsUser(userHandle, 0 /* flags */); ShortcutManager sm = (ShortcutManager) selectedProfileContext .getSystemService(Context.SHORTCUT_SERVICE); List<ShortcutManager.ShareShortcutInfo> resultList = sm.getShareTargets(filter); - sendShareShortcutInfoList(resultList, driList, null, userHandle); + sendShareShortcutInfoList(resultList, adapter, null, userHandle); }); } @@ -2058,7 +2032,7 @@ public class ChooserActivity extends ResolverActivity implements private void sendShareShortcutInfoList( List<ShortcutManager.ShareShortcutInfo> resultList, - List<DisplayResolveInfo> driList, + ChooserListAdapter chooserListAdapter, @Nullable List<AppTarget> appTargets, UserHandle userHandle) { if (appTargets != null && appTargets.size() != resultList.size()) { throw new RuntimeException("resultList and appTargets must have the same size." @@ -2084,10 +2058,10 @@ public class ChooserActivity extends ResolverActivity implements // for direct share targets. After ShareSheet is refactored we should use the // ShareShortcutInfos directly. boolean resultMessageSent = false; - for (int i = 0; i < driList.size(); i++) { + for (int i = 0; i < chooserListAdapter.getDisplayResolveInfoCount(); i++) { List<ShortcutManager.ShareShortcutInfo> matchingShortcuts = new ArrayList<>(); for (int j = 0; j < resultList.size(); j++) { - if (driList.get(i).getResolvedComponentName().equals( + if (chooserListAdapter.getDisplayResolveInfo(i).getResolvedComponentName().equals( resultList.get(j).getTargetComponent())) { matchingShortcuts.add(resultList.get(j)); } @@ -2102,7 +2076,8 @@ public class ChooserActivity extends ResolverActivity implements final Message msg = Message.obtain(); msg.what = ChooserHandler.SHORTCUT_MANAGER_SHARE_TARGET_RESULT; - msg.obj = new ServiceResultInfo(driList.get(i), chooserTargets, null, userHandle); + msg.obj = new ServiceResultInfo(chooserListAdapter.getDisplayResolveInfo(i), + chooserTargets, null, userHandle); msg.arg1 = shortcutType; mChooserHandler.sendMessage(msg); resultMessageSent = true; @@ -2660,7 +2635,7 @@ public class ChooserActivity extends ResolverActivity implements // and b/150936654 recyclerView.setAdapter(gridAdapter); ((GridLayoutManager) recyclerView.getLayoutManager()).setSpanCount( - gridAdapter.getMaxTargetsPerRow()); + getMaxTargetsPerRow()); } UserHandle currentUserHandle = mChooserMultiProfilePagerAdapter.getCurrentUserHandle(); @@ -2825,9 +2800,7 @@ public class ChooserActivity extends ResolverActivity implements @Override // ChooserListCommunicator public int getMaxRankedTargets() { - return mChooserMultiProfilePagerAdapter.getCurrentRootAdapter() == null - ? ChooserGridAdapter.MAX_TARGETS_PER_ROW_PORTRAIT - : mChooserMultiProfilePagerAdapter.getCurrentRootAdapter().getMaxTargetsPerRow(); + return getMaxTargetsPerRow(); } @Override // ChooserListCommunicator @@ -3176,6 +3149,13 @@ public class ChooserActivity extends ResolverActivity implements } } + int getMaxTargetsPerRow() { + int maxTargets = MAX_TARGETS_PER_ROW_PORTRAIT; + if (mShouldDisplayLandscape) { + maxTargets = MAX_TARGETS_PER_ROW_LANDSCAPE; + } + return maxTargets; + } /** * Adapter for all types of items and targets in ShareSheet. * Note that ranked sections like Direct Share - while appearing grid-like - are handled on the @@ -3204,9 +3184,6 @@ public class ChooserActivity extends ResolverActivity implements private static final int VIEW_TYPE_CALLER_AND_RANK = 5; private static final int VIEW_TYPE_FOOTER = 6; - private static final int MAX_TARGETS_PER_ROW_PORTRAIT = 4; - private static final int MAX_TARGETS_PER_ROW_LANDSCAPE = 8; - private static final int NUM_EXPANSIONS_TO_HIDE_AZ_LABEL = 20; ChooserGridAdapter(ChooserListAdapter wrappedAdapter) { @@ -3255,14 +3232,6 @@ public class ChooserActivity extends ResolverActivity implements return false; } - int getMaxTargetsPerRow() { - int maxTargets = MAX_TARGETS_PER_ROW_PORTRAIT; - if (mShouldDisplayLandscape) { - maxTargets = MAX_TARGETS_PER_ROW_LANDSCAPE; - } - return maxTargets; - } - /** * Hides the list item content preview. * <p>Not to be confused with the sticky content preview which is above the @@ -3632,8 +3601,7 @@ public class ChooserActivity extends ResolverActivity implements position -= getSystemRowCount() + getProfileRowCount(); final int serviceCount = mChooserListAdapter.getServiceTargetCount(); - final int serviceRows = (int) Math.ceil((float) serviceCount - / ChooserListAdapter.MAX_SERVICE_TARGETS); + final int serviceRows = (int) Math.ceil((float) serviceCount / getMaxRankedTargets()); if (position < serviceRows) { return position * getMaxTargetsPerRow(); } diff --git a/core/java/com/android/internal/app/ChooserListAdapter.java b/core/java/com/android/internal/app/ChooserListAdapter.java index 00b5cb646bca..570066807f16 100644 --- a/core/java/com/android/internal/app/ChooserListAdapter.java +++ b/core/java/com/android/internal/app/ChooserListAdapter.java @@ -82,8 +82,6 @@ public class ChooserListAdapter extends ResolverListAdapter { private static final int MAX_SERVICE_TARGET_APP = 8; private static final int DEFAULT_DIRECT_SHARE_RANKING_SCORE = 1000; - static final int MAX_SERVICE_TARGETS = 8; - /** {@link #getBaseScore} */ public static final float CALLER_TARGET_SCORE_BOOST = 900.f; /** {@link #getBaseScore} */ @@ -130,10 +128,10 @@ public class ChooserListAdapter extends ResolverListAdapter { super(context, payloadIntents, null, rList, filterLastUsed, resolverListController, chooserListCommunicator, false); - createPlaceHolders(); mMaxShortcutTargetsPerApp = context.getResources().getInteger(R.integer.config_maxShortcutTargetsPerApp); mChooserListCommunicator = chooserListCommunicator; + createPlaceHolders(); mSelectableTargetInfoCommunicator = selectableTargetInfoCommunicator; if (initialIntents != null) { @@ -227,7 +225,7 @@ public class ChooserListAdapter extends ResolverListAdapter { mParkingDirectShareTargets.clear(); mPendingChooserTargetService.clear(); mShortcutComponents.clear(); - for (int i = 0; i < MAX_SERVICE_TARGETS; i++) { + for (int i = 0; i < mChooserListCommunicator.getMaxRankedTargets(); i++) { mServiceTargets.add(mPlaceHolderTargetInfo); } } @@ -382,7 +380,7 @@ public class ChooserListAdapter extends ResolverListAdapter { public int getServiceTargetCount() { if (mChooserListCommunicator.isSendAction(mChooserListCommunicator.getTargetIntent()) && !ActivityManager.isLowRamDeviceStatic()) { - return Math.min(mServiceTargets.size(), MAX_SERVICE_TARGETS); + return Math.min(mServiceTargets.size(), mChooserListCommunicator.getMaxRankedTargets()); } return 0; @@ -847,7 +845,8 @@ public class ChooserListAdapter extends ResolverListAdapter { int currentSize = mServiceTargets.size(); final float newScore = chooserTargetInfo.getModifiedScore(); - for (int i = 0; i < Math.min(currentSize, MAX_SERVICE_TARGETS); i++) { + for (int i = 0; i < Math.min(currentSize, mChooserListCommunicator.getMaxRankedTargets()); + i++) { final ChooserTargetInfo serviceTarget = mServiceTargets.get(i); if (serviceTarget == null) { mServiceTargets.set(i, chooserTargetInfo); @@ -858,7 +857,7 @@ public class ChooserListAdapter extends ResolverListAdapter { } } - if (currentSize < MAX_SERVICE_TARGETS) { + if (currentSize < mChooserListCommunicator.getMaxRankedTargets()) { mServiceTargets.add(chooserTargetInfo); return true; } diff --git a/core/java/com/android/internal/app/ChooserMultiProfilePagerAdapter.java b/core/java/com/android/internal/app/ChooserMultiProfilePagerAdapter.java index 3a65a324f9d6..dd837fc2194c 100644 --- a/core/java/com/android/internal/app/ChooserMultiProfilePagerAdapter.java +++ b/core/java/com/android/internal/app/ChooserMultiProfilePagerAdapter.java @@ -39,17 +39,19 @@ public class ChooserMultiProfilePagerAdapter extends AbstractMultiProfilePagerAd private final ChooserProfileDescriptor[] mItems; private final boolean mIsSendAction; private int mBottomOffset; + private int mMaxTargetsPerRow; ChooserMultiProfilePagerAdapter(Context context, ChooserActivity.ChooserGridAdapter adapter, UserHandle personalProfileUserHandle, UserHandle workProfileUserHandle, - boolean isSendAction) { + boolean isSendAction, int maxTargetsPerRow) { super(context, /* currentPage */ 0, personalProfileUserHandle, workProfileUserHandle); mItems = new ChooserProfileDescriptor[] { createProfileDescriptor(adapter) }; mIsSendAction = isSendAction; + mMaxTargetsPerRow = maxTargetsPerRow; } ChooserMultiProfilePagerAdapter(Context context, @@ -58,7 +60,7 @@ public class ChooserMultiProfilePagerAdapter extends AbstractMultiProfilePagerAd @Profile int defaultProfile, UserHandle personalProfileUserHandle, UserHandle workProfileUserHandle, - boolean isSendAction) { + boolean isSendAction, int maxTargetsPerRow) { super(context, /* currentPage */ defaultProfile, personalProfileUserHandle, workProfileUserHandle); mItems = new ChooserProfileDescriptor[] { @@ -66,6 +68,7 @@ public class ChooserMultiProfilePagerAdapter extends AbstractMultiProfilePagerAd createProfileDescriptor(workAdapter) }; mIsSendAction = isSendAction; + mMaxTargetsPerRow = maxTargetsPerRow; } private ChooserProfileDescriptor createProfileDescriptor( @@ -114,7 +117,7 @@ public class ChooserMultiProfilePagerAdapter extends AbstractMultiProfilePagerAd ChooserActivity.ChooserGridAdapter chooserGridAdapter = getItem(pageIndex).chooserGridAdapter; GridLayoutManager glm = (GridLayoutManager) recyclerView.getLayoutManager(); - glm.setSpanCount(chooserGridAdapter.getMaxTargetsPerRow()); + glm.setSpanCount(mMaxTargetsPerRow); glm.setSpanSizeLookup( new GridLayoutManager.SpanSizeLookup() { @Override diff --git a/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java b/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java index b4cd145ca374..40c21bddf41b 100644 --- a/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java +++ b/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java @@ -428,6 +428,22 @@ public final class SystemUiDeviceConfigFlags { */ public static final String SCREENSHOT_KEYCHORD_DELAY = "screenshot_keychord_delay"; + /** + * (boolean) Whether to use an ML model for the Back Gesture. + */ + public static final String USE_BACK_GESTURE_ML_MODEL = "use_back_gesture_ml_model"; + + /** + * (string) The name of the ML model for Back Gesture. + */ + public static final String BACK_GESTURE_ML_MODEL_NAME = "back_gesture_ml_model_name"; + + /** + * (float) Threshold for Back Gesture ML model prediction. + */ + public static final String BACK_GESTURE_ML_MODEL_THRESHOLD = "back_gesture_ml_model_threshold"; + + private SystemUiDeviceConfigFlags() { } } diff --git a/core/java/com/android/internal/policy/PhoneWindow.java b/core/java/com/android/internal/policy/PhoneWindow.java index 046981cf2e8f..d90a0225608d 100644 --- a/core/java/com/android/internal/policy/PhoneWindow.java +++ b/core/java/com/android/internal/policy/PhoneWindow.java @@ -1510,11 +1510,13 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { if (drawable != mBackgroundDrawable) { mBackgroundDrawable = drawable; if (mDecor != null) { + mDecor.startChanging(); mDecor.setWindowBackground(drawable); if (mBackgroundFallbackDrawable != null) { mDecor.setBackgroundFallback(drawable != null ? null : mBackgroundFallbackDrawable); } + mDecor.finishChanging(); } } } |