fix: permission screen - location tap opens settings when permanently denied, battery dialog re-checks on done
This commit is contained in:
parent
650a6efeca
commit
6cbb7a2070
3 changed files with 83 additions and 38 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue