mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2025-02-25 08:51:18 +00:00
codecheck bugfix
Signed-off-by: majiajun <majiajun@huawei.com> Change-Id: I5dc76ba107ba944988792945304ec999cbdcf19b
This commit is contained in:
parent
0e36b18f2d
commit
1d854d4fcb
@ -239,11 +239,10 @@ NativeValue* JsContinuationManager::OnUnregisterDeviceSelectionCallback(NativeEn
|
||||
if (!IsCallbackRegistered(token, cbType)) {
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
CallbackPair& callbackPair = jsCbMap_[token][cbType];
|
||||
auto& listener = callbackPair.second;
|
||||
int32_t ret = DistributedAbilityManagerClient::GetInstance().UnregisterDeviceSelectionCallback(token, cbType);
|
||||
if (ret == ERR_OK) {
|
||||
listener->RemoveCallback(cbType);
|
||||
CallbackPair& callbackPair = jsCbMap_[token][cbType];
|
||||
callbackPair.second->RemoveCallback(cbType);
|
||||
jsCbMap_[token].erase(cbType);
|
||||
if (jsCbMap_[token].empty()) {
|
||||
jsCbMap_.erase(token);
|
||||
@ -458,7 +457,7 @@ bool JsContinuationManager::UnWrapContinuationExtraParams(const napi_env& env, c
|
||||
}
|
||||
|
||||
bool JsContinuationManager::UnwrapJsonByPropertyName(const napi_env& env, const napi_value& param,
|
||||
const std::string& field, nlohmann::json& jsonObject)
|
||||
const std::string& field, nlohmann::json& jsonObj)
|
||||
{
|
||||
HILOGD("called.");
|
||||
if (!IsTypeForNapiValue(env, param, napi_object)) {
|
||||
@ -477,7 +476,7 @@ bool JsContinuationManager::UnwrapJsonByPropertyName(const napi_env& env, const
|
||||
uint32_t jsProCount = 0;
|
||||
napi_get_property_names(env, jsonField, &jsProNameList);
|
||||
napi_get_array_length(env, jsProNameList, &jsProCount);
|
||||
if (!PraseJson(env, jsonField, jsProNameList, jsProCount, jsonObject)) {
|
||||
if (!PraseJson(env, jsonField, jsProNameList, jsProCount, jsonObj)) {
|
||||
HILOGE("PraseJson failed.");
|
||||
return false;
|
||||
}
|
||||
@ -485,7 +484,7 @@ bool JsContinuationManager::UnwrapJsonByPropertyName(const napi_env& env, const
|
||||
}
|
||||
|
||||
bool JsContinuationManager::PraseJson(const napi_env& env, const napi_value& jsonField,
|
||||
const napi_value& jsProNameList, uint32_t jsProCount, nlohmann::json& jsonObject)
|
||||
const napi_value& jsProNameList, uint32_t jsProCount, nlohmann::json& jsonObj)
|
||||
{
|
||||
napi_value jsProName = nullptr;
|
||||
napi_value jsProValue = nullptr;
|
||||
@ -499,14 +498,14 @@ bool JsContinuationManager::PraseJson(const napi_env& env, const napi_value& jso
|
||||
case napi_string: {
|
||||
std::string elementValue = UnwrapStringFromJS(env, jsProValue);
|
||||
HILOGI("Property name=%{public}s, string, value=%{public}s", strProName.c_str(), elementValue.c_str());
|
||||
jsonObject[strProName] = elementValue;
|
||||
jsonObj[strProName] = elementValue;
|
||||
break;
|
||||
}
|
||||
case napi_boolean: {
|
||||
bool elementValue = false;
|
||||
napi_get_value_bool(env, jsProValue, &elementValue);
|
||||
HILOGI("Property name=%{public}s, boolean, value=%{public}d.", strProName.c_str(), elementValue);
|
||||
jsonObject[strProName] = elementValue;
|
||||
jsonObj[strProName] = elementValue;
|
||||
break;
|
||||
}
|
||||
case napi_number: {
|
||||
@ -515,7 +514,7 @@ bool JsContinuationManager::PraseJson(const napi_env& env, const napi_value& jso
|
||||
HILOGE("Property name=%{public}s, Property int32_t parse error", strProName.c_str());
|
||||
} else {
|
||||
HILOGI("Property name=%{public}s, number, value=%{public}d.", strProName.c_str(), elementValue);
|
||||
jsonObject[strProName] = elementValue;
|
||||
jsonObj[strProName] = elementValue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -52,15 +52,15 @@ private:
|
||||
NativeValue* OnStartDeviceManager(NativeEngine &engine, NativeCallbackInfo &info);
|
||||
NativeValue* OnInitDeviceConnectStateObject(NativeEngine &engine, NativeCallbackInfo &info);
|
||||
NativeValue* OnInitContinuationModeObject(NativeEngine &engine, NativeCallbackInfo &info);
|
||||
napi_status SetEnumItem(const napi_env& env, napi_value object, const char* name, int32_t value);
|
||||
static napi_status SetEnumItem(const napi_env& env, napi_value object, const char* name, int32_t value);
|
||||
|
||||
bool IsCallbackValid(NativeValue* listenerObj);
|
||||
static bool IsCallbackValid(NativeValue* listenerObj);
|
||||
bool IsCallbackRegistered(int32_t token, const std::string& cbType);
|
||||
bool UnWrapContinuationExtraParams(const napi_env& env, const napi_value& options,
|
||||
std::shared_ptr<ContinuationExtraParams>& continuationExtraParams);
|
||||
bool UnwrapJsonByPropertyName(const napi_env& env, const napi_value& param,
|
||||
const std::string& fieldStr, nlohmann::json& jsonObj);
|
||||
bool PraseJson(const napi_env& env, const napi_value& jsonField, const napi_value& jsProNameList,
|
||||
const std::string& field, nlohmann::json& jsonObj);
|
||||
static bool PraseJson(const napi_env& env, const napi_value& jsonField, const napi_value& jsProNameList,
|
||||
uint32_t jsProCount, nlohmann::json& jsonObj);
|
||||
|
||||
std::mutex jsCbMapMutex_;
|
||||
|
@ -100,7 +100,6 @@ private:
|
||||
bool DeleteInnerLocked(const std::string& uuid, int32_t missionId);
|
||||
bool FuzzyDeleteInnerLocked(const std::string& networkId);
|
||||
bool QueryInnerLocked(const std::string& uuid, int32_t missionId, DistributedKv::Value& value) const;
|
||||
bool InitHandler();
|
||||
static void GenerateKey(const std::string& uuid, int32_t missionId, DistributedKv::Key& key);
|
||||
static void GenerateValue(const uint8_t* byteStream, size_t len, DistributedKv::Value& value);
|
||||
|
||||
|
@ -90,7 +90,7 @@ public:
|
||||
int32_t StartSyncMissionsFromRemote(const CallerInfo& callerInfo, std::vector<DstbMissionInfo>& missionInfos);
|
||||
int32_t StopSyncRemoteMissions(const std::string& dstDevId, bool offline, bool exit = false);
|
||||
void StopSyncMissionsFromRemote(const std::string& deviceId);
|
||||
bool needSyncDevice(const std::string& deviceId);
|
||||
bool NeedSyncDevice(const std::string& deviceId);
|
||||
|
||||
void NotifySnapshotChanged(const std::string& networkId, int32_t missionId);
|
||||
void OnRemoteDied(const wptr<IRemoteObject>& remote);
|
||||
|
@ -127,7 +127,7 @@ bool BundleManagerInternal::QueryExtensionAbilityInfo(const AAFwk::Want& want,
|
||||
std::vector<AppExecFwk::ExtensionAbilityInfo> extensionInfos;
|
||||
bundleMgr->QueryExtensionAbilityInfos(want, AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_DEFAULT
|
||||
| AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_PERMISSION, ids[0], extensionInfos);
|
||||
if (extensionInfos.size() <= 0) {
|
||||
if (extensionInfos.empty()) {
|
||||
HILOGE("QueryExtensionAbilityInfo failed.");
|
||||
return false;
|
||||
}
|
||||
|
@ -52,12 +52,11 @@ bool DistributedDataStorage::Init()
|
||||
if (kvStoreDeathRecipient_ == nullptr) {
|
||||
kvStoreDeathRecipient_ = sptr<IRemoteObject::DeathRecipient>(new KvStoreDeathRecipient());
|
||||
}
|
||||
bool ret = InitHandler();
|
||||
if (!ret) {
|
||||
HILOGE("InitHandler failed!");
|
||||
return false;
|
||||
if (dmsDataStorageHandler_ == nullptr) {
|
||||
shared_ptr<AppExecFwk::EventRunner> runner = AppExecFwk::EventRunner::Create("dmsDataStorageHandler");
|
||||
dmsDataStorageHandler_ = make_shared<AppExecFwk::EventHandler>(runner);
|
||||
}
|
||||
ret = InitKvDataService();
|
||||
int32_t ret = InitKvDataService();
|
||||
if (!ret) {
|
||||
HILOGE("InitKvDataService failed!");
|
||||
return false;
|
||||
@ -175,19 +174,6 @@ void DistributedDataStorage::SubscribeDistributedDataStorage()
|
||||
}
|
||||
}
|
||||
|
||||
bool DistributedDataStorage::InitHandler()
|
||||
{
|
||||
if (dmsDataStorageHandler_ == nullptr) {
|
||||
shared_ptr<AppExecFwk::EventRunner> runner = AppExecFwk::EventRunner::Create("dmsDataStorageHandler");
|
||||
dmsDataStorageHandler_ = make_shared<AppExecFwk::EventHandler>(runner);
|
||||
}
|
||||
if (dmsDataStorageHandler_ == nullptr) {
|
||||
HILOGW("dmsDataStorageHandler_ is null!");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void DistributedDataStorage::NotifyRemoteDied(const wptr<IRemoteObject>& remote)
|
||||
{
|
||||
HILOGD("begin.");
|
||||
|
@ -540,7 +540,7 @@ void DistributedSchedMissionManager::StopSyncMissionsFromRemote(const std::strin
|
||||
}
|
||||
}
|
||||
|
||||
bool DistributedSchedMissionManager::needSyncDevice(const std::string& deviceId)
|
||||
bool DistributedSchedMissionManager::NeedSyncDevice(const std::string& deviceId)
|
||||
{
|
||||
std::lock_guard<std::mutex> autoLock(remoteSyncDeviceLock_);
|
||||
if (remoteSyncDeviceSet_.count(deviceId) == 0) {
|
||||
|
@ -357,7 +357,7 @@ HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions014, TestSize.Level3)
|
||||
HWTEST_F(DMSMissionManagerTest, testNeedSyncDevice001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "testCleanMissionResources001 begin" << std::endl;
|
||||
bool ret = DistributedSchedMissionManager::GetInstance().needSyncDevice(DEVICE_ID);
|
||||
bool ret = DistributedSchedMissionManager::GetInstance().NeedSyncDevice(DEVICE_ID);
|
||||
EXPECT_EQ(false, ret);
|
||||
DTEST_LOG << "testNeedSyncDevice001 end" << std::endl;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user