Commit 3e70c9fd authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

Fix incremental_install on Android P

Turns out it uses a different setting for disabling hidden API access
from Q. hidden_api_policy_p_apps vs hidden_api_policy.

Bug: None
Change-Id: I25d603664da762f24d44f66bafb20fe641a2b935
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2159408
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarPeter Conn <peconn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#761003}
parent b5e305cf
...@@ -233,20 +233,28 @@ def Install(device, install_json, apk=None, enable_device_cache=False, ...@@ -233,20 +233,28 @@ def Install(device, install_json, apk=None, enable_device_cache=False,
target_sdk_version = int(apk.GetTargetSdkVersion()) target_sdk_version = int(apk.GetTargetSdkVersion())
# Beta Q builds apply whitelist to targetSdk=28 as well. # Beta Q builds apply whitelist to targetSdk=28 as well.
if target_sdk_version >= 28 and device.build_version_sdk >= 28: if target_sdk_version >= 28 and device.build_version_sdk >= 28:
# In P, there are two settings:
# * hidden_api_policy_p_apps
# * hidden_api_policy_pre_p_apps
# In Q, there is just one:
# * hidden_api_policy
if device.build_version_sdk == 28:
setting_name = 'hidden_api_policy_p_apps'
else:
setting_name = 'hidden_api_policy'
apis_allowed = ''.join( apis_allowed = ''.join(
device.RunShellCommand( device.RunShellCommand(['settings', 'get', 'global', setting_name],
['settings', 'get', 'global', 'hidden_api_policy'],
check_return=True)) check_return=True))
if apis_allowed.strip() not in '01': if apis_allowed.strip() not in '01':
msg = """\ msg = """\
Cannot use incremental installs on Android Q+ without first enabling access to Cannot use incremental installs on Android P+ without first enabling access to
non-SDK interfaces (https://developer.android.com/preview/non-sdk-q). non-SDK interfaces (https://developer.android.com/preview/non-sdk-q).
To enable access: To enable access:
adb -s {0} shell settings put global hidden_api_policy 0 adb -s {0} shell settings put global {1} 0
To restore back to default: To restore back to default:
adb -s {0} shell settings delete global hidden_api_policy""" adb -s {0} shell settings delete global {1}"""
raise Exception(msg.format(device.serial)) raise Exception(msg.format(device.serial, setting_name))
cache_path = _DeviceCachePath(device) cache_path = _DeviceCachePath(device)
def restore_cache(): def restore_cache():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment