Trip On v2.1.2版本的 MD5 值为:55953a6deb5e434bd7a356ea51d31456
以下内容为反编译后的 MeiQiaService.java 源代码,内容仅作参考
package com.meiqia.core;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.text.TextUtils;
import com.baidu.speech.utils.AsrError;
import com.meiqia.core.a.j;
import com.meiqia.core.a.k;
import com.meiqia.core.bean.MQAgent;
import com.meiqia.core.bean.MQConversation;
import com.meiqia.core.bean.MQMessage;
import com.meiqia.core.bean.MQNotificationMessage;
import com.meiqia.core.callback.OnGetMessageListCallback;
import com.meiqia.core.callback.SimpleCallback;
import com.meiqia.core.h;
import com.meiqia.meiqiasdk.controller.MQController;
import com.taobao.weex.el.parse.Operators;
import io.dcloud.WebAppActivity;
import io.dcloud.common.DHInterface.IWebview;
import io.dcloud.common.constant.AbsoluteConst;
import io.dcloud.common.util.net.NetCheckReceiver;
import java.io.File;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.WebSocket;
import okhttp3.WebSocketListener;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class MeiQiaService extends Service {
public static boolean a = false;
public static boolean b = false;
public static boolean c = false;
public static boolean d = false;
protected static boolean e = false;
public static long f;
public static Set<Long> g = new HashSet();
public static Set<Long> h = new HashSet();
private com.meiqia.core.a.i n;
private a o;
private c p;
private Handler q;
private OkHttpClient r;
private WebSocket s;
private String v;
private boolean w;
private AtomicBoolean i = new AtomicBoolean(false);
private int j = 0;
private long k = 0;
private long l = 0;
private String m = "";
private boolean t = false;
private boolean u = false;
private AtomicBoolean x = new AtomicBoolean(false);
private class a extends BroadcastReceiver {
private boolean b;
private a() {
this.b = true;
}
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (NetCheckReceiver.netACTION.equals(action)) {
if (k.f(context) && !this.b) {
com.meiqia.core.a.f.b("socket net reconnect");
MeiQiaService.this.d();
}
this.b = false;
} else if ("ACTION_MQ_CONVERSATION_CLOSE".equals(action)) {
MeiQiaService.this.m();
com.meiqia.core.a.f.b("reset retryCount");
} else if ("ACTION_MARK_MESSAGES_READ".equals(action)) {
if (intent.getBooleanExtra("isOnlyRemarkRead", false)) {
MeiQiaService.this.q.sendEmptyMessage(5);
return;
}
long[] longArrayExtra = intent.getLongArrayExtra("message_ids");
long longExtra = intent.getLongExtra("conv_id", -1L);
if (longArrayExtra == null || longExtra == -1) {
return;
}
MeiQiaService.this.b(longExtra, longArrayExtra);
}
}
}
public void a() {
SSLContext sSLContext;
X509TrustManager x509TrustManager = new X509TrustManager() {
@Override
public void checkClientTrusted(X509Certificate[] x509CertificateArr, String str) {
}
@Override
public void checkServerTrusted(X509Certificate[] x509CertificateArr, String str) {
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
};
TrustManager[] trustManagerArr = {x509TrustManager};
SSLContext sSLContext2 = null;
try {
sSLContext = SSLContext.getInstance("SSL");
} catch (KeyManagementException e2) {
e = e2;
} catch (NoSuchAlgorithmException e3) {
e = e3;
}
try {
sSLContext.init(null, trustManagerArr, new SecureRandom());
} catch (KeyManagementException e4) {
e = e4;
sSLContext2 = sSLContext;
e.printStackTrace();
sSLContext = sSLContext2;
OkHttpClient.Builder builder = new OkHttpClient.Builder();
if (sSLContext != null) {
}
} catch (NoSuchAlgorithmException e5) {
e = e5;
sSLContext2 = sSLContext;
e.printStackTrace();
sSLContext = sSLContext2;
OkHttpClient.Builder builder2 = new OkHttpClient.Builder();
if (sSLContext != null) {
}
}
OkHttpClient.Builder builder22 = new OkHttpClient.Builder();
if (sSLContext != null) {
this.r = builder22.sslSocketFactory(sSLContext.getSocketFactory(), x509TrustManager).hostnameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String str, SSLSession sSLSession) {
return true;
}
}).build();
}
}
private void a(long j, long j2) {
if (j != f || g.contains(Long.valueOf(j2))) {
return;
}
g.add(Long.valueOf(j2));
}
public void a(final long j, final long... jArr) {
final JSONArray jSONArray = new JSONArray();
try {
for (long j2 : jArr) {
jSONArray.put(j2);
a(j, j2);
}
h.a().a(Long.parseLong(d.a.getEnterpriseId()), d.a.getTrackId(), j, jSONArray, new h.b() {
@Override
public void a(JSONObject jSONObject, Response response) {
MeiQiaService.this.a(jSONArray);
if (!MeiQiaService.d) {
MeiQiaService.this.b(j, jArr);
return;
}
for (long j3 : jArr) {
MeiQiaService.this.b(j, j3);
}
}
});
this.q.removeMessages(4);
this.q.sendEmptyMessageDelayed(4, 2000L);
} catch (Exception e2) {
e2.printStackTrace();
}
}
public void a(MQAgent mQAgent) {
if (MQManager.getInstance(this).getCurrentAgent().getAgentId() == mQAgent.getAgentId()) {
return;
}
MQManager.getInstance(this).a(mQAgent);
Intent intent = new Intent("agent_change_action");
intent.putExtra("client_is_redirected", true);
k.a(this, intent);
if (a) {
com.meiqia.core.a.f.b("action directAgent : agentName = " + mQAgent.getNickname());
}
}
public void a(MQMessage mQMessage) {
Intent intent = new Intent("agent_send_card");
intent.putExtra("clueCardMessageId", String.valueOf(mQMessage.getId()));
MQMessageManager.getInstance(this).setAgentClueCardMessage(mQMessage);
k.a(this, intent);
}
public void a(String str) {
MQManager.getInstance(this).a((MQAgent) null);
k.a(this, new Intent(str));
}
public void a(JSONArray jSONArray) {
if (jSONArray == null) {
return;
}
for (int i = 0; i < jSONArray.length(); i++) {
long optLong = jSONArray.optLong(i);
MQMessage b2 = f.a(this).b(optLong);
if (b2 != null) {
b2.setRead_status(2);
f.a(this).a(b2);
}
g.remove(Long.valueOf(optLong));
if (g.size() == 0) {
this.q.removeMessages(4);
}
com.meiqia.core.a.f.b("ack Delivered " + optLong);
}
}
public void a(JSONObject jSONObject) {
JSONObject optJSONObject = jSONObject.optJSONObject("body");
if (optJSONObject != null) {
MQMessage b2 = com.meiqia.core.a.c.b(optJSONObject);
d.a(b2, System.currentTimeMillis());
b(b2);
this.n.c(d.a, System.currentTimeMillis());
}
}
public void b() {
if ((this.s != null && e) || d.a == null || this.t) {
return;
}
if (this.r == null) {
this.r = new OkHttpClient.Builder().build();
}
this.v = d.a.getTrackId();
com.meiqia.core.a.f.b("socket init");
this.t = true;
d.a.setBrowserId(g());
f.a(this).a(d.a);
if (!TextUtils.equals(this.m, d.a.getTrackId())) {
g.clear();
h.clear();
}
this.m = d.a.getTrackId();
String browserId = d.a.getBrowserId();
String str = this.m;
String visitId = d.a.getVisitId();
String str2 = "?browser_id=" + browserId + "&ent_id=" + (d.a.getEnterpriseId() + "") + "&visit_id=" + visitId + "&visit_page_id=" + d.a.getVisitPageId() + "&track_id=" + str + "&time=" + (System.currentTimeMillis() + "");
com.meiqia.core.a.f.b("socket: t = " + str + " b = " + browserId + " v = " + visitId);
try {
this.s = this.r.newWebSocket(new Request.Builder().header(IWebview.USER_AGENT, ("Mozilla/5.0 (Linux; Android " + Build.VERSION.RELEASE + "; " + Build.MODEL + Operators.SPACE_STR + Build.DEVICE + ") MeiqiaSDK/ Source/SDK " + MQManager.getMeiqiaSDKVersion() + " Language/" + Locale.getDefault().getLanguage()).replaceAll("[^\\x00-\\x7F]", "")).url("wss://eco-push-api-client.meiqia.com/pusher/websocket" + str2).build(), new WebSocketListener() {
@Override
public void onClosed(WebSocket webSocket, int i, String str3) {
com.meiqia.core.a.f.b("socket close: i = " + i + " s = " + str3);
MeiQiaService.e = false;
MeiQiaService.this.t = false;
MeiQiaService.this.d();
}
@Override
public void onFailure(WebSocket webSocket, Throwable th, Response response) {
if (th instanceof SSLHandshakeException) {
MeiQiaService.this.a();
}
MeiQiaService.e = false;
MeiQiaService.this.t = false;
MeiQiaService.this.d();
com.meiqia.core.a.f.b("socket error: message = " + th.getMessage() + " class = " + th.getClass().getSimpleName());
}
@Override
public void onMessage(WebSocket webSocket, String str3) {
if (TextUtils.isEmpty(str3) || MeiQiaService.b) {
return;
}
try {
JSONObject jSONObject = new JSONObject(str3);
String optString = jSONObject.optString("action");
if ("message".equals(optString)) {
MQMessage b2 = com.meiqia.core.a.c.b(jSONObject);
MeiQiaService.this.b(b2);
if (TextUtils.equals(b2.getFrom_type(), "agent")) {
MeiQiaService.this.a(b2.getConversation_id(), b2.getId());
}
} else if ("agent_send_card".equals(optString)) {
MeiQiaService.this.a(com.meiqia.core.a.c.a(jSONObject));
} else if ("ticket_reply".equals(optString)) {
MeiQiaService.this.a(jSONObject);
} else if (MQMessageManager.ACTION_RECALL_MESSAGE.equals(optString)) {
MeiQiaService.this.c(jSONObject);
} else if ("agent_redirect".equals(optString) || "timeout_redirect".equals(optString) || "bot_redirect_auto".equals(optString) || "bot_redirect_manual".equals(optString) || "bot_redirect_keyword".equals(optString)) {
MeiQiaService.this.a(com.meiqia.core.a.c.c(jSONObject.optJSONObject("body").optJSONObject("to")));
} else if ("switch_human".equals(optString)) {
MeiQiaService.this.e();
} else if ("agent_inputting".equals(optString) || "mpush_simulate_inputting".equals(optString)) {
Intent intent = new Intent("agent_inputting_action");
JSONObject optJSONObject = jSONObject.optJSONObject("body");
intent.putExtra("duration", optJSONObject != null ? optJSONObject.optInt("interval", 2) : 2);
k.a(MeiQiaService.this, intent);
} else {
if (!"invite_evaluation".equals(optString)) {
if (MQMessageManager.ACTION_END_CONV_TIMEOUT.equals(optString)) {
MeiQiaService.this.a(optString);
JSONObject optJSONObject2 = jSONObject.optJSONObject("body");
if (optJSONObject2 == null || !optJSONObject2.optBoolean("evaluation")) {
return;
}
} else if (!MQMessageManager.ACTION_END_CONV_AGENT.equals(optString)) {
if ("agent_update".equals(optString)) {
MeiQiaService.this.d(jSONObject);
return;
} else if (TextUtils.equals("visit_black_add", optString)) {
MeiQiaService.this.e(jSONObject);
return;
} else if (TextUtils.equals("visit_black_del", optString)) {
MeiQiaService.this.f(jSONObject);
return;
} else if ("queueing_remove".equals(optString)) {
MeiQiaService.this.f();
return;
} else if ("init_conv".equals(optString)) {
MeiQiaService.this.g(jSONObject);
return;
} else if ("mass_message_push".equals(optString)) {
MeiQiaService.this.h(jSONObject);
return;
} else {
"open_mass_message".equals(optString);
return;
}
} else {
MeiQiaService.this.a(optString);
JSONObject optJSONObject3 = jSONObject.optJSONObject("body");
if (optJSONObject3 == null || !optJSONObject3.optBoolean("evaluation")) {
return;
}
}
}
MeiQiaService.this.b(jSONObject);
}
} catch (JSONException unused) {
}
}
@Override
public void onOpen(WebSocket webSocket, Response response) {
com.meiqia.core.a.f.b("socket open");
MeiQiaService.e = true;
MeiQiaService.this.x.set(false);
MeiQiaService.this.t = false;
MeiQiaService.this.q.removeMessages(3);
if (!MeiQiaService.this.u) {
MeiQiaService.this.q.sendEmptyMessageDelayed(3, 2000L);
}
MeiQiaService.this.u = false;
MeiQiaService.this.q.removeMessages(1);
MeiQiaService.this.k();
k.a(MeiQiaService.this, new Intent(MQMessageManager.ACTION_SOCKET_OPEN));
Object a2 = i.a().a("ONLINE_MARK_READ_CONVERSATION_KEY");
if (a2 != null) {
MQConversation mQConversation = (MQConversation) a2;
MeiQiaService.this.b(mQConversation.getId(), k.a(mQConversation.getMessageList()));
}
}
});
} catch (Exception unused) {
e = false;
this.t = false;
com.meiqia.core.a.f.a("socket AssertionError");
}
}
public void b(long j, long j2) {
if (j != f || h.contains(Long.valueOf(j2))) {
return;
}
h.add(Long.valueOf(j2));
}
public void b(long j, long[] jArr) {
JSONObject jSONObject = new JSONObject();
final JSONArray jSONArray = new JSONArray();
try {
for (long j2 : jArr) {
jSONArray.put(j2);
b(j, j2);
}
jSONObject.put("action", "msg_read");
jSONObject.put("conv_id", j);
jSONObject.put("msg_ids", jSONArray);
h.a().b(Long.parseLong(d.a.getEnterpriseId()), d.a.getTrackId(), j, jSONArray, new h.b() {
@Override
public void a(JSONObject jSONObject2, Response response) {
MeiQiaService.this.b(jSONArray);
}
});
this.q.sendEmptyMessageDelayed(5, 2000L);
} catch (Exception e2) {
e2.printStackTrace();
}
}
public void b(final MQMessage mQMessage) {
mQMessage.setIs_read(false);
if ("ending".equals(mQMessage.getType())) {
MQManager.getInstance(this).a((MQAgent) null);
}
if ("audio".equals(mQMessage.getType())) {
mQMessage.setIs_read(false);
c(mQMessage);
} else if (TextUtils.equals(mQMessage.getFrom_type(), "client")) {
this.q.postDelayed(new Runnable() {
@Override
public void run() {
MeiQiaService.this.p.a(mQMessage);
}
}, 100L);
} else {
this.p.a(mQMessage);
}
}
public void b(JSONArray jSONArray) {
if (jSONArray == null) {
return;
}
for (int i = 0; i < jSONArray.length(); i++) {
long optLong = jSONArray.optLong(i);
MQMessage b2 = f.a(this).b(optLong);
if (b2 != null) {
b2.setRead_status(3);
f.a(this).a(b2);
}
h.remove(Long.valueOf(optLong));
if (h.size() == 0) {
this.q.removeMessages(5);
}
}
}
public void b(JSONObject jSONObject) {
String optString = jSONObject.optString("target_id");
if (TextUtils.isEmpty(optString)) {
return;
}
Intent intent = new Intent("invite_evaluation");
intent.putExtra("conversation_id", optString);
k.a(this, intent);
}
private void c() {
WebSocket webSocket = this.s;
if (webSocket != null) {
e = false;
webSocket.close(1000, "manual");
}
}
private void c(final MQMessage mQMessage) {
File externalCacheDir = getExternalCacheDir();
String media_url = mQMessage.getMedia_url();
if (externalCacheDir == null || !k.a()) {
b(mQMessage);
return;
}
String absolutePath = externalCacheDir.getAbsolutePath();
h.a().a(media_url, absolutePath, mQMessage.getId() + "", new SimpleCallback() {
@Override
public void onFailure(int i, String str) {
MeiQiaService.this.b(mQMessage);
}
@Override
public void onSuccess() {
MeiQiaService.this.b(mQMessage);
}
});
}
public void c(JSONObject jSONObject) {
Intent intent = new Intent(MQMessageManager.ACTION_RECALL_MESSAGE);
intent.putExtra("nickname", jSONObject.optString("agent_nickname"));
long optLong = jSONObject.optJSONObject("body").optLong("msg_id");
intent.putExtra("id", optLong);
f.a(this).a(optLong);
k.a(this, intent);
}
public void d() {
if (e || this.x.get() || b || !k.f(this) || d.a == null) {
return;
}
this.x.set(true);
this.q.sendEmptyMessageDelayed(1, WebAppActivity.SPLASH_SECOND);
i();
k.a(this, new Intent(MQController.ACTION_SOCKET_RECONNECT));
}
public void d(JSONObject jSONObject) {
JSONObject optJSONObject = jSONObject.optJSONObject("body");
if (optJSONObject != null) {
MQAgent c2 = com.meiqia.core.a.c.c(optJSONObject);
MQAgent currentAgent = MQManager.getInstance(this).getCurrentAgent();
if (currentAgent != null) {
c2.setNickname(currentAgent.getNickname());
MQManager.getInstance(this).a(c2);
k.a(this, new Intent("action_agent_status_update_event"));
}
}
}
public void e() {
MQManager.getInstance(this).a((MQAgent) null);
k.a(this, new Intent("no_agent_action"));
}
public void e(JSONObject jSONObject) {
if (TextUtils.equals(jSONObject.optString("track_id"), this.v)) {
MQManager.getInstance(this).a((MQAgent) null);
k.a(this, new Intent("action_black_add"));
}
}
public void f() {
this.w = true;
MQManager.getInstance(this).a(false);
k.a(this, new Intent("action_queueing_remove"));
}
public void f(JSONObject jSONObject) {
if (TextUtils.equals(jSONObject.optString("track_id"), this.v)) {
k.a(this, new Intent("action_black_del"));
}
}
private String g() {
StringBuilder sb = new StringBuilder();
sb.append(System.currentTimeMillis());
String str = "";
sb.append("");
String sb2 = sb.toString();
Random random = new Random();
for (int i = 0; i < 5; i++) {
str = str + random.nextInt(10);
}
return str + sb2;
}
public void g(JSONObject jSONObject) {
JSONObject optJSONObject;
JSONObject optJSONObject2;
if ((!this.w && (d.b == null || d.b.isRealAgent())) || (optJSONObject = jSONObject.optJSONObject("body")) == null || (optJSONObject2 = optJSONObject.optJSONObject("agent")) == null) {
return;
}
MQAgent c2 = com.meiqia.core.a.c.c(optJSONObject2);
c2.setIsOnline(true);
MQManager.getInstance(this).a(false);
long j = 0;
try {
j = Long.parseLong(jSONObject.optString("target_id"));
} catch (Exception e2) {
e2.printStackTrace();
}
this.n.a(d.a, j);
MQManager.getInstance(this).a(c2);
Intent intent = new Intent("action_queueing_init_conv");
intent.putExtra("convId", j);
k.a(this, intent);
this.w = false;
}
static long h(MeiQiaService meiQiaService) {
long j = meiQiaService.k;
meiQiaService.k = 1 + j;
return j;
}
public void h() {
com.meiqia.core.a.f.b("service synMessages");
MQManager.getInstance(this).a(new OnGetMessageListCallback() {
@Override
public void onFailure(int i, String str) {
}
@Override
public void onSuccess(List<MQMessage> list) {
for (MQMessage mQMessage : list) {
MeiQiaService.this.p.a(mQMessage);
}
}
});
}
public void h(JSONObject jSONObject) {
MQNotificationMessage e2 = com.meiqia.core.a.c.e(jSONObject.optJSONObject("body"));
if (e2 == null) {
com.meiqia.core.a.f.a("handleNotificationMessage null");
} else {
g.a().a((Context) this, e2, true);
}
}
private void i() {
if (j()) {
this.i.set(true);
this.q.sendEmptyMessageDelayed(2, l());
}
}
static long j(MeiQiaService meiQiaService) {
long j = meiQiaService.l;
meiQiaService.l = 1 + j;
return j;
}
private boolean j() {
return (e || this.i.get() || b || !k.f(this) || d.a == null || 50 < ((long) this.j) || c) ? false : true;
}
public void k() {
this.j = 0;
this.i.set(false);
this.q.removeMessages(2);
}
public long l() {
int nextInt = new Random().nextInt(6) * 1000;
if (nextInt < 3000) {
nextInt = 3000;
}
return nextInt + (this.j * 500);
}
public void m() {
this.j = 0;
}
public void n() {
if (j()) {
final long b2 = this.n.b(d.a);
String a2 = j.a(b2);
HashMap hashMap = new HashMap();
hashMap.put("socket_error", AbsoluteConst.TRUE);
hashMap.put("limit", "100");
hashMap.put("ent_id", d.a.getEnterpriseId());
hashMap.put("last_message_created_on", a2);
hashMap.put("ascending", "1");
hashMap.put("_time", String.valueOf(System.currentTimeMillis()));
h.a().a(hashMap, new OnGetMessageListCallback() {
@Override
public void onFailure(int i, String str) {
}
@Override
public void onSuccess(List<MQMessage> list) {
for (MQMessage mQMessage : list) {
if (mQMessage.getCreated_on() > b2) {
MeiQiaService.this.n.b(d.a, mQMessage.getCreated_on());
MeiQiaService.this.m();
}
MeiQiaService.this.p.a(mQMessage);
}
if (list.size() != 0) {
MeiQiaService.this.a(list.get(0).getConversation_id(), k.a(list));
}
}
});
this.j++;
com.meiqia.core.a.f.b("pollMessages retryCount = " + this.j);
}
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
this.q = new Handler();
this.o = new a();
this.n = new com.meiqia.core.a.i(this);
this.p = c.a(this);
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(NetCheckReceiver.netACTION);
intentFilter.addAction("ACTION_MQ_CONVERSATION_CLOSE");
intentFilter.addAction("ACTION_MARK_MESSAGE_READ");
intentFilter.addAction("ACTION_MARK_MESSAGES_READ");
registerReceiver(this.o, intentFilter);
this.q = new Handler(new Handler.Callback() {
@Override
public boolean handleMessage(Message message) {
int i = message.what;
if (1 == i) {
com.meiqia.core.a.f.b("socket reconnect");
MeiQiaService.this.x.set(false);
MeiQiaService.this.b();
} else if (2 == i) {
MeiQiaService.this.i.set(false);
MeiQiaService.this.n();
MeiQiaService.this.q.sendEmptyMessageDelayed(2, MeiQiaService.this.l());
} else if (3 == i) {
MeiQiaService.this.h();
} else if (4 == i) {
com.meiqia.core.a.f.b("MESSAGE_ACK_DELIVERED");
MeiQiaService.this.q.removeMessages(4);
if (MeiQiaService.g.size() != 0) {
for (Long l : MeiQiaService.g) {
MeiQiaService.this.a(MeiQiaService.f, l.longValue());
}
com.meiqia.core.a.f.b("ack needAckDeliveredSet.size() = " + MeiQiaService.g.size());
MeiQiaService.h(MeiQiaService.this);
MeiQiaService.this.q.sendEmptyMessageDelayed(4, (MeiQiaService.this.k * 2000) + 2000 + ((long) new Random().nextInt(AsrError.ERROR_NETWORK_FAIL_CONNECT)));
} else {
com.meiqia.core.a.f.b("MESSAGE_ACK_DELIVERED clear");
MeiQiaService.this.k = 0L;
}
} else if (5 == i) {
com.meiqia.core.a.f.b("MESSAGE_ACK_READ");
MeiQiaService.this.q.removeMessages(5);
if (MeiQiaService.h.size() != 0) {
try {
long[] jArr = new long[MeiQiaService.h.size()];
int i2 = 0;
for (Long l2 : MeiQiaService.h) {
jArr[i2] = l2.longValue();
i2++;
}
MeiQiaService.this.b(MeiQiaService.f, jArr);
com.meiqia.core.a.f.b("ack needAckReadMessageIdSet.size() = " + MeiQiaService.h.size());
MeiQiaService.j(MeiQiaService.this);
Handler handler = MeiQiaService.this.q;
long j = MeiQiaService.this.l;
Long.signum(j);
handler.sendEmptyMessageDelayed(5, (j * 2000) + 2000 + new Random().nextInt(AsrError.ERROR_NETWORK_FAIL_CONNECT));
} catch (Exception e2) {
e2.printStackTrace();
}
} else {
com.meiqia.core.a.f.b("MESSAGE_ACK_READ clear");
MeiQiaService.this.l = 0L;
}
}
return false;
}
});
}
@Override
public void onDestroy() {
super.onDestroy();
try {
this.q.removeMessages(1);
this.q.removeMessages(2);
this.q.removeMessages(3);
this.q.removeMessages(4);
this.q.removeMessages(5);
unregisterReceiver(this.o);
c();
} catch (Exception unused) {
}
}
@Override
public int onStartCommand(Intent intent, int i, int i2) {
if (d.a == null) {
return super.onStartCommand(intent, i, i2);
}
if ("ACTION_OPEN_SOCKET".equals(intent != null ? intent.getAction() : "ACTION_OPEN_SOCKET")) {
boolean z = false;
b = false;
if (!TextUtils.isEmpty(this.v) && !TextUtils.isEmpty(d.a.getTrackId()) && !d.a.getTrackId().equals(this.v)) {
c();
}
if (intent != null && intent.getBooleanExtra("KEY_BOOLEAN_SYNC_MSG", false)) {
z = true;
}
this.u = z;
b();
} else {
c();
}
return super.onStartCommand(intent, i, i2);
}
}