Add better error logging for single backup Uris.

fork-5.53.8
Alex Hart 2020-11-03 15:23:58 -04:00 zatwierdzone przez Alan Evans
rodzic 936e772ba0
commit f796447815
1 zmienionych plików z 15 dodań i 0 usunięć

Wyświetl plik

@ -174,6 +174,7 @@ public class BackupUtil {
return new BackupInfo(backupTimestamp, documentFile.length(), documentFile.getUri());
} else {
logIssueWithDocumentFile(documentFile);
Log.w(TAG, "Could not load backup info.");
return null;
}
@ -259,6 +260,20 @@ public class BackupUtil {
return -1;
}
private static void logIssueWithDocumentFile(@Nullable DocumentFile documentFile) {
if (documentFile == null) {
throw new AssertionError("We do not support platforms prior to KitKat.");
} else if (!documentFile.exists()) {
Log.w(TAG, "The document at the specified Uri cannot be found.");
} else if (!documentFile.canRead()) {
Log.w(TAG, "The document at the specified Uri cannot be read.");
} else if (!documentFile.canWrite()) {
Log.w(TAG, "The document at the specified Uri cannot be written to.");
} else if (!documentFile.getName().endsWith(".backup")) {
Log.w(TAG, "The document at the specified Uri has an unsupported file extension.");
}
}
public static class BackupInfo {
private final long timestamp;