Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 50eda989 authored by vince-bourgmayer's avatar vince-bourgmayer
Browse files

make file readable by user

parent deac7849
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import java.lang.Thread.UncaughtExceptionHandler;
 * @author Vincent Bourgmayer
 */
public class ServiceExceptionHandler implements UncaughtExceptionHandler{
    private final static String TAG = ServiceExceptionHandler.class.getSimpleName();
    private UncaughtExceptionHandler defaultUEH;

    Service service;
@@ -39,12 +40,19 @@ public class ServiceExceptionHandler implements UncaughtExceptionHandler{

            //Create a new file that user can sent to us
            String fileName = "eDrive-crash-"+timestamp+".log";
            File downloadDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath());

            File downloadDir = service.getApplication().getExternalFilesDir("Logs");
            //File downloadDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath());
            File logFile = new File(downloadDir, fileName);
            try {

                FileOutputStream fos = new FileOutputStream(logFile);
                fos.write(getStackTraceAsString(e).getBytes());
                fos.close();
                logFile.setReadable(true, false);

                //DID NOT WORKS: CommonUtils.doActionMediaScannerConnexionScanFile(service, logFile.getCanonicalPath());

            } catch (IOException exception) {
                exception.printStackTrace();
            }