Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1612)

Unified Diff: mojo/devtools/common/devtoolslib/android_shell.py

Issue 1509473002: Grant runtime permissions on install in `android_shell.py`. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/devtools/common/devtoolslib/android_shell.py
diff --git a/mojo/devtools/common/devtoolslib/android_shell.py b/mojo/devtools/common/devtoolslib/android_shell.py
index bda59c94db76abe454340181889f5ed087cec998..67e848778d9c670400f6146fecfea376dfeba7d2 100644
--- a/mojo/devtools/common/devtoolslib/android_shell.py
+++ b/mojo/devtools/common/devtoolslib/android_shell.py
@@ -194,6 +194,12 @@ class AndroidShell(Shell):
return len(subprocess.check_output(self._adb_command([
'shell', 'pm', 'list', 'packages', _MOJO_SHELL_PACKAGE_NAME]))) > 0
+ def _get_api_level(self):
+ """Returns the API level of Android running on the device."""
+ output = subprocess.check_output(self._adb_command([
+ 'shell', 'getprop', 'ro.build.version.sdk']))
+ return int(output)
+
@staticmethod
def get_tmp_dir_path():
"""Returns a path to a cache directory owned by the shell where temporary
@@ -264,9 +270,15 @@ class AndroidShell(Shell):
not self._is_shell_package_installed())
if do_install:
- subprocess.check_call(
- self._adb_command(['install', '-r', shell_apk_path, '-i',
- _MOJO_SHELL_PACKAGE_NAME]),
+ install_command = ['install']
+ install_command += ['-r'] # Allow to overwrite an existing installation.
+ install_command += ['-i', _MOJO_SHELL_PACKAGE_NAME]
+ if self._get_api_level() >= 23: # Check if running Lollipop or later.
+ # Grant all permissions listed in manifest. This flag is available only
+ # in Lollipop or later.
+ install_command += ['-g']
+ install_command += [shell_apk_path]
+ subprocess.check_call(self._adb_command(install_command),
stdout=self.verbose_stdout, stderr=self.verbose_stderr)
# Update the stamp on the device.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698