Add ability to exclude apps from adjustments
Specifically bundling and summarization Test: BundleManageAppsPreferenceControllerTest Test: AdjustmentExcludedAppsPreferenceControllerTest Test: SummarizationManageAppsPreferenceControllerTest Flag: android.app.nm_summarization Flag: android.app.notification_classification_ui Bug: 390415383 Bug: 377697346 Change-Id: Ica4b77212f4660624bfe12be7e6c9c584cd2c812
This commit is contained in:
@@ -17,12 +17,16 @@
|
||||
package com.android.settings.spa.notification
|
||||
|
||||
import android.content.pm.ApplicationInfo
|
||||
import android.service.notification.Adjustment
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.android.settings.spa.app.storage.StorageAppListModel
|
||||
import com.android.settings.spa.app.storage.StorageType
|
||||
|
||||
class AppNotificationController(
|
||||
private val repository: AppNotificationRepository,
|
||||
private val app: ApplicationInfo,
|
||||
private val listType: ListType,
|
||||
) {
|
||||
val isEnabled: LiveData<Boolean>
|
||||
get() = _isEnabled
|
||||
@@ -47,4 +51,62 @@ class AppNotificationController(
|
||||
postValue(it)
|
||||
}
|
||||
}
|
||||
|
||||
val isAllowed: LiveData<Boolean>
|
||||
get() = _isAllowed
|
||||
|
||||
fun getAllowed() = _isAllowed.get()
|
||||
|
||||
fun setAllowed(enabled: Boolean) {
|
||||
when (listType) {
|
||||
ListType.ExcludeSummarization -> {
|
||||
if (repository.setAdjustmentSupportedForPackage(
|
||||
app, Adjustment.KEY_SUMMARIZATION, enabled)) {
|
||||
_isAllowed.postValue(enabled)
|
||||
}
|
||||
}
|
||||
ListType.ExcludeClassification -> {
|
||||
if (repository.setAdjustmentSupportedForPackage(
|
||||
app, Adjustment.KEY_TYPE, enabled)) {
|
||||
_isAllowed.postValue(enabled)
|
||||
}
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
private val _isAllowed = object : MutableLiveData<Boolean>() {
|
||||
override fun onActive() {
|
||||
when (listType) {
|
||||
ListType.ExcludeSummarization -> {
|
||||
postValue(repository.isAdjustmentSupportedForPackage(
|
||||
app, Adjustment.KEY_SUMMARIZATION))
|
||||
}
|
||||
ListType.ExcludeClassification -> {
|
||||
postValue(repository.isAdjustmentSupportedForPackage(
|
||||
app, Adjustment.KEY_TYPE))
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onInactive() {
|
||||
}
|
||||
|
||||
fun get(): Boolean = when (listType) {
|
||||
ListType.ExcludeSummarization -> {
|
||||
value ?: repository.isAdjustmentSupportedForPackage(
|
||||
app, Adjustment.KEY_SUMMARIZATION).also {
|
||||
postValue(it)
|
||||
}
|
||||
}
|
||||
ListType.ExcludeClassification -> {
|
||||
value ?: repository.isAdjustmentSupportedForPackage(
|
||||
app, Adjustment.KEY_TYPE).also {
|
||||
postValue(it)
|
||||
}
|
||||
}
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user