From 44e332de8f53c9dfc2bc8c7f8611d595af6621c0 Mon Sep 17 00:00:00 2001 From: Sean Regan Date: Mon, 29 Sep 2025 23:58:27 -0400 Subject: [PATCH 1/2] Update service declaration foregroundServiceType and permissions --- stream-log-android-file/src/main/AndroidManifest.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stream-log-android-file/src/main/AndroidManifest.xml b/stream-log-android-file/src/main/AndroidManifest.xml index 161fba3..31630d7 100644 --- a/stream-log-android-file/src/main/AndroidManifest.xml +++ b/stream-log-android-file/src/main/AndroidManifest.xml @@ -19,6 +19,7 @@ > + @@ -26,6 +27,7 @@ android:name=".StreamLogFileService" android:enabled="true" android:exported="true" + android:foregroundServiceType="dataSync" > From 6c19cd0bd0e5f3a3a8a59315bb0459c29dce9188 Mon Sep 17 00:00:00 2001 From: Sean Regan Date: Mon, 29 Sep 2025 23:59:15 -0400 Subject: [PATCH 2/2] Fix FileStreamLogger to use file if it already exists --- .../io/getstream/log/file/FileStreamLogger.kt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/stream-log-android-file/src/main/kotlin/io/getstream/log/file/FileStreamLogger.kt b/stream-log-android-file/src/main/kotlin/io/getstream/log/file/FileStreamLogger.kt index e430a3b..939402c 100644 --- a/stream-log-android-file/src/main/kotlin/io/getstream/log/file/FileStreamLogger.kt +++ b/stream-log-android-file/src/main/kotlin/io/getstream/log/file/FileStreamLogger.kt @@ -115,18 +115,18 @@ public class FileStreamLogger( * This helper ensures safe creation of files by handling edge cases and logging issues to improve * stability across all devices. */ - if (!internalFile.exists()) { - try { + try { + if (!internalFile.exists()) { internalFile.createNewFile() + } - if (internalFile.canWrite()) { - currentFile = internalFile - currentWriter = internalFile.fileWriter() - } - } catch (e: Exception) { - Log.e("FileInit", "Failed to create or write to file: ${internalFile.absolutePath}", e) - return + if (internalFile.canWrite()) { + currentFile = internalFile + currentWriter = internalFile.fileWriter() } + } catch (e: Exception) { + Log.e("FileInit", "Failed to create or write to file: ${internalFile.absolutePath}", e) + return } } }