Apply next HAL architecture 83/251483/5
authorWootak Jung <wootak.jung@samsung.com>
Thu, 14 Jan 2021 07:38:49 +0000 (16:38 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Wed, 20 Jan 2021 23:49:37 +0000 (08:49 +0900)
Add cap_sys_module capability to bt-core

Change-Id: I428e77e429c277d21d8ba41dc8f7e4ce7d477b8e
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
bt-core/CMakeLists.txt
bt-core/bluetooth-frwk-core.service
bt-core/bt-core-adapter.c
packaging/bluetooth-frwk.spec

index c782570..32c79bf 100644 (file)
@@ -23,7 +23,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED dlog vconf gio-2.0 gio-unix-2.0 eventsystem capi-system-info libactd)
+pkg_check_modules(pkgs REQUIRED dlog vconf gio-2.0 gio-unix-2.0 eventsystem capi-system-info libactd hal-api-bluetooth)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index 6ac73b2..db232ae 100644 (file)
@@ -8,8 +8,11 @@ SmackProcessLabel=System
 SupplementaryGroups=priv_mediastorage priv_externalstorage dialout
 Type=dbus
 BusName=org.projectx.bt_core
+Capabilities=cap_sys_module,cap_kill,cap_net_admin=i
+SecureBits=keep-caps
 ExecStart=/usr/bin/bt-core
 KillMode=process
+Environment=LD_LIBRARY_PATH=/usr/lib/hal
 
 [Install]
 WantedBy=multi-user.target
index 7a79afc..3fab9b0 100644 (file)
@@ -22,6 +22,7 @@
 #include <eventsystem.h>
 #include <stdio.h>
 #include <actd/unit_control.h>
+#include <hal-bluetooth.h>
 
 #include "bt-core-main.h"
 #include "bt-core-adapter.h"
@@ -186,6 +187,21 @@ static int __bt_stack_up(void)
                return -1;
        }
 
+       /* Precondition to start bluetooth hal */
+       ret = hal_bluetooth_get_backend();
+       if (ret < 0) {
+               BT_ERR("hal_bluetooth_get_backend() failed. ret: %d", ret);
+               return -1;
+       }
+
+       /* Start bluetooth hal */
+       ret = hal_bluetooth_start();
+       if (ret < 0) {
+               BT_ERR("hal_bluetooth_start() failed. ret: %d", ret);
+               return -1;
+       }
+       BT_ERR("Started successfully bluetooth hal");
+
        /* activate Bluez */
        ret = __bt_call_systemact_service(BT_SYSTEMACT_BLUEZ_START);
        if (ret < 0) {
@@ -306,8 +322,22 @@ int _bt_disable_adapter(void)
                                if (__bt_call_systemact_service(BT_SYSTEMACT_STACK_DOWN_WITH_RADIO) < 0)
                                        BT_ERR("running script failed");
                        } else {
-                               if (__bt_call_systemact_service(BT_SYSTEMACT_STACK_DOWN) < 0)
-                                       BT_ERR("running script failed");
+                               int ret;
+
+                               /* Precondition to stop bluetooth hal */
+                               ret = hal_bluetooth_get_backend();
+                               if (ret < 0) {
+                                       BT_ERR("hal_bluetooth_get_backend() failed. ret: %d", ret);
+                                       return -1;
+                               }
+
+                               /* Stop bluetooth hal */
+                               ret = hal_bluetooth_stop();
+                               if (ret < 0) {
+                                       BT_ERR("hal_bluetooth_stop() failed. ret: %d", ret);
+                                       return -1;
+                               }
+                               BT_ERR("Stopped successfully bluetooth hal");
                        }
                }
                _bt_core_terminate();
@@ -341,11 +371,22 @@ int _bt_disable_adapter(void)
                                return -1;
                        }
                } else {
-                       if (__bt_call_systemact_service(BT_SYSTEMACT_STACK_DOWN) < 0) {
-                               BT_ERR("running script failed");
-                               __bt_core_set_status(BT_ACTIVATED);
+                       int ret;
+
+                       /* Precondition to stop bluetooth hal */
+                       ret = hal_bluetooth_get_backend();
+                       if (ret < 0) {
+                               BT_ERR("hal_bluetooth_get_backend() failed. ret: %d", ret);
+                               return -1;
+                       }
+
+                       /* Stop bluetooth hal */
+                       ret = hal_bluetooth_stop();
+                       if (ret < 0) {
+                               BT_ERR("hal_bluetooth_stop() failed. ret: %d", ret);
                                return -1;
                        }
+                       BT_ERR("Stopped successfully bluetooth hal");
                }
        }
 
index 2480195..bdd82ed 100644 (file)
@@ -56,6 +56,7 @@ BuildRequires:  pkgconfig(capi-appfw-app-control)
 BuildRequires:  pkgconfig(gmock)
 BuildRequires:  pkgconfig(libactd)
 BuildRequires:  pkgconfig(libsystemd-daemon)
+BuildRequires:  pkgconfig(hal-api-bluetooth)
 
 Requires(post): /usr/bin/vconftool
 Requires(post): /sbin/ldconfig