Loading android/app/src/com/android/bluetooth/Utils.java +8 −7 Original line number Diff line number Diff line Loading @@ -45,7 +45,6 @@ import android.content.Context; import android.content.PermissionChecker; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.UserInfo; import android.location.LocationManager; import android.net.Uri; import android.os.Binder; Loading Loading @@ -585,9 +584,10 @@ public final class Utils { } public static boolean checkCallerIsSystemOrActiveUser() { 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 @@ -608,18 +608,19 @@ public final class Utils { if (context == null) { return checkCallerIsSystemOrActiveUser(); } 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) context.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 +4 −4 Original line number Diff line number Diff line Loading @@ -124,10 +124,10 @@ import com.android.internal.os.BackgroundThread; import com.android.internal.os.BinderCallsStats; import com.android.internal.util.ArrayUtils; import libcore.util.SneakyThrow; import com.google.protobuf.InvalidProtocolBufferException; import libcore.util.SneakyThrow; import java.io.FileDescriptor; import java.io.FileOutputStream; import java.io.IOException; Loading Loading @@ -2554,7 +2554,7 @@ public class AdapterService extends Service { } boolean startDiscovery(AttributionSource attributionSource) { UserHandle callingUser = UserHandle.of(UserHandle.getCallingUserId()); UserHandle callingUser = Binder.getCallingUserHandle(); debugLog("startDiscovery"); String callingPackage = attributionSource.getPackageName(); mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); Loading Loading @@ -2624,7 +2624,7 @@ public class AdapterService extends Service { CallerInfo createBondCaller = new CallerInfo(); createBondCaller.callerPackageName = callingPackage; createBondCaller.user = UserHandle.of(UserHandle.getCallingUserId()); createBondCaller.user = Binder.getCallingUserHandle(); mBondAttemptCallerInfo.put(device.getAddress(), createBondCaller); mRemoteDevices.setBondingInitiatedLocally(Utils.getByteAddress(device)); Loading android/app/src/com/android/bluetooth/btservice/ProfileService.java +1 −2 Original line number Diff line number Diff line Loading @@ -35,7 +35,6 @@ import android.os.UserManager; import android.util.Log; import com.android.bluetooth.BluetoothMetricsProto; import com.android.bluetooth.Utils; /** * Base class for a background service that runs a Bluetooth profile Loading Loading @@ -303,7 +302,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 +2 −2 Original line number Diff line number Diff line Loading @@ -2277,7 +2277,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 @@ -2353,7 +2353,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 @@ -45,7 +45,6 @@ import android.content.Context; import android.content.PermissionChecker; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.UserInfo; import android.location.LocationManager; import android.net.Uri; import android.os.Binder; Loading Loading @@ -585,9 +584,10 @@ public final class Utils { } public static boolean checkCallerIsSystemOrActiveUser() { 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 @@ -608,18 +608,19 @@ public final class Utils { if (context == null) { return checkCallerIsSystemOrActiveUser(); } 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) context.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 +4 −4 Original line number Diff line number Diff line Loading @@ -124,10 +124,10 @@ import com.android.internal.os.BackgroundThread; import com.android.internal.os.BinderCallsStats; import com.android.internal.util.ArrayUtils; import libcore.util.SneakyThrow; import com.google.protobuf.InvalidProtocolBufferException; import libcore.util.SneakyThrow; import java.io.FileDescriptor; import java.io.FileOutputStream; import java.io.IOException; Loading Loading @@ -2554,7 +2554,7 @@ public class AdapterService extends Service { } boolean startDiscovery(AttributionSource attributionSource) { UserHandle callingUser = UserHandle.of(UserHandle.getCallingUserId()); UserHandle callingUser = Binder.getCallingUserHandle(); debugLog("startDiscovery"); String callingPackage = attributionSource.getPackageName(); mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); Loading Loading @@ -2624,7 +2624,7 @@ public class AdapterService extends Service { CallerInfo createBondCaller = new CallerInfo(); createBondCaller.callerPackageName = callingPackage; createBondCaller.user = UserHandle.of(UserHandle.getCallingUserId()); createBondCaller.user = Binder.getCallingUserHandle(); mBondAttemptCallerInfo.put(device.getAddress(), createBondCaller); mRemoteDevices.setBondingInitiatedLocally(Utils.getByteAddress(device)); Loading
android/app/src/com/android/bluetooth/btservice/ProfileService.java +1 −2 Original line number Diff line number Diff line Loading @@ -35,7 +35,6 @@ import android.os.UserManager; import android.util.Log; import com.android.bluetooth.BluetoothMetricsProto; import com.android.bluetooth.Utils; /** * Base class for a background service that runs a Bluetooth profile Loading Loading @@ -303,7 +302,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 +2 −2 Original line number Diff line number Diff line Loading @@ -2277,7 +2277,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 @@ -2353,7 +2353,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