Parcourir la source

去掉来电时的无限震动,修复来电去电铃声声音忽大忽小问题

weizhengliang il y a 2 ans
Parent
commit
df281b7a06

+ 2 - 2
home/src/main/code/com/wdkl/ncs/android/component/home/ui/CallSingleActivity.java

@@ -270,9 +270,9 @@ public class CallSingleActivity extends AppCompatActivity {
             //RingPlayHelper.playRingTone(this, R.raw.incoming_call, true);
             long[] pattern = new long[]{100L, 2000L, 1000L, 2000L, 1000L, 2000L};
             if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
-                mVibrator.vibrate(VibrationEffect.createWaveform(pattern, 0));
+                mVibrator.vibrate(VibrationEffect.createWaveform(pattern, -1));
             } else {
-                mVibrator.vibrate(pattern, 0);
+                mVibrator.vibrate(pattern, -1);
             }
         }
 

+ 11 - 4
janus/src/main/java/com/wdkl/rtc/rtc/WebRTCEngine.java

@@ -404,6 +404,13 @@ public class WebRTCEngine {
         if (_localStream == null) {
             createLocalStream();
         }
+
+        if (isHeadphonesPlugged()) {
+            toggleHeadset(true);
+        } else {
+            audioManager.setMode(AudioManager.MODE_NORMAL);
+            audioManager.setSpeakerphoneOn(true);
+        }
     }
 
     /**
@@ -563,11 +570,11 @@ public class WebRTCEngine {
                     audioManager.setMode(AudioManager.MODE_IN_CALL);
                 }
                 audioManager.setSpeakerphoneOn(false);
-            } else {
+            } /*else {
                 if (mIsAudioOnly) {
                     toggleSpeaker(isSpeakerOn);
                 }
-            }
+            }*/
         }
         return false;
     }
@@ -705,12 +712,12 @@ public class WebRTCEngine {
             peer.addLocalStream(_localStream);
             peerMap.put(userId, peer);
         }
-        if (isHeadphonesPlugged()) {
+        /*if (isHeadphonesPlugged()) {
             toggleHeadset(true);
         } else {
             audioManager.setMode(AudioManager.MODE_NORMAL);
             audioManager.setSpeakerphoneOn(true);
-        }
+        }*/
     }
 
     public void createLocalPeer(BigInteger userId, CreatePeerConnectionCallback peerConnectionCallback){