本讲是android camera native framework专题的第20讲,我们介绍icameraservicelistener.aidl详解。
更多资源:
资源 | 描述 |
---|---|
在线课程 | |
知识星球 | 星球名称:深入浅出android camera 星球id: 17296815 |
极客笔记圈 |
icameraservicelistener类图
android aidl oneway修饰符
在 android aidl中,oneway 是一种修饰符,用于声明一个方法是单向的(one-way)。
使用 oneway 修饰符声明的方法不会阻塞调用线程,而是立即返回并在后台运行,因此不需要等待方法执行完成。
这种方式适用于客户端和服务端之间不需要进行同步通信的情况,例如通知服务端某项任务已经完成。
需要注意的是,在客户端调用带有 oneway 修饰符的方法时,无法得知方法是否返回成功或失败,因为该方法会立即返回,而不会等待服务端响应。因此,建议将 oneway 修饰符仅用于不需要接收服务端响应的方法。
icameraservicelistener.aidl接口详解
function | description |
---|---|
oneway void ontorchstatuschanged(int status, string cameraid) | 回调通知flash torch模式的状态变化 |
oneway void ontorchstrengthlevelchanged(string cameraid, int newtorchstrength) | 回调通知flash torch的强度发生变化 |
oneway void oncameraaccessprioritieschanged() | 当进程(cameraservice的任何一个client)的adj或前后台状态发生变化时,会回调该方法。 |
oneway void oncameraopened(string cameraid, string clientpackageid) | 回调通知某个client(clientpackageid)打开了某颗(cameraid)camera。 需要有android.permission.camera_open_close_listener权限。 |
oneway void oncameraclosed(string cameraid) | 回调通知某颗(cameraid)camera被关闭了。 需要有android.permission.camera_open_close_listener权限。 |
android 13 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);
}