|
25 | 25 | import android.content.ContentResolver; |
26 | 26 | import android.database.Cursor; |
27 | 27 | import android.net.Uri; |
| 28 | +import android.os.Build; |
28 | 29 | import android.provider.DocumentsContract; |
29 | 30 | import android.provider.DocumentsContract.Document; |
30 | 31 |
|
@@ -52,6 +53,8 @@ public final class VfsImplementationSaf |
52 | 53 | */ |
53 | 54 | public static int openSafFile(ContentResolver content, String tree, String path, boolean read, boolean write, boolean truncate) |
54 | 55 | { |
| 56 | + if (Build.VERSION.SDK_INT < 21) |
| 57 | + return -1; |
55 | 58 | boolean createdFile = false; |
56 | 59 | while (true) |
57 | 60 | { |
@@ -126,6 +129,8 @@ else if (!read) |
126 | 129 | */ |
127 | 130 | public static boolean removeSafFile(ContentResolver content, String tree, String path) |
128 | 131 | { |
| 132 | + if (Build.VERSION.SDK_INT < 21) |
| 133 | + return false; |
129 | 134 | final Uri treeUri = Uri.parse(tree); |
130 | 135 | try |
131 | 136 | { |
@@ -176,6 +181,8 @@ public static class SafStat |
176 | 181 | */ |
177 | 182 | public SafStat(ContentResolver content, String tree, String path, boolean includeSize) |
178 | 183 | { |
| 184 | + if (Build.VERSION.SDK_INT < 21) |
| 185 | + return; |
179 | 186 | final Uri treeUri = Uri.parse(tree); |
180 | 187 | try |
181 | 188 | { |
@@ -246,6 +253,8 @@ public long getSize() |
246 | 253 | */ |
247 | 254 | public static int mkdirSaf(ContentResolver content, String tree, String path) |
248 | 255 | { |
| 256 | + if (Build.VERSION.SDK_INT < 21) |
| 257 | + return -1; |
249 | 258 | final Uri treeUri = Uri.parse(tree); |
250 | 259 | final Path directoryPath; |
251 | 260 | try |
@@ -320,6 +329,8 @@ public static class SafDirectory implements Closeable |
320 | 329 | */ |
321 | 330 | public SafDirectory(ContentResolver content, String tree, String path) |
322 | 331 | { |
| 332 | + if (Build.VERSION.SDK_INT < 21) |
| 333 | + return; |
323 | 334 | final Uri treeUri = Uri.parse(tree); |
324 | 335 | try |
325 | 336 | { |
@@ -355,6 +366,8 @@ public void close() |
355 | 366 | */ |
356 | 367 | public boolean readdir() |
357 | 368 | { |
| 369 | + if (Build.VERSION.SDK_INT < 21) |
| 370 | + return false; |
358 | 371 | if (cursor == null) |
359 | 372 | return false; |
360 | 373 | if (cursor.moveToNext()) |
|
0 commit comments