@@ -232,18 +232,6 @@ func (device *Device) Version() *semver.SemVer {
232
232
return device .version
233
233
}
234
234
235
- // inferVersionAndProduct either sets the version and product by using REQ_INFO if they were not
236
- // provided. In this case, the firmware is assumed to be >=v4.3.0, before that REQ_INFO was not
237
- // available.
238
- func (device * Device ) inferVersionAndProduct (version * semver.SemVer , product common.Product ) {
239
- // The version has not been provided, so we try to get it from REQ_INFO.
240
- if device .version == nil {
241
- device .log .Info (fmt .Sprintf ("REQ_INFO: version=%s, product=%s" , version , product ))
242
- device .version = version
243
- device .product = & product
244
- }
245
- }
246
-
247
235
// Init initializes the device. It changes the status to StatusRequireAppUpgrade if needed,
248
236
// otherwise performs the attestation check, unlock, and noise pairing. This call is blocking.
249
237
// After this call finishes, Status() will be either:
@@ -259,17 +247,24 @@ func (device *Device) Init() error {
259
247
device .sendCipher = nil
260
248
device .receiveCipher = nil
261
249
262
- if device .version == nil || device .version .AtLeast (semver .NewSemVer (4 , 3 , 0 )) {
250
+ if device .version == nil || device .version .AtLeast (semver .NewSemVer (9 , 2 , 0 )) {
263
251
deviceInfo , err := device .info ()
264
252
if err != nil {
265
253
return errp .New (
266
254
"REQ_INFO unavailable; need to provide version and product via the USB HID descriptor" )
267
255
}
268
- // Does nothing if device.version == nil
269
- device .inferVersionAndProduct (deviceInfo .version , deviceInfo .product )
270
-
271
- if deviceInfo .unlocked || (deviceInfo .initialized != nil && * deviceInfo .initialized ) {
256
+ device .log .Info (fmt .Sprintf ("REQ_INFO: version=%s, product=%s" , deviceInfo .version ,
257
+ deviceInfo .product ))
258
+ device .version = deviceInfo .version
259
+ device .product = & deviceInfo .product
260
+
261
+ if ! deviceInfo .version .AtLeast (semver .NewSemVer (9 , 20 , 0 )) {
262
+ device .changeStatus (StatusConnected )
263
+ } else if deviceInfo .unlocked {
272
264
device .changeStatus (StatusInitialized )
265
+ } else if * deviceInfo .initialized {
266
+ // deviceInfo.initialized is not nil if version is at least 9.20.0.
267
+ device .changeStatus (StatusConnected )
273
268
} else {
274
269
device .changeStatus (StatusUninitialized )
275
270
}
0 commit comments