# This Source Code Form is subject to the terms of the Mozilla Public # 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/. import sys import tempfile import time from pathlib import Path
import mozlog from mozdevice import ADBDevice, ADBError
from mozperftest.layers import Layer from mozperftest.system.android_perf_tuner import tune_performance from mozperftest.utils import download_file
def enable_notifications(self, package_id): """
The code block with pm grant enables notifications for the app,
otherwise during testing a request to enable/disable notifications will persist
through app shutdowns. """
self.device.shell(
f"pm grant {package_id} android.permission.POST_NOTIFICATIONS"
)
def skip_app_onboarding(self, package_id): """
We skip onboarding for focus in measure_start_up.py because it's stateful and needs to be called for every cold start intent.
Onboarding only visibly gets in the way of our MAIN test results. """ # This sets mutable state we only need to pass this flag once, before we start the test
self.device.shell(
f"am start-activity -W -a android.intent.action.MAIN --ez "
f"performancetest true -n {package_id}/org.mozilla.fenix.App"
)
time.sleep(4) # ensure skip onboarding call has time to propagate.
def setup(self): if self.custom_apk_exists():
self.info(
f"Replacing --android-install-apk with custom APK found at "
f"{self.custom_apk_path}"
)
self.set_arg("android-install-apk", [self.custom_apk_path])
def teardown(self): if self.capture_file isnotNone:
self.capture_file.close() if self.capture_logcat isnotNoneand self.device isnotNone:
self.info("Dumping logcat into %r" % str(self.capture_logcat)) with self.capture_logcat.open("wb") as f: for line in self.device.get_logcat():
f.write(line.encode("utf8", errors="replace") + b"\n")
def _set_output_path(self, path): if path in (None, "stdout"): return path # check if the path is absolute or relative to output
path = Path(path) ifnot path.is_absolute(): return Path(self.get_arg("output"), path) return path
if self.get_arg("android-perf-tuning", False):
tune_performance(self.device)
# set up default activity with the app name if none given if self.android_activity isNone: # guess the activity, given the app if"fenix"in self.app_name:
self.android_activity = "org.mozilla.fenix.IntentReceiverActivity" elif"geckoview_example"in self.app_name:
self.android_activity = ( "org.mozilla.geckoview_example.GeckoViewActivity"
)
self.set_arg("android_activity", self.android_activity)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.