From 0dce291a597b34fe4d8f030e085c2074fe10b2f8 Mon Sep 17 00:00:00 2001 From: Hasib Prince Date: Wed, 8 Jun 2022 19:16:35 +0600 Subject: [PATCH 1/2] App Lounge: Timber logging added partially --- app/build.gradle | 3 +++ .../foundation/e/apps/AppLoungeApplication.kt | 6 ++++++ .../java/foundation/e/apps/MainActivity.kt | 17 ++++++++------- .../e/apps/MainActivityViewModel.kt | 5 +++-- .../e/apps/api/fused/FusedAPIImpl.kt | 3 ++- .../e/apps/application/ApplicationFragment.kt | 3 ++- .../e/apps/categories/CategoriesFragment.kt | 3 ++- .../manager/download/DownloadManagerBR.kt | 3 ++- .../e/apps/manager/fused/FusedManagerImpl.kt | 21 ++++++++++--------- .../e/apps/manager/pkg/PkgManagerBR.kt | 3 ++- .../e/apps/manager/pkg/PkgManagerModule.kt | 3 ++- .../manager/workmanager/InstallAppWorker.kt | 7 ++++--- .../e/apps/purchase/AppPurchaseFragment.kt | 3 ++- .../e/apps/settings/SettingsFragment.kt | 3 ++- .../manager/UpdatesBroadcastReceiver.kt | 3 ++- 15 files changed, 54 insertions(+), 32 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 09d7acdd5..a4fbe95e0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -116,6 +116,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 f33fe1e91..7a8c42151 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 733b68107..18ca5ab7c 100644 --- a/app/src/main/java/foundation/e/apps/MainActivity.kt +++ b/app/src/main/java/foundation/e/apps/MainActivity.kt @@ -48,6 +48,7 @@ import foundation.e.apps.utils.enums.User import foundation.e.apps.utils.parentFragment.TimeoutFragment import foundation.e.apps.utils.modules.CommonUtilsModule import kotlinx.coroutines.launch +import timber.log.Timber import java.io.File import java.util.UUID @@ -90,7 +91,7 @@ class MainActivity : AppCompatActivity() { when (User.valueOf(user)) { User.ANONYMOUS -> { if (viewModel.authDataJson.value.isNullOrEmpty() && !viewModel.authRequestRunning) { - Log.d(TAG, "Fetching new authentication data") + Timber.d( "Fetching new authentication data") viewModel.setFirstTokenFetchTime() viewModel.getAuthData() } @@ -100,7 +101,7 @@ class MainActivity : AppCompatActivity() { } User.GOOGLE -> { if (viewModel.authData.value == null && !viewModel.authRequestRunning) { - Log.d(TAG, "Fetching new authentication data") + Timber.d( "Fetching new authentication data") viewModel.setFirstTokenFetchTime() signInViewModel.fetchAuthData() } @@ -127,7 +128,7 @@ class MainActivity : AppCompatActivity() { viewModel.authDataJson.observe(this) { if (!it.isNullOrEmpty()) { viewModel.generateAuthData() - Log.d(TAG, "Authentication data is available!") + Timber.d( "Authentication data is available!") } } } @@ -135,22 +136,22 @@ class MainActivity : AppCompatActivity() { viewModel.authValidity.observe(this) { if (it != true) { - Log.d(TAG, "Authentication data validation failed!") + Timber.d( "Authentication data validation failed!") viewModel.destroyCredentials { user -> if (viewModel.isTimeEligibleForTokenRefresh()) { generateAuthDataBasedOnUserType(user) } else { - Log.d(TAG, "Timeout validating auth data!") + Timber.d( "Timeout validating auth data!") val lastFragment = navHostFragment.childFragmentManager.fragments[0] if (lastFragment is TimeoutFragment) { - Log.d(TAG, "Displaying timeout from MainActivity on fragment: " + Timber.d( "Displaying timeout from MainActivity on fragment: " + lastFragment::class.java.name) lastFragment.onTimeout() } } } } else { - Log.d(TAG, "Authentication data is valid!") + Timber.d( "Authentication data is valid!") } } @@ -250,7 +251,7 @@ class MainActivity : AppCompatActivity() { } viewModel.updateAwaiting(it) InstallWorkManager.enqueueWork(it) - Log.d(TAG, "===> onCreate: AWAITING ${it.name}") + Timber.d( "===> onCreate: AWAITING ${it.name}") } } diff --git a/app/src/main/java/foundation/e/apps/MainActivityViewModel.kt b/app/src/main/java/foundation/e/apps/MainActivityViewModel.kt index 23083096b..00d5942d5 100644 --- a/app/src/main/java/foundation/e/apps/MainActivityViewModel.kt +++ b/app/src/main/java/foundation/e/apps/MainActivityViewModel.kt @@ -57,6 +57,7 @@ import foundation.e.apps.utils.modules.DataStoreModule import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import ru.beryukhov.reactivenetwork.ReactiveNetwork +import timber.log.Timber import java.io.ByteArrayOutputStream import javax.inject.Inject @@ -185,10 +186,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/api/fused/FusedAPIImpl.kt b/app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt index aac88fa67..61e03a332 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 @@ -53,6 +53,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 @@ -155,7 +156,7 @@ 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() 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 7fcfed4a5..8740177ca 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.CommonUtilsModule.LIST_OF_NULL import foundation.e.apps.utils.modules.PWAManagerModule import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +import timber.log.Timber import javax.inject.Inject @AndroidEntryPoint @@ -365,7 +366,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 2fb4fc7c9..76360f2d3 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 c303424bf..a7ecf29a4 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/fused/FusedManagerImpl.kt b/app/src/main/java/foundation/e/apps/manager/fused/FusedManagerImpl.kt index b1a26f2ca..4a04effd5 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,7 @@ class FusedManagerImpl @Inject constructor( flushOldDownload(fusedDownload.packageName) databaseRepository.deleteDownload(fusedDownload) } else if (status == Status.INSTALLING) { - Log.d(TAG, "updateDownloadStatus: Downloaded ===> ${fusedDownload.name} INSTALLING") + Timber.d( "updateDownloadStatus: Downloaded ===> ${fusedDownload.name} INSTALLING") fusedDownload.downloadIdMap.all { true } fusedDownload.status = status databaseRepository.updateDownload(fusedDownload) @@ -128,9 +129,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) { installationIssue(fusedDownload) throw e @@ -138,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) @@ -162,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!") } } @@ -180,7 +181,7 @@ class FusedManagerImpl @Inject constructor( } } } - Log.d(TAG, "getFusedDownload: $fusedDownload") + Timber.d( "getFusedDownload: $fusedDownload") return fusedDownload } @@ -201,7 +202,7 @@ class FusedManagerImpl @Inject constructor( databaseRepository.updateDownload(fusedDownload) DownloadProgressLD.setDownloadId(-1) delay(100) - Log.d(TAG, "downloadNativeApp: ${fusedDownload.name} ${fusedDownload.downloadURLList.size}") + Timber.d( "downloadNativeApp: ${fusedDownload.name} ${fusedDownload.downloadURLList.size}") fusedDownload.downloadURLList.forEach { count += 1 val packagePath: File = if (fusedDownload.files.isNotEmpty()) { @@ -209,7 +210,7 @@ class FusedManagerImpl @Inject constructor( } else { File(parentPath, "${fusedDownload.packageName}_$count.apk") } - Log.d(TAG, "downloadNativeApp: destination path: $packagePath") + Timber.d( "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)) @@ -249,12 +250,12 @@ 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}") + Timber.d( "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") + Timber.d( "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/PkgManagerBR.kt b/app/src/main/java/foundation/e/apps/manager/pkg/PkgManagerBR.kt index d80a32afe..9b087c767 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) { 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 a4b11fc9a..50d3b7622 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() } 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 2470d31fe..5c711287c 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 @@ -46,6 +46,7 @@ import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.takeWhile 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 @@ -84,7 +85,7 @@ class InstallAppWorker @AssistedInject constructor( var fusedDownload: FusedDownload? = null try { val fusedDownloadString = params.inputData.getString(INPUT_DATA_FUSED_DOWNLOAD) ?: "" - Log.d(TAG, "Fused download name $fusedDownloadString") + Timber.d( "Fused download name $fusedDownloadString") fusedDownload = databaseRepository.getDownloadById(fusedDownloadString) fusedDownload?.let { if (fusedDownload.status != Status.AWAITING) { @@ -104,7 +105,7 @@ class InstallAppWorker @AssistedInject constructor( fusedManagerRepository.installationIssue(it) } } finally { - Log.d(TAG, "doWork: RESULT SUCCESS: ${fusedDownload?.name}") + Timber.d( "doWork: RESULT SUCCESS: ${fusedDownload?.name}") return Result.success() } } @@ -113,7 +114,7 @@ class InstallAppWorker @AssistedInject constructor( fusedDownload: FusedDownload ) { fusedManagerRepository.downloadApp(fusedDownload) - Log.d(TAG, "===> doWork: Download started ${fusedDownload.name} ${fusedDownload.status}") + Timber.d( "===> doWork: Download started ${fusedDownload.name} ${fusedDownload.status}") if (fusedDownload.type == Type.NATIVE) { isDownloading = true tickerFlow(1.seconds) 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 b24939084..5590b6982 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,7 @@ class AppPurchaseFragment : Fragment() { binding.playStoreWebView.webViewClient = object : WebViewClient() { override fun onPageFinished(view: WebView, url: String) { - Log.d(TAG, "onPageFinished: $url") + Timber.d( "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 562ec459b..1244a7b78 100644 --- a/app/src/main/java/foundation/e/apps/settings/SettingsFragment.kt +++ b/app/src/main/java/foundation/e/apps/settings/SettingsFragment.kt @@ -38,6 +38,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 @@ -66,7 +67,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, newValue.toString().toLong(), ExistingPeriodicWorkPolicy.REPLACE) } true } 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 c4b566402..db2da50be 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 = -- GitLab From 2f3263093913b49e589d41a47613bf4222769374 Mon Sep 17 00:00:00 2001 From: Hasib Prince Date: Thu, 9 Jun 2022 13:47:38 +0600 Subject: [PATCH 2/2] App Lounge: clean up unncessary logs --- .../java/foundation/e/apps/MainActivity.kt | 2 +- .../foundation/e/apps/PrivacyInfoViewModel.kt | 5 +--- .../foundation/e/apps/api/DownloadManager.kt | 15 ++-------- .../e/apps/api/gplay/utils/GPlayHttpClient.kt | 5 ++-- .../manager/download/DownloadManagerUtils.kt | 6 ++-- .../download/data/DownloadProgressLD.kt | 3 +- .../e/apps/manager/fused/FileManager.kt | 5 ++-- .../e/apps/manager/fused/FusedManagerImpl.kt | 6 ---- .../e/apps/manager/pkg/InstallerService.kt | 7 +++-- .../manager/pkg/PackageInstallerService.kt | 3 +- .../e/apps/manager/pkg/PkgManagerBR.kt | 4 +-- .../e/apps/manager/pkg/PkgManagerModule.kt | 2 +- .../manager/workmanager/InstallAppWorker.kt | 30 ++++--------------- .../e/apps/purchase/AppPurchaseFragment.kt | 1 - .../signin/LocaleChangedBroadcastReceiver.kt | 3 +- .../e/apps/updates/manager/UpdatesWorker.kt | 6 ++-- 16 files changed, 34 insertions(+), 69 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/MainActivity.kt b/app/src/main/java/foundation/e/apps/MainActivity.kt index 18ca5ab7c..ab67e04cb 100644 --- a/app/src/main/java/foundation/e/apps/MainActivity.kt +++ b/app/src/main/java/foundation/e/apps/MainActivity.kt @@ -306,7 +306,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/PrivacyInfoViewModel.kt b/app/src/main/java/foundation/e/apps/PrivacyInfoViewModel.kt index 968d99e94..a4ade66ae 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 f5e8cbeed..8356dc230 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/gplay/utils/GPlayHttpClient.kt b/app/src/main/java/foundation/e/apps/api/gplay/utils/GPlayHttpClient.kt index 6411d870f..351bf9051 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/manager/download/DownloadManagerUtils.kt b/app/src/main/java/foundation/e/apps/manager/download/DownloadManagerUtils.kt index 2b27368aa..386c2542d 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 b606f3b9b..a8a3c05b9 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 @@ -13,6 +13,7 @@ import kotlinx.coroutines.cancel import kotlinx.coroutines.delay import kotlinx.coroutines.isActive import kotlinx.coroutines.launch +import timber.log.Timber import javax.inject.Inject import kotlin.coroutines.CoroutineContext @@ -85,7 +86,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 3aa7b4c59..1fed37915 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 4a04effd5..dd309f356 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 @@ -99,7 +99,6 @@ class FusedManagerImpl @Inject constructor( flushOldDownload(fusedDownload.packageName) databaseRepository.deleteDownload(fusedDownload) } else if (status == Status.INSTALLING) { - Timber.d( "updateDownloadStatus: Downloaded ===> ${fusedDownload.name} INSTALLING") fusedDownload.downloadIdMap.all { true } fusedDownload.status = status databaseRepository.updateDownload(fusedDownload) @@ -181,7 +180,6 @@ class FusedManagerImpl @Inject constructor( } } } - Timber.d( "getFusedDownload: $fusedDownload") return fusedDownload } @@ -202,7 +200,6 @@ class FusedManagerImpl @Inject constructor( databaseRepository.updateDownload(fusedDownload) DownloadProgressLD.setDownloadId(-1) delay(100) - Timber.d( "downloadNativeApp: ${fusedDownload.name} ${fusedDownload.downloadURLList.size}") fusedDownload.downloadURLList.forEach { count += 1 val packagePath: File = if (fusedDownload.files.isNotEmpty()) { @@ -210,7 +207,6 @@ class FusedManagerImpl @Inject constructor( } else { File(parentPath, "${fusedDownload.packageName}_$count.apk") } - Timber.d( "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 +246,10 @@ class FusedManagerImpl @Inject constructor( fusedDownload.files.forEach { val parentPath = context.getExternalFilesDir(null)?.absolutePath + "/Android/obb/" + fusedDownload.packageName - Timber.d( "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 - Timber.d( "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 236dea7d2..8c9f88769 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 @@ -30,6 +30,7 @@ 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 @@ -52,7 +53,7 @@ class InstallerService : Service() { } private fun postStatus(status: Int, packageName: String?, extra: String?) { - Log.d("InstallerService", "postStatus: $status $packageName $extra") + Timber.d("postStatus: $status $packageName $extra") if (status != PackageInstaller.STATUS_SUCCESS) { updateInstallationIssue(packageName ?: "") } @@ -64,7 +65,7 @@ class InstallerService : Service() { 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) @@ -75,7 +76,7 @@ class InstallerService : Service() { private fun updateInstallationIssue(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/PackageInstallerService.kt b/app/src/main/java/foundation/e/apps/manager/pkg/PackageInstallerService.kt index 5840bb536..4614c46f2 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 9b087c767..384ab2e62 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 @@ -67,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) } } @@ -86,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 50d3b7622..f195384f6 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 @@ -169,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 5c711287c..826f1bc3b 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 @@ -100,7 +100,7 @@ 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) } @@ -138,18 +138,9 @@ class InstallAppWorker @AssistedInject constructor( 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) } @@ -167,14 +158,11 @@ class InstallAppWorker @AssistedInject constructor( unlockMutex() return@collect } - Log.d( - TAG, - "doWork: flow collect ===> ${fusedDownload.name} ${fusedDownload.status}" - ) + Timber.d("doWork: flow collect ===> ${fusedDownload.name} ${fusedDownload.status}") try { handleFusedDownloadStatus(fusedDownload) } catch (e: Exception) { - Log.e(TAG, "observeDownload: ", e) + Timber.e( "observeDownload: ", e) isDownloading = false unlockMutex() } @@ -189,18 +177,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 unlockMutex() - Log.d( - TAG, - "===> doWork: Installed/Failed: ${fusedDownload.name} ${fusedDownload.status}" - ) + 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 5590b6982..901490495 100644 --- a/app/src/main/java/foundation/e/apps/purchase/AppPurchaseFragment.kt +++ b/app/src/main/java/foundation/e/apps/purchase/AppPurchaseFragment.kt @@ -62,7 +62,6 @@ class AppPurchaseFragment : Fragment() { binding.playStoreWebView.webViewClient = object : WebViewClient() { override fun onPageFinished(view: WebView, url: String) { - Timber.d( "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/setup/signin/LocaleChangedBroadcastReceiver.kt b/app/src/main/java/foundation/e/apps/setup/signin/LocaleChangedBroadcastReceiver.kt index 8865e5263..15980e9ed 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/UpdatesWorker.kt b/app/src/main/java/foundation/e/apps/updates/manager/UpdatesWorker.kt index 4aac338db..89941aa57 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) } } -- GitLab