1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2024-10-06 10:51:13 +01:00

AndroidWorkload: Added unchangeable android permissions

Some android permissions are categorized as 'unchangeable' so we don't need to
try and set them.
This commit is contained in:
Marc Bonnici 2017-05-18 17:51:15 +01:00
parent 3f03dec7af
commit 70f646f87d
2 changed files with 32 additions and 11 deletions

View File

@ -26,7 +26,8 @@ from wlauto.core.resource import NO_ONE
from wlauto.common.android.resources import ApkFile, ReventFile from wlauto.common.android.resources import ApkFile, ReventFile
from wlauto.common.resources import ExtensionAsset, Executable, File from wlauto.common.resources import ExtensionAsset, Executable, File
from wlauto.exceptions import WorkloadError, ResourceError, DeviceError from wlauto.exceptions import WorkloadError, ResourceError, DeviceError
from wlauto.utils.android import ApkInfo, ANDROID_NORMAL_PERMISSIONS, UNSUPPORTED_PACKAGES from wlauto.utils.android import (ApkInfo, ANDROID_NORMAL_PERMISSIONS,
ANDROID_UNCHANGEABLE_PERMISSIONS, UNSUPPORTED_PACKAGES)
from wlauto.utils.types import boolean, ParameterDict from wlauto.utils.types import boolean, ParameterDict
from wlauto.utils.revent import ReventRecording from wlauto.utils.revent import ReventRecording
import wlauto.utils.statedetect as state_detector import wlauto.utils.statedetect as state_detector
@ -446,16 +447,18 @@ class ApkWorkload(Workload):
# "Normal" Permisions are automatically granted and cannot be changed # "Normal" Permisions are automatically granted and cannot be changed
permission_name = permission.rsplit('.', 1)[1] permission_name = permission.rsplit('.', 1)[1]
if permission_name not in ANDROID_NORMAL_PERMISSIONS: if permission_name not in ANDROID_NORMAL_PERMISSIONS:
# On some API 23+ devices, this may fail with a SecurityException # Some permissions are not allowed to be "changed"
# on previously granted permissions. In that case, just skip as it if permission_name not in ANDROID_UNCHANGEABLE_PERMISSIONS:
# is not fatal to the workload execution # On some API 23+ devices, this may fail with a SecurityException
try: # on previously granted permissions. In that case, just skip as it
self.device.execute("pm grant {} {}".format(self.package, permission)) # is not fatal to the workload execution
except DeviceError as e: try:
if "changeable permission" in e.message or "Unknown permission" in e.message: self.device.execute("pm grant {} {}".format(self.package, permission))
self.logger.debug(e) except DeviceError as e:
else: if "changeable permission" in e.message or "Unknown permission" in e.message:
raise e self.logger.debug(e)
else:
raise e
def do_post_install(self, context): def do_post_install(self, context):
""" May be overwritten by derived classes.""" """ May be overwritten by derived classes."""

View File

@ -103,6 +103,24 @@ ANDROID_NORMAL_PERMISSIONS = [
'UNINSTALL_SHORTCUT', 'UNINSTALL_SHORTCUT',
] ]
ANDROID_UNCHANGEABLE_PERMISSIONS = [
'USE_CREDENTIALS',
'MANAGE_ACCOUNTS',
'DOWNLOAD_WITHOUT_NOTIFICATION',
'AUTHENTICATE_ACCOUNTS',
'WRITE_SETTINGS',
'WRITE_SYNC_STATS',
'SUBSCRIBED_FEEDS_WRITE',
'SUBSCRIBED_FEEDS_READ',
'READ_PROFILE',
'WRITE_MEDIA_STORAGE',
'RESTART_PACKAGES',
'MOUNT_UNMOUNT_FILESYSTEMS',
'CLEAR_APP_CACHE',
'GET_TASKS',
]
# Package versions that are known to have problems with AndroidUiAutoBenchmark workloads. # Package versions that are known to have problems with AndroidUiAutoBenchmark workloads.
# NOTE: ABI versions are not included. # NOTE: ABI versions are not included.
UNSUPPORTED_PACKAGES = { UNSUPPORTED_PACKAGES = {