adb-sdklib 0.0.2 → 0.0.3
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 +8 -8
- data/.gitignore +1 -0
- data/lib/adb-sdklib.rb +1 -0
- data/lib/adb_sdklib/device.rb +5 -1
- data/lib/adb_sdklib/raw_image.rb +112 -0
- data/lib/adb_sdklib/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OTA0ZTdiZDlhYTU0YTI5YTE5OTY4NjhiMjY2OTdkZDE2MDI3NjVhZg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZWQyM2Q1Y2YxMjdlYWI0YmUyNTdiOTcwZmQwNGNiMjBkZGRlNWFiMQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NTU5ODk1ZDBhODdmYTY3MGNjMTIzN2UyMTg3ODMzOGQ1Y2IwNTQ5Y2FmOTk0
|
10
|
+
MzdlMzY0MjkzYTA2ZWMxZmQ4MjFjNjMyZDMxMzVkZmRiMjc3MDU4ZTE3N2E2
|
11
|
+
MWRlOGIwNGQ0MTcwNzYwYjg2MjcwM2NiMjFjZjlkOGFiZjIzMmQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YmY3NWI0MGQyZmY2MTEzZTZjMWExMjI5MjhhYWYzNjcyN2Y4YTg0NWFmNjlk
|
14
|
+
ZjI5Y2VhY2FiNDAwNjUyMTExOGFhY2Y5OTc3ZDVmZmJkMGQ5NDI0MjFmMmJj
|
15
|
+
MGU1ZjE1MzNlZjBjNGNjMTJlYjQ2NzNjOWU3ZTFkNDQzMTk3ZGE=
|
data/.gitignore
CHANGED
data/lib/adb-sdklib.rb
CHANGED
data/lib/adb_sdklib/device.rb
CHANGED
@@ -56,7 +56,11 @@ module AdbSdkLib
|
|
56
56
|
# @!attribute [r] bootloader?
|
57
57
|
# @return [Boolean] true if the device is in bootloader mode.
|
58
58
|
def bootloader?; @device.isBootloader end
|
59
|
-
|
59
|
+
|
60
|
+
# Get a screenshot from the device
|
61
|
+
# @return [AdbSdkLib::RawImage] Wrapper of com.android.ddmlib.RawImage object.
|
62
|
+
def screenshot(); RawImage.new(@device.getScreenshot()) end
|
63
|
+
|
60
64
|
# Reboot the device
|
61
65
|
# @param [String, nil] into the bootloader name to reboot into,
|
62
66
|
# or nil to just reboot the device
|
@@ -0,0 +1,112 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module AdbSdkLib
|
4
|
+
|
5
|
+
class Pixel
|
6
|
+
attr_accessor :x, :y, :red, :green, :blue, :alpha, :argb
|
7
|
+
|
8
|
+
def initialize(x,y, argb)
|
9
|
+
@x = x
|
10
|
+
@y = y
|
11
|
+
@argb = argb
|
12
|
+
@alpha = (argb >> 8*3) & 0xFF
|
13
|
+
@red = (argb >> 8*2) & 0xFF
|
14
|
+
@green = (argb >> 8*1) & 0xFF
|
15
|
+
@blue = (argb >> 8*0) & 0xFF
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Data representing an image taken from a device frame buffer.
|
20
|
+
#
|
21
|
+
# This is a wrapper of com.android.ddmlib.RawImage
|
22
|
+
class RawImage
|
23
|
+
include Common
|
24
|
+
|
25
|
+
# @param [Rjb::Rjb_JavaProxy] RawImage Rjb proxy of com.android.ddmlib.RawImage
|
26
|
+
def initialize(image)
|
27
|
+
unless image.instance_of?(Rjb::Rjb_JavaProxy) &&
|
28
|
+
image._classname == 'com.android.ddmlib.RawImage'
|
29
|
+
raise TypeError, "Parameter is not com.android.ddmlib.RawImage class"
|
30
|
+
end
|
31
|
+
class << image
|
32
|
+
def call_java_method(method_name, *args)
|
33
|
+
rjb_method_missing(method_name, *args)
|
34
|
+
rescue => e
|
35
|
+
raise SdkLibError.new(e.message, e.class.to_s, self._classname, method_name)
|
36
|
+
end
|
37
|
+
alias_method :rjb_method_missing, :method_missing
|
38
|
+
alias_method :method_missing, :call_java_method
|
39
|
+
end
|
40
|
+
@image = image
|
41
|
+
end
|
42
|
+
|
43
|
+
# Returns a rotated version of the image
|
44
|
+
# The image is rotated counter-clockwise.
|
45
|
+
# @return [RawImage] rotated image
|
46
|
+
def rotated
|
47
|
+
RawImage.new(@image.getRotated())
|
48
|
+
end
|
49
|
+
|
50
|
+
# Returns ARGB value of a pixel
|
51
|
+
# @param [Integer] index of the pixel in data
|
52
|
+
# @return [Integer] ARGB value of the given pixel
|
53
|
+
def argb(index)
|
54
|
+
@image.getARGB(index)
|
55
|
+
end
|
56
|
+
|
57
|
+
# Returns ARGB value of a pixel
|
58
|
+
# @param [Integer] pixel index
|
59
|
+
# @return [Integer] ARGB value of the given pixel
|
60
|
+
def argb_at(x,y)
|
61
|
+
@image.getARGB(point_to_index(x,y))
|
62
|
+
end
|
63
|
+
|
64
|
+
# Returns pixel content
|
65
|
+
# @param [Integer, Integer] pixel position x,y
|
66
|
+
# @return [AdbSdkLib::Pixel] pixel content
|
67
|
+
def pixel(x,y)
|
68
|
+
Pixel.new(x,y,@image.getARGB(point_to_index(x,y)))
|
69
|
+
end
|
70
|
+
|
71
|
+
# Calls block once for each pixel in data, passing that device as a parameter.
|
72
|
+
# If no block is given, an enumerator is returned instead.
|
73
|
+
# @return [Enumerator] if not block given
|
74
|
+
# @return [self] if block given
|
75
|
+
# @yield [pixel] called with each pixel
|
76
|
+
# @yieldparam [Pixel] pixel a pixel instance
|
77
|
+
def each_pixel()
|
78
|
+
return to_enum :each_pixel unless block_given?
|
79
|
+
@image.height.times do |y|
|
80
|
+
@image.width.times do |x|
|
81
|
+
yield pixel(x,y)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
self
|
85
|
+
end
|
86
|
+
|
87
|
+
# Returns image's width
|
88
|
+
# @return [Integer] image's width
|
89
|
+
def width()
|
90
|
+
@image.width
|
91
|
+
end
|
92
|
+
|
93
|
+
# Returns image's height
|
94
|
+
# @return [Integer] image's height
|
95
|
+
def height()
|
96
|
+
@image.height
|
97
|
+
end
|
98
|
+
|
99
|
+
# Returns image's bpp
|
100
|
+
# @return [Integer] image's bpp
|
101
|
+
def bpp()
|
102
|
+
@image.bpp
|
103
|
+
end
|
104
|
+
|
105
|
+
# Returns pixel index for a given position
|
106
|
+
# @param [Integer, Integer] pixel position x,y
|
107
|
+
# @return [Integer] pixel index
|
108
|
+
def point_to_index(x,y)
|
109
|
+
return (x*(bpp >> 3))+(y*((bpp >> 3)*(width)))
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
data/lib/adb_sdklib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adb-sdklib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yoyo0906
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rjb
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- lib/adb-sdklib.rb
|
71
71
|
- lib/adb_sdklib/common.rb
|
72
72
|
- lib/adb_sdklib/device.rb
|
73
|
+
- lib/adb_sdklib/raw_image.rb
|
73
74
|
- lib/adb_sdklib/version.rb
|
74
75
|
homepage: http://github.com/yoyo0906/ruby-adb-sdklib
|
75
76
|
licenses:
|