Bug 1853967 - Capture telemetry for the amount of RAM a device has.

fenix/119.0
Arturo Mejia 8 months ago committed by mergify[bot]
parent 9ce2e6fb39
commit b57b742be5

@ -2539,6 +2539,28 @@ metrics:
metadata:
tags:
- Experiments
device_total_ram:
type: quantity
lifetime: application
description: >
The total amount of memory this device in bytes, when available will be
MemoryInfo.advertisedMem otherwise it will be MemoryInfo.totalMem.
This doesn't represent memory available to the application however.
send_in_pings:
- metrics
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1853967
data_reviews:
- https://github.com/mozilla-mobile/firefox-android/pull/2620
data_sensitivity:
- technical
notification_emails:
- android-probes@mozilla.com
expires: never
unit: integer
metadata:
tags:
- Performance
search_page_load_time:
type: timing_distribution
time_unit: millisecond

@ -801,6 +801,7 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
)
ramMoreThanThreshold.set(isDeviceRamAboveThreshold)
deviceTotalRam.set(getDeviceTotalRAM())
}
with(AndroidAutofill) {
@ -849,12 +850,27 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
}
}
private fun deviceRamApproxMegabytes(): Long {
@VisibleForTesting
internal fun getDeviceTotalRAM(): Long {
val memoryInfo = getMemoryInfo()
return if (SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
memoryInfo.advertisedMem
} else {
memoryInfo.totalMem
}
}
@VisibleForTesting
internal fun getMemoryInfo(): ActivityManager.MemoryInfo {
val memoryInfo = ActivityManager.MemoryInfo()
val activityManager = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
activityManager.getMemoryInfo(memoryInfo)
val deviceRamBytes = memoryInfo.totalMem
return memoryInfo
}
private fun deviceRamApproxMegabytes(): Long {
val deviceRamBytes = getMemoryInfo().totalMem
return deviceRamBytes.toRoundedMegabytes()
}

@ -143,6 +143,7 @@ class FenixApplicationTest {
every { settings.showPocketRecommendationsFeature } returns true
every { settings.showContileFeature } returns true
every { application.reportHomeScreenMetrics(settings) } just Runs
every { application.getDeviceTotalRAM() } returns 7L
every { settings.inactiveTabsAreEnabled } returns true
every { application.isDeviceRamAboveThreshold } returns true
@ -193,6 +194,7 @@ class FenixApplicationTest {
assertEquals(expectedAppInstallSource, Metrics.installSource.testGetValue())
assertEquals(true, Metrics.defaultWallpaper.testGetValue())
assertEquals(true, Metrics.ramMoreThanThreshold.testGetValue())
assertEquals(7L, Metrics.deviceTotalRam.testGetValue())
val contextId = TopSites.contextId.testGetValue()!!.toString()

Loading…
Cancel
Save