--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __FRAME_BROKER_EXTENSION_H__
+#define __FRAME_BROKER_EXTENSION_H__
+
+#include <frame_broker.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief The frame broker event handle.
+ * @since_tizen 5.5
+ */
+typedef struct frame_broker_event_s *frame_broker_event_h;
+
+/**
+ * @brief Enumeration for frame context event.
+ * @since_tizen 5.5
+ */
+typedef enum {
+ FRAME_CONTEXT_EVENT_STARTED, /** The animation is started. */
+ FRAME_CONTEXT_EVENT_FINISHED, /** The animation is finished. */
+} frame_context_event_e;
+
+/**
+ * @brief Called when the animation of the application is started or finished.
+ * @since_tizen 5.5
+ *
+ * @param[in] app_id The application ID
+ * @param[in] pid The process ID
+ * @param[in] event The frame context event
+ * @param[in] user_data Ther user data passed from the registration function
+ *
+ * @see frame_broker_add_event_handler()
+ * @see #frame_context_event_e
+ */
+typedef void (*frame_broker_event_cb)(const char *app_id, int pid, frame_context_event_e event, void *user_data);
+
+/**
+ * @brief Adds the event handle of the frame broker.
+ * @since_tizen 5.5
+ *
+ * @param[in] app_id The application ID
+ * @param[in] callback The callback function
+ * @param[in] user_data The user data to be passed to the callback function
+ * @param[out] handle The frame broker event handle
+ * @return 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #FRAME_BROKER_ERROR_NONE Successful
+ * @retval #FRAME_BROKER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #FRAME_BROKER_ERROR_IO_ERROR I/O error
+ * @retval #FRAME_BROKER_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see frame_broker_remove_event_handler()
+ * @see frame_broker_event_cb()
+ */
+int frame_broker_add_event_handler(const char *app_id, frame_broker_event_cb callback, void *user_data, frame_broker_event_h *handle);
+
+/**
+ * @brief Removes the event handle of the frame broker.
+ * @since_tizen 5.5
+ *
+ * @param[in] handle The frame broker event handle
+ * @return 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #FRAME_BROKER_ERROR_NONE Successful
+ * @retval #FRAME_BROKER_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see frame_broker_add_event_handler()
+ */
+int frame_broker_remove_event_handler(frame_broker_event_h handle);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __FRAME_BROKER_EXTENSION_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <aul.h>
+#include <aul_app_com.h>
+
+#include "frame_broker_extension.h"
+#include "log_private.h"
+#include "private.h"
+
+struct frame_broker_event_s {
+ aul_app_com_connection_h conn;
+ char *app_id;
+ frame_broker_event_cb callback;
+ void *user_data;
+};
+
+static int __launcher_service_event_cb(const char *endpoint,
+ aul_app_com_result_e res, bundle *envelope, void *user_data)
+{
+ struct frame_broker_event_s *handle = user_data;
+ char *app_id = NULL;
+ char *instance_id = NULL;
+ char *pid_str = NULL;
+ int pid;
+ char *event_str = NULL;
+ frame_context_event_e event;
+
+ bundle_get_str(envelope, AUL_K_APPID, &app_id);
+ if (!app_id) {
+ _E("Failed to get application ID");
+ return -1;
+ }
+
+ bundle_get_str(envelope, AUL_K_INSTANCE_ID, &instance_id);
+ if (!instance_id) {
+ _E("Failed to get instance ID");
+ return -1;
+ }
+
+ bundle_get_str(envelope, AUL_K_PID, &pid_str);
+ if (!pid_str) {
+ _E("Failed to get process ID");
+ return -1;
+ }
+ pid = atoi(pid_str);
+
+ bundle_get_str(envelope, AUL_K_LAUNCHER_SERVICE_EVENT, &event_str);
+ if (!event_str) {
+ _E("Failed to get frame broker event");
+ return -1;
+ }
+ event = atoi(event_str);
+
+ handle->callback(app_id, pid, event, handle->user_data);
+ _I("[__FRAME_BROKER_EVENT__] app_id(%s), id(%s), pid(%d), event(%d)",
+ app_id, instance_id, pid, event);
+
+ return 0;
+}
+
+API int frame_broker_add_event_handler(const char *app_id,
+ frame_broker_event_cb callback, void *user_data,
+ frame_broker_event_h *handle)
+{
+ struct frame_broker_event_s *h;
+ char endpoint[512];
+ int ret;
+
+ if (!app_id || !callback || !handle) {
+ _E("Invalid parameter");
+ return FRAME_BROKER_ERROR_INVALID_PARAMETER;
+ }
+
+ h = calloc(1, sizeof(struct frame_broker_event_s));
+ if (!h) {
+ _E("Out of memory");
+ return FRAME_BROKER_ERROR_OUT_OF_MEMORY;
+ }
+
+ snprintf(endpoint, sizeof(endpoint), "launcher_service_event:%s",
+ app_id);
+ ret = aul_app_com_create(endpoint, NULL, __launcher_service_event_cb,
+ h, &h->conn);
+ if (ret < 0) {
+ _E("aul_app_com_create() is failed. error(%d)", ret);
+ frame_broker_remove_event_handler(h);
+ return FRAME_BROKER_ERROR_IO_ERROR;
+ }
+
+ h->app_id = strdup(app_id);
+ if (!h->app_id) {
+ _E("Failed to duplicate app_id(%s)", app_id);
+ frame_broker_remove_event_handler(h);
+ return FRAME_BROKER_ERROR_OUT_OF_MEMORY;
+ }
+
+ h->callback = callback;
+ h->user_data = user_data;
+
+ *handle = h;
+
+ return FRAME_BROKER_ERROR_NONE;
+}
+
+API int frame_broker_remove_event_handler(frame_broker_event_h handle)
+{
+ if (!handle) {
+ _E("Invalid parameter");
+ return FRAME_BROKER_ERROR_INVALID_PARAMETER;
+ }
+
+ aul_app_com_leave(handle->conn);
+ free(handle->app_id);
+ free(handle);
+
+ return FRAME_BROKER_ERROR_NONE;
+}