SAF实现修改
This commit is contained in:
+4
-4
@@ -13,7 +13,7 @@ import io.flutter.plugin.common.EventChannel
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
|
||||
class MainActivity : FlutterActivity() {
|
||||
private val CHANNEL = "com.lxh.battery_health/charge"
|
||||
private val CHARGE_CHANNEL = "com.lxh.battery_health/charge"
|
||||
private val EVENT_CHANNEL = "com.lxh.battery_health/charge_events"
|
||||
private var eventSink: EventChannel.EventSink? = null
|
||||
|
||||
@@ -35,7 +35,7 @@ class MainActivity : FlutterActivity() {
|
||||
when (plug) {
|
||||
BatteryManager.BATTERY_PLUGGED_AC -> "AC"
|
||||
BatteryManager.BATTERY_PLUGGED_USB -> "USB"
|
||||
BatteryManager.BATTERY_PLUGGED_WIRELESS -> "WIRELESS" // 🟢 关键修复
|
||||
BatteryManager.BATTERY_PLUGGED_WIRELESS -> "WIRELESS"
|
||||
else -> "UNKNOWN"
|
||||
}
|
||||
} else {
|
||||
@@ -47,7 +47,7 @@ class MainActivity : FlutterActivity() {
|
||||
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
|
||||
super.configureFlutterEngine(flutterEngine)
|
||||
|
||||
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler { call, result ->
|
||||
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHARGE_CHANNEL).setMethodCallHandler { call, result ->
|
||||
if (call.method == "getChargeState") {
|
||||
val isCharging = getBatteryStatus()
|
||||
val chargeType = if (isCharging) {
|
||||
@@ -56,7 +56,7 @@ class MainActivity : FlutterActivity() {
|
||||
when (plug) {
|
||||
BatteryManager.BATTERY_PLUGGED_AC -> "AC"
|
||||
BatteryManager.BATTERY_PLUGGED_USB -> "USB"
|
||||
BatteryManager.BATTERY_PLUGGED_WIRELESS -> "WIRELESS" // 🟢 关键修复
|
||||
BatteryManager.BATTERY_PLUGGED_WIRELESS -> "WIRELESS"
|
||||
else -> "UNKNOWN"
|
||||
}
|
||||
} else {
|
||||
Reference in New Issue
Block a user