Commit 3975f951 authored by Max Lv's avatar Max Lv

add getABI()

parent 34a54dca
...@@ -460,6 +460,7 @@ public class Shadowsocks extends PreferenceActivity implements ...@@ -460,6 +460,7 @@ public class Shadowsocks extends PreferenceActivity implements
Utils.runRootCommand(sb.toString()); Utils.runRootCommand(sb.toString());
copyAssets(""); copyAssets("");
copyAssets(Utils.getABI());
Utils.runCommand("chmod 755 /data/data/com.github.shadowsocks/iptables\n" 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/redsocks\n"
......
...@@ -46,15 +46,17 @@ import android.graphics.drawable.Drawable; ...@@ -46,15 +46,17 @@ import android.graphics.drawable.Drawable;
import android.os.Environment; import android.os.Environment;
import android.util.Log; import android.util.Log;
import java.io.File; import java.io.*;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
public class Utils { public class Utils {
public final static String TAG = "Shadowsocks"; public final static String TAG = "Shadowsocks";
public final static String ABI_PROP = "ro.product.cpu.abi";
public final static String ABI2_PROP = "ro.product.cpu.abi2";
public final static String ARM_ABI = "arm";
public final static String X86_ABI = "x86";
public final static String MIPS_ABI = "mips";
public final static String DEFAULT_SHELL = "/system/bin/sh"; public final static String DEFAULT_SHELL = "/system/bin/sh";
public final static String DEFAULT_ROOT = "/system/bin/su"; public final static String DEFAULT_ROOT = "/system/bin/su";
public final static String ALTERNATIVE_ROOT = "/system/xbin/su"; public final static String ALTERNATIVE_ROOT = "/system/xbin/su";
...@@ -69,6 +71,54 @@ public class Utils { ...@@ -69,6 +71,54 @@ public class Utils {
private static String iptables = null; private static String iptables = null;
private static String data_path = null; private static String data_path = null;
public static String getABI() {
String abi = getSystemProperty(ABI_PROP);
String abi2 = getSystemProperty(ABI2_PROP);
if (abi2 != null) {
if (abi2.toLowerCase().contains(ARM_ABI)) {
return ARM_ABI;
} else if (abi2.toLowerCase().contains(X86_ABI)) {
return X86_ABI;
}
} else if (abi != null) {
if (abi.toLowerCase().contains(ARM_ABI)) {
return ARM_ABI;
} else if (abi.toLowerCase().contains(X86_ABI)) {
return X86_ABI;
}
}
return ARM_ABI;
}
/**
* Returns a SystemProperty
*
* @param propName The Property to retrieve
* @return The Property, or NULL if not found
*/
private static String getSystemProperty(String propName) {
String line;
BufferedReader input = null;
try {
Process p = Runtime.getRuntime().exec("getprop " + propName);
input = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024);
line = input.readLine();
input.close();
} catch (IOException ex) {
Log.e(TAG, "Unable to read sysprop " + propName, ex);
return null;
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
Log.e(TAG, "Exception while closing InputStream", e);
}
}
}
return line;
}
private static void checkIptables() { private static void checkIptables() {
if (!isRoot()) { if (!isRoot()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment