--- /dev/null
+/*
+* Copyright © 2021 Samsung Electronics co., Ltd. All Rights Reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#include "mmifw.h"
+#include "mmifw-ipc.h"
+#include "mmifw-dbg.h"
+
+#include <tzplatform_config.h>
+#include <unistd.h>
+#include <rpc-port.h>
+
+static rpc_port_proxy_mmifw_h _rpc_h;
+static const char* _appid = "";
+static const char* _stub_appid = "mmi-manager";
+static uid_t _uid = -1;
+static int _connected = 0;
+static mmi_state _state = MMI_STATE_NONE;
+
+rpc_port_proxy_mmifw_h
+mmi_ipc_get_rpc_h(void)
+{
+ return _rpc_h;
+}
+
+mmi_state
+mmi_ipc_get_state(void)
+{
+ return _state;
+}
+
+int
+mmi_ipc_get_uid(void)
+{
+ return _uid;
+}
+
+bool
+mmi_ipc_is_connected(void)
+{
+ return _connected ? true : false;
+}
+
+const char *
+mmi_ipc_get_appid(void)
+{
+ return _appid;
+}
+
+const char *
+mmi_ipc_get_stub_appid(void)
+{
+ return _stub_appid;
+}
+
+static void _on_connected(rpc_port_proxy_mmifw_h h, void *user_data)
+{
+ int r;
+
+ LOGI("...");
+ _connected = 1;
+}
+
+static void _on_disconnected(rpc_port_proxy_mmifw_h h, void *user_data)
+{
+ LOGI("...");
+ _connected = 0;
+}
+static void _on_rejected(rpc_port_proxy_mmifw_h h, void *user_data)
+{
+ LOGI("...");
+ _connected = 0;
+}
+
+int
+mmi_ipc_init(const char *appid)
+{
+ /* initialize handles */
+ _rpc_h = NULL;
+
+ _uid = tzplatform_getuid(TZ_SYS_DEFAULT_USER);
+ LOGI("uid=%d\n", _uid);
+
+ rpc_port_set_target_uid(_uid);
+
+ int r = rpc_port_register_proc_info(appid);
+ if (r != RPC_PORT_ERROR_NONE)
+ {
+ LOGE("Failed to register proc info ! (error:%d)\n", r);
+ goto err;
+ }
+
+ _appid = appid;
+
+ rpc_port_proxy_mmifw_callback_s callback = {
+ .connected = _on_connected,
+ .disconnected = _on_disconnected,
+ .rejected = _on_rejected
+ };
+
+ r = rpc_port_proxy_mmifw_create(_stub_appid, &callback, NULL, &_rpc_h);
+ if (r != RPC_PORT_ERROR_NONE)
+ {
+ LOGE("Failed to create mmifw proxy handle ! (error:%d)\n", r);
+ goto err;
+ }
+
+ r = rpc_port_proxy_mmifw_connect(_rpc_h);
+ if (r != RPC_PORT_ERROR_NONE)
+ {
+ LOGE("Failed to connect to %s ! (error:%d)\n", _stub_appid, r);
+ goto err;
+ }
+
+ return 0;
+err:
+ if (_rpc_h)
+ rpc_port_proxy_destroy(_rpc_h);
+
+ _rpc_h = NULL;
+ return -1;
+}
+
+void
+mmi_ipc_shutdown(void)
+{
+ rpc_port_proxy_mmifw_destroy(_rpc_h);
+ _rpc_h = NULL;
+}
--- /dev/null
+/*
+* Copyright © 2021 Samsung Electronics co., Ltd. All Rights Reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef __MMIFW_IPC_H__
+#define __MMIFW_IPC_H__
+
+#include <rpc-port.h>
+#include "interface/mmifw_proxy.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int mmi_ipc_init(const char *appid);
+void mmi_ipc_shutdown(void);
+
+rpc_port_proxy_mmifw_h mmi_ipc_get_rpc_h(void);
+mmi_state mmi_ipc_get_state(void);
+int mmi_ipc_get_uid(void);
+bool mmi_ipc_is_connected(void);
+const char *mmi_ipc_get_appid(void);
+const char *mmi_ipc_get_stub_appid(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__MMIFW_IPC_H__