|
|
@ -40,9 +40,7 @@ import android.net.Uri;
|
|
|
|
import android.os.Build;
|
|
|
|
import android.os.Build;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Environment;
|
|
|
|
import android.os.Environment;
|
|
|
|
import android.os.Handler;
|
|
|
|
|
|
|
|
import android.os.LocaleList;
|
|
|
|
import android.os.LocaleList;
|
|
|
|
import android.os.Looper;
|
|
|
|
|
|
|
|
import android.os.Parcel;
|
|
|
|
import android.os.Parcel;
|
|
|
|
import android.os.PowerManager;
|
|
|
|
import android.os.PowerManager;
|
|
|
|
import android.os.StatFs;
|
|
|
|
import android.os.StatFs;
|
|
|
@ -1258,8 +1256,6 @@ public class Helper {
|
|
|
|
static void authenticate(final FragmentActivity activity, final LifecycleOwner owner,
|
|
|
|
static void authenticate(final FragmentActivity activity, final LifecycleOwner owner,
|
|
|
|
Boolean enabled, final
|
|
|
|
Boolean enabled, final
|
|
|
|
Runnable authenticated, final Runnable cancelled) {
|
|
|
|
Runnable authenticated, final Runnable cancelled) {
|
|
|
|
final Handler handler = new Handler();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
|
|
|
String pin = prefs.getString("pin", null);
|
|
|
|
String pin = prefs.getString("pin", null);
|
|
|
|
|
|
|
|
|
|
|
@ -1289,7 +1285,7 @@ public class Helper {
|
|
|
|
if (errorCode != BiometricPrompt.ERROR_NEGATIVE_BUTTON &&
|
|
|
|
if (errorCode != BiometricPrompt.ERROR_NEGATIVE_BUTTON &&
|
|
|
|
errorCode != BiometricPrompt.ERROR_CANCELED &&
|
|
|
|
errorCode != BiometricPrompt.ERROR_CANCELED &&
|
|
|
|
errorCode != BiometricPrompt.ERROR_USER_CANCELED)
|
|
|
|
errorCode != BiometricPrompt.ERROR_USER_CANCELED)
|
|
|
|
handler.post(new Runnable() {
|
|
|
|
ApplicationEx.getMainHandler().post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
ToastEx.makeText(activity,
|
|
|
|
ToastEx.makeText(activity,
|
|
|
@ -1298,20 +1294,20 @@ public class Helper {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
handler.post(cancelled);
|
|
|
|
ApplicationEx.getMainHandler().post(cancelled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onAuthenticationSucceeded(@NonNull BiometricPrompt.AuthenticationResult result) {
|
|
|
|
public void onAuthenticationSucceeded(@NonNull BiometricPrompt.AuthenticationResult result) {
|
|
|
|
Log.i("Biometric succeeded");
|
|
|
|
Log.i("Biometric succeeded");
|
|
|
|
setAuthenticated(activity);
|
|
|
|
setAuthenticated(activity);
|
|
|
|
handler.post(authenticated);
|
|
|
|
ApplicationEx.getMainHandler().post(authenticated);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onAuthenticationFailed() {
|
|
|
|
public void onAuthenticationFailed() {
|
|
|
|
Log.w("Biometric failed");
|
|
|
|
Log.w("Biometric failed");
|
|
|
|
handler.post(cancelled);
|
|
|
|
ApplicationEx.getMainHandler().post(cancelled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -1328,12 +1324,12 @@ public class Helper {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
handler.postDelayed(cancelPrompt, 60 * 1000L);
|
|
|
|
ApplicationEx.getMainHandler().postDelayed(cancelPrompt, 60 * 1000L);
|
|
|
|
|
|
|
|
|
|
|
|
owner.getLifecycle().addObserver(new LifecycleObserver() {
|
|
|
|
owner.getLifecycle().addObserver(new LifecycleObserver() {
|
|
|
|
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
|
|
|
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
|
|
|
public void onDestroy() {
|
|
|
|
public void onDestroy() {
|
|
|
|
handler.post(cancelPrompt);
|
|
|
|
ApplicationEx.getMainHandler().post(cancelPrompt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -1352,21 +1348,21 @@ public class Helper {
|
|
|
|
|
|
|
|
|
|
|
|
if (pin.equals(entered)) {
|
|
|
|
if (pin.equals(entered)) {
|
|
|
|
setAuthenticated(activity);
|
|
|
|
setAuthenticated(activity);
|
|
|
|
handler.post(authenticated);
|
|
|
|
ApplicationEx.getMainHandler().post(authenticated);
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
handler.post(cancelled);
|
|
|
|
ApplicationEx.getMainHandler().post(cancelled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
|
|
|
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
handler.post(cancelled);
|
|
|
|
ApplicationEx.getMainHandler().post(cancelled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
|
|
|
.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onDismiss(DialogInterface dialog) {
|
|
|
|
public void onDismiss(DialogInterface dialog) {
|
|
|
|
handler.post(cancelled);
|
|
|
|
ApplicationEx.getMainHandler().post(cancelled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.create();
|
|
|
|
.create();
|
|
|
@ -1390,7 +1386,7 @@ public class Helper {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
new Handler().post(new Runnable() {
|
|
|
|
ApplicationEx.getMainHandler().post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
etPin.requestFocus();
|
|
|
|
etPin.requestFocus();
|
|
|
@ -1413,8 +1409,6 @@ public class Helper {
|
|
|
|
|
|
|
|
|
|
|
|
static void selectKeyAlias(final Activity activity, final LifecycleOwner owner, final String alias, final IKeyAlias intf) {
|
|
|
|
static void selectKeyAlias(final Activity activity, final LifecycleOwner owner, final String alias, final IKeyAlias intf) {
|
|
|
|
final Context context = activity.getApplicationContext();
|
|
|
|
final Context context = activity.getApplicationContext();
|
|
|
|
final Handler handler = new Handler(Looper.getMainLooper());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new Thread(new Runnable() {
|
|
|
|
new Thread(new Runnable() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
@ -1431,7 +1425,7 @@ public class Helper {
|
|
|
|
Log.e(ex);
|
|
|
|
Log.e(ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
handler.post(new Runnable() {
|
|
|
|
ApplicationEx.getMainHandler().post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
KeyChain.choosePrivateKeyAlias(activity, new KeyChainAliasCallback() {
|
|
|
|
KeyChain.choosePrivateKeyAlias(activity, new KeyChainAliasCallback() {
|
|
|
@ -1447,7 +1441,7 @@ public class Helper {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void deliver(final String selected) {
|
|
|
|
private void deliver(final String selected) {
|
|
|
|
handler.post(new Runnable() {
|
|
|
|
ApplicationEx.getMainHandler().post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
if (owner.getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
|
|
|
|
if (owner.getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
|
|
|
|