android: Pass absolute path to the app's data directory via JNI
This commit is contained in:
+5
-2
@@ -74,6 +74,7 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
|
|||||||
public static final int VPN_STATE_NOTIFICATION_ID = 1;
|
public static final int VPN_STATE_NOTIFICATION_ID = 1;
|
||||||
|
|
||||||
private String mLogFile;
|
private String mLogFile;
|
||||||
|
private String mAppDir;
|
||||||
private VpnProfileDataSource mDataSource;
|
private VpnProfileDataSource mDataSource;
|
||||||
private Thread mConnectionHandler;
|
private Thread mConnectionHandler;
|
||||||
private VpnProfile mCurrentProfile;
|
private VpnProfile mCurrentProfile;
|
||||||
@@ -152,6 +153,7 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
|
|||||||
public void onCreate()
|
public void onCreate()
|
||||||
{
|
{
|
||||||
mLogFile = getFilesDir().getAbsolutePath() + File.separator + LOG_FILE;
|
mLogFile = getFilesDir().getAbsolutePath() + File.separator + LOG_FILE;
|
||||||
|
mAppDir = getFilesDir().getAbsolutePath();
|
||||||
|
|
||||||
mDataSource = new VpnProfileDataSource(this);
|
mDataSource = new VpnProfileDataSource(this);
|
||||||
mDataSource.open();
|
mDataSource.open();
|
||||||
@@ -244,7 +246,7 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
|
|||||||
|
|
||||||
addNotification();
|
addNotification();
|
||||||
BuilderAdapter builder = new BuilderAdapter(mCurrentProfile);
|
BuilderAdapter builder = new BuilderAdapter(mCurrentProfile);
|
||||||
if (initializeCharon(builder, mLogFile, mCurrentProfile.getVpnType().has(VpnTypeFeature.BYOD)))
|
if (initializeCharon(builder, mLogFile, mAppDir, mCurrentProfile.getVpnType().has(VpnTypeFeature.BYOD)))
|
||||||
{
|
{
|
||||||
Log.i(TAG, "charon started");
|
Log.i(TAG, "charon started");
|
||||||
SettingsWriter writer = new SettingsWriter();
|
SettingsWriter writer = new SettingsWriter();
|
||||||
@@ -645,10 +647,11 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
|
|||||||
*
|
*
|
||||||
* @param builder BuilderAdapter for this connection
|
* @param builder BuilderAdapter for this connection
|
||||||
* @param logfile absolute path to the logfile
|
* @param logfile absolute path to the logfile
|
||||||
|
* @param appdir absolute path to the data directory of the app
|
||||||
* @param byod enable BYOD features
|
* @param byod enable BYOD features
|
||||||
* @return TRUE if initialization was successful
|
* @return TRUE if initialization was successful
|
||||||
*/
|
*/
|
||||||
public native boolean initializeCharon(BuilderAdapter builder, String logfile, boolean byod);
|
public native boolean initializeCharon(BuilderAdapter builder, String logfile, String appdir, boolean byod);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deinitialize charon, provided by libandroidbridge.so
|
* Deinitialize charon, provided by libandroidbridge.so
|
||||||
|
|||||||
@@ -515,7 +515,7 @@ static void set_options(char *logfile)
|
|||||||
* Initialize the charonservice object
|
* Initialize the charonservice object
|
||||||
*/
|
*/
|
||||||
static void charonservice_init(JNIEnv *env, jobject service, jobject builder,
|
static void charonservice_init(JNIEnv *env, jobject service, jobject builder,
|
||||||
jboolean byod)
|
char *appdir, jboolean byod)
|
||||||
{
|
{
|
||||||
private_charonservice_t *this;
|
private_charonservice_t *this;
|
||||||
static plugin_feature_t features[] = {
|
static plugin_feature_t features[] = {
|
||||||
@@ -602,11 +602,11 @@ static void segv_handler(int signal)
|
|||||||
* Initialize charon and the libraries via JNI
|
* Initialize charon and the libraries via JNI
|
||||||
*/
|
*/
|
||||||
JNI_METHOD(CharonVpnService, initializeCharon, jboolean,
|
JNI_METHOD(CharonVpnService, initializeCharon, jboolean,
|
||||||
jobject builder, jstring jlogfile, jboolean byod)
|
jobject builder, jstring jlogfile, jstring jappdir, jboolean byod)
|
||||||
{
|
{
|
||||||
struct sigaction action;
|
struct sigaction action;
|
||||||
struct utsname utsname;
|
struct utsname utsname;
|
||||||
char *logfile, *plugins;
|
char *logfile, *appdir, *plugins;
|
||||||
|
|
||||||
/* logging for library during initialization, as we have no bus yet */
|
/* logging for library during initialization, as we have no bus yet */
|
||||||
dbg = dbg_android;
|
dbg = dbg_android;
|
||||||
@@ -640,7 +640,9 @@ JNI_METHOD(CharonVpnService, initializeCharon, jboolean,
|
|||||||
|
|
||||||
charon->load_loggers(charon);
|
charon->load_loggers(charon);
|
||||||
|
|
||||||
charonservice_init(env, this, builder, byod);
|
appdir = androidjni_convert_jstring(env, jappdir);
|
||||||
|
charonservice_init(env, this, builder, appdir, byod);
|
||||||
|
free(appdir);
|
||||||
|
|
||||||
if (uname(&utsname) != 0)
|
if (uname(&utsname) != 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user