diff --git a/frameworks/native/BUILD.gn b/frameworks/native/BUILD.gn
index f77a183b111ac68452b1015d01da6ac2c936637d..61b2f58a7461fc32fa375fdd88977f660d12d190 100644
--- a/frameworks/native/BUILD.gn
+++ b/frameworks/native/BUILD.gn
@@ -125,7 +125,7 @@ config("ohsensor_public_config") {
ohos_shared_library("ohsensor") {
sources = [ "src/native_sensor.cpp" ]
-
+ output_extension = "so"
defines = [ "API_EXPORT=__attribute__((visibility (\"default\")))" ]
configs = [ ":sensor_private_config" ]
diff --git a/frameworks/native/src/native_sensor.cpp b/frameworks/native/src/native_sensor.cpp
index 22d2572f4a6717256c128f7ae0bcffbb4ae0347a..e872e902f5a29b25652d52a461734d8bf4954a25 100644
--- a/frameworks/native/src/native_sensor.cpp
+++ b/frameworks/native/src/native_sensor.cpp
@@ -74,7 +74,7 @@ Sensor_Result OH_Sensor_GetInfos(Sensor_Info **sensors, uint32_t *count)
return SENSOR_SUCCESS;
}
-Sensor_Info **OH_Sensor_Info_Create(uint32_t count)
+Sensor_Info **OH_Sensor_CreateInfos(uint32_t count)
{
auto sensors = new Sensor_Info *[count];
for (uint32_t i = 0; i < count; ++i) {
@@ -83,7 +83,7 @@ Sensor_Info **OH_Sensor_Info_Create(uint32_t count)
return sensors;
}
-int32_t OH_Sensor_Info_Destroy(Sensor_Info **sensors, uint32_t count)
+int32_t OH_Sensor_DestroyInfos(Sensor_Info **sensors, uint32_t count)
{
for (uint32_t i = 0; i < count; ++i) {
delete sensors[i];
@@ -314,12 +314,12 @@ int32_t OH_Sensor_Subscriber_GetCallback(Sensor_Subscriber* user, Sensor_EventCa
return SENSOR_SUCCESS;
}
-Sensor_SubscriptionId *OH_Sensor_SubscriptionId_Create()
+Sensor_SubscriptionId *OH_Sensor_CreateSubscriptionId()
{
return new (std::nothrow) Sensor_SubscriptionId();
}
-int32_t OH_Sensor_SubscriptionId_Destroy(Sensor_SubscriptionId *id)
+int32_t OH_Sensor_DestroySubscriptionId(Sensor_SubscriptionId *id)
{
if (id == nullptr) {
SEN_HILOGE("Parameter error");
@@ -330,12 +330,12 @@ int32_t OH_Sensor_SubscriptionId_Destroy(Sensor_SubscriptionId *id)
return SENSOR_SUCCESS;
}
-Sensor_SubscriptionAttribute *OH_Sensor_SubscriptionAttribute_Create()
+Sensor_SubscriptionAttribute *OH_Sensor_CreateSubscriptionAttribute()
{
return new (std::nothrow) Sensor_SubscriptionAttribute();
}
-int32_t OH_Sensor_SubscriptionAttribute_Destroy(Sensor_SubscriptionAttribute *attribute)
+int32_t OH_Sensor_DestroySubscriptionAttribute(Sensor_SubscriptionAttribute *attribute)
{
if (attribute == nullptr) {
SEN_HILOGE("Parameter error");
@@ -346,12 +346,12 @@ int32_t OH_Sensor_SubscriptionAttribute_Destroy(Sensor_SubscriptionAttribute *at
return SENSOR_SUCCESS;
}
-Sensor_Subscriber *OH_Sensor_Subscriber_Create()
+Sensor_Subscriber *OH_Sensor_CreateSubscriber()
{
return new (std::nothrow) Sensor_Subscriber();
}
-int32_t OH_Sensor_Subscriber_Destroy(Sensor_Subscriber *user)
+int32_t OH_Sensor_DestroySubscriber(Sensor_Subscriber *user)
{
if (user == nullptr) {
SEN_HILOGE("Parameter error");
diff --git a/interfaces/kits/c/BUILD.gn b/interfaces/kits/c/BUILD.gn
index 3629fa7aa581de4f1c012a9b1bfe52cc6a48497a..aca02c5cd11c1454b5ae335030ecf967f949a2e8 100644
--- a/interfaces/kits/c/BUILD.gn
+++ b/interfaces/kits/c/BUILD.gn
@@ -25,5 +25,6 @@ ohos_ndk_headers("sensor_ndk_header") {
ohos_ndk_library("libsensor_ndk") {
ndk_description_file = "./libsensor.ndk.json"
output_name = "ohsensor"
+ output_extension = "so"
min_compact_version = "11"
}
diff --git a/interfaces/kits/c/libsensor.ndk.json b/interfaces/kits/c/libsensor.ndk.json
index eb6d417d96b20cdb3325b0020846087dc1f0b67f..17acb13e89912746844bdec9373cad5cd5d12b4d 100644
--- a/interfaces/kits/c/libsensor.ndk.json
+++ b/interfaces/kits/c/libsensor.ndk.json
@@ -57,27 +57,27 @@
"name": "OH_Sensor_Subscriber_GetCallback"
},
{
- "name": "OH_Sensor_Info_Create"
+ "name": "OH_Sensor_CreateInfos"
},
{
- "name": "OH_Sensor_Info_Destroy"
+ "name": "OH_Sensor_DestroyInfos"
},
{
- "name": "OH_Sensor_SubscriptionId_Create"
+ "name": "OH_Sensor_CreateSubscriptionId"
},
{
- "name": "OH_Sensor_SubscriptionId_Destroy"
+ "name": "OH_Sensor_DestroySubscriptionId"
},
{
- "name": "OH_Sensor_SubscriptionAttribute_Create"
+ "name": "OH_Sensor_CreateSubscriptionAttribute"
},
{
- "name": "OH_Sensor_SubscriptionAttribute_Destroy"
+ "name": "OH_Sensor_DestroySubscriptionAttribute"
},
{
- "name": "OH_Sensor_Subscriber_Create"
+ "name": "OH_Sensor_CreateSubscriber"
},
{
- "name": "OH_Sensor_Subscriber_Destroy"
+ "name": "OH_Sensor_DestroySubscriber"
}
]
\ No newline at end of file
diff --git a/interfaces/kits/c/oh_sensor_type.h b/interfaces/kits/c/oh_sensor_type.h
index 61ae622c063855249ea4d4079f30df73c3a269e1..8c55a40c79afd1b92dafd00f2f0e6234f2482f36 100644
--- a/interfaces/kits/c/oh_sensor_type.h
+++ b/interfaces/kits/c/oh_sensor_type.h
@@ -187,7 +187,7 @@ typedef struct Sensor_Info Sensor_Info;
* returns NULL otherwise.
* @since 11
*/
-Sensor_Info **OH_Sensor_Info_Create(uint32_t count);
+Sensor_Info **OH_Sensor_CreateInfos(uint32_t count);
/**
* @brief Destroys an array of {@link Sensor_Info} instances and reclaims memory.
@@ -198,7 +198,7 @@ Sensor_Info **OH_Sensor_Info_Create(uint32_t count);
* returns an error code defined in {@link Sensor_Result} otherwise.
* @since 11
*/
-int32_t OH_Sensor_Info_Destroy(Sensor_Info **sensors, uint32_t count);
+int32_t OH_Sensor_DestroyInfos(Sensor_Info **sensors, uint32_t count);
/**
* @brief Obtains the sensor name.
@@ -355,7 +355,7 @@ typedef struct Sensor_SubscriptionId Sensor_SubscriptionId;
* returns NULL otherwise.
* @since 11
*/
-Sensor_SubscriptionId *OH_Sensor_SubscriptionId_Create(void);
+Sensor_SubscriptionId *OH_Sensor_CreateSubscriptionId(void);
/**
* @brief Destroys a {@link Sensor_SubscriptionId} instance and reclaims memory.
@@ -365,7 +365,7 @@ Sensor_SubscriptionId *OH_Sensor_SubscriptionId_Create(void);
* returns an error code defined in {@link Sensor_Result} otherwise.
* @since 11
*/
-int32_t OH_Sensor_SubscriptionId_Destroy(Sensor_SubscriptionId *id);
+int32_t OH_Sensor_DestroySubscriptionId(Sensor_SubscriptionId *id);
/**
* @brief Obtains the sensor type.
@@ -402,7 +402,7 @@ typedef struct Sensor_SubscriptionAttribute Sensor_SubscriptionAttribute;
* returns NULL otherwise.
* @since 11
*/
-Sensor_SubscriptionAttribute *OH_Sensor_SubscriptionAttribute_Create(void);
+Sensor_SubscriptionAttribute *OH_Sensor_CreateSubscriptionAttribute(void);
/**
* @brief Destroys a {@link Sensor_SubscriptionAttribute} instance and reclaims memory.
@@ -412,7 +412,7 @@ Sensor_SubscriptionAttribute *OH_Sensor_SubscriptionAttribute_Create(void);
* returns an error code defined in {@link Sensor_Result} otherwise.
* @since 11
*/
-int32_t OH_Sensor_SubscriptionAttribute_Destroy(Sensor_SubscriptionAttribute *attribute);
+int32_t OH_Sensor_DestroySubscriptionAttribute(Sensor_SubscriptionAttribute *attribute);
/**
* @brief Sets the sensor data reporting interval.
@@ -457,7 +457,7 @@ typedef struct Sensor_Subscriber Sensor_Subscriber;
* if the operation is successful; returns NULL otherwise.
* @since 11
*/
-Sensor_Subscriber *OH_Sensor_Subscriber_Create(void);
+Sensor_Subscriber *OH_Sensor_CreateSubscriber(void);
/**
* @brief Destroys a {@link Sensor_Subscriber} instance and reclaims memory.
@@ -467,7 +467,7 @@ Sensor_Subscriber *OH_Sensor_Subscriber_Create(void);
* returns an error code defined in {@link Sensor_Result} otherwise.
* @since 11
*/
-int32_t OH_Sensor_Subscriber_Destroy(Sensor_Subscriber *subscriber);
+int32_t OH_Sensor_DestroySubscriber(Sensor_Subscriber *subscriber);
/**
* @brief Sets a callback function to report sensor data.
diff --git a/test/unittest/interfaces/kits/sensor_native_test.cpp b/test/unittest/interfaces/kits/sensor_native_test.cpp
index 824c6b5ca06de8022ad86571d0bb17be0ea5eccd..757057dd8980ad0f0a79ba4dd5dff93ba6c2d901 100755
--- a/test/unittest/interfaces/kits/sensor_native_test.cpp
+++ b/test/unittest/interfaces/kits/sensor_native_test.cpp
@@ -142,7 +142,7 @@ HWTEST_F(SensorAgentTest, OH_Sensor_GetInfos_001, TestSize.Level1)
uint32_t count = 0;
int32_t ret = OH_Sensor_GetInfos(nullptr, &count);
ASSERT_EQ(ret, SENSOR_SUCCESS);
- Sensor_Info **sensors = OH_Sensor_Info_Create(count);
+ Sensor_Info **sensors = OH_Sensor_CreateInfos(count);
ASSERT_NE(sensors, nullptr);
ret = OH_Sensor_GetInfos(sensors, &count);
ASSERT_EQ(ret, SENSOR_SUCCESS);
@@ -172,7 +172,7 @@ HWTEST_F(SensorAgentTest, OH_Sensor_GetInfos_001, TestSize.Level1)
static_cast(sensorType), sensorName, vendorName,
resolution, minSamplePeriod, maxSamplePeriod);
}
- ret = OH_Sensor_Info_Destroy(sensors, count);
+ ret = OH_Sensor_DestroyInfos(sensors, count);
ASSERT_EQ(ret, SENSOR_SUCCESS);
}
@@ -187,15 +187,15 @@ HWTEST_F(SensorAgentTest, OH_Sensor_GetInfos_002, TestSize.Level1)
HWTEST_F(SensorAgentTest, OH_Sensor_Subscribe_001, TestSize.Level1)
{
SEN_HILOGI("OH_Sensor_Subscribe_001 in");
- g_user = OH_Sensor_Subscriber_Create();
+ g_user = OH_Sensor_CreateSubscriber();
int32_t ret = OH_Sensor_Subscriber_SetCallback(g_user, SensorDataCallbackImpl);
ASSERT_EQ(ret, SENSOR_SUCCESS);
- Sensor_SubscriptionId *id = OH_Sensor_SubscriptionId_Create();
+ Sensor_SubscriptionId *id = OH_Sensor_CreateSubscriptionId();
ret = OH_Sensor_SubscriptionId_SetType(id, SENSOR_ID);
ASSERT_EQ(ret, SENSOR_SUCCESS);
- Sensor_SubscriptionAttribute *attr = OH_Sensor_SubscriptionAttribute_Create();
+ Sensor_SubscriptionAttribute *attr = OH_Sensor_CreateSubscriptionAttribute();
ret = OH_Sensor_SubscriptionAttribute_SetSamplingInterval(attr, SENSOR_SAMPLE_PERIOD);
ASSERT_EQ(ret, SENSOR_SUCCESS);
@@ -206,13 +206,13 @@ HWTEST_F(SensorAgentTest, OH_Sensor_Subscribe_001, TestSize.Level1)
ret = OH_Sensor_Unsubscribe(id, g_user);
ASSERT_EQ(ret, SENSOR_SUCCESS);
if (id != nullptr) {
- OH_Sensor_SubscriptionId_Destroy(id);
+ OH_Sensor_DestroySubscriptionId(id);
}
if (attr != nullptr) {
- OH_Sensor_SubscriptionAttribute_Destroy(attr);
+ OH_Sensor_DestroySubscriptionAttribute(attr);
}
if (g_user != nullptr) {
- OH_Sensor_Subscriber_Destroy(g_user);
+ OH_Sensor_DestroySubscriber(g_user);
g_user = nullptr;
}
}
@@ -220,42 +220,42 @@ HWTEST_F(SensorAgentTest, OH_Sensor_Subscribe_001, TestSize.Level1)
HWTEST_F(SensorAgentTest, OH_Sensor_Subscribe_002, TestSize.Level1)
{
SEN_HILOGI("OH_Sensor_Subscribe_002 in");
- Sensor_SubscriptionId *id = OH_Sensor_SubscriptionId_Create();
+ Sensor_SubscriptionId *id = OH_Sensor_CreateSubscriptionId();
int32_t ret = OH_Sensor_SubscriptionId_SetType(id, SENSOR_ID);
ASSERT_EQ(ret, SENSOR_SUCCESS);
- Sensor_SubscriptionAttribute *attr = OH_Sensor_SubscriptionAttribute_Create();
+ Sensor_SubscriptionAttribute *attr = OH_Sensor_CreateSubscriptionAttribute();
ret = OH_Sensor_SubscriptionAttribute_SetSamplingInterval(attr, SENSOR_SAMPLE_PERIOD);
ASSERT_EQ(ret, SENSOR_SUCCESS);
ret = OH_Sensor_Subscribe(id, attr, nullptr);
ASSERT_EQ(ret, SENSOR_PARAMETER_ERROR);
if (id != nullptr) {
- OH_Sensor_SubscriptionId_Destroy(id);
+ OH_Sensor_DestroySubscriptionId(id);
}
if (attr != nullptr) {
- OH_Sensor_SubscriptionAttribute_Destroy(attr);
+ OH_Sensor_DestroySubscriptionAttribute(attr);
}
}
HWTEST_F(SensorAgentTest, OH_Sensor_Subscribe_003, TestSize.Level1)
{
SEN_HILOGI("OH_Sensor_Subscribe_003 in");
- g_user = OH_Sensor_Subscriber_Create();
+ g_user = OH_Sensor_CreateSubscriber();
int32_t ret = OH_Sensor_Subscriber_SetCallback(g_user, SensorDataCallbackImpl);
ASSERT_EQ(ret, SENSOR_SUCCESS);
- Sensor_SubscriptionAttribute *attr = OH_Sensor_SubscriptionAttribute_Create();
+ Sensor_SubscriptionAttribute *attr = OH_Sensor_CreateSubscriptionAttribute();
ret = OH_Sensor_SubscriptionAttribute_SetSamplingInterval(attr, SENSOR_SAMPLE_PERIOD);
ASSERT_EQ(ret, SENSOR_SUCCESS);
ret = OH_Sensor_Subscribe(nullptr, attr, g_user);
ASSERT_EQ(ret, SENSOR_PARAMETER_ERROR);
if (attr != nullptr) {
- OH_Sensor_SubscriptionAttribute_Destroy(attr);
+ OH_Sensor_DestroySubscriptionAttribute(attr);
}
if (g_user != nullptr) {
- OH_Sensor_Subscriber_Destroy(g_user);
+ OH_Sensor_DestroySubscriber(g_user);
g_user = nullptr;
}
}
@@ -263,21 +263,21 @@ HWTEST_F(SensorAgentTest, OH_Sensor_Subscribe_003, TestSize.Level1)
HWTEST_F(SensorAgentTest, OH_Sensor_Subscribe_004, TestSize.Level1)
{
SEN_HILOGI("OH_Sensor_Subscribe_004 in");
- g_user = OH_Sensor_Subscriber_Create();
+ g_user = OH_Sensor_CreateSubscriber();
int32_t ret = OH_Sensor_Subscriber_SetCallback(g_user, SensorDataCallbackImpl);
ASSERT_EQ(ret, SENSOR_SUCCESS);
- Sensor_SubscriptionId *id = OH_Sensor_SubscriptionId_Create();
+ Sensor_SubscriptionId *id = OH_Sensor_CreateSubscriptionId();
ret = OH_Sensor_SubscriptionId_SetType(id, SENSOR_ID);
ASSERT_EQ(ret, SENSOR_SUCCESS);
ret = OH_Sensor_Subscribe(id, nullptr, g_user);
ASSERT_EQ(ret, SENSOR_PARAMETER_ERROR);
if (id != nullptr) {
- OH_Sensor_SubscriptionId_Destroy(id);
+ OH_Sensor_DestroySubscriptionId(id);
}
if (g_user != nullptr) {
- OH_Sensor_Subscriber_Destroy(g_user);
+ OH_Sensor_DestroySubscriber(g_user);
g_user = nullptr;
}
}
@@ -285,14 +285,14 @@ HWTEST_F(SensorAgentTest, OH_Sensor_Subscribe_004, TestSize.Level1)
HWTEST_F(SensorAgentTest, OH_Sensor_Unsubscribe_001, TestSize.Level1)
{
SEN_HILOGI("OH_Sensor_Unsubscribe_001 in");
- g_user = OH_Sensor_Subscriber_Create();
+ g_user = OH_Sensor_CreateSubscriber();
int32_t ret = OH_Sensor_Subscriber_SetCallback(g_user, SensorDataCallbackImpl);
ASSERT_EQ(ret, SENSOR_SUCCESS);
ret = OH_Sensor_Unsubscribe(nullptr, g_user);
ASSERT_EQ(ret, SENSOR_PARAMETER_ERROR);
if (g_user != nullptr) {
- OH_Sensor_Subscriber_Destroy(g_user);
+ OH_Sensor_DestroySubscriber(g_user);
g_user = nullptr;
}
}
@@ -300,14 +300,14 @@ HWTEST_F(SensorAgentTest, OH_Sensor_Unsubscribe_001, TestSize.Level1)
HWTEST_F(SensorAgentTest, OH_Sensor_Unsubscribe_002, TestSize.Level1)
{
SEN_HILOGI("OH_Sensor_Unsubscribe_002 in");
- Sensor_SubscriptionId *id = OH_Sensor_SubscriptionId_Create();
+ Sensor_SubscriptionId *id = OH_Sensor_CreateSubscriptionId();
int32_t ret = OH_Sensor_SubscriptionId_SetType(id, SENSOR_ID);
ASSERT_EQ(ret, SENSOR_SUCCESS);
ret = OH_Sensor_Unsubscribe(id, nullptr);
ASSERT_EQ(ret, SENSOR_PARAMETER_ERROR);
if (id != nullptr) {
- OH_Sensor_SubscriptionId_Destroy(id);
+ OH_Sensor_DestroySubscriptionId(id);
}
}
@@ -329,11 +329,11 @@ HWTEST_F(SensorAgentTest, OH_Sensor_SubscriptionId_GetType_001, TestSize.Level1)
HWTEST_F(SensorAgentTest, OH_Sensor_SubscriptionId_GetType_002, TestSize.Level1)
{
SEN_HILOGI("OH_Sensor_SubscriptionId_GetType_002 in");
- Sensor_SubscriptionId *id = OH_Sensor_SubscriptionId_Create();
+ Sensor_SubscriptionId *id = OH_Sensor_CreateSubscriptionId();
int32_t ret = OH_Sensor_SubscriptionId_GetType(id, nullptr);
ASSERT_EQ(ret, SENSOR_PARAMETER_ERROR);
if (id != nullptr) {
- OH_Sensor_SubscriptionId_Destroy(id);
+ OH_Sensor_DestroySubscriptionId(id);
}
}
@@ -350,11 +350,11 @@ HWTEST_F(SensorAgentTest, OH_Sensor_SubscriptionAttribute_SetSamplingInterval_00
TestSize.Level1)
{
SEN_HILOGI("OH_Sensor_SubscriptionAttribute_SetSamplingInterval_002 in");
- Sensor_SubscriptionAttribute *attr = OH_Sensor_SubscriptionAttribute_Create();
+ Sensor_SubscriptionAttribute *attr = OH_Sensor_CreateSubscriptionAttribute();
int32_t ret = OH_Sensor_SubscriptionAttribute_SetSamplingInterval(attr, INVALID_VALUE);
ASSERT_EQ(ret, SENSOR_PARAMETER_ERROR);
if (attr != nullptr) {
- OH_Sensor_SubscriptionAttribute_Destroy(attr);
+ OH_Sensor_DestroySubscriptionAttribute(attr);
}
}
@@ -372,11 +372,11 @@ HWTEST_F(SensorAgentTest, OH_Sensor_SubscriptionAttribute_GetSamplingInterval_00
TestSize.Level1)
{
SEN_HILOGI("OH_Sensor_SubscriptionAttribute_GetSamplingInterval_002 in");
- Sensor_SubscriptionAttribute *attr = OH_Sensor_SubscriptionAttribute_Create();
+ Sensor_SubscriptionAttribute *attr = OH_Sensor_CreateSubscriptionAttribute();
int32_t ret = OH_Sensor_SubscriptionAttribute_GetSamplingInterval(attr, nullptr);
ASSERT_EQ(ret, SENSOR_PARAMETER_ERROR);
if (attr != nullptr) {
- OH_Sensor_SubscriptionAttribute_Destroy(attr);
+ OH_Sensor_DestroySubscriptionAttribute(attr);
}
}
@@ -390,7 +390,7 @@ HWTEST_F(SensorAgentTest, OH_Sensor_Subscriber_SetCallback_001, TestSize.Level1)
HWTEST_F(SensorAgentTest, OH_Sensor_Subscriber_SetCallback_002, TestSize.Level1)
{
SEN_HILOGI("OH_Sensor_Subscriber_SetCallback_002 in");
- g_user = OH_Sensor_Subscriber_Create();
+ g_user = OH_Sensor_CreateSubscriber();
int32_t ret = OH_Sensor_Subscriber_SetCallback(g_user, nullptr);
ASSERT_EQ(ret, SENSOR_PARAMETER_ERROR);
}
@@ -406,11 +406,11 @@ HWTEST_F(SensorAgentTest, OH_Sensor_Subscriber_GetCallback_001, TestSize.Level1)
HWTEST_F(SensorAgentTest, OH_Sensor_Subscriber_GetCallback_002, TestSize.Level1)
{
SEN_HILOGI("OH_Sensor_Subscriber_GetCallback_002 in");
- g_user = OH_Sensor_Subscriber_Create();
+ g_user = OH_Sensor_CreateSubscriber();
int32_t ret = OH_Sensor_Subscriber_GetCallback(g_user, nullptr);
ASSERT_EQ(ret, SENSOR_PARAMETER_ERROR);
if (g_user != nullptr) {
- OH_Sensor_Subscriber_Destroy(g_user);
+ OH_Sensor_DestroySubscriber(g_user);
}
}
} // namespace Sensors