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

Commit 62309d7d authored by Hasib Prince's avatar Hasib Prince
Browse files

App Lounge: some code refactoring

cleanup logs, removed unused methods
parent 584382cc
Loading
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -382,7 +382,6 @@ class MainActivityViewModel @Inject constructor(
            val fusedDownload =
                fusedManagerRepository.getFusedDownload(packageName = app.package_name)
            fusedManagerRepository.cancelDownload(fusedDownload)
//            InstallWorkManager.cancelWork(app._id)
        }
    }

+6 −14
Original line number Diff line number Diff line
@@ -41,6 +41,10 @@ class InstallerService : Service() {
    @Inject
    lateinit var pkgManagerModule: PkgManagerModule

    companion object {
        const val TAG = "InstallerService"
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
        val status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -69)
@@ -52,7 +56,7 @@ class InstallerService : Service() {
    }

    private fun postStatus(status: Int, packageName: String?, extra: String?) {
        Log.d("InstallerService", "postStatus: $status $packageName $extra")
        Log.d(TAG, "postStatus: $status $packageName $extra")
        if (status != PackageInstaller.STATUS_SUCCESS) {
            updateInstallationIssue(packageName ?: "")
        }
@@ -62,25 +66,13 @@ class InstallerService : Service() {
        return null
    }

    private fun updateDownloadStatus(pkgName: String) {
        if (pkgName.isEmpty()) {
            Log.d("PkgManagerBR", "updateDownloadStatus: package name should not be empty!")
        }
        GlobalScope.launch {
            val fusedDownload = fusedManagerRepository.getFusedDownload(packageName = pkgName)
            pkgManagerModule.setFakeStoreAsInstallerIfNeeded(fusedDownload)
            fusedManagerRepository.updateDownloadStatus(fusedDownload, Status.INSTALLED)
        }
    }

    private fun updateInstallationIssue(pkgName: String) {
        if (pkgName.isEmpty()) {
            Log.d("PkgManagerBR", "updateDownloadStatus: package name should not be empty!")
            Log.d(TAG, "updateDownloadStatus: package name should not be empty!")
        }
        GlobalScope.launch {
            val fusedDownload = fusedManagerRepository.getFusedDownload(packageName = pkgName)
            fusedManagerRepository.installationIssue(fusedDownload)
            Log.d("InstallService", ">>> install failed ")
        }
    }
}
+3 −3
Original line number Diff line number Diff line
@@ -145,7 +145,7 @@ class InstallAppWorker @AssistedInject constructor(
        try {
            handleFusedDownloadStatus(download)
        } catch (e: Exception) {
            Log.e(TAG, " >>> observeDownload: ", e)
            Log.e(TAG, "observeDownload: ", e)
            isDownloading = false
            unlockMutex()
        }
@@ -203,7 +203,7 @@ class InstallAppWorker @AssistedInject constructor(
                isDownloading = false
                Log.d(
                    TAG,
                    ">>> ===> doWork: Installed/Failed: ${fusedDownload.name} ${fusedDownload.status}"
                    "===> doWork: Installed/Failed: ${fusedDownload.name} ${fusedDownload.status}"
                )
                unlockMutex()
            }
@@ -212,7 +212,7 @@ class InstallAppWorker @AssistedInject constructor(
                unlockMutex()
                Log.wtf(
                    TAG,
                    ">>> ===> ${fusedDownload.name} is in wrong state ${fusedDownload.status}"
                    "===> ${fusedDownload.name} is in wrong state ${fusedDownload.status}"
                )
            }
        }