droid_adbs 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/droid_adbs.gemspec +25 -0
- data/lib/droid_adbs/aapt.rb +11 -0
- data/lib/droid_adbs/commons/backup.rb +39 -0
- data/lib/droid_adbs/commons/devices.rb +51 -0
- data/lib/droid_adbs/commons/settings.rb +143 -0
- data/lib/droid_adbs/version.rb +3 -0
- data/lib/droid_adbs.rb +156 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c06783a633fb470aac4197887b6f5ea1fc7cbc0f
|
4
|
+
data.tar.gz: e01b132a3f4388b2dc8428a0e5bf2decf8f10ee5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e9dae586b04d91227cb4a73fb481f00aee282e4926641f5c689cb4bfd4ef50e59671bf38cf902fc18f0738b51f8b4c10a44bb22fc90620f3a466a057e889a191
|
7
|
+
data.tar.gz: 44d893850ac174013b1d822d8df1c17a19bebb06c08f3d15c4715016c600c68ce121311296f9b9bc93b81dd4c26ac5ca797ad045e7690a595d2fe5d8f76a61cf
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Kazuaki MATSUO
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# DroidAdbs
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/droid_adbs`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'droid_adbs'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install droid_adbs
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/droid_adbs. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "droid_adbs"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/droid_adbs.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'droid_adbs/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "droid_adbs"
|
8
|
+
spec.version = DroidAdbs::VERSION
|
9
|
+
spec.authors = ["Kazuaki MATSUO"]
|
10
|
+
spec.email = ["fly.49.89.over@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{adb command wrapper}
|
13
|
+
spec.description = %q{adb command wrapper}
|
14
|
+
spec.homepage = "https://github.com/KazuCocoa/droid_adbs"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
25
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module DroidAdbs
|
2
|
+
module Aapt
|
3
|
+
class << self
|
4
|
+
def get_manifesto(package_path, out_path)
|
5
|
+
raise "should set path to aapt, android-sdks/build-tools/xxxx" if `which aapt`.empty?
|
6
|
+
dumped_data = `aapt dump xmltree #{package_path} AndroidManifest.xml`
|
7
|
+
File.write out_path, dumped_data
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end # module Aapt
|
11
|
+
end # module DroidAdbs
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative "../../droid_adbs"
|
2
|
+
|
3
|
+
module DroidAdbs
|
4
|
+
module BackupUtils
|
5
|
+
class << self
|
6
|
+
|
7
|
+
# https://developer.android.com/intl/ja/training/backup/autosyncapi.html#testing
|
8
|
+
|
9
|
+
def enable_backup_logs
|
10
|
+
fail "Backup support over SDK 23(Android 6.0, M)" unless available_backup?
|
11
|
+
`#{::DroidAdbs.shell} setprop log.tag.BackupXmlParserLogging VERBOSE`
|
12
|
+
end
|
13
|
+
|
14
|
+
def full_backup(package)
|
15
|
+
fail "Backup support over SDK 23(Android 6.0, M)" unless available_backup?
|
16
|
+
`#{::DroidAdbs.shell} bmgr run`
|
17
|
+
`#{::DroidAdbs.shell} bmgr fullbackup #{package}`
|
18
|
+
end
|
19
|
+
|
20
|
+
def restore(package)
|
21
|
+
fail "Backup support over SDK 23(Android 6.0, M)" unless available_backup?
|
22
|
+
`#{::DroidAdbs.shell} bmgr restore #{package}`
|
23
|
+
end
|
24
|
+
|
25
|
+
def transports
|
26
|
+
`#{::DroidAdbs.shell} bmgr list transports`
|
27
|
+
end
|
28
|
+
|
29
|
+
def clear_backup(transport, package)
|
30
|
+
`#{::DroidAdbs.shell} bmgr wipe #{transport} #{package}`
|
31
|
+
puts "You can also clear the backup data and associated metadata wither by turning backup off and on in Settings > Backup."
|
32
|
+
end
|
33
|
+
|
34
|
+
def available_backup?
|
35
|
+
::DroidAdbs::Devices.device_build_version_sdk.to_i >= 23
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end # module Debug
|
39
|
+
end # module Adb
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require_relative "../../droid_adbs"
|
2
|
+
|
3
|
+
module DroidAdbs
|
4
|
+
module Devices
|
5
|
+
class << self
|
6
|
+
### device infos
|
7
|
+
# @return [String] message from adb command
|
8
|
+
# e.g: docomo/SO-04E_1274-2936/SO-04E:4.2.2/10.3.1.B.0.256/_753rg:user/release-keys
|
9
|
+
def device_fingerprint
|
10
|
+
`#{::DroidAdbs.shell} getprop ro.build.fingerprint`.chomp
|
11
|
+
end
|
12
|
+
|
13
|
+
### device infos
|
14
|
+
# @return [String] message from adb command
|
15
|
+
# e.g: SO-04E
|
16
|
+
def device_model
|
17
|
+
`#{::DroidAdbs.shell} getprop ro.product.model`.chomp
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [String] message from adb command
|
21
|
+
# e.g: 4.2.2
|
22
|
+
def device_build_version_release
|
23
|
+
`#{::DroidAdbs.shell} getprop ro.build.version.release`.chomp
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [String] message from adb command
|
27
|
+
# e.g: 17
|
28
|
+
def device_build_version_sdk
|
29
|
+
`#{::DroidAdbs.shell} getprop ro.build.version.sdk`.chomp
|
30
|
+
end
|
31
|
+
|
32
|
+
# @return [String] message from adb command
|
33
|
+
# e.g: "en"
|
34
|
+
def current_language
|
35
|
+
language = `#{::DroidAdbs.shell} getprop persist.sys.language`.chomp
|
36
|
+
return language unless language.empty?
|
37
|
+
|
38
|
+
`#{::DroidAdbs.shell} getprop ro.product.locale.language`.chomp
|
39
|
+
end
|
40
|
+
|
41
|
+
# @return [String] message from adb command
|
42
|
+
# e.g.: "ja-JP"
|
43
|
+
def current_locale
|
44
|
+
locale = `#{::DroidAdbs.shell} getprop persist.sys.locale`.chomp
|
45
|
+
return locale unless locale.empty?
|
46
|
+
|
47
|
+
`#{::DroidAdbs.shell} getprop ro.product.locale`.chomp
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
require_relative "../../droid_adbs"
|
2
|
+
|
3
|
+
module DroidAdbs
|
4
|
+
module Settings
|
5
|
+
class << self
|
6
|
+
# @return [String] message from adb command
|
7
|
+
def disable_always_finish_activities
|
8
|
+
`#{::DroidAdbs.shell} settings put global always_finish_activities 0`
|
9
|
+
end
|
10
|
+
|
11
|
+
# @return [String] message from adb command
|
12
|
+
def enable_always_finish_activities
|
13
|
+
`#{::DroidAdbs.shell} settings put global always_finish_activities 1`
|
14
|
+
end
|
15
|
+
|
16
|
+
### Network mode
|
17
|
+
# @return [String] message from adb command
|
18
|
+
def turn_airplain_mode_on
|
19
|
+
`#{::DroidAdbs.shell} settings put global airplane_mode_on 1`
|
20
|
+
`#{::DroidAdbs.shell} am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true`
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [String] message from adb command
|
24
|
+
def turn_airplain_mode_off
|
25
|
+
`#{::DroidAdbs.shell} settings put global airplane_mode_on 0`
|
26
|
+
`#{::DroidAdbs.shell} am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false`
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [String] message from adb command
|
30
|
+
def turn_wifi_on
|
31
|
+
`#{::DroidAdbs.shell} settings put global wifi_on 1`
|
32
|
+
`#{::DroidAdbs.shell} am broadcast -a android.intent.action.WIFI_ON --ez state false`
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [String] message from adb command
|
36
|
+
def turn_wifi_off
|
37
|
+
`#{::DroidAdbs.shell} settings put global wifi_on 0`
|
38
|
+
`#{::DroidAdbs.shell} am broadcast -a android.intent.action.WIFI_ON --ez state false`
|
39
|
+
end
|
40
|
+
|
41
|
+
# @return [String] message from adb command
|
42
|
+
def turn_cpu_monitoring_on
|
43
|
+
`#{::DroidAdbs.shell} settings put global show_processes 1`
|
44
|
+
end
|
45
|
+
|
46
|
+
# @return [String] message from adb command
|
47
|
+
def turn_cpu_monitoring_off
|
48
|
+
`#{::DroidAdbs.shell} settings put global show_processes 0`
|
49
|
+
end
|
50
|
+
|
51
|
+
# @return [String] message from adb command
|
52
|
+
def turn_auto_time_on
|
53
|
+
`#{::DroidAdbs.shell} settings put global auto_time 1`
|
54
|
+
end
|
55
|
+
|
56
|
+
# @return [String] message from adb command
|
57
|
+
def turn_auto_time_off
|
58
|
+
`#{::DroidAdbs.shell} settings put global auto_time 0`
|
59
|
+
end
|
60
|
+
|
61
|
+
# @return [String] message from adb command
|
62
|
+
def set_date_to(yyyymmdd, hhmmss)
|
63
|
+
turn_auto_time_off
|
64
|
+
`#{::DroidAdbs.shell} date -s #{yyyymmdd}.#{hhmmss}`
|
65
|
+
end
|
66
|
+
|
67
|
+
# animation settings
|
68
|
+
# @return [String] message from adb command
|
69
|
+
def turn_all_animation_off
|
70
|
+
if ::DroidAdbs::Devices.device_build_version_sdk.to_i < 17
|
71
|
+
puts "the device is not over API Level 17"
|
72
|
+
return true
|
73
|
+
end
|
74
|
+
|
75
|
+
if all_animation_off?
|
76
|
+
puts "already all animation settings are off"
|
77
|
+
return true
|
78
|
+
end
|
79
|
+
|
80
|
+
scale_off "window_animation_scale"
|
81
|
+
scale_off "transition_animation_scale"
|
82
|
+
scale_off "animator_duration_scale"
|
83
|
+
intent_boot_completed
|
84
|
+
puts "adopt settings..."
|
85
|
+
false
|
86
|
+
end
|
87
|
+
|
88
|
+
# @return [String] message from adb command
|
89
|
+
def turn_all_animation_on
|
90
|
+
if ::DroidAdbs::Devices.device_build_version_sdk.to_i < 17
|
91
|
+
puts "the device is not over API Level 17"
|
92
|
+
return true
|
93
|
+
end
|
94
|
+
|
95
|
+
scale_on "window_animation_scale"
|
96
|
+
scale_on "transition_animation_scale"
|
97
|
+
scale_on "animator_duration_scale"
|
98
|
+
intent_boot_completed
|
99
|
+
puts "adopt settings..."
|
100
|
+
false
|
101
|
+
end
|
102
|
+
|
103
|
+
private
|
104
|
+
|
105
|
+
def scale_off(setting)
|
106
|
+
`#{::DroidAdbs.shell} settings put global #{setting} 0`
|
107
|
+
end
|
108
|
+
|
109
|
+
def scale_on(setting)
|
110
|
+
`#{::DroidAdbs.shell} settings put global #{setting} 1`
|
111
|
+
end
|
112
|
+
|
113
|
+
def get_scale_of(setting)
|
114
|
+
result = `#{::DroidAdbs.shell} settings get global #{setting}`.chomp
|
115
|
+
return 0 if result == "null"
|
116
|
+
result.to_i
|
117
|
+
end
|
118
|
+
|
119
|
+
def intent_boot_completed
|
120
|
+
`#{::DroidAdbs.shell} am broadcast -a android.intent.action.BOOT_COMPLETED`
|
121
|
+
end
|
122
|
+
|
123
|
+
# for window animations
|
124
|
+
def window_animation_scale
|
125
|
+
get_scale_of "window_animation_scale"
|
126
|
+
end
|
127
|
+
|
128
|
+
def transition_animation_scale
|
129
|
+
get_scale_of "transition_animation_scale"
|
130
|
+
end
|
131
|
+
|
132
|
+
def animator_duration_scale
|
133
|
+
get_scale_of "transition_animation_scale"
|
134
|
+
end
|
135
|
+
|
136
|
+
def all_animation_off?
|
137
|
+
return true if window_animation_scale == 0 && transition_animation_scale == 0 && animator_duration_scale == 0
|
138
|
+
false
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
data/lib/droid_adbs.rb
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
require "droid_adbs/version"
|
2
|
+
require_relative "droid_adbs/commons/settings"
|
3
|
+
require_relative "droid_adbs/commons/devices"
|
4
|
+
# require_relative "droid_adbs/commons/debug"
|
5
|
+
require_relative "droid_adbs/commons/backup"
|
6
|
+
require_relative "droid_adbs/aapt"
|
7
|
+
|
8
|
+
module DroidAdbs
|
9
|
+
class << self
|
10
|
+
attr_accessor :device_serial
|
11
|
+
|
12
|
+
# @return [String] adb shell command
|
13
|
+
def shell
|
14
|
+
"#{adb_serial} shell"
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [String] Get results of adb devices command
|
18
|
+
def devices
|
19
|
+
`#{adb} devices`
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Array] array of serial number to specify adb command
|
23
|
+
def device_serials
|
24
|
+
`#{adb} devices`.scan(/^.*\t/).map(&:strip)
|
25
|
+
end
|
26
|
+
|
27
|
+
# @param app [String] application path
|
28
|
+
# @return [String] message from adb command
|
29
|
+
def install(app)
|
30
|
+
result = `#{adb_serial} install -r #{app}`
|
31
|
+
fail "invalid APK" if result.include?("Invalid APK file:")
|
32
|
+
fail "failed to update apk because INSTALL_FAILED_VERSION_DOWNGRADE" if result.include?("INSTALL_FAILED_VERSION_DOWNGRADE")
|
33
|
+
result
|
34
|
+
end
|
35
|
+
|
36
|
+
# @param package [String] package name you would like to uninstall
|
37
|
+
# @return [String] message from adb command
|
38
|
+
def uninstall(package)
|
39
|
+
`#{adb_serial} uninstall #{package}`
|
40
|
+
end
|
41
|
+
|
42
|
+
# @param package [String] package name you would like to uninstall similar ones
|
43
|
+
# @return [String] message from adb command
|
44
|
+
def uninstall_similar(package)
|
45
|
+
installed_packages = installed_similar(package)
|
46
|
+
installed_packages.each { |pack| `#{adb_serial} uninstall #{pack}` }
|
47
|
+
end
|
48
|
+
|
49
|
+
# @param package [String] package name you would like to delete data in device local
|
50
|
+
# @return [String] message from adb command
|
51
|
+
def delete_data(package)
|
52
|
+
result = `#{shell} pm clear #{package}`.strip
|
53
|
+
puts "failed to delete data" unless result == "Success"
|
54
|
+
end
|
55
|
+
|
56
|
+
# @param package [String] package name you would like to check installed or not
|
57
|
+
# @return [Bool] If the package installed, return true. Else return false
|
58
|
+
def installed?(package)
|
59
|
+
result = `#{shell} pm list packages -e #{package}`.strip
|
60
|
+
return true if result == "package:#{package}"
|
61
|
+
false
|
62
|
+
end
|
63
|
+
|
64
|
+
# @param package [String] package name you would like to collect similar package
|
65
|
+
# @return [Array] all package names
|
66
|
+
def installed_similar(package)
|
67
|
+
result = `#{shell} pm list packages -e #{package}`.strip
|
68
|
+
result.each_line.map { |pack| pack.strip.sub("package:", "") }
|
69
|
+
end
|
70
|
+
|
71
|
+
# @param activity [String] activity name you would like to launch
|
72
|
+
# @return [String] message from adb command
|
73
|
+
def start(activity)
|
74
|
+
`#{shell} am start -n #{activity}`
|
75
|
+
end
|
76
|
+
|
77
|
+
# @param account_type [String] accountType of Android OS
|
78
|
+
# @return [String] message from adb command
|
79
|
+
def launch_login_activity(account_type)
|
80
|
+
if ::DroidAdbs::Devices.device_build_version_sdk.to_i >= 21
|
81
|
+
`#{shell} am start -a android.settings.ADD_ACCOUNT_SETTINGS --esa authorities #{account_type}`
|
82
|
+
else
|
83
|
+
puts "Can't launch LoginActivity.java because version of sdk in the target device is lower than 21."
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# @param activity [String] activity name you would like to stop
|
88
|
+
# @return [String] message from adb command
|
89
|
+
def force_stop(package)
|
90
|
+
`#{shell} am force-stop #{package}`
|
91
|
+
end
|
92
|
+
|
93
|
+
# @param broadcats_item [String] Target item for broadcast
|
94
|
+
# @param broadcast_extra [String] putExtra to send broadcast.
|
95
|
+
# @return [String] message from adb command
|
96
|
+
def send_broadcast(broadcats_item, broadcast_extra = "")
|
97
|
+
`#{shell} am broadcast -a #{broadcats_item} #{broadcast_extra}`
|
98
|
+
end
|
99
|
+
|
100
|
+
## resources
|
101
|
+
# @return [String] about cpuinfo via adb command
|
102
|
+
def dump_all_cpuinfos
|
103
|
+
`#{shell} dumpsys cpuinfo`.scan(/^.*$/).map(&:strip)
|
104
|
+
end
|
105
|
+
|
106
|
+
### Activity
|
107
|
+
# @return [String] message from adb command regarding current activities
|
108
|
+
def current_activity
|
109
|
+
`#{shell} dumpsys window windows | grep -E "mCurrentFocus|mFocusedApp"`
|
110
|
+
end
|
111
|
+
|
112
|
+
# @param [String] referrer to broadcast
|
113
|
+
# @return [String] message from adb command
|
114
|
+
def install_referrer_broadcast(referrer)
|
115
|
+
`#{shell} broadcast window -a com.android.vending.INSTALL_REFERRER --include-stopped-packages --es referrer #{referrer}`
|
116
|
+
end
|
117
|
+
|
118
|
+
# send referrer for TVs
|
119
|
+
# @param [String] referrer to broadcast
|
120
|
+
# @return [String] message from adb command
|
121
|
+
def broad_install_referrer(ref)
|
122
|
+
`#{shell} am broadcast -a com.android.vending.INSTALL_REFERRER --include-stopped-packages --es referrer #{ref}`
|
123
|
+
end
|
124
|
+
|
125
|
+
# Emulator should be unlocked after launch emulator with -wipe-data option
|
126
|
+
# Should unlock screen if current focus is like `mCurrentFocus=Window{2e85df18 u0 StatusBar}` .
|
127
|
+
# @return [String] message from adb command
|
128
|
+
def unlock_without_pin
|
129
|
+
`#{shell} input keyevent 82`
|
130
|
+
end
|
131
|
+
|
132
|
+
def unlock_with_pin(text)
|
133
|
+
`#{shell} input text #{text} && #{shell} input keyevent 66`
|
134
|
+
end
|
135
|
+
|
136
|
+
def screen_on_or_off
|
137
|
+
`#{shell} input keyevent 26`
|
138
|
+
end
|
139
|
+
|
140
|
+
private
|
141
|
+
|
142
|
+
def adb
|
143
|
+
fail "Please set ANDROID_HOME" unless ENV["ANDROID_HOME"]
|
144
|
+
"#{ENV["ANDROID_HOME"]}/platform-tools/adb"
|
145
|
+
end
|
146
|
+
|
147
|
+
def adb_serial
|
148
|
+
"#{adb} #{device_serial_option}"
|
149
|
+
end
|
150
|
+
|
151
|
+
def device_serial_option
|
152
|
+
return "" unless device_serial && !device_serial.empty?
|
153
|
+
"-s #{device_serial}"
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: droid_adbs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kazuaki MATSUO
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
description: adb command wrapper
|
56
|
+
email:
|
57
|
+
- fly.49.89.over@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/console
|
69
|
+
- bin/setup
|
70
|
+
- droid_adbs.gemspec
|
71
|
+
- lib/droid_adbs.rb
|
72
|
+
- lib/droid_adbs/aapt.rb
|
73
|
+
- lib/droid_adbs/commons/backup.rb
|
74
|
+
- lib/droid_adbs/commons/devices.rb
|
75
|
+
- lib/droid_adbs/commons/settings.rb
|
76
|
+
- lib/droid_adbs/version.rb
|
77
|
+
homepage: https://github.com/KazuCocoa/droid_adbs
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.5.1
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: adb command wrapper
|
101
|
+
test_files: []
|