diff --git a/core/api/current.txt b/core/api/current.txt index 7b97a65cf7380..443954b0cbb22 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -12812,6 +12812,7 @@ package android.content.pm { field public static final long MAXIMUM_VERIFICATION_TIMEOUT = 3600000L; // 0x36ee80L field public static final int PERMISSION_DENIED = -1; // 0xffffffff field public static final int PERMISSION_GRANTED = 0; // 0x0 + field public static final String PROPERTY_COMPAT_OVERRIDE_LANDSCAPE_TO_PORTRAIT = "android.camera.PROPERTY_COMPAT_OVERRIDE_LANDSCAPE_TO_PORTRAIT"; field public static final String PROPERTY_MEDIA_CAPABILITIES = "android.media.PROPERTY_MEDIA_CAPABILITIES"; field public static final String PROPERTY_SELF_CERTIFIED_NETWORK_CAPABILITIES = "android.net.PROPERTY_SELF_CERTIFIED_NETWORK_CAPABILITIES"; field public static final String PROPERTY_SPECIAL_USE_FGS_SUBTYPE = "android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"; diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java index 6486278030554..328b0ae962119 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -203,6 +203,36 @@ public abstract class PackageManager { public static final String PROPERTY_SPECIAL_USE_FGS_SUBTYPE = "android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"; + /** + * Application level {@link android.content.pm.PackageManager.Property PackageManager + * .Property} for an app to inform the system that the app can be opted-in or opted-out + * from the compatibility treatment that rotates camera output by 90 degrees on landscape + * sensors on devices known to have compatibility issues. + * + *
The treatment is disabled by default but device manufacturers can enable the treatment + * using their discretion to improve camera compatibility. With this property set to + * {@code false}, the rotation will not be applied. A value of {@code true} + * will ensure that rotation is applied, provided it is enabled for the device. In most cases, + * if rotation is the desired behavior this property need not be set. However, if your app + * experiences stretching or incorrect rotation on these devices, explicitly setting this to + * {@code true} may resolve that behavior. Apps should set this to {@code false} if there + * is confidence that the app handles + * {@link android.hardware.camera2.CameraCharacteristics#SENSOR_ORIENTATION} correctly. + * See the + * documentation for best practice. + * + *
Syntax: + *
+ * <application> + * <property + * android:name="android.camera.PROPERTY_COMPAT_OVERRIDE_LANDSCAPE_TO_PORTRAIT" + * android:value="true|false"/> + * </application> + *+ */ + public static final String PROPERTY_COMPAT_OVERRIDE_LANDSCAPE_TO_PORTRAIT = + "android.camera.PROPERTY_COMPAT_OVERRIDE_LANDSCAPE_TO_PORTRAIT"; + /** * A property value set within the manifest. *
diff --git a/core/java/android/hardware/camera2/CameraManager.java b/core/java/android/hardware/camera2/CameraManager.java index 6cd4a2e6a947b..722dd08d1ee12 100644 --- a/core/java/android/hardware/camera2/CameraManager.java +++ b/core/java/android/hardware/camera2/CameraManager.java @@ -117,13 +117,6 @@ public final class CameraManager { @TestApi public static final long OVERRIDE_CAMERA_LANDSCAPE_TO_PORTRAIT = 250678880L; - /** - * Package-level opt in/out for the above. - * @hide - */ - public static final String PROPERTY_COMPAT_OVERRIDE_LANDSCAPE_TO_PORTRAIT = - "android.camera.PROPERTY_COMPAT_OVERRIDE_LANDSCAPE_TO_PORTRAIT"; - /** * System property for allowing the above * @hide @@ -1189,7 +1182,8 @@ public final class CameraManager { PackageManager packageManager = context.getPackageManager(); try { - return packageManager.getProperty(PROPERTY_COMPAT_OVERRIDE_LANDSCAPE_TO_PORTRAIT, + return packageManager.getProperty( + PackageManager.PROPERTY_COMPAT_OVERRIDE_LANDSCAPE_TO_PORTRAIT, context.getOpPackageName()).getBoolean(); } catch (PackageManager.NameNotFoundException e) { // No such property