1、 property_get/property_set
? ?每個屬性都有一個名稱和值,他們都是字串格式,屬性被大量使用在Android系統中,用來記錄系統設定或行程之間的資訊交換,屬性是在整個系統中全域可見的,每個行程可以get/set屬性,
在系統初始化時,Android將分配一個共享記憶體區來存盤的屬性,這些是由“init”守護行程完成的,其源代碼位于:device/system/init,“init”守護行程將啟動一個屬**,
屬在“init”守護行程中運行,每一個客戶端想要設定屬性時,必須連接屬
,再向其發送資訊,屬**將會在共享記憶體區中修改和創建屬性,任何客戶端想獲得屬性資訊,可以從共享記憶體直接讀取,這提高了讀取性能, 客戶端應用程式可以呼叫libcutils中的API函式以GET/SET屬性資訊,libcutils的源代碼位于:device/libs/cutils,API函式是:
int property_get(const char *key, char *value, const char *default_value);
int property_get(const char *key, const char *value);
實體1:引數分離
#include <log/log.h>
#include <cutils/properties.h>
#include <cstdio>
#include <cstdlib>
#include <string.h>
static strSyncAEInitInfo gSyncAEInitInfo_1111 = 略
static strSyncAEInitInfo gSyncAEInitInfo_2222 = 略
const strSyncAEInitInfo*
getSyncAEInitInfo()
{
char pSensorName[PROPERTY_VALUE_MAX];
property_get("persist.vendor.camera.sensor0", pSensorName, "NULL");
ALOGD("Sensor Name xxxxxxxxxxxxxxx=%s", pSensorName);
if(0 != strstr(pSensorName,"xxxx1111_mipi_raw"))
{
ALOGD("Sensor Name1 xxxxxxxxxxxxxxx=%s", pSensorName);
return &gSyncAEInitInfo_1111;
}
else if(0 != strstr(pSensorName,"xxxx2222_mipi_raw"))
{
ALOGD("Sensor Name2 xxxxxxxxxxxxxxx=%s", pSensorName);
return &gSyncAEInitInfo_2222;
}
ALOGD("Sensor Name3 xxxxxxxxxxxxxxx=%s", pSensorName);
return &gSyncAEInitInfo;
}
疑問1:persist.vendor.camera.sensor0 在哪獲取的?
mtkcam/drv/src/sensor/common/v1/HalSensorList.cpp
中 這塊是廠商自己定制,具體在哪,要看具體代碼
searchsensor
property_set("persist.vendor.camera.sensor.number", SensorNum);
到此就有set 和 get 的操作
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/271597.html
標籤:其他
上一篇:View事件分發
