Add app lock for SDK < 18 with root (#35)

This commit is contained in:
Rafał Borcz 2017-11-18 22:35:48 +01:00 committed by Mikołaj Pich
parent 29d12b79ca
commit 6e334f2721
6 changed files with 28 additions and 7 deletions

View File

@ -4,10 +4,12 @@ import android.animation.Animator;
import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorListenerAdapter;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.support.design.widget.Snackbar; import android.support.design.widget.Snackbar;
import android.support.design.widget.TextInputLayout; import android.support.design.widget.TextInputLayout;
import android.support.v7.app.AlertDialog;
import android.view.View; import android.view.View;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.EditText; import android.widget.EditText;
@ -86,6 +88,8 @@ public class LoginTask extends AsyncTask<Void, String, Integer> {
return R.string.encrypt_failed_text; return R.string.encrypt_failed_text;
} catch (NotLoggedInErrorException | IOException e) { } catch (NotLoggedInErrorException | IOException e) {
return R.string.login_denied_text; return R.string.login_denied_text;
} catch (UnsupportedOperationException e) {
return -1;
} }
GradeJob gradeJob = new GradeJob(); GradeJob gradeJob = new GradeJob();
@ -135,6 +139,21 @@ public class LoginTask extends AsyncTask<Void, String, Integer> {
showSoftKeyboard(symbolView); showSoftKeyboard(symbolView);
break; break;
// if rooted and SDK < 18
case -1:
final AlertDialog.Builder alertDialog = new AlertDialog.Builder(activity.get())
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle(R.string.alert_dialog_blocked_app)
.setMessage(R.string.alert_dialog_blocked_app_message)
.setPositiveButton(R.string.dialog_close, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
alertDialog.show();
break;
default: default:
Snackbar.make(activity.get().findViewById(R.id.coordinatorLayout), Snackbar.make(activity.get().findViewById(R.id.coordinatorLayout),
messageID, Snackbar.LENGTH_LONG).show(); messageID, Snackbar.LENGTH_LONG).show();

View File

@ -3,7 +3,6 @@ package io.github.wulkanowy.security;
import android.content.Context; import android.content.Context;
import android.os.Build; import android.os.Build;
import android.util.Base64; import android.util.Base64;
import android.util.Log;
import io.github.wulkanowy.utilities.RootUtilities; import io.github.wulkanowy.utilities.RootUtilities;
@ -19,8 +18,7 @@ public class Safety extends Scrambler {
if (!RootUtilities.isRooted()) { if (!RootUtilities.isRooted()) {
return new String(Base64.encode(plainText.getBytes(), Base64.DEFAULT)); return new String(Base64.encode(plainText.getBytes(), Base64.DEFAULT));
} else { } else {
Log.e(Scrambler.DEBUG_TAG, "Password store in this devices isn't safe because is rooted"); throw new UnsupportedOperationException("Stored data in this devices isn't safe because android is rooted");
throw new UnsupportedOperationException("Password store in this devices isn't safe because is rooted");
} }
} }
} }

View File

@ -39,7 +39,8 @@ public class VulcanSynchronization {
} }
public void firstLoginSignInStep(Context context, DaoSession daoSession) public void firstLoginSignInStep(Context context, DaoSession daoSession)
throws NotLoggedInErrorException, AccountPermissionException, IOException, CryptoException { throws NotLoggedInErrorException, AccountPermissionException, IOException, CryptoException,
UnsupportedOperationException {
if (firstAccountLogin != null && certificate != null) { if (firstAccountLogin != null && certificate != null) {
loginSession = firstAccountLogin.login(context, daoSession, certificate); loginSession = firstAccountLogin.login(context, daoSession, certificate);
} else { } else {

View File

@ -44,7 +44,8 @@ public class FirstAccountLogin {
} }
public LoginSession login(Context context, DaoSession daoSession, String certificate) public LoginSession login(Context context, DaoSession daoSession, String certificate)
throws NotLoggedInErrorException, AccountPermissionException, IOException, CryptoException { throws NotLoggedInErrorException, AccountPermissionException, IOException, CryptoException,
UnsupportedOperationException {
long userId; long userId;

View File

@ -39,10 +39,11 @@
<string name="fragment_no_grades">Brak ocen</string> <string name="fragment_no_grades">Brak ocen</string>
<string name="noInternet_text">Brak połączenia z internetem</string> <string name="noInternet_text">Brak połączenia z internetem</string>
<string name="root_failed_text">To urządzenie posiada posiada podwyższone uprawnienia (root). Automatyczne logowanie zosatło wyłączone.</string>
<string name="encrypt_failed_text">Szyfrowanie nie powiodło się. Automatyczne logowanie zostało wyłączone</string> <string name="encrypt_failed_text">Szyfrowanie nie powiodło się. Automatyczne logowanie zostało wyłączone</string>
<string name="version_text">Wersja %1$s</string> <string name="version_text">Wersja %1$s</string>
<string name="refresh_error_text">"Podczas odświeżania zawartości wystąpił błąd. "</string> <string name="refresh_error_text">"Podczas odświeżania zawartości wystąpił błąd. "</string>
<string name="alert_dialog_blocked_app">Blokada aplikacji</string>
<string name="alert_dialog_blocked_app_message">W obawie o bezpieczeństwo przechowywanych danych osobistych na urządzeniu z podwyższonymi uprawnieniami (root), aplikacja Wulkanowy została zablokowana</string>
<string name="dialog_description_text">Opis</string> <string name="dialog_description_text">Opis</string>
<string name="dialog_weight_text">Waga</string> <string name="dialog_weight_text">Waga</string>

View File

@ -39,10 +39,11 @@
<string name="fragment_no_grades">No grades</string> <string name="fragment_no_grades">No grades</string>
<string name="noInternet_text">No internet connection</string> <string name="noInternet_text">No internet connection</string>
<string name="root_failed_text">This device is rooted. Automatic login has been disabled</string>
<string name="encrypt_failed_text">Encryption failed. Automatic login has been disabled</string> <string name="encrypt_failed_text">Encryption failed. Automatic login has been disabled</string>
<string name="version_text">Version %1$s</string> <string name="version_text">Version %1$s</string>
<string name="refresh_error_text">An error occurred while refreshing the content.</string> <string name="refresh_error_text">An error occurred while refreshing the content.</string>
<string name="alert_dialog_blocked_app">Application lock</string>
<string name="alert_dialog_blocked_app_message">For the sake of safety of personal data stored on a device with increased authorization (root), the Wulkanowy application has been blocked.</string>
<string name="dialog_description_text">Description</string> <string name="dialog_description_text">Description</string>
<string name="dialog_weight_text">Weight</string> <string name="dialog_weight_text">Weight</string>