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

Commit c2a1b050 authored by Sayantan Roychowdhury's avatar Sayantan Roychowdhury
Browse files

Merge branch '1273-JsonSyntaxException' into 'main'

Issue 1273: Sentry json syntax exception

See merge request !316
parents 020237ab 1d21289f
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -150,7 +150,7 @@ dependencies {
    // TODO: Add splitinstall-lib to a repo https://gitlab.e.foundation/e/os/backlog/-/issues/628
    api files('libs/splitinstall-lib.jar')

    implementation 'foundation.e.lib:telemetry:0.0.8-alpha'
    implementation 'foundation.e.lib:telemetry:0.0.9-alpha'

    implementation 'foundation.e:gplayapi:3.0.1'
    implementation 'androidx.core:core-ktx:1.9.0'
+15 −5
Original line number Diff line number Diff line
@@ -20,12 +20,14 @@ package foundation.e.apps.data.blockedApps
import com.google.gson.Gson
import foundation.e.apps.data.DownloadManager
import foundation.e.apps.data.fusedDownload.FileManager
import foundation.e.lib.telemetry.Telemetry
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import java.io.File
import javax.inject.Inject
import javax.inject.Named
import javax.inject.Singleton
import timber.log.Timber

@Singleton
class BlockedAppRepository @Inject constructor(
@@ -60,11 +62,19 @@ class BlockedAppRepository @Inject constructor(

    private fun parseBlockedAppDataFromFile() {
        coroutineScope.launch {
            blockedAppInfoList = try {
                val outputPath = "$cacheDir/warning_list/"
                FileManager.moveFile("$cacheDir/", WARNING_LIST_FILE_NAME, outputPath)
                val downloadedFile = File(outputPath + WARNING_LIST_FILE_NAME)
                Timber.i("Blocked list file exists: ${downloadedFile.exists()}")
                val blockedAppInfoJson = String(downloadedFile.inputStream().readBytes())
            blockedAppInfoList = gson.fromJson(blockedAppInfoJson, AppWarningInfo::class.java)
                Timber.i("Blocked list file contents: $blockedAppInfoJson")
                gson.fromJson(blockedAppInfoJson, AppWarningInfo::class.java)
            } catch (exception: Exception) {
                exception.printStackTrace()
                Telemetry.reportException(exception)
                AppWarningInfo(listOf())
            }
        }
    }
}