Skip to content

Commit 0bfb6e4

Browse files
author
Brendan Jackman
committed
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.
1 parent dc453ad commit 0bfb6e4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

devlib/target.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1252,9 +1252,11 @@ def set_airplane_mode(self, mode):
12521252
root_required = self.get_sdk_version() > 23
12531253
if root_required and not self.is_rooted:
12541254
raise TargetError('Root is required to toggle airplane mode on Android 7+')
1255+
mode = int(boolean(mode))
12551256
cmd = 'settings put global airplane_mode_on {}'
1256-
self.execute(cmd.format(int(boolean(mode))))
1257-
self.execute('am broadcast -a android.intent.action.AIRPLANE_MODE', as_root=root_required)
1257+
self.execute(cmd.format(mode))
1258+
self.execute('am broadcast -a android.intent.action.AIRPLANE_MODE '
1259+
'--ez state {}'.format(mode), as_root=root_required)
12581260

12591261
def get_auto_rotation(self):
12601262
cmd = 'settings get system accelerometer_rotation'

0 commit comments

Comments
 (0)