File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
open_wearable/lib/view_models Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -9,11 +9,12 @@ class WearablesProvider with ChangeNotifier {
99 List <Wearable > get wearables => _wearables;
1010 Map <Wearable , SensorConfigurationProvider > get sensorConfigurationProviders => _sensorConfigurationProviders;
1111
12- void addWearable (Wearable wearable) {
12+ void addWearable (Wearable wearable) async {
1313 // ignore all wearables that are already added
1414 if (_wearables.any ((w) => w.deviceId == wearable.deviceId)) {
1515 return ;
1616 }
17+
1718 _wearables.add (wearable);
1819 if (wearable is SensorConfigurationManager ) {
1920 if (! _sensorConfigurationProviders.containsKey (wearable)) {
@@ -33,6 +34,21 @@ class WearablesProvider with ChangeNotifier {
3334 removeWearable (wearable);
3435 notifyListeners ();
3536 });
37+
38+ if (wearable is StereoDevice ) {
39+ if (await (wearable as StereoDevice ).pairedDevice == null ) {
40+ List <StereoDevice > possiblePairs =
41+ await WearableManager ().findValidPairsFor ((wearable as StereoDevice ), _wearables.whereType <StereoDevice >().toList ());
42+
43+ logger.d ("possible pairs: $possiblePairs " );
44+
45+ if (possiblePairs.isNotEmpty) {
46+ (wearable as StereoDevice ).pair (possiblePairs.first);
47+ logger.i ("Paired ${wearable .name } with ${(wearable as StereoDevice ).pairedDevice }" );
48+ }
49+ }
50+ }
51+
3652 notifyListeners ();
3753 }
3854
You can’t perform that action at this time.
0 commit comments