515 lines
18 KiB
TypeScript
515 lines
18 KiB
TypeScript
// Module ID: 6830
|
|
// Function ID: 6831
|
|
// Name: receiveNetworkInfoformation
|
|
// Dependencies: [5, 17, 4960, 6831, 1862, 676, 3, 1456, 1455, 6842, 687, 595, 709, 4143, 6832, 6843, 9, 2]
|
|
// Exports: getSignalStrength, isSlowNetwork
|
|
|
|
// Module 6830 (receiveNetworkInfoformation)
|
|
import ME from "ME";
|
|
import get_ActivityIndicator from "set";
|
|
import _handleConnectionOpen from "_handleConnectionOpen";
|
|
import result from "result";
|
|
import createGuildRecordFromRust from "createGuildRecordFromRust";
|
|
import { AnalyticEvents } from "ME";
|
|
import importDefaultResult from "notifyListeners";
|
|
import importDefaultResult1 from "notifyListeners";
|
|
import importDefaultResult2 from "dispatcher";
|
|
import importDefaultResult3 from "dispatcher";
|
|
import importDefaultResult4 from "dispatcher";
|
|
|
|
let AppState;
|
|
let c4;
|
|
const require = arg1;
|
|
function receiveNetworkInfoformation(arg0) {
|
|
let closure_12 = arg0;
|
|
if (null == closure_13) {
|
|
closure_13 = arg0;
|
|
}
|
|
const SystemResourceManager = closure_4.SystemResourceManager;
|
|
const getNetworkUsage = SystemResourceManager.getNetworkUsage;
|
|
if (getNetworkUsage != null) {
|
|
const networkUsage = getNetworkUsage((arg0) => {
|
|
let closure_10 = arg0;
|
|
if (null == closure_11) {
|
|
closure_11 = arg0;
|
|
}
|
|
const obj = { state: closure_12, nativeStats: closure_10, rtc: null };
|
|
obj[2] = callback(table[9]).getRTCTotalBytes();
|
|
closure_9.fileOnly("Updating Network Info", obj);
|
|
});
|
|
}
|
|
}
|
|
function updateNetworkUsage() {
|
|
const SystemResourceManager = closure_4.SystemResourceManager;
|
|
const getNetworkUsage = SystemResourceManager.getNetworkUsage;
|
|
if (getNetworkUsage != null) {
|
|
const networkUsage = getNetworkUsage((arg0) => {
|
|
let closure_10 = arg0;
|
|
if (null == closure_11) {
|
|
closure_11 = arg0;
|
|
}
|
|
const obj = { state: closure_12, nativeStats: closure_10, rtc: null };
|
|
obj[2] = callback(table[9]).getRTCTotalBytes();
|
|
closure_9.fileOnly("Updating Network Info", obj);
|
|
});
|
|
}
|
|
}
|
|
({ NativeModules: c4, AppState } = get_ActivityIndicator);
|
|
let c9 = new require("result")("NetStats");
|
|
let closure_10 = { signalStrengthLevel: null, isNetworkRoaming: false, cellularReceiveBytes: 0, cellularSendBytes: 0, totalReceiveBytes: 0, totalSendBytes: 0, uidReceiveBytes: 0, uidSendBytes: 0, socketBytesReceived: 0, otaBytesReceived: 0, otaNumRequests: 0, xhrBytesReceived: 0, xhrNumRequests: 0, frescoBytesReceived: 0, frescoNumRequests: 0, downloadBytesReceived: 0, downloadNumRequests: 0, mediaPlayerBytesReceived: 0 };
|
|
let c11 = null;
|
|
let obj = { type: require("configure").NetInfoStateType.unknown, effectiveSpeed: null, serviceProvider: null };
|
|
let c13 = null;
|
|
let closure_14 = "active" === AppState.currentState;
|
|
let c15 = 0;
|
|
let c16 = 0;
|
|
let c17 = 0;
|
|
let c18 = 0;
|
|
const tmp3 = new require("result")("NetStats");
|
|
require("notifyListeners").addChangeCallback(receiveNetworkInfoformation);
|
|
const networkInformation = require("notifyListeners").getNetworkInformation();
|
|
networkInformation.then(receiveNetworkInfoformation);
|
|
class EventTracker {
|
|
constructor() {
|
|
obj = Object.create(new.target.prototype);
|
|
closure_0 = obj;
|
|
num = 0;
|
|
if (c14) {
|
|
tmp = globalThis;
|
|
_setTimeout = setTimeout;
|
|
tmp2 = closure_1;
|
|
tmp3 = closure_2;
|
|
num2 = 1;
|
|
num = setTimeout(() => obj.track(), require("set").Millis.MINUTE);
|
|
}
|
|
obj.trackTimeout = num;
|
|
num3 = 0;
|
|
if (c14) {
|
|
tmp4 = globalThis;
|
|
_setInterval = setInterval;
|
|
tmp5 = closure_1;
|
|
tmp6 = closure_2;
|
|
num4 = 5;
|
|
num3 = setInterval(() => obj.writeExistingEventStorage(), 5 * require("set").Millis.SECOND);
|
|
}
|
|
obj.flushStorageInterval = num3;
|
|
obj.didEverTrack = false;
|
|
tmp7 = closure_2;
|
|
Storage = require("Storage").Storage;
|
|
value = Storage.get("previousNetStatsEvents");
|
|
if (value == null) {
|
|
value = [];
|
|
}
|
|
obj.existingEvents = value;
|
|
obj.trackExistingEvents = function trackExistingEvents() {
|
|
if (obj.existingEvents.length > 0) {
|
|
let result = outer1_6.submitEventsImmediately(tmp.existingEvents);
|
|
result.then(() => {
|
|
outer1_9.fileOnly("Successfully logged existing network usage events", closure_0.existingEvents);
|
|
closure_0.existingEvents = [];
|
|
const result = closure_0.writeExistingEventStorage();
|
|
}).catch((status) => {
|
|
if (tmp) {
|
|
outer1_9.error("Failed to log log existing network usage events", closure_0.existingEvents, status);
|
|
}
|
|
});
|
|
const nextPromise = result.then(() => {
|
|
outer1_9.fileOnly("Successfully logged existing network usage events", closure_0.existingEvents);
|
|
closure_0.existingEvents = [];
|
|
const result = closure_0.writeExistingEventStorage();
|
|
});
|
|
}
|
|
};
|
|
if (NativeModules.isConnected()) {
|
|
trackExistingEventsResult = obj.trackExistingEvents();
|
|
} else {
|
|
tmp8 = closure_1;
|
|
obj2 = require("dispatcher");
|
|
str = "CONNECTION_OPEN";
|
|
subscription = obj2.subscribe("CONNECTION_OPEN", obj.trackExistingEvents);
|
|
}
|
|
return obj;
|
|
}
|
|
}
|
|
const prototype = EventTracker.prototype;
|
|
prototype["handleAppStateChange"] = function handleAppStateChange(arg0) {
|
|
let self = this;
|
|
self = this;
|
|
if (!this.didEverTrack) {
|
|
if (arg0) {
|
|
if (!tmp2) {
|
|
let c14 = true;
|
|
const _setTimeout = setTimeout;
|
|
self.trackTimeout = setTimeout(() => closure_20.track(), importDefault(687).Millis.MINUTE);
|
|
const _setInterval = setInterval;
|
|
self.flushStorageInterval = setInterval(() => self.writeExistingEventStorage(), 5000);
|
|
}
|
|
} else if (tmp2) {
|
|
self.track();
|
|
}
|
|
}
|
|
};
|
|
prototype["writeExistingEventStorage"] = function writeExistingEventStorage() {
|
|
const self = this;
|
|
return callback(function*() {
|
|
if (c3 === 2) {
|
|
c3 = 3;
|
|
HermesBuiltin.throwTypeError();
|
|
} else if (tmp5 === 3) {
|
|
if (arg0 === 1) {
|
|
throw arg1;
|
|
} else if (arg0 === 2) {
|
|
let obj = { value: null, done: true };
|
|
obj[0] = arg1;
|
|
return obj;
|
|
} else {
|
|
return { value: "HermesInternal", done: null };
|
|
}
|
|
} 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 {
|
|
let length = tmp2;
|
|
let items = tmp3;
|
|
items = undefined;
|
|
length = undefined;
|
|
if (!outer1_0.didEverTrack) {
|
|
if (outer1_14) {
|
|
dependencyMap = 1;
|
|
c3 = 1;
|
|
const obj1 = { value: null, done: false };
|
|
obj1[0] = outer1_0.getQueuedEvent();
|
|
return obj1;
|
|
}
|
|
}
|
|
items = [];
|
|
}
|
|
} 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 {
|
|
items = [arg1];
|
|
}
|
|
const existingEvents = outer1_0.existingEvents;
|
|
length = existingEvents.concat(items);
|
|
if (0 === length.length) {
|
|
const Storage2 = outer1_0(595).Storage;
|
|
Storage2.remove("previousNetStatsEvents");
|
|
} else {
|
|
const Storage = outer1_0(595).Storage;
|
|
const result = Storage.set("previousNetStatsEvents", length);
|
|
}
|
|
c3 = 3;
|
|
} catch (tmp24) {
|
|
c3 = tmp;
|
|
throw tmp24;
|
|
}
|
|
}
|
|
})();
|
|
};
|
|
prototype["track"] = function track() {
|
|
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 {
|
|
return { value: "HermesInternal", done: null };
|
|
}
|
|
} else {
|
|
try {
|
|
c3 = 2;
|
|
if (0 === c2) {
|
|
if (arg0 === 1) {
|
|
c3 = 3;
|
|
throw arg1;
|
|
} else if (arg0 === 2) {
|
|
c3 = 3;
|
|
obj = { value: null, done: true };
|
|
obj[0] = arg1;
|
|
return obj;
|
|
} else {
|
|
let closure_1 = tmp5;
|
|
let items = tmp2;
|
|
items = undefined;
|
|
if (outer1_0.didEverTrack) {
|
|
c3 = 3;
|
|
} else {
|
|
obj5.didEverTrack = true;
|
|
const _clearTimeout = clearTimeout;
|
|
clearTimeout(obj5.trackTimeout);
|
|
const _clearInterval = clearInterval;
|
|
clearInterval(obj5.flushStorageInterval);
|
|
c2 = 1;
|
|
c3 = 1;
|
|
const obj1 = { value: null, done: false };
|
|
obj1[0] = obj5.getQueuedEvent();
|
|
return obj1;
|
|
}
|
|
}
|
|
} else if (arg0 === 1) {
|
|
c3 = 3;
|
|
throw arg1;
|
|
} else if (arg0 !== 2) {
|
|
items = [arg1];
|
|
let result = outer1_6.submitEventsImmediately(items);
|
|
result.then(() => {
|
|
outer2_9.fileOnly("Successfully tracked latest network usage", items);
|
|
const result = items.writeExistingEventStorage();
|
|
}).catch((status) => {
|
|
if (!tmp) {
|
|
outer2_9.error("Failed to track latest network usage", items, status);
|
|
}
|
|
const existingEvents = items.existingEvents;
|
|
existingEvents.push(items[0]);
|
|
const result = items.writeExistingEventStorage();
|
|
});
|
|
const nextPromise = result.then(() => {
|
|
outer2_9.fileOnly("Successfully tracked latest network usage", items);
|
|
const result = items.writeExistingEventStorage();
|
|
});
|
|
}
|
|
c3 = 3;
|
|
obj = { value: null, done: true };
|
|
obj[0] = arg1;
|
|
return obj;
|
|
} catch (tmp14) {
|
|
c3 = tmp;
|
|
throw tmp14;
|
|
}
|
|
}
|
|
})();
|
|
};
|
|
prototype["getQueuedEvent"] = function getQueuedEvent() {
|
|
return callback(function*() {
|
|
if (guildCount === 2) {
|
|
guildCount = 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 {
|
|
return { value: "HermesInternal", done: null };
|
|
}
|
|
} else {
|
|
try {
|
|
guildCount = 2;
|
|
if (0 === c6) {
|
|
if (arg0 === 1) {
|
|
guildCount = 3;
|
|
throw arg1;
|
|
} else if (arg0 === 2) {
|
|
guildCount = 3;
|
|
obj = { value: null, done: true };
|
|
obj[0] = arg1;
|
|
return obj;
|
|
} else {
|
|
const socket = tmp5;
|
|
let closure_4 = tmp2;
|
|
let callback;
|
|
let lib;
|
|
outer1_19();
|
|
let obj7 = outer1_1(outer1_2[13]);
|
|
c6 = 1;
|
|
guildCount = 1;
|
|
let obj1 = { value: null, done: false };
|
|
obj1[0] = obj7.getAppFirstVisibleTimestamp();
|
|
return obj1;
|
|
}
|
|
} else if (1 === tmp5) {
|
|
if (arg0 === 1) {
|
|
guildCount = 3;
|
|
throw arg1;
|
|
} else if (arg0 === 2) {
|
|
guildCount = 3;
|
|
const obj2 = { value: null, done: true };
|
|
obj2[0] = arg1;
|
|
return obj2;
|
|
} else {
|
|
callback = arg1;
|
|
let obj4 = callback(6832);
|
|
c6 = 2;
|
|
guildCount = 1;
|
|
const obj3 = { value: null, done: false };
|
|
obj3[0] = obj4.getSession();
|
|
return obj3;
|
|
}
|
|
} else if (arg0 === 1) {
|
|
guildCount = 3;
|
|
throw arg1;
|
|
} else if (arg0 === 2) {
|
|
guildCount = 3;
|
|
obj4 = { value: null, done: true };
|
|
obj4[0] = arg1;
|
|
return obj4;
|
|
} else {
|
|
lib = arg1;
|
|
const obj5 = { type: null, properties: null };
|
|
obj5[0] = constants.APP_NETWORK_USAGE;
|
|
const obj6 = {};
|
|
const merged = Object.assign(callback(6843).getDeviceMetadata());
|
|
const _Date = Date;
|
|
obj6.client_track_timestamp = Date.now();
|
|
let uuid;
|
|
if (lib != null) {
|
|
uuid = lib.uuid;
|
|
}
|
|
obj6.client_heartbeat_session_id = uuid;
|
|
obj = callback(6843);
|
|
obj6.load_id = obj.currentLoadId();
|
|
obj6.num_guilds = guildCount.getGuildCount();
|
|
obj6.was_authenticated = lib(9).wasAuthenticated;
|
|
obj6.did_background_app = lib(9).didBackgroundApp;
|
|
obj6.headless_task_ran = lib(9).extraProperties.headless_task_ran;
|
|
const ready = lib(9).ready;
|
|
obj6.ready_payload_duration_ms = ready.serializeEnd(callback);
|
|
let signalStrengthLevel;
|
|
if (signalStrengthLevel != null) {
|
|
signalStrengthLevel = signalStrengthLevel.signalStrengthLevel;
|
|
}
|
|
callback = signalStrengthLevel;
|
|
if (signalStrengthLevel == null) {
|
|
callback = undefined;
|
|
}
|
|
obj6.initial_signal_strength_level = callback;
|
|
signalStrengthLevel = closure_10.signalStrengthLevel;
|
|
lib = signalStrengthLevel;
|
|
if (signalStrengthLevel == null) {
|
|
lib = undefined;
|
|
}
|
|
obj6.final_signal_strength_level = lib;
|
|
let type;
|
|
if (closure_13 != null) {
|
|
type = closure_13.type;
|
|
}
|
|
let dependencyMap = type;
|
|
if (type == null) {
|
|
dependencyMap = undefined;
|
|
}
|
|
obj6.initial_network_type = dependencyMap;
|
|
obj6.final_network_type = closure_12.type;
|
|
let effectiveSpeed;
|
|
if (closure_13 != null) {
|
|
effectiveSpeed = closure_13.effectiveSpeed;
|
|
}
|
|
let c3 = effectiveSpeed;
|
|
if (effectiveSpeed == null) {
|
|
c3 = undefined;
|
|
}
|
|
obj6.initial_cellular_generation = c3;
|
|
obj6.final_cellular_generation = closure_12.effectiveSpeed;
|
|
obj6.is_network_roaming = closure_10.isNetworkRoaming;
|
|
obj6.cellular_receive_bytes = closure_10.cellularReceiveBytes;
|
|
obj6.cellular_send_bytes = closure_10.cellularSendBytes;
|
|
obj6.total_receive_bytes = closure_10.totalReceiveBytes;
|
|
obj6.total_send_bytes = closure_10.totalSendBytes;
|
|
obj6.uid_receive_bytes = closure_10.uidReceiveBytes;
|
|
obj6.uid_send_bytes = closure_10.uidSendBytes;
|
|
obj6.socket_bytes_received = closure_10.socketBytesReceived;
|
|
obj6.ota_bytes_received = closure_10.otaBytesReceived;
|
|
obj6.ota_num_requests = closure_10.otaNumRequests;
|
|
obj6.xhr_bytes_received = closure_10.xhrBytesReceived;
|
|
obj6.xhr_num_requests = closure_10.xhrNumRequests;
|
|
obj6.fresco_bytes_received = closure_10.frescoBytesReceived;
|
|
obj6.fresco_num_requests = closure_10.frescoNumRequests;
|
|
obj6.download_bytes_received = closure_10.downloadBytesReceived;
|
|
obj6.download_num_requests = closure_10.downloadNumRequests;
|
|
obj6.media_player_bytes_received = closure_10.mediaPlayerBytesReceived;
|
|
obj1 = callback(6842);
|
|
obj6.rtc_bytes = obj1.getRTCTotalBytes();
|
|
obj6.num_message_sends = closure_15;
|
|
let tmp56;
|
|
if (0 !== closure_15) {
|
|
tmp56 = closure_16;
|
|
}
|
|
obj6.max_message_send_duration = tmp56;
|
|
let tmp60;
|
|
if (0 !== closure_15) {
|
|
tmp60 = closure_17;
|
|
}
|
|
obj6.max_message_queue_length = tmp60;
|
|
obj6.num_message_send_fails = closure_18;
|
|
obj6.num_identifies = socket.getSocket().identifyCount;
|
|
const renderLatestMessages = lib(9).renderLatestMessages;
|
|
obj6.render_latest_messages_duration_ms = renderLatestMessages.serialize(callback);
|
|
obj5[1] = obj6;
|
|
guildCount = 3;
|
|
obj7 = { value: null, done: true };
|
|
obj7[0] = obj5;
|
|
return obj7;
|
|
}
|
|
} catch (tmp77) {
|
|
guildCount = tmp;
|
|
throw tmp77;
|
|
}
|
|
}
|
|
})();
|
|
};
|
|
let closure_20 = new EventTracker();
|
|
let subscription = require("dispatcher").subscribe("APP_STATE_UPDATE", (state) => {
|
|
closure_20.handleAppStateChange("active" === state.state);
|
|
});
|
|
const subscription1 = require("dispatcher").subscribe("MESSAGE_CREATE", (sendMessageOptions) => {
|
|
sendMessageOptions = sendMessageOptions.sendMessageOptions;
|
|
let sendAnalytics;
|
|
if (sendMessageOptions != null) {
|
|
sendAnalytics = sendMessageOptions.sendAnalytics;
|
|
}
|
|
if (null != sendAnalytics) {
|
|
closure_15 = closure_15 + 1;
|
|
const _Math = Math;
|
|
closure_16 = Math.max(closure_16, sendMessageOptions.sendMessageOptions.sendAnalytics.duration);
|
|
const _Math2 = Math;
|
|
closure_17 = Math.max(closure_17, sendMessageOptions.sendMessageOptions.sendAnalytics.queueSize);
|
|
}
|
|
});
|
|
const subscription2 = require("dispatcher").subscribe("MESSAGE_SEND_FAILED", (arg0) => {
|
|
closure_18 = closure_18 + 1;
|
|
});
|
|
let result = require("_handleConnectionOpen").fileFinishedImporting("modules/network/NetStats.android.tsx");
|
|
|
|
export const isSlowNetwork = function isSlowNetwork() {
|
|
let tmp = obj.type === require(1456) /* configure */.NetInfoStateType.cellular;
|
|
if (tmp) {
|
|
let isNetworkRoaming = null != closure_10.signalStrengthLevel;
|
|
if (isNetworkRoaming) {
|
|
isNetworkRoaming = closure_10.signalStrengthLevel <= 2;
|
|
}
|
|
if (!isNetworkRoaming) {
|
|
isNetworkRoaming = "2g" === obj.effectiveSpeed;
|
|
}
|
|
if (!isNetworkRoaming) {
|
|
isNetworkRoaming = closure_10.isNetworkRoaming;
|
|
}
|
|
tmp = isNetworkRoaming;
|
|
}
|
|
return tmp;
|
|
};
|
|
export const getSignalStrength = function getSignalStrength() {
|
|
return closure_10.signalStrengthLevel;
|
|
};
|