diff --git a/frameworks/js/napi/src/sensor_napi_utils.cpp b/frameworks/js/napi/src/sensor_napi_utils.cpp index a62895176d180251040286b50ab834bcc42f7e72..20adf402d3345e29afc6bdff49a42e39b994a4c8 100644 --- a/frameworks/js/napi/src/sensor_napi_utils.cpp +++ b/frameworks/js/napi/src/sensor_napi_utils.cpp @@ -265,7 +265,7 @@ bool ConvertToSensorInfo(const napi_env &env, const SensorInfo &sensorInfo, napi "napi_create_string_latin1"); CHKNRF(env, napi_set_named_property(env, result, "hardwareVersion", value), "napi_set_named_property"); value = nullptr; - CHKNRF(env, napi_create_double(env, sensorInfo.sensorId, &value), "napi_create_double"); + CHKNRF(env, napi_create_double(env, sensorInfo.sensorIndex, &value), "napi_create_double"); CHKNRF(env, napi_set_named_property(env, result, "sensorIndex", value), "napi_set_named_property"); value = nullptr; CHKNRF(env, napi_create_double(env, sensorInfo.sensorTypeId, &value), "napi_create_double"); diff --git a/frameworks/native/include/sensor_agent_proxy.h b/frameworks/native/include/sensor_agent_proxy.h index 4121bb43257a14d1b244f36253320958b3a96e99..ab4cf4773b8fec19bd935fe31888d169a517fd41 100644 --- a/frameworks/native/include/sensor_agent_proxy.h +++ b/frameworks/native/include/sensor_agent_proxy.h @@ -65,7 +65,7 @@ private: bool IsSubscribeMapEmpty() const; int32_t UpdateSensorInfo(SensorInfo* sensorInfo, const Sensor& sensor); int32_t UpdateSensorInfosCache(const std::vector& deviceSensorList); - bool FindSensorInfo(int32_t deviceId, int32_t sensorId, int32_t sensorTypeId); + bool FindSensorInfo(int32_t deviceId, int32_t sensorIndex, int32_t sensorTypeId); void UpdataSensorStatusEvent(SensorStatusEvent &event, SensorPlugData info); bool UpdataSensorInfo(SensorPlugData info); void EraseCacheSensorInfos(SensorPlugData info); diff --git a/frameworks/native/src/sensor_agent_proxy.cpp b/frameworks/native/src/sensor_agent_proxy.cpp index fb191157cafa4d30990f2c8e9307c8e65a5cfbc0..6ebf660a65aefb78b1db0d1609ec16d67c08b206 100644 --- a/frameworks/native/src/sensor_agent_proxy.cpp +++ b/frameworks/native/src/sensor_agent_proxy.cpp @@ -436,8 +436,9 @@ int32_t SensorAgentProxy::ConvertSensorInfos() const sensorList[i].GetFirmwareVersion().c_str()); CHKCR(ret == EOK, ERROR); sensorInfo->deviceId = sensorList[i].GetDeviceId(); - sensorInfo->sensorId = sensorList[i].GetSensorId(); + sensorInfo->sensorId = sensorList[i].GetSensorTypeId(); sensorInfo->sensorTypeId = sensorList[i].GetSensorTypeId(); + sensorInfo->sensorIndex = sensorList[i].GetSensorId(); sensorInfo->location = sensorList[i].GetLocation(); sensorInfo->maxRange = sensorList[i].GetMaxRange(); sensorInfo->precision = sensorList[i].GetResolution(); @@ -515,8 +516,9 @@ int32_t SensorAgentProxy::UpdateSensorInfo(SensorInfo* sensorInfo, const Sensor& sensor.GetFirmwareVersion().c_str()); CHKCR(ret == EOK, ERROR); sensorInfo->deviceId = sensor.GetDeviceId(); - sensorInfo->sensorId = sensor.GetSensorId(); + sensorInfo->sensorId = sensor.GetSensorTypeId(); sensorInfo->sensorTypeId = sensor.GetSensorTypeId(); + sensorInfo->sensorIndex = sensor.GetSensorId(); sensorInfo->location = sensor.GetLocation(); sensorInfo->maxRange = sensor.GetMaxRange(); sensorInfo->precision = sensor.GetResolution(); @@ -526,7 +528,7 @@ int32_t SensorAgentProxy::UpdateSensorInfo(SensorInfo* sensorInfo, const Sensor& return SUCCESS; } -bool SensorAgentProxy::FindSensorInfo(int32_t deviceId, int32_t sensorId, int32_t sensorTypeId) +bool SensorAgentProxy::FindSensorInfo(int32_t deviceId, int32_t sensorIndex, int32_t sensorTypeId) { CALL_LOG_ENTER; if (sensorInfoCheck_.sensorInfos == nullptr) { @@ -534,10 +536,10 @@ bool SensorAgentProxy::FindSensorInfo(int32_t deviceId, int32_t sensorId, int32_ } for (int32_t i = 0; i < sensorInfoCount_; ++i) { if (sensorInfoCheck_.sensorInfos[i].deviceId == deviceId && - sensorInfoCheck_.sensorInfos[i].sensorId == sensorId && + sensorInfoCheck_.sensorInfos[i].sensorIndex == sensorIndex && sensorInfoCheck_.sensorInfos[i].sensorTypeId == sensorTypeId) { SEN_HILOGI("FindSensorInfo deviceId:%{public}d, sensorTypeId:%{public}d, sensorId:%{public}d", - deviceId, sensorTypeId, sensorId); + deviceId, sensorTypeId, sensorIndex); return true; } } @@ -830,7 +832,7 @@ void SensorAgentProxy::EraseCacheSensorInfos(SensorPlugData info) for (int32_t i = 0; i < sensorInfoCount_; ++i) { if ((sensorInfoCheck_.sensorInfos[i].deviceId == info.deviceId) && (sensorInfoCheck_.sensorInfos[i].sensorTypeId == info.sensorTypeId) && - (sensorInfoCheck_.sensorInfos[i].sensorId == info.sensorId)) { + (sensorInfoCheck_.sensorInfos[i].sensorIndex == info.sensorId)) { for (int j = i; j < sensorInfoCount_ - 1; ++j) { sensorInfoCheck_.sensorInfos[j] = sensorInfoCheck_.sensorInfos[j+1]; } diff --git a/interfaces/inner_api/sensor_agent_type.h b/interfaces/inner_api/sensor_agent_type.h index 0a1d238e1ab84354265e61b7d8dc022f76b88bcf..3a020696efa24c687756871f2bcc9ad3976e3abc 100644 --- a/interfaces/inner_api/sensor_agent_type.h +++ b/interfaces/inner_api/sensor_agent_type.h @@ -126,6 +126,7 @@ typedef struct SensorInfo { int64_t maxSamplePeriod = -1; /**< Maximum sample period allowed, in ns */ int32_t deviceId = -1; /**< Device ID */ int32_t location = -1; /**< Is the device a local device or an external device */ + int32_t sensorIndex = -1; /**< Sensor Index */ } SensorInfo; /** diff --git a/services/hdi_connection/adapter/src/compatible_connection.cpp b/services/hdi_connection/adapter/src/compatible_connection.cpp index 8b5364737a9b7859b9ae20a2adfc60f0eae928be..5de33fc9302c78a0584a6d98a8d3c40de83d582f 100644 --- a/services/hdi_connection/adapter/src/compatible_connection.cpp +++ b/services/hdi_connection/adapter/src/compatible_connection.cpp @@ -50,7 +50,7 @@ int32_t CompatibleConnection::GetSensorList(std::vector &sensorList) const std::string vendorName(sensorInfos[i].vendorName); const std::string firmwareVersion(sensorInfos[i].firmwareVersion); const std::string hardwareVersion(sensorInfos[i].hardwareVersion); - const int32_t sensorId = sensorInfos[i].sensorId; + const int32_t sensorId = sensorInfos[i].sensorIndex; const int32_t sensorTypeId = sensorInfos[i].sensorTypeId; const int32_t deviceId = sensorInfos[i].deviceId; const int32_t location = sensorInfos[i].location; @@ -193,7 +193,7 @@ int32_t CompatibleConnection::GetSensorListByDevice(int32_t deviceId, std::vecto const std::string vendorName(sensorInfos[i].vendorName); const std::string firmwareVersion(sensorInfos[i].firmwareVersion); const std::string hardwareVersion(sensorInfos[i].hardwareVersion); - const int32_t sensorId = sensorInfos[i].sensorId; + const int32_t sensorId = sensorInfos[i].sensorIndex; const int32_t sensorTypeId = sensorInfos[i].sensorTypeId; const int32_t deviceId = sensorInfos[i].deviceId; const int32_t location = sensorInfos[i].location; diff --git a/services/hdi_connection/hardware/src/hdi_service_impl.cpp b/services/hdi_connection/hardware/src/hdi_service_impl.cpp index e715a98c2162f19f7f9ecc287f4e621236c2a919..909a29820dce752920dd8ae5c30db5646caa57c6 100644 --- a/services/hdi_connection/hardware/src/hdi_service_impl.cpp +++ b/services/hdi_connection/hardware/src/hdi_service_impl.cpp @@ -35,7 +35,7 @@ constexpr int32_t DEFAULT_SENSOR_ID = 0; constexpr int32_t IS_LOCAL_DEVICE = 1; const std::string SENSOR_PRODUCE_THREAD_NAME = "OS_SenMock"; std::vector g_sensorInfos = { - {"sensor_test", "default", "1.0.0", "1.0.0", 1, 0, 9999.0, 0.000001, 23.0, 100000000, 1000000000, -1, 1}, + {"sensor_test", "default", "1.0.0", "1.0.0", 1, 1, 9999.0, 0.000001, 23.0, 100000000, 1000000000, -1, 1, 0}, }; std::vector g_supportSensors = { SENSOR_TYPE_ID_ACCELEROMETER, diff --git a/test/fuzztest/services/getsensorlistbydevicestub_fuzzer/BUILD.gn b/test/fuzztest/services/getsensorlistbydevicestub_fuzzer/BUILD.gn index 8d0cbaaf14f6c5f5e16cf54c519ecebe696198cb..26787bff1b22f80cc99e6bb06e56800ba0fb6950 100644 --- a/test/fuzztest/services/getsensorlistbydevicestub_fuzzer/BUILD.gn +++ b/test/fuzztest/services/getsensorlistbydevicestub_fuzzer/BUILD.gn @@ -57,12 +57,14 @@ ohos_fuzztest("GetSensorListByDeviceStubFuzzTest") { "access_token:libaccesstoken_sdk", "access_token:libnativetoken_shared", "access_token:libtokensetproc_shared", + "cJSON:cjson_static", "c_utils:utils", + "drivers_interface_sensor:libsensor_proxy_3.0", "hilog:libhilog", "ipc:ipc_single", "safwk:system_ability_fwk", "samgr:samgr_proxy", - "drivers_interface_sensor:libsensor_proxy_3.0", + "selinux_adapter:librestorecon", ] } diff --git a/test/fuzztest/services/transferclientremoteobjectstub_fuzzer/BUILD.gn b/test/fuzztest/services/transferclientremoteobjectstub_fuzzer/BUILD.gn index 2c7a5eb50eaf521be0e736ed69990b94a8de7729..a06d5954450df12159988e5d54136bae141ea486 100644 --- a/test/fuzztest/services/transferclientremoteobjectstub_fuzzer/BUILD.gn +++ b/test/fuzztest/services/transferclientremoteobjectstub_fuzzer/BUILD.gn @@ -58,11 +58,13 @@ ohos_fuzztest("TransferClientRemoteObjectStubFuzzTest") { "access_token:libnativetoken_shared", "access_token:libtokensetproc_shared", "c_utils:utils", + "cJSON:cjson_static", + "drivers_interface_sensor:libsensor_proxy_3.0", "hilog:libhilog", "ipc:ipc_single", "safwk:system_ability_fwk", "samgr:samgr_proxy", - "drivers_interface_sensor:libsensor_proxy_3.0", + "selinux_adapter:librestorecon", ] }