Backed out 9 changesets (bug 1880805, bug 1880792) for causing Android build bustages CLOSED TREE

Backed out changeset 31bdbc9aeaa4 (bug 1880805)
Backed out changeset 774f35ca40c6 (bug 1880805)
Backed out changeset 245c3192541e (bug 1880805)
Backed out changeset b6ebbf12ab50 (bug 1880805)
Backed out changeset 17995dc18511 (bug 1880805)
Backed out changeset 42b34af74a6b (bug 1880805)
Backed out changeset 2f77befbf593 (bug 1880805)
Backed out changeset 974b02a7b0c6 (bug 1880792)
Backed out changeset bb02a20ea5fd (bug 1880792)
This commit is contained in:
Noemi Erli
2024-08-07 21:36:15 +03:00
parent eb7031e6ab
commit 078b6e5660
28 changed files with 38 additions and 214 deletions

View File

@@ -125,7 +125,7 @@ allprojects {
buildId = getBuildId()
buildToolsVersion = mozconfig.substs.ANDROID_BUILD_TOOLS_VERSION
compileSdkVersion = tryInt(mozconfig.substs.ANDROID_COMPILE_SDK)
compileSdkVersion = tryInt(mozconfig.substs.ANDROID_TARGET_SDK)
targetSdkVersion = tryInt(mozconfig.substs.ANDROID_TARGET_SDK)
minSdkVersion = tryInt(mozconfig.substs.MOZ_ANDROID_MIN_SDK_VERSION)
manifestPlaceholders = [

View File

@@ -58,8 +58,7 @@ def android_sdk_version():
# If you think you can't handle the whole set of changes, please reach out to the Release
# Engineering team.
return namespace(
build_tools_version="35.0.0",
compile_sdk_version="35",
build_tools_version="34.0.0",
target_sdk_version="34",
min_sdk_version="21",
)
@@ -156,4 +155,3 @@ set_config("ANDROID_SDK_ROOT", android_sdk_root)
set_config("ANDROID_BUILD_TOOLS_VERSION", android_sdk_version.build_tools_version)
set_config("ANDROID_TARGET_SDK", android_sdk_version.target_sdk_version)
set_config("ANDROID_COMPILE_SDK", android_sdk_version.compile_sdk_version)

View File

@@ -68,7 +68,7 @@ opengles_version_minor = 0
[package.metadata.android.sdk]
# keep it in sync with android-sdk-version in android-sdk.configure
target_sdk_version = 35
target_sdk_version = 34
min_sdk_version = 18
[package.metadata.android.application]

View File

@@ -3,6 +3,6 @@ componentsGroupId: "org.mozilla.components"
# Synchronized build configuration for all modules
jvmTargetCompatibility: 17
compileSdkVersion: 35
compileSdkVersion: 34
minSdkVersion: 21
targetSdkVersion: 34

View File

@@ -282,6 +282,7 @@ class SystemEngineSession(
// Explicitly set global defaults.
cacheMode = LOAD_NO_CACHE
databaseEnabled = false
setDeprecatedWebSettings(this)
@@ -304,8 +305,6 @@ class SystemEngineSession(
webSettings.saveFormData = false
// Deprecated in API18.
webSettings.savePassword = false
// Deprecated in API35; default value is false.
webSettings.databaseEnabled = false
}
private fun setUseWideViewPort(settings: WebSettings, useWideViewPort: Boolean?) {

View File

@@ -341,8 +341,6 @@ class BrowserIcons constructor(
sharedMemoryCache.clear()
}
@Suppress("DEPRECATION") // Apps are not notified of these levels since API level 34.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1909473
override fun onTrimMemory(level: Int) {
val shouldClearMemoryCache = when (level) {
// Foreground: The device is running much lower on memory. The app is running and not killable, but the

View File

@@ -77,8 +77,6 @@ internal class TrimMemoryMiddleware : Middleware<BrowserState, BrowserAction> {
}
}
@Suppress("DEPRECATION") // Apps are not notified of these levels since API level 34.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1909473
private fun shouldCloseEngineSessions(level: Int): Boolean {
return when (level) {
// Foreground: The device is running extremely low on memory. The app is not yet considered a killable

View File

@@ -192,8 +192,6 @@ class TrimMemoryMiddlewareTest {
@Test
fun `TrimMemoryMiddleware - TRIM_MEMORY_RUNNING_CRITICAL`() {
@Suppress("DEPRECATION") // Apps are not notified of these levels since API level 34.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1909473
store.dispatch(
SystemAction.LowMemoryAction(
level = ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL,

View File

@@ -2,8 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@file:Suppress("DEPRECATION")
package mozilla.components.feature.autofill.response.dataset
import android.annotation.SuppressLint

View File

@@ -126,7 +126,6 @@ class CustomTabsToolbarFeatureTest {
assertFalse(toolbar.display.onUrlClicked.invoke())
}
@Suppress("DEPRECATION")
@Test
@Config(sdk = [28])
fun `initialize updates toolbar, window and text color on SDK 28`() {
@@ -167,7 +166,6 @@ class CustomTabsToolbarFeatureTest {
assertEquals(Color.WHITE, toolbar.display.colors.text)
}
@Suppress("DEPRECATION")
@Test
fun `initialize updates toolbar, window and text color`() {
val tab = createCustomTab(

View File

@@ -68,8 +68,8 @@ class AndroidAssetFinder {
private fun PackageManager.getSignatures(packageName: String): Array<Signature> {
val packageInfo = getPackageSignatureInfo(packageName) ?: return emptyArray()
val signatures = if (SDK_INT >= Build.VERSION_CODES.P) {
val signingInfo = packageInfo.signingInfo ?: return emptyArray()
return if (SDK_INT >= Build.VERSION_CODES.P) {
val signingInfo = packageInfo.signingInfo
if (signingInfo.hasMultipleSigners()) {
signingInfo.apkContentsSigners
} else {
@@ -82,10 +82,8 @@ class AndroidAssetFinder {
}
} else {
@Suppress("Deprecation")
packageInfo.signatures ?: emptyArray()
packageInfo.signatures
}
return signatures
}
@SuppressLint("PackageManagerGetSignatures")

View File

@@ -24,7 +24,6 @@ import android.content.pm.PackageManager.PERMISSION_GRANTED
import android.hardware.camera2.CameraManager
import android.net.Uri
import android.os.Build
import android.os.Build.VERSION.SDK_INT
import android.os.Process
import android.provider.ContactsContract
import android.view.accessibility.AccessibilityManager
@@ -46,10 +45,10 @@ import java.io.File
/**
* The (visible) version name of the application, as specified by the <manifest> tag's versionName
* attribute. E.g. "2.0". Returns an empty string if versionName is null.
* attribute. E.g. "2.0".
*/
val Context.appVersionName: String
get() = packageManager.getPackageInfoCompat(packageName, 0).versionName ?: ""
get() = packageManager.getPackageInfoCompat(packageName, 0).versionName
/**
* Returns the name (label) of the application or the package name as a fallback.
@@ -333,18 +332,6 @@ inline fun Context.runOnlyInMainProcess(block: () -> Unit) {
fun Context.getColorFromAttr(@AttrRes attr: Int) =
ContextCompat.getColor(this, theme.resolveAttribute(attr))
/**
* Returns the color int corresponding to the Android statusBarColor attribute.
*/
@ColorInt
fun Context.getStatusBarColor() =
if (SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM) {
@Suppress("DEPRECATION")
ContextCompat.getColor(this, theme.resolveAttribute(android.R.attr.statusBarColor))
} else {
null
}
/**
* Returns a tinted drawable for the given resource ID.
* @param resId ID of the drawable to load.

View File

@@ -5,7 +5,6 @@
package mozilla.components.support.ktx.android.graphics
import android.graphics.Bitmap
import android.graphics.Bitmap.Config
import android.graphics.BitmapShader
import android.graphics.Canvas
import android.graphics.Paint
@@ -36,7 +35,7 @@ private const val BITMAP_COMPRESSION_QUALITY = 100
* - Wrap your bitmap's ImageView with a layout that masks your view with rounded corners (e.g. CardView)
*/
@CheckResult
fun Bitmap.withRoundedCorners(cornerRadiusPx: Float, config: Config): Bitmap {
fun Bitmap.withRoundedCorners(cornerRadiusPx: Float): Bitmap {
val roundedBitmap = Bitmap.createBitmap(width, height, config)
val canvas = Canvas(roundedBitmap)
val paint = Paint().apply {

View File

@@ -17,7 +17,7 @@ import mozilla.components.support.utils.ColorUtils.isDark
*/
fun Window.setStatusBarTheme(@ColorInt color: Int) {
createWindowInsetsController().isAppearanceLightStatusBars = !isDark(color)
setStatusBarColorCompat(color)
statusBarColor = color
}
/**
@@ -29,10 +29,13 @@ fun Window.setNavigationBarTheme(
@ColorInt navBarDividerColor: Int? = null,
) {
navBarColor?.let {
setNavigationBarColorCompat(it)
navigationBarColor = it
createWindowInsetsController().isAppearanceLightNavigationBars = !isDark(it)
}
setNavigationBarDividerColorCompat(navBarDividerColor)
if (SDK_INT >= Build.VERSION_CODES.P) {
navigationBarDividerColor = navBarDividerColor ?: 0
}
}
/**
@@ -41,39 +44,3 @@ fun Window.setNavigationBarTheme(
fun Window.createWindowInsetsController(): WindowInsetsControllerCompat {
return WindowInsetsControllerCompat(this, this.decorView)
}
/**
* Sets the status bar color.
*
* @param color The color to set as the status bar color.
*/
fun Window.setStatusBarColorCompat(@ColorInt color: Int) {
if (SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM) {
@Suppress("DEPRECATION")
statusBarColor = color
}
}
/**
* Sets the navigation bar color.
*
* @param color The color to set as the navigation bar color.
*/
fun Window.setNavigationBarColorCompat(@ColorInt color: Int) {
if (SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM) {
@Suppress("DEPRECATION")
navigationBarColor = color
}
}
/**
* Sets the navigation bar divider color.
*
* @param color The color to set as the navigation bar divider color.
*/
fun Window.setNavigationBarDividerColorCompat(@ColorInt color: Int?) {
if (SDK_INT >= Build.VERSION_CODES.P && SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM) {
@Suppress("DEPRECATION")
navigationBarDividerColor = color ?: 0
}
}

View File

@@ -18,8 +18,6 @@ import android.content.Intent.EXTRA_SUBJECT
import android.content.Intent.EXTRA_TEXT
import android.content.Intent.EXTRA_TITLE
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import android.content.pm.PackageManager.PERMISSION_GRANTED
import android.hardware.camera2.CameraManager
import android.net.Uri
@@ -29,7 +27,6 @@ import androidx.core.content.getSystemService
import androidx.core.net.toUri
import androidx.test.ext.junit.runners.AndroidJUnit4
import mozilla.components.support.ktx.R
import mozilla.components.support.test.any
import mozilla.components.support.test.argumentCaptor
import mozilla.components.support.test.fakes.android.FakeContext
import mozilla.components.support.test.mock
@@ -42,11 +39,9 @@ import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mockito.anyString
import org.mockito.Mockito.doReturn
import org.mockito.Mockito.spy
import org.mockito.Mockito.verify
import org.mockito.Mockito.`when`
import org.robolectric.Robolectric
import org.robolectric.Shadows.shadowOf
import org.robolectric.annotation.Config
@@ -292,44 +287,6 @@ class ContextTest {
whenever(cameraManager.cameraIdList).thenThrow(AssertionError("Test"))
assertFalse(context.hasCamera())
}
@Test
fun `appVersionName returns proper value`() {
val context: Context = mock()
val packageManager: PackageManager = mock()
val packageInfo = PackageInfo().apply { versionName = "1.0.0" }
`when`(context.packageManager).thenReturn(packageManager)
`when`(context.packageName).thenReturn("org.mozilla.app")
`when`(
packageManager.getPackageInfo(
anyString(),
any<PackageManager.PackageInfoFlags>(),
),
).thenReturn(packageInfo)
val versionName = context.appVersionName
assertEquals("1.0.0", versionName)
}
@Test
fun `appVersionName returns empty string when versionName is null`() {
val context: Context = mock()
val packageManager: PackageManager = mock()
val packageInfo = PackageInfo().apply { versionName = null }
`when`(context.packageManager).thenReturn(packageManager)
`when`(context.packageName).thenReturn("org.mozilla.app")
`when`(
packageManager.getPackageInfo(
anyString(),
any<PackageManager.PackageInfoFlags>(),
),
).thenReturn(packageInfo)
val versionName = context.appVersionName
assertEquals("", versionName)
}
}
@Implements(FileProvider::class)

View File

@@ -31,12 +31,11 @@ class BitmapKtTest {
fun `WHEN withRoundedCorners is called THEN returned bitmap's corners should be transparent and center with color`() {
val dimen = 200
val fillColor = Color.RED
val config = Bitmap.Config.ARGB_8888
val bitmap = Bitmap.createBitmap(dimen, dimen, config).apply {
val bitmap = Bitmap.createBitmap(dimen, dimen, Bitmap.Config.ARGB_8888).apply {
eraseColor(fillColor)
}
val roundedBitmap = bitmap.withRoundedCorners(40f, config)
val roundedBitmap = bitmap.withRoundedCorners(40f)
fun assertCornersAreTransparent() {
val cornerLocations = listOf(0, dimen - 1)

View File

@@ -46,7 +46,6 @@ class WindowTest {
@After
fun teardown() = setStaticField(Build.VERSION::SDK_INT.javaField, 0)
@Suppress("DEPRECATION")
@Test
fun `GIVEN a color WHEN setStatusBarTheme THEN sets the status bar color`() {
window.setStatusBarTheme(Color.BLUE)
@@ -65,7 +64,6 @@ class WindowTest {
}
@Test
@Suppress("DEPRECATION")
fun `GIVEN Android 8 & has nav bar color WHEN setNavigationBarTheme THEN only the nav bar color is set`() {
setStaticField(Build.VERSION::SDK_INT.javaField, Build.VERSION_CODES.O_MR1)
window.setNavigationBarTheme(navBarColor = Color.MAGENTA)
@@ -87,7 +85,6 @@ class WindowTest {
}
@Test
@Suppress("DEPRECATION")
fun `GIVEN Android 8 & all args WHEN setNavigationBarTheme THEN only the nav bar color is set`() {
setStaticField(Build.VERSION::SDK_INT.javaField, Build.VERSION_CODES.O_MR1)
window.setNavigationBarTheme(navBarColor = Color.MAGENTA, navBarDividerColor = Color.DKGRAY)
@@ -101,7 +98,6 @@ class WindowTest {
}
@Test
@Suppress("DEPRECATION")
fun `GIVEN Android 9 & no args WHEN setNavigationBarTheme THEN the nav bar divider color is set to default`() {
setStaticField(Build.VERSION::SDK_INT.javaField, Build.VERSION_CODES.P)
window.setNavigationBarTheme()
@@ -111,7 +107,6 @@ class WindowTest {
}
@Test
@Suppress("DEPRECATION")
fun `GIVEN Android 9 has nav bar color WHEN setNavigationBarTheme THEN the nav bar color is set & nav bar divider color set to default`() {
setStaticField(Build.VERSION::SDK_INT.javaField, Build.VERSION_CODES.P)
window.setNavigationBarTheme(navBarColor = Color.BLUE)
@@ -121,7 +116,6 @@ class WindowTest {
}
@Test
@Suppress("DEPRECATION")
fun `GIVEN Android 9 has nav bar divider color WHEN setNavigationBarTheme THEN only the nav bar divider color is set`() {
setStaticField(Build.VERSION::SDK_INT.javaField, Build.VERSION_CODES.P)
window.setNavigationBarTheme(navBarDividerColor = Color.GREEN)
@@ -131,7 +125,6 @@ class WindowTest {
}
@Test
@Suppress("DEPRECATION")
fun `GIVEN Android 9 & all args WHEN setNavigationBarTheme THEN the nav bar & nav bar divider colors are set`() {
setStaticField(Build.VERSION::SDK_INT.javaField, Build.VERSION_CODES.P)
window.setNavigationBarTheme(navBarColor = Color.YELLOW, navBarDividerColor = Color.CYAN)

View File

@@ -5,8 +5,6 @@ permalink: /changelog/
---
# 131.0 (In Development)
* **All components**
*Increased `compileSdkVersion` to 35 (Android 15)
# 130.0

View File

@@ -37,7 +37,6 @@ import mozilla.components.concept.engine.translate.findLanguage
import mozilla.components.lib.state.ext.observeAsState
import mozilla.components.service.fxa.manager.AccountState.NotAuthenticated
import mozilla.components.support.ktx.android.util.dpToPx
import mozilla.components.support.ktx.android.view.setNavigationBarColorCompat
import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R
@@ -86,14 +85,12 @@ class MenuDialogFragment : BottomSheetDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog =
super.onCreateDialog(savedInstanceState).apply {
setOnShowListener {
val navigationBarColor = if (browsingModeManager.mode.isPrivate) {
window?.navigationBarColor = if (browsingModeManager.mode.isPrivate) {
ContextCompat.getColor(context, R.color.fx_mobile_private_layer_color_3)
} else {
ContextCompat.getColor(context, R.color.fx_mobile_layer_color_3)
}
window?.setNavigationBarColorCompat(navigationBarColor)
val bottomSheet = findViewById<View?>(R.id.design_bottom_sheet)
bottomSheet?.setBackgroundResource(android.R.color.transparent)
BottomSheetBehavior.from(bottomSheet).apply {

View File

@@ -18,10 +18,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.colorResource
import mozilla.components.support.ktx.android.content.getColorFromAttr
import mozilla.components.support.ktx.android.content.getStatusBarColor
import mozilla.components.support.ktx.android.view.createWindowInsetsController
import mozilla.components.support.ktx.android.view.setNavigationBarColorCompat
import mozilla.components.support.ktx.android.view.setStatusBarColorCompat
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
@@ -90,10 +87,10 @@ abstract class ThemeManager(
private fun updateLightSystemBars(window: Window, context: Context) {
if (SDK_INT >= Build.VERSION_CODES.M) {
context.getStatusBarColor()?.let { window.setStatusBarColorCompat(it) }
window.statusBarColor = context.getColorFromAttr(android.R.attr.statusBarColor)
window.createWindowInsetsController().isAppearanceLightStatusBars = true
} else {
window.setStatusBarColorCompat(Color.BLACK)
window.statusBarColor = Color.BLACK
}
if (SDK_INT >= Build.VERSION_CODES.O) {
@@ -116,7 +113,7 @@ abstract class ThemeManager(
}
private fun updateNavigationBar(window: Window, context: Context) {
window.setNavigationBarColorCompat(context.getColorFromAttr(R.attr.layer1))
window.navigationBarColor = context.getColorFromAttr(R.attr.layer1)
}
}
}

View File

@@ -18,7 +18,6 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.utils.Settings
import kotlin.collections.removeFirst as removeFirstKt
@RunWith(FenixRobolectricTestRunner::class)
class WifiConnectionMonitorTest {
@@ -180,7 +179,7 @@ class WifiConnectionMonitorTest {
wifiConnectionMonitor.addOnWifiConnectedChangedListener {
// Altering callbacks while looping.
if (wifiConnectionMonitor.callbacks.isNotEmpty()) {
wifiConnectionMonitor.callbacks.removeFirstKt()
wifiConnectionMonitor.callbacks.removeFirst()
}
}

View File

@@ -42,7 +42,7 @@ class SettingsMozillaMenuRobot {
fun verifyVersionNumbers() {
val context = InstrumentationRegistry.getInstrumentation().targetContext
val packageInfo = context.packageManager.getPackageInfoCompat(context.packageName, 0)
val versionName = packageInfo.versionName ?: ""
val versionName = packageInfo.versionName
val gvBuildId = org.mozilla.geckoview.BuildConfig.MOZ_APP_BUILDID
val gvVersion = org.mozilla.geckoview.BuildConfig.MOZ_APP_VERSION

View File

@@ -28,11 +28,8 @@ import mozilla.components.feature.search.widget.BaseVoiceSearchActivity
import mozilla.components.lib.auth.canUseBiometricFeature
import mozilla.components.lib.crash.Crash
import mozilla.components.support.base.feature.UserInteractionHandler
import mozilla.components.support.ktx.android.content.getStatusBarColor
import mozilla.components.support.ktx.android.content.getColorFromAttr
import mozilla.components.support.ktx.android.view.createWindowInsetsController
import mozilla.components.support.ktx.android.view.setNavigationBarColorCompat
import mozilla.components.support.ktx.android.view.setNavigationBarDividerColorCompat
import mozilla.components.support.ktx.android.view.setStatusBarColorCompat
import mozilla.components.support.locale.LocaleAwareAppCompatActivity
import mozilla.components.support.utils.SafeIntent
import mozilla.components.support.utils.StatusBarUtils
@@ -110,7 +107,7 @@ open class MainActivity : LocaleAwareAppCompatActivity() {
window.decorView.systemUiVisibility =
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
window.setStatusBarColorCompat(ContextCompat.getColor(this, android.R.color.transparent))
window.statusBarColor = ContextCompat.getColor(this, android.R.color.transparent)
when (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) {
Configuration.UI_MODE_NIGHT_UNDEFINED, // We assume light here per Android doc's recommendation
Configuration.UI_MODE_NIGHT_NO,
@@ -396,21 +393,20 @@ open class MainActivity : LocaleAwareAppCompatActivity() {
private fun updateLightSystemBars() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
window.context.getStatusBarColor()?.let { window.setStatusBarColorCompat(it) }
window.statusBarColor = getColorFromAttr(android.R.attr.statusBarColor)
window.createWindowInsetsController().isAppearanceLightStatusBars = true
} else {
window.setStatusBarColorCompat(Color.BLACK)
window.statusBarColor = Color.BLACK
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// API level can display handle light navigation bar color
window.createWindowInsetsController().isAppearanceLightNavigationBars = true
window.setNavigationBarColorCompat(ContextCompat.getColor(this, android.R.color.transparent))
window.navigationBarColor = ContextCompat.getColor(this, android.R.color.transparent)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
window.setNavigationBarDividerColorCompat(
ContextCompat.getColor(this, android.R.color.transparent),
)
window.navigationBarDividerColor =
ContextCompat.getColor(this, android.R.color.transparent)
}
}
}

View File

@@ -85,11 +85,11 @@ object SupportUtils {
}
/**
* Returns the version name of this package or an empty string if versionName is null.
* Returns the version name of this package.
*/
fun getAppVersion(context: Context): String {
try {
return context.packageManager.getPackageInfoCompat(context.packageName, 0).versionName ?: ""
return context.packageManager.getPackageInfoCompat(context.packageName, 0).versionName
} catch (e: PackageManager.NameNotFoundException) {
// This should be impossible - we should always be able to get information about ourselves:
throw IllegalStateException("Unable find package details for Focus", e)

View File

@@ -4,14 +4,8 @@
package org.mozilla.focus.utils
import android.content.Context
import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import org.junit.Assert.assertEquals
import org.junit.Assert.assertThrows
import org.junit.Test
import org.mockito.Mockito.mock
import org.mockito.Mockito.`when`
import java.util.Locale
class SupportUtilsTest {
@@ -67,47 +61,4 @@ class SupportUtilsTest {
SupportUtils.manifestoURL,
)
}
@Test
fun `appVersionName returns proper value`() {
val context: Context = mock()
val packageManager: PackageManager = mock()
val packageInfo = PackageInfo().apply { versionName = "1.0.0" }
`when`(context.packageManager).thenReturn(packageManager)
`when`(context.packageName).thenReturn("org.mozilla.focus")
`when`(packageManager.getPackageInfo("org.mozilla.focus", 0)).thenReturn(packageInfo)
val version = SupportUtils.getAppVersion(context)
assertEquals("1.0.0", version)
}
@Test
fun `appVersionName returns empty string when versionName is null`() {
val context: Context = mock()
val packageManager: PackageManager = mock()
val packageInfo = PackageInfo().apply { versionName = null }
`when`(context.packageManager).thenReturn(packageManager)
`when`(context.packageName).thenReturn("org.mozilla.focus")
`when`(packageManager.getPackageInfo("org.mozilla.focus", 0)).thenReturn(packageInfo)
val version = SupportUtils.getAppVersion(context)
assertEquals("", version)
}
@Test
fun `appVersionName throws IllegalStateException when package not found`() {
val context: Context = mock()
val packageManager: PackageManager = mock()
`when`(context.packageManager).thenReturn(packageManager)
`when`(context.packageName).thenReturn("org.mozilla.focus")
`when`(packageManager.getPackageInfo("org.mozilla.focus", 0))
.thenThrow(PackageManager.NameNotFoundException::class.java)
assertThrows(IllegalStateException::class.java) {
SupportUtils.getAppVersion(context)
}
}
}

View File

@@ -16,7 +16,6 @@ exclude: true
## v131
- Added [`GeckoDisplay.windowInsetsChanged`][131.1].
- Added [`GeckoView.addWindowInsetsListener`][131.2] and [`GeckoView.removeWindowInsetsListener`][131.3] to allow listening WindowInsets changes of Activity's root window with multiple listeners.
-Increased `compileSdkVersion` to 35 (Android 15)
[131.1]: {{javadoc_uri}}/GeckoDisplay.html#windowInsetsChanged
[131.2]: {{javadoc_uri}}/GeckoView.html#addWindowInsetsListener

View File

@@ -1,4 +1,4 @@
emulator
platform-tools
build-tools;35.0.0
platforms;android-35
build-tools;34.0.0
platforms;android-34

View File

@@ -288,8 +288,8 @@ def install(logger, dest=None, reinstall=False, prompt=True):
if new_install:
packages = ["platform-tools",
"build-tools;35.0.0",
"platforms;android-35",
"build-tools;34.0.0",
"platforms;android-34",
"emulator"]
install_android_packages(logger, paths, packages, prompt=prompt)