#include <stdlib.h>
#include <notification_type.h>
#include <notification_viewer.h>
+#include <aul.h>
+#include <app_control_internal.h>
+#include <pkgmgr-info.h>
+#include <bundle.h>
+#include <bundle_internal.h>
#include <iostream>
#include <sstream>
#include <notification-ex/ievent_info_internal.h>
#include <notification-ex/iitem_info_internal.h>
#include <notification-ex/shared_file.h>
+#include <notification-ex/group_item.h>
+#include <notification-ex/app_control_action.h>
#include "debug.h"
#include "notification_ex_service.h"
+#define NORMAL_UID_BASE 5000
+
using namespace std;
using namespace notification;
using namespace notification::item;
DBG("Add !!!");
int ret;
+ SetIndirectRequest(info, addedItem);
+
ret = DBManager::InsertNotification(addedItem);
if (ret == ERROR_NONE) {
facade_->shared_file_.SetPrivateSharing(addedItem,
int ret;
UpdateHideApp(updatedItem);
+ SetIndirectRequest(info, updatedItem);
ret = DBManager::UpdateNotification(updatedItem);
if (ret == ERROR_NONE) {
}
}
+ void SetIndirectRequest(const IEventInfo& info,
+ list<shared_ptr<AbstractItem>> addedItem) {
+ for (auto& i : addedItem)
+ SetIndirectRequest(info, i);
+ }
+
+ void SetIndirectRequest(const IEventInfo& info,
+ shared_ptr<AbstractItem> addedItem) {
+ SetIndirectRequest(info, addedItem->GetAction());
+
+ if (addedItem->GetType() != AbstractItem::Type::Group)
+ return;
+
+ auto item_group = static_pointer_cast<GroupItem>(addedItem);
+ auto children_list = item_group->GetChildren();
+ for (auto& i : children_list)
+ SetIndirectRequest(info, i);
+ }
+
+ void SetIndirectRequest(const IEventInfo& info, shared_ptr<AbstractAction>action) {
+ if (action == nullptr || action->GetType() != AbstractAction::Type::AppControl)
+ return;
+
+ uid_t uid = static_cast<const IEventInfoInternal&>(info).GetValidatedUid();
+ if (uid < NORMAL_UID_BASE)
+ return;
+
+ string owner = static_cast<const IEventInfoInternal&>(info).GetValidatedOwner();
+ app_control_h appcontrol = static_pointer_cast<AppControlAction>(action)->GetAppControl();
+ bundle* b = nullptr;
+ app_control_export_as_bundle(appcontrol, &b);
+
+ bundle_del(b, AUL_K_REQUEST_TYPE);
+ bundle_add(b, AUL_K_REQUEST_TYPE, "indirect-request");
+
+ bundle_del(b, AUL_K_ORG_CALLER_UID);
+ bundle_add(b, AUL_K_ORG_CALLER_UID, std::to_string(uid).c_str());
+
+ bundle_del(b, AUL_K_ORG_CALLER_APPID);
+ bundle_add(b, AUL_K_ORG_CALLER_APPID, owner.c_str());
+
+ pkgmgrinfo_appinfo_h handle;
+ int r = pkgmgrinfo_appinfo_get_usr_appinfo(owner.c_str(), uid, &handle);
+ if (r == PMINFO_R_OK) {
+ char* pkgid = nullptr;
+ pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
+ if (pkgid) {
+ bundle_del(b, AUL_K_ORG_CALLER_PKGID);
+ bundle_add(b, AUL_K_ORG_CALLER_PKGID, pkgid);
+ }
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
+ }
+
+ app_control_import_from_bundle(appcontrol, b);
+ bundle_free(b);
+ }
+
public:
DPMManager(std::unique_ptr<IEventSender> sender,
std::unique_ptr<IEventListener> listener)