File tree Expand file tree Collapse file tree
app/src/main/java/com/nextcloud/client/device Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66 */
77package com.nextcloud.client.device
88
9+ import android.annotation.SuppressLint
910import android.content.Context
1011import android.content.Intent
1112import android.content.IntentFilter
1213import android.os.BatteryManager
1314import android.os.PowerManager
15+ import android.provider.Settings
16+ import androidx.core.net.toUri
1417import com.nextcloud.utils.extensions.registerBroadcastReceiver
1518import com.owncloud.android.datamodel.ReceiverFlag
1619
@@ -27,6 +30,23 @@ internal class PowerManagementServiceImpl(
2730 }
2831 }
2932
33+ /* *
34+ * Opens page for OS's battery saver screen.
35+ */
36+ fun openBatterySaverPage () {
37+ context.startActivity(Intent (Settings .ACTION_BATTERY_SAVER_SETTINGS ))
38+ }
39+
40+ /* *
41+ * Shows dialog to allow background usage for app.
42+ */
43+ @SuppressLint(" BatteryLife" )
44+ fun showIgnoreBatteryOptimizationDialog () {
45+ val intent = Intent (Settings .ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS )
46+ intent.data = " package:${context.packageName} " .toUri()
47+ context.startActivity(intent)
48+ }
49+
3050 override val isIgnoringOptimization: Boolean
3151 get() {
3252 val powerManager = context.getSystemService(Context .POWER_SERVICE ) as PowerManager
You can’t perform that action at this time.
0 commit comments