From 5d3b171e21772615123a4e2109d51f2df57cc1d8 Mon Sep 17 00:00:00 2001 From: arrase Date: Sun, 27 Nov 2016 19:19:44 +0100 Subject: [PATCH] refactor --- .../android/ui/hiddenservices/backup/BackupUtils.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/backup/BackupUtils.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/backup/BackupUtils.java index a11cb710..5be10d31 100644 --- a/app/src/main/java/org/torproject/android/ui/hiddenservices/backup/BackupUtils.java +++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/backup/BackupUtils.java @@ -118,6 +118,9 @@ public class BackupUtils { } public void restoreZipBackup(File backup) { + + int port; + Cursor service; String backupName = backup.getName(); String hsDir = backupName.substring(0, backupName.lastIndexOf('.')); String configFilePath = mHSBasePath + "/" + hsDir + "/" + configFileName; @@ -149,15 +152,12 @@ public class BackupUtils { try { JSONObject savedValues = new JSONObject(jString); ContentValues fields = new ContentValues(); - int port = savedValues.getInt(HSContentProvider.HiddenService.PORT); fields.put( HSContentProvider.HiddenService.NAME, savedValues.getString(HSContentProvider.HiddenService.NAME) ); - fields.put(HSContentProvider.HiddenService.PORT, port); - fields.put( HSContentProvider.HiddenService.ONION_PORT, savedValues.getInt(HSContentProvider.HiddenService.ONION_PORT) @@ -173,7 +173,10 @@ public class BackupUtils { savedValues.getInt(HSContentProvider.HiddenService.CREATED_BY_USER) ); - Cursor service = mResolver.query( + port = savedValues.getInt(HSContentProvider.HiddenService.PORT); + fields.put(HSContentProvider.HiddenService.PORT, port); + + service = mResolver.query( HSContentProvider.CONTENT_URI, HSContentProvider.PROJECTION, HSContentProvider.HiddenService.PORT + "=" + port,