[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [orbot/master] move hidden services to files directory



commit fca54cfcdc2407810621dd5247de262cfc0d495a
Author: arrase <arrase@xxxxxxxxx>
Date:   Sun Nov 27 16:03:38 2016 +0100

    move hidden services to files directory
---
 app/build.gradle                                   |  7 ----
 app/src/main/AndroidManifest.xml                   |  4 +--
 .../ui/hiddenservices/backup/BackupUtils.java      | 16 ++++-----
 .../ui/hiddenservices/storage/AppDataProvider.java | 39 ----------------------
 app/src/main/res/xml/hidden_services_paths.xml     |  3 +-
 .../org/torproject/android/service/TorService.java |  8 +++--
 6 files changed, 14 insertions(+), 63 deletions(-)

diff --git a/app/build.gradle b/app/build.gradle
index 7debed3..cc364c7 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -26,16 +26,9 @@ android {
     }
 }
 
-repositories {
-    maven {
-        url "https://s3.amazonaws.com/repo.commonsware.com";
-    }
-}
-
 dependencies {
     compile project(':orbotservice')
     compile 'com.android.support:support-v4:23.4.0'
     compile 'com.android.support:appcompat-v7:23.4.0'
     compile 'com.android.support:design:23.4.0'
-    compile 'com.commonsware.cwac:provider:0.4.4'
 }
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index b7a5e87..1704c70 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -151,12 +151,12 @@
             android:authorities="org.torproject.android.ui.hiddenservices.providers" />
 
         <provider
-            android:name=".ui.hiddenservices.storage.AppDataProvider"
+            android:name="android.support.v4.content.FileProvider"
             android:authorities="org.torproject.android.ui.hiddenservices.storage"
             android:exported="false"
             android:grantUriPermissions="true">
             <meta-data
-                android:name="com.commonsware.cwac.provider.STREAM_PROVIDER_PATHS"
+                android:name="android.support.FILE_PROVIDER_PATHS"
                 android:resource="@xml/hidden_services_paths"/>
         </provider>
     </application>
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 c60beb9..70da302 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
@@ -1,6 +1,5 @@
 package org.torproject.android.ui.hiddenservices.backup;
 
-import android.app.Application;
 import android.content.Context;
 import android.widget.Toast;
 
@@ -17,9 +16,9 @@ public class BackupUtils {
 
     public BackupUtils(Context context) {
         mContext = context;
-        mHSBasePath = mContext.getDir(
-                TorServiceConstants.DIRECTORY_TOR_DATA,
-                Application.MODE_PRIVATE
+        mHSBasePath = new File(
+                mContext.getFilesDir().getAbsolutePath(),
+                TorServiceConstants.HIDDEN_SERVICES_DIR
         );
     }
 
@@ -32,8 +31,8 @@ public class BackupUtils {
 
         String zip_path = storage_path.getAbsolutePath() + "/hs" + port + ".zip";
         String files[] = {
-                mHSBasePath + "/" + TorServiceConstants.HIDDEN_SERVICES_DIR + "/hs" + port + "/hostname",
-                mHSBasePath + "/" + TorServiceConstants.HIDDEN_SERVICES_DIR + "/hs" + port + "/private_key"
+                mHSBasePath + "/hs" + port + "/hostname",
+                mHSBasePath + "/hs" + port + "/private_key"
         };
 
         ZipIt zip = new ZipIt(files, zip_path);
@@ -46,11 +45,8 @@ public class BackupUtils {
     }
 
     public void restoreZipBackup(Integer port, String path) {
-        String hsBasePath;
-
         try {
-            hsBasePath = mHSBasePath.getCanonicalPath() + "/" + TorServiceConstants.HIDDEN_SERVICES_DIR;
-            File hsPath = new File(hsBasePath, "/hs" + port);
+            File hsPath = new File(mHSBasePath.getCanonicalPath(), "/hs" + port);
             if (hsPath.mkdirs()) {
                 ZipIt zip = new ZipIt(null, path);
                 zip.unzip(hsPath.getCanonicalPath());
diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/storage/AppDataProvider.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/storage/AppDataProvider.java
deleted file mode 100644
index 6e55569..0000000
--- a/app/src/main/java/org/torproject/android/ui/hiddenservices/storage/AppDataProvider.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.torproject.android.ui.hiddenservices.storage;
-
-
-import android.app.Application;
-import android.content.Context;
-
-import com.commonsware.cwac.provider.LocalPathStrategy;
-import com.commonsware.cwac.provider.StreamProvider;
-import com.commonsware.cwac.provider.StreamStrategy;
-
-import org.torproject.android.service.TorServiceConstants;
-
-import java.io.IOException;
-import java.util.HashMap;
-
-public class AppDataProvider extends StreamProvider {
-    private static final String TAG = "app-data-path";
-
-    @Override
-    protected StreamStrategy buildStrategy(Context context,
-                                           String tag, String name,
-                                           String path,
-                                           HashMap<String, String> attrs)
-            throws IOException {
-
-        if (TAG.equals(tag)) {
-            return (new LocalPathStrategy(
-                    name,
-                    context.getDir(
-                            TorServiceConstants.DIRECTORY_TOR_DATA,
-                            Application.MODE_PRIVATE
-                    )
-            )
-            );
-        }
-
-        return (super.buildStrategy(context, tag, name, path, attrs));
-    }
-}
diff --git a/app/src/main/res/xml/hidden_services_paths.xml b/app/src/main/res/xml/hidden_services_paths.xml
index 943fd09..073732b 100644
--- a/app/src/main/res/xml/hidden_services_paths.xml
+++ b/app/src/main/res/xml/hidden_services_paths.xml
@@ -1,5 +1,4 @@
 <?xml version="1.0" encoding="utf-8"?>
 <paths xmlns:android="http://schemas.android.com/apk/res/android";>
-    <app-data-path name="hidden-services" path="hidden_services/"/>
-
+    <files-path name="hidden-services" path="hidden_services/" />
 </paths>
\ No newline at end of file
diff --git a/orbotservice/src/main/java/org/torproject/android/service/TorService.java b/orbotservice/src/main/java/org/torproject/android/service/TorService.java
index 6d12424..c2a2431 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/TorService.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/TorService.java
@@ -531,11 +531,13 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
             fileXtables = new File(appBinHome, TorServiceConstants.IPTABLES_ASSET_KEY);
             fileTorRc = new File(appBinHome, TorServiceConstants.TORRC_ASSET_KEY);
 
-            mHSBasePath = new File(appCacheHome , TorServiceConstants.HIDDEN_SERVICES_DIR);
+            mHSBasePath = new File(
+                    getFilesDir().getAbsolutePath(),
+                    TorServiceConstants.HIDDEN_SERVICES_DIR
+            );
 
-            if (!mHSBasePath.isDirectory()) {
+            if (!mHSBasePath.isDirectory())
                 mHSBasePath.mkdirs();
-            }
 
             mEventHandler = new TorEventHandler(this);
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits