Browse Source

3.0 optimize:代码优化,副屏日志打印,Ampe日志优化

xwh 1 month ago
parent
commit
649504e989

+ 1 - 1
app/src/main/java/com/hh/arome/activity/MainActivity.java

@@ -678,7 +678,7 @@ public class MainActivity extends BaseMVPActivity<MainPresenter> implements View
     **/
     @Override
     public void onCalled(String action, BaseAmpeRequestBean dataBean, AromeServiceInvoker.BridgeCallback bridgeCallback) {
-        if(dataBean==null){
+        if (dataBean == null) {
             return;
         }
         dataBean.setBridgeCallback(bridgeCallback);

+ 10 - 9
app/src/main/java/com/hh/arome/broadcastreceiver/AutoStartBroadReceiver.java

@@ -9,6 +9,7 @@ import com.hh.arome.activity.MainActivity;
 import com.hh.lib_base.Constants;
 import com.hh.lib_base.log.AppLogUtils;
 import com.hh.lib_base.log.LogType;
+import com.hh.lib_base.log.UploadLogUtils;
 import com.hh.lib_base.manager.ActivityManager;
 import com.hh.lib_base.utils.device.DeviceUtils;
 import com.hh.lib_common.local.AppLocalConfigHandler;
@@ -30,7 +31,7 @@ public class AutoStartBroadReceiver extends BroadcastReceiver {
 
 
         boolean firstStart = localConfig.isFirstStart();
-        AppLogUtils.e("firstStart--" + firstStart);
+        UploadLogUtils.sendLogs(false,"开机广播"," ","","收到开机广播:"+firstStart);
         if (!firstStart) {
             localConfig.setFirstStart(true);
 
@@ -60,14 +61,12 @@ public class AutoStartBroadReceiver extends BroadcastReceiver {
                     mainIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
                     context.startActivity(mainIntent);
                     String logLine= (new Throwable().getStackTrace())[0].toString();
-                    // 开始保存本地日志
-                    AppLogUtils.saveLog(
-                            LogType.Logcat, new  StringBuilder()
-                                    .append(Constants.LogcatValue.LINE)
-                                    .append(logLine).append(Constants.LogcatValue.WARP)
-                                    .append(Constants.LogcatValue.NODE)
-                                    .append("HHArome  开机广播  启动MainActivity ")
-                                    .toString());
+                    UploadLogUtils.sendLogs(false,"开机广播"," ",logLine,new  StringBuilder()
+                            .append(Constants.LogcatValue.LINE)
+                            .append(logLine).append(Constants.LogcatValue.WARP)
+                            .append(Constants.LogcatValue.NODE)
+                            .append("HHArome  开机广播  启动MainActivity ")
+                            .toString());
                 }catch (Exception e){
 
                 }
@@ -99,6 +98,8 @@ public class AutoStartBroadReceiver extends BroadcastReceiver {
             AppLogUtils.e("startApp--onReceive: 启动了。。。");
 
             boolean autoApp = localConfig.isAutoApp();
+            UploadLogUtils.sendLogs(false,"开机广播"," ","",
+                    "收到开机广播-是否自启动:"+autoApp);
             AppLogUtils.e("autoApp--" + autoApp);
             if (autoApp) {
                 AppLogUtils.e("autoApp--自启动");

+ 3 - 1
lib_ampe/src/main/java/com/hh/lib_ampe/utils/AromeInvoker.java

@@ -106,7 +106,9 @@ public class AromeInvoker {
                 StringBuilder logContentSb = new StringBuilder();
                 logContentSb.append("onCalled").append(WARP)
                         .append("action = ").append(action).append(WARP)
-                        .append("params = ").append(ampeAppletRequestBean.toString());
+                        .append("params = ").append(ShortenLogUtils.shortenLog(params,"params"));
+
+
                 UploadLogUtils.sendLogs("小程序通道建立---入参---", "", logLine, logContentSb.toString());
                 String actionName = ampeAppletRequestBean.getAction();
                 if (StringUtils.isNull(actionName)) {

+ 13 - 4
lib_base/src/main/java/com/hh/lib_base/utils/ShortenLogUtils.java

@@ -24,10 +24,15 @@ public class ShortenLogUtils {
             JSONObject uploadJson=new JSONObject(jsonStr);
             //下面就是具体字段,模拟下方字段取值修改就可以
             String photoBase64 =uploadJson.optString("photoBase64");
+            //下面就是具体字段,模拟下方字段取值修改就可以
+            String voiceContent =uploadJson.optString("voiceContent");
             if(!TextUtils.isEmpty(photoBase64)){
-                uploadJson.put("photoBase64","size->"+photoBase64.length());
+                uploadJson.put("photoBase64","Base64统一日志格式,Base64字符串长度:"+photoBase64.length());
+            }
+            //麦克风语音byte[]数据转base64
+            if(!TextUtils.isEmpty(voiceContent)){
+                uploadJson.put("voiceContent","Base64统一日志格式,Base64字符串长度:"+photoBase64.length());
             }
-
             return uploadJson.toString();
 
         } catch (JSONException e) {
@@ -59,10 +64,14 @@ public class ShortenLogUtils {
 
             //下面就是具体字段,模拟下方字段取值修改就可以
             String photoBase64 =data.optString("photoBase64");
+            //下面就是具体字段,模拟下方字段取值修改就可以
+            String secondaryScreenBase64 =data.optString("secondaryScreenBase64");
             if(!TextUtils.isEmpty(photoBase64)){
-                data.put("photoBase64","size->"+photoBase64.length());
+                data.put("photoBase64","Base64统一日志格式,Base64字符串长度:"+photoBase64.length());
+            }
+            if(!TextUtils.isEmpty(secondaryScreenBase64)){
+                data.put("secondaryScreenBase64","Base64统一日志格式,Base64字符串长度:"+photoBase64.length());
             }
-
 
             uploadJson.put(dataKey,data);
             return uploadJson.toString();

+ 2 - 4
lib_infrared/src/main/java/com/hh/lib_infrared/InfraredInvoker.java

@@ -32,8 +32,6 @@ import org.json.JSONObject;
 
 import java.io.IOException;
 import java.security.InvalidParameterException;
-import java.util.ArrayList;
-import java.util.List;
 import java.util.Timer;
 import java.util.TimerTask;
 
@@ -203,7 +201,7 @@ public class InfraredInvoker {
         // 波特率
         sc.setBaudRate("9600");
         // 打开红外感应
-        OpenInductionLightComPort(sc);
+        openInductionLightComPort(sc);
 
     }
 
@@ -213,7 +211,7 @@ public class InfraredInvoker {
      * Time 2024/9/6
      * Description: 打开红外线串口
      **/
-    public void OpenInductionLightComPort(SerialHelper comPort) {
+    public void openInductionLightComPort(SerialHelper comPort) {
         try {
             comPort.open();
             this.comPortInfraredInduction = comPort;

+ 20 - 6
secondaryscreen/src/main/java/com/hh/arome/secondaryscreen/SecondaryScreenPage.java

@@ -16,6 +16,8 @@ import android.widget.Toast;
 
 import com.bumptech.glide.Glide;
 import com.hh.arome.secondaryscreen.bean.ConfigBean;
+import com.hh.lib_base.Constants;
+import com.hh.lib_base.log.UploadLogUtils;
 
 import java.util.Base64;
 
@@ -42,18 +44,30 @@ public class SecondaryScreenPage extends Presentation implements View.OnClickLis
         super.onCreate(savedInstanceState);
         setContentView(R.layout.layout_secondary_screen_page);
         imageView=findViewById(R.id.iv_bg);
-        Glide.with(getContext())
-                .load(mConfig.getPhotoBase64Str())
-                //.apply(mRequestOptions)
-                .centerCrop()
-                .into(imageView);
+        if (mConfig != null) {
+            String logLine = (new Throwable().getStackTrace())[0].toString();
+            UploadLogUtils.sendLogs(false
+                    , Constants.LogcatValue.LOG_SECONDARY_SCREEN_PAGE,
+                    " SecondaryScreenPage-onCreate"
+                    , logLine, mConfig.getPhotoBase64Str());
+            Glide.with(getContext())
+                    .load(mConfig.getPhotoBase64Str())
+                    //.apply(mRequestOptions)
+                    .centerCrop()
+                    .into(imageView);
+        }
 
 
 
     }
 
     public void updateConfig(ConfigBean config){
-        if(imageView!=null){
+        if (imageView != null && config != null) {
+            String logLine = (new Throwable().getStackTrace())[0].toString();
+            UploadLogUtils.sendLogs(false
+                    , Constants.LogcatValue.LOG_SECONDARY_SCREEN_PAGE,
+                    "SecondaryScreenPage-updateConfig"
+                    , logLine, config.getPhotoBase64Str());
             Glide.with(getContext())
                     .load(config.getPhotoBase64Str())
                     //.apply(mRequestOptions)