summaryrefslogtreecommitdiffstats
path: root/keystore/java/android/security/KeymasterUtils.java
blob: 4f175864a9df8d1b0b0fa14859ac1c2e88992b71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package android.security;

import android.security.keymaster.KeymasterDefs;

/**
 * @hide
 */
public abstract class KeymasterUtils {
    private KeymasterUtils() {}

    public static KeymasterException getExceptionForKeymasterError(int keymasterErrorCode) {
        switch (keymasterErrorCode) {
            case KeymasterDefs.KM_ERROR_INVALID_AUTHORIZATION_TIMEOUT:
                // The name of this parameter significantly differs between Keymaster and framework
                // APIs. Use the framework wording to make life easier for developers.
                return new KeymasterException(keymasterErrorCode,
                        "Invalid user authentication validity duration");
            default:
                return new KeymasterException(keymasterErrorCode,
                        KeymasterDefs.getErrorMessage(keymasterErrorCode));
        }
    }
}