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

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

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

parents f00ecb20 4630250d
Loading
Loading
Loading
Loading
+106 −113
Original line number Diff line number Diff line
@@ -159,8 +159,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 |
@@ -785,8 +784,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 =
@@ -851,8 +849,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 =
@@ -1132,9 +1129,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) {
@@ -1275,8 +1272,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 {
@@ -1523,8 +1519,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);
@@ -1580,9 +1575,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;
            }
@@ -1878,8 +1872,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++) {
@@ -2086,8 +2079,8 @@ public class LeAudioService extends ProfileService {
            return;
        }

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

    /**
@@ -2126,11 +2119,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);
            }
@@ -2145,11 +2138,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);
            }
@@ -2163,11 +2156,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);
            }
@@ -2181,11 +2174,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);
            }
@@ -2199,11 +2192,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);
            }
@@ -2218,11 +2211,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);
            }
@@ -2237,11 +2230,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);
            }
@@ -2254,11 +2247,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);
            }
@@ -2273,11 +2266,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);
            }
@@ -2292,11 +2285,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);
            }
@@ -2311,13 +2304,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);
            }
@@ -2353,13 +2346,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);
            }
@@ -2374,13 +2367,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);
            }
@@ -2395,13 +2388,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);
            }
@@ -2542,12 +2535,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);
            }
@@ -2557,12 +2550,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);
            }
@@ -2572,12 +2565,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);
            }