Loading app/src/main/java/foundation/e/apps/data/DownloadManager.kt +10 −6 Original line number Diff line number Diff line Loading @@ -50,8 +50,11 @@ class DownloadManager @Inject constructor( ) { private val downloadsMaps = HashMap<Long, Boolean>() companion object { private val SDCARD_PATH = Environment.getExternalStorageDirectory().absolutePath val EXTERNAL_STORAGE_TEMP_CACHE_DIR = "$SDCARD_PATH/Download/AppLounge/SplitInstallApks" private const val UNKNOWN_ERROR_OR_REASON = -1 } fun downloadFileInCache( url: String, Loading Loading @@ -186,7 +189,8 @@ class DownloadManager @Inject constructor( } fun hasDownloadFailed(downloadId: Long): Boolean { return getDownloadStatus(downloadId) == DownloadManager.STATUS_FAILED return listOf(DownloadManager.STATUS_FAILED, UNKNOWN_ERROR_OR_REASON) .contains(getDownloadStatus(downloadId)) } fun getSizeRequired(downloadId: Long): Long { Loading Loading @@ -218,8 +222,8 @@ class DownloadManager @Inject constructor( } private fun getDownloadStatus(downloadId: Long): Int { var status = -1 var reason = -1 var status = UNKNOWN_ERROR_OR_REASON var reason = UNKNOWN_ERROR_OR_REASON try { downloadManager.query(downloadManagerQuery.setFilterById(downloadId)) .use { cursor -> Loading Loading @@ -261,7 +265,7 @@ class DownloadManager @Inject constructor( } fun getDownloadFailureReason(downloadId: Long): Int { var reason = -1 var reason = UNKNOWN_ERROR_OR_REASON try { downloadManager.query(downloadManagerQuery.setFilterById(downloadId)) .use { cursor -> Loading app/src/main/java/foundation/e/apps/data/application/apps/AppsApiImpl.kt +6 −11 Original line number Diff line number Diff line Loading @@ -114,11 +114,8 @@ class AppsApiImpl @Inject constructor( val applicationList = mutableListOf<Application>() for (packageName in packageNameList) { val result = getCleanApkSearchResultByPackageName(packageName, applicationList) status = result.getResultStatus() if (status != ResultStatus.OK) { return Pair(applicationList, status) getCleanApkSearchResultByPackageName(packageName).data?.run { handleCleanApkSearch(applicationList) } } Loading Loading @@ -151,10 +148,11 @@ class AppsApiImpl @Inject constructor( authData: AuthData, applicationList: MutableList<Application> ) { val filter = applicationDataManager.getAppFilterLevel(app.toApplication(context), authData) val application = app.toApplication(context) val filter = applicationDataManager.getAppFilterLevel(application, authData) if (filter.isUnFiltered()) { applicationList.add( app.toApplication(context).apply { application.apply { filterLevel = filter } ) Loading @@ -163,14 +161,11 @@ class AppsApiImpl @Inject constructor( private suspend fun getCleanApkSearchResultByPackageName( packageName: String, applicationList: MutableList<Application> ) = handleNetworkResult { appSources.cleanApkAppsRepo.getSearchResult( packageName, KEY_SEARCH_PACKAGE_NAME ).body()?.run { handleCleanApkSearch(applicationList) } ).body() } private suspend fun Search.handleCleanApkSearch( Loading app/src/main/java/foundation/e/apps/data/updates/UpdatesManagerImpl.kt +31 −14 Original line number Diff line number Diff line Loading @@ -30,9 +30,11 @@ import foundation.e.apps.data.enums.Status import foundation.e.apps.data.enums.isUnFiltered import foundation.e.apps.data.faultyApps.FaultyAppRepository import foundation.e.apps.data.fdroid.FdroidRepository import foundation.e.apps.data.playstore.PlayStoreRepositoryImpl import foundation.e.apps.data.application.ApplicationRepository import foundation.e.apps.data.application.search.SearchApi.Companion.APP_TYPE_ANY import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.handleNetworkResult import foundation.e.apps.data.preference.AppLoungePreference import foundation.e.apps.install.pkg.AppLoungePackageManager import kotlinx.coroutines.Dispatchers Loading Loading @@ -196,8 +198,9 @@ class UpdatesManagerImpl @Inject constructor( * Aurora Store, Apk mirror, apps installed from browser, apps from ADB etc. */ private fun getAppsFromOtherStores(): List<String> { val gplayAndOpenSourceInstalledApps = getGPlayInstalledApps() + getOpenSourceInstalledApps() return userApplications.filter { it.packageName !in (getGPlayInstalledApps() + getOpenSourceInstalledApps()) it.packageName !in gplayAndOpenSourceInstalledApps }.map { it.packageName } } Loading Loading @@ -225,8 +228,8 @@ class UpdatesManagerImpl @Inject constructor( } /** * Bulk info from gplay api is not providing correct geo restriction status of apps. * So we get all individual app information asynchronously. * Bulk info from gplay api [PlayStoreRepositoryImpl.getAppsDetails] is not providing correct * geo restriction status of apps. So we get all individual app information asynchronously. * Example: in.startv.hotstar.dplus * Issue: https://gitlab.e.foundation/e/backlog/-/issues/7135 */ Loading @@ -250,7 +253,7 @@ class UpdatesManagerImpl @Inject constructor( } val status = appsResults.find { it.second != ResultStatus.OK }?.second ?: ResultStatus.OK val appsList = appsResults.map { it.first } val appsList = appsResults.filter { it.first.package_name.isNotEmpty() }.map { it.first } return Pair(appsList, status) } Loading @@ -273,24 +276,32 @@ class UpdatesManagerImpl @Inject constructor( private suspend fun getFDroidAppsAndSignatures(installedPackageNames: List<String>): Map<String, String> { val appsAndSignatures = hashMapOf<String, String>() for (packageName in installedPackageNames) { updateAppsWithPGPSignature(packageName, appsAndSignatures) } return appsAndSignatures } private suspend fun updateAppsWithPGPSignature( packageName: String, appsAndSignatures: HashMap<String, String> ) { val cleanApkFusedApp = applicationRepository.getCleanapkAppDetails(packageName).first if (cleanApkFusedApp.package_name.isBlank()) { continue return } appsAndSignatures[packageName] = getPgpSignature(cleanApkFusedApp) } return appsAndSignatures } private suspend fun getPgpSignature(cleanApkApplication: Application): String { val installedVersionSignature = calculateSignatureVersion(cleanApkApplication) val downloadInfo = val downloadInfoResult = handleNetworkResult { applicationRepository .getOSSDownloadInfo(cleanApkApplication._id, installedVersionSignature) .body()?.download_data } val pgpSignature = downloadInfo?.signature ?: "" val pgpSignature = downloadInfoResult.data?.signature ?: "" Timber.i( "Signature calculated for : ${cleanApkApplication.package_name}, " + Loading @@ -298,7 +309,7 @@ class UpdatesManagerImpl @Inject constructor( "is sig blank: ${pgpSignature.isBlank()}" ) return downloadInfo?.signature ?: "" return pgpSignature } /** Loading @@ -314,8 +325,12 @@ class UpdatesManagerImpl @Inject constructor( val fDroidAppsAndSignatures = getFDroidAppsAndSignatures(installedPackageNames) val fDroidUpdatablePackageNames = fDroidAppsAndSignatures.filter { if (it.value.isEmpty()) return@filter false // For each installed app also present on F-droid, check signature of base APK. val baseApkPath = appLoungePackageManager.getBaseApkPath(it.key) if (baseApkPath.isEmpty()) return@filter false ApkSignatureManager.verifyFdroidSignature(context, baseApkPath, it.value, it.key) }.map { it.key } Loading Loading @@ -358,9 +373,11 @@ class UpdatesManagerImpl @Inject constructor( // Received list has build info of the latest version at the bottom. // We want it at the top. val builds = fdroidRepository.getBuildVersionInfo(packageName)?.asReversed() ?: return "" val builds = handleNetworkResult { fdroidRepository.getBuildVersionInfo(packageName)?.asReversed() ?: listOf() }.data val matchingIndex = builds.find { val matchingIndex = builds?.find { it.versionCode == installedVersionCode && it.versionName == installedVersionName }?.run { builds.indexOf(this) Loading app/src/main/java/foundation/e/apps/install/pkg/AppLoungePackageManager.kt +33 −20 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.content.pm.PackageInfo import android.content.pm.PackageInstaller.Session import android.content.pm.PackageInstaller.SessionParams import android.content.pm.PackageManager import android.content.pm.PackageManager.NameNotFoundException import android.os.Build import androidx.core.content.pm.PackageInfoCompat import dagger.hilt.android.qualifiers.ApplicationContext Loading @@ -39,6 +40,7 @@ import foundation.e.apps.data.fusedDownload.models.FusedDownload import kotlinx.coroutines.DelicateCoroutinesApi import timber.log.Timber import java.io.File import java.lang.IllegalArgumentException import javax.inject.Inject import javax.inject.Singleton Loading @@ -51,7 +53,9 @@ class AppLoungePackageManager @Inject constructor( const val ERROR_PACKAGE_INSTALL = "ERROR_PACKAGE_INSTALL" const val PACKAGE_NAME = "packageName" const val FAKE_STORE_PACKAGE_NAME = "com.android.vending" private const val UNKNOWN_VALUE = "" } private val packageManager = context.packageManager fun isInstalled(packageName: String): Boolean { Loading @@ -69,15 +73,8 @@ class AppLoungePackageManager @Inject constructor( } private fun isUpdatable(packageName: String, versionCode: Int): Boolean { return try { val packageInfo = getPackageInfo(packageName) packageInfo?.let { return versionCode.toLong() > PackageInfoCompat.getLongVersionCode(it) } true } catch (e: PackageManager.NameNotFoundException) { false } val packageInfo = getPackageInfo(packageName) ?: return false return versionCode.toLong() > PackageInfoCompat.getLongVersionCode(packageInfo) } fun getLaunchIntent(packageName: String): Intent? { Loading @@ -85,7 +82,12 @@ class AppLoungePackageManager @Inject constructor( } private fun getPackageInfo(packageName: String): PackageInfo? { return packageManager.getPackageInfo(packageName, 0) return try { packageManager.getPackageInfo(packageName, 0) } catch (e: NameNotFoundException) { Timber.e("getPackageInfo: ${e.localizedMessage}") null } } /** Loading Loading @@ -133,11 +135,19 @@ class AppLoungePackageManager @Inject constructor( } fun getInstallerName(packageName: String): String { return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { return try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { val installerInfo = packageManager.getInstallSourceInfo(packageName) installerInfo.originatingPackageName ?: installerInfo.installingPackageName ?: "" installerInfo.originatingPackageName ?: installerInfo.installingPackageName ?: UNKNOWN_VALUE } else { packageManager.getInstallerPackageName(packageName) ?: "" packageManager.getInstallerPackageName(packageName) ?: UNKNOWN_VALUE } } catch (e: NameNotFoundException) { Timber.e("getInstallerName -> $packageName : ${e.localizedMessage}") UNKNOWN_VALUE } catch (e: IllegalArgumentException) { Timber.e("getInstallerName -> $packageName : ${e.localizedMessage}") UNKNOWN_VALUE } } Loading @@ -146,22 +156,22 @@ class AppLoungePackageManager @Inject constructor( */ fun getBaseApkPath(packageName: String): String { val packageInfo = getPackageInfo(packageName) return packageInfo?.applicationInfo?.publicSourceDir ?: "" return packageInfo?.applicationInfo?.publicSourceDir ?: UNKNOWN_VALUE } fun getVersionCode(packageName: String): String { val packageInfo = getPackageInfo(packageName) return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { packageInfo?.longVersionCode?.toString() ?: "" packageInfo?.longVersionCode?.toString() ?: UNKNOWN_VALUE } else { @Suppress("DEPRECATION") packageInfo?.versionCode?.toString() ?: "" packageInfo?.versionCode?.toString() ?: UNKNOWN_VALUE } } fun getVersionName(packageName: String): String { val packageInfo = getPackageInfo(packageName) return packageInfo?.versionName?.toString() ?: "" return packageInfo?.versionName?.toString() ?: UNKNOWN_VALUE } /** Loading Loading @@ -194,7 +204,10 @@ class AppLoungePackageManager @Inject constructor( ) session.commit(servicePendingIntent.intentSender) } catch (e: Exception) { Timber.e("Initiating Install Failed for $packageName exception: ${e.localizedMessage}", e) Timber.e( "Initiating Install Failed for $packageName exception: ${e.localizedMessage}", e ) val pendingIntent = PendingIntent.getBroadcast( context, sessionId, Loading app/src/main/java/foundation/e/apps/install/updates/UpdatesWorker.kt +3 −3 Original line number Diff line number Diff line Loading @@ -138,7 +138,7 @@ class UpdatesWorker @AssistedInject constructor( } if (resultStatus != ResultStatus.OK) { manageRetry() manageRetry(resultStatus.toString()) } else { /* * Show notification only if enabled. Loading @@ -162,7 +162,7 @@ class UpdatesWorker @AssistedInject constructor( } } private suspend fun manageRetry() { private suspend fun manageRetry(extraMessage: String) { retryCount++ if (retryCount == 1) { EventBus.invokeEvent(AppEvent.UpdateEvent(ResultSupreme.WorkError(ResultStatus.RETRY))) Loading @@ -172,7 +172,7 @@ class UpdatesWorker @AssistedInject constructor( delay(DELAY_FOR_RETRY) checkForUpdates() } else { val message = "Update is aborted after trying for $MAX_RETRY_COUNT times!" val message = "Update is aborted after trying for $MAX_RETRY_COUNT times! message: $extraMessage" Timber.e(message) EventBus.invokeEvent(AppEvent.UpdateEvent(ResultSupreme.WorkError(ResultStatus.UNKNOWN))) } Loading Loading
app/src/main/java/foundation/e/apps/data/DownloadManager.kt +10 −6 Original line number Diff line number Diff line Loading @@ -50,8 +50,11 @@ class DownloadManager @Inject constructor( ) { private val downloadsMaps = HashMap<Long, Boolean>() companion object { private val SDCARD_PATH = Environment.getExternalStorageDirectory().absolutePath val EXTERNAL_STORAGE_TEMP_CACHE_DIR = "$SDCARD_PATH/Download/AppLounge/SplitInstallApks" private const val UNKNOWN_ERROR_OR_REASON = -1 } fun downloadFileInCache( url: String, Loading Loading @@ -186,7 +189,8 @@ class DownloadManager @Inject constructor( } fun hasDownloadFailed(downloadId: Long): Boolean { return getDownloadStatus(downloadId) == DownloadManager.STATUS_FAILED return listOf(DownloadManager.STATUS_FAILED, UNKNOWN_ERROR_OR_REASON) .contains(getDownloadStatus(downloadId)) } fun getSizeRequired(downloadId: Long): Long { Loading Loading @@ -218,8 +222,8 @@ class DownloadManager @Inject constructor( } private fun getDownloadStatus(downloadId: Long): Int { var status = -1 var reason = -1 var status = UNKNOWN_ERROR_OR_REASON var reason = UNKNOWN_ERROR_OR_REASON try { downloadManager.query(downloadManagerQuery.setFilterById(downloadId)) .use { cursor -> Loading Loading @@ -261,7 +265,7 @@ class DownloadManager @Inject constructor( } fun getDownloadFailureReason(downloadId: Long): Int { var reason = -1 var reason = UNKNOWN_ERROR_OR_REASON try { downloadManager.query(downloadManagerQuery.setFilterById(downloadId)) .use { cursor -> Loading
app/src/main/java/foundation/e/apps/data/application/apps/AppsApiImpl.kt +6 −11 Original line number Diff line number Diff line Loading @@ -114,11 +114,8 @@ class AppsApiImpl @Inject constructor( val applicationList = mutableListOf<Application>() for (packageName in packageNameList) { val result = getCleanApkSearchResultByPackageName(packageName, applicationList) status = result.getResultStatus() if (status != ResultStatus.OK) { return Pair(applicationList, status) getCleanApkSearchResultByPackageName(packageName).data?.run { handleCleanApkSearch(applicationList) } } Loading Loading @@ -151,10 +148,11 @@ class AppsApiImpl @Inject constructor( authData: AuthData, applicationList: MutableList<Application> ) { val filter = applicationDataManager.getAppFilterLevel(app.toApplication(context), authData) val application = app.toApplication(context) val filter = applicationDataManager.getAppFilterLevel(application, authData) if (filter.isUnFiltered()) { applicationList.add( app.toApplication(context).apply { application.apply { filterLevel = filter } ) Loading @@ -163,14 +161,11 @@ class AppsApiImpl @Inject constructor( private suspend fun getCleanApkSearchResultByPackageName( packageName: String, applicationList: MutableList<Application> ) = handleNetworkResult { appSources.cleanApkAppsRepo.getSearchResult( packageName, KEY_SEARCH_PACKAGE_NAME ).body()?.run { handleCleanApkSearch(applicationList) } ).body() } private suspend fun Search.handleCleanApkSearch( Loading
app/src/main/java/foundation/e/apps/data/updates/UpdatesManagerImpl.kt +31 −14 Original line number Diff line number Diff line Loading @@ -30,9 +30,11 @@ import foundation.e.apps.data.enums.Status import foundation.e.apps.data.enums.isUnFiltered import foundation.e.apps.data.faultyApps.FaultyAppRepository import foundation.e.apps.data.fdroid.FdroidRepository import foundation.e.apps.data.playstore.PlayStoreRepositoryImpl import foundation.e.apps.data.application.ApplicationRepository import foundation.e.apps.data.application.search.SearchApi.Companion.APP_TYPE_ANY import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.handleNetworkResult import foundation.e.apps.data.preference.AppLoungePreference import foundation.e.apps.install.pkg.AppLoungePackageManager import kotlinx.coroutines.Dispatchers Loading Loading @@ -196,8 +198,9 @@ class UpdatesManagerImpl @Inject constructor( * Aurora Store, Apk mirror, apps installed from browser, apps from ADB etc. */ private fun getAppsFromOtherStores(): List<String> { val gplayAndOpenSourceInstalledApps = getGPlayInstalledApps() + getOpenSourceInstalledApps() return userApplications.filter { it.packageName !in (getGPlayInstalledApps() + getOpenSourceInstalledApps()) it.packageName !in gplayAndOpenSourceInstalledApps }.map { it.packageName } } Loading Loading @@ -225,8 +228,8 @@ class UpdatesManagerImpl @Inject constructor( } /** * Bulk info from gplay api is not providing correct geo restriction status of apps. * So we get all individual app information asynchronously. * Bulk info from gplay api [PlayStoreRepositoryImpl.getAppsDetails] is not providing correct * geo restriction status of apps. So we get all individual app information asynchronously. * Example: in.startv.hotstar.dplus * Issue: https://gitlab.e.foundation/e/backlog/-/issues/7135 */ Loading @@ -250,7 +253,7 @@ class UpdatesManagerImpl @Inject constructor( } val status = appsResults.find { it.second != ResultStatus.OK }?.second ?: ResultStatus.OK val appsList = appsResults.map { it.first } val appsList = appsResults.filter { it.first.package_name.isNotEmpty() }.map { it.first } return Pair(appsList, status) } Loading @@ -273,24 +276,32 @@ class UpdatesManagerImpl @Inject constructor( private suspend fun getFDroidAppsAndSignatures(installedPackageNames: List<String>): Map<String, String> { val appsAndSignatures = hashMapOf<String, String>() for (packageName in installedPackageNames) { updateAppsWithPGPSignature(packageName, appsAndSignatures) } return appsAndSignatures } private suspend fun updateAppsWithPGPSignature( packageName: String, appsAndSignatures: HashMap<String, String> ) { val cleanApkFusedApp = applicationRepository.getCleanapkAppDetails(packageName).first if (cleanApkFusedApp.package_name.isBlank()) { continue return } appsAndSignatures[packageName] = getPgpSignature(cleanApkFusedApp) } return appsAndSignatures } private suspend fun getPgpSignature(cleanApkApplication: Application): String { val installedVersionSignature = calculateSignatureVersion(cleanApkApplication) val downloadInfo = val downloadInfoResult = handleNetworkResult { applicationRepository .getOSSDownloadInfo(cleanApkApplication._id, installedVersionSignature) .body()?.download_data } val pgpSignature = downloadInfo?.signature ?: "" val pgpSignature = downloadInfoResult.data?.signature ?: "" Timber.i( "Signature calculated for : ${cleanApkApplication.package_name}, " + Loading @@ -298,7 +309,7 @@ class UpdatesManagerImpl @Inject constructor( "is sig blank: ${pgpSignature.isBlank()}" ) return downloadInfo?.signature ?: "" return pgpSignature } /** Loading @@ -314,8 +325,12 @@ class UpdatesManagerImpl @Inject constructor( val fDroidAppsAndSignatures = getFDroidAppsAndSignatures(installedPackageNames) val fDroidUpdatablePackageNames = fDroidAppsAndSignatures.filter { if (it.value.isEmpty()) return@filter false // For each installed app also present on F-droid, check signature of base APK. val baseApkPath = appLoungePackageManager.getBaseApkPath(it.key) if (baseApkPath.isEmpty()) return@filter false ApkSignatureManager.verifyFdroidSignature(context, baseApkPath, it.value, it.key) }.map { it.key } Loading Loading @@ -358,9 +373,11 @@ class UpdatesManagerImpl @Inject constructor( // Received list has build info of the latest version at the bottom. // We want it at the top. val builds = fdroidRepository.getBuildVersionInfo(packageName)?.asReversed() ?: return "" val builds = handleNetworkResult { fdroidRepository.getBuildVersionInfo(packageName)?.asReversed() ?: listOf() }.data val matchingIndex = builds.find { val matchingIndex = builds?.find { it.versionCode == installedVersionCode && it.versionName == installedVersionName }?.run { builds.indexOf(this) Loading
app/src/main/java/foundation/e/apps/install/pkg/AppLoungePackageManager.kt +33 −20 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.content.pm.PackageInfo import android.content.pm.PackageInstaller.Session import android.content.pm.PackageInstaller.SessionParams import android.content.pm.PackageManager import android.content.pm.PackageManager.NameNotFoundException import android.os.Build import androidx.core.content.pm.PackageInfoCompat import dagger.hilt.android.qualifiers.ApplicationContext Loading @@ -39,6 +40,7 @@ import foundation.e.apps.data.fusedDownload.models.FusedDownload import kotlinx.coroutines.DelicateCoroutinesApi import timber.log.Timber import java.io.File import java.lang.IllegalArgumentException import javax.inject.Inject import javax.inject.Singleton Loading @@ -51,7 +53,9 @@ class AppLoungePackageManager @Inject constructor( const val ERROR_PACKAGE_INSTALL = "ERROR_PACKAGE_INSTALL" const val PACKAGE_NAME = "packageName" const val FAKE_STORE_PACKAGE_NAME = "com.android.vending" private const val UNKNOWN_VALUE = "" } private val packageManager = context.packageManager fun isInstalled(packageName: String): Boolean { Loading @@ -69,15 +73,8 @@ class AppLoungePackageManager @Inject constructor( } private fun isUpdatable(packageName: String, versionCode: Int): Boolean { return try { val packageInfo = getPackageInfo(packageName) packageInfo?.let { return versionCode.toLong() > PackageInfoCompat.getLongVersionCode(it) } true } catch (e: PackageManager.NameNotFoundException) { false } val packageInfo = getPackageInfo(packageName) ?: return false return versionCode.toLong() > PackageInfoCompat.getLongVersionCode(packageInfo) } fun getLaunchIntent(packageName: String): Intent? { Loading @@ -85,7 +82,12 @@ class AppLoungePackageManager @Inject constructor( } private fun getPackageInfo(packageName: String): PackageInfo? { return packageManager.getPackageInfo(packageName, 0) return try { packageManager.getPackageInfo(packageName, 0) } catch (e: NameNotFoundException) { Timber.e("getPackageInfo: ${e.localizedMessage}") null } } /** Loading Loading @@ -133,11 +135,19 @@ class AppLoungePackageManager @Inject constructor( } fun getInstallerName(packageName: String): String { return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { return try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { val installerInfo = packageManager.getInstallSourceInfo(packageName) installerInfo.originatingPackageName ?: installerInfo.installingPackageName ?: "" installerInfo.originatingPackageName ?: installerInfo.installingPackageName ?: UNKNOWN_VALUE } else { packageManager.getInstallerPackageName(packageName) ?: "" packageManager.getInstallerPackageName(packageName) ?: UNKNOWN_VALUE } } catch (e: NameNotFoundException) { Timber.e("getInstallerName -> $packageName : ${e.localizedMessage}") UNKNOWN_VALUE } catch (e: IllegalArgumentException) { Timber.e("getInstallerName -> $packageName : ${e.localizedMessage}") UNKNOWN_VALUE } } Loading @@ -146,22 +156,22 @@ class AppLoungePackageManager @Inject constructor( */ fun getBaseApkPath(packageName: String): String { val packageInfo = getPackageInfo(packageName) return packageInfo?.applicationInfo?.publicSourceDir ?: "" return packageInfo?.applicationInfo?.publicSourceDir ?: UNKNOWN_VALUE } fun getVersionCode(packageName: String): String { val packageInfo = getPackageInfo(packageName) return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { packageInfo?.longVersionCode?.toString() ?: "" packageInfo?.longVersionCode?.toString() ?: UNKNOWN_VALUE } else { @Suppress("DEPRECATION") packageInfo?.versionCode?.toString() ?: "" packageInfo?.versionCode?.toString() ?: UNKNOWN_VALUE } } fun getVersionName(packageName: String): String { val packageInfo = getPackageInfo(packageName) return packageInfo?.versionName?.toString() ?: "" return packageInfo?.versionName?.toString() ?: UNKNOWN_VALUE } /** Loading Loading @@ -194,7 +204,10 @@ class AppLoungePackageManager @Inject constructor( ) session.commit(servicePendingIntent.intentSender) } catch (e: Exception) { Timber.e("Initiating Install Failed for $packageName exception: ${e.localizedMessage}", e) Timber.e( "Initiating Install Failed for $packageName exception: ${e.localizedMessage}", e ) val pendingIntent = PendingIntent.getBroadcast( context, sessionId, Loading
app/src/main/java/foundation/e/apps/install/updates/UpdatesWorker.kt +3 −3 Original line number Diff line number Diff line Loading @@ -138,7 +138,7 @@ class UpdatesWorker @AssistedInject constructor( } if (resultStatus != ResultStatus.OK) { manageRetry() manageRetry(resultStatus.toString()) } else { /* * Show notification only if enabled. Loading @@ -162,7 +162,7 @@ class UpdatesWorker @AssistedInject constructor( } } private suspend fun manageRetry() { private suspend fun manageRetry(extraMessage: String) { retryCount++ if (retryCount == 1) { EventBus.invokeEvent(AppEvent.UpdateEvent(ResultSupreme.WorkError(ResultStatus.RETRY))) Loading @@ -172,7 +172,7 @@ class UpdatesWorker @AssistedInject constructor( delay(DELAY_FOR_RETRY) checkForUpdates() } else { val message = "Update is aborted after trying for $MAX_RETRY_COUNT times!" val message = "Update is aborted after trying for $MAX_RETRY_COUNT times! message: $extraMessage" Timber.e(message) EventBus.invokeEvent(AppEvent.UpdateEvent(ResultSupreme.WorkError(ResultStatus.UNKNOWN))) } Loading