ik.java 源代码
package com.inmobi.media;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.location.LocationManager;
import android.os.Build;
import android.telephony.CellInfo;
import android.telephony.CellLocation;
import android.telephony.TelephonyManager;
import android.telephony.cdma.CdmaCellLocation;
import android.telephony.gsm.GsmCellLocation;
import androidx.annotation.NonNull;
import com.x8zs.plugin.android.net.http.Headers;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.json.JSONArray;
@TargetApi(17)
public class ik {
private static final String f15801a = "ik";
private static boolean a(int i6, int i7) {
return (i6 & i7) == i7;
}
private static int[] b(String str) {
int[] iArr = {-1, -1};
if (str != null && !"".equals(str)) {
try {
int parseInt = Integer.parseInt(str.substring(0, 3));
int parseInt2 = Integer.parseInt(str.substring(3));
iArr[0] = parseInt;
iArr[1] = parseInt2;
} catch (IndexOutOfBoundsException | NumberFormatException unused) {
}
}
return iArr;
}
@SuppressLint({"NewApi"})
private static boolean c() {
boolean isLocationEnabled;
if (Build.VERSION.SDK_INT < 28) {
return true;
}
LocationManager locationManager = (LocationManager) gy.c().getSystemService(Headers.LOCATION);
if (locationManager != null) {
isLocationEnabled = locationManager.isLocationEnabled();
if (isLocationEnabled) {
return true;
}
return false;
}
return false;
}
private static boolean d() {
if (!gy.a()) {
return false;
}
boolean a7 = hg.a(gy.c(), "android.permission.READ_PHONE_STATE");
boolean a8 = hg.a(gy.c(), "android.permission.ACCESS_FINE_LOCATION");
int i6 = Build.VERSION.SDK_INT;
if (i6 == 29) {
return a8;
}
if (i6 >= 30) {
if (!a8 || !a7) {
return false;
}
return true;
}
if (!hg.a(gy.c(), "android.permission.ACCESS_COARSE_LOCATION") && !a8) {
return false;
}
return true;
}
public static Map<String, String> a(String str) {
String str2;
HashMap hashMap = new HashMap();
Context c6 = gy.c();
if (c6 == null) {
return hashMap;
}
ih.a();
String m6 = gy.m();
io b6 = iq.b();
String str3 = null;
String e6 = b6 != null ? b6.e() : null;
if (!((m6 == null || ih.a(m6).f15520c.oe) && (e6 == null || b6.c()) && (!(b6 != null && b6.d()) || ih.a(e6).f15520c.oe))) {
return hashMap;
}
String g6 = "InMobi".equals(str) ? gy.g() : gy.h();
ih.a();
int i6 = ih.a(g6).f15520c.cof;
boolean a7 = a(i6, 2);
boolean a8 = a(i6, 1);
ii iiVar = new ii();
TelephonyManager telephonyManager = (TelephonyManager) c6.getSystemService("phone");
if (!a7) {
int[] b7 = b(telephonyManager.getNetworkOperator());
iiVar.f15792a = b7[0];
iiVar.f15793b = b7[1];
String networkCountryIso = telephonyManager.getNetworkCountryIso();
if (networkCountryIso != null) {
iiVar.f15796e = networkCountryIso.toLowerCase(Locale.ENGLISH);
}
}
if (!a8) {
int[] b8 = b(telephonyManager.getSimOperator());
iiVar.f15794c = b8[0];
iiVar.f15795d = b8[1];
}
if (iiVar.f15794c == -1 && iiVar.f15795d == -1) {
str2 = null;
} else {
str2 = iiVar.f15794c + "_" + iiVar.f15795d;
}
hashMap.put("s-ho", str2);
if (iiVar.f15792a != -1 || iiVar.f15793b != -1) {
str3 = iiVar.f15792a + "_" + iiVar.f15793b;
}
hashMap.put("s-co", str3);
hashMap.put("s-iso", iiVar.f15796e);
hashMap.put("s-cn", hm.a(c6));
return hashMap;
}
public static Map<String, String> b() {
ArrayList arrayList;
if (gy.a() && d() && c()) {
ih.a();
String m6 = gy.m();
io b6 = iq.b();
String e6 = b6 != null ? b6.e() : null;
if ((m6 == null || ih.a(m6).f15520c.vce) && (e6 == null || b6.c()) && (!(b6 != null && b6.d()) || ih.a(e6).f15520c.vce)) {
Context c6 = gy.c();
if (c6 == null) {
arrayList = new ArrayList();
} else {
TelephonyManager telephonyManager = (TelephonyManager) c6.getSystemService("phone");
ArrayList arrayList2 = new ArrayList();
int[] b7 = b(telephonyManager.getNetworkOperator());
String valueOf = String.valueOf(b7[0]);
String valueOf2 = String.valueOf(b7[1]);
List<CellInfo> allCellInfo = telephonyManager.getAllCellInfo();
if (allCellInfo != null) {
for (CellInfo cellInfo : allCellInfo) {
if (!cellInfo.isRegistered()) {
arrayList2.add(new ij(cellInfo, valueOf, valueOf2, a(telephonyManager)));
}
}
}
arrayList = arrayList2;
}
HashMap hashMap = new HashMap();
if (!arrayList.isEmpty()) {
JSONArray jSONArray = new JSONArray();
jSONArray.put(((ij) arrayList.get(arrayList.size() - 1)).a());
hashMap.put("v-sc", jSONArray.toString());
}
return hashMap;
}
}
arrayList = new ArrayList();
HashMap hashMap2 = new HashMap();
if (!arrayList.isEmpty()) {
}
return hashMap2;
}
@SuppressLint({"MissingPermission"})
private static int a(@NonNull TelephonyManager telephonyManager) {
int dataNetworkType;
if (Build.VERSION.SDK_INT >= 30) {
dataNetworkType = telephonyManager.getDataNetworkType();
return dataNetworkType;
}
return telephonyManager.getNetworkType();
}
public static Map<String, String> a() {
Context c6;
ih.a();
String m6 = gy.m();
io b6 = iq.b();
ij ijVar = null;
String e6 = b6 != null ? b6.e() : null;
if (((m6 == null || ih.a(m6).f15520c.cce) && (e6 == null || b6.c()) && (!(b6 != null && b6.d()) || ih.a(e6).f15520c.cce)) && d() && c() && (c6 = gy.c()) != null) {
TelephonyManager telephonyManager = (TelephonyManager) c6.getSystemService("phone");
int[] b7 = b(telephonyManager.getNetworkOperator());
String valueOf = String.valueOf(b7[0]);
String valueOf2 = String.valueOf(b7[1]);
List<CellInfo> allCellInfo = telephonyManager.getAllCellInfo();
if (allCellInfo != null) {
CellInfo cellInfo = null;
for (int i6 = 0; i6 < allCellInfo.size(); i6++) {
cellInfo = allCellInfo.get(i6);
if (cellInfo.isRegistered()) {
break;
}
}
if (cellInfo != null) {
ijVar = new ij(cellInfo, valueOf, valueOf2, a(telephonyManager));
}
}
CellLocation cellLocation = telephonyManager.getCellLocation();
if (cellLocation != null && b7[0] != -1) {
ijVar = new ij();
if (cellLocation instanceof CdmaCellLocation) {
CdmaCellLocation cdmaCellLocation = (CdmaCellLocation) cellLocation;
ijVar.f15799b = Integer.MAX_VALUE;
ijVar.f15800c = a(telephonyManager);
ijVar.f15798a = ij.a(valueOf, cdmaCellLocation.getSystemId(), cdmaCellLocation.getNetworkId(), cdmaCellLocation.getBaseStationId());
} else {
GsmCellLocation gsmCellLocation = (GsmCellLocation) cellLocation;
ijVar.f15799b = Integer.MAX_VALUE;
ijVar.f15800c = a(telephonyManager);
ijVar.f15798a = ij.a(valueOf, valueOf2, gsmCellLocation.getLac(), gsmCellLocation.getCid(), gsmCellLocation.getPsc(), Integer.MAX_VALUE);
}
}
}
HashMap hashMap = new HashMap();
if (ijVar != null) {
hashMap.put("c-sc", ijVar.a().toString());
}
return hashMap;
}
}