remotedroid 0.5.4 → 0.6.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/remotedroid.rb +159 -30
- data/lib/remotedroid/client.rb +173 -20
- data/lib/remotedroid/control.rb +188 -7
- data/lib/remotedroid/controller.rb +43 -19
- data/lib/remotedroid/query.rb +45 -5
- metadata +44 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8b216c60a929b3c6ece03a4b5979da738a0e3f7fb2994060a605391ab8068b9
|
4
|
+
data.tar.gz: d5bfed22b7fbc59767cc1a3af2597cc95b05ddbf8aca80420305a6bdbc12960c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fb42e16c68052d50a4ac532a88997fd723178142951dfb4aaaf2da6458128ff7fedea58d56b20020dac6b631f8a439371e4ac231b43ba9dd61db96aef1dd9f0
|
7
|
+
data.tar.gz: 763dc18a3b896bb77b53d1dddf70e4b839a314301e00642e96c326b36f0cdf2d7beed025df3a7232f6879fd097f715ff813fac62913a7988a57d5deec1543b8f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/remotedroid.rb
CHANGED
@@ -45,6 +45,7 @@ require 'ruby-macrodroid'
|
|
45
45
|
# ## Camera/Photo
|
46
46
|
#
|
47
47
|
# * Take Picture
|
48
|
+
# * Take Screenshot
|
48
49
|
#
|
49
50
|
# ## Connectivity
|
50
51
|
#
|
@@ -66,7 +67,7 @@ require 'ruby-macrodroid'
|
|
66
67
|
#
|
67
68
|
# ## MacroDroid specific
|
68
69
|
#
|
69
|
-
# * Disable Macro
|
70
|
+
# * Enable/Disable Macro
|
70
71
|
#
|
71
72
|
# ## Media
|
72
73
|
#
|
@@ -79,7 +80,7 @@ require 'ruby-macrodroid'
|
|
79
80
|
# ## Screen
|
80
81
|
#
|
81
82
|
# * Keep Device Awake
|
82
|
-
# * Screen On
|
83
|
+
# * Screen On/Off
|
83
84
|
#
|
84
85
|
|
85
86
|
# Variables which can be queried
|
@@ -197,48 +198,43 @@ m: stay awake off
|
|
197
198
|
t: webhook
|
198
199
|
a: stay awake off
|
199
200
|
|
200
|
-
m: Launch Google Play Music
|
201
|
-
t: webhook
|
202
|
-
a: Launch Google Play Music
|
203
|
-
|
204
|
-
|
205
201
|
m: Media Next
|
206
202
|
t: webhook
|
207
203
|
a:
|
208
204
|
Media Next
|
209
|
-
Simulate
|
205
|
+
Simulate Audio Button
|
210
206
|
|
211
207
|
m: Media Pause
|
212
208
|
t: webhook
|
213
209
|
a:
|
214
210
|
Media Pause
|
215
|
-
Simulate
|
211
|
+
Simulate Audio Button
|
216
212
|
|
217
213
|
m: Media Play
|
218
214
|
t: webhook
|
219
215
|
a:
|
220
216
|
Media Play
|
221
|
-
Simulate
|
217
|
+
Simulate Audio Button
|
222
218
|
|
223
219
|
m: Media Play Pause
|
224
220
|
t: webhook
|
225
221
|
a:
|
226
222
|
Media Play/Pause
|
227
|
-
Simulate
|
223
|
+
Simulate Audio Button
|
228
224
|
|
229
225
|
m: Media Previous
|
230
226
|
t: webhook
|
231
227
|
a:
|
232
228
|
Media Previous
|
233
|
-
Simulate
|
229
|
+
Simulate Audio Button
|
234
230
|
|
235
231
|
m: Media Stop
|
236
232
|
t: webhook
|
237
233
|
a:
|
238
234
|
Media Stop
|
239
|
-
Simulate
|
235
|
+
Simulate Audio Button
|
240
236
|
|
241
|
-
m: Open
|
237
|
+
m: Open web page
|
242
238
|
v: url
|
243
239
|
t: webhook
|
244
240
|
a: goto [lv=url]
|
@@ -249,14 +245,90 @@ t: webhook
|
|
249
245
|
a:
|
250
246
|
Fill Clipboard
|
251
247
|
[lv=clipboard]
|
252
|
-
|
248
|
+
|
253
249
|
m: click text content
|
254
250
|
v: content
|
255
251
|
t: webhook
|
256
252
|
a:
|
257
253
|
UI Interaction
|
258
|
-
Click [[lv=content]]
|
254
|
+
Click [[lv=content]]
|
255
|
+
|
256
|
+
m: Launch by package
|
257
|
+
v: package
|
258
|
+
t: webhook
|
259
|
+
a: Launch [lv=package]
|
259
260
|
|
261
|
+
m: Take Screenshot
|
262
|
+
t: webhook
|
263
|
+
a:
|
264
|
+
Take Screenshot
|
265
|
+
Save to device
|
266
|
+
a: wait 2 seconds
|
267
|
+
a: webhook
|
268
|
+
|
269
|
+
m: Voice search
|
270
|
+
t: webhook
|
271
|
+
a: Voice search
|
272
|
+
|
273
|
+
m: Ask Alexa
|
274
|
+
t: webhook
|
275
|
+
a: shortcut Ask Alexa
|
276
|
+
|
277
|
+
m: Set Auto Rotate
|
278
|
+
v: state
|
279
|
+
t: webhook
|
280
|
+
a:
|
281
|
+
if state = 0
|
282
|
+
Auto Rotate On
|
283
|
+
Else If state = 1
|
284
|
+
Auto Rotate Off
|
285
|
+
Else If state = 2
|
286
|
+
Auto Rotate Toggle
|
287
|
+
end if
|
288
|
+
|
289
|
+
m: Set Bluetooth
|
290
|
+
v: state
|
291
|
+
t: webhook
|
292
|
+
a:
|
293
|
+
if state = 0
|
294
|
+
Enable Bluetooth
|
295
|
+
Else If state = 1
|
296
|
+
Disable Bluetooth
|
297
|
+
Else If state = 2
|
298
|
+
Toggle Bluetooth
|
299
|
+
Else If state = 3
|
300
|
+
Connect Audio Device
|
301
|
+
Else If state = 4
|
302
|
+
Disconnect Audio Device
|
303
|
+
end if
|
304
|
+
|
305
|
+
m: Set Airplane Mode
|
306
|
+
v: state
|
307
|
+
t: webhook
|
308
|
+
a:
|
309
|
+
if state = 0
|
310
|
+
Airplane Mode On
|
311
|
+
Else If state = 1
|
312
|
+
Airplane Mode Off
|
313
|
+
Else If state = 2
|
314
|
+
Airplane Mode Toggle
|
315
|
+
end if
|
316
|
+
|
317
|
+
m: Set Wifi
|
318
|
+
v: state
|
319
|
+
t: webhook
|
320
|
+
a:
|
321
|
+
if state = 0
|
322
|
+
Enable Wifi
|
323
|
+
Else If state = 1
|
324
|
+
Disable Wifi
|
325
|
+
Else If state = 2
|
326
|
+
Toggle Wifi
|
327
|
+
Else If state = 3
|
328
|
+
Connect to Network
|
329
|
+
end if
|
330
|
+
|
331
|
+
|
260
332
|
m: Share location
|
261
333
|
t:
|
262
334
|
WebHook
|
@@ -345,15 +417,24 @@ a:
|
|
345
417
|
|
346
418
|
m: Power Button Toggle3
|
347
419
|
t: Power Button Toggle (3)
|
348
|
-
a:
|
420
|
+
a:
|
421
|
+
webhook
|
422
|
+
identifier: power-button-toggle
|
423
|
+
num_toggles: 3
|
349
424
|
|
350
425
|
m: Power Button Toggle4
|
351
426
|
t: Power Button Toggle (4)
|
352
|
-
a:
|
427
|
+
a:
|
428
|
+
webhook
|
429
|
+
identifier: power-button-toggle
|
430
|
+
num_toggles: 4
|
353
431
|
|
354
432
|
m: Power Button Toggle5
|
355
433
|
t: Power Button Toggle (5)
|
356
|
-
a:
|
434
|
+
a:
|
435
|
+
webhook
|
436
|
+
identifier: power-button-toggle
|
437
|
+
num_toggles: 5
|
357
438
|
|
358
439
|
m: Connected to network
|
359
440
|
t:
|
@@ -490,10 +571,10 @@ module RemoteDroid
|
|
490
571
|
|
491
572
|
class Server
|
492
573
|
|
493
|
-
def initialize(s, drb_host: '127.0.0.1',
|
574
|
+
def initialize(s, drb_host: '127.0.0.1', devices: nil, debug: false)
|
494
575
|
|
495
576
|
md = MacroDroid.new(s)
|
496
|
-
rdc = RemoteDroid::Controller.new(md,
|
577
|
+
rdc = RemoteDroid::Controller.new(md, devices: devices, debug: debug)
|
497
578
|
@drb = OneDrb::Server.new host: drb_host, port: '5777', obj: rdc
|
498
579
|
|
499
580
|
end
|
@@ -505,20 +586,25 @@ module RemoteDroid
|
|
505
586
|
end
|
506
587
|
|
507
588
|
class TriggerSubscriber < SPSSub
|
589
|
+
using ColouredText
|
508
590
|
|
509
591
|
def initialize(host: 'sps.home', drb_host: '127.0.0.1')
|
510
592
|
@remote = OneDrb::Client.new host: drb_host, port: '5777'
|
511
593
|
super(host: host)
|
594
|
+
puts 'TriggerSubscriber'.highlight
|
512
595
|
end
|
513
596
|
|
514
|
-
def subscribe(topic: 'macrodroid
|
597
|
+
def subscribe(topic: 'macrodroid/#/trigger')
|
515
598
|
|
516
|
-
super(topic: topic) do |msg|
|
599
|
+
super(topic: topic) do |msg, topic|
|
517
600
|
|
601
|
+
dev_id = topic.split('/')[1]
|
518
602
|
trigger, json = msg.split(/:\s+/,2)
|
603
|
+
|
519
604
|
a = @remote.trigger_fired trigger.to_sym,
|
520
605
|
JSON.parse(json, symbolize_names: true)
|
521
|
-
|
606
|
+
|
607
|
+
a.each {|msg| self.notice "macrodroid/%s/action: %s" % [dev_id, msg] }
|
522
608
|
|
523
609
|
end
|
524
610
|
end
|
@@ -526,13 +612,15 @@ module RemoteDroid
|
|
526
612
|
end
|
527
613
|
|
528
614
|
class ActionSubscriber < SPSSub
|
615
|
+
using ColouredText
|
529
616
|
|
530
617
|
def initialize(host: 'sps.home', drb_host: '127.0.0.1')
|
531
618
|
@remote = OneDrb::Client.new host: drb_host, port: '5777'
|
532
619
|
super(host: host)
|
620
|
+
puts 'ActionSubscriber'.highlight
|
533
621
|
end
|
534
622
|
|
535
|
-
def subscribe(topic: 'macrodroid
|
623
|
+
def subscribe(topic: 'macrodroid/#/action')
|
536
624
|
|
537
625
|
super(topic: topic) do |msg|
|
538
626
|
|
@@ -541,10 +629,21 @@ module RemoteDroid
|
|
541
629
|
|
542
630
|
h = JSON.parse(json, symbolize_names: true)
|
543
631
|
|
544
|
-
if
|
632
|
+
if h[:serverside]then
|
545
633
|
|
546
|
-
|
547
|
-
|
634
|
+
if action == 'force_macro_run' then
|
635
|
+
|
636
|
+
a = @remote.run_macro(h)
|
637
|
+
a.each {|msg| self.notice 'macrodroid/action: ' + msg }
|
638
|
+
|
639
|
+
else
|
640
|
+
|
641
|
+
puts 'action: ' + action.inspect
|
642
|
+
puts 'h: ' + h.inspect
|
643
|
+
r = @remote.local(action.to_sym, h)
|
644
|
+
puts 'r: ' + r.inspect
|
645
|
+
|
646
|
+
end
|
548
647
|
|
549
648
|
else
|
550
649
|
|
@@ -559,27 +658,57 @@ module RemoteDroid
|
|
559
658
|
end
|
560
659
|
|
561
660
|
class ResponseSubscriber < SPSSub
|
661
|
+
using ColouredText
|
562
662
|
|
563
663
|
def initialize(host: 'sps.home', drb_host: '127.0.0.1')
|
564
664
|
@remote = OneDrb::Client.new host: drb_host, port: '5777'
|
565
665
|
super(host: host)
|
666
|
+
puts 'ResponseSubscriber'.highlight
|
566
667
|
end
|
567
668
|
|
568
|
-
def subscribe(topic: 'macrodroid
|
669
|
+
def subscribe(topic: 'macrodroid/#/response')
|
569
670
|
|
570
671
|
super(topic: topic) do |msg|
|
571
672
|
|
673
|
+
#puts 'msg: ' + msg.inspect
|
572
674
|
json, id = msg.split(/:\s+/,2).reverse
|
573
675
|
|
574
676
|
h = JSON.parse(json, symbolize_names: true)
|
575
677
|
id ||= h.keys.first
|
678
|
+
#puts '->' + [id, h].inspect
|
576
679
|
@remote.update id.to_sym, h
|
577
680
|
|
578
681
|
end
|
579
682
|
|
580
683
|
end
|
581
684
|
|
582
|
-
end
|
685
|
+
end
|
686
|
+
|
687
|
+
|
688
|
+
class Clients
|
689
|
+
using ColouredText
|
690
|
+
|
691
|
+
attr_reader :devices
|
692
|
+
|
693
|
+
def initialize(hostx='127.0.0.1', host: hostx, port: '5777',
|
694
|
+
sps_host: 'sps.home', sps_port: '59000')
|
695
|
+
|
696
|
+
@drb = OneDrb::Client.new host: host, port: port
|
697
|
+
#sleep 3
|
698
|
+
@devices = @drb.devices.keys.inject({}) do |r, name|
|
699
|
+
obj = RemoteDroid::Client.new(host: host, port: port,
|
700
|
+
sps_host: sps_host, sps_port: sps_port, device: name)
|
701
|
+
r.merge!(name => obj)
|
702
|
+
end
|
703
|
+
|
704
|
+
end
|
705
|
+
|
706
|
+
def device(name)
|
707
|
+
idx = @devices.index name.to_sym
|
708
|
+
@devices[idx] if idx
|
709
|
+
end
|
710
|
+
|
711
|
+
end
|
583
712
|
end
|
584
713
|
|
585
714
|
# PASTE_END
|
data/lib/remotedroid/client.rb
CHANGED
@@ -3,13 +3,19 @@ module RemoteDroid
|
|
3
3
|
class Client
|
4
4
|
using ColouredText
|
5
5
|
|
6
|
-
def initialize(hostx='127.0.0.1', host: hostx, port: '5777',
|
6
|
+
def initialize(hostx='127.0.0.1', host: hostx, port: '5777',
|
7
|
+
sps_host: 'sps.home', sps_port: '59000', device: nil)
|
8
|
+
|
9
|
+
raise 'supply a device name' unless device
|
10
|
+
|
11
|
+
@device = device
|
7
12
|
@drb = OneDrb::Client.new host: host, port: port
|
8
13
|
@sps = SPSPub.new host: sps_host, port: sps_port
|
14
|
+
|
9
15
|
end
|
10
16
|
|
11
17
|
def control
|
12
|
-
@drb.control
|
18
|
+
@drb.control @device
|
13
19
|
end
|
14
20
|
|
15
21
|
def export(s)
|
@@ -17,7 +23,7 @@ module RemoteDroid
|
|
17
23
|
end
|
18
24
|
|
19
25
|
def invoke(s, *args)
|
20
|
-
@drb.invoke(s, *args)
|
26
|
+
@drb.invoke(@device, s, *args)
|
21
27
|
end
|
22
28
|
|
23
29
|
def macros()
|
@@ -26,9 +32,9 @@ module RemoteDroid
|
|
26
32
|
|
27
33
|
def query(id=nil)
|
28
34
|
|
29
|
-
return @drb.query unless id
|
35
|
+
return @drb.query(@device) unless id
|
30
36
|
t = Time.now
|
31
|
-
h = @drb.query(id)
|
37
|
+
h = @drb.query(@device, id)
|
32
38
|
h.merge({latency: (Time.now - t).round(3)})
|
33
39
|
|
34
40
|
end
|
@@ -52,25 +58,61 @@ module RemoteDroid
|
|
52
58
|
|
53
59
|
# -- helpful methods -----------------
|
54
60
|
|
61
|
+
def ask_alexa()
|
62
|
+
control.ask_alexa
|
63
|
+
end
|
64
|
+
|
55
65
|
def battery()
|
56
66
|
query.battery
|
57
67
|
end
|
58
68
|
|
69
|
+
def bluetooth()
|
70
|
+
control.bluetooth
|
71
|
+
end
|
72
|
+
|
59
73
|
def cell_tower()
|
60
74
|
query.cell_tower
|
61
75
|
end
|
62
76
|
|
77
|
+
def click(s)
|
78
|
+
control.click content: s
|
79
|
+
end
|
80
|
+
|
63
81
|
def control_media(option='Play/Pause')
|
64
82
|
control.control_media({option: option})
|
65
83
|
end
|
66
84
|
|
67
|
-
def
|
68
|
-
control.
|
85
|
+
def disable_airplane_mode()
|
86
|
+
control.disable_airplane_mode
|
87
|
+
end
|
88
|
+
|
89
|
+
def disable_bluetooth()
|
90
|
+
control.disable_bluetooth
|
91
|
+
end
|
92
|
+
|
93
|
+
def disable_macro(macro)
|
94
|
+
control.disable_macro macro
|
69
95
|
end
|
70
96
|
|
71
|
-
def
|
72
|
-
control.
|
73
|
-
end
|
97
|
+
def disable_wifi()
|
98
|
+
control.disable_wifi
|
99
|
+
end
|
100
|
+
|
101
|
+
def enable_airplane_mode()
|
102
|
+
control.enable_airplane_mode
|
103
|
+
end
|
104
|
+
|
105
|
+
def enable_bluetooth()
|
106
|
+
control.enable_bluetooth
|
107
|
+
end
|
108
|
+
|
109
|
+
def enable_macro(macro)
|
110
|
+
control.enable_macro macro
|
111
|
+
end
|
112
|
+
|
113
|
+
def enable_wifi()
|
114
|
+
control.enable_wifi
|
115
|
+
end
|
74
116
|
|
75
117
|
def fill_clipboard(text)
|
76
118
|
control.fill_clipboard clipboard: text
|
@@ -81,11 +123,34 @@ module RemoteDroid
|
|
81
123
|
def hotspot(state=nil)
|
82
124
|
control.hotspot state
|
83
125
|
end
|
126
|
+
|
127
|
+
def last_loc()
|
128
|
+
query.last_loc
|
129
|
+
end
|
130
|
+
|
131
|
+
def last_loc_link()
|
132
|
+
"<a href='%s' target='_blank'>map link</a>" % last_loc.link
|
133
|
+
end
|
134
|
+
|
135
|
+
def launch_activity(app)
|
136
|
+
|
137
|
+
package = APPS[app]
|
138
|
+
|
139
|
+
if package then
|
140
|
+
control.launch_package package: package
|
141
|
+
else
|
142
|
+
r = APPS.find {|k,v| k =~ /#{app}/i}
|
143
|
+
control.launch_package(package: r[1]) if r
|
144
|
+
end
|
84
145
|
|
85
|
-
def launch_activity(app='')
|
86
|
-
control.launch_activity(app)
|
87
146
|
end
|
88
147
|
|
148
|
+
def launch_package(name)
|
149
|
+
|
150
|
+
control.launch_package(package: name)
|
151
|
+
|
152
|
+
end
|
153
|
+
|
89
154
|
alias launch launch_activity
|
90
155
|
|
91
156
|
def location()
|
@@ -95,7 +160,6 @@ module RemoteDroid
|
|
95
160
|
def location_watch(refresh: '1 minute', interval: refresh,
|
96
161
|
duration: '30 minutes')
|
97
162
|
|
98
|
-
|
99
163
|
d = ChronicDuration.parse(duration)
|
100
164
|
seconds = ChronicDuration.parse(interval)
|
101
165
|
puts ("monitoring location every %s for %s" % [interval, duration]).info
|
@@ -115,32 +179,43 @@ module RemoteDroid
|
|
115
179
|
|
116
180
|
end
|
117
181
|
|
182
|
+
def open_website(url)
|
183
|
+
control.open_website url: url
|
184
|
+
end
|
185
|
+
|
186
|
+
alias goto open_website
|
187
|
+
alias visit open_website
|
188
|
+
|
118
189
|
def ip()
|
119
190
|
query.ip
|
120
191
|
end
|
121
192
|
|
122
193
|
def next()
|
123
|
-
control_media(
|
194
|
+
control_media('Next')
|
124
195
|
end
|
125
196
|
|
126
197
|
def pause()
|
127
|
-
control_media(
|
198
|
+
control_media('Pause')
|
128
199
|
end
|
129
200
|
|
130
201
|
def play()
|
131
|
-
control_media(
|
202
|
+
control_media('Play')
|
132
203
|
end
|
133
204
|
|
134
205
|
def play_pause()
|
135
|
-
control_media(
|
206
|
+
control_media('Play/Pause')
|
136
207
|
end
|
137
208
|
|
138
209
|
def photo()
|
139
210
|
take_picture
|
140
211
|
end
|
141
212
|
|
213
|
+
def power_connected?()
|
214
|
+
query.power_connected?
|
215
|
+
end
|
216
|
+
|
142
217
|
def previous()
|
143
|
-
control_media(option
|
218
|
+
control.control_media(option: 'Previous')
|
144
219
|
end
|
145
220
|
|
146
221
|
def say(text)
|
@@ -165,6 +240,22 @@ module RemoteDroid
|
|
165
240
|
screen :off
|
166
241
|
end
|
167
242
|
|
243
|
+
def set_auto_rotate(state=nil)
|
244
|
+
control.set_auto_rotate state
|
245
|
+
end
|
246
|
+
|
247
|
+
def set_auto_rotate_on()
|
248
|
+
control.set_auto_rotate 0
|
249
|
+
end
|
250
|
+
|
251
|
+
def set_auto_rotate_off()
|
252
|
+
control.set_auto_rotate 1
|
253
|
+
end
|
254
|
+
|
255
|
+
def set_auto_rotate_toggle()
|
256
|
+
control.set_auto_rotate 2
|
257
|
+
end
|
258
|
+
|
168
259
|
def stay_awake()
|
169
260
|
control.stay_awake
|
170
261
|
end
|
@@ -173,17 +264,20 @@ module RemoteDroid
|
|
173
264
|
control.stay_awake_off
|
174
265
|
end
|
175
266
|
|
267
|
+
alias awake_off stay_awake_off
|
268
|
+
|
176
269
|
def stop()
|
177
|
-
control_media(option
|
270
|
+
control_media(option: 'Stop')
|
178
271
|
end
|
179
272
|
|
180
273
|
def take_picture(ftp_src: nil, fileout: '.')
|
181
274
|
|
182
275
|
#screen.on
|
183
|
-
|
276
|
+
#launch 'camera'
|
184
277
|
|
185
278
|
if ftp_src then
|
186
279
|
|
280
|
+
r = query.take_picture
|
187
281
|
# give the device a second to write the image to file
|
188
282
|
sleep 1
|
189
283
|
|
@@ -193,12 +287,49 @@ module RemoteDroid
|
|
193
287
|
filename = ftp.ls.sort_by {|x| x[:ctime]}.last[:name]
|
194
288
|
ftp.cp filename, fileout
|
195
289
|
|
290
|
+
else
|
291
|
+
|
292
|
+
contro.take_picture
|
293
|
+
|
196
294
|
end
|
197
295
|
|
198
296
|
end
|
199
297
|
|
200
298
|
alias take_photo take_picture
|
201
299
|
|
300
|
+
def take_screenshot(ftp_src: nil, fileout: '.')
|
301
|
+
|
302
|
+
#screen.on
|
303
|
+
|
304
|
+
|
305
|
+
if ftp_src then
|
306
|
+
|
307
|
+
r = query.take_screenshot
|
308
|
+
# give the device a second to write the image to file
|
309
|
+
sleep 1
|
310
|
+
|
311
|
+
credentials, dir = ftp_src.match(/(ftp:\/\/[^\/]+)\/([^$]+)/).captures
|
312
|
+
ftp = MyMediaFTP.new(credentials)
|
313
|
+
ftp.cd dir
|
314
|
+
filename = ftp.ls.sort_by {|x| x[:ctime]}.last[:name]
|
315
|
+
ftp.cp filename, fileout
|
316
|
+
|
317
|
+
end
|
318
|
+
|
319
|
+
end
|
320
|
+
|
321
|
+
def toggle_airplane_mode()
|
322
|
+
control.toggle_airplane_mode
|
323
|
+
end
|
324
|
+
|
325
|
+
def toggle_bluetooth()
|
326
|
+
control.toggle_bluetooth
|
327
|
+
end
|
328
|
+
|
329
|
+
def toggle_wifi()
|
330
|
+
control.toggle_wifi
|
331
|
+
end
|
332
|
+
|
202
333
|
def torch()
|
203
334
|
control.torch
|
204
335
|
end
|
@@ -206,6 +337,28 @@ module RemoteDroid
|
|
206
337
|
def vibrate
|
207
338
|
control.vibrate
|
208
339
|
end
|
340
|
+
|
341
|
+
def voice_search
|
342
|
+
control.voice_search
|
343
|
+
end
|
344
|
+
|
345
|
+
def volume(context=nil)
|
346
|
+
query.volume context
|
347
|
+
end
|
348
|
+
|
349
|
+
def vol()
|
350
|
+
volume.music
|
351
|
+
end
|
209
352
|
|
210
353
|
end
|
354
|
+
|
355
|
+
|
356
|
+
class WebServer < AppHttp
|
357
|
+
|
358
|
+
def initialize(port: 9292)
|
359
|
+
super(RemoteDroid::Client.new, port: port)
|
360
|
+
end
|
361
|
+
|
362
|
+
end
|
363
|
+
|
211
364
|
end
|
data/lib/remotedroid/control.rb
CHANGED
@@ -8,26 +8,129 @@ module RemoteDroid
|
|
8
8
|
|
9
9
|
end
|
10
10
|
|
11
|
+
def airplane_mode()
|
12
|
+
|
13
|
+
def self.enable()
|
14
|
+
http_exec 'set-airplane-mode', {state: 0}
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.on()
|
18
|
+
self.enable
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.disable()
|
22
|
+
http_exec 'set-airplane-mode', {state: 1}
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.off()
|
26
|
+
self.disable
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.toggle()
|
30
|
+
http_exec 'set-airplane-mode', {state: 2}
|
31
|
+
end
|
32
|
+
|
33
|
+
self
|
34
|
+
end
|
35
|
+
|
36
|
+
def ask_alexa(options={})
|
37
|
+
http_exec 'ask-alexa', options
|
38
|
+
end
|
39
|
+
|
40
|
+
def autorotate()
|
41
|
+
|
42
|
+
def self.enable()
|
43
|
+
http_exec 'set-auto-rotate', {state: 0}
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.on()
|
47
|
+
self.enable
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.disable()
|
51
|
+
http_exec 'set-auto-rotate', {state: 1}
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.off()
|
55
|
+
self.disable
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.toggle()
|
59
|
+
http_exec 'set-auto-rotate', {state: 2}
|
60
|
+
end
|
61
|
+
|
62
|
+
self
|
63
|
+
end
|
64
|
+
|
11
65
|
def bluetooth()
|
12
|
-
|
66
|
+
|
67
|
+
def self.enable()
|
68
|
+
http_exec 'set-bluetooth', {state: 0}
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.on()
|
72
|
+
self.enable
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.disable()
|
76
|
+
http_exec 'set-bluetooth', {state: 1}
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.off()
|
80
|
+
self.disable
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.toggle()
|
84
|
+
http_exec 'set-bluetooth', {state: 2}
|
85
|
+
end
|
86
|
+
|
87
|
+
self
|
13
88
|
end
|
14
89
|
|
15
90
|
def camera_flash_light(options={})
|
16
91
|
http_exec 'camera-flash-light', options
|
17
92
|
end
|
18
93
|
|
94
|
+
def click(options={content: ''})
|
95
|
+
http_exec 'click-text-content', options
|
96
|
+
end
|
97
|
+
|
19
98
|
def control_media(options={})
|
20
99
|
http_exec 'media-' + options[:option].downcase.gsub(/\W/,'-')
|
21
100
|
end
|
22
101
|
|
23
|
-
def
|
102
|
+
def disable_airplane_mode()
|
103
|
+
http_exec 'set-airplane-mode', {state: 1}
|
104
|
+
end
|
105
|
+
|
106
|
+
def disable_bluetooth()
|
107
|
+
http_exec 'set-bluetooth', {state: 1}
|
108
|
+
end
|
109
|
+
|
110
|
+
def disable_macro(macro)
|
24
111
|
http_exec 'disable-macro', {name: macro}
|
25
112
|
end
|
26
113
|
|
27
|
-
def
|
114
|
+
def disable_wifi()
|
115
|
+
http_exec 'set-wifi', {state: 1}
|
116
|
+
end
|
117
|
+
|
118
|
+
def enable_airplane_mode()
|
119
|
+
http_exec 'set-airplane-mode', {state: 0}
|
120
|
+
end
|
121
|
+
|
122
|
+
def enable_bluetooth()
|
123
|
+
http_exec 'set-bluetooth', {state: 0}
|
124
|
+
end
|
125
|
+
|
126
|
+
def enable_macro(macro)
|
28
127
|
http_exec 'enable-macro', {name: macro}
|
29
128
|
end
|
30
129
|
|
130
|
+
def enable_wifi()
|
131
|
+
http_exec 'set-wifi', {state: 0}
|
132
|
+
end
|
133
|
+
|
31
134
|
def fill_clipboard(options={})
|
32
135
|
http_exec 'fill-clipboard', options
|
33
136
|
end
|
@@ -77,15 +180,39 @@ module RemoteDroid
|
|
77
180
|
|
78
181
|
end
|
79
182
|
|
80
|
-
def launch_activity(options={})
|
81
|
-
|
82
|
-
|
183
|
+
def launch_activity(options={app: ''})
|
184
|
+
|
185
|
+
return if options[:app].empty?
|
186
|
+
|
187
|
+
app = options[:app]
|
188
|
+
|
189
|
+
package = APPS[app]
|
190
|
+
|
191
|
+
if package then
|
192
|
+
launch_package package: package
|
193
|
+
else
|
194
|
+
r = APPS.find {|k,v| k =~ /#{app}/i}
|
195
|
+
launch_package(package: r[1]) if r
|
196
|
+
end
|
197
|
+
|
83
198
|
end
|
84
199
|
|
200
|
+
def launch_package(options={package: 'com.google.android.chrome'})
|
201
|
+
http_exec 'launch-by-package', options
|
202
|
+
end
|
203
|
+
|
85
204
|
def location(options={})
|
86
205
|
http_exec 'location'
|
87
206
|
end
|
88
207
|
|
208
|
+
def open_web_page(options={url: ''})
|
209
|
+
http_exec 'open-web-page', options
|
210
|
+
end
|
211
|
+
|
212
|
+
alias open_website open_web_page
|
213
|
+
alias goto open_web_page
|
214
|
+
alias visit open_web_page
|
215
|
+
|
89
216
|
def say_current_time(options={})
|
90
217
|
http_exec 'say-current-time'
|
91
218
|
end
|
@@ -111,6 +238,29 @@ module RemoteDroid
|
|
111
238
|
end
|
112
239
|
end
|
113
240
|
|
241
|
+
def set_auto_rotate(state=nil)
|
242
|
+
|
243
|
+
if state then
|
244
|
+
http_exec 'set-auto-rotate', {state: state}
|
245
|
+
else
|
246
|
+
|
247
|
+
def self.on()
|
248
|
+
http_exec 'set-auto-rotate', {state: 0}
|
249
|
+
end
|
250
|
+
|
251
|
+
def self.off()
|
252
|
+
http_exec 'set-auto-rotate', {state: 1}
|
253
|
+
end
|
254
|
+
|
255
|
+
def self.toggle()
|
256
|
+
http_exec 'set-auto-rotate', {state: 2}
|
257
|
+
end
|
258
|
+
|
259
|
+
self
|
260
|
+
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
114
264
|
def share_location(options={})
|
115
265
|
http_exec 'share-location'
|
116
266
|
end
|
@@ -143,6 +293,9 @@ module RemoteDroid
|
|
143
293
|
|
144
294
|
alias take_photo take_picture
|
145
295
|
|
296
|
+
def take_screenshot(options={})
|
297
|
+
http_exec 'take-screenshot', options
|
298
|
+
end
|
146
299
|
|
147
300
|
def toast(options={})
|
148
301
|
http_exec :toast, options
|
@@ -155,8 +308,36 @@ module RemoteDroid
|
|
155
308
|
def vibrate(options={})
|
156
309
|
http_exec :vibrate
|
157
310
|
end
|
311
|
+
|
312
|
+
def voice_search(options={})
|
313
|
+
http_exec 'voice-search'
|
314
|
+
end
|
158
315
|
|
159
|
-
|
316
|
+
def wifi()
|
317
|
+
|
318
|
+
def self.enable()
|
319
|
+
http_exec 'set-wifi', {state: 0}
|
320
|
+
end
|
321
|
+
|
322
|
+
def self.on()
|
323
|
+
self.enable
|
324
|
+
end
|
325
|
+
|
326
|
+
def self.disable()
|
327
|
+
http_exec 'set-wifi', {state: 1}
|
328
|
+
end
|
329
|
+
|
330
|
+
def self.off()
|
331
|
+
self.disable
|
332
|
+
end
|
333
|
+
|
334
|
+
def self.toggle()
|
335
|
+
http_exec 'set-wifi', {state: 2}
|
336
|
+
end
|
337
|
+
|
338
|
+
self
|
339
|
+
end
|
340
|
+
|
160
341
|
def write(s)
|
161
342
|
|
162
343
|
d = MacroDroid.new(RD_MACROS, deviceid: @deviceid,
|
@@ -2,15 +2,20 @@ module RemoteDroid
|
|
2
2
|
|
3
3
|
class Controller
|
4
4
|
|
5
|
-
attr_reader :model, :
|
5
|
+
attr_reader :model, :syslog, :devices
|
6
6
|
attr_accessor :title, :macros, :store
|
7
7
|
|
8
|
-
def initialize(mcs, model=MODEL,
|
8
|
+
def initialize(mcs, model=MODEL, devices: {}, debug: false)
|
9
9
|
|
10
10
|
@debug = debug
|
11
11
|
@syslog = []
|
12
|
-
|
13
|
-
@
|
12
|
+
|
13
|
+
@devices = devices
|
14
|
+
|
15
|
+
@devices.each do |key, deviceid|
|
16
|
+
devices[key] = Control.new(deviceid)
|
17
|
+
end
|
18
|
+
|
14
19
|
@macros = mcs.macros
|
15
20
|
|
16
21
|
if model then
|
@@ -18,7 +23,7 @@ module RemoteDroid
|
|
18
23
|
end
|
19
24
|
|
20
25
|
@store = {}
|
21
|
-
|
26
|
+
#@query = Query.new(self)
|
22
27
|
|
23
28
|
# enable the required triggers on the Android device
|
24
29
|
#
|
@@ -35,6 +40,10 @@ module RemoteDroid
|
|
35
40
|
=end
|
36
41
|
end
|
37
42
|
|
43
|
+
def control(device)
|
44
|
+
@devices[device]
|
45
|
+
end
|
46
|
+
|
38
47
|
def delete_all()
|
39
48
|
@macros = []
|
40
49
|
end
|
@@ -42,16 +51,24 @@ module RemoteDroid
|
|
42
51
|
def export(s, replace: false)
|
43
52
|
|
44
53
|
macros = MacroDroid.new(s).macros
|
45
|
-
replace ? @macros = macros : @macros
|
54
|
+
replace ? @macros = macros : @macros.concat(macros)
|
46
55
|
|
47
56
|
end
|
48
57
|
|
49
|
-
def invoke(name, options={})
|
58
|
+
def invoke(device, name, options={})
|
50
59
|
|
51
|
-
if
|
52
|
-
|
60
|
+
if control(device).respond_to? name.to_sym then
|
61
|
+
control(device).method(name.to_sym).call(options)
|
53
62
|
else
|
54
|
-
|
63
|
+
control(device).http_exec name.to_sym, options
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def local(action, options={})
|
68
|
+
|
69
|
+
case action.to_sym
|
70
|
+
when :open_web_page
|
71
|
+
open(options[:url_to_open]).read
|
55
72
|
end
|
56
73
|
end
|
57
74
|
|
@@ -63,9 +80,9 @@ module RemoteDroid
|
|
63
80
|
@model.op
|
64
81
|
end
|
65
82
|
|
66
|
-
def query(id=nil)
|
83
|
+
def query(device, id=nil)
|
67
84
|
|
68
|
-
return
|
85
|
+
return Query.new(device, self) unless id
|
69
86
|
|
70
87
|
@store[id] = nil
|
71
88
|
|
@@ -79,20 +96,22 @@ module RemoteDroid
|
|
79
96
|
|
80
97
|
# send http request via macrodroid.com API
|
81
98
|
|
82
|
-
if id.downcase.to_sym == :location then
|
83
|
-
|
99
|
+
identifier, options = if id.downcase.to_sym == :location then
|
100
|
+
id
|
84
101
|
elsif sys.include? id
|
85
|
-
|
102
|
+
[:'query-setting-system', {qvar: id}]
|
86
103
|
elsif global.include? id
|
87
|
-
|
104
|
+
[:'query-setting-global', {qvar: id}]
|
88
105
|
elsif secure.include? id
|
89
|
-
|
106
|
+
[:'query-setting-secure', {qvar: id}]
|
90
107
|
elsif id.downcase.to_sym == :'take-picture'
|
91
|
-
|
108
|
+
id
|
92
109
|
else
|
93
|
-
|
110
|
+
[:query, {qvar: id}]
|
94
111
|
end
|
95
112
|
|
113
|
+
control(device).http_exec identifier, options
|
114
|
+
|
96
115
|
# wait for the local variable to be updated
|
97
116
|
# timeout after 5 seoncds
|
98
117
|
t = Time.now
|
@@ -155,6 +174,11 @@ module RemoteDroid
|
|
155
174
|
|
156
175
|
def update(id, val)
|
157
176
|
|
177
|
+
if @debug then
|
178
|
+
puts 'inside update'
|
179
|
+
puts [id, val].inspect
|
180
|
+
end
|
181
|
+
|
158
182
|
key = if %i(location take-picture).include? id
|
159
183
|
id
|
160
184
|
else
|
data/lib/remotedroid/query.rb
CHANGED
@@ -4,8 +4,8 @@ module RemoteDroid
|
|
4
4
|
|
5
5
|
attr_accessor :locations
|
6
6
|
|
7
|
-
def initialize(callback)
|
8
|
-
@callback = callback
|
7
|
+
def initialize(device, callback)
|
8
|
+
@device, @callback = device, callback
|
9
9
|
@locations = []
|
10
10
|
end
|
11
11
|
|
@@ -33,9 +33,19 @@ module RemoteDroid
|
|
33
33
|
q(:ip)
|
34
34
|
end
|
35
35
|
|
36
|
+
def last_loc()
|
37
|
+
|
38
|
+
def self.alt() q(:last_loc_alt) end
|
39
|
+
def self.latlon() q(:last_latlong) end
|
40
|
+
def self.link() q(:last_loc_link) end
|
41
|
+
def self.time() q(:last_loc_age_timestamp) end
|
42
|
+
|
43
|
+
self
|
44
|
+
end
|
45
|
+
|
36
46
|
def location()
|
37
47
|
|
38
|
-
r = @callback.query(:location)
|
48
|
+
r = @callback.query(@device, :location)
|
39
49
|
return r if r.nil? or r.empty? or r[:coords].nil?
|
40
50
|
|
41
51
|
r[:coords] = r[:coords].split(',')
|
@@ -44,16 +54,46 @@ module RemoteDroid
|
|
44
54
|
@locations.shift if @locations.length > 1000
|
45
55
|
|
46
56
|
return r
|
57
|
+
end
|
58
|
+
|
59
|
+
def power_connected?()
|
60
|
+
status = q(:power)
|
61
|
+
status.downcase == 'on' if status
|
47
62
|
end
|
48
63
|
|
49
64
|
def take_picture()
|
50
|
-
@callback.query(:'take-picture')
|
65
|
+
@callback.query(@device, :'take-picture')
|
51
66
|
end
|
52
67
|
|
68
|
+
def take_screenshot()
|
69
|
+
@callback.query(@device, :'take-screenshot')
|
70
|
+
end
|
71
|
+
|
72
|
+
def volume(context=nil)
|
73
|
+
|
74
|
+
if context then
|
75
|
+
q(context)
|
76
|
+
else
|
77
|
+
|
78
|
+
def self.alarm() q(:vol_alarm) end
|
79
|
+
def self.bt_voice() q(:vol_bt_voice) end
|
80
|
+
def self.call() q(:vol_call) end
|
81
|
+
def self.music() q(:vol_music) end
|
82
|
+
def self.notify() q(:vol_notif) end
|
83
|
+
def self.system() q(:vol_system) end
|
84
|
+
|
85
|
+
self
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
alias vol volume
|
91
|
+
|
92
|
+
|
53
93
|
private
|
54
94
|
|
55
95
|
def q(id)
|
56
|
-
@callback.query(id)[id]
|
96
|
+
@callback.query(@device, id)[id]
|
57
97
|
end
|
58
98
|
|
59
99
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remotedroid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
io3WPRDjULC924M5S8wbrus31v2AUjqFBPvmHr7caf/VHErWypV482xcDhWt1eif
|
36
36
|
0G2k2ptozXcBS9odsqGUTb5N
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2020-
|
38
|
+
date: 2020-11-01 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: onedrb
|
@@ -97,6 +97,46 @@ dependencies:
|
|
97
97
|
- - ">="
|
98
98
|
- !ruby/object:Gem::Version
|
99
99
|
version: 0.3.7
|
100
|
+
- !ruby/object:Gem::Dependency
|
101
|
+
name: sps-pub
|
102
|
+
requirement: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - "~>"
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0.5'
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 0.5.5
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0.5'
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: 0.5.5
|
120
|
+
- !ruby/object:Gem::Dependency
|
121
|
+
name: apphttp
|
122
|
+
requirement: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: 0.2.0
|
127
|
+
- - "~>"
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0.2'
|
130
|
+
type: :runtime
|
131
|
+
prerelease: false
|
132
|
+
version_requirements: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: 0.2.0
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0.2'
|
100
140
|
- !ruby/object:Gem::Dependency
|
101
141
|
name: ruby-macrodroid
|
102
142
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,7 +146,7 @@ dependencies:
|
|
106
146
|
version: '0.9'
|
107
147
|
- - ">="
|
108
148
|
- !ruby/object:Gem::Version
|
109
|
-
version: 0.9.
|
149
|
+
version: 0.9.17
|
110
150
|
type: :runtime
|
111
151
|
prerelease: false
|
112
152
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -116,7 +156,7 @@ dependencies:
|
|
116
156
|
version: '0.9'
|
117
157
|
- - ">="
|
118
158
|
- !ruby/object:Gem::Version
|
119
|
-
version: 0.9.
|
159
|
+
version: 0.9.17
|
120
160
|
description:
|
121
161
|
email: james@jamesrobertson.eu
|
122
162
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|