From 6c4aec9441efd6069b6fbf7cc5d920bbb2f095e4 Mon Sep 17 00:00:00 2001 From: Patrick Bellasi Date: Mon, 13 Jun 2016 14:45:28 +0100 Subject: [PATCH 1/2] libs/utils/android: add initial support for system utilities The Android::System module is meant to collect functions related to system tunables. For the time being we add just one function which allows to toggle the AIRPLANE mode of an Android target. Signed-off-by: Patrick Bellasi --- libs/utils/android/__init__.py | 1 + libs/utils/android/system.py | 40 ++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 libs/utils/android/system.py diff --git a/libs/utils/android/__init__.py b/libs/utils/android/__init__.py index c067fc8b1..23b868f98 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 000000000..87258e49e --- /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 -- GitLab From 9e443fcf810d000003cdf5431a07b50ee3285017 Mon Sep 17 00:00:00 2001 From: Patrick Bellasi Date: Mon, 13 Jun 2016 14:47:16 +0100 Subject: [PATCH 2/2] libs/utils/android: ensure Jankbench is executed while in AIRPLANE mode We do not need WiFi connectivity while Jankbench runs thus, to have more stable measurements for energy consumption, let's enabled AIRPLANE mode before starting the test. Signed-off-by: Patrick Bellasi --- libs/utils/android/workloads/jankbench.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/utils/android/workloads/jankbench.py b/libs/utils/android/workloads/jankbench.py index d7c1443bd..cd9fd3c2b 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) -- GitLab