OSDN Git Service

Merge "Add guest mode functionality (2/3)" into mnc-dev
[android-x86/system-bt.git] / btif / src / bluetooth.c
index 8863f75..b4d5a62 100644 (file)
@@ -56,6 +56,7 @@
 #include "osi/include/osi.h"
 #include "stack_manager.h"
 #include "btif_config.h"
+#include "btif_storage.h"
 
 /************************************************************************************
 **  Constants & Macros
@@ -68,6 +69,7 @@
 ************************************************************************************/
 
 bt_callbacks_t *bt_hal_cbacks = NULL;
+bool restricted_mode = FALSE;
 
 /** Operating System specific callouts for resource management */
 bt_os_callouts_t *bt_os_callouts = NULL;
@@ -136,8 +138,10 @@ static int init(bt_callbacks_t *callbacks) {
   return BT_STATUS_SUCCESS;
 }
 
-static int enable(void) {
-  LOG_INFO("%s", __func__);
+static int enable(bool start_restricted) {
+  LOG_INFO(LOG_TAG, "%s: start restricted = %d", __func__, start_restricted);
+
+  restricted_mode = start_restricted;
 
   if (!interface_ready())
     return BT_STATUS_NOT_READY;
@@ -158,6 +162,10 @@ static void cleanup(void) {
   stack_manager_get_interface()->clean_up_stack_async();
 }
 
+bool is_restricted_mode() {
+  return restricted_mode;
+}
+
 static int get_adapter_properties(void)
 {
     /* sanity check */
@@ -268,6 +276,9 @@ static int cancel_bond(const bt_bdaddr_t *bd_addr)
 
 static int remove_bond(const bt_bdaddr_t *bd_addr)
 {
+    if (is_restricted_mode() && !btif_storage_is_restricted_device(bd_addr))
+        return BT_STATUS_SUCCESS;
+
     /* sanity check */
     if (interface_ready() == FALSE)
         return BT_STATUS_NOT_READY;