# Conflicts: # app/src/main/java/com/aispeech/nativedemo/BaseMainActivity.java # app/src/main/java/com/aispeech/nativedemo/config/BaseConfig.java # app/src/main/java/com/aispeech/nativedemo/mqtt/BaseMqttConfig.javatags/v20231201
@@ -3,7 +3,7 @@ apply from: 'p_module.gradle' | |||
def VERSION_CODE = 3 | |||
def VERSION_NAME_LT = "LT.A.1.0.0.0_20231101_prod" | |||
def VERSION_NAME = "A.1.3.1.1_20231026" | |||
def VERSION_NAME = "A.2.3.0.0_20231103" | |||
def flag = "_inner_test" | |||
android { | |||
@@ -62,6 +62,7 @@ import com.aispeech.nativedemo.entity.EmpStrong; | |||
import com.aispeech.nativedemo.entity.PersonInfo; | |||
import com.aispeech.nativedemo.entity.Skill; | |||
import com.aispeech.nativedemo.face.FaceManager; | |||
import com.aispeech.nativedemo.face.IntroduceNewPartner; | |||
import com.aispeech.nativedemo.log.Logger; | |||
import com.aispeech.nativedemo.mqtt.MqttManager; | |||
import com.aispeech.nativedemo.network.NetworkStatusCallback; | |||
@@ -166,6 +167,14 @@ public class BaseMainActivity extends Activity implements DuiUpdateObserver.Upda | |||
private void initView() { | |||
mCaptureView = findViewById(R.id.capture_cl); | |||
mCaptureView.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View v) { | |||
FaceManager.getInstance().setIntroduceVisitor(false); | |||
IntroduceNewPartner.clearTimer(); | |||
setCaptureViewVisibility(View.GONE); | |||
} | |||
}); | |||
mCaptureInfo = findViewById(R.id.capture_info); | |||
mWebCore = findViewById(R.id.webCore); | |||
mWebCameraView = findViewById(R.id.web_camera); | |||
@@ -509,6 +518,7 @@ public class BaseMainActivity extends Activity implements DuiUpdateObserver.Upda | |||
webSettings.setLoadsImagesAutomatically(true); //支持自动加载图片 | |||
webSettings.setDefaultTextEncodingName("utf-8");//设置编码格式 | |||
webSettings.setDomStorageEnabled(true); | |||
//webSettings.setSaveFormData(false); | |||
webSettings.setMediaPlaybackRequiresUserGesture(false); | |||
mWebView2.loadUrl(getH5Url()); | |||
@@ -572,6 +582,7 @@ public class BaseMainActivity extends Activity implements DuiUpdateObserver.Upda | |||
private void initManager() { | |||
mWSManager = WebSocketManager.getInstance(getApplicationContext()); | |||
mWSManager.clearSocket(); | |||
mFaceManager = FaceManager.getInstance(); | |||
mFaceManager.setCallback(this); | |||
mCameraController = CameraController.getInstance(getApplicationContext()); | |||
@@ -598,36 +609,18 @@ public class BaseMainActivity extends Activity implements DuiUpdateObserver.Upda | |||
} | |||
showPersonRect(result, trackIds); | |||
// if(System.currentTimeMillis() - mDoaTime > 1000){ | |||
// mDoaTime = System.currentTimeMillis(); | |||
// int doa = 0; | |||
// if(bd_x != 0 && bd_x > 100){ | |||
// doa = 90 - (1080 - bd_x) / 25; | |||
// } | |||
// if(Math.abs(mDoa - doa) >= 5){ | |||
// if(doa > 50 && doa < 130){ | |||
// mDoa = doa; | |||
// try { | |||
// DDS.getInstance().getAgent().getWakeupEngine().setWakeupDoa(doa); | |||
// MessageUtils.sendDoa("define", doa); | |||
// } catch (DDSNotInitCompleteException e) { | |||
// throw new RuntimeException(e); | |||
// } | |||
// } | |||
// } | |||
// } | |||
} | |||
}); | |||
} | |||
private void showPersonRect(MultiAtt result, String trackIds) { | |||
float scale = 895f/2048f; | |||
float scale = 634f/2048f; | |||
float scaleY = 634f/1536f; | |||
int fwidth = (int) (result.fa_w * scale); | |||
int fheight = (int) (result.fa_h * scale); | |||
int fheight = (int) (result.fa_h * scaleY); | |||
int fx1 = (int) ((result.fa_x1 * scale) + mWebCameraView.getLeft()); | |||
int fy1 = (int) (result.fa_y1 * scale) + 810; | |||
int fy1 = (int) (result.fa_y1 * scaleY) + 449; | |||
ViewGroup.LayoutParams textureParams2 = mRectFaceView.getLayoutParams(); | |||
textureParams2.height = fheight; | |||
textureParams2.width = fwidth; | |||
@@ -647,9 +640,9 @@ public class BaseMainActivity extends Activity implements DuiUpdateObserver.Upda | |||
bd_x = (result.bd_x1 + result.bd_x2) / 2; | |||
int width = (int) (result.bd_w * scale); | |||
int height = (int) (result.bd_h * scale); | |||
int height = (int) (result.bd_h * scaleY); | |||
int x1 = (int) ((result.bd_x1 * scale) + mWebCameraView.getLeft()); | |||
int y1 = (int) (result.bd_y1 * scale) + 810; | |||
int y1 = (int) (result.bd_y1 * scaleY) + 449; | |||
ViewGroup.LayoutParams textureParams = mRectView.getLayoutParams(); | |||
textureParams.height = height; | |||
textureParams.width = width; | |||
@@ -668,9 +661,9 @@ public class BaseMainActivity extends Activity implements DuiUpdateObserver.Upda | |||
return; | |||
} | |||
int width = (int) (result.hd_w * scale); | |||
int height = (int) (result.hd_h * scale); | |||
int height = (int) (result.hd_h * scaleY); | |||
int x1 = (int) ((result.hd_x1 * scale) + mWebCameraView.getLeft()); | |||
int y1 = (int) (result.hd_y1 * scale) + 810; | |||
int y1 = (int) (result.hd_y1 * scaleY) + 449; | |||
ViewGroup.LayoutParams textureParams = mFaceFocusView.getLayoutParams(); | |||
textureParams.height = height; | |||
textureParams.width = width; | |||
@@ -680,7 +673,7 @@ public class BaseMainActivity extends Activity implements DuiUpdateObserver.Upda | |||
mFaceFocusView.setY(y1); | |||
mFaceFocusView.setLayoutParams(textureParams); | |||
mFaceFocusView.setBackground(xml3); | |||
mFaceFocusView.setText(trackIds); | |||
mFaceFocusView.setText(result.fa_x1 + "-" + result.fa_x2); | |||
//mFaceFocusView.setRotationY(180); | |||
} | |||
@@ -733,7 +726,7 @@ public class BaseMainActivity extends Activity implements DuiUpdateObserver.Upda | |||
initView(); | |||
initManager(); | |||
initDDS(); | |||
Log.e("testh", "main " + Thread.currentThread()); | |||
Log.e("testkit", "main " + Thread.currentThread() + " intent " + getIntent()); | |||
FaceManager.getInstance().setCameraTextureView(mTextureView); | |||
FaceManager.getInstance().startBackgroundThread(); | |||
@@ -748,6 +741,7 @@ public class BaseMainActivity extends Activity implements DuiUpdateObserver.Upda | |||
@Override | |||
protected void onNewIntent(Intent intent) { | |||
super.onNewIntent(intent); | |||
Log.e("testkit", "onNewIntent"); | |||
} | |||
@Override | |||
@@ -6,6 +6,7 @@ import android.graphics.Bitmap; | |||
import android.text.TextUtils; | |||
import android.util.Log; | |||
import com.aispeech.nativedemo.DuiApplication; | |||
import com.aispeech.nativedemo.MainActivity; | |||
import com.aispeech.nativedemo.asr.observer.DuiMessageObserver; | |||
import com.aispeech.nativedemo.config.Config; | |||
@@ -21,6 +22,7 @@ import com.aispeech.nativedemo.entity.Skill; | |||
import com.aispeech.nativedemo.entity.Stranger; | |||
import com.aispeech.nativedemo.log.Logger; | |||
import com.aispeech.nativedemo.network.ws.MessageUtils; | |||
import com.aispeech.nativedemo.network.ws.WebSocketManager; | |||
import com.aispeech.nativedemo.utils.BmpCompressUtils; | |||
import com.aispeech.nativedemo.utils.HttpUtil; | |||
import com.aispeech.nativedemo.utils.StatusUtils; | |||
@@ -719,13 +721,14 @@ public class FaceChatGreetingQueueMode implements ChatMode { | |||
continue; | |||
} | |||
if (!value.hasBeenGreeted && type > 0) { | |||
value.last_greet_time = time; | |||
value.hasBeenGreeted = true; | |||
if (type != NEED_LEAVE_GREETING_CUSTOM) { | |||
greetingResp = null; | |||
} | |||
Log.e("testtrack", "type " + greetingType+ " greetingResp " + greetingResp + " skill " + skill + " greeting emp eid " + value + " greeting duration " + (System.currentTimeMillis() - value.last_in_time)); | |||
sendGreeting(value, skill, greetingResp); | |||
if (sendGreeting(value, skill, greetingResp)) { | |||
value.last_greet_time = time; | |||
value.hasBeenGreeted = true; | |||
Log.e("testtrack", "type " + greetingType+ " greetingResp " + greetingResp + " skill " + skill + " greeting emp eid " + value + " greeting duration " + (System.currentTimeMillis() - value.last_in_time)); | |||
} | |||
return; | |||
} | |||
} | |||
@@ -743,19 +746,23 @@ public class FaceChatGreetingQueueMode implements ChatMode { | |||
} | |||
if (!value.hasBeenGreeted && (((time - value.last_in_time) >= UNKNOWN_GREETING_DURATION) || value.hasBeenIdentify) | |||
&& type > 0) { | |||
value.last_greet_time = time; | |||
value.hasBeenGreeted = true; | |||
Log.e("testtrack", "greeting trackId " + value.trackId + " old value " + value + " greeting duration " + (System.currentTimeMillis() - value.last_in_time)); | |||
if (type != NEED_LEAVE_GREETING_CUSTOM) { | |||
greetingResp = null; | |||
} | |||
sendGreeting(value, skill, greetingResp); | |||
if (sendGreeting(value, skill, greetingResp)) { | |||
value.last_greet_time = time; | |||
value.hasBeenGreeted = true; | |||
Log.e("testtrack", "greeting trackId " + value.trackId + " old value " + value + " greeting duration " + (System.currentTimeMillis() - value.last_in_time)); | |||
} | |||
break; | |||
} | |||
} | |||
} | |||
public void sendGreeting(PersonInfo message, Skill skill, String greetingLeaveResp) { | |||
public boolean sendGreeting(PersonInfo message, Skill skill, String greetingLeaveResp) { | |||
if (!WebSocketManager.getInstance(DuiApplication.getContext()).isSocketOpen()) { | |||
return false; | |||
} | |||
try { | |||
JSONObject obj = new JSONObject(); | |||
obj.put("type", "greeting"); | |||
@@ -814,6 +821,7 @@ public class FaceChatGreetingQueueMode implements ChatMode { | |||
} catch (JSONException e) { | |||
e.printStackTrace(); | |||
} | |||
return true; | |||
} | |||
public void sendStrangerToServer() { | |||
@@ -6,6 +6,7 @@ import android.util.Log; | |||
import android.view.View; | |||
import com.aispeech.nativedemo.MainActivity; | |||
import com.aispeech.nativedemo.R; | |||
import com.aispeech.nativedemo.config.Config; | |||
import com.aispeech.nativedemo.entity.PersonInfo; | |||
import com.aispeech.nativedemo.log.Logger; | |||
@@ -16,6 +17,7 @@ import com.aispeech.nativedemo.utils.StatusUtils; | |||
import com.aispeech.nativedemo.utils.Utils; | |||
import com.lenovo.lefacesdk.MultiAtt; | |||
import org.json.JSONException; | |||
import org.json.JSONObject; | |||
import org.json.JSONTokener; | |||
@@ -31,34 +33,50 @@ public class IntroduceNewPartner { | |||
private static final String TAG = "IntroduceNewPartner"; | |||
private static boolean isInProgress = false; | |||
private static String dmInput = ""; | |||
private static int mInterval = 5000; | |||
private static int mInterval = 3000; | |||
private static Timer mTimer = null; | |||
public static void sendMessage(String message){ | |||
MessageUtils.sendAsrText(message); | |||
MessageUtils.sendTtsText(message); | |||
JSONObject jo = new JSONObject(); | |||
try { | |||
jo.put("text", message); | |||
MessageUtils.sendChatMessage(jo.toString()); | |||
MessageUtils.sendTtsText(message); | |||
} catch (JSONException e) { | |||
throw new RuntimeException(e); | |||
} | |||
} | |||
public static void setDmInput(String input){ | |||
dmInput = input; | |||
} | |||
public static void clearTimer(){ | |||
if(mTimer != null){ | |||
mTimer.cancel(); | |||
mTimer = null; | |||
} | |||
} | |||
public static void introduceNewPartner(PersonInfo oldInfo, PersonInfo newInfo){ | |||
if(isInProgress){ | |||
return; | |||
} | |||
isInProgress = true; | |||
final PersonInfo oInfo = oldInfo; | |||
final PersonInfo nInfo = newInfo; | |||
if(mTimer == null){ | |||
sendMessage("好的,请让我认识你"); | |||
sendMessage("好的,我给您拍张照吧"); | |||
mTimer = new Timer(); | |||
mTimer.schedule(new TimerTask() { | |||
@Override | |||
public void run() { | |||
introduce(oldInfo, newInfo); | |||
introduce(oInfo, nInfo); | |||
} | |||
}, 3000); | |||
}, 4000); | |||
} else{ | |||
introduce(oldInfo, newInfo); | |||
introduce(oInfo, nInfo); | |||
} | |||
} | |||
@@ -107,8 +125,25 @@ public class IntroduceNewPartner { | |||
} | |||
} | |||
if(!TextUtils.isEmpty(name)){ | |||
if(newInfo.result.hd_fa > 0 && newInfo.result.fa_quality >= 0.6f) { | |||
MainActivity.instance.setCaptureInfo("脸部质量不合格"); | |||
if(newInfo.result.fa_quality < 0.6f) { | |||
MultiAtt att = newInfo.result; | |||
if(att.fa_w < 150){ | |||
MainActivity.instance.setCaptureInfo("请往前一点"); | |||
sendMessage("请往前一点"); | |||
} else if(att.fa_w > 500){ | |||
MainActivity.instance.setCaptureInfo("请往后一点"); | |||
sendMessage("请往后一点"); | |||
} else if(att.fa_x1 < 512){ | |||
MainActivity.instance.setCaptureInfo("请往右一点"); | |||
sendMessage("请往右一点"); | |||
} else if(att.fa_x2 > 1536){ | |||
MainActivity.instance.setCaptureInfo("请往左一点"); | |||
sendMessage("请往左一点"); | |||
} | |||
isInProgress = false; | |||
return; | |||
} | |||
if(newInfo.result.hd_fa == 0) { | |||
isInProgress = false; | |||
return; | |||
} | |||
@@ -120,29 +155,37 @@ public class IntroduceNewPartner { | |||
final String name1 = name; | |||
final String type1 = type; | |||
final int gender = newInfo.gender; | |||
MainActivity.instance.setCaptureInfo(mInterval / 1000 + ""); | |||
final Bitmap bitmap = newInfo.bitmap; | |||
final MultiAtt result = newInfo.result; | |||
Timer timer = new Timer(); | |||
timer.schedule(new TimerTask() { | |||
MainActivity.instance.setCaptureInfo("好的,请保持不动,我要拍照啦"); | |||
sendMessage("好的,请保持不动,我要拍照啦"); | |||
Timer stay = new Timer(); | |||
stay.schedule(new TimerTask() { | |||
@Override | |||
public void run() { | |||
mInterval -= 1000; | |||
if(mInterval == 0){ | |||
MainActivity.instance.setCaptureInfo("开始介绍"); | |||
byte[] bitmapBytes = BmpCompressUtils.getBytesByBitmap(Utils.CompressBmp(bitmap, result), 100, Bitmap.CompressFormat.JPEG); | |||
String base64 = Base64.encodeToString(bitmapBytes, Base64.DEFAULT); | |||
base64 = base64.replace("\n", "").replace("\\", "") + ""; | |||
newVisitor(name1, type1, gender, base64); | |||
timer.cancel(); | |||
} else{ | |||
MainActivity.instance.setCaptureInfo(mInterval / 1000 + ""); | |||
} | |||
MainActivity.instance.setCaptureInfo(mInterval / 1000 + ""); | |||
final Bitmap bitmap = newInfo.bitmap; | |||
final MultiAtt result = newInfo.result; | |||
Timer timer = new Timer(); | |||
timer.schedule(new TimerTask() { | |||
@Override | |||
public void run() { | |||
mInterval -= 1000; | |||
if(mInterval == 0){ | |||
Utils.playMusic(R.raw.kaca); | |||
MainActivity.instance.setCaptureInfo("请稍等片刻"); | |||
byte[] bitmapBytes = BmpCompressUtils.getBytesByBitmap(Utils.CompressBmp(bitmap, result), 100, Bitmap.CompressFormat.JPEG); | |||
String base64 = Base64.encodeToString(bitmapBytes, Base64.DEFAULT); | |||
base64 = base64.replace("\n", "").replace("\\", "") + ""; | |||
newVisitor(name1, type1, gender, base64); | |||
timer.cancel(); | |||
} else{ | |||
MainActivity.instance.setCaptureInfo(mInterval / 1000 + ""); | |||
} | |||
} | |||
}, 1000, 1000); | |||
} | |||
}, 1000, 1000); | |||
}, 5000); | |||
} else{ | |||
MainActivity.instance.setCaptureInfo("请描述介绍对象的类型"); | |||
// MessageUtils.sendAsrText("请描述介绍对象的类型"); | |||
isInProgress = false; | |||
} | |||
} else{ | |||
@@ -159,7 +202,6 @@ public class IntroduceNewPartner { | |||
postParam.put("gender", gender); | |||
postParam.put("devId", StatusUtils.getSerialNumber()); | |||
postParam.put("staffBase64Img", base64); | |||
// MessageUtils.sendAsrText("调用接口"); | |||
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), new JSONObject(postParam).toString()); | |||
HttpUtil.post(Config.CURRENT_URL + "system/staff/api/new-staff", requestBody, null, new HttpUtil.HttpCallback<String>() { | |||
@Override | |||
@@ -179,13 +221,10 @@ public class IntroduceNewPartner { | |||
} | |||
String message = ""; | |||
if (status == 0) { | |||
message = "介绍成功,您好" + name + "欢迎您"; | |||
message = "拍照完成啦,下次您再过来,我就记住你啦"; | |||
MainActivity.instance.setCaptureViewVisibility(View.GONE); | |||
FaceManager.getInstance().setIntroduceVisitor(false); | |||
if(mTimer != null){ | |||
mTimer.cancel(); | |||
mTimer = null; | |||
} | |||
clearTimer(); | |||
} else { | |||
message = "介绍失败:" + errMsg; | |||
onFail(errMsg); | |||
@@ -19,7 +19,7 @@ public class BaseMqttConfig { | |||
public static final String ENV_PROD = "/prod"; | |||
public static final String ENV_TEST = "/test"; | |||
public static final String ENV_DEV = "/dev"; | |||
public static String ENV_CURRENT = ENV_TEST; | |||
public static final String ENV_CURRENT = ENV_PROD; | |||
/** | |||
* 心跳 | |||
@@ -8,6 +8,7 @@ import android.os.SystemClock; | |||
import android.util.Log; | |||
import com.aispeech.nativedemo.DDSService; | |||
import com.aispeech.nativedemo.DuiApplication; | |||
import com.aispeech.nativedemo.MainActivity; | |||
import com.aispeech.nativedemo.asr.observer.DuiMessageObserver; | |||
import com.aispeech.nativedemo.config.ConfigManager; | |||
@@ -49,7 +50,8 @@ public class DigiWebSocketServer extends WebSocketServer { | |||
private static final String TAG = "DigiWebSocketServer"; | |||
public Long heartbeatTime = 0l; | |||
public Context context; | |||
public List<WebSocket> mConns; | |||
public boolean isOpen = false; | |||
public List<WebSocket> mConns = new ArrayList<>(); | |||
public DigiWebSocketServer(InetSocketAddress host, Context context) { | |||
super(host); | |||
@@ -75,14 +77,18 @@ public class DigiWebSocketServer extends WebSocketServer { | |||
if (MainActivity.instance != null) { | |||
MainActivity.instance.onSocketOpen(InitView.INIT_SUCCESS); | |||
} | |||
isOpen = true; | |||
} | |||
@Override | |||
public void onClose(WebSocket conn, int code, String reason, boolean remote) { | |||
Logger.e(conn.getRemoteSocketAddress() + "onClose()服务器关闭"); | |||
Logger.e(conn.getRemoteSocketAddress() + "onClose()服务器关闭 " + mConns.size()); | |||
Utils.websocketList.remove(conn.getRemoteSocketAddress().toString()); | |||
mConns.add(conn); | |||
mConns.remove(conn); | |||
removeConnection(conn); | |||
if (mConns.size() == 0) { | |||
isOpen = false; | |||
} | |||
MqttManager.getInstance(MainActivity.instance).getFileUploadPath(Config.ErrorEvent.ERROR_UPLOAD_WARNING, Config.ErrorEvent.ERROR_LEVEL_2, "socket_status", "onClose"); | |||
} | |||
@@ -209,23 +215,25 @@ public class DigiWebSocketServer extends WebSocketServer { | |||
public void onStart() { | |||
Logger.e("onStart(),WebSocket服务端启动成功"); | |||
heartbeatTime = System.currentTimeMillis(); | |||
new Thread(new Runnable() { | |||
@Override | |||
public void run() { | |||
DigiWebSocketClient.connect(Utils.getIP(context)); | |||
Timer timer = new Timer(); | |||
timer.schedule(new TimerTask() { | |||
@Override | |||
public void run() { | |||
DigiWebSocketClient.Send("ping"); | |||
} | |||
}, 0, 5000); | |||
} | |||
}).start(); | |||
// new Thread(new Runnable() { | |||
// @Override | |||
// public void run() { | |||
// DigiWebSocketClient.connect(Utils.getIP(context)); | |||
// Timer timer = new Timer(); | |||
// timer.schedule(new TimerTask() { | |||
// @Override | |||
// public void run() { | |||
// DigiWebSocketClient.Send("ping"); | |||
// } | |||
// }, 0, 5000); | |||
// } | |||
// }).start(); | |||
} | |||
public void removeAllConn(){ | |||
Log.e("testkit", "stopWebSocketServer " + mConns.size() + " application " + DigiNetworkManager.getManager()); | |||
for(WebSocket conn : mConns){ | |||
removeConnection(conn); | |||
} | |||
@@ -3,11 +3,17 @@ package com.aispeech.nativedemo.network.ws; | |||
import android.content.Context; | |||
import android.util.Log; | |||
import com.aispeech.nativedemo.DuiApplication; | |||
import com.aispeech.nativedemo.camera.CameraController; | |||
import com.aispeech.nativedemo.log.Logger; | |||
import com.aispeech.nativedemo.network.DigiNetworkManager; | |||
import org.java_websocket.WebSocket; | |||
import java.io.IOException; | |||
import java.net.InetSocketAddress; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
public class WebSocketManager { | |||
private static final String TAG = "CameraController"; | |||
@@ -45,6 +51,10 @@ public class WebSocketManager { | |||
// } catch (Exception e) { | |||
// Log.e(TAG, "onClick: " + e.getMessage()); | |||
// } | |||
if (wsServer != null) { | |||
Log.e("testkit", "before wsServer.mConns.size() " + wsServer.mConns.size()); | |||
} | |||
new Thread(new Runnable() { | |||
@Override | |||
public void run() { | |||
@@ -58,6 +68,7 @@ public class WebSocketManager { | |||
port = "9091"; | |||
} | |||
wsServer = new DigiWebSocketServer(myHost, mContext); | |||
Log.e("testkit", "before wsServer.mConns.size() " + wsServer.mConns.size()); | |||
wsServer.start(); | |||
} catch (Exception e) { | |||
Log.e(TAG, "onClick: " + e.getMessage()); | |||
@@ -68,7 +79,6 @@ public class WebSocketManager { | |||
public void stopWebSocketServer(){ | |||
try { | |||
Log.e(TAG, "stopWebSocketServer"); | |||
wsServer.removeAllConn(); | |||
wsServer.stop(); | |||
} catch (IOException | InterruptedException e) { | |||
@@ -97,7 +107,25 @@ public class WebSocketManager { | |||
public void sendMsg(String message) { | |||
// Logger.e("发送消息给H5" + message); | |||
if(wsServer != null){ | |||
wsServer.broadcast(message); | |||
Collection<WebSocket> collections = wsServer.getConnections(); | |||
Log.e("testkit", DigiNetworkManager.getManager() + " collections.size() " + collections.size() + " wsServer.mConns.size() " + wsServer.mConns.size()); | |||
wsServer.broadcast(message, wsServer.mConns); | |||
} | |||
} | |||
public void clearSocket() { | |||
Log.e("testkit", "clearSocket " + DigiNetworkManager.getManager()); | |||
if (wsServer != null) { | |||
wsServer.removeAllConn(); | |||
} | |||
} | |||
public boolean isSocketOpen() { | |||
if (wsServer == null) { | |||
return false; | |||
} | |||
return wsServer.isOpen; | |||
} | |||
} |
@@ -10,6 +10,7 @@ import android.content.pm.PackageManager; | |||
import android.graphics.Bitmap; | |||
import android.graphics.Matrix; | |||
import android.graphics.Rect; | |||
import android.media.MediaPlayer; | |||
import android.net.ConnectivityManager; | |||
import android.net.NetworkInfo; | |||
import android.net.wifi.WifiInfo; | |||
@@ -24,6 +25,7 @@ import android.widget.Toast; | |||
import androidx.appcompat.app.AlertDialog; | |||
import com.aispeech.nativedemo.DuiApplication; | |||
import com.aispeech.nativedemo.MainActivity; | |||
import com.aispeech.nativedemo.entity.ProcessEntity; | |||
import com.lenovo.lefacesdk.MultiAtt; | |||
import com.lenovo.lefacesdk.RectEx; | |||
@@ -617,4 +619,9 @@ public class Utils { | |||
CommandExecution.CommandResult commandResult = CommandExecution.execCommand(commons, true); | |||
// logCommandResult(commandResult); | |||
} | |||
public static void playMusic(int id) { | |||
MediaPlayer player = MediaPlayer.create(MainActivity.instance, id); | |||
player.start(); | |||
} | |||
} |
@@ -40,17 +40,16 @@ | |||
android:gravity="center" | |||
android:textColor="@color/white" | |||
android:textSize="40sp" | |||
android:layout_marginBottom="20px" | |||
android:layout_marginBottom="50px" | |||
app:layout_constraintBottom_toTopOf="@id/web_camera" | |||
app:layout_constraintLeft_toLeftOf="@id/web_camera" | |||
app:layout_constraintRight_toRightOf="@id/web_camera" /> | |||
<com.aispeech.nativedemo.widget.CameraTextureView | |||
android:id="@+id/web_camera" | |||
android:layout_width="895px" | |||
android:layout_height="932px" | |||
android:layout_marginTop="790px" | |||
android:layout_marginStart="37px" | |||
android:layout_width="634px" | |||
android:layout_height="634px" | |||
android:layout_marginTop="449px" | |||
app:layout_constraintTop_toTopOf="parent" | |||
app:layout_constraintLeft_toLeftOf="parent" | |||
app:layout_constraintRight_toRightOf="parent" /> | |||