Browse Source

Fix proximity sensor video stop

Signed-off-by: Mario Danic <mario@lovelyhq.com>
Mario Danic 6 years ago
parent
commit
942c0581d3

+ 9 - 6
app/src/main/java/com/nextcloud/talk/controllers/CallController.java

@@ -1453,12 +1453,15 @@ public class CallController extends BaseController {
                 .PeerConnectionEventType.SENSOR_FAR) ||
                 .PeerConnectionEventType.SENSOR_FAR) ||
                 peerConnectionEvent.getPeerConnectionEventType().equals(PeerConnectionEvent
                 peerConnectionEvent.getPeerConnectionEventType().equals(PeerConnectionEvent
                         .PeerConnectionEventType.SENSOR_NEAR)) {
                         .PeerConnectionEventType.SENSOR_NEAR)) {
-            boolean enableVideo = peerConnectionEvent.getPeerConnectionEventType().equals(PeerConnectionEvent
-                    .PeerConnectionEventType.SENSOR_FAR) && videoOn;
-            if (getActivity() != null && EffortlessPermissions.hasPermissions(getActivity(), PERMISSIONS_CAMERA) &&
-                    inCall && videoOn
-                    && enableVideo != localVideoTrack.enabled()) {
-                toggleMedia(enableVideo, true);
+            
+            if (!isVoiceOnlyCall) {
+                boolean enableVideo = peerConnectionEvent.getPeerConnectionEventType().equals(PeerConnectionEvent
+                        .PeerConnectionEventType.SENSOR_FAR) && videoOn;
+                if (getActivity() != null && EffortlessPermissions.hasPermissions(getActivity(), PERMISSIONS_CAMERA) &&
+                        inCall && videoOn
+                        && enableVideo != localVideoTrack.enabled()) {
+                    toggleMedia(enableVideo, true);
+                }
             }
             }
         } else if (peerConnectionEvent.getPeerConnectionEventType().equals(PeerConnectionEvent
         } else if (peerConnectionEvent.getPeerConnectionEventType().equals(PeerConnectionEvent
                 .PeerConnectionEventType.NICK_CHANGE)) {
                 .PeerConnectionEventType.NICK_CHANGE)) {

+ 2 - 2
app/src/main/java/com/nextcloud/talk/webrtc/MagicAudioManager.java

@@ -176,7 +176,7 @@ public class MagicAudioManager {
                 setAudioDeviceInternal(MagicAudioManager.AudioDevice.EARPIECE);
                 setAudioDeviceInternal(MagicAudioManager.AudioDevice.EARPIECE);
 
 
                 EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
                 EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
-                        .SENSOR_FAR, null, null, null));
+                        .SENSOR_NEAR, null, null, null));
 
 
             } else {
             } else {
                 // Sensor reports that a "handset is removed from a person's ear", or
                 // Sensor reports that a "handset is removed from a person's ear", or
@@ -184,7 +184,7 @@ public class MagicAudioManager {
                 setAudioDeviceInternal(MagicAudioManager.AudioDevice.SPEAKER_PHONE);
                 setAudioDeviceInternal(MagicAudioManager.AudioDevice.SPEAKER_PHONE);
 
 
                 EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
                 EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
-                        .SENSOR_NEAR, null, null, null));
+                        .SENSOR_FAR, null, null, null));
             }
             }
         }
         }
     }
     }