Loading android/app/src/com/android/bluetooth/Utils.java +28 −3 Original line number Diff line number Diff line Loading @@ -264,6 +264,21 @@ public final class Utils { || (Process.SYSTEM_UID == callingUid); } static Context mParentUserCacheContext = null; // Cache location off for 10 users, cache is valid for 2 seconds. static LoadingCache<Integer, Integer> mParentUserCache = CacheBuilder.newBuilder() .maximumSize(10) .expireAfterWrite(2, TimeUnit.SECONDS) .build( new CacheLoader<Integer, Integer>() { public Integer load(Integer callingUser) { UserManager um = (UserManager) mParentUserCacheContext.getSystemService(Context.USER_SERVICE); UserInfo ui = um.getProfileParent(callingUser); int parentUser = (ui != null) ? ui.id : UserHandle.USER_NULL; return parentUser; } }); public static boolean checkCallerAllowManagedProfiles(Context mContext) { if (mContext == null) { return checkCaller(); Loading @@ -274,9 +289,19 @@ public final class Utils { // Use the Bluetooth process identity when making call to get parent user long ident = Binder.clearCallingIdentity(); try { if (mParentUserCacheContext == null) mParentUserCacheContext = mContext; int parentUser = 0; try { parentUser = mParentUserCache.get(callingUid); } catch (java.util.concurrent.ExecutionException e) { UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE); UserInfo ui = um.getProfileParent(callingUser); int parentUser = (ui != null) ? ui.id : UserHandle.USER_NULL; parentUser = (ui != null) ? ui.id : UserHandle.USER_NULL; } // Always allow SystemUI/System access. return (sForegroundUserId == callingUser) || (sForegroundUserId == parentUser) Loading Loading
android/app/src/com/android/bluetooth/Utils.java +28 −3 Original line number Diff line number Diff line Loading @@ -264,6 +264,21 @@ public final class Utils { || (Process.SYSTEM_UID == callingUid); } static Context mParentUserCacheContext = null; // Cache location off for 10 users, cache is valid for 2 seconds. static LoadingCache<Integer, Integer> mParentUserCache = CacheBuilder.newBuilder() .maximumSize(10) .expireAfterWrite(2, TimeUnit.SECONDS) .build( new CacheLoader<Integer, Integer>() { public Integer load(Integer callingUser) { UserManager um = (UserManager) mParentUserCacheContext.getSystemService(Context.USER_SERVICE); UserInfo ui = um.getProfileParent(callingUser); int parentUser = (ui != null) ? ui.id : UserHandle.USER_NULL; return parentUser; } }); public static boolean checkCallerAllowManagedProfiles(Context mContext) { if (mContext == null) { return checkCaller(); Loading @@ -274,9 +289,19 @@ public final class Utils { // Use the Bluetooth process identity when making call to get parent user long ident = Binder.clearCallingIdentity(); try { if (mParentUserCacheContext == null) mParentUserCacheContext = mContext; int parentUser = 0; try { parentUser = mParentUserCache.get(callingUid); } catch (java.util.concurrent.ExecutionException e) { UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE); UserInfo ui = um.getProfileParent(callingUser); int parentUser = (ui != null) ? ui.id : UserHandle.USER_NULL; parentUser = (ui != null) ? ui.id : UserHandle.USER_NULL; } // Always allow SystemUI/System access. return (sForegroundUserId == callingUser) || (sForegroundUserId == parentUser) Loading