From fef94711ae3a60b6903d0d3a991fbbe53dbf79c4 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Mon, 29 Apr 2024 11:35:21 +0200 Subject: [PATCH 1/3] chore: remove unused class: ServiceExceptionHandler --- .../drive/utils/ServiceExceptionHandler.java | 100 ------------------ 1 file changed, 100 deletions(-) delete mode 100644 app/src/main/java/foundation/e/drive/utils/ServiceExceptionHandler.java diff --git a/app/src/main/java/foundation/e/drive/utils/ServiceExceptionHandler.java b/app/src/main/java/foundation/e/drive/utils/ServiceExceptionHandler.java deleted file mode 100644 index 71da2297..00000000 --- a/app/src/main/java/foundation/e/drive/utils/ServiceExceptionHandler.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright © CLEUS SAS 2018-2019. - * Copyright © ECORP SAS 2022. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - */ -package foundation.e.drive.utils; -import android.annotation.SuppressLint; -import android.app.Service; -import android.os.Environment; - -import androidx.annotation.NonNull; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.lang.Thread.UncaughtExceptionHandler; - -/** - * todo: check if still usefull or if it can be remove - * @author Vincent Bourgmayer - */ -public class ServiceExceptionHandler implements UncaughtExceptionHandler { - public final static String CRASH_LOG_FOLDER = "crash-logs"; - public final static String LOG_FILE_NAME_PREFIX = "eDrive-crash-"; - public final static String LOG_FILE_EXTENSION = ".log"; - private final UncaughtExceptionHandler defaultUEH; - - Service service; - - /** - * Update the service which use this handler - * @param service current running service - */ - public void setService(@NonNull Service service) { - this.service = service; - } - - public ServiceExceptionHandler(@NonNull Service service) { - this.service = service; - defaultUEH = Thread.getDefaultUncaughtExceptionHandler(); - } - - @SuppressLint("SetWorldReadable") - @Override - public void uncaughtException(@NonNull Thread t, @NonNull Throwable exception) { - - if (isExternalStorageAvailable() && !isExternalStorageReadOnly()) { - - final long timestamp = System.currentTimeMillis(); - - final String fileName = LOG_FILE_NAME_PREFIX+timestamp+LOG_FILE_EXTENSION; - - final File downloadDir = service.getApplication().getExternalFilesDir(CRASH_LOG_FOLDER); - final File logFile = new File(downloadDir, fileName); - try (FileOutputStream fos = new FileOutputStream(logFile)) { - fos.write(service.getClass().getSimpleName().getBytes()); - fos.write(getStackTraceAsString(exception).getBytes()); - logFile.setReadable(true, false); - } catch (IOException ioException) { - ioException.printStackTrace(); - } - } - //source: https://stackoverflow.com/questions/9050962/rethrow-uncaughtexceptionhandler-exception-after-logging-it/9050990#9050990 - if (defaultUEH != null) { - defaultUEH.uncaughtException(t, exception); - } else { - System.exit(1); //Kill /e/ Drive... - } - } - - //source: https://www.journaldev.com/9400/android-external-storage-read-write-save-file - private static boolean isExternalStorageAvailable() { - final String extStorageState = Environment.getExternalStorageState(); - return Environment.MEDIA_MOUNTED.equals(extStorageState); - } - - //source: https://www.journaldev.com/9400/android-external-storage-read-write-save-file - private static boolean isExternalStorageReadOnly() { - final String extStorageState = Environment.getExternalStorageState(); - return Environment.MEDIA_MOUNTED_READ_ONLY.equals(extStorageState); - } - - /** - * Return the stackTrace of the exception as a String - * @param exception the exception - * @return the Stacktrace as a string - */ - @NonNull - private String getStackTraceAsString(Throwable exception) { - final StringWriter sw = new StringWriter(); - final PrintWriter pw = new PrintWriter(sw); - exception.printStackTrace(pw); - return sw.toString(); - } -} \ No newline at end of file -- GitLab From 6466903e1f2f898eb88d578191e31a6062e4b97d Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Mon, 29 Apr 2024 14:10:34 +0200 Subject: [PATCH 2/3] chore: remove persistence reference in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 35f46a7f..bfb15610 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # eDrive -eDrive is a [persistent][doc-persistence] application provided by default with /e/OS. +eDrive is a application provided by default with /e/OS. It synchronizes user's data files to /e/Cloud or a self-hosted cloud. ## Install -- GitLab From e86102e60fd62d21842f9c5dd0ae1ee59ab6a714 Mon Sep 17 00:00:00 2001 From: Fahim Masud Choudhury Date: Mon, 29 Apr 2024 16:11:23 +0000 Subject: [PATCH 3/3] chore: apply suggestion. Fix Readme typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bfb15610..2ac3a5d0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # eDrive -eDrive is a application provided by default with /e/OS. +eDrive is an application provided by default with /e/OS. It synchronizes user's data files to /e/Cloud or a self-hosted cloud. ## Install -- GitLab