Loading android/app/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -342,6 +342,7 @@ android_app { "-Xep:InvalidParam:ERROR", "-Xep:LoopOverCharArray:ERROR", "-Xep:MissingCasesInEnumSwitch:ERROR", "-Xep:MixedMutabilityReturnType:ERROR", "-Xep:MockNotUsedInProduction:ERROR", "-Xep:ModifyCollectionInEnhancedForLoop:ERROR", "-Xep:NarrowCalculation:ERROR", Loading android/app/src/com/android/bluetooth/bass_client/BassClientService.java +4 −8 Original line number Diff line number Diff line Loading @@ -100,6 +100,7 @@ import java.util.Optional; import java.util.PriorityQueue; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; /** Broadcast Assistant Scan Service */ public class BassClientService extends ProfileService { Loading Loading @@ -3059,14 +3060,9 @@ public class BassClientService extends ProfileService { log("stateMachine is null"); return Collections.emptyList(); } List<BluetoothLeBroadcastReceiveState> recvStates = new ArrayList<BluetoothLeBroadcastReceiveState>(); for (BluetoothLeBroadcastReceiveState rs : stateMachine.getAllSources()) { if (!isEmptyBluetoothDevice(rs.getSourceDevice())) { recvStates.add(rs); } } return recvStates; return stateMachine.getAllSources().stream() .filter(rs -> !isEmptyBluetoothDevice(rs.getSourceDevice())) .collect(Collectors.toList()); } } Loading android/app/src/com/android/bluetooth/btservice/MetricsLogger.java +3 −2 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ import android.util.proto.ProtoOutputStream; import androidx.annotation.RequiresApi; import com.android.bluetooth.bass_client.BassConstants; import com.android.bluetooth.BluetoothMetricsProto.BluetoothLog; import com.android.bluetooth.BluetoothMetricsProto.BluetoothRemoteDeviceInformation; import com.android.bluetooth.BluetoothMetricsProto.ProfileConnectionStats; Loading @@ -36,6 +35,7 @@ import com.android.bluetooth.BluetoothMetricsProto.ProfileId; import com.android.bluetooth.BluetoothStatsLog; import com.android.bluetooth.BtRestrictedStatsLog; import com.android.bluetooth.Utils; import com.android.bluetooth.bass_client.BassConstants; import com.android.modules.utils.build.SdkLevel; import com.google.common.annotations.VisibleForTesting; Loading Loading @@ -411,7 +411,8 @@ public class MetricsLogger { } } return wordBreakdownList; // Prevent returning a mutable list return Collections.unmodifiableList(wordBreakdownList); } @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) Loading android/app/src/com/android/bluetooth/gatt/GattService.java +14 −22 Original line number Diff line number Diff line Loading @@ -98,6 +98,8 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; import java.util.stream.Collectors; import java.util.stream.Stream; /** Provides Bluetooth Gatt profile, as a service in the Bluetooth application. */ public class GattService extends ProfileService { Loading Loading @@ -1872,18 +1874,10 @@ public class GattService extends ProfileService { } // Create matching device sub-set List<BluetoothDevice> deviceList = new ArrayList<>(); for (Map.Entry<BluetoothDevice, Integer> entry : deviceStates.entrySet()) { for (int state : states) { if (entry.getValue() == state) { deviceList.add(entry.getKey()); } } } return deviceList; return deviceStates.entrySet().stream() .filter(e -> Arrays.stream(states).anyMatch(s -> s == e.getValue())) .map(Map.Entry::getKey) .collect(Collectors.toList()); } @RequiresPermission(BLUETOOTH_CONNECT) Loading Loading @@ -2213,11 +2207,9 @@ public class GattService extends ProfileService { this, attributionSource, "GattService getRegisteredServiceUuids")) { return Collections.emptyList(); } List<ParcelUuid> serviceUuids = new ArrayList<>(); for (HandleMap.Entry entry : mHandleMap.getEntries()) { serviceUuids.add(new ParcelUuid(entry.uuid)); } return serviceUuids; return mHandleMap.getEntries().stream() .map(entry -> new ParcelUuid(entry.uuid)) .collect(Collectors.toList()); } @RequiresPermission(BLUETOOTH_CONNECT) Loading @@ -2227,11 +2219,11 @@ public class GattService extends ProfileService { return Collections.emptyList(); } Set<String> connectedDevAddress = new HashSet<>(); connectedDevAddress.addAll(mClientMap.getConnectedDevices()); connectedDevAddress.addAll(mServerMap.getConnectedDevices()); List<String> connectedDeviceList = new ArrayList<>(connectedDevAddress); return connectedDeviceList; return Stream.concat( mClientMap.getConnectedDevices().stream(), mServerMap.getConnectedDevices().stream()) .distinct() .collect(Collectors.toList()); } @RequiresPermission(BLUETOOTH_CONNECT) Loading android/app/src/com/android/bluetooth/le_scan/TransitionalScanHelper.java +11 −10 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.stream.Collectors; /** * A helper class which contains all scan related functions extracted from {@link Loading Loading @@ -1107,17 +1108,17 @@ public class TransitionalScanHelper { return Collections.emptyList(); } List<String> macAddresses = new ArrayList(); final long identity = Binder.clearCallingIdentity(); try { for (AssociationInfo info : mCompanionManager.getAllAssociations()) { if (info.getPackageName().equals(callingPackage) return mCompanionManager.getAllAssociations().stream() .filter( info -> info.getPackageName().equals(callingPackage) && !info.isSelfManaged() && info.getDeviceMacAddress() != null) { macAddresses.add(info.getDeviceMacAddress().toString()); } } && info.getDeviceMacAddress() != null) .map(AssociationInfo::getDeviceMacAddress) .map(MacAddress::toString) .collect(Collectors.toList()); } catch (SecurityException se) { // Not an app with associated devices } catch (Exception e) { Loading @@ -1125,7 +1126,7 @@ public class TransitionalScanHelper { } finally { Binder.restoreCallingIdentity(identity); } return macAddresses; return Collections.emptyList(); } @RequiresPermission(BLUETOOTH_SCAN) Loading Loading
android/app/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -342,6 +342,7 @@ android_app { "-Xep:InvalidParam:ERROR", "-Xep:LoopOverCharArray:ERROR", "-Xep:MissingCasesInEnumSwitch:ERROR", "-Xep:MixedMutabilityReturnType:ERROR", "-Xep:MockNotUsedInProduction:ERROR", "-Xep:ModifyCollectionInEnhancedForLoop:ERROR", "-Xep:NarrowCalculation:ERROR", Loading
android/app/src/com/android/bluetooth/bass_client/BassClientService.java +4 −8 Original line number Diff line number Diff line Loading @@ -100,6 +100,7 @@ import java.util.Optional; import java.util.PriorityQueue; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; /** Broadcast Assistant Scan Service */ public class BassClientService extends ProfileService { Loading Loading @@ -3059,14 +3060,9 @@ public class BassClientService extends ProfileService { log("stateMachine is null"); return Collections.emptyList(); } List<BluetoothLeBroadcastReceiveState> recvStates = new ArrayList<BluetoothLeBroadcastReceiveState>(); for (BluetoothLeBroadcastReceiveState rs : stateMachine.getAllSources()) { if (!isEmptyBluetoothDevice(rs.getSourceDevice())) { recvStates.add(rs); } } return recvStates; return stateMachine.getAllSources().stream() .filter(rs -> !isEmptyBluetoothDevice(rs.getSourceDevice())) .collect(Collectors.toList()); } } Loading
android/app/src/com/android/bluetooth/btservice/MetricsLogger.java +3 −2 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ import android.util.proto.ProtoOutputStream; import androidx.annotation.RequiresApi; import com.android.bluetooth.bass_client.BassConstants; import com.android.bluetooth.BluetoothMetricsProto.BluetoothLog; import com.android.bluetooth.BluetoothMetricsProto.BluetoothRemoteDeviceInformation; import com.android.bluetooth.BluetoothMetricsProto.ProfileConnectionStats; Loading @@ -36,6 +35,7 @@ import com.android.bluetooth.BluetoothMetricsProto.ProfileId; import com.android.bluetooth.BluetoothStatsLog; import com.android.bluetooth.BtRestrictedStatsLog; import com.android.bluetooth.Utils; import com.android.bluetooth.bass_client.BassConstants; import com.android.modules.utils.build.SdkLevel; import com.google.common.annotations.VisibleForTesting; Loading Loading @@ -411,7 +411,8 @@ public class MetricsLogger { } } return wordBreakdownList; // Prevent returning a mutable list return Collections.unmodifiableList(wordBreakdownList); } @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) Loading
android/app/src/com/android/bluetooth/gatt/GattService.java +14 −22 Original line number Diff line number Diff line Loading @@ -98,6 +98,8 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; import java.util.stream.Collectors; import java.util.stream.Stream; /** Provides Bluetooth Gatt profile, as a service in the Bluetooth application. */ public class GattService extends ProfileService { Loading Loading @@ -1872,18 +1874,10 @@ public class GattService extends ProfileService { } // Create matching device sub-set List<BluetoothDevice> deviceList = new ArrayList<>(); for (Map.Entry<BluetoothDevice, Integer> entry : deviceStates.entrySet()) { for (int state : states) { if (entry.getValue() == state) { deviceList.add(entry.getKey()); } } } return deviceList; return deviceStates.entrySet().stream() .filter(e -> Arrays.stream(states).anyMatch(s -> s == e.getValue())) .map(Map.Entry::getKey) .collect(Collectors.toList()); } @RequiresPermission(BLUETOOTH_CONNECT) Loading Loading @@ -2213,11 +2207,9 @@ public class GattService extends ProfileService { this, attributionSource, "GattService getRegisteredServiceUuids")) { return Collections.emptyList(); } List<ParcelUuid> serviceUuids = new ArrayList<>(); for (HandleMap.Entry entry : mHandleMap.getEntries()) { serviceUuids.add(new ParcelUuid(entry.uuid)); } return serviceUuids; return mHandleMap.getEntries().stream() .map(entry -> new ParcelUuid(entry.uuid)) .collect(Collectors.toList()); } @RequiresPermission(BLUETOOTH_CONNECT) Loading @@ -2227,11 +2219,11 @@ public class GattService extends ProfileService { return Collections.emptyList(); } Set<String> connectedDevAddress = new HashSet<>(); connectedDevAddress.addAll(mClientMap.getConnectedDevices()); connectedDevAddress.addAll(mServerMap.getConnectedDevices()); List<String> connectedDeviceList = new ArrayList<>(connectedDevAddress); return connectedDeviceList; return Stream.concat( mClientMap.getConnectedDevices().stream(), mServerMap.getConnectedDevices().stream()) .distinct() .collect(Collectors.toList()); } @RequiresPermission(BLUETOOTH_CONNECT) Loading
android/app/src/com/android/bluetooth/le_scan/TransitionalScanHelper.java +11 −10 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.stream.Collectors; /** * A helper class which contains all scan related functions extracted from {@link Loading Loading @@ -1107,17 +1108,17 @@ public class TransitionalScanHelper { return Collections.emptyList(); } List<String> macAddresses = new ArrayList(); final long identity = Binder.clearCallingIdentity(); try { for (AssociationInfo info : mCompanionManager.getAllAssociations()) { if (info.getPackageName().equals(callingPackage) return mCompanionManager.getAllAssociations().stream() .filter( info -> info.getPackageName().equals(callingPackage) && !info.isSelfManaged() && info.getDeviceMacAddress() != null) { macAddresses.add(info.getDeviceMacAddress().toString()); } } && info.getDeviceMacAddress() != null) .map(AssociationInfo::getDeviceMacAddress) .map(MacAddress::toString) .collect(Collectors.toList()); } catch (SecurityException se) { // Not an app with associated devices } catch (Exception e) { Loading @@ -1125,7 +1126,7 @@ public class TransitionalScanHelper { } finally { Binder.restoreCallingIdentity(identity); } return macAddresses; return Collections.emptyList(); } @RequiresPermission(BLUETOOTH_SCAN) Loading