decord/source/modules/js_watchdog/native/JSWatchdogManager.android.tsx

380 lines
12 KiB
TypeScript
Raw Normal View History

2026-09-03 10:05:34 +00:00
// Module ID: 17246
// Function ID: 17247
2026-07-29 08:29:29 +00:00
// Name: handleAppStateUpdate
2026-09-03 10:05:34 +00:00
// Dependencies: [5, 673, 3, 684, 5495, 17247, 1205, 695, 7230, 7227, 7217, 2]
2026-07-20 16:05:17 +00:00
2026-09-03 10:05:34 +00:00
// Module 17246 (handleAppStateUpdate)
2026-08-24 06:08:38 +00:00
import timestampDefault from "timestamp" /* 3 */;
2026-09-02 09:53:35 +00:00
import setDefault from "set" /* 684 */;
import expandEventPropertiesDefault from "expandEventProperties" /* 695 */;
2026-09-03 10:05:34 +00:00
import initializeDefault from "initialize" /* 5495 */;
import getDeviceMetadata from "getDeviceMetadata" /* 7230 */;
2026-08-24 06:08:38 +00:00
import closure_3 from "asyncGeneratorStep" /* 5 */;
2026-09-02 09:53:35 +00:00
import ME from "ME" /* 673 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
require = arg1;
2026-07-29 08:29:29 +00:00
({ AppStates: c4, AnalyticEvents: c5 } = ME);
2026-08-24 06:08:38 +00:00
let closure_6 = new timestampDefault("JSWatchdogManager");
const HALF_SECOND = setDefault.Millis.HALF_SECOND;
initializeDefault;
2026-07-29 08:29:29 +00:00
class JSWatchdogManager extends tmp4 {
constructor() {
applyArgumentsResult = HermesBuiltin.applyArguments(new.target, new.target);
closure_0 = applyArgumentsResult;
applyArgumentsResult._enabled = true;
applyArgumentsResult._timeoutId = null;
applyArgumentsResult._analyticsReportsRemaining = 3;
applyArgumentsResult._cachedSession = null;
applyArgumentsResult._lastSessionId = null;
applyArgumentsResult._pingCompleted = true;
applyArgumentsResult.actions = {
APP_STATE_UPDATE(arg0) {
applyArgumentsResult.handleAppStateUpdate(arg0);
},
CONNECTION_OPEN_SUPPLEMENTAL() {
const result = applyArgumentsResult.handleConnectionOpenSupplemental();
}
};
return applyArgumentsResult;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
const prototype = JSWatchdogManager.prototype;
prototype["handleAppStateUpdate"] = function handleAppStateUpdate(state) {
const self = this;
if (state.state === constants.ACTIVE) {
self.startWatchdog();
} else {
self.stopWatchdog();
}
};
prototype["handleConnectionOpenSupplemental"] = function handleConnectionOpenSupplemental() {
const self = this;
const timerId = setTimeout(() => {
self.startWatchdog();
}, 0);
};
prototype["ping"] = function ping() {
let flag = arg0;
if (arg0 === undefined) {
flag = false;
}
const self = this;
return callback(function*() {
if (c5 === 2) {
c5 = 3;
HermesBuiltin.throwTypeError();
} else if (tmp7 === 3) {
if (arg0 === 1) {
throw arg1;
} else if (arg0 === 2) {
let obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-09-01 10:26:29 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
}
} else {
try {
c5 = 2;
if (0 === c4) {
if (arg0 === 1) {
c5 = 3;
throw arg1;
} else if (arg0 === 2) {
c5 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
let _lastSessionId = tmp4;
2026-08-24 06:08:38 +00:00
c0 = tmp8;
2026-07-29 08:29:29 +00:00
c0 = undefined;
_lastSessionId = undefined;
2026-08-24 06:08:38 +00:00
checkForStallReportResult._pingCompleted = false;
c3 = 2;
2026-07-29 08:29:29 +00:00
c4 = 3;
c5 = 1;
2026-08-24 06:08:38 +00:00
obj1 = { value: null, done: false };
obj1[0] = checkForStallReportResult.getCurrentSessionId();
2026-07-29 08:29:29 +00:00
return obj1;
}
} else if (1 === tmp8) {
c3 = 0;
2026-08-24 06:08:38 +00:00
checkForStallReportResult._pingCompleted = true;
throw dependencyMap;
2026-07-29 08:29:29 +00:00
} else {
if (2 === tmp8) {
c3 = 1;
2026-09-02 09:53:35 +00:00
checkForStallReportResult(1205).captureException(dependencyMap);
2026-07-29 08:29:29 +00:00
c3 = 0;
2026-08-24 06:08:38 +00:00
checkForStallReportResult._pingCompleted = true;
2026-07-29 08:29:29 +00:00
c5 = 3;
2026-09-02 09:53:35 +00:00
const obj8 = checkForStallReportResult(1205);
2026-07-29 08:29:29 +00:00
} else if (3 === tmp8) {
if (arg0 === 1) {
c5 = 3;
throw arg1;
} else if (arg0 === 2) {
c3 = 0;
2026-08-24 06:08:38 +00:00
checkForStallReportResult._pingCompleted = true;
2026-07-29 08:29:29 +00:00
c5 = 3;
const obj2 = { value: null, done: true };
obj2[0] = arg1;
return obj2;
} else {
2026-08-24 06:08:38 +00:00
closure_0 = arg1;
if (null == closure_0) {
if (checkForStallReportResult._enabled) {
2026-07-29 08:29:29 +00:00
const _setTimeout2 = setTimeout;
2026-08-24 06:08:38 +00:00
const timerId = setTimeout(() => _undefined.ping(), closure_1_7);
2026-07-29 08:29:29 +00:00
_lastSessionId._timeoutId = timerId;
}
c3 = 0;
2026-08-24 06:08:38 +00:00
checkForStallReportResult._pingCompleted = true;
2026-07-29 08:29:29 +00:00
c5 = 3;
let obj3 = { value: null, done: true };
obj3[0] = undefined;
return obj3;
} else {
2026-09-03 10:05:34 +00:00
obj3 = checkForStallReportResult(17247);
2026-07-29 08:29:29 +00:00
let pingResult;
if (obj3 != null) {
const _Date = Date;
2026-08-24 06:08:38 +00:00
pingResult = obj3.ping(Date.now(), closure_0, closure_0, false);
2026-07-29 08:29:29 +00:00
}
c4 = 4;
c5 = 1;
const obj4 = { value: null, done: false };
obj4[0] = pingResult;
return obj4;
}
}
} else if (arg0 === 1) {
c5 = 3;
throw arg1;
} else if (arg0 !== 2) {
if (arg1) {
2026-09-03 10:05:34 +00:00
obj = checkForStallReportResult(17247);
2026-08-24 06:08:38 +00:00
checkForStallReportResult = undefined;
2026-07-29 08:29:29 +00:00
if (obj != null) {
checkForStallReportResult = obj.checkForStallReport();
}
2026-08-24 06:08:38 +00:00
if (null != checkForStallReportResult) {
if (_lastSessionId._lastSessionId !== closure_0) {
checkForStallReportResult._lastSessionId = c0;
checkForStallReportResult._analyticsReportsRemaining = 3;
2026-07-29 08:29:29 +00:00
}
2026-08-24 06:08:38 +00:00
checkForStallReportResult._analyticsReportsRemaining = +checkForStallReportResult._analyticsReportsRemaining - 1;
if (+checkForStallReportResult._analyticsReportsRemaining > 0) {
checkForStallReportResult.reportStall(_lastSessionId, c0, false, checkForStallReportResult._analyticsReportsRemaining);
2026-07-29 08:29:29 +00:00
}
2026-08-24 06:08:38 +00:00
if (0 === checkForStallReportResult._analyticsReportsRemaining) {
checkForStallReportResult.stopWatchdog();
2026-09-03 10:05:34 +00:00
obj1 = checkForStallReportResult(17247);
2026-07-29 08:29:29 +00:00
if (obj1 != null) {
obj1.disable();
}
}
}
}
2026-08-24 06:08:38 +00:00
if (checkForStallReportResult._enabled) {
2026-07-29 08:29:29 +00:00
const _setTimeout = setTimeout;
2026-08-24 06:08:38 +00:00
_lastSessionId._timeoutId = setTimeout(() => _undefined.ping(), closure_1_7);
2026-07-29 08:29:29 +00:00
}
c3 = 1;
}
c3 = 0;
2026-08-24 06:08:38 +00:00
checkForStallReportResult._pingCompleted = true;
2026-07-29 08:29:29 +00:00
c5 = 3;
const obj5 = { value: null, done: true };
obj5[0] = arg1;
return obj5;
}
} catch (tmp84) {
2026-08-24 06:08:38 +00:00
dependencyMap = tmp84;
2026-07-29 08:29:29 +00:00
if (tmp5 === c3) {
c5 = tmp3;
throw tmp84;
} else if (tmp2 === tmp86) {
c4 = tmp2;
} else {
c4 = tmp;
}
}
}
})();
};
prototype["startWatchdog"] = function startWatchdog() {
const self = this;
return callback(function*() {
if (c3 === 2) {
c3 = 3;
HermesBuiltin.throwTypeError();
} else if (tmp4 === 3) {
if (arg0 === 1) {
throw arg1;
} else if (arg0 === 2) {
let obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-09-01 10:26:29 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
}
} else {
try {
c3 = 2;
if (0 === dependencyMap) {
if (arg0 === 1) {
c3 = 3;
throw arg1;
} else if (arg0 === 2) {
c3 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
c1 = tmp2;
closure_0 = 0;
2026-07-29 08:29:29 +00:00
closure_0 = undefined;
c1 = undefined;
2026-08-24 06:08:38 +00:00
if (null == closure_1_0._timeoutId) {
2026-09-03 10:05:34 +00:00
if (null != checkForStallReportResult(17247)) {
2026-07-29 08:29:29 +00:00
dependencyMap = 1;
c3 = 1;
2026-08-24 06:08:38 +00:00
obj1 = { value: null, done: false };
obj1[0] = closure_1_0.getCurrentSessionId();
2026-07-29 08:29:29 +00:00
return obj1;
}
}
c3 = 3;
}
} else if (arg0 === 1) {
c3 = 3;
throw arg1;
} else if (arg0 !== 2) {
closure_0 = arg1;
if (null != closure_0) {
if (closure_0._lastSessionId !== closure_0) {
2026-08-24 06:08:38 +00:00
closure_1_6.info("startWatchdog()");
2026-07-29 08:29:29 +00:00
closure_0._enabled = true;
if (closure_0._pingCompleted) {
2026-08-24 06:08:38 +00:00
checkForStallReportResult = undefined;
2026-09-03 10:05:34 +00:00
obj = checkForStallReportResult(17247);
2026-07-29 08:29:29 +00:00
if (obj != null) {
checkForStallReportResult = obj.checkForStallReport();
}
2026-08-24 06:08:38 +00:00
if (null != checkForStallReportResult) {
closure_0.reportStall(checkForStallReportResult, closure_1_0, true, -1);
2026-07-29 08:29:29 +00:00
}
}
2026-08-24 06:08:38 +00:00
closure_1_0.ping(true);
2026-07-29 08:29:29 +00:00
}
}
}
c3 = 3;
const obj2 = { value: null, done: true };
obj2[0] = arg1;
return obj2;
} catch (tmp32) {
c3 = tmp;
throw tmp32;
}
}
})();
};
prototype["stopWatchdog"] = function stopWatchdog() {
2026-08-24 06:08:38 +00:00
logger.info("stopWatchdog()");
2026-07-29 08:29:29 +00:00
this._enabled = false;
clearTimeout(this._timeoutId);
this._timeoutId = null;
};
prototype["reportStall"] = function reportStall(c1, c0, is_previous, _analyticsReportsRemaining) {
2026-08-24 06:08:38 +00:00
let obj = expandEventPropertiesDefault;
2026-07-29 08:29:29 +00:00
obj = {};
2026-08-24 06:08:38 +00:00
const merged = Object.assign(getDeviceMetadata.getDeviceMetadata());
2026-07-29 08:29:29 +00:00
obj.version = 1;
obj.stall_time = c1.stallTime;
obj.is_previous = is_previous;
obj.reports_remaining = _analyticsReportsRemaining;
let sessionId = null;
if (c1.sessionId !== c0) {
sessionId = c1.sessionId;
}
obj.stall_session_id = sessionId;
obj.trace = null;
obj.track(constants2.APP_JS_STALLED, obj);
};
prototype["getCurrentSessionId"] = function getCurrentSessionId() {
const self = this;
return callback(function*() {
if (c3 === 2) {
c3 = 3;
HermesBuiltin.throwTypeError();
} else if (tmp4 === 3) {
if (arg0 === 1) {
throw arg1;
} else if (arg0 === 2) {
let obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-09-01 10:26:29 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
}
} else {
try {
c3 = 2;
if (0 === dependencyMap) {
if (arg0 === 1) {
c3 = 3;
throw arg1;
} else if (arg0 === 2) {
c3 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
closure_1 = tmp5;
closure_0 = tmp2;
2026-07-29 08:29:29 +00:00
closure_0 = undefined;
2026-08-24 06:08:38 +00:00
if (null != closure_1_0._cachedSession) {
2026-09-03 10:05:34 +00:00
obj1 = closure_1_0(7227);
2026-08-24 06:08:38 +00:00
if (!obj1.isSessionExpired(closure_1_0._cachedSession)) {
const uuid = closure_1_0._cachedSession.uuid;
2026-07-29 08:29:29 +00:00
c3 = 3;
}
}
dependencyMap = 1;
c3 = 1;
obj1 = { value: null, done: false };
2026-09-03 10:05:34 +00:00
obj1[0] = closure_1_0(7217).getSession();
2026-07-29 08:29:29 +00:00
return obj1;
}
} else if (arg0 === 1) {
c3 = 3;
throw arg1;
} else if (arg0 === 2) {
c3 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
closure_0 = arg1;
if (null != closure_0) {
closure_0._cachedSession = closure_0;
}
}
c3 = 3;
return { value: null, done: true };
} catch (tmp20) {
c3 = tmp;
throw tmp20;
}
}
})();
};
const jSWatchdogManager = new JSWatchdogManager();
2026-08-24 06:08:38 +00:00
const tmp3 = new timestampDefault("JSWatchdogManager");
let result = require("set").fileFinishedImporting("modules/js_watchdog/native/JSWatchdogManager.android.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default jSWatchdogManager;