CarrotChat v2.8.80.240429版本的 MD5 值为:fdf98761f01e715a89df24b85b0d206e
以下内容为反编译后的 AKCoreService.java 源代码,内容仅作参考
package ak.im.service;
import a.a;
import a1.a1;
import a1.b1;
import a1.c1;
import a1.d0;
import a1.d1;
import a1.e0;
import a1.e1;
import a1.k0;
import a1.l1;
import a1.p1;
import a1.r1;
import a1.s1;
import a1.x;
import a1.z;
import a1.z1;
import ak.application.AKApplication;
import ak.event.FindBoxFailedEvent;
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.LoginConfig;
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.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.b5;
import ak.im.sdk.manager.bf;
import ak.im.sdk.manager.f1;
import ak.im.sdk.manager.n3;
import ak.im.sdk.manager.s7;
import ak.im.sdk.manager.sd;
import ak.im.sdk.manager.zb;
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.utils.AkeyChatUtils;
import ak.im.utils.FileUtil;
import ak.im.utils.HttpURLTools;
import ak.im.utils.Log;
import ak.im.utils.o3;
import ak.im.utils.q5;
import ak.im.utils.s3;
import ak.im.utils.s5;
import ak.smack.AKLoginException;
import ak.view.AKeyDialog;
import ak.worker.MessageReliabilityManager;
import ak.worker.RawEncrMessageDecryptionHandler;
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 g.InitAPPPathEvent;
import g.c7;
import g.d8;
import g.e3;
import g.e6;
import g.e8;
import g.f3;
import g.f6;
import g.h0;
import g.h3;
import g.i5;
import g.i7;
import g.j2;
import g.n5;
import g.o7;
import g.p0;
import g.p5;
import g.u3;
import g.u4;
import g.v;
import g.v3;
import g.w5;
import g.x0;
import j.u0;
import j.y1;
import j0.c0;
import j0.t;
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 kd.s;
import mc.o;
import okhttp3.m;
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 org.slf4j.Marker;
import retrofit2.k;
import u0.g0;
import u0.u;
import vd.p;
import y0.w1;
@SuppressLint({"HandlerLeak"})
public class AKCoreService extends Service {
public static long H;
v0.a<String> A;
jc.b D;
v0.a<String> E;
private Context f2729a;
private jc.b f2735g;
private jc.b f2736h;
private v0.a<Long> f2737i;
private v0.a<Object> f2738j;
long f2739k;
public static final String F = "asimCoreService.restartlogin.action" + u0.f40386a;
public static String G = "AKCoreService_kill_self";
public static volatile int I = 0;
static int J = 775;
public static boolean K = false;
private Handler f2730b = null;
protected MessageListenerManger f2731c = null;
private SimStateReceiver f2732d = new SimStateReceiver();
private int f2733e = 0;
private jc.b f2734f = null;
private boolean f2740l = false;
private BroadcastReceiver f2741m = new d();
AtomicReference<ak.worker.f> f2742n = new AtomicReference<>();
private a.AbstractBinderC0000a f2743o = new e();
private UnStableChatStatusReceiver f2744p = null;
private boolean f2745q = true;
private boolean f2746r = false;
private boolean f2747s = false;
private boolean f2748t = false;
private boolean f2749u = false;
private String f2750v = "hotFixTime";
public long f2751w = 5400000;
private boolean f2752x = false;
private boolean f2753y = false;
jc.b f2754z = null;
private final Object B = new Object();
HashMap<ChatMessage, HashMap<String, String>> C = new HashMap<>();
public class a extends v0.a<String> {
final String f2764a;
a(String str) {
this.f2764a = str;
}
@Override
public void onError(Throwable th) {
th.printStackTrace();
Log.e("AKCoreService", "checkAndReportMsg failed " + th + ",id " + this.f2764a);
}
@Override
public void onNext(String str) {
Log.i("AKCoreService", "checkAndReportMsg finish " + str);
}
}
public class b extends v0.a<String> {
final int f2766a;
b(int i10) {
this.f2766a = i10;
}
@Override
public void onError(Throwable th) {
AkeyChatUtils.logException(th);
}
@Override
public void onNext(String str) {
if (TextUtils.isEmpty(str)) {
return;
}
try {
FileUtil.uploadLogFile(this.f2766a, str);
} catch (Exception e10) {
AkeyChatUtils.logException(e10);
}
}
}
public class c extends v0.a<NotifyLogUploadResultBean> {
final Map f2768a;
c(Map map) {
this.f2768a = 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.I0(null);
return;
}
JSONObject jSONObject = new JSONObject();
jSONObject.put("collect_id", this.f2768a.get("collect_id"));
jSONObject.put("status", this.f2768a.get("status"));
jSONObject.put("logurl", this.f2768a.get("logurl"));
AKCoreService.this.I0(jSONObject.toJSONString());
if (XMPPConnectionManager.INSTANCE.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.F0(this.f2768a);
} catch (InterruptedException e10) {
e10.printStackTrace();
}
}
}
public class d extends BroadcastReceiver {
d() {
}
public void b() {
AKCoreService.this.sendAKBroadcast(AKCoreService.F);
}
@Override
public void onReceive(Context context, Intent intent) {
String str;
String str2;
if (intent == null) {
Log.w("AKCoreService", "intent is null");
return;
}
a1.a aVar = null;
String action = intent.getAction();
Log.i("AKCoreService", "mAKCoreServiceReceiver rev action:" + action + ",main thread name:" + Thread.currentThread().getName());
if (AKCoreService.F.equals(action)) {
AKCoreService.this.O0(action);
} else if (u0.f40418q.equals(action)) {
AKCoreService.this.f2745q = false;
AKCoreService.this.f2746r = intent.getBooleanExtra("stop_service_need_clear_username", false);
AKCoreService.this.f2747s = intent.getBooleanExtra("stop_service_need_clear_pwd", false);
AKCoreService.this.f2748t = intent.getBooleanExtra("stop_service_need_clear_data", false);
AKCoreService.this.f2749u = intent.getBooleanExtra("need_kill_process", true);
AKCoreService.this.f2740l = intent.getBooleanExtra("need_restart", false);
AKCoreService.this.stopSelf();
} else if ("android.net.conn.CONNECTIVITY_CHANGE".equals(action)) {
f1.getInstance().loadBlackListFromServer();
f1.getInstance().uploadBlackListErrorToOSS();
t.isNetWorkAvailableInPhysical();
s3.sendEvent(h3.getInstance("cmr-action"));
if (!AKApplication.isAppHadLogin()) {
Log.i("AKCoreService", "not init Complete-in-connectity-changed.");
CallBackManager.INSTANCE.getInstance().notifyNetChanged();
return;
}
XMPPConnectionManager.Companion companion = XMPPConnectionManager.INSTANCE;
if (companion.getInstance().getIsDoLogin()) {
Log.i("AKCoreService", "IS doing login");
return;
}
AbstractXMPPConnection connection = companion.getInstance().getConnection();
if (t.isNetWorkAvailableInPhysical()) {
boolean isEffective = companion.getInstance().isEffective();
Log.i("AKCoreService", "receive network connectivity changed, is effective:" + isEffective);
if (!isEffective) {
AKCoreService.this.O0("network_accessibility_reconnect");
} else {
MessageListenerManger messageListenerManger = AKCoreService.this.f2731c;
if (!messageListenerManger.f1515b) {
messageListenerManger.initChatListener();
} else {
messageListenerManger.addMucInviteListener(connection);
}
}
} else {
Log.d("AKCoreService", "network connection is lost,should not start reconnect");
f1.getInstance().setOnline(false);
}
} else if (u0.f40390c.equals(action)) {
XMPPConnectionManager.Companion companion2 = XMPPConnectionManager.INSTANCE;
boolean isDoLogin = companion2.getInstance().getIsDoLogin();
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");
f1.getInstance().getServer().setEffective(false);
companion2.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.f2731c;
if (!messageListenerManger2.f1515b) {
messageListenerManger2.initChatListener();
} else {
messageListenerManger2.addMucInviteListener(companion2.getInstance().getConnection());
}
Log.i("UserManager", "CONNECTED 2");
aVar = AKCoreService.this.U();
AKCoreService.this.Z();
} else if ("xmpp.connecting".equals(stringExtra)) {
Log.i("AKCoreService", "rcv connecting");
if (companion2.getInstance().isEffective()) {
Log.w("AKCoreService", "xmpp connection is ok,do not reconnect: in Service");
return;
}
MessageReliabilityManager.getInstance().waitingForOnline();
f1.getInstance().setOnline(false);
Log.i("AKCoreService", "start ConnThread; reconn");
AKCoreService.this.O0("xmpp_reconnect");
}
} else if (!u0.A.equals(action) && !ABKeySettingActivity.A.equals(action)) {
if (u0.f40427x.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")) {
aVar = new z(chatMessage);
}
} else {
Log.i("AKCoreService", "send remote destroy:" + chatType);
aVar = new a1(chatMessage);
}
} else if (u0.f40428y.equals(action)) {
aVar = new d1(intent.getStringExtra(IMMessage.PROP_TYPE_CHAT), intent.getStringExtra("name"), intent.getStringArrayListExtra("destroy_msgs_id_list_key"));
} else if (u0.f40429z.equals(action)) {
if (!f1.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());
aVar = new x(chatMessage2);
}
} else {
aVar = new e0(chatMessage2);
}
} else if (u0.f40420r.equals(action)) {
ChatMessage chatMessage3 = (ChatMessage) intent.getParcelableExtra("immessage.sendfile.key.message");
AbstractXMPPConnection connection2 = XMPPConnectionManager.INSTANCE.getInstance().getConnection();
if (connection2 == null || !connection2.isAuthenticated()) {
chatMessage3.setStatus("error");
EventBus.getDefault().post(new u4(chatMessage3, false, false));
}
Log.d("AKCoreService", "send file action in single chat");
if (sd.getIntance().getmActiveUnstableChatID() != null) {
sd.getIntance().setmLastActiveMsgTime(System.currentTimeMillis());
}
aVar = MessageManager.getInstance().handleFileMsgBeforeSend(chatMessage3);
} else if (u0.f40423t.equals(action)) {
aVar = MessageManager.getInstance().handleTxtMsgBeforeSend((ChatMessage) intent.getParcelableExtra("immessage.sendmessage.key.message"), false);
} else if (u0.f40426w.equals(action)) {
aVar = new z1(intent.getStringExtra("immessage.group.key.group.name"), intent.getStringExtra("immessage.group.key.group.info"));
} else if ("android.intent.action.MEDIA_SHARED".equals(action)) {
if (FileUtil.getSDCardRootDirectory() == null) {
Log.d("AKCoreService", "sdcard switch to mass storage mode at time:" + o3.getCurDateStr() + ",which effect our APP");
s3.sendEvent(o7.newToastEvent(y1.sdcard_swtich_to_mass_storage));
} else {
Log.d("AKCoreService", "sdcard switch to mass storage mode at time:" + o3.getCurDateStr() + ",which don't effect our APP");
}
} else if (u0.O.equals(action)) {
int intExtra = intent.getIntExtra("toast_content_key", -1);
if (-1 != intExtra) {
AKCoreService.this.K0(intExtra, 0);
return;
}
String stringExtra2 = intent.getStringExtra("toast_content_string_key");
if (stringExtra2 != null) {
AKCoreService.this.showToast(stringExtra2, 0);
return;
}
} else if (u0.P.equals(action)) {
String stringExtra3 = intent.getStringExtra("delete_session_key");
if (stringExtra3 != null) {
MessageManager.addHandlerIntoSender(new l1(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 v(chatMessage4));
}
}
}
str2 = str;
if (chatMessage4 != null) {
MessageManager.getInstance().hideMessageByUniqueId(chatMessage4.getUniqueId());
EventBus.getDefault().post(new v(chatMessage4));
}
}
}
} else {
Log.d("AKCoreService", "with or type is null,with");
}
} else {
if (u0.B.equals(action)) {
String stringExtra4 = intent.getStringExtra("delete_contact_msg_key");
if (stringExtra4 != null) {
MessageManager.addHandlerIntoSender(new b1(stringExtra4));
return;
} else {
Log.w("AKCoreService", "userJid is null,user jid");
return;
}
}
if (u0.Q.equals(action)) {
Log.d("AKCoreService", "send bulk remote destroy receipt.");
return;
}
if (u0.C.equals(action)) {
Log.i("AKCoreService", "send jid bulk remote destroy receipt.");
return;
}
if (u0.D.equals(action)) {
Log.i("AKCoreService", "send room remote destroy receipt.");
return;
}
if (u0.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.P0("unknown", -1, intExtra3);
return;
} else {
AKCoreService.this.P0("conflict", intExtra2, intExtra3);
return;
}
}
if (u0.E.equals(action)) {
MessageManager.addHandlerIntoSender(new e1(intent.getStringExtra("delete_all_cipher_msg_action")));
} else {
if (p.a.f44689f.equals(action)) {
AKCoreService.this.P0("conflict", y1.jwmx_logout, -1);
return;
}
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 sb2 = new StringBuilder();
sb2.append("app unlocked,check current sipcall is null?");
sb2.append(sipCall == null);
Log.debug("AKCoreService", sb2.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.G.equals(action)) {
AKApplication.f793t = f1.getInstance().isOpenForeground();
Log.i("AKCoreService", "KILL_SELF_SERVICE " + AKApplication.f793t);
AKCoreService.this.f2745q = true;
AKCoreService.this.stopSelf();
}
} else {
Log.i("AKCoreService", "app intent to be in background status, update online status");
}
}
}
} else if (AKeyManager.getInstance().getAttachedBindingAKey() != null && bf.getInstance().getUserMe() != null) {
Log.i("AKCoreService", "now binding akey attached, start batch decryption task.");
MessageManager.addHandlerIntoRecver(new RawEncrMessageDecryptionHandler(context));
}
if (aVar != null) {
MessageManager.addHandlerIntoSender(aVar);
}
}
}
class e extends a.AbstractBinderC0000a {
e() {
}
@Override
public void make_unstablechat_call(String str, String str2, String str3) {
AKCoreService.this.D0(str, str2, str3);
}
@Override
public void unstablechat_accept(String str, String str2, String str3) {
AKCoreService.this.S0(str, str2, str3);
}
@Override
public void unstablechat_busy(String str, String str2, String str3) {
AKCoreService.this.T0(str, str2, str3);
}
@Override
public void unstablechat_config(String str, String str2, String str3) {
AKCoreService.this.U0(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.V0(str, str2, str3);
}
@Override
public void unstablechat_heart(String str, String str2, String str3) {
AKCoreService.this.unstablechat_heart_(str, str2, str3);
}
}
class f extends v0.a<Long> {
f() {
}
@Override
public void onError(Throwable th) {
Log.e("AKCoreService", "kill self error is " + th.getMessage());
}
@Override
public void onNext(Long l10) {
Log.debug("AKCoreService", "stopSelf");
Log.i("AKCoreService", "kill self success");
AKApplication.f793t = false;
AKCoreService.this.stopSelf();
}
}
public class g extends v0.a<Object> {
g() {
}
@Override
public void onError(Throwable th) {
Log.i("AKCoreService", "maybeLogin failed, e is " + th.getMessage());
}
@Override
public void onNext(Object obj) {
AKCoreService.this.O0("maybeLogin");
}
}
public class h implements o<String, Object> {
h() {
}
@Override
public Object apply(String str) throws Exception {
AKCDiscoverManager.Companion companion;
int i10 = 0;
while (true) {
companion = AKCDiscoverManager.INSTANCE;
if (companion.getInstance().getNodesHadInit() || i10 >= 25) {
break;
}
i10++;
Thread.sleep(200L);
}
if (!companion.getInstance().getNodesHadInit()) {
AKCAppConfiguration aKCAppConfiguration = AKCAppConfiguration.f9925a;
aKCAppConfiguration.initConfig();
aKCAppConfiguration.initHintConfig();
companion.getInstance().getDiscoverNodes(0).subscribe();
}
return str;
}
}
public class i extends v0.a<Long> {
final int f2775a;
i(int i10) {
this.f2775a = i10;
}
@Override
public void onComplete() {
}
@Override
public void onError(Throwable th) {
}
@Override
public void onNext(Long l10) {
Log.w("AKCoreService", ",pid:" + this.f2775a + ",my pid:" + Process.myPid());
j.a.sendStopService(false, false, true);
int i10 = this.f2775a;
if (i10 == -1) {
Process.killProcess(Process.myPid());
} else {
Process.killProcess(i10);
}
}
}
public class j implements mc.g<Long> {
j() {
}
@Override
public void accept(Long l10) throws Exception {
if (AKApplication.isNeedTimerToFindID() && XMPPConnectionManager.INSTANCE.getInstance().isEffective()) {
AKCoreService.this.W(false);
}
}
}
public class k implements Runnable {
private String f2778a;
private String f2779b;
private String f2780c;
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 e10) {
e10.printStackTrace();
}
if (this.f2780c.equalsIgnoreCase(sd.getIntance().getmActiveUnstableChatID()) && sd.getIntance().hasActiveUnstableChat(this.f2778a, this.f2779b) && !sd.getIntance().isAccepted()) {
sd.getIntance().setmActiveUnstableChatID(null);
AKCoreService.this.akUnstableChatBroadcast("callstate_recvring_outtime", this.f2779b, this.f2780c);
AKCoreService.this.V0(this.f2778a, this.f2779b, this.f2780c);
return;
}
Log.i("AKCoreService", "do not need check CheckAcceptOutTime or is not AcceptOutTime");
}
private k(String str, String str2, String str3) {
this.f2778a = str;
this.f2779b = str2;
this.f2780c = str3;
}
}
public class l implements Runnable {
private String f2782a;
private String f2783b;
private String f2784c;
l(String str, String str2, String str3) {
this.f2782a = str;
this.f2783b = str2;
this.f2784c = str3;
}
@Override
public void run() {
try {
Thread.sleep(30000L);
} catch (InterruptedException e10) {
e10.printStackTrace();
}
if (sd.getIntance().hasActiveUnstableChat(this.f2782a, this.f2783b) && this.f2784c.equals(sd.getIntance().getmActiveUnstableChatID()) && !sd.getIntance().isAccepted() && sd.getIntance().isInviteResponseOutTime(this.f2784c)) {
sd.getIntance().setmActiveUnstableChatID(null);
AKCoreService.this.akUnstableChatBroadcast("callstate_recvring_outtime", this.f2783b, this.f2784c);
} else {
Log.i("AKCoreService", "do not need check isInviteResponseOutTime or is not isInviteResponseOutTime");
}
}
}
public static String A0(Long l10) throws Exception {
String str;
String str2;
boolean z10;
String str3;
String str4 = new String(HttpURLTools.getBytesFromHttpsUrl("https://akey-app-configuration.oss-accelerate.aliyuncs.com/config/autolog.json", 3000, null, null));
Log.debug("AKCoreService", "上传日志配置:" + str4);
if (TextUtils.isEmpty(str4)) {
return "";
}
JSONObject parseObject = JSON.parseObject(str4);
Server server = f1.getInstance().getServer();
if (server == null || !parseObject.containsKey(server.getEnterpriseId())) {
str = "";
str2 = str;
} else {
try {
str2 = (String) parseObject.get(server.getEnterpriseId());
} catch (Exception unused) {
str2 = "";
}
try {
str = server.getEnterpriseId();
} catch (Exception unused2) {
str = "";
if (TextUtils.isEmpty(str2)) {
str2 = parseObject.getString("universal");
str = "universal";
}
z10 = false;
if (!TextUtils.isEmpty(str2)) {
}
Log.debug("AKCoreService", "needUpload " + z10);
if (z10) {
}
}
}
if (TextUtils.isEmpty(str2) && parseObject.containsKey("universal")) {
str2 = parseObject.getString("universal");
str = "universal";
}
z10 = false;
if (!TextUtils.isEmpty(str2)) {
if (!str2.contains(Marker.ANY_MARKER)) {
LoginConfig loginConfig = f1.getInstance().getmLoginCfg();
Log.debug("AKCoreService", "rule is " + str2 + "," + loginConfig);
if (loginConfig != null) {
if (!TextUtils.isEmpty(loginConfig.getUuid())) {
}
if (!TextUtils.isEmpty(loginConfig.getLoginKey())) {
}
if (!TextUtils.isEmpty(loginConfig.getPhone())) {
}
if (!TextUtils.isEmpty(loginConfig.getUsername())) {
}
}
}
z10 = true;
}
Log.debug("AKCoreService", "needUpload " + z10);
if (z10) {
return "";
}
if (!str2.contains(HiAnalyticsConstant.REPORT_VAL_SEPARATOR)) {
str3 = "";
} else {
String[] split = str2.split(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
str3 = split[split.length - 1];
}
String string = f1.getInstance().getMMKV().getString("back_log_info", "");
JSONObject parseObject2 = JSON.parseObject(string);
String str5 = str + "-" + str3;
Log.debug("AKCoreService", "backLogInfo is " + string + ", info:" + str5);
if (parseObject2 != null && parseObject2.containsKey(str5)) {
if (System.currentTimeMillis() - parseObject2.getLong(str5).longValue() <= 86400000) {
return "";
}
return str5;
}
return str5;
}
private void B0(final String str) throws Exception {
int i10;
j0.a endCheckAction;
Log.i("AKCoreService", "login,thread:" + Thread.currentThread().getName());
XMPPConnectionManager.Companion companion = XMPPConnectionManager.INSTANCE;
if (companion.getInstance().isEffective()) {
Log.w("AKCoreService", "is effective do not continue");
companion.getInstance().setDoLogin(false);
return;
}
Server server = f1.getInstance().getServer();
String serverId = f1.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");
s3.sendEvent(new w1(911, getString(y1.pls_choose_a_server)));
companion.getInstance().setDoLogin(false);
return;
}
Log.i("AKCoreService", "server address is available or is auto login we login directly,is auto login:" + str);
if (I == 0) {
i10 = getRetryTimes();
} else {
i10 = I;
}
XMPPConnectionManager companion2 = companion.getInstance();
AbstractXMPPConnection connection = companion2.getConnection();
Log.i("AKCoreService", "discoverserverGetFailedCount is " + this.f2733e + ",limi is " + i10);
final p pVar = new p() {
@Override
public final Object mo26invoke(Object obj, Object obj2) {
kd.s l02;
l02 = AKCoreService.this.l0(str, (AKCDiscoverGlobal.DiscoverServerResponse) obj, (Boolean) obj2);
return l02;
}
};
int i11 = this.f2733e;
if (i11 > 1 && i11 % i10 == 0) {
if (AKCCheckPoint.isChecking("CHECKPOINT_LOGIN") != null && this.f2733e <= i10 * 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) {
companion2.destroy(true);
}
if (!AKApplication.isAppHadLogin()) {
Log.i("AKCoreService", "IN LAUNCH AUTO LOGIN");
final Activity topActivity = AKApplication.getTopActivity();
if (topActivity != null && !topActivity.isFinishing() && !AKApplication.f777d) {
Log.i("lwxid-log", this.f2733e + "次xmpp链接失败,提示用户重连");
final AKeyDialog aKeyDialog = new AKeyDialog(topActivity);
aKeyDialog.setTip(getString(y1.login_failed_hint_22));
aKeyDialog.setPositiveButton(getString(y1.retry), new View.OnClickListener() {
@Override
public final void onClick(View view) {
AKCoreService.n0(AKeyDialog.this, pVar, view);
}
});
aKeyDialog.setNegativeButton(getString(y1.cancel), new View.OnClickListener() {
@Override
public final void onClick(View view) {
AKCoreService.this.o0(topActivity, aKeyDialog, view);
}
});
aKeyDialog.setCanceledOnTouchOutside(false);
topActivity.runOnUiThread(new s7(aKeyDialog));
return;
}
}
AKCDiscoverManager.INSTANCE.getInstance().refreshServer(new vd.l() {
@Override
public final Object invoke(Object obj) {
kd.s p02;
p02 = AKCoreService.p0(vd.p.this, (AKCDiscoverGlobal.DiscoverServerResponse) obj);
return p02;
}
}, true);
return;
}
if (!AKApplication.f777d && 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.INSTANCE.getInstance().getServer(serverId, num.intValue(), new vd.l() {
@Override
public final Object invoke(Object obj) {
kd.s q02;
q02 = AKCoreService.q0(vd.p.this, (AKCDiscoverGlobal.DiscoverServerResponse) obj);
return q02;
}
}, false, false);
}
private void C0(String str) {
String username = f1.getInstance().getUsername();
this.f2739k = System.currentTimeMillis();
Log.i("AKCoreService", "check-user name:" + username);
if (t.isNetWorkAvailableInPhysical()) {
N0(str);
return;
}
Log.w("AKCoreService", "network is unavailable");
XMPPConnectionManager.Companion companion = XMPPConnectionManager.INSTANCE;
companion.getInstance().increaseLoginFailedTimes();
s3.sendEvent(new w1(913, null));
companion.getInstance().setDoLogin(false);
}
public void D0(String str, String str2, String str3) {
Log.i("AKCoreService", "make_unstablechat_call_ >");
Message unStableChatCtrlMessage = sd.getIntance().getUnStableChatCtrlMessage(str3, str2, str, CtrlMessage.LAUNCH_UNSTABLECHAT_IN);
if (unStableChatCtrlMessage != null) {
Log.i("AKCoreService", "make_unstablechat_call_ ===");
Intent intent = new Intent(u0.T);
intent.putExtra(UnStableChatStatusReceiver.f1223a, new UnStableCallInfo(str2, "callstate_calling", str3));
sendBroadcast(intent);
MessageManager.addHandlerIntoSender(new s1(unStableChatCtrlMessage));
if (this.f2730b != 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 E0() {
if (f1.getInstance().isOnline()) {
Log.i("AKCoreService", "stop maybeLogin,is online is true");
} else {
this.f2738j = new g();
fc.z.just("").map(new h()).subscribeOn(gd.b.io()).observeOn(ic.a.mainThread()).subscribe(this.f2738j);
}
}
public void F0(Map<String, String> map) {
String str = "https://" + f1.getInstance().getServer().getAppSrvHost() + ":" + f1.getInstance().getServer().getAppSrvPort() + CookieSpec.PATH_DELIM;
m.b okHttpClientBuilder = HttpURLTools.getOkHttpClientBuilder(str, f1.getInstance().getAccessToken(), false);
okHttpClientBuilder.addInterceptor(new g0(3));
((u) new k.b().baseUrl(str).client(okHttpClientBuilder.build()).addCallAdapterFactory(mf.g.create()).addConverterFactory(nf.a.create()).build().create(u.class)).notifyResult(map).subscribeOn(gd.b.io()).subscribe(new c(map));
}
private void G0() {
EventBus.getDefault().register(this);
}
private void H0() {
if (this.f2744p == null) {
this.f2744p = new UnStableChatStatusReceiver();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(u0.T);
this.f2729a.registerReceiver(this.f2744p, intentFilter);
}
}
public void I0(String str) {
f1.getInstance().saveReSendCollectLogNotice(str);
}
private void J0(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);
f1.getInstance().saveCollect_log(jSONObject.toString());
} catch (JSONException e10) {
e10.printStackTrace();
}
}
public void K0(int i10, int i11) {
showToast(getString(i10), i11);
}
private void L0(String str) {
showToast(str, 0);
}
private void M0(long j10) {
try {
Thread.sleep(j10);
} catch (InterruptedException e10) {
e10.printStackTrace();
}
}
@SuppressLint({"CheckResult"})
private void N0(String str) {
boolean z10;
boolean z11;
boolean z12;
boolean z13;
boolean z14;
boolean z15;
boolean z16;
boolean z17;
boolean z18;
boolean z19;
boolean z20;
boolean z21;
String xmppIP;
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 (!f3.isAutoLogin(str) && !f1.getInstance().f2016g1) {
int pwdSaveValidDate = f1.getInstance().getPwdSaveValidDate();
if (pwdSaveValidDate > 0) {
f1.getInstance().updatePwdSaveValidDate(pwdSaveValidDate).subscribeOn(gd.b.io()).subscribe();
}
} else if (f1.getInstance().isPwdInvalid()) {
Log.i("AKCoreService", "pwd invalid do not auto login");
f1.getInstance().clearPwdInSharedPref();
XMPPConnectionManager.INSTANCE.getInstance().setDoLogin(false);
s3.sendEvent(new w1(441, getString(y1.pwd_invalid)));
return;
}
boolean handleEnvironmentDetect = handleEnvironmentDetect();
int loginCode = XMPPConnectionManager.getLoginCode();
if (902 == loginCode) {
z10 = true;
} else {
z10 = false;
}
if (handleEnvironmentDetect | z10) {
XMPPConnectionManager.INSTANCE.getInstance().setDoLogin(false);
Log.w("AKCoreService", "forbidden go on:" + loginCode);
return;
}
if (903 == loginCode) {
z11 = true;
} else {
z11 = false;
}
if (403 == loginCode) {
z12 = true;
} else {
z12 = false;
}
boolean z22 = z11 | z12;
if (900 == loginCode) {
z13 = true;
} else {
z13 = false;
}
boolean z23 = z22 | z13;
if (901 == loginCode) {
z14 = true;
} else {
z14 = false;
}
boolean z24 = z23 | z14;
if (483 == loginCode) {
z15 = true;
} else {
z15 = false;
}
boolean z25 = z24 | z15;
if (401 == loginCode) {
z16 = true;
} else {
z16 = false;
}
boolean z26 = z25 | z16;
if (13 == loginCode) {
z17 = true;
} else {
z17 = false;
}
boolean z27 = z26 | z17;
if (814 == loginCode) {
z18 = true;
} else {
z18 = false;
}
boolean z28 = z27 | z18;
if (815 == loginCode) {
z19 = true;
} else {
z19 = false;
}
boolean z29 = z28 | z19;
if (816 == loginCode) {
z20 = true;
} else {
z20 = false;
}
boolean z30 = z29 | z20;
if (12 == loginCode) {
z21 = true;
} else {
z21 = false;
}
if ((z30 | z21) && AKApplication.isAppHadLogin()) {
Log.w("AKCoreService", "for login code is:" + loginCode + ",forbidden login");
XMPPConnectionManager.INSTANCE.getInstance().setDoLogin(false);
return;
}
H = System.currentTimeMillis();
XMPPConnectionManager.Companion companion = XMPPConnectionManager.INSTANCE;
XMPPConnectionManager companion2 = companion.getInstance();
AbstractXMPPConnection connection = companion2.getConnection();
if (connection != null) {
String host = connection.getHost();
Server server = f1.getInstance().getServer();
if (server == null) {
xmppIP = null;
} else {
xmppIP = 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);
companion2.destroy(true);
} else {
Log.i("AKCoreService", "xmpp configuration is not changed so we just reconnect directly");
}
}
companion2.unregisterConnectionChangeListeners();
companion2.registerConnectionChangeListener(new AKConnectedListener(getApplicationContext()));
try {
companion.getInstance().reconnect("manual_login".equals(str));
I = 0;
this.f2733e = 0;
b0();
if (!o3.isInternetTimeRight()) {
fc.z.timer(0L, TimeUnit.MILLISECONDS, gd.b.io()).subscribe(new mc.g() {
@Override
public final void accept(Object obj) {
AKCoreService.y0((Long) obj);
}
});
}
Log.i("AKCoreService", "current id is " + f1.getInstance().getServerId() + "***" + n3.getInstance().getCurrentEnterpriseInfo().discoverServerIP);
StringBuilder sb2 = new StringBuilder();
sb2.append("startLoginProgress end, loginType:");
sb2.append(str);
Log.d("AKCoreService", sb2.toString());
W(isAppHadLogin);
} catch (Exception e10) {
Log.i("AKCoreService", "login - exception:" + e10.getMessage());
XMPPConnectionManager.Companion companion3 = XMPPConnectionManager.INSTANCE;
companion3.getInstance().increaseLoginFailedTimes();
AkeyChatUtils.logException(e10);
companion3.getInstance().setDoLogin(false);
AKApplication.isAppHadLogin();
long j10 = 200;
if (AKApplication.f777d) {
j10 = 5000;
}
if ((!(e10 instanceof SmackException) || (e10 instanceof AKLoginException)) && !(e10 instanceof SSLHandshakeException) && !(e10 instanceof SocketTimeoutException)) {
if (e10 instanceof LoginException) {
s3.sendEvent(new w1(301, q5.getStrByResId(y1.pls_repeat_choose_server)));
} else if (!(e10 instanceof AKLoginException)) {
s3.sendEvent(new w1(-1, getString(y1.unrecoverable_error)));
}
this.f2733e = 0;
return;
}
if (e10 instanceof SmackException.ConnectionException) {
u0.f40401h0 = "bad";
M0(j10);
f1.getInstance().setOnline(false);
}
this.f2733e++;
Log.i("lwxid-log", this.f2733e + "次xmpp链接1");
O0(str);
}
}
public void O0(String str) {
boolean z10;
XMPPConnectionManager.Companion companion = XMPPConnectionManager.INSTANCE;
if (companion.getInstance().getIsDoLogin()) {
Log.w("AKCoreService", "is login give up reconnect :" + str);
return;
}
if (AKApplication.f777d) {
if (!AkeyChatUtils.isIgnoringBatteryOptimizations() && !AKCAppConfiguration.f9925a.canIgnoreBackground()) {
Log.w("AKCoreService", "app run background-stop re-connect");
return;
}
Log.i("AKCoreService", "ignore battery optimize so reconnect");
}
if (companion.getInstance().isEffective()) {
Log.w("AKCoreService", "xmpp connection is ok,do not reconnect:" + str);
return;
}
Log.i("AKCoreService", "start reconnect thread in-" + str);
f1 f1Var = f1.getInstance();
int loginCategory = f1Var.getLoginCategory();
String password = f1Var.getPassword();
if (TextUtils.isEmpty(password) && (loginCategory == 3 || loginCategory == 4)) {
password = f1Var.getLoginCode();
f1Var.setLoginCode("");
}
String loginKey = f1Var.getLoginKey();
boolean z11 = false;
if (!TextUtils.isEmpty(password) && !TextUtils.isEmpty(loginKey)) {
z10 = false;
} else {
z10 = true;
}
if (z10 && !TextUtils.isEmpty(f1.getInstance().f2001c2) && f1.getInstance().isOneKeyLogin() && !"maybeLogin".equals(str)) {
password = f1.getInstance().f2001c2;
loginKey = "one_key_login_name";
} else {
z11 = z10;
}
if (z11 && (TextUtils.isEmpty(loginKey) || f1Var.getGetLoginCodeTimes() <= 0 || "maybeLogin".equals(str))) {
Log.w("AKCoreService", "account or pwd is empty,account is " + loginKey + ",stop reconnect");
return;
}
f1Var.f2040m1 = loginKey;
Log.i("AKCoreService", "currentLoginPwd is " + password);
f1Var.f2044n1 = password;
if (f3.isBelongLoginType(str)) {
Y(str);
} else {
Y("normal_auto_login");
}
}
public void P0(String str, int i10, int i11) {
if (this.f2753y) {
return;
}
this.f2753y = true;
if ("unknow".equals(str)) {
K0(y1.unknow_error_asim_will_exit, 1);
} else if ("conflict".equals(str)) {
K0(i10, 1);
}
fc.z.timer(2000L, TimeUnit.MILLISECONDS, gd.b.io()).subscribe(new i(i11));
}
private void Q0() {
s3.unregister(this);
}
private void R0() {
UnStableChatStatusReceiver unStableChatStatusReceiver = this.f2744p;
if (unStableChatStatusReceiver != null) {
this.f2729a.unregisterReceiver(unStableChatStatusReceiver);
}
}
private void S() {
a0();
MessageManager.addHandlerIntoSender(new k0());
MessageManager.addHandlerIntoSender(new a1.a() {
@Override
public final void execute() {
AKCoreService.c0();
}
});
MessageManager.addHandlerIntoSender(new a1.a() {
@Override
public final void execute() {
AKCoreService.d0();
}
});
a1.a U = U();
if (U != null) {
MessageManager.addHandlerIntoSender(U);
}
Z();
}
public void S0(String str, String str2, String str3) {
Message unStableChatCtrlMessage = sd.getIntance().getUnStableChatCtrlMessage(str3, str2, str, CtrlMessage.LAUNCH_UNSTABLECHAT_ACCEPT);
if (unStableChatCtrlMessage != null) {
MessageManager.addHandlerIntoSender(new s1(unStableChatCtrlMessage));
}
}
private void T(final ChatMessage chatMessage) {
if (!f1.getInstance().needCheckSensitive()) {
return;
}
final AKSessionBean aKSession = SessionManager.getInstance().getAKSession(chatMessage.getWith());
String uniqueId = chatMessage.getUniqueId();
this.A = new a(uniqueId);
fc.z.just(uniqueId).map(new o() {
@Override
public final Object apply(Object obj) {
String[] e02;
e02 = AKCoreService.this.e0(chatMessage, (String) obj);
return e02;
}
}).map(new o() {
@Override
public final Object apply(Object obj) {
String h02;
h02 = AKCoreService.this.h0(chatMessage, aKSession, (String[]) obj);
return h02;
}
}).subscribeOn(gd.b.io()).subscribe(this.A);
}
public void T0(String str, String str2, String str3) {
Message unStableChatCtrlMessage = sd.getIntance().getUnStableChatCtrlMessage(str3, str2, str, CtrlMessage.LAUNCH_UNSTABLECHAT_BUSY);
if (unStableChatCtrlMessage != null) {
sd.getIntance().setRecvHeart(false);
MessageManager.addHandlerIntoSender(new s1(unStableChatCtrlMessage));
}
}
public a1.a U() {
String collect_log = f1.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 e10) {
e10.printStackTrace();
}
}
return null;
}
public void U0(String str, String str2, String str3) {
Message unStableChatCtrlMessage = sd.getIntance().getUnStableChatCtrlMessage(str3, str2, str, CtrlMessage.LAUNCH_UNSTABLECHAT_CONFIG);
if (unStableChatCtrlMessage != null) {
MessageManager.addProperty(unStableChatCtrlMessage, CtrlMessage.CTRL_SEND_UNSTABLECHAT_TIMER, sd.getIntance().getmSendSetTime());
MessageManager.addHandlerIntoSender(new s1(unStableChatCtrlMessage));
}
}
private HashMap<String, String> V(HashMap<String, String> hashMap, boolean z10) {
Log.debug("AKCoreService", "测试数据 before map:" + JSON.toJSONString(hashMap));
HashMap<String, String> hashMap2 = new HashMap<>();
StringBuilder sb2 = new StringBuilder();
String str = hashMap.get("serverID");
String str2 = "";
if (TextUtils.isEmpty(str)) {
str = "";
}
sb2.append(str);
sb2.append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
String str3 = hashMap.get("sessionID");
if (TextUtils.isEmpty(str3)) {
str3 = "";
}
sb2.append(str3);
sb2.append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
String str4 = hashMap.get("messageID");
if (TextUtils.isEmpty(str4)) {
str4 = "";
}
sb2.append(str4);
sb2.append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
String str5 = hashMap.get("chatType");
if (TextUtils.isEmpty(str5)) {
str5 = "";
}
sb2.append(str5);
sb2.append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
String str6 = hashMap.get("senderUserID");
if (TextUtils.isEmpty(str6)) {
str6 = "";
}
sb2.append(str6);
sb2.append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
String str7 = hashMap.get("receiverID");
if (TextUtils.isEmpty(str7)) {
str7 = "";
}
sb2.append(str7);
sb2.append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
String str8 = hashMap.get("senderName");
if (TextUtils.isEmpty(str8)) {
str8 = "";
}
sb2.append(str8);
sb2.append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
String str9 = hashMap.get("senderPhone");
if (TextUtils.isEmpty(str9)) {
str9 = "";
}
sb2.append(str9);
sb2.append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
String str10 = hashMap.get("receiverName");
if (TextUtils.isEmpty(str10)) {
str10 = "";
}
sb2.append(str10);
sb2.append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
if (!z10) {
String str11 = hashMap.get("Result");
if (TextUtils.isEmpty(str11)) {
str11 = "";
}
sb2.append(str11);
sb2.append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
String str12 = hashMap.get("Msgs");
if (!TextUtils.isEmpty(str12)) {
str2 = str12;
}
sb2.append(str2);
} else {
String str13 = hashMap.get("links");
if (!TextUtils.isEmpty(str13)) {
str2 = str13;
}
sb2.append(str2);
}
hashMap2.put("ex", sb2.toString());
return hashMap2;
}
public void V0(String str, String str2, String str3) {
Log.i("AKCoreService", "unstablechat_hangup_ >");
Message unStableChatCtrlMessage = sd.getIntance().getUnStableChatCtrlMessage(str3, str2, str, CtrlMessage.LAUNCH_UNSTABLECHAT_CANNCLE);
if (unStableChatCtrlMessage != null) {
Log.i("AKCoreService", "unstablechat_hangup_ =====");
MessageManager.addHandlerIntoSender(new s1(unStableChatCtrlMessage));
MessageReliabilityManager.getInstance().cancelSYSReliability(str3);
}
Log.i("AKCoreService", "unstablechat_hangup_ <");
}
public void W(final boolean z10) {
Log.i("AKCoreService", "login success isReconnect:" + z10 + ",start discoveryForReconnectLogin");
AKCDiscoverManager.INSTANCE.getInstance().updateServer(new vd.l() {
@Override
public final Object invoke(Object obj) {
kd.s i02;
i02 = AKCoreService.this.i0(z10, (AKCDiscoverGlobal.DiscoverServerResponse) obj);
return i02;
}
});
}
private void W0() {
AKCAppConfiguration aKCAppConfiguration = AKCAppConfiguration.f9925a;
int logAutoReportInterval = aKCAppConfiguration.logAutoReportInterval();
int logAutoReportCount = aKCAppConfiguration.logAutoReportCount();
Log.i("AKCoreService", "uploadLogDaily time:" + logAutoReportInterval + ",count:" + logAutoReportCount);
this.E = new b(logAutoReportCount);
if (logAutoReportInterval > 0) {
fc.z.interval(0L, logAutoReportInterval, TimeUnit.MINUTES).map(new o() {
@Override
public final Object apply(Object obj) {
String A0;
A0 = AKCoreService.A0((Long) obj);
return A0;
}
}).subscribeOn(gd.b.io()).observeOn(ic.a.mainThread()).subscribe(this.E);
}
}
private void X() {
jc.b bVar = this.f2735g;
if (bVar != null) {
bVar.dispose();
}
jc.b bVar2 = this.f2736h;
if (bVar2 != null) {
bVar2.dispose();
}
v0.a<Long> aVar = this.f2737i;
if (aVar != null) {
aVar.dispose();
}
v0.a<Object> aVar2 = this.f2738j;
if (aVar2 != null) {
aVar2.dispose();
}
jc.b bVar3 = this.f2734f;
if (bVar3 != null) {
bVar3.dispose();
}
v0.a<String> aVar3 = this.A;
if (aVar3 != null) {
aVar3.dispose();
}
v0.a<String> aVar4 = this.E;
if (aVar4 != null) {
aVar4.dispose();
}
stopFindIdTimer();
}
private void Y(final String str) {
if (AKApplication.f777d) {
if (XMPPConnectionManager.INSTANCE.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");
}
f1.getInstance().setConstraintUnSec(false);
if (!t.isNetWorkAvailableInPhysical()) {
Log.w("AKCoreService", "network unavailable do not login");
s3.sendEvent(new w1(913, null));
return;
}
ak.worker.f fVar = this.f2742n.get();
if (fVar == null) {
fVar = new ak.worker.f();
fVar.initilize("login-W-" + fVar.hashCode());
this.f2742n.set(fVar);
}
Log.i("AKCoreService", "executeLoginTask,thread:" + Thread.currentThread().getName() + ",login-type:" + str + ",check worker:" + fVar);
StringBuilder sb2 = new StringBuilder();
sb2.append("1 is ");
XMPPConnectionManager.Companion companion = XMPPConnectionManager.INSTANCE;
sb2.append(companion.getInstance().getIsDoLogin());
Log.i("lwxlogin", sb2.toString());
if (!companion.getInstance().getIsDoLogin()) {
if (fVar.isWorkerEmpty()) {
fVar.addHandler(new a1.a() {
@Override
public final void execute() {
AKCoreService.this.j0(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 Z() {
String reSendCollectLogNotice = f1.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"));
F0(hashMap);
} catch (Exception e10) {
e10.printStackTrace();
}
}
}
private void a0() {
int i10;
AlarmManager alarmManager = (AlarmManager) getSystemService(NotificationCompat.CATEGORY_ALARM);
if (alarmManager == null) {
Log.w("AKCoreService", "alar mgr is null");
return;
}
Intent intent = new Intent(getApplicationContext(), (Class<?>) KeepLiveReceiver.class);
Context applicationContext = getApplicationContext();
int i11 = Build.VERSION.SDK_INT;
if (i11 >= 23) {
i10 = 201326592;
} else {
i10 = 134217728;
}
PendingIntent broadcast = PendingIntent.getBroadcast(applicationContext, 0, intent, i10);
long elapsedRealtime = SystemClock.elapsedRealtime() + 5000;
if (i11 >= 23) {
try {
alarmManager.setAndAllowWhileIdle(2, elapsedRealtime, broadcast);
} catch (Exception e10) {
Log.e("AKCoreService", "initKeepAliveAlarm alarmMgr set error , " + e10.getMessage());
}
}
alarmManager.setRepeating(2, elapsedRealtime, 5000L, broadcast);
Log.debug("AKCoreService", "initKeepAliveAlarm success");
}
private void b0() {
String userVideoPath = FileUtil.getUserVideoPath();
if (!TextUtils.isEmpty(userVideoPath)) {
FileUtil.createDir(new File(userVideoPath));
}
String userImagePath = FileUtil.getUserImagePath();
if (!TextUtils.isEmpty(userImagePath)) {
FileUtil.createDir(new File(userImagePath));
}
String userAudioPath = FileUtil.getUserAudioPath();
if (!TextUtils.isEmpty(userAudioPath)) {
FileUtil.createDir(new File(userAudioPath));
}
String userFilePath = FileUtil.getUserFilePath();
if (!TextUtils.isEmpty(userFilePath)) {
FileUtil.createDir(new File(userFilePath));
}
String userTempPath = FileUtil.getUserTempPath();
if (!TextUtils.isEmpty(userTempPath)) {
FileUtil.createDir(new File(userTempPath));
}
String emoticonPath = FileUtil.getEmoticonPath();
if (!TextUtils.isEmpty(emoticonPath)) {
FileUtil.createDir(new File(emoticonPath));
}
}
public static void c0() {
Log.i("AKCoreService", "send update.presence; recv offline msgs");
EventBus.getDefault().post(new u3(User.UPDATE_INFO));
f1.getInstance().setOnline(true);
f1.getInstance().queryDesktopStatus();
}
public static void d0() {
sd.getIntance().checkUnstablePush();
}
public String[] e0(ChatMessage chatMessage, String str) throws Exception {
String sensitiveMatch;
String str2 = "";
if (AKCAppConfiguration.f9925a.supportSurveillance()) {
AKCSensitiveUtils.Companion companion = AKCSensitiveUtils.INSTANCE;
if (companion.getInstance().getCanUse()) {
synchronized (this.B) {
sensitiveMatch = companion.getInstance().sensitiveMatch(chatMessage.getContent());
}
str2 = sensitiveMatch;
} else {
Log.i("AKCoreService", "getCanUse is false");
}
Log.debug("AKCoreService", "测试数据:命中为:" + str2);
}
if (TextUtils.isEmpty(str2) || !str2.contains(HiAnalyticsConstant.REPORT_VAL_SEPARATOR)) {
str2 = "";
}
return new String[]{str, str2};
}
public Long f0(int i10, int i11, boolean z10, User user, User user2, Group group, Long l10) throws Exception {
String sb2;
List<ChatMessage> list;
User userByName;
String phone;
String phone2;
int i12 = i10;
Log.debug("AKCoreService", "测试 开始 " + Thread.currentThread().getName());
long currentTimeMillis = System.currentTimeMillis();
HashMap hashMap = new HashMap(this.C);
for (ChatMessage chatMessage : hashMap.keySet()) {
List<ChatMessage> queryMessageListWithLimit = MessageManager.getInstance().queryMessageListWithLimit(chatMessage.getWith(), chatMessage.getmSeqNO(), i10, chatMessage.getChatType(), "text");
long parseLong = Long.parseLong(chatMessage.getTimestamp());
if (queryMessageListWithLimit.size() < i12 && currentTimeMillis - parseLong < i11 * 1000) {
}
this.C.remove(chatMessage);
queryMessageListWithLimit.add(0, chatMessage);
StringBuilder sb3 = new StringBuilder();
int i13 = 0;
while (i13 < Math.min(queryMessageListWithLimit.size(), i12 + 1)) {
ChatMessage chatMessage2 = queryMessageListWithLimit.get(i13);
Log.debug("AKCoreService", "测试数据:消息内容:" + chatMessage2.getContent() + ",seq:" + chatMessage2.getmSeqNO());
try {
String from = chatMessage2.getFrom();
sb3.append(",");
JSONObject jSONObject = new JSONObject();
list = queryMessageListWithLimit;
try {
jSONObject.put("sender_uid", (Object) q5.getUserNameByJid(chatMessage2.getFrom()));
if (z10) {
if (user.getJID().equals(from)) {
jSONObject.put("sender_name", (Object) user.getNickName());
jSONObject.put("sender_phone", (Object) user.getPhone());
} else if (user2 != null) {
jSONObject.put("sender_name", (Object) user2.getNickName());
if (user2.getPhone() == null) {
phone2 = "";
} else {
phone2 = user2.getPhone();
}
jSONObject.put("sender_phone", (Object) phone2);
}
} else if (group != null && (userByName = group.getUserByName(q5.getUserNameByJid(from))) != null) {
jSONObject.put("sender_name", (Object) userByName.getNickName());
if (userByName.getPhone() == null) {
phone = "";
} else {
phone = userByName.getPhone();
}
jSONObject.put("sender_phone", (Object) phone);
}
jSONObject.put("msg_text", (Object) chatMessage2.getContent());
jSONObject.put("time_stamp", (Object) chatMessage2.getTimestamp());
jSONObject.put("msg_id", (Object) chatMessage2.getUniqueId());
String jSONString = jSONObject.toJSONString();
Log.debug("测试数据", " enContent:" + jSONString);
AKeyManager aKeyManager = AKeyManager.getInstance();
AKCAppConfiguration aKCAppConfiguration = AKCAppConfiguration.f9925a;
sb3.append(w.b.encrypt(jSONString, aKeyManager.getSensitiveKey(aKCAppConfiguration.getSurveillanceKey2()), AKeyManager.getInstance().getSensitiveVi(aKCAppConfiguration.getSurveillanceIv2())));
} catch (Exception e10) {
e = e10;
e.printStackTrace();
i13++;
i12 = i10;
queryMessageListWithLimit = list;
}
} catch (Exception e11) {
e = e11;
list = queryMessageListWithLimit;
}
i13++;
i12 = i10;
queryMessageListWithLimit = list;
}
if (sb3.length() > 1) {
sb2 = sb3.substring(1);
} else {
sb2 = sb3.toString();
}
HashMap<String, String> hashMap2 = (HashMap) hashMap.get(chatMessage);
hashMap2.put("Msgs", sb2);
AKCCheckPoint.aliyunLog2(V(hashMap2, false), AKCCheckPoint.AKCSLSLogTopic.AKCSLSLogTopic_Regulation_Report.getValue(), "surveillance-log", "mixin-client-log");
Log.debug("AKCoreService", "测试数据 report map:" + JSON.toJSONString(V(hashMap2, false)));
i12 = i10;
}
return l10;
}
public void g0(Long l10) throws Exception {
jc.b bVar;
Log.debug("AKCoreService", "测试 结束" + this.C.size());
if (this.C.size() == 0 && (bVar = this.D) != null) {
bVar.dispose();
this.D = null;
}
}
public static int getRetryTimes() {
I = AKCAppConfiguration.f9925a.connRetries();
return I;
}
public String h0(ChatMessage chatMessage, AKSessionBean aKSessionBean, String[] strArr) throws Exception {
String nickName;
final AKCoreService aKCoreService;
String str;
String str2;
String str3;
String str4;
String str5;
String str6;
String str7;
HashMap<String, String> hashMap;
String str8;
String str9;
Matcher matcher;
boolean z10;
String str10;
String[] split;
int surveilanceCount;
final int surveilanceTime;
int i10;
String[] strArr2;
int i11;
final int i12;
String str11;
HashMap<String, String> hashMap2;
String str12;
String str13;
String str14;
StringBuilder sb2;
final Group group;
int i13;
int i14;
boolean z11;
String str15;
?? r11;
User userByName;
long j10;
AKeyManager aKeyManager;
AKCAppConfiguration aKCAppConfiguration;
ChatMessage chatMessage2 = chatMessage;
String serverStatus = f1.getInstance().getServerStatus();
boolean equals = "single".equals(chatMessage.getChatType());
final User userMe = bf.getInstance().getUserMe();
User userIncontacters = aKSessionBean == null ? null : bf.getInstance().getUserIncontacters(aKSessionBean.getWith());
Group groupBySimpleName = aKSessionBean == null ? null : b5.getInstance().getGroupBySimpleName(b5.getInstance().getSimpleNameByGroupname(aKSessionBean.getWith()));
if (equals) {
nickName = userIncontacters != null ? userIncontacters.getNickName() : chatMessage.getWith();
} else {
nickName = groupBySimpleName != null ? groupBySimpleName.getNickName() : chatMessage.getWith();
}
String str16 = nickName;
String str17 = "";
String userNameByJid = aKSessionBean == null ? "" : q5.getUserNameByJid(aKSessionBean.getWith());
String nickName2 = userMe.getNickName();
AKeyManager aKeyManager2 = AKeyManager.getInstance();
AKCAppConfiguration aKCAppConfiguration2 = AKCAppConfiguration.f9925a;
String encrypt = w.b.encrypt(nickName2, aKeyManager2.getSensitiveKey(aKCAppConfiguration2.getSurveillanceKey2()), AKeyManager.getInstance().getSensitiveVi(aKCAppConfiguration2.getSurveillanceIv2()));
String encrypt2 = w.b.encrypt(userMe.getPhone(), AKeyManager.getInstance().getSensitiveKey(aKCAppConfiguration2.getSurveillanceKey2()), AKeyManager.getInstance().getSensitiveVi(aKCAppConfiguration2.getSurveillanceIv2()));
String encrypt3 = w.b.encrypt(str16, AKeyManager.getInstance().getSensitiveKey(aKCAppConfiguration2.getSurveillanceKey2()), AKeyManager.getInstance().getSensitiveVi(aKCAppConfiguration2.getSurveillanceIv2()));
Log.debug("测试数据", " eName:" + userMe.getNickName() + ",ePhone:" + userMe.getPhone() + ",rName:" + str16 + ",reId:" + userNameByJid);
HashMap<String, String> hashMap3 = r1;
String str18 = userNameByJid;
Group group2 = groupBySimpleName;
HashMap<String, String> hashMap4 = new HashMap<String, String>(aKSessionBean, chatMessage, equals, userNameByJid, encrypt, encrypt2, encrypt3) {
final AKSessionBean f2755a;
final ChatMessage f2756b;
final boolean f2757c;
final String f2758d;
final String f2759e;
final String f2760f;
final String f2761g;
{
String serverId;
String sessionId;
String str19;
this.f2755a = aKSessionBean;
this.f2756b = chatMessage;
this.f2757c = equals;
this.f2758d = userNameByJid;
this.f2759e = encrypt;
this.f2760f = encrypt2;
this.f2761g = encrypt3;
if (f1.getInstance().getServer() != null) {
serverId = f1.getInstance().getServer().getEnterpriseId();
} else {
serverId = f1.getInstance().getServerId();
}
put("serverID", serverId);
if (aKSessionBean == null) {
sessionId = "";
} else {
sessionId = aKSessionBean.getSessionId();
}
put("sessionID", sessionId);
put("messageID", chatMessage.getUniqueId());
if (equals) {
str19 = "1";
} else {
str19 = "2";
}
put("chatType", str19);
put("senderUserID", f1.getInstance().getUsername());
put("receiverID", userNameByJid);
put("senderName", encrypt);
put("senderPhone", encrypt2);
put("receiverName", encrypt3);
}
};
if (Akeychat.RiskStatus.surveillance.name().equals(serverStatus)) {
String str19 = "msg_id";
String str20 = "time_stamp";
String str21 = "msg_text";
String str22 = "sender_uid";
String str23 = "sender_phone";
String str24 = "sender_name";
String str25 = "surveillance-log";
if (strArr.length > 1 && !TextUtils.isEmpty(strArr[1])) {
try {
String[] split2 = strArr[1].split("\n\\|\n");
split = split2.length > 1 ? split2[1].split("\n") : null;
surveilanceCount = aKCAppConfiguration2.surveilanceCount();
surveilanceTime = aKCAppConfiguration2.surveilanceTime();
} catch (Exception e10) {
e = e10;
aKCoreService = this;
str = "sender_name";
str2 = "sender_phone";
str3 = "time_stamp";
str4 = "msg_id";
str5 = "mixin-client-log";
str6 = "测试数据";
str7 = str25;
}
if (split != null) {
String str26 = "mixin-client-log";
try {
int length = split.length;
str6 = "测试数据";
int i15 = 0;
while (i15 < length) {
try {
String str27 = split[i15];
i10 = length;
StringBuilder sb3 = new StringBuilder();
strArr2 = split;
sb3.append("测试数据 report:");
sb3.append(str27);
Log.debug("AKCoreService", sb3.toString());
String[] split3 = str27.split("\\|");
StringBuilder sb4 = new StringBuilder();
int i16 = 2;
i11 = i15;
while (true) {
str4 = str19;
if (i16 >= split3.length) {
break;
}
try {
sb4.append(q5.shaHash(split3[i16]));
if (i16 == split3.length - 1) {
break;
}
sb4.append(",");
i16++;
str19 = str4;
} catch (Exception e11) {
e = e11;
aKCoreService = this;
str = str24;
str2 = str23;
str8 = str22;
str3 = str20;
str7 = str25;
str5 = str26;
hashMap = hashMap3;
str9 = str21;
AkeyChatUtils.logException(e);
matcher = s5.f10409e.matcher(chatMessage.getContent());
String content = chatMessage.getContent();
while (true) {
if (matcher.find()) {
}
}
if (!z10) {
}
if (z10) {
}
str10 = str17;
if (!TextUtils.isEmpty(str10)) {
}
return strArr[0];
}
}
?? r12 = hashMap3;
try {
r12.put("Result", sb4.toString());
List<ChatMessage> queryMessageListWithLimit = MessageManager.getInstance().queryMessageListWithLimit(chatMessage.getWith(), chatMessage.getmSeqNO(), -surveilanceCount, chatMessage.getChatType(), "text");
queryMessageListWithLimit.add(0, chatMessage2);
StringBuilder sb5 = new StringBuilder();
i12 = surveilanceCount;
int size = queryMessageListWithLimit.size() - 1;
while (size >= 0) {
try {
ChatMessage chatMessage3 = queryMessageListWithLimit.get(size);
StringBuilder sb6 = new StringBuilder();
List<ChatMessage> list = queryMessageListWithLimit;
sb6.append("测试数据:消息内容:");
sb6.append(chatMessage3.getContent());
sb6.append(",seq:");
hashMap = r12;
try {
sb6.append(chatMessage3.getmSeqNO());
Log.debug("AKCoreService", sb6.toString());
try {
sb5.append(",");
?? jSONObject = new JSONObject();
String from = chatMessage3.getFrom();
jSONObject.put(str22, q5.getUserNameByJid(from));
if (equals) {
if (userMe.getJID().equals(from)) {
jSONObject.put(str24, userMe.getNickName());
jSONObject.put(str23, userMe.getPhone());
} else if (userIncontacters != null) {
jSONObject.put(str24, userIncontacters.getNickName());
jSONObject.put(str23, userIncontacters.getPhone() == null ? "" : userIncontacters.getPhone());
}
} else if (group2 != null && (userByName = group2.getUserByName(q5.getUserNameByJid(from))) != null) {
jSONObject.put(str24, userByName.getNickName());
jSONObject.put(str23, userByName.getPhone() == null ? "" : userByName.getPhone());
}
jSONObject.put(str21, chatMessage3.getContent());
try {
j10 = Long.parseLong(chatMessage3.getTimestamp());
} catch (Exception e12) {
Log.e("AKCoreService", "time is " + chatMessage3.getTimestamp() + "," + e12.getMessage());
j10 = 0;
}
jSONObject.put(str20, Long.valueOf(j10));
r11 = str4;
try {
jSONObject.put(r11, chatMessage3.getUniqueId());
String jSONString = jSONObject.toJSONString();
r12 = str6;
try {
Log.debug(r12, " enContent:" + jSONString);
aKeyManager = AKeyManager.getInstance();
aKCAppConfiguration = AKCAppConfiguration.f9925a;
str4 = str24;
} catch (Exception e13) {
e = e13;
str4 = str24;
}
try {
str11 = str23;
try {
sb5.append(w.b.encrypt(jSONString, aKeyManager.getSensitiveKey(aKCAppConfiguration.getSurveillanceKey2()), AKeyManager.getInstance().getSensitiveVi(aKCAppConfiguration.getSurveillanceIv2())));
} catch (Exception e14) {
e = e14;
try {
e.printStackTrace();
size--;
str6 = r12;
str24 = str4;
str23 = str11;
queryMessageListWithLimit = list;
r12 = hashMap;
str4 = r11;
r11 = chatMessage;
} catch (Exception e15) {
e = e15;
aKCoreService = this;
str8 = str22;
str9 = str21;
str3 = str20;
str6 = r12;
str7 = str25;
str5 = str26;
str = str4;
str15 = r11;
str4 = str15;
str2 = str11;
AkeyChatUtils.logException(e);
matcher = s5.f10409e.matcher(chatMessage.getContent());
String content2 = chatMessage.getContent();
while (true) {
if (matcher.find()) {
}
}
if (!z10) {
}
if (z10) {
}
str10 = str17;
if (!TextUtils.isEmpty(str10)) {
}
return strArr[0];
}
}
} catch (Exception e16) {
e = e16;
str11 = str23;
e.printStackTrace();
size--;
str6 = r12;
str24 = str4;
str23 = str11;
queryMessageListWithLimit = list;
r12 = hashMap;
str4 = r11;
r11 = chatMessage;
}
} catch (Exception e17) {
e = e17;
str4 = str24;
str11 = str23;
r12 = str6;
}
} catch (Exception e18) {
e = e18;
str11 = str23;
r12 = str6;
r11 = str4;
str4 = str24;
e.printStackTrace();
size--;
str6 = r12;
str24 = str4;
str23 = str11;
queryMessageListWithLimit = list;
r12 = hashMap;
str4 = r11;
r11 = chatMessage;
}
size--;
str6 = r12;
str24 = str4;
str23 = str11;
queryMessageListWithLimit = list;
r12 = hashMap;
str4 = r11;
r11 = chatMessage;
} catch (Exception e19) {
e = e19;
aKCoreService = this;
str = str24;
str8 = str22;
str9 = str21;
str3 = str20;
str7 = str25;
str5 = str26;
str2 = str23;
AkeyChatUtils.logException(e);
matcher = s5.f10409e.matcher(chatMessage.getContent());
String content22 = chatMessage.getContent();
while (true) {
if (matcher.find()) {
}
}
if (!z10) {
}
if (z10) {
}
str10 = str17;
if (!TextUtils.isEmpty(str10)) {
}
return strArr[0];
}
} catch (Exception e20) {
e = e20;
hashMap = r12;
}
}
str11 = str23;
hashMap2 = r12;
str12 = str6;
str13 = str4;
str14 = str24;
try {
hashMap2.put("Msgs", sb5.length() > 1 ? sb5.substring(1) : sb5.toString());
sb2 = new StringBuilder();
sb2.append("测试数据 report map:");
group = group2;
aKCoreService = this;
} catch (Exception e21) {
e = e21;
aKCoreService = this;
}
} catch (Exception e22) {
e = e22;
aKCoreService = this;
str = str24;
str2 = str23;
str8 = str22;
str9 = str21;
str3 = str20;
hashMap = r12;
str7 = str25;
str5 = str26;
}
} catch (Exception e23) {
e = e23;
aKCoreService = this;
str = str24;
str2 = str23;
str8 = str22;
str3 = str20;
str4 = str19;
}
try {
sb2.append(JSON.toJSONString(aKCoreService.V(hashMap2, false)));
Log.debug("AKCoreService", sb2.toString());
String str28 = str25;
String str29 = str26;
try {
AKCCheckPoint.aliyunLog2(aKCoreService.V(hashMap2, false), AKCCheckPoint.AKCSLSLogTopic.AKCSLSLogTopic_Regulation_Report.getValue(), str28, str29);
aKCoreService.C.put(chatMessage, new HashMap<>(hashMap2));
if (aKCoreService.D == null) {
str26 = str29;
try {
str2 = str11;
hashMap = hashMap2;
str8 = str22;
str6 = str12;
str3 = str20;
final boolean z12 = equals;
z11 = equals;
i13 = i12;
str7 = str28;
str4 = str13;
str = str14;
final User user = userIncontacters;
str9 = str21;
str5 = str26;
i14 = i10;
try {
aKCoreService.D = fc.z.interval(1L, 1L, TimeUnit.SECONDS).map(new o() {
@Override
public final Object apply(Object obj) {
Long f02;
f02 = AKCoreService.this.f0(i12, surveilanceTime, z12, userMe, user, group, (Long) obj);
return f02;
}
}).subscribeOn(gd.b.io()).subscribe(new mc.g() {
@Override
public final void accept(Object obj) {
AKCoreService.this.g0((Long) obj);
}
});
} catch (Exception e24) {
e = e24;
AkeyChatUtils.logException(e);
matcher = s5.f10409e.matcher(chatMessage.getContent());
String content222 = chatMessage.getContent();
while (true) {
if (matcher.find()) {
}
}
if (!z10) {
}
if (z10) {
}
str10 = str17;
if (!TextUtils.isEmpty(str10)) {
}
return strArr[0];
}
} catch (Exception e25) {
e = e25;
str9 = str21;
str3 = str20;
str7 = str28;
str6 = str12;
hashMap = hashMap2;
str5 = str26;
str = str14;
str8 = str22;
str15 = str13;
str4 = str15;
str2 = str11;
AkeyChatUtils.logException(e);
matcher = s5.f10409e.matcher(chatMessage.getContent());
String content2222 = chatMessage.getContent();
while (true) {
if (matcher.find()) {
}
}
if (!z10) {
}
if (z10) {
}
str10 = str17;
if (!TextUtils.isEmpty(str10)) {
}
return strArr[0];
}
} else {
str3 = str20;
str7 = str28;
str5 = str29;
str6 = str12;
hashMap = hashMap2;
i13 = i12;
i14 = i10;
str8 = str22;
str9 = str21;
str4 = str13;
str2 = str11;
z11 = equals;
str = str14;
}
str23 = str2;
str24 = str;
str22 = str8;
surveilanceCount = i13;
group2 = group;
length = i14;
str21 = str9;
split = strArr2;
str19 = str4;
equals = z11;
hashMap3 = hashMap;
str20 = str3;
str25 = str7;
str26 = str5;
chatMessage2 = chatMessage;
i15 = i11 + 1;
} catch (Exception e26) {
e = e26;
str9 = str21;
str3 = str20;
str7 = str28;
str5 = str29;
str6 = str12;
hashMap = hashMap2;
str = str14;
str8 = str22;
str15 = str13;
str4 = str15;
str2 = str11;
AkeyChatUtils.logException(e);
matcher = s5.f10409e.matcher(chatMessage.getContent());
String content22222 = chatMessage.getContent();
while (true) {
if (matcher.find()) {
}
}
if (!z10) {
}
if (z10) {
}
str10 = str17;
if (!TextUtils.isEmpty(str10)) {
}
return strArr[0];
}
} catch (Exception e27) {
e = e27;
str9 = str21;
str3 = str20;
str6 = str12;
hashMap = hashMap2;
str7 = str25;
str5 = str26;
str = str14;
str8 = str22;
str15 = str13;
str4 = str15;
str2 = str11;
AkeyChatUtils.logException(e);
matcher = s5.f10409e.matcher(chatMessage.getContent());
String content222222 = chatMessage.getContent();
while (true) {
if (matcher.find()) {
}
}
if (!z10) {
}
if (z10) {
}
str10 = str17;
if (!TextUtils.isEmpty(str10)) {
}
return strArr[0];
}
}
aKCoreService = this;
str = str24;
str2 = str23;
str8 = str22;
str3 = str20;
str4 = str19;
str7 = str25;
str5 = str26;
hashMap = hashMap3;
str9 = str21;
} catch (Exception e28) {
e = e28;
aKCoreService = this;
str = "sender_name";
str2 = "sender_phone";
str3 = "time_stamp";
str4 = "msg_id";
str6 = "测试数据";
str7 = str25;
str5 = str26;
hashMap = hashMap3;
str8 = "sender_uid";
str9 = str21;
AkeyChatUtils.logException(e);
matcher = s5.f10409e.matcher(chatMessage.getContent());
String content2222222 = chatMessage.getContent();
while (true) {
if (matcher.find()) {
}
}
if (!z10) {
}
if (z10) {
}
str10 = str17;
if (!TextUtils.isEmpty(str10)) {
}
return strArr[0];
}
matcher = s5.f10409e.matcher(chatMessage.getContent());
String content22222222 = chatMessage.getContent();
while (true) {
if (matcher.find()) {
z10 = false;
break;
}
if (HttpURLTools.UrlType.PublicNetworkExternalUrl.equals(HttpURLTools.checkHttpUrlType(matcher.group()))) {
z10 = true;
break;
}
}
if (!z10) {
Matcher matcher2 = s5.f10408d.matcher(content22222222);
while (true) {
if (!matcher2.find()) {
break;
}
String group3 = matcher2.group();
Log.debug("AKCoreService", "测试数据 1 :" + group3);
if (HttpURLTools.UrlType.PublicNetworkExternalUrl.equals(HttpURLTools.checkHttpUrlType(group3))) {
z10 = true;
break;
}
}
}
if (z10) {
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put(str8, (Object) q5.getUserNameByJid(chatMessage.getFrom()));
jSONObject2.put(str, (Object) userMe.getNickName());
jSONObject2.put(str2, (Object) userMe.getPhone());
jSONObject2.put(str9, (Object) chatMessage.getContent());
jSONObject2.put(str3, (Object) chatMessage.getTimestamp());
jSONObject2.put(str4, (Object) chatMessage.getUniqueId());
String jSONString2 = jSONObject2.toJSONString();
AKeyManager aKeyManager3 = AKeyManager.getInstance();
AKCAppConfiguration aKCAppConfiguration3 = AKCAppConfiguration.f9925a;
str17 = w.b.encrypt(jSONString2, aKeyManager3.getSensitiveKey(aKCAppConfiguration3.getSurveillanceKey3()), AKeyManager.getInstance().getSensitiveVi(aKCAppConfiguration3.getSurveillanceIv3()));
}
str10 = str17;
if (!TextUtils.isEmpty(str10)) {
String nickName3 = userMe.getNickName();
AKeyManager aKeyManager4 = AKeyManager.getInstance();
AKCAppConfiguration aKCAppConfiguration4 = AKCAppConfiguration.f9925a;
String encrypt4 = w.b.encrypt(nickName3, aKeyManager4.getSensitiveKey(aKCAppConfiguration4.getSurveillanceKey3()), AKeyManager.getInstance().getSensitiveVi(aKCAppConfiguration4.getSurveillanceIv3()));
String encrypt5 = w.b.encrypt(userMe.getPhone(), AKeyManager.getInstance().getSensitiveKey(aKCAppConfiguration4.getSurveillanceKey3()), AKeyManager.getInstance().getSensitiveVi(aKCAppConfiguration4.getSurveillanceIv3()));
String encrypt6 = w.b.encrypt(str16, AKeyManager.getInstance().getSensitiveKey(aKCAppConfiguration4.getSurveillanceKey3()), AKeyManager.getInstance().getSensitiveVi(aKCAppConfiguration4.getSurveillanceIv3()));
Log.debug(str6, " eName:" + userMe.getNickName() + ",ePhone:" + userMe.getPhone() + ",rName:" + str16 + ",reId:" + str18);
HashMap<String, String> hashMap5 = hashMap;
hashMap5.put("senderName", encrypt4);
hashMap5.put("senderPhone", encrypt5);
hashMap5.put("receiverName", encrypt6);
hashMap5.put("links", str10);
AKCCheckPoint.aliyunLog2(aKCoreService.V(hashMap5, true), AKCCheckPoint.AKCSLSLogTopic.AKCSLSLogTopic_Regulation_Report_Link.getValue(), str7, str5);
Log.debug("AKCoreService", "测试数据 link map:" + JSON.toJSONString(aKCoreService.V(hashMap5, true)));
}
}
}
aKCoreService = this;
str = "sender_name";
str2 = "sender_phone";
str3 = "time_stamp";
str4 = "msg_id";
str5 = "mixin-client-log";
str6 = "测试数据";
str7 = str25;
hashMap = hashMap3;
str8 = "sender_uid";
str9 = str21;
matcher = s5.f10409e.matcher(chatMessage.getContent());
String content222222222 = chatMessage.getContent();
while (true) {
if (matcher.find()) {
}
}
if (!z10) {
}
if (z10) {
}
str10 = str17;
if (!TextUtils.isEmpty(str10)) {
}
}
return strArr[0];
}
public s i0(boolean z10, AKCDiscoverGlobal.DiscoverServerResponse discoverServerResponse) {
if (discoverServerResponse.getError().getCode() == -1) {
stopFindIdTimer();
AKApplication.setNeedTimerToFindID(false);
Log.i("AKCoreService", "update server success");
AKCDiscoverInstance queryDiscoverInstanceBy = AKCDiscoverInstance.INSTANCE.queryDiscoverInstanceBy(f1.getInstance().getServerId());
if (queryDiscoverInstanceBy != null) {
Log.i("AKCoreService", "current:" + queryDiscoverInstanceBy);
if (!z10) {
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);
s3.sendEvent(new x0(true, 10));
} else {
int code = discoverServerResponse.getError().getCode();
if (code == 65539) {
code = 28;
} else if (code != 65538) {
code = 403;
}
EventBus.getDefault().postSticky(new g.b1(discoverServerResponse.getError().getDescription(), code));
return null;
}
return null;
}
public void j0(String str) {
XMPPConnectionManager.INSTANCE.getInstance().setDoLogin(true);
Log.e("AKCoreService", "lwx start log auto by akcoreService");
try {
B0(str);
} catch (Exception e10) {
e10.printStackTrace();
Log.e("AKCoreService", "login failed ,e is " + e10.getMessage());
XMPPConnectionManager.INSTANCE.getInstance().setDoLogin(false);
}
}
public static void k0(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.");
return;
}
if (longValue == userPrivateSyncResponse.getVersioncode() - 1) {
if (userPrivateSyncResponse.hasWithProperties()) {
Log.w("AKCoreService", "presence modify:" + userPrivateSyncResponse.getWithProperties().toString());
if (userPrivateSyncResponse.getWithProperties().getPushstatusCount() > 0) {
for (int i10 = 0; i10 < userPrivateSyncResponse.getWithProperties().getPushstatusCount(); i10++) {
Akeychat.UserPrivateWithBoolean pushstatus = userPrivateSyncResponse.getWithProperties().getPushstatus(i10);
String withId = pushstatus.getWithId();
Boolean valueOf = Boolean.valueOf(pushstatus.getValue());
if (!withId.contains("_")) {
if (bf.getInstance().contactersContainsKey(withId) && (contacterByUserName2 = bf.getInstance().getContacterByUserName(bf.getInstance().getUserNameByJid(withId))) != null) {
StringBuilder sb2 = new StringBuilder();
sb2.append("modify.user:");
sb2.append(contacterByUserName2.getName());
sb2.append(",pushStatus:");
sb2.append(!valueOf.booleanValue());
Log.i("AKCoreService", sb2.toString());
contacterByUserName2.setPushStatus(!valueOf.booleanValue());
bf.getInstance().updateContactPushStatus(contacterByUserName2);
s3.sendEvent(new e8(true, contacterByUserName2));
}
} else {
Group groupBySimpleName = b5.getInstance().getGroupBySimpleName(withId.split("@")[0]);
if (groupBySimpleName != null) {
StringBuilder sb3 = new StringBuilder();
sb3.append("modify.group:");
sb3.append(groupBySimpleName.getSimpleName());
sb3.append(",pushStatus:");
sb3.append(!valueOf.booleanValue());
Log.i("AKCoreService", sb3.toString());
groupBySimpleName.setPushStatus(!valueOf.booleanValue());
b5.getInstance().updateGroupPushStatus(groupBySimpleName.getPushStatus(), groupBySimpleName);
s3.sendEvent(new j2(groupBySimpleName));
}
}
}
}
if (userPrivateSyncResponse.getWithProperties().getAliasCount() > 0) {
for (int i11 = 0; i11 < userPrivateSyncResponse.getWithProperties().getAliasCount(); i11++) {
Akeychat.UserPrivateWithString alias = userPrivateSyncResponse.getWithProperties().getAlias(i11);
String withId2 = alias.getWithId();
String value = alias.getValue();
if (bf.getInstance().contactersContainsKey(withId2) && (contacterByUserName = bf.getInstance().getContacterByUserName(bf.getInstance().getUserNameByJid(withId2))) != null) {
Log.i("AKCoreService", "modify.user:" + contacterByUserName.getName() + ",alias:" + value);
contacterByUserName.setRemarkNickName(value);
bf.getInstance().updateContactAlias(contacterByUserName);
EventBus.getDefault().post(new d8(contacterByUserName.getName(), contacterByUserName));
}
}
}
if (userPrivateSyncResponse.getWithProperties().getFocusListCount() > 0) {
for (int i12 = 0; i12 < userPrivateSyncResponse.getWithProperties().getFocusListCount(); i12++) {
Akeychat.UserPrivateWithString focusList = userPrivateSyncResponse.getWithProperties().getFocusList(i12);
String withId3 = focusList.getWithId();
String value2 = focusList.getValue();
Group groupBySimpleName2 = b5.getInstance().getGroupBySimpleName(withId3.split("@")[0]);
if (groupBySimpleName2 != null) {
Log.i("AKCoreService", "modify.group:" + groupBySimpleName2.getSimpleName() + ",focus list:" + value2);
groupBySimpleName2.setmAttentionList(JSON.parseArray(value2));
b5.getInstance().updateGroupAttentionListInDB(groupBySimpleName2);
}
}
}
}
if (userPrivateSyncResponse.hasDelwithproperties()) {
Log.w("AKCoreService", "presence delete:" + userPrivateSyncResponse.getDelwithproperties().toString());
if (userPrivateSyncResponse.getDelwithproperties().getDelpushstatuswithCount() > 0) {
for (int i13 = 0; i13 < userPrivateSyncResponse.getDelwithproperties().getDelpushstatuswithCount(); i13++) {
String delpushstatuswith = userPrivateSyncResponse.getDelwithproperties().getDelpushstatuswith(i13);
if (!delpushstatuswith.contains("_")) {
User userInfoByName = bf.getInstance().getUserInfoByName(bf.getInstance().getUserNameByJid(delpushstatuswith), false, false);
if (userInfoByName != null) {
userInfoByName.setPushStatus(false);
Log.i("AKCoreService", "delete.user:" + userInfoByName.getName() + ",pushStatus:" + userInfoByName.getPushStatus());
}
} else {
Group groupBySimpleName3 = b5.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 i14 = 0; i14 < userPrivateSyncResponse.getDelwithproperties().getDelaliaswithCount(); i14++) {
User userInfoByName2 = bf.getInstance().getUserInfoByName(userPrivateSyncResponse.getDelwithproperties().getDelaliaswith(i14), false, false);
if (userInfoByName2 != null) {
userInfoByName2.setRemarkNickName("");
Log.i("AKCoreService", "delete.user:" + userInfoByName2.getName() + ",alias:" + userInfoByName2.getRemarkNickName());
}
}
}
if (userPrivateSyncResponse.getDelwithproperties().getDelfocusListwithCount() > 0) {
for (int i15 = 0; i15 < userPrivateSyncResponse.getDelwithproperties().getDelfocusListwithCount(); i15++) {
Group groupBySimpleName4 = b5.getInstance().getGroupBySimpleName(userPrivateSyncResponse.getDelwithproperties().getDelfocusListwith(i15));
if (groupBySimpleName4 != null) {
groupBySimpleName4.setmAttentionList(JSON.parseArray(""));
Log.i("AKCoreService", "delete.group:" + groupBySimpleName4.getSimpleName() + ",focuslist:" + groupBySimpleName4.getmAttentionList());
}
}
}
}
SyncManager.getSingleton().generateUserMePrivateInfoSyncResponse(userPrivateSyncResponse);
if (userPrivateSyncResponse.hasSecModeSwitchHidden()) {
s3.sendEvent(new w5(1, userPrivateSyncResponse.getSecModeSwitchHidden()));
}
if (userPrivateSyncResponse.hasSendRecvReadReceipts()) {
s3.sendEvent(new v3(1, userPrivateSyncResponse.getSendRecvReadReceipts()));
}
if (userPrivateSyncResponse.hasSendDestroyReceipts()) {
s3.sendEvent(new v3(2, userPrivateSyncResponse.getSendDestroyReceipts()));
}
if (userPrivateSyncResponse.hasShowReceiptsLabel()) {
s3.sendEvent(new v3(4, userPrivateSyncResponse.getShowReceiptsLabel()));
}
if (userPrivateSyncResponse.hasAkeyidsearch()) {
s3.sendEvent(new v3(5, userPrivateSyncResponse.getAkeyidsearch()));
}
if (userPrivateSyncResponse.hasPhonesearch()) {
s3.sendEvent(new v3(6, userPrivateSyncResponse.getPhonesearch()));
}
SyncManager.getSingleton().updateSyncInfo("my_private_info", userPrivateSyncResponse.getVersioncode());
return;
}
Log.i("AKCoreService", "sync my pri all");
Log.i("AKCoreService", "sync my info ret:" + SyncManager.getSingleton().syncMyPrivateInfo(userPrivateSyncResponse.getVersioncode()));
}
public s l0(String str, AKCDiscoverGlobal.DiscoverServerResponse discoverServerResponse, Boolean bool) {
Log.w("AKCoreService", "discover end, is refreshedServer?:" + bool + ",error code:" + discoverServerResponse.getError().getCode());
AKCDiscoverInstance queryDiscoverInstanceBy = AKCDiscoverInstance.INSTANCE.queryDiscoverInstanceBy(f1.getInstance().getServerId());
if (bool.booleanValue() && AKApplication.isAppHadLogin() && queryDiscoverInstanceBy != null) {
queryDiscoverInstanceBy.recordReport(2);
}
int i10 = -1;
if (discoverServerResponse.getError().getCode() == -1) {
f1.getInstance().setAndSaveServerInfo(discoverServerResponse.getServer());
C0(str);
} else {
XMPPConnectionManager.INSTANCE.getInstance().setDoLogin(false);
Log.d("lwxx", "login error code:" + discoverServerResponse.getError().getCode() + ",Description:" + discoverServerResponse.getError().getDescription());
if (discoverServerResponse.getError().getCode() == 600000) {
s3.sendEvent(new FindBoxFailedEvent(1, discoverServerResponse.getError().getDescription()));
if (AKApplication.isAppHadLogin()) {
f1.getInstance().setBoxOffLine(true);
}
return null;
}
int i11 = 911;
if (bool.booleanValue()) {
if (!DiscoverExtKt.ServerInvalid(discoverServerResponse.getError().getCode()) && !DiscoverExtKt.ServerErr(discoverServerResponse.getError().getCode())) {
Log.i("AKCoreService", "IN RECONNECTING:" + str);
O0(str);
} else if (discoverServerResponse.getError().getCode() == 65538) {
s3.sendEvent(new w1(AKCDiscoverGlobal.AKCDiscoverError_ServerStoped, discoverServerResponse.getError().getDescription()));
} else if (AKApplication.isAppHadLogin()) {
s3.sendEvent(new w1(403, discoverServerResponse.getError().getDescription()));
} else {
s3.sendEvent(new w1(911, discoverServerResponse.getError().getDescription()));
}
} else {
String description = discoverServerResponse.getError().getDescription();
if (TextUtils.isEmpty(description)) {
description = getString(y1.unknow_error);
}
if (!DiscoverExtKt.ServerInvalid(discoverServerResponse.getError().getCode()) && !DiscoverExtKt.ServerErr(discoverServerResponse.getError().getCode())) {
if (queryDiscoverInstanceBy != null) {
queryDiscoverInstanceBy.recordReport(1);
}
} else {
int code = discoverServerResponse.getError().getCode();
if (code == 65538) {
i10 = code;
}
}
if (i10 < 0) {
if (discoverServerResponse.getError().getCode() == 600001) {
i11 = 1001;
} else if (DiscoverExtKt.TLSErrors(discoverServerResponse.getError().getCode())) {
i11 = 1002;
} else if (AKApplication.isAppHadLogin()) {
i11 = discoverServerResponse.getError().getCode();
}
} else {
i11 = i10;
}
s3.sendEvent(new w1(i11, description));
}
}
return null;
}
public static s m0(p pVar, AKCDiscoverGlobal.DiscoverServerResponse discoverServerResponse) {
return (s) pVar.mo26invoke(discoverServerResponse, Boolean.TRUE);
}
public static void n0(AKeyDialog aKeyDialog, final p pVar, View view) {
aKeyDialog.dismiss();
AKCDiscoverManager.INSTANCE.getInstance().refreshServer(new vd.l() {
@Override
public final Object invoke(Object obj) {
kd.s m02;
m02 = AKCoreService.m0(vd.p.this, (AKCDiscoverGlobal.DiscoverServerResponse) obj);
return m02;
}
}, false);
}
public void o0(Activity activity, AKeyDialog aKeyDialog, View view) {
XMPPConnectionManager.INSTANCE.getInstance().setDoLogin(false);
AKCDiscoverInstance queryDiscoverInstanceBy = AKCDiscoverInstance.INSTANCE.queryDiscoverInstanceBy(f1.getInstance().getServerId());
if (queryDiscoverInstanceBy != null && queryDiscoverInstanceBy.getBestAccessServerNetInfo() != -1) {
queryDiscoverInstanceBy.getServer_net_info().get(queryDiscoverInstanceBy.getBestAccessServerNetInfo()).reSet(f1.getInstance().getServerId());
queryDiscoverInstanceBy.save();
}
this.f2733e = 0;
I = 0;
if (activity instanceof AKeyLauncherActivity) {
s3.sendEvent(new i5());
aKeyDialog.dismiss();
} else {
aKeyDialog.dismiss();
new c1(activity, 1, false, true, (AccountInfo) null).start();
}
}
public static s p0(p pVar, AKCDiscoverGlobal.DiscoverServerResponse discoverServerResponse) {
return (s) pVar.mo26invoke(discoverServerResponse, Boolean.TRUE);
}
public static s q0(p pVar, AKCDiscoverGlobal.DiscoverServerResponse discoverServerResponse) {
return (s) pVar.mo26invoke(discoverServerResponse, Boolean.FALSE);
}
public static void r0() {
AKeyManager.getInstance().init();
}
public void s0(Long l10) throws Exception {
try {
Log.i("AKCoreService", "start init time");
o3.initTimeRecorder();
} catch (InterruptedException unused) {
Log.w("AKCoreService", "timer init is interrupted");
} catch (Exception unused2) {
}
E0();
Log.i("AKCoreService", "after init folder");
}
public static void t0(Long l10) throws Exception {
f1.getInstance().uploadBlackListToServer(null);
}
public static Long u0(Long l10) throws Exception {
while (VoIpManager.getInstance().getmCurrentCall() != null) {
Thread.sleep(5000L);
}
return l10;
}
public void v0(Long l10) throws Exception {
if (this.f2749u) {
stopForeground(true);
BadgeManager.getSingleton().clearBadge(this.f2729a);
Process.killProcess(Process.myPid());
}
}
public void x0(String str, String str2, String str3, boolean z10, String str4, String str5) {
HashMap hashMap = new HashMap();
if (z10) {
Log.i("AKCoreService", "upload ok resUrl success :" + str5);
f1.getInstance().saveCollect_log(null);
FileUtil.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");
J0(str, str2, str3);
FileUtil.deleteFile(str4);
return;
} else {
Log.i("AKCoreService", "no log to upload");
hashMap.put("collect_id", str);
hashMap.put("status", "log lost");
}
F0(hashMap);
}
public static void y0(Long l10) throws Exception {
try {
Log.i("AKCoreService", "start init time");
o3.initTimeRecorder();
} catch (InterruptedException unused) {
Log.w("AKCoreService", "timer init is interrupted");
}
Log.i("AKCoreService", "after init folder");
}
public static void z0(long j10, Long l10) throws Exception {
long uptimeMillis = SystemClock.uptimeMillis();
long j11 = uptimeMillis - AKApplication.D;
Log.i("AKCoreService", "current time is " + uptimeMillis + "," + j11 + "," + j10);
if (j11 >= j10) {
if (!AKApplication.f784k) {
try {
Log.i("AKCoreService", "SwitchToForegroundOrBackgroundEvent to back,check sip");
int i10 = 0;
while (true) {
if (VoIpManager.getInstance().getmCurrentCall() != null) {
if (i10 > 60 && !VoIpManager.getInstance().getmCurrentCall().hasMedia()) {
Log.e("AKCoreService", "SwitchToForegroundOrBackgroundEvent call is not null break");
break;
} else {
Thread.sleep(1000L);
i10++;
}
} else {
break;
}
}
Log.i("AKCoreService", "SwitchToForegroundOrBackgroundEvent to back prepare is leaveStatus :" + AKApplication.f784k);
if (!AKApplication.f784k) {
XMPPConnectionManager.Companion companion = XMPPConnectionManager.INSTANCE;
if (companion.getInstance().isEffective()) {
companion.getInstance().reconnect(false);
return;
}
return;
}
return;
} catch (Exception e10) {
Log.e("AKCoreService", "SwitchToForegroundOrBackgroundEvent timerForLeaveStatus failed,e is " + e10.getMessage());
return;
}
}
Log.e("AKCoreService", "SwitchToForegroundOrBackgroundEvent current isLeaveStatus drop ");
return;
}
Log.i("AKCoreService", "SwitchToForegroundOrBackgroundEvent to back wrong");
}
public void akUnstableChatBroadcast(String str, String str2, String str3) {
Intent intent = new Intent(u0.T);
intent.putExtra(UnStableChatStatusReceiver.f1223a, new UnStableCallInfo(str2, str, str3));
this.f2729a.sendBroadcast(intent);
}
public void analysisNet(Long l10) {
f1 f1Var = f1.getInstance();
try {
InetAddress byName = InetAddress.getByName("www.baidu.com");
if (!byName.isLoopbackAddress() && (byName instanceof Inet4Address)) {
Log.d("morse", "analysisNet onSuccess ");
f1Var.f2084x1.add("success" + l10);
} else {
Log.d("morse", "analysisNet onFailure 0");
f1Var.f2084x1.add(StreamManagement.Failed.ELEMENT + l10);
}
} catch (Throwable th) {
Log.d("morse", "analysisNet onFailure 1 " + th);
}
}
public void asimCoreServicePostRunner(Runnable runnable, long j10) {
Handler handler = this.f2730b;
if (handler != null) {
handler.postDelayed(runnable, j10);
}
}
public a1.a generateExPrivateHandler(final Akeychat.UserPrivateSyncResponse userPrivateSyncResponse) {
return new a1.a() {
@Override
public final void execute() {
AKCoreService.k0(Akeychat.UserPrivateSyncResponse.this);
}
};
}
public boolean handleEnvironmentDetect() {
w1 environmentDetectResult = AkeyChatUtils.getEnvironmentDetectResult(this);
if (environmentDetectResult == null) {
return false;
}
XMPPConnectionManager.Companion companion = XMPPConnectionManager.INSTANCE;
companion.setmLoginCode(environmentDetectResult.f48964a);
s3.sendEvent(environmentDetectResult);
companion.getInstance().destroy(false);
return true;
}
@Override
public IBinder onBind(Intent intent) {
Log.i("AKCoreService", "onBind");
return this.f2743o;
}
@Override
public void onCreate() {
super.onCreate();
Log.i("AKCoreService", "core service create ");
K = true;
this.f2745q = true;
MessageManager.initWorker();
this.f2729a = this;
XMPPConnectionManager.INSTANCE.getInstance().setDoLogin(false);
this.f2730b = new Handler();
this.f2731c = MessageListenerManger.getInstance();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("android.intent.action.MEDIA_SHARED");
intentFilter.addAction(F);
intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
intentFilter.addAction(u0.f40390c);
intentFilter.addAction(u0.f40420r);
intentFilter.addAction(u0.f40423t);
intentFilter.addAction(u0.f40427x);
intentFilter.addAction(u0.f40429z);
intentFilter.addAction(u0.f40426w);
intentFilter.addAction(u0.f40425v);
intentFilter.addAction(u0.A);
intentFilter.addAction(ABKeySettingActivity.A);
intentFilter.addAction(u0.f40418q);
intentFilter.addAction(u0.O);
intentFilter.addAction(u0.B);
intentFilter.addAction(u0.Q);
intentFilter.addAction(u0.C);
intentFilter.addAction(u0.S);
intentFilter.addAction(u0.E);
intentFilter.addAction(u0.P);
intentFilter.addAction(u0.D);
intentFilter.addAction(u0.f40428y);
intentFilter.addAction(p.a.f44689f);
intentFilter.addAction("android.intent.action.CLOSE_SYSTEM_DIALOGS");
intentFilter.addAction("android.intent.action.SCREEN_OFF");
intentFilter.addAction("android.intent.action.USER_PRESENT");
intentFilter.addAction(G);
registerReceiver(this.f2741m, intentFilter);
SimStateReceiver simStateReceiver = this.f2732d;
registerReceiver(simStateReceiver, simStateReceiver.getFilter());
MessageManager.addHandlerIntoSender(new a1.a() {
@Override
public final void execute() {
AKCoreService.r0();
}
});
H0();
G0();
if (!o3.isInternetTimeRight()) {
fc.z.timer(0L, TimeUnit.MILLISECONDS, gd.b.io()).subscribe(new mc.g() {
@Override
public final void accept(Object obj) {
AKCoreService.this.s0((Long) obj);
}
});
} else {
E0();
}
f1.getInstance().uploadBlackListErrorToOSS();
f1.getInstance().loadBlackListFromServer();
TimeUnit timeUnit = TimeUnit.SECONDS;
this.f2736h = fc.z.timer(7L, timeUnit, gd.b.io()).subscribe(new mc.g() {
@Override
public final void accept(Object obj) {
AKCoreService.t0((Long) obj);
}
});
Log.i("AKCoreService", "AKApplication.isForegroundService " + AKApplication.f793t);
if (AKApplication.f793t && Build.VERSION.SDK_INT >= 26) {
f1.getInstance().setHadStartForeground(true);
startForeground(12, zb.getInstance().dispatchVoipCallNotify(this, getString(y1.app_name) + getString(y1.app_run_bg_hint), 12));
if (!f1.getInstance().isOpenForeground()) {
this.f2737i = new f();
fc.z.timer(60L, timeUnit).map(new o() {
@Override
public final Object apply(Object obj) {
Long u02;
u02 = AKCoreService.u0((Long) obj);
return u02;
}
}).subscribeOn(gd.b.io()).observeOn(ic.a.mainThread()).subscribe(this.f2737i);
}
} else {
f1.getInstance().setHadStartForeground(false);
}
this.f2735g = fc.z.interval(10L, 10L, TimeUnit.MINUTES).observeOn(gd.b.io()).subscribe(new mc.g() {
@Override
public final void accept(Object obj) {
AKCoreService.this.analysisNet((Long) obj);
}
});
W0();
}
@Override
@SuppressLint({"CheckResult"})
public void onDestroy() {
int i10;
super.onDestroy();
X();
f1.getInstance().setHadStartForeground(false);
Log.i("AKCoreService", "onDestroy");
AKCCheckPoint.endCheckAction("CHECKPOINT_LOGIN");
R0();
Q0();
ak.worker.f fVar = this.f2742n.get();
if (fVar != null) {
fVar.destroy();
}
zb.getInstance().clearAllMessageNotify();
unregisterReceiver(this.f2741m);
unregisterReceiver(this.f2732d);
Intent intent = new Intent(getApplicationContext(), (Class<?>) KeepLiveReceiver.class);
Context applicationContext = getApplicationContext();
int i11 = Build.VERSION.SDK_INT;
if (i11 >= 23) {
i10 = 201326592;
} else {
i10 = 0;
}
PendingIntent broadcast = PendingIntent.getBroadcast(applicationContext, 0, intent, i10);
AlarmManager alarmManager = (AlarmManager) getSystemService(NotificationCompat.CATEGORY_ALARM);
if (alarmManager != null && i11 >= 23) {
Log.debug("AKCoreService", "设置一次性");
try {
alarmManager.set(2, SystemClock.elapsedRealtime() + 5000, broadcast);
} catch (Exception e10) {
Log.e("AKCoreService", "onDestroy alarmMgr set error , " + e10.getMessage());
}
}
if (this.f2745q) {
if (f1.getInstance().isOpenForeground() && Build.VERSION.SDK_INT >= 26) {
Log.i("AKCoreService", "needRestartMyself isOpenForeground");
Intent intent2 = new Intent(this, (Class<?>) AKCoreService.class);
intent2.putExtra("launch-mode", "auto_login");
try {
startForegroundService(intent2);
return;
} catch (Exception e11) {
e11.printStackTrace();
}
}
if (AKApplication.f777d && Build.VERSION.SDK_INT >= 26) {
Log.w("AKCoreService", "run bg do not start service");
return;
}
Intent intent3 = new Intent(this, (Class<?>) AKCoreService.class);
intent3.putExtra("launch-mode", "auto_login");
try {
startService(intent3);
return;
} catch (Exception e12) {
e12.printStackTrace();
return;
}
}
Log.i("AKCoreService", "clear name:" + this.f2746r + ",clear pwd:" + this.f2747s + ",needKillPro:" + this.f2749u + ",need clear data:" + this.f2748t);
if (this.f2748t) {
String userRootPath = FileUtil.getUserRootPath();
Log.i("AKCoreService", "delete file path:" + userRootPath);
FileUtil.deleteFile(userRootPath);
FileUtil.deleteFile(FileUtil.getSandBoxPath());
String username = f1.getInstance().getUsername();
if (!TextUtils.isEmpty(username)) {
try {
File encryptedDatabasePath = ak.db.d.getEncryptedDatabasePath(this, username);
FileUtil.deleteFile(encryptedDatabasePath);
FileUtil.deleteFile(FileUtil.getDownloadPath(this));
Log.w("AKCoreService", "after delete folder,ret:" + FileUtil.checkPathValid(userRootPath));
Log.w("AKCoreService", "after delete db-file:" + encryptedDatabasePath.getAbsolutePath() + ",ret:" + FileUtil.checkPathValid(encryptedDatabasePath.getAbsolutePath()));
} catch (Exception e13) {
e13.printStackTrace();
}
}
}
if (this.f2746r) {
f1.getInstance().setUsername(null);
f1.getInstance().setCountryCode(null);
}
if (this.f2747s) {
f1.getInstance().setPassword(null);
f1.getInstance().setEncryptedPassword(null);
AkeyChatUtils.cancelConnectivityJobScheduler();
CookieManager.getInstance().removeAllCookie();
}
f1.getInstance().saveCollect_log(null);
f1.getInstance().saveReSendCollectLogNotice(null);
f1.getInstance().saveLoginConfig();
if (this.f2740l) {
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");
}
}
fc.z.timer(0L, TimeUnit.MILLISECONDS, gd.b.io()).subscribe(new mc.g() {
@Override
public final void accept(Object obj) {
AKCoreService.this.v0((Long) obj);
}
});
}
@Subscribe(threadMode = ThreadMode.ASYNC)
public void onEventAsync(e6 e6Var) {
Thread.currentThread().setName("send-report-message-event-" + Thread.currentThread());
MessageManager.addHandlerIntoSender(new r1(e6Var.f35695c, e6Var.f35693a, e6Var.f35694b));
}
@Subscribe(sticky = true, threadMode = ThreadMode.BACKGROUND)
public void onEventBackgroundThread(g.l lVar) {
Log.i("AKCoreService", "onEventBackgroundThread,recv one event:" + lVar.getmEventType());
f1.getInstance().getGroupSpeakListMap().clear();
EventBus.getDefault().removeStickyEvent(lVar);
if ("start_online".equals(lVar.getmEventType())) {
S();
s3.sendEvent(h3.getInstance("start-on-line"));
long currentTimeMillis = System.currentTimeMillis();
for (int i10 = 10; !f1.getInstance().isOnline() && i10 > 0; i10--) {
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(o7 o7Var) {
String str = o7Var.f35804a;
if (str != null) {
L0(str);
return;
}
int i10 = o7Var.f35805b;
if (i10 > 0) {
L0(getResources().getString(i10));
}
}
@Override
public int onStartCommand(Intent intent, int i10, int i11) {
Log.i("AKCoreService", "service start");
if (this.f2752x) {
s3.sendEvent(new g.g0("start-check-login-in-on-start-service"));
}
this.f2752x = true;
return 2;
}
public void resetTimes() {
Log.i("AKCoreService", "normal login ,reset times");
this.f2733e = 0;
}
public void ringtone() {
try {
Ringtone ringtone = RingtoneManager.getRingtone(this.f2729a, RingtoneManager.getActualDefaultRingtoneUri(this.f2729a, 2));
Log.i("AKCoreService", "ringtone is " + ((AudioManager) this.f2729a.getSystemService(ChatMessage.CHAT_AUDIO)).getRingerMode());
ringtone.play();
Vibrator vibrator = (Vibrator) getSystemService("vibrator");
AudioAttributes.Builder builder = new AudioAttributes.Builder();
builder.setContentType(4);
builder.setUsage(5);
vibrator.vibrate(new long[]{0, 300, 80, 120}, -1, builder.build());
} catch (Exception e10) {
Log.i("AKCoreService", "ringtone failed , reason is " + e10.getMessage());
e10.printStackTrace();
}
}
public void sendAKBroadcast(String str) {
this.f2729a.sendBroadcast(new Intent(str));
}
public a1.a sendLogFile(final String str, final String str2, final String str3) {
return new ak.worker.e(str3, this.f2729a, str, str2, new d0() {
@Override
public final void onSentResult(boolean z10, String str4, String str5) {
AKCoreService.this.x0(str3, str, str2, z10, str4, str5);
}
});
}
public void showToast(String str, int i10) {
if (AKApplication.f777d) {
Log.w("AKCoreService", "app run bg we do not toast:" + str);
return;
}
c0.f40451a.showToast(this.f2729a, str, i10);
}
public void startTimerForSip(long j10, final long j11) {
this.f2734f = fc.z.timer(j11 - j10, TimeUnit.MILLISECONDS).subscribe(new mc.g() {
@Override
public final void accept(Object obj) {
AKCoreService.z0(j11, (Long) obj);
}
});
}
public void startTimerToFindID(int i10) {
long j10 = i10;
this.f2754z = fc.z.interval(j10, j10, TimeUnit.MINUTES).observeOn(gd.b.io()).subscribe(new j());
}
public void stopFindIdTimer() {
jc.b bVar = this.f2754z;
if (bVar != null) {
bVar.dispose();
}
}
public void unstablechat_destroy_(String str, String str2, String str3) {
Message unStableChatCtrlMessage = sd.getIntance().getUnStableChatCtrlMessage(str3, str2, str, CtrlMessage.DESTROY_UNSTABLECHAT_IN);
if (unStableChatCtrlMessage != null) {
MessageManager.addHandlerIntoSender(new s1(unStableChatCtrlMessage));
}
}
public void unstablechat_heart_(String str, String str2, String str3) {
Message unStableChatCtrlMessage = sd.getIntance().getUnStableChatCtrlMessage(str3, str2, str, CtrlMessage.UNSTABLECHAT_HEART);
if (unStableChatCtrlMessage != null) {
MessageManager.addHandlerIntoSender(new s1(unStableChatCtrlMessage));
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(f6 f6Var) {
List<ChatMessage> list = f6Var.f35706a;
if (list == null) {
Log.w("AKCoreService", "empty message list do not need send recv receipts ");
return;
}
if (!f1.getInstance().getPrivacyRecvAndReadSwitch()) {
Log.w("AKCoreService", "sorry switch is off so can not send receive receipts");
return;
}
for (ChatMessage chatMessage : list) {
if (IMMessage.RECV.equals(chatMessage.getDir())) {
MessageManager.addHandlerIntoRecver(new a1.g0(chatMessage, Boolean.FALSE));
}
}
}
@Subscribe(threadMode = ThreadMode.ASYNC)
public void onEventAsync(e3 e3Var) {
sendAKBroadcast(u0.f40414o);
sendAKBroadcast(u0.f40412n);
sendAKBroadcast(u0.f40416p);
this.f2731c.addConnectionListener();
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(g.g0 g0Var) {
if (XMPPConnectionManager.INSTANCE.getInstance().isEffective()) {
Log.w("AKCoreService", "xmpp is effective do not need re-connect:" + g0Var.f35711a);
return;
}
Log.i("AKCoreService", "receive a check login event in ak-coreservice");
if (!"receiver".equals(g0Var.f35711a) || AKApplication.isAppHadLogin()) {
O0("check_login");
}
}
@Subscribe(threadMode = ThreadMode.BACKGROUND)
public void onEventBackgroundThread(u3 u3Var) {
MessageManager.addHandlerIntoSender(new p1(u3Var.f35851a));
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(f3 f3Var) {
String f35704a = f3Var.getF35704a();
if (f3.isAutoLogin(f35704a) | "manual_login".equals(f35704a) | "AnyOffice".equals(f35704a)) {
O0(f35704a);
return;
}
Log.w("AKCoreService", "other login type handle it by yourself:" + f35704a);
}
@Subscribe(threadMode = ThreadMode.MAIN)
@SuppressLint({"CheckResult"})
public void onEventMainThread(InitAPPPathEvent initAPPPathEvent) {
Log.i("AKCoreService", "check event:" + initAPPPathEvent.getCome());
fc.j.timer(0L, TimeUnit.SECONDS, gd.b.io()).subscribe(new mc.g() {
@Override
public final void accept(Object obj) {
AKApplication.initRootPath();
}
});
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(p0 p0Var) {
Log.i("AKCoreService", "need close app,reason is " + p0Var.getF35807a());
if (AKApplication.f777d) {
new c1(AKApplication.getTopActivity(), 1).start();
return;
}
Intent intent = new Intent(this, (Class<?>) UserConflictActivity.class);
intent.putExtra("description", p0Var.getF35807a());
intent.addFlags(User.UserStatus.camera_on);
intent.addFlags(536870912);
j.a.get().startActivity(intent);
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(n5 n5Var) {
resetTimes();
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(x0 x0Var) {
stopFindIdTimer();
startTimerToFindID(x0Var.getF35877b());
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(c7 c7Var) {
if (this.f2738j != null) {
Log.i("AKCoreService", "StopMaybeLoginEvent stop maybe");
this.f2738j.dispose();
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(p5 p5Var) {
ringtone();
}
@Subscribe(threadMode = ThreadMode.ASYNC)
public void onEventMainThread(g.c1 c1Var) {
String str;
Object f35667a = c1Var.getF35667a();
if (f35667a instanceof ak.im.module.User) {
ak.im.module.User user = (ak.im.module.User) f35667a;
str = user.getJID();
Akeychat.E2EKeysPublicBundle e2EKeysPublicBundle = user.getmPubKeyBundle();
Log.i("DecryptFailedEvent", user.getName() + "*identityKey is " + e.e.encodeBytes(e2EKeysPublicBundle.getIdentityKey().toByteArray()));
Log.i("DecryptFailedEvent", user.getName() + "*signedKey is " + e.e.encodeBytes(e2EKeysPublicBundle.getSignedKey().toByteArray()));
Iterator<Akeychat.E2EOneTimeKeyPublic> it = e2EKeysPublicBundle.getOneTimePreKeysList().iterator();
while (it.hasNext()) {
Log.i("DecryptFailedEvent", user.getName() + "*timeKey is " + e.e.encodeBytes(it.next().toByteArray()));
}
String username = f1.getInstance().getUsername();
Akeychat.E2EKeysPrivateBundle myKeyBundle = AKeyManager.getInstance().getMyKeyBundle();
Log.i("DecryptFailedEvent", username + "*identityKey is " + e.e.encodeBytes(myKeyBundle.getIdentityKey().toByteArray()));
Log.i("DecryptFailedEvent", username + "*signedKey is " + e.e.encodeBytes(myKeyBundle.getSignedKey().toByteArray()));
Iterator<Akeychat.E2EOneTimeKey> it2 = myKeyBundle.getOneTimePreKeysList().iterator();
while (it2.hasNext()) {
Log.i("DecryptFailedEvent", username + "*timeKey is " + e.e.encodeBytes(it2.next().toByteArray()));
}
} else if (f35667a instanceof Group) {
Group group = (Group) f35667a;
str = group.getName();
Akeychat.E2EKeysPrivateBundle e2EKeysPrivateBundle = group.getmKeyBundle();
Log.i("DecryptFailedEvent", group.getName() + "*timeKey is " + e.e.encodeBytes(e2EKeysPrivateBundle.getIdentityKey().toByteArray()));
Log.i("DecryptFailedEvent", group.getName() + "*signedKey is " + e.e.encodeBytes(e2EKeysPrivateBundle.getSignedKey().toByteArray()));
Iterator<Akeychat.E2EOneTimeKey> it3 = e2EKeysPrivateBundle.getOneTimePreKeysList().iterator();
while (it3.hasNext()) {
Log.i("DecryptFailedEvent", group.getName() + "*timeKey is " + e.e.encodeBytes(it3.next().toByteArray()));
}
} else {
str = "";
}
if (TextUtils.isEmpty(str)) {
return;
}
String str2 = f1.getInstance().getUsername() + str;
long j10 = f1.getInstance().getMMKV().getLong(str2, 0L);
long curDateLong = o3.getCurDateLong();
if (curDateLong - j10 >= 86400) {
f1.getInstance().getMMKV().putLong(str2, curDateLong);
try {
FileUtil.uploadLogFile("manual");
} catch (Exception e10) {
Log.e("DecryptFailedEvent", "uploadLogFile failed");
f1.getInstance().getMMKV().putLong(str2, 0L);
e10.printStackTrace();
}
}
}
@Subscribe(sticky = true, threadMode = ThreadMode.ASYNC)
public void onEventMainThread(i7 i7Var) {
if (f1.getInstance().isIgnoreCanLeave() || !AKCAppConfiguration.f9925a.canLeave()) {
return;
}
long f35746b = i7Var.getF35746b();
EventBus.getDefault().removeStickyEvent(i7Var);
if (!i7Var.getF35745a()) {
jc.b bVar = this.f2734f;
if (bVar != null) {
bVar.dispose();
}
if (AKApplication.f784k) {
XMPPConnectionManager.Companion companion = XMPPConnectionManager.INSTANCE;
if (companion.getInstance().isEffective()) {
try {
Log.i("AKCoreService", "SwitchToForegroundOrBackgroundEvent to foreground");
companion.getInstance().reconnect(false);
return;
} catch (Exception e10) {
AkeyChatUtils.logException(e10);
return;
}
}
}
if (AKApplication.f777d) {
startTimerForSip(0L, f35746b);
return;
}
return;
}
if (AKApplication.D != 0) {
long uptimeMillis = SystemClock.uptimeMillis();
long j10 = uptimeMillis - AKApplication.D;
Log.i("AKCoreService", "current time is " + uptimeMillis + "," + j10 + "," + f35746b);
if (j10 >= f35746b) {
try {
if (!AKApplication.f784k) {
Log.i("AKCoreService", "SwitchToForegroundOrBackgroundEvent to back,check sip");
int i10 = 0;
while (true) {
if (VoIpManager.getInstance().getmCurrentCall() != null) {
if (i10 > 60 && !VoIpManager.getInstance().getmCurrentCall().hasMedia()) {
Log.e("AKCoreService", "SwitchToForegroundOrBackgroundEvent call is not null break");
break;
} else {
Thread.sleep(1000L);
i10++;
}
} else {
break;
}
}
Log.i("AKCoreService", "SwitchToForegroundOrBackgroundEvent to back prepare is leaveStatus :" + AKApplication.f784k);
if (AKApplication.f784k) {
return;
}
XMPPConnectionManager.INSTANCE.getInstance().reconnect(false);
return;
}
Log.e("AKCoreService", "SwitchToForegroundOrBackgroundEvent current isLeaveStatus drop ");
return;
} catch (Exception e11) {
AkeyChatUtils.logException(e11);
return;
}
}
jc.b bVar2 = this.f2734f;
if (bVar2 != null && !bVar2.isDisposed()) {
Log.i("AKCoreService", "SwitchToForegroundOrBackgroundEvent current timerForLeaveStatus is doing");
return;
} else {
startTimerForSip(j10, f35746b);
return;
}
}
Log.e("AKCoreService", "current is not back ,drop SwitchToForegroundOrBackgroundEvent");
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(h0 h0Var) {
ChatMessage oneMessageByUniqueId = MessageManager.getInstance().getOneMessageByUniqueId(h0Var.getF35726a());
if (oneMessageByUniqueId != null) {
oneMessageByUniqueId.setmSeqNO(h0Var.getF35727b());
T(oneMessageByUniqueId);
} else {
Log.i("AKCoreService", "checkAndReportMsg msg is null");
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(g.o oVar) {
String string = f1.getInstance().getMMKV().getString("back_log_info", "");
JSONObject jSONObject = new JSONObject();
try {
JSONObject parseObject = JSON.parseObject(string);
if (parseObject != null) {
String str = oVar.getF35799a().split("-")[0];
for (String str2 : parseObject.keySet()) {
if (!str.equals(str2.split("-")[0])) {
jSONObject.put(str2, parseObject.get(str2));
}
}
}
} catch (Exception e10) {
e10.printStackTrace();
}
jSONObject.put(oVar.getF35799a(), (Object) Long.valueOf(System.currentTimeMillis()));
f1.getInstance().getMMKV().putString("back_log_info", jSONObject.toJSONString());
}
}