NetMirror.apk
Download file
package com.learnium.RNDeviceInfo;
import android.app.ActivityManager;
import android.app.KeyguardManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.FeatureInfo;
import android.content.pm.PackageInfo;
import android.hardware.camera2.CameraManager;
import android.location.LocationManager;
import android.media.AudioManager;
import android.media.MediaCodecList;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Debug;
import android.os.Environment;
import android.os.PowerManager;
import android.os.Process;
import android.os.StatFs;
import android.os.SystemClock;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import android.webkit.WebSettings;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.WritableArray;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeArray;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import h2.C0556a;
import h2.C0557b;
import java.math.BigInteger;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import v1.InterfaceC0756a;
/* JADX INFO: loaded from: classes.dex */
@InterfaceC0756a(name = RNDeviceModule.NAME)
public class RNDeviceModule extends ReactContextBaseJavaModule {
private static String BATTERY_LEVEL = "batteryLevel";
private static String BATTERY_STATE = "batteryState";
private static String LOW_POWER_MODE = "lowPowerMode";
public static final String NAME = "RNDeviceInfo";
private final C0556a deviceIdResolver;
private final C0557b deviceTypeResolver;
private BroadcastReceiver headphoneBluetoothConnectionReceiver;
private BroadcastReceiver headphoneConnectionReceiver;
private BroadcastReceiver headphoneWiredConnectionReceiver;
private InputMethodManager inputMethodManager;
private g installReferrerClient;
private double mLastBatteryLevel;
private String mLastBatteryState;
private boolean mLastPowerSaveState;
private BroadcastReceiver receiver;
class a extends BroadcastReceiver {
a() {
}
@Override // android.content.BroadcastReceiver
public void onReceive(Context context, Intent intent) {
WritableMap powerStateFromIntent = RNDeviceModule.this.getPowerStateFromIntent(intent);
if (powerStateFromIntent == null) {
return;
}
String string = powerStateFromIntent.getString(RNDeviceModule.BATTERY_STATE);
double d4 = powerStateFromIntent.getDouble(RNDeviceModule.BATTERY_LEVEL);
Double dValueOf = Double.valueOf(d4);
boolean z3 = powerStateFromIntent.getBoolean(RNDeviceModule.LOW_POWER_MODE);
if (!RNDeviceModule.this.mLastBatteryState.equalsIgnoreCase(string) || RNDeviceModule.this.mLastPowerSaveState != z3) {
WritableMap writableMapCreateMap = Arguments.createMap();
writableMapCreateMap.putString(RNDeviceModule.BATTERY_STATE, string);
writableMapCreateMap.putDouble(RNDeviceModule.BATTERY_LEVEL, d4);
writableMapCreateMap.putBoolean(RNDeviceModule.LOW_POWER_MODE, z3);
RNDeviceModule rNDeviceModule = RNDeviceModule.this;
rNDeviceModule.sendEvent(rNDeviceModule.getReactApplicationContext(), "RNDeviceInfo_powerStateDidChange", writableMapCreateMap);
RNDeviceModule.this.mLastBatteryState = string;
RNDeviceModule.this.mLastPowerSaveState = z3;
}
if (RNDeviceModule.this.mLastBatteryLevel != d4) {
RNDeviceModule rNDeviceModule2 = RNDeviceModule.this;
rNDeviceModule2.sendEvent(rNDeviceModule2.getReactApplicationContext(), "RNDeviceInfo_batteryLevelDidChange", dValueOf);
if (d4 <= 0.15d) {
RNDeviceModule rNDeviceModule3 = RNDeviceModule.this;
rNDeviceModule3.sendEvent(rNDeviceModule3.getReactApplicationContext(), "RNDeviceInfo_batteryLevelIsLow", dValueOf);
}
RNDeviceModule.this.mLastBatteryLevel = d4;
}
}
}
class b extends BroadcastReceiver {
b() {
}
@Override // android.content.BroadcastReceiver
public void onReceive(Context context, Intent intent) {
boolean zIsHeadphonesConnectedSync = RNDeviceModule.this.isHeadphonesConnectedSync();
RNDeviceModule rNDeviceModule = RNDeviceModule.this;
rNDeviceModule.sendEvent(rNDeviceModule.getReactApplicationContext(), "RNDeviceInfo_headphoneConnectionDidChange", Boolean.valueOf(zIsHeadphonesConnectedSync));
}
}
class c extends BroadcastReceiver {
c() {
}
@Override // android.content.BroadcastReceiver
public void onReceive(Context context, Intent intent) {
boolean zIsWiredHeadphonesConnectedSync = RNDeviceModule.this.isWiredHeadphonesConnectedSync();
RNDeviceModule rNDeviceModule = RNDeviceModule.this;
rNDeviceModule.sendEvent(rNDeviceModule.getReactApplicationContext(), "RNDeviceInfo_headphoneWiredConnectionDidChange", Boolean.valueOf(zIsWiredHeadphonesConnectedSync));
}
}
class d extends BroadcastReceiver {
d() {
}
@Override // android.content.BroadcastReceiver
public void onReceive(Context context, Intent intent) {
boolean zIsBluetoothHeadphonesConnectedSync = RNDeviceModule.this.isBluetoothHeadphonesConnectedSync();
RNDeviceModule rNDeviceModule = RNDeviceModule.this;
rNDeviceModule.sendEvent(rNDeviceModule.getReactApplicationContext(), "RNDeviceInfo_headphoneBluetoothConnectionDidChange", Boolean.valueOf(zIsBluetoothHeadphonesConnectedSync));
}
}
public RNDeviceModule(ReactApplicationContext reactApplicationContext) {
super(reactApplicationContext);
this.mLastBatteryLevel = -1.0d;
this.mLastBatteryState = "";
this.mLastPowerSaveState = false;
this.deviceTypeResolver = new C0557b(reactApplicationContext);
this.deviceIdResolver = new C0556a(reactApplicationContext);
this.installReferrerClient = new g(reactApplicationContext.getBaseContext());
this.inputMethodManager = (InputMethodManager) reactApplicationContext.getSystemService("input_method");
}
private long getBlockSize(StatFs statFs, Boolean bool) {
return bool.booleanValue() ? statFs.getBlockSizeLong() : statFs.getBlockSize();
}
private BigInteger getDirTotalCapacity(StatFs statFs) {
return BigInteger.valueOf(statFs.getBlockCountLong()).multiply(BigInteger.valueOf(statFs.getBlockSizeLong()));
}
private PackageInfo getPackageInfo() {
return getReactApplicationContext().getPackageManager().getPackageInfo(getReactApplicationContext().getPackageName(), 0);
}
/* JADX INFO: Access modifiers changed from: private */
public WritableMap getPowerStateFromIntent(Intent intent) {
if (intent == null) {
return null;
}
int intExtra = intent.getIntExtra("level", -1);
int intExtra2 = intent.getIntExtra("scale", -1);
int intExtra3 = intent.getIntExtra("plugged", -1);
int intExtra4 = intent.getIntExtra("status", -1);
float f3 = intExtra / intExtra2;
String str = intExtra3 == 0 ? "unplugged" : intExtra4 == 2 ? "charging" : intExtra4 == 5 ? "full" : "unknown";
boolean zIsPowerSaveMode = ((PowerManager) getReactApplicationContext().getSystemService("power")).isPowerSaveMode();
WritableMap writableMapCreateMap = Arguments.createMap();
writableMapCreateMap.putString(BATTERY_STATE, str);
writableMapCreateMap.putDouble(BATTERY_LEVEL, f3);
writableMapCreateMap.putBoolean(LOW_POWER_MODE, zIsPowerSaveMode);
return writableMapCreateMap;
}
public static SharedPreferences getRNDISharedPreferences(Context context) {
return context.getSharedPreferences("react-native-device-info", 0);
}
private long getTotalAvailableBlocks(StatFs statFs, Boolean bool) {
return bool.booleanValue() ? statFs.getAvailableBlocksLong() : statFs.getAvailableBlocks();
}
private WifiInfo getWifiInfo() {
WifiManager wifiManager = (WifiManager) getReactApplicationContext().getApplicationContext().getSystemService("wifi");
if (wifiManager != null) {
return wifiManager.getConnectionInfo();
}
return null;
}
private boolean hasKeyboard(String str) {
List<InputMethodInfo> enabledInputMethodList = this.inputMethodManager.getEnabledInputMethodList();
if (enabledInputMethodList == null || enabledInputMethodList.isEmpty()) {
return false;
}
for (InputMethodInfo inputMethodInfo : enabledInputMethodList) {
String lowerCase = inputMethodInfo.getServiceName().toLowerCase();
String lowerCase2 = inputMethodInfo.getId().toLowerCase();
if (lowerCase.contains(str.toLowerCase()) || lowerCase2.contains(str.toLowerCase())) {
return true;
}
}
return false;
}
private void initializeHeadphoneConnectionReceivers() {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("android.intent.action.HEADSET_PLUG");
intentFilter.addAction("android.media.ACTION_SCO_AUDIO_STATE_UPDATED");
this.headphoneConnectionReceiver = new b();
registerReceiver(getReactApplicationContext(), this.headphoneConnectionReceiver, intentFilter);
new IntentFilter().addAction("android.intent.action.HEADSET_PLUG");
this.headphoneWiredConnectionReceiver = new c();
registerReceiver(getReactApplicationContext(), this.headphoneWiredConnectionReceiver, intentFilter);
new IntentFilter().addAction("android.media.ACTION_SCO_AUDIO_STATE_UPDATED");
this.headphoneBluetoothConnectionReceiver = new d();
registerReceiver(getReactApplicationContext(), this.headphoneBluetoothConnectionReceiver, intentFilter);
}
private Boolean isLowRamDevice() {
return Boolean.valueOf(((ActivityManager) getReactApplicationContext().getSystemService("activity")).isLowRamDevice());
}
private void registerReceiver(Context context, BroadcastReceiver broadcastReceiver, IntentFilter intentFilter) {
if (Build.VERSION.SDK_INT < 34 || context.getApplicationInfo().targetSdkVersion < 34) {
context.registerReceiver(broadcastReceiver, intentFilter);
} else {
context.registerReceiver(broadcastReceiver, intentFilter, 4);
}
}
/* JADX INFO: Access modifiers changed from: private */
public void sendEvent(ReactContext reactContext, String str, Object obj) {
((DeviceEventManagerModule.RCTDeviceEventEmitter) reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)).emit(str, obj);
}
@ReactMethod
public void addListener(String str) {
}
@ReactMethod
public void getAndroidId(Promise promise) {
promise.resolve(getAndroidIdSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getAndroidIdSync() {
return getUniqueIdSync();
}
@ReactMethod
public void getApiLevel(Promise promise) {
promise.resolve(Integer.valueOf(getApiLevelSync()));
}
@ReactMethod(isBlockingSynchronousMethod = true)
public int getApiLevelSync() {
return Build.VERSION.SDK_INT;
}
@ReactMethod
public void getAvailableLocationProviders(Promise promise) {
promise.resolve(getAvailableLocationProvidersSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public WritableMap getAvailableLocationProvidersSync() {
LocationManager locationManager = (LocationManager) getReactApplicationContext().getSystemService("location");
WritableMap writableMapCreateMap = Arguments.createMap();
try {
for (String str : locationManager.getProviders(false)) {
writableMapCreateMap.putBoolean(str, locationManager.isProviderEnabled(str));
}
} catch (Exception unused) {
System.err.println("Unable to get location providers. LocationManager was null");
}
return writableMapCreateMap;
}
@ReactMethod
public void getBaseOs(Promise promise) {
promise.resolve(getBaseOsSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getBaseOsSync() {
return Build.VERSION.BASE_OS;
}
@ReactMethod
public void getBatteryLevel(Promise promise) {
promise.resolve(Double.valueOf(getBatteryLevelSync()));
}
@ReactMethod(isBlockingSynchronousMethod = true)
public double getBatteryLevelSync() {
WritableMap powerStateFromIntent = getPowerStateFromIntent(getReactApplicationContext().registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED")));
if (powerStateFromIntent == null) {
return 0.0d;
}
return powerStateFromIntent.getDouble(BATTERY_LEVEL);
}
@ReactMethod
public void getBootloader(Promise promise) {
promise.resolve(getBootloaderSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getBootloaderSync() {
return Build.BOOTLOADER;
}
@ReactMethod
public void getBuildId(Promise promise) {
promise.resolve(getBuildIdSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getBuildIdSync() {
return Build.ID;
}
@ReactMethod
public void getCarrier(Promise promise) {
promise.resolve(getCarrierSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getCarrierSync() {
TelephonyManager telephonyManager = (TelephonyManager) getReactApplicationContext().getSystemService("phone");
if (telephonyManager != null) {
return telephonyManager.getNetworkOperatorName();
}
System.err.println("Unable to get network operator name. TelephonyManager was null");
return "unknown";
}
@ReactMethod
public void getCodename(Promise promise) {
promise.resolve(getCodenameSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getCodenameSync() {
return Build.VERSION.CODENAME;
}
@Override // com.facebook.react.bridge.BaseJavaModule
public Map<String, Object> getConstants() {
String str;
String string;
String string2;
try {
str = getPackageInfo().versionName;
string = Integer.toString(getPackageInfo().versionCode);
string2 = getReactApplicationContext().getApplicationInfo().loadLabel(getReactApplicationContext().getPackageManager()).toString();
} catch (Exception unused) {
str = "unknown";
string = "unknown";
string2 = string;
}
HashMap map = new HashMap();
map.put("deviceId", Build.BOARD);
map.put("bundleId", getReactApplicationContext().getPackageName());
map.put("systemName", "Android");
map.put("systemVersion", Build.VERSION.RELEASE);
map.put("appVersion", str);
map.put("buildNumber", string);
map.put("isTablet", Boolean.valueOf(this.deviceTypeResolver.d()));
map.put("isLowRamDevice", isLowRamDevice());
map.put("appName", string2);
map.put("brand", Build.BRAND);
map.put("model", Build.MODEL);
map.put("deviceType", this.deviceTypeResolver.a().b());
return map;
}
@ReactMethod
public void getDevice(Promise promise) {
promise.resolve(getDeviceSync());
}
@ReactMethod
public void getDeviceName(Promise promise) {
promise.resolve(getDeviceNameSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getDeviceNameSync() {
String string;
try {
int i3 = Build.VERSION.SDK_INT;
if (i3 <= 31 && (string = Settings.Secure.getString(getReactApplicationContext().getContentResolver(), "bluetooth_name")) != null) {
return string;
}
if (i3 < 25) {
return "unknown";
}
String string2 = Settings.Global.getString(getReactApplicationContext().getContentResolver(), "device_name");
return string2 != null ? string2 : "unknown";
} catch (Exception unused) {
return "unknown";
}
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getDeviceSync() {
return Build.DEVICE;
}
@ReactMethod
public void getDisplay(Promise promise) {
promise.resolve(getDisplaySync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getDisplaySync() {
return Build.DISPLAY;
}
@ReactMethod
public void getFingerprint(Promise promise) {
promise.resolve(getFingerprintSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getFingerprintSync() {
return Build.FINGERPRINT;
}
@ReactMethod
public void getFirstInstallTime(Promise promise) {
promise.resolve(Double.valueOf(getFirstInstallTimeSync()));
}
@ReactMethod(isBlockingSynchronousMethod = true)
public double getFirstInstallTimeSync() {
try {
return getPackageInfo().firstInstallTime;
} catch (Exception unused) {
return -1.0d;
}
}
@ReactMethod
public void getFontScale(Promise promise) {
promise.resolve(Float.valueOf(getFontScaleSync()));
}
@ReactMethod(isBlockingSynchronousMethod = true)
public float getFontScaleSync() {
return getReactApplicationContext().getResources().getConfiguration().fontScale;
}
@ReactMethod
public void getFreeDiskStorage(Promise promise) {
promise.resolve(Double.valueOf(getFreeDiskStorageSync()));
}
@ReactMethod
public void getFreeDiskStorageOld(Promise promise) {
promise.resolve(Double.valueOf(getFreeDiskStorageOldSync()));
}
@ReactMethod(isBlockingSynchronousMethod = true)
public double getFreeDiskStorageOldSync() {
try {
StatFs statFs = new StatFs(Environment.getExternalStorageDirectory().getAbsolutePath());
return BigInteger.valueOf(statFs.getAvailableBlocksLong()).multiply(BigInteger.valueOf(statFs.getBlockSizeLong())).doubleValue();
} catch (Exception unused) {
return -1.0d;
}
}
@ReactMethod(isBlockingSynchronousMethod = true)
public double getFreeDiskStorageSync() {
try {
StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath());
StatFs statFs2 = new StatFs(Environment.getDataDirectory().getAbsolutePath());
return BigInteger.valueOf(getTotalAvailableBlocks(statFs, true)).multiply(BigInteger.valueOf(getBlockSize(statFs, true))).doubleValue() + BigInteger.valueOf(getTotalAvailableBlocks(statFs2, true)).multiply(BigInteger.valueOf(getBlockSize(statFs2, true))).doubleValue();
} catch (Exception unused) {
return -1.0d;
}
}
@ReactMethod
public void getHardware(Promise promise) {
promise.resolve(getHardwareSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getHardwareSync() {
return Build.HARDWARE;
}
@ReactMethod
public void getHost(Promise promise) {
promise.resolve(getHostSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getHostSync() {
return Build.HOST;
}
@ReactMethod
public void getIncremental(Promise promise) {
promise.resolve(getIncrementalSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getIncrementalSync() {
return Build.VERSION.INCREMENTAL;
}
@ReactMethod
public void getInstallReferrer(Promise promise) {
promise.resolve(getInstallReferrerSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getInstallReferrerSync() {
return getRNDISharedPreferences(getReactApplicationContext()).getString("installReferrer", "unknown");
}
@ReactMethod
public void getInstallerPackageName(Promise promise) {
promise.resolve(getInstallerPackageNameSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getInstallerPackageNameSync() {
String installerPackageName = getReactApplicationContext().getPackageManager().getInstallerPackageName(getReactApplicationContext().getPackageName());
return installerPackageName == null ? "unknown" : installerPackageName;
}
@ReactMethod
public void getInstanceId(Promise promise) {
promise.resolve(getInstanceIdSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getInstanceIdSync() {
return this.deviceIdResolver.d();
}
@ReactMethod
public void getIpAddress(Promise promise) {
promise.resolve(getIpAddressSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getIpAddressSync() {
try {
return InetAddress.getByAddress(ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putInt(getWifiInfo().getIpAddress()).array()).getHostAddress();
} catch (Exception unused) {
return "unknown";
}
}
@ReactMethod
public void getLastUpdateTime(Promise promise) {
promise.resolve(Double.valueOf(getLastUpdateTimeSync()));
}
@ReactMethod(isBlockingSynchronousMethod = true)
public double getLastUpdateTimeSync() {
try {
return getPackageInfo().lastUpdateTime;
} catch (Exception unused) {
return -1.0d;
}
}
@ReactMethod
public void getMacAddress(Promise promise) {
promise.resolve(getMacAddressSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getMacAddressSync() {
WifiInfo wifiInfo = getWifiInfo();
String macAddress = wifiInfo != null ? wifiInfo.getMacAddress() : "";
if (getReactApplicationContext().checkCallingOrSelfPermission("android.permission.INTERNET") == 0) {
try {
for (NetworkInterface networkInterface : Collections.list(NetworkInterface.getNetworkInterfaces())) {
if (networkInterface.getName().equalsIgnoreCase("wlan0")) {
byte[] hardwareAddress = networkInterface.getHardwareAddress();
if (hardwareAddress == null) {
macAddress = "";
} else {
StringBuilder sb = new StringBuilder();
for (byte b4 : hardwareAddress) {
sb.append(String.format("%02X:", Byte.valueOf(b4)));
}
if (sb.length() > 0) {
sb.deleteCharAt(sb.length() - 1);
}
macAddress = sb.toString();
}
}
}
} catch (Exception unused) {
}
}
return macAddress;
}
@ReactMethod
public void getMaxMemory(Promise promise) {
promise.resolve(Double.valueOf(getMaxMemorySync()));
}
@ReactMethod(isBlockingSynchronousMethod = true)
public double getMaxMemorySync() {
return Runtime.getRuntime().maxMemory();
}
@Override // com.facebook.react.bridge.NativeModule
public String getName() {
return NAME;
}
@ReactMethod
public void getPowerState(Promise promise) {
promise.resolve(getPowerStateSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public WritableMap getPowerStateSync() {
return getPowerStateFromIntent(getReactApplicationContext().registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED")));
}
@ReactMethod
public void getPreviewSdkInt(Promise promise) {
promise.resolve(getPreviewSdkIntSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getPreviewSdkIntSync() {
return Integer.toString(Build.VERSION.PREVIEW_SDK_INT);
}
@ReactMethod
public void getProduct(Promise promise) {
promise.resolve(getProductSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getProductSync() {
return Build.PRODUCT;
}
@ReactMethod
public void getSecurityPatch(Promise promise) {
promise.resolve(getSecurityPatchSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getSecurityPatchSync() {
return Build.VERSION.SECURITY_PATCH;
}
@ReactMethod
public void getSerialNumber(Promise promise) {
promise.resolve(getSerialNumberSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getSerialNumberSync() {
try {
return Build.VERSION.SDK_INT >= 26 ? Build.getSerial() : Build.SERIAL;
} catch (Exception e4) {
System.err.println("getSerialNumber failed, it probably should not be used: " + e4.getMessage());
return "unknown";
}
}
@ReactMethod
public void getStartupTime(Promise promise) {
promise.resolve(Double.valueOf(getStartupTimeSync()));
}
@ReactMethod(isBlockingSynchronousMethod = true)
public double getStartupTimeSync() {
long jCurrentTimeMillis = System.currentTimeMillis();
return BigInteger.valueOf((jCurrentTimeMillis - SystemClock.uptimeMillis()) + Process.getStartUptimeMillis()).doubleValue();
}
@ReactMethod
public void getSupported32BitAbis(Promise promise) {
promise.resolve(getSupported32BitAbisSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public WritableArray getSupported32BitAbisSync() {
WritableNativeArray writableNativeArray = new WritableNativeArray();
for (String str : Build.SUPPORTED_32_BIT_ABIS) {
writableNativeArray.pushString(str);
}
return writableNativeArray;
}
@ReactMethod
public void getSupported64BitAbis(Promise promise) {
promise.resolve(getSupported64BitAbisSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public WritableArray getSupported64BitAbisSync() {
WritableNativeArray writableNativeArray = new WritableNativeArray();
for (String str : Build.SUPPORTED_64_BIT_ABIS) {
writableNativeArray.pushString(str);
}
return writableNativeArray;
}
@ReactMethod
public void getSupportedAbis(Promise promise) {
promise.resolve(getSupportedAbisSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public WritableArray getSupportedAbisSync() {
WritableNativeArray writableNativeArray = new WritableNativeArray();
for (String str : Build.SUPPORTED_ABIS) {
writableNativeArray.pushString(str);
}
return writableNativeArray;
}
@ReactMethod
public void getSupportedMediaTypeList(Promise promise) {
promise.resolve(getSupportedMediaTypeListSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public WritableArray getSupportedMediaTypeListSync() {
WritableNativeArray writableNativeArray = new WritableNativeArray();
for (int i3 = 0; i3 < MediaCodecList.getCodecCount(); i3++) {
for (String str : MediaCodecList.getCodecInfoAt(i3).getSupportedTypes()) {
writableNativeArray.pushString(str);
}
}
return writableNativeArray;
}
@ReactMethod
public void getSystemAvailableFeatures(Promise promise) {
promise.resolve(getSystemAvailableFeaturesSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public WritableArray getSystemAvailableFeaturesSync() {
FeatureInfo[] systemAvailableFeatures = getReactApplicationContext().getPackageManager().getSystemAvailableFeatures();
WritableArray writableArrayCreateArray = Arguments.createArray();
for (FeatureInfo featureInfo : systemAvailableFeatures) {
String str = featureInfo.name;
if (str != null) {
writableArrayCreateArray.pushString(str);
}
}
return writableArrayCreateArray;
}
@ReactMethod
public void getSystemManufacturer(Promise promise) {
promise.resolve(getSystemManufacturerSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getSystemManufacturerSync() {
return Build.MANUFACTURER;
}
@ReactMethod
public void getTags(Promise promise) {
promise.resolve(getTagsSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getTagsSync() {
return Build.TAGS;
}
@ReactMethod
public void getTotalDiskCapacity(Promise promise) {
promise.resolve(Double.valueOf(getTotalDiskCapacitySync()));
}
@ReactMethod
public void getTotalDiskCapacityOld(Promise promise) {
promise.resolve(Double.valueOf(getTotalDiskCapacityOldSync()));
}
@ReactMethod(isBlockingSynchronousMethod = true)
@Deprecated
public double getTotalDiskCapacityOldSync() {
try {
StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath());
return BigInteger.valueOf(statFs.getBlockCount()).multiply(BigInteger.valueOf(statFs.getBlockSize())).doubleValue();
} catch (Exception unused) {
return -1.0d;
}
}
@ReactMethod(isBlockingSynchronousMethod = true)
public double getTotalDiskCapacitySync() {
try {
return getDirTotalCapacity(new StatFs(Environment.getRootDirectory().getAbsolutePath())).add(getDirTotalCapacity(new StatFs(Environment.getDataDirectory().getAbsolutePath()))).doubleValue();
} catch (Exception unused) {
return -1.0d;
}
}
@ReactMethod
public void getTotalMemory(Promise promise) {
promise.resolve(Double.valueOf(getTotalMemorySync()));
}
@ReactMethod(isBlockingSynchronousMethod = true)
public double getTotalMemorySync() {
ActivityManager activityManager = (ActivityManager) getReactApplicationContext().getSystemService("activity");
ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
if (activityManager != null) {
activityManager.getMemoryInfo(memoryInfo);
return memoryInfo.totalMem;
}
System.err.println("Unable to getMemoryInfo. ActivityManager was null");
return -1.0d;
}
@ReactMethod
public void getType(Promise promise) {
promise.resolve(getTypeSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getTypeSync() {
return Build.TYPE;
}
@ReactMethod
public void getUniqueId(Promise promise) {
promise.resolve(getUniqueIdSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getUniqueIdSync() {
return Settings.Secure.getString(getReactApplicationContext().getContentResolver(), "android_id");
}
@ReactMethod
public void getUsedMemory(Promise promise) {
promise.resolve(Double.valueOf(getUsedMemorySync()));
}
@ReactMethod(isBlockingSynchronousMethod = true)
public double getUsedMemorySync() {
ActivityManager activityManager = (ActivityManager) getReactApplicationContext().getSystemService("activity");
if (activityManager == null) {
System.err.println("Unable to getProcessMemoryInfo. ActivityManager was null");
return -1.0d;
}
Debug.MemoryInfo[] processMemoryInfo = activityManager.getProcessMemoryInfo(new int[]{Process.myPid()});
if (processMemoryInfo.length == 1) {
return ((double) processMemoryInfo[0].getTotalPss()) * 1024.0d;
}
System.err.println("Unable to getProcessMemoryInfo. getProcessMemoryInfo did not return any info for the PID");
return -1.0d;
}
@ReactMethod
public void getUserAgent(Promise promise) {
promise.resolve(getUserAgentSync());
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getUserAgentSync() {
try {
return WebSettings.getDefaultUserAgent(getReactApplicationContext());
} catch (RuntimeException unused) {
return System.getProperty("http.agent");
}
}
@ReactMethod
public void hasGms(Promise promise) {
promise.resolve(Boolean.valueOf(hasGmsSync()));
}
@ReactMethod(isBlockingSynchronousMethod = true)
public boolean hasGmsSync() {
try {
Object objInvoke = Class.forName("com.google.android.gms.common.GoogleApiAvailability").getMethod("getInstance", new Class[0]).invoke(null, new Object[0]);
return ((Integer) objInvoke.getClass().getMethod("isGooglePlayServicesAvailable", Context.class).invoke(objInvoke, getReactApplicationContext())).intValue() == 0;
} catch (Exception unused) {
return false;
}
}
@ReactMethod
public void hasHms(Promise promise) {
promise.resolve(Boolean.valueOf(hasHmsSync()));
}
@ReactMethod(isBlockingSynchronousMethod = true)
public boolean hasHmsSync() {
try {
Object objInvoke = Class.forName("com.huawei.hms.api.HuaweiApiAvailability").getMethod("getInstance", new Class[0]).invoke(null, new Object[0]);
return ((Integer) objInvoke.getClass().getMethod("isHuaweiMobileServicesAvailable", Context.class).invoke(objInvoke, getReactApplicationContext())).intValue() == 0;
} catch (Exception unused) {
return false;
}
}
@ReactMethod
public void hasSystemFeature(String str, Promise promise) {
promise.resolve(Boolean.valueOf(hasSystemFeatureSync(str)));
}
@ReactMethod(isBlockingSynchronousMethod = true)
public boolean hasSystemFeatureSync(String str) {
if (str == null || str.equals("")) {
return false;
}
return getReactApplicationContext().getPackageManager().hasSystemFeature(str);
}
@Override // com.facebook.react.bridge.BaseJavaModule, com.facebook.react.bridge.NativeModule, com.facebook.react.turbomodule.core.interfaces.TurboModule
public void initialize() {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("android.intent.action.BATTERY_CHANGED");
intentFilter.addAction("android.intent.action.ACTION_POWER_CONNECTED");
intentFilter.addAction("android.intent.action.ACTION_POWER_DISCONNECTED");
intentFilter.addAction("android.os.action.POWER_SAVE_MODE_CHANGED");
this.receiver = new a();
registerReceiver(getReactApplicationContext(), this.receiver, intentFilter);
initializeHeadphoneConnectionReceivers();
}
@Override // com.facebook.react.bridge.BaseJavaModule, com.facebook.react.bridge.NativeModule, com.facebook.react.turbomodule.core.interfaces.TurboModule
public void invalidate() {
getReactApplicationContext().unregisterReceiver(this.receiver);
getReactApplicationContext().unregisterReceiver(this.headphoneConnectionReceiver);
getReactApplicationContext().unregisterReceiver(this.headphoneWiredConnectionReceiver);
getReactApplicationContext().unregisterReceiver(this.headphoneBluetoothConnectionReceiver);
}
@ReactMethod
public void isAirplaneMode(Promise promise) {
promise.resolve(Boolean.valueOf(isAirplaneModeSync()));
}
@ReactMethod(isBlockingSynchronousMethod = true)
public boolean isAirplaneModeSync() {
return Settings.Global.getInt(getReactApplicationContext().getContentResolver(), "airplane_mode_on", 0) != 0;
}
@ReactMethod
public void isBatteryCharging(Promise promise) {
promise.resolve(Boolean.valueOf(isBatteryChargingSync()));
}
@ReactMethod(isBlockingSynchronousMethod = true)
public boolean isBatteryChargingSync() {
Intent intentRegisterReceiver = getReactApplicationContext().registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED"));
return (intentRegisterReceiver != null ? intentRegisterReceiver.getIntExtra("status", -1) : 0) == 2;
}
@ReactMethod
public void isBluetoothHeadphonesConnected(Promise promise) {
promise.resolve(Boolean.valueOf(isBluetoothHeadphonesConnectedSync()));
}
@ReactMethod(isBlockingSynchronousMethod = true)
public boolean isBluetoothHeadphonesConnectedSync() {
return ((AudioManager) getReactApplicationContext().getSystemService("audio")).isBluetoothA2dpOn();
}
@ReactMethod
public void isCameraPresent(Promise promise) {
promise.resolve(Boolean.valueOf(isCameraPresentSync()));
}
@ReactMethod(isBlockingSynchronousMethod = true)
public boolean isCameraPresentSync() {
try {
return ((CameraManager) getReactApplicationContext().getSystemService("camera")).getCameraIdList().length > 0;
} catch (Exception unused) {
return false;
}
}
@ReactMethod
public void isEmulator(Promise promise) {
promise.resolve(Boolean.valueOf(isEmulatorSync()));
}
@ReactMethod(isBlockingSynchronousMethod = true)
public boolean isEmulatorSync() {
String str = Build.FINGERPRINT;
if (!str.startsWith("generic") && !str.startsWith("unknown")) {
String str2 = Build.MODEL;
if (!str2.contains("google_sdk")) {
Locale locale = Locale.ROOT;
if (!str2.toLowerCase(locale).contains("droid4x") && !str2.contains("Emulator") && !str2.contains("Android SDK built for x86") && !Build.MANUFACTURER.contains("Genymotion")) {
String str3 = Build.HARDWARE;
if (!str3.contains("goldfish") && !str3.contains("ranchu") && !str3.contains("vbox86")) {
String str4 = Build.PRODUCT;
if (!str4.contains("sdk") && !str4.contains("google_sdk") && !str4.contains("sdk_google") && !str4.contains("sdk_x86") && !str4.contains("vbox86p") && !str4.contains("emulator") && !str4.contains("simulator") && !Build.BOARD.toLowerCase(locale).contains("nox") && !Build.BOOTLOADER.toLowerCase(locale).contains("nox") && !str3.toLowerCase(locale).contains("nox") && !str4.toLowerCase(locale).contains("nox") && !Build.SERIAL.toLowerCase(locale).contains("nox") && ((!Build.BRAND.startsWith("generic") || !Build.DEVICE.startsWith("generic")) && !hasKeyboard("memuime"))) {
return false;
}
}
}
}
}
return true;
}
@ReactMethod
public void isHeadphonesConnected(Promise promise) {
promise.resolve(Boolean.valueOf(isHeadphonesConnectedSync()));
}
@ReactMethod(isBlockingSynchronousMethod = true)
public boolean isHeadphonesConnectedSync() {
AudioManager audioManager = (AudioManager) getReactApplicationContext().getSystemService("audio");
return audioManager.isWiredHeadsetOn() || audioManager.isBluetoothA2dpOn();
}
@ReactMethod
public void isLocationEnabled(Promise promise) {
promise.resolve(Boolean.valueOf(isLocationEnabledSync()));
}
@ReactMethod(isBlockingSynchronousMethod = true)
public boolean isLocationEnabledSync() {
if (Build.VERSION.SDK_INT < 28) {
return Settings.Secure.getInt(getReactApplicationContext().getContentResolver(), "location_mode", 0) != 0;
}
try {
return ((LocationManager) getReactApplicationContext().getSystemService("location")).isLocationEnabled();
} catch (Exception unused) {
System.err.println("Unable to determine if location enabled. LocationManager was null");
return false;
}
}
@ReactMethod
public void isPinOrFingerprintSet(Promise promise) {
promise.resolve(Boolean.valueOf(isPinOrFingerprintSetSync()));
}
@ReactMethod(isBlockingSynchronousMethod = true)
public boolean isPinOrFingerprintSetSync() {
KeyguardManager keyguardManager = (KeyguardManager) getReactApplicationContext().getSystemService("keyguard");
if (keyguardManager != null) {
return keyguardManager.isKeyguardSecure();
}
System.err.println("Unable to determine keyguard status. KeyguardManager was null");
return false;
}
@ReactMethod
public void isWiredHeadphonesConnected(Promise promise) {
promise.resolve(Boolean.valueOf(isWiredHeadphonesConnectedSync()));
}
@ReactMethod(isBlockingSynchronousMethod = true)
public boolean isWiredHeadphonesConnectedSync() {
return ((AudioManager) getReactApplicationContext().getSystemService("audio")).isWiredHeadsetOn();
}
@Override // com.facebook.react.bridge.NativeModule
public void onCatalystInstanceDestroy() {
invalidate();
}
@ReactMethod
public void removeListeners(Integer num) {
}
}
⚠️ This content was hidden by an advertisement filtering extension in your browser. Please disable it and reload the page to access the decompiled content.
We only display one small text ad to keep this service free. Here's what it looks like:
Read the Docs for Business: You write the docs. We do the rest.
Try it today!Ad by EthicalAds
Download file