aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/services/ExportLogsService.java
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-02-26 19:38:19 +0100
committerChristian Schneppe <christian@pix-art.de>2018-03-08 20:32:06 +0100
commitb95bdbe791a8b7609b46ec5b9c089b2dc2461314 (patch)
treebd7ffe2d4416c29db9c3c8d624e225988b7022f9 /src/main/java/de/pixart/messenger/services/ExportLogsService.java
parent06014f81e5e312bf0dec557fb23ba49d37ba3270 (diff)
implement multi accounts via expert settings
Diffstat (limited to 'src/main/java/de/pixart/messenger/services/ExportLogsService.java')
-rw-r--r--src/main/java/de/pixart/messenger/services/ExportLogsService.java30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/main/java/de/pixart/messenger/services/ExportLogsService.java b/src/main/java/de/pixart/messenger/services/ExportLogsService.java
index 2337d04d0..63ac1be68 100644
--- a/src/main/java/de/pixart/messenger/services/ExportLogsService.java
+++ b/src/main/java/de/pixart/messenger/services/ExportLogsService.java
@@ -9,6 +9,7 @@ import android.os.IBinder;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.preference.PreferenceManager;
+import android.support.annotation.BoolRes;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
@@ -37,6 +38,8 @@ import de.pixart.messenger.persistance.FileBackend;
import de.pixart.messenger.utils.EncryptDecryptFile;
import de.pixart.messenger.xmpp.jid.Jid;
+import static de.pixart.messenger.ui.SettingsActivity.USE_MULTI_ACCOUNTS;
+
public class ExportLogsService extends Service {
private static final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
@@ -49,6 +52,7 @@ public class ExportLogsService extends Service {
boolean ReadableLogsEnabled = false;
private WakeLock wakeLock;
private PowerManager pm;
+ XmppConnectionService mXmppConnectionService;
@Override
public void onCreate() {
@@ -178,6 +182,7 @@ public class ExportLogsService extends Service {
public void ExportDatabase() throws IOException {
Account mAccount = mAccounts.get(0);
+ String EncryptionKey = null;
// Get hold of the db:
FileInputStream InputFile = new FileInputStream(this.getDatabasePath(DatabaseBackend.DATABASE_NAME));
// Set the output folder on the SDcard
@@ -195,7 +200,18 @@ public class ExportLogsService extends Service {
// Set the output file stream up:
FileOutputStream OutputFile = new FileOutputStream(directory.getPath() + "/database.db.crypt");
- String EncryptionKey = mAccount.getPassword(); //get account password
+ if (mAccounts.size() == 1 && !multipleAccounts()) {
+ EncryptionKey = mAccount.getPassword(); //get account password
+ } else {
+ SharedPreferences multiaccount_prefs = getApplicationContext().getSharedPreferences(USE_MULTI_ACCOUNTS, Context.MODE_PRIVATE);
+ String password = multiaccount_prefs.getString("BackupPW", null);
+ if (password == null) {
+ Log.d(Config.LOGTAG, "Database exporter: failed to write encryted backup to sdcard because of missing password");
+ return;
+ }
+ EncryptionKey = password; //get previously set backup password
+ }
+ Log.d(Config.LOGTAG, "Database exporter: encrypt backup with password " + EncryptionKey);
// encrypt database from the input file to the output file
try {
@@ -216,4 +232,16 @@ public class ExportLogsService extends Service {
public IBinder onBind(Intent intent) {
return null;
}
+
+ public SharedPreferences getPreferences() {
+ return PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
+ }
+
+ public boolean getBooleanPreference(String name, @BoolRes int res) {
+ return getPreferences().getBoolean(name, getResources().getBoolean(res));
+ }
+
+ public boolean multipleAccounts() {
+ return getBooleanPreference("enable_multi_accounts", R.bool.confirm_messages);
+ }
}