android: StringArrayListMDMSetting should check for String[] (#527)

getFromBundle should check for both String[] and ArrayList<String>

Fixes tailscale/corp#23557

Signed-off-by: kari-ts <kari@tailscale.com>
pull/528/head
kari-ts 2 months ago committed by GitHub
parent 8eabe8d6dd
commit f5ecca3c96
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -46,9 +46,26 @@ class StringMDMSetting(key: String, localizedTitle: String) :
class StringArrayListMDMSetting(key: String, localizedTitle: String) :
MDMSetting<List<String>?>(null, key, localizedTitle) {
override fun getFromBundle(bundle: Bundle) = bundle.getStringArrayList(key)
override fun getFromPrefs(prefs: SharedPreferences) =
prefs.getStringSet(key, HashSet<String>())?.toList()
override fun getFromBundle(bundle: Bundle): List<String>? {
// Try to retrieve the value as a String[] first
val stringArray = bundle.getStringArray(key)
if (stringArray != null) {
return stringArray.toList()
}
// Optionally, handle other types if necessary
val stringArrayList = bundle.getStringArrayList(key)
if (stringArrayList != null) {
return stringArrayList
}
// If neither String[] nor ArrayList<String> is found, return null
return null
}
override fun getFromPrefs(prefs: SharedPreferences): List<String>? {
return prefs.getStringSet(key, HashSet<String>())?.toList()
}
}
class AlwaysNeverUserDecidesMDMSetting(key: String, localizedTitle: String) :

Loading…
Cancel
Save