#include "notification/notification_manager.h"
+#include <fcntl.h>
+#include <unistd.h>
+
#include <app_control_internal.h>
#include <device/led.h>
#include <notification_internal.h>
return PlatformResult(ErrorCode::NO_ERROR);
}
+bool NotificationPackageEqual(notification_h handle) {
+ LoggerD("Entered");
+ char* package = NULL;
+ char* handle_package = NULL;
+ char cmdline[512] = {0,};
+ char buf[64] = {0,};
+
+ if (notification_get_pkgname(handle, &handle_package))
+ {
+ return false;
+ }
+
+ LoggerD("handle package = %s", handle_package);
+
+ if (app_get_id(&package))
+ {
+
+ int ret = 0;
+ int fd = -1;
+ int pid = getpid();
+
+ snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
+
+ fd = open(buf, O_RDONLY);
+ if (fd < 0) {
+ return false;
+ }
+
+ ret = read(fd, cmdline, sizeof(cmdline) - 1);
+ if (ret <= 0) {
+ close(fd);
+ return false;
+ }
+
+ cmdline[ret] = 0;
+ close(fd);
+
+ if (strlen(cmdline) == strlen(handle_package))
+ {
+ if (!strncmp(cmdline, handle_package, strlen(cmdline)))
+ {
+ return true;
+ }
+ }
+ }
+ else
+ {
+ LoggerD("package = %s", package);
+
+ if (strlen(package) == strlen(handle_package))
+ {
+ if (!strncmp(package, handle_package, strlen(package)))
+ {
+ free(package);
+ return true;
+ }
+ }
+ }
+ free(package);
+ return false;
+}
+
PlatformResult NotificationManager::GetAll(picojson::array& out) {
LoggerD("Enter");
notification_h noti = nullptr;
while (noti_list_iter != nullptr) {
noti = notification_list_get_data(noti_list_iter);
- if (noti != nullptr) {
+ if (noti != nullptr && NotificationPackageEqual(noti)) {
int noti_priv = -1;
ret = notification_get_id(noti, NULL, ¬i_priv);
if (ret != NOTIFICATION_ERROR_NONE) {
return PlatformResult(ErrorCode::UNKNOWN_ERR,
"Get notification image error");
}
-
if (path) {
*image_path = path;
}
const std::string& progess_type,
double* progress_value) {
LoggerD("Enter");
- *progress_value = 0.0;
+ double tmp_progress_value = 0.0;
if (progess_type == kProgressTypeByte) {
- if (notification_get_size(noti_handle, progress_value) !=
+ if (notification_get_size(noti_handle, &tmp_progress_value) !=
NOTIFICATION_ERROR_NONE) {
LoggerE("Get notification size error");
return PlatformResult(ErrorCode::UNKNOWN_ERR,
"Get notification size error");
}
} else if (progess_type == kProgressTypePercentage) {
- if (notification_get_progress(noti_handle, progress_value) !=
+ if (notification_get_progress(noti_handle, &tmp_progress_value) !=
NOTIFICATION_ERROR_NONE) {
LoggerE("Get notification progress error");
return PlatformResult(ErrorCode::UNKNOWN_ERR,
"Unknown notification progress type");
}
- LOGGER(DEBUG) << "Progress " << progess_type << " = " << *progress_value;
+ LOGGER(DEBUG) << "Progress " << progess_type << " = " << tmp_progress_value;
+ *progress_value = tmp_progress_value;
return PlatformResult(ErrorCode::NO_ERROR);
}