Add additional log lines to inform of the sync state

This commit is contained in:
RichyHBM 2020-08-10 18:01:05 +01:00
parent 9237c1e423
commit 18fdbb96ce
3 changed files with 23 additions and 0 deletions

View file

@ -40,6 +40,7 @@ import android.preference.PreferenceManager;
import androidx.appcompat.widget.Toolbar;
import android.provider.DocumentsContract;
import android.util.Log;
import android.view.ViewStub;
import android.widget.Toast;
@ -166,6 +167,13 @@ public class SettingsActivity extends BaseActivity
if (fragment.useAndroidSync != null)
fragment.useAndroidSync.setEnabled(true);
}
} else if(key.equals(getString(R.string.settings_key_enable_android_backup_service)))
{
Log.d(SettingsActivity.class.getSimpleName(), "onSharedPreferenceChanged called modifying settings_key_enable_android_backup_service service is now: " +
(settings.getAndroidBackupServiceEnabled() ? "enabled" : "disabled"));
int message = settings.getAndroidBackupServiceEnabled() ? R.string.settings_toast_android_sync_enabled : R.string.settings_toast_android_sync_disabled;
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
}
fragment.updateAutoBackup();

View file

@ -29,6 +29,8 @@ import android.app.backup.BackupDataOutput;
import android.app.backup.FileBackupHelper;
import android.app.backup.SharedPreferencesBackupHelper;
import android.os.ParcelFileDescriptor;
import android.util.Log;
import java.io.IOException;
@ -44,19 +46,29 @@ public class BackupAgent extends BackupAgentHelper {
@Override
public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data, ParcelFileDescriptor newState) throws IOException {
Settings settings = new Settings(this);
StringBuilder stringBuilder = new StringBuilder("onBackup called with the backup service set to ");
stringBuilder.append(settings.getAndroidBackupServiceEnabled() ? "enabled" : "disabled");
if(settings.getAndroidBackupServiceEnabled()) {
synchronized (DatabaseHelper.DatabaseFileLock) {
stringBuilder.append(" calling parent onBackup");
super.onBackup(oldState, data, newState);
}
}
Log.d(BackupAgent.class.getSimpleName(), stringBuilder.toString());
}
@Override
public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException {
Settings settings = new Settings(this);
StringBuilder stringBuilder = new StringBuilder("onRestore called with the backup service set to ");
stringBuilder.append(settings.getAndroidBackupServiceEnabled() ? "enabled" : "disabled");
synchronized (DatabaseHelper.DatabaseFileLock) {
stringBuilder.append(" but restore happens regardless, calling parent onRestore");
super.onRestore(data, appVersionCode, newState);
}
Log.d(BackupAgent.class.getSimpleName(), stringBuilder.toString());
}
@Override

View file

@ -134,6 +134,9 @@
<string name="settings_toast_auth_upgrade_failed">Failed to silently upgrade your password / PIN
to the new encryption, please manually reset it in the Settings!</string>
<string name="settings_toast_android_sync_enabled">Android sync enabled</string>
<string name="settings_toast_android_sync_disabled">Android sync disabled</string>
<string name="settings_dialog_title_warning">Warning</string>
<string name="settings_dialog_title_error">Error</string>
<string name="settings_dialog_title_clear_keystore">Clear the KeyStore?</string>