blob: c9f06e9bbc81b51dc0699adc8bc4e5c557d37ba4 [file] [log] [blame]
Alex Klyubin10a9f172015-04-16 13:41:19 -07001package android.security;
2
3import android.os.RemoteException;
4import android.os.ServiceManager;
5import android.os.UserHandle;
6import android.service.gatekeeper.IGateKeeperService;
7
8/**
9 * Convenience class for accessing the gatekeeper service.
10 *
11 * @hide
12 */
13public abstract class GateKeeper {
14
15 private GateKeeper() {}
16
17 public static IGateKeeperService getService() {
18 return IGateKeeperService.Stub.asInterface(
19 ServiceManager.getService("android.service.gatekeeper.IGateKeeperService"));
20 }
21
22 public static long getSecureUserId() throws IllegalStateException {
23 try {
24 return GateKeeper.getService().getSecureUserId(UserHandle.myUserId());
25 } catch (RemoteException e) {
26 throw new IllegalStateException(
27 "Failed to obtain secure user ID from gatekeeper", e);
28 }
29 }
30}