fix: Call requires API level 23 (current min is 14): isFingerprintReady

This commit is contained in:
tobiasKaminsky 2017-08-01 10:30:23 +02:00
parent d8cf4f8464
commit 28e7caedda
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7
2 changed files with 9 additions and 21 deletions

View file

@ -23,6 +23,7 @@ import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.PowerManager;
import android.preference.PreferenceManager;
import android.view.WindowManager;
@ -71,26 +72,22 @@ public class PassCodeManager {
}
public void onActivityStarted(Activity activity) {
if (!sExemptOfPasscodeActivites.contains(activity.getClass()) &&
passCodeShouldBeRequested()
){
if (!sExemptOfPasscodeActivites.contains(activity.getClass()) && passCodeShouldBeRequested()) {
Intent i = new Intent(MainApp.getAppContext(), PassCodeActivity.class);
i.setAction(PassCodeActivity.ACTION_CHECK);
i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
activity.startActivity(i);
}
if (!sExemptOfPasscodeActivites.contains(activity.getClass()) &&
fingerprintShouldBeRequested() && FingerprintActivity.isFingerprintReady(MainApp.getAppContext())
){
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
fingerprintShouldBeRequested() && FingerprintActivity.isFingerprintReady(MainApp.getAppContext())) {
Intent i = new Intent(MainApp.getAppContext(), FingerprintActivity.class);
i.setAction(PassCodeActivity.ACTION_CHECK);
i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
activity.startActivity(i);
}
mVisibleActivitiesCounter++; // keep it AFTER passCodeShouldBeRequested was checked

View file

@ -20,8 +20,6 @@
package com.owncloud.android.ui.activity;
import android.Manifest;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.KeyguardManager;
import android.content.Context;
import android.content.Intent;
@ -71,7 +69,7 @@ import javax.crypto.SecretKey;
/**
* Activity to handle access to the app based on the fingerprint.
*/
@TargetApi(Build.VERSION_CODES.M)
@RequiresApi(Build.VERSION_CODES.M)
public class FingerprintActivity extends AppCompatActivity {
private static final String TAG = FingerprintActivity.class.getSimpleName();
@ -274,28 +272,21 @@ public class FingerprintActivity extends AppCompatActivity {
return false;
}
@RequiresApi(api = Build.VERSION_CODES.M)
static public boolean isFingerprintReady(Context context) {
try {
FingerprintManager fingerprintManager =
(FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.USE_FINGERPRINT)
!= PackageManager.PERMISSION_GRANTED) {
return false;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return fingerprintManager.isHardwareDetected() && fingerprintManager.hasEnrolledFingerprints();
}
return ActivityCompat.checkSelfPermission(context, Manifest.permission.USE_FINGERPRINT) ==
PackageManager.PERMISSION_GRANTED && fingerprintManager.isHardwareDetected() &&
fingerprintManager.hasEnrolledFingerprints();
} catch (Exception e) {
return false;
}
return false;
}
}
@SuppressLint("NewApi")
@RequiresApi(Build.VERSION_CODES.M)
class FingerprintHandler extends FingerprintManager.AuthenticationCallback {
private TextView text;