ソースを参照

跃朗门禁机

xunchuanzhi 4 ヶ月 前
コミット
c773ff2fd7

+ 11 - 9
app/build.gradle

@@ -17,7 +17,7 @@ kapt {
 android {
     compileSdkVersion target_sdk_version
     buildToolsVersion build_tools_version
-
+    ndkVersion '22.1.7171670'
     defaultConfig {
         applicationId "com.wdkl.ncs.entraceguard"
         minSdkVersion min_sdk_version
@@ -160,6 +160,8 @@ dependencies {
 
     compile project(':janus')
 
+    
+
 //    compile project(':webrtc')
 
 
@@ -173,17 +175,17 @@ dependencies {
     //compile project(':rtc-chat')
     //compile project(':keepalive')
 
-    // 旷世算法
-    implementation files('libs/FacePassAndroidSDK-McvSafe-release.aar')
-    implementation files('libs/mcvSafe.v1.2.2.aar')
+//    // 旷世算法
+//    implementation files('libs/FacePassAndroidSDK-McvSafe-release.aar')
+//    implementation files('libs/mcvSafe.v1.2.2.aar')
 
     //sip
     implementation files('libs/linphone-sdk-android-5.2.10.aar')
 
-    // 硬件 sdk
-    implementation 'io.github.jimmy-j:facesdk:2.0.19'
-    // todo 下面是主板依赖,需要开发人员根据更新系统类型切换,rk 表示 rk 主板,well 表示三星主板,如果依赖错误会 crash
-    // rk 主板依赖
-    implementation 'io.github.jimmy-j:rk-system:1.0.6'
+//    // 硬件 sdk
+//    implementation 'io.github.jimmy-j:facesdk:2.0.19'
+//    // todo 下面是主板依赖,需要开发人员根据更新系统类型切换,rk 表示 rk 主板,well 表示三星主板,如果依赖错误会 crash
+//    // rk 主板依赖
+//    implementation 'io.github.jimmy-j:rk-system:1.0.6'
 
 }

BIN
app/libs/FacePassAndroidSDK-McvSafe-release.aar


BIN
app/libs/mcvSafe.v1.2.2.aar


BIN
app/release/app-release.apk


+ 0 - 1
app/release/output.json

@@ -1 +0,0 @@
-[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":10,"versionName":"1.1.0_black","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]

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

@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
-    android:sharedUserId="android.uid.system"
     package="iot.facereco.smart.terminal">
 
     <uses-permission android:name="android.permission.CAMERA"/>
@@ -21,6 +20,8 @@
 
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
+    <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
+    <uses-permission android:name="android.permission.ROOT"/>
     <uses-permission android:name="android.permission.INTERNET"/>
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
     <uses-permission android:name="android.permission.ACCESS_DOWNLOAD_MANAGER"/>

+ 113 - 72
app/src/main/java/com/wdkl/ncs/entraceguard/activity/MainActivity.kt

@@ -9,10 +9,8 @@ import android.content.pm.PackageManager
 import android.media.AudioAttributes
 import android.media.AudioManager
 import android.media.SoundPool
-import android.os.Build
-import android.os.CountDownTimer
-import android.os.Handler
-import android.os.Looper
+import android.os.*
+import android.provider.Settings
 import android.text.TextUtils
 import android.util.Log
 import android.view.View
@@ -21,7 +19,6 @@ import androidx.annotation.RequiresApi
 import com.alibaba.fastjson.JSON
 import com.enation.javashop.net.engine.plugin.permission.RxPermissions
 import com.google.common.base.Strings
-import com.szeasco.facesdk.helper.GpioHelper
 import com.wdkl.ncs.entraceguard.adapter.NumAdapter
 import com.wdkl.ncs.entraceguard.contracts.MainActivityContract
 import com.wdkl.ncs.entraceguard.di.DaggerApplicationComponent
@@ -34,9 +31,7 @@ import com.wdkl.ncs.entraceguard.tcp.channel.EntraceGuardUtil
 import com.wdkl.ncs.entraceguard.tcp.dto.TcpModel
 import com.wdkl.ncs.entraceguard.tcp.enums.TcpAction
 import com.wdkl.ncs.entraceguard.tcp.enums.TcpType
-import com.wdkl.ncs.entraceguard.utils.AudioRouteUtils
-import com.wdkl.ncs.entraceguard.utils.LocaleMangerUtils
-import com.wdkl.ncs.entraceguard.utils.SettingConfig
+import com.wdkl.ncs.entraceguard.utils.*
 import com.wdkl.ncs.janus.client.CallSessionCallback
 import com.wdkl.ncs.janus.client.JanusClient
 import com.wdkl.ncs.janus.client.VideoRoomCallback
@@ -64,11 +59,11 @@ import org.greenrobot.eventbus.ThreadMode
 import org.linphone.core.*
 import org.linphone.mediastream.Version
 import org.webrtc.SurfaceViewRenderer
-import java.io.File
-import java.io.IOException
+import java.io.*
 import java.math.BigInteger
 import java.util.*
 
+
 class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(), MainActivityContract.View, CallSessionCallback /*IUserState, CallSession.CallSessionCallback*/ {
     val TAG = MainActivity::class.java.getSimpleName()
 
@@ -82,7 +77,7 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
                 .build()
     }
 
-    private var gpioHelper: GpioHelper? = null
+
     private var interactionVO: InteractionVO? = null
     private var tid: String? = ""
 
@@ -104,12 +99,15 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
     //sip
     private val START_SIPPHONE_LOGS = " ==== Device information dump ===="
     private var sipHandler: Handler? = null
-    private var sipTimer: Timer? = null
+    private var sipTimer: Timer?  =null
 
     private var mCore: Core? = null
     private var mCoreListener: CoreListenerStub? = null
     private var mAccountCreator: AccountCreator? = null
 
+
+
+
     override fun getLayId(): Int {
         return R.layout.activity_main
     }
@@ -124,25 +122,26 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
     @RequiresApi(Build.VERSION_CODES.N)
     override fun init() {
         //猫瞳默认已经给了权限
-        /*Observable.just("").compose(
-            RxPermissions(this).ensure(
-                Manifest.permission.CAMERA,
-                Manifest.permission.READ_EXTERNAL_STORAGE,
-                Manifest.permission.WRITE_EXTERNAL_STORAGE,
-                Manifest.permission.ACCESS_WIFI_STATE,
-                Manifest.permission.BLUETOOTH,
-                Manifest.permission.RECORD_AUDIO
-            )
+        Observable.just("").compose(
+                RxPermissions(this).ensure(
+                        Manifest.permission.CAMERA,
+                        Manifest.permission.READ_EXTERNAL_STORAGE,
+                        Manifest.permission.WRITE_EXTERNAL_STORAGE,
+                        Manifest.permission.ACCESS_WIFI_STATE,
+                        Manifest.permission.BLUETOOTH,
+                        Manifest.permission.RECORD_AUDIO
+                )
         ).subscribe {
             if (it) {
                 permissionGrant()
             } else {
-                showMessage("请重新授权!")
+                showMessage(R.string.str_accredit)
             }
-        }.joinManager(disposableManager)*/
+        }.joinManager(disposableManager)
+
 
 
-        permissionGrant()
+//        permissionGrant()
     }
 
     @RequiresApi(Build.VERSION_CODES.N)
@@ -154,14 +153,12 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
             tv_voice_type.text = "RTC"
         }
 
-        Constants.imei = Build.SERIAL
+        Constants.imei = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
         passSoundID = mSoundPool.load(this, R.raw.pass, 1)
         strangerSoundID = mSoundPool.load(this, R.raw.not_allow, 1)
-        // 门禁SDK
-        gpioHelper = GpioHelper.getInstance()
 
         if(!NetHelper.getInstance().netAvailable){
-            showTipView(R.drawable.net_inavailable,R.string.no_network, true, 5000)
+            showTipView(R.drawable.net_inavailable, R.string.no_network, true, 5000)
             //exitApp(5000)
         }else {
             //获取tcp服务器信息
@@ -192,10 +189,10 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
         //主监听器,根据事件调用界面
         mCoreListener = object : CoreListenerStub() {
             override fun onCallStateChanged(
-                core: Core,
-                call: Call,
-                state: Call.State,
-                message: String
+                    core: Core,
+                    call: Call,
+                    state: Call.State,
+                    message: String
             ) {
                 if (!SettingConfig.getSipEnabled(BaseApplication.appContext)) {
                     return
@@ -217,10 +214,10 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
             }
 
             override fun onRegistrationStateChanged(
-                core: Core,
-                cfg: ProxyConfig,
-                state: RegistrationState,
-                message: String
+                    core: Core,
+                    cfg: ProxyConfig,
+                    state: RegistrationState,
+                    message: String
             ) {
                 if (!SettingConfig.getSipEnabled(BaseApplication.appContext)) {
                     return
@@ -300,7 +297,6 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
 
     override fun initDevice(deviceDO: DeviceDO) {
         responseCountDownTimer.cancel()
-
         Log.i("设备信息:", JSON.toJSONString(deviceDO))
         if (!Strings.isNullOrEmpty(deviceDO.sipId)&&deviceDO.status.equals(1)) {
             Constants.sipId = deviceDO.sipId
@@ -350,7 +346,7 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
 
             TcpClient.getInstance().sendMsg(EntraceGuardUtil.startVisit(Constants.deviceId).toJson())
         }else{
-            showTipView(R.drawable.unregister,R.string.device_unregister, true, 3000)
+            showTipView(R.drawable.unregister, R.string.device_unregister, true, 3000)
             //exitApp(3000)
         }
     }
@@ -384,6 +380,7 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
                             interactionVO = JSON.parseObject(tcpModel.data.toString(), InteractionVO::class.java)
 
                             RingPlayHelper.playRingTone(this, R.raw.alice, true)
+                            GpioController.writeGpioValue3(1)
 
                             if (SettingConfig.getSipEnabled(activity)) {
                                 //发起sip视频请求
@@ -391,6 +388,16 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
                                     val addressToCall = mCore!!.interpretUrl(interactionVO!!.toSipId)
                                     val params = mCore!!.createCallParams(null)
                                     params?.isVideoEnabled = true
+//                                    val videoDevices = mCore!!.videoDevicesList
+//
+//                                    // 选择第一个摄像头(可以根据需要选择其他摄像头)
+//                                    val selectedDevice = videoDevices.getOrNull(2)
+//                                    Log.d(TAG, ">>>>>>>>>>> selectedDevice: 2" )
+//
+//                                    // 设置摄像头
+//                                    if (selectedDevice != null) {
+//                                        mCore!!.videoDevice = selectedDevice
+//                                    }
 
                                     if (addressToCall != null) {
                                         mCore!!.inviteAddressWithParams(addressToCall, params!!)
@@ -400,20 +407,25 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
                             }
                         }
 
-                        TcpAction.EntraceGuardAction.FAILED ->{  //护士主机不在线
+                        TcpAction.EntraceGuardAction.FAILED -> {  //护士主机不在线
                             //取消响应计时
                             responseCountDownTimer.cancel()
-                            showTipView(R.drawable.host_offline,R.string.call_failed, false, 3000)
+                            showTipView(R.drawable.host_offline, R.string.call_failed, false, 3000)
                             //exitApp(3000)
+                            GpioController.writeGpioValue3(0)
+                            GpioController.writeGpioValue5(1)
                         }
 
 
                         TcpAction.EntraceGuardAction.UNLOCKDOOR -> { //开门指令
                             //停止等待音乐,停止倒计时
                             cancelCountDownTimer()
+
                             // 通过,亮起绿色灯光,并开门
-                            gpioHelper!!.setPassStatus(true)
-                            gpioHelper!!.setWhiteLedStatus(true)
+                            GpioController.writeGpioValue3(0)
+                            GpioController.writeGpioValue4(1)
+                            GpioController.writeGpioValue6(1)
+
                             //结束通话
                             if (SettingConfig.getSipEnabled(activity)) {
                                 sipCallTerminate()
@@ -422,7 +434,7 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
                                 janusClient!!.disConnect()
                             }
 
-                            showTipView(R.drawable.allow_in,R.string.door_opened, false, 10000)
+                            showTipView(R.drawable.allow_in, R.string.door_opened, false, 10000)
                             play(passSoundID!!)
 
                             //10秒后退出程序,调起门禁默认应用
@@ -430,9 +442,11 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
 
                         }
 
-                        TcpAction.EntraceGuardAction.REJECT ->{
+                        TcpAction.EntraceGuardAction.REJECT -> {
                             //停止等待音乐,停止倒计时
                             cancelCountDownTimer()
+                            GpioController.writeGpioValue3(0)
+                            GpioController.writeGpioValue5(1)
 
                             if (SettingConfig.getSipEnabled(activity)) {
                                 sipCallTerminate()
@@ -441,7 +455,7 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
                                 janusClient!!.disConnect()
                             }
 
-                            showTipView(R.drawable.busyline,R.string.call_busy, false, 3000)
+                            showTipView(R.drawable.busyline, R.string.call_busy, false, 3000)
                             play(strangerSoundID!!)
 
                             //3秒后退出程序
@@ -450,8 +464,10 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
                         }
                         TcpAction.EntraceGuardAction.LOCKDOOR -> {
                             // 陌生人,亮起红外灯光
-                            gpioHelper!!.setPassStatus(false)
                             play(strangerSoundID!!)
+                            GpioController.writeGpioValue3(0)
+                            GpioController.writeGpioValue5(1)
+
                         }
 
                         TcpAction.EntraceGuardAction.OPENSPEAKER -> { //打开音频
@@ -493,7 +509,10 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
                             }
 
                             play(strangerSoundID!!)
-                            showTipView(R.drawable.not_allow,R.string.not_allowed, false, 3000)
+                            GpioController.writeGpioValue3(0)
+                            GpioController.writeGpioValue5(1)
+
+                            showTipView(R.drawable.not_allow, R.string.not_allowed, false, 3000)
 
                             //3秒后退出程序
                             //exitApp(3000)
@@ -512,20 +531,20 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
 
                 }
             }
-            Constants.TIME->{
+            Constants.TIME -> {
                 var tcpModel = messageEvent.getMessage() as TcpModel
-                if(tcpModel.type.equals(TcpType.TIME)&&tcpModel.action.equals(TcpAction.TimeAction.SYNC)){
+                if (tcpModel.type.equals(TcpType.TIME) && tcpModel.action.equals(TcpAction.TimeAction.SYNC)) {
                     var time = 0L
                     var timeZone = "Asia/Shanghai"
-                    if(canPaseJson(tcpModel.data.toString())){
+                    if (canPaseJson(tcpModel.data.toString())) {
                         var json = JSON.parseObject(tcpModel.data.toString())
-                        time=json.getLong("time")*1000+200
-                        timeZone=json.getString("time_zone")
-                    }else {
-                        time = tcpModel.data.toString().toLong()*1000+200
+                        time = json.getLong("time") * 1000 + 200
+                        timeZone = json.getString("time_zone")
+                    } else {
+                        time = tcpModel.data.toString().toLong() * 1000 + 200
                     }
                     (this.getSystemService(Context.ALARM_SERVICE) as AlarmManager).setTime(time)
-                    (this.getSystemService(Context.ALARM_SERVICE) as AlarmManager).setTimeZone(timeZone)
+//                    (this.getSystemService(Context.ALARM_SERVICE) as AlarmManager).setTimeZone(timeZone)
                 }
             }
         }
@@ -550,12 +569,9 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
     private fun exitApp(delay: Long) {
         if (delay > 0) {
             handler.postDelayed({
-                //关闭灯光,闭合继电器
-                gpioHelper!!.ledDismiss(false);
-
                 try {
                     val packageManager: PackageManager = packageManager
-                    val intent: Intent = packageManager.getLaunchIntentForPackage("com.rlapk")
+                    val intent: Intent = packageManager.getLaunchIntentForPackage("org.zg.app")
                     startActivity(intent)
                 } catch (e: Exception) {
                     e.printStackTrace()
@@ -565,11 +581,11 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
             }, delay)
         } else {
             //关闭灯光,闭合继电器
-            gpioHelper!!.ledDismiss(false);
+
 
             try {
                 val packageManager: PackageManager = packageManager
-                val intent: Intent = packageManager.getLaunchIntentForPackage("com.rlapk")
+                val intent: Intent = packageManager.getLaunchIntentForPackage("org.zg.app")
                 startActivity(intent)
             } catch (e: Exception) {
                 e.printStackTrace()
@@ -607,7 +623,7 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
                 //呼叫超时,返回到主界面
                 callFinish()
 
-                showTipView(R.drawable.no_reponse,R.string.call_no_response, false, 3000)
+                showTipView(R.drawable.no_reponse, R.string.call_no_response, false, 3000)
                 //exitApp(3000)
             }
         }
@@ -626,7 +642,7 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
 
            }
            override fun onFinish() {
-               showTipView(R.drawable.no_reponse,R.string.call_no_response, true, 3000)
+               showTipView(R.drawable.no_reponse, R.string.call_no_response, true, 3000)
                //exitApp(3000)
            }
        }
@@ -720,7 +736,6 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
                 } else {
                     //保存配置
                     CommonUtils.setUrl(BaseApplication.appContext, url)
-
                     Toast.makeText(activity, R.string.str_save, Toast.LENGTH_SHORT).show()
                 }
             }
@@ -767,6 +782,10 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
 
     }
 
+
+
+
+
     override fun didCreateLocalVideoTrack() {
         runOnUiThread {
             if (localSurfaceView == null) {
@@ -823,18 +842,18 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
 
         if (enable) {
             audioManager.setStreamVolume(
-                AudioManager.MODE_IN_COMMUNICATION,
-                audioManager.getStreamMaxVolume(AudioManager.MODE_IN_COMMUNICATION),
-                AudioManager.FX_KEY_CLICK
+                    AudioManager.MODE_IN_COMMUNICATION,
+                    audioManager.getStreamMaxVolume(AudioManager.MODE_IN_COMMUNICATION),
+                    AudioManager.FX_KEY_CLICK
             )
             audioManager.setSpeakerphoneOn(true)
 
             AudioRouteUtils.routeAudioToSpeaker(mCore!!)
         } else {
             audioManager.setStreamVolume(
-                AudioManager.STREAM_MUSIC,
-                audioManager.getStreamVolume(AudioManager.STREAM_MUSIC),
-                AudioManager.FX_KEY_CLICK
+                    AudioManager.STREAM_MUSIC,
+                    audioManager.getStreamVolume(AudioManager.STREAM_MUSIC),
+                    AudioManager.FX_KEY_CLICK
             )
             audioManager.setSpeakerphoneOn(false)
 
@@ -885,6 +904,28 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
             Log.i("sipCall", ">>>>>>>>>>>>>>>>>2 " + pt.getMimeType() + " = " + pt.enabled())
         }
         mCore?.setAudioPayloadTypes(payloads)
+
+        val videoCodecs = mCore!!.videoPayloadTypes
+        if (videoCodecs != null) {
+            val h264Codecs = videoCodecs.filter { it.mimeType == "H264" }
+            // 将 h264Codecs 转换为数组
+            val h264CodecsArray = h264Codecs.toTypedArray()
+            if (h264CodecsArray.isNotEmpty()) {
+                mCore?.setVideoPayloadTypes(h264CodecsArray)
+                Log.i("sipCall", "Set video payload types to H264 codecs.")
+            } else {
+                Log.w("sipCall", "No H264 codecs found.")
+            }
+//            for (i in videoCodecs.indices) {
+//                val pt = videoCodecs[i]
+//                if (pt.mimeType == "H264") {
+//                    mCore?.setVideoPayloadTypes(videoCodecs)
+//                }
+//                Log.i("sipCall", ">>>>>>>>>>>>>>>>>2 " + pt.getMimeType() + " = " + pt.enabled())
+//            }
+        }
+
+
     }
 
     private fun dumpDeviceInformation() {
@@ -910,8 +951,8 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
         }
         if (info != null) {
             Log.i(TAG,
-                "[Service] sipphone version is " +
-                info.versionName + " (" + info.versionCode + ")"
+                    "[Service] sipphone version is " +
+                            info.versionName + " (" + info.versionCode + ")"
             )
         } else {
             Log.i(TAG, "[Service] sipphone version is unknown")

+ 7 - 9
app/src/main/java/com/wdkl/ncs/entraceguard/application/Application.java

@@ -1,7 +1,5 @@
 package com.wdkl.ncs.entraceguard.application;
 
-import com.szeasco.facesdk.FaceSdkApplication;
-import com.szeasco.facesdk.config.FaceSdkConfig;
 import com.wdkl.ncs.middleware.base.BaseApplication;
 import com.wdkl.ncs.middleware.helper.NetHelper;
 
@@ -10,15 +8,15 @@ public class Application extends BaseApplication {
     public void onCreate() {
         super.onCreate();
         initFrame();
-        initFaceSDK();
+//        initFaceSDK();
     }
 
-    private void initFaceSDK() {
-        FaceSdkConfig config = new FaceSdkConfig(true, this);
-        config.setDeviceNumber(android.os.Build.SERIAL);
-        FaceSdkApplication.initFaceSDKApplication(config);
-        FaceSdkApplication.Companion.version();
-    }
+//    private void initFaceSDK() {
+//        FaceSdkConfig config = new FaceSdkConfig(true, this);
+//        config.setDeviceNumber(android.os.Build.SERIAL);
+//        FaceSdkApplication.initFaceSDKApplication(config);
+//        FaceSdkApplication.Companion.version();
+//    }
 
     private void initFrame() {
         //init

+ 169 - 0
app/src/main/java/com/wdkl/ncs/entraceguard/utils/GpioController.java

@@ -0,0 +1,169 @@
+package com.wdkl.ncs.entraceguard.utils;
+
+import java.io.BufferedWriter;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.OutputStream;
+
+public class GpioController {
+
+
+    //上面红外补光灯
+    private static final String GPIO_EXPORT_PATH_2 = "/sys/class/gpio/gpio150/value";
+    //底下白灯
+    private static final String GPIO_EXPORT_PATH_3 = "/sys/class/gpio/gpio56/value";
+    //底下绿灯
+    private static final String GPIO_EXPORT_PATH_4 = "/sys/class/gpio/gpio35/value";
+    //底下红灯
+    private static final String GPIO_EXPORT_PATH_5 = "/sys/class/gpio/gpio52/value";
+    //继电器
+    private static final String GPIO_EXPORT_PATH_6 = "/sys/class/gpio/gpio152/value";
+    //上面白色补光灯
+    private static final String GPIO_EXPORT_PATH = "/sys/class/gpio/gpio149/value";
+
+
+
+    // 上面白色补光灯
+    public static void writeGpioValue(int value) {
+        try {
+            FileWriter valueFile = new FileWriter(GPIO_EXPORT_PATH);
+            valueFile.write(String.valueOf(value));
+            valueFile.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    // 上面红外补光灯
+    public static void writeGpioValue2(int value) {
+        try {
+            FileWriter valueFile = new FileWriter(GPIO_EXPORT_PATH_2);
+            valueFile.write(String.valueOf(value));
+            valueFile.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    // 底下白灯
+    public static void writeGpioValue3(int value) {
+        try {
+            FileWriter valueFile = new FileWriter(GPIO_EXPORT_PATH_3);
+            valueFile.write(String.valueOf(value));
+            valueFile.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+    // 底下绿灯
+//    public static void writeGpioValue4(int value) {
+//        try {
+//            BufferedWriter bufWriter = null;
+//            bufWriter = new BufferedWriter(new FileWriter(GPIO_EXPORT_PATH_4));
+//            bufWriter.write(String.valueOf(value));  // 写操作
+//            bufWriter.close();
+//        } catch (IOException e) {
+//            e.printStackTrace();
+//        }
+//    }
+//    public static void write(String data) {
+//        OutputStream os = null;
+//        try {
+//            os = new FileOutputStream(new File("/sys/class/gpio/gpio149/value"));
+//            os.write(data.getBytes(), 0, data.length());
+//        } catch (IOException e) {
+//            e.printStackTrace();
+//        }finally{
+//            try {
+//                os.close();
+//            } catch (IOException e) {
+//                e.printStackTrace();
+//            } catch (NullPointerException e) {
+//                e.printStackTrace();
+//            }
+//        }
+//    }
+    // 底下绿灯
+    public static void writeGpioValue4(int value) {
+        try {
+            FileWriter valueFile = new FileWriter(GPIO_EXPORT_PATH_4);
+            valueFile.write(String.valueOf(value));
+            valueFile.close();
+            Thread.sleep(1000);
+            // 关闭GPIO
+            FileWriter valueFileOff = new FileWriter(GPIO_EXPORT_PATH_4);
+            valueFileOff.write(String.valueOf(0)); // 关闭
+            valueFileOff.close();
+        } catch (IOException | InterruptedException e) {
+            e.printStackTrace();
+        }
+    }
+
+    // 底下红灯
+    public static void writeGpioValue5(int value) {
+        try {
+            FileWriter valueFile = new FileWriter(GPIO_EXPORT_PATH_5);
+            valueFile.write(String.valueOf(value));
+            valueFile.close();
+            // 延迟1秒后关闭
+            Thread.sleep(1000);
+            // 关闭GPIO
+            FileWriter valueFileOff = new FileWriter(GPIO_EXPORT_PATH_5);
+            valueFileOff.write(String.valueOf(0)); // 关闭
+            valueFileOff.close();
+        } catch (IOException | InterruptedException e) {
+            e.printStackTrace();
+        }
+    }
+
+    // 继电器
+    public static void writeGpioValue6(int value) {
+        try {
+            FileWriter valueFile = new FileWriter(GPIO_EXPORT_PATH_6);
+            valueFile.write(String.valueOf(value));
+            valueFile.close();
+            Thread.sleep(2000);
+            // 关闭GPIO
+            FileWriter valueFileOff = new FileWriter(GPIO_EXPORT_PATH_6);
+            valueFileOff.write(String.valueOf(0)); // 关闭
+            valueFileOff.close();
+        } catch (IOException | InterruptedException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public static boolean writeGpioValue8() {    //打开
+        boolean FLAG =  RootCommand("echo 1 > /sys/class/gpio/gpio149/value");
+//        read_gpio0();
+        return FLAG;
+    }
+
+    //下面的是执行的方法
+    private static boolean RootCommand(String command) {
+        Process process = null;
+        DataOutputStream os = null;
+        try {
+            process = Runtime.getRuntime().exec("su");
+            os = new DataOutputStream(process.getOutputStream());
+            os.writeBytes(command + "\n");
+            os.writeBytes("exit\n");
+            os.flush();
+            process.waitFor();
+        } catch (Exception e) {
+            return false;
+        } finally {
+            try {
+                if (os != null) {
+                    os.close();
+                }
+                process.destroy();
+            } catch (Exception e) {
+            }
+        }
+        return true;
+    }
+
+}

BIN
app/src/main/res/raw-zh/not_allow.mp3


BIN
app/src/main/res/raw-zh/pass.mp3


BIN
app/src/main/res/raw/not_allow.mp3


BIN
app/src/main/res/raw/pass.mp3


+ 2 - 2
build.gradle

@@ -33,12 +33,12 @@ buildscript {
     /**
      * APP版本码
      */
-    ext.app_version_code = 11
+    ext.app_version_code = 12
 
     /**
      * APP版本号
      */
-    ext.app_version = "1.1.1_black"
+    ext.app_version = "1.1.3_black"
 
     repositories {
         /**

+ 16 - 9
janus/src/main/java/com/wdkl/ncs/janus/rtc/WebRTCEngine.java

@@ -346,17 +346,24 @@ public class WebRTCEngine {
         final String[] deviceNames = enumerator.getDeviceNames();
         Log.d(TAG, "createCameraCapture devices: " + deviceNames.length);
 
-        // First, try to find front facing camera
-        for (String deviceName : deviceNames) {
-            Log.d(TAG, "createCameraCapture device name: " + deviceName);
-            if (enumerator.isFrontFacing(deviceName)) {
-                enumerator.getSupportedFormats(deviceName);
-                VideoCapturer videoCapturer = enumerator.createCapturer(deviceName, null);
-                if (videoCapturer != null) {
-                    return videoCapturer;
-                }
+        if (deviceNames.length > 1) {
+            String camera1 = deviceNames[0]; // This would be camera 1
+            VideoCapturer videoCapturer = enumerator.createCapturer(camera1, null);
+            if (videoCapturer != null) {
+                return videoCapturer;
             }
         }
+        // First, try to find front facing camera
+//        for (String deviceName : deviceNames) {
+//            Log.d(TAG, "createCameraCapture device name: " + deviceName);
+//            if (enumerator.isFrontFacing(deviceName)) {
+//                enumerator.getSupportedFormats(deviceName);
+//                VideoCapturer videoCapturer = enumerator.createCapturer(deviceName, null);
+//                if (videoCapturer != null) {
+//                    return videoCapturer;
+//                }
+//            }
+//        }
 
         // Front facing camera not found, try something else
         for (String deviceName : deviceNames) {

+ 4 - 0
middleware/src/main/code/com/wdkl/ncs/middleware/utils/ExtendMethods.kt

@@ -57,6 +57,10 @@ fun errorLog(tag: String, message: String) {
     Log.e("【Tag -> $tag】 >>>>>>>>>>", "Message -> $message >>>>>>>>>>>>>>>>>>>>>>>>>> 【Location ->Class:${st.className} - Method:${st.methodName} - Line:${st.lineNumber}】 ")
 }
 
+fun showMessage(resId: Int) {
+    val msg = BaseApplication.appContext.getString(resId)
+    showMessage(msg)
+}
 /**
  * @author  LDD
  * @From   com.wdkl.ncs.android.lib.utils ExtendMethods.kt

+ 1 - 0
resource/src/main/res/values-es/strings.xml

@@ -22,6 +22,7 @@
     <string name="str_loading">Carga</string>
     <string name="str_yes">Sí</string>
     <string name="str_no">No</string>
+    <string name="str_accredit">Por favor, reautorice</string> <!-- Spanish -->
 
     <string name="setting_sip_enable">Enable SIP:</string>
 </resources>

+ 1 - 0
resource/src/main/res/values-ru/strings.xml

@@ -22,6 +22,7 @@
     <string name="str_loading">Загрузка</string>
     <string name="str_yes">Да</string>
     <string name="str_no">Нет</string>
+    <string name="str_accredit">Пожалуйста, переавторизуйтесь</string> <!-- Russian -->
 
     <string name="setting_sip_enable">Enable SIP:</string>
 </resources>

+ 1 - 0
resource/src/main/res/values-zh/strings.xml

@@ -23,5 +23,6 @@
     <string name="str_yes">是</string>
     <string name="str_no">否</string>
 
+    <string name="str_accredit">请重新授权</string>
     <string name="setting_sip_enable">启用SIP:</string>
 </resources>

+ 2 - 0
resource/src/main/res/values/strings.xml

@@ -22,6 +22,8 @@
     <string name="str_loading">Loading</string>
     <string name="str_yes">Yes</string>
     <string name="str_no">No</string>
+    <string name="str_accredit">Please reauthorize</string> <!-- English -->
+
 
     <string name="setting_sip_enable">Enable SIP:</string>
 </resources>

+ 16 - 10
rtc-chat/src/main/java/com/wdkl/skywebrtc/engine/webrtc/WebRTCEngine.java

@@ -644,18 +644,24 @@ public class WebRTCEngine implements IEngine, Peer.IPeerEvent {
     private VideoCapturer createCameraCapture(CameraEnumerator enumerator) {
         final String[] deviceNames = enumerator.getDeviceNames();
         Log.e(TAG, "createCameraCapture devices: " + deviceNames.length);
-
-        // First, try to find front facing camera
-        for (String deviceName : deviceNames) {
-            Log.e(TAG, "createCameraCapture device name: " + deviceName);
-            if (enumerator.isFrontFacing(deviceName)) {
-                VideoCapturer videoCapturer = enumerator.createCapturer(deviceName, null);
-
-                if (videoCapturer != null) {
-                    return videoCapturer;
-                }
+        if (deviceNames.length > 1) {
+            String camera1 = deviceNames[2]; // This would be camera 1
+            VideoCapturer videoCapturer = enumerator.createCapturer(camera1, null);
+            if (videoCapturer != null) {
+                return videoCapturer;
             }
         }
+        // First, try to find front facing camera
+//        for (String deviceName : deviceNames) {
+//            Log.e(TAG, "createCameraCapture device name: " + deviceName);
+//            if (enumerator.isFrontFacing(deviceName)) {
+//                VideoCapturer videoCapturer = enumerator.createCapturer(deviceName, null);
+//
+//                if (videoCapturer != null) {
+//                    return videoCapturer;
+//                }
+//            }
+//        }
 
         // Front facing camera not found, try something else
         for (String deviceName : deviceNames) {