forked from github/wulkanowy-mirror
Add app lock for SDK < 18 with root (#35)
This commit is contained in:

committed by
Mikołaj Pich

parent
29d12b79ca
commit
6e334f2721
@ -4,10 +4,12 @@ import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.design.widget.TextInputLayout;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
@ -86,6 +88,8 @@ public class LoginTask extends AsyncTask<Void, String, Integer> {
|
||||
return R.string.encrypt_failed_text;
|
||||
} catch (NotLoggedInErrorException | IOException e) {
|
||||
return R.string.login_denied_text;
|
||||
} catch (UnsupportedOperationException e) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
GradeJob gradeJob = new GradeJob();
|
||||
@ -135,6 +139,21 @@ public class LoginTask extends AsyncTask<Void, String, Integer> {
|
||||
showSoftKeyboard(symbolView);
|
||||
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:
|
||||
Snackbar.make(activity.get().findViewById(R.id.coordinatorLayout),
|
||||
messageID, Snackbar.LENGTH_LONG).show();
|
||||
|
@ -3,7 +3,6 @@ package io.github.wulkanowy.security;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
|
||||
import io.github.wulkanowy.utilities.RootUtilities;
|
||||
|
||||
@ -19,8 +18,7 @@ public class Safety extends Scrambler {
|
||||
if (!RootUtilities.isRooted()) {
|
||||
return new String(Base64.encode(plainText.getBytes(), Base64.DEFAULT));
|
||||
} else {
|
||||
Log.e(Scrambler.DEBUG_TAG, "Password store in this devices isn't safe because is rooted");
|
||||
throw new UnsupportedOperationException("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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,8 @@ public class VulcanSynchronization {
|
||||
}
|
||||
|
||||
public void firstLoginSignInStep(Context context, DaoSession daoSession)
|
||||
throws NotLoggedInErrorException, AccountPermissionException, IOException, CryptoException {
|
||||
throws NotLoggedInErrorException, AccountPermissionException, IOException, CryptoException,
|
||||
UnsupportedOperationException {
|
||||
if (firstAccountLogin != null && certificate != null) {
|
||||
loginSession = firstAccountLogin.login(context, daoSession, certificate);
|
||||
} else {
|
||||
|
@ -44,7 +44,8 @@ public class FirstAccountLogin {
|
||||
}
|
||||
|
||||
public LoginSession login(Context context, DaoSession daoSession, String certificate)
|
||||
throws NotLoggedInErrorException, AccountPermissionException, IOException, CryptoException {
|
||||
throws NotLoggedInErrorException, AccountPermissionException, IOException, CryptoException,
|
||||
UnsupportedOperationException {
|
||||
|
||||
long userId;
|
||||
|
||||
|
Reference in New Issue
Block a user