module DroidAdbs::Settings

Public Class Methods

disable_always_finish_activities() click to toggle source

@return [String] message from adb command

# File lib/droid_adbs/commons/settings.rb, line 5
def disable_always_finish_activities
  `#{::DroidAdbs.shell} settings put global always_finish_activities 0`.strip
end
enable_always_finish_activities() click to toggle source

@return [String] message from adb command

# File lib/droid_adbs/commons/settings.rb, line 10
def enable_always_finish_activities
  `#{::DroidAdbs.shell} settings put global always_finish_activities 1`.strip
end
get_date(format = "") click to toggle source

@param [String] format A format to `adb shell date`. `+%Y-%m-%dT%T%z` is one format. @return [String] message from adb command

# File lib/droid_adbs/commons/settings.rb, line 71
def get_date(format = "")
  `#{::DroidAdbs.shell} date #{format}`.strip
end
set_date(date) click to toggle source

Only for rooted devices.

Default SET format is “MMDDhhmm[[CC]YY]”, that's (2 digits each) month, day, hour (0-23), and minute. Optionally century, year, and second. 060910002016.00 Thu Jun 9 10:00:00 GMT 2016 @example

# Error case
::DroidAdbs::Settings.set_date '060910002016.00' #=> "date: cannot set date: Operation not permitted\r\nThu Jun  9 10:00:00 JST 2016"
# File lib/droid_adbs/commons/settings.rb, line 86
def set_date(date)
  turn_auto_time_off
  result = `#{::DroidAdbs.shell} date #{date}`.strip
  `#{::DroidAdbs.shell} am broadcast -a android.intent.action.TIME_SET`

  result
end
set_date_to(yyyymmdd, hhmmss) click to toggle source

@return [String] message from adb command

# File lib/droid_adbs/commons/settings.rb, line 64
def set_date_to(yyyymmdd, hhmmss)
  turn_auto_time_off
  `#{::DroidAdbs.shell} date -s #{yyyymmdd}.#{hhmmss}`.strip
end
turn_airplain_mode_off() click to toggle source

@return [String] message from adb command

# File lib/droid_adbs/commons/settings.rb, line 23
def turn_airplain_mode_off
  result1 = `#{::DroidAdbs.shell} settings put global airplane_mode_on 0`
  result2 = `#{::DroidAdbs.shell} am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false`.strip
  result1.concat result2
end
turn_airplain_mode_on() click to toggle source
Network mode

@return [String] message from adb command

# File lib/droid_adbs/commons/settings.rb, line 16
def turn_airplain_mode_on
  result1 = `#{::DroidAdbs.shell} settings put global airplane_mode_on 1`
  result2 = `#{::DroidAdbs.shell} am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true`.strip
  result1.concat result2
end
turn_all_animation_off() click to toggle source

animation settings @return [String] message from adb command

# File lib/droid_adbs/commons/settings.rb, line 96
def turn_all_animation_off
  turn_all_animation_off_without_reboot
  intent_boot_completed
  puts "adopt settings..."
  false
end
turn_all_animation_off_without_reboot() click to toggle source

animation settings @return [String] message from adb command

# File lib/droid_adbs/commons/settings.rb, line 105
def turn_all_animation_off_without_reboot
  unless available_changing_animation?
    puts "the device is not over API Level 17"
    return true
  end

  if all_animation_off?
    puts "already all animation settings are off"
    return true
  end

  scale_off "window_animation_scale"
  scale_off "transition_animation_scale"
  scale_off "animator_duration_scale"
  false
end
turn_all_animation_on() click to toggle source

@return [String] message from adb command

# File lib/droid_adbs/commons/settings.rb, line 123
def turn_all_animation_on
  turn_all_animation_on_without_reboot
  intent_boot_completed
  puts "adopt settings..."
  false
end
turn_all_animation_on_without_reboot() click to toggle source

@return [String] message from adb command

# File lib/droid_adbs/commons/settings.rb, line 131
def turn_all_animation_on_without_reboot
  unless available_changing_animation?
    puts "the device is not over API Level 17"
    return true
  end

  if all_animation_on?
    puts "already all animation settings are on"
    return true
  end

  scale_on "window_animation_scale"
  scale_on "transition_animation_scale"
  scale_on "animator_duration_scale"
  false
end
turn_auto_time_off() click to toggle source

@return [String] message from adb command

# File lib/droid_adbs/commons/settings.rb, line 59
def turn_auto_time_off
  `#{::DroidAdbs.shell} settings put global auto_time 0`.strip
end
turn_auto_time_on() click to toggle source

@return [String] message from adb command

# File lib/droid_adbs/commons/settings.rb, line 54
def turn_auto_time_on
  `#{::DroidAdbs.shell} settings put global auto_time 1`.strip
end
turn_cpu_monitoring_off() click to toggle source

@return [String] message from adb command

# File lib/droid_adbs/commons/settings.rb, line 49
def turn_cpu_monitoring_off
  `#{::DroidAdbs.shell} settings put global show_processes 0`.strip
end
turn_cpu_monitoring_on() click to toggle source

@return [String] message from adb command

# File lib/droid_adbs/commons/settings.rb, line 44
def turn_cpu_monitoring_on
  `#{::DroidAdbs.shell} settings put global show_processes 1`.strip
end
turn_wifi_off() click to toggle source

@return [String] message from adb command

# File lib/droid_adbs/commons/settings.rb, line 37
def turn_wifi_off
  result1 = `#{::DroidAdbs.shell} settings put global wifi_on 0`
  result2 = `#{::DroidAdbs.shell} am broadcast -a android.intent.action.WIFI_ON --ez state false`.strip
  result1.concat result2
end
turn_wifi_on() click to toggle source

@return [String] message from adb command

# File lib/droid_adbs/commons/settings.rb, line 30
def turn_wifi_on
  result1 = `#{::DroidAdbs.shell} settings put global wifi_on 1`
  result2 = `#{::DroidAdbs.shell} am broadcast -a android.intent.action.WIFI_ON --ez state false`.strip
  result1.concat result2
end

Private Class Methods

all_animation_off?() click to toggle source
# File lib/droid_adbs/commons/settings.rb, line 185
def all_animation_off?
  return true if window_animation_scale == 0 && transition_animation_scale == 0 && animator_duration_scale == 0
  false
end
all_animation_on?() click to toggle source
# File lib/droid_adbs/commons/settings.rb, line 190
def all_animation_on?
  return true if window_animation_scale == 1 && transition_animation_scale == 1 && animator_duration_scale == 1
  false
end
animator_duration_scale() click to toggle source
# File lib/droid_adbs/commons/settings.rb, line 177
def animator_duration_scale
  get_scale_of "transition_animation_scale"
end
available_changing_animation?() click to toggle source
# File lib/droid_adbs/commons/settings.rb, line 181
def available_changing_animation?
  ::DroidAdbs::Devices.device_build_version_sdk.to_i >= 17
end
get_scale_of(setting) click to toggle source
# File lib/droid_adbs/commons/settings.rb, line 158
def get_scale_of(setting)
  result = `#{::DroidAdbs.shell} settings get global #{setting}`.chomp
  return 0 if result == "null"
  result.to_i
end
intent_boot_completed() click to toggle source
# File lib/droid_adbs/commons/settings.rb, line 164
def intent_boot_completed
  `#{::DroidAdbs.shell} am broadcast -a android.intent.action.BOOT_COMPLETED`
end
scale_off(setting) click to toggle source
# File lib/droid_adbs/commons/settings.rb, line 150
def scale_off(setting)
  `#{::DroidAdbs.shell} settings put global #{setting} 0`
end
scale_on(setting) click to toggle source
# File lib/droid_adbs/commons/settings.rb, line 154
def scale_on(setting)
  `#{::DroidAdbs.shell} settings put global #{setting} 1`
end
transition_animation_scale() click to toggle source
# File lib/droid_adbs/commons/settings.rb, line 173
def transition_animation_scale
  get_scale_of "transition_animation_scale"
end
window_animation_scale() click to toggle source

for window animations

# File lib/droid_adbs/commons/settings.rb, line 169
def window_animation_scale
  get_scale_of "window_animation_scale"
end