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 +4 -4
- data/lib/android-adb-extension/adb.rb +32 -26
- data/lib/android-adb-extension/version.rb +3 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b721f915f6113fc7329337a3bd7ee55413ef69f
|
4
|
+
data.tar.gz: 64b59fbc90a2742e62b3d1c9ea48fbb6d7e51c1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 |
|
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
|
-
|
29
|
-
res =
|
30
|
-
|
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
|
-
|
36
|
-
res =
|
37
|
-
|
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
|
-
|
54
|
+
change_airplane_mode(1)
|
51
55
|
end
|
52
56
|
|
53
57
|
def disable_airplane_mode
|
54
|
-
|
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
|
66
|
-
|
67
|
-
|
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
|
-
|
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
|
74
|
-
|
75
|
-
|
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
|
-
|
84
|
+
`#{command} #{param1} #{param2} #{param3}`
|
85
|
+
end
|
78
86
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
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
|
-
|
93
|
+
`#{command1} & #{command2} #{param1} #{param2}`
|
88
94
|
end
|
89
95
|
end
|
90
96
|
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.
|
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-
|
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:
|