* fix: 重构

* fix: 1

* fix: 重构

* fix: 修复 iOS 和 macOS 代码错误

* fix: 优化项目

* fix: 构建项目

* fix: 修复权限问题

* fix: 解决 macOS 沙盒权限问题

* fix: 修复代码问题

* fix: 更新依赖

* fix: 更新依赖项

* fix: 添加缺失的位置权限
This commit is contained in:
Mr剑侠客
2023-08-21 01:06:57 +08:00
committed by GitHub
parent 689b1fb045
commit 0f4fb7f553
127 changed files with 560 additions and 3693 deletions

View File

@ -1,4 +1,4 @@
group 'dev.yanshouwang.bluetooth_low_energy'
group 'dev.yanshouwang.bluetooth_low_energy_android'
version '1.0-SNAPSHOT'
buildscript {
@ -25,6 +25,10 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
if (project.android.hasProperty("namespace")) {
namespace 'dev.yanshouwang.bluetooth_low_energy_android'
}
compileSdkVersion 31
compileOptions {

View File

@ -1 +1 @@
rootProject.name = 'bluetooth_low_energy'
rootProject.name = 'bluetooth_low_energy_android'

View File

@ -1,6 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dev.yanshouwang.bluetooth_low_energy">
package="dev.yanshouwang.bluetooth_low_energy_android">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH"
@ -10,4 +11,4 @@
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
</manifest>
</manifest>

View File

@ -1,4 +1,4 @@
package dev.yanshouwang.bluetooth_low_energy
package dev.yanshouwang.bluetooth_low_energy_android
import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.embedding.engine.plugins.activity.ActivityAware

View File

@ -1,7 +1,7 @@
// Autogenerated from Pigeon (v10.1.6), do not edit directly.
// See also: https://pub.dev/packages/pigeon
package dev.yanshouwang.bluetooth_low_energy
package dev.yanshouwang.bluetooth_low_energy_android
import android.util.Log
import io.flutter.plugin.common.BasicMessageChannel

View File

@ -1,4 +1,4 @@
package dev.yanshouwang.bluetooth_low_energy
package dev.yanshouwang.bluetooth_low_energy_android
import android.bluetooth.BluetoothGatt
import android.bluetooth.BluetoothGattCallback

View File

@ -1,4 +1,4 @@
package dev.yanshouwang.bluetooth_low_energy
package dev.yanshouwang.bluetooth_low_energy_android
import android.content.BroadcastReceiver
import android.content.Context

View File

@ -1,4 +1,4 @@
package dev.yanshouwang.bluetooth_low_energy
package dev.yanshouwang.bluetooth_low_energy_android
import android.bluetooth.BluetoothAdapter
import android.bluetooth.BluetoothDevice
@ -77,9 +77,9 @@ class MyCentralController(private val context: Context, binaryMessenger: BinaryM
throw IllegalStateException()
}
val permissions = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
arrayOf(android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.BLUETOOTH_SCAN, android.Manifest.permission.BLUETOOTH_CONNECT)
arrayOf(android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.BLUETOOTH_SCAN, android.Manifest.permission.BLUETOOTH_CONNECT)
} else {
arrayOf(android.Manifest.permission.ACCESS_FINE_LOCATION)
arrayOf(android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION)
}
val activity = binding.activity
ActivityCompat.requestPermissions(activity, permissions, REQUEST_CODE)

View File

@ -1,4 +1,4 @@
package dev.yanshouwang.bluetooth_low_energy
package dev.yanshouwang.bluetooth_low_energy_android
import io.flutter.plugin.common.PluginRegistry.RequestPermissionsResultListener

View File

@ -1,4 +1,4 @@
package dev.yanshouwang.bluetooth_low_energy
package dev.yanshouwang.bluetooth_low_energy_android
import android.bluetooth.le.ScanCallback
import android.bluetooth.le.ScanResult

View File

@ -1,4 +1,4 @@
package dev.yanshouwang.bluetooth_low_energy
package dev.yanshouwang.bluetooth_low_energy_android
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
@ -13,10 +13,10 @@ import org.mockito.Mockito
* you can run them directly from IDEs that support JUnit such as Android Studio.
*/
internal class BluetoothLowEnergyPluginTest {
internal class BluetoothLowEnergyAndroidPluginTest {
@Test
fun onMethodCall_getPlatformVersion_returnsExpectedValue() {
val plugin = BluetoothLowEnergyAndroid()
val plugin = BluetoothLowEnergyAndroidPlugin()
val call = MethodCall("getPlatformVersion", null)
val mockResult: MethodChannel.Result = Mockito.mock(MethodChannel.Result::class.java)