mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1241907 - Grant runtime permissions before running browser tests; r=jmaher
This commit is contained in:
parent
55c6244cda
commit
6fe30ec610
@ -246,6 +246,9 @@ class ReftestRunner(MozbuildObject):
|
||||
kwargs["ignoreWindowSize"] = True
|
||||
kwargs["printDeviceInfo"] = False
|
||||
|
||||
from mozrunner.devices.android_device import grant_runtime_permissions
|
||||
grant_runtime_permissions(self, kwargs['app'])
|
||||
|
||||
# A symlink and some path manipulations are required so that test
|
||||
# manifests can be found both locally and remotely (via a url)
|
||||
# using the same relative path.
|
||||
|
@ -11,8 +11,6 @@ package:
|
||||
@$(MAKE) -C mobile/android/installer
|
||||
|
||||
ifeq ($(OS_TARGET),Android)
|
||||
sdk_level=$(shell $(ADB) shell getprop ro.build.version.sdk)
|
||||
permissions-required=$(shell if [ $(sdk_level) -gt 22 ] ; then echo yes ; else echo no ; fi)
|
||||
ifneq ($(MOZ_ANDROID_INSTALL_TARGET),)
|
||||
ANDROID_SERIAL = $(MOZ_ANDROID_INSTALL_TARGET)
|
||||
endif
|
||||
@ -36,12 +34,7 @@ endif
|
||||
endif
|
||||
|
||||
install::
|
||||
ifeq ($(permissions-required),yes)
|
||||
|
||||
$(ADB) install -r -g $(DIST)/$(PKG_PATH)$(PKG_BASENAME).apk
|
||||
else
|
||||
$(ADB) install -r $(DIST)/$(PKG_PATH)$(PKG_BASENAME).apk
|
||||
endif
|
||||
else
|
||||
@echo 'Mobile can't be installed directly.'
|
||||
@exit 1
|
||||
|
@ -537,6 +537,8 @@ class MachCommands(MachCommandBase):
|
||||
if buildapp in ('b2g',):
|
||||
run_mochitest = mochitest.run_b2g_test
|
||||
elif buildapp == 'android':
|
||||
from mozrunner.devices.android_device import grant_runtime_permissions
|
||||
grant_runtime_permissions(self, kwargs['app'])
|
||||
run_mochitest = mochitest.run_android_test
|
||||
else:
|
||||
run_mochitest = mochitest.run_desktop_test
|
||||
@ -608,6 +610,9 @@ class RobocopCommands(MachCommandBase):
|
||||
sorted(list(test_paths)))))
|
||||
return 1
|
||||
|
||||
from mozrunner.devices.android_device import grant_runtime_permissions
|
||||
grant_runtime_permissions(self, kwargs['app'])
|
||||
|
||||
mochitest = self._spawn(MochitestRunner)
|
||||
return mochitest.run_robocop_test(self._mach_context, tests, 'robocop', **kwargs)
|
||||
|
||||
|
@ -260,6 +260,26 @@ def run_firefox_for_android(build_obj, params):
|
||||
return 1
|
||||
return 0
|
||||
|
||||
def grant_runtime_permissions(build_obj, app):
|
||||
"""
|
||||
Grant required runtime permissions to the specified app (typically org.mozilla.fennec_$USER).
|
||||
"""
|
||||
adb_path = _find_sdk_exe(build_obj.substs, 'adb', False)
|
||||
if not adb_path:
|
||||
adb_path = 'adb'
|
||||
dm = DeviceManagerADB(autoconnect=False, adbPath=adb_path, retryLimit=1)
|
||||
dm.default_timeout = 10
|
||||
try:
|
||||
sdk_level = dm.shellCheckOutput(['getprop', 'ro.build.version.sdk'])
|
||||
if sdk_level and int(sdk_level) >= 23:
|
||||
_log_info("Granting important runtime permissions to %s" % app)
|
||||
dm.shellCheckOutput(['pm', 'grant', app, 'android.permission.WRITE_EXTERNAL_STORAGE'])
|
||||
dm.shellCheckOutput(['pm', 'grant', app, 'android.permission.ACCESS_FINE_LOCATION'])
|
||||
dm.shellCheckOutput(['pm', 'grant', app, 'android.permission.CAMERA'])
|
||||
dm.shellCheckOutput(['pm', 'grant', app, 'android.permission.WRITE_CONTACTS'])
|
||||
except DMError:
|
||||
_log_warning("Unable to grant runtime permissions to %s" % app)
|
||||
|
||||
class AndroidEmulator(object):
|
||||
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user