2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <notification_type.h>
23 #include <notification_viewer.h>
25 #include <app_control_internal.h>
26 #include <pkgmgr-info.h>
28 #include <bundle_internal.h>
29 #include <tzplatform_config.h>
30 #include <notification_setting.h>
31 #include <notification_setting_internal.h>
32 #include <notification_setting_service.h>
39 #include <notification_ex_item.h>
40 #include <notification-ex/manager.h>
41 #include <notification-ex/reporter.h>
42 #include <notification-ex/dbus_sender.h>
43 #include <notification-ex/dbus_event_listener.h>
44 #include <notification-ex/dbus_connection_manager.h>
45 #include <notification-ex/db_manager.h>
46 #include <notification-ex/common.h>
47 #include <notification-ex/exception.h>
48 #include <notification-ex/item_info_internal.h>
49 #include <notification-ex/button_item.h>
50 #include <notification-ex/ex_util.h>
51 #include <notification-ex/ievent_info_internal.h>
52 #include <notification-ex/event_info_internal.h>
53 #include <notification-ex/iitem_info_internal.h>
54 #include <notification-ex/shared_file.h>
55 #include <notification-ex/group_item.h>
56 #include <notification-ex/app_control_action.h>
59 #include "notification_ex_service.h"
61 #define NORMAL_UID_BASE 5000
62 #define MAX_TIMEOUT 30 * 1000 /* 30 sec */
65 using namespace notification;
66 using namespace notification::item;
70 DPMFacade(unique_ptr<Reporter> reporter, unique_ptr<Manager> manager, int restartCount)
71 : reporter_(move(reporter)), manager_(move(manager)) {
72 DBManager::InitializeDB();
74 if (restartCount == 0)
75 DBManager::InitializeData();
77 hide_map_ = DBManager::GetHideMap();
80 void DelegateReporterEvent(const IEventInfo& info,
81 list<shared_ptr<item::AbstractItem>> itemList) {
82 reporter_->SendEvent(info, itemList);
85 void DelegateManagerEvent(const IEventInfo& info,
86 list<shared_ptr<item::AbstractItem>> itemList) {
87 manager_->SendEvent(info, itemList);
90 void LaunchDefaultViewer(list<shared_ptr<item::AbstractItem>> item,
91 notification_op_type_e status) {
97 priv_id = NOTIFICATION_PRIV_ID_NONE;
99 priv_id = static_pointer_cast<IItemInfoInternal>(
100 item.front()->GetInfo())->GetPrivateId();
102 LaunchDefaultViewer(priv_id, status,
103 static_pointer_cast<IItemInfoInternal>(
104 item.front()->GetInfo())->GetUid());
107 void LaunchDefaultViewer(shared_ptr<item::AbstractItem> item,
108 notification_op_type_e status) {
110 static_pointer_cast<IItemInfoInternal>(item->GetInfo())->GetPrivateId(),
112 static_pointer_cast<IItemInfoInternal>(item->GetInfo())->GetUid());
115 void LaunchDefaultViewer(int64_t privId, notification_op_type_e status,
117 int ret = notification_launch_default_viewer(
118 static_cast<int>(privId), status, uid);
119 if (ret != ERROR_NONE)
120 ERR("Failed to launch default viewer [%d]", ret);
123 uid_t GetUid(const IEventInfo& info) {
124 uid_t validated_uid =
125 static_cast<const IEventInfoInternal&>(info).GetValidatedUid();
127 return validated_uid > NORMAL_UID_BASE ?
128 validated_uid : tzplatform_getuid(TZ_SYS_DEFAULT_USER);
131 void TranslateText(list<shared_ptr<item::AbstractItem>> item) {
136 void TranslateText(shared_ptr<item::AbstractItem> item) {
137 if (item->GetMultiLanguage() != nullptr)
138 item->GetMultiLanguage()->UpdateString();
140 if (item->GetType() != AbstractItem::Type::Group)
143 auto item_group = static_pointer_cast<GroupItem>(item);
144 auto children_list = item_group->GetChildren();
146 for (auto& i : children_list)
150 bool CheckAllowedToNotify(list<shared_ptr<item::AbstractItem>> item) {
151 auto iter = item.begin();
153 while (iter != item.end()) {
154 if (CheckAllowedToNotify(*iter) == false)
155 iter = item.erase(iter);
160 if (item.size() == 0)
166 bool CheckAllowedToNotify(shared_ptr<item::AbstractItem> item) {
167 notification_setting_h setting;
169 bool allow_to_notify, app_disabled;
170 uid_t uid = static_pointer_cast<IItemInfoInternal>(item->GetInfo())->GetUid();
172 ret = noti_setting_service_get_setting_by_app_id(item->GetSenderAppId().c_str(),
174 if (ret != NOTIFICATION_ERROR_NONE)
177 notification_setting_get_allow_to_notify(setting, &allow_to_notify);
178 notification_setting_get_app_disabled(setting, &app_disabled);
179 notification_setting_free_notification(setting);
181 if (!allow_to_notify || app_disabled) {
182 ERR("[%s] is not allowed to notify[%d,%d]", item->GetSenderAppId().c_str(),
183 allow_to_notify, app_disabled);
190 bool CheckDoNoDisturbStatus(uid_t uid, const string& owner) {
192 bool do_not_disturb = false;
193 bool do_not_disturb_exception;
194 notification_setting_h setting = nullptr;
195 notification_system_setting_h system_setting = nullptr;
197 ret = noti_system_setting_load_system_setting(&system_setting, uid);
198 if (ret != NOTIFICATION_ERROR_NONE) {
199 WARN("Failed to load system setting [%d]", ret);
203 ret = notification_system_setting_get_do_not_disturb(system_setting, &do_not_disturb);
204 if (ret != NOTIFICATION_ERROR_NONE) {
205 WARN("Failed to get do_not_disturb [%d]", ret);
209 if (do_not_disturb) {
210 do_not_disturb = false;
211 /* Check exception option of the caller app_id */
212 ret = noti_setting_service_get_setting_by_app_id(owner.c_str(), &setting, uid);
213 if (ret != NOTIFICATION_ERROR_NONE) {
214 WARN("Failed to get setting by app_id [%d]", ret);
218 ret = notification_setting_get_do_not_disturb_except(setting, &do_not_disturb_exception);
219 if (ret != NOTIFICATION_ERROR_NONE) {
220 WARN("Failed to get do_not_disturb_exception [%d]", ret);
224 if (do_not_disturb_exception == false)
225 do_not_disturb = true;
229 DBG("do_not_disturb [%d]", do_not_disturb);
231 notification_system_setting_free_system_setting(system_setting);
234 notification_setting_free_notification(setting);
236 return do_not_disturb;
239 void SetDoNoDisturbPolicy(list<shared_ptr<item::AbstractItem>> item) {
241 SetDoNoDisturbPolicy(i);
244 void SetDoNoDisturbPolicy(shared_ptr<item::AbstractItem> item) {
245 uid_t uid = static_pointer_cast<IItemInfoInternal>(item->GetInfo())->GetUid();
246 if (CheckDoNoDisturbStatus(uid, item->GetSenderAppId()) == false)
249 item->SetSoundPath("");
250 item->SetVibrationPath("");
251 item->SetLEDInfo(nullptr);
253 std::list<std::string> receiver_list = item->GetReceiverList();
254 if (receiver_list.size() == 0) {
255 item->AddReceiver(NOTI_EX_RECEIVER_GROUP_PANEL);
256 item->AddReceiver(NOTI_EX_RECEIVER_GROUP_INDICATOR);
258 auto iter = receiver_list.begin();
260 while (iter != receiver_list.end()) {
261 if ((*iter).compare(NOTI_EX_RECEIVER_GROUP_PANEL) != 0
262 && (*iter).compare(NOTI_EX_RECEIVER_GROUP_INDICATOR) != 0)
263 iter = receiver_list.erase(iter);
270 void SetPopUpPolicy(list<shared_ptr<item::AbstractItem>> item) {
275 void SetPopUpPolicy(shared_ptr<item::AbstractItem> item) {
276 notification_setting_h setting;
279 uid_t uid = static_pointer_cast<IItemInfoInternal>(item->GetInfo())->GetUid();
280 ret = noti_setting_service_get_setting_by_app_id(item->GetSenderAppId().c_str(),
282 if (ret != NOTIFICATION_ERROR_NONE) {
283 WARN("Failed get the setting for [%s] [%x]", item->GetSenderAppId().c_str(), ret);
287 notification_setting_get_pop_up_notification(setting, &is_pop_up);
288 notification_setting_free_notification(setting);
289 if (is_pop_up == true)
292 std::list<std::string> receiver_list = item->GetReceiverList();
293 if (receiver_list.size() == 0) {
294 item->AddReceiver(NOTI_EX_RECEIVER_GROUP_PANEL);
295 item->AddReceiver(NOTI_EX_RECEIVER_GROUP_TICKER);
296 item->AddReceiver(NOTI_EX_RECEIVER_GROUP_LOCKSCREEN);
297 item->AddReceiver(NOTI_EX_RECEIVER_GROUP_INDICATOR);
299 auto iter = receiver_list.begin();
301 while (iter != receiver_list.end()) {
302 if ((*iter).compare(NOTI_EX_RECEIVER_GROUP_POPUP) == 0)
303 iter = receiver_list.erase(iter);
310 void SetMemoryTrimTimer(void) {
311 static guint timer = 0;
313 g_source_remove(timer);
315 timer = g_timeout_add(MAX_TIMEOUT, TimeoutHandler, &timer);
318 static gboolean TimeoutHandler(gpointer data) {
319 guint* timer = static_cast<guint*>(data);
320 sqlite3_release_memory(-1);
327 unique_ptr<Reporter> reporter_;
328 unique_ptr<Manager> manager_;
329 map<string, string> hide_map_;
330 multimap<string, string> receiver_group_list_;
331 SharedFile shared_file_;
334 static DPMFacade* facade_;
336 class DPMReporter : public Reporter {
338 void OnUpdate(const IEventInfo& info,
339 list<shared_ptr<item::AbstractItem>> updatedList) {
343 /* check Manager::Hide() */
344 ret = UpdateHideApp(updatedList);
345 if (ret == ERROR_NONE)
348 if (ret != ERROR_NOT_EXIST_ID) {
349 SendError(info, static_cast<NotificationError>(ret));
353 ret = DBManager::UpdateNotification(updatedList);
354 if (ret == ERROR_NONE) {
355 facade_->TranslateText(updatedList);
357 facade_->DelegateManagerEvent(info, updatedList);
359 /* noti to viewers */
360 facade_->DelegateReporterEvent(info, updatedList);
362 SendError(info, static_cast<NotificationError>(ret));
366 void DoDelete(const IEventInfo& info,
367 list<shared_ptr<item::AbstractItem>> deletedList) {
368 int ret = DBManager::DeleteNotification(deletedList);
369 if (ret == ERROR_NONE) {
371 facade_->DelegateManagerEvent(info, deletedList);
373 /* noti to viewers */
374 facade_->DelegateReporterEvent(info, deletedList);
376 facade_->shared_file_.RemovePrivateSharing(deletedList,
377 facade_->receiver_group_list_);
379 SendError(info, static_cast<NotificationError>(ret));
383 void OnDelete(const IEventInfo& info,
384 list<shared_ptr<item::AbstractItem>> deletedList) {
386 if (info.GetEventType() == IEventInfo::EventType::DeleteAll) {
387 list<shared_ptr<item::AbstractItem>> noti_list;
388 if(!info.GetItemId().empty()) /* The item_id is actually an app_id. */
389 noti_list = DBManager::GetNotificationList(
390 info.GetItemId(), facade_->GetUid(info), "");
392 noti_list = DBManager::GetNotificationList(
393 facade_->GetUid(info), info.GetChannel());
395 EventInfo event_info(EventInfo::Delete, info.GetOwner(), info.GetChannel());
396 DoDelete(event_info, noti_list);
398 DoDelete(info, deletedList);
402 void OnEvent(const IEventInfo& info,
403 list<shared_ptr<item::AbstractItem>> noti_list) override {
404 LOGI("Event received (%d) !!", (int)info.GetEventType());
405 int type = info.GetEventType();
408 case IEventInfo::EventType::Update:
409 OnUpdate(info, noti_list);
411 case IEventInfo::EventType::Delete:
412 OnDelete(info, noti_list);
414 case IEventInfo::EventType::DeleteAll:
415 OnDelete(info, noti_list);
417 case IEventInfo::EventType::Register:
424 facade_->SetMemoryTrimTimer();
427 list<shared_ptr<item::AbstractItem>> OnRequestEvent(const IEventInfo& info) override {
428 list<shared_ptr<item::AbstractItem>> item_list;
430 DBG("Get report !!! %s", info.GetItemId().c_str());
431 item_list = DBManager::GetNotificationList(facade_->GetUid(info),
432 ((const IEventInfoInternal&)info).GetChannel().c_str());
434 facade_->shared_file_.SetPrivateSharing(item_list,
435 facade_->receiver_group_list_);
437 facade_->TranslateText(item_list);
438 facade_->SetMemoryTrimTimer();
443 int OnRequestNumber(const IEventInfo& info) override {
444 DBG("Get count !!! %s", info.GetItemId().c_str());
445 facade_->SetMemoryTrimTimer();
447 return DBManager::GetNotificationList(facade_->GetUid(info)).size();
450 int UpdateHideApp(list<shared_ptr<item::AbstractItem>> updatedList) {
452 for (auto& i : updatedList) {
454 int uid = static_pointer_cast<IItemInfoInternal>(i->GetInfo())->GetUid();
455 DBG("try update hide app_id(%s) sender(%s) uid(%s)",
457 i->GetSenderAppId().c_str(), string(to_string(uid)).c_str());
458 string map_key = i->GetId() + i->GetSenderAppId() + string(to_string(uid));
459 list<string> updated_hide_list = static_pointer_cast<IItemInfoInternal>(i->GetInfo())->GetHideViewerList();
461 /* Check new hide app */
462 auto noti = facade_->hide_map_.find(map_key);
463 if (noti == facade_->hide_map_.end()) {
464 if (updated_hide_list.size() > 0) {
465 for (auto& j : updated_hide_list)
466 hide_list += j + ";";
468 ret = DBManager::UpdateHideList(i, hide_list);
469 if (ret != ERROR_NONE)
472 facade_->hide_map_[map_key] = hide_list;
475 DBG("Empty hide viewer list");
476 return ERROR_NOT_EXIST_ID;
480 /* Check new hide app */
481 hide_list = noti->second;
482 for (auto& j : updated_hide_list) {
483 if (hide_list.find(j + ";") == string::npos) {
484 string new_hide_list = hide_list + j + ";";
485 ret = DBManager::UpdateHideList(i, new_hide_list);
486 if (ret != ERROR_NONE)
489 facade_->hide_map_[map_key] = new_hide_list;
494 return ERROR_NOT_EXIST_ID;
497 void OnRegister(const IEventInfo& info) {
498 std::string receiver_group = info.GetChannel();
499 std::string appid = info.GetOwner();
501 std::multimap<std::string,std::string>::iterator it;
502 for(auto receiver_group_ : facade_->receiver_group_list_) {
503 if (receiver_group_.first.compare(receiver_group) == 0 &&
504 receiver_group_.second.compare(appid) == 0)
508 facade_->receiver_group_list_.insert(make_pair(receiver_group, appid));
512 DPMReporter(std::unique_ptr<IEventSender> sender,
513 std::unique_ptr<IEventListener> listener)
514 : Reporter(move(sender), move(listener)) {
518 class DPMManager : public Manager {
520 void OnAdd(const IEventInfo& info,
521 list<shared_ptr<item::AbstractItem>> addedList) override {
525 ret = ValidateUid(info, addedList);
526 if (ret != ERROR_NONE) {
527 SendError(info, static_cast<NotificationError>(ret));
531 SetIndirectRequest(info, addedList);
533 if (facade_->CheckAllowedToNotify(addedList) == false)
536 facade_->SetDoNoDisturbPolicy(addedList);
537 facade_->SetPopUpPolicy(addedList);
539 ret = DBManager::InsertNotification(addedList);
540 if (ret == ERROR_NONE) {
541 facade_->shared_file_.SetPrivateSharing(addedList,
542 facade_->receiver_group_list_);
543 facade_->TranslateText(addedList);
544 facade_->DelegateReporterEvent(info, addedList);
545 facade_->LaunchDefaultViewer(addedList, NOTIFICATION_OP_INSERT);
547 DBG("SendError !!!");
548 SendError(info, static_cast<NotificationError>(ret));
550 facade_->SetMemoryTrimTimer();
553 void OnUpdate(const IEventInfo& info,
554 list<shared_ptr<item::AbstractItem>> updatedList) override {
558 ret = ValidateUid(info, updatedList);
559 if (ret != ERROR_NONE) {
560 SendError(info, static_cast<NotificationError>(ret));
564 UpdateHideApp(updatedList);
565 SetIndirectRequest(info, updatedList);
567 if (facade_->CheckAllowedToNotify(updatedList) == false)
570 facade_->SetDoNoDisturbPolicy(updatedList);
571 facade_->SetPopUpPolicy(updatedList);
573 ret = DBManager::UpdateNotification(updatedList);
574 if (ret == ERROR_NONE) {
575 facade_->shared_file_.UpdatePrivateSharing(updatedList,
576 facade_->receiver_group_list_);
577 facade_->TranslateText(updatedList);
578 facade_->DelegateReporterEvent(info, updatedList);
579 facade_->LaunchDefaultViewer(updatedList, NOTIFICATION_OP_UPDATE);
581 SendError(info, static_cast<NotificationError>(ret));
583 facade_->SetMemoryTrimTimer();
586 int DoDelete(const IEventInfo& info,
587 list<shared_ptr<item::AbstractItem>> deletedList) {
590 ret = DBManager::DeleteNotification(deletedList);
591 if (ret == ERROR_NONE) {
592 facade_->DelegateReporterEvent(info, deletedList);
593 facade_->shared_file_.RemovePrivateSharing(deletedList,
594 facade_->receiver_group_list_);
596 SendError(info, static_cast<NotificationError>(ret));
601 void OnDelete(const IEventInfo& info,
602 list<shared_ptr<item::AbstractItem>> deletedList) override {
604 if (info.GetEventType() == IEventInfo::EventType::DeleteAll) {
605 list<shared_ptr<item::AbstractItem>> noti_list =
606 DBManager::GetNotificationList(info.GetOwner(), facade_->GetUid(info),
608 EventInfo event_info(EventInfo::Delete, info.GetOwner(), info.GetChannel());
610 DoDelete(event_info, noti_list);
611 facade_->LaunchDefaultViewer(noti_list, NOTIFICATION_OP_DELETE);
613 int64_t priv_id = static_pointer_cast<IItemInfoInternal>
614 (deletedList.front()->GetInfo())->GetPrivateId();
615 list<shared_ptr<item::AbstractItem>> noti_list;
617 noti_list = DBManager::GetNotificationList(info.GetOwner(),
618 deletedList.front()->GetId(), facade_->GetUid(info));
620 noti_list = deletedList;
622 int ret = DoDelete(info, noti_list);
623 if (ret == ERROR_NONE)
624 facade_->LaunchDefaultViewer(deletedList, NOTIFICATION_OP_DELETE);
626 facade_->SetMemoryTrimTimer();
629 list<shared_ptr<item::AbstractItem>> OnRequestEvent(const IEventInfo& info) override {
630 DBG("Get !!! %s", info.GetOwner().c_str());
631 list<shared_ptr<item::AbstractItem>> item_list;
632 uid_t uid = facade_->GetUid(info);
633 facade_->SetMemoryTrimTimer();
635 if (info.GetItemId().empty()) {
636 if (!info.GetChannel().empty()) {
638 item_list = DBManager::GetNotificationList(info.GetOwner(), uid, info.GetChannel());
639 facade_->TranslateText(item_list);
643 item_list = DBManager::GetNotificationList(info.GetOwner(), uid);
644 facade_->TranslateText(item_list);
649 item_list = DBManager::GetNotificationList(info.GetOwner(), info.GetItemId(), uid);
650 facade_->TranslateText(item_list);
655 int OnRequestNumber(const IEventInfo& info) override {
657 DBG("Get count !!! %s, %s", info.GetOwner().c_str(), info.GetChannel().c_str());
658 DBManager::GetCount(info.GetOwner(), info.GetChannel(), facade_->GetUid(info), &count);
659 facade_->SetMemoryTrimTimer();
664 void UpdateHideApp(list<shared_ptr<item::AbstractItem>> updatedList) {
665 for (auto& i : updatedList) {
667 int uid = static_pointer_cast<IItemInfoInternal>(i->GetInfo())->GetUid();
668 string map_key = i->GetId() + i->GetSenderAppId() + string(to_string(uid));
669 list<string> updated_hide_list =
670 static_pointer_cast<item::IItemInfoInternal>(i->GetInfo())->GetHideViewerList();
672 auto noti = facade_->hide_map_.find(map_key);
673 if (noti == facade_->hide_map_.end())
676 /* hide app list synchronization */
677 hide_list = noti->second;
678 istringstream stream(hide_list);
681 while (getline(stream, hide_app_id, ';')) {
682 list<string>::iterator iter = std::find(updated_hide_list.begin(),
683 updated_hide_list.end(), hide_app_id);
684 if (iter == updated_hide_list.end())
685 static_pointer_cast<item::IItemInfoInternal>(i->GetInfo())->AddHideViewer(hide_app_id);
690 void SetIndirectRequest(const IEventInfo& info,
691 list<shared_ptr<AbstractItem>> addedList) {
692 for (auto& i : addedList)
693 SetIndirectRequest(info, i);
696 void SetIndirectRequest(const IEventInfo& info,
697 shared_ptr<AbstractItem> addedItem) {
698 SetIndirectRequest(info, addedItem->GetAction());
700 if (addedItem->GetType() != AbstractItem::Type::Group)
703 auto item_group = static_pointer_cast<GroupItem>(addedItem);
704 auto children_list = item_group->GetChildren();
705 for (auto& i : children_list)
706 SetIndirectRequest(info, i);
709 void SetIndirectRequest(const IEventInfo& info, shared_ptr<AbstractAction>action) {
710 if (action == nullptr || action->GetType() != AbstractAction::Type::AppControl)
713 uid_t uid = static_cast<const IEventInfoInternal&>(info).GetValidatedUid();
714 if (uid < NORMAL_UID_BASE)
717 string owner = static_cast<const IEventInfoInternal&>(info).GetValidatedOwner();
718 app_control_h appcontrol = static_pointer_cast<AppControlAction>(action)->GetAppControl();
720 app_control_export_as_bundle(appcontrol, &b);
722 bundle_del(b, AUL_K_REQUEST_TYPE);
723 bundle_add(b, AUL_K_REQUEST_TYPE, "indirect-request");
725 bundle_del(b, AUL_K_ORG_CALLER_UID);
726 bundle_add(b, AUL_K_ORG_CALLER_UID, std::to_string(uid).c_str());
728 bundle_del(b, AUL_K_ORG_CALLER_APPID);
729 bundle_add(b, AUL_K_ORG_CALLER_APPID, owner.c_str());
731 pkgmgrinfo_appinfo_h handle;
732 int r = pkgmgrinfo_appinfo_get_usr_appinfo(owner.c_str(), uid, &handle);
733 if (r == PMINFO_R_OK) {
734 char* pkgid = nullptr;
735 pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
737 bundle_del(b, AUL_K_ORG_CALLER_PKGID);
738 bundle_add(b, AUL_K_ORG_CALLER_PKGID, pkgid);
740 pkgmgrinfo_appinfo_destroy_appinfo(handle);
743 app_control_import_from_bundle(appcontrol, b);
747 int ValidateUid(const IEventInfo& info, list<shared_ptr<AbstractItem>> addedList) {
749 for (auto& i : addedList) {
750 ret = ValidateUid(info, i);
751 if (ret != ERROR_NONE)
758 int ValidateUid(const IEventInfo& info, shared_ptr<AbstractItem> addedItem) {
759 uid_t validated_uid = static_cast<const IEventInfoInternal&>(info).GetValidatedUid();
760 uid_t item_uid = static_pointer_cast<IItemInfoInternal>
761 (addedItem->GetInfo())->GetUid();
763 if (validated_uid <= NORMAL_UID_BASE) {
764 static_pointer_cast<IItemInfoInternal>
765 (addedItem->GetInfo())->SetUid(tzplatform_getuid(TZ_SYS_DEFAULT_USER));
766 } else if (validated_uid != item_uid) {
767 ERR("Invalid sender uid[%d] noti_uid[%d]", validated_uid, item_uid);
768 return ERROR_INVALID_PARAMETER;
775 DPMManager(std::unique_ptr<IEventSender> sender,
776 std::unique_ptr<IEventListener> listener)
777 : Manager(move(sender), move(listener)) {
781 HAPI int notification_ex_service_init(int restart_count) {
782 facade_ = new DPMFacade(
783 unique_ptr<Reporter>(
785 unique_ptr<DBusSender>(new DBusSender(Manager::GetPath())),
786 unique_ptr<DBusEventListener>(new DBusEventListener(Reporter::GetPath())))),
789 unique_ptr<DBusSender>(new DBusSender(Reporter::GetPath())),
790 unique_ptr<DBusEventListener>(new DBusEventListener(Manager::GetPath())))),
793 notification_init_default_viewer();
794 facade_->SetMemoryTrimTimer();
799 HAPI int notification_ex_service_fini() {
804 HAPI GDBusConnection* notification_ex_service_get_gdbus_connection() {
805 return DBusConnectionManager::GetInst().GetConnection();