android-adb-extension 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2406ccdd27e0559069c65a7270f6d420ddf0eb66
4
- data.tar.gz: 520e3cf6106be80b89865bf76fd1d70e83ced0d3
3
+ metadata.gz: 4b721f915f6113fc7329337a3bd7ee55413ef69f
4
+ data.tar.gz: 64b59fbc90a2742e62b3d1c9ea48fbb6d7e51c1f
5
5
  SHA512:
6
- metadata.gz: cf5fdbe9404c541aad996eb48bee3cf23f100e284c34d9b3bf01eea233ba69c7682f581fbc58e9c8ee711bae37fb848888a9f5094463c2a6f9f574bc254da70c
7
- data.tar.gz: 232b6a20502f7d1e193003810623c0974e8e8208d841301c943f871819cc1d21bab81efb98d5bc1166592a10a3a793bd74b6d5b533882aeb31fca3e88fbfa3a2
6
+ metadata.gz: 3c851481ef8b317e51f9b4b455a6258f3ccd6347414f378533fd1875cc61c0397014b0de7fa1750a37bb2b5492d8c30c125f7a4d72ea2f1a241df22a74ef54b8
7
+ data.tar.gz: dfadc3b9383c30b16abddcdaad7cac6bdff53e41e37713be4fc638bd3f2962435259f8057de13d11d7acbcb4b049ec06c1200f51039921e9ebb10fa70a8faf17
@@ -1,3 +1,5 @@
1
+ # Class to handle Android Debug Bridge shell commands
2
+ #
1
3
  class ADB
2
4
  class << self
3
5
  def sdk
@@ -13,7 +15,9 @@ class ADB
13
15
  end
14
16
 
15
17
  def orientation
16
- `adb shell dumpsys input | grep 'SurfaceOrientation' | awk '{ print $2 }'`.strip.to_i
18
+ `adb shell dumpsys input |
19
+ grep 'SurfaceOrientation' |
20
+ awk '{ print $2 }'`.strip.to_i
17
21
  end
18
22
 
19
23
  def portrait?
@@ -25,16 +29,16 @@ class ADB
25
29
  end
26
30
 
27
31
  def set_portrait
28
- set_accelerometer_control(0)
29
- res = set_device_orientation(0)
30
- set_accelerometer_control(1)
32
+ change_accelerometer_control(0)
33
+ res = change_device_orientation(0)
34
+ change_accelerometer_control(1)
31
35
  res.empty? ? nil : res
32
36
  end
33
37
 
34
38
  def set_landscape
35
- set_accelerometer_control(0)
36
- res = set_device_orientation(1)
37
- set_accelerometer_control(1)
39
+ change_accelerometer_control(0)
40
+ res = change_device_orientation(1)
41
+ change_accelerometer_control(1)
38
42
  res.empty? ? nil : res
39
43
  end
40
44
 
@@ -47,11 +51,11 @@ class ADB
47
51
  end
48
52
 
49
53
  def enable_airplane_mode
50
- set_airplane_mode(true)
54
+ change_airplane_mode(1)
51
55
  end
52
56
 
53
57
  def disable_airplane_mode
54
- set_airplane_mode(false)
58
+ change_airplane_mode(0)
55
59
  end
56
60
 
57
61
  def help
@@ -62,29 +66,31 @@ class ADB
62
66
 
63
67
  private
64
68
 
65
- def set_accelerometer_control(aMode)
66
- `adb shell content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:#{aMode}`
67
- end
69
+ def change_accelerometer_control(aMode)
70
+ command = 'adb shell content insert'
71
+ param1 = '--uri content://settings/system'
72
+ param2 = '--bind name:s:accelerometer_rotation'
73
+ param3 = "--bind value:i:#{aMode}"
68
74
 
69
- def set_device_orientation(aOrientation)
70
- `adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:#{aOrientation}`
75
+ `#{command} #{param1} #{param2} #{param3}`
71
76
  end
72
77
 
73
- def set_airplane_mode(aMode)
74
- bool = aMode.is_a?(TrueClass) || aMode.is_a?(FalseClass)
75
- int = aMode.is_a?(Integer)
78
+ def change_device_orientation(aOrientation)
79
+ command = 'adb shell content insert'
80
+ param1 = '--uri content://settings/system'
81
+ param2 = '--bind name:s:user_rotation'
82
+ param3 = "--bind value:i:#{aOrientation}"
76
83
 
77
- raise 'invalid parameter' unless bool || int
84
+ `#{command} #{param1} #{param2} #{param3}`
85
+ end
78
86
 
79
- if bool
80
- mode = aMode.eql?(true) ? 1 : 0
81
- state = aMode
82
- else
83
- mode = aMode
84
- state = aMode.eql?(1) ? true : false
85
- end
87
+ def change_airplane_mode(aMode)
88
+ command1 = "adb shell settings put global airplane_mode_on #{aMode}"
89
+ command2 = 'adb shell am broadcast'
90
+ param1 = '-a android.intent.action.AIRPLANE_MODE'
91
+ param2 = "--ez state #{aMode.to_boolean}"
86
92
 
87
- `adb shell settings put global airplane_mode_on #{mode} & adb shell am broadcast -a android.intent.action.AIRPLANE_MODE --ez state #{state}`
93
+ `#{command1} & #{command2} #{param1} #{param2}`
88
94
  end
89
95
  end
90
96
  end
@@ -1,3 +1,5 @@
1
+ # Gem version
2
+ #
1
3
  module AndroidAdbExtension
2
- VERSION = '0.0.1'
4
+ VERSION = '0.0.2'
3
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: android-adb-extension
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jani Jegoroff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-27 00:00:00.000000000 Z
11
+ date: 2014-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: to_boolean
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.26'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.26'
69
83
  description: Android Debug Bridge extension provides convenient metaclass to execute
70
84
  ADB shell commands.
71
85
  email: