From b8b3655f68a9c0a64bf8cfd9d44dc8aaebb9eb39 Mon Sep 17 00:00:00 2001
From: Aiswarya Cyriac <aiswarya.cyriac@intel.com>
Date: Mon, 23 Jul 2018 15:17:48 +0530
Subject: [PATCH] Fix for Bluetooth device name is resetting to default name
 after reboot

Reason: When the BT device name is updated is getting saved to the
config data pointer but not to the persistent data (i.e. bt_config.conf).
So, when the reboot is happening it is not able to get the updated device
name from the persistent data (i.e. bt_config.conf) as during reboot
bt_config_flush is not called.

Fix: Saving the BT Device name to persistent data using btif_config_flush
once it is set.

Test: Manual Reboot test
Bug: 110301897
Change-Id: Ie329b475eaaf208ed667f27e271a00e230e4b95c
Signed-off-by: Aiswarya Cyriac <aiswarya.cyriac@intel.com>
Signed-off-by: Gaganpreet kaur <gaganpreetx.kaur@intel.com>
---
 system/btif/src/btif_storage.cc | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/system/btif/src/btif_storage.cc b/system/btif/src/btif_storage.cc
index 3b10eeea200..826244af3db 100644
--- a/system/btif/src/btif_storage.cc
+++ b/system/btif/src/btif_storage.cc
@@ -209,10 +209,12 @@ static int prop2cfg(const RawAddress* remote_bd_addr, bt_property_t* prop) {
                             : prop->len;
       strncpy(value, (char*)prop->val, name_length);
       value[name_length] = '\0';
-      if (remote_bd_addr)
+      if (remote_bd_addr) {
         btif_config_set_str(bdstr, BTIF_STORAGE_PATH_REMOTE_NAME, value);
-      else
+      } else {
         btif_config_set_str("Adapter", BTIF_STORAGE_KEY_ADAPTER_NAME, value);
+        btif_config_flush();
+      }
       break;
     }
     case BT_PROPERTY_REMOTE_FRIENDLY_NAME:
-- 
GitLab