Closed Bug 1993949 Opened 1 year ago Closed 1 year ago

Refactor: Improve the testing for applicationInstalledTime in Settings to not rely on manually setting the applicationInstalledTime in testing

Categories

(Firefox for Android :: Experimentation and Telemetry, task)

All
Android
task

Tracking

()

RESOLVED FIXED
147 Branch
Tracking Status
firefox147 --- fixed

People

(Reporter: towhite, Assigned: towhite)

References

Details

(Whiteboard: [fxdroid][group2][refactor])

Attachments

(4 external files, 1 obsolete file)

No description provided.

Hey Tom! We noticed during review n brew that the current implementation breaks Compose previews. As you refactor, could you look to find a way to remove the package manager code from being used during initialization of Settings? Here's the stacktrace we were seeing:

java.lang.UnsupportedOperationException: getPackageInfo not implemented in subclass
  at android.content.pm.PackageManager.getPackageInfo(PackageManager.java:5850)
  at mozilla.components.support.utils.ext.PackageManagerKt.getPackageInfoCompat(PackageManager.kt:50)
  at org.mozilla.fenix.ext.ContextKt.getApplicationInstalledTime(Context.kt:188)
  at org.mozilla.fenix.utils.Settings.<init>(Settings.kt:618)
  at org.mozilla.fenix.debugsettings.crashtools.ComposableSingletons$CrashToolsKt.lambda_1638751670$lambda$0(CrashTools.kt:111)
  at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.kt:121)
  at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.kt:51)
  at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:390)
  at androidx.compose.material3.TextKt.ProvideTextStyle(Text.kt:462)
  at androidx.compose.material3.MaterialThemeKt$MaterialTheme$2.invoke(MaterialTheme.kt:107)
  at androidx.compose.material3.MaterialThemeKt$MaterialTheme$2.invoke(MaterialTheme.kt:106)
  at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.kt:121)

while trying to provide Settings as a dependency to a preview function like:

@FlexibleWindowLightDarkPreview
@Composable
private fun CrashToolsPreview() {
    FirefoxTheme {
        CrashTools(Settings(LocalContext.current))
    }
}

Matt, thanks for letting me know! Patched a separate fix for this specific error in https://bugzilla.mozilla.org/show_bug.cgi?id=1994679

Assignee: nobody → towhite
Summary: Refactor: Improve the testing for termsOfUseAcceptedTimeInMillis in Settings to not rely on manually setting the applicationInstalledTime in testing → Refactor: Improve the testing for applicationInstalledTime in Settings to not rely on manually setting the applicationInstalledTime in testing
Attachment #9522291 - Attachment description: WIP: Bug 1993949 - Part 2: Use the PsckageManagerCompatHelper in Settings to enable removal of the applicationInstalledTime var. → WIP: Bug 1993949 - Part 2: Use the PackageManagerCompatHelper in Settings to enable removal of the applicationInstalledTime var.
Attachment #9521981 - Attachment description: WIP: Bug 1993949 - Part 1: Refactor the PackageManager compat functions to an interface → Bug 1993949 - Part 1: Refactor the PackageManager compat functions to an interface
Attachment #9522291 - Attachment description: WIP: Bug 1993949 - Part 2: Use the PackageManagerCompatHelper in Settings to enable removal of the applicationInstalledTime var. → Bug 1993949 - Part 2: Use the PackageManagerCompatHelper in Settings to enable removal of the applicationInstalledTime var.
Attachment #9522327 - Attachment description: WIP: Bug 1993949 - Part 3: Refactor the Browsers.kt to use the context to get the package manager. → Bug 1993949 - Part 3: Refactor the Browsers.kt to use the context to get the package manager.
Attachment #9522327 - Attachment description: Bug 1993949 - Part 3: Refactor the Browsers.kt to use the context to get the package manager. → WIP Bug 1993949 - Part 3: Refactor the Browsers.kt to use the context to get the package manager.
Attachment #9522327 - Attachment description: WIP Bug 1993949 - Part 3: Refactor the Browsers.kt to use the context to get the package manager. → WIP Bug 1993949 - Refactor the Browsers.kt to use the context to get the package manager.
Attachment #9522327 - Attachment is obsolete: true
Attachment #9522656 - Attachment description: Bug 1993949 - Part 3: Improve the PackageManagerCompatHelper documentation → WIP Bug 1993949 - Part 3: Improve the PackageManagerCompatHelper documentation
Attachment #9522291 - Attachment description: Bug 1993949 - Part 2: Use the PackageManagerCompatHelper in Settings to enable removal of the applicationInstalledTime var. → WIP Bug 1993949 - Part 2: Use the PackageManagerCompatHelper in Settings to enable removal of the applicationInstalledTime var.
Attachment #9521981 - Attachment description: Bug 1993949 - Part 1: Refactor the PackageManager compat functions to an interface → WIP Bug 1993949 - Part 1: Refactor the PackageManager compat functions to an interface
Attachment #9526508 - Attachment description: WIP: Bug 1993949 - Refactor the applicationInstalledTime var in Settings used for testing, and use the PackageManagerCompatHelper → WIP: Bug 1993949 - Refactor the applicationInstalledTime var in Settings used for testing, to use the PackageManagerCompatHelper
Attachment #9526508 - Attachment description: WIP: Bug 1993949 - Refactor the applicationInstalledTime var in Settings used for testing, to use the PackageManagerCompatHelper → Bug 1993949 - Refactor the applicationInstalledTime var in Settings used for testing, to use the PackageManagerCompatHelper
Pushed by icedicedcoffee@proton.me: https://github.com/mozilla-firefox/firefox/commit/5e8844a9dd26 https://hg.mozilla.org/integration/autoland/rev/f7f04732d3bf Refactor the applicationInstalledTime var in Settings used for testing, to use the PackageManagerCompatHelper r=android-reviewers,gmalekpour
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 147 Branch
Blocks: 2091371
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: