正在查看: WeatherSense v1.8.9 应用的 APconnectPresenterImp.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: WeatherSense v1.8.9 应用的 APconnectPresenterImp.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.emax.weather.presenter;
import android.content.Context;
import android.net.wifi.ScanResult;
import android.util.Log;
import com.emax.weahter.R;
import com.emax.weather.base.BaseApplication;
import com.emax.weather.base.BasePresenter;
import com.emax.weather.bean.CmdConstant;
import com.emax.weather.bean.Device;
import com.emax.weather.bean.db.DaoHadle;
import com.emax.weather.ble.BlueConnectManage;
import com.emax.weather.dao.DeviceDao;
import com.emax.weather.event.APconnectEvent;
import com.emax.weather.net.ApiException;
import com.emax.weather.net.CodeHandledSubscriber;
import com.emax.weather.net.ResponseData;
import com.emax.weather.net.RetrofitUtil;
import com.ezon.health.utils_lib.SharedPreUtils;
import com.yyl.kwifi_lib.ConnectorTransmit;
import com.yyl.kwifi_lib.WifiBeanInfo;
import com.yyl.kwifi_lib.WifiConnectManage;
import io.reactivex.Observable;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.StringsKt;
import okhttp3.RequestBody;
import org.json.JSONException;
import org.json.JSONObject;
@Metadata(d1 = {"\u0000`\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\u000e\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010 \n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0002\b\u000f\n\u0002\u0018\u0002\n\u0002\b\r\n\u0002\u0018\u0002\n\u0002\b\u0007\u0018\u00002\b\u0012\u0004\u0012\u00020\u00020\u00012\u00020\u0003B\u0011\b\u0016\u0012\b\u0010\u0004\u001a\u0004\u0018\u00010\u0002¢\u0006\u0002\u0010\u0005B\u0005¢\u0006\u0002\u0010\u0006J\u0010\u0010 \u001a\u00020!2\u0006\u0010\"\u001a\u00020\bH\u0016J\b\u0010#\u001a\u00020!H\u0016J\u000e\u0010$\u001a\u00020!2\u0006\u0010%\u001a\u00020\bJ\u0010\u0010&\u001a\u00020!2\u0006\u0010\"\u001a\u00020\bH\u0016J\b\u0010'\u001a\u00020!H\u0016J\b\u0010(\u001a\u00020!H\u0016J\b\u0010)\u001a\u00020!H\u0016J\b\u0010*\u001a\u00020!H\u0016J\b\u0010+\u001a\u00020!H\u0016J\b\u0010,\u001a\u00020!H\u0016J,\u0010-\u001a\u00020!2\u0006\u0010.\u001a\u00020\u00102\u0006\u0010/\u001a\u00020\b2\u0012\u00100\u001a\u000e\u0012\u0004\u0012\u00020\u0010\u0012\u0004\u0012\u00020!01H\u0016J\b\u00102\u001a\u00020!H\u0016J\b\u00103\u001a\u00020!H\u0016J\b\u00104\u001a\u00020!H\u0016J\b\u00105\u001a\u00020!H\u0016J\b\u00106\u001a\u00020!H\u0016J\u0010\u00107\u001a\u00020!2\u0006\u00108\u001a\u00020\bH\u0016J\b\u00109\u001a\u00020!H\u0016J\u0006\u0010:\u001a\u00020!J\u0006\u0010;\u001a\u00020!J$\u0010<\u001a\u00020!2\u0006\u0010/\u001a\u00020\b2\u0012\u00100\u001a\u000e\u0012\u0004\u0012\u00020\u0010\u0012\u0004\u0012\u00020!01H\u0002J\u0006\u0010=\u001a\u00020!J\u0019\u0010>\u001a\u0013\u0012\u0004\u0012\u00020\u0010\u0012\u0004\u0012\u00020!01¢\u0006\u0002\b?H\u0002J\u0006\u0010@\u001a\u00020\bJ\b\u0010A\u001a\u00020!H\u0016J\b\u0010B\u001a\u00020!H\u0016J\b\u0010C\u001a\u00020!H\u0016J\b\u0010D\u001a\u00020!H\u0016J\u000e\u0010E\u001a\u00020!2\u0006\u00108\u001a\u00020\bR\u0014\u0010\u0007\u001a\u00020\bX\u0086D¢\u0006\b\n\u0000\u001a\u0004\b\t\u0010\nR\u0014\u0010\u000b\u001a\u00020\bX\u0086D¢\u0006\b\n\u0000\u001a\u0004\b\f\u0010\nR\u0010\u0010\r\u001a\u0004\u0018\u00010\u000eX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u000f\u001a\u00020\u0010X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0011\u001a\u00020\bX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0012\u001a\u00020\bX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u0013\u001a\u0004\u0018\u00010\u0014X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u0015\u001a\u0004\u0018\u00010\bX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0016\u001a\u00020\bX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u0017\u001a\u0004\u0018\u00010\u0018X\u0082\u000e¢\u0006\u0002\n\u0000R\u0016\u0010\u0019\u001a\n\u0012\u0004\u0012\u00020\u0014\u0018\u00010\u001aX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u001b\u001a\u0004\u0018\u00010\bX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u001c\u001a\u0004\u0018\u00010\u0018X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u0004\u001a\u0004\u0018\u00010\u0002X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u001d\u001a\u0004\u0018\u00010\u001eX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u001f\u001a\u0004\u0018\u00010\u0018X\u0082\u000e¢\u0006\u0002\n\u0000¨\u0006F"}, d2 = {"Lcom/emax/weather/presenter/APconnectPresenterImp;", "Lcom/emax/weather/base/BasePresenter;", "Lcom/emax/weather/event/APconnectEvent$APconnectView;", "Lcom/emax/weather/event/APconnectEvent$APconnectPresenter;", "view", "(Lcom/emax/weather/event/APconnectEvent$APconnectView;)V", "()V", "ENCRY_AES", "", "getENCRY_AES", "()Ljava/lang/String;", "ENCRY_NONE", "getENCRY_NONE", "blueConnectManager", "Lcom/emax/weather/ble/BlueConnectManage;", "currentPort", "", "currentServerId", "currentSsid", "currentWifiResult", "Landroid/net/wifi/ScanResult;", "deviceMac", "modelType", "notifyUuid", "Ljava/util/UUID;", "results", "", "selectSsid", "serviceUuid", "wifiConnectManage", "Lcom/yyl/kwifi_lib/WifiConnectManage;", "writeUuid", "beginBleConnect", "", "bleMac", "beginConnect", "bind", "matchingMode", "bleDisconnect", "callbackBleConnectFail", "callbackBleConnectSuccess", "callbackConNetFail", "callbackConNetSuccess", "callbackConnectFail", "callbackConnectSuccess", "callbackData", "state", "data", "checkAfter", "Lkotlin/Function1;", "callbackNotResponse", "callbackScanLivingSmartFail", "callbackScanLivingSmartSuccess", "callbackSuccess", "callbackTranDataFail", "callbackTranDataSuccess", "mac", "checkCloseAp", "closeConnect", "connectNetWorkWifi", "currentModelId", "destory", "errorCallback", "Lkotlin/ExtensionFunctionType;", "getDeviceMac", "performCallbackFail", "requestBleConnect", "requestConnect", "requestData", "setDeviceMac", "app_release"}, k = 1, mv = {1, 5, 1}, xi = 48)
public final class APconnectPresenterImp extends BasePresenter<APconnectEvent.APconnectView> implements APconnectEvent.APconnectPresenter {
private final String ENCRY_AES;
private final String ENCRY_NONE;
private BlueConnectManage blueConnectManager;
private int currentPort;
private String currentServerId;
private String currentSsid;
private ScanResult currentWifiResult;
private String deviceMac;
private String modelType;
private UUID notifyUuid;
private List<ScanResult> results;
private String selectSsid;
private UUID serviceUuid;
private APconnectEvent.APconnectView view;
private WifiConnectManage wifiConnectManage;
private UUID writeUuid;
public APconnectPresenterImp() {
this.ENCRY_NONE = "NONE";
this.ENCRY_AES = "AES";
this.currentServerId = "10.10.100.254";
this.currentPort = 48899;
this.currentSsid = "HF-LPT220";
this.modelType = CmdConstant.W_0;
}
public final String getENCRY_NONE() {
return this.ENCRY_NONE;
}
public final String getENCRY_AES() {
return this.ENCRY_AES;
}
public APconnectPresenterImp(APconnectEvent.APconnectView aPconnectView) {
this();
this.view = aPconnectView;
if (aPconnectView == null) {
return;
}
this.modelType = aPconnectView.getConnectType();
APconnectPresenterImp aPconnectPresenterImp = this;
this.wifiConnectManage = new WifiConnectManage(aPconnectView.getCurrentContext(), aPconnectPresenterImp, errorCallback());
this.blueConnectManager = new BlueConnectManage(aPconnectView.getCurrentContext(), aPconnectPresenterImp);
}
@Override
public void requestData() {
List scanResult;
APconnectEvent.APconnectView aPconnectView;
WifiConnectManage wifiConnectManage = this.wifiConnectManage;
if (wifiConnectManage == null || (scanResult = wifiConnectManage.getScanResult()) == null || (aPconnectView = this.view) == null) {
return;
}
aPconnectView.refreshContentView(0, scanResult);
}
@Override
public void beginConnect() {
WifiConnectManage wifiConnectManage = this.wifiConnectManage;
if (wifiConnectManage == null) {
return;
}
System.out.println((Object) "扫描周围wifi");
wifiConnectManage.wifiScan();
}
@Override
public void beginBleConnect(String bleMac) {
Intrinsics.checkNotNullParameter(bleMac, "bleMac");
BlueConnectManage blueConnectManage = this.blueConnectManager;
if (blueConnectManage == null) {
return;
}
APconnectEvent.APconnectView aPconnectView = this.view;
Intrinsics.checkNotNull(aPconnectView);
ScanResult currentWifiResult = aPconnectView.getCurrentWifiResult();
APconnectEvent.APconnectView aPconnectView2 = this.view;
Intrinsics.checkNotNull(aPconnectView2);
blueConnectManage.bleConnect(bleMac, currentWifiResult, aPconnectView2.getWifiPwd());
}
@Override
public void bleDisconnect(String bleMac) {
Intrinsics.checkNotNullParameter(bleMac, "bleMac");
BlueConnectManage blueConnectManage = this.blueConnectManager;
if (blueConnectManage == null) {
return;
}
blueConnectManage.bleDisconnect(bleMac);
}
public void callbackBleConnectSuccess() {
APconnectEvent.APconnectView aPconnectView = this.view;
if (aPconnectView == null) {
return;
}
aPconnectView.connectSuccess();
}
public void callbackTranDataFail() {
APconnectEvent.APconnectView aPconnectView = this.view;
if (aPconnectView == null) {
return;
}
aPconnectView.refreshTranDataFail();
}
public void callbackTranDataSuccess(String mac) {
Intrinsics.checkNotNullParameter(mac, "mac");
APconnectEvent.APconnectView aPconnectView = this.view;
if (aPconnectView == null) {
return;
}
aPconnectView.refreshTranDataSuccess(mac);
}
public final void setDeviceMac(String mac) {
Intrinsics.checkNotNullParameter(mac, "mac");
String upperCase = mac.toUpperCase();
Intrinsics.checkNotNullExpressionValue(upperCase, "(this as java.lang.String).toUpperCase()");
this.deviceMac = upperCase;
}
public void callbackBleConnectFail() {
APconnectEvent.APconnectView aPconnectView = this.view;
if (aPconnectView == null) {
return;
}
aPconnectView.refreshConnectBlueFail();
}
@Override
public void requestConnect() {
APconnectEvent.APconnectView aPconnectView = this.view;
if (aPconnectView == null) {
return;
}
ScanResult currentWifiResult = aPconnectView.getCurrentWifiResult();
WifiConnectManage wifiConnectManage = this.wifiConnectManage;
if (wifiConnectManage == null) {
return;
}
String stringPlus = Intrinsics.stringPlus(currentWifiResult.SSID, "\r");
StringBuilder sb = new StringBuilder();
sb.append(wifiConnectManage.encryptionType1(currentWifiResult) ? getENCRY_AES() : getENCRY_NONE());
sb.append(',');
sb.append(aPconnectView.getWifiPwd());
String str = wifiConnectManage.encryptionType2(currentWifiResult) + ',' + sb.toString() + '\r';
if (Intrinsics.areEqual(this.modelType, CmdConstant.W_0)) {
wifiConnectManage.setCurrentCmdMap(CmdConstant.INSTANCE.initWCmp(stringPlus, str));
this.currentPort = 8800;
this.currentServerId = "11.11.11.254";
this.currentSsid = "LivingSmart";
} else if (Intrinsics.areEqual(this.modelType, CmdConstant.W_1)) {
wifiConnectManage.setCurrentCmdMap(CmdConstant.INSTANCE.initCmp(aPconnectView.getCurrentContext(), stringPlus, str));
this.currentPort = 48899;
this.currentServerId = "10.10.100.254";
this.currentSsid = "LivingSmart";
}
wifiConnectManage.setMPort(this.currentPort);
wifiConnectManage.setMServerId(this.currentServerId);
wifiConnectManage.setMDeiviceSsid(this.currentSsid);
wifiConnectManage.setConnectNetWorkWifi(currentWifiResult);
wifiConnectManage.startRequestConnect();
}
@Override
public void requestBleConnect() {
BlueConnectManage blueConnectManage = this.blueConnectManager;
Intrinsics.checkNotNull(blueConnectManage);
blueConnectManage.requestConnect();
}
public final void destory() {
WifiConnectManage wifiConnectManage = this.wifiConnectManage;
Intrinsics.checkNotNull(wifiConnectManage);
wifiConnectManage.destory();
}
public final void closeConnect() {
WifiConnectManage wifiConnectManage = this.wifiConnectManage;
Intrinsics.checkNotNull(wifiConnectManage);
wifiConnectManage.closeDisposable();
}
private final Function1<Integer, Unit> errorCallback() {
return new Function1<Integer, Unit>() {
{
super(1);
}
public Object invoke(Object obj) {
invoke(((Number) obj).intValue());
return Unit.INSTANCE;
}
public final void invoke(int i) {
APconnectEvent.APconnectView aPconnectView;
aPconnectView = APconnectPresenterImp.this.view;
if (aPconnectView == null) {
return;
}
aPconnectView.dismissLoadingViews();
if (i == WifiConnectManage.Companion.getPWD_ERROR()) {
System.out.println((Object) "密码错误");
aPconnectView.showToastMessage(R.string.invalid_pwd);
return;
}
if (i == WifiConnectManage.Companion.getCONNECT_TIME_OUT()) {
System.out.println((Object) "连接超时");
aPconnectView.showToastMessage(R.string.wifi_unable_connect);
} else if (i == WifiConnectManage.Companion.getNOT_FOUND_DEVICE()) {
System.out.println((Object) "没有找到设备");
aPconnectView.showToastMessage(R.string.no_device);
} else if (i == WifiConnectManage.Companion.getCONNECT_FAIL()) {
System.out.println((Object) "连接失败");
aPconnectView.showToastMessage(R.string.invalid_pwd);
}
}
};
}
public void performCallbackFail() {
APconnectEvent.APconnectView aPconnectView = this.view;
if (aPconnectView == null) {
return;
}
aPconnectView.dismissLoadingViews();
aPconnectView.showToastMessage(R.string.setting_failure);
}
public void callbackNotResponse() {
APconnectEvent.APconnectView aPconnectView = this.view;
if (aPconnectView == null) {
return;
}
aPconnectView.dismissLoadingViews();
aPconnectView.showToastMessage(R.string.not_response);
}
public void callbackData(int state, String data, Function1<? super Integer, Unit> checkAfter) {
Intrinsics.checkNotNullParameter(data, "data");
Intrinsics.checkNotNullParameter(checkAfter, "checkAfter");
if (state == CmdConstant.INSTANCE.getSTATE_CONNECT()) {
currentModelId(data, checkAfter);
return;
}
if (StringsKt.contains$default(data, "+ok", false, 2, (Object) null)) {
checkAfter.invoke(Integer.valueOf(ConnectorTransmit.Companion.getCURRENT_SEND_CMD()));
} else if (Intrinsics.areEqual(this.modelType, CmdConstant.W_0)) {
checkAfter.invoke(Integer.valueOf(ConnectorTransmit.Companion.getRESTART_SEND_CMD()));
} else if (Intrinsics.areEqual(CmdConstant.W_1, this.modelType)) {
checkAfter.invoke(Integer.valueOf(ConnectorTransmit.Companion.getSEND_ERROR_COMD()));
}
}
private final void currentModelId(String data, Function1<? super Integer, Unit> checkAfter) {
String str = this.modelType;
if (Intrinsics.areEqual(str, CmdConstant.W_0)) {
List split$default = StringsKt.split$default(data, new String[]{","}, false, 0, 6, (Object) null);
if (split$default.size() == 2) {
System.out.println((Object) Intrinsics.stringPlus("当前macId是", split$default.get(0)));
checkAfter.invoke(Integer.valueOf(ConnectorTransmit.Companion.getCURRENT_SEND_CMD()));
this.deviceMac = (String) split$default.get(0);
return;
}
checkAfter.invoke(Integer.valueOf(ConnectorTransmit.Companion.getSEND_ERROR_COMD()));
return;
}
if (Intrinsics.areEqual(str, CmdConstant.W_1)) {
List split$default2 = StringsKt.split$default(data, new String[]{","}, false, 0, 6, (Object) null);
if (split$default2.size() >= 3) {
System.out.println((Object) Intrinsics.stringPlus("当前macId是", split$default2.get(1)));
this.deviceMac = (String) split$default2.get(1);
checkAfter.invoke(Integer.valueOf(ConnectorTransmit.Companion.getCURRENT_SEND_CMD()));
return;
}
checkAfter.invoke(Integer.valueOf(ConnectorTransmit.Companion.getSEND_ERROR_COMD()));
}
}
public void callbackSuccess() {
APconnectEvent.APconnectView aPconnectView = this.view;
if (aPconnectView != null) {
aPconnectView.dismissLoadingViews();
WifiConnectManage wifiConnectManage = this.wifiConnectManage;
if (wifiConnectManage != null) {
wifiConnectManage.cleanTimeOut();
}
if (Intrinsics.areEqual(this.modelType, CmdConstant.W_1)) {
String string = aPconnectView.getCurrentContext().getString(R.string.Bind_successful);
Intrinsics.checkNotNullExpressionValue(string, "getCurrentContext().getString(R.string.Bind_successful)");
aPconnectView.cfgSuccess(string);
} else {
String string2 = aPconnectView.getCurrentContext().getString(R.string.msg_restart);
Intrinsics.checkNotNullExpressionValue(string2, "getCurrentContext().getString(R.string.msg_restart)");
aPconnectView.cfgSuccess(string2);
}
}
System.out.println((Object) "连接可用网络中...");
connectNetWorkWifi();
}
public final void connectNetWorkWifi() {
WifiConnectManage wifiConnectManage = this.wifiConnectManage;
if (wifiConnectManage == null) {
return;
}
wifiConnectManage.connectNetWorkWifi();
}
@Override
public void checkCloseAp() {
WifiConnectManage wifiConnectManage = this.wifiConnectManage;
if (wifiConnectManage == null) {
return;
}
if (Intrinsics.areEqual(wifiConnectManage.getCurrentConnectWifi().getSSID(), wifiConnectManage.getMDeiviceSsid())) {
callbackSuccess();
return;
}
APconnectEvent.APconnectView aPconnectView = this.view;
if (aPconnectView != null) {
aPconnectView.dismissLoadingViews();
}
APconnectEvent.APconnectView aPconnectView2 = this.view;
SharedPreUtils.putString(aPconnectView2 == null ? null : aPconnectView2.getCurrentContext(), "mac_device", this.deviceMac);
BaseApplication.getApplication().isBind = true;
APconnectEvent.APconnectView aPconnectView3 = this.view;
if (aPconnectView3 == null) {
return;
}
aPconnectView3.allSuccess(String.valueOf(this.deviceMac));
}
public void callbackConnectSuccess() {
APconnectEvent.APconnectView aPconnectView = this.view;
if (aPconnectView == null) {
return;
}
aPconnectView.connectSuccess();
}
public void callbackConNetSuccess() {
APconnectEvent.APconnectView aPconnectView = this.view;
if (aPconnectView == null) {
return;
}
aPconnectView.connectNetSuccess();
}
public void callbackConNetFail() {
APconnectEvent.APconnectView aPconnectView = this.view;
if (aPconnectView == null) {
return;
}
aPconnectView.connectNetFail();
}
public final String getDeviceMac() {
return String.valueOf(this.deviceMac);
}
public final void bind(String matchingMode) {
Intrinsics.checkNotNullParameter(matchingMode, "matchingMode");
System.out.println((Object) "执行绑定接口bind申请绑定");
String token = DaoHadle.getUser().getToken();
JSONObject jSONObject = new JSONObject();
String valueOf = String.valueOf(this.deviceMac);
Objects.requireNonNull(valueOf, "null cannot be cast to non-null type java.lang.String");
String upperCase = valueOf.toUpperCase();
Intrinsics.checkNotNullExpressionValue(upperCase, "(this as java.lang.String).toUpperCase()");
try {
jSONObject.put("mac", upperCase);
jSONObject.put("matchingMode", matchingMode);
} catch (JSONException e) {
e.printStackTrace();
}
Log.i("APconnectPresenterImp", Intrinsics.stringPlus("lyq bind jsonObject:", jSONObject));
Observable timeout = RetrofitUtil.getHttpService().bind(token, RequestBody.create(this.MEDIA_STREM, jSONObject.toString())).compose(new RetrofitUtil.CommonOptions()).timeout(10L, TimeUnit.SECONDS);
APconnectEvent.APconnectView aPconnectView = this.view;
final Context currentContext = aPconnectView == null ? null : aPconnectView.getCurrentContext();
timeout.subscribe(new CodeHandledSubscriber<ResponseData<Device>>(currentContext) {
@Override
protected void onError(ApiException apiException) {
APconnectEvent.APconnectView aPconnectView2;
Intrinsics.checkNotNullParameter(apiException, "apiException");
aPconnectView2 = APconnectPresenterImp.this.view;
if (aPconnectView2 == null) {
return;
}
aPconnectView2.bindFail();
}
@Override
public void onBusinessNext(ResponseData<Device> data) {
APconnectEvent.APconnectView aPconnectView2;
APconnectEvent.APconnectView aPconnectView3;
String str;
APconnectEvent.APconnectView aPconnectView4;
Intrinsics.checkNotNullParameter(data, "data");
Device content = data.getContent();
if (content != null) {
aPconnectView3 = APconnectPresenterImp.this.view;
Intrinsics.checkNotNull(aPconnectView3);
Context currentContext2 = aPconnectView3.getCurrentContext();
str = APconnectPresenterImp.this.deviceMac;
String valueOf2 = String.valueOf(str);
Objects.requireNonNull(valueOf2, "null cannot be cast to non-null type java.lang.String");
String upperCase2 = valueOf2.toUpperCase();
Intrinsics.checkNotNullExpressionValue(upperCase2, "(this as java.lang.String).toUpperCase()");
SharedPreUtils.putString(currentContext2, "mac_device", upperCase2);
DeviceDao deviceDao = BaseApplication.getApplication().getDaoSession().getDeviceDao();
content.setId(1L);
deviceDao.insertOrReplace(content);
aPconnectView4 = APconnectPresenterImp.this.view;
if (aPconnectView4 == null) {
return;
}
aPconnectView4.bindSuccess();
return;
}
aPconnectView2 = APconnectPresenterImp.this.view;
if (aPconnectView2 == null) {
return;
}
aPconnectView2.bindFail();
}
});
}
public void callbackConnectFail() {
APconnectEvent.APconnectView aPconnectView = this.view;
if (aPconnectView == null) {
return;
}
aPconnectView.connectFail();
}
public void callbackScanLivingSmartSuccess() {
final APconnectEvent.APconnectView aPconnectView = this.view;
if (aPconnectView == null) {
return;
}
String wifiPwd = aPconnectView.getWifiPwd();
final WifiConnectManage wifiConnectManage = this.wifiConnectManage;
if (wifiConnectManage == null) {
return;
}
wifiConnectManage.routeConnect(aPconnectView.getCurrentWifiResult(), wifiPwd, new Function1<WifiBeanInfo, Unit>() {
{
super(1);
}
public Object invoke(Object obj) {
invoke((WifiBeanInfo) obj);
return Unit.INSTANCE;
}
public final void invoke(WifiBeanInfo wifiBeanInfo) {
String str;
String str2;
int i;
String str3;
String str4;
Intrinsics.checkNotNullParameter(wifiBeanInfo, "it");
APconnectPresenterImp.this.selectSsid = wifiBeanInfo.getSsidString();
String stringPlus = Intrinsics.stringPlus(wifiBeanInfo.getSsidString(), "\r");
StringBuilder sb = new StringBuilder();
sb.append(wifiBeanInfo.getHasPassword() ? APconnectPresenterImp.this.getENCRY_AES() : APconnectPresenterImp.this.getENCRY_NONE());
sb.append(',');
sb.append((Object) wifiBeanInfo.getPwdString());
String str5 = ((Object) wifiBeanInfo.getEncryMode()) + ',' + sb.toString() + '\r';
str = APconnectPresenterImp.this.modelType;
if (!Intrinsics.areEqual(str, CmdConstant.W_0)) {
str2 = APconnectPresenterImp.this.modelType;
if (Intrinsics.areEqual(str2, CmdConstant.W_1)) {
wifiConnectManage.setCurrentCmdMap(CmdConstant.INSTANCE.initCmp(aPconnectView.getCurrentContext(), stringPlus, str5));
APconnectPresenterImp.this.currentPort = 48899;
APconnectPresenterImp.this.currentServerId = "10.10.100.254";
APconnectPresenterImp.this.currentSsid = "LivingSmart";
}
} else {
wifiConnectManage.setCurrentCmdMap(CmdConstant.INSTANCE.initWCmp(stringPlus, str5));
APconnectPresenterImp.this.currentPort = 8800;
APconnectPresenterImp.this.currentServerId = "11.11.11.254";
APconnectPresenterImp.this.currentSsid = "LivingSmart";
}
WifiConnectManage wifiConnectManage2 = wifiConnectManage;
i = APconnectPresenterImp.this.currentPort;
wifiConnectManage2.setMPort(i);
WifiConnectManage wifiConnectManage3 = wifiConnectManage;
str3 = APconnectPresenterImp.this.currentServerId;
wifiConnectManage3.setMServerId(str3);
WifiConnectManage wifiConnectManage4 = wifiConnectManage;
str4 = APconnectPresenterImp.this.currentSsid;
wifiConnectManage4.setMDeiviceSsid(str4);
}
});
}
public void callbackScanLivingSmartFail() {
WifiConnectManage wifiConnectManage = this.wifiConnectManage;
if (wifiConnectManage == null) {
return;
}
wifiConnectManage.notFoundDevice();
}
}