mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-15 18:12:54 +00:00
For #25808: Handle PackageManager methods deprecation.
This commit is contained in:
parent
324b29cca7
commit
0b2fe605ce
@ -15,6 +15,7 @@ import mozilla.components.feature.intent.ext.sanitize
|
||||
import mozilla.components.feature.intent.processing.IntentProcessor
|
||||
import mozilla.components.support.utils.EXTRA_ACTIVITY_REFERRER_CATEGORY
|
||||
import mozilla.components.support.utils.EXTRA_ACTIVITY_REFERRER_PACKAGE
|
||||
import mozilla.components.support.utils.ext.getApplicationInfoCompat
|
||||
import org.mozilla.fenix.GleanMetrics.Events
|
||||
import org.mozilla.fenix.HomeActivity.Companion.PRIVATE_BROWSING_MODE
|
||||
import org.mozilla.fenix.components.IntentProcessorType
|
||||
@ -125,7 +126,7 @@ class IntentReceiverActivity : Activity() {
|
||||
// Category is supported for API>=26.
|
||||
r.host?.let { host ->
|
||||
try {
|
||||
val category = packageManager.getApplicationInfo(host, 0).category
|
||||
val category = packageManager.getApplicationInfoCompat(host, 0).category
|
||||
intent.putExtra(EXTRA_ACTIVITY_REFERRER_CATEGORY, category)
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
// At least we tried.
|
||||
|
@ -8,6 +8,7 @@ import android.content.Context
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import mozilla.components.support.utils.ext.getPackageInfoCompat
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.nimbus.FxNimbus
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
@ -76,7 +77,7 @@ internal class DefaultMetricsStorage(
|
||||
|
||||
fun shouldSendGenerally(context: Context): Boolean {
|
||||
val installedTime = context.packageManager
|
||||
.getPackageInfo(context.packageName, 0)
|
||||
.getPackageInfoCompat(context.packageName, 0)
|
||||
.firstInstallTime
|
||||
val timeDifference = System.currentTimeMillis() - installedTime
|
||||
val withinWindow = timeDifference in windowStartMillis..windowEndMillis
|
||||
|
@ -6,6 +6,7 @@ package org.mozilla.fenix.components.metrics
|
||||
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import mozilla.components.support.utils.ext.getPackageInfoCompat
|
||||
import org.mozilla.fenix.utils.BrowsersCache
|
||||
|
||||
object MozillaProductDetector {
|
||||
@ -45,7 +46,7 @@ object MozillaProductDetector {
|
||||
|
||||
fun packageIsInstalled(context: Context, packageName: String): Boolean {
|
||||
try {
|
||||
context.packageManager.getPackageInfo(packageName, 0)
|
||||
context.packageManager.getPackageInfoCompat(packageName, 0)
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
return false
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.recyclerview.widget.DividerItemDecoration
|
||||
import mozilla.components.service.glean.private.NoExtras
|
||||
import mozilla.components.support.utils.ext.getPackageInfoCompat
|
||||
import org.mozilla.fenix.BrowserDirection
|
||||
import org.mozilla.fenix.BuildConfig
|
||||
import org.mozilla.fenix.GleanMetrics.Events
|
||||
@ -96,7 +97,7 @@ class AboutFragment : Fragment(), AboutPageListener {
|
||||
private fun populateAboutHeader() {
|
||||
val aboutText = try {
|
||||
val packageInfo =
|
||||
requireContext().packageManager.getPackageInfo(requireContext().packageName, 0)
|
||||
requireContext().packageManager.getPackageInfoCompat(requireContext().packageName, 0)
|
||||
val versionCode = PackageInfoCompat.getLongVersionCode(packageInfo).toString()
|
||||
val maybeFenixGitHash = if (BuildConfig.GIT_HASH.isNotBlank()) ", ${BuildConfig.GIT_HASH}" else ""
|
||||
val componentsAbbreviation = getString(R.string.components_abbreviation)
|
||||
|
@ -24,6 +24,7 @@ import kotlinx.coroutines.launch
|
||||
import mozilla.components.concept.sync.DeviceCapability
|
||||
import mozilla.components.feature.share.RecentAppsStorage
|
||||
import mozilla.components.service.fxa.manager.FxaAccountManager
|
||||
import mozilla.components.support.utils.ext.queryIntentActivitiesCompat
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.ext.isOnline
|
||||
@ -162,7 +163,7 @@ class ShareViewModel(application: Application) : AndroidViewModel(application) {
|
||||
@VisibleForTesting
|
||||
@WorkerThread
|
||||
fun getIntentActivities(shareIntent: Intent, context: Context): List<ResolveInfo>? {
|
||||
return context.packageManager.queryIntentActivities(shareIntent, 0)
|
||||
return context.packageManager.queryIntentActivitiesCompat(shareIntent, 0)
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user