Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
dadeffa9
Commit
dadeffa9
authored
Jan 24, 2017
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename System to JniHelper to rename naming conflicts with
`java.lang.System`
parent
04e0cb02
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
19 deletions
+19
-19
mobile/build.sbt
mobile/build.sbt
+1
-1
mobile/src/main/java/com/github/shadowsocks/JniHelper.java
mobile/src/main/java/com/github/shadowsocks/JniHelper.java
+4
-4
mobile/src/main/jni/Android.mk
mobile/src/main/jni/Android.mk
+3
-3
mobile/src/main/jni/jni-helper.cpp
mobile/src/main/jni/jni-helper.cpp
+9
-9
mobile/src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
.../scala/com/github/shadowsocks/ShadowsocksVpnService.scala
+1
-1
mobile/src/main/scala/com/github/shadowsocks/ShadowsocksVpnThread.scala
...n/scala/com/github/shadowsocks/ShadowsocksVpnThread.scala
+1
-1
No files found.
mobile/build.sbt
View file @
dadeffa9
...
...
@@ -6,7 +6,7 @@ version := "4.0.0"
versionCode
:=
Some
(
175
)
proguardOptions
++=
"-keep class com.github.shadowsocks.
System
{ *; }"
::
"-keep class com.github.shadowsocks.
JniHelper
{ *; }"
::
"-dontwarn com.google.android.gms.internal.**"
::
"-dontwarn com.j256.ormlite.**"
::
"-dontwarn okio.**"
::
...
...
mobile/src/main/java/com/github/shadowsocks/
System
.java
→
mobile/src/main/java/com/github/shadowsocks/
JniHelper
.java
View file @
dadeffa9
...
...
@@ -38,12 +38,12 @@
package
com.github.shadowsocks
;
public
class
System
{
public
class
JniHelper
{
static
{
java
.
lang
.
System
.
loadLibrary
(
"system
"
);
System
.
loadLibrary
(
"jni-helper
"
);
}
public
static
native
int
exec
(
String
cmd
);
public
static
native
int
send
f
d
(
int
fd
,
String
path
);
public
static
native
void
jni
close
(
int
fd
);
public
static
native
int
send
F
d
(
int
fd
,
String
path
);
public
static
native
void
close
(
int
fd
);
}
mobile/src/main/jni/Android.mk
View file @
dadeffa9
...
...
@@ -388,16 +388,16 @@ LOCAL_LDLIBS := -llog
include
$(BUILD_SHARED_EXECUTABLE)
########################################################
##
system
##
jni-helper
########################################################
include
$(CLEAR_VARS)
LOCAL_MODULE
:=
system
LOCAL_MODULE
:=
jni-helper
LOCAL_C_INCLUDES
:=
$(LOCAL_PATH)
/libancillary
LOCAL_SRC_FILES
:=
system
.cpp
LOCAL_SRC_FILES
:=
jni-helper
.cpp
LOCAL_LDLIBS
:=
-ldl
-llog
...
...
mobile/src/main/jni/
system
.cpp
→
mobile/src/main/jni/
jni-helper
.cpp
View file @
dadeffa9
...
...
@@ -17,7 +17,7 @@
#define LOGW(...) do { __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__); } while(0)
#define LOGE(...) do { __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__); } while(0)
jint
Java_com_github_shadowsocks_
system
_exec
(
JNIEnv
*
env
,
jobject
thiz
,
jstring
cmd
)
{
jint
Java_com_github_shadowsocks_
jnihelper
_exec
(
JNIEnv
*
env
,
jobject
thiz
,
jstring
cmd
)
{
const
char
*
cmd_str
=
env
->
GetStringUTFChars
(
cmd
,
0
);
pid_t
pid
;
...
...
@@ -40,11 +40,11 @@ jint Java_com_github_shadowsocks_system_exec(JNIEnv *env, jobject thiz, jstring
return
1
;
}
void
Java_com_github_shadowsocks_
system_jni
close
(
JNIEnv
*
env
,
jobject
thiz
,
jint
fd
)
{
void
Java_com_github_shadowsocks_
jnihelper_
close
(
JNIEnv
*
env
,
jobject
thiz
,
jint
fd
)
{
close
(
fd
);
}
jint
Java_com_github_shadowsocks_
system
_sendfd
(
JNIEnv
*
env
,
jobject
thiz
,
jint
tun_fd
,
jstring
path
)
{
jint
Java_com_github_shadowsocks_
jnihelper
_sendfd
(
JNIEnv
*
env
,
jobject
thiz
,
jint
tun_fd
,
jstring
path
)
{
int
fd
;
struct
sockaddr_un
addr
;
const
char
*
sock_str
=
env
->
GetStringUTFChars
(
path
,
0
);
...
...
@@ -75,15 +75,15 @@ jint Java_com_github_shadowsocks_system_sendfd(JNIEnv *env, jobject thiz, jint t
return
0
;
}
static
const
char
*
classPathName
=
"com/github/shadowsocks/
System
"
;
static
const
char
*
classPathName
=
"com/github/shadowsocks/
JniHelper
"
;
static
JNINativeMethod
method_table
[]
=
{
{
"
jni
close"
,
"(I)V"
,
(
void
*
)
Java_com_github_shadowsocks_
system_jni
close
},
{
"send
f
d"
,
"(ILjava/lang/String;)I"
,
(
void
*
)
Java_com_github_shadowsocks_
system
_sendfd
},
{
"close"
,
"(I)V"
,
(
void
*
)
Java_com_github_shadowsocks_
jnihelper_
close
},
{
"send
F
d"
,
"(ILjava/lang/String;)I"
,
(
void
*
)
Java_com_github_shadowsocks_
jnihelper
_sendfd
},
{
"exec"
,
"(Ljava/lang/String;)I"
,
(
void
*
)
Java_com_github_shadowsocks_
system
_exec
}
(
void
*
)
Java_com_github_shadowsocks_
jnihelper
_exec
}
};
...
...
mobile/src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
View file @
dadeffa9
...
...
@@ -291,7 +291,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
var
tries
=
1
while
(
tries
<
5
)
{
Thread
.
sleep
(
1000
*
tries
)
if
(
System
.
sendf
d
(
fd
,
new
File
(
getFilesDir
,
"sock_path"
).
getAbsolutePath
)
!=
-
1
)
{
if
(
JniHelper
.
sendF
d
(
fd
,
new
File
(
getFilesDir
,
"sock_path"
).
getAbsolutePath
)
!=
-
1
)
{
return
true
}
tries
+=
1
...
...
mobile/src/main/scala/com/github/shadowsocks/ShadowsocksVpnThread.scala
View file @
dadeffa9
...
...
@@ -92,7 +92,7 @@ class ShadowsocksVpnThread(service: ShadowsocksVpnService) extends Thread {
val
ret
=
service
.
protect
(
fd
)
// Trick to close file decriptor
System
.
jni
close
(
fd
)
JniHelper
.
close
(
fd
)
if
(
ret
)
{
output
.
write
(
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment