mirror of
https://gitee.com/openharmony/sensors_sensor
synced 2024-11-23 06:29:42 +00:00
Alarm modification
Signed-off-by: bailu1992 <bailu27@huawei.com>
This commit is contained in:
parent
a22832416d
commit
977aff981c
@ -86,6 +86,10 @@ static bool copySensorData(sptr<AsyncCallbackInfo> callbackInfo, SensorEvent *ev
|
|||||||
(fabs(g_bodyState - BODY_STATE_EXCEPT) < THRESHOLD) ? true : false;
|
(fabs(g_bodyState - BODY_STATE_EXCEPT) < THRESHOLD) ? true : false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (sizeof(callbackInfo->data.sensorData.data) < event->dataLen) {
|
||||||
|
SEN_HILOGE("callbackInfo space is insufficient");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (memcpy_s(callbackInfo->data.sensorData.data, sizeof(callbackInfo->data.sensorData.data),
|
if (memcpy_s(callbackInfo->data.sensorData.data, sizeof(callbackInfo->data.sensorData.data),
|
||||||
data, event->dataLen) != EOK) {
|
data, event->dataLen) != EOK) {
|
||||||
SEN_HILOGE("Copy data failed");
|
SEN_HILOGE("Copy data failed");
|
||||||
|
@ -29,7 +29,7 @@ napi_value CreateBusinessError(const napi_env &env, const int32_t errCode, const
|
|||||||
napi_value msg = nullptr;
|
napi_value msg = nullptr;
|
||||||
NAPI_CALL(env, napi_create_int32(env, errCode, &code));
|
NAPI_CALL(env, napi_create_int32(env, errCode, &code));
|
||||||
NAPI_CALL(env, napi_create_string_utf8(env, errMessage.c_str(), NAPI_AUTO_LENGTH, &msg));
|
NAPI_CALL(env, napi_create_string_utf8(env, errMessage.c_str(), NAPI_AUTO_LENGTH, &msg));
|
||||||
napi_create_error(env, nullptr, msg, &businessError);
|
NAPI_CALL(env, napi_create_error(env, nullptr, msg, &businessError));
|
||||||
napi_set_named_property(env, businessError, "code", code);
|
napi_set_named_property(env, businessError, "code", code);
|
||||||
return businessError;
|
return businessError;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ bool GetFloatArray(const napi_env &env, const napi_value &value, vector<float> &
|
|||||||
CALL_LOG_ENTER;
|
CALL_LOG_ENTER;
|
||||||
uint32_t arrayLength = 0;
|
uint32_t arrayLength = 0;
|
||||||
CHKNRF(env, napi_get_array_length(env, value, &arrayLength), "napi_get_array_length");
|
CHKNRF(env, napi_get_array_length(env, value, &arrayLength), "napi_get_array_length");
|
||||||
for (size_t i = 0; i < arrayLength; ++i) {
|
for (uint32_t i = 0; i < arrayLength; ++i) {
|
||||||
napi_value element = nullptr;
|
napi_value element = nullptr;
|
||||||
CHKNRF(env, napi_get_element(env, value, i, &element), "napi_get_element");
|
CHKNRF(env, napi_get_element(env, value, i, &element), "napi_get_element");
|
||||||
CHKNCF(env, IsMatchType(env, element, napi_number), "Wrong argument type. Number or function expected");
|
CHKNCF(env, IsMatchType(env, element, napi_number), "Wrong argument type. Number or function expected");
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
#include "sensor_errors.h"
|
#include "sensor_errors.h"
|
||||||
#include "sensor_utils.h"
|
#include "sensor_utils.h"
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
using namespace OHOS::Sensors;
|
using namespace OHOS::Sensors;
|
||||||
namespace {
|
namespace {
|
||||||
constexpr float EARTH_MAJOR_AXIS_RADIUS = 6378.137f;
|
constexpr float EARTH_MAJOR_AXIS_RADIUS = 6378.137f;
|
||||||
|
@ -36,7 +36,7 @@ namespace {
|
|||||||
#ifdef BUILD_VARIANT_ENG
|
#ifdef BUILD_VARIANT_ENG
|
||||||
constexpr float MAX_RANGE = 9999.0;
|
constexpr float MAX_RANGE = 9999.0;
|
||||||
constexpr float POWER = 20.0;
|
constexpr float POWER = 20.0;
|
||||||
constexpr float RESOLITION = 0.000001;
|
constexpr float RESOLUTION = 0.000001;
|
||||||
constexpr float MIN_SAMPLE_PERIOD_NS = 100000000;
|
constexpr float MIN_SAMPLE_PERIOD_NS = 100000000;
|
||||||
constexpr float MAX_SAMPLE_PERIOD_NS = 1000000000;
|
constexpr float MAX_SAMPLE_PERIOD_NS = 1000000000;
|
||||||
const std::string VERSION_NAME = "1.0.1";
|
const std::string VERSION_NAME = "1.0.1";
|
||||||
@ -140,7 +140,7 @@ Sensor SensorHdiConnection::GenerateColorSensor()
|
|||||||
sensorColor.SetMaxRange(MAX_RANGE);
|
sensorColor.SetMaxRange(MAX_RANGE);
|
||||||
sensorColor.SetSensorName("sensor_color");
|
sensorColor.SetSensorName("sensor_color");
|
||||||
sensorColor.SetVendorName("default_color");
|
sensorColor.SetVendorName("default_color");
|
||||||
sensorColor.SetResolution(RESOLITION);
|
sensorColor.SetResolution(RESOLUTION);
|
||||||
sensorColor.SetPower(POWER);
|
sensorColor.SetPower(POWER);
|
||||||
sensorColor.SetMinSamplePeriodNs(MIN_SAMPLE_PERIOD_NS);
|
sensorColor.SetMinSamplePeriodNs(MIN_SAMPLE_PERIOD_NS);
|
||||||
sensorColor.SetMaxSamplePeriodNs(MAX_SAMPLE_PERIOD_NS);
|
sensorColor.SetMaxSamplePeriodNs(MAX_SAMPLE_PERIOD_NS);
|
||||||
@ -157,7 +157,7 @@ Sensor SensorHdiConnection::GenerateSarSensor()
|
|||||||
sensorSar.SetMaxRange(MAX_RANGE);
|
sensorSar.SetMaxRange(MAX_RANGE);
|
||||||
sensorSar.SetSensorName("sensor_sar");
|
sensorSar.SetSensorName("sensor_sar");
|
||||||
sensorSar.SetVendorName("default_sar");
|
sensorSar.SetVendorName("default_sar");
|
||||||
sensorSar.SetResolution(RESOLITION);
|
sensorSar.SetResolution(RESOLUTION);
|
||||||
sensorSar.SetPower(POWER);
|
sensorSar.SetPower(POWER);
|
||||||
sensorSar.SetMinSamplePeriodNs(MIN_SAMPLE_PERIOD_NS);
|
sensorSar.SetMinSamplePeriodNs(MIN_SAMPLE_PERIOD_NS);
|
||||||
sensorSar.SetMaxSamplePeriodNs(MAX_SAMPLE_PERIOD_NS);
|
sensorSar.SetMaxSamplePeriodNs(MAX_SAMPLE_PERIOD_NS);
|
||||||
@ -174,7 +174,7 @@ Sensor SensorHdiConnection::GenerateHeadPostureSensor()
|
|||||||
sensorHeadPosture.SetMaxRange(MAX_RANGE);
|
sensorHeadPosture.SetMaxRange(MAX_RANGE);
|
||||||
sensorHeadPosture.SetSensorName("sensor_headPosture");
|
sensorHeadPosture.SetSensorName("sensor_headPosture");
|
||||||
sensorHeadPosture.SetVendorName("default_headPosture");
|
sensorHeadPosture.SetVendorName("default_headPosture");
|
||||||
sensorHeadPosture.SetResolution(RESOLITION);
|
sensorHeadPosture.SetResolution(RESOLUTION);
|
||||||
sensorHeadPosture.SetPower(POWER);
|
sensorHeadPosture.SetPower(POWER);
|
||||||
sensorHeadPosture.SetMinSamplePeriodNs(MIN_SAMPLE_PERIOD_NS);
|
sensorHeadPosture.SetMinSamplePeriodNs(MIN_SAMPLE_PERIOD_NS);
|
||||||
sensorHeadPosture.SetMaxSamplePeriodNs(MAX_SAMPLE_PERIOD_NS);
|
sensorHeadPosture.SetMaxSamplePeriodNs(MAX_SAMPLE_PERIOD_NS);
|
||||||
@ -191,7 +191,7 @@ Sensor SensorHdiConnection::GenerateProximitySensor()
|
|||||||
sensorProximity.SetMaxRange(MAX_RANGE);
|
sensorProximity.SetMaxRange(MAX_RANGE);
|
||||||
sensorProximity.SetSensorName("sensor_proximity1");
|
sensorProximity.SetSensorName("sensor_proximity1");
|
||||||
sensorProximity.SetVendorName("default_proximity1");
|
sensorProximity.SetVendorName("default_proximity1");
|
||||||
sensorProximity.SetResolution(RESOLITION);
|
sensorProximity.SetResolution(RESOLUTION);
|
||||||
sensorProximity.SetPower(POWER);
|
sensorProximity.SetPower(POWER);
|
||||||
sensorProximity.SetMinSamplePeriodNs(MIN_SAMPLE_PERIOD_NS);
|
sensorProximity.SetMinSamplePeriodNs(MIN_SAMPLE_PERIOD_NS);
|
||||||
sensorProximity.SetMaxSamplePeriodNs(MAX_SAMPLE_PERIOD_NS);
|
sensorProximity.SetMaxSamplePeriodNs(MAX_SAMPLE_PERIOD_NS);
|
||||||
|
@ -37,6 +37,10 @@ StreamServer::~StreamServer()
|
|||||||
std::lock_guard<std::mutex> sessionLock(sessionMutex_);
|
std::lock_guard<std::mutex> sessionLock(sessionMutex_);
|
||||||
idxPidMap_.clear();
|
idxPidMap_.clear();
|
||||||
for (const auto &item : sessionsMap_) {
|
for (const auto &item : sessionsMap_) {
|
||||||
|
if (item.second == nullptr) {
|
||||||
|
SEN_HILOGE("SessionPtr is null");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
item.second->Close();
|
item.second->Close();
|
||||||
}
|
}
|
||||||
sessionsMap_.clear();
|
sessionsMap_.clear();
|
||||||
|
@ -40,10 +40,11 @@ std::unordered_map<int32_t, std::string> PermissionUtil::sensorPermissions_ = {
|
|||||||
|
|
||||||
int32_t PermissionUtil::CheckSensorPermission(AccessTokenID callerToken, int32_t sensorTypeId)
|
int32_t PermissionUtil::CheckSensorPermission(AccessTokenID callerToken, int32_t sensorTypeId)
|
||||||
{
|
{
|
||||||
if (sensorPermissions_.find(sensorTypeId) == sensorPermissions_.end()) {
|
auto iter = sensorPermissions_.find(sensorTypeId);
|
||||||
|
if (iter == sensorPermissions_.end()) {
|
||||||
return PERMISSION_GRANTED;
|
return PERMISSION_GRANTED;
|
||||||
}
|
}
|
||||||
std::string permissionName = sensorPermissions_[sensorTypeId];
|
std::string permissionName = iter->second;
|
||||||
int32_t ret = AccessTokenKit::VerifyAccessToken(callerToken, permissionName);
|
int32_t ret = AccessTokenKit::VerifyAccessToken(callerToken, permissionName);
|
||||||
if ((permissionName == ACTIVITY_MOTION_PERMISSION)
|
if ((permissionName == ACTIVITY_MOTION_PERMISSION)
|
||||||
|| (permissionName == READ_HEALTH_DATA_PERMISSION)) {
|
|| (permissionName == READ_HEALTH_DATA_PERMISSION)) {
|
||||||
|
@ -24,7 +24,9 @@ StreamBuffer::StreamBuffer(const StreamBuffer &buf)
|
|||||||
|
|
||||||
StreamBuffer &StreamBuffer::operator=(const StreamBuffer &other)
|
StreamBuffer &StreamBuffer::operator=(const StreamBuffer &other)
|
||||||
{
|
{
|
||||||
Clone(other);
|
if (this != &other) {
|
||||||
|
Clone(other);
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,6 +143,7 @@ int32_t VibrationConvertCore::ResampleAudioData(const std::vector<double> &srcDa
|
|||||||
}
|
}
|
||||||
size_t originDataSize = srcDatas.size();
|
size_t originDataSize = srcDatas.size();
|
||||||
srcAudioDatas_.clear();
|
srcAudioDatas_.clear();
|
||||||
|
srcAudioDatas_.reserve(originDataSize);
|
||||||
for (size_t i = 0; i < (originDataSize - 1); i += RESAMPLE_MULTIPLE) {
|
for (size_t i = 0; i < (originDataSize - 1); i += RESAMPLE_MULTIPLE) {
|
||||||
srcAudioDatas_.push_back(srcDatas[i]);
|
srcAudioDatas_.push_back(srcDatas[i]);
|
||||||
srcAudioDatas_.push_back(srcDatas[i+1]);
|
srcAudioDatas_.push_back(srcDatas[i+1]);
|
||||||
|
Loading…
Reference in New Issue
Block a user