diff --git a/libs/utils/android/__init__.py b/libs/utils/android/__init__.py index c067fc8b1990b39ccda250039cab1dc91e903e0f..23b868f9893c4267ba31135a1babcc978d833327 100644 --- a/libs/utils/android/__init__.py +++ b/libs/utils/android/__init__.py @@ -18,4 +18,5 @@ """Initialization for Android module""" from screen import Screen +from system import System from workload import Workload diff --git a/libs/utils/android/system.py b/libs/utils/android/system.py new file mode 100644 index 0000000000000000000000000000000000000000..87258e49e7308acf0e1ed06cea73a50c859f1a09 --- /dev/null +++ b/libs/utils/android/system.py @@ -0,0 +1,40 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2015, ARM Limited and contributors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import logging + +class System(object): + """ + Collection of Android related services + """ + + @staticmethod + def set_airplane_mode(target, on=True): + """ + Set airplane mode + """ + ap_mode = 1 if on else 0 + ap_state = 'true' if on else 'false' + + target.execute('settings put global airplane_mode_on {}'\ + .format(ap_mode)) + target.execute('am broadcast '\ + '-a android.intent.action.AIRPLANE_MODE '\ + '--ez state {}'\ + .format(ap_state)) + +# vim :set tabstop=4 shiftwidth=4 expandtab diff --git a/libs/utils/android/workloads/jankbench.py b/libs/utils/android/workloads/jankbench.py index d7c1443bd489e7fa130a2ff25268074fbf6a1d29..cd9fd3c2bd9da38b40f3ac4ae78c6b4842c226cf 100644 --- a/libs/utils/android/workloads/jankbench.py +++ b/libs/utils/android/workloads/jankbench.py @@ -19,7 +19,7 @@ import re import os from subprocess import Popen, PIPE -from android import Screen, Workload +from android import Screen, System, Workload import logging @@ -88,6 +88,9 @@ class Jankbench(Workload): self.target.execute('am force-stop com.android.benchmark') self.target.execute('pm clear com.android.benchmark') + # Set airplane mode + System.set_airplane_mode(self.target, on=True) + # Force screen in PORTRAIT mode Screen.set_orientation(self.target, portrait=True)