mirror of
https://gitee.com/openharmony/applications_settings
synced 2024-11-23 06:20:01 +00:00
[settings]AI检视意见CodeCity清理
Signed-off-by: 杨云鹏 <yangyunpeng7@huawei.com>
This commit is contained in:
parent
8b45884a9b
commit
a159378c9c
@ -251,7 +251,10 @@ napi_value napi_get_uri(napi_env env, napi_callback_info info)
|
||||
.uri = "",
|
||||
.status = false,
|
||||
};
|
||||
|
||||
if (asyncCallbackInfo == nullptr) {
|
||||
SETTING_LOG_ERROR("asyncCallbackInfo is null");
|
||||
return wrap_void_to_js(env);
|
||||
}
|
||||
std::string keyStr = unwrap_string_from_js(env, args[PARAM0]);
|
||||
// get userId string
|
||||
std::vector<int> tmpId;
|
||||
@ -759,7 +762,10 @@ napi_value napi_get_value(napi_env env, napi_callback_info info)
|
||||
.uri = "",
|
||||
.status = false,
|
||||
};
|
||||
|
||||
if (asyncCallbackInfo == nullptr) {
|
||||
SETTING_LOG_ERROR("asyncCallbackInfo is null");
|
||||
return wrap_void_to_js(env);
|
||||
}
|
||||
if (wrapper != nullptr) {
|
||||
asyncCallbackInfo->dataAbilityHelper = wrapper->GetDataAbilityHelper();
|
||||
}
|
||||
@ -915,7 +921,10 @@ napi_value napi_get_value_ext(napi_env env, napi_callback_info info, const bool
|
||||
.uri = "",
|
||||
.status = false,
|
||||
};
|
||||
|
||||
if (asyncCallbackInfo == nullptr) {
|
||||
SETTING_LOG_ERROR("asyncCallbackInfo is null");
|
||||
return wrap_void_to_js(env);
|
||||
}
|
||||
asyncCallbackInfo->dataShareHelper = getDataShareHelper(env, args[PARAM0], stageMode);
|
||||
|
||||
asyncCallbackInfo->key = unwrap_string_from_js(env, args[PARAM1]);
|
||||
@ -1311,7 +1320,10 @@ napi_value napi_set_value(napi_env env, napi_callback_info info)
|
||||
.uri = "",
|
||||
.status = false,
|
||||
};
|
||||
|
||||
if (asyncCallbackInfo == nullptr) {
|
||||
SETTING_LOG_ERROR("asyncCallbackInfo is null");
|
||||
return wrap_void_to_js(env);
|
||||
}
|
||||
if (wrapper != nullptr) {
|
||||
asyncCallbackInfo->dataAbilityHelper = wrapper->GetDataAbilityHelper();
|
||||
}
|
||||
@ -1351,7 +1363,10 @@ napi_value napi_set_value_ext(napi_env env, napi_callback_info info, const bool
|
||||
.uri = "",
|
||||
.status = false,
|
||||
};
|
||||
|
||||
if (asyncCallbackInfo == nullptr) {
|
||||
SETTING_LOG_ERROR("asyncCallbackInfo is null");
|
||||
return wrap_void_to_js(env);
|
||||
}
|
||||
asyncCallbackInfo->dataShareHelper = getDataShareHelper(env, args[PARAM0], stageMode);
|
||||
asyncCallbackInfo->key = unwrap_string_from_js(env, args[PARAM1]);
|
||||
asyncCallbackInfo->uri = unwrap_string_from_js(env, args[PARAM2]); //temp
|
||||
@ -1492,7 +1507,10 @@ napi_value napi_enable_airplane_mode(napi_env env, napi_callback_info info)
|
||||
.uri = "",
|
||||
.status = 0,
|
||||
};
|
||||
|
||||
if (asyncCallbackInfo == nullptr) {
|
||||
SETTING_LOG_ERROR("asyncCallbackInfo is null");
|
||||
return wrap_void_to_js(env);
|
||||
}
|
||||
if (argc == paramOfCallback) {
|
||||
SETTING_LOG_INFO("%{public}s, asyncCallback.", __func__);
|
||||
|
||||
@ -1622,7 +1640,10 @@ napi_value napi_can_show_floating(napi_env env, napi_callback_info info)
|
||||
.uri = "",
|
||||
.status = 0,
|
||||
};
|
||||
|
||||
if (asyncCallbackInfo == nullptr) {
|
||||
SETTING_LOG_ERROR("asyncCallbackInfo is null");
|
||||
return wrap_void_to_js(env);
|
||||
}
|
||||
napi_value resource = nullptr;
|
||||
NAPI_CALL(env, napi_create_string_utf8(env, "enableAirplaneMode", NAPI_AUTO_LENGTH, &resource));
|
||||
|
||||
@ -1846,6 +1867,10 @@ napi_value napi_set_value_sync_ext(bool stageMode, size_t argc, napi_env env, na
|
||||
{
|
||||
SETTING_LOG_INFO("argv[0] is a context, Stage Model: %{public}d", stageMode);
|
||||
AsyncCallbackInfo *asyncCallbackInfo = new AsyncCallbackInfo();
|
||||
if (asyncCallbackInfo == nullptr) {
|
||||
SETTING_LOG_ERROR("asyncCallbackInfo is null");
|
||||
return wrap_void_to_js(env);
|
||||
}
|
||||
asyncCallbackInfo->key = unwrap_string_from_js(env, args[PARAM1]);
|
||||
napi_valuetype valueType;
|
||||
|
||||
|
@ -34,9 +34,13 @@ using namespace OHOS::AccountSA;
|
||||
namespace OHOS {
|
||||
namespace Settings {
|
||||
std::map<std::string, sptr<SettingsObserver>> g_observerMap;
|
||||
std::mutex g_observerMapMutex;
|
||||
|
||||
SettingsObserver::~SettingsObserver()
|
||||
{
|
||||
if (this->cbInfo == nullptr) {
|
||||
return;
|
||||
}
|
||||
delete this->cbInfo;
|
||||
this->cbInfo = nullptr;
|
||||
}
|
||||
@ -163,12 +167,17 @@ namespace Settings {
|
||||
return wrap_bool_to_js(env, false);
|
||||
}
|
||||
AsyncCallbackInfo *callbackInfo = new AsyncCallbackInfo();
|
||||
if (callbackInfo == nullptr) {
|
||||
SETTING_LOG_ERROR("%{public}s, failed to get callbackInfo.", __func__);
|
||||
return wrap_bool_to_js(env, false);
|
||||
}
|
||||
|
||||
callbackInfo->env = env;
|
||||
callbackInfo->key = unwrap_string_from_js(env, args[PARAM1]);
|
||||
callbackInfo->tableName = unwrap_string_from_js(env, args[PARAM2]);
|
||||
napi_create_reference(env, args[PARAM3], 1, &(callbackInfo->callbackRef));
|
||||
|
||||
std::lock_guard<std::mutex> lockGuard(g_observerMapMutex);
|
||||
if (g_observerMap.find(callbackInfo->key) != g_observerMap.end() &&
|
||||
g_observerMap[callbackInfo->key] != nullptr) {
|
||||
SETTING_LOG_INFO("%{public}s, already registered.", __func__);
|
||||
@ -225,6 +234,7 @@ namespace Settings {
|
||||
std::string key = unwrap_string_from_js(env, args[PARAM1]);
|
||||
std::string tableName = unwrap_string_from_js(env, args[PARAM2]);
|
||||
|
||||
std::lock_guard<std::mutex> lockGuard(g_observerMapMutex);
|
||||
if (g_observerMap.find(key) == g_observerMap.end()) {
|
||||
SETTING_LOG_ERROR("%{public}s, null.", __func__);
|
||||
return wrap_bool_to_js(env, false);
|
||||
|
@ -30,7 +30,7 @@ EXTERN_C_START
|
||||
*/
|
||||
static napi_value Init(napi_env env, napi_value exports)
|
||||
{
|
||||
SETTING_LOG_INFO("napi_moudule Init start...");
|
||||
SETTING_LOG_INFO("napi_module Init start...");
|
||||
|
||||
napi_property_descriptor desc[] = {
|
||||
DECLARE_NAPI_FUNCTION("getURI", napi_get_uri),
|
||||
@ -49,7 +49,7 @@ static napi_value Init(napi_env env, napi_value exports)
|
||||
// init settings class
|
||||
NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc));
|
||||
InitNapiClass(env, exports);
|
||||
SETTING_LOG_INFO("napi_moudule Init end...");
|
||||
SETTING_LOG_INFO("napi_module Init end...");
|
||||
return exports;
|
||||
}
|
||||
EXTERN_C_END
|
||||
|
Loading…
Reference in New Issue
Block a user