mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-15 06:22:49 +00:00
Explain vault backup permission error
Users understandably get confused by the "No persisted URI permissions" error. This patch adds some text to the dialog explaining why this happened and how the user can fix the issue. This permission issue can happen for one of two reasons: - The user made a change to the backup destination (renamed, moved, deleted, etc) - Aegis was restored from an Android backup
This commit is contained in:
parent
88caafd61c
commit
08c73922cc
5 changed files with 31 additions and 8 deletions
|
@ -11,6 +11,7 @@ import androidx.annotation.Nullable;
|
|||
|
||||
import com.beemdevelopment.aegis.util.JsonUtils;
|
||||
import com.beemdevelopment.aegis.util.TimeUtils;
|
||||
import com.beemdevelopment.aegis.vault.VaultBackupPermissionException;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
@ -507,14 +508,16 @@ public class Preferences {
|
|||
private final Date _time;
|
||||
private boolean _isBuiltIn;
|
||||
private final String _error;
|
||||
private final boolean _isPermissionError;
|
||||
|
||||
public BackupResult(@Nullable Exception e) {
|
||||
this(new Date(), e == null ? null : e.toString());
|
||||
this(new Date(), e == null ? null : e.toString(), e instanceof VaultBackupPermissionException);
|
||||
}
|
||||
|
||||
private BackupResult(Date time, @Nullable String error) {
|
||||
private BackupResult(Date time, @Nullable String error, boolean isPermissionError) {
|
||||
_time = time;
|
||||
_error = error;
|
||||
_isPermissionError = isPermissionError;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -542,12 +545,17 @@ public class Preferences {
|
|||
_isBuiltIn = isBuiltIn;
|
||||
}
|
||||
|
||||
public boolean isPermissionError() {
|
||||
return _isPermissionError;
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
JSONObject obj = new JSONObject();
|
||||
|
||||
try {
|
||||
obj.put("time", _time.getTime());
|
||||
obj.put("error", _error == null ? JSONObject.NULL : _error);
|
||||
obj.put("isPermissionError", _isPermissionError);
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -559,7 +567,8 @@ public class Preferences {
|
|||
JSONObject obj = new JSONObject(json);
|
||||
long time = obj.getLong("time");
|
||||
String error = JsonUtils.optString(obj, "error");
|
||||
return new BackupResult(new Date(time), error);
|
||||
boolean isPermissionError = obj.optBoolean("isPermissionError");
|
||||
return new BackupResult(new Date(time), error, isPermissionError);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue