1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-01-03 13:44:40 +00:00

Block restore if Google backup is disabled

This commit is contained in:
M66B 2024-10-26 07:58:50 +02:00
parent 918f759447
commit 2c75c43315

View file

@ -153,7 +153,13 @@ public class FairEmailBackupAgent extends BackupAgent {
@Override @Override
public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) { public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) {
try { try {
EntityLog.log(this, "Restore start version=" + appVersionCode); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean enabled = prefs.getBoolean("google_backup", BuildConfig.PLAY_STORE_RELEASE);
EntityLog.log(this, "Restore start enabled=" + enabled + " version=" + appVersionCode);
if (!enabled)
return;
while (data.readNextHeader()) { while (data.readNextHeader()) {
String dataKey = data.getKey(); String dataKey = data.getKey();
@ -175,7 +181,6 @@ public class FairEmailBackupAgent extends BackupAgent {
JSONObject jroot = new JSONObject(new String(dataBuf, StandardCharsets.UTF_8)); JSONObject jroot = new JSONObject(new String(dataBuf, StandardCharsets.UTF_8));
EntityLog.log(this, "Restore version=" + jroot.optInt("version", 0)); EntityLog.log(this, "Restore version=" + jroot.optInt("version", 0));
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = prefs.edit(); SharedPreferences.Editor editor = prefs.edit();
JSONObject jsettings = jroot.getJSONObject("settings"); JSONObject jsettings = jroot.getJSONObject("settings");
editor.putBoolean("enabled", jsettings.optBoolean("enabled")); editor.putBoolean("enabled", jsettings.optBoolean("enabled"));