Skip to content

Commit

Permalink
Avoid OsLib setenv. It is not implemented in 4.2.2
Browse files Browse the repository at this point in the history
Create a jni function to call setenv
  • Loading branch information
krrishnarraj committed Jul 19, 2014
1 parent aea3490 commit a171071
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 19 deletions.
1 change: 1 addition & 0 deletions android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="kr.clpeak"
android:versionCode="1"
Expand Down
10 changes: 8 additions & 2 deletions android/src/kr/clpeak/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;

import kr.clpeak.jni_connect;
import libcore.io.*;

public class MainActivity extends Activity {

public native void setenv(String key, String value);

static {
System.loadLibrary("clpeak");
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -132,7 +138,7 @@ public void onClick(DialogInterface dialog, int id)
return;
}
}
Libcore.os.setenv("LIBOPENCL_SO_PATH", libopenclSoPaths.get(arg2), true);
setenv("LIBOPENCL_SO_PATH", libopenclSoPaths.get(arg2));
}

@Override
Expand Down
4 changes: 0 additions & 4 deletions android/src/kr/clpeak/jni_connect.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ public class jni_connect extends AsyncTask<Integer, String, Integer>

public native int launchClpeak(int argc, String[] argv);

static {
System.loadLibrary("clpeak");
}

jni_connect(Activity _activity)
{
rootActivity = _activity;
Expand Down
7 changes: 0 additions & 7 deletions android/src/libcore/io/Libcore.java

This file was deleted.

6 changes: 0 additions & 6 deletions android/src/libcore/io/Os.java

This file was deleted.

8 changes: 8 additions & 0 deletions src/entry_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,11 @@ jint JNICALL Java_kr_clpeak_jni_1connect_launchClpeak(JNIEnv *_jniEnv,

return clObj.runAll();
}


void Java_kr_clpeak_MainActivity_setenv(JNIEnv *jniEnv,
jobject _jObj, jstring key, jstring value)
{
setenv((char*) jniEnv->GetStringUTFChars(key, 0),
(char*) jniEnv->GetStringUTFChars(value, 0), 1);
}
19 changes: 19 additions & 0 deletions src/include/jni_entry.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a171071

Please sign in to comment.