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
aae95df4
Commit
aae95df4
authored
Dec 01, 2013
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add abi helper function
parent
af6fcf0e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
28 deletions
+25
-28
src/main/java/com/github/shadowsocks/System.java
src/main/java/com/github/shadowsocks/System.java
+1
-0
src/main/jni/Android.mk
src/main/jni/Android.mk
+4
-0
src/main/jni/system.cpp
src/main/jni/system.cpp
+19
-2
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+1
-1
src/main/scala/com/github/shadowsocks/utils/Utils.scala
src/main/scala/com/github/shadowsocks/utils/Utils.scala
+0
-25
No files found.
src/main/java/com/github/shadowsocks/System.java
View file @
aae95df4
...
...
@@ -44,4 +44,5 @@ public class System {
}
public
static
native
void
exec
(
String
cmd
);
public
static
native
String
getABI
();
}
src/main/jni/Android.mk
View file @
aae95df4
...
...
@@ -136,6 +136,8 @@ LOCAL_SRC_FILES:= \
LOCAL_LDLIBS
:=
-ldl
-llog
LOCAL_STATIC_LIBRARIES
:=
cpufeatures
include
$(BUILD_SHARED_LIBRARY)
########################################################
...
...
@@ -241,3 +243,5 @@ iptables_subdirs := $(addprefix $(LOCAL_PATH)/iptables/,$(addsuffix /Android.mk,
))
include
$(iptables_subdirs)
# Import cpufeatures
$(call
import-module,android/cpufeatures)
\ No newline at end of file
src/main/jni/system.cpp
View file @
aae95df4
...
...
@@ -5,12 +5,27 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <cpu-features.h>
#define LOGI(...) do { __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__); } while(0)
#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)
void
Java_com_github_shadowsocks_Node_exec
(
JNIEnv
*
env
,
jobject
thiz
,
jstring
cmd
)
{
jstring
Java_com_github_shadowsocks_system_getabi
(
JNIEnv
*
env
,
jobject
thiz
)
{
AndroidCpuFamily
family
=
android_getCpuFamily
();
const
char
*
abi
;
if
(
family
==
ANDROID_CPU_FAMILY_X86
)
{
abi
=
"x86"
;
}
else
if
(
family
==
ANDROID_CPU_FAMILY_MIPS
)
{
abi
=
"mips"
;
}
else
if
(
family
==
ANDROID_CPU_FAMILY_ARM
)
{
abi
=
"arm"
;
}
return
env
->
NewStringUTF
(
abi
);
}
void
Java_com_github_shadowsocks_system_exec
(
JNIEnv
*
env
,
jobject
thiz
,
jstring
cmd
)
{
const
char
*
str
=
env
->
GetStringUTFChars
(
cmd
,
0
);
setenv
(
"LD_LIBRARY_PATH"
,
"/vendor/lib:/system/lib"
,
1
);
setegid
(
getgid
());
...
...
@@ -23,7 +38,9 @@ static const char *classPathName = "com/github/shadowsocks/System";
static
JNINativeMethod
method_table
[]
=
{
{
"exec"
,
"(Ljava/lang/String;)V"
,
(
void
*
)
Java_com_github_shadowsocks_Node_exec
}
(
void
*
)
Java_com_github_shadowsocks_system_exec
},
{
"getABI"
,
"()Ljava/lang/String;"
,
(
void
*
)
Java_com_github_shadowsocks_system_getabi
}
};
/*
...
...
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
View file @
aae95df4
...
...
@@ -800,7 +800,7 @@ class Shadowsocks
def
reset
()
{
crash_recovery
()
copyAssets
(
Utils
.
getABI
)
copyAssets
(
System
.
getABI
)
Utils
.
runCommand
(
"chmod 755 /data/data/com.github.shadowsocks/iptables\n"
+
"chmod 755 /data/data/com.github.shadowsocks/redsocks\n"
+
"chmod 755 /data/data/com.github.shadowsocks/pdnsd\n"
...
...
src/main/scala/com/github/shadowsocks/utils/Utils.scala
View file @
aae95df4
...
...
@@ -282,31 +282,6 @@ object Utils {
false
}
/**
* Get the ABI of the device
* @return The ABI of the device, or ARM_ABI if not found
*/
def
getABI
:
String
=
{
val
prop
=
getSystemProperty
(
ABI_PROP
)
prop
match
{
case
abi
if
abi
.
toLowerCase
.
contains
(
ARM_ABI
)
=>
ARM_ABI
case
abi
if
abi
.
toLowerCase
.
contains
(
X86_ABI
)
=>
X86_ABI
case
_
=>
ARM_ABI
}
}
/**
* Returns a SystemProperty
*
* @param propName The Property to retrieve
* @return The Property, or NULL if not found
*/
def
getSystemProperty
(
propName
:
String
)
:
String
=
{
val
p
:
Process
=
Runtime
.
getRuntime
.
exec
(
"getprop "
+
propName
)
val
lines
=
scala
.
io
.
Source
.
fromInputStream
(
p
.
getInputStream
).
getLines
()
if
(
lines
.
hasNext
)
lines
.
next
()
else
null
}
/**
* Check the system's iptables
* Default to use the app's iptables
...
...
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