@ -16,6 +16,7 @@
@@ -16,6 +16,7 @@
package io.element.android.libraries.androidutils.system
import android.annotation.SuppressLint
import android.annotation.TargetApi
import android.app.Activity
import android.content.ActivityNotFoundException
@ -77,6 +78,7 @@ fun Context.getApplicationLabel(packageName: String): String {
@@ -77,6 +78,7 @@ fun Context.getApplicationLabel(packageName: String): String {
* Note : If the user finally does not grant the permission , PushManager . isBackgroundSyncAllowed ( )
* will return false and the notification privacy will fallback to " LOW_DETAIL " .
* /
@SuppressLint ( " BatteryLife " )
fun requestDisablingBatteryOptimization ( activity : Activity , activityResultLauncher : ActivityResultLauncher < Intent > ) {
val intent = Intent ( )
intent . action = Settings . ACTION _REQUEST _IGNORE _BATTERY _OPTIMIZATIONS
@ -114,9 +116,9 @@ fun startNotificationSettingsIntent(context: Context, activityResultLauncher: Ac
@@ -114,9 +116,9 @@ fun startNotificationSettingsIntent(context: Context, activityResultLauncher: Ac
intent . action = Settings . ACTION _APP _NOTIFICATION _SETTINGS
intent . putExtra ( Settings . EXTRA _APP _PACKAGE , context . packageName )
} else {
intent . action = Settings . ACTION _APP _NOTIFICATION _SETTINGS
intent . putExtra ( " app_package " , context . packageName )
intent . putExtra ( " app_uid " , context . applicationInfo ?. uid )
intent . action = Settings . ACTION _APPLICATION _DETAILS _SETTINGS
intent . addFlags ( Intent . FLAG _ACTIVITY _NEW _TASK )
intent . data = Uri . fromParts ( " package " , context . packageName , null )
}
activityResultLauncher . launch ( intent )
}