* This API is only for Appfw internally.
*/
int aul_notify_exit(void);
+int aul_notify_start(void);
#ifdef __cplusplus
}
RPC_PORT_CREATE_SOCKET_PAIR = 101,
RPC_PORT_NOTIFY_RPC_FINISHED = 102,
COMPLICATION_UPDATE_REQUEST = 103,
+ APP_NOTIFY_START = 104,
APP_CMD_MAX
};
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
+#include <ctype.h>
#include <glib.h>
#include <gio/gio.h>
#include <ttrace.h>
return 0;
}
+static int __get_preinit_fd(void)
+{
+ int fd = -1;
+ const char *listen_fd;
+
+ listen_fd = getenv("AUL_LISTEN_FD");
+ if (listen_fd) {
+ if (isdigit(*listen_fd))
+ fd = atoi(listen_fd);
+ unsetenv("AUL_LISTEN_FD");
+ }
+
+ return fd;
+}
+
int aul_initialize()
{
+ int flag;
+
if (aul_initialized)
return AUL_R_ECANCELED;
-
- aul_fd = aul_sock_create_server(getpid(), getuid());
- if (aul_fd < 0) {
- _E("aul_init create sock failed");
- return AUL_R_ECOMM;
+ aul_fd = __get_preinit_fd();
+ if (aul_fd > 0 && aul_fd < sysconf(_SC_OPEN_MAX)) {
+ flag = fcntl(aul_fd, F_GETFD);
+ flag |= FD_CLOEXEC;
+ (void)fcntl(aul_fd, F_SETFD, flag);
+ } else {
+ _W("Failed to get preinit fd");
+ aul_fd = aul_sock_create_server(getpid(), getuid());
+ if (aul_fd < 0) {
+ _E("aul_init create sock failed");
+ return AUL_R_ECOMM;
+ }
}
+ aul_notify_start();
aul_initialized = 1;
{
return aul_sock_send_raw(AUL_UTIL_PID, getuid(),
APP_NOTIFY_EXIT, NULL, 0, AUL_SOCK_NOREPLY);
-}
\ No newline at end of file
+}
+
+API int aul_notify_start(void)
+{
+ int r;
+
+ r = aul_sock_send_raw(AUL_UTIL_PID, getuid(),
+ APP_NOTIFY_START, NULL, 0, AUL_SOCK_NOREPLY);
+ return r;
+}