Merge "[Catalyst] Support Getter API for settings service" into main
This commit is contained in:
@@ -19,6 +19,7 @@ package com.android.settings
|
|||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import com.android.settings.flags.Flags
|
import com.android.settings.flags.Flags
|
||||||
|
import com.android.settingslib.graph.PreferenceGetterRequest
|
||||||
import com.android.settingslib.graph.PreferenceSetterRequest
|
import com.android.settingslib.graph.PreferenceSetterRequest
|
||||||
import com.android.settingslib.ipc.ApiPermissionChecker
|
import com.android.settingslib.ipc.ApiPermissionChecker
|
||||||
import com.android.settingslib.service.PreferenceService
|
import com.android.settingslib.service.PreferenceService
|
||||||
@@ -28,6 +29,7 @@ class SettingsService :
|
|||||||
PreferenceService(
|
PreferenceService(
|
||||||
graphPermissionChecker = ApiPermissionChecker.alwaysAllow(),
|
graphPermissionChecker = ApiPermissionChecker.alwaysAllow(),
|
||||||
setterPermissionChecker = SetterPermissionChecker(),
|
setterPermissionChecker = SetterPermissionChecker(),
|
||||||
|
getterPermissionChecker = GetterPermissionChecker(),
|
||||||
) {
|
) {
|
||||||
|
|
||||||
override fun onBind(intent: Intent) =
|
override fun onBind(intent: Intent) =
|
||||||
@@ -44,3 +46,14 @@ private class SetterPermissionChecker : ApiPermissionChecker<PreferenceSetterReq
|
|||||||
request: PreferenceSetterRequest,
|
request: PreferenceSetterRequest,
|
||||||
) = true
|
) = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Permission checker for external getter API. */
|
||||||
|
private class GetterPermissionChecker : ApiPermissionChecker<PreferenceGetterRequest> {
|
||||||
|
|
||||||
|
override fun hasPermission(
|
||||||
|
application: Application,
|
||||||
|
myUid: Int,
|
||||||
|
callingUid: Int,
|
||||||
|
request: PreferenceGetterRequest,
|
||||||
|
) = true
|
||||||
|
}
|
||||||
|
@@ -39,6 +39,9 @@ class DataSaverMainSwitchPreference(context: Context) :
|
|||||||
|
|
||||||
override fun storage(context: Context): KeyValueStore = DataSaverStore(dataSaverBackend)
|
override fun storage(context: Context): KeyValueStore = DataSaverStore(dataSaverBackend)
|
||||||
|
|
||||||
|
override fun getReadPermit(context: Context, myUid: Int, callingUid: Int) =
|
||||||
|
ReadWritePermit.ALLOW
|
||||||
|
|
||||||
override fun getWritePermit(context: Context, value: Boolean?, myUid: Int, callingUid: Int) =
|
override fun getWritePermit(context: Context, value: Boolean?, myUid: Int, callingUid: Int) =
|
||||||
ReadWritePermit.ALLOW
|
ReadWritePermit.ALLOW
|
||||||
|
|
||||||
|
@@ -64,6 +64,9 @@ class AutoBrightnessScreen :
|
|||||||
override fun storage(context: Context): KeyValueStore =
|
override fun storage(context: Context): KeyValueStore =
|
||||||
AutoBrightnessDataStore(SettingsSystemStore.get(context))
|
AutoBrightnessDataStore(SettingsSystemStore.get(context))
|
||||||
|
|
||||||
|
override fun getReadPermit(context: Context, myUid: Int, callingUid: Int) =
|
||||||
|
ReadWritePermit.ALLOW
|
||||||
|
|
||||||
override fun getWritePermit(context: Context, value: Boolean?, myUid: Int, callingUid: Int) =
|
override fun getWritePermit(context: Context, value: Boolean?, myUid: Int, callingUid: Int) =
|
||||||
ReadWritePermit.ALLOW
|
ReadWritePermit.ALLOW
|
||||||
|
|
||||||
|
@@ -48,6 +48,9 @@ class BatteryPercentageSwitchPreference :
|
|||||||
com.android.internal.R.bool.config_battery_percentage_setting_available
|
com.android.internal.R.bool.config_battery_percentage_setting_available
|
||||||
)
|
)
|
||||||
|
|
||||||
|
override fun getReadPermit(context: Context, myUid: Int, callingUid: Int) =
|
||||||
|
ReadWritePermit.ALLOW
|
||||||
|
|
||||||
override fun getWritePermit(context: Context, value: Boolean?, myUid: Int, callingUid: Int) =
|
override fun getWritePermit(context: Context, value: Boolean?, myUid: Int, callingUid: Int) =
|
||||||
ReadWritePermit.ALLOW
|
ReadWritePermit.ALLOW
|
||||||
|
|
||||||
|
@@ -49,6 +49,9 @@ class PeakRefreshRateSwitchPreference :
|
|||||||
override fun storage(context: Context): KeyValueStore =
|
override fun storage(context: Context): KeyValueStore =
|
||||||
PeakRefreshRateStore(context, SettingsSystemStore.get(context))
|
PeakRefreshRateStore(context, SettingsSystemStore.get(context))
|
||||||
|
|
||||||
|
override fun getReadPermit(context: Context, myUid: Int, callingUid: Int) =
|
||||||
|
ReadWritePermit.ALLOW
|
||||||
|
|
||||||
override fun getWritePermit(context: Context, value: Boolean?, myUid: Int, callingUid: Int) =
|
override fun getWritePermit(context: Context, value: Boolean?, myUid: Int, callingUid: Int) =
|
||||||
ReadWritePermit.ALLOW
|
ReadWritePermit.ALLOW
|
||||||
|
|
||||||
|
@@ -70,6 +70,9 @@ class DarkModeScreen :
|
|||||||
override val keywords: Int
|
override val keywords: Int
|
||||||
get() = R.string.keywords_dark_ui_mode
|
get() = R.string.keywords_dark_ui_mode
|
||||||
|
|
||||||
|
override fun getReadPermit(context: Context, myUid: Int, callingUid: Int) =
|
||||||
|
ReadWritePermit.ALLOW
|
||||||
|
|
||||||
override fun getWritePermit(context: Context, value: Boolean?, myUid: Int, callingUid: Int) =
|
override fun getWritePermit(context: Context, value: Boolean?, myUid: Int, callingUid: Int) =
|
||||||
ReadWritePermit.ALLOW
|
ReadWritePermit.ALLOW
|
||||||
|
|
||||||
|
@@ -43,6 +43,9 @@ class BatterySaverPreference :
|
|||||||
|
|
||||||
override fun storage(context: Context) = BatterySaverStore(context)
|
override fun storage(context: Context) = BatterySaverStore(context)
|
||||||
|
|
||||||
|
override fun getReadPermit(context: Context, myUid: Int, callingUid: Int) =
|
||||||
|
ReadWritePermit.ALLOW
|
||||||
|
|
||||||
override fun getWritePermit(context: Context, value: Boolean?, myUid: Int, callingUid: Int) =
|
override fun getWritePermit(context: Context, value: Boolean?, myUid: Int, callingUid: Int) =
|
||||||
ReadWritePermit.ALLOW
|
ReadWritePermit.ALLOW
|
||||||
|
|
||||||
|
@@ -75,6 +75,9 @@ open class CallVolumePreference :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getReadPermit(context: Context, myUid: Int, callingUid: Int) =
|
||||||
|
ReadWritePermit.ALLOW
|
||||||
|
|
||||||
override fun getWritePermit(context: Context, value: Int?, myUid: Int, callingUid: Int) =
|
override fun getWritePermit(context: Context, value: Int?, myUid: Int, callingUid: Int) =
|
||||||
ReadWritePermit.ALLOW
|
ReadWritePermit.ALLOW
|
||||||
|
|
||||||
|
@@ -76,6 +76,9 @@ open class MediaVolumePreference :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getReadPermit(context: Context, myUid: Int, callingUid: Int) =
|
||||||
|
ReadWritePermit.ALLOW
|
||||||
|
|
||||||
override fun getWritePermit(context: Context, value: Int?, myUid: Int, callingUid: Int) =
|
override fun getWritePermit(context: Context, value: Int?, myUid: Int, callingUid: Int) =
|
||||||
ReadWritePermit.ALLOW
|
ReadWritePermit.ALLOW
|
||||||
|
|
||||||
|
@@ -85,6 +85,9 @@ open class SeparateRingVolumePreference :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getReadPermit(context: Context, myUid: Int, callingUid: Int) =
|
||||||
|
ReadWritePermit.ALLOW
|
||||||
|
|
||||||
override fun getWritePermit(context: Context, value: Int?, myUid: Int, callingUid: Int) =
|
override fun getWritePermit(context: Context, value: Int?, myUid: Int, callingUid: Int) =
|
||||||
ReadWritePermit.ALLOW
|
ReadWritePermit.ALLOW
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user