Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e49857d0 authored by Sungsoo Lim's avatar Sungsoo Lim Committed by Automerger Merge Worker
Browse files

Merge "Fix Java style in LeAudioService.java" am: 084191e4

parents 65960530 084191e4
Loading
Loading
Loading
Loading
+106 −113
Original line number Diff line number Diff line
@@ -156,8 +156,7 @@ public class LeAudioService extends ProfileService {
    private final Map<BluetoothDevice, Integer> mDeviceAudioLocationMap = new ConcurrentHashMap<>();

    private final int mContextSupportingInputAudio =
            BluetoothLeAudio.CONTEXT_TYPE_COMMUNICATION |
            BluetoothLeAudio.CONTEXT_TYPE_MAN_MACHINE;
            BluetoothLeAudio.CONTEXT_TYPE_COMMUNICATION | BluetoothLeAudio.CONTEXT_TYPE_MAN_MACHINE;

    private final int mContextSupportingOutputAudio = BluetoothLeAudio.CONTEXT_TYPE_COMMUNICATION |
            BluetoothLeAudio.CONTEXT_TYPE_MEDIA |
@@ -769,8 +768,7 @@ public class LeAudioService extends ProfileService {
    }

    private boolean updateActiveInDevice(BluetoothDevice device, Integer groupId,
                                            Integer oldActiveContexts,
                                            Integer newActiveContexts) {
            Integer oldActiveContexts, Integer newActiveContexts) {
        Integer oldSupportedAudioDirections =
                getAudioDirectionsFromActiveContextsMap(oldActiveContexts);
        Integer newSupportedAudioDirections =
@@ -834,8 +832,7 @@ public class LeAudioService extends ProfileService {
    }

    private boolean updateActiveOutDevice(BluetoothDevice device, Integer groupId,
                                       Integer oldActiveContexts,
                                       Integer newActiveContexts) {
            Integer oldActiveContexts, Integer newActiveContexts) {
        Integer oldSupportedAudioDirections =
                getAudioDirectionsFromActiveContextsMap(oldActiveContexts);
        Integer newSupportedAudioDirections =
@@ -1091,9 +1088,9 @@ public class LeAudioService extends ProfileService {
                     * To improve scenario when lead Le Audio device is disconnected for the
                     * streaming group, while there are still other devices streaming,
                     * LeAudioService will not notify audio framework or other users about
                    * Le Audio lead device disconnection. Instead we try to reconnect under the hood
                    * and keep using lead device as a audio device indetifier in the audio framework
                    * in order to not stop the stream.
                     * Le Audio lead device disconnection. Instead we try to reconnect under
                     * the hood and keep using lead device as a audio device indetifier in
                     * the audio framework in order to not stop the stream.
                     */
                    int groupId = getGroupId(device);
                    synchronized (mGroupLock) {
@@ -1234,8 +1231,7 @@ public class LeAudioService extends ProfileService {
                    if (descriptor != null) {
                        if (!descriptor.mIsActive) {
                            descriptor.mIsActive = updateActiveDevices(groupId,
                                                ACTIVE_CONTEXTS_NONE,
                                                descriptor.mActiveContexts, true);
                                    ACTIVE_CONTEXTS_NONE, descriptor.mActiveContexts, true);
                            notifyGroupStatus = descriptor.mIsActive;
                        }
                    } else {
@@ -1482,8 +1478,7 @@ public class LeAudioService extends ProfileService {
    }

    @VisibleForTesting
    synchronized void connectionStateChanged(BluetoothDevice device, int fromState,
                                                     int toState) {
    synchronized void connectionStateChanged(BluetoothDevice device, int fromState, int toState) {
        if ((device == null) || (fromState == toState)) {
            Log.e(TAG, "connectionStateChanged: unexpected invocation. device=" + device
                    + " fromState=" + fromState + " toState=" + toState);
@@ -1539,9 +1534,8 @@ public class LeAudioService extends ProfileService {

            List<BluetoothDevice> connectedDevices = getConnectedPeerDevices(myGroupId);
            /* Let's check if the last connected device is really connected */
            if (connectedDevices.size() == 1
                    && Objects.equals(connectedDevices.get(0),
                            descriptor.mLostLeadDeviceWhileStreaming)) {
            if (connectedDevices.size() == 1 && Objects.equals(
                    connectedDevices.get(0), descriptor.mLostLeadDeviceWhileStreaming)) {
                clearLostDevicesWhileStreaming(descriptor);
                return;
            }
@@ -1835,8 +1829,7 @@ public class LeAudioService extends ProfileService {
        }
    }

    private void notifyUnicastCodecConfigChanged(int groupId,
                                                 BluetoothLeAudioCodecStatus status) {
    private void notifyUnicastCodecConfigChanged(int groupId, BluetoothLeAudioCodecStatus status) {
        if (mLeAudioCallbacks != null) {
            int n = mLeAudioCallbacks.beginBroadcast();
            for (int i = 0; i < n; i++) {
@@ -2043,8 +2036,8 @@ public class LeAudioService extends ProfileService {
            return;
        }

        mLeAudioNativeInterface.setCodecConfigPreference(groupId,
                                inputCodecConfig, outputCodecConfig);
        mLeAudioNativeInterface.setCodecConfigPreference(
                groupId, inputCodecConfig, outputCodecConfig);
    }

    /**
@@ -2083,11 +2076,11 @@ public class LeAudioService extends ProfileService {
                Objects.requireNonNull(receiver, "receiver cannot be null");

                LeAudioService service = getService(source);
                boolean defaultValue = false;
                boolean result = false;
                if (service != null) {
                    defaultValue = service.connect(device);
                    result = service.connect(device);
                }
                receiver.send(defaultValue);
                receiver.send(result);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
            }
@@ -2102,11 +2095,11 @@ public class LeAudioService extends ProfileService {
                Objects.requireNonNull(receiver, "receiver cannot be null");

                LeAudioService service = getService(source);
                boolean defaultValue = false;
                boolean result = false;
                if (service != null) {
                    defaultValue = service.disconnect(device);
                    result = service.disconnect(device);
                }
                receiver.send(defaultValue);
                receiver.send(result);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
            }
@@ -2120,11 +2113,11 @@ public class LeAudioService extends ProfileService {
                Objects.requireNonNull(receiver, "receiver cannot be null");

                LeAudioService service = getService(source);
                List<BluetoothDevice> defaultValue = new ArrayList<>(0);
                List<BluetoothDevice> result = new ArrayList<>(0);
                if (service != null) {
                    defaultValue = service.getConnectedDevices();
                    result = service.getConnectedDevices();
                }
                receiver.send(defaultValue);
                receiver.send(result);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
            }
@@ -2138,11 +2131,11 @@ public class LeAudioService extends ProfileService {
                Objects.requireNonNull(receiver, "receiver cannot be null");

                LeAudioService service = getService(source);
                BluetoothDevice defaultValue = null;
                BluetoothDevice result = null;
                if (service != null) {
                    defaultValue = service.getConnectedGroupLeadDevice(groupId);
                    result = service.getConnectedGroupLeadDevice(groupId);
                }
                receiver.send(defaultValue);
                receiver.send(result);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
            }
@@ -2156,11 +2149,11 @@ public class LeAudioService extends ProfileService {
                Objects.requireNonNull(receiver, "receiver cannot be null");

                LeAudioService service = getService(source);
                List<BluetoothDevice> defaultValue = new ArrayList<>(0);
                List<BluetoothDevice> result = new ArrayList<>(0);
                if (service != null) {
                    defaultValue = service.getDevicesMatchingConnectionStates(states);
                    result = service.getDevicesMatchingConnectionStates(states);
                }
                receiver.send(defaultValue);
                receiver.send(result);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
            }
@@ -2175,11 +2168,11 @@ public class LeAudioService extends ProfileService {
                Objects.requireNonNull(receiver, "receiver cannot be null");

                LeAudioService service = getService(source);
                int defaultValue = BluetoothProfile.STATE_DISCONNECTED;
                int result = BluetoothProfile.STATE_DISCONNECTED;
                if (service != null) {
                    defaultValue = service.getConnectionState(device);
                    result = service.getConnectionState(device);
                }
                receiver.send(defaultValue);
                receiver.send(result);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
            }
@@ -2194,11 +2187,11 @@ public class LeAudioService extends ProfileService {
                Objects.requireNonNull(receiver, "receiver cannot be null");

                LeAudioService service = getService(source);
                boolean defaultValue = false;
                boolean result = false;
                if (service != null) {
                    defaultValue = service.setActiveDevice(device);
                    result = service.setActiveDevice(device);
                }
                receiver.send(defaultValue);
                receiver.send(result);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
            }
@@ -2211,11 +2204,11 @@ public class LeAudioService extends ProfileService {
                Objects.requireNonNull(receiver, "receiver cannot be null");

                LeAudioService service = getService(source);
                List<BluetoothDevice> defaultValue = new ArrayList<>();
                List<BluetoothDevice> result = new ArrayList<>();
                if (service != null) {
                    defaultValue = service.getActiveDevices();
                    result = service.getActiveDevices();
                }
                receiver.send(defaultValue);
                receiver.send(result);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
            }
@@ -2230,11 +2223,11 @@ public class LeAudioService extends ProfileService {
                Objects.requireNonNull(receiver, "receiver cannot be null");

                LeAudioService service = getService(source);
                int defaultValue = BluetoothLeAudio.AUDIO_LOCATION_INVALID;
                int result = BluetoothLeAudio.AUDIO_LOCATION_INVALID;
                if (service != null) {
                    defaultValue = service.getAudioLocation(device);
                    result = service.getAudioLocation(device);
                }
                receiver.send(defaultValue);
                receiver.send(result);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
            }
@@ -2249,11 +2242,11 @@ public class LeAudioService extends ProfileService {

            try {
                LeAudioService service = getService(source);
                boolean defaultValue = false;
                boolean result = false;
                if (service != null) {
                    defaultValue = service.setConnectionPolicy(device, connectionPolicy);
                    result = service.setConnectionPolicy(device, connectionPolicy);
                }
                receiver.send(defaultValue);
                receiver.send(result);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
            }
@@ -2268,13 +2261,13 @@ public class LeAudioService extends ProfileService {
                Objects.requireNonNull(receiver, "receiver cannot be null");

                LeAudioService service = getService(source);
                int defaultValue = BluetoothProfile.CONNECTION_POLICY_UNKNOWN;
                int result = BluetoothProfile.CONNECTION_POLICY_UNKNOWN;
                if (service == null) {
                    throw new IllegalStateException("service is null");
                }
                enforceBluetoothPrivilegedPermission(service);
                defaultValue = service.getConnectionPolicy(device);
                receiver.send(defaultValue);
                result = service.getConnectionPolicy(device);
                receiver.send(result);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
            }
@@ -2310,13 +2303,13 @@ public class LeAudioService extends ProfileService {
                Objects.requireNonNull(receiver, "receiver cannot be null");

                LeAudioService service = getService(source);
                int defaultValue = LE_AUDIO_GROUP_ID_INVALID;
                int result = LE_AUDIO_GROUP_ID_INVALID;
                if (service == null) {
                    throw new IllegalStateException("service is null");
                }
                enforceBluetoothPrivilegedPermission(service);
                defaultValue = service.getGroupId(device);
                receiver.send(defaultValue);
                result = service.getGroupId(device);
                receiver.send(result);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
            }
@@ -2331,13 +2324,13 @@ public class LeAudioService extends ProfileService {
                Objects.requireNonNull(receiver, "receiver cannot be null");

                LeAudioService service = getService(source);
                boolean defaultValue = false;
                boolean result = false;
                if (service == null) {
                    throw new IllegalStateException("service is null");
                }
                enforceBluetoothPrivilegedPermission(service);
                defaultValue = service.groupAddNode(group_id, device);
                receiver.send(defaultValue);
                result = service.groupAddNode(group_id, device);
                receiver.send(result);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
            }
@@ -2352,13 +2345,13 @@ public class LeAudioService extends ProfileService {
                Objects.requireNonNull(receiver, "receiver cannot be null");

                LeAudioService service = getService(source);
                boolean defaultValue = false;
                boolean result = false;
                if (service == null) {
                    throw new IllegalStateException("service is null");
                }
                enforceBluetoothPrivilegedPermission(service);
                defaultValue = service.groupRemoveNode(groupId, device);
                receiver.send(defaultValue);
                result = service.groupRemoveNode(groupId, device);
                receiver.send(result);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
            }
@@ -2499,12 +2492,12 @@ public class LeAudioService extends ProfileService {
        public void isPlaying(int broadcastId, AttributionSource source,
                SynchronousResultReceiver receiver) {
            try {
                boolean defaultValue = false;
                boolean result = false;
                LeAudioService service = getService(source);
                if (service != null) {
                    defaultValue = service.isPlaying(broadcastId);
                    result = service.isPlaying(broadcastId);
                }
                receiver.send(defaultValue);
                receiver.send(result);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
            }
@@ -2514,12 +2507,12 @@ public class LeAudioService extends ProfileService {
        public void getAllBroadcastMetadata(AttributionSource source,
                SynchronousResultReceiver receiver) {
            try {
                List<BluetoothLeBroadcastMetadata> defaultValue = new ArrayList<>();
                List<BluetoothLeBroadcastMetadata> result = new ArrayList<>();
                LeAudioService service = getService(source);
                if (service != null) {
                    defaultValue = service.getAllBroadcastMetadata();
                    result = service.getAllBroadcastMetadata();
                }
                receiver.send(defaultValue);
                receiver.send(result);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
            }
@@ -2529,12 +2522,12 @@ public class LeAudioService extends ProfileService {
        public void getMaximumNumberOfBroadcasts(AttributionSource source,
                SynchronousResultReceiver receiver) {
            try {
                int defaultValue = 0;
                int result = 0;
                LeAudioService service = getService(source);
                if (service != null) {
                    defaultValue = service.getMaximumNumberOfBroadcasts();
                    result = service.getMaximumNumberOfBroadcasts();
                }
                receiver.send(defaultValue);
                receiver.send(result);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
            }