Loading android/app/src/com/android/bluetooth/Utils.java +8 −7 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ import android.content.ContentValues; import android.content.Context; import android.content.ContextWrapper; import android.content.pm.PackageManager; import android.content.pm.UserInfo; import android.location.LocationManager; import android.net.Uri; import android.os.Binder; Loading Loading @@ -332,9 +331,10 @@ public final class Utils { } public static boolean checkCaller() { int callingUser = UserHandle.getCallingUserId(); int callingUid = Binder.getCallingUid(); return (sForegroundUserId == callingUser) UserHandle callingUser = UserHandle.getUserHandleForUid(callingUid); return (sForegroundUserId == callingUser.getIdentifier()) || (UserHandle.getAppId(sSystemUiUid) == UserHandle.getAppId(callingUid)) || (UserHandle.getAppId(Process.SYSTEM_UID) == UserHandle.getAppId(callingUid)); } Loading @@ -343,18 +343,19 @@ public final class Utils { if (mContext == null) { return checkCaller(); } int callingUser = UserHandle.getCallingUserId(); int callingUid = Binder.getCallingUid(); UserHandle callingUser = UserHandle.getUserHandleForUid(callingUid); // Use the Bluetooth process identity when making call to get parent user final long ident = Binder.clearCallingIdentity(); try { UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE); UserInfo ui = um.getProfileParent(callingUser); int parentUser = (ui != null) ? ui.id : UserHandle.USER_NULL; UserHandle uh = um.getProfileParent(callingUser); int parentUser = (uh != null) ? uh.getIdentifier() : UserHandle.USER_NULL; // Always allow SystemUI/System access. return (sForegroundUserId == callingUser) || (sForegroundUserId == parentUser) return (sForegroundUserId == callingUser.getIdentifier()) || (sForegroundUserId == parentUser) || (UserHandle.getAppId(sSystemUiUid) == UserHandle.getAppId(callingUid)) || (UserHandle.getAppId(Process.SYSTEM_UID) == UserHandle.getAppId(callingUid)); } catch (Exception ex) { Loading android/app/src/com/android/bluetooth/btservice/AdapterService.java +1 −1 Original line number Diff line number Diff line Loading @@ -2390,7 +2390,7 @@ public class AdapterService extends Service { } boolean startDiscovery(String callingPackage, @Nullable String callingFeatureId) { UserHandle callingUser = UserHandle.of(UserHandle.getCallingUserId()); UserHandle callingUser = Binder.getCallingUserHandle(); debugLog("startDiscovery"); mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); boolean isQApp = Utils.isQApp(this, callingPackage); Loading android/app/src/com/android/bluetooth/btservice/ProfileService.java +1 −1 Original line number Diff line number Diff line Loading @@ -261,7 +261,7 @@ public abstract class ProfileService extends Service { int currentUserId = ActivityManager.getCurrentUser(); setCurrentUser(currentUserId); UserManager userManager = UserManager.get(getApplicationContext()); if (userManager.isUserUnlocked(currentUserId)) { if (userManager.isUserUnlocked(UserHandle.of(currentUserId))) { setUserUnlocked(currentUserId); } mProfileStarted = start(); Loading android/app/src/com/android/bluetooth/gatt/GattService.java +3 −3 Original line number Diff line number Diff line Loading @@ -2141,7 +2141,7 @@ public class GattService extends ProfileService { if (DBG) { Log.d(TAG, "start scan with filters"); } UserHandle callingUser = UserHandle.of(UserHandle.getCallingUserId()); enforceAdminPermission(); if (needsPrivilegedPermissionForScan(settings)) { enforcePrivilegedPermission(); Loading @@ -2149,7 +2149,7 @@ public class GattService extends ProfileService { settings = enforceReportDelayFloor(settings); enforcePrivilegedPermissionIfNeeded(filters); final ScanClient scanClient = new ScanClient(scannerId, settings, filters, storages); scanClient.userHandle = UserHandle.of(UserHandle.getCallingUserId()); scanClient.userHandle = Binder.getCallingUserHandle(); mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); scanClient.eligibleForSanitizedExposureNotification = callingPackage.equals(mExposureNotificationPackage); Loading Loading @@ -2216,7 +2216,7 @@ public class GattService extends ProfileService { pendingIntent.registerCancelListener(mScanIntentCancelListener); app.mUserHandle = UserHandle.of(UserHandle.getCallingUserId()); app.mUserHandle = UserHandle.getUserHandleForUid(Binder.getCallingUid()); mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); app.mEligibleForSanitizedExposureNotification = callingPackage.equals(mExposureNotificationPackage); Loading android/app/src/com/android/bluetooth/mapclient/MapUtils.java +2 −2 Original line number Diff line number Diff line Loading @@ -15,8 +15,8 @@ */ package com.android.bluetooth.mapclient; import android.os.Binder; import android.os.SystemProperties; import android.os.UserHandle; import com.android.bluetooth.Utils; import com.android.internal.annotations.VisibleForTesting; Loading @@ -34,7 +34,7 @@ class MapUtils { } static boolean isSystemUser() { return UserHandle.getCallingUserId() == UserHandle.USER_SYSTEM; return Binder.getCallingUserHandle().isSystem(); } static MnsService newMnsServiceInstance(MapClientService mapClientService) { Loading Loading
android/app/src/com/android/bluetooth/Utils.java +8 −7 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ import android.content.ContentValues; import android.content.Context; import android.content.ContextWrapper; import android.content.pm.PackageManager; import android.content.pm.UserInfo; import android.location.LocationManager; import android.net.Uri; import android.os.Binder; Loading Loading @@ -332,9 +331,10 @@ public final class Utils { } public static boolean checkCaller() { int callingUser = UserHandle.getCallingUserId(); int callingUid = Binder.getCallingUid(); return (sForegroundUserId == callingUser) UserHandle callingUser = UserHandle.getUserHandleForUid(callingUid); return (sForegroundUserId == callingUser.getIdentifier()) || (UserHandle.getAppId(sSystemUiUid) == UserHandle.getAppId(callingUid)) || (UserHandle.getAppId(Process.SYSTEM_UID) == UserHandle.getAppId(callingUid)); } Loading @@ -343,18 +343,19 @@ public final class Utils { if (mContext == null) { return checkCaller(); } int callingUser = UserHandle.getCallingUserId(); int callingUid = Binder.getCallingUid(); UserHandle callingUser = UserHandle.getUserHandleForUid(callingUid); // Use the Bluetooth process identity when making call to get parent user final long ident = Binder.clearCallingIdentity(); try { UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE); UserInfo ui = um.getProfileParent(callingUser); int parentUser = (ui != null) ? ui.id : UserHandle.USER_NULL; UserHandle uh = um.getProfileParent(callingUser); int parentUser = (uh != null) ? uh.getIdentifier() : UserHandle.USER_NULL; // Always allow SystemUI/System access. return (sForegroundUserId == callingUser) || (sForegroundUserId == parentUser) return (sForegroundUserId == callingUser.getIdentifier()) || (sForegroundUserId == parentUser) || (UserHandle.getAppId(sSystemUiUid) == UserHandle.getAppId(callingUid)) || (UserHandle.getAppId(Process.SYSTEM_UID) == UserHandle.getAppId(callingUid)); } catch (Exception ex) { Loading
android/app/src/com/android/bluetooth/btservice/AdapterService.java +1 −1 Original line number Diff line number Diff line Loading @@ -2390,7 +2390,7 @@ public class AdapterService extends Service { } boolean startDiscovery(String callingPackage, @Nullable String callingFeatureId) { UserHandle callingUser = UserHandle.of(UserHandle.getCallingUserId()); UserHandle callingUser = Binder.getCallingUserHandle(); debugLog("startDiscovery"); mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); boolean isQApp = Utils.isQApp(this, callingPackage); Loading
android/app/src/com/android/bluetooth/btservice/ProfileService.java +1 −1 Original line number Diff line number Diff line Loading @@ -261,7 +261,7 @@ public abstract class ProfileService extends Service { int currentUserId = ActivityManager.getCurrentUser(); setCurrentUser(currentUserId); UserManager userManager = UserManager.get(getApplicationContext()); if (userManager.isUserUnlocked(currentUserId)) { if (userManager.isUserUnlocked(UserHandle.of(currentUserId))) { setUserUnlocked(currentUserId); } mProfileStarted = start(); Loading
android/app/src/com/android/bluetooth/gatt/GattService.java +3 −3 Original line number Diff line number Diff line Loading @@ -2141,7 +2141,7 @@ public class GattService extends ProfileService { if (DBG) { Log.d(TAG, "start scan with filters"); } UserHandle callingUser = UserHandle.of(UserHandle.getCallingUserId()); enforceAdminPermission(); if (needsPrivilegedPermissionForScan(settings)) { enforcePrivilegedPermission(); Loading @@ -2149,7 +2149,7 @@ public class GattService extends ProfileService { settings = enforceReportDelayFloor(settings); enforcePrivilegedPermissionIfNeeded(filters); final ScanClient scanClient = new ScanClient(scannerId, settings, filters, storages); scanClient.userHandle = UserHandle.of(UserHandle.getCallingUserId()); scanClient.userHandle = Binder.getCallingUserHandle(); mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); scanClient.eligibleForSanitizedExposureNotification = callingPackage.equals(mExposureNotificationPackage); Loading Loading @@ -2216,7 +2216,7 @@ public class GattService extends ProfileService { pendingIntent.registerCancelListener(mScanIntentCancelListener); app.mUserHandle = UserHandle.of(UserHandle.getCallingUserId()); app.mUserHandle = UserHandle.getUserHandleForUid(Binder.getCallingUid()); mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); app.mEligibleForSanitizedExposureNotification = callingPackage.equals(mExposureNotificationPackage); Loading
android/app/src/com/android/bluetooth/mapclient/MapUtils.java +2 −2 Original line number Diff line number Diff line Loading @@ -15,8 +15,8 @@ */ package com.android.bluetooth.mapclient; import android.os.Binder; import android.os.SystemProperties; import android.os.UserHandle; import com.android.bluetooth.Utils; import com.android.internal.annotations.VisibleForTesting; Loading @@ -34,7 +34,7 @@ class MapUtils { } static boolean isSystemUser() { return UserHandle.getCallingUserId() == UserHandle.USER_SYSTEM; return Binder.getCallingUserHandle().isSystem(); } static MnsService newMnsServiceInstance(MapClientService mapClientService) { Loading