Alarm modification

Signed-off-by: bailu1992 <bailu27@huawei.com>
This commit is contained in:
bailu1992 2024-11-21 23:25:42 +08:00
parent a22832416d
commit 977aff981c
9 changed files with 22 additions and 11 deletions

View File

@ -86,6 +86,10 @@ static bool copySensorData(sptr<AsyncCallbackInfo> callbackInfo, SensorEvent *ev
(fabs(g_bodyState - BODY_STATE_EXCEPT) < THRESHOLD) ? true : false;
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),
data, event->dataLen) != EOK) {
SEN_HILOGE("Copy data failed");

View File

@ -29,7 +29,7 @@ napi_value CreateBusinessError(const napi_env &env, const int32_t errCode, const
napi_value msg = nullptr;
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_create_error(env, nullptr, msg, &businessError);
NAPI_CALL(env, napi_create_error(env, nullptr, msg, &businessError));
napi_set_named_property(env, businessError, "code", code);
return businessError;
}

View File

@ -61,7 +61,7 @@ bool GetFloatArray(const napi_env &env, const napi_value &value, vector<float> &
CALL_LOG_ENTER;
uint32_t arrayLength = 0;
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;
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");

View File

@ -21,7 +21,6 @@
#include "sensor_errors.h"
#include "sensor_utils.h"
using namespace std;
using namespace OHOS::Sensors;
namespace {
constexpr float EARTH_MAJOR_AXIS_RADIUS = 6378.137f;

View File

@ -36,7 +36,7 @@ namespace {
#ifdef BUILD_VARIANT_ENG
constexpr float MAX_RANGE = 9999.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 MAX_SAMPLE_PERIOD_NS = 1000000000;
const std::string VERSION_NAME = "1.0.1";
@ -140,7 +140,7 @@ Sensor SensorHdiConnection::GenerateColorSensor()
sensorColor.SetMaxRange(MAX_RANGE);
sensorColor.SetSensorName("sensor_color");
sensorColor.SetVendorName("default_color");
sensorColor.SetResolution(RESOLITION);
sensorColor.SetResolution(RESOLUTION);
sensorColor.SetPower(POWER);
sensorColor.SetMinSamplePeriodNs(MIN_SAMPLE_PERIOD_NS);
sensorColor.SetMaxSamplePeriodNs(MAX_SAMPLE_PERIOD_NS);
@ -157,7 +157,7 @@ Sensor SensorHdiConnection::GenerateSarSensor()
sensorSar.SetMaxRange(MAX_RANGE);
sensorSar.SetSensorName("sensor_sar");
sensorSar.SetVendorName("default_sar");
sensorSar.SetResolution(RESOLITION);
sensorSar.SetResolution(RESOLUTION);
sensorSar.SetPower(POWER);
sensorSar.SetMinSamplePeriodNs(MIN_SAMPLE_PERIOD_NS);
sensorSar.SetMaxSamplePeriodNs(MAX_SAMPLE_PERIOD_NS);
@ -174,7 +174,7 @@ Sensor SensorHdiConnection::GenerateHeadPostureSensor()
sensorHeadPosture.SetMaxRange(MAX_RANGE);
sensorHeadPosture.SetSensorName("sensor_headPosture");
sensorHeadPosture.SetVendorName("default_headPosture");
sensorHeadPosture.SetResolution(RESOLITION);
sensorHeadPosture.SetResolution(RESOLUTION);
sensorHeadPosture.SetPower(POWER);
sensorHeadPosture.SetMinSamplePeriodNs(MIN_SAMPLE_PERIOD_NS);
sensorHeadPosture.SetMaxSamplePeriodNs(MAX_SAMPLE_PERIOD_NS);
@ -191,7 +191,7 @@ Sensor SensorHdiConnection::GenerateProximitySensor()
sensorProximity.SetMaxRange(MAX_RANGE);
sensorProximity.SetSensorName("sensor_proximity1");
sensorProximity.SetVendorName("default_proximity1");
sensorProximity.SetResolution(RESOLITION);
sensorProximity.SetResolution(RESOLUTION);
sensorProximity.SetPower(POWER);
sensorProximity.SetMinSamplePeriodNs(MIN_SAMPLE_PERIOD_NS);
sensorProximity.SetMaxSamplePeriodNs(MAX_SAMPLE_PERIOD_NS);

View File

@ -37,6 +37,10 @@ StreamServer::~StreamServer()
std::lock_guard<std::mutex> sessionLock(sessionMutex_);
idxPidMap_.clear();
for (const auto &item : sessionsMap_) {
if (item.second == nullptr) {
SEN_HILOGE("SessionPtr is null");
continue;
}
item.second->Close();
}
sessionsMap_.clear();

View File

@ -40,10 +40,11 @@ std::unordered_map<int32_t, std::string> PermissionUtil::sensorPermissions_ = {
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;
}
std::string permissionName = sensorPermissions_[sensorTypeId];
std::string permissionName = iter->second;
int32_t ret = AccessTokenKit::VerifyAccessToken(callerToken, permissionName);
if ((permissionName == ACTIVITY_MOTION_PERMISSION)
|| (permissionName == READ_HEALTH_DATA_PERMISSION)) {

View File

@ -24,7 +24,9 @@ StreamBuffer::StreamBuffer(const StreamBuffer &buf)
StreamBuffer &StreamBuffer::operator=(const StreamBuffer &other)
{
Clone(other);
if (this != &other) {
Clone(other);
}
return *this;
}

View File

@ -143,6 +143,7 @@ int32_t VibrationConvertCore::ResampleAudioData(const std::vector<double> &srcDa
}
size_t originDataSize = srcDatas.size();
srcAudioDatas_.clear();
srcAudioDatas_.reserve(originDataSize);
for (size_t i = 0; i < (originDataSize - 1); i += RESAMPLE_MULTIPLE) {
srcAudioDatas_.push_back(srcDatas[i]);
srcAudioDatas_.push_back(srcDatas[i+1]);