瀏覽代碼

测试模式新增加开关机压力测试

weizhengliang 1 年之前
父節點
當前提交
f0084c9c67

+ 2 - 1
android_door/src/main/h10_3128/AndroidManifest.xml

@@ -26,7 +26,8 @@
             android:launchMode="singleTask"/>
         <activity android:name="com.wdkl.app.ncs.callingbed.activity.AppTextActivity"
             android:screenOrientation="landscape"
-            android:launchMode="singleInstance"/>
+            android:launchMode="singleInstance"
+            android:windowSoftInputMode = "stateAlwaysHidden|adjustPan"/>
 
         <activity android:name="com.wdkl.ncs.host.activity.SipTestActivity" />
         <activity android:name="com.wdkl.ncs.host.activity.CallActivity" />

+ 7 - 1
android_door/src/main/h10_3128/java/com/wdkl/app/ncs/callingdoor/activity/AppTextActivity.kt

@@ -91,7 +91,7 @@ class AppTextActivity :BaseActivity<QrCodeFragmentPresenter, TestLayBinding>(),
         RecordHelper.getInstance().init()
         //SoundPoolManager.getInstance().playSound(4, 1.0f, 1.0f, 0)
         tv_test_info.movementMethod = ScrollingMovementMethod.getInstance()
-        tv_ip.text = "IP:" + NetHelper.getInstance().localIP
+        tv_ip.text = "本机IP:" + NetHelper.getInstance().localIP
 
         startCameraPreview()
     }
@@ -233,6 +233,12 @@ class AppTextActivity :BaseActivity<QrCodeFragmentPresenter, TestLayBinding>(),
                 SerialPortUtil433.getInstance().send(cmd)
             }
         }
+
+        btn_reboot_test.setOnClickListener {
+            SettingConfig.setRebootTest(activity, true)
+
+            RebootTestTipsDialogHelper.showDialog(activity)
+        }
     }
 
     private fun startScreenTest() {

+ 5 - 0
android_door/src/main/h10_3128/java/com/wdkl/app/ncs/callingdoor/activity/CallingdoorActivity.kt

@@ -398,6 +398,11 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
             Constant.silentUpdate = true
             checkAppVersion()
         }
+
+
+        if (SettingConfig.getRebootTest(activity)) {
+            RebootTestTipsDialogHelper.showDialog(activity)
+        }
     }
 
     //检查launch版本

+ 0 - 228
android_door/src/main/h10_3128/java/com/wdkl/app/ncs/callingdoor/helper/AnrFcExceptionUtil.java.bak

@@ -1,228 +0,0 @@
-package com.wdkl.app.ncs.callingdoor.helper;
-
-import android.app.AlarmManager;
-import android.app.Application;
-import android.app.PendingIntent;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Build;
-import android.os.Environment;
-import android.util.Log;
-
-import com.github.anrwatchdog.ANRError;
-import com.github.anrwatchdog.ANRWatchDog;
-import com.wdkl.ncs.android.component.welcome.activity.WelcomeActivity;
-import com.wdkl.ncs.android.middleware.tcp.channel.DeviceChannel;
-import com.wdkl.skywebrtc.CallSession;
-import com.wdkl.skywebrtc.EnumType;
-import com.wdkl.skywebrtc.SkyEngineKit;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.TimeZone;
-
-/**
- * Created by dengzhe on 2018/4/2.
- * //=========================FC&ANR异常处理类=========================//
- */
-
-public class AnrFcExceptionUtil implements Thread.UncaughtExceptionHandler {
-
-    private static ANRWatchDog mANRWatchDog;
-    private Thread.UncaughtExceptionHandler mDefaultHandler;
-    public static final String TAG = "MyApplication";
-    private static Application application;
-
-    private static AnrFcExceptionUtil mAnrFcExceptionUtil;
-
-    /**
-     * 存储异常和参数信息
-     */
-    private Map<String, String> paramsMap = new HashMap<>();
-    /**
-     * 格式化时间
-     */
-    private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
-
-
-    public static AnrFcExceptionUtil getInstance(Application application) {
-        if (mAnrFcExceptionUtil == null) {
-            mAnrFcExceptionUtil = new AnrFcExceptionUtil(application);
-        }
-        return mAnrFcExceptionUtil;
-    }
-
-    private AnrFcExceptionUtil(Application application) {
-        //获取系统默认的UncaughtException处理器
-        mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();
-        this.application = application;
-    }
-
-    @Override
-    public void uncaughtException(Thread thread, Throwable ex) {
-        if (!handleException(ex) && mDefaultHandler != null) {
-            //如果用户没有处理则让系统默认的异常处理器来处理
-            mDefaultHandler.uncaughtException(thread, ex);
-        } else {
-            try {
-                Thread.sleep(2000);
-            } catch (InterruptedException e) {
-                Log.e(TAG, "error : ", e);
-            }
-
-            restartApp();
-            //android.os.Process.killProcess(android.os.Process.myPid());
-            //System.exit(0);
-        }
-    }
-
-    /**
-     * 自定义错误处理,收集错误信息 发送错误报告等操作均在此完成.
-     *
-     * @param ex
-     * @return true:如果处理了该异常信息;否则返回false.
-     */
-    private boolean handleException(Throwable ex) {
-        if (ex == null) {
-            return false;
-        }
-        //使用Toast来显示异常信息
-        /*new Thread() {
-            @Override
-            public void run() {
-                Looper.prepare();
-//                Toast.makeText(application.getApplicationContext(), "很抱歉,程序出现异常,即将重新启动.",
-//                        Toast.LENGTH_SHORT).show();
-                Looper.loop();
-            }
-        }.start();*/
-        saveCrashInfo2File(ex);
-        return true;
-    }
-
-    /**
-     * 保存错误信息到文件中
-     *
-     * @param ex
-     * @return 返回文件名称
-     */
-    private String saveCrashInfo2File(Throwable ex) {
-        StringBuffer sb = new StringBuffer();
-        for (Map.Entry<String, String> entry : paramsMap.entrySet()) {
-            String key = entry.getKey();
-            String value = entry.getValue();
-            sb.append(key + "=" + value + "\n");
-        }
-
-        Writer writer = new StringWriter();
-        PrintWriter printWriter = new PrintWriter(writer);
-        ex.printStackTrace(printWriter);
-        Throwable cause = ex.getCause();
-        while (cause != null) {
-            cause.printStackTrace(printWriter);
-            cause = cause.getCause();
-        }
-        printWriter.close();
-        String result = writer.toString();
-        sb.append(result);
-
-        try {
-            long timestamp = System.currentTimeMillis();
-            format.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
-            String time = format.format(new Date());
-            String fileName = "crash-" + time + "-" + timestamp + ".txt";
-            if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
-                String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/crash/";
-                File dir = new File(path);
-                if (!dir.exists()) {
-                    dir.mkdirs();
-                }
-                FileOutputStream fos = new FileOutputStream(path + fileName);
-                fos.write(sb.toString().getBytes());
-                Log.i(TAG, "saveCrashInfo2File: "+sb.toString());
-                fos.close();
-            }
-            return fileName;
-        } catch (Exception e) {
-            Log.e(TAG, "an error occured while writing file...", e);
-        }
-        return null;
-    }
-
-    private void restartApp() {
-        CallSession session= SkyEngineKit.Instance().getCurrentSession();
-        if(session!=null&&session.getState()!= EnumType.CallState.Idle){
-            SkyEngineKit.Instance().endCall();
-        }
-
-        //重新启动app
-        Intent mStartActivity = new Intent(application.getApplicationContext(), WelcomeActivity.class);
-        mStartActivity.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
-        int mPendingIntentId = 123456;
-        PendingIntent mPendingIntent = PendingIntent.getActivity(application.getApplicationContext(), mPendingIntentId, mStartActivity, PendingIntent.FLAG_CANCEL_CURRENT);
-        AlarmManager mgr = (AlarmManager) application.getApplicationContext().getSystemService(Context.ALARM_SERVICE);
-        mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 1500, mPendingIntent);
-
-        android.os.Process.killProcess(android.os.Process.myPid());
-        System.exit(0);
-    }
-
-    /**
-     * ===================================================崩溃异常处理===================================================
-     */
-    public void initFCException() {
-        //设置该CrashHandler为程序的默认处理器
-        AnrFcExceptionUtil catchExcep = AnrFcExceptionUtil.getInstance(application);
-        Thread.setDefaultUncaughtExceptionHandler(catchExcep);
-        mANRWatchDog = new ANRWatchDog(8000);
-        mANRWatchDog.setInterruptionListener(new ANRWatchDog.InterruptionListener() {
-            @Override
-            public void onInterrupted(InterruptedException exception) {
-            }
-        }).setIgnoreDebugger(true).setANRListener(new ANRWatchDog.ANRListener() {
-            @Override
-            public void onAppNotResponding(ANRError error) {
-                /*Intent mStartActivity = new Intent(application.getApplicationContext(), Constants.ANR_FC);
-                int mPendingIntentId = 123456;
-                PendingIntent mPendingIntent = PendingIntent.getActivity(application.getApplicationContext(), mPendingIntentId, mStartActivity, PendingIntent.FLAG_CANCEL_CURRENT);
-                AlarmManager mgr = (AlarmManager) application.getApplicationContext().getSystemService(Context.ALARM_SERVICE);
-                mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 1500, mPendingIntent);
-                android.os.Process.killProcess(android.os.Process.myPid());*/
-
-                //记录anr发生时间
-                /*try {
-                    long timestamp = System.currentTimeMillis();
-                    String time = format.format(new Date());
-                    format.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
-                    String fileName = "anr-" + time + "-" + timestamp + ".txt";
-                    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
-                        String path = Environment.getExternalStorageDirectory() + "/anr/";
-                        File dir = new File(path);
-                        if (!dir.exists()) {
-                            dir.mkdirs();
-                        }
-                        FileOutputStream fos = new FileOutputStream(path + fileName);
-                        fos.write(fileName.getBytes());
-                        fos.close();
-                    }
-                } catch (Exception e) {
-                }*/
-
-                Log.d("anr", "Anr restart app...");
-                if ("rk3128".equals(Build.MODEL)) {
-                    AppUpdateHelper.reboot(application);
-                } else {
-                    restartApp();
-                }
-            }
-        }).start();
-
-    }
-}

+ 84 - 0
android_door/src/main/h10_3128/java/com/wdkl/app/ncs/callingdoor/helper/RebootTestTipsDialogHelper.java

@@ -0,0 +1,84 @@
+package com.wdkl.app.ncs.callingdoor.helper;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.os.CountDownTimer;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.TextView;
+
+import com.wdkl.app.ncs.callingdoor.R;
+import com.wdkl.ncs.android.lib.base.BaseApplication;
+import com.wdkl.ncs.android.lib.settings.SettingConfig;
+
+public class RebootTestTipsDialogHelper {
+
+    private static AlertDialog dialog;
+
+    public static void showDialog(Activity activity) {
+        if (dialog != null) {
+            dialog.dismiss();
+            dialog = null;
+        }
+
+        View contentView = LayoutInflater.from(activity).inflate(R.layout.reboot_tips_dialog, null);
+        AlertDialog.Builder builder = new AlertDialog.Builder(activity);
+        builder.setView(contentView);
+        TextView tvTime = contentView.findViewById(R.id.tv_time);
+        Button buttonExit = contentView.findViewById(R.id.exit_button);
+
+        final CountDownTimer timer = new CountDownTimer(300000, 1000) {
+
+            @Override
+            public void onTick(long millisUntilFinished) {
+                String text = "" + millisUntilFinished/1000;
+                tvTime.setText(text);
+            }
+
+            @Override
+            public void onFinish() {
+                AppUpdateHelper.reboot(BaseApplication.appContext);
+
+                if (dialog != null) {
+                    dialog.dismiss();
+                }
+            }
+        };
+        timer.start();
+
+        buttonExit.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                SettingConfig.setRebootTest(BaseApplication.appContext, false);
+
+                if (timer != null) {
+                    timer.cancel();
+                }
+                if (dialog != null) {
+                    dialog.dismiss();
+                }
+            }
+        });
+
+        dialog = builder.create();
+        dialog.setCanceledOnTouchOutside(false);
+        dialog.setCancelable(false);
+        dialog.show();
+
+        //设置dialog宽高及位置
+        try {
+            Window window = dialog.getWindow();
+            WindowManager.LayoutParams lp = window.getAttributes();
+            lp.width = 600;
+            lp.height = 320;
+            lp.gravity = Gravity.CENTER;
+            window.setAttributes(lp);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}

+ 40 - 0
android_door/src/main/h10_3128/res/layout/reboot_tips_dialog.xml

@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:gravity="center"
+    android:orientation="vertical">
+
+    <TextView
+        android:id="@+id/reboot_text"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="20dp"
+        android:padding="8dp"
+        android:text="@string/reboot_test"
+        android:textColor="@color/red_color"
+        android:textSize="32sp"
+        android:gravity="center" />
+
+    <TextView
+        android:id="@+id/tv_time"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="10dp"
+        android:padding="8dp"
+        android:textColor="@color/red_color"
+        android:textSize="30sp"
+        android:gravity="center" />
+
+    <Button
+        android:id="@+id/exit_button"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="32dp"
+        android:background="@mipmap/bg_bottom_btn"
+        android:padding="8dp"
+        android:text="@string/str_exit"
+        android:textSize="20sp"
+        android:textColor="@drawable/selector_bottom_btn_text_color"/>
+
+</LinearLayout>

+ 32 - 14
android_door/src/main/h10_3128/res/layout/test_lay.xml

@@ -71,12 +71,22 @@
                     android:layout_width="160dp"
                     android:layout_height="160dp" />
 
+                <TextView
+                    android:id="@+id/tv_ip"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginLeft="10dp"
+                    android:layout_toRightOf="@id/camera_preview_surface"
+                    android:text="IP:"
+                    android:textSize="20sp" />
+
                 <Button
                     android:id="@+id/btn_sos_test"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:layout_margin="10dp"
                     android:padding="10dp"
+                    android:layout_below="@id/tv_ip"
                     android:layout_toRightOf="@id/camera_preview_surface"
                     android:background="@drawable/shape_main_hos_txt_bg"
                     android:textColor="@drawable/selector_bottom_btn_text_color"
@@ -89,6 +99,7 @@
                     android:layout_height="wrap_content"
                     android:layout_margin="10dp"
                     android:padding="10dp"
+                    android:layout_below="@id/tv_ip"
                     android:layout_toRightOf="@id/btn_sos_test"
                     android:background="@drawable/shape_main_hos_txt_bg"
                     android:textColor="@drawable/selector_bottom_btn_text_color"
@@ -101,6 +112,7 @@
                     android:layout_height="wrap_content"
                     android:layout_margin="10dp"
                     android:padding="10dp"
+                    android:layout_below="@id/tv_ip"
                     android:layout_toRightOf="@id/btn_reset"
                     android:background="@drawable/shape_main_hos_txt_bg"
                     android:textColor="@drawable/selector_bottom_btn_text_color"
@@ -113,6 +125,7 @@
                     android:layout_height="wrap_content"
                     android:layout_margin="10dp"
                     android:padding="10dp"
+                    android:layout_below="@id/tv_ip"
                     android:layout_toRightOf="@id/btn_net_off"
                     android:background="@drawable/shape_main_hos_txt_bg"
                     android:textColor="@drawable/selector_bottom_btn_text_color"
@@ -125,6 +138,7 @@
                     android:layout_height="wrap_content"
                     android:layout_margin="10dp"
                     android:padding="10dp"
+                    android:layout_below="@id/tv_ip"
                     android:layout_toRightOf="@id/btn_color"
                     android:background="@drawable/shape_main_hos_txt_bg"
                     android:textColor="@drawable/selector_bottom_btn_text_color"
@@ -137,27 +151,18 @@
                     android:layout_height="wrap_content"
                     android:layout_margin="10dp"
                     android:padding="10dp"
+                    android:layout_below="@id/tv_ip"
                     android:layout_toRightOf="@id/btn_cm"
                     android:background="@drawable/shape_main_hos_txt_bg"
                     android:textColor="@drawable/selector_bottom_btn_text_color"
                     android:text="屏幕老化测试"
                     android:textSize="24sp"/>
 
-                <TextView
-                    android:id="@+id/tv_ip"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_below="@id/btn_reset"
-                    android:layout_marginLeft="10dp"
-                    android:layout_toRightOf="@id/camera_preview_surface"
-                    android:text="IP:"
-                    android:textSize="20sp" />
-
                 <EditText
                     android:id="@+id/edit_flash_mac"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:layout_below="@id/tv_ip"
+                    android:layout_below="@id/btn_sos_test"
                     android:layout_marginLeft="10dp"
                     android:layout_toRightOf="@id/camera_preview_surface"
                     android:text="13"
@@ -168,7 +173,7 @@
                     android:id="@+id/btn_flash_on"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:layout_below="@id/tv_ip"
+                    android:layout_below="@id/btn_sos_test"
                     android:layout_marginLeft="20dp"
                     android:padding="10dp"
                     android:layout_toRightOf="@id/edit_flash_mac"
@@ -181,7 +186,7 @@
                     android:id="@+id/btn_flash_off"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:layout_below="@id/tv_ip"
+                    android:layout_below="@id/btn_sos_test"
                     android:layout_marginLeft="20dp"
                     android:padding="10dp"
                     android:layout_toRightOf="@id/btn_flash_on"
@@ -189,6 +194,19 @@
                     android:textColor="@drawable/selector_bottom_btn_text_color"
                     android:text="关闭声光报警器"
                     android:textSize="24sp" />
+
+                <Button
+                    android:id="@+id/btn_reboot_test"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_below="@id/btn_sos_test"
+                    android:layout_marginLeft="20dp"
+                    android:padding="10dp"
+                    android:layout_toRightOf="@id/btn_flash_off"
+                    android:background="@drawable/shape_main_hos_txt_bg"
+                    android:textColor="@drawable/selector_bottom_btn_text_color"
+                    android:text="开关机测试"
+                    android:textSize="24sp" />
             </RelativeLayout>
 
             <TextView
@@ -203,7 +221,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_marginTop="10dp"
-                android:text="请按任意按键开始测试"
+                android:text="请点击空白处开始自动化测试"
                 android:textColor="@color/red_color"
                 android:textSize="28sp" />
 

+ 11 - 0
common/src/main/code/com/wdkl/ncs/android/lib/settings/SettingConfig.java

@@ -82,6 +82,9 @@ public class SettingConfig {
     //喇叭增益
     private static final String KEY_SP_HORN_ENABLE = "KEY_SP_HORN_ENABLE";
 
+    //开关机压力测试
+    private static final String KEY_SP_REBOOT_TEST = "KEY_SP_REBOOT_TEST";
+
     public static void setMIC(Context context, int mode) {
         getEditor(context).putInt(KEY_SP_MIC_ENABLE, mode).apply();
     }
@@ -182,6 +185,14 @@ public class SettingConfig {
         getEditor(context).putBoolean(KEY_SP_AUTO_ANSWER, value).apply();
     }
 
+    public static boolean getRebootTest(Context context) {
+        return getSP(context).getBoolean(KEY_SP_REBOOT_TEST, false);
+    }
+
+    public static void setRebootTest(Context context, boolean enable) {
+        getEditor(context).putBoolean(KEY_SP_REBOOT_TEST, enable).apply();
+    }
+
     /**
      * 获取白天亮度
      *

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

@@ -257,4 +257,7 @@
     <string name="qr_code_main">Principal</string>
     <string name="qr_code_h1">Manejador 1</string>
     <string name="qr_code_h2">Manejador 2</string>
+
+    <string name="reboot_test">Reboot test…</string>
+    <string name="str_exit">Exit</string>
 </resources>

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

@@ -243,4 +243,7 @@
     <string name="qr_code_main">Main</string>
     <string name="qr_code_h1">Handler 1</string>
     <string name="qr_code_h2">Handler 2</string>
+
+    <string name="reboot_test">Reboot test…</string>
+    <string name="str_exit">Exit</string>
 </resources>

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

@@ -256,4 +256,7 @@
     <string name="qr_code_main">主机二维码</string>
     <string name="qr_code_h1">手柄1二维码</string>
     <string name="qr_code_h2">手柄2二维码</string>
+
+    <string name="reboot_test">设备开关机测试中…</string>
+    <string name="str_exit">退出</string>
 </resources>

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

@@ -255,4 +255,7 @@
     <string name="qr_code_main">Main</string>
     <string name="qr_code_h1">Handler 1</string>
     <string name="qr_code_h2">Handler 2</string>
+
+    <string name="reboot_test">Reboot test…</string>
+    <string name="str_exit">Exit</string>
 </resources>