浏览代码

Use comparison operator rather than equals for enums in WebRTC code

Fixes SPP_EQUALS_ON_ENUM issue from SpotBugs.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Daniel Calviño Sánchez 2 年之前
父节点
当前提交
969c08ea79

+ 1 - 1
app/src/main/java/com/nextcloud/talk/webrtc/MagicWebSocketInstance.java

@@ -467,7 +467,7 @@ public class MagicWebSocketInstance extends WebSocketListener {
 
 
     @Subscribe(threadMode = ThreadMode.BACKGROUND)
     @Subscribe(threadMode = ThreadMode.BACKGROUND)
     public void onMessageEvent(NetworkEvent networkEvent) {
     public void onMessageEvent(NetworkEvent networkEvent) {
-        if (networkEvent.getNetworkConnectionEvent().equals(NetworkEvent.NetworkConnectionEvent.NETWORK_CONNECTED) && !isConnected()) {
+        if (networkEvent.getNetworkConnectionEvent() == NetworkEvent.NetworkConnectionEvent.NETWORK_CONNECTED && !isConnected()) {
             restartWebSocket();
             restartWebSocket();
         }
         }
     }
     }

+ 9 - 9
app/src/main/java/com/nextcloud/talk/webrtc/PeerConnectionWrapper.java

@@ -276,7 +276,7 @@ public class PeerConnectionWrapper {
 
 
         @Override
         @Override
         public void onStateChange() {
         public void onStateChange() {
-            if (dataChannel != null && dataChannel.state().equals(DataChannel.State.OPEN) &&
+            if (dataChannel != null && dataChannel.state() == DataChannel.State.OPEN &&
                     dataChannel.label().equals("status")) {
                     dataChannel.label().equals("status")) {
                 sendInitialMediaStatus();
                 sendInitialMediaStatus();
             }
             }
@@ -343,7 +343,7 @@ public class PeerConnectionWrapper {
         public void onIceConnectionChange(PeerConnection.IceConnectionState iceConnectionState) {
         public void onIceConnectionChange(PeerConnection.IceConnectionState iceConnectionState) {
 
 
             Log.d("iceConnectionChangeTo: ", iceConnectionState.name() + " over " + peerConnection.hashCode() + " " + sessionId);
             Log.d("iceConnectionChangeTo: ", iceConnectionState.name() + " over " + peerConnection.hashCode() + " " + sessionId);
-            if (iceConnectionState.equals(PeerConnection.IceConnectionState.CONNECTED)) {
+            if (iceConnectionState == PeerConnection.IceConnectionState.CONNECTED) {
                 EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType.PEER_CONNECTED,
                 EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType.PEER_CONNECTED,
                                                                    sessionId, null, null, null));
                                                                    sessionId, null, null, null));
 
 
@@ -354,18 +354,18 @@ public class PeerConnectionWrapper {
                 if (hasInitiated) {
                 if (hasInitiated) {
                     sendInitialMediaStatus();
                     sendInitialMediaStatus();
                 }
                 }
-            } else if (iceConnectionState.equals(PeerConnection.IceConnectionState.COMPLETED)) {
+            } else if (iceConnectionState == PeerConnection.IceConnectionState.COMPLETED) {
                 EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType.PEER_CONNECTED,
                 EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType.PEER_CONNECTED,
                                                                    sessionId, null, null, null));
                                                                    sessionId, null, null, null));
-            } else if (iceConnectionState.equals(PeerConnection.IceConnectionState.CLOSED)) {
+            } else if (iceConnectionState == PeerConnection.IceConnectionState.CLOSED) {
                 EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
                 EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
                         .PEER_CLOSED, sessionId, null, null, videoStreamType));
                         .PEER_CLOSED, sessionId, null, null, videoStreamType));
-            } else if (iceConnectionState.equals(PeerConnection.IceConnectionState.DISCONNECTED) ||
-                    iceConnectionState.equals(PeerConnection.IceConnectionState.NEW) ||
-                    iceConnectionState.equals(PeerConnection.IceConnectionState.CHECKING)) {
+            } else if (iceConnectionState == PeerConnection.IceConnectionState.DISCONNECTED ||
+                    iceConnectionState == PeerConnection.IceConnectionState.NEW ||
+                    iceConnectionState == PeerConnection.IceConnectionState.CHECKING) {
                 EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType.PEER_DISCONNECTED,
                 EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType.PEER_DISCONNECTED,
                                                                    sessionId, null, null, null));
                                                                    sessionId, null, null, null));
-            } else if (iceConnectionState.equals(PeerConnection.IceConnectionState.FAILED)) {
+            } else if (iceConnectionState == PeerConnection.IceConnectionState.FAILED) {
                 EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType.PEER_DISCONNECTED,
                 EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType.PEER_DISCONNECTED,
                                                                    sessionId, null, null, null));
                                                                    sessionId, null, null, null));
                 if (isMCUPublisher) {
                 if (isMCUPublisher) {
@@ -469,7 +469,7 @@ public class PeerConnectionWrapper {
 
 
                     if (shouldNotReceiveVideo()) {
                     if (shouldNotReceiveVideo()) {
                         for (RtpTransceiver t : peerConnection.getTransceivers()) {
                         for (RtpTransceiver t : peerConnection.getTransceivers()) {
-                            if (t.getMediaType().equals(MediaStreamTrack.MediaType.MEDIA_TYPE_VIDEO)) {
+                            if (t.getMediaType() == MediaStreamTrack.MediaType.MEDIA_TYPE_VIDEO) {
                                 t.stop();
                                 t.stop();
                             }
                             }
                         }
                         }

+ 1 - 1
app/src/main/java/com/nextcloud/talk/webrtc/WebRtcAudioManager.java

@@ -129,7 +129,7 @@ public class WebRtcAudioManager {
             return;
             return;
         }
         }
 
 
-        if (userSelectedAudioDevice.equals(AudioDevice.SPEAKER_PHONE)
+        if (userSelectedAudioDevice == AudioDevice.SPEAKER_PHONE
             && audioDevices.contains(AudioDevice.EARPIECE)
             && audioDevices.contains(AudioDevice.EARPIECE)
             && audioDevices.contains(AudioDevice.SPEAKER_PHONE)) {
             && audioDevices.contains(AudioDevice.SPEAKER_PHONE)) {