示例#1
0
    def __enter__(self):
        Hardware.__enter__(self)
        if not self._adb.is_root() and self._adb.root():
            self._adb.remount()

        self._adb.shell('\n'.join([
            # turn on airplane mode.
            '''
      settings put global airplane_mode_on 1''',

            # disable GPS.
            '''
      settings put secure location_providers_allowed -gps
      settings put secure location_providers_allowed -wifi
      settings put secure location_providers_allowed -network'''
        ]))

        if self._adb.is_root():

            # For explanation of variance reducing steps, see
            # https://g3doc.corp.google.com/engedu/portal/android/g3doc/learn/develop/performance/content/best/reliable-startup-latency.md?cl=head

            self._adb.shell('\n'.join([
                # disable bluetooth, wifi, and mobile data.
                '''
        service call bluetooth_manager 8
        svc wifi disable
        svc data disable''',

                # kill the gui.
                '''
        setprop ctl.stop media
        setprop ctl.stop zygote
        setprop ctl.stop surfaceflinger
        setprop ctl.stop drm''',

                # disable ASLR
                '''
        echo 0 > /proc/sys/kernel/randomize_va_space''',
            ]))

            self.lock_top_three_cores()

            self.lock_adreno_gpu()

        else:
            print("WARNING: no adb root access; results may be unreliable.",
                  file=sys.stderr)

        return self
示例#2
0
  def __enter__(self):
    Hardware.__enter__(self)
    if not self._adb.is_root() and self._adb.root():
      self._adb.remount()

    self._adb.shell('\n'.join([
      # turn on airplane mode.
      '''
      settings put global airplane_mode_on 1''',

      # disable GPS.
      '''
      settings put secure location_providers_allowed -gps
      settings put secure location_providers_allowed -wifi
      settings put secure location_providers_allowed -network''']))

    if self._adb.is_root():

      self._adb.shell('\n'.join([
        # disable bluetooth, wifi, and mobile data.
        '''
        service call bluetooth_manager 8
        svc wifi disable
        svc data disable''',

        # kill the gui.
        '''
        setprop ctl.stop media
        setprop ctl.stop zygote
        setprop ctl.stop surfaceflinger
        setprop ctl.stop drm''',

        # disable ASLR
        '''
        echo 0 > /proc/sys/kernel/randomize_va_space''',

        # stop services which can change clock speed
        '''
        stop thermal-engine
        stop perfd''']))

      self.lock_top_three_cores()

    else:
      print("WARNING: no adb root access; results may be unreliable.",
            file=sys.stderr)

    return self
  def __enter__(self):
    self._adb.shell('\n'.join([
      # turn on airplane mode.
      '''
      settings put global airplane_mode_on 1''',

      # disable GPS.
      '''
      for MODE in gps wifi network; do
        settings put secure location_providers_allowed -$MODE
      done''']))

    if self._adb.is_root():
      self._adb.shell('\n'.join([
        # disable bluetooth, wifi, and mobile data.
        '''
        service call bluetooth_manager 8
        svc wifi disable
        svc data disable''',

        # kill the gui.
        '''
        setprop ctl.stop media
        setprop ctl.stop zygote
        setprop ctl.stop surfaceflinger
        setprop ctl.stop drm''',

        # disable ASLR
        '''
        echo 0 > /proc/sys/kernel/randomize_va_space''']))
    else:
      print("WARNING: no adb root access; results may be unreliable.",
            file=sys.stderr)

    return Hardware.__enter__(self)
示例#4
0
  def __enter__(self):
    # turn on airplane mode.
    self._initial_airplane_mode = \
      self._adb.check('settings get global airplane_mode_on')
    self._adb.shell('settings put global airplane_mode_on 1')

    # disable GPS.
    self._initial_location_providers = \
      self._adb.check('settings get secure location_providers_allowed')
    self._initial_location_providers = \
      self._initial_location_providers.replace(',', ' ')
    self._adb.shell('''\
      for PROVIDER in %s; do
        settings put secure location_providers_allowed -$PROVIDER
      done''' % self._initial_location_providers)

    if self._is_root:
      # disable bluetooth, wifi, and mobile data.
      # TODO: can we query these initial values?
      self._adb.shell('''\
        service call bluetooth_manager 8 &&
        svc wifi disable &&
        svc data disable''')

      # kill the gui.
      self._adb.shell('''\
        setprop ctl.stop media &&
        setprop ctl.stop zygote &&
        setprop ctl.stop surfaceflinger &&
        setprop ctl.stop drm''')

      # disable ASLR.
      self._initial_ASLR = \
        self._adb.check('cat /proc/sys/kernel/randomize_va_space')
      self._adb.shell('echo 0 > /proc/sys/kernel/randomize_va_space')
    else:
      print("WARNING: no adb root access; results may be unreliable.",
            file=sys.stderr)

    return Hardware.__enter__(self)