1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 10:10:46 +00:00

AndroidTarget: Add boolean 'state' to airplane mode intent broadcast

Recently I've been seeing some errors with enabling airplane mode on
hikey960 - firstly I get a 'broken pipe' error followed by a 'cmd:
Can't find service: settings'. This missing boolean was the first
thing I found that had changed wrt. the code I used to use, and
adding it back appears to fix the issue.
This commit is contained in:
Brendan Jackman 2017-10-11 13:09:15 +01:00
parent dc453ad891
commit 0bfb6e4e54

View File

@ -1252,9 +1252,11 @@ class AndroidTarget(Target):
root_required = self.get_sdk_version() > 23
if root_required and not self.is_rooted:
raise TargetError('Root is required to toggle airplane mode on Android 7+')
mode = int(boolean(mode))
cmd = 'settings put global airplane_mode_on {}'
self.execute(cmd.format(int(boolean(mode))))
self.execute('am broadcast -a android.intent.action.AIRPLANE_MODE', as_root=root_required)
self.execute(cmd.format(mode))
self.execute('am broadcast -a android.intent.action.AIRPLANE_MODE '
'--ez state {}'.format(mode), as_root=root_required)
def get_auto_rotation(self):
cmd = 'settings get system accelerometer_rotation'