From ff886457f58791eea4532f6167af51184d9dfe43 Mon Sep 17 00:00:00 2001 From: lss <lsc@hdlchina.com.cn> Date: 星期四, 26 五月 2022 17:31:42 +0800 Subject: [PATCH] 送测 --- HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneIntercomActivity.java | 61 +++++++++++++++++++++++++++--- 1 files changed, 55 insertions(+), 6 deletions(-) diff --git a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneIntercomActivity.java b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneIntercomActivity.java index 03679e5..0a48ba6 100644 --- a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneIntercomActivity.java +++ b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneIntercomActivity.java @@ -5,9 +5,12 @@ import android.content.Intent; import android.content.IntentFilter; import android.graphics.Bitmap; +import android.media.AudioAttributes; +import android.os.Build; import android.os.Bundle; import android.os.CountDownTimer; import android.os.SystemClock; +import android.os.Vibrator; import android.text.TextUtils; import android.util.DisplayMetrics; import android.util.Log; @@ -60,11 +63,16 @@ //鍙傛暟 private boolean isAnswer;//鏄惁宸茬粡鎺ュ惉浜� private int callTime;//閫氳瘽鏃堕棿 - + //鍊掕鏃� private CountDownTimer mCountDownTimer; + /** + * 鎵嬫満鎸姩鍣� + */ + private Vibrator mVibrator; //Linphone private CoreListenerStub mCoreListener; + @Override protected void onCreate(Bundle savedInstanceState) { @@ -79,6 +87,7 @@ initCallBack(); initCountDownTimer(); initLinphone(); + initVibrator(); } @@ -88,17 +97,22 @@ @Override protected void onDestroy() { super.onDestroy(); - + //1.鎸傛柇 + HDLLinphoneKit.getInstance().hangUp(); + //2.鏆傚仠璁℃椂 if (null != timer_lp_calltime) { timer_lp_calltime.stop(); } - + //3.娉ㄩ攢callBack HDLLinphoneKit.getInstance().setOpenOpenDoorCallBack(null); - + //4.鍙栨秷闇囧姩鍣� + cancelVibrator(); + //5. if (mCountDownTimer != null) { mCountDownTimer.cancel(); mCountDownTimer = null; } + //5. onDestroyLinphone(); HDLLog.i(TAG, "onDestroy"); @@ -246,7 +260,6 @@ } } - /** * 寮�閿佺偣鍑讳簨浠� */ @@ -284,6 +297,9 @@ private void onClickAnswer() { //1.鎺ュ惉 HDLLinphoneKit.getInstance().acceptCall(); + //2.鍙栨秷闇囧姩 + cancelVibrator(); + //3.淇敼UI isAnswer = true; tv_lp_hangUp.setText(getString(R.string.lp_hangupStr)); setViewGone(rl_lp_answerView); @@ -381,13 +397,15 @@ core.setNativePreviewWindowId(video_lp_rendering2); // Listen for call state changes core.addListener(mCoreListener); + core.enableMic(true);//寮�鍚害鍏嬮 } + } /** * onDestroyLinphone */ - void onDestroyLinphone(){ + void onDestroyLinphone() { Core core = HDLLinphoneKit.getInstance().getCore(); if (core != null) { core.removeListener(mCoreListener); @@ -398,5 +416,36 @@ video_lp_rendering2 = null; } + /** + * 鍒濆鍖栭渿鍔ㄥ櫒 + */ + void initVibrator() { + mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); + if (mVibrator.hasVibrator()) { + long[] patern = {0, 1000, 1000}; + AudioAttributes audioAttributes = null; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + audioAttributes = new AudioAttributes.Builder() + .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) + .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE) //key + .build(); + mVibrator.vibrate(patern, 1, audioAttributes); + } else { + mVibrator.vibrate(patern, 1); + } + } else { + HDLLog.E("褰撳墠鎵嬫満娌℃湁闇囧姩鍣�"); + } + } + /** + * 鍏抽棴闇囧姩鍣� + */ + void cancelVibrator() { + if (mVibrator != null) { + mVibrator.cancel(); + mVibrator = null; + } + + } } \ No newline at end of file -- Gitblit v1.8.0