第20讲 ICameraServiceListener.aidl详解

https://deepinout.com/android-camera-native-framework/camera-java-fw-aidl-icameraservicelistener-aidl-details.html
在这里插入图片描述

1 ICameraServiceListener类图

在这里插入图片描述黑色部分为对应的程序代码,

在这里插入图片描述调用流程
C++
BpCameraServiceListener – ICameraServiceListener
AIDL
Java
ICameraServiceListener.Stub – OnTransact()

2 Android AIDL oneway修饰符

在 Android AIDL中,oneway 是一种修饰符,用于声明一个方法是单向的(one-way)。

使用 oneway 修饰符声明的方法不会阻塞调用线程,而是立即返回并在后台运行,因此不需要等待方法执行完成。

这种方式适用于客户端和服务端之间不需要进行同步通信的情况,例如通知服务端某项任务已经完成。

需要注意的是,在客户端调用带有 oneway 修饰符的方法时,无法得知方法是否返回成功或失败,因为该方法会立即返回,而不会等待服务端响应。
因此,建议将 oneway 修饰符仅用于不需要接收服务端响应的方法。

3 ICameraServiceListener.aidl接口详解

在这里插入图片描述

/** @hide */
interface ICameraServiceListener
{

    /**
     * Initial status will be transmitted with onStatusChange immediately
     * after this listener is added to the service listener list.
     *
     * Allowed transitions:
     *
     *     (Any)               -> NOT_PRESENT
     *     NOT_PRESENT         -> PRESENT
     *     NOT_PRESENT         -> ENUMERATING
     *     ENUMERATING         -> PRESENT
     *     PRESENT             -> NOT_AVAILABLE
     *     NOT_AVAILABLE       -> PRESENT
     *
     * A state will never immediately transition back to itself.
     *
     * The enums must match the values in
     * include/hardware/camera_common.h when applicable
     */
    // Device physically unplugged
    const int STATUS_NOT_PRESENT      = 0;
    // Device physically has been plugged in and the camera can be used exclusively
    const int STATUS_PRESENT          = 1;
    // Device physically has been plugged in but it will not be connect-able until enumeration is
    // complete
    const int STATUS_ENUMERATING      = 2;
    // Camera is in use by another app and cannot be used exclusively
    const int STATUS_NOT_AVAILABLE    = -2;

    // Use to initialize variables only
    const int STATUS_UNKNOWN          = -1;

    oneway void onStatusChanged(int status, String cameraId);

    /**
     * Notify registered client about status changes for a physical camera backing
     * a logical camera.
     */
    oneway void onPhysicalCameraStatusChanged(int status, String cameraId, String physicalCameraId);

    /**
     * The torch mode status of a camera.
     *
     * Initial status will be transmitted with onTorchStatusChanged immediately
     * after this listener is added to the service listener list.
     *
     * The enums must match the values in
     * include/hardware/camera_common.h
     */
    // The camera's torch mode has become not available to use via
    // setTorchMode().
    const int TORCH_STATUS_NOT_AVAILABLE = 0;
    // The camera's torch mode is off and available to be turned on via
    // setTorchMode().
    const int TORCH_STATUS_AVAILABLE_OFF = 1;
    // The camera's torch mode is on and available to be turned off via
    // setTorchMode().
    const int TORCH_STATUS_AVAILABLE_ON  = 2;

    // Use to initialize variables only
    const int TORCH_STATUS_UNKNOWN = -1;

    oneway void onTorchStatusChanged(int status, String cameraId);

    oneway void onTorchStrengthLevelChanged(String cameraId, int newTorchStrength);

    /**
     * Notify registered clients about camera access priority changes.
     * Clients which were previously unable to open a certain camera device
     * can retry after receiving this callback.
     */
    oneway void onCameraAccessPrioritiesChanged();

    /**
     * Notify registered clients about cameras being opened/closed.
     * Only clients with android.permission.CAMERA_OPEN_CLOSE_LISTENER permission
     * will receive such callbacks.
     */
    oneway void onCameraOpened(String cameraId, String clientPackageId);
    oneway void onCameraClosed(String cameraId);
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值