This patch supports that the daemon process can be the stub.
The daemon or service process has to call the rpc_port_register_proc_info()
to set the process name. When the proxy tries to connect to the stub,
the rpc-port library calls the aul_proc_get_name() if calling the
aul_app_get_appid_bypid() is failed.
Change-Id: I133b04c6a0196420fcd6aeba52085cf73c10f4d3
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
#include <sys/types.h>
#include <unistd.h>
+#include <bundle.h>
#include <rpc-port.h>
#ifdef __cplusplus
*/
uid_t rpc_port_get_target_uid(void);
+/**
+ * @brief Registers the process information.
+ * @since_tizen 6.5
+ * @remarks This function is only for a daemon process.
+ * @param[in] proc_name The process name
+ * @param[in] extra The extra data
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @see rpc_port_register_proc_info()
+ */
+int rpc_port_register_proc_info(const char *proc_name, bundle *extra);
+
+/**
+ * @brief Dergisters the process information.
+ * @since_tizen 6.5
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @see rpc_port_deregister_proc_info()
+ */
+int rpc_port_deregister_proc_info(void);
+
#ifdef __cplusplus
}
#endif
#include <aul.h>
#include <aul_rpc_port.h>
+#include <aul_proc.h>
#include <memory>
int ret = aul_app_get_appid_bypid(pid, app_id, sizeof(app_id));
if (ret != AUL_R_OK) {
_E("aul_app_get_appid_bypid() is failed. pid(%d), error(%d)", pid, ret);
- return "Daemon";
+ char* name = nullptr;
+ ret = aul_proc_get_name(pid, &name);
+ if (ret != AUL_R_OK)
+ return "";
+
+ std::unique_ptr<char, decltype(std::free)*> name_auto(name, std::free);
+ return std::string(name);
}
return std::string(app_id);
* limitations under the License.
*/
+#include <aul_proc.h>
#include <sys/types.h>
#include <tzplatform_config.h>
#include <unistd.h>
return __target_uid;
}
+
+RPC_API int rpc_port_register_proc_info(const char* proc_name, bundle* extra) {
+ if (proc_name == nullptr)
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+
+ int ret = aul_proc_register(proc_name, extra);
+ if (ret != AUL_R_OK)
+ return RPC_PORT_ERROR_IO_ERROR;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+RPC_API int rpc_port_deregister_proc_info(void) {
+ int ret = aul_proc_deregister();
+ if (ret != AUL_R_OK)
+ return RPC_PORT_ERROR_IO_ERROR;
+
+ return RPC_PORT_ERROR_NONE;
+}