From e0b4415296f49b3272fab7955a591cf3fe626a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Kojdecki?= Date: Wed, 10 Jun 2020 18:08:30 +0200 Subject: [PATCH] Release 2.2.5 (#476) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix capitalization style for UUID and constant names (#437) * Fix capitalization of UUID in Service * Fix capitalization of UUID in ScanResult * Fix capitalization of UUID in Peripheral * Rename bytes to value * Fix capitalization of UUID in metadata strings in ScanResult * Fix constants capitalization in BleError * Revert "Fix capitalization of UUID in metadata strings in ScanResult" This reverts commit 08516ec65b7a5874331fff3813f97d4b2e511dcb. * Fix capitalization of UUID in managers for classes * Fix capitalization of UUID for InternalBleManager * Fix capitalization of UUID in CharacteristicsMixin * Fix capitalization of UUID in DevicesMixin * Rename bytes to value in internal classes * Add unit tests for Service (#439) * unit test for BleManager * [descriptor] override equals & hashcode functions * [tests] add: mock classes for managers * [service] add: service tests * [tests] create characteristics and descriptors using separate generators * [service][tests] cover generating transactionId when it's not specified * [service][tests] clear mocks interactions after each test * [service][tests] add missing test for getting all descriptors for specified characteristic Co-authored-by: Paweł Byszewski <4048063+pawelByszewski@users.noreply.github.com> * Descriptor unit tests (#441) * unit test for BleManager * [descriptor] override equals & hashcode functions * [tests] add: mock classes for managers * [tests] create characteristics and descriptors using separate generators * [descriptor] add: tests * [descriptor] fix: test names * [tests] move all mocks declarations to one aggregate file * [ble-manager][test] add matcher to always check objects' references * [descriptor][test] add tests that check uniquity of transactionId Co-authored-by: pawelByszewski * [iOS] Fixed casting of Bool arguments received from dart (#451) * Remove root level `Flutter User Facing API.dart` (#455) * rename root level file naming interfered with certain build_runner code generators * remove flutter_user_facing_api.dart * Handle destroyClient call on iOS (#461) * Handle destroyClient call on iOS * Add missing semicolon * [Android] Fix race condition in ConnectionStateStreamHanderl (#468) (#469) * [Android] Fix race condition in ConnectionStateStreamHanderl (#468) Add extra null check and synchronized block in async callback * [Android] Move json generation back into try catch block (#468) * Update pubspec format (#418) * Remove author field * Add supported platforms * Enforce Flutter version * Release 2.2.5 Co-authored-by: Łukasz Rejman Co-authored-by: Bartosz Wilk Co-authored-by: Paweł Byszewski <4048063+pawelByszewski@users.noreply.github.com> Co-authored-by: pawelByszewski Co-authored-by: Tomasz Bogusz Co-authored-by: Dustin Graham Co-authored-by: Leo Huang --- CHANGELOG.md | 8 ++++++++ android/build.gradle | 4 ++-- .../event/ConnectionStateStreamHandler.java | 15 +++++++++++---- ios/Classes/FlutterBleLibPlugin.m | 2 ++ ios/flutter_ble_lib.podspec | 4 ++-- pubspec.yaml | 13 +++++++++---- 6 files changed, 34 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bf7eec9..6ef6d943 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 2.2.5 + +* add missing handling of destroyClient call on iOS +* fix race condition in ConnectionStateStreamHandler (thanks, @cbreezier!) +* fix issue with picking incorrect characteristic on Android when there are multiple characteristics with the same UUID on the peripheral +* update pubspec format to properly display supported platforms +* fix messages in IllegalStateExceptions on Android + ## 2.2.4 * Fix issue where `withResponse` argument was always true when writing to a characteristic on iOS diff --git a/android/build.gradle b/android/build.gradle index de076171..2423646c 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,5 +1,5 @@ group 'com.polidea.flutter_ble_lib' -version '2.2.4' +version '2.2.5' buildscript { repositories { @@ -36,5 +36,5 @@ android { dependencies { implementation 'androidx.annotation:annotation:1.1.0' - implementation 'com.github.Polidea:MultiPlatformBleAdapter:0.1.5' + implementation 'com.github.Polidea:MultiPlatformBleAdapter:0.1.6' } diff --git a/android/src/main/java/com/polidea/flutter_ble_lib/event/ConnectionStateStreamHandler.java b/android/src/main/java/com/polidea/flutter_ble_lib/event/ConnectionStateStreamHandler.java index a506753f..4e183991 100644 --- a/android/src/main/java/com/polidea/flutter_ble_lib/event/ConnectionStateStreamHandler.java +++ b/android/src/main/java/com/polidea/flutter_ble_lib/event/ConnectionStateStreamHandler.java @@ -27,13 +27,20 @@ synchronized public void onCancel(Object o) { synchronized public void onNewConnectionState(final ConnectionStateChange connectionState) { if (eventSink != null) { + final ConnectionStateStreamHandler that = this; new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { - try { - eventSink.success(connectionStateChangeJsonConverter.toJson(connectionState)); - } catch (JSONException e) { - eventSink.error("-1", e.getMessage(), e.getStackTrace()); + synchronized (that) { + // Check again for null - by the time we get into this async runnable our eventSink + // may have been canceled + if (eventSink != null) { + try { + eventSink.success(connectionStateChangeJsonConverter.toJson(connectionState)); + } catch (JSONException e) { + eventSink.error("-1", e.getMessage(), e.getStackTrace()); + } + } } } }); diff --git a/ios/Classes/FlutterBleLibPlugin.m b/ios/Classes/FlutterBleLibPlugin.m index 07e26441..de3e5f04 100644 --- a/ios/Classes/FlutterBleLibPlugin.m +++ b/ios/Classes/FlutterBleLibPlugin.m @@ -69,6 +69,8 @@ + (void)registerWithRegistrar:(NSObject *)registrar { - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result { if ([METHOD_NAME_CREATE_CLIENT isEqualToString:call.method]) { [self createClient:call result:result]; + } else if ([METHOD_NAME_DESTROY_CLIENT isEqualToString:call.method]) { + [self destroyClient]; } else if ([METHOD_NAME_ENABLE_RADIO isEqualToString:call.method]) { [self enable:call result:result]; } else if ([METHOD_NAME_DISABLE_RADIO isEqualToString:call.method]) { diff --git a/ios/flutter_ble_lib.podspec b/ios/flutter_ble_lib.podspec index c950af3d..aa03a4bf 100644 --- a/ios/flutter_ble_lib.podspec +++ b/ios/flutter_ble_lib.podspec @@ -3,7 +3,7 @@ # Pod::Spec.new do |s| s.name = 'flutter_ble_lib' - s.version = '2.2.4' + s.version = '2.2.5' s.summary = 'A new flutter plugin project.' s.description = <<-DESC A new flutter plugin project. @@ -16,7 +16,7 @@ A new flutter plugin project. s.public_header_files = 'Classes/**/*.h' s.dependency 'Flutter' s.swift_versions = ['4.0', '4.2', '5.0'] - s.dependency 'MultiplatformBleAdapter', '~> 0.1.5' + s.dependency 'MultiplatformBleAdapter', '~> 0.1.6' s.ios.deployment_target = '8.0' end diff --git a/pubspec.yaml b/pubspec.yaml index ec93ec18..9c1d1ebc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,11 +1,12 @@ name: flutter_ble_lib description: FlutterBle Library is a flutter library that supports BLE operations. It uses MultiPlatformBleAdapter as a native backend.. -version: 2.2.4 -author: "Polidea " +version: 2.2.5 homepage: https://github.com/Polidea/FlutterBleLib environment: sdk: ">=2.1.0 <3.0.0" + # Flutter versions prior to 1.10 did not support the flutter.plugin.platforms map. + flutter: ">=1.10.0 <2.0.0" dependencies: collection: ^1.14.11 @@ -30,8 +31,12 @@ flutter: # be modified. They are used by the tooling to maintain consistency when # adding or updating assets for this project. plugin: - androidPackage: com.polidea.flutter_ble_lib - pluginClass: FlutterBleLibPlugin + platforms: + android: + package: com.polidea.flutter_ble_lib + pluginClass: FlutterBleLibPlugin + ios: + pluginClass: FlutterBleLibPlugin # To add assets to your plugin package, add an assets section, like this: # assets: # - images/a_dot_burr.jpeg