工作空间 v3.7.4.6版本的 MD5 值为:94c1c0052e9f2e949ae1349e6caf437b
以下内容为反编译后的 UUSdpClient.java 源代码,内容仅作参考
package com.uusafe.sdp.bridge;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Application;
import android.app.Dialog;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.net.VpnService;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import com.huawei.hms.framework.common.ContainerUtils;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import com.uusafe.base.modulesdk.module.bean.PushCode;
import com.uusafe.emm.policy.PolicyProvider;
import com.uusafe.h5app.library.internal.res.H5Lan;
import com.uusafe.sandbox.netsvr.VpnServiceBaseImpl;
import com.uusafe.sdp.R;
import com.uusafe.sdp.auth.bean.rsp.HeartRsp;
import com.uusafe.sdp.auth.bean.rsp.LoginRsp;
import com.uusafe.sdp.auth.bean.rsp.RefreshSmsRsp;
import com.uusafe.sdp.auth.listener.IamAuthCallback;
import com.uusafe.sdp.auth.listener.SdpGetSmsCallback;
import com.uusafe.sdp.auth.listener.SdpHeartBeatCallback;
import com.uusafe.sdp.auth.listener.SdpLoginCallback;
import com.uusafe.sdp.auth.listener.SdpMpCallback;
import com.uusafe.sdp.auth.listener.SdpPluginCallback;
import com.uusafe.sdp.auth.listener.SdpRefreshSmsCallback;
import com.uusafe.sdp.bridge.UUSdpClient;
import com.uusafe.sdp.bridge.bean.info.AppPolicyDetail;
import com.uusafe.sdp.bridge.bean.info.NetworkInfo;
import com.uusafe.sdp.bridge.bean.info.UUPluginReq;
import com.uusafe.sdp.bridge.bean.info.UUSdpAccessInfo;
import com.uusafe.sdp.bridge.bean.info.UUSdpGatewayInfo;
import com.uusafe.sdp.bridge.bean.info.UUSdpInitInfo;
import com.uusafe.sdp.bridge.bean.info.UUSdpUpdateInfo;
import com.uusafe.sdp.bridge.bean.info.UUSdpUserInfo;
import com.uusafe.sdp.bridge.bean.req.UUSdpCheckSmsRequestInfo;
import com.uusafe.sdp.bridge.bean.req.UUSdpLoginRequestInfo;
import com.uusafe.sdp.bridge.bean.req.UUSdpModifyPasswordRequestInfo;
import com.uusafe.sdp.bridge.bean.req.UUSdpRefreshSmsRequestInfo;
import com.uusafe.sdp.bridge.bean.rsp.UUSdpLoginResponseInfo;
import com.uusafe.sdp.bridge.listener.SdpAppReceiver;
import com.uusafe.sdp.bridge.listener.SdpScreenReceiver;
import com.uusafe.sdp.bridge.listener.UUSdpCheckSmsCallback;
import com.uusafe.sdp.bridge.listener.UUSdpEmmCallback;
import com.uusafe.sdp.bridge.listener.UUSdpGatewayInfoChangeListener;
import com.uusafe.sdp.bridge.listener.UUSdpGetSmsCallback;
import com.uusafe.sdp.bridge.listener.UUSdpLoginBreakCallback;
import com.uusafe.sdp.bridge.listener.UUSdpLoginCallback;
import com.uusafe.sdp.bridge.listener.UUSdpLogoutCallback;
import com.uusafe.sdp.bridge.listener.UUSdpModifyPasswordCallback;
import com.uusafe.sdp.bridge.listener.UUSdpRefreshSmsCallback;
import com.uusafe.sdp.bridge.listener.UUSdpSpeedListener;
import com.uusafe.sdp.bridge.listener.UUSdpTunnelStateListener;
import com.uusafe.sdp.channel.android.backend.GoBackend;
import com.uusafe.sdp.invoke.util.PreferenceUtils;
import com.uusafe.sdp.proguard.a3;
import com.uusafe.sdp.proguard.a4;
import com.uusafe.sdp.proguard.b3;
import com.uusafe.sdp.proguard.b4;
import com.uusafe.sdp.proguard.c2;
import com.uusafe.sdp.proguard.d1;
import com.uusafe.sdp.proguard.d2;
import com.uusafe.sdp.proguard.e1;
import com.uusafe.sdp.proguard.e3;
import com.uusafe.sdp.proguard.f1;
import com.uusafe.sdp.proguard.g0;
import com.uusafe.sdp.proguard.g2;
import com.uusafe.sdp.proguard.h0;
import com.uusafe.sdp.proguard.i0;
import com.uusafe.sdp.proguard.i1;
import com.uusafe.sdp.proguard.j1;
import com.uusafe.sdp.proguard.j2;
import com.uusafe.sdp.proguard.l1;
import com.uusafe.sdp.proguard.m0;
import com.uusafe.sdp.proguard.m1;
import com.uusafe.sdp.proguard.n1;
import com.uusafe.sdp.proguard.o2;
import com.uusafe.sdp.proguard.p2;
import com.uusafe.sdp.proguard.p3;
import com.uusafe.sdp.proguard.q1;
import com.uusafe.sdp.proguard.q2;
import com.uusafe.sdp.proguard.r1;
import com.uusafe.sdp.proguard.s;
import com.uusafe.sdp.proguard.s1;
import com.uusafe.sdp.proguard.t;
import com.uusafe.sdp.proguard.t1;
import com.uusafe.sdp.proguard.u1;
import com.uusafe.sdp.proguard.v;
import com.uusafe.sdp.proguard.v1;
import com.uusafe.sdp.proguard.v2;
import com.uusafe.sdp.proguard.w;
import com.uusafe.sdp.proguard.w0;
import com.uusafe.sdp.proguard.w1;
import com.uusafe.sdp.proguard.w2;
import com.uusafe.sdp.proguard.x0;
import com.uusafe.sdp.proguard.x1;
import com.uusafe.sdp.proguard.x2;
import com.uusafe.sdp.proguard.y;
import com.uusafe.sdp.proguard.y1;
import com.uusafe.sdp.proguard.z1;
import com.uusafe.sdp.proguard.z2;
import com.xiaomi.mipush.sdk.Constants;
import com.zhizhangyi.platform.zwebview.DefaultWebClient;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
import net.sqlcipher.database.SQLiteDatabase;
import org.json.JSONArray;
import org.json.JSONObject;
public class UUSdpClient implements r1.a, s1.a {
public static final int DEFAULT_PORT = 9081;
public static final String DEFAULT_URL = "https://10.168.255.193:9081";
private static final String DIR_APP = "uusafe";
private static final String DIR_LOG = "safelink";
public static final int HEART_KILL_10001 = 10001;
public static final int HEART_KILL_10002 = 10002;
public static final int HEART_KILL_10003 = 10003;
public static final int HEART_KILL_10004 = 10004;
public static final int HEART_KILL_10005 = 10005;
public static final int HEART_KILL_10006 = 10006;
public static final int HEART_KILL_10007 = 10007;
public static final String SDP_NAME = "SafeLink";
public static final String SDP_VERSION = "1.3.4.9";
private static final String SERVER_PROVIDER_AUTHORITIES = ".SdpBridgeProvider";
private static final String SERVER_PROVIDER_SCHEME = "content://";
public static boolean SM_ENCRYPT = false;
public static final String TAG = "SafeLink";
private static final String TUNNEL_DEAFULT_NAME = "SafeLink";
public static boolean WARRPING_SDK = false;
private static UUSdpClient instance = null;
public static final String timeCountTag = "=timeCount=";
public static long timeCountValue;
private GoBackend backend;
private long checkTime;
private Context context;
private Activity currentActivity;
private List<InetAddress> currentDnsServers;
private q2 customBottomDialog;
private String getResUrl;
private Handler handler;
private Properties heartReqProperties;
private HeartRsp heartRsp;
private e1 kcpConfig;
private int lastErrorCode;
private long lastHeartTime;
private m0 loginReq;
private LoginRsp loginRsp;
private String ssl_caPublicKeyPemStr;
private boolean ssl_skipCertificate;
private r1 uuNetWorkStateReceiver;
private UUSdpEmmCallback uuSdpEmmCallback;
private ArrayList<UUSdpGatewayInfo> uuSdpGatewayInfos;
private UUSdpLoginBreakCallback uuSdpLoginBreakCallback;
private s1 uuSdpTunnel;
private VpnServiceBaseImpl vpnServiceBase;
private n1 heartAlarm = null;
private int ht = 60;
private ArrayList<UUSdpTunnelStateListener> uuSdpTunnelStateListeners = new ArrayList<>();
private ArrayList<UUSdpGatewayInfoChangeListener> uuSdpGatewayInfoChangeListeners = new ArrayList<>();
private int tunnelCloseCode = 110;
private boolean isZlogInit = true;
private String cid = null;
private boolean startThirdApp = false;
private boolean multipleSdk = false;
private boolean showNotification = true;
private int VPNDelay = 10;
private final ExecutorService executorService = Executors.newCachedThreadPool();
private boolean v1 = false;
private int mtu = -1;
private boolean ipv6 = false;
private boolean autoLogin = false;
private boolean kickedByServer = false;
private boolean publicDNS = false;
private String dd_app_id = "ding8cyfs8jd5l0caw7f";
private String checkDns = "";
public boolean isReStart = false;
private boolean showVpnDetail = false;
private ArrayList<AppPolicyDetail> appPolicyDetails = new ArrayList<>();
private ArrayList<UUSdpLoginCallback> uuSdpLoginCallbacks = new ArrayList<>();
private boolean appInForeground = false;
private boolean first = true;
public final int interval = PolicyProvider.DataContract.TYPE_ENCRYPTION;
private boolean reConnect = false;
private boolean sdpClient = false;
public class a implements Runnable {
public a() {
}
@Override
public void run() {
try {
Thread.sleep(1000L);
} catch (Exception e2) {
e2.printStackTrace();
}
UUSdpClient.this.sendHeartBeatMessage();
}
}
public class b implements Runnable {
public final String f5167a;
public final LoginRsp f5168b;
public final ArrayList f5169c;
public final String f5170d;
public final int f5171e;
public class a implements Runnable {
public final ArrayList f5172a;
public a(b bVar, ArrayList arrayList) {
this.f5172a = arrayList;
}
@Override
public void run() {
z1.a(((UUSdpGatewayInfo) this.f5172a.get(0)).getIp(), 5);
}
}
public class RunnableC0105b implements Runnable {
public final UUSdpLoginResponseInfo f5173a;
public RunnableC0105b(UUSdpLoginResponseInfo uUSdpLoginResponseInfo) {
this.f5173a = uUSdpLoginResponseInfo;
}
@Override
public void run() {
try {
Thread.sleep(UUSdpClient.this.getVPNDelay());
} catch (Exception unused) {
}
UUSdpClient.this.loginSuccess(this.f5173a);
}
}
public b(String str, LoginRsp loginRsp, ArrayList arrayList, String str2, int i) {
this.f5167a = str;
this.f5168b = loginRsp;
this.f5169c = arrayList;
this.f5170d = str2;
this.f5171e = i;
}
@Override
public void run() {
String str;
try {
d2 a2 = d2.a(new ByteArrayInputStream(this.f5167a.getBytes("UTF-8")));
String dnsSettings = UUSdpClient.this.getDnsSettings(this.f5168b);
q1.c("SafeLink", "openTunnel->dnsSettings==" + dnsSettings + "=endpoint=" + a2.b().get(0).b().toString(), new Object[0]);
this.f5169c.clear();
if (this.f5168b.getData().getAaf() == 1) {
ArrayList<AppPolicyDetail> apds = this.f5168b.getData().getApds();
String a3 = new a4().a(apds);
if (apds != null && (apds instanceof List)) {
for (AppPolicyDetail appPolicyDetail : apds) {
if (appPolicyDetail.getPkn() != null) {
this.f5169c.add(appPolicyDetail.getPkn());
UUSdpClient.this.appPolicyDetails.add(appPolicyDetail);
}
}
}
str = a3;
} else {
str = "";
}
q1.d("SafeLink", "openTunnel-> allowedApplications==" + this.f5169c.toString(), new Object[0]);
UUSdpClient.this.uuSdpTunnel = new s1(this.f5170d, a2, u1.a.DOWN, this.f5171e, dnsSettings, this.f5169c, str);
UUSdpClient.this.uuSdpTunnel.a(UUSdpClient.this);
UUSdpClient.this.uuSdpTunnel.a(this.f5168b.getData().getDf());
UUSdpClient.this.uuSdpTunnel.c(this.f5168b.getData().getDt());
UUSdpClient.this.uuSdpTunnel.b(this.f5168b.getData().getNif());
String c2 = com.uusafe.sdp.proguard.p.a(UUSdpClient.this.context).c();
String a4 = a2.b().get(0).b().b().a();
boolean isCorrectIp = UUSdpClient.this.isCorrectIp(c2);
boolean isCorrectIp2 = UUSdpClient.this.isCorrectIp(a4);
if (isCorrectIp) {
for (j2 j2Var : UUSdpClient.this.uuSdpTunnel.h().b()) {
for (g2 g2Var : j2Var.a()) {
if (g2Var.toString().contains(c2)) {
q1.c("SafeLink", "SDP_CLIENT_LOGIN_CONFIG_ERROR addr= " + g2Var + "=currentHost=" + c2, new Object[0]);
UUSdpClient.this.loginError(113, null);
return;
}
}
}
}
if (isCorrectIp2) {
for (j2 j2Var2 : UUSdpClient.this.uuSdpTunnel.h().b()) {
for (g2 g2Var2 : j2Var2.a()) {
if (g2Var2.toString().contains(a4)) {
q1.c("SafeLink", "SDP_CLIENT_LOGIN_CONFIG_ERROR addr= " + g2Var2 + "=endPointHost=" + c2, new Object[0]);
UUSdpClient.this.loginError(113, null);
return;
}
}
}
}
GoBackend goBackend = UUSdpClient.this.backend;
s1 s1Var = UUSdpClient.this.uuSdpTunnel;
u1.a aVar = u1.a.UP;
if (goBackend.b(s1Var, aVar, UUSdpClient.this.uuSdpTunnel.h()) == aVar) {
q1.c("SafeLink", "openTunnel->Login success,tunnel open", new Object[0]);
try {
UUSdpLoginResponseInfo generateLoginResponseInfo = UUSdpClient.this.generateLoginResponseInfo(this.f5168b);
UUSdpClient.this.setHeartBeatListener();
q1.d("SafeLink", "generateHeartProperties", new Object[0]);
UUSdpClient.this.generateHeartProperties(null);
UUSdpClient.this.lastHeartTime = System.currentTimeMillis();
UUSdpClient.this.startAlarm();
q1.c("SafeLink", UUSdpClient.this.getVPNDelay() + "Login success,loginCallback" + UUSdpClient.timeCountTag + (System.currentTimeMillis() - UUSdpClient.timeCountValue), new Object[0]);
ArrayList<UUSdpGatewayInfo> gis = generateLoginResponseInfo.getGis();
if (gis == null || gis.size() <= 0) {
return;
}
UUSdpClient.this.executorService.execute(new a(this, gis));
UUSdpClient.this.executorService.execute(new RunnableC0105b(generateLoginResponseInfo));
UUSdpClient uUSdpClient = UUSdpClient.this;
uUSdpClient.backToApp(uUSdpClient.getCurrentActivity());
return;
} catch (Exception e2) {
q1.b("SafeLink", "openTunnel->UUSdpClient login generateLoginResponseInfo fail" + e2.getMessage(), new Object[0]);
UUSdpClient.this.loginError(t1.a.SDP_CLIENT_LOGIN_SETSTATE_FAIL.getCode(), null);
return;
}
}
q1.b("SafeLink", "openTunnel->UUSdpClient login setState fail:", new Object[0]);
UUSdpClient.this.loginError(t1.a.SDP_CLIENT_LOGIN_SETSTATE_FAIL.getCode(), null);
} catch (Exception e3) {
q1.a("SafeLink", e3);
q1.b("SafeLink", "openTunnel->UUSdpClient login openTunnel exception:" + e3.getMessage(), new Object[0]);
if (e3 instanceof t1) {
UUSdpClient.this.loginError(((t1) e3).getReason().getCode(), null);
} else if (e3 instanceof c2) {
UUSdpClient.this.loginError(106, null);
} else {
UUSdpClient.this.loginError(110, null);
}
}
}
}
public class c implements Runnable {
public final UUSdpLogoutCallback f5175a;
public c(UUSdpLogoutCallback uUSdpLogoutCallback) {
this.f5175a = uUSdpLogoutCallback;
}
@Override
public void run() {
try {
GoBackend goBackend = UUSdpClient.this.backend;
s1 s1Var = UUSdpClient.this.uuSdpTunnel;
u1.a aVar = u1.a.DOWN;
if (goBackend.b(s1Var, aVar, null) == aVar) {
if (UUSdpClient.this.loginReq != null) {
Properties properties = new Properties();
properties.setProperty(com.uusafe.sdp.proguard.p.G, UUSdpClient.this.loginReq.getCid());
com.uusafe.sdp.proguard.p.a(UUSdpClient.this.context).b(properties);
}
UUSdpClient.this.heartAlarm.a(UUSdpClient.this.context);
if (UUSdpClient.this.uuSdpTunnel != null) {
UUSdpClient.this.uuSdpTunnel = null;
}
UUSdpClient.this.loginReq = null;
UUSdpClient.this.loginRsp = null;
UUSdpClient.this.heartRsp = null;
UUSdpClient.this.heartReqProperties.clear();
q1.c("SafeLink", "Logout success,tunnel closed", new Object[0]);
UUSdpLogoutCallback uUSdpLogoutCallback = this.f5175a;
if (uUSdpLogoutCallback != null) {
uUSdpLogoutCallback.onSuccess();
return;
}
return;
}
UUSdpLogoutCallback uUSdpLogoutCallback2 = this.f5175a;
if (uUSdpLogoutCallback2 != null) {
uUSdpLogoutCallback2.onError(102);
}
q1.b("SafeLink", "closeTunnel error SDP_TUNNEL_ERROR:102", new Object[0]);
} catch (Exception e2) {
e2.printStackTrace();
q1.b("SafeLink", "closeTunnel error SDP_TUNNEL_ERROR:102", new Object[0]);
UUSdpLogoutCallback uUSdpLogoutCallback3 = this.f5175a;
if (uUSdpLogoutCallback3 != null) {
uUSdpLogoutCallback3.onError(102);
}
}
}
}
public class d implements SdpHeartBeatCallback {
public class a implements UUSdpLoginCallback {
public final int f5178a;
public final int f5179b;
public a(d dVar, int i, int i2) {
this.f5178a = i;
this.f5179b = i2;
}
@Override
public void onError(int i, UUSdpLoginResponseInfo uUSdpLoginResponseInfo) {
q1.b("SafeLink", "kicksign error code==" + i, new Object[0]);
}
@Override
public void onSuccess(UUSdpLoginResponseInfo uUSdpLoginResponseInfo) {
q1.b("SafeLink", "kicksign success ==code==" + this.f5178a + "errorCode==" + this.f5179b, new Object[0]);
}
}
public d() {
}
@Override
public void onError(int i, int i2) {
UUSdpClient.this.lastErrorCode = i2;
q1.b("SafeLink", "heartBeat error ,errorCode:" + i2 + "=code=" + i, new Object[0]);
try {
if (i != 1000 || (i2 != 10001 && i2 != 10004)) {
if (!UUSdpClient.this.autoLogin || i != 1000 || i2 != -1) {
UUSdpClient.this.tunnelCloseCode = 1000;
} else {
q1.b("SafeLink", "heartBeat autoLogin", new Object[0]);
UUSdpClient.this.setKickedByServer(true);
}
if (i == 1000) {
UUSdpClient.this.backend.b(UUSdpClient.this.uuSdpTunnel, u1.a.DOWN, null);
return;
}
return;
}
UUSdpClient.this.sign(new a(this, i, i2));
} catch (Exception e2) {
e2.printStackTrace();
}
}
@Override
public void onSuccess(HeartRsp heartRsp) {
if (heartRsp != null) {
q1.c("SafeLink", "received heartBeat response", new Object[0]);
UUSdpClient.this.processHeartRsp(heartRsp);
return;
}
q1.b("SafeLink", "heartBeat no response", new Object[0]);
}
}
public class e implements UUSdpLoginCallback {
public e() {
}
@Override
public void onError(int i, UUSdpLoginResponseInfo uUSdpLoginResponseInfo) {
q1.a("SafeLink", "Sdp reConnect error,errorCode:" + i, new Object[0]);
}
@Override
public void onSuccess(UUSdpLoginResponseInfo uUSdpLoginResponseInfo) {
q1.a("SafeLink", "Sdp reConnect success,tunnel open", new Object[0]);
UUSdpClient.this.setKickedByServer(false);
}
}
public class f implements Runnable {
public f() {
}
@Override
public void run() {
UUSdpClient.this.heartBeat();
}
}
public class g implements Runnable {
public g(UUSdpClient uUSdpClient) {
}
@Override
public void run() {
for (int i = 0; i < 3; i++) {
z1.a("www.baidu.com");
try {
Thread.sleep(1000L);
} catch (Exception e2) {
e2.printStackTrace();
}
}
}
}
public class h implements Runnable {
public final UUSdpLoginResponseInfo f5182a;
public h(UUSdpLoginResponseInfo uUSdpLoginResponseInfo) {
this.f5182a = uUSdpLoginResponseInfo;
}
@Override
public void run() {
String str;
String str2;
ArrayList<UUSdpGatewayInfo> gis = this.f5182a.getGis();
if (gis == null || gis.size() <= 0) {
UUSdpClient.this.getResUrl = "10.168.255.193";
str = UUSdpClient.DEFAULT_URL;
} else {
str = DefaultWebClient.HTTPS_SCHEME + this.f5182a.getGis().get(0).getIp() + Constants.COLON_SEPARATOR + UUSdpClient.DEFAULT_PORT;
UUSdpClient.this.getResUrl = this.f5182a.getGis().get(0).getIp();
}
if (this.f5182a.getV() >= 6) {
str2 = str + o2.f5806b;
} else if (this.f5182a.getV() >= 4) {
str2 = str + o2.f5807c;
} else if (this.f5182a.getV() >= 3) {
str2 = str + o2.f5808d;
} else if (this.f5182a.getV() >= 2) {
str2 = str + o2.f5809e;
} else {
str2 = str + o2.f;
}
z2.a(str2).a("SdpAuth", o2.a(UUSdpClient.this.loginReq.getOc(), com.uusafe.sdp.proguard.p.a(UUSdpClient.this.context).b().b().f())).a(o2.a(UUSdpClient.this.loginReq.getCid())).a().a(new a());
}
public class a extends b3<byte[]> {
public a() {
}
@Override
public byte[] a(a3 a3Var) throws Exception {
byte[] bArr = new byte[1024];
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
while (true) {
int read = a3Var.a().read(bArr);
if (read != -1) {
byteArrayOutputStream.write(bArr, 0, read);
} else {
byteArrayOutputStream.close();
a3Var.a().close();
return byteArrayOutputStream.toByteArray();
}
}
}
@Override
public void a(byte[] bArr, Object... objArr) {
try {
String str = new String(GoBackend.sm4CBCDecrypt("79642c6dff3f4746".getBytes(), "afc13cd958a3d33b".getBytes(), bArr));
if (h.this.f5182a.getV() >= 3) {
int b2 = UUSdpClient.this.getBackend().b();
try {
String obj = new JSONObject(str).get("data").toString();
q1.c("SafeLink", "wgSetFilter handle=" + b2, new Object[0]);
GoBackend.wgSetFilter(b2, obj);
} catch (Exception e2) {
q1.b("SafeLink", "wgSetFilter error " + e2.getMessage(), new Object[0]);
}
}
} catch (Exception e3) {
e3.getMessage();
}
}
@Override
public void a(e3 e3Var) {
e3Var.a();
String b2 = e3Var.b();
q1.c("SafeLink", "getResData onFailure=" + b2, new Object[0]);
}
}
}
public class i implements Application.ActivityLifecycleCallbacks {
public int f5185a = 0;
public i() {
}
public void a() {
UUSdpClient.getInstance(UUSdpClient.this.context).checkHeart();
}
@Override
public void onActivityCreated(Activity activity, Bundle bundle) {
}
@Override
public void onActivityDestroyed(Activity activity) {
}
@Override
public void onActivityPaused(Activity activity) {
}
@Override
public void onActivityResumed(Activity activity) {
if (activity != null) {
UUSdpClient.this.currentActivity = activity;
}
}
@Override
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
}
@Override
public void onActivityStarted(Activity activity) {
int i = this.f5185a + 1;
this.f5185a = i;
if (i == 1) {
UUSdpClient.this.appInForeground = true;
q1.c("SafeLink", "activityStartCount===1, AppInForeground isFirst=" + UUSdpClient.this.first, new Object[0]);
if (!UUSdpClient.this.first) {
UUSdpClient.this.executorService.execute(new Runnable() {
@Override
public final void run() {
UUSdpClient.i.this.a();
}
});
}
UUSdpClient.this.first = false;
}
}
@Override
public void onActivityStopped(Activity activity) {
int i = this.f5185a - 1;
this.f5185a = i;
if (i == 0) {
UUSdpClient.this.appInForeground = false;
q1.c("SafeLink", "activityStartCount===0, AppInBackground", new Object[0]);
}
}
}
public class j implements View.OnClickListener {
public final UUSdpLoginRequestInfo f5187a;
public final Dialog f5188b;
public j(UUSdpLoginRequestInfo uUSdpLoginRequestInfo, Dialog dialog) {
this.f5187a = uUSdpLoginRequestInfo;
this.f5188b = dialog;
}
@Override
public void onClick(View view) {
ComponentName componentName = new ComponentName(UUSdpClient.this.context.getPackageName(), "com.uusafe.sdp.invoke.ui.SdpVpnActivity");
Intent intent = new Intent();
intent.setComponent(componentName);
intent.putExtra(this.f5187a.getClass().getName(), this.f5187a);
UUSdpClient.this.context.startActivity(intent);
this.f5188b.dismiss();
}
}
public class k implements View.OnClickListener {
public final Dialog f5190a;
public k(Dialog dialog) {
this.f5190a = dialog;
}
@Override
public void onClick(View view) {
UUSdpClient.this.loginError(SdpHeartBeatCallback.SDP_CLIENT_HEARTBEAT_ERROR, null);
this.f5190a.dismiss();
}
}
public class l implements Runnable {
public l() {
}
@Override
public void run() {
UUSdpClient uUSdpClient = UUSdpClient.this;
uUSdpClient.currentDnsServers = l1.b(uUSdpClient.context);
}
}
public class m implements SdpLoginCallback {
public final String f5193a;
public final UUSdpLoginRequestInfo f5194b;
public m(String str, UUSdpLoginRequestInfo uUSdpLoginRequestInfo) {
this.f5193a = str;
this.f5194b = uUSdpLoginRequestInfo;
}
@Override
public void onError(int i, LoginRsp loginRsp) {
q1.c("SafeLink", "Login error:" + i, new Object[0]);
if (i == 103) {
UUSdpClient.this.loginError(103, null);
return;
}
if (i == 1002) {
p2.a().a(UUSdpClient.this.context, this.f5194b);
} else {
PreferenceUtils.clearSsoData(UUSdpClient.this.context);
}
if (loginRsp != null) {
UUSdpClient.this.loginError(i, UUSdpClient.this.generateLoginResponseInfo(loginRsp));
return;
}
UUSdpClient.this.loginError(i, null);
}
@Override
public void onSuccess(m0 m0Var, LoginRsp loginRsp) {
q1.c("SafeLink", "login onSuccess", new Object[0]);
UUSdpClient.this.processLoginRsp(this.f5193a, this.f5194b.getAlgorithm(), this.f5194b.getAllowedApplications(), m0Var, loginRsp);
if (loginRsp.getData().getV() >= 1) {
UUSdpClient.this.v1 = true;
} else {
UUSdpClient.this.v1 = false;
}
if (this.f5194b.isMain()) {
PreferenceUtils.setTicket(loginRsp.getData().getTicket(), UUSdpClient.this.context);
PreferenceUtils.setCid(this.f5194b.getCid(), UUSdpClient.this.context);
}
}
}
public class n implements SdpMpCallback {
public final UUSdpModifyPasswordCallback f5196a;
public n(UUSdpClient uUSdpClient, UUSdpModifyPasswordCallback uUSdpModifyPasswordCallback) {
this.f5196a = uUSdpModifyPasswordCallback;
}
@Override
public void onError(int i) {
this.f5196a.onError(i);
}
@Override
public void onSuccess() {
this.f5196a.onSuccess();
}
}
public class o implements SdpMpCallback {
public final UUSdpModifyPasswordCallback f5197a;
public o(UUSdpClient uUSdpClient, UUSdpModifyPasswordCallback uUSdpModifyPasswordCallback) {
this.f5197a = uUSdpModifyPasswordCallback;
}
@Override
public void onError(int i) {
this.f5197a.onError(i);
}
@Override
public void onSuccess() {
this.f5197a.onSuccess();
}
}
public class p implements SdpRefreshSmsCallback {
public final UUSdpRefreshSmsCallback f5198a;
public p(UUSdpClient uUSdpClient, UUSdpRefreshSmsCallback uUSdpRefreshSmsCallback) {
this.f5198a = uUSdpRefreshSmsCallback;
}
@Override
public void onError(int i) {
this.f5198a.onError(i);
}
@Override
public void onSuccess() {
this.f5198a.onSuccess();
}
}
public class q implements SdpGetSmsCallback {
public final UUSdpGetSmsCallback f5199a;
public q(UUSdpClient uUSdpClient, UUSdpGetSmsCallback uUSdpGetSmsCallback) {
this.f5199a = uUSdpGetSmsCallback;
}
@Override
public void onError(int i, String str) {
this.f5199a.onError(i, str);
}
@Override
public void onSuccess(RefreshSmsRsp refreshSmsRsp) {
this.f5199a.onSuccess(refreshSmsRsp);
}
}
private UUSdpClient(Context context) {
if (context != null) {
this.context = context.getApplicationContext();
this.vpnServiceBase = new VpnServiceBaseImpl();
return;
}
throw new IllegalArgumentException("Context must not be empty.");
}
private boolean checkSdpLogin() {
if (this.multipleSdk) {
ContentResolver contentResolver = this.context.getContentResolver();
Bundle bundle = new Bundle();
String lastPackageName = PreferenceUtils.getLastPackageName(this.context);
if (lastPackageName != null && !lastPackageName.equals(this.context.getPackageName())) {
try {
if (contentResolver.call(Uri.parse("content://" + lastPackageName + SERVER_PROVIDER_AUTHORITIES), "getTunnelState", (String) null, bundle).getInt("state") == 1) {
q1.c("SafeLink", "UUSdpClient multipleSdk has login", new Object[0]);
return true;
}
} catch (Exception e2) {
q1.c("SafeLink", "UUSdpClient multipleSdk Exception =" + e2.getMessage(), new Object[0]);
}
}
return false;
}
return false;
}
private boolean checkSecurity(g0 g0Var) throws Exception {
String[] split;
String allowNetworkAccess = g0Var.getAllowNetworkAccess();
int c2 = l1.c(this.context);
if ((allowNetworkAccess.equals("10") && c2 == 0) || (allowNetworkAccess.equals(HiAnalyticsConstant.KeyAndValue.NUMBER_01) && c2 == 1)) {
try {
this.tunnelCloseCode = 1001;
this.backend.b(this.uuSdpTunnel, u1.a.DOWN, null);
q1.c("SafeLink", "SecurityConfig allowNetworkAccess cause Tunnel closed", new Object[0]);
return true;
} catch (Exception e2) {
q1.a("SafeLink", e2);
}
}
String wifiWhiteList = g0Var.getWifiWhiteList();
if (wifiWhiteList != null && (split = wifiWhiteList.split(Constants.ACCEPT_TIME_SEPARATOR_SP)) != null && split.length > 0 && ((allowNetworkAccess.equals("10") || allowNetworkAccess.equals(PushCode.DEVICE_ERASE)) && c2 == 1)) {
String e3 = l1.e(this.context);
boolean z = false;
for (String str : split) {
if (str.equalsIgnoreCase(e3)) {
z = true;
}
}
if (!z) {
try {
this.tunnelCloseCode = 1001;
this.backend.b(this.uuSdpTunnel, u1.a.DOWN, null);
q1.c("SafeLink", "SecurityConfig wifi wifiWhiteList cause Tunnel closed", new Object[0]);
return true;
} catch (Exception e4) {
q1.a("SafeLink", e4);
}
}
}
int safeWifiAccess = g0Var.getSafeWifiAccess();
int d2 = l1.d(this.context);
if (safeWifiAccess == 1 && d2 == 0) {
try {
this.tunnelCloseCode = 1001;
this.backend.b(this.uuSdpTunnel, u1.a.DOWN, null);
q1.c("SafeLink", "SecurityConfig wifi safeWifiAccess cause Tunnel closed", new Object[0]);
return true;
} catch (Exception e5) {
q1.a("SafeLink", e5);
}
}
return false;
}
private void closeTunnel(UUSdpLogoutCallback uUSdpLogoutCallback) {
if (this.uuSdpTunnel != null) {
this.executorService.execute(new c(uUSdpLogoutCallback));
} else if (uUSdpLogoutCallback != null) {
uUSdpLogoutCallback.onError(101);
q1.b("SafeLink", "closeTunnel error SDP_TUNNEL_NULL:101", new Object[0]);
}
}
private void closeVpn(UUSdpLogoutCallback uUSdpLogoutCallback) {
q1.c("SafeLink", "closeVpn", new Object[0]);
this.tunnelCloseCode = 111;
s1 s1Var = this.uuSdpTunnel;
if (s1Var == null) {
if (uUSdpLogoutCallback != null) {
uUSdpLogoutCallback.onError(101);
q1.b("SafeLink", "closeTunnel error SDP_TUNNEL_NULL:101", new Object[0]);
return;
}
return;
}
try {
GoBackend goBackend = this.backend;
u1.a aVar = u1.a.DOWN;
if (goBackend.b(s1Var, aVar, null) == aVar) {
n1 n1Var = this.heartAlarm;
if (n1Var != null) {
n1Var.a(this.context);
}
if (this.uuSdpTunnel != null) {
this.uuSdpTunnel = null;
}
this.loginReq = null;
this.loginRsp = null;
this.heartRsp = null;
this.heartReqProperties.clear();
if (uUSdpLogoutCallback != null) {
uUSdpLogoutCallback.onSuccess();
return;
}
return;
}
if (uUSdpLogoutCallback != null) {
uUSdpLogoutCallback.onError(102);
}
q1.b("SafeLink", "closeTunnel error SDP_TUNNEL_ERROR:102", new Object[0]);
} catch (Exception e2) {
e2.printStackTrace();
q1.b("SafeLink", "closeTunnel error SDP_TUNNEL_ERROR:102", new Object[0]);
if (uUSdpLogoutCallback != null) {
uUSdpLogoutCallback.onError(102);
}
}
}
private void dialogShow(UUSdpLoginRequestInfo uUSdpLoginRequestInfo) {
AlertDialog.Builder builder = new AlertDialog.Builder(this.currentActivity, R.style.Dialog_No_border);
builder.setCancelable(false);
View inflate = LayoutInflater.from(this.currentActivity).inflate(R.layout.dialog_vpn, (ViewGroup) null);
((TextView) inflate.findViewById(R.id.dialog_content)).setText(uUSdpLoginRequestInfo.getVpnTip());
builder.setView(inflate);
AlertDialog create = builder.create();
create.show();
((Button) inflate.findViewById(R.id.dialog_btn_sure)).setOnClickListener(new j(uUSdpLoginRequestInfo, create));
((Button) inflate.findViewById(R.id.dialog_btn_cancel)).setOnClickListener(new k(create));
}
public void generateHeartProperties(HeartRsp heartRsp) {
if (heartRsp == null) {
if (this.loginReq.getCid() != null) {
this.heartReqProperties.setProperty(com.uusafe.sdp.proguard.p.H, this.loginReq.getCid());
this.cid = this.loginReq.getCid();
}
if (this.loginRsp.getData().getCft() != null) {
this.heartReqProperties.setProperty(com.uusafe.sdp.proguard.p.I, this.loginRsp.getData().getCft());
}
if (this.loginRsp.getData().getSct() != null) {
this.heartReqProperties.setProperty(com.uusafe.sdp.proguard.p.J, this.loginRsp.getData().getSct());
}
if (this.loginRsp.getData().getDt() != null) {
this.heartReqProperties.setProperty(com.uusafe.sdp.proguard.p.K, this.loginRsp.getData().getDt());
}
if (this.loginRsp.getData().getHt() != 0) {
Properties properties = this.heartReqProperties;
String str = com.uusafe.sdp.proguard.p.L;
properties.setProperty(str, "" + this.loginRsp.getData().getHt());
}
if (this.loginRsp.getData().getApt() != null) {
this.heartReqProperties.setProperty(com.uusafe.sdp.proguard.p.M, this.loginRsp.getData().getApt());
return;
}
return;
}
if (heartRsp.getData().getCft() != null) {
this.heartReqProperties.setProperty(com.uusafe.sdp.proguard.p.I, heartRsp.getData().getCft());
}
if (heartRsp.getData().getSct() != null) {
this.heartReqProperties.setProperty(com.uusafe.sdp.proguard.p.J, heartRsp.getData().getSct());
}
if (heartRsp.getData().getDt() != null) {
this.heartReqProperties.setProperty(com.uusafe.sdp.proguard.p.K, heartRsp.getData().getDt());
}
if (heartRsp.getData().getHt() != 0) {
Properties properties2 = this.heartReqProperties;
String str2 = com.uusafe.sdp.proguard.p.L;
properties2.setProperty(str2, "" + heartRsp.getData().getHt());
}
if (this.loginRsp.getData().getApt() != null) {
this.heartReqProperties.setProperty(com.uusafe.sdp.proguard.p.M, this.loginRsp.getData().getApt());
}
}
public UUSdpLoginResponseInfo generateLoginResponseInfo(LoginRsp loginRsp) {
UUSdpLoginResponseInfo uUSdpLoginResponseInfo = new UUSdpLoginResponseInfo();
if (loginRsp != null) {
if (!TextUtils.isEmpty(loginRsp.getExtendParam())) {
uUSdpLoginResponseInfo.setExtendParam(loginRsp.getExtendParam());
}
if (loginRsp.getData() != null && !TextUtils.isEmpty(loginRsp.getData().getExtendParam())) {
uUSdpLoginResponseInfo.setExtendParam(loginRsp.getData().getExtendParam());
}
}
if (loginRsp.getData() == null) {
return uUSdpLoginResponseInfo;
}
if (loginRsp.getData().getUinfo() != null) {
UUSdpUserInfo uUSdpUserInfo = new UUSdpUserInfo();
uUSdpUserInfo.setEmail(loginRsp.getData().getUinfo().getEmail());
uUSdpUserInfo.setLoginName(loginRsp.getData().getUinfo().getLoginName());
uUSdpUserInfo.setCountryCode(loginRsp.getData().getUinfo().getCountryCode());
uUSdpUserInfo.setPhoneNum(loginRsp.getData().getUinfo().getPhoneNum());
uUSdpUserInfo.setUserId(loginRsp.getData().getUinfo().getUserId());
uUSdpUserInfo.setUserName(loginRsp.getData().getUinfo().getUserName());
uUSdpLoginResponseInfo.setUserInfo(uUSdpUserInfo);
}
if (loginRsp.getData().getAis() != null && loginRsp.getData().getAis().length > 0) {
ArrayList<UUSdpAccessInfo> arrayList = new ArrayList<>();
for (int i2 = 0; i2 < loginRsp.getData().getAis().length; i2++) {
com.uusafe.sdp.proguard.q qVar = loginRsp.getData().getAis()[i2];
UUSdpAccessInfo uUSdpAccessInfo = new UUSdpAccessInfo();
uUSdpAccessInfo.setIconId(qVar.getIconId());
uUSdpAccessInfo.setName(qVar.getName());
uUSdpAccessInfo.setType(qVar.getType());
uUSdpAccessInfo.setUrl(qVar.getUrl());
arrayList.add(uUSdpAccessInfo);
}
uUSdpLoginResponseInfo.setAccessInfo(arrayList);
}
if (loginRsp.getData().getUi() != null) {
i0 ui = loginRsp.getData().getUi();
UUSdpUpdateInfo uUSdpUpdateInfo = new UUSdpUpdateInfo();
uUSdpUpdateInfo.setDescription(ui.getDescription());
uUSdpUpdateInfo.setDownloadUrl(ui.getDownloadUrl());
uUSdpUpdateInfo.setUpdateFlag(ui.getUpdateFlag());
uUSdpUpdateInfo.setVersionName(ui.getVersionName());
uUSdpLoginResponseInfo.setUpdateInfo(uUSdpUpdateInfo);
}
if (loginRsp.getData().getGis() != null) {
ArrayList<UUSdpGatewayInfo> arrayList2 = new ArrayList<>();
for (int i3 = 0; i3 < loginRsp.getData().getGis().length; i3++) {
y yVar = loginRsp.getData().getGis()[i3];
UUSdpGatewayInfo uUSdpGatewayInfo = new UUSdpGatewayInfo();
uUSdpGatewayInfo.setIp(yVar.getIp());
uUSdpGatewayInfo.setName(yVar.getName());
arrayList2.add(uUSdpGatewayInfo);
}
uUSdpLoginResponseInfo.setGis(arrayList2);
this.uuSdpGatewayInfos = arrayList2;
}
uUSdpLoginResponseInfo.setVct(loginRsp.getData().getVct());
uUSdpLoginResponseInfo.setMpc(loginRsp.getData().getMpc());
uUSdpLoginResponseInfo.setMpf(loginRsp.getData().getMpf());
uUSdpLoginResponseInfo.setTicket(loginRsp.getData().getTicket());
uUSdpLoginResponseInfo.setV(loginRsp.getData().getV());
uUSdpLoginResponseInfo.setMpl(loginRsp.getData().getMpl());
return uUSdpLoginResponseInfo;
}
public String getDnsSettings(LoginRsp loginRsp) {
try {
y1 y1Var = new y1();
x1 x1Var = new x1();
for (InetAddress inetAddress : l1.b(this.context)) {
String hostAddress = inetAddress.getHostAddress();
if (hostAddress.indexOf(".") > 0) {
if (x1Var.getIpv4Preferred() == null) {
x1Var.setIpv4Preferred(inetAddress.getHostAddress());
} else if (x1Var.getIpv4Alternate() == null) {
x1Var.setIpv4Alternate(inetAddress.getHostAddress());
}
} else if (hostAddress.indexOf(Constants.COLON_SEPARATOR) > 0) {
if (x1Var.getIpv6Preferred() == null) {
x1Var.setIpv6Preferred(inetAddress.getHostAddress());
} else if (x1Var.getIpv6Alternate() == null) {
x1Var.setIpv6Alternate(inetAddress.getHostAddress());
}
}
}
y1Var.setServer(x1Var);
w1 w1Var = new w1();
if (x1Var.getIpv4Preferred() != null) {
w1Var.setIpv4Preferred("198.51.100.1");
}
if (x1Var.getIpv4Alternate() != null) {
w1Var.setIpv4Alternate("10.255.255.255");
}
if (x1Var.getIpv6Preferred() != null) {
w1Var.setIpv6Preferred(x1Var.getIpv6Preferred());
}
y1Var.setRoute(w1Var);
s[] dns = loginRsp.getData().getDns();
int i2 = 0;
if (dns != null && dns.length > 0 && loginRsp.getData().getDf() != 1) {
int length = dns.length;
v1[] v1VarArr = new v1[length];
for (int i3 = 0; i3 < length; i3++) {
s sVar = dns[i3];
v1 v1Var = new v1();
v1Var.setName(sVar.getName());
v1Var.setIpv4(sVar.getIpv4());
v1Var.setIpv6(sVar.getIpv6());
v1Var.setType(sVar.getType());
v1VarArr[i3] = v1Var;
}
y1Var.setHosts(v1VarArr);
}
if (loginRsp.getData().getDf() != 1) {
w wVar = new w();
wVar.setHosts(loginRsp.getData().getFdns());
y1Var.setFw(wVar);
}
if (loginRsp.getData().getDr() != null && loginRsp.getData().getDr().size() > 0) {
v vVar = new v();
t[] tVarArr = new t[loginRsp.getData().getDr().size()];
Iterator<t> it = loginRsp.getData().getDr().iterator();
while (it.hasNext()) {
tVarArr[i2] = it.next();
i2++;
}
vVar.setDomains(tVarArr);
y1Var.setFwExt(vVar);
}
return new b4().b().a().a(y1Var);
} catch (Exception e2) {
q1.a("getDnsSettings Exception ==" + e2.getMessage());
return "";
}
}
public static UUSdpClient getInstance(Context context) {
if (instance == null) {
instance = new UUSdpClient(context);
}
return instance;
}
public void heartBeat() {
sendHeartBeatMessage();
startAlarm();
}
public void loginSuccess(UUSdpLoginResponseInfo uUSdpLoginResponseInfo) {
Handler handler = this.handler;
if (handler != null && this.customBottomDialog != null) {
handler.post(new Runnable() {
@Override
public final void run() {
UUSdpClient.this.f();
}
});
}
this.tunnelCloseCode = 110;
if (this.uuSdpLoginCallbacks.size() > 0) {
if (this.multipleSdk) {
PreferenceUtils.setLastPackageName(this.context);
}
for (int size = this.uuSdpLoginCallbacks.size() - 1; size >= 0; size--) {
UUSdpLoginCallback uUSdpLoginCallback = this.uuSdpLoginCallbacks.get(size);
this.uuSdpLoginCallbacks.remove(uUSdpLoginCallback);
uUSdpLoginCallback.onSuccess(uUSdpLoginResponseInfo);
}
this.uuSdpLoginCallbacks.clear();
getResData(uUSdpLoginResponseInfo);
return;
}
q1.c("SafeLink", "loginSuccess but uuSdpLoginCallback==null", new Object[0]);
}
private void openTunnel(String str, int i2, ArrayList<String> arrayList, LoginRsp loginRsp) {
this.appPolicyDetails.clear();
if (loginRsp != null) {
String cf = loginRsp.getData().getCf();
if (cf == null) {
q1.b("SafeLink", "openTunnel-> login tunnelConfig is null", new Object[0]);
loginError(105, null);
return;
}
q1.d("SafeLink", "openTunnel-> start", new Object[0]);
q1.d("SafeLink", "openTunnel->tunnelConfig【" + cf + "】", new Object[0]);
this.executorService.execute(new b(cf, loginRsp, arrayList, str, i2));
return;
}
q1.b("SafeLink", "openTunnel->UUSdpClient login authResponse is null", new Object[0]);
loginError(105, null);
}
private boolean paramsCheck(UUSdpLoginRequestInfo uUSdpLoginRequestInfo) {
if (uUSdpLoginRequestInfo.getPassword() == null || uUSdpLoginRequestInfo.getCid() == null || uUSdpLoginRequestInfo.getCid().length() != 32) {
q1.c("SafeLink", "cid=" + uUSdpLoginRequestInfo.getCid(), new Object[0]);
return false;
}
return true;
}
private void processGatewayInfo(y[] yVarArr) {
if (yVarArr == null) {
return;
}
if (yVarArr.length != this.uuSdpGatewayInfos.size()) {
updateGatewayInfo(yVarArr);
return;
}
boolean z = false;
y yVar = yVarArr[0];
UUSdpGatewayInfo uUSdpGatewayInfo = this.uuSdpGatewayInfos.get(0);
if ((uUSdpGatewayInfo.getIp().equals(yVar.getIp()) && uUSdpGatewayInfo.getName().equals(yVar.getName())) ? true : true) {
updateGatewayInfo(yVarArr);
}
}
public void processHeartRsp(HeartRsp heartRsp) {
String dt;
String sct;
int ht;
String cft;
boolean z;
int aaf;
String apt;
g0 sc;
if (heartRsp != null) {
try {
this.lastHeartTime = System.currentTimeMillis();
generateHeartProperties(heartRsp);
HeartRsp heartRsp2 = this.heartRsp;
if (heartRsp2 == null) {
dt = this.loginRsp.getData().getDt();
} else {
dt = heartRsp2.getData().getDt();
}
if (heartRsp.getData().getDt() != null) {
heartRsp.getData().getDt().equals(dt);
}
HeartRsp heartRsp3 = this.heartRsp;
if (heartRsp3 == null) {
sct = this.loginRsp.getData().getSct();
} else {
sct = heartRsp3.getData().getSct();
}
if (heartRsp.getData().getSct() == null || heartRsp.getData().getSct().equals(sct) || (sc = heartRsp.getData().getSc()) == null || !checkSecurity(sc)) {
HeartRsp heartRsp4 = this.heartRsp;
if (heartRsp4 == null) {
ht = this.loginRsp.getData().getHt();
} else {
ht = heartRsp4.getData().getHt();
}
if (heartRsp.getData().getHt() != 0 && heartRsp.getData().getHt() != ht) {
this.heartAlarm.a(this.context);
this.ht = heartRsp.getData().getHt();
startAlarm();
}
q1.c("SafeLink", "processHeartRsp==nul", new Object[0]);
if (heartRsp.getData() != null && heartRsp.getData().getGis() != null) {
q1.c("SafeLink", "processHeartRsp==" + heartRsp.getData().getGis().length, new Object[0]);
processGatewayInfo(heartRsp.getData().getGis());
}
HeartRsp heartRsp5 = this.heartRsp;
if (heartRsp5 == null) {
cft = this.loginRsp.getData().getCft();
} else {
cft = heartRsp5.getData().getCft();
}
if (heartRsp.getData().getCft() == null || heartRsp.getData().getCft().equals(cft)) {
z = false;
} else {
String cf = heartRsp.getData().getCf();
q1.a("SafeLink", "Heart tunnelConfig【" + cf + "】", new Object[0]);
if (this.uuSdpTunnel != null) {
this.uuSdpTunnel.a(d2.a(new ByteArrayInputStream(cf.getBytes("UTF-8"))));
}
z = true;
}
HeartRsp heartRsp6 = this.heartRsp;
if (heartRsp6 == null) {
aaf = this.loginRsp.getData().getAaf();
} else {
aaf = heartRsp6.getData().getAaf();
}
HeartRsp heartRsp7 = this.heartRsp;
if (heartRsp7 == null) {
apt = this.loginRsp.getData().getApt();
} else {
apt = heartRsp7.getData().getApt();
}
if (heartRsp.getData().getAaf() != aaf || (heartRsp.getData().getApt() != null && apt != null && !heartRsp.getData().getApt().equals(apt))) {
q1.c("SafeLink", "processHeartRsp AllowedApplications changed oldAaf==" + aaf + "==" + heartRsp.getData().getAaf() + "==oldApt==" + apt + "==" + heartRsp.getData().getApt(), new Object[0]);
s1 s1Var = this.uuSdpTunnel;
if (s1Var != null) {
s1Var.a().clear();
if (heartRsp.getData().getAaf() == 1) {
Object apds = heartRsp.getData().getApds();
if (apds != null && (apds instanceof List)) {
for (Map map : (List) apds) {
if (map.get("pkn") != null) {
this.uuSdpTunnel.a().add(map.get("pkn").toString());
}
}
}
if (heartRsp.getData().getApt() != null && heartRsp.getData().getApt().length() > 0) {
this.uuSdpTunnel.a(new a4().a(apds));
}
} else {
this.uuSdpTunnel.a("");
}
}
z = true;
}
if (this.uuSdpTunnel.e() != heartRsp.getData().getDf() && this.uuSdpTunnel.i() != null && heartRsp.getData().getDt() != null && heartRsp.getData().getDt().length() > 10 && !this.uuSdpTunnel.i().equals(heartRsp.getData().getDt())) {
q1.c("SafeLink", "processHeartRsp df value changed uuSdpTunnel.getDf()=" + this.uuSdpTunnel.e() + ContainerUtils.KEY_VALUE_DELIMITER + heartRsp.getData().getDf() + "=response.dt=" + heartRsp.getData().getDt() + "=uuSdpTunnel.getDt()=" + this.uuSdpTunnel.i(), new Object[0]);
this.uuSdpTunnel.a(heartRsp.getData().getDf());
this.uuSdpTunnel.c(heartRsp.getData().getDt());
z = true;
}
if (z) {
q1.d("SafeLink", "processHeartRsp need reStart", new Object[0]);
GoBackend goBackend = this.backend;
if (goBackend != null) {
goBackend.a(this.uuSdpTunnel, null, u1.a.DOWN, true);
}
this.uuSdpTunnel.b(getDnsSettings(heartRsp));
a();
}
this.heartRsp = heartRsp;
}
} catch (Exception e2) {
q1.b("SafeLink", "processHeartRsp Exception " + e2.getMessage(), new Object[0]);
q1.a("SafeLink", e2);
}
}
}
public void processLoginRsp(String str, int i2, ArrayList<String> arrayList, m0 m0Var, LoginRsp loginRsp) {
g0 sc;
String[] split;
if (loginRsp != null) {
if (loginRsp.getData().getSc() != null && (sc = loginRsp.getData().getSc()) != null) {
String allowNetworkAccess = sc.getAllowNetworkAccess();
int c2 = l1.c(this.context);
if ((allowNetworkAccess.equals("10") && c2 == 0) || (allowNetworkAccess.equals(HiAnalyticsConstant.KeyAndValue.NUMBER_01) && c2 == 1)) {
q1.c("SafeLink", "LoginRsp SecurityConfig wifi wifiWhiteList cause Tunnel closed", new Object[0]);
loginError(102, null);
return;
}
String wifiWhiteList = sc.getWifiWhiteList();
if (wifiWhiteList != null && (split = wifiWhiteList.split(Constants.ACCEPT_TIME_SEPARATOR_SP)) != null && split.length > 0 && ((allowNetworkAccess.equals("10") || allowNetworkAccess.equals(PushCode.DEVICE_ERASE)) && c2 == 1)) {
String e2 = l1.e(this.context);
boolean z = false;
for (String str2 : split) {
if (str2.equalsIgnoreCase(e2)) {
z = true;
}
}
if (!z) {
q1.c("SafeLink", "LoginRsp SecurityConfig wifi wifiWhiteList cause Tunnel closed", new Object[0]);
loginError(102, null);
return;
}
}
int safeWifiAccess = sc.getSafeWifiAccess();
int d2 = l1.d(this.context);
if (safeWifiAccess == 1 && d2 == 0) {
q1.c("SafeLink", "LoginRsp SecurityConfig wifi safeWifiAccess cause Tunnel closed", new Object[0]);
loginError(102, null);
return;
}
}
loginRsp.getData().getDns();
if (loginRsp.getData().getHt() != 0) {
this.ht = loginRsp.getData().getHt();
}
this.loginReq = m0Var;
this.loginRsp = loginRsp;
if (this.uuSdpLoginBreakCallback != null) {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("llt", loginRsp.getData().getLlt());
} catch (Exception unused) {
}
if (this.uuSdpLoginBreakCallback.processLoginRsp(jSONObject)) {
return;
}
}
openTunnel(str, i2, arrayList, loginRsp);
return;
}
q1.c("SafeLink", "processLoginRsp==NULL", new Object[0]);
}
public void setHeartBeatListener() {
com.uusafe.sdp.proguard.p.a(this.context).a(new d());
}
public void startAlarm() {
n1 n1Var = this.heartAlarm;
if (n1Var != null) {
n1Var.a(this.context);
}
n1 n1Var2 = new n1(new f(), this.context.getMainLooper(), this.context);
this.heartAlarm = n1Var2;
n1Var2.a(this.ht * 1000, this.context);
}
private void updateGatewayInfo(y[] yVarArr) {
this.uuSdpGatewayInfos.clear();
for (y yVar : yVarArr) {
UUSdpGatewayInfo uUSdpGatewayInfo = new UUSdpGatewayInfo();
uUSdpGatewayInfo.setIp(yVar.getIp());
uUSdpGatewayInfo.setName(yVar.getName());
this.uuSdpGatewayInfos.add(uUSdpGatewayInfo);
}
ArrayList<UUSdpGatewayInfo> arrayList = this.uuSdpGatewayInfos;
if (arrayList != null && arrayList.size() > 0) {
this.getResUrl = this.uuSdpGatewayInfos.get(0).getIp();
}
q1.c("SafeLink", "uuSdpGatewayInfoChangeListeners onGatewayInfoChange size:" + this.uuSdpGatewayInfoChangeListeners.size() + "=getResUrl=" + this.getResUrl, new Object[0]);
Iterator<UUSdpGatewayInfoChangeListener> it = this.uuSdpGatewayInfoChangeListeners.iterator();
while (it.hasNext()) {
it.next().onGatewayInfoChange(this.uuSdpGatewayInfos);
}
}
public void addGatewayInfoChangeListener(UUSdpGatewayInfoChangeListener uUSdpGatewayInfoChangeListener) {
if (uUSdpGatewayInfoChangeListener == null || this.uuSdpGatewayInfoChangeListeners.contains(uUSdpGatewayInfoChangeListener)) {
return;
}
this.uuSdpGatewayInfoChangeListeners.clear();
this.uuSdpGatewayInfoChangeListeners.add(uUSdpGatewayInfoChangeListener);
}
public void addSpeedListener(UUSdpSpeedListener uUSdpSpeedListener) {
VpnServiceBaseImpl vpnServiceBaseImpl = this.vpnServiceBase;
if (vpnServiceBaseImpl != null) {
vpnServiceBaseImpl.setUuSdpSpeedListener(uUSdpSpeedListener);
}
}
public void addTunnelStateListener(UUSdpTunnelStateListener uUSdpTunnelStateListener) {
if (uUSdpTunnelStateListener != null) {
this.uuSdpTunnelStateListeners.add(uUSdpTunnelStateListener);
}
}
public void addUnInstallAppList(String str) {
q1.c("SafeLink", "addUnInstallAppList start pkgName=" + str, new Object[0]);
ArrayList<String> allowedApplications = getAllowedApplications();
if (allowedApplications == null || !allowedApplications.contains(str)) {
return;
}
GoBackend goBackend = this.backend;
ArrayList<String> d2 = goBackend != null ? goBackend.d() : null;
if (d2 == null || d2.contains(str)) {
return;
}
q1.c("SafeLink", "addUnInstallAppList pkgName=" + str, new Object[0]);
this.backend.d().add(str);
}
public void b() {
if (checkConnect()) {
return;
}
z1.a("www.baidu.com");
z1.a("www.taobao.com");
sendHeartBeatMessage();
}
public void backToApp(Activity activity) {
q1.c("SafeLink", "Login success back to third app", new Object[0]);
p2.a().b();
if (this.startThirdApp) {
p2.a().a(activity);
}
}
public Boolean c() throws Exception {
boolean queryDns = queryDns();
if (!queryDns && checkConnect()) {
a();
Thread.sleep(500L);
}
return Boolean.valueOf(queryDns);
}
public boolean checkAllowApps(String str) {
if (this.backend == null) {
q1.c("SafeLink", "checkAllowApps backend is null" + str, new Object[0]);
return false;
}
q1.c("SafeLink", "checkAllowApps pkgName ==" + str + "=backend.getUnInstallAppList()=" + this.backend.d().toString(), new Object[0]);
if (this.backend.d().contains(str)) {
reStart();
return true;
}
return false;
}
public void checkAppInstall(String str) {
q1.c("SafeLink", "checkAppInstall packageName " + str, new Object[0]);
if (getTunnelState() == 1 && getAllowedApplications().contains(str)) {
this.executorService.execute(new Runnable() {
@Override
public final void run() {
UUSdpClient.this.a();
}
});
}
}
public boolean checkConnect() {
return v2.a(getGetResUrl());
}
public void checkHeart() {
if (getVPNAndTunnelStatus() == 0 && this.reConnect) {
q1.c("SafeLink", "checkHeart reConnect", new Object[0]);
sign(new e());
return;
}
long currentTimeMillis = System.currentTimeMillis();
if (currentTimeMillis - this.checkTime < 5000) {
return;
}
this.checkTime = currentTimeMillis;
long j2 = currentTimeMillis - this.lastHeartTime;
if (getSelfTunnelState() == 1) {
int wgGetReceiveStatus = wgGetReceiveStatus();
q1.d("SafeLink", "wgGetReceiveStatus==" + wgGetReceiveStatus, new Object[0]);
if (wgGetReceiveStatus == 2) {
s1 s1Var = this.uuSdpTunnel;
if (s1Var != null && s1Var.e() == 2) {
a();
sendHeartBeatMessage();
} else {
wgBumpSockets();
checkTunnel();
}
} else {
checkTunnel();
}
q1.d("SafeLink", "checkHeart start time diff = " + j2 + "checkDns add", new Object[0]);
if (this.lastHeartTime <= 0 || j2 <= this.ht * 1000 * 2) {
return;
}
q1.d("SafeLink", "checkHeart reSend time diff = " + j2, new Object[0]);
sendHeartBeatMessage();
}
}
public boolean checkNeedRestart(String str) {
if (this.backend == null) {
q1.c("SafeLink", "checkAllowApps backend is null" + str, new Object[0]);
return false;
}
q1.c("SafeLink", "checkAllowApps pkgName ==" + str + "=backend.getUnInstallAppList()=" + this.backend.d().toString(), new Object[0]);
return this.backend.d().contains(str);
}
public boolean checkSign() {
return !TextUtils.isEmpty(PreferenceUtils.getTicket(this.context));
}
public void checkSmsCode(UUSdpCheckSmsRequestInfo uUSdpCheckSmsRequestInfo, UUSdpCheckSmsCallback uUSdpCheckSmsCallback) {
try {
com.uusafe.sdp.proguard.p.a(this.context).a(uUSdpCheckSmsRequestInfo, uUSdpCheckSmsCallback);
} catch (Exception unused) {
uUSdpCheckSmsCallback.onError(110, "error");
}
}
public void checkTunnel() {
if (needCheckTunnel()) {
this.executorService.execute(new Runnable() {
@Override
public final void run() {
UUSdpClient.this.b();
}
});
FutureTask futureTask = new FutureTask(new Callable() {
@Override
public final Object call() {
return UUSdpClient.this.c();
}
});
this.executorService.execute(futureTask);
try {
boolean booleanValue = ((Boolean) futureTask.get(2L, TimeUnit.SECONDS)).booleanValue();
q1.c("SafeLink", "checkTunnel first=" + booleanValue, new Object[0]);
if (booleanValue) {
return;
}
} catch (Exception e2) {
q1.c("SafeLink", "checkTunnel first Exception " + e2.getMessage(), new Object[0]);
}
this.executorService.execute(new Runnable() {
@Override
public final void run() {
UUSdpClient.this.d();
}
});
}
}
public void clearGatewayInfoChangeListener() {
this.uuSdpGatewayInfoChangeListeners.clear();
}
public void clearTunnelStateListener() {
this.uuSdpTunnelStateListeners.clear();
}
public void continueProcessLoginRsp() {
openTunnel("SafeLink", 0, new ArrayList<>(), this.loginRsp);
com.uusafe.sdp.proguard.p.a(this.context).a(this.cid, this.loginRsp.getData().getLlt());
}
public void d() {
int i2 = 0;
while (true) {
if (i2 >= 3) {
break;
}
try {
Thread.sleep(1000L);
} catch (Exception e2) {
e2.printStackTrace();
}
if (queryDns()) {
q1.c("SafeLink", "checkTunnel second=" + i2, new Object[0]);
break;
}
i2++;
}
if (!queryDns()) {
q1.c("SafeLink", "checkTunnel last error", new Object[0]);
a();
return;
}
q1.c("SafeLink", "checkTunnel last ok", new Object[0]);
}
public void e() {
this.customBottomDialog.dismiss();
}
public void enableDebugLog() {
q1.a(this.context, 1, m1.a(Environment.getExternalStorageDirectory(), DIR_APP, DIR_LOG).getAbsolutePath(), true);
}
public void f() {
this.customBottomDialog.dismiss();
}
public Boolean g() throws Exception {
return Boolean.valueOf(a());
}
public ArrayList<String> getAllowedApplications() {
s1 s1Var = this.uuSdpTunnel;
if (s1Var != null) {
return s1Var.a();
}
return null;
}
public ArrayList<AppPolicyDetail> getAppPolicyDetails() {
return this.appPolicyDetails;
}
public GoBackend getBackend() {
return this.backend;
}
public String getCheckDns() {
return this.checkDns;
}
public Activity getCurrentActivity() {
Activity activity = this.currentActivity;
if (activity != null) {
return activity;
}
Context context = this.context;
if (context == null || !(context instanceof Activity)) {
return null;
}
return (Activity) context;
}
public String getDd_app_id() {
return this.dd_app_id;
}
public String getErrorMsg(int i2) {
if (i2 == 101) {
return this.context.getString(R.string.uu_login_error_param);
}
if (i2 == 102) {
return this.context.getString(R.string.uu_login_error_102);
}
if (i2 == 103) {
return this.context.getString(R.string.uu_login_error_noresponse) + " : " + i2;
} else if (i2 == 104) {
return this.context.getString(R.string.uu_login_error_104);
} else {
if (i2 == 105) {
return this.context.getString(R.string.uu_login_error_106);
}
if (i2 == 106) {
return this.context.getString(R.string.uu_login_error_106);
}
if (i2 == 112) {
return this.context.getString(R.string.uu_login_error_111);
}
if (i2 == 113) {
return this.context.getString(R.string.uu_login_error_113);
}
if (i2 == 1001) {
return this.context.getString(R.string.uu_login_error_1001);
}
if (i2 == 1003) {
return this.context.getString(R.string.uu_login_error_1003);
}
if (i2 == 1004) {
return this.context.getString(R.string.uu_login_error_1004);
}
if (i2 == 1005) {
return this.context.getString(R.string.uu_login_error_1005);
}
if (i2 == 1006) {
return this.context.getString(R.string.uu_login_error_1006);
}
if (i2 == 1007) {
return this.context.getString(R.string.uu_login_error_1007);
}
if (i2 == 1008) {
return this.context.getString(R.string.uu_login_error_1008);
}
if (i2 == 1009) {
return this.context.getString(R.string.uu_login_error_1009);
}
if (i2 == 1010) {
return this.context.getString(R.string.uu_login_error_1010);
}
if (i2 == 1011) {
return this.context.getString(R.string.uu_login_error_1011);
}
if (i2 == 1012) {
return this.context.getString(R.string.uu_login_error_1012);
}
if (i2 == 1013) {
return this.context.getString(R.string.uu_login_error_1013);
}
if (i2 == 1014) {
return this.context.getString(R.string.uu_login_error_1014);
}
if (i2 == 2002) {
return this.context.getString(R.string.uu_login_error_2002);
}
if (i2 == 2003) {
return this.context.getString(R.string.uu_login_error_2003);
}
if (i2 == 2004) {
return this.context.getString(R.string.uu_login_error_2004);
}
if (i2 == 2005) {
return this.context.getString(R.string.uu_login_error_2005);
}
if (i2 == 2006) {
return this.context.getString(R.string.uu_login_error_2006);
}
if (i2 == 2007) {
return this.context.getString(R.string.uu_login_error_2007);
}
if (i2 == 2008) {
return this.context.getString(R.string.uu_login_error_2008);
}
if (i2 == 2010) {
return this.context.getString(R.string.uu_login_error_2010);
}
if (i2 == 2011) {
return this.context.getString(R.string.uu_login_error_2011);
}
if (i2 == 2012) {
return this.context.getString(R.string.uu_login_error_2012);
}
if (i2 == 2013) {
return this.context.getString(R.string.uu_login_error_2013);
}
if (i2 == 2009) {
return this.context.getString(R.string.uu_login_error_2009);
}
if (i2 == 2019) {
return this.context.getString(R.string.uu_login_error_2019);
}
if (i2 == 2014) {
return this.context.getString(R.string.uu_login_error_2014);
}
if (i2 == 2015) {
return this.context.getString(R.string.uu_login_error_2015);
}
if (i2 == 2016) {
return this.context.getString(R.string.uu_login_error_2016);
}
if (i2 == 2017) {
return this.context.getString(R.string.uu_login_error_2017);
}
if (i2 == 2018) {
return this.context.getString(R.string.uu_login_error_2018);
}
if (i2 == 1021) {
return this.context.getString(R.string.uu_login_error_1021);
}
if (i2 == 1020) {
return this.context.getString(R.string.uu_login_error_1020);
}
if (i2 == 1022) {
return this.context.getString(R.string.uu_login_error_1022);
}
if (i2 == 1023) {
return this.context.getString(R.string.uu_login_error_1023);
}
if (i2 == 1025) {
return this.context.getString(R.string.uu_login_error_1025);
}
if (i2 == 1099) {
return "用户拒绝授权";
}
return this.context.getString(R.string.uu_login_error_unknown) + " " + i2;
}
}
public ExecutorService getExecutorService() {
return this.executorService;
}
public String getGetResUrl() {
return this.getResUrl;
}
public e1 getKcpConfig() {
return this.kcpConfig;
}
public int getLastErrorCode() {
return this.lastErrorCode;
}
public m0 getLoginReq() {
return this.loginReq;
}
public LoginRsp getLoginRsp() {
return this.loginRsp;
}
public int getMtu() {
return this.mtu;
}
public ArrayList<NetworkInfo> getNetworkState() {
ArrayList<NetworkInfo> arrayList = new ArrayList<>();
if (this.uuSdpGatewayInfos != null) {
for (int i2 = 0; i2 < this.uuSdpGatewayInfos.size(); i2++) {
UUSdpGatewayInfo uUSdpGatewayInfo = this.uuSdpGatewayInfos.get(i2);
NetworkInfo networkInfo = new NetworkInfo();
networkInfo.setNetworkInfoHost(uUSdpGatewayInfo.getIp());
networkInfo.setNetworkInfoName(uUSdpGatewayInfo.getName());
networkInfo.setNetworkInfoPing(z1.a(networkInfo.getNetworkInfoHost(), 4, 1));
arrayList.add(networkInfo);
}
}
return arrayList;
}
public void getResData(UUSdpLoginResponseInfo uUSdpLoginResponseInfo) {
if (!this.sdpClient && uUSdpLoginResponseInfo != null && this.loginReq != null) {
if (uUSdpLoginResponseInfo.getV() < 2) {
q1.c("SafeLink", "getV()<2 ", new Object[0]);
return;
}
q1.c("SafeLink", "getResData start", new Object[0]);
this.executorService.execute(new h(uUSdpLoginResponseInfo));
return;
}
q1.c("SafeLink", "getResData null", new Object[0]);
}
public int getSSLTunnelStatus() {
GoBackend goBackend;
boolean z;
s1 s1Var = this.uuSdpTunnel;
if (s1Var == null || (goBackend = this.backend) == null || goBackend.a(s1Var) != u1.a.UP) {
return 0;
}
try {
JSONArray jSONArray = new JSONArray(GoBackend.wgGetSSLTunnelState(this.backend.f5212d));
z = true;
for (int i2 = 0; i2 < jSONArray.length(); i2++) {
try {
if (((JSONObject) jSONArray.get(i2)).getInt("state") != 1) {
z = false;
}
} catch (Exception e2) {
e = e2;
q1.c("SafeLink", "getSSLTunnelStatus e= " + e.getMessage(), new Object[0]);
if (z) {
}
}
}
} catch (Exception e3) {
e = e3;
z = true;
}
return z ? 0 : 1;
}
public int getSelfTunnelState() {
s1 s1Var = this.uuSdpTunnel;
return (s1Var != null && this.backend.a(s1Var) == u1.a.UP) ? 1 : 0;
}
public void getSmsCode(UUSdpRefreshSmsRequestInfo uUSdpRefreshSmsRequestInfo, UUSdpGetSmsCallback uUSdpGetSmsCallback) {
try {
com.uusafe.sdp.proguard.p.a(this.context).a(uUSdpRefreshSmsRequestInfo, new q(this, uUSdpGetSmsCallback));
} catch (Exception e2) {
uUSdpGetSmsCallback.onError(110, e2.getMessage());
}
}
public String getSsl_caPublicKeyPemStr() {
return this.ssl_caPublicKeyPemStr;
}
public String getSt(String str) {
if (this.context.getPackageName().equals(str)) {
try {
h0 h0Var = new h0();
StringBuffer stringBuffer = new StringBuffer();
Iterator<String> it = this.backend.f5211c.a().iterator();
while (it.hasNext()) {
stringBuffer.append(it.next());
stringBuffer.append(" ");
}
h0Var.setAllowedApplications(stringBuffer.toString());
StringBuffer stringBuffer2 = new StringBuffer();
for (g2 g2Var : this.backend.f5210b.a().a()) {
stringBuffer2.append(g2Var.toString());
stringBuffer2.append(" ");
}
h0Var.setAddress(stringBuffer2.toString());
StringBuffer stringBuffer3 = new StringBuffer();
for (InetAddress inetAddress : this.backend.f5210b.a().b()) {
stringBuffer3.append(inetAddress.toString());
stringBuffer3.append(" ");
}
h0Var.setDns(stringBuffer3.toString());
StringBuffer stringBuffer4 = new StringBuffer();
for (j2 j2Var : this.backend.f5210b.b()) {
for (g2 g2Var2 : j2Var.a()) {
stringBuffer4.append(g2Var2.toString());
stringBuffer4.append(" ");
}
}
h0Var.setAllowedIPs(stringBuffer4.toString());
StringBuffer stringBuffer5 = new StringBuffer();
for (j2 j2Var2 : this.backend.f5210b.b()) {
stringBuffer5.append(j2Var2.b().b().toString());
stringBuffer5.append(" ");
}
h0Var.setEndPoint(stringBuffer5.toString());
h0Var.setDnsHost(this.backend.f5211c.f());
return w0.a(x0.a(this.context.getPackageName()), new a4().a(h0Var));
} catch (Exception e2) {
e2.printStackTrace();
return "";
}
}
return "";
}
public String getToken() {
return com.uusafe.sdp.proguard.p.a(this.context).e();
}
public int getTunnelState() {
GoBackend goBackend;
s1 s1Var = this.uuSdpTunnel;
return ((s1Var == null || (goBackend = this.backend) == null || goBackend.a(s1Var) != u1.a.UP) && !checkSdpLogin()) ? 0 : 1;
}
public UUSdpEmmCallback getUuSdpEmmCallback() {
return this.uuSdpEmmCallback;
}
public UUSdpLoginBreakCallback getUuSdpLoginBreakCallback() {
return this.uuSdpLoginBreakCallback;
}
public int getVPNAndTunnelStatus() {
GoBackend goBackend;
boolean z;
s1 s1Var = this.uuSdpTunnel;
if (s1Var == null || (goBackend = this.backend) == null || goBackend.a(s1Var) != u1.a.UP) {
return 0;
}
try {
JSONArray jSONArray = new JSONArray(GoBackend.wgGetTunnelState(this.backend.f5212d));
z = true;
for (int i2 = 0; i2 < jSONArray.length(); i2++) {
try {
if (((JSONObject) jSONArray.get(i2)).getInt("state") != 1) {
z = false;
}
} catch (Exception e2) {
e = e2;
e.printStackTrace();
if (z) {
}
}
}
} catch (Exception e3) {
e = e3;
z = true;
}
return z ? 0 : 1;
}
public int getVPNDelay() {
return this.VPNDelay;
}
public VpnServiceBaseImpl getVpnServiceBase() {
return this.vpnServiceBase;
}
public void iamAuth(String str, String str2, String str3, IamAuthCallback iamAuthCallback) {
com.uusafe.sdp.proguard.p.a(this.context).a(str, str2, str3, iamAuthCallback);
}
public void init(UUSdpInitInfo uUSdpInitInfo) {
Log.i("SafeLink", "init start");
if (this.isZlogInit) {
String absolutePath = m1.a(Environment.getExternalStorageDirectory(), DIR_APP, DIR_LOG).getAbsolutePath();
if (!new File(absolutePath).exists()) {
absolutePath = m1.a(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), DIR_APP, DIR_LOG).getAbsolutePath();
}
q1.a(this.context, 2, absolutePath, true);
}
z2.a(p3.e(), new x2(), w2.a()).a(45).d().a();
q1.b("SafeLink", "init start params=" + new a4().a(uUSdpInitInfo), new Object[0]);
setIpv6(uUSdpInitInfo.isIpv6());
setShowNotification(uUSdpInitInfo.isShowNotification());
setMtu(uUSdpInitInfo.getMtu());
setPublicDNS(uUSdpInitInfo.isPublicDNS());
setSsl_skipCertificate(uUSdpInitInfo.isSsl_skipCertificate());
setSsl_caPublicKeyPemStr(uUSdpInitInfo.getSsl_caPublicKeyPemStr());
setCheckDns(uUSdpInitInfo.getCheckDns());
if (this.backend == null) {
q1.b("SafeLink", "GoBackend init start", new Object[0]);
this.backend = new GoBackend(this.context);
q1.b("SafeLink", "GoBackend init over", new Object[0]);
registerActivityLifecycleCallbacks();
}
q1.b("SafeLink", "init 3", new Object[0]);
if (uUSdpInitInfo != null) {
com.uusafe.sdp.proguard.p.a(this.context).a(uUSdpInitInfo);
}
q1.b("SafeLink", "init 4 host=" + uUSdpInitInfo.getHost() + "=port=" + uUSdpInitInfo.getPort() + "=ec=" + uUSdpInitInfo.getEc(), new Object[0]);
this.heartReqProperties = new Properties();
registerNetWorkStateReceiver();
}
public boolean isAppInForeground() {
return this.appInForeground;
}
public boolean isAutoLogin() {
return this.autoLogin;
}
public boolean isCorrectIp(String str) {
if (str.matches("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}")) {
for (String str2 : str.split("\\.")) {
int parseInt = Integer.parseInt(str2);
if (parseInt < 0 || parseInt > 255) {
return false;
}
}
return true;
}
return false;
}
public boolean isIpv6() {
return this.ipv6;
}
public boolean isKickedByServer() {
return this.kickedByServer;
}
public boolean isMultipleSdk() {
return this.multipleSdk;
}
public boolean isPublicDNS() {
return this.publicDNS;
}
public boolean isReStart() {
return this.isReStart;
}
public boolean isSdpClient() {
return this.sdpClient;
}
public boolean isShowNotification() {
return this.showNotification;
}
public boolean isShowVpnDetail() {
return this.showVpnDetail;
}
public boolean isSsl_skipCertificate() {
return this.ssl_skipCertificate;
}
public boolean isStartThirdApp() {
return this.startThirdApp;
}
public boolean isV1() {
return this.v1;
}
public void login(UUSdpLoginRequestInfo uUSdpLoginRequestInfo, UUSdpLoginCallback uUSdpLoginCallback) {
timeCountValue = System.currentTimeMillis();
q1.c("SafeLink", "UUSdpClient login called 1.3.4.9=timeCount=", new Object[0]);
if (this.uuSdpLoginCallbacks.size() > 0) {
this.uuSdpLoginCallbacks.add(uUSdpLoginCallback);
q1.c("SafeLink", "UUSdpClient login not completed size=" + this.uuSdpLoginCallbacks.size(), new Object[0]);
} else if (!paramsCheck(uUSdpLoginRequestInfo)) {
q1.c("SafeLink", "paramsCheck error params.cid=" + uUSdpLoginRequestInfo.getCid(), new Object[0]);
loginError(101, null);
} else {
this.uuSdpLoginCallbacks.add(uUSdpLoginCallback);
if (!l1.g(this.context)) {
loginError(112, null);
}
if (uUSdpLoginRequestInfo.isBreakCurrent()) {
closeVpn(null);
}
if (VpnService.prepare(this.context) != null) {
if (this.showVpnDetail) {
dialogShow(uUSdpLoginRequestInfo);
return;
}
ComponentName componentName = new ComponentName(this.context.getPackageName(), "com.uusafe.sdp.invoke.ui.SdpVpnActivity");
Intent intent = new Intent();
intent.addFlags(SQLiteDatabase.CREATE_IF_NECESSARY);
intent.setComponent(componentName);
intent.putExtra(uUSdpLoginRequestInfo.getClass().getName(), uUSdpLoginRequestInfo);
this.context.startActivity(intent);
return;
}
loginInternal(uUSdpLoginRequestInfo);
}
}
public void loginError(int i2, UUSdpLoginResponseInfo uUSdpLoginResponseInfo) {
Handler handler = this.handler;
if (handler != null && this.customBottomDialog != null) {
handler.post(new Runnable() {
@Override
public final void run() {
UUSdpClient.this.e();
}
});
}
if (this.uuSdpLoginCallbacks.size() > 0) {
if (uUSdpLoginResponseInfo == null) {
uUSdpLoginResponseInfo = new UUSdpLoginResponseInfo();
}
for (int size = this.uuSdpLoginCallbacks.size() - 1; size >= 0; size--) {
UUSdpLoginCallback uUSdpLoginCallback = this.uuSdpLoginCallbacks.get(size);
this.uuSdpLoginCallbacks.remove(uUSdpLoginCallback);
uUSdpLoginCallback.onError(i2, uUSdpLoginResponseInfo);
}
if (i2 == 103) {
this.executorService.execute(new g(this));
return;
}
return;
}
q1.c("SafeLink", "loginError but uuSdpLoginCallback==null", new Object[0]);
}
public void loginInternal(UUSdpLoginRequestInfo uUSdpLoginRequestInfo) {
if (uUSdpLoginRequestInfo.isShowProgressBar()) {
q2 q2Var = new q2(this.currentActivity);
this.customBottomDialog = q2Var;
q2Var.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public final void onCancel(DialogInterface dialogInterface) {
UUSdpClient.this.a(dialogInterface);
}
});
if (this.handler == null) {
this.handler = new Handler(Looper.getMainLooper());
}
this.customBottomDialog.setContentView(R.layout.bottom_dialog_layout);
this.customBottomDialog.show();
}
SdpScreenReceiver.registerScreenReceiver(this.context);
SdpAppReceiver.registerScreenReceiver(this.context);
this.executorService.execute(new l());
try {
com.uusafe.sdp.proguard.p.a(this.context).a(uUSdpLoginRequestInfo, new m(uUSdpLoginRequestInfo.getSdpName() != null ? uUSdpLoginRequestInfo.getSdpName() : "SafeLink", uUSdpLoginRequestInfo));
} catch (Exception e2) {
q1.a("SafeLink", e2);
loginError(110, null);
}
}
public void logout(UUSdpLogoutCallback uUSdpLogoutCallback) {
q1.c("SafeLink", "UUSdpClient logout called", new Object[0]);
this.tunnelCloseCode = 111;
logoutInternal(uUSdpLogoutCallback);
}
public void logoutInternal(UUSdpLogoutCallback uUSdpLogoutCallback) {
q1.c("SafeLink", "UUSdpClient logoutInternal called", new Object[0]);
closeTunnel(uUSdpLogoutCallback);
SdpScreenReceiver.unRegisterScreenReceiver(this.context);
SdpAppReceiver.unRegisterScreenReceiver(this.context);
}
public void modifyPassword(UUSdpModifyPasswordRequestInfo uUSdpModifyPasswordRequestInfo, UUSdpModifyPasswordCallback uUSdpModifyPasswordCallback) {
try {
com.uusafe.sdp.proguard.p.a(this.context).a(uUSdpModifyPasswordRequestInfo, new o(this, uUSdpModifyPasswordCallback));
} catch (Exception unused) {
uUSdpModifyPasswordCallback.onError(110);
}
}
public boolean needCheckTunnel() {
if (getSelfTunnelState() == 0) {
q1.c("SafeLink", "needCheckTunnel == 0", new Object[0]);
return false;
} else if (l1.g(this.context)) {
return true;
} else {
q1.c("SafeLink", "needCheckTunnel isConnectedToInternet false", new Object[0]);
return false;
}
}
@Override
public void onNetChange(int i2) {
List<InetAddress> b2;
q1.c("SafeLink", "onNetChange netType: ==" + i2, new Object[0]);
if ((this.heartRsp == null && this.loginRsp == null) || getSelfTunnelState() == 0 || (b2 = l1.b(this.context)) == null || b2.size() == 0) {
return;
}
List<InetAddress> list = this.currentDnsServers;
if (list != null && list.size() == b2.size()) {
boolean z = false;
for (int i3 = 0; i3 < this.currentDnsServers.size(); i3++) {
if (!this.currentDnsServers.get(i3).getHostAddress().equals(b2.get(i3).getHostAddress())) {
z = true;
}
}
if (!z) {
q1.c("SafeLink", "onNetChange dns not changed", new Object[0]);
return;
}
}
boolean z2 = this.currentDnsServers.size() != b2.size();
q1.c("SafeLink", "onNetChange dns changed old=" + this.currentDnsServers.toString(), new Object[0]);
this.currentDnsServers.clear();
this.currentDnsServers.addAll(b2);
g0 g0Var = null;
try {
HeartRsp heartRsp = this.heartRsp;
if (heartRsp != null) {
g0Var = heartRsp.getData().getSc();
} else {
LoginRsp loginRsp = this.loginRsp;
if (loginRsp != null) {
g0Var = loginRsp.getData().getSc();
}
}
if (g0Var != null) {
if (checkSecurity(g0Var)) {
return;
}
}
} catch (Exception unused) {
q1.b("SafeLink", "onNetChange SecurityConfig wifi Exception", new Object[0]);
}
try {
x1 x1Var = new x1();
for (InetAddress inetAddress : b2) {
if (inetAddress.getHostAddress().indexOf(".") > 0) {
if (x1Var.getIpv4Preferred() == null) {
x1Var.setIpv4Preferred(inetAddress.getHostAddress());
} else if (x1Var.getIpv4Alternate() == null) {
x1Var.setIpv4Alternate(inetAddress.getHostAddress());
}
}
}
if (z2) {
s1 s1Var = this.uuSdpTunnel;
if (s1Var != null) {
s1Var.a(this.context, x1Var);
}
a();
this.executorService.execute(new a());
return;
}
String a2 = new a4().a(x1Var);
q1.a("SafeLink", "onNetChange DnsServer " + a2, new Object[0]);
GoBackend.wgSetDNSServer(this.backend.b(), a2);
sendHeartBeatMessage();
} catch (Exception e2) {
q1.a("SafeLink", e2);
q1.b("SafeLink", "onNetChange Dns set Exception", new Object[0]);
}
}
@Override
public void onStateChange(u1.a aVar) {
if (aVar == u1.a.UP) {
Iterator<UUSdpTunnelStateListener> it = this.uuSdpTunnelStateListeners.iterator();
while (it.hasNext()) {
it.next().onTunnelUp();
}
} else if (aVar == u1.a.DOWN) {
q1.c("SafeLink", "onStateChange Down,Countdown start", new Object[0]);
try {
int selfTunnelState = getSelfTunnelState();
q1.c("SafeLink", "onStateChange Down,Countdown over tunnel close tunnelCloseCode=" + this.tunnelCloseCode + "=tunnState=" + selfTunnelState, new Object[0]);
StringBuilder sb = new StringBuilder();
sb.append("UUSdpTunnelStateListener size:");
sb.append(this.uuSdpTunnelStateListeners.size());
q1.c("SafeLink", sb.toString(), new Object[0]);
if (selfTunnelState == 0 && this.tunnelCloseCode != 111) {
Iterator<UUSdpTunnelStateListener> it2 = this.uuSdpTunnelStateListeners.iterator();
while (it2.hasNext()) {
it2.next().onTunnelDown(this.tunnelCloseCode);
}
logoutInternal(null);
return;
}
q1.c("SafeLink", "onStateChange Down,Countdown over tunnel reopen", new Object[0]);
} catch (Exception e2) {
e2.printStackTrace();
}
}
}
public boolean queryDns() {
if (needCheckTunnel()) {
return v2.a(this.checkDns, getExecutorService());
}
return true;
}
public boolean reStart() {
q1.c("SafeLink", "Tunnel reStart called", new Object[0]);
FutureTask futureTask = new FutureTask(new Callable() {
@Override
public final Object call() {
return UUSdpClient.this.g();
}
});
this.executorService.execute(futureTask);
try {
boolean booleanValue = ((Boolean) futureTask.get(5L, TimeUnit.SECONDS)).booleanValue();
q1.c("SafeLink", "Tunnel reStart result=" + booleanValue, new Object[0]);
return booleanValue;
} catch (Exception e2) {
q1.c("SafeLink", "Tunnel reStart Exception " + e2.getMessage(), new Object[0]);
return false;
}
}
public boolean a() {
this.isReStart = true;
try {
if (this.uuSdpTunnel != null) {
q1.c("SafeLink", "Tunnel reStartInternal begin", new Object[0]);
GoBackend goBackend = this.backend;
s1 s1Var = this.uuSdpTunnel;
u1.a aVar = u1.a.UP;
if (goBackend.a(s1Var, aVar, s1Var.h()) == aVar) {
q1.c("SafeLink", "Tunnel reStartInternal success", new Object[0]);
this.isReStart = false;
return true;
}
q1.b("SafeLink", "Tunnel reStartInternal fail", new Object[0]);
} else {
q1.c("SafeLink", "Tunnel reStartInternal uuSdpTunnel==null", new Object[0]);
}
} catch (Exception e2) {
q1.a("SafeLink", e2);
}
this.isReStart = false;
return false;
}
public void refreshSms(UUSdpRefreshSmsRequestInfo uUSdpRefreshSmsRequestInfo, UUSdpRefreshSmsCallback uUSdpRefreshSmsCallback) {
try {
com.uusafe.sdp.proguard.p.a(this.context).a(uUSdpRefreshSmsRequestInfo, new p(this, uUSdpRefreshSmsCallback));
} catch (Exception unused) {
uUSdpRefreshSmsCallback.onError(110);
}
}
public void registerActivityLifecycleCallbacks() {
Application a2 = a.a.b.a.a();
if (a2 == null) {
q1.b("SafeLink", "registerActivityLifecycleCallbacks application==null", new Object[0]);
} else {
a2.registerActivityLifecycleCallbacks(new i());
}
}
public void registerNetWorkStateReceiver() {
if (this.uuNetWorkStateReceiver == null) {
this.uuNetWorkStateReceiver = new r1();
try {
q1.c("SafeLink", "registerNetWorkStateReceiver ", new Object[0]);
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
this.context.registerReceiver(this.uuNetWorkStateReceiver, intentFilter);
this.uuNetWorkStateReceiver.a(this);
} catch (Exception e2) {
q1.c("SafeLink", "registerNetWorkStateReceiver Exception e: ==" + e2.getMessage(), new Object[0]);
}
}
}
public void removeGatewayInfoChangeListener(UUSdpGatewayInfoChangeListener uUSdpGatewayInfoChangeListener) {
if (uUSdpGatewayInfoChangeListener != null) {
this.uuSdpGatewayInfoChangeListeners.remove(uUSdpGatewayInfoChangeListener);
}
}
public void removeTunnelStateListener(UUSdpTunnelStateListener uUSdpTunnelStateListener) {
if (uUSdpTunnelStateListener != null) {
this.uuSdpTunnelStateListeners.remove(uUSdpTunnelStateListener);
}
}
public void resetPassword(UUSdpModifyPasswordRequestInfo uUSdpModifyPasswordRequestInfo, UUSdpModifyPasswordCallback uUSdpModifyPasswordCallback) {
try {
com.uusafe.sdp.proguard.p.a(this.context).b(uUSdpModifyPasswordRequestInfo, new n(this, uUSdpModifyPasswordCallback));
} catch (Exception unused) {
uUSdpModifyPasswordCallback.onError(110);
}
}
public void sendHeartBeatMessage() {
if (this.uuSdpTunnel == null) {
q1.b("SafeLink", "heartBeat error SDP_TUNNEL_NULL", new Object[0]);
return;
}
try {
StringBuffer stringBuffer = new StringBuffer();
Properties properties = this.heartReqProperties;
if (properties != null) {
for (Map.Entry entry : properties.entrySet()) {
stringBuffer.append(entry.getKey());
stringBuffer.append("==");
stringBuffer.append(entry.getValue());
stringBuffer.append(";");
}
if (this.heartReqProperties.getProperty(com.uusafe.sdp.proguard.p.H) == null) {
this.heartReqProperties.setProperty(com.uusafe.sdp.proguard.p.H, this.cid);
}
}
Properties properties2 = this.heartReqProperties;
if (properties2 != null && properties2.getProperty(com.uusafe.sdp.proguard.p.H) != null) {
q1.a("SafeLink", "heartBeat start==" + stringBuffer.toString() + "=cid=" + this.cid + "=state=" + getTunnelState(), new Object[0]);
if (getSelfTunnelState() != 1) {
return;
}
this.lastHeartTime = System.currentTimeMillis();
com.uusafe.sdp.proguard.p.a(this.context).a(this.heartReqProperties);
return;
}
q1.b("SafeLink", "heartBeat error ,no cid!!! logout", new Object[0]);
logoutInternal(null);
} catch (Exception e2) {
e2.printStackTrace();
q1.b("SafeLink", "heartBeat error SDP_TUNNEL_ERROR:" + e2.getCause(), new Object[0]);
}
}
public void sendPluginMsg(UUPluginReq uUPluginReq, SdpPluginCallback sdpPluginCallback) {
try {
if (j1.a(uUPluginReq.getCid())) {
uUPluginReq.setCid(this.cid);
}
com.uusafe.sdp.proguard.p.a(this.context).a(uUPluginReq, sdpPluginCallback);
} catch (Exception unused) {
sdpPluginCallback.onError(110, "error");
}
}
public void setAutoLogin(boolean z) {
this.autoLogin = z;
}
public void setCheckDns(String str) {
this.checkDns = str;
}
public void setCurrentActivity(Activity activity) {
this.currentActivity = activity;
}
public void setDd_app_id(String str) {
this.dd_app_id = str;
}
public void setDebugMode(boolean z) {
String absolutePath = m1.a(Environment.getExternalStorageDirectory(), DIR_APP, DIR_LOG).getAbsolutePath();
if (!z) {
q1.a(this.context, 2, absolutePath, true);
PreferenceUtils.setDebug(false, this.context);
setWgLog(false);
return;
}
q1.a(this.context, 1, absolutePath, true);
PreferenceUtils.setDebug(true, this.context);
setWgLog(true);
}
public void setGetResUrl(String str) {
this.getResUrl = str;
}
public void setIpv6(boolean z) {
this.ipv6 = z;
}
public void setKcpBufferSize(int i2) {
f1.g = i2;
}
public void setKcpConfig(e1 e1Var) {
this.kcpConfig = e1Var;
d1.L = e1Var.getMtu();
}
public void setKickedByServer(boolean z) {
this.kickedByServer = z;
}
public void setMtu(int i2) {
this.mtu = i2;
}
public void setMultipleSdk(boolean z) {
this.multipleSdk = z;
}
public void setPublicDNS(boolean z) {
this.publicDNS = z;
}
public void setReConnect(boolean z) {
this.reConnect = z;
}
public void setSdpClient(boolean z) {
this.sdpClient = z;
}
public void setShowNotification(boolean z) {
this.showNotification = z;
}
public void setShowVpnDetail(boolean z) {
this.showVpnDetail = z;
}
public void setSsl_caPublicKeyPemStr(String str) {
this.ssl_caPublicKeyPemStr = str;
}
public void setSsl_skipCertificate(boolean z) {
this.ssl_skipCertificate = z;
}
public void setStartThirdApp(boolean z) {
this.startThirdApp = z;
}
public void setUuSdpEmmCallback(UUSdpEmmCallback uUSdpEmmCallback) {
this.uuSdpEmmCallback = uUSdpEmmCallback;
}
public void setUuSdpLoginBreakCallback(UUSdpLoginBreakCallback uUSdpLoginBreakCallback) {
this.uuSdpLoginBreakCallback = uUSdpLoginBreakCallback;
}
public void setVPNDelay(int i2) {
this.VPNDelay = i2;
}
public void setWgLog(boolean z) {
GoBackend goBackend = this.backend;
if (goBackend != null) {
goBackend.a(z);
}
}
public void setZlogInit(boolean z) {
this.isZlogInit = z;
}
public void sign(UUSdpLoginCallback uUSdpLoginCallback) {
q1.c("SafeLink", "UUSdpClient sign called 1.3.4.9", new Object[0]);
String ticket = PreferenceUtils.getTicket(this.context);
String cid = PreferenceUtils.getCid(this.context);
if (ticket != null && ticket.length() != 0 && cid != null && cid.length() == 32) {
if (!l1.g(this.context)) {
loginError(112, null);
}
UUSdpLoginRequestInfo uUSdpLoginRequestInfo = new UUSdpLoginRequestInfo();
uUSdpLoginRequestInfo.setCid(cid);
uUSdpLoginRequestInfo.setPassword(ticket);
uUSdpLoginRequestInfo.setType(7);
uUSdpLoginRequestInfo.setSdpName(DIR_LOG);
uUSdpLoginRequestInfo.setAlgorithm(0);
login(uUSdpLoginRequestInfo, uUSdpLoginCallback);
return;
}
uUSdpLoginCallback.onError(111, new UUSdpLoginResponseInfo());
}
public void unregisterNetWorkStateReceiver() {
this.context.unregisterReceiver(this.uuNetWorkStateReceiver);
this.uuNetWorkStateReceiver = null;
}
public boolean web_enable() {
return false;
}
public void wgBumpSockets() {
if (this.backend != null) {
q1.d("SafeLink", "wgBumpSockets", new Object[0]);
GoBackend.wgBumpSockets(this.backend.f5212d);
return;
}
q1.d("SafeLink", "wgBumpSockets backend ==null", new Object[0]);
}
public void wgCloseSocket() {
if (this.backend != null) {
q1.d("SafeLink", "wgCloseSocket", new Object[0]);
GoBackend.wgCloseSocket(this.backend.f5212d);
return;
}
q1.d("SafeLink", "wgCloseSocket backend ==null", new Object[0]);
}
public int wgGetReceiveBytes() {
GoBackend goBackend = this.backend;
if (goBackend != null) {
int wgGetReceiveBytes = GoBackend.wgGetReceiveBytes(goBackend.f5212d);
q1.d("SafeLink", "wgGetReceiveBytes = " + wgGetReceiveBytes, new Object[0]);
return wgGetReceiveBytes;
}
q1.d("SafeLink", "wgGetReceiveBytes backend ==null", new Object[0]);
return -1;
}
public int wgGetReceiveStatus() {
GoBackend goBackend = this.backend;
if (goBackend != null) {
int wgGetReceiveStatus = GoBackend.wgGetReceiveStatus(goBackend.f5212d);
q1.d("SafeLink", "wgGetReceiveStatus = " + wgGetReceiveStatus, new Object[0]);
return wgGetReceiveStatus;
}
q1.d("SafeLink", "wgGetReceiveStatus backend ==null", new Object[0]);
return -1;
}
public int wgGetSendBytes() {
GoBackend goBackend = this.backend;
if (goBackend != null) {
int wgGetSendBytes = GoBackend.wgGetSendBytes(goBackend.f5212d);
q1.d("SafeLink", "wgGetSendBytes = " + wgGetSendBytes, new Object[0]);
return wgGetSendBytes;
}
q1.d("SafeLink", "wgGetSendBytes backend ==null", new Object[0]);
return -1;
}
public void a(DialogInterface dialogInterface) {
this.uuSdpLoginCallbacks.clear();
}
public void logout(UUSdpLogoutCallback uUSdpLogoutCallback, boolean z) {
q1.c("SafeLink", "UUSdpClient logout called cleanSession=" + z, new Object[0]);
if (z) {
PreferenceUtils.setTicket("", this.context);
}
this.tunnelCloseCode = 111;
logoutInternal(uUSdpLogoutCallback);
}
public void sign(UUSdpLoginCallback uUSdpLoginCallback, String str) {
q1.c("SafeLink", "UUSdpClient sign called 1.3.4.9", new Object[0]);
String ticket = PreferenceUtils.getTicket(this.context);
String cid = PreferenceUtils.getCid(this.context);
if (ticket != null && ticket.length() != 0 && cid != null && cid.length() == 32) {
if (!l1.g(this.context)) {
loginError(112, null);
}
UUSdpLoginRequestInfo uUSdpLoginRequestInfo = new UUSdpLoginRequestInfo();
uUSdpLoginRequestInfo.setCid(cid);
uUSdpLoginRequestInfo.setPassword(ticket);
uUSdpLoginRequestInfo.setType(7);
uUSdpLoginRequestInfo.setClientVersion(str);
uUSdpLoginRequestInfo.setSdpName(DIR_LOG);
uUSdpLoginRequestInfo.setAlgorithm(0);
login(uUSdpLoginRequestInfo, uUSdpLoginCallback);
return;
}
uUSdpLoginCallback.onError(111, new UUSdpLoginResponseInfo());
}
public void sign(UUSdpLoginCallback uUSdpLoginCallback, int i2) {
q1.c("SafeLink", "UUSdpClient sign called 1.3.4.9", new Object[0]);
String ticket = PreferenceUtils.getTicket(this.context);
String cid = PreferenceUtils.getCid(this.context);
if (ticket != null && ticket.length() != 0 && cid != null && cid.length() == 32) {
if (!l1.g(this.context)) {
loginError(112, null);
}
UUSdpLoginRequestInfo uUSdpLoginRequestInfo = new UUSdpLoginRequestInfo();
uUSdpLoginRequestInfo.setRetryCount(i2);
uUSdpLoginRequestInfo.setCid(cid);
uUSdpLoginRequestInfo.setPassword(ticket);
uUSdpLoginRequestInfo.setType(7);
uUSdpLoginRequestInfo.setSdpName(DIR_LOG);
uUSdpLoginRequestInfo.setAlgorithm(0);
login(uUSdpLoginRequestInfo, uUSdpLoginCallback);
return;
}
uUSdpLoginCallback.onError(111, new UUSdpLoginResponseInfo());
}
public String getErrorMsg(int i2, int i3) {
String str;
String str2;
if (i3 == 1) {
str = H5Lan.H5_ENGLISH;
str2 = "US";
} else if (i3 == 2) {
str = "ja";
str2 = "JP";
} else {
str = "zh";
str2 = "CN";
}
if (i2 == 101) {
return i1.a(this.context, R.string.uu_login_error_param, str, str2) + " : " + i2;
} else if (i2 == 102) {
return i1.a(this.context, R.string.uu_login_error_102, str, str2) + " : " + i2;
} else if (i2 == 103) {
return i1.a(this.context, R.string.uu_login_error_noresponse, str, str2) + " : " + i2;
} else if (i2 == 104) {
return i1.a(this.context, R.string.uu_login_error_104, str, str2) + " : " + i2;
} else if (i2 == 105) {
return i1.a(this.context, R.string.uu_login_error_106, str, str2) + " : " + i2;
} else if (i2 == 106) {
return i1.a(this.context, R.string.uu_login_error_106, str, str2) + " : " + i2;
} else if (i2 == 1001) {
return i1.a(this.context, R.string.uu_login_error_1001, str, str2);
} else {
if (i2 == 1003) {
return i1.a(this.context, R.string.uu_login_error_1003, str, str2);
}
if (i2 == 1004) {
return i1.a(this.context, R.string.uu_login_error_1004, str, str2);
}
if (i2 == 1005) {
return i1.a(this.context, R.string.uu_login_error_1005, str, str2);
}
if (i2 == 1006) {
return i1.a(this.context, R.string.uu_login_error_1006, str, str2);
}
if (i2 == 1007) {
return i1.a(this.context, R.string.uu_login_error_1007, str, str2);
}
if (i2 == 1008) {
return i1.a(this.context, R.string.uu_login_error_1008, str, str2);
}
if (i2 == 1009) {
return i1.a(this.context, R.string.uu_login_error_1009, str, str2);
}
if (i2 == 1010) {
return i1.a(this.context, R.string.uu_login_error_1010, str, str2);
}
if (i2 == 1011) {
return i1.a(this.context, R.string.uu_login_error_1011, str, str2);
}
if (i2 == 1012) {
return i1.a(this.context, R.string.uu_login_error_1012, str, str2);
}
if (i2 == 1013) {
return i1.a(this.context, R.string.uu_login_error_1013, str, str2);
}
if (i2 == 1014) {
return i1.a(this.context, R.string.uu_login_error_1014, str, str2);
}
if (i2 == 2002) {
return i1.a(this.context, R.string.uu_login_error_2002, str, str2);
}
if (i2 == 2003) {
return i1.a(this.context, R.string.uu_login_error_2003, str, str2);
}
if (i2 == 2004) {
return i1.a(this.context, R.string.uu_login_error_2004, str, str2);
}
if (i2 == 2005) {
return i1.a(this.context, R.string.uu_login_error_2005, str, str2);
}
if (i2 == 2006) {
return i1.a(this.context, R.string.uu_login_error_2006, str, str2);
}
if (i2 == 2007) {
return i1.a(this.context, R.string.uu_login_error_2007, str, str2);
}
if (i2 == 2008) {
return i1.a(this.context, R.string.uu_login_error_2008, str, str2);
}
if (i2 == 2010) {
return i1.a(this.context, R.string.uu_login_error_2010, str, str2);
}
if (i2 == 2011) {
return i1.a(this.context, R.string.uu_login_error_2011, str, str2);
}
if (i2 == 2012) {
return i1.a(this.context, R.string.uu_login_error_2012, str, str2);
}
if (i2 == 2013) {
return i1.a(this.context, R.string.uu_login_error_2013, str, str2);
}
if (i2 == 2009) {
return i1.a(this.context, R.string.uu_login_error_2009, str, str2);
}
if (i2 == 2019) {
return i1.a(this.context, R.string.uu_login_error_2019, str, str2);
}
if (i2 == 2014) {
return i1.a(this.context, R.string.uu_login_error_2014, str, str2);
}
if (i2 == 2015) {
return i1.a(this.context, R.string.uu_login_error_2015, str, str2);
}
if (i2 == 2016) {
return i1.a(this.context, R.string.uu_login_error_2016, str, str2);
}
if (i2 == 2017) {
return i1.a(this.context, R.string.uu_login_error_2017, str, str2);
}
if (i2 == 2018) {
return i1.a(this.context, R.string.uu_login_error_2018, str, str2);
}
if (i2 == 1021) {
return i1.a(this.context, R.string.uu_login_error_1021, str, str2);
}
if (i2 == 1020) {
return i1.a(this.context, R.string.uu_login_error_1020, str, str2);
}
if (i2 == 1022) {
return i1.a(this.context, R.string.uu_login_error_1022, str, str2);
}
if (i2 == 1023) {
return i1.a(this.context, R.string.uu_login_error_1023, str, str2);
}
return i1.a(this.context, R.string.uu_login_error_unknown, str, str2) + " " + i2;
}
}
private String getDnsSettings(HeartRsp heartRsp) {
try {
y1 y1Var = new y1();
x1 x1Var = new x1();
for (InetAddress inetAddress : l1.b(this.context)) {
String hostAddress = inetAddress.getHostAddress();
if (hostAddress.indexOf(".") > 0) {
if (x1Var.getIpv4Preferred() == null) {
x1Var.setIpv4Preferred(inetAddress.getHostAddress());
} else if (x1Var.getIpv4Alternate() == null) {
x1Var.setIpv4Alternate(inetAddress.getHostAddress());
}
} else if (hostAddress.indexOf(Constants.COLON_SEPARATOR) > 0) {
if (x1Var.getIpv6Preferred() == null) {
x1Var.setIpv6Preferred(inetAddress.getHostAddress());
} else if (x1Var.getIpv6Alternate() == null) {
x1Var.setIpv6Alternate(inetAddress.getHostAddress());
}
}
}
y1Var.setServer(x1Var);
w1 w1Var = new w1();
if (x1Var.getIpv4Preferred() != null) {
w1Var.setIpv4Preferred("198.51.100.1");
}
if (x1Var.getIpv4Alternate() != null) {
w1Var.setIpv4Alternate("10.255.255.255");
}
if (x1Var.getIpv6Preferred() != null) {
w1Var.setIpv6Preferred(x1Var.getIpv6Preferred());
}
y1Var.setRoute(w1Var);
s[] dns = heartRsp.getData().getDns();
int i2 = 0;
if (dns != null && dns.length > 0 && heartRsp.getData().getDf() != 1) {
int length = dns.length;
v1[] v1VarArr = new v1[length];
for (int i3 = 0; i3 < length; i3++) {
s sVar = dns[i3];
v1 v1Var = new v1();
v1Var.setName(sVar.getName());
v1Var.setIpv4(sVar.getIpv4());
v1Var.setIpv6(sVar.getIpv6());
v1VarArr[i3] = v1Var;
}
y1Var.setHosts(v1VarArr);
}
if (heartRsp.getData().getDf() != 1) {
w wVar = new w();
wVar.setHosts(heartRsp.getData().getFdns());
y1Var.setFw(wVar);
}
if (heartRsp.getData().getDr() != null && heartRsp.getData().getDr().size() > 0) {
v vVar = new v();
t[] tVarArr = new t[heartRsp.getData().getDr().size()];
Iterator<t> it = heartRsp.getData().getDr().iterator();
while (it.hasNext()) {
tVarArr[i2] = it.next();
i2++;
}
vVar.setDomains(tVarArr);
y1Var.setFwExt(vVar);
}
return new b4().b().a().a(y1Var);
} catch (Exception unused) {
return "";
}
}
}