diff --git a/.gitignore b/.gitignore index e9dc58d..a34a8b5 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,8 @@ .packages .pub/ +.fvm/ +.idea/ +local.properties build/ diff --git a/android/build.gradle b/android/build.gradle index bc78bd3..5cd22d4 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -4,25 +4,25 @@ version '1.0' buildscript { repositories { google() - jcenter() + mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.0' + classpath 'com.android.tools.build:gradle:3.5.4' } } rootProject.allprojects { repositories { google() - jcenter() + mavenCentral() } } apply plugin: 'com.android.library' android { - compileSdkVersion 28 + compileSdkVersion 31 defaultConfig { minSdkVersion 21 diff --git a/android/gradle.properties b/android/gradle.properties index 38c8d45..94adc3a 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,4 +1,3 @@ org.gradle.jvmargs=-Xmx1536M -android.enableR8=true android.useAndroidX=true android.enableJetifier=true diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 5866eb1..fec5b9b 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -3,4 +3,6 @@ + + diff --git a/android/src/main/java/com/tablemi/flutter_bluetooth_basic/FlutterBluetoothBasicPlugin.java b/android/src/main/java/com/tablemi/flutter_bluetooth_basic/FlutterBluetoothBasicPlugin.java index 3eca57f..30e752c 100644 --- a/android/src/main/java/com/tablemi/flutter_bluetooth_basic/FlutterBluetoothBasicPlugin.java +++ b/android/src/main/java/com/tablemi/flutter_bluetooth_basic/FlutterBluetoothBasicPlugin.java @@ -15,8 +15,21 @@ import android.content.IntentFilter; import android.content.pm.PackageManager; import android.util.Log; + +import androidx.annotation.NonNull; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Vector; + +import io.flutter.embedding.engine.plugins.FlutterPlugin; +import io.flutter.embedding.engine.plugins.activity.ActivityAware; +import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding; +import io.flutter.plugin.common.BinaryMessenger; import io.flutter.plugin.common.EventChannel; import io.flutter.plugin.common.EventChannel.EventSink; import io.flutter.plugin.common.EventChannel.StreamHandler; @@ -27,319 +40,317 @@ import io.flutter.plugin.common.PluginRegistry.Registrar; import io.flutter.plugin.common.PluginRegistry.RequestPermissionsResultListener; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Vector; +/** + * FlutterBluetoothBasicPlugin + */ +public class FlutterBluetoothBasicPlugin implements FlutterPlugin, MethodCallHandler, ActivityAware, RequestPermissionsResultListener { + private static final String TAG = "BluetoothBasicPlugin"; + private final int id = 0; + private ThreadPool threadPool; + private static final int REQUEST_COARSE_LOCATION_PERMISSIONS = 1451; + private static final String NAMESPACE = "flutter_bluetooth_basic"; + private Activity activity; + private MethodChannel channel; + private EventChannel stateChannel; + private BluetoothAdapter bluetoothAdapter; + private ActivityPluginBinding activityPluginBinding; + + private Result pendingResult; + + // plugin should still contain the static registerWith() method to remain compatible with apps + // that don’t use the v2 Android embedding. + public static void registerWith(Registrar registrar) { + FlutterBluetoothBasicPlugin instance = new FlutterBluetoothBasicPlugin(); + instance.createChannel(registrar.messenger()); + registrar.addRequestPermissionsResultListener(instance); + } -/** FlutterBluetoothBasicPlugin */ -public class FlutterBluetoothBasicPlugin implements MethodCallHandler, RequestPermissionsResultListener { - private static final String TAG = "BluetoothBasicPlugin"; - private int id = 0; - private ThreadPool threadPool; - private static final int REQUEST_COARSE_LOCATION_PERMISSIONS = 1451; - private static final String NAMESPACE = "flutter_bluetooth_basic"; - private final Registrar registrar; - private final Activity activity; - private final MethodChannel channel; - private final EventChannel stateChannel; - private final BluetoothManager mBluetoothManager; - private BluetoothAdapter mBluetoothAdapter; - - private MethodCall pendingCall; - private Result pendingResult; - - public static void registerWith(Registrar registrar) { - final FlutterBluetoothBasicPlugin instance = new FlutterBluetoothBasicPlugin(registrar); - registrar.addRequestPermissionsResultListener(instance); - } - - FlutterBluetoothBasicPlugin(Registrar r){ - this.registrar = r; - this.activity = r.activity(); - this.channel = new MethodChannel(registrar.messenger(), NAMESPACE + "/methods"); - this.stateChannel = new EventChannel(registrar.messenger(), NAMESPACE + "/state"); - this.mBluetoothManager = (BluetoothManager) registrar.activity().getSystemService(Context.BLUETOOTH_SERVICE); - this.mBluetoothAdapter = mBluetoothManager.getAdapter(); - channel.setMethodCallHandler(this); - stateChannel.setStreamHandler(stateStreamHandler); - } - - @Override - public void onMethodCall(MethodCall call, Result result) { - if (mBluetoothAdapter == null && !"isAvailable".equals(call.method)) { - result.error("bluetooth_unavailable", "Bluetooth is unavailable", null); - return; + @Override + public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) { + if (bluetoothAdapter == null && !"isAvailable".equals(call.method)) { + result.error("bluetooth_unavailable", "Bluetooth is unavailable", null); + return; + } + + final Map args = call.arguments(); + + switch (call.method) { + case "state": + state(result); + break; + case "isAvailable": + result.success(bluetoothAdapter != null); + break; + case "isOn": + result.success(bluetoothAdapter.isEnabled()); + break; + case "isConnected": + result.success(threadPool != null); + break; + case "startScan": { + if (ContextCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_COARSE_LOCATION) + != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions( + activity, + new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, + REQUEST_COARSE_LOCATION_PERMISSIONS); + pendingResult = result; + break; + } + startScan(result); + break; + } + case "stopScan": + stopScan(); + result.success(null); + break; + case "connect": + connect(result, args); + break; + case "disconnect": + result.success(disconnect()); + break; + case "destroy": + result.success(destroy()); + break; + case "writeData": + writeData(result, args); + break; + default: + result.notImplemented(); + break; + } } - final Map args = call.arguments(); - - switch (call.method){ - case "state": - state(result); - break; - case "isAvailable": - result.success(mBluetoothAdapter != null); - break; - case "isOn": - result.success(mBluetoothAdapter.isEnabled()); - break; - case "isConnected": - result.success(threadPool != null); - break; - case "startScan": { - if (ContextCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_COARSE_LOCATION) - != PackageManager.PERMISSION_GRANTED) { - ActivityCompat.requestPermissions( - activity, - new String[] {Manifest.permission.ACCESS_COARSE_LOCATION}, - REQUEST_COARSE_LOCATION_PERMISSIONS); - pendingCall = call; - pendingResult = result; - break; + private void state(Result result) { + try { + switch (bluetoothAdapter.getState()) { + case BluetoothAdapter.STATE_OFF: + result.success(BluetoothAdapter.STATE_OFF); + break; + case BluetoothAdapter.STATE_ON: + result.success(BluetoothAdapter.STATE_ON); + break; + case BluetoothAdapter.STATE_TURNING_OFF: + result.success(BluetoothAdapter.STATE_TURNING_OFF); + break; + case BluetoothAdapter.STATE_TURNING_ON: + result.success(BluetoothAdapter.STATE_TURNING_ON); + break; + default: + result.success(0); + break; + } + } catch (SecurityException e) { + result.error("invalid_argument", "Argument 'address' not found", null); } - startScan(call, result); - break; - } - case "stopScan": - stopScan(); - result.success(null); - break; - case "connect": - connect(result, args); - break; - case "disconnect": - result.success(disconnect()); - break; - case "destroy": - result.success(destroy()); - break; - case "writeData": - writeData(result, args); - break; - default: - result.notImplemented(); - break; } - } + private void startScan(Result result) { + Log.d(TAG, "start scan "); - private void getDevices(Result result){ - List> devices = new ArrayList<>(); - for (BluetoothDevice device : mBluetoothAdapter.getBondedDevices()) { - Map ret = new HashMap<>(); - ret.put("address", device.getAddress()); - ret.put("name", device.getName()); - ret.put("type", device.getType()); - devices.add(ret); + try { + startScan(); + result.success(null); + } catch (Exception e) { + result.error("startScan", e.getMessage(), null); + } } - result.success(devices); - } - - private void state(Result result){ - try { - switch(mBluetoothAdapter.getState()) { - case BluetoothAdapter.STATE_OFF: - result.success(BluetoothAdapter.STATE_OFF); - break; - case BluetoothAdapter.STATE_ON: - result.success(BluetoothAdapter.STATE_ON); - break; - case BluetoothAdapter.STATE_TURNING_OFF: - result.success(BluetoothAdapter.STATE_TURNING_OFF); - break; - case BluetoothAdapter.STATE_TURNING_ON: - result.success(BluetoothAdapter.STATE_TURNING_ON); - break; - default: - result.success(0); - break; - } - } catch (SecurityException e) { - result.error("invalid_argument", "Argument 'address' not found", null); + private void invokeMethodUIThread(final String name, final BluetoothDevice device) { + final Map ret = new HashMap<>(); + ret.put("address", device.getAddress()); + ret.put("name", device.getName()); + ret.put("type", device.getType()); + + activity.runOnUiThread(() -> channel.invokeMethod(name, ret)); } - } + private final ScanCallback mScanCallback = new ScanCallback() { + @Override + public void onScanResult(int callbackType, ScanResult result) { + BluetoothDevice device = result.getDevice(); + if (device != null && device.getName() != null) { + invokeMethodUIThread("ScanResult", device); + } + } + }; - private void startScan(MethodCall call, Result result) { - Log.d(TAG,"start scan "); + private void startScan() throws IllegalStateException { + BluetoothLeScanner scanner = bluetoothAdapter.getBluetoothLeScanner(); + if (scanner == null) + throw new IllegalStateException("getBluetoothLeScanner() is null. Is the Adapter on?"); - try { - startScan(); - result.success(null); - } catch (Exception e) { - result.error("startScan", e.getMessage(), null); + // 0:lowPower 1:balanced 2:lowLatency -1:opportunistic + ScanSettings settings = new ScanSettings.Builder().setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build(); + scanner.startScan(null, settings, mScanCallback); } - } - - private void invokeMethodUIThread(final String name, final BluetoothDevice device) { - final Map ret = new HashMap<>(); - ret.put("address", device.getAddress()); - ret.put("name", device.getName()); - ret.put("type", device.getType()); - - activity.runOnUiThread( - new Runnable() { - @Override - public void run() { - channel.invokeMethod(name, ret); - } - }); - } - private ScanCallback mScanCallback = new ScanCallback() { - @Override - public void onScanResult(int callbackType, ScanResult result) { - BluetoothDevice device = result.getDevice(); - if(device != null && device.getName() != null){ - invokeMethodUIThread("ScanResult", device); - } + private void stopScan() { + BluetoothLeScanner scanner = bluetoothAdapter.getBluetoothLeScanner(); + if (scanner != null) scanner.stopScan(mScanCallback); } - }; - - private void startScan() throws IllegalStateException { - BluetoothLeScanner scanner = mBluetoothAdapter.getBluetoothLeScanner(); - if(scanner == null) throw new IllegalStateException("getBluetoothLeScanner() is null. Is the Adapter on?"); - - // 0:lowPower 1:balanced 2:lowLatency -1:opportunistic - ScanSettings settings = new ScanSettings.Builder().setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build(); - scanner.startScan(null, settings, mScanCallback); - } - - private void stopScan() { - BluetoothLeScanner scanner = mBluetoothAdapter.getBluetoothLeScanner(); - if(scanner != null) scanner.stopScan(mScanCallback); - } - - private void connect(Result result, Map args) { - if (args.containsKey("address")) { - String address = (String) args.get("address"); - disconnect(); - - new DeviceConnFactoryManager.Build() - .setId(id) - // Set the connection method - .setConnMethod(DeviceConnFactoryManager.CONN_METHOD.BLUETOOTH) - // Set the connected Bluetooth mac address - .setMacAddress(address) - .build(); - // Open port - threadPool = ThreadPool.getInstantiation(); - threadPool.addSerialTask(new Runnable() { - @Override - public void run() { - DeviceConnFactoryManager.getDeviceConnFactoryManagers()[id].openPort(); - } - }); - result.success(true); - } else { - result.error("invalid_argument", "Argument 'address' not found", null); + private void connect(Result result, Map args) { + if (args.containsKey("address")) { + String address = (String) args.get("address"); + disconnect(); + + new DeviceConnFactoryManager.Build() + .setId(id) + // Set the connection method + .setConnMethod(DeviceConnFactoryManager.CONN_METHOD.BLUETOOTH) + // Set the connected Bluetooth mac address + .setMacAddress(address) + .build(); + // Open port + threadPool = ThreadPool.getInstantiation(); + threadPool.addSerialTask(() -> DeviceConnFactoryManager.getDeviceConnFactoryManagers()[id].openPort()); + + result.success(true); + } else { + result.error("invalid_argument", "Argument 'address' not found", null); + } } - } - - /** - * Reconnect to recycle the last connected object to avoid memory leaks - */ - private boolean disconnect(){ + /** + * Reconnect to recycle the last connected object to avoid memory leaks + */ + private boolean disconnect() { - if(DeviceConnFactoryManager.getDeviceConnFactoryManagers()[id]!=null&&DeviceConnFactoryManager.getDeviceConnFactoryManagers()[id].mPort!=null) { - DeviceConnFactoryManager.getDeviceConnFactoryManagers()[id].reader.cancel(); - DeviceConnFactoryManager.getDeviceConnFactoryManagers()[id].mPort.closePort(); - DeviceConnFactoryManager.getDeviceConnFactoryManagers()[id].mPort=null; + if (DeviceConnFactoryManager.getDeviceConnFactoryManagers()[id] != null && DeviceConnFactoryManager.getDeviceConnFactoryManagers()[id].mPort != null) { + DeviceConnFactoryManager.getDeviceConnFactoryManagers()[id].reader.cancel(); + DeviceConnFactoryManager.getDeviceConnFactoryManagers()[id].mPort.closePort(); + DeviceConnFactoryManager.getDeviceConnFactoryManagers()[id].mPort = null; + } + return true; } - return true; - } - private boolean destroy() { - DeviceConnFactoryManager.closeAllPort(); - if (threadPool != null) { - threadPool.stopThreadPool(); + private boolean destroy() { + DeviceConnFactoryManager.closeAllPort(); + if (threadPool != null) { + threadPool.stopThreadPool(); + } + + return true; } - return true; - } + @SuppressWarnings("unchecked") + private void writeData(Result result, Map args) { + if (args.containsKey("bytes")) { + final ArrayList bytes = Objects.requireNonNull((ArrayList) args.get("bytes")); - @SuppressWarnings("unchecked") - private void writeData(Result result, Map args) { - if (args.containsKey("bytes")) { - final ArrayList bytes = (ArrayList)args.get("bytes"); + threadPool = ThreadPool.getInstantiation(); + threadPool.addSerialTask(() -> { + Vector vectorData = new Vector<>(); + for (int i = 0; i < bytes.size(); ++i) { + Integer val = bytes.get(i); + vectorData.add(Byte.valueOf(Integer.toString(val > 127 ? val - 256 : val))); + } - threadPool = ThreadPool.getInstantiation(); - threadPool.addSerialTask(new Runnable() { - @Override - public void run() { - Vector vectorData = new Vector<>(); - for(int i = 0; i < bytes.size(); ++i) { - Integer val = bytes.get(i); - vectorData.add(Byte.valueOf( Integer.toString(val > 127 ? val-256 : val ) )); - } - - DeviceConnFactoryManager.getDeviceConnFactoryManagers()[id].sendDataImmediately(vectorData); + DeviceConnFactoryManager.getDeviceConnFactoryManagers()[id].sendDataImmediately(vectorData); + }); + } else { + result.error("bytes_empty", "Bytes param is empty", null); } - }); - } else { - result.error("bytes_empty", "Bytes param is empty", null); } - } - - @Override - public boolean onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { - - if (requestCode == REQUEST_COARSE_LOCATION_PERMISSIONS) { - if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { - startScan(pendingCall, pendingResult); - } else { - pendingResult.error("no_permissions", "This app requires location permissions for scanning", null); - pendingResult = null; - } - return true; - } - return false; - - } - - private final StreamHandler stateStreamHandler = new StreamHandler() { - private EventSink sink; - - private final BroadcastReceiver mReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - final String action = intent.getAction(); - Log.d(TAG, "stateStreamHandler, current action: " + action); - - if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) { - threadPool = null; - sink.success(intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1)); - } else if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action)) { - sink.success(1); - } else if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action)) { - threadPool = null; - sink.success(0); + + @Override + public boolean onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { + + if (requestCode == REQUEST_COARSE_LOCATION_PERMISSIONS) { + if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { + startScan(pendingResult); + } else { + pendingResult.error("no_permissions", "This app requires location permissions for scanning", null); + pendingResult = null; + } + return true; } - } - }; + return false; + } + + private void createChannel(BinaryMessenger binaryMessenger) { + channel = new MethodChannel(binaryMessenger, NAMESPACE + "/methods"); + channel.setMethodCallHandler(this); + + stateChannel = new EventChannel(binaryMessenger, NAMESPACE + "/state"); + StreamHandler stateStreamHandler = new StreamHandler() { + private EventSink sink; + + private final BroadcastReceiver mReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + final String action = intent.getAction(); + Log.d(TAG, "stateStreamHandler, current action: " + action); + + if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) { + threadPool = null; + sink.success(intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1)); + } else if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action)) { + sink.success(1); + } else if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action)) { + threadPool = null; + sink.success(0); + } + } + }; + + @Override + public void onListen(Object o, EventSink eventSink) { + sink = eventSink; + IntentFilter filter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED); + filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED); + filter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED); + filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED); + activity.registerReceiver(mReceiver, filter); + } + + @Override + public void onCancel(Object o) { + sink = null; + activity.unregisterReceiver(mReceiver); + } + }; + stateChannel.setStreamHandler(stateStreamHandler); + } + + @Override + public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) { + createChannel(binding.getBinaryMessenger()); + } @Override - public void onListen(Object o, EventSink eventSink) { - sink = eventSink; - IntentFilter filter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED); - filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED); - filter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED); - filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED); - activity.registerReceiver(mReceiver, filter); + public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) { + channel.setMethodCallHandler(null); + stateChannel.setStreamHandler(null); } @Override - public void onCancel(Object o) { - sink = null; - activity.unregisterReceiver(mReceiver); + public void onAttachedToActivity(@NonNull ActivityPluginBinding binding) { + activity = binding.getActivity(); + BluetoothManager bluetoothManager = (BluetoothManager) activity.getSystemService(Context.BLUETOOTH_SERVICE); + bluetoothAdapter = bluetoothManager.getAdapter(); + + activityPluginBinding = binding; + binding.addRequestPermissionsResultListener(this); } - }; + @Override + public void onDetachedFromActivityForConfigChanges() { + onDetachedFromActivity(); + } + @Override + public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding) { + onAttachedToActivity(binding); + } + @Override + public void onDetachedFromActivity() { + if (activityPluginBinding != null) { + activityPluginBinding.removeRequestPermissionsResultListener(this); + activityPluginBinding = null; + } + } } diff --git a/example/android/.gitignore b/example/android/.gitignore index bc2100d..5da0a3e 100644 --- a/example/android/.gitignore +++ b/example/android/.gitignore @@ -1,7 +1,4 @@ -gradle-wrapper.jar /.gradle /captures/ -/gradlew -/gradlew.bat /local.properties GeneratedPluginRegistrant.java diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 316b5cf..adfae8f 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -8,7 +8,7 @@ if (localPropertiesFile.exists()) { def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") + throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") } def flutterVersionCode = localProperties.getProperty('flutter.versionCode') @@ -25,7 +25,7 @@ apply plugin: 'com.android.application' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 28 + compileSdkVersion 31 lintOptions { disable 'InvalidPackage' @@ -35,7 +35,7 @@ android { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.tablemi.flutter_bluetooth_basic_example" minSdkVersion 21 - targetSdkVersion 28 + targetSdkVersion 31 versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -55,7 +55,8 @@ flutter { } dependencies { - testImplementation 'junit:junit:4.12' - androidTestImplementation 'androidx.test:runner:1.1.1' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test:runner:1.4.0' + androidTestImplementation 'androidx.test:rules:1.4.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' } diff --git a/example/android/app/src/androidTest/java/com/tablemi/flutter_bluetooth_basic_example/MainActivityTest.java b/example/android/app/src/androidTest/java/com/tablemi/flutter_bluetooth_basic_example/MainActivityTest.java new file mode 100644 index 0000000..2597fda --- /dev/null +++ b/example/android/app/src/androidTest/java/com/tablemi/flutter_bluetooth_basic_example/MainActivityTest.java @@ -0,0 +1,13 @@ +package com.tablemi.flutter_bluetooth_basic_example; + +import androidx.test.rule.ActivityTestRule; +import dev.flutter.plugins.integration_test.FlutterTestRunner; + +import org.junit.Rule; +import org.junit.runner.RunWith; + +@RunWith(FlutterTestRunner.class) +public class MainActivityTest { + // Replace `MainActivity` with `io.flutter.embedding.android.FlutterActivity` if you removed `MainActivity`. + @Rule public ActivityTestRule rule = new ActivityTestRule<>(MainActivity.class); +} diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index c32e045..ed3d13a 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -15,7 +15,21 @@ android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" - android:windowSoftInputMode="adjustResize"> + android:windowSoftInputMode="adjustResize" + android:exported="true"> + + + + + + diff --git a/example/android/app/src/main/java/com/tablemi/flutter_bluetooth_basic_example/EmbeddingV1Activity.java b/example/android/app/src/main/java/com/tablemi/flutter_bluetooth_basic_example/EmbeddingV1Activity.java new file mode 100644 index 0000000..ddc61bc --- /dev/null +++ b/example/android/app/src/main/java/com/tablemi/flutter_bluetooth_basic_example/EmbeddingV1Activity.java @@ -0,0 +1,15 @@ +package com.tablemi.flutter_bluetooth_basic_example; + +import android.os.Bundle; + +import com.tablemi.flutter_bluetooth_basic.FlutterBluetoothBasicPlugin; + +import io.flutter.app.FlutterActivity; + +public class EmbeddingV1Activity extends FlutterActivity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + FlutterBluetoothBasicPlugin.registerWith(registrarFor("com.tablemi.flutter_bluetooth_basic.FlutterBluetoothBasicPlugin")); + } +} diff --git a/example/android/app/src/main/java/com/tablemi/flutter_bluetooth_basic_example/MainActivity.java b/example/android/app/src/main/java/com/tablemi/flutter_bluetooth_basic_example/MainActivity.java index 87aa346..40c2e9f 100644 --- a/example/android/app/src/main/java/com/tablemi/flutter_bluetooth_basic_example/MainActivity.java +++ b/example/android/app/src/main/java/com/tablemi/flutter_bluetooth_basic_example/MainActivity.java @@ -1,13 +1,6 @@ package com.tablemi.flutter_bluetooth_basic_example; -import androidx.annotation.NonNull; import io.flutter.embedding.android.FlutterActivity; -import io.flutter.embedding.engine.FlutterEngine; -import io.flutter.plugins.GeneratedPluginRegistrant; public class MainActivity extends FlutterActivity { - @Override - public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) { - GeneratedPluginRegistrant.registerWith(flutterEngine); - } } diff --git a/example/android/build.gradle b/example/android/build.gradle index 6de3728..9971094 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,18 +1,18 @@ buildscript { repositories { google() - jcenter() + mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.3' + classpath 'com.android.tools.build:gradle:7.0.2' } } allprojects { repositories { google() - jcenter() + mavenCentral() } } diff --git a/example/android/gradle.properties b/example/android/gradle.properties index 38c8d45..94adc3a 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -1,4 +1,3 @@ org.gradle.jvmargs=-Xmx1536M -android.enableR8=true android.useAndroidX=true android.enableJetifier=true diff --git a/example/android/gradle/wrapper/gradle-wrapper.jar b/example/android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..7454180 Binary files /dev/null and b/example/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 296b146..b8793d3 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip diff --git a/example/android/gradlew b/example/android/gradlew new file mode 100755 index 0000000..1b6c787 --- /dev/null +++ b/example/android/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/example/android/gradlew.bat b/example/android/gradlew.bat new file mode 100644 index 0000000..107acd3 --- /dev/null +++ b/example/android/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 6b4c0f7..f2872cf 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 8.0 + 9.0 diff --git a/example/pubspec.lock b/example/pubspec.lock index 486f161..cbaa811 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -1,13 +1,20 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + archive: + dependency: transitive + description: + name: archive + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.2" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.8.1" boolean_selector: dependency: transitive description: @@ -21,7 +28,7 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.1.0" charcode: dependency: transitive description: @@ -43,6 +50,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.15.0" + crypto: + dependency: transitive + description: + name: crypto + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1" cupertino_icons: dependency: "direct main" description: @@ -82,26 +96,41 @@ packages: path: ".." relative: true source: path - version: "0.1.5" + version: "0.1.6" + flutter_driver: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + fuchsia_remote_debug_protocol: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + integration_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" json_annotation: dependency: transitive description: name: json_annotation url: "https://pub.dartlang.org" source: hosted - version: "3.1.1" + version: "4.1.0" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" + version: "0.12.10" meta: dependency: transitive description: @@ -157,7 +186,7 @@ packages: name: platform url: "https://pub.dartlang.org" source: hosted - version: "3.0.2" + version: "3.0.0" plugin_platform_interface: dependency: transitive description: @@ -212,6 +241,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.0" + sync_http: + dependency: transitive + description: + name: sync_http + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.0" term_glyph: dependency: transitive description: @@ -225,7 +261,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.3" + version: "0.4.2" typed_data: dependency: transitive description: @@ -240,6 +276,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.0" + vm_service: + dependency: transitive + description: + name: vm_service + url: "https://pub.dartlang.org" + source: hosted + version: "7.1.1" + webdriver: + dependency: transitive + description: + name: webdriver + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" win32: dependency: transitive description: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 56bef48..0dcde49 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -17,6 +17,10 @@ dev_dependencies: flutter_bluetooth_basic: path: ../ + integration_test: + sdk: flutter + flutter_driver: + sdk: flutter flutter: uses-material-design: true diff --git a/pubspec.lock b/pubspec.lock index e2e6f12..c5bc584 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,14 +7,21 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "14.0.0" + version: "22.0.0" analyzer: dependency: transitive description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "0.41.2" + version: "1.7.2" + archive: + dependency: transitive + description: + name: archive + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.2" args: dependency: transitive description: @@ -28,7 +35,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.8.1" boolean_selector: dependency: transitive description: @@ -42,14 +49,14 @@ packages: name: build url: "https://pub.dartlang.org" source: hosted - version: "1.6.2" + version: "2.0.3" build_config: dependency: transitive description: name: build_config url: "https://pub.dartlang.org" source: hosted - version: "0.4.6" + version: "0.4.7" build_daemon: dependency: transitive description: @@ -63,21 +70,21 @@ packages: name: build_resolvers url: "https://pub.dartlang.org" source: hosted - version: "1.5.3" + version: "2.0.4" build_runner: dependency: "direct dev" description: name: build_runner url: "https://pub.dartlang.org" source: hosted - version: "1.11.5" + version: "1.12.2" build_runner_core: dependency: transitive description: name: build_runner_core url: "https://pub.dartlang.org" source: hosted - version: "6.1.10" + version: "6.1.12" built_collection: dependency: transitive description: @@ -98,7 +105,7 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.1.0" charcode: dependency: transitive description: @@ -112,7 +119,7 @@ packages: name: checked_yaml url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "2.0.1" cli_util: dependency: transitive description: @@ -161,7 +168,7 @@ packages: name: dart_style url: "https://pub.dartlang.org" source: hosted - version: "1.3.12" + version: "2.1.1" fake_async: dependency: transitive description: @@ -188,11 +195,21 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_driver: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + fuchsia_remote_debug_protocol: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" glob: dependency: transitive description: @@ -206,7 +223,7 @@ packages: name: graphs url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "1.0.0" http_multi_server: dependency: transitive description: @@ -221,6 +238,11 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.0.0" + integration_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" io: dependency: transitive description: @@ -241,14 +263,14 @@ packages: name: json_annotation url: "https://pub.dartlang.org" source: hosted - version: "3.1.1" + version: "4.1.0" json_serializable: dependency: "direct dev" description: name: json_serializable url: "https://pub.dartlang.org" source: hosted - version: "3.5.1" + version: "4.1.4" logging: dependency: transitive description: @@ -262,7 +284,7 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" + version: "0.12.10" meta: dependency: transitive description: @@ -283,7 +305,7 @@ packages: name: package_config url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "2.0.2" path: dependency: transitive description: @@ -298,6 +320,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.11.1" + platform: + dependency: transitive + description: + name: platform + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" pool: dependency: transitive description: @@ -305,6 +334,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.5.0" + process: + dependency: transitive + description: + name: process + url: "https://pub.dartlang.org" + source: hosted + version: "4.2.3" pub_semver: dependency: transitive description: @@ -318,7 +354,7 @@ packages: name: pubspec_parse url: "https://pub.dartlang.org" source: hosted - version: "0.1.8" + version: "1.1.0" rxdart: dependency: "direct main" description: @@ -351,7 +387,7 @@ packages: name: source_gen url: "https://pub.dartlang.org" source: hosted - version: "0.9.10+3" + version: "1.0.3" source_span: dependency: transitive description: @@ -387,6 +423,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.0" + sync_http: + dependency: transitive + description: + name: sync_http + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.0" term_glyph: dependency: transitive description: @@ -400,7 +443,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.3" + version: "0.4.2" timing: dependency: transitive description: @@ -422,6 +465,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.0" + vm_service: + dependency: transitive + description: + name: vm_service + url: "https://pub.dartlang.org" + source: hosted + version: "7.1.1" watcher: dependency: transitive description: @@ -436,6 +486,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + webdriver: + dependency: transitive + description: + name: webdriver + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" yaml: dependency: transitive description: @@ -445,4 +502,4 @@ packages: version: "3.1.0" sdks: dart: ">=2.12.0 <3.0.0" - flutter: ">=1.12.0" + flutter: ">=1.12.13+hotfix.6" diff --git a/pubspec.yaml b/pubspec.yaml index b883526..449a2d4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ homepage: https://github.com/andrey-ushakov/flutter_bluetooth_basic environment: sdk: ">=2.12.0 <3.0.0" - flutter: ">=1.12.0" + flutter: ">=1.12.13+hotfix.6" dependencies: flutter: @@ -17,7 +17,11 @@ dev_dependencies: flutter_test: sdk: flutter build_runner: ^1.0.0 - json_serializable: ^3.2.2 + json_serializable: ^4.1.0 + integration_test: + sdk: flutter + flutter_driver: + sdk: flutter flutter: plugin: diff --git a/test/flutter_bluetooth_basic_e2e.dart b/test/flutter_bluetooth_basic_e2e.dart new file mode 100644 index 0000000..b8a9ab0 --- /dev/null +++ b/test/flutter_bluetooth_basic_e2e.dart @@ -0,0 +1,11 @@ +import 'package:flutter_test/flutter_test.dart'; +// import 'package:battery/battery.dart'; +import 'package:integration_test/integration_test.dart'; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + testWidgets('sample test', (WidgetTester tester) async { + expect(2+2, equals(4)); + }); +}