コード例 #1
0
def SetProperties(device, enable_java_debug, disable_location,
                  disable_mock_location):
    try:
        device.EnableRoot()
    except device_errors.CommandFailedError as e:
        logger.warning(str(e))

    if not device.IsUserBuild():
        _ConfigureLocalProperties(device, enable_java_debug)
    else:
        logger.warning('Cannot configure properties in user builds.')
    settings.ConfigureContentSettings(device,
                                      settings.DETERMINISTIC_DEVICE_SETTINGS)
    if disable_location:
        settings.ConfigureContentSettings(device,
                                          settings.DISABLE_LOCATION_SETTINGS)
    else:
        settings.ConfigureContentSettings(device,
                                          settings.ENABLE_LOCATION_SETTINGS)

    if disable_mock_location:
        settings.ConfigureContentSettings(
            device, settings.DISABLE_MOCK_LOCATION_SETTINGS)
    else:
        settings.ConfigureContentSettings(
            device, settings.ENABLE_MOCK_LOCATION_SETTINGS)

    settings.SetLockScreenSettings(device)

    # Some device types can momentarily disappear after setting properties.
    device.adb.WaitForDevice()
コード例 #2
0
      presentation.device, settings.DETERMINISTIC_DEVICE_SETTINGS)
  if disable_location:
    settings.ConfigureContentSettings(
        presentation.device, settings.DISABLE_LOCATION_SETTINGS)
  else:
    settings.ConfigureContentSettings(
        presentation.device, settings.ENABLE_LOCATION_SETTINGS)

  if disable_mock_location:
    settings.ConfigureContentSettings(
        presentation.device, settings.DISABLE_MOCK_LOCATION_SETTINGS)
  else:
    settings.ConfigureContentSettings(
        presentation.device, settings.ENABLE_MOCK_LOCATION_SETTINGS)

  settings.SetLockScreenSettings(presentation.device)

  # Some presentation.device types can momentarily disappear after setting properties.
  presentation.device.adb.WaitForDevice()


def DisableNetwork(presentation.device):
  settings.ConfigureContentSettings(
      presentation.device, settings.NETWORK_DISABLED_SETTINGS)
  if presentation.device.build_version_sdk >= version_codes.MARSHMALLOW:
    # Ensure that NFC is also switched off.
    presentation.device.RunShellCommand(['svc', 'nfc', 'disable'],
                           as_root=True, check_return=True)


def DisableSystemChrome(presentation.device):