diff --git a/app/build.gradle b/app/build.gradle
index db00ce284..5e63b0436 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,4 +1,19 @@
+buildscript {
+ repositories {
+ maven { url 'https://maven.fabric.io/public' }
+ }
+
+ dependencies {
+ classpath 'io.fabric.tools:gradle:1.+'
+ }
+}
apply plugin: 'com.android.application'
+apply plugin: 'io.fabric'
+
+repositories {
+ maven { url 'https://maven.fabric.io/public' }
+}
+
android {
compileSdkVersion 26
@@ -57,4 +72,10 @@ dependencies {
compile 'com.google.zxing:core:3.2.1'
compile 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
testCompile 'junit:junit:4.12'
+ compile('com.crashlytics.sdk.android:crashlytics:2.8.0@aar') {
+ transitive = true;
+ }
+ compile('com.crashlytics.sdk.android:answers:1.4.1@aar') {
+ transitive = true;
+ }
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 995b987db..bd90f92bb 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -79,6 +79,9 @@
android:name=".views.TokenListActivity"
android:label="@string/title_activity_token_list"
android:theme="@style/AppTheme.NoActionBar" />
+
\ No newline at end of file
diff --git a/app/src/main/java/com/wallet/crypto/trustapp/util/PMMigrateHelper.java b/app/src/main/java/com/wallet/crypto/trustapp/util/PMMigrateHelper.java
index 839970ce3..4a8a7080f 100644
--- a/app/src/main/java/com/wallet/crypto/trustapp/util/PMMigrateHelper.java
+++ b/app/src/main/java/com/wallet/crypto/trustapp/util/PMMigrateHelper.java
@@ -18,7 +18,6 @@ public class PMMigrateHelper {
String address = key.replace("-pwd", "");
try {
KS.put(context, address.toLowerCase(), PasswordManager.getPassword(address, context));
- pref.edit().remove(key).apply();
} catch (ServiceErrorException ex) {
throw ex;
} catch (Exception ex) {
diff --git a/app/src/main/java/com/wallet/crypto/trustapp/util/RootUtil.java b/app/src/main/java/com/wallet/crypto/trustapp/util/RootUtil.java
new file mode 100644
index 000000000..514fdaea7
--- /dev/null
+++ b/app/src/main/java/com/wallet/crypto/trustapp/util/RootUtil.java
@@ -0,0 +1,42 @@
+package com.wallet.crypto.trustapp.util;
+
+import java.io.BufferedReader;
+import java.io.File;
+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", "/su/bin/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();
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/wallet/crypto/trustapp/views/SplashActivity.java b/app/src/main/java/com/wallet/crypto/trustapp/views/SplashActivity.java
index ee490d836..7fe056159 100644
--- a/app/src/main/java/com/wallet/crypto/trustapp/views/SplashActivity.java
+++ b/app/src/main/java/com/wallet/crypto/trustapp/views/SplashActivity.java
@@ -3,6 +3,8 @@ package com.wallet.crypto.trustapp.views;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
+import com.crashlytics.android.Crashlytics;
+import io.fabric.sdk.android.Fabric;
public class SplashActivity extends AppCompatActivity {
@@ -11,6 +13,7 @@ public class SplashActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ Fabric.with(this, new Crashlytics());
// Start home activity
diff --git a/app/src/main/java/com/wallet/crypto/trustapp/views/TransactionListActivity.java b/app/src/main/java/com/wallet/crypto/trustapp/views/TransactionListActivity.java
index a16ce4b77..3e928719e 100644
--- a/app/src/main/java/com/wallet/crypto/trustapp/views/TransactionListActivity.java
+++ b/app/src/main/java/com/wallet/crypto/trustapp/views/TransactionListActivity.java
@@ -33,6 +33,7 @@ import com.wallet.crypto.trustapp.model.ESTransaction;
import com.wallet.crypto.trustapp.model.VMAccount;
import com.wallet.crypto.trustapp.util.KS;
import com.wallet.crypto.trustapp.util.PMMigrateHelper;
+import com.wallet.crypto.trustapp.util.RootUtil;
import java.util.List;
@@ -170,58 +171,74 @@ public class TransactionListActivity extends AppCompatActivity {
@Override
public void onResume() {
- Log.d(TAG, "onResume");
-
super.onResume();
init();
- Log.d(TAG, "Number of accounts: " + mController.getNumberOfAccounts());
-
-
- KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
- SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
- if (keyguardManager != null
- && !keyguardManager.isDeviceSecure()
- && pref.getBoolean("should_show_security_alert", true)) {
- pref.edit().putBoolean("should_show_security_alert", false).apply();
- new AlertDialog.Builder(this)
- .setTitle(R.string.lock_title)
- .setMessage(R.string.lock_body)
- .setPositiveButton(R.string.lock_settings, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- Intent intent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
- startActivity(intent);
- }
- })
- .setNegativeButton(R.string.skip, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- }
- })
- .show();
- } else {
- if (mController.getAccounts().size() == 0) {
- Intent intent = new Intent(getApplicationContext(), CreateAccountActivity.class);
- this.startActivityForResult(intent, Controller.IMPORT_ACCOUNT_REQUEST);
- finish();
- } else {
- mController.onResume();
- try {
- PMMigrateHelper.migrate(this);
- } catch (ServiceErrorException e) {
- if (e.code == ServiceErrorException.USER_NOT_AUTHENTICATED) {
- KS.showAuthenticationScreen(this, Controller.UNLOCK_SCREEN_REQUEST);
- } else {
- Toast.makeText(this, "Could not process passwords.", Toast.LENGTH_LONG)
- .show();
- }
- }
- }
- }
+ checkGuard();
+ checkRoot();
+
+ if (mController.getAccounts().size() == 0) {
+ Intent intent = new Intent(getApplicationContext(), CreateAccountActivity.class);
+ this.startActivityForResult(intent, Controller.IMPORT_ACCOUNT_REQUEST);
+ finish();
+ } else {
+ mController.onResume();
+ try {
+ PMMigrateHelper.migrate(this);
+ } catch (ServiceErrorException e) {
+ if (e.code == ServiceErrorException.USER_NOT_AUTHENTICATED) {
+ KS.showAuthenticationScreen(this, Controller.UNLOCK_SCREEN_REQUEST);
+ } else {
+ Toast.makeText(this, "Could not process passwords.", Toast.LENGTH_LONG)
+ .show();
+ }
+ }
+ }
}
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ private void checkRoot() {
+ SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
+ if (RootUtil.isDeviceRooted() && pref.getBoolean("should_show_root_warning", true)) {
+ pref.edit().putBoolean("should_show_root_warning", false).apply();
+ new AlertDialog.Builder(this)
+ .setTitle(R.string.root_title)
+ .setMessage(R.string.root_body)
+ .setNegativeButton(R.string.ok, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ }
+ })
+ .show();
+ }
+ }
+
+ private void checkGuard() {
+ KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
+ SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
+ if (keyguardManager != null
+ && !keyguardManager.isDeviceSecure()
+ && pref.getBoolean("should_show_security_warning", true)) {
+ pref.edit().putBoolean("should_show_security_warning", false).apply();
+ new AlertDialog.Builder(this)
+ .setTitle(R.string.lock_title)
+ .setMessage(R.string.lock_body)
+ .setPositiveButton(R.string.lock_settings, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ Intent intent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
+ startActivity(intent);
+ }
+ })
+ .setNegativeButton(R.string.skip, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ }
+ })
+ .show();
+ }
+ }
+
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == Controller.IMPORT_ACCOUNT_REQUEST) {
if (resultCode == RESULT_OK) {
this.finish();
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 846d11fdd..ea8175e59 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -123,5 +123,7 @@
Gas Limit
Gas Price (Wei)
Skip
+ Your device is rooted.
+ Your device is rooted. Your data is under threat.