From ed60236831c354407b68eb0d0994e5864bb0bbc5 Mon Sep 17 00:00:00 2001 From: fangJinliang1 Date: Mon, 19 Sep 2022 22:27:21 +0800 Subject: [PATCH] log level update Signed-off-by: fangJinliang1 Change-Id: I45ccaafcb4682fdac8871242df37d24055d42dde Signed-off-by: fangJinliang1 --- frameworks/js/napi/src/common.cpp | 19 ++++++++++--------- services/ans/src/access_token_helper.cpp | 2 +- .../ans/src/advanced_notification_service.cpp | 7 ++++++- .../include/distributed_preferences_info.h | 2 +- .../src/distributed_device_callback.cpp | 2 +- .../src/distributed_notification_manager.cpp | 6 +++--- .../src/distributed_screen_status_manager.cpp | 2 +- 7 files changed, 23 insertions(+), 17 deletions(-) diff --git a/frameworks/js/napi/src/common.cpp b/frameworks/js/napi/src/common.cpp index 851a565b2..91ad1b766 100644 --- a/frameworks/js/napi/src/common.cpp +++ b/frameworks/js/napi/src/common.cpp @@ -2993,7 +2993,7 @@ napi_value Common::GetNotificationBasicContentDetailed( } NAPI_CALL(env, napi_get_value_string_utf8(env, value, str, STR_MAX_SIZE - 1, &strLen)); basicContent->SetTitle(str); - ANS_LOGI("normal::title = %{public}s", str); + ANS_LOGD("normal::title = %{public}s", str); // text: string NAPI_CALL(env, napi_has_named_property(env, contentResult, "text", &hasProperty)); @@ -3009,7 +3009,7 @@ napi_value Common::GetNotificationBasicContentDetailed( } NAPI_CALL(env, napi_get_value_string_utf8(env, value, str, STR_MAX_SIZE - 1, &strLen)); basicContent->SetText(str); - ANS_LOGI("normal::text = %{public}s", str); + ANS_LOGD("normal::text = %{public}s", str); // additionalText?: string NAPI_CALL(env, napi_has_named_property(env, contentResult, "additionalText", &hasProperty)); @@ -3097,7 +3097,7 @@ napi_value Common::GetNotificationLongTextContentDetailed( } NAPI_CALL(env, napi_get_value_string_utf8(env, longContentResult, long_str, LONG_STR_MAX_SIZE, &strLen)); longContent->SetLongText(long_str); - ANS_LOGI("longText::longText = %{public}s", long_str); + ANS_LOGD("longText::longText = %{public}s", long_str); // briefText: string NAPI_CALL(env, napi_has_named_property(env, contentResult, "briefText", &hasProperty)); @@ -3113,7 +3113,7 @@ napi_value Common::GetNotificationLongTextContentDetailed( } NAPI_CALL(env, napi_get_value_string_utf8(env, longContentResult, str, STR_MAX_SIZE - 1, &strLen)); longContent->SetBriefText(str); - ANS_LOGI("longText::briefText = %{public}s", str); + ANS_LOGD("longText::briefText = %{public}s", str); // expandedTitle: string NAPI_CALL(env, napi_has_named_property(env, contentResult, "expandedTitle", &hasProperty)); @@ -3129,7 +3129,7 @@ napi_value Common::GetNotificationLongTextContentDetailed( } NAPI_CALL(env, napi_get_value_string_utf8(env, longContentResult, str, STR_MAX_SIZE - 1, &strLen)); longContent->SetExpandedTitle(str); - ANS_LOGI("longText::expandedTitle = %{public}s", str); + ANS_LOGD("longText::expandedTitle = %{public}s", str); return NapiGetNull(env); } @@ -3342,7 +3342,7 @@ napi_value Common::GetNotificationConversationalContentTitle( } NAPI_CALL(env, napi_get_value_string_utf8(env, conversationalContentResult, str, STR_MAX_SIZE - 1, &strLen)); conversationalContent->SetConversationTitle(str); - ANS_LOGI("conversationTitle = %{public}s", str); + ANS_LOGD("conversationTitle = %{public}s", str); return NapiGetNull(env); } @@ -3662,7 +3662,7 @@ napi_value Common::GetMessageUserByBool(const napi_env &env, const napi_value &r bool machine = false; napi_get_value_bool(env, machineResult, &machine); messageUser.SetMachine(machine); - ANS_LOGI("MessageUser::isMachine = %{public}d", machine); + ANS_LOGD("MessageUser::isMachine = %{public}d", machine); // isUserImportant: boolean NAPI_CALL(env, napi_has_named_property(env, result, "isUserImportant", &hasProperty)); @@ -3763,7 +3763,7 @@ napi_value Common::GetNotificationMultiLineContent( } NAPI_CALL(env, napi_get_value_string_utf8(env, multiLineContentResult, str, STR_MAX_SIZE - 1, &strLen)); multiLineContent->SetBriefText(str); - ANS_LOGI("multiLine: briefText = %{public}s", str); + ANS_LOGD("multiLine: briefText = %{public}s", str); // longTitle: string NAPI_CALL(env, napi_has_named_property(env, contentResult, "longTitle", &hasProperty)); @@ -3779,7 +3779,7 @@ napi_value Common::GetNotificationMultiLineContent( } NAPI_CALL(env, napi_get_value_string_utf8(env, multiLineContentResult, str, STR_MAX_SIZE - 1, &strLen)); multiLineContent->SetExpandedTitle(str); - ANS_LOGI("multiLine: longTitle = %{public}s", str); + ANS_LOGD("multiLine: longTitle = %{public}s", str); // lines: Array NAPI_CALL(env, napi_has_named_property(env, contentResult, "lines", &hasProperty)); @@ -3793,6 +3793,7 @@ napi_value Common::GetNotificationMultiLineContent( request.SetContent(std::make_shared(multiLineContent)); + ANS_LOGI("end"); return NapiGetNull(env); } diff --git a/services/ans/src/access_token_helper.cpp b/services/ans/src/access_token_helper.cpp index 881c810d9..56c226c69 100644 --- a/services/ans/src/access_token_helper.cpp +++ b/services/ans/src/access_token_helper.cpp @@ -32,7 +32,7 @@ bool AccessTokenHelper::VerifyCallerPermission( bool AccessTokenHelper::VerifyNativeToken(const AccessTokenID &callerToken) { ATokenTypeEnum tokenType = AccessTokenKit::GetTokenTypeFlag(callerToken); - return tokenType == ATokenTypeEnum::TOKEN_NATIVE; + return (tokenType == ATokenTypeEnum::TOKEN_NATIVE || tokenType == ATokenTypeEnum::TOKEN_SHELL); } bool AccessTokenHelper::IsSystemHap() diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 8584d950d..bd9a13570 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -3643,8 +3643,13 @@ ErrCode AdvancedNotificationService::ShellDump(const std::string &cmd, const std std::vector &dumpInfo) { ANS_LOGD("%{public}s", __FUNCTION__); - ErrCode result = ERR_ANS_NOT_ALLOWED; + if (!AccessTokenHelper::VerifyNativeToken(IPCSkeleton::GetCallingTokenID())) { + ANS_LOGE("Not subsystem or shell request"); + return ERR_ANS_NON_SYSTEM_APP; + } + + ErrCode result = ERR_ANS_NOT_ALLOWED; handler_->PostSyncTask(std::bind([&]() { if (cmd == ACTIVE_NOTIFICATION_OPTION) { result = ActiveNotificationDump(bundle, userId, dumpInfo); diff --git a/services/distributed/include/distributed_preferences_info.h b/services/distributed/include/distributed_preferences_info.h index 612b1653d..8548fa151 100644 --- a/services/distributed/include/distributed_preferences_info.h +++ b/services/distributed/include/distributed_preferences_info.h @@ -78,7 +78,7 @@ public: ErrCode GetSyncEnabledWithoutApp(const int32_t userId, bool &enabled); private: - bool distributedEnable_ = true; + bool distributedEnable_ = false; std::map, bool> bundleEnable_; std::map enabledWithoutApp_; }; diff --git a/services/distributed/src/distributed_device_callback.cpp b/services/distributed/src/distributed_device_callback.cpp index d59850783..92a910f0c 100644 --- a/services/distributed/src/distributed_device_callback.cpp +++ b/services/distributed/src/distributed_device_callback.cpp @@ -29,7 +29,7 @@ void DistributedDeviceCallback::OnDeviceChanged( { ANS_LOGI("%{public}s start", __FUNCTION__); if (type == DistributedKv::DeviceChangeType::DEVICE_ONLINE) { - ANS_LOGI("device %{public}s is ONLINE", info.deviceId.c_str()); + ANS_LOGD("device %{public}s is ONLINE", info.deviceId.c_str()); if (callback_.OnConnected) { callback_.OnConnected(info.deviceId); } diff --git a/services/distributed/src/distributed_notification_manager.cpp b/services/distributed/src/distributed_notification_manager.cpp index 460405aab..7228c9b93 100644 --- a/services/distributed/src/distributed_notification_manager.cpp +++ b/services/distributed/src/distributed_notification_manager.cpp @@ -134,7 +134,7 @@ void DistributedNotificationManager::OnDatabaseInsert( ANS_LOGD("%{public}s", __FUNCTION__); handler_->PostTask(std::bind([=]() { if (!CheckDeviceId(deviceId, key)) { - ANS_LOGW("device id are not the same. deviceId:%{public}s key:%{public}s", deviceId.c_str(), key.c_str()); + ANS_LOGD("device id are not the same. deviceId:%{public}s key:%{public}s", deviceId.c_str(), key.c_str()); } ResolveKey resolveKey; @@ -160,7 +160,7 @@ void DistributedNotificationManager::OnDatabaseUpdate( ANS_LOGD("%{public}s", __FUNCTION__); handler_->PostTask(std::bind([=]() { if (!CheckDeviceId(deviceId, key)) { - ANS_LOGW("device id are not the same. deviceId:%{public}s key:%{public}s", deviceId.c_str(), key.c_str()); + ANS_LOGD("device id are not the same. deviceId:%{public}s key:%{public}s", deviceId.c_str(), key.c_str()); } ResolveKey resolveKey; @@ -186,7 +186,7 @@ void DistributedNotificationManager::OnDatabaseDelete( ANS_LOGD("%{public}s", __FUNCTION__); handler_->PostTask(std::bind([=]() { if (!CheckDeviceId(deviceId, key)) { - ANS_LOGW("device id are not the same. deviceId:%{public}s key:%{public}s", deviceId.c_str(), key.c_str()); + ANS_LOGD("device id are not the same. deviceId:%{public}s key:%{public}s", deviceId.c_str(), key.c_str()); } ResolveKey resolveKey; diff --git a/services/distributed/src/distributed_screen_status_manager.cpp b/services/distributed/src/distributed_screen_status_manager.cpp index d8b0bd5bc..695348a50 100644 --- a/services/distributed/src/distributed_screen_status_manager.cpp +++ b/services/distributed/src/distributed_screen_status_manager.cpp @@ -45,7 +45,7 @@ DistributedScreenStatusManager::~DistributedScreenStatusManager() void DistributedScreenStatusManager::OnDeviceConnected(const std::string &deviceId) { - ANS_LOGI("deviceId:%{public}s", deviceId.c_str()); + ANS_LOGD("deviceId:%{public}s", deviceId.c_str()); std::lock_guard lock(mutex_); CheckKvStore(); } -- Gitee