0

我可以使用下面的代码getEncryptionState来确定手机是否已加密。要继续,我需要验证用户输入的密码是否正确。所以我尝试了verifyEncryptionPassword(),但效果不佳:每次调用此方法时,总是得到相同的返回值:0。这意味着它将任何字符串作为正确的加密密码,这显然是错误的。

    IMountService mountService = IMountService.Stub.asInterface(ServiceManager.getService("mount"));
    boolean isEncrypted;
    try {
        isEncrypted = (mountService.getEncryptionState() != MountService.ENCRYPTION_STATE_NONE);
        if (isEncrypted) {
            int result = mountService.verifyEncryptionPassword(candidatePw);
            if (result == 0) {
                Log.d(TAG, "Pw verifies");                    
            } else if (result != -2) {
                Log.d(TAG, "Pw mismatch");
            } else {
                Log.e(TAG, "verified failed");
            }
        }
    } catch (Exception e) {
    }

如何验证加密密码?

4

0 回答 0