#include <security-manager.h>
#include "eventsystem_daemon.h"
+#define DEFAULT_USER tzplatform_getuid(TZ_SYS_DEFAULT_USER)
#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
#define ROOT_USER 0
return ES_R_OK;
}
-static int __esd_get_user_items(void)
+static int __esd_get_user_items(uid_t uid)
{
int ret = 0;
- int i = 0;
- uid_t *uids = NULL;
- uid_t cur_uid = 0;
pkgmgrinfo_appinfo_filter_h handle = NULL;
- ret = sd_get_uids(&uids);
+ _I("get user items for uid(%d)", uid);
+ /* reset user's item */
+ __esd_launch_table_remove_private_usr_items();
+
+ ret = pkgmgrinfo_appinfo_filter_create(&handle);
if (ret < 0) {
- _E("failed to get uids (%d)", ret);
+ _E("failed to create appinfo filter");
return ES_R_ERROR;
}
-
- if (ret == 0 || uids == NULL) {
- _I("there is no uid for now");
- } else {
- /* reset user's item */
- __esd_launch_table_remove_private_usr_items();
- for (i = 0; i < ret; i++) {
- cur_uid = uids[i];
- _I("found uid(%d)", cur_uid);
-
- ret = pkgmgrinfo_appinfo_filter_create(&handle);
- if (ret < 0) {
- _E("failed to create appinfo filter");
- return ES_R_ERROR;
- }
- ret = pkgmgrinfo_appinfo_filter_add_string(handle,
- PMINFO_APPINFO_PROP_APP_COMPONENT, "svcapp");
- if (ret < 0) {
- _E("failed to add appinfo filter string");
- pkgmgrinfo_appinfo_filter_destroy(handle);
- return ES_R_ERROR;
- }
- ret = pkgmgrinfo_appinfo_filter_add_string(handle,
- PMINFO_APPINFO_PROP_APP_OPERATION, APPSVC_OPERATION_LAUNCH_ON_EVENT);
- if (ret < 0) {
- _E("failed to add appinfo filter string");
- pkgmgrinfo_appinfo_filter_destroy(handle);
- return ES_R_ERROR;
- }
- ret = pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle,
- __esd_add_appinfo_handler, &cur_uid, cur_uid);
- if (ret < 0) {
- _E("appinfo filter foreach error");
- pkgmgrinfo_appinfo_filter_destroy(handle);
- return ES_R_ERROR;
- }
- pkgmgrinfo_appinfo_filter_destroy(handle);
- }
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle,
+ PMINFO_APPINFO_PROP_APP_COMPONENT, "svcapp");
+ if (ret < 0) {
+ _E("failed to add appinfo filter string");
+ pkgmgrinfo_appinfo_filter_destroy(handle);
+ return ES_R_ERROR;
}
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle,
+ PMINFO_APPINFO_PROP_APP_OPERATION, APPSVC_OPERATION_LAUNCH_ON_EVENT);
+ if (ret < 0) {
+ _E("failed to add appinfo filter string");
+ pkgmgrinfo_appinfo_filter_destroy(handle);
+ return ES_R_ERROR;
+ }
+ ret = pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle,
+ __esd_add_appinfo_handler, &uid, uid);
+ if (ret < 0) {
+ _E("appinfo filter foreach error");
+ pkgmgrinfo_appinfo_filter_destroy(handle);
+ return ES_R_ERROR;
+ }
+ pkgmgrinfo_appinfo_filter_destroy(handle);
__esd_launch_table_print_items();
{
int handle;
bundle *b;
+ guint64 uid = 0;
if (!g_strcmp0(signal_name,
SYSTEMD_DBUS_SIGNAL_STARTUP_FINISHED)) {
handle = creat(ESD_BOOT_COMPLETED, 0640);
if (handle != -1)
close(handle);
+ } else if (!g_strcmp0(signal_name,
+ SYSTEMD_DBUS_SIGNAL_USER_STARTUP_FINISHED)) {
+ g_variant_get(parameters, "(t)", &uid);
+ _I("User session finished uid : %d", uid);
+ if ((uid_t)uid != DEFAULT_USER)
+ __esd_get_user_items((uid_t)uid);
}
}
guint reg_id = 0;
guint boot_id = 0;
+ guint user_boot_id = 0;
GError *error = NULL;
reg_id = g_dbus_connection_register_object(connection,
_E("g_dbus_connection_signal_subscribe() is failed.");
g_object_unref(connection);
}
+
+ user_boot_id = g_dbus_connection_signal_subscribe(connection,
+ NULL,
+ SYSTEMD_DBUS_IFACE_MANAGER,
+ SYSTEMD_DBUS_SIGNAL_USER_STARTUP_FINISHED,
+ SYSTEMD_DBUS_PATH,
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ __esd_signal_handler,
+ NULL,
+ NULL);
+
+ if (user_boot_id == 0) {
+ _E("g_dbus_connection_signal_subscribe() is failed.");
+ g_object_unref(connection);
+ }
}
static void __esd_on_name_acquired(GDBusConnection *connection,
__esd_trusted_busname_print_items();
- __esd_get_user_items();
+ __esd_get_user_items(DEFAULT_USER);
__esd_dbus_name_monitor(connection);
}