Loading app/src/main/java/foundation/e/apps/install/download/DownloadManagerUtils.kt +1 −1 Original line number Diff line number Diff line Loading @@ -123,9 +123,9 @@ class DownloadManagerUtils @Inject constructor( val numberOfDownloadedItems = fusedDownload.downloadIdMap.values.filter { it }.size Timber.d("===> updateDownloadStatus: ${fusedDownload.name}: $downloadId: $numberOfDownloadedItems/${fusedDownload.downloadIdMap.size}") // if download status code is unknown (-1), consider installation is failed. val areAllFilesDownloaded = areAllFilesDownloaded( numberOfDownloadedItems, fusedDownload Loading app/src/main/java/foundation/e/apps/receivers/DumpAppInstallStatusReceiver.kt +18 −16 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ import foundation.e.apps.data.DownloadManager import foundation.e.apps.data.enums.Status import foundation.e.apps.data.fusedDownload.FusedDownloadRepository import foundation.e.apps.data.fusedDownload.models.FusedDownload import foundation.e.apps.install.download.DownloadManagerUtils import foundation.e.apps.utils.NetworkStatusManager import foundation.e.apps.utils.StorageComputer import kotlinx.coroutines.MainScope Loading @@ -48,6 +47,7 @@ class DumpAppInstallStatusReceiver : BroadcastReceiver() { @Inject lateinit var downloadManager: DownloadManager override fun onReceive(context: Context?, intent: Intent?) { if (intent?.action == null) { return Loading @@ -56,38 +56,40 @@ class DumpAppInstallStatusReceiver : BroadcastReceiver() { MainScope().launch { val gson = Gson() val appList = fusedDownloadRepository.getDownloadList() Timber.tag(Constants.TAG_APP_INSTALL_STATE) .i("App install status: ${gson.toJson(appList)}") val appInstallStatusLog = "App install status: ${gson.toJson(appList)}" val deviceStatusLog = getDeviceInfo(context) val downloadStatusLog = getDownloadStatus(appList) logDownloadStatusFromDownloadManager(appList) logDeviceStatus(context) Timber.tag(Constants.TAG_APP_INSTALL_STATE) .e("%s\n\n%s\n\n%s", deviceStatusLog, appInstallStatusLog, downloadStatusLog) } } private fun logDeviceStatus(context: Context?) { private fun getDeviceInfo(context: Context?): String? { context?.let { val bm = context.getSystemService(BATTERY_SERVICE) as BatteryManager val batteryLevel = bm.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY) Timber.tag(Constants.TAG_APP_INSTALL_STATE) .i( "Available Space: ${StorageComputer.calculateAvailableDiskSpace()}" + return "Available Space: ${StorageComputer.calculateAvailableDiskSpace()}" + "\nInternet: ${ NetworkStatusManager.init(context).value }\nBattery level: $batteryLevel" ) } return null } private fun logDownloadStatusFromDownloadManager(appList: List<FusedDownload>) { private fun getDownloadStatus(appList: List<FusedDownload>): String { var downloadStatusLog = "" appList.forEach { if (listOf(Status.DOWNLOADING, Status.DOWNLOADED).contains(it.status)) { it.downloadIdMap.keys.forEach { downloadId -> val downloadStatus = downloadManager.isDownloadSuccessful(downloadId) Timber.tag(Constants.TAG_APP_INSTALL_STATE) .i("DownloadStatus: ${it.name}: Id: $downloadId: ${downloadStatus.second}") downloadStatusLog += "DownloadStatus: ${it.name}: Id: $downloadId: ${downloadStatus.second}\n" } } } return downloadStatusLog } } Loading
app/src/main/java/foundation/e/apps/install/download/DownloadManagerUtils.kt +1 −1 Original line number Diff line number Diff line Loading @@ -123,9 +123,9 @@ class DownloadManagerUtils @Inject constructor( val numberOfDownloadedItems = fusedDownload.downloadIdMap.values.filter { it }.size Timber.d("===> updateDownloadStatus: ${fusedDownload.name}: $downloadId: $numberOfDownloadedItems/${fusedDownload.downloadIdMap.size}") // if download status code is unknown (-1), consider installation is failed. val areAllFilesDownloaded = areAllFilesDownloaded( numberOfDownloadedItems, fusedDownload Loading
app/src/main/java/foundation/e/apps/receivers/DumpAppInstallStatusReceiver.kt +18 −16 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ import foundation.e.apps.data.DownloadManager import foundation.e.apps.data.enums.Status import foundation.e.apps.data.fusedDownload.FusedDownloadRepository import foundation.e.apps.data.fusedDownload.models.FusedDownload import foundation.e.apps.install.download.DownloadManagerUtils import foundation.e.apps.utils.NetworkStatusManager import foundation.e.apps.utils.StorageComputer import kotlinx.coroutines.MainScope Loading @@ -48,6 +47,7 @@ class DumpAppInstallStatusReceiver : BroadcastReceiver() { @Inject lateinit var downloadManager: DownloadManager override fun onReceive(context: Context?, intent: Intent?) { if (intent?.action == null) { return Loading @@ -56,38 +56,40 @@ class DumpAppInstallStatusReceiver : BroadcastReceiver() { MainScope().launch { val gson = Gson() val appList = fusedDownloadRepository.getDownloadList() Timber.tag(Constants.TAG_APP_INSTALL_STATE) .i("App install status: ${gson.toJson(appList)}") val appInstallStatusLog = "App install status: ${gson.toJson(appList)}" val deviceStatusLog = getDeviceInfo(context) val downloadStatusLog = getDownloadStatus(appList) logDownloadStatusFromDownloadManager(appList) logDeviceStatus(context) Timber.tag(Constants.TAG_APP_INSTALL_STATE) .e("%s\n\n%s\n\n%s", deviceStatusLog, appInstallStatusLog, downloadStatusLog) } } private fun logDeviceStatus(context: Context?) { private fun getDeviceInfo(context: Context?): String? { context?.let { val bm = context.getSystemService(BATTERY_SERVICE) as BatteryManager val batteryLevel = bm.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY) Timber.tag(Constants.TAG_APP_INSTALL_STATE) .i( "Available Space: ${StorageComputer.calculateAvailableDiskSpace()}" + return "Available Space: ${StorageComputer.calculateAvailableDiskSpace()}" + "\nInternet: ${ NetworkStatusManager.init(context).value }\nBattery level: $batteryLevel" ) } return null } private fun logDownloadStatusFromDownloadManager(appList: List<FusedDownload>) { private fun getDownloadStatus(appList: List<FusedDownload>): String { var downloadStatusLog = "" appList.forEach { if (listOf(Status.DOWNLOADING, Status.DOWNLOADED).contains(it.status)) { it.downloadIdMap.keys.forEach { downloadId -> val downloadStatus = downloadManager.isDownloadSuccessful(downloadId) Timber.tag(Constants.TAG_APP_INSTALL_STATE) .i("DownloadStatus: ${it.name}: Id: $downloadId: ${downloadStatus.second}") downloadStatusLog += "DownloadStatus: ${it.name}: Id: $downloadId: ${downloadStatus.second}\n" } } } return downloadStatusLog } }