Merge "Change the strings on the opt-out toggle to also account for archiving." into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
2368e260fe
@@ -9107,6 +9107,12 @@
|
|||||||
<!-- Summary of the switch preference that controls whether the system will pause app activity when the app has not been used for months [CHAR LIMIT=NONE]-->
|
<!-- Summary of the switch preference that controls whether the system will pause app activity when the app has not been used for months [CHAR LIMIT=NONE]-->
|
||||||
<string name="unused_apps_switch_summary">Remove permissions, delete temporary files, and stop notifications</string>
|
<string name="unused_apps_switch_summary">Remove permissions, delete temporary files, and stop notifications</string>
|
||||||
|
|
||||||
|
<!-- Label of a switch preference that controls whether the system will pause app activity when the app has not been used for a while [CHAR LIMIT=40]-->
|
||||||
|
<string name="unused_apps_switch_v2">Manage app if unused</string>
|
||||||
|
|
||||||
|
<!-- Summary of the switch preference that controls whether the system will pause app activity when the app has not been used for a while [CHAR LIMIT=NONE]-->
|
||||||
|
<string name="unused_apps_switch_summary_v2">Remove permissions, delete temporary files, stop notifications, and archive the app</string>
|
||||||
|
|
||||||
<!-- Label for showing all apps in list [CHAR LIMIT=30] -->
|
<!-- Label for showing all apps in list [CHAR LIMIT=30] -->
|
||||||
<string name="filter_all_apps">All apps</string>
|
<string name="filter_all_apps">All apps</string>
|
||||||
<!-- Label for showing enabled apps in list [CHAR LIMIT=30] -->
|
<!-- Label for showing enabled apps in list [CHAR LIMIT=30] -->
|
||||||
|
@@ -22,6 +22,7 @@ import android.app.AppOpsManager.MODE_IGNORED
|
|||||||
import android.app.AppOpsManager.OP_AUTO_REVOKE_PERMISSIONS_IF_UNUSED
|
import android.app.AppOpsManager.OP_AUTO_REVOKE_PERMISSIONS_IF_UNUSED
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.pm.ApplicationInfo
|
import android.content.pm.ApplicationInfo
|
||||||
|
import android.content.pm.Flags
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.permission.PermissionControllerManager.HIBERNATION_ELIGIBILITY_EXEMPT_BY_SYSTEM
|
import android.permission.PermissionControllerManager.HIBERNATION_ELIGIBILITY_EXEMPT_BY_SYSTEM
|
||||||
import android.permission.PermissionControllerManager.HIBERNATION_ELIGIBILITY_UNKNOWN
|
import android.permission.PermissionControllerManager.HIBERNATION_ELIGIBILITY_UNKNOWN
|
||||||
@@ -60,8 +61,17 @@ fun HibernationSwitchPreference(app: ApplicationInfo) {
|
|||||||
val isCheckedState = presenter.isCheckedFlow.collectAsStateWithLifecycle(initialValue = null)
|
val isCheckedState = presenter.isCheckedFlow.collectAsStateWithLifecycle(initialValue = null)
|
||||||
SwitchPreference(remember {
|
SwitchPreference(remember {
|
||||||
object : SwitchPreferenceModel {
|
object : SwitchPreferenceModel {
|
||||||
override val title = context.getString(R.string.unused_apps_switch)
|
override val title =
|
||||||
override val summary = { context.getString(R.string.unused_apps_switch_summary) }
|
if (isArchivingEnabled())
|
||||||
|
context.getString(R.string.unused_apps_switch_v2)
|
||||||
|
else
|
||||||
|
context.getString(R.string.unused_apps_switch)
|
||||||
|
override val summary = {
|
||||||
|
if (isArchivingEnabled())
|
||||||
|
context.getString(R.string.unused_apps_switch_summary_v2)
|
||||||
|
else
|
||||||
|
context.getString(R.string.unused_apps_switch_summary)
|
||||||
|
}
|
||||||
override val changeable = { isEligibleState }
|
override val changeable = { isEligibleState }
|
||||||
override val checked = { if (changeable()) isCheckedState.value else false }
|
override val checked = { if (changeable()) isCheckedState.value else false }
|
||||||
override val onCheckedChange = presenter::onCheckedChange
|
override val onCheckedChange = presenter::onCheckedChange
|
||||||
@@ -69,6 +79,9 @@ fun HibernationSwitchPreference(app: ApplicationInfo) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun isArchivingEnabled() =
|
||||||
|
Flags.archiving() || "true" == System.getProperty("pm.archiving.enabled")
|
||||||
|
|
||||||
private class HibernationSwitchPresenter(context: Context, private val app: ApplicationInfo) {
|
private class HibernationSwitchPresenter(context: Context, private val app: ApplicationInfo) {
|
||||||
private val appOpsManager = context.appOpsManager
|
private val appOpsManager = context.appOpsManager
|
||||||
private val permissionControllerManager =
|
private val permissionControllerManager =
|
||||||
|
Reference in New Issue
Block a user