From f79d2d9005e3f8be3b9bd0db805e04fcb9c01a8c Mon Sep 17 00:00:00 2001 From: arrase Date: Wed, 23 Nov 2016 21:20:50 +0100 Subject: [PATCH] bug fix and refactor --- .../org/torproject/android/OrbotMainActivity.java | 4 ++-- .../org/torproject/android/backup/BackupUtils.java | 12 ++++++------ .../android/ui/hs/dialogs/HSActionsDialog.java | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/torproject/android/OrbotMainActivity.java b/app/src/main/java/org/torproject/android/OrbotMainActivity.java index e0fdbb0f..1ea9b6e9 100644 --- a/app/src/main/java/org/torproject/android/OrbotMainActivity.java +++ b/app/src/main/java/org/torproject/android/OrbotMainActivity.java @@ -649,14 +649,14 @@ public class OrbotMainActivity extends AppCompatActivity BackupUtils hsutils = new BackupUtils(getApplicationContext()); if(keyZipPath != null && keyZipPath.length() > 0) { - hsutils.restoreOnionBackup(hsPort, keyZipPath); + hsutils.restoreZipBackup(hsPort, keyZipPath); requestTorRereadConfig(); } /* TODO if(doBackup) { - backupPath = hsutils.createOnionBackup(hsPort); + backupPath = hsutils.createZipBackup(hsPort); } */ onion.close(); diff --git a/app/src/main/java/org/torproject/android/backup/BackupUtils.java b/app/src/main/java/org/torproject/android/backup/BackupUtils.java index 5d77d17f..e05532f4 100644 --- a/app/src/main/java/org/torproject/android/backup/BackupUtils.java +++ b/app/src/main/java/org/torproject/android/backup/BackupUtils.java @@ -9,16 +9,16 @@ import org.torproject.android.storage.ExternalStorage; import java.io.File; public class BackupUtils { - private static File mHSBasePath; + private File mHSBasePath; public BackupUtils(Context context) { mHSBasePath = context.getDir( - TorServiceConstants.DIRECTORY_TOR_DATA + "/" + TorServiceConstants.HIDDEN_SERVICES_DIR, + TorServiceConstants.DIRECTORY_TOR_DATA, Application.MODE_PRIVATE ); } - public String createOnionBackup(Integer port) { + public String createZipBackup(Integer port) { ExternalStorage storage = new ExternalStorage(); String storage_path = storage.createBackupDir(); @@ -28,8 +28,8 @@ public class BackupUtils { String zip_path = storage_path + "/hs" + port + ".zip"; String files[] = { - mHSBasePath + "/hs" + port + "/hostname", - mHSBasePath + "/hs" + port + "/private_key" + mHSBasePath + "/" + TorServiceConstants.HIDDEN_SERVICES_DIR + "/hs" + port + "/hostname", + mHSBasePath + "/" + TorServiceConstants.HIDDEN_SERVICES_DIR + "/hs" + port + "/private_key" }; ZipIt zip = new ZipIt(files, zip_path); @@ -41,7 +41,7 @@ public class BackupUtils { return zip_path; } - public void restoreOnionBackup(Integer port, String path) { + public void restoreZipBackup(Integer port, String path) { ZipIt zip = new ZipIt(null, path); zip.unzip(mHSBasePath + "/hs" + port); } diff --git a/app/src/main/java/org/torproject/android/ui/hs/dialogs/HSActionsDialog.java b/app/src/main/java/org/torproject/android/ui/hs/dialogs/HSActionsDialog.java index f432a018..46315433 100644 --- a/app/src/main/java/org/torproject/android/ui/hs/dialogs/HSActionsDialog.java +++ b/app/src/main/java/org/torproject/android/ui/hs/dialogs/HSActionsDialog.java @@ -50,7 +50,7 @@ public class HSActionsDialog extends DialogFragment { } BackupUtils hsutils = new BackupUtils(mContext); - String backupPath = hsutils.createOnionBackup(Integer.parseInt(arguments.getString("port"))); + String backupPath = hsutils.createZipBackup(Integer.parseInt(arguments.getString("port"))); if (backupPath == null || backupPath.length() < 1) { Toast.makeText(mContext, R.string.error, Toast.LENGTH_LONG).show();