Restore TestBatteryOptimization
This commit is contained in:
parent
7efc58cb42
commit
2ed7be243b
|
@ -15,29 +15,30 @@
|
||||||
*/
|
*/
|
||||||
package im.vector.app.fdroid.features.settings.troubleshoot
|
package im.vector.app.fdroid.features.settings.troubleshoot
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
|
import im.vector.app.core.resources.StringProvider
|
||||||
import im.vector.app.core.utils.isIgnoringBatteryOptimizations
|
import im.vector.app.core.utils.isIgnoringBatteryOptimizations
|
||||||
import im.vector.app.core.utils.requestDisablingBatteryOptimization
|
import im.vector.app.core.utils.requestDisablingBatteryOptimization
|
||||||
import im.vector.app.features.settings.troubleshoot.NotificationTroubleshootTestManager
|
import im.vector.app.features.settings.troubleshoot.NotificationTroubleshootTestManager
|
||||||
import im.vector.app.features.settings.troubleshoot.TroubleshootTest
|
import im.vector.app.features.settings.troubleshoot.TroubleshootTest
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
// Not used anymore
|
class TestBatteryOptimization @Inject constructor(
|
||||||
class TestBatteryOptimization(val fragment: Fragment) : TroubleshootTest(R.string.settings_troubleshoot_test_battery_title) {
|
private val context: AppCompatActivity,
|
||||||
|
private val stringProvider: StringProvider
|
||||||
|
) : TroubleshootTest(R.string.settings_troubleshoot_test_battery_title) {
|
||||||
|
|
||||||
override fun perform() {
|
override fun perform() {
|
||||||
val context = fragment.context
|
if (isIgnoringBatteryOptimizations(context)) {
|
||||||
if (context != null && isIgnoringBatteryOptimizations(context)) {
|
description = stringProvider.getString(R.string.settings_troubleshoot_test_battery_success)
|
||||||
description = fragment.getString(R.string.settings_troubleshoot_test_battery_success)
|
|
||||||
status = TestStatus.SUCCESS
|
status = TestStatus.SUCCESS
|
||||||
quickFix = null
|
quickFix = null
|
||||||
} else {
|
} else {
|
||||||
description = fragment.getString(R.string.settings_troubleshoot_test_battery_failed)
|
description = stringProvider.getString(R.string.settings_troubleshoot_test_battery_failed)
|
||||||
quickFix = object : TroubleshootQuickFix(R.string.settings_troubleshoot_test_battery_quickfix) {
|
quickFix = object : TroubleshootQuickFix(R.string.settings_troubleshoot_test_battery_quickfix) {
|
||||||
override fun doFix() {
|
override fun doFix() {
|
||||||
fragment.activity?.let {
|
requestDisablingBatteryOptimization(context, null, NotificationTroubleshootTestManager.REQ_CODE_FIX)
|
||||||
requestDisablingBatteryOptimization(it, fragment, NotificationTroubleshootTestManager.REQ_CODE_FIX)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
status = TestStatus.FAILED
|
status = TestStatus.FAILED
|
||||||
|
|
|
@ -18,6 +18,7 @@ package im.vector.app.push.fcm
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import im.vector.app.fdroid.features.settings.troubleshoot.TestAutoStartBoot
|
import im.vector.app.fdroid.features.settings.troubleshoot.TestAutoStartBoot
|
||||||
import im.vector.app.fdroid.features.settings.troubleshoot.TestBackgroundRestrictions
|
import im.vector.app.fdroid.features.settings.troubleshoot.TestBackgroundRestrictions
|
||||||
|
import im.vector.app.fdroid.features.settings.troubleshoot.TestBatteryOptimization
|
||||||
import im.vector.app.features.settings.troubleshoot.NotificationTroubleshootTestManager
|
import im.vector.app.features.settings.troubleshoot.NotificationTroubleshootTestManager
|
||||||
import im.vector.app.features.settings.troubleshoot.TestAccountSettings
|
import im.vector.app.features.settings.troubleshoot.TestAccountSettings
|
||||||
import im.vector.app.features.settings.troubleshoot.TestDeviceSettings
|
import im.vector.app.features.settings.troubleshoot.TestDeviceSettings
|
||||||
|
@ -30,7 +31,8 @@ class NotificationTroubleshootTestManagerFactory @Inject constructor(private val
|
||||||
private val testDeviceSettings: TestDeviceSettings,
|
private val testDeviceSettings: TestDeviceSettings,
|
||||||
private val testPushRulesSettings: TestPushRulesSettings,
|
private val testPushRulesSettings: TestPushRulesSettings,
|
||||||
private val testAutoStartBoot: TestAutoStartBoot,
|
private val testAutoStartBoot: TestAutoStartBoot,
|
||||||
private val testBackgroundRestrictions: TestBackgroundRestrictions) {
|
private val testBackgroundRestrictions: TestBackgroundRestrictions,
|
||||||
|
private val testBatteryOptimization: TestBatteryOptimization) {
|
||||||
|
|
||||||
fun create(fragment: Fragment): NotificationTroubleshootTestManager {
|
fun create(fragment: Fragment): NotificationTroubleshootTestManager {
|
||||||
val mgr = NotificationTroubleshootTestManager(fragment)
|
val mgr = NotificationTroubleshootTestManager(fragment)
|
||||||
|
@ -40,6 +42,7 @@ class NotificationTroubleshootTestManagerFactory @Inject constructor(private val
|
||||||
mgr.addTest(testPushRulesSettings)
|
mgr.addTest(testPushRulesSettings)
|
||||||
mgr.addTest(testAutoStartBoot)
|
mgr.addTest(testAutoStartBoot)
|
||||||
mgr.addTest(testBackgroundRestrictions)
|
mgr.addTest(testBackgroundRestrictions)
|
||||||
|
mgr.addTest(testBatteryOptimization)
|
||||||
return mgr
|
return mgr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue