Merge "[Catalyst] Support Getter API for settings service" into main

This commit is contained in:
Jacky Wang
2024-11-17 05:53:58 +00:00
committed by Android (Google) Code Review
10 changed files with 40 additions and 0 deletions

View File

@@ -19,6 +19,7 @@ package com.android.settings
import android.app.Application
import android.content.Intent
import com.android.settings.flags.Flags
import com.android.settingslib.graph.PreferenceGetterRequest
import com.android.settingslib.graph.PreferenceSetterRequest
import com.android.settingslib.ipc.ApiPermissionChecker
import com.android.settingslib.service.PreferenceService
@@ -28,6 +29,7 @@ class SettingsService :
PreferenceService(
graphPermissionChecker = ApiPermissionChecker.alwaysAllow(),
setterPermissionChecker = SetterPermissionChecker(),
getterPermissionChecker = GetterPermissionChecker(),
) {
override fun onBind(intent: Intent) =
@@ -44,3 +46,14 @@ private class SetterPermissionChecker : ApiPermissionChecker<PreferenceSetterReq
request: PreferenceSetterRequest,
) = true
}
/** Permission checker for external getter API. */
private class GetterPermissionChecker : ApiPermissionChecker<PreferenceGetterRequest> {
override fun hasPermission(
application: Application,
myUid: Int,
callingUid: Int,
request: PreferenceGetterRequest,
) = true
}

View File

@@ -39,6 +39,9 @@ class DataSaverMainSwitchPreference(context: Context) :
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) =
ReadWritePermit.ALLOW

View File

@@ -64,6 +64,9 @@ class AutoBrightnessScreen :
override fun storage(context: Context): KeyValueStore =
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) =
ReadWritePermit.ALLOW

View File

@@ -48,6 +48,9 @@ class BatteryPercentageSwitchPreference :
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) =
ReadWritePermit.ALLOW

View File

@@ -49,6 +49,9 @@ class PeakRefreshRateSwitchPreference :
override fun storage(context: Context): KeyValueStore =
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) =
ReadWritePermit.ALLOW

View File

@@ -70,6 +70,9 @@ class DarkModeScreen :
override val keywords: Int
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) =
ReadWritePermit.ALLOW

View File

@@ -43,6 +43,9 @@ class BatterySaverPreference :
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) =
ReadWritePermit.ALLOW

View File

@@ -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) =
ReadWritePermit.ALLOW

View File

@@ -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) =
ReadWritePermit.ALLOW

View File

@@ -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) =
ReadWritePermit.ALLOW