Added crashlytics and answer from fabric.io. Add warning for rooted device. Change migration to KeyChain.

pull/2/head
MadCake 7 years ago
parent 4fb8cfa939
commit 3c89a5ec0d
  1. 21
      app/build.gradle
  2. 3
      app/src/main/AndroidManifest.xml
  3. 1
      app/src/main/java/com/wallet/crypto/trustapp/util/PMMigrateHelper.java
  4. 42
      app/src/main/java/com/wallet/crypto/trustapp/util/RootUtil.java
  5. 3
      app/src/main/java/com/wallet/crypto/trustapp/views/SplashActivity.java
  6. 111
      app/src/main/java/com/wallet/crypto/trustapp/views/TransactionListActivity.java
  7. 2
      app/src/main/res/values/strings.xml

@ -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: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android { android {
compileSdkVersion 26 compileSdkVersion 26
@ -57,4 +72,10 @@ dependencies {
compile 'com.google.zxing:core:3.2.1' compile 'com.google.zxing:core:3.2.1'
compile 'com.journeyapps:zxing-android-embedded:3.2.0@aar' compile 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
testCompile 'junit:junit:4.12' 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;
}
} }

@ -79,6 +79,9 @@
android:name=".views.TokenListActivity" android:name=".views.TokenListActivity"
android:label="@string/title_activity_token_list" android:label="@string/title_activity_token_list"
android:theme="@style/AppTheme.NoActionBar" /> android:theme="@style/AppTheme.NoActionBar" />
<meta-data
android:name="io.fabric.ApiKey"
android:value="74d3fa8b5038a154c0c05555d27112a0d4a80d68" />
</application> </application>
</manifest> </manifest>

@ -18,7 +18,6 @@ public class PMMigrateHelper {
String address = key.replace("-pwd", ""); String address = key.replace("-pwd", "");
try { try {
KS.put(context, address.toLowerCase(), PasswordManager.getPassword(address, context)); KS.put(context, address.toLowerCase(), PasswordManager.getPassword(address, context));
pref.edit().remove(key).apply();
} catch (ServiceErrorException ex) { } catch (ServiceErrorException ex) {
throw ex; throw ex;
} catch (Exception ex) { } catch (Exception ex) {

@ -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();
}
}
}

@ -3,6 +3,8 @@ package com.wallet.crypto.trustapp.views;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import com.crashlytics.android.Crashlytics;
import io.fabric.sdk.android.Fabric;
public class SplashActivity extends AppCompatActivity { public class SplashActivity extends AppCompatActivity {
@ -11,6 +13,7 @@ public class SplashActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
Fabric.with(this, new Crashlytics());
// Start home activity // Start home activity

@ -33,6 +33,7 @@ import com.wallet.crypto.trustapp.model.ESTransaction;
import com.wallet.crypto.trustapp.model.VMAccount; import com.wallet.crypto.trustapp.model.VMAccount;
import com.wallet.crypto.trustapp.util.KS; import com.wallet.crypto.trustapp.util.KS;
import com.wallet.crypto.trustapp.util.PMMigrateHelper; import com.wallet.crypto.trustapp.util.PMMigrateHelper;
import com.wallet.crypto.trustapp.util.RootUtil;
import java.util.List; import java.util.List;
@ -170,58 +171,74 @@ public class TransactionListActivity extends AppCompatActivity {
@Override @Override
public void onResume() { public void onResume() {
Log.d(TAG, "onResume");
super.onResume(); super.onResume();
init(); init();
Log.d(TAG, "Number of accounts: " + mController.getNumberOfAccounts()); checkGuard();
checkRoot();
KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); if (mController.getAccounts().size() == 0) {
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this); Intent intent = new Intent(getApplicationContext(), CreateAccountActivity.class);
if (keyguardManager != null this.startActivityForResult(intent, Controller.IMPORT_ACCOUNT_REQUEST);
&& !keyguardManager.isDeviceSecure() finish();
&& pref.getBoolean("should_show_security_alert", true)) { } else {
pref.edit().putBoolean("should_show_security_alert", false).apply(); mController.onResume();
new AlertDialog.Builder(this) try {
.setTitle(R.string.lock_title) PMMigrateHelper.migrate(this);
.setMessage(R.string.lock_body) } catch (ServiceErrorException e) {
.setPositiveButton(R.string.lock_settings, new DialogInterface.OnClickListener() { if (e.code == ServiceErrorException.USER_NOT_AUTHENTICATED) {
@Override KS.showAuthenticationScreen(this, Controller.UNLOCK_SCREEN_REQUEST);
public void onClick(DialogInterface dialog, int which) { } else {
Intent intent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD); Toast.makeText(this, "Could not process passwords.", Toast.LENGTH_LONG)
startActivity(intent); .show();
} }
}) }
.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();
}
}
}
}
} }
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 (requestCode == Controller.IMPORT_ACCOUNT_REQUEST) {
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
this.finish(); this.finish();

@ -123,5 +123,7 @@
<string name="gas_limit">Gas Limit</string> <string name="gas_limit">Gas Limit</string>
<string name="gas_price">Gas Price (Wei)</string> <string name="gas_price">Gas Price (Wei)</string>
<string name="skip">Skip</string> <string name="skip">Skip</string>
<string name="root_title">Your device is rooted.</string>
<string name="root_body">Your device is rooted. Your data is under threat.</string>
</resources> </resources>

Loading…
Cancel
Save