da_funk 3.28.1 → 3.31.0

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: 311e4bb5dbb5ecdb3a478dd44abf39209723de9dc7fd5e5fa9d0cc862d164392
4
- data.tar.gz: 708e6b4ad318d18bc9f5b5e46a5fd3a6132f82f36550aa77f715f901d13cbf33
3
+ metadata.gz: 5492c7a7c61fc8559c3d0267a010c62fc6b85f47ff9c40b6164d6afef3536cfd
4
+ data.tar.gz: 06cccc06f994055eb85e68163412af8b076b2342a59661f92e2ab2907514be32
5
5
  SHA512:
6
- metadata.gz: 67ddb6cbebcbe026dddc91bd4eb4eadbdb0a5e8a3f1d24f83677afbcc2249ab78ff2847618770492e0fa8223d771df9d3f8aa00708be1431f8255fd3d677ee4a
7
- data.tar.gz: ded4f9f7947ca0423b946426bc7a1a440b88ecfa499acfd0f3f9e05c61c369c690f25511d6c1b3bb1b6008679722d88aaef8ee7378aea62abaef2a744f177c56
6
+ metadata.gz: 158eb51a52a2895383bfb2864c5717659aa3d601a3780c0abcc42029b3ad86e7606aa5b1c02c55bb95e6c90dbe187f55e5fdc0ab3a1af659a4320598ef192703
7
+ data.tar.gz: cdff69f582095c79cbe9a5e1e063e495aec2a21fd74e29cc132b12653942b770da6d56d8fa309a07c433ea4e2d0a3ac8b9680c47692c109897d68020d615fa56
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- da_funk (3.28.1)
4
+ da_funk (3.31.0)
5
5
  archive-zip (~> 0.5)
6
6
  bundler
7
7
  cloudwalk_handshake
@@ -18,7 +18,7 @@ GEM
18
18
  cloudwalk (1.15.0)
19
19
  bundler
20
20
  rake
21
- cloudwalk_handshake (1.20.0)
21
+ cloudwalk_handshake (1.21.3)
22
22
  funky-simplehttp (~> 0.6)
23
23
  funky-emv (1.4.1)
24
24
  funky-tlv (~> 0.2)
@@ -27,25 +27,25 @@ GEM
27
27
  funky-tlv (0.2.3)
28
28
  io-like (0.3.1)
29
29
  parallel (1.19.2)
30
- parser (2.7.1.4)
30
+ parser (2.7.2.0)
31
31
  ast (~> 2.4.1)
32
32
  posxml_parser (2.26.0)
33
33
  funky-emv (~> 1)
34
34
  rainbow (3.0.0)
35
35
  rake (13.0.1)
36
- regexp_parser (1.7.1)
36
+ regexp_parser (1.8.2)
37
37
  rexml (3.2.4)
38
- rubocop (0.90.0)
38
+ rubocop (1.1.0)
39
39
  parallel (~> 1.10)
40
- parser (>= 2.7.1.1)
40
+ parser (>= 2.7.1.5)
41
41
  rainbow (>= 2.2.2, < 4.0)
42
- regexp_parser (>= 1.7)
42
+ regexp_parser (>= 1.8)
43
43
  rexml
44
- rubocop-ast (>= 0.3.0, < 1.0)
44
+ rubocop-ast (>= 1.0.1)
45
45
  ruby-progressbar (~> 1.7)
46
46
  unicode-display_width (>= 1.4.0, < 2.0)
47
- rubocop-ast (0.4.0)
48
- parser (>= 2.7.1.4)
47
+ rubocop-ast (1.1.0)
48
+ parser (>= 2.7.1.5)
49
49
  ruby-progressbar (1.10.1)
50
50
  unicode-display_width (1.7.0)
51
51
  yard (0.9.25)
@@ -1,5 +1,32 @@
1
1
  # DaFunk
2
2
 
3
+ ### 3.31.0 - 2020-11-27
4
+
5
+ - Added support to new battery view (Exact percentage);
6
+ - Added support to new main screen when there's a pending sale.
7
+
8
+ ### 3.30.0 - 2020-11-16
9
+
10
+ - Replace GPRS icon to 3G;
11
+ - Added new method main_image_format on Device::Display;
12
+ - Use main_image_format method to get the image name instead adapter;
13
+ - Added new class DaFunk::Transaction::Reversal.
14
+
15
+ ### 3.29.1 - 2020-11-04
16
+
17
+ - Fix battery charging status. When power supply is connected the SDK always returns 50% of battery, in this case it won't show the percentage until the SDK returns 100%.
18
+
19
+ ### 3.29.0 - 2020-11-03
20
+
21
+ - Added support to Ruby SecureRandom;
22
+ - Update cloudwalk_handshake (1.21.3).
23
+
24
+ ### 3.28.2 - 2020-10-07
25
+
26
+ - Added support of params.dat file restore if it was corrupted;
27
+ - Wait 3 seconds before restart after main update;
28
+ - Fixed method_missing exception;
29
+
3
30
  ### 3.28.1 - 2020-09-26
4
31
 
5
32
  - Close socket in case of ssl exceptions;
data/Rakefile CHANGED
@@ -53,9 +53,11 @@ FILES = FileList[
53
53
  "lib/da_funk/application.rb",
54
54
  "lib/da_funk/transaction/iso.rb",
55
55
  "lib/da_funk/transaction/download.rb",
56
+ "lib/da_funk/transaction/reversal.rb",
56
57
  "lib/da_funk/notification_event.rb",
57
58
  "lib/da_funk/notification_callback.rb",
58
59
  "lib/da_funk/notification.rb",
60
+ "lib/da_funk/secure_random.rb",
59
61
 
60
62
  "lib/device.rb",
61
63
  "lib/device/audio.rb",
@@ -1,12 +1,23 @@
1
+ #
2
+ # @file status_bar.rb
3
+ # @brief DaFunk status bar helper script.
4
+ # @platform N/A
5
+ #
6
+ # @copyright Copyright (c) 2016 CloudWalk, Inc.
7
+ #
8
+
1
9
  module DaFunk
2
10
  module Helper
11
+ # Status bar class definition.
3
12
  class StatusBar
4
- STATUS_TIMEOUT = 60
5
- SLOT_MEDIA = 0
6
- SLOT_SIGNAL_LEVEL = 1
7
- SLOT_UPDATE = 2
13
+ # Class macros and constants
14
+ STATUS_TIMEOUT = 60
15
+ SLOT_MEDIA = 0
16
+ SLOT_SIGNAL_LEVEL = 1
17
+ SLOT_UPDATE = 2
8
18
  SLOT_BATTERY_PERCENTUAL = 6
9
- SLOT_BATTERY_LEVEL = 7
19
+ SLOT_BATTERY_LEVEL = 7
20
+
10
21
  SLOT_MESSAGE_CONNECTION = {
11
22
  true => {
12
23
  :slot1 => 2,
@@ -22,10 +33,53 @@ module DaFunk
22
33
  }
23
34
  }
24
35
 
36
+ # TODO: review the 'print_status_bar' API to reduce the number of files
37
+ # to eleven?
38
+ BATTERY_PERCENTAGE_IMAGES = [
39
+ './shared/1%.png', './shared/1%.png', './shared/2%.png',
40
+ './shared/3%.png', './shared/4%.png', './shared/5%.png',
41
+ './shared/6%.png', './shared/7%.png', './shared/8%.png',
42
+ './shared/9%.png', './shared/10%.png', './shared/11%.png',
43
+ './shared/12%.png', './shared/13%.png', './shared/14%.png',
44
+ './shared/15%.png', './shared/16%.png', './shared/17%.png',
45
+ './shared/18%.png', './shared/19%.png', './shared/20%.png',
46
+ './shared/21%.png', './shared/22%.png', './shared/23%.png',
47
+ './shared/24%.png', './shared/25%.png', './shared/26%.png',
48
+ './shared/27%.png', './shared/28%.png', './shared/29%.png',
49
+ './shared/30%.png', './shared/31%.png', './shared/32%.png',
50
+ './shared/33%.png', './shared/34%.png', './shared/35%.png',
51
+ './shared/36%.png', './shared/37%.png', './shared/38%.png',
52
+ './shared/39%.png', './shared/40%.png', './shared/41%.png',
53
+ './shared/42%.png', './shared/43%.png', './shared/44%.png',
54
+ './shared/45%.png', './shared/46%.png', './shared/47%.png',
55
+ './shared/48%.png', './shared/49%.png', './shared/50%.png',
56
+ './shared/51%.png', './shared/52%.png', './shared/53%.png',
57
+ './shared/54%.png', './shared/55%.png', './shared/56%.png',
58
+ './shared/57%.png', './shared/58%.png', './shared/59%.png',
59
+ './shared/60%.png', './shared/61%.png', './shared/62%.png',
60
+ './shared/63%.png', './shared/64%.png', './shared/65%.png',
61
+ './shared/66%.png', './shared/67%.png', './shared/68%.png',
62
+ './shared/69%.png', './shared/70%.png', './shared/71%.png',
63
+ './shared/72%.png', './shared/73%.png', './shared/74%.png',
64
+ './shared/75%.png', './shared/76%.png', './shared/77%.png',
65
+ './shared/78%.png', './shared/79%.png', './shared/80%.png',
66
+ './shared/81%.png', './shared/82%.png', './shared/83%.png',
67
+ './shared/84%.png', './shared/85%.png', './shared/86%.png',
68
+ './shared/87%.png', './shared/88%.png', './shared/89%.png',
69
+ './shared/90%.png', './shared/91%.png', './shared/92%.png',
70
+ './shared/93%.png', './shared/94%.png', './shared/95%.png',
71
+ './shared/96%.png', './shared/97%.png', './shared/98%.png',
72
+ './shared/99%.png', './shared/100%.png'
73
+ ].freeze
74
+
75
+ BATTERY_CHARGING = [
76
+ "./shared/battery_charging.png",
77
+ "./shared/battery_charged.png"
78
+ ].freeze
79
+
25
80
  BATTERY_IMAGES = {
26
81
  0..4 => "./shared/battery0.png",
27
- 5..9 => "./shared/baterry5.png",
28
- 10..19 => "./shared/battery10.png",
82
+ 5..19 => "./shared/battery10.png",
29
83
  20..29 => "./shared/battery20.png",
30
84
  30..39 => "./shared/battery30.png",
31
85
  40..49 => "./shared/battery40.png",
@@ -34,44 +88,24 @@ module DaFunk
34
88
  70..79 => "./shared/battery70.png",
35
89
  80..89 => "./shared/battery80.png",
36
90
  90..99 => "./shared/battery90.png",
37
- 100..100 => "./shared/battery100.png",
38
- }
39
-
40
- BATTERY_CHARGE_IMAGES = {
41
- 50 => "./shared/battery0c.png",
42
- 100 => "./shared/battery100c.png"
43
- }
44
-
45
- BATTERY_PERCENTAGE_IMAGES = {
46
- 0..4 => "./shared/battery1_percent.png",
47
- 5..9 => "./shared/battery5_percent.png",
48
- 10..19 => "./shared/battery10_percent.png",
49
- 20..29 => "./shared/battery20_percent.png",
50
- 30..39 => "./shared/battery30_percent.png",
51
- 40..49 => "./shared/battery40_percent.png",
52
- 50..59 => "./shared/battery50_percent.png",
53
- 60..69 => "./shared/battery60_percent.png",
54
- 70..79 => "./shared/battery70_percent.png",
55
- 80..89 => "./shared/battery80_percent.png",
56
- 90..99 => "./shared/battery90_percent.png",
57
- 100..100 => "./shared/battery100_percent.png",
91
+ 100..100 => "./shared/battery100.png"
58
92
  }
59
93
 
60
94
  WIFI_IMAGES = {
61
- 0..0 => "./shared/wifi0.png",
62
- 1..25 => "./shared/wifi25.png",
63
- 26..50 => "./shared/wifi50.png",
64
- 59..75 => "./shared/wifi75.png",
65
- 76..200 => "./shared/wifi100.png"
95
+ 0..0 => "./shared/wifi0.png",
96
+ 1..25 => "./shared/wifi25.png",
97
+ 26..50 => "./shared/wifi50.png",
98
+ 59..75 => "./shared/wifi75.png",
99
+ 76..200 => "./shared/wifi100.png"
66
100
  }
67
101
 
68
102
  MOBILE_IMAGES = {
69
- 0..0 => "./shared/mobile0.png",
70
- 1..20 => "./shared/mobile20.png",
71
- 21..40 => "./shared/mobile40.png",
72
- 41..60 => "./shared/mobile60.png",
73
- 61..80 => "./shared/mobile80.png",
74
- 81..200 => "./shared/mobile100.png"
103
+ 0..0 => "./shared/mobile0.png",
104
+ 1..20 => "./shared/mobile20.png",
105
+ 21..40 => "./shared/mobile40.png",
106
+ 41..60 => "./shared/mobile60.png",
107
+ 61..80 => "./shared/mobile80.png",
108
+ 81..200 => "./shared/mobile100.png"
75
109
  }
76
110
 
77
111
  class << self
@@ -92,7 +126,7 @@ module DaFunk
92
126
  PAX::Display.print_status_bar(3, nil)
93
127
  self.connected = false
94
128
  else
95
- change_message
129
+ self.change_message
96
130
  end
97
131
  end
98
132
 
@@ -123,13 +157,13 @@ module DaFunk
123
157
  self.signal = sig
124
158
 
125
159
  if Device::Network.gprs?
126
- Device::Display.print_status_bar(SLOT_MEDIA, "./shared/GPRS.png")
160
+ Device::Display.print_status_bar(SLOT_MEDIA, "./shared/3G.png")
127
161
  Device::Display.print_status_bar(SLOT_SIGNAL_LEVEL,
128
162
  get_image_path(:gprs, self.signal))
129
163
  elsif Device::Network.wifi?
130
164
  Device::Display.print_status_bar(SLOT_MEDIA, "./shared/WIFI.png")
131
- Device::Display.print_status_bar(SLOT_SIGNAL_LEVEL,
132
- get_image_path(:wifi, self.signal))
165
+ Device::Display.print_status_bar(SLOT_SIGNAL_LEVEL,
166
+ self.get_image_path(:wifi, self.signal))
133
167
  end
134
168
  end
135
169
  else
@@ -138,45 +172,74 @@ module DaFunk
138
172
  end
139
173
  end
140
174
 
175
+ # Updates the battery slot whenever a capacity or power supply change is
176
+ # detected.
141
177
  def self.change_battery
142
- bat = Device::System.battery
143
- dock = Device::System.power_supply
144
-
145
- if self.battery != bat || self.power != dock
146
- self.battery = bat
147
- self.power = dock
148
-
149
- Device::Display.print_status_bar(SLOT_BATTERY_PERCENTUAL,
150
- get_image_path(:battery_percentual, self.battery))
151
- if self.power
152
- Device::Display.print_status_bar(
153
- SLOT_BATTERY_LEVEL, get_image_path(:battery_charge, self.battery))
178
+ capacity_type = Device::System.battery_capacity_type
179
+
180
+ capacity = Device::System.battery
181
+ charging = Device::System.power_supply
182
+
183
+ if self.battery != capacity || self.power != charging
184
+
185
+ if self.battery.nil? # basic integrity check
186
+ self.battery = capacity
187
+ elsif charging
188
+ capacity >= self.battery && self.battery = capacity
189
+ else
190
+ capacity <= self.battery && self.battery = capacity
191
+ end
192
+
193
+ if self.power == charging && capacity != self.battery
194
+ return nil
195
+ end
196
+
197
+ self.power = charging
198
+
199
+ rsc = self.get_image_path(self.power ? :battery_charge : :battery, self.battery)
200
+
201
+ Device::Display.print_status_bar(SLOT_BATTERY_LEVEL, rsc)
202
+
203
+ if capacity_type == 'percentage' || !self.power
204
+ rsc = self.get_image_path(:battery_percentual, self.battery)
154
205
  else
155
- Device::Display.print_status_bar(SLOT_BATTERY_LEVEL,
156
- get_image_path(:battery, self.battery))
206
+ rsc = nil
157
207
  end
208
+
209
+ Device::Display.print_status_bar(SLOT_BATTERY_PERCENTUAL, rsc)
158
210
  end
159
211
  end
160
212
 
213
+ # Searches for the correspondent image to 'type' and 'signal strength'.
161
214
  def self.get_image_path(type, sig)
162
215
  return if sig.nil?
163
216
  case type
164
217
  when :gprs
165
- MOBILE_IMAGES.each {|k,v| return v if k.include? sig }
218
+ MOBILE_IMAGES.each do |k, v|
219
+ return v if k.include? sig
220
+ end
166
221
  when :wifi
167
- WIFI_IMAGES.each {|k,v| return v if k.include? sig }
222
+ WIFI_IMAGES.each do |k, v|
223
+ return v if k.include? sig
224
+ end
168
225
  when :battery
169
- BATTERY_IMAGES.each {|k,v| return v if k.include? sig }
226
+ BATTERY_IMAGES.each do |k, v|
227
+ return v if k.include? sig
228
+ end
170
229
  when :battery_charge
171
- BATTERY_CHARGE_IMAGES[sig]
230
+ if sig < 100
231
+ BATTERY_CHARGING[0]
232
+ else
233
+ BATTERY_CHARGING[1]
234
+ end
172
235
  when :battery_percentual
173
- BATTERY_PERCENTAGE_IMAGES.each {|k,v| return v if k.include? sig }
236
+ BATTERY_PERCENTAGE_IMAGES[sig]
174
237
  else
175
238
  nil
176
239
  end
177
240
  end
178
241
 
179
- self.managment ||= true
242
+ self.managment ||= true
180
243
  def self.valid?
181
244
  if self.managment
182
245
  true
@@ -185,4 +248,3 @@ module DaFunk
185
248
  end
186
249
  end
187
250
  end
188
-
@@ -5,7 +5,7 @@ module DaFunk
5
5
  include DaFunk::Helper
6
6
 
7
7
  class << self
8
- attr_accessor :file, :apps, :valid, :files
8
+ attr_accessor :file, :apps, :valid, :files, :checksum
9
9
  end
10
10
 
11
11
  self.apps = Array.new
@@ -20,9 +20,19 @@ module DaFunk
20
20
  end
21
21
 
22
22
  def self.setup
23
+ @checksum = calculate_checksum
23
24
  @file = FileDb.new(FILE_NAME)
24
25
  end
25
26
 
27
+ def self.calculate_checksum
28
+ Device::Crypto.crc16_hex(File.read(FILE_NAME)) if exists?
29
+ end
30
+
31
+ def self.corrupted?
32
+ return true unless exists?
33
+ @checksum != calculate_checksum
34
+ end
35
+
26
36
  def self.exists?
27
37
  File.exists?(FILE_NAME)
28
38
  end
@@ -153,6 +163,7 @@ module DaFunk
153
163
  Device::Display.clear
154
164
  if File.exists?('./shared/init_reboot.bmp')
155
165
  Device::Display.print_bitmap('./shared/init_reboot.bmp')
166
+ getc(3000)
156
167
  else
157
168
  I18n.pt(:admin_main_update_message)
158
169
  3.times do |i|
@@ -31,7 +31,7 @@ module DaFunk
31
31
  @resources_out ||= @resources.pathmap("%{resources,#{File.join(root_path, "out")}}p")
32
32
  @tests_res_out ||= @tests_resources.pathmap("%{test/resources,out}p")
33
33
  @mruby ||= "cloudwalk run -b"
34
- @mrbc = get_mrbc_bin(@mrbc)
34
+ @mrbc = get_mrbc_bin(@mrbc)
35
35
 
36
36
  define
37
37
  end
@@ -44,14 +44,21 @@ module DaFunk
44
44
  end
45
45
  end
46
46
 
47
+ # Searches for a mrbc binary.
47
48
  def get_mrbc_bin(from_user)
48
- if (! system("type mrbc > /dev/null 2>&1 ")) && from_user
49
+ device = "/dev/null"
50
+
51
+ if %w[i386-mingw32 x64-mingw32].include?(RUBY_PLATFORM) && !ENV['SHELL']
52
+ device = "NUL" # Windows Command Prompt
53
+ end
54
+
55
+ if !system("type mrbc > #{device} 2>&1") && from_user
49
56
  from_user
50
- elsif system("type mrbc > /dev/null 2>&1 ")
57
+ elsif system("type mrbc > #{device} 2>&1")
51
58
  "env mrbc"
52
59
  elsif ENV["MRBC"]
53
60
  ENV["MRBC"]
54
- elsif system("type cloudwalk > /dev/null 2>&1 ")
61
+ elsif system("type cloudwalk > #{device} 2>&1")
55
62
  "env cloudwalk compile"
56
63
  else
57
64
  puts "$MRBC isn't set or mrbc/cloudwalk isn't on $PATH"
@@ -64,7 +71,7 @@ module DaFunk
64
71
  command_line = File.join(File.dirname(__FILE__), "..", "..", "utils", "command_line_platform.rb")
65
72
  command_line_obj = File.join(root_path, "out", "main", "command_line_platform.mrb")
66
73
  all_files = FileList["test/test_helper.rb"] + libs + files + [command_line] + [File.join(File.dirname(__FILE__), "..", "..", "utils", "test_run.rb")]
67
- if platform_call("#{mrbc} -g -o #{command_line_obj} #{command_line}") && platform_call("#{mrbc} -g -o #{test_out} #{all_files.uniq}")
74
+ if platform_call("#{@mrbc} -g -o #{command_line_obj} #{command_line}") && platform_call("#{@mrbc} -g -o #{test_out} #{all_files.uniq}")
68
75
  puts "cd #{File.dirname(out_path)}"
69
76
  FileUtils.cd File.dirname(out_path)
70
77
  platform_call("#{mruby} #{File.join(name, "test.mrb")}")
@@ -108,7 +115,7 @@ module DaFunk
108
115
 
109
116
  desc "Compile app to mrb and process resources"
110
117
  task :build => :resources do
111
- platform_call "#{mrbc} #{debug_flag} -o #{main_out} #{libs} "
118
+ platform_call "#{@mrbc} #{debug_flag} -o #{main_out} #{libs} "
112
119
  end
113
120
 
114
121
  desc "Compile, build and pack app and resources"
@@ -0,0 +1,17 @@
1
+ module DaFunk
2
+ class SecureRandom
3
+ CHARS = [('a'..'z'), ('A'..'Z')].map(&:to_a).flatten
4
+
5
+ def self.random_bytes(n = nil)
6
+ n = n ? n.to_int : 16
7
+ (0...n).map { CHARS[rand(CHARS.length)] }.join
8
+ end
9
+
10
+ def self.uuid
11
+ bytes = random_bytes.unpack('NnnnnN')
12
+ bytes[2] = (bytes[2] & 0x0fff) | 0x4000
13
+ bytes[3] = (bytes[3] & 0x3fff) | 0x8000
14
+ "%08x-%04x-%04x-%04x-%04x%08x" % bytes
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ module DaFunk
2
+ class Transaction
3
+ class Reversal
4
+ def self.filename
5
+ DaFunk::ParamsDat.file['reversal_file_name'] || 'cw_reversal_transact.dat'
6
+ end
7
+
8
+ def self.exists?
9
+ File.exists? "./shared/#{filename}"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,4 +1,4 @@
1
1
  module DaFunk
2
- VERSION="3.28.1"
2
+ VERSION="3.31.0"
3
3
  end
4
4
 
@@ -71,13 +71,23 @@ class Device
71
71
  end
72
72
 
73
73
  def self.main_image
74
- if adapter.respond_to?(:main_image) &&
75
- File.exists?("./shared/#{adapter.main_image}")
76
- adapter.main_image
74
+ file = main_image_format
75
+ if File.exists?("./shared/#{file}")
76
+ file
77
77
  else
78
78
  MAIN_BMP
79
79
  end
80
80
  end
81
+
82
+ private
83
+ def self.main_image_format
84
+ major, min, patch = Device.version.to_s.split('.').map { |v| v.to_i }
85
+ if DaFunk::Transaction::Reversal.exists? && major >= 8
86
+ "main_#{Device::System.model}_reversal.bmp"
87
+ else
88
+ "main_#{Device::System.model}.bmp"
89
+ end
90
+ end
81
91
  end
82
92
  end
83
93
 
@@ -152,16 +152,16 @@ class Device
152
152
 
153
153
  # Custom Attributes
154
154
  def self.tcp_recv_timeout
155
- DaFunk::ParamsDat.file["tcp_recv_timeout"] || method_missing(:tcp_recv_timeout)
155
+ DaFunk::ParamsDat.file["tcp_recv_timeout"] || @file&.dig("tcp_recv_timeout")
156
156
  end
157
157
 
158
158
  def self.attach_gprs_timeout
159
- value = (DaFunk::ParamsDat.file["attach_gprs_timeout"] || method_missing(:attach_gprs_timeout))
159
+ value = (DaFunk::ParamsDat.file["attach_gprs_timeout"] || @file&.dig("attach_gprs_timeout"))
160
160
  value.to_s.empty? ? nil : value.to_s.to_i
161
161
  end
162
162
 
163
163
  def self.heartbeat
164
- DaFunk::ParamsDat.file["heartbeat"] || method_missing(:heartbeat)
164
+ DaFunk::ParamsDat.file["heartbeat"] || @file&.dig("heartbeat")
165
165
  end
166
166
 
167
167
  def self.logical_number
@@ -45,6 +45,15 @@ class Device
45
45
  adapter.battery
46
46
  end
47
47
 
48
+ # Checks the type of the battery capacity return (percentage or scale).
49
+ def self.battery_capacity_type
50
+ begin
51
+ adapter.battery_capacity_type
52
+ rescue StandardError => exception
53
+ 'scale'
54
+ end
55
+ end
56
+
48
57
  def self.beep
49
58
  adapter.beep
50
59
  end
@@ -0,0 +1,18 @@
1
+ class SecureRandomTest < DaFunk::Test.case
2
+ def setup
3
+ @uuid = DaFunk::SecureRandom.uuid
4
+ @random_bytes = DaFunk::SecureRandom.random_bytes
5
+ end
6
+
7
+ def test_uuid
8
+ assert_equal(36, @uuid.size)
9
+
10
+ # Check time_hi_and_version and clock_seq_hi_res bits (RFC 4122 4.4)
11
+ assert_equal('4', @uuid[14])
12
+ assert_include(%w'8 9 a b', @uuid[19])
13
+ end
14
+
15
+ def test_random_bytes
16
+ assert_equal(16, @random_bytes.size)
17
+ end
18
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: da_funk
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.28.1
4
+ version: 3.31.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thiago Scalone
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-26 00:00:00.000000000 Z
11
+ date: 2020-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -174,10 +174,12 @@ files:
174
174
  - lib/da_funk/rake_task.rb
175
175
  - lib/da_funk/screen.rb
176
176
  - lib/da_funk/screen_flow.rb
177
+ - lib/da_funk/secure_random.rb
177
178
  - lib/da_funk/struct.rb
178
179
  - lib/da_funk/test.rb
179
180
  - lib/da_funk/transaction/download.rb
180
181
  - lib/da_funk/transaction/iso.rb
182
+ - lib/da_funk/transaction/reversal.rb
181
183
  - lib/da_funk/version.rb
182
184
  - lib/device.rb
183
185
  - lib/device/audio.rb
@@ -220,6 +222,7 @@ files:
220
222
  - test/resources/shared/bitmap_gp.dat
221
223
  - test/test_helper.rb
222
224
  - test/unit/da_funk/event_listener_test.rb
225
+ - test/unit/da_funk/secure_random.rb
223
226
  - test/unit/da_funk/struct_test.rb
224
227
  - test/unit/da_funk/support_test.rb
225
228
  - test/unit/device/application_test.rb
@@ -269,6 +272,7 @@ test_files:
269
272
  - test/resources/shared/bitmap_gp.dat
270
273
  - test/test_helper.rb
271
274
  - test/unit/da_funk/event_listener_test.rb
275
+ - test/unit/da_funk/secure_random.rb
272
276
  - test/unit/da_funk/struct_test.rb
273
277
  - test/unit/da_funk/support_test.rb
274
278
  - test/unit/device/application_test.rb