1717package com.google.samples.apps.nowinandroid
1818
1919import android.os.Bundle
20- import android.util.Log
2120import androidx.activity.ComponentActivity
2221import androidx.activity.SystemBarStyle
2322import androidx.activity.compose.setContent
@@ -37,7 +36,6 @@ import androidx.lifecycle.Lifecycle
3736import androidx.lifecycle.lifecycleScope
3837import androidx.lifecycle.repeatOnLifecycle
3938import androidx.metrics.performance.JankStats
40- import androidx.profileinstaller.ProfileVerifier
4139import com.google.samples.apps.nowinandroid.MainActivityUiState.Loading
4240import com.google.samples.apps.nowinandroid.MainActivityUiState.Success
4341import com.google.samples.apps.nowinandroid.core.analytics.AnalyticsHelper
@@ -49,12 +47,9 @@ import com.google.samples.apps.nowinandroid.core.model.data.DarkThemeConfig
4947import com.google.samples.apps.nowinandroid.core.model.data.ThemeBrand
5048import com.google.samples.apps.nowinandroid.ui.NiaApp
5149import dagger.hilt.android.AndroidEntryPoint
52- import kotlinx.coroutines.Dispatchers
5350import kotlinx.coroutines.flow.collect
5451import kotlinx.coroutines.flow.onEach
55- import kotlinx.coroutines.guava.await
5652import kotlinx.coroutines.launch
57- import kotlinx.coroutines.withContext
5853import javax.inject.Inject
5954
6055private const val TAG = " MainActivity"
@@ -150,48 +145,12 @@ class MainActivity : ComponentActivity() {
150145 override fun onResume () {
151146 super .onResume()
152147 lazyStats.get().isTrackingEnabled = true
153- lifecycleScope.launch {
154- logCompilationStatus()
155- }
156148 }
157149
158150 override fun onPause () {
159151 super .onPause()
160152 lazyStats.get().isTrackingEnabled = false
161153 }
162-
163- /* *
164- * Logs the app's Baseline Profile Compilation Status using [ProfileVerifier].
165- */
166- private suspend fun logCompilationStatus () {
167- /*
168- When delivering through Google Play, the baseline profile is compiled during installation.
169- In this case you will see the correct state logged without any further action necessary.
170- To verify baseline profile installation locally, you need to manually trigger baseline
171- profile installation.
172- For immediate compilation, call:
173- `adb shell cmd package compile -f -m speed-profile com.example.macrobenchmark.target`
174- You can also trigger background optimizations:
175- `adb shell pm bg-dexopt-job`
176- Both jobs run asynchronously and might take some time complete.
177- To see quick turnaround of the ProfileVerifier, we recommend using `speed-profile`.
178- If you don't do either of these steps, you might only see the profile status reported as
179- "enqueued for compilation" when running the sample locally.
180- */
181- withContext(Dispatchers .IO ) {
182- val status = ProfileVerifier .getCompilationStatusAsync().await()
183- Log .d(TAG , " ProfileInstaller status code: ${status.profileInstallResultCode} " )
184- Log .d(
185- TAG ,
186- when {
187- status.isCompiledWithProfile -> " ProfileInstaller: is compiled with profile"
188- status.hasProfileEnqueuedForCompilation() ->
189- " ProfileInstaller: Enqueued for compilation"
190- else -> " Profile not compiled or enqueued"
191- },
192- )
193- }
194- }
195154}
196155
197156/* *
0 commit comments