Aqara Home v2.4.1版本的 MD5 值为:529779ac2bc0131db52a1fc3098d2b35
以下内容为反编译后的 e.java 源代码,内容仅作参考
package k.t.i.p.e.a;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiManager;
import android.util.Log;
import com.amazonaws.regions.ServiceAbbreviations;
import com.github.druk.rx2dnssd.BonjourService;
import com.github.druk.rx2dnssd.Rx2DnssdBindable;
import com.lumi.lumidevsdk.LumiDevSDK;
import com.lumi.lumidevsdk.bean.LANDeviceEntity;
import com.umeng.socialize.net.utils.SocializeProtocolConstants;
import java.net.Inet4Address;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.concurrent.TimeUnit;
import k.t.i.p.f.m;
import k.t.i.p.f.q;
import okhttp3.HttpUrl;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.json.JSONArray;
import org.json.JSONObject;
import p.a.l;
import p.a.n;
import p.a.x0.o;
import p.a.x0.r;
import s.b0;
import s.b3.w.k0;
import s.b3.w.m0;
import s.e0;
import s.h0;
import s.r2.f0;
@h0(bv = {1, 0, 3}, d1 = {"\u0000\\\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0000\n\u0002\u0010!\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0002\b\u0004\u0018\u00002\u00020\u0001:\u0001'B\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004J\u001a\u0010\u0018\u001a\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u001a0\u00110\u00192\u0006\u0010\u001b\u001a\u00020\u001cJ0\u0010\u001d\u001a\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u001a0\u001e0\u00192\b\b\u0002\u0010\u001b\u001a\u00020\u001c2\b\b\u0002\u0010\u001f\u001a\u00020 2\b\b\u0002\u0010!\u001a\u00020 J\u001a\u0010\"\u001a\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00120\u00110\u00192\u0006\u0010\u001b\u001a\u00020\u001cJ\b\u0010#\u001a\u00020$H\u0002J\b\u0010%\u001a\u00020$H\u0002J\b\u0010&\u001a\u00020$H\u0002R\u0011\u0010\u0002\u001a\u00020\u0003¢\u0006\b\n\u0000\u001a\u0004\b\u0005\u0010\u0006R\u001b\u0010\u0007\u001a\u00020\b8FX\u0086\u0084\u0002¢\u0006\f\n\u0004\b\u000b\u0010\f\u001a\u0004\b\t\u0010\nR\u0012\u0010\r\u001a\u00060\u000eR\u00020\u0000X\u0082\u0004¢\u0006\u0002\n\u0000R\u001c\u0010\u000f\u001a\u0010\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00120\u0011\u0018\u00010\u0010X\u0082\u000e¢\u0006\u0002\n\u0000R\u001b\u0010\u0013\u001a\u00020\u00148BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\u0017\u0010\f\u001a\u0004\b\u0015\u0010\u0016¨\u0006("}, d2 = {"Lcom/lumi/module/smart_connect/model/ap/WifiScanner;", "", com.umeng.analytics.pro.d.R, "Landroid/content/Context;", "(Landroid/content/Context;)V", "getContext", "()Landroid/content/Context;", "mWifiManager", "Landroid/net/wifi/WifiManager;", "getMWifiManager", "()Landroid/net/wifi/WifiManager;", "mWifiManager$delegate", "Lkotlin/Lazy;", "mWifiReceiver", "Lcom/lumi/module/smart_connect/model/ap/WifiScanner$WifiReceiver;", "mWifiResultEmitter", "Lio/reactivex/FlowableEmitter;", "", "Landroid/net/wifi/ScanResult;", "rxDnssd", "Lcom/github/druk/rx2dnssd/Rx2DnssdBindable;", "getRxDnssd", "()Lcom/github/druk/rx2dnssd/Rx2DnssdBindable;", "rxDnssd$delegate", "findDeviceByMDns", "Lio/reactivex/Flowable;", "Lcom/lumi/lumidevsdk/bean/LANDeviceEntity;", "delayTime", "", "findDeviceByMulticast", "", "currentIpAddress", "", "multicastIpAddress", "findDeviceByWifi", "refreshWifiList", "", "registerReceiver", "stopScan", "WifiReceiver", "module-ble_debug"}, k = 1, mv = {1, 4, 2})
public final class e {
@NotNull
public final b0 a;
public final b0 b;
public final a c;
public n<List<ScanResult>> d;
@NotNull
public final Context f21572e;
public final class a extends BroadcastReceiver {
public a() {
}
@Override
public void onReceive(@Nullable Context context, @Nullable Intent intent) {
String action = intent != null ? intent.getAction() : null;
if (action == null) {
return;
}
switch (action.hashCode()) {
case -1875733435:
if (action.equals("android.net.wifi.WIFI_STATE_CHANGED")) {
int intExtra = intent.getIntExtra("wifi_state", 1);
if (intExtra != 1) {
if (intExtra != 3) {
return;
}
Log.d("【DeBugActivity】", "开始Wifi");
return;
}
n nVar = e.this.d;
if (nVar != null) {
nVar.a(new k.t.i.p.c.d(-1, "wifi state is disable"));
return;
}
return;
}
return;
case -385684331:
action.equals("android.net.wifi.RSSI_CHANGED");
return;
case -343630553:
action.equals("android.net.wifi.STATE_CHANGE");
return;
case 1878357501:
if (action.equals("android.net.wifi.SCAN_RESULTS")) {
intent.getBooleanExtra("resultsUpdated", false);
List<ScanResult> scanResults = e.this.b().getScanResults();
k0.d(scanResults, "scanResults");
HashSet hashSet = new HashSet();
ArrayList arrayList = new ArrayList();
for (Object obj : scanResults) {
if (hashSet.add(((ScanResult) obj).SSID)) {
arrayList.add(obj);
}
}
List r2 = f0.r((Collection) arrayList);
n nVar2 = e.this.d;
if (nVar2 != null) {
nVar2.onNext(r2);
return;
}
return;
}
return;
default:
return;
}
}
}
public static final class b<T> implements r<BonjourService> {
public static final b a = new b();
@Override
public final boolean test(@NotNull BonjourService bonjourService) {
k0.e(bonjourService, "it");
return bonjourService.getInet4Address() != null && (k0.a((Object) bonjourService.getTxtRecords().get(SocializeProtocolConstants.PROTOCOL_KEY_PV), (Object) "true") ^ true) && k0.a((Object) bonjourService.getTxtRecords().get("ln"), (Object) "true");
}
}
public static final class c<T, R> implements o<BonjourService, LANDeviceEntity> {
public static final c a = new c();
@Override
public final LANDeviceEntity apply(@NotNull BonjourService bonjourService) {
k0.e(bonjourService, "info");
StringBuilder sb = new StringBuilder();
Inet4Address inet4Address = bonjourService.getInet4Address();
sb.append(inet4Address != null ? inet4Address.getHostAddress() : null);
sb.append(":");
sb.append(bonjourService.getPort());
String sb2 = sb.toString();
LANDeviceEntity lANDeviceEntity = new LANDeviceEntity();
lANDeviceEntity.setModel(bonjourService.getTxtRecords().get("md"));
lANDeviceEntity.setAddress(sb2);
lANDeviceEntity.setName(bonjourService.getServiceName());
lANDeviceEntity.setDid(bonjourService.getTxtRecords().get("id"));
Inet4Address inet4Address2 = bonjourService.getInet4Address();
lANDeviceEntity.setIpAddress(inet4Address2 != null ? inet4Address2.getHostAddress() : null);
lANDeviceEntity.setIpPort(bonjourService.getPort());
Log.d("【DeBugActivity】----MDS", lANDeviceEntity.toString());
return lANDeviceEntity;
}
}
@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/FlowableEmitter;", "", "kotlin.jvm.PlatformType", "subscribe"}, k = 3, mv = {1, 4, 2})
public static final class d<T> implements p.a.o<String> {
public final String a;
public final String b;
public final long c;
public static final class a implements k.t.i.p.d.b {
public final n a;
public a(n nVar) {
this.a = nVar;
}
@Override
public void a(long j2, @Nullable String str) {
this.a.a(new k.t.i.p.c.d((int) j2, str));
}
@Override
public void onSuccess(@Nullable String str) {
n nVar = this.a;
if (str == null) {
str = HttpUrl.PATH_SEGMENT_ENCODE_SET_URI;
}
nVar.onNext(str);
this.a.onComplete();
}
}
public d(String str, String str2, long j2) {
this.a = str;
this.b = str2;
this.c = j2;
}
@Override
public final void subscribe(@NotNull n<String> nVar) {
k0.e(nVar, "it");
k.t.i.p.e.a.b.a(k.t.i.p.e.a.b.b, this.a, this.b, this.c, new a(nVar), null, 16, null);
}
}
public static final class C0484e<T, R> implements o<String, List<LANDeviceEntity>> {
public static final C0484e a = new C0484e();
@Override
public final List<LANDeviceEntity> apply(@NotNull String str) {
k0.e(str, "it");
ArrayList arrayList = new ArrayList();
JSONArray jSONArray = new JSONArray(str);
int length = jSONArray.length();
for (int i2 = 0; i2 < length; i2++) {
JSONObject jSONObject = jSONArray.getJSONObject(i2);
if (k0.a((Object) jSONObject.getString("command"), (Object) ServiceAbbreviations.f2740r)) {
LANDeviceEntity lANDeviceEntity = new LANDeviceEntity();
lANDeviceEntity.setAddress(jSONObject.getString("address"));
lANDeviceEntity.setDid(jSONObject.getString("address"));
lANDeviceEntity.setModel(jSONObject.getString("model"));
lANDeviceEntity.setName(jSONObject.getString("name"));
lANDeviceEntity.setRegistered(jSONObject.getString("registered"));
arrayList.add(lANDeviceEntity);
}
}
return arrayList;
}
}
public static final class f<T> implements p.a.x0.g<x.g.e> {
public f() {
}
@Override
public final void accept(x.g.e eVar) {
e.this.e();
e.this.d();
}
}
public static final class g<T> implements p.a.x0.g<Long> {
public g() {
}
@Override
public final void accept(Long l2) {
e.this.d();
}
}
public static final class h implements p.a.x0.a {
public h() {
}
@Override
public final void run() {
e.this.f();
}
}
@h0(bv = {1, 0, 3}, d1 = {"\u0000\u001a\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\t\n\u0002\b\u0002\u0010\u0000\u001aB\u0012\u001a\b\u0001\u0012\u0016\u0012\u0004\u0012\u00020\u0003 \u0004*\n\u0012\u0004\u0012\u00020\u0003\u0018\u00010\u00020\u0002 \u0004* \u0012\u001a\b\u0001\u0012\u0016\u0012\u0004\u0012\u00020\u0003 \u0004*\n\u0012\u0004\u0012\u00020\u0003\u0018\u00010\u00020\u0002\u0018\u00010\u00010\u00012\u0006\u0010\u0005\u001a\u00020\u0006H\n¢\u0006\u0004\b\u0007\u0010\b"}, d2 = {"<anonymous>", "Lorg/reactivestreams/Publisher;", "", "Landroid/net/wifi/ScanResult;", "kotlin.jvm.PlatformType", "it", "", "apply", "(Ljava/lang/Long;)Lorg/reactivestreams/Publisher;"}, k = 3, mv = {1, 4, 2})
public static final class i<T, R> implements o<Long, x.g.c<? extends List<? extends ScanResult>>> {
public static final class a<T> implements p.a.o<List<? extends ScanResult>> {
public a() {
}
@Override
public final void subscribe(@NotNull n<List<? extends ScanResult>> nVar) {
k0.e(nVar, "it");
e.this.d = nVar;
}
}
public i() {
}
@Override
public final x.g.c<? extends List<ScanResult>> apply(@NotNull Long l2) {
k0.e(l2, "it");
return l.a((p.a.o) new a(), p.a.b.BUFFER);
}
}
public static final class j extends m0 implements s.b3.v.a<WifiManager> {
public j() {
super(0);
}
@Override
@NotNull
public final WifiManager invoke() {
Object systemService = e.this.a().getApplicationContext().getSystemService("wifi");
if (systemService != null) {
return (WifiManager) systemService;
}
throw new NullPointerException("null cannot be cast to non-null type android.net.wifi.WifiManager");
}
}
public static final class k extends m0 implements s.b3.v.a<Rx2DnssdBindable> {
public k() {
super(0);
}
@Override
@NotNull
public final Rx2DnssdBindable invoke() {
return new Rx2DnssdBindable(e.this.a().getApplicationContext());
}
}
public e(@NotNull Context context) {
k0.e(context, com.umeng.analytics.pro.d.R);
this.f21572e = context;
this.a = e0.a(new j());
this.b = e0.a(new k());
this.c = new a();
}
private final Rx2DnssdBindable c() {
return (Rx2DnssdBindable) this.b.getValue();
}
public final void e() {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("android.net.wifi.WIFI_STATE_CHANGED");
intentFilter.addAction("android.net.wifi.SCAN_RESULTS");
intentFilter.addAction("android.net.wifi.STATE_CHANGE");
intentFilter.addAction("resultsUpdated");
this.f21572e.getApplicationContext().registerReceiver(this.c, intentFilter);
}
public final void f() {
try {
this.f21572e.unregisterReceiver(this.c);
} catch (Exception e2) {
e2.printStackTrace();
}
}
@NotNull
public final WifiManager b() {
return (WifiManager) this.a.getValue();
}
public final void d() {
if (b().isWifiEnabled()) {
boolean startScan = b().startScan();
m.a("startScan:" + startScan);
}
}
@NotNull
public final l<List<ScanResult>> b(long j2) {
l p2 = l.q(j2, TimeUnit.MILLISECONDS).g(new f()).c(new g()).b(new h()).p(new i());
k0.d(p2, "Flowable.interval(delayT…egy.BUFFER)\n }");
return p2;
}
@NotNull
public final Context a() {
return this.f21572e;
}
@NotNull
public final l<List<LANDeviceEntity>> a(long j2) {
l<List<LANDeviceEntity>> a2 = c().browse(LumiDevSDK.MDNS_SERVICE_TYPE, "local.").a(c().resolve()).a(c().queryIPV4Records()).c(p.a.e1.b.b()).c((r) b.a).v(c.a).a(j2, TimeUnit.MILLISECONDS);
k0.d(a2, "rxDnssd.browse(LumiDevSD…e, TimeUnit.MILLISECONDS)");
return a2;
}
public static l a(e eVar, long j2, String str, String str2, int i2, Object obj) {
if ((i2 & 1) != 0) {
j2 = 2000;
}
if ((i2 & 2) != 0) {
str = q.c() + ":10008";
}
if ((i2 & 4) != 0) {
str2 = "230.0.0.1:10008";
}
return eVar.a(j2, str, str2);
}
@NotNull
public final l<List<LANDeviceEntity>> a(long j2, @NotNull String str, @NotNull String str2) {
k0.e(str, "currentIpAddress");
k0.e(str2, "multicastIpAddress");
l<List<LANDeviceEntity>> c2 = l.a((p.a.o) new d(str, str2, j2), p.a.b.BUFFER).v(C0484e.a).e(Integer.MAX_VALUE).c(p.a.e1.b.e());
k0.d(c2, "Flowable.create<String>(…beOn(Schedulers.single())");
return c2;
}
}