CarrotChat v2.8.60.240131版本的 MD5 值为:2baf8b9f31830b86b5c5a85ae6b47e05
以下内容为反编译后的 AKCoreService.java 源代码,内容仅作参考
package ak.im.service;
import ak.a.a;
import ak.application.AKApplication;
import ak.event.FindBoxFailedEvent;
import ak.event.a1;
import ak.event.a6;
import ak.event.a8;
import ak.event.b1;
import ak.event.b6;
import ak.event.d3;
import ak.event.e3;
import ak.event.e5;
import ak.event.e7;
import ak.event.f0;
import ak.event.g3;
import ak.event.i2;
import ak.event.j5;
import ak.event.k7;
import ak.event.l5;
import ak.event.s4;
import ak.event.s5;
import ak.event.t3;
import ak.event.u2;
import ak.event.u3;
import ak.event.w0;
import ak.event.y6;
import ak.event.z7;
import ak.i.g0;
import ak.im.b2;
import ak.im.listener.AKConnectedListener;
import ak.im.module.AKCDiscoverGlobal;
import ak.im.module.AKCDiscoverInstance;
import ak.im.module.AKSessionBean;
import ak.im.module.AccountInfo;
import ak.im.module.BleConstant;
import ak.im.module.ChatMessage;
import ak.im.module.CtrlMessage;
import ak.im.module.DiscoverExtKt;
import ak.im.module.Group;
import ak.im.module.IMMessage;
import ak.im.module.NotifyLogUploadResultBean;
import ak.im.module.Server;
import ak.im.module.UnStableCallInfo;
import ak.im.module.User;
import ak.im.modules.akey.SimStateReceiver;
import ak.im.p1;
import ak.im.receiver.KeepLiveReceiver;
import ak.im.receiver.UnStableChatStatusReceiver;
import ak.im.sdk.manager.AKCDiscoverManager;
import ak.im.sdk.manager.AKeyManager;
import ak.im.sdk.manager.BadgeManager;
import ak.im.sdk.manager.CallBackManager;
import ak.im.sdk.manager.MessageListenerManger;
import ak.im.sdk.manager.MessageManager;
import ak.im.sdk.manager.SessionManager;
import ak.im.sdk.manager.SyncManager;
import ak.im.sdk.manager.XMPPConnectionManager;
import ak.im.sdk.manager.af;
import ak.im.sdk.manager.df;
import ak.im.sdk.manager.gf;
import ak.im.sdk.manager.mf;
import ak.im.sdk.manager.nf;
import ak.im.sdk.manager.ye;
import ak.im.service.AKCoreService;
import ak.im.ui.activity.AKeyLauncherActivity;
import ak.im.ui.activity.UserConflictActivity;
import ak.im.ui.activity.settings.ABKeySettingActivity;
import ak.im.uitls.AKCAppConfiguration;
import ak.im.uitls.AKCCheckPoint;
import ak.im.uitls.a0;
import ak.im.uitls.d0;
import ak.im.uitls.y;
import ak.im.utils.AkeyChatUtils;
import ak.im.utils.HttpURLTools;
import ak.im.utils.Log;
import ak.im.utils.f4;
import ak.im.utils.j4;
import ak.im.utils.l4;
import ak.im.utils.n5;
import ak.im.utils.p5;
import ak.smack.AKLoginException;
import ak.smack.w1;
import ak.view.AKeyDialog;
import ak.worker.MessageReliabilityManager;
import ak.worker.RawEncrMessageDecryptionHandler;
import ak.worker.a2;
import ak.worker.b0;
import ak.worker.e2;
import ak.worker.f2;
import ak.worker.m0;
import ak.worker.o0;
import ak.worker.o1;
import ak.worker.q1;
import ak.worker.r1;
import ak.worker.s0;
import ak.worker.s1;
import ak.worker.t0;
import ak.worker.u1;
import ak.worker.v0;
import ak.worker.x1;
import ak.worker.y0;
import ak.worker.z1;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.media.AudioAttributes;
import android.media.AudioManager;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.os.Process;
import android.os.SystemClock;
import android.os.Vibrator;
import android.text.TextUtils;
import android.util.SparseArray;
import android.view.View;
import android.webkit.CookieManager;
import androidx.core.app.NotificationCompat;
import cn.tee3.avd.RolePrivilege;
import cn.tee3.avd.User;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.asim.protobuf.Akeychat;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import com.view.akcsensitiveutils.AKCSensitiveUtils;
import io.reactivex.z;
import java.io.File;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.SocketTimeoutException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Matcher;
import javax.net.ssl.SSLHandshakeException;
import javax.security.auth.login.LoginException;
import okhttp3.y;
import org.apache.commons.httpclient.cookie.CookieSpec;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.jivesoftware.smack.AbstractXMPPConnection;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.sm.packet.StreamManagement;
import org.json.JSONException;
import org.pjsip.pjsua2.app.CallActivity;
import org.pjsip.pjsua2.app.SipCall;
import org.pjsip.pjsua2.app.VoIpManager;
import retrofit2.m;
@SuppressLint({"HandlerLeak"})
public class AKCoreService extends Service {
public static long f1288c;
ak.j.a<String> G;
private Context g;
private io.reactivex.disposables.b m;
private io.reactivex.disposables.b n;
private ak.j.a<Long> o;
private ak.j.a<Object> p;
long q;
public static final String a = "asimCoreService.restartlogin.action" + p1.a;
public static String f1287b = "AKCoreService_kill_self";
public static volatile int f1289d = 0;
static int f1290e = 775;
public static boolean f = false;
private Handler h = null;
protected MessageListenerManger i = null;
private SimStateReceiver j = new SimStateReceiver();
private int k = 0;
private io.reactivex.disposables.b l = null;
private boolean r = false;
private BroadcastReceiver s = new d();
AtomicReference<f2> t = new AtomicReference<>();
private a.AbstractBinderC0000a u = new e();
private UnStableChatStatusReceiver v = null;
private boolean w = true;
private boolean x = false;
private boolean y = false;
private boolean z = false;
private boolean A = false;
private String B = "hotFixTime";
public long C = 5400000;
private boolean D = false;
private boolean E = false;
io.reactivex.disposables.b F = null;
private final Object H = new Object();
public class a implements io.reactivex.s0.g<Long> {
a() {
}
@Override
public void accept(Long l) throws Exception {
if (AKApplication.isNeedTimerToFindID() && XMPPConnectionManager.a.getInstance().isEffective()) {
AKCoreService.this.x(false);
}
}
}
public class b extends ak.j.a<String> {
final String a;
b(String str) {
this.a = str;
}
@Override
public void onError(Throwable th) {
th.printStackTrace();
Log.e("AKCoreService", "checkAndReportMsg failed " + th + ",id " + this.a);
}
@Override
public void onNext(String str) {
Log.i("AKCoreService", "checkAndReportMsg finish " + str);
}
}
public class c extends ak.j.a<NotifyLogUploadResultBean> {
final Map a;
c(Map map) {
this.a = map;
}
@Override
public void onComplete() {
}
@Override
public void onError(Throwable th) {
th.printStackTrace();
}
@Override
public void onNext(NotifyLogUploadResultBean notifyLogUploadResultBean) {
if (notifyLogUploadResultBean.returnCode == 0) {
AKCoreService.this.p0(null);
return;
}
JSONObject jSONObject = new JSONObject();
jSONObject.put("collect_id", this.a.get("collect_id"));
jSONObject.put("status", this.a.get("status"));
jSONObject.put("logurl", this.a.get("logurl"));
AKCoreService.this.p0(jSONObject.toJSONString());
if (XMPPConnectionManager.a.getInstance().isEffective()) {
Log.i("AKCoreService", "notify log upload, disconnection break");
return;
}
try {
Log.i("AKCoreService", "notify log upload , connection retry");
Thread.sleep(BleConstant.SEND_OUTTIME);
AKCoreService.this.m0(this.a);
} catch (InterruptedException e2) {
e2.printStackTrace();
}
}
}
public class d extends BroadcastReceiver {
d() {
}
public void b() {
AKCoreService.this.sendAKBroadcast(AKCoreService.a);
}
@Override
public void onReceive(Context context, Intent intent) {
String str;
String str2;
if (intent == null) {
Log.w("AKCoreService", "intent is null");
return;
}
b0 b0Var = null;
String action = intent.getAction();
Log.i("AKCoreService", "mAKCoreServiceReceiver rev action:" + action + ",main thread name:" + Thread.currentThread().getName());
if (AKCoreService.a.equals(action)) {
AKCoreService.this.v0(action);
} else if (p1.q.equals(action)) {
AKCoreService.this.w = false;
AKCoreService.this.x = intent.getBooleanExtra("stop_service_need_clear_username", false);
AKCoreService.this.y = intent.getBooleanExtra("stop_service_need_clear_pwd", false);
AKCoreService.this.z = intent.getBooleanExtra("stop_service_need_clear_data", false);
AKCoreService.this.A = intent.getBooleanExtra("need_kill_process", true);
AKCoreService.this.r = intent.getBooleanExtra("need_restart", false);
AKCoreService.this.stopSelf();
} else if ("android.net.conn.CONNECTIVITY_CHANGE".equals(action)) {
ye.getInstance().loadBlackListFromServer();
ye.getInstance().uploadBlackListErrorToOSS();
a0.isNetWorkAvailableInPhysical();
j4.sendEvent(g3.getInstance("cmr-action"));
if (!AKApplication.isAppHadLogin()) {
Log.i("AKCoreService", "not init Complete-in-connectity-changed.");
CallBackManager.a.getInstance().notifyNetChanged();
return;
}
XMPPConnectionManager.a aVar = XMPPConnectionManager.a;
if (aVar.getInstance().isDoLogin()) {
Log.i("AKCoreService", "IS doing login");
return;
}
AbstractXMPPConnection connection = aVar.getInstance().getConnection();
a0 a0Var = a0.a;
if (a0.isNetWorkAvailableInPhysical()) {
boolean isEffective = aVar.getInstance().isEffective();
Log.i("AKCoreService", "receive network connectivity changed, is effective:" + isEffective);
if (!isEffective) {
AKCoreService.this.v0("network_accessibility_reconnect");
} else {
MessageListenerManger messageListenerManger = AKCoreService.this.i;
if (!messageListenerManger.f768b) {
messageListenerManger.initChatListener();
} else {
messageListenerManger.addMucInviteListener(connection);
}
}
} else {
Log.d("AKCoreService", "network connection is lost,should not start reconnect");
ye.getInstance().setOnline(false);
}
} else if (p1.f615c.equals(action)) {
XMPPConnectionManager.a aVar2 = XMPPConnectionManager.a;
boolean isDoLogin = aVar2.getInstance().isDoLogin();
Log.i("AKCoreService", "ignorethisRcv:" + isDoLogin);
String stringExtra = intent.getStringExtra("reconnect_state");
Log.i("AKCoreService", "receive reconnection action,status:" + stringExtra);
if ("xmpp.disconnected".equals(stringExtra)) {
MessageReliabilityManager.getInstance().waitingForOnline();
if (isDoLogin) {
Log.i("AKCoreService", "ignore this Rcv :" + isDoLogin + "when I logon,Xmpp disconnected, need cancel the login task end re-login");
ye.getInstance().getServer().setEffective(false);
aVar2.getInstance().setDoLogin(false);
AKCoreService.this.asimCoreServicePostRunner(new Runnable() {
@Override
public final void run() {
AKCoreService.d.this.b();
}
}, BleConstant.SEND_OUTTIME);
return;
}
} else if ("xmpp.connected".equals(stringExtra)) {
MessageListenerManger messageListenerManger2 = AKCoreService.this.i;
if (!messageListenerManger2.f768b) {
messageListenerManger2.initChatListener();
} else {
messageListenerManger2.addMucInviteListener(aVar2.getInstance().getConnection());
}
Log.i("UserManager", "CONNECTED 2");
b0Var = AKCoreService.this.v();
AKCoreService.this.A();
} else if ("xmpp.connecting".equals(stringExtra)) {
Log.i("AKCoreService", "rcv connecting");
if (aVar2.getInstance().isEffective()) {
Log.w("AKCoreService", "xmpp connection is ok,do not reconnect: in Service");
return;
}
MessageReliabilityManager.getInstance().waitingForOnline();
ye.getInstance().setOnline(false);
Log.i("AKCoreService", "start ConnThread; reconn");
AKCoreService.this.v0("xmpp_reconnect");
}
} else if (!p1.A.equals(action) && !ABKeySettingActivity.a.equals(action)) {
if (p1.x.equals(action)) {
ChatMessage chatMessage = (ChatMessage) intent.getParcelableExtra("immessage.remotedestroy.key.message");
String chatType = chatMessage.getChatType();
if (!"single".equals(chatType) && !IMMessage.UNSTABLE.equals(chatType) && !"channel".equals(chatType) && !"bot".equals(chatType)) {
if (chatMessage.getChatType().equals("group")) {
b0Var = new o0(chatMessage);
}
} else {
Log.i("AKCoreService", "send remote destroy:" + chatType);
b0Var = new o1(chatMessage);
}
} else if (p1.y.equals(action)) {
b0Var = new r1(intent.getStringExtra(IMMessage.PROP_TYPE_CHAT), intent.getStringExtra("name"), intent.getStringArrayListExtra("destroy_msgs_id_list_key"));
} else if (p1.z.equals(action)) {
if (!ye.getInstance().getPrivacyDestroySwitch()) {
Log.w("AKCoreService", "switch is off,do not send burn receipts");
return;
}
ChatMessage chatMessage2 = (ChatMessage) intent.getParcelableExtra("immessage.receipts.key.message");
String chatType2 = chatMessage2.getChatType();
if (!"single".equals(chatType2) && !IMMessage.UNSTABLE.equals(chatType2) && !"channel".equals(chatType2) && !"bot".equals(chatType2)) {
if ("group".equals(chatMessage2.getChatType())) {
Log.w("AKCoreService", "group chat messge burn,msg id:" + chatMessage2.toString());
b0Var = new m0(chatMessage2);
}
} else {
b0Var = new t0(chatMessage2);
}
} else if (p1.r.equals(action)) {
ChatMessage chatMessage3 = (ChatMessage) intent.getParcelableExtra("immessage.sendfile.key.message");
AbstractXMPPConnection connection2 = XMPPConnectionManager.a.getInstance().getConnection();
if (connection2 == null || !connection2.isAuthenticated()) {
chatMessage3.setStatus("error");
EventBus.getDefault().post(new s4(chatMessage3, false, false));
}
Log.d("AKCoreService", "send file action in single chat");
if (mf.getIntance().getmActiveUnstableChatID() != null) {
mf.getIntance().setmLastActiveMsgTime(System.currentTimeMillis());
}
b0Var = MessageManager.getInstance().handleFileMsgBeforeSend(chatMessage3);
} else if (p1.t.equals(action)) {
b0Var = MessageManager.getInstance().handleTxtMsgBeforeSend((ChatMessage) intent.getParcelableExtra("immessage.sendmessage.key.message"), false);
} else if (p1.w.equals(action)) {
b0Var = new e2(intent.getStringExtra("immessage.group.key.group.name"), intent.getStringExtra("immessage.group.key.group.info"));
} else if ("android.intent.action.MEDIA_SHARED".equals(action)) {
if (l4.getSDCardRootDirectory() == null) {
Log.d("AKCoreService", "sdcard switch to mass storage mode at time:" + f4.getCurDateStr() + ",which effect our APP");
j4.sendEvent(k7.newToastEvent(b2.sdcard_swtich_to_mass_storage));
} else {
Log.d("AKCoreService", "sdcard switch to mass storage mode at time:" + f4.getCurDateStr() + ",which don't effect our APP");
}
} else if (p1.O.equals(action)) {
int intExtra = intent.getIntExtra("toast_content_key", -1);
if (-1 != intExtra) {
AKCoreService.this.r0(intExtra, 0);
return;
}
String stringExtra2 = intent.getStringExtra("toast_content_string_key");
if (stringExtra2 != null) {
AKCoreService.this.showToast(stringExtra2, 0);
return;
}
} else if (p1.P.equals(action)) {
String stringExtra3 = intent.getStringExtra("delete_session_key");
if (stringExtra3 != null) {
MessageManager.addHandlerIntoSender(new u1(stringExtra3));
List<ChatMessage> sessionMessages = MessageManager.getInstance().getSessionMessages(stringExtra3);
if (sessionMessages != null && !sessionMessages.isEmpty()) {
for (ChatMessage chatMessage4 : sessionMessages) {
str = "";
if (chatMessage4 != null) {
str = TextUtils.isEmpty(chatMessage4.getDir()) ? "" : chatMessage4.getDir();
if (!TextUtils.isEmpty(chatMessage4.getDestroy())) {
str2 = chatMessage4.getDestroy();
if (chatMessage4 != null && str.equals(IMMessage.SEND) && str2.equals(IMMessage.SHOULD_BURN)) {
MessageManager.getInstance().hideMessageByUniqueId(chatMessage4.getUniqueId());
EventBus.getDefault().post(new ak.event.u(chatMessage4));
}
}
}
str2 = str;
if (chatMessage4 != null) {
MessageManager.getInstance().hideMessageByUniqueId(chatMessage4.getUniqueId());
EventBus.getDefault().post(new ak.event.u(chatMessage4));
}
}
}
} else {
Log.d("AKCoreService", "with or type is null,with");
}
} else if (p1.B.equals(action)) {
String stringExtra4 = intent.getStringExtra("delete_contact_msg_key");
if (stringExtra4 != null) {
MessageManager.addHandlerIntoSender(new ak.worker.p1(stringExtra4));
return;
} else {
Log.w("AKCoreService", "userJid is null,user jid");
return;
}
} else if (p1.Q.equals(action)) {
Log.d("AKCoreService", "send bulk remote destroy receipt.");
return;
} else if (p1.C.equals(action)) {
Log.i("AKCoreService", "send jid bulk remote destroy receipt.");
return;
} else if (p1.D.equals(action)) {
Log.i("AKCoreService", "send room remote destroy receipt.");
return;
} else if (p1.S.equals(action)) {
Log.d("AKCoreService", "recv stop app action.");
int intExtra2 = intent.getIntExtra("toast_content_key", -1);
int intExtra3 = intent.getIntExtra("asim_app_pid_key", -1);
if (-1 == intExtra2) {
AKCoreService.this.w0("unknown", -1, intExtra3);
return;
} else {
AKCoreService.this.w0("conflict", intExtra2, intExtra3);
return;
}
} else if (p1.E.equals(action)) {
MessageManager.addHandlerIntoSender(new s1(intent.getStringExtra("delete_all_cipher_msg_action")));
} else if (ak.im.g2.a.a.f.equals(action)) {
AKCoreService.this.w0("conflict", b2.jwmx_logout, -1);
return;
} else if (!"android.intent.action.CLOSE_SYSTEM_DIALOGS".equals(action) && !"android.intent.action.SCREEN_OFF".equals(action)) {
if ("android.intent.action.USER_PRESENT".equals(action)) {
SipCall sipCall = VoIpManager.getInstance().getmCurrentCall();
StringBuilder sb = new StringBuilder();
sb.append("app unlocked,check current sipcall is null?");
sb.append(sipCall == null);
Log.debug("AKCoreService", sb.toString());
if (sipCall != null && !(AKApplication.getTopActivity() instanceof CallActivity) && !VoIpManager.getInstance().isShowingFloatView() && VoIpManager.getInstance().tempCallinfo != null && sipCall.akeyCallId.equals(VoIpManager.getInstance().tempCallinfo.first)) {
VoIpManager.getInstance().startCallActivity(sipCall.getCallUsername(), sipCall.getCalleeUsername(), (String) VoIpManager.getInstance().tempCallinfo.second, -1);
}
} else if (AKCoreService.f1287b.equals(action)) {
AKApplication.r = ye.getInstance().isOpenForeground();
Log.i("AKCoreService", "KILL_SELF_SERVICE " + AKApplication.r);
AKCoreService.this.w = true;
AKCoreService.this.stopSelf();
}
} else {
Log.i("AKCoreService", "app intent to be in background status, update online status");
}
} else if (AKeyManager.getInstance().getAttachedBindingAKey() != null && nf.getInstance().getUserMe() != null) {
Log.i("AKCoreService", "now binding akey attached, start batch decryption task.");
MessageManager.addHandlerIntoRecver(new RawEncrMessageDecryptionHandler(context));
}
if (b0Var != null) {
MessageManager.addHandlerIntoSender(b0Var);
}
}
}
class e extends a.AbstractBinderC0000a {
e() {
}
@Override
public void make_unstablechat_call(String str, String str2, String str3) {
AKCoreService.this.k0(str, str2, str3);
}
@Override
public void unstablechat_accept(String str, String str2, String str3) {
AKCoreService.this.z0(str, str2, str3);
}
@Override
public void unstablechat_busy(String str, String str2, String str3) {
AKCoreService.this.A0(str, str2, str3);
}
@Override
public void unstablechat_config(String str, String str2, String str3) {
AKCoreService.this.B0(str, str2, str3);
}
@Override
public void unstablechat_destroy(String str, String str2, String str3) {
AKCoreService.this.unstablechat_destroy_(str, str2, str3);
}
@Override
public void unstablechat_hangup(String str, String str2, String str3) {
AKCoreService.this.C0(str, str2, str3);
}
@Override
public void unstablechat_heart(String str, String str2, String str3) {
AKCoreService.this.unstablechat_heart_(str, str2, str3);
}
}
class f extends ak.j.a<Long> {
f() {
}
@Override
public void onError(Throwable th) {
Log.e("AKCoreService", "kill self error is " + th.getMessage());
}
@Override
public void onNext(Long l) {
Log.debug("AKCoreService", "stopSelf");
Log.i("AKCoreService", "kill self success");
AKApplication.r = false;
AKCoreService.this.stopSelf();
}
}
class g implements io.reactivex.s0.g<Long> {
g() {
}
@Override
public void accept(Long l) throws Exception {
AKCoreService.this.analysisNet(l);
}
}
public class h extends ak.j.a<Object> {
h() {
}
@Override
public void onError(Throwable th) {
Log.i("AKCoreService", "maybeLogin failed, e is " + th.getMessage());
}
@Override
public void onNext(Object obj) {
AKCoreService.this.v0("maybeLogin");
}
}
public class i implements io.reactivex.s0.o<String, Object> {
i() {
}
@Override
public Object apply(String str) throws Exception {
AKCDiscoverManager.a aVar;
int i = 0;
while (true) {
aVar = AKCDiscoverManager.a;
if (aVar.getInstance().getNodesHadInit() || i >= 25) {
break;
}
i++;
Thread.sleep(200L);
}
if (!aVar.getInstance().getNodesHadInit()) {
AKCAppConfiguration aKCAppConfiguration = AKCAppConfiguration.a;
aKCAppConfiguration.initConfig();
aKCAppConfiguration.initHintConfig();
aVar.getInstance().getDiscoverNodes(0).subscribe();
}
return str;
}
}
public class j extends ak.j.a<Long> {
final int a;
j(int i) {
this.a = i;
}
@Override
public void onComplete() {
}
@Override
public void onError(Throwable th) {
}
@Override
public void onNext(Long l) {
Log.w("AKCoreService", ",pid:" + this.a + ",my pid:" + Process.myPid());
ak.im.o1.sendStopService(false, false, true);
int i = this.a;
if (i == -1) {
Process.killProcess(Process.myPid());
} else {
Process.killProcess(i);
}
}
}
public class k implements Runnable {
private String a;
private String f1296b;
private String f1297c;
k(AKCoreService aKCoreService, String str, String str2, String str3, c cVar) {
this(str, str2, str3);
}
@Override
public void run() {
try {
Thread.sleep(30000L);
} catch (InterruptedException e2) {
e2.printStackTrace();
}
if (this.f1297c.equalsIgnoreCase(mf.getIntance().getmActiveUnstableChatID()) && mf.getIntance().hasActiveUnstableChat(this.a, this.f1296b) && !mf.getIntance().isAccepted()) {
mf.getIntance().setmActiveUnstableChatID(null);
AKCoreService.this.akUnstableChatBroadcast("callstate_recvring_outtime", this.f1296b, this.f1297c);
AKCoreService.this.C0(this.a, this.f1296b, this.f1297c);
return;
}
Log.i("AKCoreService", "do not need check CheckAcceptOutTime or is not AcceptOutTime");
}
private k(String str, String str2, String str3) {
this.a = str;
this.f1296b = str2;
this.f1297c = str3;
}
}
public class l implements Runnable {
private String a;
private String f1299b;
private String f1300c;
l(String str, String str2, String str3) {
this.a = str;
this.f1299b = str2;
this.f1300c = str3;
}
@Override
public void run() {
try {
Thread.sleep(30000L);
} catch (InterruptedException e2) {
e2.printStackTrace();
}
if (mf.getIntance().hasActiveUnstableChat(this.a, this.f1299b) && this.f1300c.equals(mf.getIntance().getmActiveUnstableChatID()) && !mf.getIntance().isAccepted() && mf.getIntance().isInviteResponseOutTime(this.f1300c)) {
mf.getIntance().setmActiveUnstableChatID(null);
AKCoreService.this.akUnstableChatBroadcast("callstate_recvring_outtime", this.f1299b, this.f1300c);
return;
}
Log.i("AKCoreService", "do not need check isInviteResponseOutTime or is not isInviteResponseOutTime");
}
}
public void A() {
String reSendCollectLogNotice = ye.getInstance().getReSendCollectLogNotice();
if (reSendCollectLogNotice != null) {
try {
JSONObject parseObject = JSON.parseObject(reSendCollectLogNotice);
HashMap hashMap = new HashMap();
hashMap.put("collect_id", parseObject.getString("collect_id"));
hashMap.put("status", parseObject.getString("status"));
hashMap.put("logurl", parseObject.getString("logurl"));
m0(hashMap);
} catch (Exception e2) {
e2.printStackTrace();
}
}
}
public void A0(String str, String str2, String str3) {
Message unStableChatCtrlMessage = mf.getIntance().getUnStableChatCtrlMessage(str3, str2, str, CtrlMessage.LAUNCH_UNSTABLECHAT_BUSY);
if (unStableChatCtrlMessage != null) {
mf.getIntance().setRecvHeart(false);
MessageManager.addHandlerIntoSender(new a2(unStableChatCtrlMessage));
}
}
private void B() {
AlarmManager alarmManager = (AlarmManager) getSystemService(NotificationCompat.CATEGORY_ALARM);
if (alarmManager == null) {
Log.w("AKCoreService", "alar mgr is null");
return;
}
Intent intent = new Intent(getApplicationContext(), KeepLiveReceiver.class);
Context applicationContext = getApplicationContext();
int i2 = Build.VERSION.SDK_INT;
PendingIntent broadcast = PendingIntent.getBroadcast(applicationContext, 0, intent, i2 >= 23 ? 201326592 : 134217728);
long elapsedRealtime = SystemClock.elapsedRealtime() + 5000;
if (i2 >= 23) {
try {
alarmManager.setAndAllowWhileIdle(2, elapsedRealtime, broadcast);
} catch (Exception e2) {
Log.e("AKCoreService", "initKeepAliveAlarm alarmMgr set error , " + e2.getMessage());
}
}
alarmManager.setRepeating(2, elapsedRealtime, 5000L, broadcast);
Log.debug("AKCoreService", "initKeepAliveAlarm success");
}
public void B0(String str, String str2, String str3) {
Message unStableChatCtrlMessage = mf.getIntance().getUnStableChatCtrlMessage(str3, str2, str, CtrlMessage.LAUNCH_UNSTABLECHAT_CONFIG);
if (unStableChatCtrlMessage != null) {
MessageManager.addProperty(unStableChatCtrlMessage, CtrlMessage.CTRL_SEND_UNSTABLECHAT_TIMER, mf.getIntance().getmSendSetTime());
MessageManager.addHandlerIntoSender(new a2(unStableChatCtrlMessage));
}
}
private void C() {
String userVideoPath = l4.getUserVideoPath();
if (!TextUtils.isEmpty(userVideoPath)) {
l4.createDir(new File(userVideoPath));
}
String userImagePath = l4.getUserImagePath();
if (!TextUtils.isEmpty(userImagePath)) {
l4.createDir(new File(userImagePath));
}
String userAudioPath = l4.getUserAudioPath();
if (!TextUtils.isEmpty(userAudioPath)) {
l4.createDir(new File(userAudioPath));
}
String userFilePath = l4.getUserFilePath();
if (!TextUtils.isEmpty(userFilePath)) {
l4.createDir(new File(userFilePath));
}
String userTempPath = l4.getUserTempPath();
if (!TextUtils.isEmpty(userTempPath)) {
l4.createDir(new File(userTempPath));
}
String emoticonPath = l4.getEmoticonPath();
if (TextUtils.isEmpty(emoticonPath)) {
return;
}
l4.createDir(new File(emoticonPath));
}
public void C0(String str, String str2, String str3) {
Log.i("AKCoreService", "unstablechat_hangup_ >");
Message unStableChatCtrlMessage = mf.getIntance().getUnStableChatCtrlMessage(str3, str2, str, CtrlMessage.LAUNCH_UNSTABLECHAT_CANNCLE);
if (unStableChatCtrlMessage != null) {
Log.i("AKCoreService", "unstablechat_hangup_ =====");
MessageManager.addHandlerIntoSender(new a2(unStableChatCtrlMessage));
MessageReliabilityManager.getInstance().cancelSYSReliability(str3);
}
Log.i("AKCoreService", "unstablechat_hangup_ <");
}
public static void D() {
Log.i("AKCoreService", "send update.presence; recv offline msgs");
EventBus.getDefault().post(new t3(User.UPDATE_INFO));
ye.getInstance().setOnline(true);
ye.getInstance().queryDesktopStatus();
}
public String[] G(ChatMessage chatMessage, String str) throws Exception {
String sensitiveMatch;
String str2 = "";
if (AKCAppConfiguration.a.supportSurveillance()) {
AKCSensitiveUtils.a aVar = AKCSensitiveUtils.a;
if (aVar.getInstance().getCanUse()) {
synchronized (this.H) {
sensitiveMatch = aVar.getInstance().sensitiveMatch(chatMessage.getContent());
}
str2 = sensitiveMatch;
} else {
Log.i("AKCoreService", "getCanUse is false");
}
Log.debug("AKCoreService", "测试数据:命中为:" + str2);
}
return new String[]{str, (TextUtils.isEmpty(str2) || !str2.contains(HiAnalyticsConstant.REPORT_VAL_SEPARATOR)) ? "" : ""};
}
public String I(AKSessionBean aKSessionBean, ChatMessage chatMessage, String[] strArr) throws Exception {
String str;
boolean z;
ChatMessage chatMessage2 = chatMessage;
String serverStatus = ye.getInstance().getServerStatus();
HashMap<String, String> hashMap = new HashMap<String, String>(aKSessionBean, chatMessage2) {
final AKSessionBean a;
final ChatMessage f1291b;
{
this.a = aKSessionBean;
this.f1291b = chatMessage2;
put("serverID", ye.getInstance().getServer() != null ? ye.getInstance().getServer().getEnterpriseId() : ye.getInstance().getServerId());
put("sessionID", aKSessionBean == null ? "" : aKSessionBean.getSessionId());
put("messageID", chatMessage2.getUniqueId());
put("chatType", "single".equals(chatMessage2.getChatType()) ? "1" : "2");
put("senderUserID", ye.getInstance().getUsername());
}
};
if (Akeychat.RiskStatus.surveillance.name().equals(serverStatus)) {
int i2 = 1;
if (strArr.length > 1 && !TextUtils.isEmpty(strArr[1])) {
try {
String[] split = strArr[1].split("\n\\|\n");
String[] split2 = split.length > 1 ? split[1].split("\n") : null;
if (split2 != null) {
int length = split2.length;
int i3 = 0;
while (i3 < length) {
String str2 = split2[i3];
Log.debug("AKCoreService", "测试数据 report:" + str2);
String[] split3 = str2.split("\\|");
StringBuilder sb = new StringBuilder();
for (int i4 = 2; i4 < split3.length; i4++) {
sb.append(n5.shaHash(split3[i4]));
if (i4 == split3.length - i2) {
break;
}
sb.append(",");
}
hashMap.put("Result", sb.toString());
List<ChatMessage> queryMessageListWithLimit = MessageManager.getInstance().queryMessageListWithLimit(chatMessage.getWith(), chatMessage.getmSeqNO(), -9, chatMessage.getChatType(), "text");
queryMessageListWithLimit.add(0, chatMessage2);
StringBuilder sb2 = new StringBuilder();
int size = queryMessageListWithLimit.size() - i2;
while (size >= 0) {
ChatMessage chatMessage3 = queryMessageListWithLimit.get(size);
StringBuilder sb3 = new StringBuilder();
sb3.append("测试数据:消息内容:");
sb3.append(chatMessage3.getContent());
sb3.append(",seq:");
String[] strArr2 = split2;
int i5 = length;
sb3.append(chatMessage3.getmSeqNO());
Log.debug("AKCoreService", sb3.toString());
try {
sb2.append(",");
String content = chatMessage3.getContent();
AKeyManager aKeyManager = AKeyManager.getInstance();
AKCAppConfiguration aKCAppConfiguration = AKCAppConfiguration.a;
sb2.append(ak.im.h2.b.encrypt(content, aKeyManager.getSensitiveKey(aKCAppConfiguration.getSurveillanceKey2()), AKeyManager.getInstance().getSensitiveVi(aKCAppConfiguration.getSurveillanceIv2())));
} catch (Exception e2) {
e2.printStackTrace();
}
size--;
split2 = strArr2;
length = i5;
}
String[] strArr3 = split2;
int i6 = length;
hashMap.put("Msgs", sb2.length() > 1 ? sb2.substring(1) : sb2.toString());
Log.debug("AKCoreService", "测试数据 report map:" + JSON.toJSONString(w(hashMap, false)));
AKCCheckPoint.aliyunLog2(w(hashMap, false), AKCCheckPoint.AKCSLSLogTopic.AKCSLSLogTopic_Regulation_Report.getValue(), "surveillance-log", "mixin-client-log");
i3++;
split2 = strArr3;
length = i6;
i2 = 1;
chatMessage2 = chatMessage;
}
}
} catch (Exception e3) {
AkeyChatUtils.logException(e3);
}
}
StringBuilder sb4 = new StringBuilder();
Matcher matcher = p5.f3736e.matcher(chatMessage.getContent());
String content2 = chatMessage.getContent();
while (true) {
str = "";
if (!matcher.find()) {
break;
}
sb4.append(",");
String group = matcher.group();
content2 = content2.replace(group, "");
Log.debug("AKCoreService", "测试数据 2 :" + group + ",replace is " + content2);
if (HttpURLTools.UrlType.PublicNetworkExternalUrl.equals(HttpURLTools.checkHttpUrlType(group))) {
AKeyManager aKeyManager2 = AKeyManager.getInstance();
AKCAppConfiguration aKCAppConfiguration2 = AKCAppConfiguration.a;
sb4.append(ak.im.h2.b.encrypt(group, aKeyManager2.getSensitiveKey(aKCAppConfiguration2.getSurveillanceKey3()), AKeyManager.getInstance().getSensitiveVi(aKCAppConfiguration2.getSurveillanceIv3())));
}
}
Matcher matcher2 = p5.f3735d.matcher(content2);
while (matcher2.find()) {
sb4.append(",");
String group2 = matcher2.group();
Log.debug("AKCoreService", "测试数据 1 :" + group2);
if (!group2.startsWith("http://") && !group2.startsWith("https://")) {
group2 = "https://" + group2;
}
if (HttpURLTools.UrlType.PublicNetworkExternalUrl.equals(HttpURLTools.checkHttpUrlType(group2))) {
AKeyManager aKeyManager3 = AKeyManager.getInstance();
AKCAppConfiguration aKCAppConfiguration3 = AKCAppConfiguration.a;
sb4.append(ak.im.h2.b.encrypt(group2, aKeyManager3.getSensitiveKey(aKCAppConfiguration3.getSurveillanceKey3()), AKeyManager.getInstance().getSensitiveVi(aKCAppConfiguration3.getSurveillanceIv3())));
}
}
if (sb4.length() > 0) {
z = true;
str = sb4.substring(1);
} else {
z = true;
}
if (!TextUtils.isEmpty(str)) {
hashMap.put("links", str);
AKCCheckPoint.aliyunLog2(w(hashMap, z), AKCCheckPoint.AKCSLSLogTopic.AKCSLSLogTopic_Regulation_Report_Link.getValue(), "surveillance-log", "mixin-client-log");
Log.debug("AKCoreService", "测试数据 link map:" + JSON.toJSONString(w(hashMap, z)));
}
}
return strArr[0];
}
private kotlin.v J(boolean z, AKCDiscoverGlobal.DiscoverServerResponse discoverServerResponse) {
if (discoverServerResponse.getError().getCode() == -1) {
stopFindIdTimer();
AKApplication.setNeedTimerToFindID(false);
Log.i("AKCoreService", "update server success");
AKCDiscoverInstance queryDiscoverInstanceBy = AKCDiscoverInstance.Companion.queryDiscoverInstanceBy(ye.getInstance().getServerId());
if (queryDiscoverInstanceBy != null) {
Log.i("AKCoreService", "current:" + queryDiscoverInstanceBy);
if (!z) {
queryDiscoverInstanceBy.recordReport(0);
} else {
queryDiscoverInstanceBy.recordReport2(0);
}
queryDiscoverInstanceBy.scoreServerNetInfo(4);
}
} else if (!DiscoverExtKt.ServerInvalid(discoverServerResponse.getError().getCode()) && !DiscoverExtKt.ServerErrNeedHandleAfterLogin(discoverServerResponse.getError().getCode())) {
Log.i("AKCoreService", "discoveryForReconnectLogin start timer");
AKApplication.setNeedTimerToFindID(true);
j4.sendEvent(new w0(true, 10));
} else {
int code = discoverServerResponse.getError().getCode();
if (code == 65539) {
code = 28;
} else if (code != 65538) {
code = 403;
}
EventBus.getDefault().postSticky(new a1(discoverServerResponse.getError().getDescription(), code));
return null;
}
return null;
}
public void M(String str) {
XMPPConnectionManager.a.getInstance().setDoLogin(true);
Log.e("AKCoreService", "lwx start log auto by akcoreService");
try {
i0(str);
} catch (Exception e2) {
e2.printStackTrace();
Log.e("AKCoreService", "login failed ,e is " + e2.getMessage());
XMPPConnectionManager.a.getInstance().setDoLogin(false);
}
}
public static void N(Akeychat.UserPrivateSyncResponse userPrivateSyncResponse) {
User contacterByUserName;
User contacterByUserName2;
ArrayList<String> arrayList = new ArrayList<>();
arrayList.add("my_private_info");
SparseArray<Long> syncInfoVersionCode = SyncManager.getSingleton().getSyncInfoVersionCode(arrayList);
long longValue = syncInfoVersionCode.get(syncInfoVersionCode.keyAt(0)).longValue();
Log.i("AKCoreService", "userExPrivateInfo.local ver code:" + longValue + ",remote ver code:" + userPrivateSyncResponse.getVersioncode());
if (longValue >= userPrivateSyncResponse.getVersioncode()) {
Log.w("AKCoreService", "userExPrivateInfo.versioncode error,ignore.");
} else if (longValue == userPrivateSyncResponse.getVersioncode() - 1) {
if (userPrivateSyncResponse.hasWithProperties()) {
Log.w("AKCoreService", "presence modify:" + userPrivateSyncResponse.getWithProperties().toString());
if (userPrivateSyncResponse.getWithProperties().getPushstatusCount() > 0) {
for (int i2 = 0; i2 < userPrivateSyncResponse.getWithProperties().getPushstatusCount(); i2++) {
Akeychat.UserPrivateWithBoolean pushstatus = userPrivateSyncResponse.getWithProperties().getPushstatus(i2);
String withId = pushstatus.getWithId();
Boolean valueOf = Boolean.valueOf(pushstatus.getValue());
if (!withId.contains("_")) {
if (nf.getInstance().contactersContainsKey(withId) && (contacterByUserName2 = nf.getInstance().getContacterByUserName(nf.getInstance().getUserNameByJid(withId))) != null) {
StringBuilder sb = new StringBuilder();
sb.append("modify.user:");
sb.append(contacterByUserName2.getName());
sb.append(",pushStatus:");
sb.append(!valueOf.booleanValue());
Log.i("AKCoreService", sb.toString());
contacterByUserName2.setPushStatus(!valueOf.booleanValue());
nf.getInstance().updateContactPushStatus(contacterByUserName2);
j4.sendEvent(new a8(true, contacterByUserName2));
}
} else {
Group groupBySimpleName = df.getInstance().getGroupBySimpleName(withId.split("@")[0]);
if (groupBySimpleName != null) {
StringBuilder sb2 = new StringBuilder();
sb2.append("modify.group:");
sb2.append(groupBySimpleName.getSimpleName());
sb2.append(",pushStatus:");
sb2.append(!valueOf.booleanValue());
Log.i("AKCoreService", sb2.toString());
groupBySimpleName.setPushStatus(!valueOf.booleanValue());
df.getInstance().updateGroupPushStatus(groupBySimpleName.getPushStatus(), groupBySimpleName);
j4.sendEvent(new i2(groupBySimpleName));
}
}
}
}
if (userPrivateSyncResponse.getWithProperties().getAliasCount() > 0) {
for (int i3 = 0; i3 < userPrivateSyncResponse.getWithProperties().getAliasCount(); i3++) {
Akeychat.UserPrivateWithString alias = userPrivateSyncResponse.getWithProperties().getAlias(i3);
String withId2 = alias.getWithId();
String value = alias.getValue();
if (nf.getInstance().contactersContainsKey(withId2) && (contacterByUserName = nf.getInstance().getContacterByUserName(nf.getInstance().getUserNameByJid(withId2))) != null) {
Log.i("AKCoreService", "modify.user:" + contacterByUserName.getName() + ",alias:" + value);
contacterByUserName.setRemarkNickName(value);
nf.getInstance().updateContactAlias(contacterByUserName);
EventBus.getDefault().post(new z7(contacterByUserName.getName(), contacterByUserName));
}
}
}
if (userPrivateSyncResponse.getWithProperties().getFocusListCount() > 0) {
for (int i4 = 0; i4 < userPrivateSyncResponse.getWithProperties().getFocusListCount(); i4++) {
Akeychat.UserPrivateWithString focusList = userPrivateSyncResponse.getWithProperties().getFocusList(i4);
String withId3 = focusList.getWithId();
String value2 = focusList.getValue();
Group groupBySimpleName2 = df.getInstance().getGroupBySimpleName(withId3.split("@")[0]);
if (groupBySimpleName2 != null) {
Log.i("AKCoreService", "modify.group:" + groupBySimpleName2.getSimpleName() + ",focus list:" + value2);
groupBySimpleName2.setmAttentionList(JSON.parseArray(value2));
df.getInstance().updateGroupAttentionListInDB(groupBySimpleName2);
}
}
}
}
if (userPrivateSyncResponse.hasDelwithproperties()) {
Log.w("AKCoreService", "presence delete:" + userPrivateSyncResponse.getDelwithproperties().toString());
if (userPrivateSyncResponse.getDelwithproperties().getDelpushstatuswithCount() > 0) {
for (int i5 = 0; i5 < userPrivateSyncResponse.getDelwithproperties().getDelpushstatuswithCount(); i5++) {
String delpushstatuswith = userPrivateSyncResponse.getDelwithproperties().getDelpushstatuswith(i5);
if (!delpushstatuswith.contains("_")) {
User userInfoByName = nf.getInstance().getUserInfoByName(nf.getInstance().getUserNameByJid(delpushstatuswith), false, false);
if (userInfoByName != null) {
userInfoByName.setPushStatus(false);
Log.i("AKCoreService", "delete.user:" + userInfoByName.getName() + ",pushStatus:" + userInfoByName.getPushStatus());
}
} else {
Group groupBySimpleName3 = df.getInstance().getGroupBySimpleName(delpushstatuswith.split("@")[0]);
if (groupBySimpleName3 != null) {
groupBySimpleName3.setPushStatus(false);
Log.i("AKCoreService", "delete.group:" + groupBySimpleName3.getSimpleName() + ",pushStatus:" + groupBySimpleName3.getPushStatus());
}
}
}
}
if (userPrivateSyncResponse.getDelwithproperties().getDelaliaswithCount() > 0) {
for (int i6 = 0; i6 < userPrivateSyncResponse.getDelwithproperties().getDelaliaswithCount(); i6++) {
User userInfoByName2 = nf.getInstance().getUserInfoByName(userPrivateSyncResponse.getDelwithproperties().getDelaliaswith(i6), false, false);
if (userInfoByName2 != null) {
userInfoByName2.setRemarkNickName("");
Log.i("AKCoreService", "delete.user:" + userInfoByName2.getName() + ",alias:" + userInfoByName2.getRemarkNickName());
}
}
}
if (userPrivateSyncResponse.getDelwithproperties().getDelfocusListwithCount() > 0) {
for (int i7 = 0; i7 < userPrivateSyncResponse.getDelwithproperties().getDelfocusListwithCount(); i7++) {
Group groupBySimpleName4 = df.getInstance().getGroupBySimpleName(userPrivateSyncResponse.getDelwithproperties().getDelfocusListwith(i7));
if (groupBySimpleName4 != null) {
groupBySimpleName4.setmAttentionList(JSON.parseArray(""));
Log.i("AKCoreService", "delete.group:" + groupBySimpleName4.getSimpleName() + ",focuslist:" + groupBySimpleName4.getmAttentionList());
}
}
}
}
SyncManager.getSingleton().generateUserMePrivateInfoSyncResponse(userPrivateSyncResponse);
if (userPrivateSyncResponse.hasSecModeSwitchHidden()) {
j4.sendEvent(new s5(1, userPrivateSyncResponse.getSecModeSwitchHidden()));
}
if (userPrivateSyncResponse.hasSendRecvReadReceipts()) {
j4.sendEvent(new u3(1, userPrivateSyncResponse.getSendRecvReadReceipts()));
}
if (userPrivateSyncResponse.hasSendDestroyReceipts()) {
j4.sendEvent(new u3(2, userPrivateSyncResponse.getSendDestroyReceipts()));
}
if (userPrivateSyncResponse.hasShowReceiptsLabel()) {
j4.sendEvent(new u3(4, userPrivateSyncResponse.getShowReceiptsLabel()));
}
if (userPrivateSyncResponse.hasAkeyidsearch()) {
j4.sendEvent(new u3(5, userPrivateSyncResponse.getAkeyidsearch()));
}
if (userPrivateSyncResponse.hasPhonesearch()) {
j4.sendEvent(new u3(6, userPrivateSyncResponse.getPhonesearch()));
}
SyncManager.getSingleton().updateSyncInfo("my_private_info", userPrivateSyncResponse.getVersioncode());
} else {
Log.i("AKCoreService", "sync my pri all");
int syncMyPrivateInfo = SyncManager.getSingleton().syncMyPrivateInfo(userPrivateSyncResponse.getVersioncode());
Log.i("AKCoreService", "sync my info ret:" + syncMyPrivateInfo);
}
}
private kotlin.v O(String str, AKCDiscoverGlobal.DiscoverServerResponse discoverServerResponse, Boolean bool) {
Log.w("AKCoreService", "discover end, is refreshedServer?:" + bool + ",error code:" + discoverServerResponse.getError().getCode());
AKCDiscoverInstance queryDiscoverInstanceBy = AKCDiscoverInstance.Companion.queryDiscoverInstanceBy(ye.getInstance().getServerId());
if (bool.booleanValue() && AKApplication.isAppHadLogin() && queryDiscoverInstanceBy != null) {
queryDiscoverInstanceBy.recordReport(2);
}
int i2 = -1;
if (discoverServerResponse.getError().getCode() == -1) {
ye.getInstance().setAndSaveServerInfo(discoverServerResponse.getServer());
j0(str);
} else {
XMPPConnectionManager.a.getInstance().setDoLogin(false);
Log.d("lwxx", "login error code:" + discoverServerResponse.getError().getCode() + ",Description:" + discoverServerResponse.getError().getDescription());
if (discoverServerResponse.getError().getCode() == 600000) {
j4.sendEvent(new FindBoxFailedEvent(1, discoverServerResponse.getError().getDescription()));
if (AKApplication.isAppHadLogin()) {
ye.getInstance().setBoxOffLine(true);
}
return null;
}
int i3 = 911;
if (bool.booleanValue()) {
if (!DiscoverExtKt.ServerInvalid(discoverServerResponse.getError().getCode()) && !DiscoverExtKt.ServerErr(discoverServerResponse.getError().getCode())) {
Log.i("AKCoreService", "IN RECONNECTING:" + str);
v0(str);
} else if (discoverServerResponse.getError().getCode() == 65538) {
j4.sendEvent(new w1(AKCDiscoverGlobal.AKCDiscoverError_ServerStoped, discoverServerResponse.getError().getDescription()));
} else if (AKApplication.isAppHadLogin()) {
j4.sendEvent(new w1(403, discoverServerResponse.getError().getDescription()));
} else {
j4.sendEvent(new w1(911, discoverServerResponse.getError().getDescription()));
}
} else {
String description = discoverServerResponse.getError().getDescription();
if (TextUtils.isEmpty(description)) {
description = getString(b2.unknow_error);
}
if (DiscoverExtKt.ServerInvalid(discoverServerResponse.getError().getCode()) || DiscoverExtKt.ServerErr(discoverServerResponse.getError().getCode())) {
int code = discoverServerResponse.getError().getCode();
if (code == 65538) {
i2 = code;
}
} else if (queryDiscoverInstanceBy != null) {
queryDiscoverInstanceBy.recordReport(1);
}
if (i2 >= 0) {
i3 = i2;
} else if (discoverServerResponse.getError().getCode() == 600001) {
i3 = 1001;
} else if (DiscoverExtKt.TLSErrors(discoverServerResponse.getError().getCode())) {
i3 = 1002;
} else if (AKApplication.isAppHadLogin()) {
i3 = discoverServerResponse.getError().getCode();
}
j4.sendEvent(new w1(i3, description));
}
}
return null;
}
public static kotlin.v Q(kotlin.jvm.b.p pVar, AKCDiscoverGlobal.DiscoverServerResponse discoverServerResponse) {
return (kotlin.v) pVar.invoke(discoverServerResponse, Boolean.TRUE);
}
public static void R(AKeyDialog aKeyDialog, final kotlin.jvm.b.p pVar, View view) {
aKeyDialog.dismiss();
AKCDiscoverManager.a.getInstance().refreshServer(new kotlin.jvm.b.l() {
@Override
public final Object invoke(Object obj) {
return AKCoreService.Q(kotlin.jvm.b.p.this, (AKCDiscoverGlobal.DiscoverServerResponse) obj);
}
}, false);
}
public void T(Activity activity, AKeyDialog aKeyDialog, View view) {
XMPPConnectionManager.a.getInstance().setDoLogin(false);
AKCDiscoverInstance queryDiscoverInstanceBy = AKCDiscoverInstance.Companion.queryDiscoverInstanceBy(ye.getInstance().getServerId());
if (queryDiscoverInstanceBy != null && queryDiscoverInstanceBy.getBestAccessServerNetInfo() != -1) {
queryDiscoverInstanceBy.getServer_net_info().get(queryDiscoverInstanceBy.getBestAccessServerNetInfo()).reSet(ye.getInstance().getServerId());
queryDiscoverInstanceBy.save();
}
this.k = 0;
f1289d = 0;
if (activity instanceof AKeyLauncherActivity) {
j4.sendEvent(new e5());
aKeyDialog.dismiss();
return;
}
aKeyDialog.dismiss();
new q1(activity, 1, false, true, (AccountInfo) null).start();
}
public static kotlin.v U(kotlin.jvm.b.p pVar, AKCDiscoverGlobal.DiscoverServerResponse discoverServerResponse) {
return (kotlin.v) pVar.invoke(discoverServerResponse, Boolean.TRUE);
}
public static kotlin.v V(kotlin.jvm.b.p pVar, AKCDiscoverGlobal.DiscoverServerResponse discoverServerResponse) {
return (kotlin.v) pVar.invoke(discoverServerResponse, Boolean.FALSE);
}
public void Y(Long l2) throws Exception {
try {
Log.i("AKCoreService", "start init time");
f4.initTimeRecorder();
} catch (InterruptedException unused) {
Log.w("AKCoreService", "timer init is interrupted");
} catch (Exception unused2) {
}
l0();
Log.i("AKCoreService", "after init folder");
}
public static Long a0(Long l2) throws Exception {
while (VoIpManager.getInstance().getmCurrentCall() != null) {
Thread.sleep(5000L);
}
return l2;
}
public void c0(Long l2) throws Exception {
if (this.A) {
stopForeground(true);
BadgeManager.getSingleton().clearBadge(this.g);
Process.killProcess(Process.myPid());
}
}
public void f0(String str, String str2, String str3, boolean z, String str4, String str5) {
HashMap hashMap = new HashMap();
if (z) {
Log.i("AKCoreService", "upload ok resUrl success :" + str5);
ye.getInstance().saveCollect_log(null);
l4.deleteFile(str4);
hashMap.put("collect_id", str);
hashMap.put("status", "success");
hashMap.put("logurl", str5);
} else if (str4 != null) {
Log.i("AKCoreService", "upload log to qi niu failed");
q0(str, str2, str3);
l4.deleteFile(str4);
return;
} else {
Log.i("AKCoreService", "no log to upload");
hashMap.put("collect_id", str);
hashMap.put("status", "log lost");
}
m0(hashMap);
}
public static void g0(Long l2) throws Exception {
try {
Log.i("AKCoreService", "start init time");
f4.initTimeRecorder();
} catch (InterruptedException unused) {
Log.w("AKCoreService", "timer init is interrupted");
}
Log.i("AKCoreService", "after init folder");
}
public static int getRetryTimes() {
f1289d = AKCAppConfiguration.a.connRetries();
return f1289d;
}
public static void h0(long j2, Long l2) throws Exception {
long uptimeMillis = SystemClock.uptimeMillis();
long j3 = uptimeMillis - AKApplication.B;
Log.i("AKCoreService", "current time is " + uptimeMillis + "," + j3 + "," + j2);
if (j3 >= j2) {
if (!AKApplication.i) {
try {
Log.i("AKCoreService", "SwitchToForegroundOrBackgroundEvent to back,check sip");
int i2 = 0;
while (true) {
if (VoIpManager.getInstance().getmCurrentCall() != null) {
if (i2 > 60 && !VoIpManager.getInstance().getmCurrentCall().hasMedia()) {
Log.e("AKCoreService", "SwitchToForegroundOrBackgroundEvent call is not null break");
break;
} else {
Thread.sleep(1000L);
i2++;
}
} else {
break;
}
}
Log.i("AKCoreService", "SwitchToForegroundOrBackgroundEvent to back prepare is leaveStatus :" + AKApplication.i);
if (AKApplication.i) {
return;
}
XMPPConnectionManager.a aVar = XMPPConnectionManager.a;
if (aVar.getInstance().isEffective()) {
aVar.getInstance().reconnect(false);
return;
}
return;
} catch (Exception e2) {
Log.e("AKCoreService", "SwitchToForegroundOrBackgroundEvent timerForLeaveStatus failed,e is " + e2.getMessage());
return;
}
}
Log.e("AKCoreService", "SwitchToForegroundOrBackgroundEvent current isLeaveStatus drop ");
return;
}
Log.i("AKCoreService", "SwitchToForegroundOrBackgroundEvent to back wrong");
}
private void i0(final String str) throws Exception {
y endCheckAction;
Log.i("AKCoreService", "login,thread:" + Thread.currentThread().getName());
XMPPConnectionManager.a aVar = XMPPConnectionManager.a;
if (aVar.getInstance().isEffective()) {
Log.w("AKCoreService", "is effective do not continue");
aVar.getInstance().setDoLogin(false);
return;
}
Server server = ye.getInstance().getServer();
String serverId = ye.getInstance().getServerId();
Log.i("AKCoreService", "server address is not available,query and parse.");
if (TextUtils.isEmpty(serverId)) {
Log.d("AKCoreService", "serverId is null , stop login");
j4.sendEvent(new w1(911, getString(b2.pls_choose_a_server)));
aVar.getInstance().setDoLogin(false);
return;
}
Log.i("AKCoreService", "server address is available or is auto login we login directly,is auto login:" + str);
int retryTimes = f1289d == 0 ? getRetryTimes() : f1289d;
XMPPConnectionManager aVar2 = aVar.getInstance();
AbstractXMPPConnection connection = aVar2.getConnection();
Log.i("AKCoreService", "discoverserverGetFailedCount is " + this.k + ",limi is " + retryTimes);
final kotlin.jvm.b.p pVar = new kotlin.jvm.b.p() {
@Override
public final Object invoke(Object obj, Object obj2) {
AKCoreService.this.P(str, (AKCDiscoverGlobal.DiscoverServerResponse) obj, (Boolean) obj2);
return null;
}
};
int i2 = this.k;
if (i2 > 1 && i2 % retryTimes == 0) {
if (AKCCheckPoint.isChecking("CHECKPOINT_LOGIN") != null && this.k <= retryTimes * 2 && (endCheckAction = AKCCheckPoint.endCheckAction("CHECKPOINT_LOGIN")) != null) {
HashMap<String, String> hashMap = new HashMap<String, String>() {
{
put("ls", "0");
}
};
Map<String, String> customInfo = AKCCheckPoint.getCustomInfo("CHECKPOINT_LOGIN");
if (customInfo != null) {
hashMap.putAll(customInfo);
} else {
hashMap.put("fr", "1");
}
Log.d("AKCoreService", "login fail info:" + hashMap.toString());
AKCCheckPoint.aliyunLog(endCheckAction.info(hashMap), AKCCheckPoint.AKCSLSLogTopic.AKCSLSLogTopic_LOGIN.getValue());
}
if (connection != null) {
aVar2.destroy(true);
}
if (!AKApplication.isAppHadLogin()) {
Log.i("AKCoreService", "IN LAUNCH AUTO LOGIN");
final Activity topActivity = AKApplication.getTopActivity();
if (topActivity != null && !topActivity.isFinishing() && !AKApplication.f139b) {
Log.i("lwxid-log", this.k + "次xmpp链接失败,提示用户重连");
final AKeyDialog aKeyDialog = new AKeyDialog(topActivity);
aKeyDialog.setTip(getString(b2.login_failed_hint_22));
aKeyDialog.setPositiveButton(getString(b2.retry), new View.OnClickListener() {
@Override
public final void onClick(View view) {
AKCoreService.R(AKeyDialog.this, pVar, view);
}
});
aKeyDialog.setNegativeButton(getString(b2.cancel), new View.OnClickListener() {
@Override
public final void onClick(View view) {
AKCoreService.this.T(topActivity, aKeyDialog, view);
}
});
aKeyDialog.setCanceledOnTouchOutside(false);
topActivity.runOnUiThread(new Runnable() {
@Override
public final void run() {
AKeyDialog.this.show();
}
});
return;
}
}
AKCDiscoverManager.a.getInstance().refreshServer(new kotlin.jvm.b.l() {
@Override
public final Object invoke(Object obj) {
return AKCoreService.U(kotlin.jvm.b.p.this, (AKCDiscoverGlobal.DiscoverServerResponse) obj);
}
}, true);
return;
}
if (!AKApplication.f139b && AKCCheckPoint.isChecking("CHECKPOINT_LOGIN") == null) {
AKCCheckPoint.initCheckAction("CHECKPOINT_LOGIN");
}
Integer num = 2;
if (!server.isEffective()) {
num = 1;
}
Log.d("AKCoreService", "+++" + serverId + "**" + DiscoverExtKt.ServerGetPolicyF(num.intValue()));
AKCDiscoverManager.a.getInstance().getServer(serverId, num.intValue(), new kotlin.jvm.b.l() {
@Override
public final Object invoke(Object obj) {
return AKCoreService.V(kotlin.jvm.b.p.this, (AKCDiscoverGlobal.DiscoverServerResponse) obj);
}
}, false);
}
private void j0(String str) {
String username = ye.getInstance().getUsername();
this.q = System.currentTimeMillis();
Log.i("AKCoreService", "check-user name:" + username);
if (a0.isNetWorkAvailableInPhysical()) {
u0(str);
return;
}
Log.w("AKCoreService", "network is unavailable");
XMPPConnectionManager.a aVar = XMPPConnectionManager.a;
aVar.getInstance().increaseLoginFailedTimes();
j4.sendEvent(new w1(913, null));
aVar.getInstance().setDoLogin(false);
}
public void k0(String str, String str2, String str3) {
Log.i("AKCoreService", "make_unstablechat_call_ >");
Message unStableChatCtrlMessage = mf.getIntance().getUnStableChatCtrlMessage(str3, str2, str, CtrlMessage.LAUNCH_UNSTABLECHAT_IN);
if (unStableChatCtrlMessage != null) {
Log.i("AKCoreService", "make_unstablechat_call_ ===");
Intent intent = new Intent(p1.T);
intent.putExtra(UnStableChatStatusReceiver.a, new UnStableCallInfo(str2, "callstate_calling", str3));
sendBroadcast(intent);
MessageManager.addHandlerIntoSender(new a2(unStableChatCtrlMessage));
if (this.h != null) {
new Thread(new l(str, str2, str3)).start();
new Thread(new k(this, str, str2, str3, null)).start();
}
}
Log.i("AKCoreService", "make_unstablechat_call_ <");
}
private void l0() {
if (ye.getInstance().isOnline()) {
Log.i("AKCoreService", "stop maybeLogin,is online is true");
return;
}
this.p = new h();
z.just("").map(new i()).subscribeOn(io.reactivex.w0.a.io()).observeOn(io.reactivex.q0.c.a.mainThread()).subscribe(this.p);
}
public void m0(Map<String, String> map) {
String str = "https://" + ye.getInstance().getServer().getAppSrvHost() + ":" + ye.getInstance().getServer().getAppSrvPort() + CookieSpec.PATH_DELIM;
y.b okHttpClientBuilder = HttpURLTools.getOkHttpClientBuilder(str, ye.getInstance().getAccessToken(), false);
okHttpClientBuilder.addInterceptor(new g0(3));
((ak.i.u) new m.b().baseUrl(str).client(okHttpClientBuilder.build()).addCallAdapterFactory(retrofit2.adapter.rxjava2.g.create()).addConverterFactory(retrofit2.p.a.a.create()).build().create(ak.i.u.class)).notifyResult(map).subscribeOn(io.reactivex.w0.a.io()).subscribe(new c(map));
}
private void n0() {
EventBus.getDefault().register(this);
}
private void o0() {
if (this.v == null) {
this.v = new UnStableChatStatusReceiver();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(p1.T);
this.g.registerReceiver(this.v, intentFilter);
}
}
public void p0(String str) {
ye.getInstance().saveReSendCollectLogNotice(str);
}
private void q0(String str, String str2, String str3) {
org.json.JSONObject jSONObject = new org.json.JSONObject();
try {
jSONObject.put("start_time", str2);
jSONObject.put("end_time", str3);
jSONObject.put("collect_id", str);
ye.getInstance().saveCollect_log(jSONObject.toString());
} catch (JSONException e2) {
e2.printStackTrace();
}
}
public void r0(int i2, int i3) {
showToast(getString(i2), i3);
}
private void s0(String str) {
showToast(str, 0);
}
private void t() {
B();
MessageManager.addHandlerIntoSender(new y0());
MessageManager.addHandlerIntoSender(new b0() {
@Override
public final void execute() {
AKCoreService.D();
}
});
MessageManager.addHandlerIntoSender(new b0() {
@Override
public final void execute() {
mf.getIntance().checkUnstablePush();
}
});
b0 v = v();
if (v != null) {
MessageManager.addHandlerIntoSender(v);
}
A();
}
private void t0(long j2) {
try {
Thread.sleep(j2);
} catch (InterruptedException e2) {
e2.printStackTrace();
}
}
private void u(final ChatMessage chatMessage) {
if (ye.getInstance().needCheckSensitive()) {
final AKSessionBean aKSession = SessionManager.getInstance().getAKSession(chatMessage.getWith());
String uniqueId = chatMessage.getUniqueId();
this.G = new b(uniqueId);
z.just(uniqueId).map(new io.reactivex.s0.o() {
@Override
public final Object apply(Object obj) {
return AKCoreService.this.G(chatMessage, (String) obj);
}
}).map(new io.reactivex.s0.o() {
@Override
public final Object apply(Object obj) {
return AKCoreService.this.I(aKSession, chatMessage, (String[]) obj);
}
}).subscribeOn(io.reactivex.w0.a.io()).subscribe(this.G);
}
}
@SuppressLint({"CheckResult"})
private void u0(String str) {
Log.i("AKCoreService", "startLoginProgress:" + AKApplication.isAppHadLogin());
boolean isAppHadLogin = AKApplication.isAppHadLogin();
stopFindIdTimer();
AKApplication.setNeedTimerToFindID(false);
Log.i("AKCoreService", "start login progress,current thread:" + Thread.currentThread().getName());
if (!e3.isAutoLogin(str) && !ye.getInstance().h1) {
int pwdSaveValidDate = ye.getInstance().getPwdSaveValidDate();
if (pwdSaveValidDate > 0) {
ye.getInstance().updatePwdSaveValidDate(pwdSaveValidDate).subscribeOn(io.reactivex.w0.a.io()).subscribe();
}
} else if (ye.getInstance().isPwdInvalid()) {
Log.i("AKCoreService", "pwd invalid do not auto login");
ye.getInstance().clearPwdInSharedPref();
XMPPConnectionManager.a.getInstance().setDoLogin(false);
j4.sendEvent(new w1(441, getString(b2.pwd_invalid)));
return;
}
boolean handleEnvironmentDetect = handleEnvironmentDetect();
int loginCode = XMPPConnectionManager.getLoginCode();
if (handleEnvironmentDetect | (902 == loginCode)) {
XMPPConnectionManager.a.getInstance().setDoLogin(false);
Log.w("AKCoreService", "forbidden go on:" + loginCode);
return;
}
if (((903 == loginCode) | (403 == loginCode) | (900 == loginCode) | (901 == loginCode) | (483 == loginCode) | (401 == loginCode) | (13 == loginCode) | (814 == loginCode) | (815 == loginCode) | (816 == loginCode) | (12 == loginCode)) && AKApplication.isAppHadLogin()) {
Log.w("AKCoreService", "for login code is:" + loginCode + ",forbidden login");
XMPPConnectionManager.a.getInstance().setDoLogin(false);
return;
}
f1288c = System.currentTimeMillis();
XMPPConnectionManager.a aVar = XMPPConnectionManager.a;
XMPPConnectionManager aVar2 = aVar.getInstance();
AbstractXMPPConnection connection = aVar2.getConnection();
if (connection != null) {
String host = connection.getHost();
Server server = ye.getInstance().getServer();
String xmppIP = server == null ? null : server.getXmppIP();
Log.i("AKCoreService", "check need reset connection,currentHost:" + host + ",srv:" + server.toString());
if (xmppIP != null && !xmppIP.equals(host) && !Server.PROTOCOL_BOSH.equals(server.getAkSmackProtocol())) {
Log.w("AKCoreService", "we detected that server host is different with initialized host so we need destroy xmpp and re init it,h1:" + xmppIP + ",h2:" + host);
aVar2.destroy(true);
} else {
Log.i("AKCoreService", "xmpp configuration is not changed so we just reconnect directly");
}
}
aVar2.unregisterConnectionChangeListeners();
aVar2.registerConnectionChangeListener(new AKConnectedListener(getApplicationContext()));
try {
aVar.getInstance().reconnect("manual_login".equals(str));
f1289d = 0;
this.k = 0;
C();
if (!f4.isInternetTimeRight()) {
z.timer(0L, TimeUnit.MILLISECONDS, io.reactivex.w0.a.io()).subscribe(new io.reactivex.s0.g() {
@Override
public final void accept(Object obj) {
AKCoreService.g0((Long) obj);
}
});
}
Log.i("AKCoreService", "current id is " + ye.getInstance().getServerId() + "***" + af.getInstance().getCurrentEnterpriseInfo().discoverServerIP);
StringBuilder sb = new StringBuilder();
sb.append("startLoginProgress end, loginType:");
sb.append(str);
Log.d("AKCoreService", sb.toString());
x(isAppHadLogin);
} catch (Exception e2) {
Log.i("AKCoreService", "login - exception:" + e2.getMessage());
XMPPConnectionManager.a aVar3 = XMPPConnectionManager.a;
aVar3.getInstance().increaseLoginFailedTimes();
AkeyChatUtils.logException(e2);
aVar3.getInstance().setDoLogin(false);
AKApplication.isAppHadLogin();
long j2 = AKApplication.f139b ? 5000L : 200L;
if ((!(e2 instanceof SmackException) || (e2 instanceof AKLoginException)) && !(e2 instanceof SSLHandshakeException) && !(e2 instanceof SocketTimeoutException)) {
if (e2 instanceof LoginException) {
j4.sendEvent(new w1(301, n5.getStrByResId(b2.pls_repeat_choose_server)));
} else if (!(e2 instanceof AKLoginException)) {
j4.sendEvent(new w1(-1, getString(b2.unrecoverable_error)));
}
this.k = 0;
return;
}
if (e2 instanceof SmackException.ConnectionException) {
p1.h0 = "bad";
t0(j2);
ye.getInstance().setOnline(false);
}
this.k++;
Log.i("lwxid-log", this.k + "次xmpp链接1");
v0(str);
}
}
public b0 v() {
String collect_log = ye.getInstance().getCollect_log();
if (collect_log != null) {
try {
org.json.JSONObject jSONObject = new org.json.JSONObject(collect_log);
String string = jSONObject.getString("start_time");
String string2 = jSONObject.getString("end_time");
String string3 = jSONObject.getString("collect_id");
if (string == null || string2 == null || string3 == null) {
return null;
}
return sendLogFile(string, string2, string3);
} catch (JSONException e2) {
e2.printStackTrace();
}
}
return null;
}
public void v0(String str) {
XMPPConnectionManager.a aVar = XMPPConnectionManager.a;
if (aVar.getInstance().isDoLogin()) {
Log.w("AKCoreService", "is login give up reconnect :" + str);
return;
}
if (AKApplication.f139b) {
if (!AkeyChatUtils.isIgnoringBatteryOptimizations() && !AKCAppConfiguration.a.canIgnoreBackground()) {
Log.w("AKCoreService", "app run background-stop re-connect");
return;
}
Log.i("AKCoreService", "ignore battery optimize so reconnect");
}
if (aVar.getInstance().isEffective()) {
Log.w("AKCoreService", "xmpp connection is ok,do not reconnect:" + str);
return;
}
Log.i("AKCoreService", "start reconnect thread in-" + str);
ye yeVar = ye.getInstance();
int loginCategory = yeVar.getLoginCategory();
String password = yeVar.getPassword();
if (TextUtils.isEmpty(password) && (loginCategory == 3 || loginCategory == 4)) {
password = yeVar.getLoginCode();
yeVar.setLoginCode("");
}
String loginKey = yeVar.getLoginKey();
boolean z = false;
boolean z2 = TextUtils.isEmpty(password) || TextUtils.isEmpty(loginKey);
if (!z2 || TextUtils.isEmpty(ye.getInstance().d2) || !ye.getInstance().isOneKeyLogin() || "maybeLogin".equals(str)) {
z = z2;
} else {
password = ye.getInstance().d2;
loginKey = "one_key_login_name";
}
if (z && (TextUtils.isEmpty(loginKey) || yeVar.getGetLoginCodeTimes() <= 0 || "maybeLogin".equals(str))) {
Log.w("AKCoreService", "account or pwd is empty,account is " + loginKey + ",stop reconnect");
return;
}
yeVar.n1 = loginKey;
Log.i("AKCoreService", "currentLoginPwd is " + password);
yeVar.o1 = password;
if (e3.isBelongLoginType(str)) {
z(str);
} else {
z("normal_auto_login");
}
}
private HashMap<String, String> w(HashMap<String, String> hashMap, boolean z) {
HashMap<String, String> hashMap2 = new HashMap<>();
StringBuilder sb = new StringBuilder();
String str = hashMap.get("serverID");
if (TextUtils.isEmpty(str)) {
str = "unset";
}
sb.append(str);
sb.append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
String str2 = hashMap.get("sessionID");
if (TextUtils.isEmpty(str2)) {
str2 = "unset";
}
sb.append(str2);
sb.append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
String str3 = hashMap.get("messageID");
if (TextUtils.isEmpty(str3)) {
str3 = "unset";
}
sb.append(str3);
sb.append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
String str4 = hashMap.get("chatType");
if (TextUtils.isEmpty(str4)) {
str4 = "unset";
}
sb.append(str4);
sb.append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
String str5 = hashMap.get("senderUserID");
if (TextUtils.isEmpty(str5)) {
str5 = "unset";
}
sb.append(str5);
sb.append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
if (!z) {
String str6 = hashMap.get("Result");
if (TextUtils.isEmpty(str6)) {
str6 = "unset";
}
sb.append(str6);
sb.append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
String str7 = hashMap.get("Msgs");
sb.append(TextUtils.isEmpty(str7) ? "unset" : str7);
} else {
String str8 = hashMap.get("links");
sb.append(TextUtils.isEmpty(str8) ? "unset" : str8);
}
hashMap2.put("ex", sb.toString());
return hashMap2;
}
public void w0(String str, int i2, int i3) {
if (this.E) {
return;
}
this.E = true;
if ("unknow".equals(str)) {
r0(b2.unknow_error_asim_will_exit, 1);
} else if ("conflict".equals(str)) {
r0(i2, 1);
}
z.timer(2000L, TimeUnit.MILLISECONDS, io.reactivex.w0.a.io()).subscribe(new j(i3));
}
public void x(final boolean z) {
Log.i("AKCoreService", "login success isReconnect:" + z + ",start discoveryForReconnectLogin");
AKCDiscoverManager.a.getInstance().updateServer(new kotlin.jvm.b.l() {
@Override
public final Object invoke(Object obj) {
AKCoreService.this.K(z, (AKCDiscoverGlobal.DiscoverServerResponse) obj);
return null;
}
});
}
private void x0() {
j4.unregister(this);
}
private void y() {
io.reactivex.disposables.b bVar = this.m;
if (bVar != null) {
bVar.dispose();
}
io.reactivex.disposables.b bVar2 = this.n;
if (bVar2 != null) {
bVar2.dispose();
}
ak.j.a<Long> aVar = this.o;
if (aVar != null) {
aVar.dispose();
}
ak.j.a<Object> aVar2 = this.p;
if (aVar2 != null) {
aVar2.dispose();
}
io.reactivex.disposables.b bVar3 = this.l;
if (bVar3 != null) {
bVar3.dispose();
}
ak.j.a<String> aVar3 = this.G;
if (aVar3 != null) {
aVar3.dispose();
}
stopFindIdTimer();
}
private void y0() {
UnStableChatStatusReceiver unStableChatStatusReceiver = this.v;
if (unStableChatStatusReceiver != null) {
this.g.unregisterReceiver(unStableChatStatusReceiver);
}
}
private void z(final String str) {
if (AKApplication.f139b) {
if (XMPPConnectionManager.a.getInstance().isFailedTimesOverflow() && !AkeyChatUtils.isIgnoringBatteryOptimizations()) {
Log.w("AKCoreService", "app run background and do not ignore battery optimization stop re-connect");
return;
}
Log.w("AKCoreService", "app run bg we still allow it reconnect");
}
ye.getInstance().setConstraintUnSec(false);
if (!a0.isNetWorkAvailableInPhysical()) {
Log.w("AKCoreService", "network unavailable do not login");
j4.sendEvent(new w1(913, null));
return;
}
f2 f2Var = this.t.get();
if (f2Var == null) {
f2Var = new f2();
f2Var.initilize("login-W-" + f2Var.hashCode());
this.t.set(f2Var);
}
Log.i("AKCoreService", "executeLoginTask,thread:" + Thread.currentThread().getName() + ",login-type:" + str + ",check worker:" + f2Var);
StringBuilder sb = new StringBuilder();
sb.append("1 is ");
XMPPConnectionManager.a aVar = XMPPConnectionManager.a;
sb.append(aVar.getInstance().isDoLogin());
Log.i("lwxlogin", sb.toString());
if (!aVar.getInstance().isDoLogin()) {
if (f2Var.isWorkerEmpty()) {
f2Var.addHandler(new b0() {
@Override
public final void execute() {
AKCoreService.this.M(str);
}
});
return;
} else {
Log.w("AKCoreService", "there is a login task do not add it repeat");
return;
}
}
Log.w("AKCoreService", "other br ,do not login,is logining");
}
public void z0(String str, String str2, String str3) {
Message unStableChatCtrlMessage = mf.getIntance().getUnStableChatCtrlMessage(str3, str2, str, CtrlMessage.LAUNCH_UNSTABLECHAT_ACCEPT);
if (unStableChatCtrlMessage != null) {
MessageManager.addHandlerIntoSender(new a2(unStableChatCtrlMessage));
}
}
public kotlin.v K(boolean z, AKCDiscoverGlobal.DiscoverServerResponse discoverServerResponse) {
J(z, discoverServerResponse);
return null;
}
public kotlin.v P(String str, AKCDiscoverGlobal.DiscoverServerResponse discoverServerResponse, Boolean bool) {
O(str, discoverServerResponse, bool);
return null;
}
public void akUnstableChatBroadcast(String str, String str2, String str3) {
Intent intent = new Intent(p1.T);
intent.putExtra(UnStableChatStatusReceiver.a, new UnStableCallInfo(str2, str, str3));
this.g.sendBroadcast(intent);
}
public void analysisNet(Long l2) {
ye yeVar = ye.getInstance();
try {
InetAddress byName = InetAddress.getByName("www.baidu.com");
if (!byName.isLoopbackAddress() && (byName instanceof Inet4Address)) {
Log.d("morse", "analysisNet onSuccess ");
ArrayList<String> arrayList = yeVar.y1;
arrayList.add("success" + l2);
} else {
Log.d("morse", "analysisNet onFailure 0");
ArrayList<String> arrayList2 = yeVar.y1;
arrayList2.add(StreamManagement.Failed.ELEMENT + l2);
}
} catch (Throwable th) {
Log.d("morse", "analysisNet onFailure 1 " + th);
}
}
public void asimCoreServicePostRunner(Runnable runnable, long j2) {
Handler handler = this.h;
if (handler != null) {
handler.postDelayed(runnable, j2);
}
}
public b0 generateExPrivateHandler(final Akeychat.UserPrivateSyncResponse userPrivateSyncResponse) {
return new b0() {
@Override
public final void execute() {
AKCoreService.N(Akeychat.UserPrivateSyncResponse.this);
}
};
}
public boolean handleEnvironmentDetect() {
w1 environmentDetectResult = AkeyChatUtils.getEnvironmentDetectResult(this);
if (environmentDetectResult == null) {
return false;
}
XMPPConnectionManager.a aVar = XMPPConnectionManager.a;
aVar.setmLoginCode(environmentDetectResult.a);
j4.sendEvent(environmentDetectResult);
aVar.getInstance().destroy(false);
return true;
}
@Override
public IBinder onBind(Intent intent) {
Log.i("AKCoreService", "onBind");
return this.u;
}
@Override
public void onCreate() {
super.onCreate();
Log.i("AKCoreService", "core service create ");
f = true;
this.w = true;
MessageManager.initWorker();
this.g = this;
XMPPConnectionManager.a.getInstance().setDoLogin(false);
this.h = new Handler();
this.i = MessageListenerManger.getInstance();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("android.intent.action.MEDIA_SHARED");
intentFilter.addAction(a);
intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
intentFilter.addAction(p1.f615c);
intentFilter.addAction(p1.r);
intentFilter.addAction(p1.t);
intentFilter.addAction(p1.x);
intentFilter.addAction(p1.z);
intentFilter.addAction(p1.w);
intentFilter.addAction(p1.v);
intentFilter.addAction(p1.A);
intentFilter.addAction(ABKeySettingActivity.a);
intentFilter.addAction(p1.q);
intentFilter.addAction(p1.O);
intentFilter.addAction(p1.B);
intentFilter.addAction(p1.Q);
intentFilter.addAction(p1.C);
intentFilter.addAction(p1.S);
intentFilter.addAction(p1.E);
intentFilter.addAction(p1.P);
intentFilter.addAction(p1.D);
intentFilter.addAction(p1.y);
intentFilter.addAction(ak.im.g2.a.a.f);
intentFilter.addAction("android.intent.action.CLOSE_SYSTEM_DIALOGS");
intentFilter.addAction("android.intent.action.SCREEN_OFF");
intentFilter.addAction("android.intent.action.USER_PRESENT");
intentFilter.addAction(f1287b);
registerReceiver(this.s, intentFilter);
SimStateReceiver simStateReceiver = this.j;
registerReceiver(simStateReceiver, simStateReceiver.getFilter());
MessageManager.addHandlerIntoSender(new b0() {
@Override
public final void execute() {
AKeyManager.getInstance().init();
}
});
o0();
n0();
if (!f4.isInternetTimeRight()) {
z.timer(0L, TimeUnit.MILLISECONDS, io.reactivex.w0.a.io()).subscribe(new io.reactivex.s0.g() {
@Override
public final void accept(Object obj) {
AKCoreService.this.Y((Long) obj);
}
});
} else {
l0();
}
ye.getInstance().uploadBlackListErrorToOSS();
ye.getInstance().loadBlackListFromServer();
TimeUnit timeUnit = TimeUnit.SECONDS;
this.n = z.timer(7L, timeUnit, io.reactivex.w0.a.io()).subscribe(new io.reactivex.s0.g() {
@Override
public final void accept(Object obj) {
Long l2 = (Long) obj;
ye.getInstance().uploadBlackListToServer(null);
}
});
Log.i("AKCoreService", "AKApplication.isForegroundService " + AKApplication.r);
if (AKApplication.r && Build.VERSION.SDK_INT >= 26) {
ye.getInstance().setHadStartForeground(true);
gf gfVar = gf.getInstance();
startForeground(12, gfVar.dispatchVoipCallNotify(this, getString(b2.app_name) + getString(b2.app_run_bg_hint), 12));
if (!ye.getInstance().isOpenForeground()) {
this.o = new f();
z.timer(60L, timeUnit).map(new io.reactivex.s0.o() {
@Override
public final Object apply(Object obj) {
Long l2 = (Long) obj;
AKCoreService.a0(l2);
return l2;
}
}).subscribeOn(io.reactivex.w0.a.io()).observeOn(io.reactivex.q0.c.a.mainThread()).subscribe(this.o);
}
} else {
ye.getInstance().setHadStartForeground(false);
}
this.m = z.interval(10L, 10L, TimeUnit.MINUTES).observeOn(io.reactivex.w0.a.io()).subscribe(new g());
}
@Override
@SuppressLint({"CheckResult"})
public void onDestroy() {
super.onDestroy();
y();
ye.getInstance().setHadStartForeground(false);
Log.i("AKCoreService", "onDestroy");
AKCCheckPoint.endCheckAction("CHECKPOINT_LOGIN");
y0();
x0();
f2 f2Var = this.t.get();
if (f2Var != null) {
f2Var.destroy();
}
gf.getInstance().clearAllMessageNotify();
unregisterReceiver(this.s);
unregisterReceiver(this.j);
Intent intent = new Intent(getApplicationContext(), KeepLiveReceiver.class);
Context applicationContext = getApplicationContext();
int i2 = Build.VERSION.SDK_INT;
PendingIntent broadcast = PendingIntent.getBroadcast(applicationContext, 0, intent, i2 >= 23 ? 201326592 : 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(NotificationCompat.CATEGORY_ALARM);
if (alarmManager != null && i2 >= 23) {
Log.debug("AKCoreService", "设置一次性");
try {
alarmManager.set(2, SystemClock.elapsedRealtime() + 5000, broadcast);
} catch (Exception e2) {
Log.e("AKCoreService", "onDestroy alarmMgr set error , " + e2.getMessage());
}
}
if (this.w) {
if (ye.getInstance().isOpenForeground() && Build.VERSION.SDK_INT >= 26) {
Log.i("AKCoreService", "needRestartMyself isOpenForeground");
Intent intent2 = new Intent(this, AKCoreService.class);
intent2.putExtra("launch-mode", "auto_login");
try {
startForegroundService(intent2);
return;
} catch (Exception e3) {
e3.printStackTrace();
}
}
if (AKApplication.f139b && Build.VERSION.SDK_INT >= 26) {
Log.w("AKCoreService", "run bg do not start service");
return;
}
Intent intent3 = new Intent(this, AKCoreService.class);
intent3.putExtra("launch-mode", "auto_login");
try {
startService(intent3);
return;
} catch (Exception e4) {
e4.printStackTrace();
return;
}
}
Log.i("AKCoreService", "clear name:" + this.x + ",clear pwd:" + this.y + ",needKillPro:" + this.A + ",need clear data:" + this.z);
if (this.z) {
String userRootPath = l4.getUserRootPath();
Log.i("AKCoreService", "delete file path:" + userRootPath);
l4.deleteFile(userRootPath);
l4.deleteFile(l4.getSandBoxPath());
String username = ye.getInstance().getUsername();
if (!TextUtils.isEmpty(username)) {
try {
File encryptedDatabasePath = ak.db.d.getEncryptedDatabasePath(this, username);
l4.deleteFile(encryptedDatabasePath);
l4.deleteFile(l4.getDownloadPath(this));
boolean checkPathValid = l4.checkPathValid(userRootPath);
Log.w("AKCoreService", "after delete folder,ret:" + checkPathValid);
boolean checkPathValid2 = l4.checkPathValid(encryptedDatabasePath.getAbsolutePath());
Log.w("AKCoreService", "after delete db-file:" + encryptedDatabasePath.getAbsolutePath() + ",ret:" + checkPathValid2);
} catch (Exception e5) {
e5.printStackTrace();
}
}
}
if (this.x) {
ye.getInstance().setUsername(null);
ye.getInstance().setCountryCode(null);
}
if (this.y) {
ye.getInstance().setPassword(null);
ye.getInstance().setEncryptedPassword(null);
AkeyChatUtils.cancelConnectivityJobScheduler();
CookieManager.getInstance().removeAllCookie();
}
ye.getInstance().saveCollect_log(null);
ye.getInstance().saveReSendCollectLogNotice(null);
ye.getInstance().saveLoginConfig();
if (this.r) {
Log.d("lwx", "restart");
Intent launchIntentForPackage = getPackageManager().getLaunchIntentForPackage(getPackageName());
if (launchIntentForPackage != null) {
launchIntentForPackage.addFlags(RolePrivilege.privilege_room_updateroomstatus);
startActivity(launchIntentForPackage);
} else {
Log.e("AKCoreService", "restart failed");
}
}
z.timer(0L, TimeUnit.MILLISECONDS, io.reactivex.w0.a.io()).subscribe(new io.reactivex.s0.g() {
@Override
public final void accept(Object obj) {
AKCoreService.this.c0((Long) obj);
}
});
}
@Subscribe(threadMode = ThreadMode.ASYNC)
public void onEventAsync(a6 a6Var) {
Thread currentThread = Thread.currentThread();
currentThread.setName("send-report-message-event-" + Thread.currentThread());
MessageManager.addHandlerIntoSender(new z1(a6Var.f190c, a6Var.a, a6Var.f189b));
}
@Subscribe(sticky = true, threadMode = ThreadMode.BACKGROUND)
public void onEventBackgroundThread(ak.event.l lVar) {
Log.i("AKCoreService", "onEventBackgroundThread,recv one event:" + lVar.getmEventType());
ye.getInstance().getGroupSpeakListMap().clear();
EventBus.getDefault().removeStickyEvent(lVar);
if ("start_online".equals(lVar.getmEventType())) {
t();
j4.sendEvent(g3.getInstance("start-on-line"));
long currentTimeMillis = System.currentTimeMillis();
for (int i2 = 10; !ye.getInstance().isOnline() && i2 > 0; i2--) {
try {
Thread.sleep(1000L);
} catch (InterruptedException unused) {
}
}
Log.i("AKCoreService", "wait online cost " + (System.currentTimeMillis() - currentTimeMillis));
MessageReliabilityManager.getInstance().sendOffLineMessage();
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(k7 k7Var) {
String str = k7Var.a;
if (str != null) {
s0(str);
return;
}
int i2 = k7Var.f231b;
if (i2 > 0) {
s0(getResources().getString(i2));
}
}
@Override
public int onStartCommand(Intent intent, int i2, int i3) {
Log.i("AKCoreService", "service start");
if (this.D) {
j4.sendEvent(new f0("start-check-login-in-on-start-service"));
}
this.D = true;
return 2;
}
public void resetTimes() {
Log.i("AKCoreService", "normal login ,reset times");
this.k = 0;
}
public void ringtone() {
try {
Ringtone ringtone = RingtoneManager.getRingtone(this.g, RingtoneManager.getActualDefaultRingtoneUri(this.g, 2));
Log.i("AKCoreService", "ringtone is " + ((AudioManager) this.g.getSystemService(ChatMessage.CHAT_AUDIO)).getRingerMode());
ringtone.play();
AudioAttributes.Builder builder = new AudioAttributes.Builder();
builder.setContentType(4);
builder.setUsage(5);
((Vibrator) getSystemService("vibrator")).vibrate(new long[]{0, 300, 80, 120}, -1, builder.build());
} catch (Exception e2) {
Log.i("AKCoreService", "ringtone failed , reason is " + e2.getMessage());
e2.printStackTrace();
}
}
public void sendAKBroadcast(String str) {
this.g.sendBroadcast(new Intent(str));
}
public b0 sendLogFile(final String str, final String str2, final String str3) {
return new ak.worker.w1(str3, this.g, str, str2, new s0() {
@Override
public final void onSentResult(boolean z, String str4, String str5) {
AKCoreService.this.f0(str3, str, str2, z, str4, str5);
}
});
}
public void showToast(String str, int i2) {
if (AKApplication.f139b) {
Log.w("AKCoreService", "app run bg we do not toast:" + str);
return;
}
d0.a.showToast(this.g, str, i2);
}
public void startTimerForSip(long j2, final long j3) {
this.l = z.timer(j3 - j2, TimeUnit.MILLISECONDS).subscribe(new io.reactivex.s0.g() {
@Override
public final void accept(Object obj) {
AKCoreService.h0(j3, (Long) obj);
}
});
}
public void startTimerToFindID(int i2) {
long j2 = i2;
this.F = z.interval(j2, j2, TimeUnit.MINUTES).observeOn(io.reactivex.w0.a.io()).subscribe(new a());
}
public void stopFindIdTimer() {
io.reactivex.disposables.b bVar = this.F;
if (bVar != null) {
bVar.dispose();
}
}
public void unstablechat_destroy_(String str, String str2, String str3) {
Message unStableChatCtrlMessage = mf.getIntance().getUnStableChatCtrlMessage(str3, str2, str, CtrlMessage.DESTROY_UNSTABLECHAT_IN);
if (unStableChatCtrlMessage != null) {
MessageManager.addHandlerIntoSender(new a2(unStableChatCtrlMessage));
}
}
public void unstablechat_heart_(String str, String str2, String str3) {
Message unStableChatCtrlMessage = mf.getIntance().getUnStableChatCtrlMessage(str3, str2, str, CtrlMessage.UNSTABLECHAT_HEART);
if (unStableChatCtrlMessage != null) {
MessageManager.addHandlerIntoSender(new a2(unStableChatCtrlMessage));
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(b6 b6Var) {
List<ChatMessage> list = b6Var.a;
if (list == null) {
Log.w("AKCoreService", "empty message list do not need send recv receipts ");
} else if (!ye.getInstance().getPrivacyRecvAndReadSwitch()) {
Log.w("AKCoreService", "sorry switch is off so can not send receive receipts");
} else {
for (ChatMessage chatMessage : list) {
if (IMMessage.RECV.equals(chatMessage.getDir())) {
MessageManager.addHandlerIntoRecver(new v0(chatMessage, Boolean.FALSE));
}
}
}
}
@Subscribe(threadMode = ThreadMode.ASYNC)
public void onEventAsync(d3 d3Var) {
sendAKBroadcast(p1.o);
sendAKBroadcast(p1.n);
sendAKBroadcast(p1.p);
this.i.addConnectionListener();
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(f0 f0Var) {
if (XMPPConnectionManager.a.getInstance().isEffective()) {
Log.w("AKCoreService", "xmpp is effective do not need re-connect:" + f0Var.a);
return;
}
Log.i("AKCoreService", "receive a check login event in ak-coreservice");
if (!"receiver".equals(f0Var.a) || AKApplication.isAppHadLogin()) {
v0("check_login");
}
}
@Subscribe(threadMode = ThreadMode.BACKGROUND)
public void onEventBackgroundThread(t3 t3Var) {
MessageManager.addHandlerIntoSender(new x1(t3Var.a));
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(e3 e3Var) {
String loginType = e3Var.getLoginType();
if (e3.isAutoLogin(loginType) | "manual_login".equals(loginType) | "AnyOffice".equals(loginType)) {
v0(loginType);
return;
}
Log.w("AKCoreService", "other login type handle it by yourself:" + loginType);
}
@Subscribe(threadMode = ThreadMode.MAIN)
@SuppressLint({"CheckResult"})
public void onEventMainThread(u2 u2Var) {
Log.i("AKCoreService", "check event:" + u2Var.getCome());
io.reactivex.j.timer(0L, TimeUnit.SECONDS, io.reactivex.w0.a.io()).subscribe(new io.reactivex.s0.g() {
@Override
public final void accept(Object obj) {
Long l2 = (Long) obj;
AKApplication.initRootPath();
}
});
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(ak.event.o0 o0Var) {
Log.i("AKCoreService", "need close app,reason is " + o0Var.getReason());
if (AKApplication.f139b) {
new q1(AKApplication.getTopActivity(), 1).start();
return;
}
Intent intent = new Intent(this, UserConflictActivity.class);
intent.putExtra("description", o0Var.getReason());
intent.addFlags(User.UserStatus.camera_on);
intent.addFlags(536870912);
ak.im.o1.get().startActivity(intent);
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(j5 j5Var) {
resetTimes();
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(w0 w0Var) {
stopFindIdTimer();
startTimerToFindID(w0Var.getTime());
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(y6 y6Var) {
if (this.p != null) {
Log.i("AKCoreService", "StopMaybeLoginEvent stop maybe");
this.p.dispose();
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(l5 l5Var) {
ringtone();
}
@Subscribe(threadMode = ThreadMode.ASYNC)
public void onEventMainThread(b1 b1Var) {
String str;
Object obj = b1Var.getObj();
if (obj instanceof ak.im.module.User) {
ak.im.module.User user = (ak.im.module.User) obj;
str = user.getJID();
Akeychat.E2EKeysPublicBundle e2EKeysPublicBundle = user.getmPubKeyBundle();
Akeychat.E2EIDKeyPublic identityKey = e2EKeysPublicBundle.getIdentityKey();
Log.i("DecryptFailedEvent", user.getName() + "*identityKey is " + ak.comm.d.encodeBytes(identityKey.toByteArray()));
Akeychat.E2ESignedKeyPublic signedKey = e2EKeysPublicBundle.getSignedKey();
Log.i("DecryptFailedEvent", user.getName() + "*signedKey is " + ak.comm.d.encodeBytes(signedKey.toByteArray()));
Iterator<Akeychat.E2EOneTimeKeyPublic> it = e2EKeysPublicBundle.getOneTimePreKeysList().iterator();
while (it.hasNext()) {
Log.i("DecryptFailedEvent", user.getName() + "*timeKey is " + ak.comm.d.encodeBytes(it.next().toByteArray()));
}
String username = ye.getInstance().getUsername();
Akeychat.E2EKeysPrivateBundle myKeyBundle = AKeyManager.getInstance().getMyKeyBundle();
Akeychat.E2EIDKey identityKey2 = myKeyBundle.getIdentityKey();
Log.i("DecryptFailedEvent", username + "*identityKey is " + ak.comm.d.encodeBytes(identityKey2.toByteArray()));
Akeychat.E2ESignedKey signedKey2 = myKeyBundle.getSignedKey();
Log.i("DecryptFailedEvent", username + "*signedKey is " + ak.comm.d.encodeBytes(signedKey2.toByteArray()));
Iterator<Akeychat.E2EOneTimeKey> it2 = myKeyBundle.getOneTimePreKeysList().iterator();
while (it2.hasNext()) {
Log.i("DecryptFailedEvent", username + "*timeKey is " + ak.comm.d.encodeBytes(it2.next().toByteArray()));
}
} else if (obj instanceof Group) {
Group group = (Group) obj;
str = group.getName();
Akeychat.E2EKeysPrivateBundle e2EKeysPrivateBundle = group.getmKeyBundle();
Akeychat.E2EIDKey identityKey3 = e2EKeysPrivateBundle.getIdentityKey();
Log.i("DecryptFailedEvent", group.getName() + "*timeKey is " + ak.comm.d.encodeBytes(identityKey3.toByteArray()));
Akeychat.E2ESignedKey signedKey3 = e2EKeysPrivateBundle.getSignedKey();
Log.i("DecryptFailedEvent", group.getName() + "*signedKey is " + ak.comm.d.encodeBytes(signedKey3.toByteArray()));
Iterator<Akeychat.E2EOneTimeKey> it3 = e2EKeysPrivateBundle.getOneTimePreKeysList().iterator();
while (it3.hasNext()) {
Log.i("DecryptFailedEvent", group.getName() + "*timeKey is " + ak.comm.d.encodeBytes(it3.next().toByteArray()));
}
} else {
str = "";
}
if (TextUtils.isEmpty(str)) {
return;
}
String str2 = ye.getInstance().getUsername() + str;
long j2 = ye.getInstance().getMMKV().getLong(str2, 0L);
long curDateLong = f4.getCurDateLong();
if (curDateLong - j2 >= 86400) {
ye.getInstance().getMMKV().putLong(str2, curDateLong);
try {
l4.uploadLogFile("manual");
} catch (Exception e2) {
Log.e("DecryptFailedEvent", "uploadLogFile failed");
ye.getInstance().getMMKV().putLong(str2, 0L);
e2.printStackTrace();
}
}
}
@Subscribe(sticky = true, threadMode = ThreadMode.ASYNC)
public void onEventMainThread(e7 e7Var) {
if (ye.getInstance().isIgnoreCanLeave() || !AKCAppConfiguration.a.canLeave()) {
return;
}
long time = e7Var.getTime();
EventBus.getDefault().removeStickyEvent(e7Var);
if (e7Var.isBack()) {
if (AKApplication.B != 0) {
long uptimeMillis = SystemClock.uptimeMillis();
long j2 = uptimeMillis - AKApplication.B;
Log.i("AKCoreService", "current time is " + uptimeMillis + "," + j2 + "," + time);
if (j2 >= time) {
try {
if (!AKApplication.i) {
Log.i("AKCoreService", "SwitchToForegroundOrBackgroundEvent to back,check sip");
int i2 = 0;
while (true) {
if (VoIpManager.getInstance().getmCurrentCall() != null) {
if (i2 > 60 && !VoIpManager.getInstance().getmCurrentCall().hasMedia()) {
Log.e("AKCoreService", "SwitchToForegroundOrBackgroundEvent call is not null break");
break;
} else {
Thread.sleep(1000L);
i2++;
}
} else {
break;
}
}
Log.i("AKCoreService", "SwitchToForegroundOrBackgroundEvent to back prepare is leaveStatus :" + AKApplication.i);
if (AKApplication.i) {
return;
}
XMPPConnectionManager.a.getInstance().reconnect(false);
return;
}
Log.e("AKCoreService", "SwitchToForegroundOrBackgroundEvent current isLeaveStatus drop ");
return;
} catch (Exception e2) {
AkeyChatUtils.logException(e2);
return;
}
}
io.reactivex.disposables.b bVar = this.l;
if (bVar != null && !bVar.isDisposed()) {
Log.i("AKCoreService", "SwitchToForegroundOrBackgroundEvent current timerForLeaveStatus is doing");
return;
} else {
startTimerForSip(j2, time);
return;
}
}
Log.e("AKCoreService", "current is not back ,drop SwitchToForegroundOrBackgroundEvent");
return;
}
io.reactivex.disposables.b bVar2 = this.l;
if (bVar2 != null) {
bVar2.dispose();
}
if (AKApplication.i) {
XMPPConnectionManager.a aVar = XMPPConnectionManager.a;
if (aVar.getInstance().isEffective()) {
try {
Log.i("AKCoreService", "SwitchToForegroundOrBackgroundEvent to foreground");
aVar.getInstance().reconnect(false);
return;
} catch (Exception e3) {
AkeyChatUtils.logException(e3);
return;
}
}
}
if (AKApplication.f139b) {
startTimerForSip(0L, time);
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(ak.event.g0 g0Var) {
ChatMessage oneMessageByUniqueId = MessageManager.getInstance().getOneMessageByUniqueId(g0Var.getId());
if (oneMessageByUniqueId != null) {
oneMessageByUniqueId.setmSeqNO(g0Var.getSeqo());
u(oneMessageByUniqueId);
return;
}
Log.i("AKCoreService", "checkAndReportMsg msg is null");
}
}