Fix device connection state mismatch issue 07/298907/1
authorWootak Jung <wootak.jung@samsung.com>
Fri, 15 Sep 2023 05:26:48 +0000 (14:26 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Fri, 15 Sep 2023 05:26:48 +0000 (14:26 +0900)
- Modifed device added/removed logs
- Remove unnecessary remove/add to list logic
- Fix alignment
- Fix paired list empty issue

Change-Id: Ibcb849ac9668cd86c9b377d020ec17910412f356
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
SettingBluetooth/SettingBluetooth/Model/BtDevice.cs
SettingBluetooth/SettingBluetooth/View/BtDeviceView.cs
packaging/org.tizen.cssetting-bluetooth-1.0.0.rpk

index 93fb89ae701465c2a07b2cffd32a812f83b3dd2a..d13d03e314c7018762c983cfb65fcd18cfc4230a 100644 (file)
@@ -40,15 +40,28 @@ namespace SettingBluetooth
                 mServiceUuids = new string[device.ServiceCount];
                 mServiceUuids = device.ServiceUuidList.ToArray();
                 mServiceMask = device.GetMaskFromUuid(mServiceUuids);
-                if ((mServiceMask & BluetoothServiceClassType.A2dp) == BluetoothServiceClassType.A2dp)
+                if ((mServiceMask & BluetoothServiceClassType.A2dp) == BluetoothServiceClassType.A2dp ||
+                        (mServiceMask & BluetoothServiceClassType.Hsp) == BluetoothServiceClassType.Hsp)
                 {
                     Log.Info(SettingBluetooth.LogTag, "A2dp supported");
                     mIsA2dpSupported = true;
+                    if (device.IsProfileConnected(BluetoothProfileType.AdvancedAudioDistribution) ||
+                            device.IsProfileConnected(BluetoothProfileType.AdvancedAudioDistributionSink) ||
+                            device.IsProfileConnected(BluetoothProfileType.Headset))
+                    {
+                        Log.Info(SettingBluetooth.LogTag, "A2dp connected");
+                        mIsA2dpConnected = true;
+                    }
                 }
                 if ((mServiceMask & BluetoothServiceClassType.Hid) == BluetoothServiceClassType.Hid)
                 {
                     Log.Info(SettingBluetooth.LogTag, "Hid supported");
                     mIsHidSupported = true;
+                    if (device.IsProfileConnected(BluetoothProfileType.HumanInterfaceDevice))
+                    {
+                        Log.Info(SettingBluetooth.LogTag, "Hid connected");
+                        mIsHidConnected = true;
+                    }
                 }
             }
 
index 43b9b60a4e23f6d7db7b0cc496c39b0282716e92..074adf4880cf9902dbde7135a481388a115f45d7 100644 (file)
@@ -222,8 +222,6 @@ namespace SettingBluetooth
                     this.Add(new Device(btDevice));
                 }
             }
-            //this.Add(new Device(btDevice));
-            Log.Info(SettingBluetooth.LogTag, "device(" + btDevice.Address + ") added");
         }
 
         internal void RemoveDevice(BtDevice btDevice)
@@ -233,7 +231,6 @@ namespace SettingBluetooth
                 if (device.Address == btDevice.Address)
                 {
                     this.Remove(device);
-                    Log.Info(SettingBluetooth.LogTag, "device(" + device.Address + ") removed");
                     break;
                 }
             }
@@ -262,6 +259,7 @@ namespace SettingBluetooth
         {
             mSearched.AddDevice(btDevice);
             UpdateState(btDevice); // TODO: don't need to find device item. let's use return value from above function
+            Log.Info(SettingBluetooth.LogTag, "device(" + btDevice.Address + ") added in searched list");
         }
 
         internal void AddToPaired(BtDevice btDevice)
@@ -272,21 +270,23 @@ namespace SettingBluetooth
             }
             mPaired.AddDeviceFront(btDevice);
             UpdateState(btDevice); // TODO: don't need to find device item. let's use return value from above function
+            Log.Info(SettingBluetooth.LogTag, "device(" + btDevice.Address + ") added in paired list");
         }
 
         internal void RemoveFromSearched(BtDevice btDevice)
         {
             mSearched.RemoveDevice(btDevice);
+            Log.Info(SettingBluetooth.LogTag, "device(" + btDevice.Address + ") removed in searched list");
         }
 
         internal void RemoveFromPaired(BtDevice btDevice)
         {
             mPaired.RemoveDevice(btDevice);
-            mPaired.Clear();
             if (mPaired.Count == 0)
             {
                 this.Remove(mPaired);
             }
+            Log.Info(SettingBluetooth.LogTag, "device(" + btDevice.Address + ") removed in paired list");
         }
 
         internal void RemoveAllSearchedDevices()
@@ -549,15 +549,16 @@ namespace SettingBluetooth
                 case BtDeviceState.Unpaired:
                     if (mDeviceSource.FindInSearched(ev.BtDevice) == null)
                     {
-                         // TODO: need to add in front of the list
-                         try
-                         {
-                             mDeviceSource.AddToSearched(ev.BtDevice);
-                         }
-                         catch (Exception e)
-                         {
-                             Log.Debug(SettingBluetooth.LogTag, "Exception : " + e.Message);
-                         }
+                        // TODO: need to add in front of the list
+                        try
+                        {
+                            mDeviceSource.AddToSearched(ev.BtDevice);
+                        }
+                        catch (Exception e)
+                        {
+                            Log.Debug(SettingBluetooth.LogTag, "Exception : " + e.Message);
+                        }
+
                     }
                     if (mDeviceSource.FindInPaired(ev.BtDevice) != null)
                     {
@@ -573,8 +574,6 @@ namespace SettingBluetooth
                 case BtDeviceState.Connected:
                     if (mDeviceSource.FindInPaired(ev.BtDevice) != null)
                     {
-                        mDeviceSource.RemoveFromPaired(ev.BtDevice);
-                        mDeviceSource.AddToPaired(ev.BtDevice);
                         mDeviceSource.UpdateState(ev.BtDevice);
                     }
                     else
@@ -585,8 +584,6 @@ namespace SettingBluetooth
                 case BtDeviceState.Disconnecting:
                     if (mDeviceSource.FindInPaired(ev.BtDevice) != null)
                     {
-                        mDeviceSource.RemoveFromPaired(ev.BtDevice);
-                        mDeviceSource.AddToPaired(ev.BtDevice);
                         mDeviceSource.UpdateState(ev.BtDevice);
                     }
                     break;
index b721e143e982fd6b72af84ebf09b3da457e553c3..0f4f953ffea2ea8332dbd492f7abfd013132cf77 100644 (file)
Binary files a/packaging/org.tizen.cssetting-bluetooth-1.0.0.rpk and b/packaging/org.tizen.cssetting-bluetooth-1.0.0.rpk differ