Loading framework/java/android/bluetooth/BluetoothAdapter.java +5 −39 Original line number Diff line number Diff line Loading @@ -85,7 +85,6 @@ import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.UUID; import java.util.WeakHashMap; Loading Loading @@ -856,7 +855,6 @@ public final class BluetoothAdapter { private final IBluetoothManager mManagerService; private final AttributionSource mAttributionSource; private final Optional<Context> mContext; // Yeah, keeping both mService and sService isn't pretty, but it's too late // in the current release for a major refactoring, so we leave them both Loading Loading @@ -1065,13 +1063,13 @@ public final class BluetoothAdapter { @RequiresNoPermission public static synchronized BluetoothAdapter getDefaultAdapter() { if (sAdapter == null) { sAdapter = createAdapter(null); sAdapter = createAdapter(AttributionSource.myAttributionSource()); } return sAdapter; } /** @hide */ public static BluetoothAdapter createAdapter(Context context) { public static BluetoothAdapter createAdapter(AttributionSource attributionSource) { BluetoothServiceManager manager = BluetoothFrameworkInitializer.getBluetoothServiceManager(); if (manager == null) { Loading @@ -1082,7 +1080,7 @@ public final class BluetoothAdapter { IBluetoothManager.Stub.asInterface( manager.getBluetoothManagerServiceRegisterer().get()); if (service != null) { return new BluetoothAdapter(service, context); return new BluetoothAdapter(service, attributionSource); } else { Log.e(TAG, "Bluetooth service is null"); return null; Loading @@ -1090,15 +1088,9 @@ public final class BluetoothAdapter { } /** Use {@link #getDefaultAdapter} to get the BluetoothAdapter instance. */ BluetoothAdapter(IBluetoothManager managerService, @Nullable Context context) { mContext = Optional.ofNullable(context); BluetoothAdapter(IBluetoothManager managerService, AttributionSource attributionSource) { mManagerService = requireNonNull(managerService); if (context != null) { mAttributionSource = requireNonNull(context.getAttributionSource()); } else { mAttributionSource = requireNonNull(AttributionSource.myAttributionSource()); } mAttributionSource = requireNonNull(attributionSource); mServiceLock.writeLock().lock(); try { mService = getBluetoothService(mManagerCallback); Loading Loading @@ -4675,19 +4667,6 @@ public final class BluetoothAdapter { return false; } // Enforcing permission in the framework is useless from security point of view. // This is being done to help normal app developer to catch the missing permission, since // the call to the service is oneway and the SecurityException will just be logged mContext.ifPresent( ctx -> { final int pid = Process.myPid(); final int uid = Process.myUid(); ctx.enforcePermission( android.Manifest.permission.BLUETOOTH_CONNECT, pid, uid, null); ctx.enforcePermission( android.Manifest.permission.BLUETOOTH_PRIVILEGED, pid, uid, null); }); synchronized (mBluetoothConnectionCallbackExecutorMap) { if (mBluetoothConnectionCallbackExecutorMap.containsKey(callback)) { throw new IllegalArgumentException("This callback has already been registered"); Loading Loading @@ -4748,19 +4727,6 @@ public final class BluetoothAdapter { return false; } // Enforcing permission in the framework is useless from security point of view. // This is being done to help normal app developer to catch the missing permission, since // the call to the service is oneway and the SecurityException will just be logged mContext.ifPresent( ctx -> { final int pid = Process.myPid(); final int uid = Process.myUid(); ctx.enforcePermission( android.Manifest.permission.BLUETOOTH_CONNECT, pid, uid, null); ctx.enforcePermission( android.Manifest.permission.BLUETOOTH_PRIVILEGED, pid, uid, null); }); synchronized (mBluetoothConnectionCallbackExecutorMap) { if (!mBluetoothConnectionCallbackExecutorMap.containsKey(callback)) { return true; Loading framework/java/android/bluetooth/BluetoothManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -59,7 +59,7 @@ public final class BluetoothManager { /** @hide */ public BluetoothManager(Context context) { mAttributionSource = context.getAttributionSource(); mAdapter = BluetoothAdapter.createAdapter(context); mAdapter = BluetoothAdapter.createAdapter(mAttributionSource); } /** Loading framework/tests/util/src/Permissions.kt +2 −7 Original line number Diff line number Diff line Loading @@ -53,15 +53,10 @@ object Permissions { } newPermissions.forEach { val permissionsSet = newPermissions.toMutableSet() val removedPermission = it permissionsSet.remove(removedPermission) permissionsSet.remove(it) withPermissions(*arrayOf(*permissionsSet.toTypedArray())).use { assertThrows( "SecurityException wasn't throw when checking for $removedPermission", SecurityException::class.java, { action() } ) assertThrows(SecurityException::class.java, { action() }) } } } Loading Loading
framework/java/android/bluetooth/BluetoothAdapter.java +5 −39 Original line number Diff line number Diff line Loading @@ -85,7 +85,6 @@ import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.UUID; import java.util.WeakHashMap; Loading Loading @@ -856,7 +855,6 @@ public final class BluetoothAdapter { private final IBluetoothManager mManagerService; private final AttributionSource mAttributionSource; private final Optional<Context> mContext; // Yeah, keeping both mService and sService isn't pretty, but it's too late // in the current release for a major refactoring, so we leave them both Loading Loading @@ -1065,13 +1063,13 @@ public final class BluetoothAdapter { @RequiresNoPermission public static synchronized BluetoothAdapter getDefaultAdapter() { if (sAdapter == null) { sAdapter = createAdapter(null); sAdapter = createAdapter(AttributionSource.myAttributionSource()); } return sAdapter; } /** @hide */ public static BluetoothAdapter createAdapter(Context context) { public static BluetoothAdapter createAdapter(AttributionSource attributionSource) { BluetoothServiceManager manager = BluetoothFrameworkInitializer.getBluetoothServiceManager(); if (manager == null) { Loading @@ -1082,7 +1080,7 @@ public final class BluetoothAdapter { IBluetoothManager.Stub.asInterface( manager.getBluetoothManagerServiceRegisterer().get()); if (service != null) { return new BluetoothAdapter(service, context); return new BluetoothAdapter(service, attributionSource); } else { Log.e(TAG, "Bluetooth service is null"); return null; Loading @@ -1090,15 +1088,9 @@ public final class BluetoothAdapter { } /** Use {@link #getDefaultAdapter} to get the BluetoothAdapter instance. */ BluetoothAdapter(IBluetoothManager managerService, @Nullable Context context) { mContext = Optional.ofNullable(context); BluetoothAdapter(IBluetoothManager managerService, AttributionSource attributionSource) { mManagerService = requireNonNull(managerService); if (context != null) { mAttributionSource = requireNonNull(context.getAttributionSource()); } else { mAttributionSource = requireNonNull(AttributionSource.myAttributionSource()); } mAttributionSource = requireNonNull(attributionSource); mServiceLock.writeLock().lock(); try { mService = getBluetoothService(mManagerCallback); Loading Loading @@ -4675,19 +4667,6 @@ public final class BluetoothAdapter { return false; } // Enforcing permission in the framework is useless from security point of view. // This is being done to help normal app developer to catch the missing permission, since // the call to the service is oneway and the SecurityException will just be logged mContext.ifPresent( ctx -> { final int pid = Process.myPid(); final int uid = Process.myUid(); ctx.enforcePermission( android.Manifest.permission.BLUETOOTH_CONNECT, pid, uid, null); ctx.enforcePermission( android.Manifest.permission.BLUETOOTH_PRIVILEGED, pid, uid, null); }); synchronized (mBluetoothConnectionCallbackExecutorMap) { if (mBluetoothConnectionCallbackExecutorMap.containsKey(callback)) { throw new IllegalArgumentException("This callback has already been registered"); Loading Loading @@ -4748,19 +4727,6 @@ public final class BluetoothAdapter { return false; } // Enforcing permission in the framework is useless from security point of view. // This is being done to help normal app developer to catch the missing permission, since // the call to the service is oneway and the SecurityException will just be logged mContext.ifPresent( ctx -> { final int pid = Process.myPid(); final int uid = Process.myUid(); ctx.enforcePermission( android.Manifest.permission.BLUETOOTH_CONNECT, pid, uid, null); ctx.enforcePermission( android.Manifest.permission.BLUETOOTH_PRIVILEGED, pid, uid, null); }); synchronized (mBluetoothConnectionCallbackExecutorMap) { if (!mBluetoothConnectionCallbackExecutorMap.containsKey(callback)) { return true; Loading
framework/java/android/bluetooth/BluetoothManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -59,7 +59,7 @@ public final class BluetoothManager { /** @hide */ public BluetoothManager(Context context) { mAttributionSource = context.getAttributionSource(); mAdapter = BluetoothAdapter.createAdapter(context); mAdapter = BluetoothAdapter.createAdapter(mAttributionSource); } /** Loading
framework/tests/util/src/Permissions.kt +2 −7 Original line number Diff line number Diff line Loading @@ -53,15 +53,10 @@ object Permissions { } newPermissions.forEach { val permissionsSet = newPermissions.toMutableSet() val removedPermission = it permissionsSet.remove(removedPermission) permissionsSet.remove(it) withPermissions(*arrayOf(*permissionsSet.toTypedArray())).use { assertThrows( "SecurityException wasn't throw when checking for $removedPermission", SecurityException::class.java, { action() } ) assertThrows(SecurityException::class.java, { action() }) } } } Loading