summaryrefslogtreecommitdiff
path: root/keystore/java/android/security/GateKeeper.java
blob: c9f06e9bbc81b51dc0699adc8bc4e5c557d37ba4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package android.security;

import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.service.gatekeeper.IGateKeeperService;

/**
 * Convenience class for accessing the gatekeeper service.
 *
 * @hide
 */
public abstract class GateKeeper {

    private GateKeeper() {}

    public static IGateKeeperService getService() {
        return IGateKeeperService.Stub.asInterface(
                ServiceManager.getService("android.service.gatekeeper.IGateKeeperService"));
    }

    public static long getSecureUserId() throws IllegalStateException {
        try {
            return GateKeeper.getService().getSecureUserId(UserHandle.myUserId());
        } catch (RemoteException e) {
            throw new IllegalStateException(
                    "Failed to obtain secure user ID from gatekeeper", e);
        }
    }
}