@onekeyfe/hd-core 1.2.0-alpha.131 → 1.2.0-alpha.133
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.
- package/__tests__/device-lifecycle-events.test.ts +17 -1
- package/__tests__/device-settings.test.ts +69 -9
- package/__tests__/protocol-v2.test.ts +30 -0
- package/dist/api/device/DeviceSettings.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -1
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/index.js +154 -152
- package/package.json +4 -4
- package/src/api/device/DeviceSettings.ts +1 -14
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +11 -1
- package/src/core/index.ts +3 -2
package/dist/index.js
CHANGED
|
@@ -2261,7 +2261,7 @@ const createLogMessage = (type, payload) => ({
|
|
|
2261
2261
|
|
|
2262
2262
|
const MAX_ENTRIES = 500;
|
|
2263
2263
|
let postMessage$1;
|
|
2264
|
-
class Log$
|
|
2264
|
+
class Log$n {
|
|
2265
2265
|
constructor(prefix, enabled) {
|
|
2266
2266
|
this.prefix = prefix;
|
|
2267
2267
|
this.enabled = enabled;
|
|
@@ -2313,7 +2313,7 @@ class Log$m {
|
|
|
2313
2313
|
}
|
|
2314
2314
|
const _logs = {};
|
|
2315
2315
|
const initLog = (prefix, enabled) => {
|
|
2316
|
-
const instance = new Log$
|
|
2316
|
+
const instance = new Log$n(prefix, !!enabled);
|
|
2317
2317
|
_logs[prefix] = instance;
|
|
2318
2318
|
return instance;
|
|
2319
2319
|
};
|
|
@@ -2711,7 +2711,7 @@ function patchFeatures(response) {
|
|
|
2711
2711
|
return response;
|
|
2712
2712
|
}
|
|
2713
2713
|
|
|
2714
|
-
const Log$
|
|
2714
|
+
const Log$m = getLogger(exports.LoggerNames.Core);
|
|
2715
2715
|
let globalInstanceCounter = 0;
|
|
2716
2716
|
let sdkInstanceCounter = 0;
|
|
2717
2717
|
function generateSdkInstanceId() {
|
|
@@ -2771,7 +2771,7 @@ function completeRequestContext(responseID, error) {
|
|
|
2771
2771
|
context.status = error ? 'error' : 'success';
|
|
2772
2772
|
if (error) {
|
|
2773
2773
|
context.error = error.message;
|
|
2774
|
-
Log$
|
|
2774
|
+
Log$m.debug(`[RequestContext] [completeRequestContext] Error: ${formatRequestContext(context)}`);
|
|
2775
2775
|
}
|
|
2776
2776
|
globalActiveRequests.delete(responseID);
|
|
2777
2777
|
if (context.sdkInstanceId) {
|
|
@@ -40799,7 +40799,7 @@ function selectProtocolV2ResourceManifestFiles({ manifest, targetsToUpdate, }) {
|
|
|
40799
40799
|
|
|
40800
40800
|
var _a$1;
|
|
40801
40801
|
const FIRMWARE_UPDATE_CONFIG_FRESHNESS_MS = 5 * 60 * 1000;
|
|
40802
|
-
const Log$
|
|
40802
|
+
const Log$l = getLogger(exports.LoggerNames.Core);
|
|
40803
40803
|
const FIRMWARE_FIELDS = [
|
|
40804
40804
|
'firmware',
|
|
40805
40805
|
'firmware-v1',
|
|
@@ -40880,11 +40880,11 @@ class DataManager {
|
|
|
40880
40880
|
const manifestMode = (_b = settings.firmwareManifestMode) !== null && _b !== void 0 ? _b : (settings.fetchConfig ? 'sdk-managed' : undefined);
|
|
40881
40881
|
if (settings.preloadedConfig) {
|
|
40882
40882
|
this.applyRemoteConfig(settings.preloadedConfig);
|
|
40883
|
-
Log$
|
|
40883
|
+
Log$l.log('[DataConfig] Preloaded firmware config loaded');
|
|
40884
40884
|
return true;
|
|
40885
40885
|
}
|
|
40886
40886
|
if (manifestMode === 'external-only') {
|
|
40887
|
-
Log$
|
|
40887
|
+
Log$l.warn('[DataConfig] External firmware config is unavailable; SDK-managed networking remains disabled');
|
|
40888
40888
|
return false;
|
|
40889
40889
|
}
|
|
40890
40890
|
if (manifestMode !== 'sdk-managed') {
|
|
@@ -40897,7 +40897,7 @@ class DataManager {
|
|
|
40897
40897
|
let data = null;
|
|
40898
40898
|
let fetchMethod = 'none';
|
|
40899
40899
|
if (settings.configFetcher) {
|
|
40900
|
-
Log$
|
|
40900
|
+
Log$l.debug('[DataConfig] Trying client configFetcher...');
|
|
40901
40901
|
try {
|
|
40902
40902
|
data = yield settings.configFetcher(urlWithCache);
|
|
40903
40903
|
if (data) {
|
|
@@ -40905,40 +40905,40 @@ class DataManager {
|
|
|
40905
40905
|
}
|
|
40906
40906
|
}
|
|
40907
40907
|
catch (e) {
|
|
40908
|
-
Log$
|
|
40908
|
+
Log$l.warn('[DataConfig] Client configFetcher failed:', e);
|
|
40909
40909
|
}
|
|
40910
40910
|
}
|
|
40911
40911
|
if (!data) {
|
|
40912
|
-
Log$
|
|
40912
|
+
Log$l.debug('[DataConfig] Trying SDK-managed config request...');
|
|
40913
40913
|
try {
|
|
40914
40914
|
const response = yield axios__default["default"].get(urlWithCache, {
|
|
40915
40915
|
timeout: 7000,
|
|
40916
40916
|
});
|
|
40917
40917
|
data = response.data;
|
|
40918
40918
|
fetchMethod = 'axios';
|
|
40919
|
-
Log$
|
|
40919
|
+
Log$l.log('[DataConfig] SDK-managed config request succeeded');
|
|
40920
40920
|
}
|
|
40921
40921
|
catch (e) {
|
|
40922
|
-
Log$
|
|
40922
|
+
Log$l.warn('[DataConfig] SDK-managed config request failed:', e);
|
|
40923
40923
|
}
|
|
40924
40924
|
}
|
|
40925
40925
|
if (data) {
|
|
40926
40926
|
this.applyRemoteConfig(data);
|
|
40927
|
-
Log$
|
|
40927
|
+
Log$l.log(`[DataConfig] Config loaded successfully via [${fetchMethod}]`);
|
|
40928
40928
|
return true;
|
|
40929
40929
|
}
|
|
40930
|
-
Log$
|
|
40930
|
+
Log$l.warn('[DataConfig] All fetch methods failed, using built-in default config');
|
|
40931
40931
|
return false;
|
|
40932
40932
|
});
|
|
40933
40933
|
}
|
|
40934
40934
|
static applyRemoteConfig(data) {
|
|
40935
40935
|
const pro2Config = this.enrichProtocolV2FirmwareReleaseInfo(data.pro2, error => {
|
|
40936
40936
|
this.protocolV2ResourcesConfigError = error;
|
|
40937
|
-
Log$
|
|
40937
|
+
Log$l.warn('[DataConfig] Ignoring invalid Pro2 release resources config:', error);
|
|
40938
40938
|
});
|
|
40939
40939
|
const neoConfig = this.enrichProtocolV2FirmwareReleaseInfo(data.neo, error => {
|
|
40940
40940
|
this.protocolV2NeoResourcesConfigError = error;
|
|
40941
|
-
Log$
|
|
40941
|
+
Log$l.warn('[DataConfig] Ignoring invalid Neo release resources config:', error);
|
|
40942
40942
|
});
|
|
40943
40943
|
this.deviceMap = {
|
|
40944
40944
|
[hdShared.EDeviceType.Classic]: this.enrichFirmwareReleaseInfo(data.classic),
|
|
@@ -43108,7 +43108,7 @@ const getDefectiveDeviceInfo = (features) => {
|
|
|
43108
43108
|
};
|
|
43109
43109
|
};
|
|
43110
43110
|
|
|
43111
|
-
const Log$
|
|
43111
|
+
const Log$k = getLogger(exports.LoggerNames.DevicePool);
|
|
43112
43112
|
const canPathIdentifyDevice = (path) => !!path && !/^0+$/.test(path);
|
|
43113
43113
|
const getDiff = (current, descriptors) => {
|
|
43114
43114
|
const connected = descriptors.filter(d => current.find(x => x.path === d.path) === undefined);
|
|
@@ -43170,7 +43170,7 @@ class DevicePool extends events.exports {
|
|
|
43170
43170
|
yield this._checkDevicePool(initOptions, connectId);
|
|
43171
43171
|
return { devices, deviceList };
|
|
43172
43172
|
}
|
|
43173
|
-
Log$
|
|
43173
|
+
Log$k.debug('found device in cache, but path is different: ', connectId);
|
|
43174
43174
|
}
|
|
43175
43175
|
}
|
|
43176
43176
|
const matchedDescriptor = connectId
|
|
@@ -43273,7 +43273,7 @@ class DevicePool extends events.exports {
|
|
|
43273
43273
|
});
|
|
43274
43274
|
}
|
|
43275
43275
|
catch (error) {
|
|
43276
|
-
Log$
|
|
43276
|
+
Log$k.debug('Unable to refresh Protocol V2 device label during discovery', error);
|
|
43277
43277
|
}
|
|
43278
43278
|
});
|
|
43279
43279
|
}
|
|
@@ -43289,7 +43289,7 @@ class DevicePool extends events.exports {
|
|
|
43289
43289
|
const descriptor = this.connectedPool[i];
|
|
43290
43290
|
if (!connectId || descriptor.path === connectId) {
|
|
43291
43291
|
const device = yield this._createDevice(descriptor, initOptions);
|
|
43292
|
-
Log$
|
|
43292
|
+
Log$k.debug('emit DEVICE.CONNECT: ', device === null || device === void 0 ? void 0 : device.features);
|
|
43293
43293
|
this.emitter.emit(DEVICE.CONNECT, device);
|
|
43294
43294
|
this.connectedPool.splice(i, 1);
|
|
43295
43295
|
}
|
|
@@ -43311,9 +43311,9 @@ class DevicePool extends events.exports {
|
|
|
43311
43311
|
const diff = getDiff(this.current || [], upcoming);
|
|
43312
43312
|
this.upcoming = upcoming;
|
|
43313
43313
|
this.current = this.upcoming;
|
|
43314
|
-
Log$
|
|
43315
|
-
Log$
|
|
43316
|
-
Log$
|
|
43314
|
+
Log$k.debug('device pool -> current: ', this.current);
|
|
43315
|
+
Log$k.debug('device pool -> upcomming: ', this.upcoming);
|
|
43316
|
+
Log$k.debug('DeviceCache.reportDeviceChange diff: ', diff);
|
|
43317
43317
|
if (!diff.didUpdate) {
|
|
43318
43318
|
return;
|
|
43319
43319
|
}
|
|
@@ -43323,7 +43323,7 @@ class DevicePool extends events.exports {
|
|
|
43323
43323
|
this._addConnectedDeviceToPool(d);
|
|
43324
43324
|
return;
|
|
43325
43325
|
}
|
|
43326
|
-
Log$
|
|
43326
|
+
Log$k.debug('emit DEVICE.CONNECT: ', device.features);
|
|
43327
43327
|
this.emitter.emit(DEVICE.CONNECT, device);
|
|
43328
43328
|
});
|
|
43329
43329
|
diff.disconnected.forEach(d => {
|
|
@@ -43333,7 +43333,7 @@ class DevicePool extends events.exports {
|
|
|
43333
43333
|
this._addDisconnectedDeviceToPool(d);
|
|
43334
43334
|
return;
|
|
43335
43335
|
}
|
|
43336
|
-
Log$
|
|
43336
|
+
Log$k.debug('emit DEVICE.DISCONNECT: ', device.features);
|
|
43337
43337
|
device.markTransportDisconnected();
|
|
43338
43338
|
this.emitter.emit(DEVICE.DISCONNECT, device);
|
|
43339
43339
|
});
|
|
@@ -43371,7 +43371,7 @@ class DevicePool extends events.exports {
|
|
|
43371
43371
|
this.connectedPool = [];
|
|
43372
43372
|
this.disconnectPool = [];
|
|
43373
43373
|
this.devicesCache = {};
|
|
43374
|
-
Log$
|
|
43374
|
+
Log$k.debug('DevicePool state has been reset');
|
|
43375
43375
|
}
|
|
43376
43376
|
static dispose() {
|
|
43377
43377
|
this.resetState();
|
|
@@ -43385,7 +43385,7 @@ DevicePool.disconnectPool = [];
|
|
|
43385
43385
|
DevicePool.devicesCache = {};
|
|
43386
43386
|
DevicePool.emitter = new events.exports();
|
|
43387
43387
|
|
|
43388
|
-
const Log$
|
|
43388
|
+
const Log$j = getLogger(exports.LoggerNames.Transport);
|
|
43389
43389
|
const BleLogger = getLogger(exports.LoggerNames.HdBleTransport);
|
|
43390
43390
|
const HttpLogger = getLogger(exports.LoggerNames.HdTransportHttp);
|
|
43391
43391
|
const LowLevelLogger = getLogger(exports.LoggerNames.HdTransportLowLevel);
|
|
@@ -43395,7 +43395,7 @@ const WebUsbLogger = getLogger(exports.LoggerNames.HdTransportWebUsb);
|
|
|
43395
43395
|
const REACT_NATIVE_BLE_SCAN_TIMEOUT_MS = 3000;
|
|
43396
43396
|
class TransportManager {
|
|
43397
43397
|
static load() {
|
|
43398
|
-
Log$
|
|
43398
|
+
Log$j.debug('transport manager load');
|
|
43399
43399
|
this.defaultMessages = DataManager.getProtobufMessages();
|
|
43400
43400
|
this.currentMessages = this.defaultMessages;
|
|
43401
43401
|
this.protocolV1MessageSchema = 'v1CurrentSchema';
|
|
@@ -43404,14 +43404,14 @@ class TransportManager {
|
|
|
43404
43404
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43405
43405
|
try {
|
|
43406
43406
|
const env = DataManager.getSettings('env');
|
|
43407
|
-
Log$
|
|
43407
|
+
Log$j.debug('Initializing transports', env);
|
|
43408
43408
|
if (env === 'react-native') {
|
|
43409
43409
|
if (!this.reactNativeInit) {
|
|
43410
43410
|
yield this.transport.init(BleLogger, DevicePool.emitter);
|
|
43411
43411
|
this.reactNativeInit = true;
|
|
43412
43412
|
}
|
|
43413
43413
|
else {
|
|
43414
|
-
Log$
|
|
43414
|
+
Log$j.debug('React Native Do Not Initializing transports');
|
|
43415
43415
|
}
|
|
43416
43416
|
}
|
|
43417
43417
|
else if (env === 'node-usb') {
|
|
@@ -43432,15 +43432,15 @@ class TransportManager {
|
|
|
43432
43432
|
else {
|
|
43433
43433
|
yield this.transport.init(HttpLogger);
|
|
43434
43434
|
}
|
|
43435
|
-
Log$
|
|
43435
|
+
Log$j.debug('Configuring transports');
|
|
43436
43436
|
yield this.transport.configure(JSON.stringify(this.defaultMessages));
|
|
43437
43437
|
this.currentMessages = this.defaultMessages;
|
|
43438
43438
|
this.protocolV1MessageSchema = 'v1CurrentSchema';
|
|
43439
43439
|
yield this.configureProtocolV2Messages();
|
|
43440
|
-
Log$
|
|
43440
|
+
Log$j.debug('Configuring transports done');
|
|
43441
43441
|
}
|
|
43442
43442
|
catch (error) {
|
|
43443
|
-
Log$
|
|
43443
|
+
Log$j.debug('Initializing transports error: ', error);
|
|
43444
43444
|
if (error.code === 'ECONNABORTED') {
|
|
43445
43445
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BridgeTimeoutError);
|
|
43446
43446
|
}
|
|
@@ -43456,7 +43456,7 @@ class TransportManager {
|
|
|
43456
43456
|
if (this.currentMessages === messages || !messages) {
|
|
43457
43457
|
return;
|
|
43458
43458
|
}
|
|
43459
|
-
Log$
|
|
43459
|
+
Log$j.debug(`Reconfiguring transports Protocol V1 schema:${protocolV1MessageSchema}`);
|
|
43460
43460
|
try {
|
|
43461
43461
|
yield this.transport.configure(JSON.stringify(messages));
|
|
43462
43462
|
this.currentMessages = messages;
|
|
@@ -43482,9 +43482,9 @@ class TransportManager {
|
|
|
43482
43482
|
}
|
|
43483
43483
|
if (plugin) {
|
|
43484
43484
|
this.plugin = plugin;
|
|
43485
|
-
Log$
|
|
43485
|
+
Log$j.debug('set transport plugin: ', this.plugin);
|
|
43486
43486
|
}
|
|
43487
|
-
Log$
|
|
43487
|
+
Log$j.debug('set transport: ', this.transport.name, this.transport.version, this.transport.configured);
|
|
43488
43488
|
}
|
|
43489
43489
|
static getTransport() {
|
|
43490
43490
|
return this.transport;
|
|
@@ -43495,7 +43495,7 @@ class TransportManager {
|
|
|
43495
43495
|
const { configureProtocolV2 } = this.transport;
|
|
43496
43496
|
if (protocolV2Messages && typeof configureProtocolV2 === 'function') {
|
|
43497
43497
|
yield configureProtocolV2.call(this.transport, JSON.stringify(protocolV2Messages));
|
|
43498
|
-
Log$
|
|
43498
|
+
Log$j.debug('Protocol V2 messages configured');
|
|
43499
43499
|
}
|
|
43500
43500
|
});
|
|
43501
43501
|
}
|
|
@@ -43617,7 +43617,7 @@ const cancelDeviceWithInitialize = (device) => {
|
|
|
43617
43617
|
},
|
|
43618
43618
|
}));
|
|
43619
43619
|
};
|
|
43620
|
-
const Log$
|
|
43620
|
+
const Log$i = getLogger(exports.LoggerNames.DeviceCommands);
|
|
43621
43621
|
const LogCore = getLogger(exports.LoggerNames.Core);
|
|
43622
43622
|
class DeviceCommands {
|
|
43623
43623
|
constructor(device, mainId) {
|
|
@@ -43626,7 +43626,7 @@ class DeviceCommands {
|
|
|
43626
43626
|
this.transport = TransportManager.getTransport();
|
|
43627
43627
|
this.disposed = false;
|
|
43628
43628
|
this.instanceId = generateInstanceId('DeviceCommands', device.sdkInstanceId);
|
|
43629
|
-
Log$
|
|
43629
|
+
Log$i.debug(`[DeviceCommands] Created: ${this.instanceId}, device: ${this.device.instanceId}`);
|
|
43630
43630
|
}
|
|
43631
43631
|
dispose(_cancelRequest) {
|
|
43632
43632
|
var _a, _b;
|
|
@@ -43702,7 +43702,7 @@ class DeviceCommands {
|
|
|
43702
43702
|
this.transport.name === 'ReactNativeBleTransport' &&
|
|
43703
43703
|
this.transport.disconnect) {
|
|
43704
43704
|
yield this.transport.disconnect(this.mainId).catch(error => {
|
|
43705
|
-
Log$
|
|
43705
|
+
Log$i.debug('BLE cancellation timeout disconnect error (ignored)', error);
|
|
43706
43706
|
});
|
|
43707
43707
|
}
|
|
43708
43708
|
if (this.callPromise === activeCall) {
|
|
@@ -43717,7 +43717,7 @@ class DeviceCommands {
|
|
|
43717
43717
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43718
43718
|
const shouldReduceDebug = shouldReduceDebugForCall(type);
|
|
43719
43719
|
if (!shouldReduceDebug) {
|
|
43720
|
-
Log$
|
|
43720
|
+
Log$i.debug('[DeviceCommands] [call] Sending', type, hdTransport.getSafeTransportLogPayload(msg !== null && msg !== void 0 ? msg : {}, type));
|
|
43721
43721
|
}
|
|
43722
43722
|
try {
|
|
43723
43723
|
const promise = this.transport.call(this.mainId, type, msg !== null && msg !== void 0 ? msg : {}, options);
|
|
@@ -43776,10 +43776,10 @@ class DeviceCommands {
|
|
|
43776
43776
|
assertType(response, resType);
|
|
43777
43777
|
}
|
|
43778
43778
|
catch (error) {
|
|
43779
|
-
Log$
|
|
43779
|
+
Log$i.debug('DeviceCommands typedcall error: ', error);
|
|
43780
43780
|
if (error instanceof hdShared.HardwareError) {
|
|
43781
43781
|
if (error.errorCode === hdShared.HardwareErrorCode.ResponseUnexpectTypeError) {
|
|
43782
|
-
Log$
|
|
43782
|
+
Log$i.debug('[DeviceCommands] [typedCall] Unexpected response type', {
|
|
43783
43783
|
request: type,
|
|
43784
43784
|
expected: resType,
|
|
43785
43785
|
received: response.type,
|
|
@@ -43813,7 +43813,7 @@ class DeviceCommands {
|
|
|
43813
43813
|
var _a;
|
|
43814
43814
|
try {
|
|
43815
43815
|
if (!shouldReduceDebugForCall(callType)) {
|
|
43816
|
-
Log$
|
|
43816
|
+
Log$i.debug('_filterCommonTypes: ', {
|
|
43817
43817
|
request: callType,
|
|
43818
43818
|
response: {
|
|
43819
43819
|
type: res.type,
|
|
@@ -44033,7 +44033,7 @@ class DeviceCommands {
|
|
|
44033
44033
|
reject(error);
|
|
44034
44034
|
});
|
|
44035
44035
|
const listenerCount = this.device.listenerCount(DEVICE.PIN);
|
|
44036
|
-
Log$
|
|
44036
|
+
Log$i.debug(`[${this.instanceId}] _promptPin called`, {
|
|
44037
44037
|
responseID: this.currentResponseID,
|
|
44038
44038
|
deviceInstanceId: this.device.instanceId,
|
|
44039
44039
|
listenerCount,
|
|
@@ -45090,7 +45090,7 @@ const parseRunOptions = (options) => {
|
|
|
45090
45090
|
options = {};
|
|
45091
45091
|
return options;
|
|
45092
45092
|
};
|
|
45093
|
-
const Log$
|
|
45093
|
+
const Log$h = getLogger(exports.LoggerNames.Device);
|
|
45094
45094
|
const isProtocolV2DeviceStatusUnsupportedError = (error) => {
|
|
45095
45095
|
var _a, _b, _c;
|
|
45096
45096
|
if (error instanceof hdShared.HardwareError) {
|
|
@@ -45151,7 +45151,7 @@ class Device extends events.exports {
|
|
|
45151
45151
|
this.sdkInstanceId = sdkInstanceId;
|
|
45152
45152
|
this.instanceId = generateInstanceId('Device', this.sdkInstanceId);
|
|
45153
45153
|
this.createdAt = Date.now();
|
|
45154
|
-
Log$
|
|
45154
|
+
Log$h.debug(`[Device] Created: ${this.instanceId}${this.sdkInstanceId ? ` for SDK: ${this.sdkInstanceId}` : ''}`);
|
|
45155
45155
|
}
|
|
45156
45156
|
static fromDescriptor(originalDescriptor, sdkInstanceId) {
|
|
45157
45157
|
const descriptor = Object.assign({}, originalDescriptor);
|
|
@@ -45242,12 +45242,12 @@ class Device extends events.exports {
|
|
|
45242
45242
|
if (DataManager.isBleConnect(env)) {
|
|
45243
45243
|
acquireResult = yield ((_a = this.deviceConnector) === null || _a === void 0 ? void 0 : _a.acquire(this.originalDescriptor.id, undefined, true, strictProtocol, undefined));
|
|
45244
45244
|
this.mainId = (_b = acquireResult === null || acquireResult === void 0 ? void 0 : acquireResult.uuid) !== null && _b !== void 0 ? _b : '';
|
|
45245
|
-
Log$
|
|
45245
|
+
Log$h.debug('Expected uuid:', this.mainId);
|
|
45246
45246
|
}
|
|
45247
45247
|
else {
|
|
45248
45248
|
acquireResult = yield ((_c = this.deviceConnector) === null || _c === void 0 ? void 0 : _c.acquire(this.originalDescriptor.path, this.originalDescriptor.session, undefined, strictProtocol, undefined));
|
|
45249
45249
|
this.mainId = acquireResult;
|
|
45250
|
-
Log$
|
|
45250
|
+
Log$h.debug('Expected session id:', this.mainId);
|
|
45251
45251
|
}
|
|
45252
45252
|
const detectedProtocol = (_d = acquireResult === null || acquireResult === void 0 ? void 0 : acquireResult.protocolType) !== null && _d !== void 0 ? _d : (_f = (_e = TransportManager.transport) === null || _e === void 0 ? void 0 : _e.getProtocolType) === null || _f === void 0 ? void 0 : _f.call(_e, DataManager.isBleConnect(env) ? this.originalDescriptor.id : this.originalDescriptor.path);
|
|
45253
45253
|
if ((options === null || options === void 0 ? void 0 : options.forceProtocolDetection) && !detectedProtocol) {
|
|
@@ -45274,7 +45274,7 @@ class Device extends events.exports {
|
|
|
45274
45274
|
yield ((_j = (_h = this.deviceConnector) === null || _h === void 0 ? void 0 : _h.release) === null || _j === void 0 ? void 0 : _j.call(_h, failedSession, false));
|
|
45275
45275
|
}
|
|
45276
45276
|
catch (releaseError) {
|
|
45277
|
-
Log$
|
|
45277
|
+
Log$h.debug('Failed to release an unsuccessful protocol probe', releaseError);
|
|
45278
45278
|
}
|
|
45279
45279
|
}
|
|
45280
45280
|
if (!DataManager.isBleConnect(env)) {
|
|
@@ -45303,11 +45303,11 @@ class Device extends events.exports {
|
|
|
45303
45303
|
(this.mainId && DataManager.isBleConnect(env))) {
|
|
45304
45304
|
if (this.pendingCallbackPromise) {
|
|
45305
45305
|
try {
|
|
45306
|
-
Log$
|
|
45306
|
+
Log$h.debug('Waiting for callback tasks to complete before releasing device (in release method)');
|
|
45307
45307
|
yield this.pendingCallbackPromise.promise;
|
|
45308
45308
|
}
|
|
45309
45309
|
catch (error) {
|
|
45310
|
-
Log$
|
|
45310
|
+
Log$h.error('Error waiting for callback tasks in release method:', error);
|
|
45311
45311
|
}
|
|
45312
45312
|
}
|
|
45313
45313
|
if (this.commands) {
|
|
@@ -45326,7 +45326,7 @@ class Device extends events.exports {
|
|
|
45326
45326
|
this.updateDescriptor({ session: null });
|
|
45327
45327
|
}
|
|
45328
45328
|
catch (err) {
|
|
45329
|
-
Log$
|
|
45329
|
+
Log$h.error('[Device] release error: ', err);
|
|
45330
45330
|
}
|
|
45331
45331
|
finally {
|
|
45332
45332
|
this.needReloadDevice = true;
|
|
@@ -45531,7 +45531,7 @@ class Device extends events.exports {
|
|
|
45531
45531
|
});
|
|
45532
45532
|
}
|
|
45533
45533
|
getInternalState(_deviceId) {
|
|
45534
|
-
Log$
|
|
45534
|
+
Log$h.debug('getInternalState session param: ', `device_id: ${_deviceId}`, `currentDeviceId: ${this.getCurrentDeviceId()}`, `hasPassphraseState: ${Boolean(this.passphraseState)}`);
|
|
45535
45535
|
const deviceId = this.getSessionCacheDeviceKey(_deviceId);
|
|
45536
45536
|
if (!deviceId)
|
|
45537
45537
|
return undefined;
|
|
@@ -45546,7 +45546,7 @@ class Device extends events.exports {
|
|
|
45546
45546
|
return deviceWalletSessionStore.getStandard(deviceId);
|
|
45547
45547
|
}
|
|
45548
45548
|
updateInternalState(enablePassphrase, passphraseState, deviceId, sessionId = null, featuresSessionId = null, walletType = 'hidden') {
|
|
45549
|
-
Log$
|
|
45549
|
+
Log$h.debug('updateInternalState session param: ', `device_id: ${deviceId}`, `enablePassphrase: ${enablePassphrase}`, `hasPassphraseState: ${Boolean(passphraseState)}`, `hasSessionId: ${Boolean(sessionId)}`, `hasFeaturesSessionId: ${Boolean(featuresSessionId)}`);
|
|
45550
45550
|
const cacheDeviceKey = this.getSessionCacheDeviceKey(deviceId);
|
|
45551
45551
|
if (!cacheDeviceKey)
|
|
45552
45552
|
return;
|
|
@@ -45562,7 +45562,7 @@ class Device extends events.exports {
|
|
|
45562
45562
|
deviceWalletSessionStore.deletePending(cacheDeviceKey);
|
|
45563
45563
|
}
|
|
45564
45564
|
setInternalState(state, initSession) {
|
|
45565
|
-
Log$
|
|
45565
|
+
Log$h.debug('setInternalState session param: ', `hasState: ${Boolean(state)}`, `initSession: ${initSession}`, `deviceId: ${this.getCurrentDeviceId()}`, `hasPassphraseState: ${Boolean(this.passphraseState)}`);
|
|
45566
45566
|
if (!this.passphraseState && !initSession)
|
|
45567
45567
|
return;
|
|
45568
45568
|
const deviceId = this.getSessionCacheDeviceKey();
|
|
@@ -45576,7 +45576,7 @@ class Device extends events.exports {
|
|
|
45576
45576
|
}
|
|
45577
45577
|
}
|
|
45578
45578
|
clearInternalState(_deviceId) {
|
|
45579
|
-
Log$
|
|
45579
|
+
Log$h.debug('clearInternalState param: ', _deviceId);
|
|
45580
45580
|
const deviceId = this.getSessionCacheDeviceKey(_deviceId);
|
|
45581
45581
|
if (!deviceId)
|
|
45582
45582
|
return;
|
|
@@ -45644,14 +45644,14 @@ class Device extends events.exports {
|
|
|
45644
45644
|
yield callInitialize(payload, options === null || options === void 0 ? void 0 : options.initSession);
|
|
45645
45645
|
}
|
|
45646
45646
|
catch (error) {
|
|
45647
|
-
Log$
|
|
45647
|
+
Log$h.error('Initialization failed:', error);
|
|
45648
45648
|
throw error;
|
|
45649
45649
|
}
|
|
45650
45650
|
});
|
|
45651
45651
|
}
|
|
45652
45652
|
_initializeProtocolV2(options) {
|
|
45653
45653
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45654
|
-
Log$
|
|
45654
|
+
Log$h.debug('Initialize device via Protocol V2 features adapter');
|
|
45655
45655
|
try {
|
|
45656
45656
|
const deviceInfo = yield requestProtocolV2DeviceInfo({
|
|
45657
45657
|
commands: this.commands,
|
|
@@ -45660,7 +45660,7 @@ class Device extends events.exports {
|
|
|
45660
45660
|
yield this.probeProtocolV2RuntimeState(deviceInfo, options === null || options === void 0 ? void 0 : options.protocolV2DeviceInfoTimeoutMs);
|
|
45661
45661
|
}
|
|
45662
45662
|
catch (error) {
|
|
45663
|
-
Log$
|
|
45663
|
+
Log$h.error('Protocol V2 initialization failed:', error);
|
|
45664
45664
|
throw error;
|
|
45665
45665
|
}
|
|
45666
45666
|
});
|
|
@@ -45774,7 +45774,7 @@ class Device extends events.exports {
|
|
|
45774
45774
|
source,
|
|
45775
45775
|
changedKeys: result.changedKeys,
|
|
45776
45776
|
};
|
|
45777
|
-
Log$
|
|
45777
|
+
Log$h.debug('Device state updated', {
|
|
45778
45778
|
source,
|
|
45779
45779
|
revision: result.revision,
|
|
45780
45780
|
changedKeyCount: result.changedKeys.length,
|
|
@@ -45998,7 +45998,7 @@ class Device extends events.exports {
|
|
|
45998
45998
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45999
45999
|
if (this.runPromise) {
|
|
46000
46000
|
yield this.interruptionFromOutside();
|
|
46001
|
-
Log$
|
|
46001
|
+
Log$h.debug('[Device] run error:', 'Device is running, but will cancel previous operate');
|
|
46002
46002
|
}
|
|
46003
46003
|
options = parseRunOptions(options);
|
|
46004
46004
|
const runPromise = hdShared.createDeferred();
|
|
@@ -46083,7 +46083,7 @@ class Device extends events.exports {
|
|
|
46083
46083
|
yield ((_a = this.deviceConnector) === null || _a === void 0 ? void 0 : _a.disconnect(this.mainId));
|
|
46084
46084
|
}
|
|
46085
46085
|
yield this.release();
|
|
46086
|
-
Log$
|
|
46086
|
+
Log$h.debug(`error code ${e.errorCode} release device, mainId: ${this.mainId}`);
|
|
46087
46087
|
}
|
|
46088
46088
|
clearRunPromise();
|
|
46089
46089
|
return;
|
|
@@ -46093,7 +46093,7 @@ class Device extends events.exports {
|
|
|
46093
46093
|
options.keepSession === false) {
|
|
46094
46094
|
this.keepSession = false;
|
|
46095
46095
|
yield this.release();
|
|
46096
|
-
Log$
|
|
46096
|
+
Log$h.debug('release device, mainId: ', this.mainId);
|
|
46097
46097
|
}
|
|
46098
46098
|
runPromise.resolve();
|
|
46099
46099
|
clearRunPromise();
|
|
@@ -46122,7 +46122,7 @@ class Device extends events.exports {
|
|
|
46122
46122
|
DataManager.isBleConnect(DataManager.getSettings('env')) &&
|
|
46123
46123
|
this.hasDeviceAcquire()) {
|
|
46124
46124
|
yield ((_b = (_a = this.commands) === null || _a === void 0 ? void 0 : _a.cancelDevice) === null || _b === void 0 ? void 0 : _b.call(_a).catch(cancelError => {
|
|
46125
|
-
Log$
|
|
46125
|
+
Log$h.debug('Protocol V2 BLE fallback cancel error', cancelError);
|
|
46126
46126
|
}));
|
|
46127
46127
|
}
|
|
46128
46128
|
yield ((_c = this.commands) === null || _c === void 0 ? void 0 : _c.cancel());
|
|
@@ -46136,7 +46136,7 @@ class Device extends events.exports {
|
|
|
46136
46136
|
setCancelableAction(callback) {
|
|
46137
46137
|
this.cancelableAction = (e) => callback(e)
|
|
46138
46138
|
.catch(e2 => {
|
|
46139
|
-
Log$
|
|
46139
|
+
Log$h.debug('cancelableAction error', e2);
|
|
46140
46140
|
})
|
|
46141
46141
|
.finally(() => {
|
|
46142
46142
|
this.clearCancelableAction();
|
|
@@ -46419,7 +46419,7 @@ class Device extends events.exports {
|
|
|
46419
46419
|
expectedPassphraseState &&
|
|
46420
46420
|
expectedPassphraseState !== newPassphraseState;
|
|
46421
46421
|
const passphraseStateMismatch = !!expectedPassphraseState && expectedPassphraseState !== newPassphraseState;
|
|
46422
|
-
Log$
|
|
46422
|
+
Log$h.debug('Check passphrase state safety: ', {
|
|
46423
46423
|
hasExpectedPassphraseState: Boolean(expectedPassphraseState),
|
|
46424
46424
|
hasNewPassphraseState: Boolean(newPassphraseState),
|
|
46425
46425
|
passphraseStateMatches: Boolean(expectedPassphraseState) && expectedPassphraseState === newPassphraseState,
|
|
@@ -46557,7 +46557,7 @@ const getBootloaderReleaseInfo = ({ features, willUpdateFirmwareVersion, firmwar
|
|
|
46557
46557
|
};
|
|
46558
46558
|
};
|
|
46559
46559
|
|
|
46560
|
-
const Log$
|
|
46560
|
+
const Log$g = getLogger(exports.LoggerNames.Method);
|
|
46561
46561
|
const isEvmLedgerLegacyPathWithHighIndex = (path) => {
|
|
46562
46562
|
let addressN;
|
|
46563
46563
|
if (typeof path === 'string') {
|
|
@@ -46641,7 +46641,7 @@ class BaseMethod {
|
|
|
46641
46641
|
setContext(context) {
|
|
46642
46642
|
this.sdkInstanceId = context.sdkInstanceId;
|
|
46643
46643
|
this.instanceId = generateInstanceId('Method', this.sdkInstanceId);
|
|
46644
|
-
Log$
|
|
46644
|
+
Log$g.debug(`[BaseMethod] Created: ${this.instanceId}, method: ${this.name}, SDK: ${this.sdkInstanceId}`);
|
|
46645
46645
|
}
|
|
46646
46646
|
setDevice(device) {
|
|
46647
46647
|
var _a, _b;
|
|
@@ -46661,7 +46661,7 @@ class BaseMethod {
|
|
|
46661
46661
|
if (device.commands) {
|
|
46662
46662
|
device.commands.currentResponseID = this.responseID;
|
|
46663
46663
|
}
|
|
46664
|
-
Log$
|
|
46664
|
+
Log$g.debug(`[${this.instanceId}] setDevice: ${device.instanceId}, commands: ${(_b = device.commands) === null || _b === void 0 ? void 0 : _b.instanceId}`);
|
|
46665
46665
|
}
|
|
46666
46666
|
checkFirmwareRelease() {
|
|
46667
46667
|
if (!this.device || this.device.isProtocolV2())
|
|
@@ -46736,7 +46736,7 @@ class BaseMethod {
|
|
|
46736
46736
|
checkFlag = true;
|
|
46737
46737
|
}
|
|
46738
46738
|
if (checkFlag && this.device.getCurrentSafetyChecks() === hdTransport.Enum_SafetyCheckLevel.Strict) {
|
|
46739
|
-
Log$
|
|
46739
|
+
Log$g.debug('will change safety_checks level');
|
|
46740
46740
|
yield this.device.commands.typedCall('ApplySettings', 'Success', {
|
|
46741
46741
|
safety_checks: hdTransport.Enum_SafetyCheckLevel.PromptTemporarily,
|
|
46742
46742
|
});
|
|
@@ -46812,7 +46812,7 @@ class Ping extends BaseMethod {
|
|
|
46812
46812
|
}
|
|
46813
46813
|
}
|
|
46814
46814
|
|
|
46815
|
-
const Log$
|
|
46815
|
+
const Log$f = getLogger(exports.LoggerNames.Core);
|
|
46816
46816
|
const parseInitOptions$1 = (payload) => ({
|
|
46817
46817
|
initSession: payload === null || payload === void 0 ? void 0 : payload.initSession,
|
|
46818
46818
|
passphraseState: payload === null || payload === void 0 ? void 0 : payload.passphraseState,
|
|
@@ -46838,14 +46838,14 @@ class PreInitialize extends BaseMethod {
|
|
|
46838
46838
|
}
|
|
46839
46839
|
catch (_a) {
|
|
46840
46840
|
this.device.clearPreInitialized();
|
|
46841
|
-
Log$
|
|
46841
|
+
Log$f.debug('[PRE-INIT][FAILED]');
|
|
46842
46842
|
return false;
|
|
46843
46843
|
}
|
|
46844
46844
|
});
|
|
46845
46845
|
}
|
|
46846
46846
|
}
|
|
46847
46847
|
|
|
46848
|
-
const Log$
|
|
46848
|
+
const Log$e = getLogger(exports.LoggerNames.DevicePool);
|
|
46849
46849
|
class SearchDevices extends BaseMethod {
|
|
46850
46850
|
init() {
|
|
46851
46851
|
this.useDevice = false;
|
|
@@ -46887,7 +46887,7 @@ class SearchDevices extends BaseMethod {
|
|
|
46887
46887
|
const errorCode = error && typeof error === 'object' && 'errorCode' in error
|
|
46888
46888
|
? error.errorCode
|
|
46889
46889
|
: undefined;
|
|
46890
|
-
Log$
|
|
46890
|
+
Log$e.debug('Skip unavailable device during search', Object.assign({ path: descriptor.path }, (errorCode !== undefined ? { errorCode } : {})));
|
|
46891
46891
|
}
|
|
46892
46892
|
}
|
|
46893
46893
|
return deviceList.map(device => device.toMessageObject());
|
|
@@ -47789,7 +47789,7 @@ function buildProtocolV2FirmwareRelease({ currentVersions, currentVerification =
|
|
|
47789
47789
|
release,
|
|
47790
47790
|
};
|
|
47791
47791
|
}
|
|
47792
|
-
const Log$
|
|
47792
|
+
const Log$d = getLogger(exports.LoggerNames.Method);
|
|
47793
47793
|
class CheckAllFirmwareRelease extends BaseMethod {
|
|
47794
47794
|
getSupportedProtocols() {
|
|
47795
47795
|
return ['V1', 'V2'];
|
|
@@ -47850,7 +47850,7 @@ class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
47850
47850
|
((_c = error.params) === null || _c === void 0 ? void 0 : _c.firmwareUpdateCode) !== 'FirmwarePlanInvalid') {
|
|
47851
47851
|
throw error;
|
|
47852
47852
|
}
|
|
47853
|
-
Log$
|
|
47853
|
+
Log$d.warn('[CheckAllFirmwareRelease] Optional firmware Plan is unavailable; using the legacy release result');
|
|
47854
47854
|
firmwareUpdatePlan = undefined;
|
|
47855
47855
|
}
|
|
47856
47856
|
return {
|
|
@@ -47936,7 +47936,7 @@ class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
47936
47936
|
((_a = error.params) === null || _a === void 0 ? void 0 : _a.firmwareUpdateCode) !== 'FirmwarePlanInvalid') {
|
|
47937
47937
|
throw error;
|
|
47938
47938
|
}
|
|
47939
|
-
Log$
|
|
47939
|
+
Log$d.warn('[CheckAllFirmwareRelease] Optional Protocol V2 firmware Plan is unavailable; using the release result');
|
|
47940
47940
|
firmwareUpdatePlan = undefined;
|
|
47941
47941
|
}
|
|
47942
47942
|
const firmwarePlan = summarizeProtocolV2FirmwareRelease(plan, PROTOCOL_V2_MAIN_FIRMWARE_TARGETS);
|
|
@@ -48526,14 +48526,7 @@ class DeviceSettings extends BaseMethod {
|
|
|
48526
48526
|
const res = yield this.device.commands.typedCall('DeviceSettingsPageShow', 'Success', {
|
|
48527
48527
|
page: hdTransport.DeviceSettingsPage.DevicePassphrase,
|
|
48528
48528
|
});
|
|
48529
|
-
|
|
48530
|
-
const lockedAfterDisabling = requestedPassphrase === false &&
|
|
48531
|
-
current.status.unlocked === true &&
|
|
48532
|
-
updated.status.unlocked === false;
|
|
48533
|
-
if (updated.status.passphraseProtection !== requestedPassphrase &&
|
|
48534
|
-
!lockedAfterDisabling) {
|
|
48535
|
-
throw hdShared.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Protocol V2 passphrase setting did not reach the requested value.');
|
|
48536
|
-
}
|
|
48529
|
+
yield refreshStatusAndSettings();
|
|
48537
48530
|
return res.message;
|
|
48538
48531
|
}
|
|
48539
48532
|
if (requestedAirgap !== undefined) {
|
|
@@ -48922,7 +48915,7 @@ const getInfo = ({ features, updateType, targetVersion, firmwareType }) => {
|
|
|
48922
48915
|
const NEW_BOOT_UPRATE_FIRMWARE_VERSION = '2.4.5';
|
|
48923
48916
|
const SESSION_ERROR$3 = 'session not found';
|
|
48924
48917
|
const FIRMWARE_UPDATE_CONFIRM$1 = 'Firmware install confirmed';
|
|
48925
|
-
const Log$
|
|
48918
|
+
const Log$c = getLogger(exports.LoggerNames.Method);
|
|
48926
48919
|
const isDeviceDisconnectedError$1 = (error) => {
|
|
48927
48920
|
const message = error instanceof Error ? error.message : String(error !== null && error !== void 0 ? error : '');
|
|
48928
48921
|
return (message.includes('device was disconnected') ||
|
|
@@ -48977,13 +48970,13 @@ const uploadFirmwareFromSource = (updateType, typedCall, postMessage, device, so
|
|
|
48977
48970
|
const newFeatures = yield typedCall('GetFeatures', 'Features', {});
|
|
48978
48971
|
const deviceBootloaderVersion = getDeviceBootloaderVersion(buildProtocolV1FeaturesPayload(newFeatures.message, device.features)).join('.');
|
|
48979
48972
|
const supportUpgradeFileHeader = semver__default["default"].gte(deviceBootloaderVersion, '2.1.0');
|
|
48980
|
-
Log$
|
|
48973
|
+
Log$c.debug('supportUpgradeFileHeader:', supportUpgradeFileHeader);
|
|
48981
48974
|
if (supportUpgradeFileHeader) {
|
|
48982
48975
|
const HEADER_SIZE = 1024;
|
|
48983
48976
|
if (source.size < HEADER_SIZE) {
|
|
48984
48977
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `firmware payload too small: ${source.size} bytes, expected at least ${HEADER_SIZE} bytes`);
|
|
48985
48978
|
}
|
|
48986
|
-
Log$
|
|
48979
|
+
Log$c.debug('Uploading firmware header:', {
|
|
48987
48980
|
size: HEADER_SIZE,
|
|
48988
48981
|
totalSize: source.size,
|
|
48989
48982
|
});
|
|
@@ -48995,18 +48988,18 @@ const uploadFirmwareFromSource = (updateType, typedCall, postMessage, device, so
|
|
|
48995
48988
|
});
|
|
48996
48989
|
const isUnknownMessage = (_b = (_a = headerRes.message) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.includes('Failure_UnknownMessage');
|
|
48997
48990
|
if (headerRes.type !== 'Success' && !isUnknownMessage) {
|
|
48998
|
-
Log$
|
|
48991
|
+
Log$c.error('Firmware header upload failed:', headerRes);
|
|
48999
48992
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'failed to upload firmware header');
|
|
49000
48993
|
}
|
|
49001
48994
|
}
|
|
49002
48995
|
catch (error) {
|
|
49003
|
-
Log$
|
|
48996
|
+
Log$c.error('Firmware header upload failed:', error);
|
|
49004
48997
|
const message = error instanceof Error ? error.message : String(error !== null && error !== void 0 ? error : '');
|
|
49005
48998
|
if (!message.includes('Failure_UnknownMessage')) {
|
|
49006
48999
|
throw error;
|
|
49007
49000
|
}
|
|
49008
49001
|
}
|
|
49009
|
-
Log$
|
|
49002
|
+
Log$c.debug('Firmware header uploaded successfully');
|
|
49010
49003
|
}
|
|
49011
49004
|
}
|
|
49012
49005
|
const eraseCommand = isFirmware ? 'FirmwareErase' : 'FirmwareErase_ex';
|
|
@@ -49025,7 +49018,7 @@ const uploadFirmwareFromSource = (updateType, typedCall, postMessage, device, so
|
|
|
49025
49018
|
}
|
|
49026
49019
|
catch (error) {
|
|
49027
49020
|
if (isDeviceDisconnectedError$1(error)) {
|
|
49028
|
-
Log$
|
|
49021
|
+
Log$c.log('Rebooting device');
|
|
49029
49022
|
updateResponse = {
|
|
49030
49023
|
type: 'Success',
|
|
49031
49024
|
message: { message: FIRMWARE_UPDATE_CONFIRM$1 },
|
|
@@ -49123,7 +49116,7 @@ const newTouchUpdateProcess = (updateType, postMessage, device, source, rebootOn
|
|
|
49123
49116
|
}
|
|
49124
49117
|
catch (error) {
|
|
49125
49118
|
if (isDeviceDisconnectedError$1(error)) {
|
|
49126
|
-
Log$
|
|
49119
|
+
Log$c.log('Rebooting device');
|
|
49127
49120
|
response = {
|
|
49128
49121
|
type: 'Success',
|
|
49129
49122
|
message: { message: FIRMWARE_UPDATE_CONFIRM$1 },
|
|
@@ -49154,7 +49147,7 @@ const newTouchUpdateProcess = (updateType, postMessage, device, source, rebootOn
|
|
|
49154
49147
|
]);
|
|
49155
49148
|
}
|
|
49156
49149
|
catch (e) {
|
|
49157
|
-
Log$
|
|
49150
|
+
Log$c.log('catch Bluetooth error when device is restarting: ', e);
|
|
49158
49151
|
}
|
|
49159
49152
|
}
|
|
49160
49153
|
else {
|
|
@@ -49175,7 +49168,7 @@ const newTouchUpdateProcess = (updateType, postMessage, device, source, rebootOn
|
|
|
49175
49168
|
}
|
|
49176
49169
|
catch (error) {
|
|
49177
49170
|
console.error('Device reconnect failed: ', error);
|
|
49178
|
-
Log$
|
|
49171
|
+
Log$c.error('Device reconnect failed:', error);
|
|
49179
49172
|
yield wait(1000);
|
|
49180
49173
|
}
|
|
49181
49174
|
}
|
|
@@ -49215,7 +49208,7 @@ const emmcFileWriteWithRetry = (device, filePath, chunkLength, offset, chunk, ov
|
|
|
49215
49208
|
return result;
|
|
49216
49209
|
}
|
|
49217
49210
|
catch (error) {
|
|
49218
|
-
Log$
|
|
49211
|
+
Log$c.error(`emmcWrite error: `, error);
|
|
49219
49212
|
retryCount--;
|
|
49220
49213
|
if (retryCount === 0) {
|
|
49221
49214
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.EmmcFileWriteFirmwareError, 'transfer data error');
|
|
@@ -49410,7 +49403,7 @@ class DeviceFullyUploadResource extends BaseMethod {
|
|
|
49410
49403
|
}
|
|
49411
49404
|
}
|
|
49412
49405
|
|
|
49413
|
-
const Log$
|
|
49406
|
+
const Log$b = getLogger(exports.LoggerNames.Method);
|
|
49414
49407
|
const SESSION_ERROR$2 = 'session not found';
|
|
49415
49408
|
const FIRMWARE_UPDATE_CONFIRM = 'Firmware install confirmed';
|
|
49416
49409
|
const BOOTLOADER_POLL_INITIALIZE_TIMEOUT_MS = 5000;
|
|
@@ -49488,7 +49481,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49488
49481
|
const env = DataManager.getSettings('env');
|
|
49489
49482
|
const isBleReconnect = connectId && DataManager.isBleConnect(env);
|
|
49490
49483
|
let bleProbeInFlight = false;
|
|
49491
|
-
Log$
|
|
49484
|
+
Log$b.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
|
|
49492
49485
|
let isFirstCheck = true;
|
|
49493
49486
|
let checkCount = 0;
|
|
49494
49487
|
let hasPromptedWebDevice = false;
|
|
@@ -49522,10 +49515,10 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49522
49515
|
if (isFinished || isPromptingWebDevice)
|
|
49523
49516
|
return;
|
|
49524
49517
|
checkCount += 1;
|
|
49525
|
-
Log$
|
|
49518
|
+
Log$b.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] isFirstCheck: ', isFirstCheck);
|
|
49526
49519
|
if (isTouchOrProDevice && isFirstCheck) {
|
|
49527
49520
|
isFirstCheck = false;
|
|
49528
|
-
Log$
|
|
49521
|
+
Log$b.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] wait 3000ms');
|
|
49529
49522
|
yield wait(3000);
|
|
49530
49523
|
}
|
|
49531
49524
|
if (checkCount > 4 &&
|
|
@@ -49549,7 +49542,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49549
49542
|
catch (e) {
|
|
49550
49543
|
isFinished = true;
|
|
49551
49544
|
clearPollingTimers();
|
|
49552
|
-
Log$
|
|
49545
|
+
Log$b.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] _promptDeviceInBootloaderForWebDevice failed: ', e);
|
|
49553
49546
|
(_c = this.checkPromise) === null || _c === void 0 ? void 0 : _c.reject(e);
|
|
49554
49547
|
}
|
|
49555
49548
|
finally {
|
|
@@ -49571,7 +49564,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49571
49564
|
}
|
|
49572
49565
|
}
|
|
49573
49566
|
catch (e) {
|
|
49574
|
-
Log$
|
|
49567
|
+
Log$b.log('catch Bluetooth error when device is restarting: ', e);
|
|
49575
49568
|
}
|
|
49576
49569
|
finally {
|
|
49577
49570
|
bleProbeInFlight = false;
|
|
@@ -49674,7 +49667,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49674
49667
|
}
|
|
49675
49668
|
catch (error) {
|
|
49676
49669
|
if (isDeviceDisconnectedError(error)) {
|
|
49677
|
-
Log$
|
|
49670
|
+
Log$b.log('Rebooting device');
|
|
49678
49671
|
updateResponse = {
|
|
49679
49672
|
type: 'Success',
|
|
49680
49673
|
message: { message: FIRMWARE_UPDATE_CONFIRM },
|
|
@@ -49790,7 +49783,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49790
49783
|
return result;
|
|
49791
49784
|
}
|
|
49792
49785
|
catch (error) {
|
|
49793
|
-
Log$
|
|
49786
|
+
Log$b.error(`emmcWrite error: `, error);
|
|
49794
49787
|
retryCount--;
|
|
49795
49788
|
if (retryCount === 0) {
|
|
49796
49789
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.EmmcFileWriteFirmwareError, 'transfer data error');
|
|
@@ -50097,7 +50090,7 @@ class GetNextU2FCounter extends BaseMethod {
|
|
|
50097
50090
|
}
|
|
50098
50091
|
}
|
|
50099
50092
|
|
|
50100
|
-
const Log$
|
|
50093
|
+
const Log$a = getLogger(exports.LoggerNames.Method);
|
|
50101
50094
|
class FirmwareUpdate extends BaseMethod {
|
|
50102
50095
|
constructor() {
|
|
50103
50096
|
super(...arguments);
|
|
@@ -50136,7 +50129,7 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
50136
50129
|
const env = DataManager.getSettings('env');
|
|
50137
50130
|
const isBleReconnect = connectId && DataManager.isBleConnect(env);
|
|
50138
50131
|
let bleProbeInFlight = false;
|
|
50139
|
-
Log$
|
|
50132
|
+
Log$a.log('FirmwareUpdate [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
|
|
50140
50133
|
const intervalTimer = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
50141
50134
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
50142
50135
|
if (isBleReconnect) {
|
|
@@ -50152,7 +50145,7 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
50152
50145
|
}
|
|
50153
50146
|
}
|
|
50154
50147
|
catch (e) {
|
|
50155
|
-
Log$
|
|
50148
|
+
Log$a.log('catch Bluetooth error when device is restarting: ', e);
|
|
50156
50149
|
}
|
|
50157
50150
|
finally {
|
|
50158
50151
|
bleProbeInFlight = false;
|
|
@@ -50211,7 +50204,7 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
50211
50204
|
if (e instanceof hdShared.HardwareError) {
|
|
50212
50205
|
return Promise.reject(e);
|
|
50213
50206
|
}
|
|
50214
|
-
Log$
|
|
50207
|
+
Log$a.log('auto go to bootloader mode failed: ', e);
|
|
50215
50208
|
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateAutoEnterBootFailure));
|
|
50216
50209
|
}
|
|
50217
50210
|
}
|
|
@@ -50360,7 +50353,7 @@ const readVerifiedPreparedResourceArchive = ({ preparedPlan, reader, }) => __awa
|
|
|
50360
50353
|
return verifiedEntries;
|
|
50361
50354
|
});
|
|
50362
50355
|
|
|
50363
|
-
const Log$
|
|
50356
|
+
const Log$9 = getLogger(exports.LoggerNames.Method);
|
|
50364
50357
|
const FIRMWARE_DOWNLOAD_REQUEST_OPTIONS = {
|
|
50365
50358
|
connectTimeoutMs: 60000,
|
|
50366
50359
|
readTimeoutMs: 60000,
|
|
@@ -50517,7 +50510,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
50517
50510
|
const env = DataManager.getSettings('env');
|
|
50518
50511
|
const isBleReconnect = connectId && DataManager.isBleConnect(env);
|
|
50519
50512
|
let probeInFlight = false;
|
|
50520
|
-
Log$
|
|
50513
|
+
Log$9.log('FirmwareUpdateV2 [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
|
|
50521
50514
|
let isFirstCheck = true;
|
|
50522
50515
|
let checkCount = 0;
|
|
50523
50516
|
let hasPromptedWebDevice = false;
|
|
@@ -50552,10 +50545,10 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
50552
50545
|
return;
|
|
50553
50546
|
probeInFlight = true;
|
|
50554
50547
|
checkCount += 1;
|
|
50555
|
-
Log$
|
|
50548
|
+
Log$9.log('FirmwareUpdateV2 [checkDeviceToBootloader] isFirstCheck: ', isFirstCheck);
|
|
50556
50549
|
if (isTouchOrProDevice && isFirstCheck) {
|
|
50557
50550
|
isFirstCheck = false;
|
|
50558
|
-
Log$
|
|
50551
|
+
Log$9.log('FirmwareUpdateV2 [checkDeviceToBootloader] wait 3000ms');
|
|
50559
50552
|
yield wait(3000);
|
|
50560
50553
|
}
|
|
50561
50554
|
if (checkCount > 4 &&
|
|
@@ -50579,7 +50572,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
50579
50572
|
catch (e) {
|
|
50580
50573
|
isFinished = true;
|
|
50581
50574
|
clearPollingTimers();
|
|
50582
|
-
Log$
|
|
50575
|
+
Log$9.log('FirmwareUpdateV2 [checkDeviceToBootloader] promptDeviceInBootloaderForWebDevice failed: ', e);
|
|
50583
50576
|
(_b = this.checkPromise) === null || _b === void 0 ? void 0 : _b.reject(e);
|
|
50584
50577
|
}
|
|
50585
50578
|
finally {
|
|
@@ -50599,7 +50592,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
50599
50592
|
}
|
|
50600
50593
|
}
|
|
50601
50594
|
catch (e) {
|
|
50602
|
-
Log$
|
|
50595
|
+
Log$9.log('catch Bluetooth error when device is restarting: ', e);
|
|
50603
50596
|
}
|
|
50604
50597
|
finally {
|
|
50605
50598
|
probeInFlight = false;
|
|
@@ -50894,7 +50887,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
50894
50887
|
}
|
|
50895
50888
|
}
|
|
50896
50889
|
|
|
50897
|
-
const Log$
|
|
50890
|
+
const Log$8 = getLogger(exports.LoggerNames.Method);
|
|
50898
50891
|
const MIN_UPDATE_V3_BOOTLOADER_VERSION = '2.8.0';
|
|
50899
50892
|
class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
50900
50893
|
constructor() {
|
|
@@ -51012,7 +51005,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51012
51005
|
}
|
|
51013
51006
|
run() {
|
|
51014
51007
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51015
|
-
Log$
|
|
51008
|
+
Log$8.debug('FirmwareUpdateV3 strategy: Protocol V1');
|
|
51016
51009
|
return this.runProtocolV1();
|
|
51017
51010
|
});
|
|
51018
51011
|
}
|
|
@@ -51159,7 +51152,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51159
51152
|
resourceEntries: [],
|
|
51160
51153
|
};
|
|
51161
51154
|
}
|
|
51162
|
-
Log$
|
|
51155
|
+
Log$8.warn('No resource url found');
|
|
51163
51156
|
return {
|
|
51164
51157
|
resourceBinary: null,
|
|
51165
51158
|
resourceEntries: [],
|
|
@@ -51320,7 +51313,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51320
51313
|
yield this.startEmmcFirmwareUpdate({ path: '0:updates' });
|
|
51321
51314
|
}
|
|
51322
51315
|
catch (error) {
|
|
51323
|
-
Log$
|
|
51316
|
+
Log$8.error('triggerFirmwareUpdateEmmc error: ', error);
|
|
51324
51317
|
if (error === null || error === void 0 ? void 0 : error.errorCode) {
|
|
51325
51318
|
const unexpectedError = [
|
|
51326
51319
|
hdShared.HardwareErrorCode.ActionCancelled,
|
|
@@ -51390,7 +51383,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51390
51383
|
yield hdShared.wait(1000);
|
|
51391
51384
|
}
|
|
51392
51385
|
catch (error) {
|
|
51393
|
-
Log$
|
|
51386
|
+
Log$8.log('getFeatures error', error);
|
|
51394
51387
|
let shouldReconnect = true;
|
|
51395
51388
|
const progress = this.extractUpdateModeProgress(error);
|
|
51396
51389
|
if (progress !== null) {
|
|
@@ -51489,7 +51482,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51489
51482
|
return;
|
|
51490
51483
|
}
|
|
51491
51484
|
catch (e) {
|
|
51492
|
-
Log$
|
|
51485
|
+
Log$8.log('catch Bluetooth error when device is restarting: ', e);
|
|
51493
51486
|
}
|
|
51494
51487
|
}
|
|
51495
51488
|
else {
|
|
@@ -51504,7 +51497,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51504
51497
|
yield this._promptDeviceForSwitchFirmwareWebDevice();
|
|
51505
51498
|
}
|
|
51506
51499
|
catch (e) {
|
|
51507
|
-
Log$
|
|
51500
|
+
Log$8.log('WebUSB re-authorization failed: ', e);
|
|
51508
51501
|
}
|
|
51509
51502
|
webUsbCheckCount = 0;
|
|
51510
51503
|
}
|
|
@@ -51529,7 +51522,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51529
51522
|
}
|
|
51530
51523
|
catch (error) {
|
|
51531
51524
|
console.error('Device reconnect failed: ', error);
|
|
51532
|
-
Log$
|
|
51525
|
+
Log$8.error('Device reconnect failed:', error);
|
|
51533
51526
|
yield hdShared.wait(1000);
|
|
51534
51527
|
}
|
|
51535
51528
|
}
|
|
@@ -51713,7 +51706,7 @@ function prepareFirmwareUpdateV4MemoryHost({ sdk, plan, artifacts, }) {
|
|
|
51713
51706
|
};
|
|
51714
51707
|
}
|
|
51715
51708
|
|
|
51716
|
-
const Log$
|
|
51709
|
+
const Log$7 = getLogger(exports.LoggerNames.Method);
|
|
51717
51710
|
const SESSION_ERROR$1 = 'session not found';
|
|
51718
51711
|
const PROTOCOL_V2_BOOTLOADER_RECONNECT_TIMEOUT = 90 * 1000;
|
|
51719
51712
|
const PROTOCOL_V2_FINAL_RECONNECT_TIMEOUT = 3 * 60 * 1000;
|
|
@@ -52191,7 +52184,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
52191
52184
|
}
|
|
52192
52185
|
run() {
|
|
52193
52186
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52194
|
-
Log$
|
|
52187
|
+
Log$7.debug('FirmwareUpdateV4 strategy: Protocol V2');
|
|
52195
52188
|
return this.runProtocolV2();
|
|
52196
52189
|
});
|
|
52197
52190
|
}
|
|
@@ -52766,7 +52759,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
52766
52759
|
: `${Math.floor(statusVersion / 0x10000) % 0x100}.${Math.floor(statusVersion / 0x100) % 0x100}.${statusVersion % 0x100}`;
|
|
52767
52760
|
if (!observedVersion) {
|
|
52768
52761
|
if (this.protocolV2FinalStatusVerified) {
|
|
52769
|
-
Log$
|
|
52762
|
+
Log$7.warn(`Protocol V2 target ${target} has no observable final version; completed target status is authoritative`);
|
|
52770
52763
|
}
|
|
52771
52764
|
else {
|
|
52772
52765
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareVerificationFailed, `Protocol V2 target ${target} has no observable final version after status fallback`);
|
|
@@ -53136,7 +53129,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53136
53129
|
return true;
|
|
53137
53130
|
}
|
|
53138
53131
|
catch (error) {
|
|
53139
|
-
Log$
|
|
53132
|
+
Log$7.log(`[FirmwareUpdateV4] RESC bundle ${bundle.name} header check failed: `, error);
|
|
53140
53133
|
return false;
|
|
53141
53134
|
}
|
|
53142
53135
|
});
|
|
@@ -53176,7 +53169,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53176
53169
|
if (error instanceof hdShared.HardwareError) {
|
|
53177
53170
|
throw error;
|
|
53178
53171
|
}
|
|
53179
|
-
Log$
|
|
53172
|
+
Log$7.log('Protocol V2 auto go to bootloader mode failed: ', error);
|
|
53180
53173
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateAutoEnterBootFailure);
|
|
53181
53174
|
}
|
|
53182
53175
|
});
|
|
@@ -53184,12 +53177,12 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53184
53177
|
enterProtocolV2BootloaderMode() {
|
|
53185
53178
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53186
53179
|
if (this.isProtocolV2RomloaderMode()) {
|
|
53187
|
-
Log$
|
|
53180
|
+
Log$7.debug('Protocol V2 device is in romloader mode; start firmware update directly');
|
|
53188
53181
|
this.protocolV2ExecutionInLoader = true;
|
|
53189
53182
|
return false;
|
|
53190
53183
|
}
|
|
53191
53184
|
if (this.isProtocolV2BootloaderMode()) {
|
|
53192
|
-
Log$
|
|
53185
|
+
Log$7.debug('Protocol V2 device is already in bootloader mode, skip reboot');
|
|
53193
53186
|
this.protocolV2ExecutionInLoader = true;
|
|
53194
53187
|
this.postTipMessage(exports.FirmwareUpdateTipMessage.GoToBootloaderSuccess);
|
|
53195
53188
|
return false;
|
|
@@ -53225,7 +53218,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53225
53218
|
}
|
|
53226
53219
|
shouldReconnect = true;
|
|
53227
53220
|
lastError = error;
|
|
53228
|
-
Log$
|
|
53221
|
+
Log$7.log('Protocol V2 bootloader mode not ready, polling reconnect: ', error);
|
|
53229
53222
|
}
|
|
53230
53223
|
yield hdShared.wait(retryInterval);
|
|
53231
53224
|
}
|
|
@@ -53322,7 +53315,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53322
53315
|
for (const resource of resourceSources) {
|
|
53323
53316
|
const requiresFreshStaging = isProtocolV2BootResourcePackagePath(resource.devicePath);
|
|
53324
53317
|
if (!requiresFreshStaging && (yield this.isProtocolV2ResourceBundleUpToDate(resource))) {
|
|
53325
|
-
Log$
|
|
53318
|
+
Log$7.log(`[FirmwareUpdateV4] skip RESC bundle ${resource.name}; already up to date`);
|
|
53326
53319
|
}
|
|
53327
53320
|
else {
|
|
53328
53321
|
resourcesToSync.push(resource);
|
|
@@ -53437,7 +53430,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53437
53430
|
}
|
|
53438
53431
|
assertProtocolV2TargetStatus(statusTargets, expectedTargetIds, expectedPaths = new Map()) {
|
|
53439
53432
|
var _a, _b, _c;
|
|
53440
|
-
Log$
|
|
53433
|
+
Log$7.log(`[FirmwareUpdateV4] DeviceFirmwareUpdateStatus records=${JSON.stringify(statusTargets)}`);
|
|
53441
53434
|
const failedTarget = statusTargets.find(target => {
|
|
53442
53435
|
var _a;
|
|
53443
53436
|
return expectedTargetIds.has((_a = normalizeProtocolV2TargetId(target.target_id)) !== null && _a !== void 0 ? _a : -1) &&
|
|
@@ -53450,7 +53443,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53450
53443
|
payloadVersion: failedTarget.payload_version,
|
|
53451
53444
|
path: failedTarget.path,
|
|
53452
53445
|
});
|
|
53453
|
-
Log$
|
|
53446
|
+
Log$7.error(`[FirmwareUpdateV4] firmware install failed target=${failedTargetDetails}`);
|
|
53454
53447
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareError, `Protocol V2 firmware target failed: target=${failedTarget.target_id} status=${(_a = failedTarget.status) !== null && _a !== void 0 ? _a : 'unknown'} payloadVersion=${(_b = failedTarget.payload_version) !== null && _b !== void 0 ? _b : 'unknown'} path=${(_c = failedTarget.path) !== null && _c !== void 0 ? _c : 'unknown'}`);
|
|
53455
53448
|
}
|
|
53456
53449
|
const matchingTargets = statusTargets.filter(target => { var _a; return expectedTargetIds.has((_a = normalizeProtocolV2TargetId(target.target_id)) !== null && _a !== void 0 ? _a : -1); });
|
|
@@ -53625,7 +53618,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53625
53618
|
if (isNormalMode &&
|
|
53626
53619
|
(installEvidenceObserved ||
|
|
53627
53620
|
this.hasProtocolV2InstallVersionChanged(expectedTargetIds))) {
|
|
53628
|
-
Log$
|
|
53621
|
+
Log$7.log('[FirmwareUpdateV4] empty firmware status after confirmed App reboot; update complete');
|
|
53629
53622
|
this.postProgressMessage(100, 'installingFirmware');
|
|
53630
53623
|
return;
|
|
53631
53624
|
}
|
|
@@ -53673,7 +53666,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53673
53666
|
if (isNormalMode &&
|
|
53674
53667
|
(installEvidenceObserved ||
|
|
53675
53668
|
this.hasProtocolV2InstallVersionChanged(expectedTargetIds))) {
|
|
53676
|
-
Log$
|
|
53669
|
+
Log$7.log('[FirmwareUpdateV4] firmware status endpoint unavailable after confirmed App reboot');
|
|
53677
53670
|
this.postProgressMessage(100, 'installingFirmware');
|
|
53678
53671
|
return;
|
|
53679
53672
|
}
|
|
@@ -53695,7 +53688,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53695
53688
|
shouldReconnect = true;
|
|
53696
53689
|
deviceInfo = undefined;
|
|
53697
53690
|
lastError = error;
|
|
53698
|
-
Log$
|
|
53691
|
+
Log$7.log('[FirmwareUpdateV4] DeviceFirmwareUpdateStatusGet unavailable during install: ', error);
|
|
53699
53692
|
}
|
|
53700
53693
|
}
|
|
53701
53694
|
}
|
|
@@ -53714,7 +53707,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53714
53707
|
shouldReconnect = true;
|
|
53715
53708
|
deviceInfo = undefined;
|
|
53716
53709
|
resetMissingTargetStatusGrace();
|
|
53717
|
-
Log$
|
|
53710
|
+
Log$7.log('Protocol V2 firmware install device readiness probe failed: ', error);
|
|
53718
53711
|
}
|
|
53719
53712
|
yield hdShared.wait(1000);
|
|
53720
53713
|
}
|
|
@@ -53727,12 +53720,12 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53727
53720
|
const deviceInfo = yield this.verifyProtocolV2ReconnectIdentity();
|
|
53728
53721
|
try {
|
|
53729
53722
|
if (yield this.probeProtocolV2NormalMode(deviceInfo)) {
|
|
53730
|
-
Log$
|
|
53723
|
+
Log$7.log('[FirmwareUpdateV4] device already returned to App mode; skip Normal reboot');
|
|
53731
53724
|
return;
|
|
53732
53725
|
}
|
|
53733
53726
|
}
|
|
53734
53727
|
catch (error) {
|
|
53735
|
-
Log$
|
|
53728
|
+
Log$7.log('[FirmwareUpdateV4] unable to confirm App mode before Normal reboot: ', error);
|
|
53736
53729
|
}
|
|
53737
53730
|
yield this.protocolV2Reboot(hdTransport.DeviceRebootType.Normal);
|
|
53738
53731
|
this.protocolV2ExecutionInLoader = false;
|
|
@@ -53760,7 +53753,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53760
53753
|
const firmwareVersion = getDeviceFirmwareVersion(features).join('.');
|
|
53761
53754
|
this.protocolV2LatestFinalFeatures = features;
|
|
53762
53755
|
if (firmwareVersion === '0.0.0') {
|
|
53763
|
-
Log$
|
|
53756
|
+
Log$7.warn('Protocol V2 firmware update finished but app firmware version is still 0.0.0. This is allowed for Pro2 debug BLE-only update flows.');
|
|
53764
53757
|
}
|
|
53765
53758
|
return {
|
|
53766
53759
|
bootloaderVersion,
|
|
@@ -53809,7 +53802,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53809
53802
|
}
|
|
53810
53803
|
shouldReconnect = true;
|
|
53811
53804
|
lastError = error;
|
|
53812
|
-
Log$
|
|
53805
|
+
Log$7.log('Protocol V2 normal mode not ready, polling Ping: ', error);
|
|
53813
53806
|
}
|
|
53814
53807
|
yield hdShared.wait(1000);
|
|
53815
53808
|
}
|
|
@@ -53853,7 +53846,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53853
53846
|
if (!reconnectDevice) {
|
|
53854
53847
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound);
|
|
53855
53848
|
}
|
|
53856
|
-
Log$
|
|
53849
|
+
Log$7.debug('Protocol V2 firmware reconnect using matched device:', reconnectDevice.getConnectId());
|
|
53857
53850
|
this.device.updateFromCache(reconnectDevice);
|
|
53858
53851
|
yield this.ensureProtocolV2DeviceAcquired();
|
|
53859
53852
|
this.device.commands.disposed = false;
|
|
@@ -53959,7 +53952,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53959
53952
|
}
|
|
53960
53953
|
}
|
|
53961
53954
|
|
|
53962
|
-
const Log$
|
|
53955
|
+
const Log$6 = getLogger(exports.LoggerNames.Method);
|
|
53963
53956
|
class PromptWebDeviceAccess extends BaseMethod {
|
|
53964
53957
|
init() {
|
|
53965
53958
|
this.useDevice = false;
|
|
@@ -54014,7 +54007,7 @@ class PromptWebDeviceAccess extends BaseMethod {
|
|
|
54014
54007
|
return { device: null };
|
|
54015
54008
|
}
|
|
54016
54009
|
catch (error) {
|
|
54017
|
-
Log$
|
|
54010
|
+
Log$6.debug(error);
|
|
54018
54011
|
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Please select the device to connect'));
|
|
54019
54012
|
}
|
|
54020
54013
|
});
|
|
@@ -54117,7 +54110,7 @@ function decodeJpegBase64ToRgba({ jpegBase64, parameterName, expectedWidth, expe
|
|
|
54117
54110
|
return decoded;
|
|
54118
54111
|
}
|
|
54119
54112
|
|
|
54120
|
-
const Log$
|
|
54113
|
+
const Log$5 = getLogger(exports.LoggerNames.Core);
|
|
54121
54114
|
const MIN_FILE_CHUNK_SIZE = 64;
|
|
54122
54115
|
const FILE_TRANSFER_RATE_WINDOW_MS = 1000;
|
|
54123
54116
|
const FILE_TRANSFER_LOG_INTERVAL_MS = 10000;
|
|
@@ -54138,7 +54131,7 @@ function logFileTransferMetrics({ transport, status, path, transferredBytes, tot
|
|
|
54138
54131
|
const segmentedMetrics = measuredAttempts > 0
|
|
54139
54132
|
? ` hostWriteTotal=${(hostWriteElapsedMs / 1000).toFixed(2)}s responseWaitTotal=${(responseWaitElapsedMs / 1000).toFixed(2)}s measuredAttempts=${measuredAttempts}`
|
|
54140
54133
|
: '';
|
|
54141
|
-
Log$
|
|
54134
|
+
Log$5.log(`[FileWrite] metrics transport=${transport} status=${status} path=${path} bytes=${transferredBytes}/${totalBytes} elapsed=${(elapsedMs / 1000).toFixed(2)}s speed=${formatFileTransferRate(rateBytesPerSecond)} KiB/s${segmentedMetrics}`);
|
|
54142
54135
|
}
|
|
54143
54136
|
function isProtocolV2ResponseTimeout(error) {
|
|
54144
54137
|
var _a, _b;
|
|
@@ -54229,7 +54222,7 @@ function writeProtocolV2File(options) {
|
|
|
54229
54222
|
let responseWaitElapsedMs = 0;
|
|
54230
54223
|
let measuredAttempts = 0;
|
|
54231
54224
|
const transport = getFileTransferTransport();
|
|
54232
|
-
Log$
|
|
54225
|
+
Log$5.log(`[FileWrite] started transport=${transport} path=${options.path} bytes=${dataLength} offset=${startOffset} chunk=${chunkSize}`);
|
|
54233
54226
|
try {
|
|
54234
54227
|
while (written < dataLength) {
|
|
54235
54228
|
(_c = options.throwIfAborted) === null || _c === void 0 ? void 0 : _c.call(options);
|
|
@@ -54396,6 +54389,7 @@ const SAFE_FILE_NAME = /^[A-Za-z0-9_-]+(?:\.bin)?$/;
|
|
|
54396
54389
|
const DEVICE_SETTINGS_SET_MESSAGE_TYPE = 60412;
|
|
54397
54390
|
const FILESYSTEM_FILE_WRITE_MESSAGE_TYPE$2 = 60805;
|
|
54398
54391
|
const FILESYSTEM_DIR_MAKE_MESSAGE_TYPE = 60809;
|
|
54392
|
+
const Log$4 = getLogger(exports.LoggerNames.Method);
|
|
54399
54393
|
function normalizeFileName(fileName, data) {
|
|
54400
54394
|
if (fileName !== undefined && (!fileName || !SAFE_FILE_NAME.test(fileName))) {
|
|
54401
54395
|
throw invalidParameter$1('Parameter [fileName] may only contain letters, numbers, underscores, hyphens and an optional .bin suffix.');
|
|
@@ -54503,7 +54497,14 @@ class DeviceUploadWallpaper extends BaseMethod {
|
|
|
54503
54497
|
const response = yield this.device.commands.typedCall('DeviceSettingsSet', 'Success', {
|
|
54504
54498
|
settings: { wallpaper_path: this.path },
|
|
54505
54499
|
});
|
|
54506
|
-
|
|
54500
|
+
try {
|
|
54501
|
+
yield this.device.refreshProtocolV2SettingsAfterMutation();
|
|
54502
|
+
}
|
|
54503
|
+
catch (error) {
|
|
54504
|
+
Log$4.warn('Protocol V2 wallpaper settings refresh failed after apply', {
|
|
54505
|
+
error: error instanceof Error ? error.message : String(error),
|
|
54506
|
+
});
|
|
54507
|
+
}
|
|
54507
54508
|
return {
|
|
54508
54509
|
path: this.path,
|
|
54509
54510
|
size: encoded.data.byteLength,
|
|
@@ -65613,9 +65614,10 @@ function isRetryableBleProtocolV2ProbeError(method, error) {
|
|
|
65613
65614
|
message.includes('expected V2') &&
|
|
65614
65615
|
message.includes('did not respond to expected protocol'));
|
|
65615
65616
|
}
|
|
65616
|
-
function
|
|
65617
|
+
function isMissingDetectedProtocolV2Error(method, error) {
|
|
65617
65618
|
const typedError = error;
|
|
65618
|
-
return (
|
|
65619
|
+
return (method.payload.connectProtocol === 'V2' &&
|
|
65620
|
+
(typedError === null || typedError === void 0 ? void 0 : typedError.errorCode) === hdShared.HardwareErrorCode.RuntimeError &&
|
|
65619
65621
|
typeof typedError.message === 'string' &&
|
|
65620
65622
|
typedError.message.includes('Device protocol has not been detected'));
|
|
65621
65623
|
}
|
|
@@ -65653,7 +65655,7 @@ function connectDeviceForBle(method, device, retryCount = 0) {
|
|
|
65653
65655
|
}
|
|
65654
65656
|
}
|
|
65655
65657
|
catch (err) {
|
|
65656
|
-
const requiresColdReconnect =
|
|
65658
|
+
const requiresColdReconnect = isMissingDetectedProtocolV2Error(method, err);
|
|
65657
65659
|
if ((hdShared.ERROR_CODES_REQUIRE_DISCONNECT.includes(err.errorCode) || requiresColdReconnect) &&
|
|
65658
65660
|
device.mainId &&
|
|
65659
65661
|
device.deviceConnector) {
|