Browse Source

完善sip通话相关修改

weizhengliang 3 năm trước cách đây
mục cha
commit
c314079741

+ 1 - 1
app/src/main/AndroidManifest.xml

@@ -45,7 +45,7 @@
 
         <activity android:name="com.wdkl.ncs.android.component.welcome.activity.WelcomeActivity"
             android:screenOrientation="landscape"
-            android:launchMode="singleTask">
+            android:launchMode="singleInstance">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN"/>
 

+ 3 - 3
callingbed/src/main/AndroidManifest.xml

@@ -14,15 +14,15 @@
 
         <activity android:name=".activity.InitActivity"
             android:screenOrientation="landscape"
-            android:launchMode="singleTask"/>
+            android:launchMode="singleInstance"/>
 
         <activity android:name=".activity.CallingbedActivity"
             android:screenOrientation="landscape"
-            android:launchMode="singleTask"/>
+            android:launchMode="singleInstance"/>
 
         <activity android:name=".activity.AppUpdateActivity"
             android:screenOrientation="landscape"
-            android:launchMode="singleTask"/>
+            android:launchMode="singleInstance"/>
 
         <service
             android:name=".sip.WdklSipService"

+ 16 - 16
callingbed/src/main/java/com/wdkl/app/ncs/callingbed/activity/CallingbedActivity.kt

@@ -517,7 +517,8 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
         }
 
         initialized = true
-        view_title_layout_tv_hospital_name.text = deviceInfo.hospitalName + deviceInfo.partName
+        //view_title_layout_tv_hospital_name.text = deviceInfo.hospitalName + deviceInfo.partName
+        view_title_layout_tv_hospital_name.text = deviceInfo.partDisplay
         view_title_layout_tv_no.text = "设备ID:" + deviceInfo.id
 
         if (deviceInfo.customerId != null) {
@@ -546,16 +547,19 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
         if (WdklSipService.getCore() != null) {
             mAccountCreator = WdklSipService.getCore().createAccountCreator(null)
             // 以下三项必须
-            mAccountCreator!!.setDomain(Constant.TCP_SERVER_URL)
-            mAccountCreator!!.setUsername("3309")
-            mAccountCreator!!.setPassword("3309")
-            //默认使用udp
-            mAccountCreator!!.transport = TransportType.Udp
-
-            // 这里会自动创建代理配置、认证信息到 SIP核心
-            val cfg = mAccountCreator!!.createProxyConfig()
-            // 确保新创建的是最新
-            WdklSipService.getCore().defaultProxyConfig = cfg
+            if (!TextUtils.isEmpty(Constant.TCP_SERVER_URL) && !TextUtils.isEmpty(Constant.SIP_ID)) {
+                Log.e(TAG, "sip connect: ${Constant.SIP_ID}")
+                mAccountCreator!!.setDomain(Constant.TCP_SERVER_URL)
+                mAccountCreator!!.setUsername(Constant.SIP_ID)
+                mAccountCreator!!.setPassword(Constant.SIP_ID)
+                //默认使用udp
+                mAccountCreator!!.transport = TransportType.Udp
+
+                // 这里会自动创建代理配置、认证信息到 SIP核心
+                val cfg = mAccountCreator!!.createProxyConfig()
+                // 确保新创建的是最新
+                WdklSipService.getCore().defaultProxyConfig = cfg
+            }
         }
     }
 
@@ -1142,11 +1146,7 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
                                 } else {
                                     showMessage("服务未连接或sipId为空")
                                     Constant.CALL_STATE = Constant.CALL_STANDBY
-                                    VoiceUtil.rejectAudioCall(
-                                        Constant.DEVICE_ID,
-                                        Constant.fromId,
-                                        Constant.interactionId
-                                    )
+                                    VoiceUtil.rejectAudioCall(Constant.DEVICE_ID, Constant.fromId, Constant.interactionId)
                                 }
                             }
                         }

+ 1 - 4
callingbed/src/main/java/com/wdkl/app/ncs/callingbed/fragment/QrCodeFragment.kt

@@ -80,10 +80,7 @@ class QrCodeFragment : BaseFragment<QrCodeFragmentPresenter, QrcodeViewBinding>(
             tv_device_id.text = "设备ID: " + Constant.DEVICE_ID
         }
 
-        var serverIp = ""
-        if (UrlManager.build().base.length > 14) {
-            serverIp = UrlManager.build().base.substring(7, 14)
-        }
+        val serverIp =  UrlManager.build().base.substringAfterLast("//").substringBefore(":")
         tv_local_ip.text = "本机IP: " + ipAddr + " - " + serverIp
         tv_local_mac.text = "本机MAC: " + macAddr
         tv_app_version.text = "版本信息: V" + BuildConfig.VERSION_NAME

+ 6 - 4
callingbed/src/main/java/com/wdkl/app/ncs/callingbed/fragment/SipCallFragment.kt

@@ -52,6 +52,7 @@ class SipCallFragment: BaseCallFragment() {
             state: Call.State,
             message: String
         ) {
+            Log.e(TAG, "received call state: $state, ${call.remoteAddress.displayName}, $message")
             if (state == Call.State.IncomingReceived) {
                 //来电时将自动接听
                 if (sipCore != null) {
@@ -118,7 +119,6 @@ class SipCallFragment: BaseCallFragment() {
                 }
 
                 VoiceUtil.handoffAudioCall(Constant.DEVICE_ID, fromId, interactionVO?.id)
-                callTerminate()
                 callEnd()
             } else {
                 Constant.CALL_STATE = Constant.CALL_STANDBY
@@ -241,6 +241,8 @@ class SipCallFragment: BaseCallFragment() {
                 sip_voice_call_timer.stop()
             }
 
+            callTerminate()
+
             Log.e(TAG, "call end !!!!!!!!!!!!!!!!!!")
 
             backToMain()
@@ -280,18 +282,19 @@ class SipCallFragment: BaseCallFragment() {
                                 Constant.interactionId = curInteractionVO.id
                                 fromId = curTcpModel.fromId
                                 acceptCall()
-                                if (sipCore == null && TextUtils.isEmpty(curInteractionVO.toSipId)) {
+                                if (sipCore == null || TextUtils.isEmpty(curInteractionVO.toSipId)) {
                                     //通话失败,重置并返回主界面
                                     showMessage("Core或targetSipId为空!")
                                     Constant.CALL_STATE = Constant.CALL_STANDBY
                                     VoiceUtil.handoffAudioCall(Constant.DEVICE_ID, fromId, Constant.interactionId)
                                     callEnd()
                                 } else {
-                                    val addressToCall = sipCore!!.interpretUrl("3305")
+                                    val addressToCall = sipCore!!.interpretUrl(curInteractionVO.toSipId)
                                     val params = sipCore!!.createCallParams(null)
                                     params.enableVideo(false)
                                     if (addressToCall != null) {
                                         sipCore!!.inviteAddressWithParams(addressToCall, params)
+                                        Log.d(TAG, "invite target device: " + addressToCall.asString())
                                     }
                                 }
                             } else if (curTcpModel.getAction() == TcpAction.VoiceAction.REJECT) {
@@ -355,7 +358,6 @@ class SipCallFragment: BaseCallFragment() {
                     } else if (serialAction.equals("handoff")) {
                         Constant.CALL_STATE = Constant.CALL_STANDBY
                         VoiceUtil.handoffAudioCall(Constant.DEVICE_ID, fromId, Constant.interactionId)
-                        callTerminate()
                         callEnd()
                     } else if (serialAction.equals("reject")) {
                         RingPlayHelper.stopRingTone()

+ 5 - 5
callingbed/src/main/res/layout/qrcode_view.xml

@@ -27,7 +27,7 @@
                 android:id="@+id/tv_device_id"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:layout_marginLeft="40dp"
+                android:layout_marginLeft="10dp"
                 android:text="设备ID:"
                 android:textColor="@color/black"
                 android:textSize="20sp" />
@@ -37,7 +37,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_marginTop="4dp"
-                android:layout_marginLeft="40dp"
+                android:layout_marginLeft="10dp"
                 android:text="本机IP:"
                 android:textColor="@color/black"
                 android:textSize="20sp" />
@@ -47,7 +47,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_marginTop="4dp"
-                android:layout_marginLeft="40dp"
+                android:layout_marginLeft="10dp"
                 android:text="本机MAC:"
                 android:textColor="@color/black"
                 android:textSize="20sp" />
@@ -57,7 +57,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_marginTop="4dp"
-                android:layout_marginLeft="40dp"
+                android:layout_marginLeft="10dp"
                 android:text="版本信息:"
                 android:textColor="@color/black"
                 android:textSize="20sp" />
@@ -67,7 +67,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_marginTop="4dp"
-                android:layout_marginLeft="40dp"
+                android:layout_marginLeft="10dp"
                 android:text="MCU:"
                 android:textColor="@color/black"
                 android:textSize="20sp" />

+ 29 - 90
middleware/src/main/code/com/wdkl/ncs/android/middleware/model/dos/DeviceDO.java

@@ -7,12 +7,11 @@ import com.wdkl.ncs.android.middleware.model.annotation.Id;
 import com.wdkl.ncs.android.middleware.model.annotation.PrimaryKeyField;
 import com.wdkl.ncs.android.middleware.model.annotation.Table;
 
+import java.io.Serializable;
+
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
-import java.io.Serializable;
-import java.util.Objects;
-
 @Table(name = "ncs_device")
 @ApiModel
 @JsonNaming(value = PropertyNamingStrategy.SnakeCaseStrategy.class)
@@ -64,7 +63,7 @@ public class DeviceDO implements Serializable {
      * 注册设备类型:1:护士主机  2:医生主机  3:门口机  4:病床分机 5:LCD走廊屏  6:LED点阵屏  7:护士腕表  8:护工腕表  9:病人腕表  10:手机App
      */
     @Column(name = "device_type")
-    @ApiModelProperty(value = "注册设备类型:1:护士主机  2:医生主机  3:门口机  4:病床分机 5:LCD走廊屏  6:LED点阵屏  7:移动设备  8:护工腕表  9:病人腕表  10:手机App", required = false)
+    @ApiModelProperty(value = "注册设备类型:1:护士主机  2:医生主机  3:门口机  4:病床分机 5:LCD走廊屏  6:LED点阵屏  7:护士腕表  8:护工腕表  9:病人腕表  10:手机App", required = false)
     private Integer deviceType;
     /**
      * 注册设备出厂编号
@@ -109,10 +108,9 @@ public class DeviceDO implements Serializable {
     @ApiModelProperty(value = "该设备的有线以太网卡分配的IP地址", required = false)
     private String ethIp;
     /**
-     * 该设备的有线以太网卡分配的IP地址端口
-     */
-    @Column(name = "eth_ip_port")
-    @ApiModelProperty(value = "该设备的有线以太网卡分配的IP地址端口", required = false)
+     *	该设备的有线以太网卡分配的IP地址端口
+     */	@Column(name = "eth_ip_port" )
+    @ApiModelProperty(value="该设备的有线以太网卡分配的IP地址端口",required=false)
     private String ethIpPort;
     /**
      * 该设备的WIFI网卡MAC地址
@@ -171,38 +169,28 @@ public class DeviceDO implements Serializable {
     /**
      * null
      */
-    @Column(name = "member_id", allowNullUpdate = true)
+    @Column(name = "member_id")
     @ApiModelProperty(value = "null", required = false)
     private Integer memberId;
     /**
-     * 是否为后备,空或否时为并行
-     */
-    @Column(name = "bool_backup")
-    @ApiModelProperty(value = "是否为后备,空或否时为并行", required = false)
+     *	是否为后备,空或否时为并行
+     */	@Column(name = "bool_backup" )
+    @ApiModelProperty(value="是否为后备,空或否时为并行",required=false)
     private Boolean boolBackup;
     /**
-     * 后备哪个设备,设备id
-     */
-    @Column(name = "backup_id")
-    @ApiModelProperty(value = "后备哪个设备,设备id", required = false)
+     *	后备哪个设备,设备id
+     */	@Column(name = "backup_id" )
+    @ApiModelProperty(value="后备哪个设备,设备id",required=false)
     private Integer backupId;
     /**
-     * null
-     */
-    @Column(name = "priority")
-    @ApiModelProperty(value = "null", required = false)
+     *	null
+     */	@Column(name = "priority" )
+    @ApiModelProperty(value="null",required=false)
     private Integer priority;
 
-    @Column(name = "config")
-    @ApiModelProperty(value = "设备配置信息,看板设备有配置内容,已json格式存储", required = false)
-    private String config; //
-
-    /**
-     * roleId
-     */
-    @Column(name = "role_id", allowNullUpdate = true)
-    @ApiModelProperty(value = "roleId", required = false)
-    private Integer roleId;
+    @Column(name = "full_name")
+    @ApiModelProperty(value = "病房病床名称", required = false)
+    private String fullName; // 空间结构全名
 
 
     @PrimaryKeyField
@@ -241,6 +229,7 @@ public class DeviceDO implements Serializable {
         this.updateTime = updateTime;
     }
 
+
     public Integer getPartId() {
         return partId;
     }
@@ -409,6 +398,7 @@ public class DeviceDO implements Serializable {
         this.sipId = sipId;
     }
 
+
     public String getSipPassword() {
         return sipPassword;
     }
@@ -451,6 +441,14 @@ public class DeviceDO implements Serializable {
         this.backupId = backupId;
     }
 
+    public String getFullName() {
+        return fullName;
+    }
+
+    public void setFullName(String fullName) {
+        this.fullName = fullName;
+    }
+
     public Integer getPriority() {
         return priority;
     }
@@ -458,63 +456,4 @@ public class DeviceDO implements Serializable {
     public void setPriority(Integer priority) {
         this.priority = priority;
     }
-
-    public Integer getRoleId() {
-        return roleId;
-    }
-
-    public void setRoleId(Integer roleId) {
-        this.roleId = roleId;
-    }
-
-    public String getConfig() {
-        return config;
-    }
-
-    public void setConfig(String config) {
-        this.config = config;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-        DeviceDO deviceDO = (DeviceDO) o;
-        return Objects.equals(id, deviceDO.id) &&
-                Objects.equals(unionId, deviceDO.unionId) &&
-                Objects.equals(createTime, deviceDO.createTime) &&
-                Objects.equals(updateTime, deviceDO.updateTime) &&
-                Objects.equals(partId, deviceDO.partId) &&
-                Objects.equals(syncTime, deviceDO.syncTime) &&
-                Objects.equals(frameId, deviceDO.frameId) &&
-                Objects.equals(deviceType, deviceDO.deviceType) &&
-                Objects.equals(code, deviceDO.code) &&
-                Objects.equals(model, deviceDO.model) &&
-                Objects.equals(softVer, deviceDO.softVer) &&
-                Objects.equals(hardVer, deviceDO.hardVer) &&
-                Objects.equals(name, deviceDO.name) &&
-                Objects.equals(ethMac, deviceDO.ethMac) &&
-                Objects.equals(ethIp, deviceDO.ethIp) &&
-                Objects.equals(ethIpPort, deviceDO.ethIpPort) &&
-                Objects.equals(wifiMac, deviceDO.wifiMac) &&
-                Objects.equals(wifiIp, deviceDO.wifiIp) &&
-                Objects.equals(wifiHostname, deviceDO.wifiHostname) &&
-                Objects.equals(wifiPassword, deviceDO.wifiPassword) &&
-                Objects.equals(status, deviceDO.status) &&
-                Objects.equals(sipIp, deviceDO.sipIp) &&
-                Objects.equals(sipId, deviceDO.sipId) &&
-                Objects.equals(sipPassword, deviceDO.sipPassword) &&
-                Objects.equals(sipStatus, deviceDO.sipStatus) &&
-                Objects.equals(memberId, deviceDO.memberId) &&
-                Objects.equals(boolBackup, deviceDO.boolBackup) &&
-                Objects.equals(backupId, deviceDO.backupId) &&
-                Objects.equals(priority, deviceDO.priority) &&
-                Objects.equals(config, deviceDO.config) &&
-                Objects.equals(roleId, deviceDO.roleId);
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(id, unionId, createTime, updateTime, partId, syncTime, frameId, deviceType, code, model, softVer, hardVer, name, ethMac, ethIp, ethIpPort, wifiMac, wifiIp, wifiHostname, wifiPassword, status, sipIp, sipId, sipPassword, sipStatus, memberId, boolBackup, backupId, priority, config, roleId);
-    }
 }

+ 13 - 1
middleware/src/main/code/com/wdkl/ncs/android/middleware/model/vo/BedDeviceInfoVO.java

@@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty;
  * @create: 2021/04/06 11:09
  */
 
-public class BedDeviceInfoVO extends DeviceVO {
+public class BedDeviceInfoVO extends DeviceDO {
 
     @Column(name = "hospital_id")
     @ApiModelProperty(value = "医院id", required = false)
@@ -30,6 +30,10 @@ public class BedDeviceInfoVO extends DeviceVO {
     @ApiModelProperty(value = "病人id", required = false)
     private Integer customerId;
 
+    @Column(name = "part_display")
+    @ApiModelProperty(value = "科室显示名称(科室全称字段)", required = false)
+    private String partDisplay;
+
     public Integer getHospitalId() {
         return hospitalId;
     }
@@ -61,4 +65,12 @@ public class BedDeviceInfoVO extends DeviceVO {
     public void setCustomerId(Integer customerId) {
         this.customerId = customerId;
     }
+
+    public String getPartDisplay() {
+        return partDisplay;
+    }
+
+    public void setPartDisplay(String partDisplay) {
+        this.partDisplay = partDisplay;
+    }
 }

+ 12 - 3
welcome/src/main/AndroidManifest.xml

@@ -1,13 +1,22 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
           package="com.enation.javashop.android.welcome">
 
+    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
+
     <application
         android:allowBackup="true"
         android:label="@string/app_name"
         android:supportsRtl="true">
-        <activity android:name="com.wdkl.ncs.android.component.welcome.activity.WelcomeActivity"
-            >
-        </activity>
+
+        <receiver
+            android:name="com.wdkl.ncs.android.component.welcome.receiver.WdBootReceiver"
+            android:enabled="true"
+            android:exported="true">
+            <intent-filter android:priority="1000">
+                <action android:name="android.intent.action.BOOT_COMPLETED"/>
+            </intent-filter>
+        </receiver>
+
     </application>
 </manifest>
 

+ 0 - 9
welcome/src/main/ApkBuildDir/AndroidManifest.xml

@@ -8,15 +8,6 @@
         android:theme="@style/Theme.AppCompat.Light.NoActionBar"
         android:name="apkbuild.WelcomeApplication"
         android:supportsRtl="true">
-        <activity android:name="com.wdkl.ncs.android.component.welcome.activity.WelcomeActivity"
-            android:theme="@style/AppSplash"
-            >
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN"/>
-
-                <category android:name="android.intent.category.LAUNCHER"/>
-            </intent-filter>
-        </activity>
     </application>
 </manifest>
 

+ 21 - 0
welcome/src/main/code/com/wdkl/ncs/android/component/welcome/receiver/WdBootReceiver.java

@@ -0,0 +1,21 @@
+package com.wdkl.ncs.android.component.welcome.receiver;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+import com.wdkl.ncs.android.component.welcome.activity.WelcomeActivity;
+
+public class WdBootReceiver extends BroadcastReceiver {
+
+    @Override
+    public void onReceive(Context context, Intent intent) {
+        if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
+            Log.d("wdBoot", "收到开机广播,启动app");
+            Intent startIntent= new Intent(context, WelcomeActivity.class);
+            startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+            context.startActivity(startIntent);
+        }
+    }
+}