Module: DroidAdbs::Settings

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

Class Method Summary collapse

Class Method Details

.disable_always_finish_activitiesString

Returns message from adb command.

Returns:

  • (String)

    message from adb command



5
6
7
# 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_activitiesString

Returns message from adb command.

Returns:

  • (String)

    message from adb command



10
11
12
# 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 = "") ⇒ String

Returns message from adb command.

Parameters:

  • format (String) (defaults to: "")

    A format to ‘adb shell date`. `+%Y-%m-%dT%T%z` is one format.

Returns:

  • (String)

    message from adb command



71
72
73
# File 'lib/droid_adbs/commons/settings.rb', line 71

def get_date(format = "")
  `#{::DroidAdbs.shell} date #{format}`.strip
end

.set_date(date) ⇒ Object

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

Examples:


# Error case
::DroidAdbs::Settings.set_date '060910002016.00' #=> "date: cannot set date: Operation not permitted\r\nThu Jun  9 10:00:00 JST 2016"


86
87
88
89
90
91
92
# 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) ⇒ String

Returns message from adb command.

Returns:

  • (String)

    message from adb command



64
65
66
67
# 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_offString

Returns message from adb command.

Returns:

  • (String)

    message from adb command



23
24
25
26
27
# 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_onString

Network mode

Returns:

  • (String)

    message from adb command



16
17
18
19
20
# 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_offString

animation settings

Returns:

  • (String)

    message from adb command



96
97
98
99
100
101
# 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_rebootString

animation settings

Returns:

  • (String)

    message from adb command



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# 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_onString

Returns message from adb command.

Returns:

  • (String)

    message from adb command



123
124
125
126
127
128
# 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_rebootString

Returns message from adb command.

Returns:

  • (String)

    message from adb command



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# 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_offString

Returns message from adb command.

Returns:

  • (String)

    message from adb command



59
60
61
# 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_onString

Returns message from adb command.

Returns:

  • (String)

    message from adb command



54
55
56
# 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_offString

Returns message from adb command.

Returns:

  • (String)

    message from adb command



49
50
51
# 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_onString

Returns message from adb command.

Returns:

  • (String)

    message from adb command



44
45
46
# 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_offString

Returns message from adb command.

Returns:

  • (String)

    message from adb command



37
38
39
40
41
# 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_onString

Returns message from adb command.

Returns:

  • (String)

    message from adb command



30
31
32
33
34
# 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