diff --git a/app/build.gradle b/app/build.gradle index 53c0cfea8a896d286bda5ee925331e553c06ba59..73a912917fab3fe8031278dca3d5dade79f162cc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -122,6 +122,9 @@ dependencies { implementation "androidx.viewpager2:viewpager2:1.0.0" implementation "androidx.recyclerview:recyclerview:1.2.1" + //logger + implementation 'com.jakewharton.timber:timber:5.0.1' + // Retrofit def retrofit_version = "2.9.0" implementation "com.squareup.retrofit2:retrofit:$retrofit_version" diff --git a/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt b/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt index f33fe1e916dbcc6c5605b0ce8d28bfbdc6a7a582..7a8c4215110ac13a9d35745329904c681ba0476a 100644 --- a/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt +++ b/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt @@ -30,9 +30,12 @@ import foundation.e.apps.utils.modules.DataStoreModule import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.MainScope import kotlinx.coroutines.launch +import timber.log.Timber +import timber.log.Timber.Forest.plant import java.util.concurrent.Executors import javax.inject.Inject + @HiltAndroidApp @DelicateCoroutinesApi class AppLoungeApplication : Application(), Configuration.Provider { @@ -60,6 +63,9 @@ class AppLoungeApplication : Application(), Configuration.Provider { dataStoreModule.saveTOCStatus(false, "") } } + if (BuildConfig.DEBUG) { + plant(Timber.DebugTree()) + } } override fun getWorkManagerConfiguration() = diff --git a/app/src/main/java/foundation/e/apps/MainActivity.kt b/app/src/main/java/foundation/e/apps/MainActivity.kt index 8f44d8b464f07ad7dc5f0a8f97c57757a81c1b09..d79501a2fd690e29b3a02233e14daf7dd2a45cb2 100644 --- a/app/src/main/java/foundation/e/apps/MainActivity.kt +++ b/app/src/main/java/foundation/e/apps/MainActivity.kt @@ -47,6 +47,7 @@ import foundation.e.apps.utils.enums.Status import foundation.e.apps.utils.modules.CommonUtilsModule import foundation.e.apps.utils.parentFragment.TimeoutFragment import kotlinx.coroutines.launch +import timber.log.Timber import java.io.File import java.util.UUID @@ -107,7 +108,6 @@ class MainActivity : AppCompatActivity() { } viewModel.authValidity.observe(this) { - viewModel.handleAuthValidity(it) { Log.d(TAG, "Timeout validating auth data!") val lastFragment = navHostFragment.childFragmentManager.fragments[0] @@ -218,7 +218,7 @@ class MainActivity : AppCompatActivity() { } viewModel.updateAwaiting(it) InstallWorkManager.enqueueWork(it) - Log.d(TAG, "===> onCreate: AWAITING ${it.name}") + Timber.d( "===> onCreate: AWAITING ${it.name}") } } @@ -273,7 +273,7 @@ class MainActivity : AppCompatActivity() { statsManager.getFreeBytes(StorageManager.UUID_DEFAULT) } } catch (e: Exception) { - Log.e(TAG, "calculateAvailableDiskSpace: ${e.stackTraceToString()}") + Timber.e( "calculateAvailableDiskSpace: ${e.stackTraceToString()}") getAvailableInternalMemorySize() } } else { diff --git a/app/src/main/java/foundation/e/apps/MainActivityViewModel.kt b/app/src/main/java/foundation/e/apps/MainActivityViewModel.kt index b66a7d49d27a422991493f99a41a4a9c4206a49d..a38cb066f5753e2539dde9ed5f94f8da1e7eb55b 100644 --- a/app/src/main/java/foundation/e/apps/MainActivityViewModel.kt +++ b/app/src/main/java/foundation/e/apps/MainActivityViewModel.kt @@ -56,6 +56,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import ru.beryukhov.reactivenetwork.ReactiveNetwork +import timber.log.Timber import java.io.ByteArrayOutputStream import javax.inject.Inject @@ -188,10 +189,10 @@ class MainActivityViewModel @Inject constructor( if (regenerateFunction != null) { dataStoreModule.userType.collect { user -> if (!user.isBlank() && User.valueOf(user) == User.ANONYMOUS) { - Log.d(TAG, "Regenerating auth data for Anonymous user") + Timber.d( "Regenerating auth data for Anonymous user") regenerateFunction(user) } else { - Log.d(TAG, "Ask Google user to log in again") + Timber.d( "Ask Google user to log in again") dataStoreModule.clearUserType() } } diff --git a/app/src/main/java/foundation/e/apps/PrivacyInfoViewModel.kt b/app/src/main/java/foundation/e/apps/PrivacyInfoViewModel.kt index 968d99e948242036a9eae024297db0c4301e491d..a4ade66aeccf6076d91e547559d40ba84882f736 100644 --- a/app/src/main/java/foundation/e/apps/PrivacyInfoViewModel.kt +++ b/app/src/main/java/foundation/e/apps/PrivacyInfoViewModel.kt @@ -10,6 +10,7 @@ import foundation.e.apps.api.exodus.models.AppPrivacyInfo import foundation.e.apps.api.exodus.repositories.IAppPrivacyInfoRepository import foundation.e.apps.api.fused.data.FusedApp import foundation.e.apps.utils.modules.CommonUtilsModule.LIST_OF_NULL +import timber.log.Timber import javax.inject.Inject import kotlin.math.ceil import kotlin.math.round @@ -88,10 +89,6 @@ class PrivacyInfoViewModel @Inject constructor( val calculatePermissionsScore = calculatePermissionsScore( countAndroidPermissions(fusedApp) ) - Log.d( - "PrivacyInfoViewModel", - "calculatePrivacyScore: ${fusedApp.name}: privacyScore: $calculateTrackersScore permissionScore: $calculatePermissionsScore noOfPermission: ${fusedApp.perms.size}" - ) return calculateTrackersScore + calculatePermissionsScore } diff --git a/app/src/main/java/foundation/e/apps/api/DownloadManager.kt b/app/src/main/java/foundation/e/apps/api/DownloadManager.kt index f5e8cbeedeb469cd565d888e587f462298f2f624..8356dc2301a1d16bfb9a004d1daace5e760b24d8 100644 --- a/app/src/main/java/foundation/e/apps/api/DownloadManager.kt +++ b/app/src/main/java/foundation/e/apps/api/DownloadManager.kt @@ -26,6 +26,7 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach +import timber.log.Timber import java.io.File import javax.inject.Inject import javax.inject.Named @@ -79,22 +80,12 @@ class DownloadManager @Inject constructor( cursor.getLong(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_TOTAL_SIZE_BYTES)) val bytesDownloadedSoFar = cursor.getLong(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR)) - Log.d( - "DownloadManager", - "checkDownloadProcess: $filePath=> $bytesDownloadedSoFar/$totalSizeBytes $status" - ) if (status == DownloadManager.STATUS_FAILED) { - Log.d( - "DownloadManager", - "Download Failed: $filePath=> $bytesDownloadedSoFar/$totalSizeBytes $status" - ) + Timber.d("Download Failed: $filePath=> $bytesDownloadedSoFar/$totalSizeBytes $status") isDownloading = false downloadCompleted?.invoke(false, filePath) } else if (status == DownloadManager.STATUS_SUCCESSFUL) { - Log.d( - "DownloadManager", - "Download Successful: $filePath=> $bytesDownloadedSoFar/$totalSizeBytes $status" - ) + Timber.d("Download Successful: $filePath=> $bytesDownloadedSoFar/$totalSizeBytes $status") isDownloading = false downloadCompleted?.invoke(true, filePath) } diff --git a/app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt b/app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt index 409dc93ebed6f2acff4b28c44b77f416ffbc7db2..5927a805c6579ea00d2de08d68d8d5fc8ece3723 100644 --- a/app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt +++ b/app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt @@ -59,6 +59,7 @@ import foundation.e.apps.utils.modules.PWAManagerModule import foundation.e.apps.utils.modules.PreferenceManagerModule import kotlinx.coroutines.TimeoutCancellationException import kotlinx.coroutines.withTimeout +import timber.log.Timber import javax.inject.Inject import javax.inject.Singleton @@ -161,10 +162,10 @@ class FusedAPIImpl @Inject constructor( } catch (e: TimeoutCancellationException) { e.printStackTrace() apiStatus = ResultStatus.TIMEOUT - Log.d(TAG, "Timed out fetching home data for type: $applicationType") + Timber.d( "Timed out fetching home data for type: $applicationType") } catch (e: Exception) { apiStatus = ResultStatus.UNKNOWN - e.printStackTrace() + Timber.e(e) } return Pair(list, apiStatus) } diff --git a/app/src/main/java/foundation/e/apps/api/gplay/utils/GPlayHttpClient.kt b/app/src/main/java/foundation/e/apps/api/gplay/utils/GPlayHttpClient.kt index 6411d870fa2029f221c2b358b0982169bcb9ab71..351bf905130f9199073d8032c8e0860e30cc9c66 100644 --- a/app/src/main/java/foundation/e/apps/api/gplay/utils/GPlayHttpClient.kt +++ b/app/src/main/java/foundation/e/apps/api/gplay/utils/GPlayHttpClient.kt @@ -34,6 +34,7 @@ import okhttp3.Request import okhttp3.RequestBody import okhttp3.RequestBody.Companion.toRequestBody import okhttp3.Response +import timber.log.Timber import java.io.IOException import java.net.SocketTimeoutException import java.net.UnknownHostException @@ -137,7 +138,7 @@ class GPlayHttpClient @Inject constructor( ) .method(GET, null) .build() - Log.d("get auth request", request.toString()) + Timber.d("get auth request", request.toString()) return processRequest(request) } @@ -169,7 +170,7 @@ class GPlayHttpClient @Inject constructor( } private fun handleExceptionOnGooglePlayRequest(e: Exception): PlayResponse { - Log.e(TAG, "processRequest: ${e.localizedMessage}") + Timber.e( "processRequest: ${e.localizedMessage}") return PlayResponse() } diff --git a/app/src/main/java/foundation/e/apps/application/ApplicationFragment.kt b/app/src/main/java/foundation/e/apps/application/ApplicationFragment.kt index aa826417a36bbeac3cbc438f1af81f3cace740dd..60eebeba820924e536dec1f351c821b4fdb13fc9 100644 --- a/app/src/main/java/foundation/e/apps/application/ApplicationFragment.kt +++ b/app/src/main/java/foundation/e/apps/application/ApplicationFragment.kt @@ -65,6 +65,7 @@ import foundation.e.apps.utils.modules.PWAManagerModule import foundation.e.apps.utils.parentFragment.TimeoutFragment import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +import timber.log.Timber import javax.inject.Inject @AndroidEntryPoint @@ -401,7 +402,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { appSize ) else -> { - Log.d(TAG, "Unknown status: $status") + Timber.d( "Unknown status: $status") } } } diff --git a/app/src/main/java/foundation/e/apps/categories/CategoriesFragment.kt b/app/src/main/java/foundation/e/apps/categories/CategoriesFragment.kt index 2fb4fc7c989e1fd6bc32a96568536e4d8be89efb..76360f2d329c71ad2f9d8a34bed837fdc85228b6 100644 --- a/app/src/main/java/foundation/e/apps/categories/CategoriesFragment.kt +++ b/app/src/main/java/foundation/e/apps/categories/CategoriesFragment.kt @@ -28,6 +28,7 @@ import foundation.e.apps.R import foundation.e.apps.categories.model.CategoriesVPAdapter import foundation.e.apps.databinding.FragmentCategoriesBinding import foundation.e.apps.utils.parentFragment.TimeoutFragment +import timber.log.Timber @AndroidEntryPoint class CategoriesFragment : TimeoutFragment(R.layout.fragment_categories) { @@ -69,7 +70,7 @@ class CategoriesFragment : TimeoutFragment(R.layout.fragment_categories) { fragment?.let { if (it is TimeoutFragment) { - Log.d(TAG, "Showing timeout on Categories fragment: " + it::class.java.name) + Timber.d( "Showing timeout on Categories fragment: " + it::class.java.name) it.onTimeout() } } diff --git a/app/src/main/java/foundation/e/apps/manager/download/DownloadManagerBR.kt b/app/src/main/java/foundation/e/apps/manager/download/DownloadManagerBR.kt index c303424bf11d1e35127d2744b9ac227ec8e426aa..a7ecf29a4f27ae8390c28c1cbfca7db87ff839a8 100644 --- a/app/src/main/java/foundation/e/apps/manager/download/DownloadManagerBR.kt +++ b/app/src/main/java/foundation/e/apps/manager/download/DownloadManagerBR.kt @@ -25,6 +25,7 @@ import android.content.Intent import android.util.Log import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.DelicateCoroutinesApi +import timber.log.Timber import javax.inject.Inject @AndroidEntryPoint @@ -43,7 +44,7 @@ class DownloadManagerBR : BroadcastReceiver() { val action = intent?.action if (context != null && action != null) { val id = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0) - Log.d(TAG, "onReceive: DownloadBR $action $id") + Timber.d( "onReceive: DownloadBR $action $id") when (action) { DownloadManager.ACTION_DOWNLOAD_COMPLETE -> { downloadedList.add(id) diff --git a/app/src/main/java/foundation/e/apps/manager/download/DownloadManagerUtils.kt b/app/src/main/java/foundation/e/apps/manager/download/DownloadManagerUtils.kt index 2b27368aa13235e40a293651abe287fb6c3bd380..386c2542dea51c838b4e2634846324d19826fa60 100644 --- a/app/src/main/java/foundation/e/apps/manager/download/DownloadManagerUtils.kt +++ b/app/src/main/java/foundation/e/apps/manager/download/DownloadManagerUtils.kt @@ -29,6 +29,7 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock +import timber.log.Timber import javax.inject.Inject import javax.inject.Singleton @@ -58,10 +59,7 @@ class DownloadManagerUtils @Inject constructor( fusedDownload.downloadIdMap[downloadId] = true fusedManagerRepository.updateFusedDownload(fusedDownload) val downloaded = fusedDownload.downloadIdMap.values.filter { it }.size - Log.d( - TAG, - "===> updateDownloadStatus: ${fusedDownload.name}: $downloadId: $downloaded/${fusedDownload.downloadIdMap.size} " - ) + Timber.d("===> updateDownloadStatus: ${fusedDownload.name}: $downloadId: $downloaded/${fusedDownload.downloadIdMap.size}") if (downloaded == fusedDownload.downloadIdMap.size) { fusedManagerRepository.moveOBBFileToOBBDirectory(fusedDownload) fusedDownload.status = Status.DOWNLOADED diff --git a/app/src/main/java/foundation/e/apps/manager/download/data/DownloadProgressLD.kt b/app/src/main/java/foundation/e/apps/manager/download/data/DownloadProgressLD.kt index e768b25ef3006a1298f93b01241eaefc047f1137..76b7c3127d3100657d91aa87ac8623bdb6732ca0 100644 --- a/app/src/main/java/foundation/e/apps/manager/download/data/DownloadProgressLD.kt +++ b/app/src/main/java/foundation/e/apps/manager/download/data/DownloadProgressLD.kt @@ -12,6 +12,7 @@ import kotlinx.coroutines.Job import kotlinx.coroutines.cancel import kotlinx.coroutines.delay import kotlinx.coroutines.launch +import timber.log.Timber import javax.inject.Inject import kotlin.coroutines.CoroutineContext @@ -86,7 +87,7 @@ class DownloadProgressLD @Inject constructor( } } } catch (e: Exception) { - Log.e(TAG, "downloading Ids: $downloadingIds ${e.localizedMessage}") + Timber.e( "downloading Ids: $downloadingIds ${e.localizedMessage}") } delay(20) } diff --git a/app/src/main/java/foundation/e/apps/manager/fused/FileManager.kt b/app/src/main/java/foundation/e/apps/manager/fused/FileManager.kt index 3aa7b4c59c26e78dd24314237338f1a1b7db1213..1fed379151015a85401f06428ee085ba8bfc06d7 100644 --- a/app/src/main/java/foundation/e/apps/manager/fused/FileManager.kt +++ b/app/src/main/java/foundation/e/apps/manager/fused/FileManager.kt @@ -1,6 +1,7 @@ package foundation.e.apps.manager.fused import android.util.Log +import timber.log.Timber import java.io.File import java.io.FileInputStream import java.io.FileNotFoundException @@ -33,9 +34,9 @@ object FileManager { // delete the original file File(inputPath + inputFile).delete() } catch (e: FileNotFoundException) { - Log.e(TAG, e.stackTraceToString()) + Timber.e( e.stackTraceToString()) } catch (e: Exception) { - Log.e(TAG, e.stackTraceToString()) + Timber.e( e.stackTraceToString()) } finally { inputStream?.close() inputStream = null diff --git a/app/src/main/java/foundation/e/apps/manager/fused/FusedManagerImpl.kt b/app/src/main/java/foundation/e/apps/manager/fused/FusedManagerImpl.kt index 86c0f9978d9976852fb3379bf1825a8667776315..6e9c9e7ccf5aba2dfa11b82c6f6382d803a9ed52 100644 --- a/app/src/main/java/foundation/e/apps/manager/fused/FusedManagerImpl.kt +++ b/app/src/main/java/foundation/e/apps/manager/fused/FusedManagerImpl.kt @@ -41,6 +41,7 @@ import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.delay import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock +import timber.log.Timber import java.io.File import javax.inject.Inject import javax.inject.Named @@ -98,7 +99,6 @@ class FusedManagerImpl @Inject constructor( flushOldDownload(fusedDownload.packageName) databaseRepository.deleteDownload(fusedDownload) } else if (status == Status.INSTALLING) { - Log.d(TAG, "updateDownloadStatus: Downloaded ===> ${fusedDownload.name} INSTALLING") fusedDownload.downloadIdMap.all { true } fusedDownload.status = status databaseRepository.updateDownload(fusedDownload) @@ -128,9 +128,9 @@ class FusedManagerImpl @Inject constructor( list.sort() if (list.size != 0) { try { - Log.d(TAG, "installApp: STARTED ${fusedDownload.name} ${list.size}") + Timber.d( "installApp: STARTED ${fusedDownload.name} ${list.size}") pkgManagerModule.installApplication(list, fusedDownload.packageName) - Log.d(TAG, "installApp: ENDED ${fusedDownload.name} ${list.size}") + Timber.d( "installApp: ENDED ${fusedDownload.name} ${list.size}") } catch (e: Exception) { Log.d(TAG, ">>> installApp app failed ") installationIssue(fusedDownload) @@ -139,7 +139,7 @@ class FusedManagerImpl @Inject constructor( } } else -> { - Log.d(TAG, "Unsupported application type!") + Timber.d( "Unsupported application type!") fusedDownload.status = Status.INSTALLATION_ISSUE databaseRepository.updateDownload(fusedDownload) delay(100) @@ -163,7 +163,7 @@ class FusedManagerImpl @Inject constructor( databaseRepository.deleteDownload(fusedDownload) flushOldDownload(fusedDownload.packageName) } else { - Log.d(TAG, "Unable to cancel download!") + Timber.d( "Unable to cancel download!") } } @@ -181,7 +181,6 @@ class FusedManagerImpl @Inject constructor( } } } - Log.d(TAG, "getFusedDownload: $fusedDownload") return fusedDownload } @@ -202,7 +201,6 @@ class FusedManagerImpl @Inject constructor( databaseRepository.updateDownload(fusedDownload) DownloadProgressLD.setDownloadId(-1) delay(100) - Log.d(TAG, "downloadNativeApp: ${fusedDownload.name} ${fusedDownload.downloadURLList.size}") fusedDownload.downloadURLList.forEach { count += 1 val packagePath: File = if (fusedDownload.files.isNotEmpty()) { @@ -210,7 +208,6 @@ class FusedManagerImpl @Inject constructor( } else { File(parentPath, "${fusedDownload.packageName}_$count.apk") } - Log.d(TAG, "downloadNativeApp: destination path: $packagePath") val request = DownloadManager.Request(Uri.parse(it)) .setTitle(if (count == 1) fusedDownload.name else "Additional file for ${fusedDownload.name}") .setDestinationUri(Uri.fromFile(packagePath)) @@ -250,12 +247,10 @@ class FusedManagerImpl @Inject constructor( fusedDownload.files.forEach { val parentPath = context.getExternalFilesDir(null)?.absolutePath + "/Android/obb/" + fusedDownload.packageName - Log.d(TAG, "updateDownloadStatus: source path: $parentPath filename: ${it.name}") val file = File(parentPath, it.name) if (file.exists()) { val destinationDirectory = Environment.getExternalStorageDirectory() .toString() + "/Android/obb/" + fusedDownload.packageName - Log.d(TAG, "updateDownloadStatus: destination path: $destinationDirectory") File(destinationDirectory).mkdirs() FileManager.moveFile("$parentPath/", it.name, "$destinationDirectory/") } diff --git a/app/src/main/java/foundation/e/apps/manager/pkg/InstallerService.kt b/app/src/main/java/foundation/e/apps/manager/pkg/InstallerService.kt index c275790e806223fbfb43704b10cbed25b635f7aa..660e83df1d74ed48f89a75526ff97f5fccfbb8bc 100644 --- a/app/src/main/java/foundation/e/apps/manager/pkg/InstallerService.kt +++ b/app/src/main/java/foundation/e/apps/manager/pkg/InstallerService.kt @@ -23,12 +23,13 @@ import android.content.Intent import android.content.pm.PackageInstaller import android.os.Build import android.os.IBinder -import android.util.Log import androidx.annotation.RequiresApi import dagger.hilt.android.AndroidEntryPoint import foundation.e.apps.manager.fused.FusedManagerRepository +import foundation.e.apps.utils.enums.Status import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch +import timber.log.Timber import javax.inject.Inject @AndroidEntryPoint @@ -55,7 +56,7 @@ class InstallerService : Service() { } private fun postStatus(status: Int, packageName: String?, extra: String?) { - Log.d(TAG, "postStatus: $status $packageName $extra") + Timber.d("postStatus: $status $packageName $extra") if (status != PackageInstaller.STATUS_SUCCESS) { updateInstallationIssue(packageName ?: "") } @@ -65,9 +66,20 @@ class InstallerService : Service() { return null } + private fun updateDownloadStatus(pkgName: String) { + if (pkgName.isEmpty()) { + Timber.d("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(TAG, "updateDownloadStatus: package name should not be empty!") + Timber.d("updateDownloadStatus: package name should not be empty!") } GlobalScope.launch { val fusedDownload = fusedManagerRepository.getFusedDownload(packageName = pkgName) diff --git a/app/src/main/java/foundation/e/apps/manager/pkg/PackageInstallerService.kt b/app/src/main/java/foundation/e/apps/manager/pkg/PackageInstallerService.kt index 5840bb5368d94fa6591489e27686bca898f75f36..4614c46f239aaae2dd97bb68b8c0e48f4abb4fdc 100644 --- a/app/src/main/java/foundation/e/apps/manager/pkg/PackageInstallerService.kt +++ b/app/src/main/java/foundation/e/apps/manager/pkg/PackageInstallerService.kt @@ -29,6 +29,7 @@ import foundation.e.apps.utils.enums.Status import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch +import timber.log.Timber import javax.inject.Inject @AndroidEntryPoint @@ -49,7 +50,7 @@ class PackageInstallerService : Service() { if (status == PackageInstaller.STATUS_SUCCESS) { updateDownloadStatus(packageName) } else { - Log.e(TAG, "Installation failed due to error: $extra") + Timber.e( "Installation failed due to error: $extra") updateInstallationIssue(packageName) } } diff --git a/app/src/main/java/foundation/e/apps/manager/pkg/PkgManagerBR.kt b/app/src/main/java/foundation/e/apps/manager/pkg/PkgManagerBR.kt index d80a32afe0ac001f4bd2ad07e2f10b850713e1dd..384ab2e62a168d563a2fc5a86c639941abea1838 100644 --- a/app/src/main/java/foundation/e/apps/manager/pkg/PkgManagerBR.kt +++ b/app/src/main/java/foundation/e/apps/manager/pkg/PkgManagerBR.kt @@ -29,6 +29,7 @@ import foundation.e.apps.utils.enums.Status import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch +import timber.log.Timber import javax.inject.Inject @AndroidEntryPoint @@ -55,7 +56,7 @@ open class PkgManagerBR : BroadcastReceiver() { val status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -69) val packageName = intent.getStringExtra(PackageInstaller.EXTRA_PACKAGE_NAME) - Log.d(TAG, "onReceive: $packageName $action $extra $status") + Timber.d( "onReceive: $packageName $action $extra $status") packages?.let { pkgList -> pkgList.forEach { pkgName -> when (action) { @@ -66,7 +67,7 @@ open class PkgManagerBR : BroadcastReceiver() { if (!isUpdating) deleteDownload(pkgName) } PkgManagerModule.ERROR_PACKAGE_INSTALL -> { - Log.e(TAG, "Installation failed due to error: $extra") + Timber.e( "Installation failed due to error: $extra") updateInstallationIssue(pkgName) } } @@ -85,7 +86,7 @@ open class PkgManagerBR : BroadcastReceiver() { // TODO: FIND A BETTER WAY TO DO THIS private fun updateDownloadStatus(pkgName: String) { if (pkgName.isEmpty()) { - Log.d("PkgManagerBR", "updateDownloadStatus: package name should not be empty!") + Timber.d("updateDownloadStatus: package name should not be empty!") } GlobalScope.launch { val fusedDownload = fusedManagerRepository.getFusedDownload(packageName = pkgName) diff --git a/app/src/main/java/foundation/e/apps/manager/pkg/PkgManagerModule.kt b/app/src/main/java/foundation/e/apps/manager/pkg/PkgManagerModule.kt index a4b11fc9a8c97d9d139696bc0b4a0989473687a1..f195384f6fdcfe0aa0e28e4c42f8a905a0edee81 100644 --- a/app/src/main/java/foundation/e/apps/manager/pkg/PkgManagerModule.kt +++ b/app/src/main/java/foundation/e/apps/manager/pkg/PkgManagerModule.kt @@ -36,6 +36,7 @@ import foundation.e.apps.utils.enums.Origin import foundation.e.apps.utils.enums.Status import foundation.e.apps.utils.enums.Type import kotlinx.coroutines.DelicateCoroutinesApi +import timber.log.Timber import java.io.File import javax.inject.Inject import javax.inject.Singleton @@ -116,7 +117,7 @@ class PkgManagerModule @Inject constructor( val targetPackage = fusedDownload.packageName try { packageManager.setInstallerPackageName(targetPackage, fakeStorePackageName) - Log.d(TAG, "Changed installer to $fakeStorePackageName for $targetPackage") + Timber.d( "Changed installer to $fakeStorePackageName for $targetPackage") } catch (e: Exception) { e.printStackTrace() } @@ -168,7 +169,7 @@ class PkgManagerModule @Inject constructor( ) session.commit(servicePendingIntent.intentSender) } catch (e: Exception) { - Log.e(TAG, "$packageName: \n${e.stackTraceToString()}") + Timber.e( "$packageName: \n${e.stackTraceToString()}") val pendingIntent = PendingIntent.getBroadcast( context, sessionId, diff --git a/app/src/main/java/foundation/e/apps/manager/workmanager/InstallAppWorker.kt b/app/src/main/java/foundation/e/apps/manager/workmanager/InstallAppWorker.kt index 39ee678c9b2bbbfc39191625231b3f6b15e142fd..bf453373050d40e9e590f7fa859a00306ec71b33 100644 --- a/app/src/main/java/foundation/e/apps/manager/workmanager/InstallAppWorker.kt +++ b/app/src/main/java/foundation/e/apps/manager/workmanager/InstallAppWorker.kt @@ -45,6 +45,7 @@ import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.sync.Mutex +import timber.log.Timber import java.util.concurrent.atomic.AtomicInteger import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds @@ -83,6 +84,8 @@ class InstallAppWorker @AssistedInject constructor( var fusedDownload: FusedDownload? = null try { val fusedDownloadString = params.inputData.getString(INPUT_DATA_FUSED_DOWNLOAD) ?: "" + Timber.d( "Fused download name $fusedDownloadString") + fusedDownload = databaseRepository.getDownloadById(fusedDownloadString) Log.d( TAG, @@ -101,12 +104,12 @@ class InstallAppWorker @AssistedInject constructor( mutex.lock() } } catch (e: Exception) { - Log.e(TAG, ">>> doWork: Failed: ${e.stackTraceToString()}") + Timber.e( "doWork: Failed: ${e.stackTraceToString()}") fusedDownload?.let { fusedManagerRepository.installationIssue(it) } } finally { - Log.d(TAG, ">>> doWork: RESULT SUCCESS: ${fusedDownload?.name}") + Timber.d( "doWork: RESULT SUCCESS: ${fusedDownload?.name}") return Result.success() } } @@ -115,6 +118,7 @@ class InstallAppWorker @AssistedInject constructor( fusedDownload: FusedDownload ) { fusedManagerRepository.downloadApp(fusedDownload) + Timber.d( "===> doWork: Download started ${fusedDownload.name} ${fusedDownload.status}") isDownloading = true tickerFlow(3.seconds) .onEach { @@ -160,30 +164,17 @@ class InstallAppWorker @AssistedInject constructor( } private suspend fun checkDownloadProcess(fusedDownload: FusedDownload) { - try { - downloadManager.query(downloadManagerQuery.setFilterById(*fusedDownload.downloadIdMap.keys.toLongArray())) - .use { cursor -> - if (cursor.moveToFirst()) { - val id = - cursor.getLong(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_ID)) - val status = - cursor.getInt(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_STATUS)) - val totalSizeBytes = - cursor.getLong(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_TOTAL_SIZE_BYTES)) - val bytesDownloadedSoFar = - cursor.getLong(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR)) - Log.d( - TAG, - "checkDownloadProcess: ${fusedDownload.name} $bytesDownloadedSoFar/$totalSizeBytes $status" - ) - if (status == DownloadManager.STATUS_FAILED) { - fusedManagerRepository.installationIssue(fusedDownload) - } + downloadManager.query(downloadManagerQuery.setFilterById(*fusedDownload.downloadIdMap.keys.toLongArray())) + .use { cursor -> + if (cursor.moveToFirst()) { + val status = + cursor.getInt(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_STATUS)) + + if (status == DownloadManager.STATUS_FAILED) { + fusedManagerRepository.installationIssue(fusedDownload) } } - } catch (e: Exception) { - e.printStackTrace() - } + } } private suspend fun handleFusedDownloadStatus(fusedDownload: FusedDownload) { @@ -194,18 +185,12 @@ class InstallAppWorker @AssistedInject constructor( fusedManagerRepository.updateDownloadStatus(fusedDownload, Status.INSTALLING) } Status.INSTALLING -> { - Log.d( - TAG, - "===> doWork: Installing ${fusedDownload.name} ${fusedDownload.status}" - ) + Timber.d("===> doWork: Installing ${fusedDownload.name} ${fusedDownload.status}") } Status.INSTALLED, Status.INSTALLATION_ISSUE -> { isDownloading = false - Log.d( - TAG, - "===> doWork: Installed/Failed: ${fusedDownload.name} ${fusedDownload.status}" - ) unlockMutex() + Timber.d("===> doWork: Installed/Failed: ${fusedDownload.name} ${fusedDownload.status}") } else -> { isDownloading = false diff --git a/app/src/main/java/foundation/e/apps/purchase/AppPurchaseFragment.kt b/app/src/main/java/foundation/e/apps/purchase/AppPurchaseFragment.kt index b249390845d24276ec3f9d3c9fed933b9c12859b..9014904955a8e122bffe12e1b8240e2cfdeb4e84 100644 --- a/app/src/main/java/foundation/e/apps/purchase/AppPurchaseFragment.kt +++ b/app/src/main/java/foundation/e/apps/purchase/AppPurchaseFragment.kt @@ -14,6 +14,7 @@ import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import foundation.e.apps.MainActivityViewModel import foundation.e.apps.databinding.FragmentAppPurchaseBinding +import timber.log.Timber /** * A simple [Fragment] subclass. @@ -61,7 +62,6 @@ class AppPurchaseFragment : Fragment() { binding.playStoreWebView.webViewClient = object : WebViewClient() { override fun onPageFinished(view: WebView, url: String) { - Log.d(TAG, "onPageFinished: $url") if (url.contains("https://play.google.com/store/apps/details") && url.contains("raii") && url.contains("raboi") && url.contains("rasi") && url.contains("rapt") ) { diff --git a/app/src/main/java/foundation/e/apps/settings/SettingsFragment.kt b/app/src/main/java/foundation/e/apps/settings/SettingsFragment.kt index 5db6b8b7689f26c0a9062f75c6a5642c5e04b9ab..d92e92af41b60a7c730348d6b45bc38e335d2f8a 100644 --- a/app/src/main/java/foundation/e/apps/settings/SettingsFragment.kt +++ b/app/src/main/java/foundation/e/apps/settings/SettingsFragment.kt @@ -42,6 +42,7 @@ import foundation.e.apps.databinding.CustomPreferenceBinding import foundation.e.apps.setup.signin.SignInViewModel import foundation.e.apps.updates.manager.UpdatesWorkManager import foundation.e.apps.utils.enums.User +import timber.log.Timber import javax.inject.Inject @AndroidEntryPoint @@ -70,7 +71,7 @@ class SettingsFragment : PreferenceFragmentCompat() { val updateCheckInterval = preferenceManager.findPreference(getString(R.string.update_check_intervals)) updateCheckInterval?.setOnPreferenceChangeListener { _, newValue -> - Log.d(TAG, "onCreatePreferences: updated Value: $newValue") + Timber.d( "onCreatePreferences: updated Value: $newValue") context?.let { UpdatesWorkManager.enqueueWork( it, diff --git a/app/src/main/java/foundation/e/apps/setup/signin/LocaleChangedBroadcastReceiver.kt b/app/src/main/java/foundation/e/apps/setup/signin/LocaleChangedBroadcastReceiver.kt index 8865e526320985bec61dda2a5a1b569e7908d0a1..15980e9ed5321cf74c938d8c7a7022b2fb466546 100644 --- a/app/src/main/java/foundation/e/apps/setup/signin/LocaleChangedBroadcastReceiver.kt +++ b/app/src/main/java/foundation/e/apps/setup/signin/LocaleChangedBroadcastReceiver.kt @@ -32,6 +32,7 @@ import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import okhttp3.Cache +import timber.log.Timber import javax.inject.Inject @AndroidEntryPoint @@ -58,7 +59,7 @@ class LocaleChangedBroadcastReceiver : BroadcastReceiver() { cache.evictAll() } } catch (ex: Exception) { - Log.e(TAG, ex.message.toString()) + Timber.e( ex.message.toString()) } } } diff --git a/app/src/main/java/foundation/e/apps/updates/manager/UpdatesBroadcastReceiver.kt b/app/src/main/java/foundation/e/apps/updates/manager/UpdatesBroadcastReceiver.kt index c4b566402ac0503525b0b29f9e03ec272dc1cc15..db2da50be5965fff6339d40abf4e768633457ba5 100644 --- a/app/src/main/java/foundation/e/apps/updates/manager/UpdatesBroadcastReceiver.kt +++ b/app/src/main/java/foundation/e/apps/updates/manager/UpdatesBroadcastReceiver.kt @@ -24,6 +24,7 @@ import android.util.Log import androidx.preference.PreferenceManager import androidx.work.ExistingPeriodicWorkPolicy import foundation.e.apps.R +import timber.log.Timber class UpdatesBroadcastReceiver : BroadcastReceiver() { companion object { @@ -31,7 +32,7 @@ class UpdatesBroadcastReceiver : BroadcastReceiver() { } override fun onReceive(context: Context, intent: Intent) { - Log.d(TAG, "onReceive: ${intent.action}") + Timber.d( "onReceive: ${intent.action}") if (intent.action == Intent.ACTION_BOOT_COMPLETED) { val preferences = PreferenceManager.getDefaultSharedPreferences(context) val interval = diff --git a/app/src/main/java/foundation/e/apps/updates/manager/UpdatesWorker.kt b/app/src/main/java/foundation/e/apps/updates/manager/UpdatesWorker.kt index 3534c230988ca47bbd0951784531f60430b8a488..66c8b17ae0d63528c09458c3189b01769c74c9cb 100644 --- a/app/src/main/java/foundation/e/apps/updates/manager/UpdatesWorker.kt +++ b/app/src/main/java/foundation/e/apps/updates/manager/UpdatesWorker.kt @@ -28,6 +28,7 @@ import foundation.e.apps.updates.UpdatesNotifier import foundation.e.apps.utils.enums.Origin import foundation.e.apps.utils.enums.Type import foundation.e.apps.utils.modules.DataStoreModule +import timber.log.Timber import java.io.ByteArrayOutputStream import java.net.URL @@ -147,10 +148,7 @@ class UpdatesWorker @AssistedInject constructor( fusedManagerRepository.addDownload(fusedDownload) fusedManagerRepository.updateAwaiting(fusedDownload) - Log.d( - TAG, - "startUpdateProcess: Enqueued for update: ${fusedDownload.name} ${fusedDownload.id} ${fusedDownload.status}" - ) + Timber.d("startUpdateProcess: Enqueued for update: ${fusedDownload.name} ${fusedDownload.id} ${fusedDownload.status}") InstallWorkManager.enqueueWork(fusedDownload) Log.d(TAG, ">>> startUpdateProcess: ${fusedDownload.name}") }