Add discovery auto start function 93/282893/1
authorWootak Jung <wootak.jung@samsung.com>
Thu, 13 Oct 2022 05:02:31 +0000 (14:02 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Thu, 13 Oct 2022 05:02:31 +0000 (14:02 +0900)
get bonded devices when bt enabled
start discovery when bt enabled
start discovery when enter the app

Change-Id: Iec6536719f821979c0e1ad67930a0ea8acf1f02d
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
SettingBluetooth/SettingBluetooth/Controller/AdapterController.cs
SettingBluetooth/SettingBluetooth/Controller/DeviceController.cs
SettingBluetooth/SettingBluetooth/Model/BtModel.cs
SettingBluetooth/SettingBluetooth/Model/BtModelImpl.cs
SettingBluetooth/SettingBluetooth/View/BtDeviceView.cs
SettingBluetooth/SettingBluetooth/View/BtMainView.cs
packaging/org.tizen.cssetting-bluetooth-1.0.0.tpk

index fce381cad3a22baa9ead0136b0c321b4e318fafc..5a7c426730f694f6c4303d8883aa5bcd6512f31e 100644 (file)
@@ -45,5 +45,11 @@ namespace SettingBluetooth.Controller
                 BtModel.StartDiscovery();
             }
         }
+
+        internal static void AutoStart()
+        {
+            Log.Info(Program.LogTag, "Start discovery");
+            BtModel.StartDiscovery();
+        }
     }
 }
index d6c06e41a1735f6ae8e737be1a37540249bca7ec..054898549eb09e74d1b5605e3c40ade584264a13 100644 (file)
@@ -112,6 +112,10 @@ namespace SettingBluetooth.Controller
                         ConnectHid(device.BtDevice);
                     }
                 }
+                else
+                {
+                    Log.Info(Program.LogTag, "No available profile");
+                }
             }
             else
             {
index 75c3ba1ff5ff6d0092baf54c460eee2ca852cee7..39a997295b1870edfcdbf6635a4b8cfb47bf5731 100644 (file)
@@ -44,6 +44,11 @@ namespace SettingBluetooth.Model
             BtModelImpl.Instance.StopDiscovery();
         }
 
+        internal static void GetBondedDevices()
+        {
+            BtModelImpl.Instance.GetBondedDevices();
+        }
+
         internal static event EventHandler<BtOperationStateChangedEventArgs> OperationStateChanged
         {
             add
index 2a63effa17dbaa1f367900ee45760a92b851a1d3..31a4051a53439b1564334bcc91fea4f83763bb8f 100644 (file)
@@ -55,24 +55,28 @@ namespace SettingBluetooth.Model
             mOperationStateChanged?.Invoke(null, new BtOperationStateChangedEventArgs(BtOperationState.Searched));
         }
 
+        internal void GetBondedDevices()
+        {
+            IEnumerable<BluetoothDevice> devices;
+            BtDevice btDevice;
+            BtDeviceChangedEventArgs args;
+            devices = BluetoothAdapter.GetBondedDevices();
+
+            foreach (BluetoothDevice device in devices)
+            {
+                Log.Info(Program.LogTag, "GetBondedDevices. Address: " + device.Address + ", Name: " + device.Name);
+                btDevice = new BtDevice(device, BtDeviceState.Paired);
+                args = new BtDeviceChangedEventArgs(btDevice);
+                mDeviceChanged?.Invoke(null, args);
+            }
+        }
+
         private void AdapterStateChanged(object obj, StateChangedEventArgs ev)
         {
             if (ev.BTState == BluetoothState.Enabled)
             {
                 mOperationStateChanged?.Invoke(null, new BtOperationStateChangedEventArgs(BtOperationState.Activated));
-
-                IEnumerable<BluetoothDevice> devices;
-                BtDevice btDevice;
-                BtDeviceChangedEventArgs args;
-
-                devices = BluetoothAdapter.GetBondedDevices();
-                foreach (BluetoothDevice device in devices)
-                {
-                    Log.Info(Program.LogTag, "GetBondedDevices. Address: " + device.Address + ", Name: " + device.Name);
-                    btDevice = new BtDevice(device, BtDeviceState.Paired);
-                    args = new BtDeviceChangedEventArgs(btDevice);
-                    mDeviceChanged?.Invoke(null, args);
-                }
+                GetBondedDevices();
             }
             else
             {
index f7e798e29eae73211293a0321d701da15363be85..1c2e100db0aaf921724bd596be7bc469a2bba3b3 100644 (file)
@@ -406,6 +406,15 @@ namespace SettingBluetooth
             view.Add(mScanButton);
         }
 
+        internal static void AddDeviceView(View view)
+        {
+            Log.Info(Program.LogTag, "Add device view");
+            AddPairedDeviceView(view);
+            AddSearchedDeviceView(view);
+            BtModel.GetBondedDevices();
+            AdapterController.AutoStart();
+        }
+
         internal static void RemovePairedDeviceView(View view)
         {
             if (mPairedDeviceView)
index 18554675efd50d30ebfa2b721e07bac5e71e0922..e6749ee6e84a4f26fccbb589503cf8556293ff43 100644 (file)
@@ -32,9 +32,7 @@ namespace SettingBluetooth
                 case BtOperationState.Deactivating:
                     break;
                 case BtOperationState.Activated:
-                    Log.Info(Program.LogTag, "Add initial view");
-                    BtDeviceView.AddPairedDeviceView(mMainView);
-                    BtDeviceView.AddSearchedDeviceView(mMainView);
+                    BtDeviceView.AddDeviceView(mMainView);
                     break;
                 case BtOperationState.Activating:
                     break;
@@ -91,6 +89,11 @@ namespace SettingBluetooth
             BtModel.OperationStateChanged += BtModelOperationStateChanged;
             BtModel.DeviceChanged += BtDeviceView.BtModelDeviceChanged;
 
+            if (BtModel.IsEnabled)
+            {
+                BtDeviceView.AddDeviceView(mMainView);
+            }
+
             mMainPage = new ContentPage()
             {
                 AppBar = appBar,
index 2b53b8edb1a643fa964c4daf13d028d27bf2c37e..ff55c71e6db04f090e9f7737324b544c0a07805d 100644 (file)
Binary files a/packaging/org.tizen.cssetting-bluetooth-1.0.0.tpk and b/packaging/org.tizen.cssetting-bluetooth-1.0.0.tpk differ