- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
259 lines
11 KiB
Java
259 lines
11 KiB
Java
package com.facebook.devicerequests.internal;
|
|
|
|
import android.annotation.TargetApi;
|
|
import android.graphics.Bitmap;
|
|
import android.net.nsd.NsdManager;
|
|
import android.net.nsd.NsdServiceInfo;
|
|
import android.os.Build;
|
|
import androidx.core.view.ViewCompat;
|
|
import com.facebook.FacebookSdk;
|
|
import com.facebook.internal.FetchedAppSettings;
|
|
import com.facebook.internal.FetchedAppSettingsManager;
|
|
import com.facebook.internal.SmartLoginOption;
|
|
import com.facebook.internal.Utility;
|
|
import com.facebook.internal.instrument.crashshield.CrashShieldHandler;
|
|
import com.google.zxing.BarcodeFormat;
|
|
import com.google.zxing.EncodeHintType;
|
|
import com.google.zxing.MultiFormatWriter;
|
|
import com.google.zxing.WriterException;
|
|
import com.google.zxing.common.BitMatrix;
|
|
import java.util.EnumMap;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import kotlin.text.StringsKt__StringsJVMKt;
|
|
import org.json.JSONObject;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public final class DeviceRequestsHelper {
|
|
public static final String DEVICE_INFO_DEVICE = "device";
|
|
public static final String DEVICE_INFO_MODEL = "model";
|
|
public static final String DEVICE_INFO_PARAM = "device_info";
|
|
public static final String DEVICE_TARGET_USER_ID = "target_user_id";
|
|
public static final String SDK_FLAVOR = "android";
|
|
public static final String SDK_HEADER = "fbsdk";
|
|
public static final String SERVICE_TYPE = "_fb._tcp.";
|
|
public static final DeviceRequestsHelper INSTANCE = new DeviceRequestsHelper();
|
|
private static final String TAG = DeviceRequestsHelper.class.getCanonicalName();
|
|
private static final HashMap<String, NsdManager.RegistrationListener> deviceRequestsListeners = new HashMap<>();
|
|
|
|
private DeviceRequestsHelper() {
|
|
}
|
|
|
|
public static final String getDeviceInfo(Map<String, String> map) {
|
|
if (CrashShieldHandler.isObjectCrashing(DeviceRequestsHelper.class)) {
|
|
return null;
|
|
}
|
|
if (map == null) {
|
|
try {
|
|
map = new HashMap<>();
|
|
} catch (Throwable th) {
|
|
CrashShieldHandler.handleThrowable(th, DeviceRequestsHelper.class);
|
|
return null;
|
|
}
|
|
}
|
|
String DEVICE = Build.DEVICE;
|
|
Intrinsics.checkNotNullExpressionValue(DEVICE, "DEVICE");
|
|
map.put("device", DEVICE);
|
|
String MODEL = Build.MODEL;
|
|
Intrinsics.checkNotNullExpressionValue(MODEL, "MODEL");
|
|
map.put("model", MODEL);
|
|
String jSONObject = new JSONObject(map).toString();
|
|
Intrinsics.checkNotNullExpressionValue(jSONObject, "JSONObject(deviceInfo as Map<*, *>).toString()");
|
|
return jSONObject;
|
|
}
|
|
|
|
public static final String getDeviceInfo() {
|
|
if (CrashShieldHandler.isObjectCrashing(DeviceRequestsHelper.class)) {
|
|
return null;
|
|
}
|
|
try {
|
|
return getDeviceInfo(null);
|
|
} catch (Throwable th) {
|
|
CrashShieldHandler.handleThrowable(th, DeviceRequestsHelper.class);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static final boolean startAdvertisementService(String str) {
|
|
if (CrashShieldHandler.isObjectCrashing(DeviceRequestsHelper.class)) {
|
|
return false;
|
|
}
|
|
try {
|
|
if (isAvailable()) {
|
|
return INSTANCE.startAdvertisementServiceImpl(str);
|
|
}
|
|
return false;
|
|
} catch (Throwable th) {
|
|
CrashShieldHandler.handleThrowable(th, DeviceRequestsHelper.class);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static final boolean isAvailable() {
|
|
if (CrashShieldHandler.isObjectCrashing(DeviceRequestsHelper.class)) {
|
|
return false;
|
|
}
|
|
try {
|
|
FetchedAppSettingsManager fetchedAppSettingsManager = FetchedAppSettingsManager.INSTANCE;
|
|
FetchedAppSettings appSettingsWithoutQuery = FetchedAppSettingsManager.getAppSettingsWithoutQuery(FacebookSdk.getApplicationId());
|
|
if (appSettingsWithoutQuery != null) {
|
|
return appSettingsWithoutQuery.getSmartLoginOptions().contains(SmartLoginOption.Enabled);
|
|
}
|
|
return false;
|
|
} catch (Throwable th) {
|
|
CrashShieldHandler.handleThrowable(th, DeviceRequestsHelper.class);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static final Bitmap generateQRCode(String str) {
|
|
int height;
|
|
int width;
|
|
int[] iArr;
|
|
Bitmap createBitmap;
|
|
Bitmap bitmap = null;
|
|
if (CrashShieldHandler.isObjectCrashing(DeviceRequestsHelper.class)) {
|
|
return null;
|
|
}
|
|
try {
|
|
EnumMap enumMap = new EnumMap(EncodeHintType.class);
|
|
enumMap.put((EnumMap) EncodeHintType.MARGIN, (EncodeHintType) 2);
|
|
try {
|
|
BitMatrix encode = new MultiFormatWriter().encode(str, BarcodeFormat.QR_CODE, 200, 200, enumMap);
|
|
height = encode.getHeight();
|
|
width = encode.getWidth();
|
|
iArr = new int[height * width];
|
|
if (height > 0) {
|
|
int i = 0;
|
|
while (true) {
|
|
int i2 = i + 1;
|
|
int i3 = i * width;
|
|
if (width > 0) {
|
|
int i4 = 0;
|
|
while (true) {
|
|
int i5 = i4 + 1;
|
|
iArr[i3 + i4] = encode.get(i4, i) ? ViewCompat.MEASURED_STATE_MASK : -1;
|
|
if (i5 >= width) {
|
|
break;
|
|
}
|
|
i4 = i5;
|
|
}
|
|
}
|
|
if (i2 >= height) {
|
|
break;
|
|
}
|
|
i = i2;
|
|
}
|
|
}
|
|
createBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
|
} catch (WriterException unused) {
|
|
}
|
|
try {
|
|
createBitmap.setPixels(iArr, 0, width, 0, 0, width, height);
|
|
return createBitmap;
|
|
} catch (WriterException unused2) {
|
|
bitmap = createBitmap;
|
|
return bitmap;
|
|
}
|
|
} catch (Throwable th) {
|
|
CrashShieldHandler.handleThrowable(th, DeviceRequestsHelper.class);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static final void cleanUpAdvertisementService(String str) {
|
|
if (CrashShieldHandler.isObjectCrashing(DeviceRequestsHelper.class)) {
|
|
return;
|
|
}
|
|
try {
|
|
INSTANCE.cleanUpAdvertisementServiceImpl(str);
|
|
} catch (Throwable th) {
|
|
CrashShieldHandler.handleThrowable(th, DeviceRequestsHelper.class);
|
|
}
|
|
}
|
|
|
|
@TargetApi(16)
|
|
private final boolean startAdvertisementServiceImpl(final String str) {
|
|
String replace$default;
|
|
if (CrashShieldHandler.isObjectCrashing(this)) {
|
|
return false;
|
|
}
|
|
try {
|
|
HashMap<String, NsdManager.RegistrationListener> hashMap = deviceRequestsListeners;
|
|
if (hashMap.containsKey(str)) {
|
|
return true;
|
|
}
|
|
replace$default = StringsKt__StringsJVMKt.replace$default(FacebookSdk.getSdkVersion(), '.', '|', false, 4, (Object) null);
|
|
final String str2 = "fbsdk_" + Intrinsics.stringPlus("android-", replace$default) + '_' + ((Object) str);
|
|
NsdServiceInfo nsdServiceInfo = new NsdServiceInfo();
|
|
nsdServiceInfo.setServiceType(SERVICE_TYPE);
|
|
nsdServiceInfo.setServiceName(str2);
|
|
nsdServiceInfo.setPort(80);
|
|
Object systemService = FacebookSdk.getApplicationContext().getSystemService("servicediscovery");
|
|
if (systemService == null) {
|
|
throw new NullPointerException("null cannot be cast to non-null type android.net.nsd.NsdManager");
|
|
}
|
|
NsdManager.RegistrationListener registrationListener = new NsdManager.RegistrationListener() { // from class: com.facebook.devicerequests.internal.DeviceRequestsHelper$startAdvertisementServiceImpl$nsdRegistrationListener$1
|
|
@Override // android.net.nsd.NsdManager.RegistrationListener
|
|
public void onServiceUnregistered(NsdServiceInfo serviceInfo) {
|
|
Intrinsics.checkNotNullParameter(serviceInfo, "serviceInfo");
|
|
}
|
|
|
|
@Override // android.net.nsd.NsdManager.RegistrationListener
|
|
public void onUnregistrationFailed(NsdServiceInfo serviceInfo, int i) {
|
|
Intrinsics.checkNotNullParameter(serviceInfo, "serviceInfo");
|
|
}
|
|
|
|
@Override // android.net.nsd.NsdManager.RegistrationListener
|
|
public void onServiceRegistered(NsdServiceInfo NsdServiceInfo) {
|
|
Intrinsics.checkNotNullParameter(NsdServiceInfo, "NsdServiceInfo");
|
|
if (Intrinsics.areEqual(str2, NsdServiceInfo.getServiceName())) {
|
|
return;
|
|
}
|
|
DeviceRequestsHelper deviceRequestsHelper = DeviceRequestsHelper.INSTANCE;
|
|
DeviceRequestsHelper.cleanUpAdvertisementService(str);
|
|
}
|
|
|
|
@Override // android.net.nsd.NsdManager.RegistrationListener
|
|
public void onRegistrationFailed(NsdServiceInfo serviceInfo, int i) {
|
|
Intrinsics.checkNotNullParameter(serviceInfo, "serviceInfo");
|
|
DeviceRequestsHelper deviceRequestsHelper = DeviceRequestsHelper.INSTANCE;
|
|
DeviceRequestsHelper.cleanUpAdvertisementService(str);
|
|
}
|
|
};
|
|
hashMap.put(str, registrationListener);
|
|
((NsdManager) systemService).registerService(nsdServiceInfo, 1, registrationListener);
|
|
return true;
|
|
} catch (Throwable th) {
|
|
CrashShieldHandler.handleThrowable(th, this);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
@TargetApi(16)
|
|
private final void cleanUpAdvertisementServiceImpl(String str) {
|
|
if (CrashShieldHandler.isObjectCrashing(this)) {
|
|
return;
|
|
}
|
|
try {
|
|
NsdManager.RegistrationListener registrationListener = deviceRequestsListeners.get(str);
|
|
if (registrationListener != null) {
|
|
Object systemService = FacebookSdk.getApplicationContext().getSystemService("servicediscovery");
|
|
if (systemService == null) {
|
|
throw new NullPointerException("null cannot be cast to non-null type android.net.nsd.NsdManager");
|
|
}
|
|
try {
|
|
((NsdManager) systemService).unregisterService(registrationListener);
|
|
} catch (IllegalArgumentException e) {
|
|
Utility utility = Utility.INSTANCE;
|
|
Utility.logd(TAG, e);
|
|
}
|
|
deviceRequestsListeners.remove(str);
|
|
}
|
|
} catch (Throwable th) {
|
|
CrashShieldHandler.handleThrowable(th, this);
|
|
}
|
|
}
|
|
}
|