fix: permission screen - location tap opens settings when permanently denied, battery dialog re-checks on done

This commit is contained in:
fiatcode 2026-04-30 16:21:07 +07:00
parent 650a6efeca
commit 6cbb7a2070
No known key found for this signature in database
3 changed files with 83 additions and 38 deletions

View file

@ -90,6 +90,9 @@ class BridgeModule : FlutterPlugin, MethodChannel.MethodCallHandler {
"openBatteryOptimizationSettings" -> {
openBatteryOptimizationSettings(result)
}
"isBatteryOptimizationDisabled" -> {
result.success(isBatteryOptimizationDisabled())
}
else -> result.notImplemented()
}
}
@ -215,4 +218,14 @@ class BridgeModule : FlutterPlugin, MethodChannel.MethodCallHandler {
}
}
}
private fun isBatteryOptimizationDisabled(): Boolean {
return try {
val powerManager = context?.getSystemService(android.content.Context.POWER_SERVICE) as? android.os.PowerManager
val packageName = context?.packageName ?: ""
powerManager?.isIgnoringBatteryOptimizations(packageName) == true
} catch (e: Exception) {
false
}
}
}