warn user if root before starting geth
This commit is contained in:
parent
058f470ea7
commit
1f0a4214b8
|
@ -8,6 +8,10 @@ import com.facebook.react.shell.MainReactPackage;
|
||||||
import com.rt2zz.reactnativecontacts.ReactNativeContacts;
|
import com.rt2zz.reactnativecontacts.ReactNativeContacts;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.DialogInterface.OnClickListener;
|
||||||
|
import android.content.DialogInterface.OnCancelListener;
|
||||||
import com.github.ethereum.go_ethereum.cmd.Geth;
|
import com.github.ethereum.go_ethereum.cmd.Geth;
|
||||||
import com.bitgo.randombytes.RandomBytesPackage;
|
import com.bitgo.randombytes.RandomBytesPackage;
|
||||||
import com.BV.LinearGradient.LinearGradientPackage;
|
import com.BV.LinearGradient.LinearGradientPackage;
|
||||||
|
@ -18,20 +22,20 @@ import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
|
||||||
import com.i18n.reactnativei18n.ReactNativeI18n;
|
import com.i18n.reactnativei18n.ReactNativeI18n;
|
||||||
import io.realm.react.RealmReactPackage;
|
import io.realm.react.RealmReactPackage;
|
||||||
|
|
||||||
|
|
||||||
public class MainActivity extends ReactActivity {
|
public class MainActivity extends ReactActivity {
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
|
protected void startStatus() {
|
||||||
// Required for android-16 (???)
|
// Required for android-16 (???)
|
||||||
System.loadLibrary("gethraw");
|
System.loadLibrary("gethraw");
|
||||||
System.loadLibrary("geth");
|
System.loadLibrary("geth");
|
||||||
|
|
||||||
// Required because of crazy APN settings redirecting localhost
|
// Required because of crazy APN settings redirecting localhost (found in GB)
|
||||||
Properties properties = System.getProperties();
|
Properties properties = System.getProperties();
|
||||||
properties.setProperty("http.nonProxyHosts", "localhost|127.0.0.1");
|
properties.setProperty("http.nonProxyHosts", "localhost|127.0.0.1");
|
||||||
properties.setProperty("https.nonProxyHosts", "localhost|127.0.0.1");
|
properties.setProperty("https.nonProxyHosts", "localhost|127.0.0.1");
|
||||||
|
@ -50,6 +54,38 @@ public class MainActivity extends ReactActivity {
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
if(!RootUtil.isDeviceRooted()) {
|
||||||
|
startStatus();
|
||||||
|
} else {
|
||||||
|
AlertDialog dialog = new AlertDialog.Builder(MainActivity.this).setMessage(getResources().getString(R.string.root_warning))
|
||||||
|
.setPositiveButton(getResources().getString(R.string.root_okay), new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
dialog.dismiss();
|
||||||
|
startStatus();
|
||||||
|
}
|
||||||
|
}).setNegativeButton(getResources().getString(R.string.root_cancel), new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
dialog.dismiss();
|
||||||
|
MainActivity.this.finishAffinity();
|
||||||
|
}
|
||||||
|
}).setOnCancelListener(new OnCancelListener() {
|
||||||
|
@Override
|
||||||
|
public void onCancel(DialogInterface dialog) {
|
||||||
|
dialog.dismiss();
|
||||||
|
MainActivity.this.finishAffinity();
|
||||||
|
}
|
||||||
|
}).create();
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of the main component registered from JavaScript.
|
* Returns the name of the main component registered from JavaScript.
|
||||||
* This is used to schedule rendering of the component.
|
* This is used to schedule rendering of the component.
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.statusim;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
|
/** @author Kevin Kowalewski */
|
||||||
|
public class RootUtil {
|
||||||
|
|
||||||
|
public static boolean isDeviceRooted() {
|
||||||
|
return checkRootMethod1() || checkRootMethod2() || checkRootMethod3();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean checkRootMethod1() {
|
||||||
|
String buildTags = android.os.Build.TAGS;
|
||||||
|
return buildTags != null && buildTags.contains("test-keys");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean checkRootMethod2() {
|
||||||
|
String[] paths = { "/system/app/Superuser.apk", "/sbin/su", "/system/bin/su", "/system/xbin/su", "/data/local/xbin/su", "/data/local/bin/su", "/system/sd/xbin/su",
|
||||||
|
"/system/bin/failsafe/su", "/data/local/su" };
|
||||||
|
for (String path : paths) {
|
||||||
|
if (new File(path).exists()) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean checkRootMethod3() {
|
||||||
|
Process process = null;
|
||||||
|
try {
|
||||||
|
process = Runtime.getRuntime().exec(new String[] { "/system/xbin/which", "su" });
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||||
|
if (in.readLine() != null) return true;
|
||||||
|
return false;
|
||||||
|
} catch (Throwable t) {
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
if (process != null) process.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +1,6 @@
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">StatusIm</string>
|
<string name="app_name">Status</string>
|
||||||
</resources>
|
<string name="root_warning">Your phone appears to be ROOTED, this is a serious security concern, continue only if you understand and accept the risks.</string>
|
||||||
|
<string name="root_okay">Continue</string>
|
||||||
|
<string name="root_cancel">Exit</string>
|
||||||
|
</resources>
|
Loading…
Reference in New Issue