3
3
package com.woocommerce.android.ui.main
4
4
5
5
import NotificationsPermissionCard
6
+ import android.annotation.SuppressLint
6
7
import android.app.Activity
7
8
import android.app.ProgressDialog
8
9
import android.content.Intent
@@ -32,11 +33,15 @@ import androidx.fragment.app.DialogFragment
32
33
import androidx.fragment.app.Fragment
33
34
import androidx.fragment.app.FragmentManager
34
35
import androidx.fragment.app.FragmentManager.FragmentLifecycleCallbacks
36
+ import androidx.lifecycle.lifecycleScope
35
37
import androidx.navigation.NavController
36
38
import androidx.navigation.NavDestination
37
39
import androidx.navigation.NavOptions
38
40
import androidx.navigation.fragment.FragmentNavigatorExtras
39
41
import androidx.navigation.fragment.NavHostFragment
42
+ import androidx.profileinstaller.ProfileVerifier
43
+ import androidx.profileinstaller.ProfileVerifier.CompilationStatus
44
+ import androidx.work.await
40
45
import com.automattic.android.tracks.crashlogging.CrashLogging
41
46
import com.google.android.material.appbar.AppBarLayout
42
47
import com.woocommerce.android.AppPrefs
@@ -109,11 +114,15 @@ import com.woocommerce.android.util.ChromeCustomTabUtils
109
114
import com.woocommerce.android.util.PackageUtils
110
115
import com.woocommerce.android.util.WooAnimUtils.Duration
111
116
import com.woocommerce.android.util.WooAnimUtils.animateBottomBar
117
+ import com.woocommerce.android.util.WooLog
112
118
import com.woocommerce.android.util.WooPermissionUtils
113
119
import com.woocommerce.android.viewmodel.MultiLiveEvent
114
120
import com.woocommerce.android.widgets.AppRatingDialog
115
121
import com.woocommerce.android.widgets.DisabledAppBarLayoutBehavior
116
122
import dagger.hilt.android.AndroidEntryPoint
123
+ import kotlinx.coroutines.Dispatchers
124
+ import kotlinx.coroutines.launch
125
+ import kotlinx.coroutines.withContext
117
126
import org.wordpress.android.login.LoginAnalyticsListener
118
127
import org.wordpress.android.login.LoginMode
119
128
import org.wordpress.android.util.NetworkUtils
@@ -389,6 +398,7 @@ class MainActivity :
389
398
390
399
override fun onResume () {
391
400
super .onResume()
401
+ lifecycleScope.launch { logCompilationStatus() }
392
402
AnalyticsTracker .trackViewShown(this )
393
403
394
404
// Track if App was opened from a widget
@@ -404,6 +414,49 @@ class MainActivity :
404
414
viewModel.showFeatureAnnouncementIfNeeded()
405
415
}
406
416
417
+ /* *
418
+ * This method is used for debugging baseline profile purpose based on profile verifier compilation status.
419
+ *
420
+ * @see <a href="https://developer.android.com/topic/performance/baselineprofiles/debug-baseline-profiles#installation_issues</a> for more details.
421
+ */
422
+ @Suppress(" MaxLineLength" )
423
+ @SuppressLint(" RestrictedApi" )
424
+ private suspend fun logCompilationStatus () {
425
+ withContext(Dispatchers .IO ) {
426
+ val status = ProfileVerifier .getCompilationStatusAsync().await()
427
+ when (status.profileInstallResultCode) {
428
+ CompilationStatus .RESULT_CODE_NO_PROFILE_INSTALLED ->
429
+ WooLog .d(WooLog .T .BASELINE_PROFILES , " ProfileInstaller: Baseline Profile not found" )
430
+
431
+ CompilationStatus .RESULT_CODE_COMPILED_WITH_PROFILE ->
432
+ WooLog .d(WooLog .T .BASELINE_PROFILES , " ProfileInstaller: Compiled with profile" )
433
+
434
+ CompilationStatus .RESULT_CODE_PROFILE_ENQUEUED_FOR_COMPILATION ->
435
+ WooLog .d(WooLog .T .BASELINE_PROFILES , " ProfileInstaller: Enqueued for compilation" )
436
+
437
+ CompilationStatus .RESULT_CODE_COMPILED_WITH_PROFILE_NON_MATCHING ->
438
+ WooLog .d(WooLog .T .BASELINE_PROFILES , " ProfileInstaller: App was installed through Play store" )
439
+
440
+ CompilationStatus .RESULT_CODE_ERROR_PACKAGE_NAME_DOES_NOT_EXIST ->
441
+ WooLog .d(WooLog .T .BASELINE_PROFILES , " ProfileInstaller: PackageName not found" )
442
+
443
+ CompilationStatus .RESULT_CODE_ERROR_CACHE_FILE_EXISTS_BUT_CANNOT_BE_READ ->
444
+ WooLog .d(WooLog .T .BASELINE_PROFILES , " ProfileInstaller: Cache file exists but cannot be read" )
445
+
446
+ CompilationStatus .RESULT_CODE_ERROR_CANT_WRITE_PROFILE_VERIFICATION_RESULT_CACHE_FILE ->
447
+ WooLog .d(WooLog .T .BASELINE_PROFILES , " ProfileInstaller: Can't write cache file" )
448
+
449
+ CompilationStatus .RESULT_CODE_ERROR_UNSUPPORTED_API_VERSION ->
450
+ WooLog .d(WooLog .T .BASELINE_PROFILES , " ProfileInstaller: Enqueued for compilation" )
451
+
452
+ else -> WooLog .d(
453
+ WooLog .T .BASELINE_PROFILES ,
454
+ " ProfileInstaller: Profile not compiled or enqueued [Result Code: ${status.profileInstallResultCode} ]"
455
+ )
456
+ }
457
+ }
458
+ }
459
+
407
460
override fun onPause () {
408
461
binding.appBarLayout.removeOnOffsetChangedListener(appBarOffsetListener)
409
462
super .onPause()
0 commit comments