Browse Source

Merge pull request 'dev_lt' (#7) from dev_lt into test

Reviewed-on: #7
tags/A.1.2.0.0_20230908_release^2
bogemail 1 year ago
parent
commit
ee5ca5e2d4
9 changed files with 79 additions and 19 deletions
  1. +1
    -1
      app/build.gradle
  2. +1
    -1
      app/release/output-metadata.json
  3. +2
    -12
      app/src/main/java/com/aispeech/nativedemo/MainActivity.java
  4. +6
    -0
      app/src/main/java/com/aispeech/nativedemo/camera/CameraController.java
  5. +49
    -3
      app/src/main/java/com/aispeech/nativedemo/config/ConfigManager.java
  6. +1
    -1
      app/src/main/java/com/aispeech/nativedemo/db/StrangerDbHelper.java
  7. +4
    -0
      app/src/main/java/com/aispeech/nativedemo/face/FaceChatMode.java
  8. +11
    -0
      app/src/main/java/com/aispeech/nativedemo/network/ws/MessageUtils.java
  9. +4
    -1
      app/src/main/res/layout/activity_main.xml

+ 1
- 1
app/build.gradle View File

@@ -9,7 +9,7 @@ android {
minSdkVersion 26
targetSdkVersion 30
versionCode 3
versionName "A.1.0.6.3_20230831_base"
versionName "A.1.0.6.5_20230908_base"

sourceSets {
main { //这个配置是必须的,如果你的so文件放在了libs/armeabi/下,则下面srcDir = libs即可


+ 1
- 1
app/release/output-metadata.json View File

@@ -12,7 +12,7 @@
"filters": [],
"attributes": [],
"versionCode": 3,
"versionName": "A.1.0.6.3_20230831_base",
"versionName": "A.1.0.6.5_20230908_base",
"outputFile": "app-release.apk"
}
],


+ 2
- 12
app/src/main/java/com/aispeech/nativedemo/MainActivity.java View File

@@ -347,6 +347,7 @@ public class MainActivity extends Activity implements DuiUpdateObserver.UpdateCa
if(mWebView.getBackground() != null){
mWebView.getBackground().setAlpha(0);
}
mWebView.setWebViewClient();
//声明WebSettings子类
WebSettings webSettings = mWebView.getSettings();

@@ -565,8 +566,6 @@ public class MainActivity extends Activity implements DuiUpdateObserver.UpdateCa
backgroundHandler.post(periodicDetect);
}

private long mUploadInterval = 0;

/**
* 闲聊模式
*/
@@ -577,15 +576,6 @@ public class MainActivity extends Activity implements DuiUpdateObserver.UpdateCa
Log.e(TAG, "-----------------detect face----------------");
textureBitmap = mTextureView.getBitmap();

if(mUploadInterval == 0){
mUploadInterval = System.currentTimeMillis();
} else{
if(System.currentTimeMillis() - mUploadInterval > 2 * 60 * 1000){
FaceChatMode.uploadPic(textureBitmap);
mUploadInterval = System.currentTimeMillis();
}
}

//删除过期人员
FaceChatMode.deleteExpirePerson();
List<MultiAtt> results = FaceChatMode.detectMultiAtt(textureBitmap);
@@ -608,10 +598,10 @@ public class MainActivity extends Activity implements DuiUpdateObserver.UpdateCa
FaceChatMode.mInterval = System.currentTimeMillis();
}
Log.e(TAG, "---------------thread execute over-------------");
loopDetect();
} catch (Exception e) {
e.printStackTrace();
}
loopDetect();
}
};



+ 6
- 0
app/src/main/java/com/aispeech/nativedemo/camera/CameraController.java View File

@@ -34,6 +34,7 @@ import androidx.core.app.ActivityCompat;

import com.aispeech.nativedemo.log.Logger;
import com.aispeech.nativedemo.utils.BitmapUtil;
import com.aispeech.nativedemo.utils.CommandExecution;

import java.nio.ByteBuffer;
import java.util.Arrays;
@@ -88,6 +89,11 @@ public class CameraController implements ICamera{
@Override
public void onError(@NonNull CameraDevice camera, int error) {
Logger.e("camera error " + error);
if (error == ERROR_MAX_CAMERAS_IN_USE) {
String[] commons = new String[1];
commons[0] = "reboot";
CommandExecution.execCommand(commons, true);
}
camera.close();
}
};


+ 49
- 3
app/src/main/java/com/aispeech/nativedemo/config/ConfigManager.java View File

@@ -141,7 +141,7 @@ public class ConfigManager {
getReception();
}
if((data & 0x10000) > 0){
getConfig();
}
} else {
onFail(obj.getString("msg"));
@@ -343,14 +343,14 @@ public class ConfigManager {
model.workdayHour = new WorkDayHour().create(jsonObject.optJSONObject("workdayHour"));
}
if(jsonObject.has("broadcast")){
JSONArray array = jsonObject.getJSONArray("broadcast");
JSONObject object = jsonObject.getJSONObject("broadcast");
// List<Broadcast> broadcasts = new ArrayList<>();
// for (int i = 0; i < array.length(); i++) {
// JSONObject broadcastObj = array.getJSONObject(i);
// Broadcast broadcast = new Broadcast().create(broadcastObj);
// broadcasts.add(broadcast);
// }
MessageUtils.sendBroadcast(array.toString());
MessageUtils.sendBroadcast(object.toString());
}
ModelDbHelper.getInstance().add(model);
if (obj.has("timestamp")) {
@@ -424,6 +424,52 @@ public class ConfigManager {
});
}

private void getConfig() {
HashMap<String, String> map = new HashMap<>();
map.put("id", "123456");
map.put("devId", StatusUtils.getSerialNumber());
map.put("type", "4");
map.put("sign", "123456");
map.put("enterpriseName", "administrator");
map.put("timestamp", "1");
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), new JSONObject(map).toString());
HttpUtil.post(Config.CURRENT_URL + "message/api/update", requestBody, null, new HttpUtil.HttpCallback<String>() {

@Override
public void onSuccess(String success) {
Log.e(TAG, "getReception = " + success);
try {
JSONTokener t = new JSONTokener(success);
JSONObject obj = (JSONObject) t.nextValue();
int code = 0;
if (obj.has("code")) {
code = obj.getInt("code");
}
if (code == 200) {
// MessageUtils.sendMessage("接待任务:" + success);
if (obj.has("data")) {
JSONObject object = obj.getJSONObject("data");
if (object.has("msg")) {
JSONObject config = object.getJSONObject("msg");
MessageUtils.sendConfig(config.toString());
}
}
} else {
onFail(obj.getString("msg"));
}
} catch (Exception e) {
e.printStackTrace();
onFail(e.getMessage());
}
}

@Override
public void onFail(String error) {
Log.e(TAG, "getReception = " + error);
}
});
}

private void checkServiceStatus(){
boolean survive = Utils.isProcessAlive("com.lecooai.lewatchdog");//packageName
Log.e(TAG, "进程是存活: " + survive + ", PID: " + survive);


+ 1
- 1
app/src/main/java/com/aispeech/nativedemo/db/StrangerDbHelper.java View File

@@ -98,7 +98,7 @@ public class StrangerDbHelper extends IDbHelper<Stranger> {
Cursor cursor = null;
try {
database = DatabaseImpl.getDatabase().getDb();
cursor = database.rawQuery("select * from new_user_faces where eid = ?",
cursor = database.rawQuery("select * from new_user_faces where user_id = ?",
new String[]{String.valueOf(stranger.id)});
return cursor.getCount() > 0;
} catch (Exception e) {


+ 4
- 0
app/src/main/java/com/aispeech/nativedemo/face/FaceChatMode.java View File

@@ -881,6 +881,7 @@ public class FaceChatMode {
}
}


@Override
public void onFail(String error) {
Log.e(TAG, "sendStrangerToServer onFail: " + error);
@@ -889,6 +890,9 @@ public class FaceChatMode {
}

public static Stranger saveStranger(PersonInfo personInfo) {
if(personInfo.dfeatures == null || personInfo.dfeatures.length != 256){
return null;
}
long id = System.currentTimeMillis();
Utils.userNewFaces.put(id + "_1", personInfo.dfeatures);
Stranger stranger = new Stranger();


+ 11
- 0
app/src/main/java/com/aispeech/nativedemo/network/ws/MessageUtils.java View File

@@ -383,4 +383,15 @@ public class MessageUtils {
throw new RuntimeException(e);
}
}

public static void sendConfig(String message){
try {
JSONObject jo = new JSONObject();
jo.put("type", "config");
jo.put("data", message);
sendMessage(jo.toString());
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
}

+ 4
- 1
app/src/main/res/layout/activity_main.xml View File

@@ -34,7 +34,10 @@
<com.aispeech.nativedemo.widget.CameraTextureView
android:id="@+id/texture"
android:layout_width="2048px"
android:layout_height="1536px" />
android:layout_height="1536px"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"/>

<ImageView
android:id="@+id/image"


Loading…
Cancel
Save