ファイナライザによってスローされたキャッチされない例外:バインダーが確定された、アンドロイドストア

大安のDev:

私は、私のアプリで指紋ロック解除を実施し、今私は、ピンのロック解除を追加しましたが、このアプリは、すべてでは起動しません。私は、キーストアのインスタンス名を変更しようとしたと同じキーストアインスタンス名を使用していました。

そして、時にはアプリは、このエラーがスローされます。

E/System: Uncaught exception thrown by finalizer
E/System: java.lang.IllegalStateException: Binder has been finalized!
        at android.os.BinderProxy.transactNative(Native Method)
        at android.os.BinderProxy.transact(Binder.java:751)
        at android.security.IKeystoreService$Stub$Proxy.abort(IKeystoreService.java:1373)
        at android.security.KeyStore.abort(KeyStore.java:541)
        at android.security.keystore.AndroidKeyStoreCipherSpiBase.finalize(AndroidKeyStoreCipherSpiBase.java:744)
        at android.security.keystore.AndroidKeyStoreUnauthenticatedAESCipherSpi$CBC$PKCS7Padding.finalize(Unknown Source:0)
        at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:253)
        at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:240)
        at java.lang.Daemons$Daemon.run(Daemons.java:103)

私はアプリを起動しようとするとそれだけで、デバッグログまたはlogcatログにクラッシュすることなく、この問題のための任意の提案を閉じ?

コード:

@Override

    protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.auth);

    keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
    fingerprintManager = (FingerprintManager) getSystemService(FINGERPRINT_SERVICE);
    msg = (TextView) findViewById(R.id.message);


        try {
            generateKey();
        } catch (FingerprintException e) {
            e.printStackTrace();
        }

        if (initCipher()) {
            cryptoObject = new FingerprintManager.CryptoObject(cipher);
            FingerprintHandler helper = new FingerprintHandler(this);
            helper.startAuth(fingerprintManager, cryptoObject);
        }

    if (!getIntent().hasExtra(EXTRA_OPER)) {
        sendErr("operation is not defined");
        return;
    }
    oper = getIntent().getStringExtra(EXTRA_OPER);
    if (OPER_CREATE.equals(oper)) {
        msg.setText(R.string.create_code);
        if (!getIntent().hasExtra(EXTRA_SESSION)) {
            sendErr("session not found");
            return;
        }
        session = getIntent().getStringExtra(EXTRA_SESSION);
    } else if (OPER_VERIFY.equals(oper)) {
        msg.setText(R.string.type_code);
    }
    pin = new StringBuilder();
}

private void generateKey() throws FingerprintException {
    try {
        // Obtain a reference to the Keystore using the standard Android keystore container identifier (“AndroidKeystore”)//
        keyStore = KeyStore.getInstance("AndroidKeyStore");

        //Generate the key//
        keyGenerator = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore");

        //Initialize an empty KeyStore//
        keyStore.load(null);

        //Initialize the KeyGenerator//
        keyGenerator.init(new

                //Specify the operation(s) this key can be used for//
                KeyGenParameterSpec.Builder(KEY_NAME,
                KeyProperties.PURPOSE_ENCRYPT |
                        KeyProperties.PURPOSE_DECRYPT)
                .setBlockModes(KeyProperties.BLOCK_MODE_CBC)

                //Configure this key so that the user has to confirm their identity with a fingerprint each time they want to use it//
                .setUserAuthenticationRequired(true)
                .setEncryptionPaddings(
                        KeyProperties.ENCRYPTION_PADDING_PKCS7)
                .build());

        //Generate the key//
        keyGenerator.generateKey();

    } catch (KeyStoreException
            | NoSuchAlgorithmException
            | NoSuchProviderException
            | InvalidAlgorithmParameterException
            | CertificateException
            | IOException exc) {
        exc.printStackTrace();
        throw new FingerprintException(exc);
    }
}

//Create a new method that we’ll use to initialize our cipher//
public boolean initCipher() {
    try {
        //Obtain a cipher instance and configure it with the properties required for fingerprint authentication//
        cipher = Cipher.getInstance(
                KeyProperties.KEY_ALGORITHM_AES + "/"
                        + KeyProperties.BLOCK_MODE_CBC + "/"
                        + KeyProperties.ENCRYPTION_PADDING_PKCS7);
    } catch (NoSuchAlgorithmException |
            NoSuchPaddingException e) {
        throw new RuntimeException("Failed to get Cipher", e);
    }

    try {
        keyStore.load(null);
        SecretKey key = (SecretKey) keyStore.getKey(KEY_NAME,
                null);
        cipher.init(Cipher.ENCRYPT_MODE, key);
        //Return true if the cipher has been initialized successfully//
        return true;
    } catch (KeyPermanentlyInvalidatedException e) {

        //Return false if cipher initialization failed//
        return false;
    } catch (KeyStoreException | CertificateException
            | UnrecoverableKeyException | IOException
            | NoSuchAlgorithmException | InvalidKeyException e) {
        throw new RuntimeException("Failed to init Cipher", e);
    }
}

private class FingerprintException extends Exception {
    public FingerprintException(Exception e) {
        super(e);
    }
}

private void next() {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    if (OPER_CREATE.equals(oper)) {
        if (pin0 == null) {
            pin0 = pin.toString();
            pin = new StringBuilder();
            showPin();
            msg.setText(R.string.retype_code);
            return;
        }
        if (!pin0.equals(pin.toString())) {
            Toast.makeText(this, R.string.not_equal, Toast.LENGTH_LONG).show();
            pin0 = null;
            pin = new StringBuilder();
            showPin();
            msg.setText(R.string.create_code);
            return;
        }
        boolean b = new PinFacade(this).setupPin(pin.toString(), session);
        if (b) sendOk();
        else sendErr("can't setup pin");
    } else if (OPER_VERIFY.equals(oper)){
        try {
            session = new PinFacade(this).verifyPin(pin.toString());
            sendOk();
        } catch (Exception e) {
            e.printStackTrace();
            sendErr(e.getMessage());
        }
    }
}

private void sendOk() {
    setResult(RESULT_OK, new Intent().putExtra(EXTRA_SESSION, session));
    finish();
}

private void sendErr(String err) {
    setResult(RESULT_CANCELED, new Intent().putExtra(EXTRA_ERROR, err));
    finish();
}

}
大安のDev:

私は携帯電話は指紋ハードウェアを持っている場合、アプリは、指紋の権限を持っている場合と電話がロックされている場合、電話機は、構成された指紋を持っている場合は、チェックすることによって、私の問題を修正しました。

    if (!fingerprintManager.isHardwareDetected()) {
        msg.setText("Your device doesn't support fingerprint authentication");
    }
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
        msg.setText("Please enable the fingerprint permission");
    }
    if (!fingerprintManager.hasEnrolledFingerprints()) {
        msg.setText("No fingerprint configured. Please register at least one fingerprint in your device's Settings");
    }

    if (!keyguardManager.isKeyguardSecure()) {
        msg.setText("Please enable lockscreen security in your device's Settings");
    } else {
        try {
            generateKey();
        } catch (FingerprintException e) {
            e.printStackTrace();
        }

        if (initCipher()) {
            cryptoObject = new FingerprintManager.CryptoObject(cipher);
            helper = new FingerprintHandler(this);
            helper.startAuth(fingerprintManager, cryptoObject);
        }
    }

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=219935&siteId=1
おすすめ