From 0728f35cbea54943ddd23e9d8ceaa855d41aedae Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Thu, 22 Feb 2018 11:17:05 +0000 Subject: [PATCH] framwork/target: parameterize disabling of SELinux Add a parameter to optionally not attempt to disable SELinux as that can cause problems on some platforms. --- wa/framework/target/assistant.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/wa/framework/target/assistant.py b/wa/framework/target/assistant.py index 4f77b924..e8f439cc 100644 --- a/wa/framework/target/assistant.py +++ b/wa/framework/target/assistant.py @@ -31,6 +31,12 @@ class LinuxAssistant(object): class AndroidAssistant(object): parameters = [ + Parameter('disable_selinux', kind=bool, default=True, + description=""" + If ``True``, the default, and the target is rooted, an attempt will + be made to disable SELinux by running ``setenforce 0`` on the target + at the beginning of the run. + """), Parameter('logcat_poll_period', kind=int, constraint=lambda x: x > 0, description=""" @@ -47,12 +53,13 @@ class AndroidAssistant(object): """), ] - def __init__(self, target, logcat_poll_period=None): + def __init__(self, target, logcat_poll_period=None, disable_selinux=True): self.target = target self.logcat_poll_period = logcat_poll_period + self.disable_selinux = disable_selinux self.logcat_poller = None - if self.target.is_rooted: - self.disable_selinux() + if self.target.is_rooted and self.disable_selinux: + self.do_disable_selinux() def start(self): if self.logcat_poll_period: @@ -79,7 +86,7 @@ class AndroidAssistant(object): if self.logcat_poller: self.logcat_poller.clear_buffer() - def disable_selinux(self): + def do_disable_selinux(self): # SELinux was added in Android 4.3 (API level 18). Trying to # 'getenforce' in earlier versions will produce an error. if self.target.get_sdk_version() >= 18: