From 1697a5c0a1d40e756738d1f99d496c6e33b3fd52 Mon Sep 17 00:00:00 2001
From: lss <lsc@hdlchina.com.cn>
Date: 星期二, 28 六月 2022 14:09:38 +0800
Subject: [PATCH] 2022-6-28
---
HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneIntercomActivity.java | 69 +++++++++++++++++++++++++++++-----
1 files changed, 59 insertions(+), 10 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 f076514..40f0158 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();
}
@@ -90,17 +99,20 @@
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");
@@ -127,6 +139,9 @@
timer_lp_calltime = (Chronometer) findViewById(R.id.timer_lp_calltime);
tv_lp_calltime = findViewById(R.id.tv_lp_calltime);
setWidthHeightWithRatio(ll_video_lp_rendering, 16, 9);
+
+ iv_lp_screenshot.setEnabled(false);
+ iv_lp_unlock.setEnabled(false);
}
/**
@@ -198,7 +213,6 @@
@Override
public void onTick(long millisUntilFinished) {
if (!HDLLinphoneIntercomActivity.this.isFinishing()) {
-
}
}
@@ -207,12 +221,9 @@
*/
@Override
public void onFinish() {
-// showToast("寮�閿乷nFinish");
iv_lp_unlock.setEnabled(true);
}
-
};
-//
}
@Override
@@ -247,7 +258,6 @@
showToast(getString(R.string.lp_operationFailedStr));
}
}
-
/**
* 寮�閿佺偣鍑讳簨浠�
@@ -286,6 +296,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);
@@ -296,6 +309,9 @@
if (HDLLinphoneKit.getInstance().getOnHDLLinphoneCallListener() != null) {
HDLLinphoneKit.getInstance().getOnHDLLinphoneCallListener().onAnswerAction();
}
+
+ iv_lp_screenshot.setEnabled(true);
+ iv_lp_unlock.setEnabled(true);
}
/****************寮�閿佹垚鍔�********/
@@ -383,13 +399,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);
@@ -400,5 +418,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