diff options
| author | 2025-09-19 20:45:17 +0530 | |
|---|---|---|
| committer | 2025-10-20 18:22:36 +0200 | |
| commit | 3b6ab660a94ef563be25e50804951feda26bc30a (patch) | |
| tree | fd862f4428c938ac97f701eb0b6232a156a5f433 /ui/src/main/java/com/wireguard/android/activity/TvMainActivity.kt | |
| parent | tunnel: add isAlwaysOn and isLockdownEnabled (diff) | |
| download | wireguard-android-master.tar.xz wireguard-android-master.zip | |
The difference between the usage of 21 and 24 is not big enough to hold
on to all the baggage from API 21
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
| -rw-r--r-- | ui/src/main/java/com/wireguard/android/activity/TvMainActivity.kt | 31 |
1 files changed, 7 insertions, 24 deletions
diff --git a/ui/src/main/java/com/wireguard/android/activity/TvMainActivity.kt b/ui/src/main/java/com/wireguard/android/activity/TvMainActivity.kt index 3084d314..a20c983c 100644 --- a/ui/src/main/java/com/wireguard/android/activity/TvMainActivity.kt +++ b/ui/src/main/java/com/wireguard/android/activity/TvMainActivity.kt @@ -266,31 +266,14 @@ class TvMainActivity : AppCompatActivity() { private suspend fun makeStorageRoots(): Collection<KeyedFile> = withContext(Dispatchers.IO) { cachedRoots?.let { return@withContext it } val list = HashSet<KeyedFile>() - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - val storageManager: StorageManager = getSystemService() ?: return@withContext list - list.addAll(storageManager.storageVolumes.mapNotNull { volume -> - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - volume.directory?.let { KeyedFile(it, volume.getDescription(this@TvMainActivity)) } - } else { - KeyedFile((StorageVolume::class.java.getMethod("getPathFile").invoke(volume) as File), volume.getDescription(this@TvMainActivity)) - } - }) - } else { - @Suppress("DEPRECATION") - list.add(KeyedFile(Environment.getExternalStorageDirectory())) - try { - File("/storage").listFiles()?.forEach { - if (!it.isDirectory) return@forEach - try { - if (Environment.isExternalStorageRemovable(it)) { - list.add(KeyedFile(it)) - } - } catch (_: Throwable) { - } - } - } catch (_: Throwable) { + val storageManager: StorageManager = getSystemService() ?: return@withContext list + list.addAll(storageManager.storageVolumes.mapNotNull { volume -> + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + volume.directory?.let { KeyedFile(it, volume.getDescription(this@TvMainActivity)) } + } else { + KeyedFile((StorageVolume::class.java.getMethod("getPathFile").invoke(volume) as File), volume.getDescription(this@TvMainActivity)) } - } + }) cachedRoots = list list } |
