diff --git a/android/src/main/java/com/tailscale/ipn/mdm/MDMSettingsDefinitions.kt b/android/src/main/java/com/tailscale/ipn/mdm/MDMSettingsDefinitions.kt index 1ddf59c7db..173159fbcb 100644 --- a/android/src/main/java/com/tailscale/ipn/mdm/MDMSettingsDefinitions.kt +++ b/android/src/main/java/com/tailscale/ipn/mdm/MDMSettingsDefinitions.kt @@ -46,9 +46,26 @@ class StringMDMSetting(key: String, localizedTitle: String) : class StringArrayListMDMSetting(key: String, localizedTitle: String) : MDMSetting?>(null, key, localizedTitle) { - override fun getFromBundle(bundle: Bundle) = bundle.getStringArrayList(key) - override fun getFromPrefs(prefs: SharedPreferences) = - prefs.getStringSet(key, HashSet())?.toList() + override fun getFromBundle(bundle: Bundle): List? { + // 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 is found, return null + return null + } + + override fun getFromPrefs(prefs: SharedPreferences): List? { + return prefs.getStringSet(key, HashSet())?.toList() + } } class AlwaysNeverUserDecidesMDMSetting(key: String, localizedTitle: String) :