Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -16797,6 +16797,7 @@ package android.hardware.camera2 { public abstract static class CameraManager.AvailabilityCallback { ctor public CameraManager.AvailabilityCallback(); method public void onCameraAccessPrioritiesChanged(); method public void onCameraAvailable(@NonNull String); method public void onCameraUnavailable(@NonNull String); } core/java/android/hardware/camera2/CameraManager.java +54 −0 Original line number Diff line number Diff line Loading @@ -678,6 +678,31 @@ public final class CameraManager { public void onCameraUnavailable(@NonNull String cameraId) { // default empty implementation } /** * Notify registered clients about a change in the camera access priorities. * * <p>Notification that camera access priorities have changed and the camera may * now be openable. An application that was previously denied camera access due to * a higher-priority user already using the camera, or that was disconnected from an * active camera session due to a higher-priority user trying to open the camera, * should try to open the camera again if it still wants to use it. Note that * multiple applications may receive this callback at the same time, and only one of * them will succeed in opening the camera in practice, depending on exact access * priority levels and timing. This method is useful in cases where multiple * applications may be in the resumed state at the same time, and the user switches * focus between them, or if the current camera-using application moves between * full-screen and Picture-in-Picture (PiP) states. In such cases, the camera * available/unavailable callbacks will not be invoked, but another application may * now have higher priority for camera access than the current camera-using * application.</p> * * <p>The default implementation of this method does nothing.</p> * */ public void onCameraAccessPrioritiesChanged() { // default empty implementation } } /** Loading Loading @@ -1098,6 +1123,22 @@ public final class CameraManager { } } private void postSingleAccessPriorityChangeUpdate(final AvailabilityCallback callback, final Executor executor) { final long ident = Binder.clearCallingIdentity(); try { executor.execute( new Runnable() { @Override public void run() { callback.onCameraAccessPrioritiesChanged(); } }); } finally { Binder.restoreCallingIdentity(ident); } } private void postSingleUpdate(final AvailabilityCallback callback, final Executor executor, final String id, final int status) { if (isAvailable(status)) { Loading Loading @@ -1347,6 +1388,19 @@ public final class CameraManager { } } @Override public void onCameraAccessPrioritiesChanged() { synchronized (mLock) { final int callbackCount = mCallbackMap.size(); for (int i = 0; i < callbackCount; i++) { Executor executor = mCallbackMap.valueAt(i); final AvailabilityCallback callback = mCallbackMap.keyAt(i); postSingleAccessPriorityChangeUpdate(callback, executor); } } } /** * Try to connect to camera service after some delay if any client registered camera * availability callback or torch status callback. Loading media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraBinderTest.java +4 −0 Original line number Diff line number Diff line Loading @@ -309,6 +309,10 @@ public class CameraBinderTest extends AndroidTestCase { Log.v(TAG, String.format("Camera %s has torch status changed to 0x%x", cameraId, status)); } @Override public void onCameraAccessPrioritiesChanged() { Log.v(TAG, "Camera access permission change"); } } /** Loading Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -16797,6 +16797,7 @@ package android.hardware.camera2 { public abstract static class CameraManager.AvailabilityCallback { ctor public CameraManager.AvailabilityCallback(); method public void onCameraAccessPrioritiesChanged(); method public void onCameraAvailable(@NonNull String); method public void onCameraUnavailable(@NonNull String); }
core/java/android/hardware/camera2/CameraManager.java +54 −0 Original line number Diff line number Diff line Loading @@ -678,6 +678,31 @@ public final class CameraManager { public void onCameraUnavailable(@NonNull String cameraId) { // default empty implementation } /** * Notify registered clients about a change in the camera access priorities. * * <p>Notification that camera access priorities have changed and the camera may * now be openable. An application that was previously denied camera access due to * a higher-priority user already using the camera, or that was disconnected from an * active camera session due to a higher-priority user trying to open the camera, * should try to open the camera again if it still wants to use it. Note that * multiple applications may receive this callback at the same time, and only one of * them will succeed in opening the camera in practice, depending on exact access * priority levels and timing. This method is useful in cases where multiple * applications may be in the resumed state at the same time, and the user switches * focus between them, or if the current camera-using application moves between * full-screen and Picture-in-Picture (PiP) states. In such cases, the camera * available/unavailable callbacks will not be invoked, but another application may * now have higher priority for camera access than the current camera-using * application.</p> * * <p>The default implementation of this method does nothing.</p> * */ public void onCameraAccessPrioritiesChanged() { // default empty implementation } } /** Loading Loading @@ -1098,6 +1123,22 @@ public final class CameraManager { } } private void postSingleAccessPriorityChangeUpdate(final AvailabilityCallback callback, final Executor executor) { final long ident = Binder.clearCallingIdentity(); try { executor.execute( new Runnable() { @Override public void run() { callback.onCameraAccessPrioritiesChanged(); } }); } finally { Binder.restoreCallingIdentity(ident); } } private void postSingleUpdate(final AvailabilityCallback callback, final Executor executor, final String id, final int status) { if (isAvailable(status)) { Loading Loading @@ -1347,6 +1388,19 @@ public final class CameraManager { } } @Override public void onCameraAccessPrioritiesChanged() { synchronized (mLock) { final int callbackCount = mCallbackMap.size(); for (int i = 0; i < callbackCount; i++) { Executor executor = mCallbackMap.valueAt(i); final AvailabilityCallback callback = mCallbackMap.keyAt(i); postSingleAccessPriorityChangeUpdate(callback, executor); } } } /** * Try to connect to camera service after some delay if any client registered camera * availability callback or torch status callback. Loading
media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraBinderTest.java +4 −0 Original line number Diff line number Diff line Loading @@ -309,6 +309,10 @@ public class CameraBinderTest extends AndroidTestCase { Log.v(TAG, String.format("Camera %s has torch status changed to 0x%x", cameraId, status)); } @Override public void onCameraAccessPrioritiesChanged() { Log.v(TAG, "Camera access permission change"); } } /** Loading