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

Commit e75cf31b authored by Hasib Prince's avatar Hasib Prince
Browse files

Added messages for sentry

parent c8d72279
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.9-alpha'
    implementation 'foundation.e.lib:telemetry:0.0.11-alpha'
    implementation 'foundation.e:gplayapi:3.0.1-2'
    implementation 'androidx.core:core-ktx:1.9.0'
    implementation 'androidx.appcompat:appcompat:1.6.1'
+27 −3
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.os.Environment
import dagger.hilt.android.qualifiers.ApplicationContext
import foundation.e.apps.OpenForTesting
import foundation.e.apps.R
import foundation.e.lib.telemetry.Telemetry
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
@@ -167,19 +168,42 @@ class DownloadManager @Inject constructor(
    }

    private fun getDownloadStatus(downloadId: Long): Int {
        var status: Int = -1
        var reason: Int = -1
        try {
            downloadManager.query(downloadManagerQuery.setFilterById(downloadId))
                .use { cursor ->
                    if (cursor.moveToFirst()) {
                        val status =
                        status =
                            cursor.getInt(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_STATUS))
                        reason =
                            cursor.getInt(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_REASON))
                        Timber.d("Download Status: downloadId: $downloadId $status")
                    }
                }
        } catch (e: Exception) {
            Timber.e(e)
        }

        if (status != DownloadManager.STATUS_SUCCESSFUL) {
            Timber.e("Download Issue: $downloadId status: $status reason: $reason")
        }
        return status
    }

    fun getDownloadReason(downloadId: Long): Int {
        var reason = -1
        try {
            downloadManager.query(downloadManagerQuery.setFilterById(downloadId))
                .use { cursor ->
                    if (cursor.moveToFirst()) {
                        reason =
                            cursor.getInt(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_REASON))
                    }
                }
        } catch (e: Exception) {
            Timber.e(e)
        }
        return DownloadManager.STATUS_FAILED
        return reason
    }
}
+14 −6
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import foundation.e.apps.data.enums.Origin
import foundation.e.apps.data.enums.Status
import foundation.e.apps.data.fusedDownload.FusedManagerRepository
import foundation.e.apps.data.fusedDownload.models.FusedDownload
import foundation.e.lib.telemetry.Telemetry
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
@@ -65,6 +66,13 @@ class DownloadManagerUtils @Inject constructor(

                    if (downloadManager.hasDownloadFailed(downloadId)) {
                        handleDownloadFailed(fusedDownload)
                        Telemetry.reportMessage(
                            "Download failed for ${fusedDownload.packageName}, reason: ${
                                downloadManager.getDownloadReason(
                                    downloadId
                                )
                            }"
                        )
                        return@launch
                    }

@@ -86,7 +94,7 @@ class DownloadManagerUtils @Inject constructor(
    private suspend fun handleDownloadFailed(fusedDownload: FusedDownload) {
        fusedManagerRepository.installationIssue(fusedDownload)
        fusedManagerRepository.cancelDownload(fusedDownload)
        Timber.i("===> Download failed: ${fusedDownload.name} ${fusedDownload.status}")
        Timber.w("===> Download failed: ${fusedDownload.name} ${fusedDownload.status}")
    }

    private suspend fun validateDownload(
+2 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import foundation.e.apps.data.fused.UpdatesDao
import foundation.e.apps.data.fusedDownload.FusedManagerRepository
import foundation.e.apps.utils.eventBus.AppEvent
import foundation.e.apps.utils.eventBus.EventBus
import foundation.e.lib.telemetry.Telemetry
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.MainScope
@@ -77,6 +78,7 @@ class InstallerService : Service() {
            return
        }

        Telemetry.reportMessage("App install is failed for: $packageName status: $status extra: $extra")
        updateInstallationIssue(packageName ?: "")
        if (status == PackageInstaller.STATUS_FAILURE_CONFLICT && extra?.contains(
                INSTALL_FAILED_UPDATE_INCOMPATIBLE
+2 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import foundation.e.apps.data.enums.Status
import foundation.e.apps.data.enums.Type
import foundation.e.apps.data.fused.FusedApi
import foundation.e.apps.data.fusedDownload.models.FusedDownload
import foundation.e.lib.telemetry.Telemetry
import kotlinx.coroutines.DelicateCoroutinesApi
import timber.log.Timber
import java.io.File
@@ -190,6 +191,7 @@ class PkgManagerModule @Inject constructor(
            session.commit(servicePendingIntent.intentSender)
        } catch (e: Exception) {
            Timber.e("$packageName: \n${e.stackTraceToString()}")
            Telemetry.reportMessage("Initiating Install Failed for $packageName exception: ${e.localizedMessage}")
            val pendingIntent = PendingIntent.getBroadcast(
                context,
                sessionId,
Loading