From: Wootak Jung Date: Fri, 15 Sep 2023 05:26:48 +0000 (+0900) Subject: Fix device connection state mismatch issue X-Git-Tag: accepted/tizen/unified/20230918.063839~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2cce72c6f14d85dfc61209828853d6debaf546c2;p=profile%2Fiot%2Fapps%2Fdotnet%2Fsetting-bluetooth.git Fix device connection state mismatch issue - 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 --- diff --git a/SettingBluetooth/SettingBluetooth/Model/BtDevice.cs b/SettingBluetooth/SettingBluetooth/Model/BtDevice.cs index 93fb89a..d13d03e 100644 --- a/SettingBluetooth/SettingBluetooth/Model/BtDevice.cs +++ b/SettingBluetooth/SettingBluetooth/Model/BtDevice.cs @@ -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; + } } } diff --git a/SettingBluetooth/SettingBluetooth/View/BtDeviceView.cs b/SettingBluetooth/SettingBluetooth/View/BtDeviceView.cs index 43b9b60..074adf4 100644 --- a/SettingBluetooth/SettingBluetooth/View/BtDeviceView.cs +++ b/SettingBluetooth/SettingBluetooth/View/BtDeviceView.cs @@ -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; diff --git a/packaging/org.tizen.cssetting-bluetooth-1.0.0.rpk b/packaging/org.tizen.cssetting-bluetooth-1.0.0.rpk index b721e14..0f4f953 100644 Binary files a/packaging/org.tizen.cssetting-bluetooth-1.0.0.rpk and b/packaging/org.tizen.cssetting-bluetooth-1.0.0.rpk differ