14766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil#ifndef ANDROID_DVR_TRUSTED_UIDS_H_ 24766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil#define ANDROID_DVR_TRUSTED_UIDS_H_ 34766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil 44766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil#include <sys/types.h> 54766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil 64766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gilnamespace android { 74766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gilnamespace dvr { 84766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil 94766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil/** 104766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil * Tells if a provided UID can be trusted to access restricted VR APIs. 114766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil * 124766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil * UID trust is based on the android.permission.RESTRICTED_VR_ACCESS permission. 134766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil * AID_SYSTEM and AID_ROOT are automatically trusted by Android. 144766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil * 154766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil * UIDs are guaranteed not to be reused until the next reboot even in case 164766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil * of package reinstall. For performance reasons this method caches results by 174766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil * default, as otherwise every check would trigger a Java call. 184766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil * 194766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil * This function is thread-safe. 204766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil * 214766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil * @param uid The uid to check. 224766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil * @param use_cache If true any cached result for the provided uid will be 234766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil * reused. If false this call will reach the Application Manager Service 244766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil * in Java to get updated values. Any updates will be stored in the cache. 254766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil * @return true if the uid is trusted, false if not or if the VR Manager Service 264766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil * could not be reached to verify the uid. 274766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil */ 284766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gilbool IsTrustedUid(uid_t uid, bool use_cache = true); 294766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil 304766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil} // namespace dvr 314766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil} // namespace android 324766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil 334766e2a776386489667e792f9c7d8c71131b78c1Leandro Gracia Gil#endif // ANDROID_DVR_TRUSTED_UIDS_H_ 34