diff --git a/frameworks/ans/src/notification_helper.cpp b/frameworks/ans/src/notification_helper.cpp index 0722b0a9133a7f2759f5bbbbf05a9d938cd98f65..b91a05e38485fe0cc6dbe64fee654d8f5a53700a 100644 --- a/frameworks/ans/src/notification_helper.cpp +++ b/frameworks/ans/src/notification_helper.cpp @@ -189,6 +189,12 @@ ErrCode NotificationHelper::RequestEnableNotification(std::string &deviceId, deviceId, hostClient, callerToken); } +ErrCode NotificationHelper::RequestEnableNotification(const std::string bundleName, const int32_t uid) +{ + return DelayedSingleton::GetInstance()->RequestEnableNotification( + bundleName, uid); +} + ErrCode NotificationHelper::HasNotificationPolicyAccessPermission(bool &hasPermission) { return DelayedSingleton::GetInstance()->HasNotificationPolicyAccessPermission(hasPermission); diff --git a/frameworks/core/include/ans_manager_interface.h b/frameworks/core/include/ans_manager_interface.h index 384c34820893d54b53302d48e34d835052db541b..9af40693fbe85366cacc0ad1fa258bc09a1ab77b 100644 --- a/frameworks/core/include/ans_manager_interface.h +++ b/frameworks/core/include/ans_manager_interface.h @@ -403,6 +403,15 @@ public: const sptr &callback, const sptr &callerToken) = 0; + /** + * @brief Allow application to publish notifications. + * + * @param bundleName bundle name. + * @param uid uid. + * @return Returns set notifications enabled for the bundle result. + */ + virtual ErrCode RequestEnableNotification(const std::string bundleName, const int32_t uid) = 0; + /** * @brief Set whether to allow the specified deviceId to send notifications for current bundle. * diff --git a/frameworks/core/include/ans_manager_proxy.h b/frameworks/core/include/ans_manager_proxy.h index 0a906f4ebbd5cee36868ed5b5735431cd146b949..d36f5903f7f79766674728f9d48fc3e41a7608d0 100644 --- a/frameworks/core/include/ans_manager_proxy.h +++ b/frameworks/core/include/ans_manager_proxy.h @@ -390,6 +390,15 @@ public: ErrCode RequestEnableNotification(const std::string &deviceId, const sptr &callback, const sptr &callerToken) override; + + /** + * @brief Allow application to publish notifications. + * + * @param bundleName bundle name. + * @param uid uid. + * @return Returns set notifications enabled for the bundle result. + */ + ErrCode RequestEnableNotification(const std::string bundleName, const int32_t uid) override; /** * @brief Set whether to allow the specified deviceId to send notifications for current bundle. diff --git a/frameworks/core/include/ans_manager_stub.h b/frameworks/core/include/ans_manager_stub.h index 72a6b8616e83a6b164eec4400ff46cb6ded85c99..00d0877a65f15cf94a86f01e64c5e24ad2b31485 100644 --- a/frameworks/core/include/ans_manager_stub.h +++ b/frameworks/core/include/ans_manager_stub.h @@ -394,6 +394,15 @@ public: const sptr &callback, const sptr &callerToken) override; + /** + * @brief Allow application to publish notifications. + * + * @param bundleName bundle name. + * @param uid uid. + * @return Returns set notifications enabled for the bundle result. + */ + ErrCode RequestEnableNotification(const std::string bundleName, const int32_t uid) override; + /** * @brief Set whether to allow the specified deviceId to send notifications for current bundle. * @@ -1021,6 +1030,7 @@ private: ErrCode HandleGetSlotByBundle(MessageParcel &data, MessageParcel &reply); ErrCode HandleUpdateSlots(MessageParcel &data, MessageParcel &reply); ErrCode HandleRequestEnableNotification(MessageParcel &data, MessageParcel &reply); + ErrCode HandleRequestEnableNotificationByBundle(MessageParcel &data, MessageParcel &reply); ErrCode HandleSetNotificationsEnabledForBundle(MessageParcel &data, MessageParcel &reply); ErrCode HandleSetNotificationsEnabledForAllBundles(MessageParcel &data, MessageParcel &reply); ErrCode HandleSetNotificationsEnabledForSpecialBundle(MessageParcel &data, MessageParcel &reply); diff --git a/frameworks/core/include/ans_notification.h b/frameworks/core/include/ans_notification.h index be1d52d0b4ceb6040eaa58998e7c78293b807cfa..e5622cbdc3f2c5fdec511a6bdb33f5120d6d04d8 100644 --- a/frameworks/core/include/ans_notification.h +++ b/frameworks/core/include/ans_notification.h @@ -330,6 +330,15 @@ public: sptr &hostClient, sptr &callerToken); + /** + * @brief Allow application to publish notifications. + * + * @param bundleName bundle name. + * @param uid uid. + * @return Returns set notifications enabled for the bundle result. + */ + ErrCode RequestEnableNotification(const std::string bundleName, const int32_t uid); + /** * @brief Checks whether this application has permission to modify the Do Not Disturb (DND) notification policy. * diff --git a/frameworks/core/include/distributed_notification_service_ipc_interface_code.h b/frameworks/core/include/distributed_notification_service_ipc_interface_code.h index 2e2e68cbf0c7dc40d6df796713af1d4713fc5664..efe213c5cae8a5ae98f9d29e1a44eb559ece195a 100644 --- a/frameworks/core/include/distributed_notification_service_ipc_interface_code.h +++ b/frameworks/core/include/distributed_notification_service_ipc_interface_code.h @@ -153,6 +153,7 @@ namespace Notification { GET_DONOTDISTURB_PROFILE, UPDATE_NOTIFICATION_TIMER, Set_HASH_CODE_RULE, + REQUEST_ENABLE_NOTIFICATION_BY_BUNDLE, }; } } diff --git a/frameworks/core/src/ans_manager_proxy.cpp b/frameworks/core/src/ans_manager_proxy.cpp index c922ac1eed73d648e7921edc99008f66a2983d52..c182dd7d9918972337dfa9762e02d8efbf656783 100644 --- a/frameworks/core/src/ans_manager_proxy.cpp +++ b/frameworks/core/src/ans_manager_proxy.cpp @@ -1039,6 +1039,41 @@ ErrCode AnsManagerProxy::RequestEnableNotification(const std::string &deviceId, return result; } +ErrCode AnsManagerProxy::RequestEnableNotification(const std::string bundleName, const int32_t uid) +{ + ANS_LOGD("enter"); + MessageParcel data; + if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { + ANS_LOGE("[RequestEnableNotification] fail: write interface token failed."); + return ERR_ANS_PARCELABLE_FAILED; + } + + if (!data.WriteString(bundleName)) { + ANS_LOGE("[RequestEnableNotification] fail: write bundleName failed"); + return ERR_ANS_PARCELABLE_FAILED; + } + + if (!data.WriteInt32(uid)) { + ANS_LOGE("[RequestEnableNotification] fail: write uid failed"); + return ERR_ANS_PARCELABLE_FAILED; + } + + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + ErrCode result = InnerTransact(NotificationInterfaceCode::REQUEST_ENABLE_NOTIFICATION_BY_BUNDLE, + option, data, reply); + if (result != ERR_OK) { + ANS_LOGE("[RequestEnableNotification] fail: transact ErrCode=%{public}d", result); + return ERR_ANS_TRANSACT_FAILED; + } + + if (!reply.ReadInt32(result)) { + ANS_LOGE("[RequestEnableNotification] fail: read result failed."); + return ERR_ANS_PARCELABLE_FAILED; + } + return result; +} + ErrCode AnsManagerProxy::SetNotificationsEnabledForBundle(const std::string &deviceId, bool enabled) { MessageParcel data; diff --git a/frameworks/core/src/ans_manager_stub.cpp b/frameworks/core/src/ans_manager_stub.cpp index a350e8f9aefc7f6ab16ab04fb3efaeb28db294d0..e5a0c0e4777219f6ab1a621d261c75e9c9e296fd 100644 --- a/frameworks/core/src/ans_manager_stub.cpp +++ b/frameworks/core/src/ans_manager_stub.cpp @@ -183,6 +183,10 @@ int32_t AnsManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Mess result = HandleRequestEnableNotification(data, reply); break; } + case static_cast(NotificationInterfaceCode::REQUEST_ENABLE_NOTIFICATION_BY_BUNDLE): { + result = HandleRequestEnableNotificationByBundle(data, reply); + break; + } case static_cast(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_FOR_BUNDLE): { result = HandleSetNotificationsEnabledForBundle(data, reply); break; @@ -1386,6 +1390,29 @@ ErrCode AnsManagerStub::HandleRequestEnableNotification(MessageParcel &data, Mes return ERR_OK; } +ErrCode AnsManagerStub::HandleRequestEnableNotificationByBundle(MessageParcel &data, MessageParcel &reply) +{ + ANS_LOGD("enter"); + std::string bundleName; + if (!data.ReadString(bundleName)) { + ANS_LOGE("[HandleRequestEnableNotificationByBundle] fail: read bundleName failed."); + return ERR_ANS_PARCELABLE_FAILED; + } + + int32_t uid = 0; + if (!data.ReadInt32(uid)) { + ANS_LOGE("[HandleRequestEnableNotificationByBundle] fail: read uid failed"); + return ERR_ANS_PARCELABLE_FAILED; + } + + ErrCode result = RequestEnableNotification(bundleName, uid); + if (!reply.WriteInt32(result)) { + ANS_LOGE("[HandleRequestEnableNotificationByBundle] fail: write result failed, ErrCode=%{public}d", result); + return ERR_ANS_PARCELABLE_FAILED; + } + return ERR_OK; +} + ErrCode AnsManagerStub::HandleSetNotificationsEnabledForBundle(MessageParcel &data, MessageParcel &reply) { std::string deviceId; diff --git a/frameworks/core/src/ans_manager_stub_invalid.cpp b/frameworks/core/src/ans_manager_stub_invalid.cpp index db13e6eb806f02a36746d2e5d2c2cfc1c7227eb0..3a5a6c524d828d240acb0108417621910dce4a5d 100644 --- a/frameworks/core/src/ans_manager_stub_invalid.cpp +++ b/frameworks/core/src/ans_manager_stub_invalid.cpp @@ -274,6 +274,12 @@ ErrCode AnsManagerStub::RequestEnableNotification(const std::string &deviceId, return ERR_INVALID_OPERATION; } +ErrCode AnsManagerStub::RequestEnableNotification(const std::string bundleName, const int32_t uid) +{ + ANS_LOGE("AnsManagerStub::RequestEnableNotification called!"); + return ERR_INVALID_OPERATION; +} + ErrCode AnsManagerStub::SetNotificationsEnabledForBundle(const std::string &bundle, bool enabled) { ANS_LOGE("AnsManagerStub::SetNotificationsEnabledForBundle called!"); diff --git a/frameworks/core/src/ans_notification.cpp b/frameworks/core/src/ans_notification.cpp index dfb2da3889ef56fd9d216a0854cf8a6d51941671..0d9e8110804526a9c61dc27c91a2eb040b71fc6b 100644 --- a/frameworks/core/src/ans_notification.cpp +++ b/frameworks/core/src/ans_notification.cpp @@ -527,6 +527,17 @@ ErrCode AnsNotification::RequestEnableNotification(std::string &deviceId, return proxy->RequestEnableNotification(deviceId, hostClient, callerToken); } +ErrCode AnsNotification::RequestEnableNotification(const std::string bundleName, const int32_t uid) +{ + ANS_LOGD("enter"); + sptr proxy = GetAnsManagerProxy(); + if (!proxy) { + ANS_LOGE("GetAnsManagerProxy fail."); + return ERR_ANS_SERVICE_NOT_CONNECTED; + } + return proxy->RequestEnableNotification(bundleName, uid); +} + ErrCode AnsNotification::HasNotificationPolicyAccessPermission(bool &hasPermission) { sptr proxy = GetAnsManagerProxy(); diff --git a/frameworks/core/src/manager/ans_manager_proxy_bundle.cpp b/frameworks/core/src/manager/ans_manager_proxy_bundle.cpp index 8d2c39b9254a85d094cb51b0ff71ae141ffe50bc..21c00b4b2ccda9b9aba5cae604986465d22f9314 100644 --- a/frameworks/core/src/manager/ans_manager_proxy_bundle.cpp +++ b/frameworks/core/src/manager/ans_manager_proxy_bundle.cpp @@ -162,6 +162,41 @@ ErrCode AnsManagerProxy::RequestEnableNotification(const std::string &deviceId, return result; } +ErrCode AnsManagerProxy::RequestEnableNotification(const std::string bundleName, const int32_t uid) +{ + ANS_LOGD("enter"); + MessageParcel data; + if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { + ANS_LOGE("[RequestEnableNotification] fail: write interface token failed."); + return ERR_ANS_PARCELABLE_FAILED; + } + + if (!data.WriteString(bundleName)) { + ANS_LOGE("[RequestEnableNotification] fail: write bundleName failed"); + return ERR_ANS_PARCELABLE_FAILED; + } + + if (!data.WriteInt32(uid)) { + ANS_LOGE("[RequestEnableNotification] fail: write uid failed"); + return ERR_ANS_PARCELABLE_FAILED; + } + + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + ErrCode result = InnerTransact(NotificationInterfaceCode::REQUEST_ENABLE_NOTIFICATION_BY_BUNDLE, + option, data, reply); + if (result != ERR_OK) { + ANS_LOGE("[RequestEnableNotification] fail: transact ErrCode=%{public}d", result); + return ERR_ANS_TRANSACT_FAILED; + } + + if (!reply.ReadInt32(result)) { + ANS_LOGE("[RequestEnableNotification] fail: read result failed."); + return ERR_ANS_PARCELABLE_FAILED; + } + return result; +} + ErrCode AnsManagerProxy::SetNotificationsEnabledForBundle(const std::string &deviceId, bool enabled) { MessageParcel data; diff --git a/frameworks/core/test/unittest/ans_notification_branch_test/ans_notification_branch_test.cpp b/frameworks/core/test/unittest/ans_notification_branch_test/ans_notification_branch_test.cpp index 92bfd457a35701b69d64ac75693520c4dbc568a2..96efb0e4889669e0d2744b09476aa8b3b3ce68d9 100644 --- a/frameworks/core/test/unittest/ans_notification_branch_test/ans_notification_branch_test.cpp +++ b/frameworks/core/test/unittest/ans_notification_branch_test/ans_notification_branch_test.cpp @@ -238,6 +238,11 @@ public: return ERR_ANS_INVALID_PARAM; } + ErrCode RequestEnableNotification(const std::string bundleName, const int32_t uid) override + { + return ERR_ANS_INVALID_PARAM; + } + ErrCode SetNotificationsEnabledForBundle(const std::string &deviceId, bool enabled) override { return ERR_ANS_INVALID_PARAM; diff --git a/interfaces/inner_api/notification_helper.h b/interfaces/inner_api/notification_helper.h index 3625c2d7989d5f3eede822f52bc2bd85b6b5f6d6..547b0aed48dd935b6ea913bc7a7716cf483e04b2 100644 --- a/interfaces/inner_api/notification_helper.h +++ b/interfaces/inner_api/notification_helper.h @@ -329,7 +329,16 @@ public: static ErrCode RequestEnableNotification(std::string &deviceId, sptr &hostClient, sptr &callerToken); - + + /** + * @brief Allow application to publish notifications. + * + * @param bundleName bundle name. + * @param uid uid. + * @return Returns set notifications enabled for the bundle result. + */ + static ErrCode RequestEnableNotification(const std::string bundleName, const int32_t uid); + /** * @brief Checks whether this application has permission to modify the Do Not Disturb (DND) notification policy. * diff --git a/services/ans/include/advanced_notification_service.h b/services/ans/include/advanced_notification_service.h index cf0b62551f569734a7611633fa1ffeb31096e6a8..d277446c08a20ba7ecf6914be60b1454198c4f4e 100644 --- a/services/ans/include/advanced_notification_service.h +++ b/services/ans/include/advanced_notification_service.h @@ -447,6 +447,15 @@ public: const sptr &callback, const sptr &callerToken) override; + /** + * @brief Allow application to publish notifications. + * + * @param bundleName bundle name. + * @param uid uid. + * @return Returns set notifications enabled for the bundle result. + */ + ErrCode RequestEnableNotification(const std::string bundleName, const int32_t uid) override; + /** * @brief Set whether to allow the specified deviceId to send notifications for current bundle. * @@ -1465,6 +1474,12 @@ private: const sptr &bundle, bool enabled, bool isForceControl); void ClearSlotTypeData(const sptr &request, int32_t callingUid); + ErrCode CommonRequestEnableNotification(const std::string &deviceId, + const sptr &callback, + const sptr &callerToken, + const sptr bundleOption, + const bool innerLake); + private: static sptr instance_; static std::mutex instanceMutex_; diff --git a/services/ans/include/notification_dialog.h b/services/ans/include/notification_dialog.h index 941e7f47f44ae5fc3e3283be2b694ec3bd47fa85..0703496def6aabd945964f6b9c0f64f37527619f 100644 --- a/services/ans/include/notification_dialog.h +++ b/services/ans/include/notification_dialog.h @@ -34,7 +34,8 @@ public: const std::string &serviceAbilityName, int32_t uid, std::string appBundleName, - const sptr &callerToken); + const sptr &callerToken, + const bool innerLake); static int32_t GetUidByBundleName(const std::string &bundleName); }; diff --git a/services/ans/include/notification_dialog_manager.h b/services/ans/include/notification_dialog_manager.h index 2d8b6387723dc14f33af1c7140a9e6b777a81575..dc5f848cd314aea402024a188f24db80ba9693d8 100644 --- a/services/ans/include/notification_dialog_manager.h +++ b/services/ans/include/notification_dialog_manager.h @@ -84,7 +84,8 @@ public: ErrCode RequestEnableNotificationDailog( const sptr& bundle, const sptr& callback, - const sptr& callerToken + const sptr& callerToken, + const bool innerLake ); /* diff --git a/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index 2ae1182fb09b6ca15a09d1fd279c77afe75a4b85..40aacbdb6d0b3c67af8c48c5438a2396bf956352 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -67,6 +67,7 @@ constexpr int32_t TYPE_CODE_DOWNLOAD = 8; constexpr const char *FOCUS_MODE_REPEAT_CALLERS_ENABLE = "1"; constexpr const char *CONTACT_DATA = "datashare:///com.ohos.contactsdataability/contacts/contact_data?Proxy=true"; constexpr int32_t OPERATION_TYPE_COMMON_EVENT = 4; +const static std::string BUNDLE_NAME_ZYT = "com.zhuoyi.appstore.lite"; ErrCode AdvancedNotificationService::SetDefaultNotificationEnabled( const sptr &bundleOption, bool enabled) @@ -874,13 +875,39 @@ ErrCode AdvancedNotificationService::RequestEnableNotification(const std::string ANS_LOGE("callback == nullptr"); return ERR_ANS_INVALID_PARAM; } - - ErrCode result = ERR_OK; sptr bundleOption = GenerateBundleOption(); + return CommonRequestEnableNotification(deviceId, callback, callerToken, bundleOption, false); +} + +ErrCode AdvancedNotificationService::RequestEnableNotification(const std::string bundleName, const int32_t uid) +{ + ANS_LOGI("RequestEnableNotification bundleName = %{public}s uid = %{public}d", bundleName.c_str(), uid); + if (!AccessTokenHelper::CheckPermission(OHOS_PERMISSION_NOTIFICATION_CONTROLLER)) { + return ERR_ANS_PERMISSION_DENIED; + } + if (bundleName == BUNDLE_NAME_ZYT) { + return ERR_ANS_NOT_ALLOWED; + } + sptr bundleOption = new (std::nothrow) NotificationBundleOption(bundleName, uid); if (bundleOption == nullptr) { ANS_LOGE("bundleOption is nullptr."); return ERR_ANS_INVALID_BUNDLE; } + return CommonRequestEnableNotification("", nullptr, nullptr, bundleOption, true); +} + +ErrCode AdvancedNotificationService::CommonRequestEnableNotification(const std::string &deviceId, + const sptr &callback, + const sptr &callerToken, + const sptr bundleOption, + const bool innerLake) +{ + ANS_LOGI("%{public}s", __FUNCTION__); + if (bundleOption == nullptr) { + ANS_LOGE("bundleOption is nullptr."); + return ERR_ANS_INVALID_BUNDLE; + } + ErrCode result = ERR_OK; // To get the permission bool allowedNotify = false; HaMetaMessage message = HaMetaMessage(EventSceneId::SCENE_8, EventBranchId::BRANCH_5); @@ -923,7 +950,7 @@ ErrCode AdvancedNotificationService::RequestEnableNotification(const std::string return ERROR_INTERNAL_ERROR; } - result = dialogManager_->RequestEnableNotificationDailog(bundleOption, callback, callerToken); + result = dialogManager_->RequestEnableNotificationDailog(bundleOption, callback, callerToken, innerLake); if (result == ERR_OK) { result = ERR_ANS_DIALOG_POP_SUCCEEDED; } diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index bdf5f4921d00d2370e651028ce580fe92c5ff9d9..ea34b9e5ba979e8bf925381b4c2515765d130500 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -240,6 +240,16 @@ ErrCode AdvancedNotificationService::PrepareNotificationRequest(const sptrGetOwnerUid(), ownerUserId); request->SetOwnerUserId(ownerUserId); + std::shared_ptr additionalData = request->GetAdditionalData(); + if (AccessTokenHelper::CheckPermission(OHOS_PERMISSION_NOTIFICATION_CONTROLLER) && + AccessTokenHelper::CheckPermission(OHOS_PERMISSION_NOTIFICATION_AGENT_CONTROLLER) && + additionalData && additionalData->HasParam("is_ancoNotification")) { + AAFwk::IBoolean *bo = AAFwk::IBoolean::Query(additionalData->GetParam("is_ancoNotification")); + if (AAFwk::Boolean::Unbox(bo)) { + ANS_LOGI("push publish notification"); + request->SetOwnerUserId(DEFAULT_USER_ID); + } + } } ErrCode result = CheckPictureSize(request); diff --git a/services/ans/src/notification_dialog.cpp b/services/ans/src/notification_dialog.cpp index 8b635cf9f1112fcf978d5d55f6f5d89b59519d9b..ac53a95455c63f714aec08c964cb18b8356c0532 100644 --- a/services/ans/src/notification_dialog.cpp +++ b/services/ans/src/notification_dialog.cpp @@ -24,10 +24,13 @@ #include "os_account_manager_helper.h" #include "system_dialog_connect_stb.h" #include "extension_manager_client.h" +#include +#include namespace OHOS { namespace Notification { constexpr int32_t DEFAULT_VALUE = -1; +const int32_t SLEEP_TIME = 200; int32_t NotificationDialog::GetUidByBundleName(const std::string &bundleName) { @@ -41,15 +44,26 @@ ErrCode NotificationDialog::StartEnableNotificationDialogAbility( const std::string &serviceAbilityName, int32_t uid, std::string appBundleName, - const sptr &callerToken) + const sptr &callerToken, + const bool innerLake) { ANS_LOGD("%{public}s, Enter.", __func__); auto topBundleName = IN_PROCESS_CALL(AAFwk::AbilityManagerClient::GetInstance()->GetTopAbility().GetBundleName()); - auto topUid = NotificationDialog::GetUidByBundleName(topBundleName); if (topBundleName != appBundleName) { ANS_LOGE("Current application isn't in foreground, top is %{public}s.", topBundleName.c_str()); - return ERR_ANS_INVALID_BUNDLE; + if (!innerLake) { + return ERR_ANS_INVALID_BUNDLE; + } else { + ANS_LOGE("get top ability again"); + std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME)); + topBundleName = IN_PROCESS_CALL( + AAFwk::AbilityManagerClient::GetInstance()->GetTopAbility().GetBundleName()); + if (topBundleName != appBundleName) { + ANS_LOGE("get top ability again failed"); + return ERR_ANS_INVALID_BUNDLE; + } + } } AAFwk::Want want; @@ -63,6 +77,7 @@ ErrCode NotificationDialog::StartEnableNotificationDialogAbility( root["bundleName"] = appBundleName; root["bundleUid"] = uid; root["ability.want.params.uiExtensionType"] = uiExtensionType; + root["innerLake"] = innerLake; std::string command = root.dump(); auto connection_ = sptr(new (std::nothrow) SystemDialogConnectStb(command)); diff --git a/services/ans/src/notification_dialog_manager.cpp b/services/ans/src/notification_dialog_manager.cpp index 29e4bde4f149bec2d01f666e8dd8b16149967897..e7d40a91da89435b2163b92dfb9878d762604d11 100644 --- a/services/ans/src/notification_dialog_manager.cpp +++ b/services/ans/src/notification_dialog_manager.cpp @@ -88,11 +88,9 @@ bool NotificationDialogManager::Init() ErrCode NotificationDialogManager::RequestEnableNotificationDailog( const sptr& bundle, const sptr& callback, - const sptr& callerToken) + const sptr& callerToken, + const bool innerLake) { - if (bundle == nullptr || callback == nullptr) { - return ERROR_INTERNAL_ERROR; - } if (!AddDialogInfoIfNotExist(bundle, callback)) { ANS_LOGE("AddDialogIfNotExist failed. Dialog already exists."); return ERR_ANS_DIALOG_IS_POPPING; @@ -102,7 +100,8 @@ ErrCode NotificationDialogManager::RequestEnableNotificationDailog( NotificationDialogManager::NOTIFICATION_DIALOG_SERVICE_ABILITY, bundle->GetUid(), bundle->GetBundleName(), - callerToken); + callerToken, + innerLake); if (result != ERR_OK) { ANS_LOGE("StartEnableNotificationDialogAbility failed, result = %{public}d", result); std::unique_ptr dialogInfoRemoved = nullptr; diff --git a/services/ans/test/unittest/notification_dialog_test/notification_dialog_test.cpp b/services/ans/test/unittest/notification_dialog_test/notification_dialog_test.cpp index a43ffabdb159d0409b6eb5cd96facf61330cdbc9..b7f5b3e98d036bc614c09d8fb6a9305316c1801a 100644 --- a/services/ans/test/unittest/notification_dialog_test/notification_dialog_test.cpp +++ b/services/ans/test/unittest/notification_dialog_test/notification_dialog_test.cpp @@ -74,7 +74,8 @@ HWTEST_F(NotificationDialogTest, NotificationDialog_00300, Function | SmallTest NotificationDialogManager::NOTIFICATION_DIALOG_SERVICE_ABILITY, uid, bundleName, - callerToken); + callerToken, + false); ASSERT_EQ(result3, ERR_ANS_INVALID_BUNDLE); } @@ -99,7 +100,8 @@ HWTEST_F(NotificationDialogTest, NotificationDialog_00400, Function | SmallTest NotificationDialogManager::NOTIFICATION_DIALOG_SERVICE_ABILITY, uid, bundleName, - callerToken); + callerToken, + false); ASSERT_EQ(result3, ERR_ANS_INVALID_BUNDLE); } } // namespace Notification diff --git a/services/dialog_ui/enable_notification_dialog/entry/src/main/ets/ServiceExtAbility/NotificationServiceExtAbility.ts b/services/dialog_ui/enable_notification_dialog/entry/src/main/ets/ServiceExtAbility/NotificationServiceExtAbility.ts index fc1d035301c7c9cf8bda61287f8585e8992790a7..088f568a0482d153d888c944d650bbd501852dbc 100644 --- a/services/dialog_ui/enable_notification_dialog/entry/src/main/ets/ServiceExtAbility/NotificationServiceExtAbility.ts +++ b/services/dialog_ui/enable_notification_dialog/entry/src/main/ets/ServiceExtAbility/NotificationServiceExtAbility.ts @@ -91,14 +91,16 @@ export class EnableNotificationDialog { stageModel: boolean; subWindow: window.Window; initSubWindowSize: boolean; + innerLake: boolean; - constructor(id: number, want: Want, stageModel: boolean) { + constructor(id: number, want: Want, stageModel: boolean, innerLake: boolean) { this.id = id; this.want = want; this.stageModel = stageModel; this.window = undefined; this.extensionWindow = undefined; this.initSubWindowSize = false; + this.innerLake = innerLake; } @@ -266,17 +268,21 @@ class NotificationDialogServiceExtensionAbility extends UIExtensionAbility { let stageModel = false; let bundleName = want.parameters['ohos.aafwk.param.callerBundleName']; let bundleUid = want.parameters['ohos.aafwk.param.callerUid']; + let innerLake = false; if (bundleName !== EnableNotificationDialog.SCENEBOARD_BUNDLE && bundleName !== EnableNotificationDialog.SYSTEMUI_BUNDLE) { want.parameters.bundleName = bundleName; want.parameters.bundleUid = bundleUid; stageModel = true; + console.log(TAG, `stage model`); } else { stageModel = false; + innerLake = Boolean(want.parameters.innerLake); + console.log(TAG, ` un stage model innerLake = , ${innerLake}`); } console.log(TAG, `UIExtAbility onSessionCreate bundleName ${want.parameters.bundleName}` + `uid ${want.parameters.bundleUid}`); - let dialog = new EnableNotificationDialog(1, want, stageModel); + let dialog = new EnableNotificationDialog(1, want, stageModel, innerLake); await dialog.createUiExtensionWindow(session, stageModel); AppStorage.setOrCreate('dialog', dialog); } catch (err) { diff --git a/services/dialog_ui/enable_notification_dialog/entry/src/main/ets/pages/notificationDialog.ets b/services/dialog_ui/enable_notification_dialog/entry/src/main/ets/pages/notificationDialog.ets index 09b0ed0a4635e9034472d7a025e88a8b5a59de80..2a593891e1ecc0fb8011b8aabda93563aecc1dc0 100644 --- a/services/dialog_ui/enable_notification_dialog/entry/src/main/ets/pages/notificationDialog.ets +++ b/services/dialog_ui/enable_notification_dialog/entry/src/main/ets/pages/notificationDialog.ets @@ -151,7 +151,11 @@ struct PermissionDialog { Row() { Flex({ justifyContent: FlexAlign.Center }) { Text() { - Span(permission.reason) + if (!this.dialog.innerLake) { + Span(permission.reason) + } else { + Span($r('app.string.reason_zyt')) + } } .fontSize(Constants.DIALOG_DESP_FONT_SIZE) .fontWeight(FontWeight.Regular) diff --git a/services/dialog_ui/enable_notification_dialog/entry/src/main/resources/base/element/string.json b/services/dialog_ui/enable_notification_dialog/entry/src/main/resources/base/element/string.json index da8c2f069067dce9a4e0c21a6e99d4947293f0f4..02d98f4cd8de82b77792222c06c1f195f48e3528 100644 --- a/services/dialog_ui/enable_notification_dialog/entry/src/main/resources/base/element/string.json +++ b/services/dialog_ui/enable_notification_dialog/entry/src/main/resources/base/element/string.json @@ -16,6 +16,10 @@ "name": "reason", "value": "These may include lock screen notifications, banners, sounds, vibrations, and more. You can change this in Settings." }, + { + "name":"reason_zyt", + "value":"These may include lock screen and banner notifications as well as sounds and vibration. You can modify these settings in EasyAbroad > App management." + }, { "name": "ALLOW", "value": "Allow" diff --git a/services/dialog_ui/enable_notification_dialog/entry/src/main/resources/bo_CN/element/string.json b/services/dialog_ui/enable_notification_dialog/entry/src/main/resources/bo_CN/element/string.json index 1ca84808cb2eb5ec0a21812a396e032d4ba37fab..f17a3a23849bec002b4e4ad123067a280c243e93 100644 --- a/services/dialog_ui/enable_notification_dialog/entry/src/main/resources/bo_CN/element/string.json +++ b/services/dialog_ui/enable_notification_dialog/entry/src/main/resources/bo_CN/element/string.json @@ -16,6 +16,10 @@ "name": "reason", "value": "བརྡ་ཐོ་དྲན་སྐུལ་གྱི་ཐབས་ལམ་ལ་སྒོ་ལྕགས་བརྙན་ཡོལ་དང་། འཕྲེད་བྱང་། དྲིལ་སྒྲ། སྦིར་བརྡ་སོགས་ཚུད་སྲིད། ༼སྒྲིག་འགོད་༽ལ་བསྐྱོད་ནས་བཅོས་ཆོག" }, + { + "name":"reason_zyt", + "value":"བརྡ་ཐོའི་དྲན་སྐུལ་གྱི་ཐབས་ལམ་ལ་སྒོ་ལྕགས་བརྙན་ཡོལ་དང་། འཕྲེད་བྱང་། དྲིལ་སྒྲ། སྦིར་བརྡ་སོགས་ཚུད་སྲིད། ༼ཀྲུའོ་དབྱི་ཐུང་༽>༼ ཉེར་སྤྱོད་དོ་དམ་༽ལ་བསྐྱོད་ནས་བཅོས་ཆོག" + }, { "name": "ALLOW", "value": "ཆོག་པ།" diff --git a/services/dialog_ui/enable_notification_dialog/entry/src/main/resources/ug/element/string.json b/services/dialog_ui/enable_notification_dialog/entry/src/main/resources/ug/element/string.json index 2bc9b3ed16d6f3fd7767a16976942f40bd6c8806..488d6204abd81e2354448d8e7c8e82bc1057714f 100644 --- a/services/dialog_ui/enable_notification_dialog/entry/src/main/resources/ug/element/string.json +++ b/services/dialog_ui/enable_notification_dialog/entry/src/main/resources/ug/element/string.json @@ -16,6 +16,10 @@ "name": "reason", "value": "قۇلۇپ ئېكرانى، بالداق، ئاۋاز ۋە تىترەش شۇلارنىڭ ئىچىدە. تەڭشەكتىن ئۆزگەرتەلەيسىز." }, + { + "name":"reason_zyt", + "value":"قۇلۇپ ئېكرانى، بالداق، ئاۋاز ۋە تىترەش قاتارلىقلار شۇنىڭ ئىچىدە. DroiTong > ئەپ باشقۇرۇش دېگەن ئورۇندىن ئۆزگەرتەلەيسىز." + }, { "name": "ALLOW", "value": "رۇخسەت" diff --git a/services/dialog_ui/enable_notification_dialog/entry/src/main/resources/zh_CN/element/string.json b/services/dialog_ui/enable_notification_dialog/entry/src/main/resources/zh_CN/element/string.json index 9b9b9b5ea5b66f182a6f8d4cc33958e3deada262..3627f2a36909ca4858c75f0e612f97a53a5a3b64 100644 --- a/services/dialog_ui/enable_notification_dialog/entry/src/main/resources/zh_CN/element/string.json +++ b/services/dialog_ui/enable_notification_dialog/entry/src/main/resources/zh_CN/element/string.json @@ -16,6 +16,10 @@ "name": "reason", "value": "通知提醒方式可能包括锁屏、横幅、响铃、振动等。可前往“设置” 更改。" }, + { + "name":"reason_zyt", + "value":"通知提醒方式可能包括锁屏、横幅、响铃、振动等。可前往“卓易通”>“应用管理”更改。" + }, { "name": "ALLOW", "value": "允许" diff --git a/services/dialog_ui/enable_notification_dialog/entry/src/main/resources/zh_HK/element/string.json b/services/dialog_ui/enable_notification_dialog/entry/src/main/resources/zh_HK/element/string.json index 1b3ddf6bcb0b7b8589df370420d29182cc7a212f..c8a3e11ece292fc66ec0760792424fb3da9f6385 100644 --- a/services/dialog_ui/enable_notification_dialog/entry/src/main/resources/zh_HK/element/string.json +++ b/services/dialog_ui/enable_notification_dialog/entry/src/main/resources/zh_HK/element/string.json @@ -16,6 +16,10 @@ "name": "reason", "value": "通知提醒方式可能包括鎖屏、橫幅、響鬧、震動等。可前往「設定」更改。" }, + { + "name":"reason_zyt", + "value":"通知提醒方式可能包括鎖屏、橫幅、響鬧和震動等。可前往「卓易通」>「應用程式管理」更改。" + }, { "name": "ALLOW", "value": "允許" diff --git a/services/dialog_ui/enable_notification_dialog/entry/src/main/resources/zh_TW/element/string.json b/services/dialog_ui/enable_notification_dialog/entry/src/main/resources/zh_TW/element/string.json index c15a58719b6c90197652c4375a29967279fa61e4..55b69a7382749ea9f524bf4853c74201d676a233 100644 --- a/services/dialog_ui/enable_notification_dialog/entry/src/main/resources/zh_TW/element/string.json +++ b/services/dialog_ui/enable_notification_dialog/entry/src/main/resources/zh_TW/element/string.json @@ -16,6 +16,10 @@ "name": "reason", "value": "通知提醒方式可能包括鎖定螢幕、橫幅、響鈴、振動等。可前往「設定」變更。" }, + { + "name":"reason_zyt", + "value":"通知提醒方式可能包括鎖定螢幕、橫幅、響鈴、振動等。您可以前往「卓易通」>「應用程式管理」變更。" + }, { "name": "ALLOW", "value": "允許"