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

Commit 084191e4 authored by Sungsoo Lim's avatar Sungsoo Lim Committed by Gerrit Code Review
Browse files

Merge "Fix Java style in LeAudioService.java"

parents e867c5af 65402207
Loading
Loading
Loading
Loading
+106 −113
Original line number Diff line number Diff line
@@ -155,8 +155,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 |
@@ -768,8 +767,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 =
@@ -833,8 +831,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 =
@@ -1079,9 +1076,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) {
@@ -1222,8 +1219,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 {
@@ -1472,8 +1468,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);
@@ -1529,9 +1524,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;
            }
@@ -1825,8 +1819,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++) {
@@ -2033,8 +2026,8 @@ public class LeAudioService extends ProfileService {
            return;
        }

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

    /**
@@ -2073,11 +2066,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);
            }
@@ -2092,11 +2085,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);
            }
@@ -2110,11 +2103,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);
            }
@@ -2128,11 +2121,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);
            }
@@ -2146,11 +2139,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);
            }
@@ -2165,11 +2158,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);
            }
@@ -2184,11 +2177,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);
            }
@@ -2201,11 +2194,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);
            }
@@ -2220,11 +2213,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);
            }
@@ -2239,11 +2232,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);
            }
@@ -2258,13 +2251,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);
            }
@@ -2300,13 +2293,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);
            }
@@ -2321,13 +2314,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);
            }
@@ -2342,13 +2335,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);
            }
@@ -2489,12 +2482,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);
            }
@@ -2504,12 +2497,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);
            }
@@ -2519,12 +2512,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);
            }