Browse Source

fix fingerprint issue (#23)

V1.2.0-btc-release
JunZhang 5 years ago
committed by GitHub
parent
commit
1b2029725f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/src/main/java/com/cobo/cold/Utilities.java
  2. 7
      app/src/main/java/com/cobo/cold/fingerprint/FingerprintKit.java
  3. 30
      app/src/main/java/com/cobo/cold/ui/fragment/setting/MainPreferenceFragment.java

4
app/src/main/java/com/cobo/cold/Utilities.java

@ -201,8 +201,8 @@ public class Utilities {
return Settings.System.getString(context.getContentResolver(), FINGERPRINT_PASSWORD); return Settings.System.getString(context.getContentResolver(), FINGERPRINT_PASSWORD);
} }
public static void setFingerprintPassword(Context context, String pwd) { public static boolean setFingerprintPassword(Context context, String pwd) {
Settings.System.putString(context.getContentResolver(), FINGERPRINT_PASSWORD, pwd); return Settings.System.putString(context.getContentResolver(), FINGERPRINT_PASSWORD, pwd);
} }
public static void setAttackDetected(Context context) { public static void setAttackDetected(Context context) {

7
app/src/main/java/com/cobo/cold/fingerprint/FingerprintKit.java

@ -66,9 +66,10 @@ public class FingerprintKit {
fp = (FingerprintManager) mContext.getSystemService(FINGERPRINT_SERVICE); fp = (FingerprintManager) mContext.getSystemService(FINGERPRINT_SERVICE);
if (!lockPatternUtils.isLockPasswordEnabled(mUserId)) { if (!lockPatternUtils.isLockPasswordEnabled(mUserId)) {
String password = HashUtil.generateRandomPassword(20); String password = HashUtil.generateRandomPassword(20);
lockPatternUtils.saveLockPassword(password, null, if (Utilities.setFingerprintPassword(mContext, password)) {
DevicePolicyManager.PASSWORD_QUALITY_NUMERIC, mUserId); lockPatternUtils.saveLockPassword(password, null,
Utilities.setFingerprintPassword(mContext, password); DevicePolicyManager.PASSWORD_QUALITY_NUMERIC, mUserId);
}
} }
} }

30
app/src/main/java/com/cobo/cold/ui/fragment/setting/MainPreferenceFragment.java

@ -23,6 +23,7 @@ import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.graphics.Color; import android.graphics.Color;
import android.hardware.fingerprint.Fingerprint; import android.hardware.fingerprint.Fingerprint;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Bundle; import android.os.Bundle;
import android.os.Looper; import android.os.Looper;
import android.view.Gravity; import android.view.Gravity;
@ -64,6 +65,7 @@ import java.util.Locale;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import static android.content.Context.FINGERPRINT_SERVICE;
import static com.cobo.cold.Utilities.IS_SETUP_VAULT; import static com.cobo.cold.Utilities.IS_SETUP_VAULT;
import static com.cobo.cold.Utilities.SHARED_PREFERENCES_KEY; import static com.cobo.cold.Utilities.SHARED_PREFERENCES_KEY;
import static com.cobo.cold.ui.fragment.Constants.KEY_NAV_ID; import static com.cobo.cold.ui.fragment.Constants.KEY_NAV_ID;
@ -361,20 +363,20 @@ public class MainPreferenceFragment extends PreferenceFragmentCompat {
} }
public static void removeAllFingerprint(AppCompatActivity activity) { public static void removeAllFingerprint(AppCompatActivity activity) {
if (!FingerprintKit.isHardwareDetected(activity)) { FingerprintManager fm = (FingerprintManager) activity.getSystemService(FINGERPRINT_SERVICE);
return; if (fm.isHardwareDetected() && fm.hasEnrolledFingerprints()) {
} FingerprintKit fpKit = new FingerprintKit(activity);
FingerprintKit fpKit = new FingerprintKit(activity); if (FingerprintKit.isHardwareDetected(activity)) {
if (FingerprintKit.isHardwareDetected(activity)) { List<Fingerprint> fingerprints = fpKit.getEnrolledFingerprints();
List<Fingerprint> fingerprints = fpKit.getEnrolledFingerprints(); fingerprints.forEach(f -> {
fingerprints.forEach(f -> { fpKit.removeFingerprint(f, null);
fpKit.removeFingerprint(f, null); try {
try { Thread.sleep(1000);
Thread.sleep(1000); } catch (InterruptedException e) {
} catch (InterruptedException e) { e.printStackTrace();
e.printStackTrace(); }
} });
}); }
} }
} }

Loading…
Cancel
Save