package cn.jiguang.l; import android.annotation.SuppressLint; import android.content.Context; import android.net.DhcpInfo; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.text.TextUtils; import cn.jiguang.o.a; import cn.jiguang.o.d; import java.util.List; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; public class b extends a { @SuppressLint({"StaticFieldLeak"}) private static volatile b c; private Context a; private JSONObject b; private String d; private boolean e; public static b a() { if (c == null) { synchronized (b.class) { c = new b(); } } return c; } private void a(String str, String str2, String str3, String str4, String str5, String str6, String str7, String str8, String str9, List<cn.jiguang.m.a> list) { try { if (this.b == null) { this.b = new JSONObject(); } this.b.put("ssid", str); this.b.put("bssid", str2); this.b.put("local_ip", str3); this.b.put("local_mac", str4); this.b.put("netmask", str5); this.b.put("gateway", str8); this.b.put("dhcp", str9); JSONArray jSONArray = new JSONArray(); if (!TextUtils.isEmpty(str6)) { jSONArray.put(str6); } if (!TextUtils.isEmpty(str7)) { jSONArray.put(str7); } this.b.put("dns", jSONArray); JSONArray jSONArray2 = new JSONArray(); for (cn.jiguang.m.a aVar : list) { JSONObject jSONObject = new JSONObject(); jSONObject.put("ip", aVar.a); jSONObject.put("mac", aVar.d); jSONArray2.put(jSONObject); } this.b.put("data", jSONArray2); } catch (JSONException e2) { cn.jiguang.af.a.d("JArp", "packageJson exception: " + e2.getMessage()); } } /* access modifiers changed from: protected */ @Override // cn.jiguang.o.a public String a(Context context) { this.a = context; return "JArp"; } /* access modifiers changed from: protected */ @Override // cn.jiguang.o.a public void a(Context context, String str) { if (!d.a(context, "android.permission.ACCESS_WIFI_STATE")) { cn.jiguang.af.a.d("JArp", "collect arp failed because has no permission Manifest.permission.ACCESS_WIFI_STATE"); } else if (!d.k(context).toUpperCase().startsWith("WIFI")) { cn.jiguang.af.a.d("JArp", "collect arp failed because networkType is not wifi"); } else if (TextUtils.isEmpty(d.d(context))) { cn.jiguang.af.a.d("JArp", "collect arp failed because can't get registerId"); } else { WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService("wifi"); if (wifiManager == null) { cn.jiguang.af.a.a("JArp", "collect arp failed because get wifiManager failed"); return; } WifiInfo connectionInfo = wifiManager.getConnectionInfo(); String str2 = ""; String str3 = ""; if (connectionInfo != null) { str3 = d.e(connectionInfo.getSSID()); str2 = connectionInfo.getBSSID(); } String str4 = TextUtils.isEmpty(str2) ? "" : str2; String str5 = TextUtils.isEmpty(str3) ? "" : str3; this.d = TextUtils.isEmpty(str4) ? str5 : str4; if (!cn.jiguang.o.b.e(context) || !cn.jiguang.o.b.p(context, this.d)) { boolean d2 = d(context, "JArp"); if (this.e || d2) { this.e = false; DhcpInfo dhcpInfo = wifiManager.getDhcpInfo(); if (dhcpInfo != null) { byte[] a2 = cn.jiguang.n.a.a((long) dhcpInfo.ipAddress); String a3 = cn.jiguang.n.a.a(dhcpInfo.ipAddress); if (TextUtils.equals(a3, "0.0.0.0")) { a3 = ""; } String c2 = d.c(context, ""); String a4 = cn.jiguang.n.a.a(dhcpInfo.netmask); if (TextUtils.equals(a4, "0.0.0.0")) { a4 = ""; } String a5 = cn.jiguang.n.a.a(dhcpInfo.dns1); if (TextUtils.equals(a5, "0.0.0.0")) { a5 = ""; } String a6 = cn.jiguang.n.a.a(dhcpInfo.dns2); if (TextUtils.equals(a6, "0.0.0.0")) { a6 = ""; } String a7 = cn.jiguang.n.a.a(dhcpInfo.gateway); if (TextUtils.equals(a7, "0.0.0.0")) { a7 = ""; } String a8 = cn.jiguang.n.a.a(dhcpInfo.serverAddress); if (TextUtils.equals(a8, "0.0.0.0")) { a8 = ""; } cn.jiguang.n.a.a(a8, a2); List<cn.jiguang.m.a> a9 = cn.jiguang.n.a.a(a8); if (a9 == null || a9.isEmpty()) { cn.jiguang.af.a.d("JArp", "collect arp failed because can't get arp info"); return; } cn.jiguang.af.a.a("JArp", "collect arp success"); a(str5, str4, a3, c2, a4, a5, a6, a7, a8, a9); return; } return; } cn.jiguang.af.a.d("JArp", "collect arp failed because this wifi 【" + this.d + "】 is not in report time"); return; } cn.jiguang.af.a.d("JArp", "collect arp failed because this wifi 【" + this.d + "】 can't report twice"); } } /* access modifiers changed from: protected */ @Override // cn.jiguang.o.a public void a(String str, JSONObject jSONObject) { this.e = true; JSONObject optJSONObject = jSONObject.optJSONObject("content"); boolean z = !optJSONObject.optBoolean("disable"); cn.jiguang.o.b.a(this.a, "JArp", z); if (z) { long optLong = optJSONObject.optLong("frequency", 0) * 1000; if (optLong == 0) { cn.jiguang.o.b.b(this.a, true); return; } cn.jiguang.o.b.b(this.a, false); cn.jiguang.o.b.b(this.a, "JArp", optLong); } } /* access modifiers changed from: protected */ @Override // cn.jiguang.o.a public void b(Context context, String str) { JSONObject jSONObject = this.b; if (jSONObject == null) { cn.jiguang.af.a.a("JArp", "there are no data to report"); return; } d.a(context, jSONObject, "mac_list"); d.a(context, this.b, new a(this.d, context, "JArp", str)); this.b = null; } /* access modifiers changed from: protected */ @Override // cn.jiguang.o.a public boolean c() { return cn.jiguang.o.b.i(this.a, "JArp"); } /* access modifiers changed from: protected */ @Override // cn.jiguang.o.a public boolean c(Context context, String str) { return true; } /* access modifiers changed from: protected */ @Override // cn.jiguang.o.a public boolean d(Context context, String str) { long currentTimeMillis = System.currentTimeMillis(); if (TextUtils.isEmpty(this.d)) { this.d = ""; } StringBuilder sb = new StringBuilder(); sb.append("JArp"); sb.append(this.d); return currentTimeMillis - cn.jiguang.o.b.g(context, sb.toString()) > cn.jiguang.o.b.h(context, "JArp"); } }