adds AppDataProvider

This commit is contained in:
arrase 2016-11-23 01:37:06 +01:00
parent 0818b0c963
commit 22c573f70a
4 changed files with 61 additions and 0 deletions

View File

@ -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'
}

View File

@ -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>

View File

@ -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));
}
}

View File

@ -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>