mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-09 19:10:42 +00:00
For #21126: process performancetest intent for AC too.
This commit is contained in:
parent
6a3b9c4b8f
commit
3ab1ca8321
@ -37,19 +37,24 @@ object Performance {
|
||||
}
|
||||
|
||||
/**
|
||||
* The checks for the USB connections and ADB debugging are checks in case another application
|
||||
* The checks for the charging state and ADB debugging are checks in case another application
|
||||
* tries to leverage this intent to trigger a code path for Firefox that shouldn't be used unless
|
||||
* it is for testing visual metrics. These checks aren't full proof but most of our users won't have
|
||||
* ADB on and USB connected at the same time when running Firefox.
|
||||
* ADB on and charging at the same time when running Firefox.
|
||||
*/
|
||||
private fun isPerformanceTest(intent: Intent, context: Context): Boolean {
|
||||
if (!intent.getBooleanExtra(EXTRA_IS_PERFORMANCE_TEST, false)) {
|
||||
return false
|
||||
}
|
||||
|
||||
val batteryStatus = context.registerReceiver(null, IntentFilter(Intent.ACTION_BATTERY_CHANGED))
|
||||
batteryStatus?.let {
|
||||
val isPhonePlugged = it.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1) ==
|
||||
BatteryManager.BATTERY_PLUGGED_USB
|
||||
// We only run perf tests when the device is connected to USB. However, AC may be reported
|
||||
// instead if the device is connected through a USB hub so we check both states.
|
||||
val extraPlugged = it.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1)
|
||||
val isPhonePlugged = extraPlugged == BatteryManager.BATTERY_PLUGGED_USB ||
|
||||
extraPlugged == BatteryManager.BATTERY_PLUGGED_AC
|
||||
|
||||
val isAdbEnabled = AndroidSettings.Global.getInt(
|
||||
context.contentResolver,
|
||||
AndroidSettings.Global.ADB_ENABLED, 0
|
||||
|
Loading…
Reference in New Issue
Block a user