Browse Source

增加文件导出、删除失败bugly主动上报异常信息

zk 1 year ago
parent
commit
c4e0ccb595

+ 2 - 0
app/src/main/java/com/datarecovery/master/module/audiorecover/AudioRecoverViewModel.java

@@ -13,6 +13,7 @@ import com.datarecovery.master.data.repositories.DeviceFuncRepository;
 import com.datarecovery.master.handler.EventHelper;
 import com.datarecovery.master.module.imgrecover.ImageRecoverActivity;
 import com.datarecovery.master.module.member.MemberType;
+import com.datarecovery.master.sdk.bugly.BuglyHelper;
 import com.datarecovery.master.utils.FileUtil;
 import com.datarecovery.master.utils.FilesSearch;
 import com.datarecovery.master.utils.MediaStoreHelper;
@@ -233,6 +234,7 @@ public class AudioRecoverViewModel extends BaseViewModel {
         }, throwable -> {
             showLoadingEvent.setValue(false);
             ToastUtil.show(R.string.export_fail, ToastUtil.LENGTH_SHORT);
+            BuglyHelper.postCatchedException(FileUtil.getFileListFailException(list, "音频导出失败"));
         });
     }
 

+ 2 - 0
app/src/main/java/com/datarecovery/master/module/filerecover/FileRecoverViewModel.java

@@ -12,6 +12,7 @@ import com.datarecovery.master.data.consts.EventId;
 import com.datarecovery.master.data.repositories.DeviceFuncRepository;
 import com.datarecovery.master.handler.EventHelper;
 import com.datarecovery.master.module.member.MemberType;
+import com.datarecovery.master.sdk.bugly.BuglyHelper;
 import com.datarecovery.master.utils.BoxingUtil;
 import com.datarecovery.master.utils.FileUtil;
 import com.datarecovery.master.utils.FilesSearch;
@@ -259,6 +260,7 @@ public class FileRecoverViewModel extends BaseViewModel {
         }, throwable -> {
             showLoadingEvent.setValue(false);
             ToastUtil.show(R.string.export_fail, ToastUtil.LENGTH_SHORT);
+            BuglyHelper.postCatchedException(FileUtil.getFileListFailException(list, "文件导出失败"));
         });
     }
 

+ 3 - 0
app/src/main/java/com/datarecovery/master/module/imgrecover/ImageRecoverViewModel.java

@@ -29,6 +29,7 @@ import com.datarecovery.master.data.consts.EventId;
 import com.datarecovery.master.data.repositories.DeviceFuncRepository;
 import com.datarecovery.master.handler.EventHelper;
 import com.datarecovery.master.module.member.MemberType;
+import com.datarecovery.master.sdk.bugly.BuglyHelper;
 import com.datarecovery.master.utils.BoxingUtil;
 import com.datarecovery.master.utils.FileUtil;
 import com.datarecovery.master.utils.ImageDeepDetector;
@@ -435,6 +436,7 @@ public class ImageRecoverViewModel extends BaseViewModel {
                     public void onError(@NonNull Throwable e) {
                         showLoadingEvent.setValue(false);
                         ToastUtil.show(R.string.delete_fail, ToastUtil.LENGTH_SHORT);
+                        BuglyHelper.postCatchedException(FileUtil.getFileListFailException(list, "图片清除失败"));
                     }
                 });
     }
@@ -488,6 +490,7 @@ public class ImageRecoverViewModel extends BaseViewModel {
         }, throwable -> {
             showLoadingEvent.setValue(false);
             ToastUtil.show(R.string.export_fail, ToastUtil.LENGTH_SHORT);
+            BuglyHelper.postCatchedException(FileUtil.getFileListFailException(list, "图片导出失败"));
         });
     }
 

+ 2 - 0
app/src/main/java/com/datarecovery/master/module/videorecover/VideoRecoverViewModel.java

@@ -13,6 +13,7 @@ import com.datarecovery.master.data.consts.EventId;
 import com.datarecovery.master.data.repositories.DeviceFuncRepository;
 import com.datarecovery.master.handler.EventHelper;
 import com.datarecovery.master.module.member.MemberType;
+import com.datarecovery.master.sdk.bugly.BuglyHelper;
 import com.datarecovery.master.utils.FileUtil;
 import com.datarecovery.master.utils.FilesSearch;
 import com.datarecovery.master.utils.MediaStoreHelper;
@@ -201,6 +202,7 @@ public class VideoRecoverViewModel extends BaseViewModel {
         }, throwable -> {
             showLoadingEvent.setValue(false);
             ToastUtil.show(R.string.export_fail, ToastUtil.LENGTH_SHORT);
+            BuglyHelper.postCatchedException(FileUtil.getFileListFailException(list, "视频导出失败"));
         });
     }
 

+ 6 - 0
app/src/main/java/com/datarecovery/master/sdk/bugly/BuglyHelper.java

@@ -57,4 +57,10 @@ public class BuglyHelper {
     public static void initAfterGrantedAgreement() {
         CrashReport.setDeviceModel(ContextUtil.getContext(), Build.MODEL);
     }
+
+
+    public static void postCatchedException(Throwable throwable) {
+        CrashReport.postCatchedException(throwable, Thread.currentThread());
+    }
+
 }

+ 18 - 0
app/src/main/java/com/datarecovery/master/utils/FileUtil.java

@@ -10,6 +10,8 @@ import android.text.format.Formatter;
 import com.atmob.common.runtime.ContextUtil;
 import com.datarecovery.master.R;
 
+import java.util.Arrays;
+import java.util.List;
 import java.util.Locale;
 import java.util.UUID;
 
@@ -58,6 +60,10 @@ public class FileUtil {
         }
     }
 
+    public static String getExportAudioFileName(String fileName) {
+        return fileName + "_" + System.currentTimeMillis() + ".mp3";
+    }
+
 
     public static String getCreateFileName(String fileName, String defaultSuffix) {
         String uuid = UUID.randomUUID().toString();
@@ -86,5 +92,17 @@ public class FileUtil {
         return null;
     }
 
+    public static Exception getFileListFailException(List<?> list, String messageHeadTxt) {
+        if (list == null) {
+            return null;
+        }
+        StringBuilder sb = new StringBuilder();
+        sb.append(messageHeadTxt);
+        sb.append("/n");
+        sb.append("==============================");
+        sb.append(Arrays.toString(list.toArray()));
+        sb.append("==============================");
+        return new Exception(sb.toString());
+    }
 
 }