adb_extended 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 91e6580a983fa9b1ae13841522e2bec309e113f3163c42fa794930a58ee043b2
4
+ data.tar.gz: 17d3d10da7e87eeae0982505e8f2384f56add58e15663187f1411688187573d6
5
+ SHA512:
6
+ metadata.gz: a3931bb79d652c805563def14b45f016d3a7c8e18d3cb9ba642fbaa31559637ea0624829cecb3926ca7a6a8aa2685fd15b6a740e634fac94a7ec1a4dac2302ef
7
+ data.tar.gz: cebc9d1712eb1b95d7d3f6e9aa540ac966c1ff91a319dcd6cc0aa0cb1560a79cb8eda8f777e1b0ec012c65ae958d91ba53b3496ae1c6bde634841e5480e964b0
data/.gitignore ADDED
@@ -0,0 +1,91 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+
14
+
15
+ # Created by https://www.gitignore.io/api/rubymine
16
+
17
+ ### RubyMine ###
18
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
19
+ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
20
+
21
+ # User-specific stuff
22
+ .idea/**/workspace.xml
23
+ .idea/**/tasks.xml
24
+ .idea/**/usage.statistics.xml
25
+ .idea/**/dictionaries
26
+ .idea/**/shelf
27
+
28
+ # Sensitive or high-churn files
29
+ .idea/**/dataSources/
30
+ .idea/**/dataSources.ids
31
+ .idea/**/dataSources.local.xml
32
+ .idea/**/sqlDataSources.xml
33
+ .idea/**/dynamic.xml
34
+ .idea/**/uiDesigner.xml
35
+ .idea/**/dbnavigator.xml
36
+
37
+ # Gradle
38
+ .idea/**/gradle.xml
39
+ .idea/**/libraries
40
+
41
+ # Gradle and Maven with auto-import
42
+ # When using Gradle or Maven with auto-import, you should exclude module files,
43
+ # since they will be recreated, and may cause churn. Uncomment if using
44
+ # auto-import.
45
+ # .idea/modules.xml
46
+ # .idea/*.iml
47
+ # .idea/modules
48
+
49
+ # CMake
50
+ cmake-build-*/
51
+
52
+ # Mongo Explorer plugin
53
+ .idea/**/mongoSettings.xml
54
+
55
+ # File-based project format
56
+ *.iws
57
+
58
+ # IntelliJ
59
+ out/
60
+
61
+ # mpeltonen/sbt-idea plugin
62
+ .idea_modules/
63
+
64
+ # JIRA plugin
65
+ atlassian-ide-plugin.xml
66
+
67
+ # Cursive Clojure plugin
68
+ .idea/replstate.xml
69
+
70
+ # Crashlytics plugin (for Android Studio and IntelliJ)
71
+ com_crashlytics_export_strings.xml
72
+ crashlytics.properties
73
+ crashlytics-build.properties
74
+ fabric.properties
75
+
76
+ # Editor-based Rest Client
77
+ .idea/httpRequests
78
+
79
+ ### RubyMine Patch ###
80
+ # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
81
+
82
+ # *.iml
83
+ # modules.xml
84
+ # .idea/misc.xml
85
+ # *.ipr
86
+
87
+ # Sonarlint plugin
88
+ .idea/sonarlint
89
+
90
+
91
+ # End of https://www.gitignore.io/api/rubymine
data/.idea/.rakeTasks ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Settings><!--This file was automatically generated by Ruby plugin.
3
+ You are allowed to:
4
+ 1. Remove rake task
5
+ 2. Add existing rake tasks
6
+ To add existing rake tasks automatically delete this file and reload the project.
7
+ --><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="ModuleRunConfigurationManager">
4
+ <shared />
5
+ </component>
6
+ <component name="NewModuleRootManager">
7
+ <content url="file://$MODULE_DIR$" />
8
+ <orderEntry type="inheritedJdk" />
9
+ <orderEntry type="sourceFolder" forTests="false" />
10
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.16.3, ruby-2.0.0-p481) [gem]" level="application" />
11
+ <orderEntry type="library" scope="PROVIDED" name="rake (v10.4.2, ruby-2.0.0-p481) [gem]" level="application" />
12
+ </component>
13
+ </module>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="Encoding">
4
+ <file url="PROJECT" charset="UTF-8" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,6 @@
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="Rubocop" enabled="false" level="WARNING" enabled_by_default="false" />
5
+ </profile>
6
+ </component>
data/.idea/misc.xml ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="JavaScriptSettings">
4
+ <option name="languageLevel" value="ES6" />
5
+ </component>
6
+ <component name="ProjectRootManager" version="2" project-jdk-name="ruby-2.0.0-p481" project-jdk-type="RUBY_SDK" />
7
+ </project>
data/.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/adb_extended.iml" filepath="$PROJECT_DIR$/.idea/adb_extended.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
data/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.0
7
+ before_install: gem install bundler -v 1.16.3
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at ddg@daentech.co.uk. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in adb_extended.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,41 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ adb_extended (0.1.0)
5
+ terminal-table
6
+ thor
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ diff-lcs (1.3)
12
+ rake (10.5.0)
13
+ rspec (3.7.0)
14
+ rspec-core (~> 3.7.0)
15
+ rspec-expectations (~> 3.7.0)
16
+ rspec-mocks (~> 3.7.0)
17
+ rspec-core (3.7.1)
18
+ rspec-support (~> 3.7.0)
19
+ rspec-expectations (3.7.0)
20
+ diff-lcs (>= 1.2.0, < 2.0)
21
+ rspec-support (~> 3.7.0)
22
+ rspec-mocks (3.7.0)
23
+ diff-lcs (>= 1.2.0, < 2.0)
24
+ rspec-support (~> 3.7.0)
25
+ rspec-support (3.7.1)
26
+ terminal-table (1.8.0)
27
+ unicode-display_width (~> 1.1, >= 1.1.1)
28
+ thor (0.20.0)
29
+ unicode-display_width (1.4.0)
30
+
31
+ PLATFORMS
32
+ ruby
33
+
34
+ DEPENDENCIES
35
+ adb_extended!
36
+ bundler (~> 1.16)
37
+ rake (~> 10.0)
38
+ rspec (~> 3.0)
39
+
40
+ BUNDLED WITH
41
+ 1.16.3
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Dan Gilbert
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,50 @@
1
+ # AdbExtended
2
+
3
+ A wrapper around `adb` to handle working with more than 1 device plugged in at a time
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'adb_extended'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install adb_extended
20
+
21
+ ## Usage
22
+
23
+ This is intended as a commandline application. The options are as follows:
24
+
25
+ - adb_extended ashell # Lists the devices and allows you to choose one to run the shell on
26
+ - adb_extended devices # Lists the Android devices with a little more info
27
+ - adb_extended help [COMMAND] # Describe available commands or one specific command
28
+ - adb_extended install PATH # Installs the provided apk on the selected device
29
+ - adb_extended logcat PACKAGE # Lists the devices and allows you to choose one to run with logcat
30
+ - adb_extended pidcat PACKAGE # Lists the devices and allows you to choose one to run with pidcat (requires `pidcat` to be installed and available in the path)
31
+ - adb_extended uninstall PACKAGE # Uninstalls the provided package on the selected device
32
+
33
+
34
+ ## Development
35
+
36
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
37
+
38
+ 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).
39
+
40
+ ## Contributing
41
+
42
+ Bug reports and pull requests are welcome on GitHub at https://github.com/daentech/adb_extended. 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.
43
+
44
+ ## License
45
+
46
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
47
+
48
+ ## Code of Conduct
49
+
50
+ Everyone interacting in the AdbExtended project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/daentech/adb_extended/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,31 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "adb_extended/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "adb_extended"
8
+ spec.version = AdbExtended::VERSION
9
+ spec.authors = ["Dan Gilbert"]
10
+ spec.email = ["ddg@daentech.co.uk"]
11
+
12
+ spec.summary = "Extended functionality for adb when working with multiple connected devices"
13
+ spec.homepage = "https://github.com/daentech/adb_extended"
14
+ spec.license = "MIT"
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.16"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+
29
+ spec.add_dependency "thor"
30
+ spec.add_dependency "terminal-table"
31
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "adb_extended"
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(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/adb_extended ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'adb_extended/cli'
4
+ AdbExtended::CLI.start
@@ -0,0 +1,87 @@
1
+ require 'open3'
2
+
3
+ include Open3
4
+
5
+ module AdbExtended
6
+
7
+ class Adb
8
+
9
+ def self.devices
10
+ stdout, stderr, status = Open3.capture3("adb devices -l")
11
+ device_ids = stdout.lines[0...-1]
12
+ return device_ids.drop(1).map{ |device|
13
+ split = device.gsub(/\s+/m, ' ').strip.split(" ")
14
+ {
15
+ :serial => split[0],
16
+ :type => split[1],
17
+ :usb => split[2].gsub('usb:', ''),
18
+ :product => split[3].gsub('product:', ''),
19
+ :model => split[4].gsub('model:', ''),
20
+ :transport_id => split[5].gsub('transport_id:', '')
21
+ }
22
+ }
23
+ end
24
+
25
+ def self.dumpsys(serial, stat = nil)
26
+ stdout, stderr, status = Open3.capture3("adb -s #{serial} shell dumpsys #{stat}")
27
+ return stdout.lines
28
+ end
29
+
30
+ def self.battery(serial)
31
+ stats = dumpsys(serial, "battery")
32
+
33
+ return stats.select { |s| s.include?("level") }[0]
34
+ end
35
+
36
+ def self.shell(serial)
37
+ exec "adb -s #{serial} shell"
38
+ end
39
+
40
+ def self.pidcat(serial, level = "d", package = nil)
41
+ exec "pidcat -s #{serial} -l #{level} #{package}"
42
+ end
43
+
44
+ def self.logcat(serial, level = "D", package)
45
+
46
+ stdout, stderr, status = Open3.capture3("adb -s #{serial} shell ps")
47
+
48
+ filter = nil
49
+
50
+ if package != nil
51
+ package_info = stdout.lines.select { |line| line.include?("#{package}") }
52
+ if package_info.size == 0
53
+ puts 'Application not running'
54
+ exit 1
55
+ end
56
+ columns = package_info[0].gsub(/\s+/m, ' ').strip.split(" ")
57
+ filter = "| grep -F #{columns[1]}"
58
+ end
59
+ exec "adb -s #{serial} logcat *:#{level} #{filter}"
60
+ end
61
+
62
+ def self.install(path, serial = nil)
63
+ if serial != nil
64
+ exec "adb -s #{serial} install -r #{path}"
65
+ else
66
+ puts devices
67
+ devices.each { |device|
68
+ puts "Installing on #{device[:model]}"
69
+ exec "adb -s #{device[:serial]} install -r #{path}"
70
+ }
71
+ end
72
+ end
73
+
74
+ def self.uninstall(package, serial = nil)
75
+ if serial != nil
76
+ exec "adb -s #{serial} uninstall #{package}"
77
+ else
78
+ devices.each { |device|
79
+ puts "Uninstalling from #{device[:model]}"
80
+ exec "adb -s #{device[:serial]} uninstall #{package}"
81
+ }
82
+ end
83
+
84
+ end
85
+ end
86
+
87
+ end
@@ -0,0 +1,116 @@
1
+ require 'thor'
2
+ require 'terminal-table'
3
+ require 'adb_extended'
4
+
5
+ module AdbExtended
6
+ class CLI < Thor
7
+ include Thor::Actions
8
+
9
+ desc "devices", "Lists the Android devices with a little more info"
10
+ method_options :battery => :boolean, :select_device => :boolean
11
+ def devices()
12
+ devices = AdbExtended::Adb.devices
13
+
14
+ table = Terminal::Table.new do |t|
15
+ header_row = %w(# Model Serial)
16
+
17
+ if options.battery?
18
+ header_row.push('Battery')
19
+ end
20
+
21
+ t << header_row
22
+ t << :separator
23
+ devices.each_with_index {|value, index|
24
+ row = [index + 1, value[:model], value[:serial]]
25
+
26
+ if options.battery?
27
+ battery_level = AdbExtended::Adb.battery(value[:serial]).gsub('level:', '')
28
+ row.push(battery_level)
29
+ end
30
+
31
+ t.add_row row
32
+ }
33
+ end
34
+
35
+ puts table
36
+
37
+ end
38
+
39
+ desc "ashell", "Lists the devices and allows you to choose one to run the shell on"
40
+ def ashell
41
+ serial = pick_device
42
+ AdbExtended::Adb.shell(serial)
43
+ end
44
+
45
+ desc "pidcat PACKAGE", "Lists the devices and allows you to choose one to run with pidcat"
46
+ method_option :level, :default => 'd', :enum => %w(V D I W E F v d i w e f), :aliases => '-l'
47
+ def pidcat(package = nil)
48
+ serial = pick_device
49
+ AdbExtended::Adb.pidcat(serial, options[:level], package)
50
+ end
51
+
52
+ desc "logcat PACKAGE", "Lists the devices and allows you to choose one to run with logcat"
53
+ method_option :level, :default => 'D', :enum => %w(V D I W E F), :aliases => '-l'
54
+ def logcat(package = nil)
55
+ serial = pick_device
56
+ AdbExtended::Adb.logcat(serial, options[:level], package)
57
+ end
58
+
59
+ desc "install PATH", "Installs the provided apk on the selected device"
60
+ method_options :all => :boolean
61
+ def install(path)
62
+ if options.all
63
+ AdbExtended::Adb.install(path)
64
+ exit(0)
65
+ end
66
+ serial = pick_device
67
+ AdbExtended::Adb.install(path, serial)
68
+ end
69
+
70
+ desc "uninstall PACKAGE", "Uninstalls the provided package on the selected device"
71
+ method_options :all => :boolean
72
+ def uninstall(package)
73
+ if options.all
74
+ AdbExtended::Adb.uninstall(package)
75
+ exit(0)
76
+ end
77
+ serial = pick_device
78
+ AdbExtended::Adb.uninstall(package, serial)
79
+ end
80
+
81
+ private
82
+
83
+ # Returns the serial number of the chosen device
84
+ def pick_device
85
+
86
+ devices = AdbExtended::Adb.devices
87
+
88
+ if devices.size == 0
89
+ puts 'No devices found'
90
+ exit 1
91
+ end
92
+
93
+ if devices.size == 1
94
+ return devices[0][:serial]
95
+ end
96
+
97
+ table = Terminal::Table.new do |t|
98
+ header_row = %w(# Model Serial)
99
+
100
+ t << header_row
101
+ t << :separator
102
+ devices.each_with_index {|value, index|
103
+ row = [index + 1, value[:model], value[:serial]]
104
+ t.add_row row
105
+ }
106
+ end
107
+
108
+ puts table
109
+
110
+ accepted_inputs = *(1..devices.size).map {|i| i.to_s}
111
+ index = ask("Select a device (1 - #{devices.size}):", :limited_to => accepted_inputs).to_i - 1
112
+ devices[index][:serial]
113
+ end
114
+
115
+ end
116
+ end
@@ -0,0 +1,3 @@
1
+ module AdbExtended
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "adb_extended/version"
2
+ require 'adb_extended/adb'
3
+ module AdbExtended
4
+
5
+ end
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: adb_extended
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dan Gilbert
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-10-01 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.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
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: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: thor
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: terminal-table
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email:
85
+ - ddg@daentech.co.uk
86
+ executables:
87
+ - adb_extended
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".idea/.rakeTasks"
93
+ - ".idea/adb_extended.iml"
94
+ - ".idea/encodings.xml"
95
+ - ".idea/inspectionProfiles/Project_Default.xml"
96
+ - ".idea/misc.xml"
97
+ - ".idea/modules.xml"
98
+ - ".idea/vcs.xml"
99
+ - ".rspec"
100
+ - ".travis.yml"
101
+ - CODE_OF_CONDUCT.md
102
+ - Gemfile
103
+ - Gemfile.lock
104
+ - LICENSE.txt
105
+ - README.md
106
+ - Rakefile
107
+ - adb_extended.gemspec
108
+ - bin/console
109
+ - bin/setup
110
+ - exe/adb_extended
111
+ - lib/adb_extended.rb
112
+ - lib/adb_extended/adb.rb
113
+ - lib/adb_extended/cli.rb
114
+ - lib/adb_extended/version.rb
115
+ homepage: https://github.com/daentech/adb_extended
116
+ licenses:
117
+ - MIT
118
+ metadata: {}
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 2.7.6
136
+ signing_key:
137
+ specification_version: 4
138
+ summary: Extended functionality for adb when working with multiple connected devices
139
+ test_files: []