Module: DroidAdbs::Doze

Defined in:
lib/droid_adbs/commons/doze.rb

Class Method Summary collapse

Class Method Details

.force_idleString

Returns message from adb command.

Returns:

  • (String)

    message from adb command



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/droid_adbs/commons/doze.rb', line 5

def force_idle
  `#{::DroidAdbs.shell} dumpsys battery unplug`.strip
  `#{::DroidAdbs.shell} dumpsys deviceidle force-idle`.strip

  result = false

  30.times do
    deviceidle = `#{::DroidAdbs.shell} dumpsys deviceidle`.strip
    result = deviceidle.include?("mState=IDLE mLightState=OVERRIDE")
    break if result
    sleep 0.5
  end

  result
end

.resetString

Returns message from adb command.

Returns:

  • (String)

    message from adb command



22
23
24
25
26
# File 'lib/droid_adbs/commons/doze.rb', line 22

def reset
  `#{::DroidAdbs.shell} dumpsys deviceidle disable`
  `#{::DroidAdbs.shell} dumpsys deviceidle enable`
  `#{::DroidAdbs.shell} dumpsys battery reset`
end