[Android] Fix the location prompt flake in provision_devices.
BUG=401163 Review URL: https://codereview.chromium.org/481433004 git-svn-id: http://src.chromium.org/svn/trunk/src/build@290353 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
Родитель
0336472687
Коммит
1aaf810872
|
@ -35,7 +35,7 @@ def KillHostHeartbeat():
|
|||
stdout, _ = ps.communicate()
|
||||
matches = re.findall('\\n.*host_heartbeat.*', stdout)
|
||||
for match in matches:
|
||||
print 'An instance of host heart beart running... will kill'
|
||||
logging.info('An instance of host heart beart running... will kill')
|
||||
pid = re.findall('(\d+)', match)[0]
|
||||
subprocess.call(['kill', str(pid)])
|
||||
|
||||
|
@ -44,7 +44,7 @@ def LaunchHostHeartbeat():
|
|||
# Kill if existing host_heartbeat
|
||||
KillHostHeartbeat()
|
||||
# Launch a new host_heartbeat
|
||||
print 'Spawning host heartbeat...'
|
||||
logging.info('Spawning host heartbeat...')
|
||||
subprocess.Popen([os.path.join(constants.DIR_SOURCE_ROOT,
|
||||
'build/android/host_heartbeat.py')])
|
||||
|
||||
|
@ -59,7 +59,7 @@ def PushAndLaunchAdbReboot(devices, target):
|
|||
locating the adb_reboot binary.
|
||||
"""
|
||||
for device_serial in devices:
|
||||
print 'Will push and launch adb_reboot on %s' % device_serial
|
||||
logging.info('Will push and launch adb_reboot on %s' % device_serial)
|
||||
device = device_utils.DeviceUtils(device_serial)
|
||||
# Kill if adb_reboot is already running.
|
||||
try:
|
||||
|
@ -71,12 +71,12 @@ def PushAndLaunchAdbReboot(devices, target):
|
|||
# to be running.
|
||||
pass
|
||||
# Push adb_reboot
|
||||
print ' Pushing adb_reboot ...'
|
||||
logging.info(' Pushing adb_reboot ...')
|
||||
adb_reboot = os.path.join(constants.DIR_SOURCE_ROOT,
|
||||
'out/%s/adb_reboot' % target)
|
||||
device.PushChangedFiles(adb_reboot, '/data/local/tmp/')
|
||||
# Launch adb_reboot
|
||||
print ' Launching adb_reboot ...'
|
||||
logging.info(' Launching adb_reboot ...')
|
||||
device.old_interface.GetAndroidToolStatusAndOutput(
|
||||
'/data/local/tmp/adb_reboot')
|
||||
LaunchHostHeartbeat()
|
||||
|
@ -160,17 +160,19 @@ def ProvisionDevice(device_serial, is_perf, disable_location):
|
|||
device = device_utils.DeviceUtils(device_serial)
|
||||
device.old_interface.EnableAdbRoot()
|
||||
_ConfigureLocalProperties(device, is_perf)
|
||||
device_settings_map = device_settings.DETERMINISTIC_DEVICE_SETTINGS
|
||||
device_settings.ConfigureContentSettings(
|
||||
device, device_settings.DETERMINISTIC_DEVICE_SETTINGS)
|
||||
if disable_location:
|
||||
device_settings_map.update(device_settings.DISABLE_LOCATION_SETTING)
|
||||
device_settings.ConfigureContentSettings(
|
||||
device, device_settings.DISABLE_LOCATION_SETTINGS)
|
||||
else:
|
||||
device_settings_map.update(device_settings.ENABLE_LOCATION_SETTING)
|
||||
device_settings.ConfigureContentSettingsDict(device, device_settings_map)
|
||||
device_settings.ConfigureContentSettings(
|
||||
device, device_settings.ENABLE_LOCATION_SETTINGS)
|
||||
device_settings.SetLockScreenSettings(device)
|
||||
if is_perf:
|
||||
# TODO(tonyg): We eventually want network on. However, currently radios
|
||||
# can cause perfbots to drain faster than they charge.
|
||||
device_settings.ConfigureContentSettingsDict(
|
||||
device_settings.ConfigureContentSettings(
|
||||
device, device_settings.NETWORK_DISABLED_SETTINGS)
|
||||
# Some perf bots run benchmarks with USB charging disabled which leads
|
||||
# to gradual draining of the battery. We must wait for a full charge
|
||||
|
@ -214,12 +216,18 @@ def ProvisionDevices(options):
|
|||
for device_serial in devices:
|
||||
try:
|
||||
ProvisionDevice(device_serial, is_perf, options.disable_location)
|
||||
except errors.WaitForResponseTimedOutError:
|
||||
except (errors.WaitForResponseTimedOutError,
|
||||
device_errors.CommandTimeoutError):
|
||||
logging.info('Timed out waiting for device %s. Adding to blacklist.',
|
||||
device_serial)
|
||||
bad_devices.append(device_serial)
|
||||
# Device black list is reset by bb_device_status_check.py per build.
|
||||
device_blacklist.ExtendBlacklist([device_serial])
|
||||
except device_errors.CommandFailedError:
|
||||
logging.info('Failed to provision device %s. Adding to blacklist.',
|
||||
device_serial)
|
||||
bad_devices.append(device_serial)
|
||||
device_blacklist.ExtendBlacklist([device_serial])
|
||||
devices = [device for device in devices if device not in bad_devices]
|
||||
|
||||
# If there are no good devices
|
||||
|
@ -238,13 +246,19 @@ def ProvisionDevices(options):
|
|||
device.WaitUntilFullyBooted(timeout=90)
|
||||
(_, prop) = device.old_interface.GetShellCommandStatusAndOutput('getprop')
|
||||
for p in prop:
|
||||
print p
|
||||
except errors.WaitForResponseTimedOutError:
|
||||
logging.info(p)
|
||||
except (errors.WaitForResponseTimedOutError,
|
||||
device_errors.CommandTimeoutError):
|
||||
logging.info('Timed out waiting for device %s. Adding to blacklist.',
|
||||
device_serial)
|
||||
bad_devices.append(device_serial)
|
||||
# Device black list is reset by bb_device_status_check.py per build.
|
||||
device_blacklist.ExtendBlacklist([device_serial])
|
||||
except device_errors.CommandFailedError:
|
||||
logging.info('Failed to provision device %s. Adding to blacklist.',
|
||||
device_serial)
|
||||
bad_devices.append(device_serial)
|
||||
device_blacklist.ExtendBlacklist([device_serial])
|
||||
devices = [device for device in devices if device not in bad_devices]
|
||||
|
||||
# If there are no good devices
|
||||
|
|
|
@ -10,8 +10,8 @@ _LOCK_SCREEN_SETTINGS_PATH = '/data/system/locksettings.db'
|
|||
PASSWORD_QUALITY_UNSPECIFIED = '0'
|
||||
|
||||
|
||||
def ConfigureContentSettingsDict(device, desired_settings):
|
||||
"""Configures device content setings from a dictionary.
|
||||
def ConfigureContentSettings(device, desired_settings):
|
||||
"""Configures device content setings from a list.
|
||||
|
||||
Many settings are documented at:
|
||||
http://developer.android.com/reference/android/provider/Settings.Global.html
|
||||
|
@ -22,7 +22,7 @@ def ConfigureContentSettingsDict(device, desired_settings):
|
|||
|
||||
Args:
|
||||
device: A DeviceUtils instance for the device to configure.
|
||||
desired_settings: A dict of {table: {key: value}} for all
|
||||
desired_settings: A list of (table, [(key: value), ...]) for all
|
||||
settings to configure.
|
||||
"""
|
||||
try:
|
||||
|
@ -40,9 +40,9 @@ def ConfigureContentSettingsDict(device, desired_settings):
|
|||
device.old_interface.WaitForDevicePm()
|
||||
|
||||
if device.GetProp('ro.build.type') == 'userdebug':
|
||||
for table, key_value in sorted(desired_settings.iteritems()):
|
||||
for table, key_value in desired_settings:
|
||||
settings = content_settings.ContentSettings(table, device)
|
||||
for key, value in key_value.iteritems():
|
||||
for key, value in key_value:
|
||||
settings[key] = value
|
||||
logging.info('\n%s %s', table, (80 - len(table)) * '-')
|
||||
for key, value in sorted(settings.iteritems()):
|
||||
|
@ -98,79 +98,85 @@ commit transaction;""" % {
|
|||
print ' '.join(output_msg)
|
||||
|
||||
|
||||
ENABLE_LOCATION_SETTING = {
|
||||
'settings/secure': {
|
||||
ENABLE_LOCATION_SETTINGS = [
|
||||
# Note that setting these in this order is required in order for all of
|
||||
# them to take and stick through a reboot.
|
||||
('com.google.settings/partner', [
|
||||
('use_location_for_services', 1),
|
||||
]),
|
||||
('settings/secure', [
|
||||
# Ensure Geolocation is enabled and allowed for tests.
|
||||
'location_providers_allowed': 'gps,network',
|
||||
}
|
||||
}
|
||||
('location_providers_allowed', 'gps,network'),
|
||||
]),
|
||||
('com.google.settings/partner', [
|
||||
('network_location_opt_in', 1),
|
||||
])
|
||||
]
|
||||
|
||||
DISABLE_LOCATION_SETTING = {
|
||||
'settings/secure': {
|
||||
DISABLE_LOCATION_SETTINGS = [
|
||||
('com.google.settings/partner', [
|
||||
('use_location_for_services', 0),
|
||||
]),
|
||||
('settings/secure', [
|
||||
# Ensure Geolocation is disabled.
|
||||
'location_providers_allowed': '',
|
||||
}
|
||||
}
|
||||
('location_providers_allowed', ''),
|
||||
]),
|
||||
]
|
||||
|
||||
DETERMINISTIC_DEVICE_SETTINGS = {
|
||||
'com.google.settings/partner': {
|
||||
'network_location_opt_in': 0,
|
||||
'use_location_for_services': 1,
|
||||
},
|
||||
'settings/global': {
|
||||
'assisted_gps_enabled': 0,
|
||||
DETERMINISTIC_DEVICE_SETTINGS = [
|
||||
('settings/global', [
|
||||
('assisted_gps_enabled', 0),
|
||||
|
||||
# Disable "auto time" and "auto time zone" to avoid network-provided time
|
||||
# to overwrite the device's datetime and timezone synchronized from host
|
||||
# when running tests later. See b/6569849.
|
||||
'auto_time': 0,
|
||||
'auto_time_zone': 0,
|
||||
('auto_time', 0),
|
||||
('auto_time_zone', 0),
|
||||
|
||||
'development_settings_enabled': 1,
|
||||
('development_settings_enabled', 1),
|
||||
|
||||
# Flag for allowing ActivityManagerService to send ACTION_APP_ERROR intents
|
||||
# on application crashes and ANRs. If this is disabled, the crash/ANR dialog
|
||||
# will never display the "Report" button.
|
||||
# Type: int ( 0 = disallow, 1 = allow )
|
||||
'send_action_app_error': 0,
|
||||
('send_action_app_error', 0),
|
||||
|
||||
'stay_on_while_plugged_in': 3,
|
||||
('stay_on_while_plugged_in', 3),
|
||||
|
||||
'verifier_verify_adb_installs' : 0,
|
||||
},
|
||||
'settings/secure': {
|
||||
'allowed_geolocation_origins':
|
||||
'http://www.google.co.uk http://www.google.com',
|
||||
('verifier_verify_adb_installs', 0),
|
||||
]),
|
||||
('settings/secure', [
|
||||
('allowed_geolocation_origins',
|
||||
'http://www.google.co.uk http://www.google.com'),
|
||||
|
||||
# Ensure that we never get random dialogs like "Unfortunately the process
|
||||
# android.process.acore has stopped", which steal the focus, and make our
|
||||
# automation fail (because the dialog steals the focus then mistakenly
|
||||
# receives the injected user input events).
|
||||
'anr_show_background': 0,
|
||||
('anr_show_background', 0),
|
||||
|
||||
'lockscreen.disabled': 1,
|
||||
('lockscreen.disabled', 1),
|
||||
|
||||
'screensaver_enabled': 0,
|
||||
},
|
||||
'settings/system': {
|
||||
('screensaver_enabled', 0),
|
||||
]),
|
||||
('settings/system', [
|
||||
# Don't want devices to accidentally rotate the screen as that could
|
||||
# affect performance measurements.
|
||||
'accelerometer_rotation': 0,
|
||||
('accelerometer_rotation', 0),
|
||||
|
||||
'lockscreen.disabled': 1,
|
||||
('lockscreen.disabled', 1),
|
||||
|
||||
# Turn down brightness and disable auto-adjust so that devices run cooler.
|
||||
'screen_brightness': 5,
|
||||
'screen_brightness_mode': 0,
|
||||
('screen_brightness', 5),
|
||||
('screen_brightness_mode', 0),
|
||||
|
||||
'user_rotation': 0,
|
||||
},
|
||||
}
|
||||
('user_rotation', 0),
|
||||
]),
|
||||
]
|
||||
|
||||
|
||||
NETWORK_DISABLED_SETTINGS = {
|
||||
'settings/global': {
|
||||
'airplane_mode_on': 1,
|
||||
'wifi_on': 0,
|
||||
},
|
||||
}
|
||||
NETWORK_DISABLED_SETTINGS = [
|
||||
('settings/global', [
|
||||
('airplane_mode_on', 1),
|
||||
('wifi_on', 0),
|
||||
]),
|
||||
]
|
||||
|
|
Загрузка…
Ссылка в новой задаче