Remove the root check (#114)

This commit is contained in:
Rafał Borcz 2018-05-19 12:48:12 +02:00 committed by Mikołaj Pich
parent 62bc00cd68
commit e9b357e92d
3 changed files with 3 additions and 49 deletions

View File

@ -135,7 +135,7 @@ public class ExamsTabFragment extends BaseFragment implements ExamsTabContract.V
@Override
public void onDestroyView() {
super.onDestroyView();
presenter.onDestroy();
super.onDestroyView();
}
}

View File

@ -1,38 +0,0 @@
package io.github.wulkanowy.utils;
import android.os.Build;
import java.io.File;
public final class RootChecker {
private RootChecker() {
throw new IllegalStateException("Utility class");
}
public static boolean isRooted() {
return checkOne() || checkTwo() || checkThree();
}
private static boolean checkOne() {
return Build.TAGS != null && Build.TAGS.contains("test-keys");
}
private static boolean checkTwo() {
return new File("/system/app/Superuser.apk").exists();
}
private static boolean checkThree() {
String[] commands = {"/system/xbin/which su", "/system/bin/which su", "which su"};
for (String command : commands) {
try {
Runtime.getRuntime().exec(command);
return true;
} catch (Exception e) {
// ignore
}
}
return false;
}
}

View File

@ -27,7 +27,6 @@ import javax.crypto.CipherOutputStream;
import javax.security.auth.x500.X500Principal;
import io.github.wulkanowy.utils.LogUtils;
import io.github.wulkanowy.utils.RootChecker;
public final class Scrambler {
@ -46,23 +45,16 @@ public final class Scrambler {
loadKeyStore();
generateNewKey(email, context);
return encryptString(email, plainText);
} else {
if (RootChecker.isRooted()) {
}
return new String(Base64.encode(plainText.getBytes(), Base64.DEFAULT));
} else {
throw new UnsupportedOperationException("Stored data in this devices " +
"isn't safe because android is rooted");
}
}
}
public static String decrypt(String email, String encryptedText) throws CryptoException {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
loadKeyStore();
return decryptString(email, encryptedText);
} else {
return new String(Base64.decode(encryptedText, Base64.DEFAULT));
}
return new String(Base64.decode(encryptedText, Base64.DEFAULT));
}
private static void loadKeyStore() throws CryptoException {