[tor-commits] [orbot/master] adds AppDataProvider
n8fr8 at torproject.org
n8fr8 at torproject.org
Thu Mar 2 04:10:21 UTC 2017
commit 22c573f70aee830ed92f308c5fad3cbb73148ee3
Author: arrase <arrase at gmail.com>
Date: Wed Nov 23 01:37:06 2016 +0100
adds AppDataProvider
---
app/build.gradle | 7 ++++
app/src/main/AndroidManifest.xml | 10 ++++++
.../android/storage/AppDataProvider.java | 39 ++++++++++++++++++++++
app/src/main/res/xml/hidden_services_paths.xml | 5 +++
4 files changed, 61 insertions(+)
diff --git a/app/build.gradle b/app/build.gradle
index cc364c7..7debed3 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -26,9 +26,16 @@ 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 24d989a..2df7eab 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -149,6 +149,16 @@
android:name=".ui.hs.providers.HSContentProvider"
android:exported="false"
android:authorities="org.torproject.android.ui.hs.providers" />
+
+ <provider
+ android:name="com.commonsware.cwac.provider.StreamProvider"
+ android:authorities="org.torproject.android.backup"
+ android:exported="false"
+ android:grantUriPermissions="true">
+ <meta-data
+ android:name="com.commonsware.cwac.provider.STREAM_PROVIDER_PATHS"
+ android:resource="@xml/hidden_services_paths"/>
+ </provider>
</application>
</manifest>
\ No newline at end of file
diff --git a/app/src/main/java/org/torproject/android/storage/AppDataProvider.java b/app/src/main/java/org/torproject/android/storage/AppDataProvider.java
new file mode 100644
index 0000000..c04a293
--- /dev/null
+++ b/app/src/main/java/org/torproject/android/storage/AppDataProvider.java
@@ -0,0 +1,39 @@
+package org.torproject.android.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
new file mode 100644
index 0000000..943fd09
--- /dev/null
+++ b/app/src/main/res/xml/hidden_services_paths.xml
@@ -0,0 +1,5 @@
+<?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/"/>
+
+</paths>
\ No newline at end of file
More information about the tor-commits
mailing list