From 8056b53176cddb9d154e3c3ffc4a11354b338fcf Mon Sep 17 00:00:00 2001
From: panlili2024 <14743743+panlili2024@user.noreply.gitee.com>
Date: 星期四, 25 九月 2025 13:46:17 +0800
Subject: [PATCH] 代码同步
---
HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneReverseCallActivity.java | 219 +++++++++++++++++++++++++++++++++++-------------------
1 files changed, 142 insertions(+), 77 deletions(-)
diff --git a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneReverseCallActivity.java b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneReverseCallActivity.java
index 9420018..b927780 100644
--- a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneReverseCallActivity.java
+++ b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneReverseCallActivity.java
@@ -1,16 +1,14 @@
package com.hdl.hdllinphonesdk.activity;
-import android.content.Context;
-import android.content.DialogInterface;
+import android.Manifest;
+import android.content.IntentFilter;
+import android.content.pm.PackageManager;
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.support.v7.app.AlertDialog;
-import android.support.v7.app.AppCompatActivity;
-import android.os.Bundle;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
@@ -25,13 +23,20 @@
import android.widget.TextView;
import android.widget.Toast;
+import androidx.annotation.NonNull;
+import androidx.core.app.ActivityCompat;
+import androidx.core.content.ContextCompat;
+
import com.hdl.hdllinphonesdk.HDLLinphoneKit;
import com.hdl.hdllinphonesdk.R;
import com.hdl.hdllinphonesdk.callback.OnLPOpenDoorCallBack;
+import com.hdl.hdllinphonesdk.dialog.LinphoneCommonDialog;
+import com.hdl.hdllinphonesdk.receiver.CallBroadcastReceiver;
import com.hdl.hdllinphonesdk.utils.HDLImageUtils;
import com.hdl.hdllinphonesdk.utils.HDLLog;
import org.linphone.core.Call;
+import org.linphone.core.CallParams;
import org.linphone.core.Core;
import org.linphone.core.CoreListenerStub;
@@ -41,6 +46,7 @@
public class HDLLinphoneReverseCallActivity extends LPCheckPermissionsActivity implements View.OnClickListener {
private static final String TAG = "HDLLinphoneReverseCallActivity";
+ private RelativeLayout ll_lp_btn_back;
//鎺т欢
private TextView tv_lp_title;
private ImageView iv_lp_screenshot;
@@ -52,6 +58,10 @@
private ImageView iv_lp_answer;
private TextView tv_lp_answer;
private RelativeLayout rl_lp_answerView;
+
+ private ImageView iv_lp_rejectall;
+ private TextView tv_lp_rejectall;
+ private RelativeLayout rl_lp_rejectallView;
private LinearLayout ll_video_lp_rendering;
private TextureView video_lp_rendering;
@@ -74,6 +84,12 @@
private CoreListenerStub mCoreListener;
private String deviceSipAccount;//璁惧SIP璐﹀彿
+ private boolean enableVideo = false;
+
+ private CallBroadcastReceiver callBroadcastReceiver;
+ private IntentFilter callFilter;
+
+ private boolean callAllRejection = false;//鑷爺闂ㄥ彛鏈烘槸鍚︽敮鎸佸叏閮ㄦ嫆鎺�
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -88,7 +104,6 @@
initCallBack();
initCountDownTimer();
initLinphone();
-// initVibrator();
}
/**
@@ -105,14 +120,19 @@
}
//3.娉ㄩ攢callBack
HDLLinphoneKit.getInstance().setOpenOpenDoorCallBack(null);
- //4.鍙栨秷闇囧姩鍣�
- cancelVibrator();
- //5.
+
+ //4.
if (mCountDownTimer != null) {
mCountDownTimer.cancel();
mCountDownTimer = null;
}
onDestroyLinphone();
+
+ if (callBroadcastReceiver != null) {
+ unregisterReceiver(callBroadcastReceiver);
+ callBroadcastReceiver = null;
+ }
+
HDLLog.i(TAG, "onDestroy");
}
@@ -120,6 +140,7 @@
* initView
*/
private void initView() {
+ ll_lp_btn_back = findViewById(R.id.ll_lp_btn_back);
tv_lp_title = findViewById(R.id.tv_lp_title);
iv_lp_screenshot = findViewById(R.id.iv_lp_screenshot);
iv_lp_unlock = findViewById(R.id.iv_lp_unlock);
@@ -128,6 +149,9 @@
iv_lp_answer = findViewById(R.id.iv_lp_answer);
tv_lp_answer = findViewById(R.id.tv_lp_answer);
rl_lp_answerView = findViewById(R.id.rl_lp_answerView);
+ iv_lp_rejectall = findViewById(R.id.iv_lp_hangUpall);
+ tv_lp_rejectall = findViewById(R.id.tv_lp_hangUpall);
+ rl_lp_rejectallView = findViewById(R.id.rl_lp_hangUpallView);
ll_video_lp_rendering = findViewById(R.id.ll_video_lp_rendering);
video_lp_rendering = findViewById(R.id.video_lp_rendering);
video_lp_rendering2 = findViewById(R.id.video_lp_rendering2);
@@ -145,12 +169,41 @@
*/
private void initData() {
Bundle extras = getIntent().getExtras();
+ String interphoneType = "";
if (extras != null) {
String titleName = extras.getString(HDLLinphoneKit.KEY_TITLE_NAME);
if (!TextUtils.isEmpty(titleName)) {
tv_lp_title.setText(titleName);
}
deviceSipAccount = extras.getString(HDLLinphoneKit.KEY_SIP_ACCOUNT);
+ interphoneType = extras.getString("interphoneType");
+ callAllRejection = extras.getBoolean(HDLLinphoneKit.KEY_CALL_ALL_REJECTION);
+ }
+
+ rl_lp_rejectallView.setVisibility(callAllRejection ? View.VISIBLE : View.GONE);
+
+ //鐩戝惉鍛煎彨骞挎挱
+ callFilter = new IntentFilter();
+ callFilter.addAction("com.hdl.homepro.call.action");
+ callBroadcastReceiver = new CallBroadcastReceiver();
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ registerReceiver(callBroadcastReceiver, callFilter, RECEIVER_EXPORTED);
+ } else {
+ registerReceiver(callBroadcastReceiver, callFilter);
+ }
+
+ if (callBroadcastReceiver != null) {
+ String finalInterphoneType = interphoneType;
+ callBroadcastReceiver.setOnReceivedCallBroadcastListener(new CallBroadcastReceiver.CallBroadcastListener() {
+ @Override
+ public void onReceived(String callFrom) {
+ //濡傛灉鏀跺埌鎺ㄩ�侀�氱煡鎶婄洃瑙嗛〉闈inish
+ if (!TextUtils.isEmpty(callFrom) && !finalInterphoneType.equals(callFrom)) {
+ Log.d("panlili", "HDLLinphoneIntercomActivity.java:onReceived-----> " + callFrom);
+ finish();//缁撴潫褰撳墠椤甸潰
+ }
+ }
+ });
}
}
@@ -176,12 +229,15 @@
* init OnClickListener
*/
private void initOnClick() {
+ ll_lp_btn_back.setOnClickListener(this);
iv_lp_screenshot.setOnClickListener(this);
iv_lp_unlock.setOnClickListener(this);
iv_lp_hangUp.setOnClickListener(this);
tv_lp_hangUp.setOnClickListener(this);
iv_lp_answer.setOnClickListener(this);
tv_lp_answer.setOnClickListener(this);
+ iv_lp_rejectall.setOnClickListener(this);
+ tv_lp_rejectall.setOnClickListener(this);
}
/**
@@ -230,8 +286,19 @@
public void onClick(View view) {
int id = view.getId();
if (id == R.id.iv_lp_screenshot) {
- //鎴浘
- onClickScreenshot();
+ //鍔ㄦ�佹潈闄愮敵璇�
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
+ //鎴浘
+ onClickScreenshot();
+ } else {
+ if (ContextCompat.checkSelfPermission(HDLLinphoneReverseCallActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
+ && ActivityCompat.checkSelfPermission(HDLLinphoneReverseCallActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
+ ActivityCompat.requestPermissions(HDLLinphoneReverseCallActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
+ } else {
+ //鎴浘
+ onClickScreenshot();
+ }
+ }
} else if (id == R.id.iv_lp_unlock) {
//寮�閿�
onClickUnlock();
@@ -241,6 +308,31 @@
} else if (id == R.id.iv_lp_answer || id == R.id.tv_lp_answer) {
//鎺ュ惉
onClickAnswer();
+ } else if (id == R.id.iv_lp_hangUpall || id == R.id.tv_lp_hangUpall) {
+ //鎷掓帴鍏ㄩ儴
+ onClickRejectAll();
+ } else if (id == R.id.ll_lp_btn_back) {
+ //杩斿洖鎸夐挳 鎸傛柇
+ if (isAnswer) {
+ HDLLinphoneKit.getInstance().hangUp();
+ }
+ finish();
+ }
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults);
+ switch (requestCode) {
+ case 1:
+ if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+ //鎴浘
+ onClickScreenshot();
+ } else {
+ LinphoneCommonDialog.getInstance().showSettingPermissionDialog(HDLLinphoneReverseCallActivity.this, getString(R.string.open_save_permission));
+ }
+ break;
+ default:
}
}
@@ -264,37 +356,14 @@
* 寮�閿佺偣鍑讳簨浠�
*/
private void onClickUnlock() {
- try {
- AlertDialog.Builder builder = new AlertDialog.Builder(this,R.style.CustomAlertDialog);
- builder.setTitle(R.string.lp_tipStr);
- builder.setMessage(R.string.tip_confirm_unlock);
-
- builder.setPositiveButton(R.string.lp_confirm, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- // 鍦ㄧ‘瀹氭寜閽鐐瑰嚮鏃舵墽琛岀殑鎿嶄綔
- // 鍙互鍦ㄨ繖閲屾坊鍔犱綘鎯宠鎵ц鐨勯�昏緫
- if (HDLLinphoneKit.getInstance().getOnHDLLinphoneCallListener() != null) {
- HDLLinphoneKit.getInstance().getOnHDLLinphoneCallListener().onUnlockAction();
- }
- dialog.dismiss(); // 鍏抽棴寮圭獥
+ LinphoneCommonDialog.getInstance().showDialog(HDLLinphoneReverseCallActivity.this, getString(R.string.tip_confirm_unlock), getString(R.string.lp_confirm), new LinphoneCommonDialog.OnOKClickListener() {
+ @Override
+ public void onOKClick() {
+ if (HDLLinphoneKit.getInstance().getOnHDLLinphoneCallListener() != null) {
+ HDLLinphoneKit.getInstance().getOnHDLLinphoneCallListener().onUnlockAction();
}
- });
- builder.setNegativeButton(R.string.lp_cancel, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- // 鍦ㄥ彇娑堟寜閽鐐瑰嚮鏃舵墽琛岀殑鎿嶄綔
- // 鍙互鍦ㄨ繖閲屾坊鍔犱綘鎯宠鎵ц鐨勯�昏緫
- dialog.dismiss(); // 鍏抽棴寮圭獥
- }
- });
-
- AlertDialog dialog = builder.create();
- dialog.show();
- }catch (Exception exception){
- Log.e(TAG, exception.getMessage());
- }
-
+ }
+ });
}
/**
@@ -317,6 +386,19 @@
finish();
}
+
+ /**
+ * 鎷掓帴鍏ㄩ儴鐐瑰嚮浜嬩欢
+ */
+ private void onClickRejectAll() {
+ //1.鍥炶皟浜嬩欢
+ if (HDLLinphoneKit.getInstance().getOnHDLLinphoneCallListener() != null) {
+ HDLLinphoneKit.getInstance().getOnHDLLinphoneCallListener().onRejectCallAllAction();
+ }
+ //2.椤甸潰鍏抽棴
+ finish();
+ }
+
/**
* 鎺ュ惉鎸夐挳鐐瑰嚮浜嬩欢
*/
@@ -328,12 +410,11 @@
}
HDLLinphoneKit.getInstance().callTo(deviceSipAccount, true);
- //2.鍙栨秷闇囧姩
- cancelVibrator();
- //3.淇敼UI
+ //2.淇敼UI
isAnswer = true;
tv_lp_hangUp.setText(getString(R.string.lp_hangupStr));
setViewGone(rl_lp_answerView);
+ setViewGone(rl_lp_rejectallView);
setViewGone(tv_lp_calltime);
setViewVisible(timer_lp_calltime);
startCallTimeCountdown();
@@ -417,6 +498,7 @@
// Once call is finished (end state), terminate the activity
// We also check for released state (called a few seconds later) just in case
// we missed the first one
+ enableVideo = false;
showToast(getString(R.string.lp_endOfCallStr));
finish();
}
@@ -435,6 +517,21 @@
}
+
+ void enableVideo(Core core, Call call) {
+// Call currentCall = HDLLinphoneService.getCore().getCurrentCall();
+
+ CallParams params = call.getCurrentParams();
+ if (params == null) {
+ params = core.createCallParams(call);
+ }
+ params.enableVideo(true);
+ params.enableLowBandwidth(false);
+ params.setAudioBandwidthLimit(0); // disable limitation
+
+ call.update(params);
+ }
+
/**
* onDestroyLinphone
*/
@@ -449,36 +546,4 @@
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