Aqara Home v2.4.1版本的 MD5 值为:529779ac2bc0131db52a1fc3098d2b35
以下内容为反编译后的 b.java 源代码,内容仅作参考
package k.t.i.p.e.a;
import android.net.ConnectivityManager;
import android.net.Network;
import android.os.Build;
import android.text.TextUtils;
import com.lumi.lumidevsdk.LumiDevSDK;
import com.taobao.accs.utl.BaseMonitor;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.MulticastSocket;
import java.net.SocketTimeoutException;
import java.util.ArrayList;
import java.util.List;
import k.t.i.p.e.a.c;
import k.t.i.p.f.m;
import k.t.i.p.f.q;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.json.JSONObject;
import p.a.m0;
import p.a.o0;
import p.a.x0.o;
import s.b3.w.k0;
import s.h0;
import s.i3.b0;
import s.i3.c0;
import s.r2.f0;
@h0(bv = {1, 0, 3}, d1 = {"\u0000<\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0002\b\u0003\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\bÆ\u0002\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u001e\u0010\u0005\u001a\b\u0012\u0004\u0012\u00020\u00040\u00062\u0006\u0010\u0007\u001a\u00020\u00042\b\b\u0002\u0010\b\u001a\u00020\u0004J:\u0010\t\u001a\u00020\n2\b\b\u0002\u0010\u000b\u001a\u00020\u00042\b\b\u0002\u0010\f\u001a\u00020\u00042\b\b\u0002\u0010\r\u001a\u00020\u000e2\n\b\u0002\u0010\u000f\u001a\u0004\u0018\u00010\u00102\b\b\u0002\u0010\u0007\u001a\u00020\u0004J\u001e\u0010\u0011\u001a\b\u0012\u0004\u0012\u00020\u00040\u00062\u0006\u0010\u0007\u001a\u00020\u00122\b\b\u0002\u0010\u0013\u001a\u00020\u0004J&\u0010\u0014\u001a\b\u0012\u0004\u0012\u00020\u00040\u00062\u0006\u0010\u0007\u001a\u00020\u00042\b\b\u0002\u0010\u0015\u001a\u00020\u00042\u0006\u0010\u0016\u001a\u00020\u0017R\u000e\u0010\u0003\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000¨\u0006\u0018"}, d2 = {"Lcom/lumi/module/smart_connect/model/ap/FastLinkHelper;", "", "()V", "SEND_WIFI_TO_GATEWAY_API", "", "sendMsg2GatewayByHttp", "Lio/reactivex/Single;", "para", "url", "sendMsg2GatewayByMulticast", "", "currentIpAddress", "multicastIpAddress", "delayTime", "", "callBack", "Lcom/lumi/module/smart_connect/icallback/CallBack;", "sendMsg2GatewayByTcp", "Lorg/json/JSONObject;", "serverIp", "sendMsg2GatewayByUDP", "deviceIPAddressPort", "network", "Landroid/net/Network;", "module-ble_debug"}, k = 1, mv = {1, 4, 2})
public final class b {
@NotNull
public static final String a = "http://192.168.5.1:4567/example";
@NotNull
public static final b b = new b();
@h0(bv = {1, 0, 3}, d1 = {"\u0000\u0014\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010\u000e\n\u0002\b\u0002\u0010\u0000\u001a\u00020\u00012\u0014\u0010\u0002\u001a\u0010\u0012\f\u0012\n \u0005*\u0004\u0018\u00010\u00040\u00040\u0003H\n¢\u0006\u0002\b\u0006"}, d2 = {"<anonymous>", "", "it", "Lio/reactivex/SingleEmitter;", "", "kotlin.jvm.PlatformType", "subscribe"}, k = 3, mv = {1, 4, 2})
public static final class a<T> implements o0<String> {
public final String a;
public final String b;
public static final class C0481a implements k.t.i.p.d.b {
public final m0 a;
public C0481a(m0 m0Var) {
this.a = m0Var;
}
@Override
public void a(long j2, @Nullable String str) {
m0 m0Var = this.a;
int i2 = (int) j2;
if (str == null) {
str = "";
}
m0Var.a(new k.t.i.p.c.a(i2, str));
}
@Override
public void onSuccess(@Nullable String str) {
m0 m0Var = this.a;
if (str == null) {
str = "";
}
m0Var.onSuccess(str);
}
}
public a(String str, String str2) {
this.a = str;
this.b = str2;
}
@Override
public final void subscribe(@NotNull m0<String> m0Var) {
k0.e(m0Var, "it");
k.t.i.p.e.a.d.b.a(this.a, this.b, new C0481a(m0Var));
}
}
public static final class C0482b<T, R> implements o<String, String> {
public final String a;
public C0482b(String str) {
this.a = str;
}
@Override
public final String apply(@NotNull String str) {
k0.e(str, "it");
JSONObject jSONObject = new JSONObject();
jSONObject.put(BaseMonitor.COUNT_ACK, 1);
k.t.i.p.e.a.d dVar = k.t.i.p.e.a.d.b;
String str2 = this.a;
String jSONObject2 = jSONObject.toString();
k0.d(jSONObject2, "jsonObject.toString()");
k.t.i.p.e.a.d.a(dVar, str2, jSONObject2, null, 4, null);
return str;
}
}
@h0(bv = {1, 0, 3}, d1 = {"\u0000\u0012\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010\u000e\n\u0000\u0010\u0000\u001a\u00020\u00012\u000e\u0010\u0002\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\u00040\u0003H\n¢\u0006\u0002\b\u0005"}, d2 = {"<anonymous>", "", "emitter", "Lio/reactivex/SingleEmitter;", "", "subscribe"}, k = 3, mv = {1, 4, 2})
public static final class c<T> implements o0<String> {
public final String a;
public final JSONObject b;
public static final class a implements c.d {
public final k.t.i.p.e.a.c c;
public final m0 d;
public a(k.t.i.p.e.a.c cVar, m0 m0Var) {
this.c = cVar;
this.d = m0Var;
}
@Override
public final void a(int i2) {
if (i2 == 0) {
this.d.onSuccess("success");
} else {
this.d.a(new k.t.i.p.c.a(i2, ""));
}
this.c.a();
}
}
public c(String str, JSONObject jSONObject) {
this.a = str;
this.b = jSONObject;
}
@Override
public final void subscribe(@NotNull m0<String> m0Var) {
k0.e(m0Var, "emitter");
k.t.i.p.e.a.c cVar = new k.t.i.p.e.a.c(this.a, this.b);
cVar.a(new a(cVar, m0Var));
cVar.b();
}
}
public static final class d<T> implements o0<String> {
public final String a;
public final String b;
public final Network c;
public d(String str, String str2, Network network) {
this.a = str;
this.b = str2;
this.c = network;
}
@Override
public final void subscribe(@NotNull m0<String> m0Var) {
boolean z2;
String str;
k0.e(m0Var, "it");
String str2 = "";
List a = c0.a((CharSequence) this.a, new String[]{":"}, false, 0, 6, (Object) null);
m.a("deviceIP:" + this.a, "para:" + this.b);
byte[] bArr = null;
if (TextUtils.isEmpty((CharSequence) a.get(0))) {
m0Var.a(new k.t.i.p.c.a(1003, "deviceIP is empty"));
return;
}
int parseInt = Integer.parseInt((String) a.get(1));
InetAddress byName = InetAddress.getByName((String) a.get(0));
byte[] encryptedInfo = LumiDevSDK.getEncryptedInfo(this.b);
DatagramSocket datagramSocket = new DatagramSocket();
datagramSocket.setSoTimeout(5000);
try {
try {
DatagramPacket datagramPacket = new DatagramPacket(encryptedInfo, encryptedInfo.length, byName, parseInt);
if (Build.VERSION.SDK_INT >= 22) {
this.c.bindSocket(datagramSocket);
z2 = false;
} else {
z2 = ConnectivityManager.setProcessDefaultNetwork(this.c);
}
try {
DatagramPacket datagramPacket2 = new DatagramPacket(new byte[102400], 102400);
datagramSocket.send(datagramPacket);
datagramSocket.receive(datagramPacket2);
str = LumiDevSDK.getDecryptedInfo(datagramPacket2.getData(), datagramPacket2.getLength());
k0.d(str, "revData");
try {
JSONObject jSONObject = new JSONObject();
jSONObject.put(BaseMonitor.COUNT_ACK, 1);
byte[] encryptedInfo2 = LumiDevSDK.getEncryptedInfo(jSONObject.toString());
datagramSocket.send(new DatagramPacket(encryptedInfo2, encryptedInfo2.length, byName, parseInt));
datagramSocket.close();
if (z2) {
ConnectivityManager.setProcessDefaultNetwork(null);
}
} catch (SocketTimeoutException e2) {
e = e2;
str2 = str;
e.printStackTrace();
if (str2.length() == 0) {
m0Var.a(new k.t.i.p.c.b(0, 1, null));
}
datagramSocket.close();
} catch (Exception e3) {
e = e3;
str2 = str;
e.printStackTrace();
if (str2.length() == 0) {
m0Var.a(new k.t.i.p.c.b(0, 1, null));
}
datagramSocket.close();
}
} catch (SocketTimeoutException e4) {
e = e4;
} catch (Exception e5) {
e = e5;
}
} catch (Throwable th) {
th = th;
bArr = encryptedInfo;
datagramSocket.close();
if (bArr != null) {
ConnectivityManager.setProcessDefaultNetwork(null);
}
throw th;
}
} catch (SocketTimeoutException e6) {
e = e6;
z2 = false;
} catch (Exception e7) {
e = e7;
z2 = false;
} catch (Throwable th2) {
th = th2;
datagramSocket.close();
if (bArr != null) {
}
throw th;
}
m0Var.onSuccess(str);
}
}
public static p.a.k0 a(b bVar, String str, String str2, Network network, int i2, Object obj) {
if ((i2 & 2) != 0) {
str2 = q.a() + ":10008";
}
return bVar.a(str, str2, network);
}
@NotNull
public final p.a.k0<String> a(@NotNull String str, @NotNull String str2, @NotNull Network network) {
k0.e(str, "para");
k0.e(str2, "deviceIPAddressPort");
k0.e(network, "network");
p.a.k0<String> b2 = p.a.k0.a((o0) new d(str2, str, network)).b(p.a.e1.b.b());
k0.d(b2, "Single.create<String> {\n…scribeOn(Schedulers.io())");
return b2;
}
public static void a(b bVar, String str, String str2, long j2, k.t.i.p.d.b bVar2, String str3, int i2, Object obj) {
if ((i2 & 1) != 0) {
str = q.c() + ":10008";
}
if ((i2 & 2) != 0) {
str2 = "230.0.0.1:10008";
}
String str4 = str2;
if ((i2 & 4) != 0) {
j2 = 2000;
}
long j3 = j2;
if ((i2 & 8) != 0) {
bVar2 = null;
}
k.t.i.p.d.b bVar3 = bVar2;
if ((i2 & 16) != 0) {
JSONObject jSONObject = new JSONObject();
jSONObject.put("command", "whois");
jSONObject.put("address", f0.i(c0.a((CharSequence) str, new String[]{":"}, false, 0, 6, (Object) null), 0));
jSONObject.put("port", f0.i(c0.a((CharSequence) str, new String[]{":"}, false, 0, 6, (Object) null), 1));
str3 = jSONObject.toString();
k0.d(str3, "JSONObject()\n …\n }.toString()");
}
bVar.a(str, str4, j3, bVar3, str3);
}
public final void a(@NotNull String str, @NotNull String str2, long j2, @Nullable k.t.i.p.d.b bVar, @NotNull String str3) {
k0.e(str, "currentIpAddress");
k0.e(str2, "multicastIpAddress");
k0.e(str3, "para");
if (b0.a((CharSequence) str2)) {
if (bVar != null) {
bVar.a(-1L, "multicastIpAddress " + str2 + " is illegal");
return;
}
return;
}
List a2 = c0.a((CharSequence) str2, new String[]{":"}, false, 0, 6, (Object) null);
int parseInt = Integer.parseInt((String) a2.get(1));
MulticastSocket multicastSocket = new MulticastSocket(parseInt);
ArrayList arrayList = new ArrayList();
try {
try {
try {
InetAddress byName = InetAddress.getByName((String) a2.get(0));
multicastSocket.joinGroup(byName);
multicastSocket.setTimeToLive(2);
multicastSocket.setSoTimeout((int) j2);
k0.d(byName, "inetAddress");
if (!byName.isMulticastAddress()) {
if (bVar != null) {
bVar.a(-1L, "multicastIpAddress is not MulticastAddress");
}
return;
}
byte[] encryptedInfo = LumiDevSDK.getEncryptedInfo(str3.toString());
multicastSocket.send(new DatagramPacket(encryptedInfo, encryptedInfo.length, byName, parseInt));
while (true) {
DatagramPacket datagramPacket = new DatagramPacket(new byte[102400], 102400);
multicastSocket.receive(datagramPacket);
String decryptedInfo = LumiDevSDK.getDecryptedInfo(datagramPacket.getData(), datagramPacket.getLength());
m.a("data:" + decryptedInfo);
JSONObject jSONObject = new JSONObject(decryptedInfo);
StringBuilder sb = new StringBuilder();
InetAddress address = datagramPacket.getAddress();
k0.d(address, "revPacket.address");
sb.append(address.getHostAddress());
sb.append(":");
sb.append(datagramPacket.getPort());
jSONObject.put("address", sb.toString());
String jSONObject2 = jSONObject.toString();
k0.d(jSONObject2, "jsonObject.toString()");
arrayList.add(jSONObject2);
}
} catch (Exception e2) {
e2.printStackTrace();
if (bVar != null) {
bVar.a(-1L, e2.getMessage());
}
String a3 = f0.a(arrayList, ",", "[", "]", 0, null, null, 56, null);
if (bVar == null) {
bVar.onSuccess(a3);
}
}
} catch (SocketTimeoutException e3) {
m.a("timeoutException:" + e3.getMessage());
String a32 = f0.a(arrayList, ",", "[", "]", 0, null, null, 56, null);
if (bVar == null) {
}
}
} finally {
multicastSocket.close();
}
}
public static p.a.k0 a(b bVar, String str, String str2, int i2, Object obj) {
if ((i2 & 2) != 0) {
str2 = "http://192.168.5.1:4567/example";
}
return bVar.a(str, str2);
}
@NotNull
public final p.a.k0<String> a(@NotNull String str, @NotNull String str2) {
k0.e(str, "para");
k0.e(str2, "url");
p.a.k0<String> b2 = p.a.k0.a((o0) new a(str2, str)).i(new C0482b(str2)).b(p.a.e1.b.b());
k0.d(b2, "Single.create<String> {\n…scribeOn(Schedulers.io())");
return b2;
}
public static p.a.k0 a(b bVar, JSONObject jSONObject, String str, int i2, Object obj) {
if ((i2 & 2) != 0) {
str = q.a();
k0.d(str, "WifiUtil.getDeviceGatewayIPAddress()");
}
return bVar.a(jSONObject, str);
}
@NotNull
public final p.a.k0<String> a(@NotNull JSONObject jSONObject, @NotNull String str) {
k0.e(jSONObject, "para");
k0.e(str, "serverIp");
p.a.k0<String> a2 = p.a.k0.a((o0) new c(str, jSONObject));
k0.d(a2, "Single.create<String> { …)\n }\n }");
return a2;
}
}