浏览代码

打开异常处理

weizhengliang 1 年之前
父节点
当前提交
35cda0c466

+ 1 - 1
app/src/main/code/com/wdkl/app/ncs/application/Application.kt

@@ -98,7 +98,7 @@ class Application : BaseApplication() {
 
 
 
 
         //anr catcher
         //anr catcher
-        //AnrFcExceptionUtil.getInstance(this).initFCException()
+        AnrFcExceptionUtil.getInstance(this).initFCException()
 
 
         //xCrash catcher
         //xCrash catcher
         //XCrashUtils().init(this)
         //XCrashUtils().init(this)

+ 1 - 1
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/activity/CallingdoorActivity.kt

@@ -250,7 +250,7 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
 
 
         Log.d(TAG, "app data file: " + filesDir.absoluteFile + ", canWrite: " + filesDir.absoluteFile.canWrite())
         Log.d(TAG, "app data file: " + filesDir.absoluteFile + ", canWrite: " + filesDir.absoluteFile.canWrite())
 
 
-        startScheduledExecutor()
+        //startScheduledExecutor()
     }
     }
 
 
     /**
     /**

+ 4 - 38
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/helper/AnrFcExceptionUtil.java

@@ -79,12 +79,6 @@ public class AnrFcExceptionUtil implements Thread.UncaughtExceptionHandler {
             //如果用户没有处理则让系统默认的异常处理器来处理
             //如果用户没有处理则让系统默认的异常处理器来处理
             mDefaultHandler.uncaughtException(thread, ex);
             mDefaultHandler.uncaughtException(thread, ex);
         } else {
         } else {
-            try {
-                Thread.sleep(5000);
-            } catch (InterruptedException e) {
-                Log.e(TAG, "error : ", e);
-            }
-
             //restartApp();
             //restartApp();
             AppUpdateHelper.reboot(application);
             AppUpdateHelper.reboot(application);
         }
         }
@@ -110,7 +104,9 @@ public class AnrFcExceptionUtil implements Thread.UncaughtExceptionHandler {
                 Looper.loop();
                 Looper.loop();
             }
             }
         }.start();*/
         }.start();*/
-        saveCrashInfo2File(ex);
+        //saveCrashInfo2File(ex);
+
+        AppUpdateHelper.reboot(application);
         return true;
         return true;
     }
     }
 
 
@@ -227,38 +223,8 @@ public class AnrFcExceptionUtil implements Thread.UncaughtExceptionHandler {
         }).setIgnoreDebugger(true).setANRListener(new ANRWatchDog.ANRListener() {
         }).setIgnoreDebugger(true).setANRListener(new ANRWatchDog.ANRListener() {
             @Override
             @Override
             public void onAppNotResponding(ANRError error) {
             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...");
                 Log.d("anr", "Anr restart app...");
-                if ("rk3128".equals(Build.MODEL) || "WDMK_I".equals(Build.MODEL) || "WDMKI".equals(Build.MODEL)) {
-                    AppUpdateHelper.reboot(application);
-                } else {
-                    restartApp();
-                }
+                AppUpdateHelper.reboot(application);
             }
             }
         }).start();
         }).start();
 
 

+ 0 - 1
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/helper/DoorLightHelper.java

@@ -41,7 +41,6 @@ public class DoorLightHelper {
             SerialPortHelper.setDoorLight(1, Constant.nursingColor); //绿色
             SerialPortHelper.setDoorLight(1, Constant.nursingColor); //绿色
         } else {
         } else {
             SerialPortHelper.setDoorLight(1, "111"); //白色
             SerialPortHelper.setDoorLight(1, "111"); //白色
-
         }
         }
     }
     }
 }
 }