--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <hal/hal-common.h>
+
+#include "hal-device-external_connection-interface.h"
+#include "common.h"
+
+static hal_backend_device_external_connection_funcs *hal_device_external_connection_funcs = NULL;
+
+int hal_device_external_connection_passthrough_get_backend(void)
+{
+ int ret;
+
+ if (hal_device_external_connection_funcs)
+ return 0;
+
+ hal_device_external_connection_funcs = calloc(1, sizeof(hal_backend_device_external_connection_funcs));
+ if (!hal_device_external_connection_funcs)
+ return -ENOMEM;
+
+ ret = hal_common_get_backend(HAL_MODULE_DEVICE_EXTERNAL_CONNECTION, (void **)&hal_device_external_connection_funcs);
+ if (ret < 0) {
+ _E("Failed to get device-external-connection backend");
+ free(hal_device_external_connection_funcs);
+ hal_device_external_connection_funcs = NULL;
+ return -ENOTSUP;
+ }
+
+ return 0;
+}
+
+int hal_device_external_connection_passthrough_put_backend(void)
+{
+ int ret = 0;
+
+ if (!hal_device_external_connection_funcs)
+ return 0;
+
+ ret = hal_common_put_backend(HAL_MODULE_DEVICE_EXTERNAL_CONNECTION, (void *)hal_device_external_connection_funcs);
+ if (ret < 0) {
+ _E("Failed to put device-exeternal-connection backend");
+ return ret;
+ }
+
+ free(hal_device_external_connection_funcs);
+ hal_device_external_connection_funcs = NULL;
+
+ return 0;
+}
+
+
+int hal_device_external_connection_passthrough_register_changed_event(hal_device_external_connection_updated_cb updated_cb, void *user_data)
+{
+ int ret;
+
+ if (!updated_cb)
+ return -EINVAL;
+
+ if (!hal_device_external_connection_funcs) {
+ if ((ret = hal_device_external_connection_passthrough_get_backend()) < 0)
+ return ret;
+ }
+
+ if (!hal_device_external_connection_funcs ||
+ !hal_device_external_connection_funcs->register_changed_event)
+ return -ENOTSUP;
+
+ return hal_device_external_connection_funcs->register_changed_event(updated_cb, user_data);
+}
+
+int hal_device_external_connection_passthrough_unregister_changed_event(hal_device_external_connection_updated_cb updated_cb)
+{
+ int ret;
+
+ if (!updated_cb)
+ return -EINVAL;
+
+ if (!hal_device_external_connection_funcs) {
+ if ((ret = hal_device_external_connection_passthrough_get_backend()) < 0)
+ return ret;
+ }
+
+ if (!hal_device_external_connection_funcs ||
+ !hal_device_external_connection_funcs->unregister_changed_event)
+ return -ENOTSUP;
+
+ hal_device_external_connection_funcs->unregister_changed_event(updated_cb);
+ return 0;
+}
+
+int hal_device_external_connection_passthrough_get_current_state(hal_device_external_connection_updated_cb updated_cb, void *user_data)
+{
+ int ret;
+
+ if (!updated_cb)
+ return -EINVAL;
+
+ if (!hal_device_external_connection_funcs) {
+ if ((ret = hal_device_external_connection_passthrough_get_backend()) < 0)
+ return ret;
+ }
+
+ if (!hal_device_external_connection_funcs ||
+ !hal_device_external_connection_funcs->get_current_state)
+ return -ENOTSUP;
+
+ return hal_device_external_connection_funcs->get_current_state(updated_cb, user_data);
+}
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __HAL_DEVICE_EXTERNAL_CONNECTION_PASSTHROUGH_H__
+#define __HAL_DEVICE_EXTERNAL_CONNECTION_PASSTHROUGH_H__
+
+#include "hal-device-external_connection-interface.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int hal_device_external_connection_passthrough_get_backend(void);
+int hal_device_external_connection_passthrough_put_backend(void);
+int hal_device_external_connection_passthrough_register_changed_event(hal_device_external_connection_updated_cb updated_cb, void *data);
+int hal_device_external_connection_passthrough_unregister_changed_event(hal_device_external_connection_updated_cb updated_cb);
+int hal_device_external_connection_passthrough_get_current_state(hal_device_external_connection_updated_cb updated_cb, void *data);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __HAL_DEVICE_EXTERNAL_CONNECTION_PASSTHROUGH_H__ */