remotedroid 0.5.0 → 0.5.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec97faa80816c99a0b7beed8f4274c90f9b3015d6a0db1586a520e3167849351
4
- data.tar.gz: 73734010ed7db6576c84988d909ca21aed08e8561b7a9e55e3d657bcdabd0b33
3
+ metadata.gz: a86c870441f3c62f297cbcfc00422258f19d0061d0f4379c825f8abfb1d37f4b
4
+ data.tar.gz: 71f5eef47bf451ea91cbbd0b0cf2d45d4c1f656505d97bc65287bf673e7e0416
5
5
  SHA512:
6
- metadata.gz: a493dc47aa1c0cbe51c87e7189f1504eb0734088f6ae679da563fee60ea8ae45c4225d1f77909bfb91266b78f81614c89bdba6dec1dfaabedf5c3da0be1bc33e
7
- data.tar.gz: 8ff28ae91aaccf51919732e516c3915c136acf8be4511b0acfad80ef44447ee5e4b35796003ba0a010da4ed7559674caff94786434e9ba83811cff56e828af75
6
+ metadata.gz: f018dbb7e614a4555a658a8723dacbfff6127388b80d5b78a161af07076438b214ad30ed7d09d97f23ce178ccf32ee533b55e4b3fe84444c4d4c73c1d0adde96
7
+ data.tar.gz: e373a0b5a31d9e6648376bf8a17e1745dc041658f7250767da2f6ab063b7a1ea621ad4cbc66cf7cdad2e467e048b5e7f8365f3597bf63d69d6635e47d093af33
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -14,15 +14,30 @@ require 'ruby-macrodroid'
14
14
  #
15
15
  # # Triggers
16
16
  #
17
+ # ## Battery/Power
18
+ #
19
+ # * Power button toggle
20
+ #
21
+ # ## Connectivity
22
+ #
23
+ # ### Wifi State Change
24
+ #
25
+ # * Connected to Network
26
+ #
17
27
  # ## Device Events
18
28
  #
19
29
  # * screen on
20
30
  #
21
31
  # ## Sensors
22
- #
32
+ #
33
+ # * Activity Recognition
23
34
  # * proximity (near)
24
35
  # * shake device
25
36
  #
37
+ # ## User Input
38
+ #
39
+ # * Swipe Screen
40
+ #
26
41
  # ------------------------------------
27
42
  #
28
43
  # # Actions
@@ -182,6 +197,79 @@ m: stay awake off
182
197
  t: webhook
183
198
  a: stay awake off
184
199
 
200
+ m: Launch Google Play Music
201
+ t: webhook
202
+ a: Launch Google Play Music
203
+
204
+
205
+ m: Media Next
206
+ t: webhook
207
+ a:
208
+ Media Next
209
+ Simulate Media Button (Google Play Music)
210
+
211
+ m: Media Pause
212
+ t: webhook
213
+ a:
214
+ Media Pause
215
+ Simulate Media Button (Google Play Music)
216
+
217
+ m: Media Play
218
+ t: webhook
219
+ a:
220
+ Media Play
221
+ Simulate Media Button (Google Play Music)
222
+
223
+ m: Media Play Pause
224
+ t: webhook
225
+ a:
226
+ Media Play/Pause
227
+ Simulate Media Button (Google Play Music)
228
+
229
+ m: Media Previous
230
+ t: webhook
231
+ a:
232
+ Media Previous
233
+ Simulate Media Button (Google Play Music)
234
+
235
+ m: Media Stop
236
+ t: webhook
237
+ a:
238
+ Media Stop
239
+ Simulate Media Button (Google Play Music)
240
+
241
+ m: Open website
242
+ v: url
243
+ t: webhook
244
+ a: goto [lv=url]
245
+
246
+ m: Fill clipboard
247
+ v: clipboard
248
+ t: webhook
249
+ a:
250
+ Fill Clipboard
251
+ [lv=clipboard]
252
+
253
+ m: click text content
254
+ v: content
255
+ t: webhook
256
+ a:
257
+ UI Interaction
258
+ Click [[lv=content]]
259
+
260
+ m: Launch by package
261
+ v: package
262
+ t: webhook
263
+ a: Launch [lv=package]
264
+
265
+ m: Take Screenshot
266
+ t: webhook
267
+ a:
268
+ Take Screenshot
269
+ Save to device
270
+ a: wait 2 seconds
271
+ a: webhook
272
+
185
273
  m: Share location
186
274
  t:
187
275
  WebHook
@@ -261,12 +349,163 @@ m: Power connected
261
349
  t: Power Connected: Any
262
350
  a: webhook
263
351
 
264
- m: screen on off
352
+ m: Screen on
265
353
  t: screen on
354
+ a:
355
+ webhook
356
+ identifier: screen_on_off
357
+ screen_on: true
358
+
359
+ m: Power Button Toggle3
360
+ t: Power Button Toggle (3)
266
361
  a: webhook
267
362
 
268
- EOF
363
+ m: Power Button Toggle4
364
+ t: Power Button Toggle (4)
365
+ a: webhook
366
+
367
+ m: Power Button Toggle5
368
+ t: Power Button Toggle (5)
369
+ a: webhook
370
+
371
+ m: Connected to network
372
+ t:
373
+ Connected to network
374
+ Any Network
375
+ a: wait 2 seconds
376
+ a:
377
+ webhook
378
+ ssid: [ssid]
379
+
380
+ m: In Vehicle
381
+ t:
382
+ Activity - In Vehicle
383
+ Confidence >= 50%
384
+ a:
385
+ webhook
386
+ identifier: activity
387
+ index: 0
388
+
389
+ m: On Bicycle
390
+ t:
391
+ Activity - On Bicycle
392
+ Confidence >= 50%
393
+ a:
394
+ webhook
395
+ identifier: activity
396
+ index: 1
397
+
398
+ m: Running
399
+ t:
400
+ Activity - Running
401
+ Confidence >= 50%
402
+ a:
403
+ webhook
404
+ identifier: activity
405
+ index: 2
406
+
407
+ m: Walking
408
+ t:
409
+ Activity - Walking
410
+ Confidence >= 50%
411
+ a:
412
+ webhook
413
+ identifier: activity
414
+ index: 3
415
+
416
+ m: Still
417
+ t:
418
+ Activity - Still
419
+ Confidence >= 83%
420
+ a:
421
+ webhook
422
+ identifier: activity
423
+ index: 4
424
+
425
+ m: Swipe top left across
426
+ t:
427
+ Swipe Screen
428
+ Top Left - Across
429
+ a:
430
+ webhook
431
+ identifier: swipe
432
+ start: 0
433
+ motion: 0
434
+
435
+ m: Swipe top left diagonal
436
+ t:
437
+ Swipe Screen
438
+ Top Left - Diagonal
439
+ a:
440
+ webhook
441
+ identifier: swipe
442
+ start: 0
443
+ motion: 1
269
444
 
445
+ m: Swipe top left down
446
+ t:
447
+ Swipe Screen
448
+ Top Left - Down
449
+ a:
450
+ webhook
451
+ identifier: swipe
452
+ start: 0
453
+ motion: 2
454
+
455
+ m: Swipe top right across
456
+ t:
457
+ Swipe Screen
458
+ Top Right - Across
459
+ a:
460
+ webhook
461
+ identifier: swipe
462
+ start: 1
463
+ motion: 0
464
+
465
+
466
+ m: Swipe top right diagonal
467
+ t:
468
+ Swipe Screen
469
+ Top Right - Diagonal
470
+ a:
471
+ webhook
472
+ identifier: swipe
473
+ start: 1
474
+ motion: 1
475
+
476
+ m: Swipe top right down
477
+ t:
478
+ Swipe Screen
479
+ Top Right - Down
480
+ a:
481
+ webhook
482
+ identifier: swipe
483
+ start: 1
484
+ motion: 2
485
+
486
+ m: flip from up to down
487
+ t: Flip Device Face Up -> Face Down
488
+ a:
489
+ webhook
490
+ identifier: flip_device
491
+ facedown: true
492
+
493
+ m: flip from down to up
494
+ t: Flip Device Face Down -> Face Up
495
+ a:
496
+ webhook
497
+ identifier: flip_device
498
+ facedown: false
499
+ EOF
500
+ s='
501
+
502
+ m: click text content
503
+ v: content
504
+ t: webhook
505
+ a:
506
+ UI Interaction
507
+ Click [[[lv=content]]]
508
+ '
270
509
 
271
510
  module RemoteDroid
272
511
 
@@ -320,8 +559,19 @@ module RemoteDroid
320
559
 
321
560
  context, json = msg.split(/:\s+/,2)
322
561
  category, action = context.split('/',2)
323
- @remote.control.method(action.to_sym)\
324
- .call(JSON.parse(json, symbolize_names: true))
562
+
563
+ h = JSON.parse(json, symbolize_names: true)
564
+
565
+ if action == 'force_macro_run' and h[:serverside] then
566
+
567
+ a = @remote.run_macro(h)
568
+ a.each {|msg| self.notice 'macrodroid/action: ' + msg }
569
+
570
+ else
571
+
572
+ @remote.control.method(action.to_sym).call(h)
573
+
574
+ end
325
575
 
326
576
  end
327
577
 
@@ -3,8 +3,9 @@ module RemoteDroid
3
3
  class Client
4
4
  using ColouredText
5
5
 
6
- def initialize(host='127.0.0.1')
7
- @drb = OneDrb::Client.new host: host, port: '5777'
6
+ def initialize(hostx='127.0.0.1', host: hostx, port: '5777', sps_host: 'sps.home', sps_port: '59000')
7
+ @drb = OneDrb::Client.new host: host, port: port
8
+ @sps = SPSPub.new host: sps_host, port: sps_port
8
9
  end
9
10
 
10
11
  def control
@@ -32,6 +33,11 @@ module RemoteDroid
32
33
 
33
34
  end
34
35
 
36
+ def run_macro(name)
37
+ a = @drb.run_macro name
38
+ a.each {|msg| @sps.notice 'macrodroid/action: ' + msg }
39
+ end
40
+
35
41
  def update(key, val)
36
42
  @drb.update key.to_sym, val
37
43
  end
@@ -40,6 +46,10 @@ module RemoteDroid
40
46
  @drb.store
41
47
  end
42
48
 
49
+ def syslog()
50
+ @drb.syslog
51
+ end
52
+
43
53
  # -- helpful methods -----------------
44
54
 
45
55
  def battery()
@@ -50,6 +60,14 @@ module RemoteDroid
50
60
  query.cell_tower
51
61
  end
52
62
 
63
+ def click(s)
64
+ control.click content: s
65
+ end
66
+
67
+ def control_media(option='Play/Pause')
68
+ control.control_media({option: option})
69
+ end
70
+
53
71
  def disable(macro)
54
72
  control.disable macro
55
73
  end
@@ -57,11 +75,38 @@ module RemoteDroid
57
75
  def enable(macro)
58
76
  control.enable macro
59
77
  end
78
+
79
+ def fill_clipboard(text)
80
+ control.fill_clipboard clipboard: text
81
+ end
82
+
83
+ alias copy fill_clipboard
60
84
 
61
85
  def hotspot(state=nil)
62
86
  control.hotspot state
87
+ end
88
+
89
+ def launch_activity(app='')
90
+
91
+ package = APPS[app]
92
+
93
+ if package then
94
+ control.launch_package package: package
95
+ else
96
+ r = APPS.find {|k,v| k =~ /#{app}/i}
97
+ control.launch_package(package: r[1]) if r
98
+ end
99
+
100
+ end
101
+
102
+ def launch_package(name='')
103
+
104
+ control.launch_package(package: name)
105
+
63
106
  end
64
107
 
108
+ alias launch launch_activity
109
+
65
110
  def location()
66
111
  query.location
67
112
  end
@@ -69,7 +114,6 @@ module RemoteDroid
69
114
  def location_watch(refresh: '1 minute', interval: refresh,
70
115
  duration: '30 minutes')
71
116
 
72
-
73
117
  d = ChronicDuration.parse(duration)
74
118
  seconds = ChronicDuration.parse(interval)
75
119
  puts ("monitoring location every %s for %s" % [interval, duration]).info
@@ -89,10 +133,41 @@ module RemoteDroid
89
133
 
90
134
  end
91
135
 
136
+ def open_website(url)
137
+ control.open_website url: url
138
+ end
139
+
140
+ alias goto open_website
141
+ alias visit open_website
142
+
143
+ def ip()
144
+ query.ip
145
+ end
146
+
147
+ def next()
148
+ control_media(option='Next')
149
+ end
150
+
151
+ def pause()
152
+ control_media(option='Pause')
153
+ end
154
+
155
+ def play()
156
+ control_media(option='Play')
157
+ end
158
+
159
+ def play_pause()
160
+ control_media(option='Play/Pause')
161
+ end
162
+
92
163
  def photo()
93
164
  take_picture
94
165
  end
95
166
 
167
+ def previous()
168
+ control_media(option='Previous')
169
+ end
170
+
96
171
  def say(text)
97
172
  control.speak_text text
98
173
  end
@@ -123,6 +198,10 @@ module RemoteDroid
123
198
  control.stay_awake_off
124
199
  end
125
200
 
201
+ def stop()
202
+ control_media(option='Stop')
203
+ end
204
+
126
205
  def take_picture(ftp_src: nil, fileout: '.')
127
206
 
128
207
  #screen.on
@@ -145,6 +224,26 @@ module RemoteDroid
145
224
 
146
225
  alias take_photo take_picture
147
226
 
227
+ def take_screenshot(ftp_src: nil, fileout: '.')
228
+
229
+ #screen.on
230
+ r = query.take_screenshot
231
+
232
+ if ftp_src then
233
+
234
+ # give the device a second to write the image to file
235
+ sleep 1
236
+
237
+ credentials, dir = ftp_src.match(/(ftp:\/\/[^\/]+)\/([^$]+)/).captures
238
+ ftp = MyMediaFTP.new(credentials)
239
+ ftp.cd dir
240
+ filename = ftp.ls.sort_by {|x| x[:ctime]}.last[:name]
241
+ ftp.cp filename, fileout
242
+
243
+ end
244
+
245
+ end
246
+
148
247
  def torch()
149
248
  control.torch
150
249
  end
@@ -16,14 +16,30 @@ module RemoteDroid
16
16
  http_exec 'camera-flash-light', options
17
17
  end
18
18
 
19
+ def click(options={content: ''})
20
+ http_exec 'click-text-content', options
21
+ end
22
+
23
+ def control_media(options={})
24
+ http_exec 'media-' + options[:option].downcase.gsub(/\W/,'-')
25
+ end
26
+
19
27
  def disable(macro)
20
28
  http_exec 'disable-macro', {name: macro}
21
29
  end
22
30
 
23
31
  def enable(macro)
24
32
  http_exec 'enable-macro', {name: macro}
33
+ end
34
+
35
+ def fill_clipboard(options={})
36
+ http_exec 'fill-clipboard', options
25
37
  end
26
38
 
39
+ def force_macro_run(options={})
40
+ http_exec option[:macro_name].downcase.gsub(/ /,'-')
41
+ end
42
+
27
43
  def hotspot(state=nil)
28
44
 
29
45
  if state then
@@ -65,10 +81,38 @@ module RemoteDroid
65
81
 
66
82
  end
67
83
 
84
+ def launch_activity(options={app: ''})
85
+
86
+ return if options[:app].empty?
87
+
88
+ app = options[:app]
89
+
90
+ package = APPS[app]
91
+
92
+ if package then
93
+ launch_package package: package
94
+ else
95
+ r = APPS.find {|k,v| k =~ /#{app}/i}
96
+ launch_package(package: r[1]) if r
97
+ end
98
+
99
+ end
100
+
101
+ def launch_package(options={package: 'com.google.android.chrome'})
102
+ http_exec 'launch-by-package', options
103
+ end
104
+
68
105
  def location(options={})
69
106
  http_exec 'location'
70
107
  end
71
108
 
109
+ def open_website(options={url: ''})
110
+ http_exec 'open-website', options
111
+ end
112
+
113
+ alias goto open_website
114
+ alias visit open_website
115
+
72
116
  def say_current_time(options={})
73
117
  http_exec 'say-current-time'
74
118
  end
@@ -2,7 +2,7 @@ module RemoteDroid
2
2
 
3
3
  class Controller
4
4
 
5
- attr_reader :model, :control
5
+ attr_reader :model, :control, :syslog
6
6
  attr_accessor :title, :macros, :store
7
7
 
8
8
  def initialize(mcs, model=MODEL, deviceid: nil, debug: false)
@@ -25,18 +25,25 @@ module RemoteDroid
25
25
  names = @macros.map {|x| x.triggers.first.type}.uniq
26
26
  #@control.enable names.first.to_s.gsub('_',' ')
27
27
  puts 'Enabling ' + names.join(',')
28
-
28
+ =begin
29
29
  Thread.new do
30
30
  names.each do |title|
31
31
  @control.enable title.to_s.gsub('_',' ')
32
32
  sleep 0.8
33
33
  end
34
34
  end
35
-
35
+ =end
36
36
  end
37
37
 
38
- def export(s)
39
- @macros = MacroDroid.new(s).macros
38
+ def delete_all()
39
+ @macros = []
40
+ end
41
+
42
+ def export(s, replace: false)
43
+
44
+ macros = MacroDroid.new(s).macros
45
+ replace ? @macros = macros : @macros << macros
46
+
40
47
  end
41
48
 
42
49
  def invoke(name, options={})
@@ -105,8 +112,17 @@ module RemoteDroid
105
112
  @model.request s
106
113
  end
107
114
 
115
+ def run_macro(macro_name: '')
116
+
117
+ found = @macros.find do |macro|
118
+ macro.title.downcase == macro_name.downcase
119
+ end
120
+
121
+ found.run if found
122
+
123
+ end
108
124
 
109
- def trigger(name, detail={time: Time.now})
125
+ def trigger(name, detail={})
110
126
 
111
127
  macros = @macros.select do |macro|
112
128
 
@@ -117,12 +133,14 @@ module RemoteDroid
117
133
  #
118
134
  valid_trigger = macro.match?(name, detail, @model.op)
119
135
 
120
- puts 'valid_trigger: ' + valid_trigger.inspect if @debug
136
+ #puts 'valid_trigger: ' + valid_trigger.inspect if @debug
121
137
 
122
- if valid_trigger then
123
- @syslog << [Time.now, :trigger, name]
124
- @syslog << [Time.now, :macro, macro.title]
125
- end
138
+ #if valid_trigger then
139
+ # @syslog << [Time.now, :trigger, name]
140
+ # @syslog << [Time.now, :macro, macro.title]
141
+ #end
142
+
143
+ @syslog << [Time.now, name, detail]
126
144
 
127
145
  valid_trigger
128
146
 
@@ -143,7 +161,9 @@ module RemoteDroid
143
161
  val.keys.first.to_sym
144
162
  end
145
163
 
146
- @store[key] = val
164
+ @syslog << [id, val]
165
+ @store[key] = val
166
+
147
167
  end
148
168
 
149
169
  end
@@ -50,6 +50,10 @@ module RemoteDroid
50
50
  @callback.query(:'take-picture')
51
51
  end
52
52
 
53
+ def take_screenshot()
54
+ @callback.query(:'take-screenshot')
55
+ end
56
+
53
57
  private
54
58
 
55
59
  def q(id)
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.5.0
4
+ version: 0.5.5
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-10-19 00:00:00.000000000 Z
38
+ date: 2020-10-24 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: onedrb
metadata.gz.sig CHANGED
Binary file