Alex Klyubin | 10a9f17 | 2015-04-16 13:41:19 -0700 | [diff] [blame] | 1 | package android.security; |
| 2 | |
| 3 | import android.os.RemoteException; |
| 4 | import android.os.ServiceManager; |
| 5 | import android.os.UserHandle; |
| 6 | import android.service.gatekeeper.IGateKeeperService; |
| 7 | |
| 8 | /** |
| 9 | * Convenience class for accessing the gatekeeper service. |
| 10 | * |
| 11 | * @hide |
| 12 | */ |
| 13 | public 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 | } |