Merge "Merge "Camera: Add new hidden API for camera open/close callback" into rvc-dev am: abb2d5847d am: 4b69a26adc am: 1e4cf075cf" into rvc-qpr-dev-plus-aosp
This commit is contained in:
committed by
Android (Google) Code Review
commit
d16202e355
@@ -846,6 +846,33 @@ public final class CameraManager {
|
|||||||
@NonNull String physicalCameraId) {
|
@NonNull String physicalCameraId) {
|
||||||
// default empty implementation
|
// default empty implementation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A camera device has been opened by an application.
|
||||||
|
*
|
||||||
|
* <p>The default implementation of this method does nothing.</p>
|
||||||
|
*
|
||||||
|
* @param cameraId The unique identifier of the new camera.
|
||||||
|
* @param packageId The package Id of the application opening the camera.
|
||||||
|
*
|
||||||
|
* @see #onCameraClosed
|
||||||
|
*/
|
||||||
|
/** @hide */
|
||||||
|
public void onCameraOpened(@NonNull String cameraId, @NonNull String packageId) {
|
||||||
|
// default empty implementation
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A previously-opened camera has been closed.
|
||||||
|
*
|
||||||
|
* <p>The default implementation of this method does nothing.</p>
|
||||||
|
*
|
||||||
|
* @param cameraId The unique identifier of the closed camera.
|
||||||
|
*/
|
||||||
|
/** @hide */
|
||||||
|
public void onCameraClosed(@NonNull String cameraId) {
|
||||||
|
// default empty implementation
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1276,6 +1303,12 @@ public final class CameraManager {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onCameraAccessPrioritiesChanged() {
|
public void onCameraAccessPrioritiesChanged() {
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onCameraOpened(String id, String clientPackageId) {
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onCameraClosed(String id) {
|
||||||
}};
|
}};
|
||||||
|
|
||||||
String[] cameraIds = null;
|
String[] cameraIds = null;
|
||||||
@@ -1503,6 +1536,38 @@ public final class CameraManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void postSingleCameraOpenedUpdate(final AvailabilityCallback callback,
|
||||||
|
final Executor executor, final String id, final String packageId) {
|
||||||
|
final long ident = Binder.clearCallingIdentity();
|
||||||
|
try {
|
||||||
|
executor.execute(
|
||||||
|
new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
callback.onCameraOpened(id, packageId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
Binder.restoreCallingIdentity(ident);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void postSingleCameraClosedUpdate(final AvailabilityCallback callback,
|
||||||
|
final Executor executor, final String id) {
|
||||||
|
final long ident = Binder.clearCallingIdentity();
|
||||||
|
try {
|
||||||
|
executor.execute(
|
||||||
|
new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
callback.onCameraClosed(id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
Binder.restoreCallingIdentity(ident);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void postSingleUpdate(final AvailabilityCallback callback, final Executor executor,
|
private void postSingleUpdate(final AvailabilityCallback callback, final Executor executor,
|
||||||
final String id, final String physicalId, final int status) {
|
final String id, final String physicalId, final int status) {
|
||||||
if (isAvailable(status)) {
|
if (isAvailable(status)) {
|
||||||
@@ -1846,6 +1911,32 @@ public final class CameraManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCameraOpened(String cameraId, String clientPackageId) {
|
||||||
|
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);
|
||||||
|
|
||||||
|
postSingleCameraOpenedUpdate(callback, executor, cameraId, clientPackageId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCameraClosed(String cameraId) {
|
||||||
|
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);
|
||||||
|
|
||||||
|
postSingleCameraClosedUpdate(callback, executor, cameraId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to connect to camera service after some delay if any client registered camera
|
* Try to connect to camera service after some delay if any client registered camera
|
||||||
* availability callback or torch status callback.
|
* availability callback or torch status callback.
|
||||||
|
|||||||
@@ -1305,7 +1305,7 @@
|
|||||||
android:description="@string/permdesc_camera"
|
android:description="@string/permdesc_camera"
|
||||||
android:protectionLevel="dangerous|instant" />
|
android:protectionLevel="dangerous|instant" />
|
||||||
|
|
||||||
<!-- @SystemApi Required in addition to android.permission.CAMERA to be able to access
|
<!-- @SystemApi Required in addition to android.permission.CAMERA to be able to access
|
||||||
system only camera devices.
|
system only camera devices.
|
||||||
<p>Protection level: system|signature
|
<p>Protection level: system|signature
|
||||||
@hide -->
|
@hide -->
|
||||||
@@ -1315,6 +1315,15 @@
|
|||||||
android:description="@string/permdesc_systemCamera"
|
android:description="@string/permdesc_systemCamera"
|
||||||
android:protectionLevel="system|signature" />
|
android:protectionLevel="system|signature" />
|
||||||
|
|
||||||
|
<!-- Allows receiving the camera service notifications when a camera is opened
|
||||||
|
(by a certain application package) or closed.
|
||||||
|
@hide -->
|
||||||
|
<permission android:name="android.permission.CAMERA_OPEN_CLOSE_LISTENER"
|
||||||
|
android:permissionGroup="android.permission-group.UNDEFINED"
|
||||||
|
android:label="@string/permlab_cameraOpenCloseListener"
|
||||||
|
android:description="@string/permdesc_cameraOpenCloseListener"
|
||||||
|
android:protectionLevel="signature" />
|
||||||
|
|
||||||
<!-- ====================================================================== -->
|
<!-- ====================================================================== -->
|
||||||
<!-- Permissions for accessing the device sensors -->
|
<!-- Permissions for accessing the device sensors -->
|
||||||
<!-- ====================================================================== -->
|
<!-- ====================================================================== -->
|
||||||
|
|||||||
@@ -1166,6 +1166,11 @@
|
|||||||
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. [CHAR_LIMIT=NONE] -->
|
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. [CHAR_LIMIT=NONE] -->
|
||||||
<string name="permdesc_systemCamera">This privileged | system app can take pictures and record videos using a system camera at any time. Requires the android.permission.CAMERA permission to be held by the app as well</string>
|
<string name="permdesc_systemCamera">This privileged | system app can take pictures and record videos using a system camera at any time. Requires the android.permission.CAMERA permission to be held by the app as well</string>
|
||||||
|
|
||||||
|
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. [CHAR_LIMIT=NONE] -->
|
||||||
|
<string name="permlab_cameraOpenCloseListener">Allow an application or service to receive callbacks about camera devices being opened or closed.</string>
|
||||||
|
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. [CHAR_LIMIT=NONE] -->
|
||||||
|
<string name="permdesc_cameraOpenCloseListener">This signature app can receive callbacks when any camera device is being opened (by what application package) or closed.</string>
|
||||||
|
|
||||||
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
|
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
|
||||||
<string name="permlab_vibrate">control vibration</string>
|
<string name="permlab_vibrate">control vibration</string>
|
||||||
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
|
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
|
||||||
|
|||||||
@@ -63,5 +63,6 @@
|
|||||||
<permission name="android.permission.WRITE_SECURE_SETTINGS"/>
|
<permission name="android.permission.WRITE_SECURE_SETTINGS"/>
|
||||||
<permission name="android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS"/>
|
<permission name="android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS"/>
|
||||||
<permission name="android.permission.CONTROL_DISPLAY_COLOR_TRANSFORMS" />
|
<permission name="android.permission.CONTROL_DISPLAY_COLOR_TRANSFORMS" />
|
||||||
|
<permission name="android.permission.CAMERA_OPEN_CLOSE_LISTENER" />
|
||||||
</privapp-permissions>
|
</privapp-permissions>
|
||||||
</permissions>
|
</permissions>
|
||||||
|
|||||||
@@ -320,6 +320,15 @@ public class CameraBinderTest extends AndroidTestCase {
|
|||||||
public void onCameraAccessPrioritiesChanged() {
|
public void onCameraAccessPrioritiesChanged() {
|
||||||
Log.v(TAG, "Camera access permission change");
|
Log.v(TAG, "Camera access permission change");
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public void onCameraOpened(String cameraId, String clientPackageName) {
|
||||||
|
Log.v(TAG, String.format("Camera %s is opened by client package %s",
|
||||||
|
cameraId, clientPackageName));
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onCameraClosed(String cameraId) {
|
||||||
|
Log.v(TAG, String.format("Camera %s is closed", cameraId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -147,6 +147,7 @@
|
|||||||
<uses-permission android:name="android.permission.CONFIGURE_WIFI_DISPLAY" />
|
<uses-permission android:name="android.permission.CONFIGURE_WIFI_DISPLAY" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.CAMERA" />
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
|
<uses-permission android:name="android.permission.CAMERA_OPEN_CLOSE_LISTENER" />
|
||||||
|
|
||||||
<!-- Screen Capturing -->
|
<!-- Screen Capturing -->
|
||||||
<uses-permission android:name="android.permission.MANAGE_MEDIA_PROJECTION" />
|
<uses-permission android:name="android.permission.MANAGE_MEDIA_PROJECTION" />
|
||||||
|
|||||||
Reference in New Issue
Block a user