• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2014 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import logging
6
7from pylib import content_settings
8
9
10def ConfigureContentSettingsDict(device, desired_settings):
11  """Configures device content setings from a dictionary.
12
13  Many settings are documented at:
14    http://developer.android.com/reference/android/provider/Settings.Global.html
15    http://developer.android.com/reference/android/provider/Settings.Secure.html
16    http://developer.android.com/reference/android/provider/Settings.System.html
17
18  Many others are undocumented.
19
20  Args:
21    device: A DeviceUtils instance for the device to configure.
22    desired_settings: A dict of {table: {key: value}} for all
23        settings to configure.
24  """
25  try:
26    sdk_version = int(device.old_interface.system_properties[
27        'ro.build.version.sdk'])
28  except ValueError:
29    logging.error('Skipping content settings configuration, unknown sdk %s',
30                  device.old_interface.system_properties[
31                      'ro.build.version.sdk'])
32    return
33
34  if sdk_version < 16:
35    logging.error('Skipping content settings configuration due to outdated sdk')
36    return
37
38  device.old_interface.system_properties['persist.sys.usb.config'] = 'adb'
39  device.old_interface.WaitForDevicePm()
40
41  for table, key_value in sorted(desired_settings.iteritems()):
42    settings = content_settings.ContentSettings(table, device)
43    for key, value in key_value.iteritems():
44      settings[key] = value
45    logging.info('\n%s %s', table, (80 - len(table)) * '-')
46    for key, value in sorted(settings.iteritems()):
47      logging.info('\t%s: %s', key, value)
48
49
50ENABLE_LOCATION_SETTING = {
51  'settings/secure': {
52    # Ensure Geolocation is enabled and allowed for tests.
53    'location_providers_allowed': 'gps,network',
54  }
55}
56
57DISABLE_LOCATION_SETTING = {
58  'settings/secure': {
59    # Ensure Geolocation is disabled.
60    'location_providers_allowed': '',
61  }
62}
63
64DETERMINISTIC_DEVICE_SETTINGS = {
65  'com.google.settings/partner': {
66    'network_location_opt_in': 0,
67    'use_location_for_services': 1,
68  },
69  'settings/global': {
70    'assisted_gps_enabled': 0,
71
72    # Disable "auto time" and "auto time zone" to avoid network-provided time
73    # to overwrite the device's datetime and timezone synchronized from host
74    # when running tests later. See b/6569849.
75    'auto_time': 0,
76    'auto_time_zone': 0,
77
78    'development_settings_enabled': 1,
79
80    # Flag for allowing ActivityManagerService to send ACTION_APP_ERROR intents
81    # on application crashes and ANRs. If this is disabled, the crash/ANR dialog
82    # will never display the "Report" button.
83    # Type: int ( 0 = disallow, 1 = allow )
84    'send_action_app_error': 0,
85
86    'stay_on_while_plugged_in': 3,
87
88    'verifier_verify_adb_installs' : 0,
89  },
90  'settings/secure': {
91    'allowed_geolocation_origins':
92        'http://www.google.co.uk http://www.google.com',
93
94    # Ensure that we never get random dialogs like "Unfortunately the process
95    # android.process.acore has stopped", which steal the focus, and make our
96    # automation fail (because the dialog steals the focus then mistakenly
97    # receives the injected user input events).
98    'anr_show_background': 0,
99
100    'lockscreen.disabled': 1,
101
102    'screensaver_enabled': 0,
103  },
104  'settings/system': {
105    # Don't want devices to accidentally rotate the screen as that could
106    # affect performance measurements.
107    'accelerometer_rotation': 0,
108
109    'lockscreen.disabled': 1,
110
111    # Turn down brightness and disable auto-adjust so that devices run cooler.
112    'screen_brightness': 5,
113    'screen_brightness_mode': 0,
114
115    'user_rotation': 0,
116  },
117}
118
119
120NETWORK_DISABLED_SETTINGS = {
121  'settings/global': {
122    'airplane_mode_on': 1,
123    'wifi_on': 0,
124  },
125}
126