智慧城市 v1.2.1版本的 MD5 值为:d4aeacb5153a2710d0b6882be5dd2b15
以下内容为反编译后的 RongCoreClient.java 源代码,内容仅作参考
package io.rong.imlib;
import android.app.Activity;
import android.app.Application;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.Looper;
import android.os.Parcel;
import android.os.RemoteException;
import android.text.TextUtils;
import com.google.gson.Gson;
import io.rong.calllib.RongCallEvent;
import io.rong.common.ExpansionUtils;
import io.rong.common.FileUtils;
import io.rong.common.LibStorageUtils;
import io.rong.common.SystemUtils;
import io.rong.common.fwlog.FwLog;
import io.rong.common.fwlog.IFwLogWriter;
import io.rong.common.rlog.RLog;
import io.rong.common.rlog.RLogReporter;
import io.rong.imlib.ConversationStatusListener;
import io.rong.imlib.IConnectStringCallback;
import io.rong.imlib.IConnectionStatusListener;
import io.rong.imlib.IConversationListener;
import io.rong.imlib.IDownloadMediaFileCallback;
import io.rong.imlib.IDownloadMediaMessageCallback;
import io.rong.imlib.IGetNotificationQuietHoursCallback;
import io.rong.imlib.IHandler;
import io.rong.imlib.IIntegerCallback;
import io.rong.imlib.ILongCallback;
import io.rong.imlib.IMessageExpansionListener;
import io.rong.imlib.INaviContentUpdateCallBack;
import io.rong.imlib.IOperationCallback;
import io.rong.imlib.IRLogOtherProgressCallback;
import io.rong.imlib.IResultCallback;
import io.rong.imlib.IRongCoreCallback;
import io.rong.imlib.IRongCoreEnum;
import io.rong.imlib.IRongCoreListener;
import io.rong.imlib.ISendMediaMessageCallback;
import io.rong.imlib.ISendMessageCallback;
import io.rong.imlib.ISetPushSettingCallback;
import io.rong.imlib.IStringCallback;
import io.rong.imlib.IUploadCallback;
import io.rong.imlib.OnReceiveMessageListener;
import io.rong.imlib.ReadReceiptV2Manager;
import io.rong.imlib.RongCommonDefine;
import io.rong.imlib.UserProfileSettingListener;
import io.rong.imlib.common.DeviceUtils;
import io.rong.imlib.common.NetUtils;
import io.rong.imlib.common.RongLibConst;
import io.rong.imlib.common.SharedPreferencesUtils;
import io.rong.imlib.destruct.DestructionTaskManager;
import io.rong.imlib.destruct.MessageBufferPool;
import io.rong.imlib.ipc.IpcCallbackProxy;
import io.rong.imlib.ipc.RongService;
import io.rong.imlib.model.AndroidConfig;
import io.rong.imlib.model.Conversation;
import io.rong.imlib.model.ConversationIdentifier;
import io.rong.imlib.model.ConversationStatus;
import io.rong.imlib.model.ConversationTagInfo;
import io.rong.imlib.model.DownloadInfo;
import io.rong.imlib.model.HistoryMessageOption;
import io.rong.imlib.model.Message;
import io.rong.imlib.model.MessageContent;
import io.rong.imlib.model.RCSdkInfo;
import io.rong.imlib.model.ReadReceiptInfo;
import io.rong.imlib.model.RemoteHistoryMsgOption;
import io.rong.imlib.model.RemoteModelWrap;
import io.rong.imlib.model.SearchConversationResult;
import io.rong.imlib.model.SendMessageOption;
import io.rong.imlib.model.TagInfo;
import io.rong.imlib.rtc.RoomUserStateMessage;
import io.rong.imlib.statistics.Statistics;
import io.rong.imlib.typingmessage.TypingMessageManager;
import io.rong.imlib.typingmessage.TypingStatus;
import io.rong.imlib.typingmessage.TypingStatusMessage;
import io.rong.message.CommandMessage;
import io.rong.message.CommandNotificationMessage;
import io.rong.message.ContactNotificationMessage;
import io.rong.message.DestructionCmdMessage;
import io.rong.message.FileMessage;
import io.rong.message.GIFMessage;
import io.rong.message.GroupNotificationMessage;
import io.rong.message.GroupReadReceiptV2Message;
import io.rong.message.HQVoiceMessage;
import io.rong.message.HandshakeMessage;
import io.rong.message.HistoryDividerMessage;
import io.rong.message.ImageMessage;
import io.rong.message.InformationNotificationMessage;
import io.rong.message.LogCmdMessage;
import io.rong.message.MediaMessageContent;
import io.rong.message.MessageExpansionMessage;
import io.rong.message.ProfileNotificationMessage;
import io.rong.message.ReadReceiptMessage;
import io.rong.message.ReadReceiptRequestMessage;
import io.rong.message.ReadReceiptResponseMessage;
import io.rong.message.RecallCommandMessage;
import io.rong.message.RecallNotificationMessage;
import io.rong.message.ReferenceMessage;
import io.rong.message.RichContentMessage;
import io.rong.message.SuspendMessage;
import io.rong.message.SyncReadStatusMessage;
import io.rong.message.TextMessage;
import io.rong.message.VoiceMessage;
import io.rong.push.PushManager;
import io.rong.push.RongPushClient;
import io.rong.push.common.PushCacheHelper;
import io.rong.push.rongpush.PushReceiver;
import io.rong.rtlog.upload.RtFwLogConsolePrinter;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.CountDownLatch;
import java.util.regex.Pattern;
public class RongCoreClient {
private static final int GET_TAG_MAX = 100;
private static final int GET_TAG_MIN = 20;
private static String PRIVATE_STATISTIC = null;
private static final int RC_CONVERSATION_TAG_MAX = 1000;
private static final String TAG = "RongCoreClient";
private static final int TAG_ID_MAX_LENGTH = 10;
private static final int TAG_MAX_NUMBER = 20;
private static final int TAG_NAME_MAX_LENGTH = 15;
private static String URL_STATISTIC = "https://stats.cn.ronghub.com/active.json";
private static volatile boolean cancelSDKHeartBeatEnabled = false;
private static IRongCoreListener.ConversationListener conversationListener;
private static boolean isInForeground;
private static boolean isPushEnabled;
private static String mFileServer;
public static Handler mHandler;
private static String mNaviServer;
private static IRongCoreListener.PushNotificationListener mPushNotificationListener;
private static IRongCoreListener.MessageExpansionListener messageExpansionListener;
private static volatile boolean needCallBackDBOpen;
private static IRongCoreListener.ConnectionStatusListener sConnectionListener;
private static IRongCoreListener.ConversationStatusListener sConversationStatusListener;
private static IRongCoreListener.ConversationTagListener sConversationTagListener;
private static IRongCoreListener.OnRecallMessageListener sOnRecallMessageListener;
private static IRongCoreListener.ReadReceiptListener sReadReceiptListener;
private static IRongCoreListener.OnReceiveMessageListener sReceiveMessageListener;
private static boolean userPolicy;
private final int CALLBACK_LIMIT;
private final int CONVERSATION_NUMBER_OF_ONE_BATCH;
private final int MESSAGE_NUMBER_INSERT_MAX;
private final int MESSAGE_NUMBER_OF_ONE_BATCH;
private IRongCoreCallback.ConnectCallback connectCallback;
private Timer connectTimeoutTimer;
private Map<Object, List<IRongCoreCallback.IDownloadMediaMessageCallback>> downloadMap;
private IMLibExtensionModuleManager imLibExtensionModuleManager;
private boolean kickReconnectDevice;
private AidlConnection mAidlConnection;
private String mAppKey;
private Set<String> mCmdObjectNameList;
private ConnectChangeReceiver mConnectChangeReceiver;
private ConnectRunnable mConnectRunnable;
private IRongCoreListener.ConnectionStatusListener.ConnectionStatus mConnectionStatus;
private Context mContext;
private String mCurrentUserId;
private Set<String> mDeleteObjectNameList;
private IRongCoreListener.EncryptedSessionConnectionListener mEncSessionConListener;
private IHandler mLibHandler;
private IRongCoreListener.OnReceiveDestructionMessageListener mOnReceiveDestructionMessageListener;
private final List<String> mRegCache;
private StatusListener mStatusListener;
private IRongCoreListener.SyncConversationReadStatusListener mSyncConversationReadStatusListener;
private IRongCoreListener.TagListener mTagListener;
private volatile String mToken;
private Handler mUpStreamHandler;
private Handler mWorkHandler;
private Activity topForegroundActivity;
private RongCoreClient() {
this.CONVERSATION_NUMBER_OF_ONE_BATCH = 10;
this.MESSAGE_NUMBER_OF_ONE_BATCH = 10;
this.MESSAGE_NUMBER_INSERT_MAX = RongCallEvent.EVENT_ON_PERMISSION_GRANTED;
this.CALLBACK_LIMIT = 5;
this.mConnectionStatus = IRongCoreListener.ConnectionStatusListener.ConnectionStatus.UNCONNECTED;
this.kickReconnectDevice = false;
this.downloadMap = new HashMap();
RLog.i(TAG, TAG);
mHandler = new Handler(Looper.getMainLooper());
this.mRegCache = new ArrayList();
HandlerThread handlerThread = new HandlerThread("IPC_WORK");
handlerThread.start();
HandlerThread handlerThread2 = new HandlerThread("UP_WORK");
handlerThread2.start();
this.mStatusListener = new StatusListener();
this.mWorkHandler = new Handler(handlerThread.getLooper());
this.mUpStreamHandler = new Handler(handlerThread2.getLooper());
this.mConnectChangeReceiver = new ConnectChangeReceiver();
this.mAidlConnection = new AidlConnection();
this.mCmdObjectNameList = new CopyOnWriteArraySet();
this.mDeleteObjectNameList = new HashSet();
this.imLibExtensionModuleManager = IMLibExtensionModuleManager.getInstance();
IMLibRTCClient.getInstance().init(this.mWorkHandler);
ChannelClient.getInstance().init(this.mWorkHandler);
}
public static RongCoreClient getInstance() {
return SingletonHolder.sInstance;
}
public static void init(Application application, String str) {
init(application, str, true);
}
public static void init(Context context) {
init(context, null, true);
}
public static void init(Context context, String str) {
init(context, str, true);
}
public static void init(Context context, String str, boolean z) {
RLog.d(TAG, "isPushEnabled:" + z);
isPushEnabled = z;
SingletonHolder.sInstance.initSDK(context, str);
}
public static RongCoreClient connect(String str, IRongCoreCallback.ConnectCallback connectCallback) {
return connect(str, -1, connectCallback);
}
public static RongCoreClient connect(String str, int i, final IRongCoreCallback.ConnectCallback connectCallback) {
IRongCoreEnum.ConnectionErrorCode connectionErrorCode;
FwLog.write(3, 1, "A-connect-T", RongLibConst.KEY_TOKEN, str);
if (!isInitComplete()) {
connectionErrorCode = IRongCoreEnum.ConnectionErrorCode.CLIENT_NOT_INIT;
} else if (!SystemUtils.isValidToken(str)) {
connectionErrorCode = IRongCoreEnum.ConnectionErrorCode.RC_CONN_TOKEN_INCORRECT;
} else {
connectionErrorCode = (SingletonHolder.sInstance.mConnectionStatus.equals(IRongCoreListener.ConnectionStatusListener.ConnectionStatus.CONNECTING) || SingletonHolder.sInstance.mConnectionStatus.equals(IRongCoreListener.ConnectionStatusListener.ConnectionStatus.SUSPEND) || SingletonHolder.sInstance.mConnectionStatus.equals(IRongCoreListener.ConnectionStatusListener.ConnectionStatus.CONNECTED) || SingletonHolder.sInstance.mConnectionStatus.equals(IRongCoreListener.ConnectionStatusListener.ConnectionStatus.NETWORK_UNAVAILABLE)) ? IRongCoreEnum.ConnectionErrorCode.RC_CONNECTION_EXIST : null;
}
if (connectionErrorCode != null) {
FwLog.write(3, 1, "A-connect-R", "code", connectionErrorCode);
if (connectCallback != null) {
connectCallback.onError(connectionErrorCode);
}
return SingletonHolder.sInstance;
}
needCallBackDBOpen = true;
SingletonHolder.sInstance.connectCallback = new IRongCoreCallback.ConnectCallback() {
@Override
public void onSuccess(String str2) {
FwLog.write(3, 1, "A-connect-R", "code|user_id", 0, str2);
SingletonHolder.sInstance.stopConnectTimeoutTimer();
IRongCoreCallback.ConnectCallback connectCallback2 = IRongCoreCallback.ConnectCallback.this;
if (connectCallback2 != null) {
connectCallback2.onSuccess(str2);
}
}
@Override
public void onError(IRongCoreEnum.ConnectionErrorCode connectionErrorCode2) {
FwLog.write(2, 1, "A-connect-R", "code", Integer.valueOf(connectionErrorCode2.getValue()));
IRongCoreCallback.ConnectCallback connectCallback2 = IRongCoreCallback.ConnectCallback.this;
if (connectCallback2 != null) {
connectCallback2.onError(connectionErrorCode2);
}
}
@Override
public void onDatabaseOpened(IRongCoreEnum.DatabaseOpenStatus databaseOpenStatus) {
FwLog.write(3, 1, "A-connect-S", "code", Integer.valueOf(databaseOpenStatus.getValue()));
RLog.i(RongCoreClient.TAG, "DatabaseOpenStatus = " + databaseOpenStatus.getValue());
IRongCoreCallback.ConnectCallback connectCallback2 = IRongCoreCallback.ConnectCallback.this;
if (connectCallback2 != null) {
connectCallback2.onDatabaseOpened(databaseOpenStatus);
}
}
};
if (i <= 0) {
i = 2147483646;
}
SingletonHolder.sInstance.startConnectTimeoutTimer(i);
SingletonHolder.sInstance.connectServer(str, false);
return SingletonHolder.sInstance;
}
public static void setConnectionStatusListener(IRongCoreListener.ConnectionStatusListener connectionStatusListener) {
sConnectionListener = connectionStatusListener;
}
public static void reconnectServer() {
if (SingletonHolder.sInstance.mLibHandler != null) {
RLog.d(TAG, "reconnectServer, t = " + SingletonHolder.sInstance.mToken);
SingletonHolder.sInstance.connectServer(SingletonHolder.sInstance.mToken, true);
return;
}
mHandler.post(new Runnable() {
@Override
public void run() {
SingletonHolder.sInstance.connectServer(SingletonHolder.sInstance.mToken, true);
}
});
}
public static void setOnReceiveMessageListener(IRongCoreListener.OnReceiveMessageListener onReceiveMessageListener) {
sReceiveMessageListener = onReceiveMessageListener;
}
@Deprecated
public static void registerMessageType(Class<? extends MessageContent> cls) {
if (cls == null) {
FwLog.write(2, 1, FwLog.LogTag.L_REGTYPE_E.getTag(), "messageContentClass", "null");
return;
}
synchronized (SingletonHolder.sInstance.mRegCache) {
if (!SingletonHolder.sInstance.mRegCache.contains(cls.getName())) {
SingletonHolder.sInstance.mRegCache.add(cls.getName());
}
}
if (SingletonHolder.sInstance.mLibHandler != null) {
try {
SingletonHolder.sInstance.mLibHandler.registerMessageType(cls.getName());
} catch (Exception e) {
RLog.e(TAG, "registerMessageType RemoteException", e);
}
}
}
public static void registerMessageType(List<Class<? extends MessageContent>> list) {
if (list == null || list.size() == 0) {
FwLog.write(2, 1, FwLog.LogTag.L_REGTYPE_E.getTag(), "messageContentClassList", "messageContentClassList is empty");
return;
}
ArrayList arrayList = new ArrayList();
synchronized (SingletonHolder.sInstance.mRegCache) {
for (Class<? extends MessageContent> cls : list) {
String name = cls.getName();
if (!SingletonHolder.sInstance.mRegCache.contains(name)) {
SingletonHolder.sInstance.mRegCache.add(name);
arrayList.add(name);
}
}
}
if (SingletonHolder.sInstance.mLibHandler != null) {
try {
if (arrayList.size() > 0) {
SingletonHolder.sInstance.mLibHandler.registerMessageTypes(arrayList);
}
} catch (Exception e) {
RLog.e(TAG, "registerMessageType RemoteException", e);
}
}
}
public static void setTypingStatusListener(IRongCoreListener.TypingStatusListener typingStatusListener) {
TypingMessageManager.getInstance().setTypingMessageStatusListener(typingStatusListener);
}
public static void setRCLogInfoListener(final IRongCoreListener.RCLogInfoListener rCLogInfoListener) {
FwLog.setLogListener(new FwLog.ILogListener() {
@Override
public void onLogEvent(String str) {
IRongCoreListener.RCLogInfoListener.this.onRCLogInfoOccurred(str);
}
});
}
public static void setReadReceiptListener(IRongCoreListener.ReadReceiptListener readReceiptListener) {
sReadReceiptListener = readReceiptListener;
}
public static void setServerInfo(String str, String str2) {
RLog.d(TAG, "setServerInfo naviServer :" + str + ", fileServer:" + str2);
if (TextUtils.isEmpty(str)) {
RLog.e(TAG, "setServerInfo naviServer should not be null.");
throw new IllegalArgumentException("naviServer should not be null.");
} else if (!NetUtils.isLegalServer(str) || (!TextUtils.isEmpty(str2) && !NetUtils.isLegalServer(str2))) {
throw new IllegalArgumentException("Invalid url,check validity of naviServer and fileServer");
} else {
FwLog.write(3, 1, FwLog.LogTag.A_SET_SERVER_O.getTag(), "navi|file", str, str2);
mNaviServer = str.trim();
if (str2 != null) {
mFileServer = str2.trim();
}
}
}
public static void setStatisticDomain(String str) {
FwLog.write(3, 1, FwLog.LogTag.A_SET_STATISTIC_SERVER_O.getTag(), "domain", str);
PRIVATE_STATISTIC = String.format(str.toLowerCase().startsWith("http") ? "%s/active.json" : "http://%s/active.json", str);
}
public static void setOnRecallMessageListener(IRongCoreListener.OnRecallMessageListener onRecallMessageListener) {
sOnRecallMessageListener = onRecallMessageListener;
}
public void setEncryptedSessionConnectionListener(IRongCoreListener.EncryptedSessionConnectionListener encryptedSessionConnectionListener) {
this.mEncSessionConListener = encryptedSessionConnectionListener;
}
public String getToken() {
return this.mToken;
}
private void setToken(String str) {
RLog.d(TAG, "set token");
this.mToken = str;
}
public Handler getWorkHandler() {
return this.mWorkHandler;
}
public Handler getMainHandler() {
return mHandler;
}
public void initBindService() {
if (this.mLibHandler != null) {
initReceiver();
} else if (this.mContext == null || this.mAppKey == null) {
RLog.d(TAG, "initBindService context or appKey is null,cause by bind before init");
} else {
try {
Intent intent = new Intent(this.mContext, RongService.class);
intent.putExtra("appKey", this.mAppKey);
intent.putExtra("deviceId", DeviceUtils.getDeviceId(this.mContext, this.mAppKey));
this.mContext.bindService(intent, this.mAidlConnection, 1);
} catch (SecurityException e) {
RLog.e(TAG, "initBindService SecurityException");
RLog.e(TAG, "initBindService", e);
}
}
}
public IRongCoreListener.ConnectionStatusListener.ConnectionStatus getCurrentConnectionStatus() {
return this.mConnectionStatus;
}
public void registerCmdMsgType() {
try {
this.mCmdObjectNameList.add(((MessageTag) ReadReceiptMessage.class.getAnnotation(MessageTag.class)).value());
this.mCmdObjectNameList.add(((MessageTag) ReadReceiptRequestMessage.class.getAnnotation(MessageTag.class)).value());
this.mCmdObjectNameList.add(((MessageTag) ReadReceiptResponseMessage.class.getAnnotation(MessageTag.class)).value());
this.mCmdObjectNameList.add(((MessageTag) TypingStatusMessage.class.getAnnotation(MessageTag.class)).value());
this.mCmdObjectNameList.add(((MessageTag) RecallCommandMessage.class.getAnnotation(MessageTag.class)).value());
this.mCmdObjectNameList.add(((MessageTag) SyncReadStatusMessage.class.getAnnotation(MessageTag.class)).value());
this.mCmdObjectNameList.add(((MessageTag) LogCmdMessage.class.getAnnotation(MessageTag.class)).value());
this.mCmdObjectNameList.add(((MessageTag) MessageExpansionMessage.class.getAnnotation(MessageTag.class)).value());
this.mCmdObjectNameList.add(((MessageTag) GroupReadReceiptV2Message.class.getAnnotation(MessageTag.class)).value());
List<Class<? extends MessageContent>> cmdMessageContentList = this.imLibExtensionModuleManager.getCmdMessageContentList();
if (cmdMessageContentList != null) {
for (Class<? extends MessageContent> cls : cmdMessageContentList) {
this.mCmdObjectNameList.add(((MessageTag) cls.getAnnotation(MessageTag.class)).value());
}
}
} catch (ArrayIndexOutOfBoundsException e) {
RLog.e(TAG, "Exception when register command messages. e:" + e.getMessage());
} catch (IncompatibleClassChangeError e2) {
RLog.e(TAG, "error when register command message. error message:" + e2.getMessage());
}
}
public void registerDeleteMessageType() {
try {
this.mDeleteObjectNameList.add(((MessageTag) ReadReceiptMessage.class.getAnnotation(MessageTag.class)).value());
this.mDeleteObjectNameList.add(((MessageTag) SyncReadStatusMessage.class.getAnnotation(MessageTag.class)).value());
} catch (ArrayIndexOutOfBoundsException e) {
RLog.e(TAG, "Exception when register deleted messages. e:" + e.getMessage());
}
}
public void registerReconnectIntentFilter() {
try {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
intentFilter.addAction("android.intent.action.USER_PRESENT");
Context context = this.mContext;
ConnectChangeReceiver connectChangeReceiver = this.mConnectChangeReceiver;
context.registerReceiver(connectChangeReceiver, intentFilter, this.mContext.getApplicationInfo().packageName + ".permission.RONG_ACCESS_RECEIVER", null);
} catch (Exception e) {
RLog.e(TAG, "registerReconnectIntentFilter failed: " + e.getMessage());
}
}
public void initStatistics(Context context, String str) {
if (Statistics.sharedInstance().isInitialized()) {
return;
}
if (!TextUtils.isEmpty(PRIVATE_STATISTIC)) {
Statistics.sharedInstance().init(context, PRIVATE_STATISTIC, str, DeviceUtils.getDeviceId(context, this.mAppKey));
} else {
Statistics.sharedInstance().init(context, URL_STATISTIC, str, DeviceUtils.getDeviceId(context, this.mAppKey));
}
Statistics.sharedInstance().setLoggingEnabled(false);
Statistics.sharedInstance().onStart();
}
public void onAppBackgroundChanged(boolean z) {
boolean z2 = true;
FwLog.write(3, 1, FwLog.LogTag.L_APP_STATE_S.getTag(), "foreground", Boolean.valueOf(z));
isInForeground = z;
if (this.mLibHandler == null) {
if (z) {
RLog.e(TAG, "rebind RongService: " + this.mConnectionStatus);
initBindService();
return;
}
return;
}
if (z) {
try {
connectServer(this.mToken, true);
} catch (Exception e) {
RLog.e(TAG, "onAppBackgroundChanged", e);
return;
}
}
IHandler iHandler = this.mLibHandler;
if (isInForeground) {
z2 = false;
}
iHandler.notifyAppBackgroundChanged(z2);
}
private void initSDK(final Context context, String str) {
String currentProcessName = SystemUtils.getCurrentProcessName(context);
String packageName = context.getPackageName();
RLog.d(TAG, "init : " + currentProcessName + ", " + packageName + ", " + context);
if (TextUtils.isEmpty(currentProcessName) || TextUtils.isEmpty(packageName) || !packageName.equals(currentProcessName)) {
RLog.e(TAG, "SDK should init in main process.");
} else if (!TextUtils.isEmpty(this.mAppKey) && this.mAppKey.equals(str)) {
RLog.i(TAG, "The SDK has been initialized");
} else {
if (TextUtils.isEmpty(str)) {
try {
this.mAppKey = context.getPackageManager().getApplicationInfo(context.getPackageName(), 128).metaData.getString("RONG_CLOUD_APP_KEY");
} catch (PackageManager.NameNotFoundException e) {
RLog.e(TAG, "*initSDK", e);
throw new ExceptionInInitializerError("can't find packageName!");
}
} else {
this.mAppKey = str;
}
if (!SystemUtils.isValidAppKey(this.mAppKey)) {
throw new IllegalArgumentException("AppKey isn't valid.");
}
if (context instanceof Application) {
((Application) context).registerActivityLifecycleCallbacks(new Application.ActivityLifecycleCallbacks() {
@Override
public void onActivityCreated(Activity activity, Bundle bundle) {
}
@Override
public void onActivityDestroyed(Activity activity) {
}
@Override
public void onActivityPaused(Activity activity) {
}
@Override
public void onActivityStarted(Activity activity) {
}
@Override
public void onActivityResumed(Activity activity) {
if (RongCoreClient.this.topForegroundActivity == null) {
RLog.i(RongCoreClient.TAG, "in Foreground");
RongCoreClient.this.onAppBackgroundChanged(true);
}
RongCoreClient.this.topForegroundActivity = activity;
}
@Override
public void onActivityStopped(Activity activity) {
if (RongCoreClient.this.topForegroundActivity == activity) {
RLog.i(RongCoreClient.TAG, "in Background");
RongCoreClient.this.onAppBackgroundChanged(false);
RongCoreClient.this.topForegroundActivity = null;
}
}
@Override
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
RLog.i(RongCoreClient.TAG, "saveInstance");
}
});
}
this.mContext = context.getApplicationContext();
RLog.init(context, this.mAppKey, "5.1.3.5");
FwLog.setLogConsolePrinter(new RtFwLogConsolePrinter(this.mContext));
String tag = FwLog.LogTag.A_INIT_O.getTag();
FwLog.write(3, 1, tag, "appkey|platform|model|sdk", this.mAppKey, "Android-" + Build.VERSION.SDK_INT, Build.MODEL, "5.1.3.5");
MessageBufferPool.init(this.mContext);
this.imLibExtensionModuleManager.loadAllIMLibExtensionModules();
this.imLibExtensionModuleManager.onCreate(context, this.mAppKey);
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
SharedPreferencesUtils.get(context, RongLibConst.SP_STATISTICS, 0).edit().putString("appKey", RongCoreClient.this.mAppKey).commit();
RongCoreClient.this.initRegisterMessageType();
RongCoreClient.this.registerCmdMsgType();
RongCoreClient.this.registerDeleteMessageType();
RongCoreClient.this.registerReconnectIntentFilter();
RongCoreClient.this.initBindService();
RongCoreClient rongCoreClient = RongCoreClient.this;
rongCoreClient.initStatistics(context, rongCoreClient.mAppKey);
if (RongCoreClient.isPushEnabled) {
if (RongCoreClient.mNaviServer != null) {
RongPushClient.init(context, RongCoreClient.this.mAppKey, RongCoreClient.mNaviServer);
} else {
RongPushClient.init(context, RongCoreClient.this.mAppKey);
}
} else {
context.getPackageManager().setComponentEnabledSetting(new ComponentName(context, PushReceiver.class), 2, 1);
}
TypingMessageManager.getInstance().init(context);
}
});
}
}
public void initRegisterMessageType() {
LinkedList linkedList = new LinkedList();
linkedList.add(TextMessage.class);
linkedList.add(ReferenceMessage.class);
linkedList.add(VoiceMessage.class);
linkedList.add(HQVoiceMessage.class);
linkedList.add(ImageMessage.class);
linkedList.add(GIFMessage.class);
linkedList.add(CommandNotificationMessage.class);
linkedList.add(ContactNotificationMessage.class);
linkedList.add(RichContentMessage.class);
linkedList.add(ProfileNotificationMessage.class);
linkedList.add(HandshakeMessage.class);
linkedList.add(InformationNotificationMessage.class);
linkedList.add(SuspendMessage.class);
linkedList.add(ReadReceiptMessage.class);
linkedList.add(CommandMessage.class);
linkedList.add(TypingStatusMessage.class);
linkedList.add(RecallCommandMessage.class);
linkedList.add(RecallNotificationMessage.class);
linkedList.add(ReadReceiptRequestMessage.class);
linkedList.add(ReadReceiptResponseMessage.class);
linkedList.add(SyncReadStatusMessage.class);
linkedList.add(GroupNotificationMessage.class);
linkedList.add(FileMessage.class);
linkedList.add(HistoryDividerMessage.class);
linkedList.add(DestructionCmdMessage.class);
linkedList.add(RoomUserStateMessage.class);
linkedList.add(LogCmdMessage.class);
linkedList.add(MessageExpansionMessage.class);
linkedList.add(GroupReadReceiptV2Message.class);
List<Class<? extends MessageContent>> messageContentList = this.imLibExtensionModuleManager.getMessageContentList();
if (messageContentList != null) {
linkedList.addAll(messageContentList);
}
registerMessageType(linkedList);
}
public synchronized void connectServer(final String str, boolean z) {
if (TextUtils.isEmpty(str)) {
return;
}
setToken(str);
if (this.mLibHandler == null) {
FwLog.write(3, 1, z ? "L-reconnect-T" : "L-connect-T", "sequences", 0);
FwLog.write(2, 1, z ? "L-reconnect-R" : "L-connect-R", "code|network|sequences", IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT, DeviceUtils.getNetworkType(this.mContext), 0);
this.mConnectRunnable = new ConnectRunnable(str);
initBindService();
} else {
try {
RLog.d(TAG, "[connect] connect");
this.mLibHandler.connect(str, z, isInForeground, new IConnectStringCallback.Stub() {
@Override
public void onComplete(String str2) {
RLog.d(RongCoreClient.TAG, "[connect] callback onComplete");
SingletonHolder.sInstance.imLibExtensionModuleManager.onConnected(str2, str);
RongCoreClient.this.mCurrentUserId = str2;
SharedPreferencesUtils.get(RongCoreClient.this.mContext, RongLibConst.SP_STATISTICS, 0).edit().putString(RongLibConst.KEY_TOKEN, str).putString("userId", str2).commit();
RongCoreClient.this.mConnectRunnable = null;
if (RongCoreClient.this.connectCallback != null) {
RongCoreClient.this.connectCallback.onCallback(str2);
RongCoreClient.this.connectCallback = null;
}
if (RongCoreClient.isPushEnabled) {
PushManager.getInstance().updatePushServerInfoFromToken(str);
}
if (RongCoreClient.isPushEnabled) {
PushManager.getInstance().updatePushServerInfoFromToken(str);
}
if (RongCoreClient.isPushEnabled) {
PushManager.getInstance().updatePushServerInfoFromToken(str);
}
RongCoreClient.this.mUpStreamHandler.post(new Runnable() {
@Override
public void run() {
RongCoreClient.this.uploadSDKVersion();
}
});
}
@Override
public void onFailure(int i) throws RemoteException {
RLog.e(RongCoreClient.TAG, "[connect] callback onFailure, errorCode = " + i);
RongCoreClient.this.mConnectRunnable = null;
if (RongCoreClient.this.connectCallback != null) {
RongCoreClient.this.connectCallback.onFail(IRongCoreEnum.ConnectionErrorCode.valueOf(i));
RongCoreClient.this.connectCallback = null;
}
SharedPreferencesUtils.get(RongCoreClient.this.mContext, RongLibConst.SP_STATISTICS, 0).edit().putString(RongLibConst.KEY_TOKEN, str).commit();
}
@Override
public void OnDatabaseOpened(int i) throws RemoteException {
if (RongCoreClient.needCallBackDBOpen) {
if (RongCoreClient.this.connectCallback != null) {
RongCoreClient.this.connectCallback.onDatabaseOpened(IRongCoreEnum.DatabaseOpenStatus.valueOf(i));
}
boolean unused = RongCoreClient.needCallBackDBOpen = false;
}
}
});
} catch (Exception e) {
IRongCoreCallback.ConnectCallback connectCallback = this.connectCallback;
if (connectCallback != null) {
connectCallback.onError(IRongCoreEnum.ConnectionErrorCode.IPC_DISCONNECT);
}
FwLog.write(1, 1, "L-crash_main_ept-F", "stacks", FwLog.stackToString(e));
RLog.e(TAG, "connectServer", e);
}
}
}
private static boolean isInitComplete() {
return !TextUtils.isEmpty(SingletonHolder.sInstance.mAppKey);
}
public void uploadSDKVersion() {
RCSdkInfo rCSdkInfo = new RCSdkInfo();
rCSdkInfo.setImLibVer("5.1.3.5");
rCSdkInfo.setImKitVer(invokeGetVersion("io.rong.imkit.RongIM"));
rCSdkInfo.setRtcLibVer(invokeGetVersion("cn.rongcloud.rtc.api.RCRTCEngine"));
rCSdkInfo.setCallKitVer(invokeGetVersion("io.rong.callkit.RongCallKit"));
rCSdkInfo.setCallLibVer(invokeGetVersion("io.rong.calllib.RongCallClient"));
rCSdkInfo.setFlutterRTCVer(invokeGetVersion("io.rong.flutter.rtclib.agent.RCFlutterEngine"));
rCSdkInfo.setFlutterIMVer(invokeGetVersion("io.rong.flutter.imlib.RCIMFlutterWrapper"));
rCSdkInfo.setVoiceRoomVer(invokeGetVersion("cn.rongcloud.voiceroom.api.RCVoiceRoomEngine"));
try {
String json = new Gson().toJson(rCSdkInfo);
this.mLibHandler.uploadSDKVersion(json);
RLog.i(TAG, "uploadSDKVersion: The SDK information = " + json);
} catch (Exception e) {
RLog.i(TAG, "uploadSDKVersion exception: " + e);
}
}
private String invokeGetVersion(String str) {
try {
return (String) Class.forName(str).getMethod("getVersion", new Class[0]).invoke(null, new Object[0]);
} catch (Exception e) {
RLog.i(TAG, "invokeGetVersion " + e);
return null;
}
}
private void startConnectTimeoutTimer(int i) {
stopConnectTimeoutTimer();
this.connectTimeoutTimer = new Timer();
this.connectTimeoutTimer.schedule(new TimerTask() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.setIpcConnectTimeOut();
return;
} catch (Exception unused) {
RongCoreClient.this.mStatusListener.onConnectionStatusChange(IRongCoreListener.ConnectionStatusListener.ConnectionStatus.TIMEOUT);
return;
}
}
RongCoreClient.this.mStatusListener.onConnectionStatusChange(IRongCoreListener.ConnectionStatusListener.ConnectionStatus.TIMEOUT);
}
}, i * 1000);
}
public void stopConnectTimeoutTimer() {
Timer timer = this.connectTimeoutTimer;
if (timer != null) {
timer.cancel();
this.connectTimeoutTimer = null;
}
}
public Activity getTopForegroundActivity() {
return this.topForegroundActivity;
}
public void logout() {
disconnect(false);
this.imLibExtensionModuleManager.onLogout();
}
public void disconnect() {
disconnect(true);
}
public void disconnect(boolean z) {
FwLog.write(3, 1, FwLog.LogTag.A_DISCONNECT_O.getTag(), "push", Boolean.valueOf(z));
Context context = this.mContext;
if (context != null && !z) {
SharedPreferencesUtils.get(context, RongLibConst.SP_STATISTICS, 0).edit().putString("userId", "").apply();
}
this.mStatusListener.onConnectionStatusChange(IRongCoreListener.ConnectionStatusListener.ConnectionStatus.SIGN_OUT);
this.imLibExtensionModuleManager.onDisconnect();
Handler handler = this.mWorkHandler;
if (handler != null) {
handler.post(new Runnable() {
@Override
public void run() {
RongCoreClient.this.cancelAllDownloadMediaMessage(null);
}
});
}
try {
IHandler iHandler = this.mLibHandler;
if (iHandler != null) {
iHandler.disconnect(z);
}
} catch (Exception e) {
RLog.e(TAG, "disconnect", e);
}
clearToken();
}
public void getConversationList(IRongCoreCallback.ResultCallback<List<Conversation>> resultCallback) {
ChannelClient.getInstance().getConversationList(resultCallback, "");
}
public void getConversationList(IRongCoreCallback.ResultCallback<List<Conversation>> resultCallback, Conversation.ConversationType... conversationTypeArr) {
ChannelClient.getInstance().getConversationList("", resultCallback, conversationTypeArr);
}
public void getTopConversationList(IRongCoreCallback.ResultCallback<List<Conversation>> resultCallback, Conversation.ConversationType... conversationTypeArr) {
ChannelClient.getInstance().getTopConversationList(resultCallback, "", conversationTypeArr);
}
public void getConversationListByPage(IRongCoreCallback.ResultCallback<List<Conversation>> resultCallback, long j, int i, Conversation.ConversationType... conversationTypeArr) {
ChannelClient.getInstance().getConversationListByPage(resultCallback, j, i, "", conversationTypeArr);
}
public void getBlockedConversationList(IRongCoreCallback.ResultCallback<List<Conversation>> resultCallback, Conversation.ConversationType... conversationTypeArr) {
ChannelClient.getInstance().getBlockedConversationList(resultCallback, "", conversationTypeArr);
}
public void getConversation(Conversation.ConversationType conversationType, String str, IRongCoreCallback.ResultCallback<Conversation> resultCallback) {
ChannelClient.getInstance().getConversation(conversationType, str, "", resultCallback);
}
public void updateConversationInfo(Conversation.ConversationType conversationType, String str, String str2, String str3, IRongCoreCallback.ResultCallback resultCallback) {
ChannelClient.getInstance().updateConversationInfo(conversationType, str, "", str2, str3, resultCallback);
}
public void removeConversation(Conversation.ConversationType conversationType, String str, IRongCoreCallback.ResultCallback<Boolean> resultCallback) {
ChannelClient.getInstance().removeConversation(conversationType, str, "", resultCallback);
}
public void setConversationToTop(Conversation.ConversationType conversationType, String str, boolean z, IRongCoreCallback.ResultCallback<Boolean> resultCallback) {
setConversationToTop(conversationType, str, z, true, resultCallback);
}
public void setConversationToTop(Conversation.ConversationType conversationType, String str, boolean z, boolean z2, IRongCoreCallback.ResultCallback<Boolean> resultCallback) {
ChannelClient.getInstance().setConversationToTop(conversationType, str, "", z, z2, resultCallback);
}
public void getTotalUnreadCount(IRongCoreCallback.ResultCallback<Integer> resultCallback) {
ChannelClient.getInstance().getTotalUnreadCount("", resultCallback);
}
public void getTotalUnreadCount(final IRongCoreCallback.ResultCallback<Integer> resultCallback, final Conversation... conversationArr) {
if (conversationArr == null && resultCallback != null) {
RLog.e(TAG, "conversations can't be null !");
resultCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
return;
}
for (Conversation conversation : conversationArr) {
if ((conversation.getConversationType() == null || TextUtils.isEmpty(conversation.getTargetId())) && resultCallback != null) {
RLog.e(TAG, "ConversationType or targetId can't be empty !");
resultCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
return;
}
}
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
int unreadCountByConversation = RongCoreClient.this.mLibHandler.getUnreadCountByConversation(conversationArr);
IRongCoreCallback.ResultCallback resultCallback2 = resultCallback;
if (resultCallback2 != null) {
resultCallback2.onCallback(Integer.valueOf(unreadCountByConversation));
return;
}
return;
} catch (Exception unused) {
IRongCoreCallback.ResultCallback resultCallback3 = resultCallback;
if (resultCallback3 != null) {
resultCallback3.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
return;
}
return;
}
}
IRongCoreCallback.ResultCallback resultCallback4 = resultCallback;
if (resultCallback4 != null) {
resultCallback4.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
}
});
}
public void getUnreadCount(Conversation.ConversationType conversationType, String str, IRongCoreCallback.ResultCallback<Integer> resultCallback) {
ChannelClient.getInstance().getUnreadCount(conversationType, str, "", resultCallback);
}
public void getUnreadCount(IRongCoreCallback.ResultCallback<Integer> resultCallback, Conversation.ConversationType... conversationTypeArr) {
ChannelClient.getInstance().getUnreadCount(resultCallback, "", conversationTypeArr);
}
public void getUnreadCount(Conversation.ConversationType[] conversationTypeArr, boolean z, IRongCoreCallback.ResultCallback<Integer> resultCallback) {
ChannelClient.getInstance().getUnreadCount(conversationTypeArr, "", z, resultCallback);
}
public void getUnreadCount(Conversation.ConversationType[] conversationTypeArr, IRongCoreCallback.ResultCallback<Integer> resultCallback) {
getUnreadCount(resultCallback, conversationTypeArr);
}
public void getMessageCount(Conversation.ConversationType conversationType, String str, IRongCoreCallback.ResultCallback<Integer> resultCallback) {
ChannelClient.getInstance().getMessageCount(conversationType, str, "", resultCallback);
}
public void getLatestMessages(Conversation.ConversationType conversationType, String str, int i, IRongCoreCallback.ResultCallback<List<Message>> resultCallback) {
ChannelClient.getInstance().getLatestMessages(conversationType, str, "", i, resultCallback);
}
@Deprecated
public List<Message> getHistoryMessages(Conversation.ConversationType conversationType, String str, int i, int i2) {
final CountDownLatch countDownLatch = new CountDownLatch(1);
final IRongCoreCallback.ResultCallback.Result result = new IRongCoreCallback.ResultCallback.Result();
getHistoryMessages(conversationType, str, i, i2, new IRongCoreCallback.SyncCallback<List<Message>>() {
@Override
public void onSuccess(List<Message> list) {
result.t = list;
countDownLatch.countDown();
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
countDownLatch.countDown();
}
});
try {
countDownLatch.await();
} catch (InterruptedException e) {
RLog.e(TAG, "getHistoryMessages", e);
Thread.currentThread().interrupt();
}
return (List) result.t;
}
@Deprecated
public List<Message> getHistoryMessages(Conversation.ConversationType conversationType, String str, String str2, int i, int i2) {
final CountDownLatch countDownLatch = new CountDownLatch(1);
final IRongCoreCallback.ResultCallback.Result result = new IRongCoreCallback.ResultCallback.Result();
getHistoryMessages(conversationType, str, str2, i, i2, new IRongCoreCallback.SyncCallback<List<Message>>() {
@Override
public void onSuccess(List<Message> list) {
result.t = list;
countDownLatch.countDown();
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
countDownLatch.countDown();
}
});
try {
countDownLatch.await();
} catch (InterruptedException e) {
RLog.e(TAG, "getHistoryMessages", e);
Thread.currentThread().interrupt();
}
return (List) result.t;
}
public void getHistoryMessages(Conversation.ConversationType conversationType, String str, String str2, int i, int i2, IRongCoreCallback.ResultCallback<List<Message>> resultCallback) {
ChannelClient.getInstance().getHistoryMessages(conversationType, str, "", str2, i, i2, resultCallback);
}
public void getHistoryMessages(Conversation.ConversationType conversationType, String str, String str2, int i, int i2, RongCommonDefine.GetMessageDirection getMessageDirection, IRongCoreCallback.ResultCallback<List<Message>> resultCallback) {
ChannelClient.getInstance().getHistoryMessages(conversationType, str, "", str2, i, i2, getMessageDirection, resultCallback);
}
public void getHistoryMessages(Conversation.ConversationType conversationType, String str, List<String> list, long j, int i, RongCommonDefine.GetMessageDirection getMessageDirection, IRongCoreCallback.ResultCallback<List<Message>> resultCallback) {
ChannelClient.getInstance().getHistoryMessages(conversationType, str, "", list, j, i, getMessageDirection, resultCallback);
}
private List<Message> getHistoryMessagesByObjectNamesSync(Conversation.ConversationType conversationType, String str, String str2, List<String> list, long j, int i, RongCommonDefine.GetMessageDirection getMessageDirection) {
if (this.mLibHandler == null) {
return null;
}
Conversation conversation = new Conversation();
conversation.setConversationType(conversationType);
conversation.setTargetId(str);
conversation.setChannelId(str2);
try {
return this.mLibHandler.getOlderMessagesByObjectNames(conversation, list, j, i, getMessageDirection.equals(RongCommonDefine.GetMessageDirection.FRONT));
} catch (Exception e) {
RLog.e(TAG, "getHistoryMessagesByObjectNamesSync", e);
return null;
}
}
public void getRemoteHistoryMessages(Conversation.ConversationType conversationType, String str, long j, int i, IRongCoreCallback.ResultCallback<List<Message>> resultCallback) {
ChannelClient.getInstance().getRemoteHistoryMessages(conversationType, str, "", j, i, resultCallback);
}
public void getRemoteHistoryMessages(Conversation.ConversationType conversationType, String str, RemoteHistoryMsgOption remoteHistoryMsgOption, IRongCoreCallback.ResultCallback<List<Message>> resultCallback) {
ChannelClient.getInstance().getRemoteHistoryMessages(conversationType, str, "", remoteHistoryMsgOption, resultCallback);
}
public void cleanRemoteHistoryMessages(Conversation.ConversationType conversationType, String str, long j, IRongCoreCallback.OperationCallback operationCallback) {
ChannelClient.getInstance().cleanRemoteHistoryMessages(conversationType, str, "", j, operationCallback);
}
public void cleanHistoryMessages(Conversation.ConversationType conversationType, String str, long j, boolean z, IRongCoreCallback.OperationCallback operationCallback) {
ChannelClient.getInstance().cleanHistoryMessages(conversationType, str, "", j, z, operationCallback);
}
public void getHistoryMessages(Conversation.ConversationType conversationType, String str, int i, int i2, IRongCoreCallback.ResultCallback<List<Message>> resultCallback) {
ChannelClient.getInstance().getHistoryMessages(conversationType, str, i, i2, "", resultCallback);
}
private List<Message> getHistoryMessagesSync(Conversation.ConversationType conversationType, String str, int i, int i2) {
if (TextUtils.isEmpty(str) || conversationType == null) {
RLog.e(TAG, "the parameter of targetId or ConversationType is error!");
return null;
} else if (this.mLibHandler == null) {
return null;
} else {
Conversation conversation = new Conversation();
conversation.setConversationType(conversationType);
conversation.setTargetId(str);
try {
return this.mLibHandler.getOlderMessages(conversation, i, i2);
} catch (Exception e) {
RLog.e(TAG, "getHistoryMessagesSync ", e);
return null;
}
}
}
public void deleteMessages(final int[] iArr, final IRongCoreCallback.ResultCallback<Boolean> resultCallback) {
if (iArr == null || iArr.length == 0) {
RLog.e(TAG, "the messageIds is null!");
if (resultCallback != null) {
resultCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
return;
}
return;
}
StringBuilder sb = new StringBuilder();
for (int i : iArr) {
if (i <= 0) {
RLog.e(TAG, "the messageIds contains 0 value!");
if (resultCallback != null) {
resultCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
return;
}
return;
}
sb.append(i);
sb.append("/");
}
FwLog.write(4, 1, FwLog.LogTag.A_DELETE_MESSAGES_S.getTag(), "messageIds:", sb.toString());
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
boolean deleteMessage = RongCoreClient.this.mLibHandler.deleteMessage(iArr);
IRongCoreCallback.ResultCallback resultCallback2 = resultCallback;
if (resultCallback2 != null) {
resultCallback2.onCallback(Boolean.valueOf(deleteMessage));
return;
}
return;
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "deleteMessages", e);
IRongCoreCallback.ResultCallback resultCallback3 = resultCallback;
if (resultCallback3 != null) {
resultCallback3.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
return;
}
return;
}
}
IRongCoreCallback.ResultCallback resultCallback4 = resultCallback;
if (resultCallback4 != null) {
resultCallback4.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
}
});
}
public void deleteMessages(Conversation.ConversationType conversationType, String str, IRongCoreCallback.ResultCallback<Boolean> resultCallback) {
ChannelClient.getInstance().deleteMessages(conversationType, str, "", resultCallback);
}
public void deleteRemoteMessages(Conversation.ConversationType conversationType, String str, Message[] messageArr, IRongCoreCallback.OperationCallback operationCallback) {
ChannelClient.getInstance().deleteRemoteMessages(conversationType, str, "", messageArr, operationCallback);
}
public void clearMessages(Conversation.ConversationType conversationType, String str, IRongCoreCallback.ResultCallback<Boolean> resultCallback) {
ChannelClient.getInstance().clearMessages(conversationType, str, "", resultCallback);
}
public void clearMessagesUnreadStatus(Conversation.ConversationType conversationType, String str, IRongCoreCallback.ResultCallback<Boolean> resultCallback) {
ChannelClient.getInstance().clearMessagesUnreadStatus(conversationType, str, "", resultCallback);
}
public void setMessageExtra(final int i, final String str, final IRongCoreCallback.ResultCallback<Boolean> resultCallback) {
if (i == 0) {
RLog.e(TAG, "messageId is error!");
if (resultCallback != null) {
resultCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
return;
}
return;
}
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
boolean messageExtra = RongCoreClient.this.mLibHandler.setMessageExtra(i, str);
IRongCoreCallback.ResultCallback resultCallback2 = resultCallback;
if (resultCallback2 != null) {
resultCallback2.onCallback(Boolean.valueOf(messageExtra));
return;
}
return;
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "setMessageExtra", e);
IRongCoreCallback.ResultCallback resultCallback3 = resultCallback;
if (resultCallback3 != null) {
resultCallback3.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
return;
}
return;
}
}
IRongCoreCallback.ResultCallback resultCallback4 = resultCallback;
if (resultCallback4 != null) {
resultCallback4.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
}
});
}
public void setMessageReceivedStatus(final int i, final Message.ReceivedStatus receivedStatus, final IRongCoreCallback.ResultCallback<Boolean> resultCallback) {
if (i == 0 || receivedStatus == null) {
RLog.e(TAG, "Error.messageid is 0 or receivedStatus is null !");
if (resultCallback != null) {
resultCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
return;
}
return;
}
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
boolean messageReceivedStatus = RongCoreClient.this.mLibHandler.setMessageReceivedStatus(i, receivedStatus.getFlag());
IRongCoreCallback.ResultCallback resultCallback2 = resultCallback;
if (resultCallback2 != null) {
resultCallback2.onCallback(Boolean.valueOf(messageReceivedStatus));
return;
}
return;
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "setMessageReceivedStatus", e);
IRongCoreCallback.ResultCallback resultCallback3 = resultCallback;
if (resultCallback3 != null) {
resultCallback3.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
return;
}
return;
}
}
IRongCoreCallback.ResultCallback resultCallback4 = resultCallback;
if (resultCallback4 != null) {
resultCallback4.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
}
});
}
public void setMessageSentStatus(final Message message, final IRongCoreCallback.ResultCallback<Boolean> resultCallback) {
if (message == null || message.getMessageId() <= 0 || message.getSentStatus() == null) {
RLog.e(TAG, "setMessageSentStatus Error. message or the sentStatus of message cant't be null , messageId can't <= 0!");
if (resultCallback != null) {
resultCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
return;
}
return;
}
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
boolean messageSentStatus = RongCoreClient.this.mLibHandler.setMessageSentStatus(message.getMessageId(), message.getSentStatus().getValue());
IRongCoreCallback.ResultCallback resultCallback2 = resultCallback;
if (resultCallback2 != null) {
resultCallback2.onCallback(Boolean.valueOf(messageSentStatus));
return;
}
return;
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "setMessageSentStatus", e);
IRongCoreCallback.ResultCallback resultCallback3 = resultCallback;
if (resultCallback3 != null) {
resultCallback3.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
return;
}
return;
}
}
IRongCoreCallback.ResultCallback resultCallback4 = resultCallback;
if (resultCallback4 != null) {
resultCallback4.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
}
});
}
public void getTextMessageDraft(Conversation.ConversationType conversationType, String str, IRongCoreCallback.ResultCallback<String> resultCallback) {
ChannelClient.getInstance().getTextMessageDraft(conversationType, str, "", resultCallback);
}
public void saveTextMessageDraft(Conversation.ConversationType conversationType, String str, String str2, IRongCoreCallback.ResultCallback<Boolean> resultCallback) {
ChannelClient.getInstance().saveTextMessageDraft(conversationType, str, "", str2, resultCallback);
}
public void clearTextMessageDraft(Conversation.ConversationType conversationType, String str, IRongCoreCallback.ResultCallback<Boolean> resultCallback) {
ChannelClient.getInstance().clearTextMessageDraft(conversationType, str, "", resultCallback);
}
public void getMessage(final int i, final IRongCoreCallback.ResultCallback<Message> resultCallback) {
if (i <= 0) {
RLog.e(TAG, "Illegal argument of messageId.");
if (resultCallback != null) {
resultCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
return;
}
return;
}
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
Message message = RongCoreClient.this.mLibHandler.getMessage(i);
IRongCoreCallback.ResultCallback resultCallback2 = resultCallback;
if (resultCallback2 != null) {
resultCallback2.onCallback(message);
return;
}
return;
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "getMessage", e);
IRongCoreCallback.ResultCallback resultCallback3 = resultCallback;
if (resultCallback3 != null) {
resultCallback3.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
return;
}
return;
}
}
IRongCoreCallback.ResultCallback resultCallback4 = resultCallback;
if (resultCallback4 != null) {
resultCallback4.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
}
});
}
public void insertOutgoingMessage(Conversation.ConversationType conversationType, String str, Message.SentStatus sentStatus, MessageContent messageContent, IRongCoreCallback.ResultCallback<Message> resultCallback) {
insertOutgoingMessage(conversationType, str, sentStatus, messageContent, System.currentTimeMillis(), resultCallback);
}
public void insertOutgoingMessage(Conversation.ConversationType conversationType, String str, Message.SentStatus sentStatus, MessageContent messageContent, long j, IRongCoreCallback.ResultCallback<Message> resultCallback) {
ChannelClient.getInstance().insertOutgoingMessage(conversationType, str, "", sentStatus, messageContent, j, resultCallback);
}
private void insertSettingMessage(final Message message, final IRongCoreCallback.ResultCallback<Message> resultCallback) {
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler == null) {
IRongCoreCallback.ResultCallback resultCallback2 = resultCallback;
if (resultCallback2 != null) {
resultCallback2.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
return;
}
return;
}
message.setSentTime(System.currentTimeMillis());
message.setSentStatus(null);
message.setSenderUserId(RongCoreClient.this.mCurrentUserId);
message.setMessageDirection(Message.MessageDirection.SEND);
try {
Message insertSettingMessage = RongCoreClient.this.mLibHandler.insertSettingMessage(message);
if (resultCallback != null) {
if (insertSettingMessage.getMessageId() < 0) {
if (insertSettingMessage.getMessageId() == IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR.getValue()) {
resultCallback.onFail(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
} else {
resultCallback.onFail(IRongCoreEnum.CoreErrorCode.BIZ_ERROR_DATABASE_ERROR);
}
} else {
resultCallback.onCallback(insertSettingMessage);
}
}
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "insertOutgoingMessage", e);
IRongCoreCallback.ResultCallback resultCallback3 = resultCallback;
if (resultCallback3 != null) {
resultCallback3.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
}
}
});
}
public void insertIncomingMessage(Conversation.ConversationType conversationType, String str, String str2, Message.ReceivedStatus receivedStatus, MessageContent messageContent, IRongCoreCallback.ResultCallback<Message> resultCallback) {
insertIncomingMessage(conversationType, str, str2, receivedStatus, messageContent, System.currentTimeMillis(), resultCallback);
}
public void insertIncomingMessage(Conversation.ConversationType conversationType, String str, String str2, Message.ReceivedStatus receivedStatus, MessageContent messageContent, long j, IRongCoreCallback.ResultCallback<Message> resultCallback) {
ChannelClient.getInstance().insertIncomingMessage(conversationType, str, "", str2, receivedStatus, messageContent, j, resultCallback);
}
public void sendMessage(Conversation.ConversationType conversationType, String str, MessageContent messageContent, String str2, String str3, IRongCoreCallback.ISendMessageCallback iSendMessageCallback) {
ChannelClient.getInstance().sendMessage(conversationType, str, "", messageContent, str2, str3, iSendMessageCallback);
}
public void runOnUiThread(Runnable runnable) {
mHandler.post(runnable);
}
public void sendMessage(Message message, String str, String str2, IRongCoreCallback.ISendMessageCallback iSendMessageCallback) {
sendMessage(message, str, str2, null, iSendMessageCallback);
}
public void sendMessage(Message message, String str, String str2, SendMessageOption sendMessageOption, IRongCoreCallback.ISendMessageCallback iSendMessageCallback) {
IRongCoreEnum.CoreErrorCode filterSendMessage = filterSendMessage(message);
if (filterSendMessage != null) {
if (iSendMessageCallback != null) {
iSendMessageCallback.onError(message, filterSendMessage);
}
} else if (((MessageTag) message.getContent().getClass().getAnnotation(MessageTag.class)) == null) {
RLog.e(TAG, "sendMessage Custom messages have no annotated information.");
if (iSendMessageCallback != null) {
iSendMessageCallback.onError(message, IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
}
} else {
if (TypingMessageManager.getInstance().isShowMessageTyping()) {
MessageContent content = message.getContent();
if (!(content instanceof TypingStatusMessage) && !(content instanceof ReadReceiptMessage)) {
TypingMessageManager.getInstance().setTypingEnd(message.getConversationType(), message.getTargetId(), message.getChannelId());
}
}
this.mWorkHandler.post(new AnonymousClass18(new IpcCallbackProxy(iSendMessageCallback), message, str, str2, sendMessageOption));
}
}
public class AnonymousClass18 implements Runnable {
final IpcCallbackProxy val$ipcCallbackProxy;
final Message val$message;
final SendMessageOption val$option;
final String val$pushContent;
final String val$pushData;
AnonymousClass18(IpcCallbackProxy ipcCallbackProxy, Message message, String str, String str2, SendMessageOption sendMessageOption) {
this.val$ipcCallbackProxy = ipcCallbackProxy;
this.val$message = message;
this.val$pushContent = str;
this.val$pushData = str2;
this.val$option = sendMessageOption;
}
@Override
public void run() {
if (RongCoreClient.this.mLibHandler == null) {
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (AnonymousClass18.this.val$ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ISendMessageCallback) AnonymousClass18.this.val$ipcCallbackProxy.callback).onError(AnonymousClass18.this.val$message, IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
AnonymousClass18.this.val$ipcCallbackProxy.callback = null;
}
}
});
return;
}
try {
RongCoreClient.this.mLibHandler.sendMessageOption(this.val$message, this.val$pushContent, this.val$pushData, this.val$option, new ISendMessageCallback.Stub() {
@Override
public void onAttached(final Message message) throws RemoteException {
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (AnonymousClass18.this.val$ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ISendMessageCallback) AnonymousClass18.this.val$ipcCallbackProxy.callback).onAttached(message);
}
}
});
}
@Override
public void onSuccess(final Message message) throws RemoteException {
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (AnonymousClass18.this.val$ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ISendMessageCallback) AnonymousClass18.this.val$ipcCallbackProxy.callback).onSuccess(message);
AnonymousClass18.this.val$ipcCallbackProxy.callback = null;
}
}
});
}
@Override
public void onError(final Message message, final int i) throws RemoteException {
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
FwLog.write(3, 1, FwLog.LogTag.L_SEND_MESSAGES_S.getTag(), "messageId|errorCode", Integer.valueOf(message.getMessageId()), Integer.valueOf(i));
if (AnonymousClass18.this.val$ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ISendMessageCallback) AnonymousClass18.this.val$ipcCallbackProxy.callback).onError(message, IRongCoreEnum.CoreErrorCode.valueOf(i));
AnonymousClass18.this.val$ipcCallbackProxy.callback = null;
}
}
});
}
});
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "sendMessage exception : ", e);
if (this.val$ipcCallbackProxy.callback != 0) {
FwLog.write(3, 1, FwLog.LogTag.L_SEND_MESSAGES_S.getTag(), "messageId|errorCode", Integer.valueOf(this.val$message.getMessageId()), Integer.valueOf(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT.getValue()));
((IRongCoreCallback.ISendMessageCallback) this.val$ipcCallbackProxy.callback).onError(this.val$message, IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
this.val$ipcCallbackProxy.callback = null;
}
}
}
}
public void sendDirectionalMessage(Conversation.ConversationType conversationType, String str, MessageContent messageContent, String[] strArr, String str2, String str3, IRongCoreCallback.ISendMessageCallback iSendMessageCallback) {
sendDirectionalMessage(conversationType, str, messageContent, strArr, str2, str3, null, iSendMessageCallback);
}
public void sendDirectionalMessage(Conversation.ConversationType conversationType, String str, MessageContent messageContent, String[] strArr, String str2, String str3, SendMessageOption sendMessageOption, IRongCoreCallback.ISendMessageCallback iSendMessageCallback) {
ChannelClient.getInstance().sendDirectionalMessage(conversationType, str, "", messageContent, strArr, str2, str3, sendMessageOption, iSendMessageCallback);
}
public void sendImageMessage(Conversation.ConversationType conversationType, String str, MessageContent messageContent, String str2, String str3, IRongCoreCallback.SendImageMessageCallback sendImageMessageCallback) {
ChannelClient.getInstance().sendImageMessage(conversationType, str, "", messageContent, str2, str3, sendImageMessageCallback);
}
public void sendImageMessage(Message message, final String str, final String str2, final IRongCoreCallback.SendImageMessageCallback sendImageMessageCallback) {
IRongCoreEnum.CoreErrorCode filterSendMessage = filterSendMessage(message);
if (filterSendMessage != null) {
if (sendImageMessageCallback != null) {
sendImageMessageCallback.onError(filterSendMessage);
return;
}
return;
}
final IRongCoreCallback.ResultCallback.Result result = new IRongCoreCallback.ResultCallback.Result();
result.t = message;
final IRongCoreCallback.UploadMediaCallback uploadMediaCallback = new IRongCoreCallback.UploadMediaCallback() {
@Override
public void onProgress(Message message2, int i) {
IRongCoreCallback.SendImageMessageCallback sendImageMessageCallback2 = sendImageMessageCallback;
if (sendImageMessageCallback2 != null) {
sendImageMessageCallback2.onProgressCallback(message2, i);
}
}
@Override
public void onError(Message message2, IRongCoreEnum.CoreErrorCode coreErrorCode) {
message2.setSentStatus(Message.SentStatus.FAILED);
RongCoreClient.this.setMessageSentStatus(message2, new IRongCoreCallback.ResultCallback<Boolean>() {
@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode2) {
}
@Override
public void onSuccess(Boolean bool) {
}
});
IRongCoreCallback.SendImageMessageCallback sendImageMessageCallback2 = sendImageMessageCallback;
if (sendImageMessageCallback2 != null) {
sendImageMessageCallback2.onFail(message2, coreErrorCode);
}
}
@Override
public void onSuccess(Message message2) {
RongCoreClient.this.internalSendImageMessage(message2, str, str2, sendImageMessageCallback);
}
};
IRongCoreCallback.ResultCallback<Message> resultCallback = new IRongCoreCallback.ResultCallback<Message>() {
@Override
public void onSuccess(Message message2) {
if (message2 != 0) {
result.t = message2;
message2.setSentStatus(Message.SentStatus.SENDING);
RongCoreClient.this.setMessageSentStatus(message2, null);
IRongCoreCallback.SendImageMessageCallback sendImageMessageCallback2 = sendImageMessageCallback;
if (sendImageMessageCallback2 != null) {
sendImageMessageCallback2.onAttachedCallback(message2);
}
RongCoreClient.this.uploadMedia(message2, uploadMediaCallback);
return;
}
throw new IllegalArgumentException("The Message Content is empty!");
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
IRongCoreCallback.SendImageMessageCallback sendImageMessageCallback2 = sendImageMessageCallback;
if (sendImageMessageCallback2 != null) {
sendImageMessageCallback2.onFail(coreErrorCode);
}
}
};
if (message.getMessageId() <= 0) {
insertSettingMessage(message, resultCallback);
return;
}
message.setSentStatus(Message.SentStatus.SENDING);
setMessageSentStatus(message, new IRongCoreCallback.ResultCallback<Boolean>() {
@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
}
@Override
public void onSuccess(Boolean bool) {
}
});
uploadMedia(message, uploadMediaCallback);
}
public void sendImageMessage(final Message message, final String str, final String str2, final IRongCoreCallback.SendImageMessageWithUploadListenerCallback sendImageMessageWithUploadListenerCallback) {
IRongCoreEnum.CoreErrorCode filterSendMessage = filterSendMessage(message);
if (filterSendMessage != null) {
if (sendImageMessageWithUploadListenerCallback != null) {
sendImageMessageWithUploadListenerCallback.onError(null, filterSendMessage);
}
} else if (this.mLibHandler == null) {
RLog.e(TAG, "sendImageMessage IPC Process not yet running!");
if (sendImageMessageWithUploadListenerCallback != null) {
sendImageMessageWithUploadListenerCallback.onError(message, IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
} else {
insertSettingMessage(message, new IRongCoreCallback.ResultCallback<Message>() {
@Override
public void onSuccess(Message message2) {
if (message2 != null) {
message2.setSentStatus(Message.SentStatus.SENDING);
RongCoreClient.this.setMessageSentStatus(message2, null);
IRongCoreCallback.SendImageMessageWithUploadListenerCallback sendImageMessageWithUploadListenerCallback2 = sendImageMessageWithUploadListenerCallback;
if (sendImageMessageWithUploadListenerCallback2 != null) {
sendImageMessageWithUploadListenerCallback.onAttachedCallback(message2, new IRongCoreListener.UploadImageStatusListener(message2, str, str2, sendImageMessageWithUploadListenerCallback2));
return;
}
return;
}
throw new IllegalArgumentException("The Message Content is empty!");
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
IRongCoreCallback.SendImageMessageWithUploadListenerCallback sendImageMessageWithUploadListenerCallback2 = sendImageMessageWithUploadListenerCallback;
if (sendImageMessageWithUploadListenerCallback2 != null) {
sendImageMessageWithUploadListenerCallback2.onError(message, coreErrorCode);
}
}
});
}
}
public class AnonymousClass23 implements Runnable {
final IpcCallbackProxy val$ipcCallbackProxy;
final Message val$message;
final String val$pushContent;
final String val$pushData;
AnonymousClass23(IpcCallbackProxy ipcCallbackProxy, Message message, String str, String str2) {
this.val$ipcCallbackProxy = ipcCallbackProxy;
this.val$message = message;
this.val$pushContent = str;
this.val$pushData = str2;
}
@Override
public void run() {
if (RongCoreClient.this.mLibHandler == null) {
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (AnonymousClass23.this.val$ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.SendImageMessageCallback) AnonymousClass23.this.val$ipcCallbackProxy.callback).onError(AnonymousClass23.this.val$message, IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
AnonymousClass23.this.val$ipcCallbackProxy.callback = null;
}
}
});
return;
}
try {
RongCoreClient.this.mLibHandler.sendMediaMessage(this.val$message, this.val$pushContent, this.val$pushData, new ISendMediaMessageCallback.Stub() {
@Override
public void onAttached(Message message) throws RemoteException {
}
@Override
public void onCanceled(Message message) throws RemoteException {
}
@Override
public void onProgress(Message message, int i) throws RemoteException {
}
@Override
public void onSuccess(final Message message) throws RemoteException {
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (AnonymousClass23.this.val$ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.SendImageMessageCallback) AnonymousClass23.this.val$ipcCallbackProxy.callback).onSuccess(message);
AnonymousClass23.this.val$ipcCallbackProxy.callback = null;
}
}
});
}
@Override
public void onError(final Message message, final int i) throws RemoteException {
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (AnonymousClass23.this.val$ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.SendImageMessageCallback) AnonymousClass23.this.val$ipcCallbackProxy.callback).onError(message, IRongCoreEnum.CoreErrorCode.valueOf(i));
AnonymousClass23.this.val$ipcCallbackProxy.callback = null;
}
}
});
}
});
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "internalSendImageMessage", e);
if (this.val$ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.SendImageMessageCallback) this.val$ipcCallbackProxy.callback).onError(this.val$message, IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
this.val$ipcCallbackProxy.callback = null;
}
}
}
}
public void internalSendImageMessage(Message message, String str, String str2, IRongCoreCallback.SendImageMessageCallback sendImageMessageCallback) {
this.mWorkHandler.post(new AnonymousClass23(new IpcCallbackProxy(sendImageMessageCallback), message, str, str2));
}
public void uploadMedia(final Message message, IRongCoreCallback.UploadMediaCallback uploadMediaCallback) {
IRongCoreEnum.CoreErrorCode filterSendMessage = filterSendMessage(message);
if (filterSendMessage != null) {
if (uploadMediaCallback != null) {
uploadMediaCallback.onError(message, filterSendMessage);
return;
}
return;
}
Uri uri = null;
if (message.getContent() instanceof ImageMessage) {
uri = ((ImageMessage) message.getContent()).getLocalUri();
} else if (message.getContent() instanceof GIFMessage) {
uri = ((GIFMessage) message.getContent()).getLocalUri();
}
if (!FileUtils.isFileExistsWithUri(this.mContext, uri)) {
RLog.e(TAG, "uploadMedia Uri :[" + uri + "file does not exist");
if (uploadMediaCallback != null) {
uploadMediaCallback.onError(message, IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
return;
}
return;
}
final IpcCallbackProxy ipcCallbackProxy = new IpcCallbackProxy(uploadMediaCallback);
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.uploadMedia(message, new IUploadCallback.Stub() {
@Override
public void onComplete(String str) throws RemoteException {
RLog.i(RongCoreClient.TAG, "uploadMedia onComplete url = " + str);
MessageContent content = message.getContent();
if (content instanceof ImageMessage) {
((ImageMessage) content).setRemoteUri(Uri.parse(str));
}
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.UploadMediaCallback) ipcCallbackProxy.callback).onCallback(message);
ipcCallbackProxy.callback = null;
}
}
@Override
public void onFailure(int i) throws RemoteException {
RLog.e(RongCoreClient.TAG, "uploadMedia onFailure: " + i);
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.UploadMediaCallback) ipcCallbackProxy.callback).onFail(message, IRongCoreEnum.CoreErrorCode.valueOf(i));
ipcCallbackProxy.callback = null;
}
}
@Override
public void onProgress(int i) throws RemoteException {
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.UploadMediaCallback) ipcCallbackProxy.callback).onProgressCallback(message, i);
}
}
});
return;
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "uploadMedia", e);
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.UploadMediaCallback) ipcCallbackProxy.callback).onFail(message, IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
return;
}
return;
}
}
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.UploadMediaCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
ipcCallbackProxy.callback = null;
}
});
}
public void downloadMedia(Conversation.ConversationType conversationType, String str, IRongCoreEnum.MediaType mediaType, String str2, IRongCoreCallback.DownloadMediaCallback downloadMediaCallback) {
ChannelClient.getInstance().downloadMedia(conversationType, str, "", mediaType, str2, downloadMediaCallback);
}
public void downloadMediaMessage(Message message, IRongCoreCallback.IDownloadMediaMessageCallback iDownloadMediaMessageCallback) {
if (message == null || message.getConversationType() == null || TextUtils.isEmpty(message.getTargetId()) || message.getContent() == null || !(message.getContent() instanceof MediaMessageContent)) {
if (iDownloadMediaMessageCallback != null) {
iDownloadMediaMessageCallback.onError(message, IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
return;
}
return;
}
synchronized (this.downloadMap) {
if (this.downloadMap.containsKey(Integer.valueOf(message.getMessageId()))) {
List<IRongCoreCallback.IDownloadMediaMessageCallback> list = this.downloadMap.get(Integer.valueOf(message.getMessageId()));
list.add(iDownloadMediaMessageCallback);
if (list.size() > 5) {
list.remove(0);
}
return;
}
LinkedList linkedList = new LinkedList();
linkedList.add(iDownloadMediaMessageCallback);
this.downloadMap.put(Integer.valueOf(message.getMessageId()), linkedList);
this.mWorkHandler.post(new AnonymousClass25(iDownloadMediaMessageCallback, message));
}
}
public class AnonymousClass25 implements Runnable {
final IRongCoreCallback.IDownloadMediaMessageCallback val$callback;
final Message val$message;
AnonymousClass25(IRongCoreCallback.IDownloadMediaMessageCallback iDownloadMediaMessageCallback, Message message) {
this.val$callback = iDownloadMediaMessageCallback;
this.val$message = message;
}
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.downloadMediaMessage(this.val$message, new IDownloadMediaMessageCallback.Stub() {
@Override
public void onComplete(final Message message) throws RemoteException {
AnonymousClass25.this.val$message.setContent(message.getContent());
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public synchronized void run() {
if (RongCoreClient.this.downloadMap.containsKey(Integer.valueOf(message.getMessageId()))) {
List<IRongCoreCallback.IDownloadMediaMessageCallback> list = (List) RongCoreClient.this.downloadMap.get(Integer.valueOf(message.getMessageId()));
for (IRongCoreCallback.IDownloadMediaMessageCallback iDownloadMediaMessageCallback : list) {
iDownloadMediaMessageCallback.onSuccess(message);
}
list.clear();
RongCoreClient.this.downloadMap.remove(Integer.valueOf(message.getMessageId()));
}
}
});
}
@Override
public void onFailure(final int i) throws RemoteException {
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public synchronized void run() {
if (RongCoreClient.this.downloadMap.containsKey(Integer.valueOf(AnonymousClass25.this.val$message.getMessageId()))) {
List<IRongCoreCallback.IDownloadMediaMessageCallback> list = (List) RongCoreClient.this.downloadMap.get(Integer.valueOf(AnonymousClass25.this.val$message.getMessageId()));
for (IRongCoreCallback.IDownloadMediaMessageCallback iDownloadMediaMessageCallback : list) {
iDownloadMediaMessageCallback.onError(AnonymousClass25.this.val$message, IRongCoreEnum.CoreErrorCode.valueOf(i));
}
list.clear();
RongCoreClient.this.downloadMap.remove(Integer.valueOf(AnonymousClass25.this.val$message.getMessageId()));
}
}
});
}
@Override
public void onProgress(final int i) throws RemoteException {
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.downloadMap.containsKey(Integer.valueOf(AnonymousClass25.this.val$message.getMessageId()))) {
for (IRongCoreCallback.IDownloadMediaMessageCallback iDownloadMediaMessageCallback : (List) RongCoreClient.this.downloadMap.get(Integer.valueOf(AnonymousClass25.this.val$message.getMessageId()))) {
iDownloadMediaMessageCallback.onProgress(AnonymousClass25.this.val$message, i);
}
}
}
});
}
@Override
public void onCanceled() throws RemoteException {
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public synchronized void run() {
if (RongCoreClient.this.downloadMap.containsKey(Integer.valueOf(AnonymousClass25.this.val$message.getMessageId()))) {
List<IRongCoreCallback.IDownloadMediaMessageCallback> list = (List) RongCoreClient.this.downloadMap.get(Integer.valueOf(AnonymousClass25.this.val$message.getMessageId()));
for (IRongCoreCallback.IDownloadMediaMessageCallback iDownloadMediaMessageCallback : list) {
iDownloadMediaMessageCallback.onCanceled(AnonymousClass25.this.val$message);
}
list.clear();
RongCoreClient.this.downloadMap.remove(Integer.valueOf(AnonymousClass25.this.val$message.getMessageId()));
}
}
});
}
});
return;
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "downloadMediaMessage", e);
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (AnonymousClass25.this.val$callback != null) {
AnonymousClass25.this.val$callback.onError(AnonymousClass25.this.val$message, IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
}
});
return;
}
}
this.val$callback.onError(this.val$message, IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
}
public void downloadMediaFile(String str, String str2, String str3, String str4, IRongCoreCallback.IDownloadMediaFileCallback iDownloadMediaFileCallback) {
this.mWorkHandler.post(new AnonymousClass26(new IpcCallbackProxy(iDownloadMediaFileCallback), str, str2, str3, str4, iDownloadMediaFileCallback));
}
public class AnonymousClass26 implements Runnable {
final IRongCoreCallback.IDownloadMediaFileCallback val$callback;
final String val$fileName;
final String val$fileUniqueId;
final String val$fileUrl;
final IpcCallbackProxy val$ipcCallbackProxy;
final String val$path;
AnonymousClass26(IpcCallbackProxy ipcCallbackProxy, String str, String str2, String str3, String str4, IRongCoreCallback.IDownloadMediaFileCallback iDownloadMediaFileCallback) {
this.val$ipcCallbackProxy = ipcCallbackProxy;
this.val$fileUniqueId = str;
this.val$fileUrl = str2;
this.val$fileName = str3;
this.val$path = str4;
this.val$callback = iDownloadMediaFileCallback;
}
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.downloadMediaFile(this.val$fileUniqueId, this.val$fileUrl, this.val$fileName, this.val$path, new IDownloadMediaFileCallback.Stub() {
@Override
public void onFileNameChanged(String str) {
AnonymousClass26.this.val$callback.onFileNameChanged(str);
}
@Override
public void onComplete() throws RemoteException {
if (AnonymousClass26.this.val$ipcCallbackProxy.callback != 0) {
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (AnonymousClass26.this.val$ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.IDownloadMediaFileCallback) AnonymousClass26.this.val$ipcCallbackProxy.callback).onSuccess();
AnonymousClass26.this.val$ipcCallbackProxy.callback = null;
}
}
});
}
}
@Override
public void onFailure(final int i) throws RemoteException {
if (AnonymousClass26.this.val$ipcCallbackProxy.callback != 0) {
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (AnonymousClass26.this.val$ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.IDownloadMediaFileCallback) AnonymousClass26.this.val$ipcCallbackProxy.callback).onError(IRongCoreEnum.CoreErrorCode.valueOf(i));
AnonymousClass26.this.val$ipcCallbackProxy.callback = null;
}
}
});
}
}
@Override
public void onProgress(final int i) throws RemoteException {
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (AnonymousClass26.this.val$ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.IDownloadMediaFileCallback) AnonymousClass26.this.val$ipcCallbackProxy.callback).onProgress(i);
}
}
});
}
@Override
public void onCanceled() throws RemoteException {
if (AnonymousClass26.this.val$ipcCallbackProxy.callback != 0) {
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (AnonymousClass26.this.val$ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.IDownloadMediaFileCallback) AnonymousClass26.this.val$ipcCallbackProxy.callback).onCanceled();
AnonymousClass26.this.val$ipcCallbackProxy.callback = null;
}
}
});
}
}
});
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "downloadMediaFile", e);
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (AnonymousClass26.this.val$callback != null) {
AnonymousClass26.this.val$callback.onError(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
}
});
}
} else if (this.val$ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.IDownloadMediaFileCallback) this.val$ipcCallbackProxy.callback).onError(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
this.val$ipcCallbackProxy.callback = null;
}
}
}
public void cancelSendMediaMessage(final Message message, IRongCoreCallback.OperationCallback operationCallback) {
if (message == null || message.getMessageId() <= 0 || !(message.getContent() instanceof MediaMessageContent) || ((MediaMessageContent) message.getContent()).getLocalPath() == null) {
RLog.e(TAG, "cancelSendMediaMessage, parameter is abnormal。");
if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
return;
}
return;
}
final IpcCallbackProxy ipcCallbackProxy = new IpcCallbackProxy(operationCallback);
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.cancelSendMediaMessage(message, new IRongCoreCallback.DefaultOperationCallback(ipcCallbackProxy));
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "cancelSendMediaMessage", e);
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
} else if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
});
}
public void cancelDownloadMediaMessage(final Message message, IRongCoreCallback.OperationCallback operationCallback) {
if (message == null || message.getMessageId() <= 0 || !(message.getContent() instanceof MediaMessageContent) || ((MediaMessageContent) message.getContent()).getMediaUrl() == null) {
RLog.e(TAG, "cancelDownloadMediaMessage. Parameter exception.");
if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
return;
}
return;
}
final IpcCallbackProxy ipcCallbackProxy = new IpcCallbackProxy(operationCallback);
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.downloadMap.remove(Integer.valueOf(message.getMessageId()));
RongCoreClient.this.mLibHandler.cancelDownloadMediaMessage(message, new IRongCoreCallback.DefaultOperationCallback(ipcCallbackProxy));
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "cancelDownloadMediaMessage", e);
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
ipcCallbackProxy.callback = null;
}
} else if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
});
}
public void cancelAllDownloadMediaMessage(IRongCoreCallback.OperationCallback operationCallback) {
final IpcCallbackProxy ipcCallbackProxy = new IpcCallbackProxy(operationCallback);
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.downloadMap.clear();
RongCoreClient.this.mLibHandler.cancelAllDownloadMediaMessage(new IRongCoreCallback.DefaultOperationCallback(ipcCallbackProxy));
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "cancelAllDownloadMediaMessage", e);
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
ipcCallbackProxy.callback = null;
}
} else if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
});
}
public void pauseDownloadMediaMessage(final Message message, IRongCoreCallback.OperationCallback operationCallback) {
if (message == null || message.getMessageId() <= 0 || !(message.getContent() instanceof MediaMessageContent) || ((MediaMessageContent) message.getContent()).getMediaUrl() == null) {
RLog.e(TAG, "pauseDownloadMediaMessag. Parameter exception。");
if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
return;
}
return;
}
final IpcCallbackProxy ipcCallbackProxy = new IpcCallbackProxy(operationCallback);
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.downloadMap.remove(Integer.valueOf(message.getMessageId()));
RongCoreClient.this.mLibHandler.pauseTransferMediaMessage(message, new IRongCoreCallback.DefaultOperationCallback(ipcCallbackProxy));
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "pauseDownloadMediaMessage", e);
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
ipcCallbackProxy.callback = null;
}
} else if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
});
}
public void pauseDownloadMediaFile(final String str, IRongCoreCallback.OperationCallback operationCallback) {
if (!TextUtils.isEmpty(str)) {
final IpcCallbackProxy ipcCallbackProxy = new IpcCallbackProxy(operationCallback);
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.pauseTransferMediaFile(str, new IRongCoreCallback.DefaultOperationCallback(ipcCallbackProxy));
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "pauseDownloadMediaFile", e);
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
ipcCallbackProxy.callback = null;
}
} else if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
});
} else if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
}
}
public void getConversationNotificationStatus(Conversation.ConversationType conversationType, String str, IRongCoreCallback.ResultCallback<Conversation.ConversationNotificationStatus> resultCallback) {
ChannelClient.getInstance().getConversationNotificationStatus(conversationType, str, "", resultCallback);
}
public void setConversationNotificationStatus(Conversation.ConversationType conversationType, String str, Conversation.ConversationNotificationStatus conversationNotificationStatus, IRongCoreCallback.ResultCallback<Conversation.ConversationNotificationStatus> resultCallback) {
ChannelClient.getInstance().setConversationNotificationStatus(conversationType, str, "", conversationNotificationStatus, resultCallback);
}
public String getCurrentUserId() {
try {
if (TextUtils.isEmpty(SingletonHolder.sInstance.mCurrentUserId) && this.mLibHandler != null) {
SingletonHolder.sInstance.mCurrentUserId = this.mLibHandler.getCurrentUserId();
}
} catch (Exception e) {
RLog.e(TAG, "getCurrentUserId", e);
}
if (SingletonHolder.sInstance.mCurrentUserId == null) {
RLog.w(TAG, "ipc process does not created");
Context context = this.mContext;
if (context != null) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, RongLibConst.SP_STATISTICS, 0);
SingletonHolder.sInstance.mCurrentUserId = sharedPreferences.getString("userId", "");
} else {
SingletonHolder.sInstance.mCurrentUserId = null;
}
}
return SingletonHolder.sInstance.mCurrentUserId;
}
public long getDeltaTime() {
try {
IHandler iHandler = this.mLibHandler;
if (iHandler == null) {
return 0L;
}
return iHandler.getDeltaTime();
} catch (Exception e) {
RLog.e(TAG, "getDeltaTime", e);
return 0L;
}
}
public void clearConversations(IRongCoreCallback.ResultCallback resultCallback, Conversation.ConversationType... conversationTypeArr) {
ChannelClient.getInstance().clearConversations(resultCallback, "", conversationTypeArr);
}
public void addToBlacklist(final String str, IRongCoreCallback.OperationCallback operationCallback) {
if (TextUtils.isEmpty(str)) {
RLog.e(TAG, "userId is null!");
if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
return;
}
return;
}
final IpcCallbackProxy ipcCallbackProxy = new IpcCallbackProxy(operationCallback);
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.addToBlacklist(str, new IRongCoreCallback.DefaultOperationCallback(ipcCallbackProxy));
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "addToBlacklist", e);
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
} else if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
});
}
public void removeFromBlacklist(final String str, IRongCoreCallback.OperationCallback operationCallback) {
if (TextUtils.isEmpty(str)) {
RLog.e(TAG, "userId is null!");
if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
return;
}
return;
}
final IpcCallbackProxy ipcCallbackProxy = new IpcCallbackProxy(operationCallback);
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.removeFromBlacklist(str, new IRongCoreCallback.DefaultOperationCallback(ipcCallbackProxy));
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "removeFromBlacklist", e);
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
} else if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
});
}
public void getBlacklistStatus(final String str, IRongCoreCallback.ResultCallback<IRongCoreEnum.BlacklistStatus> resultCallback) {
if (TextUtils.isEmpty(str)) {
RLog.e(TAG, "userId is null!");
if (resultCallback != null) {
resultCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
return;
}
return;
}
final IpcCallbackProxy ipcCallbackProxy = new IpcCallbackProxy(resultCallback);
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.getBlacklistStatus(str, new IIntegerCallback.Stub() {
@Override
public void onComplete(int i) throws RemoteException {
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ResultCallback) ipcCallbackProxy.callback).onCallback(IRongCoreEnum.BlacklistStatus.setValue(i));
ipcCallbackProxy.callback = null;
}
}
@Override
public void onFailure(int i) throws RemoteException {
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ResultCallback) ipcCallbackProxy.callback).onFail(i);
ipcCallbackProxy.callback = null;
}
}
});
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "getBlacklistStatus", e);
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ResultCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
} else if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ResultCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
});
}
public void getBlacklist(IRongCoreCallback.GetBlacklistCallback getBlacklistCallback) {
final IpcCallbackProxy ipcCallbackProxy = new IpcCallbackProxy(getBlacklistCallback);
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.getBlacklist(new IStringCallback.Stub() {
@Override
public void onComplete(String str) throws RemoteException {
if (ipcCallbackProxy.callback != 0) {
if (str == null) {
((IRongCoreCallback.GetBlacklistCallback) ipcCallbackProxy.callback).onCallback(null);
} else {
((IRongCoreCallback.GetBlacklistCallback) ipcCallbackProxy.callback).onCallback(str.split("\n"));
}
ipcCallbackProxy.callback = null;
}
}
@Override
public void onFailure(int i) throws RemoteException {
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.GetBlacklistCallback) ipcCallbackProxy.callback).onFail(i);
ipcCallbackProxy.callback = null;
}
}
});
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "getBlacklist", e);
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.GetBlacklistCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
} else if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.GetBlacklistCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
});
}
public void setNotificationQuietHours(final String str, final int i, IRongCoreCallback.OperationCallback operationCallback) {
if (TextUtils.isEmpty(str) || i <= 0 || i >= 1440) {
RLog.e(TAG, "The starttime, spanminutes or spanminutes parameters are abnormal。");
if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
}
} else if (!Pattern.compile("^(([0-1][0-9])|2[0-3]):[0-5][0-9]:([0-5][0-9])$").matcher(str).find()) {
RLog.e(TAG, "The startTime parameter is abnormal。");
operationCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
} else {
final IpcCallbackProxy ipcCallbackProxy = new IpcCallbackProxy(operationCallback);
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.setNotificationQuietHours(str, i, new IRongCoreCallback.DefaultOperationCallback(ipcCallbackProxy));
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "setNotificationQuietHours", e);
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
} else if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
});
}
}
public void removeNotificationQuietHours(IRongCoreCallback.OperationCallback operationCallback) {
final IpcCallbackProxy ipcCallbackProxy = new IpcCallbackProxy(operationCallback);
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.removeNotificationQuietHours(new IRongCoreCallback.DefaultOperationCallback(ipcCallbackProxy));
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "removeNotificationQuietHours", e);
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
} else if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
});
}
private void updateMessageReceiptStatus(Conversation.ConversationType conversationType, String str, long j, IRongCoreCallback.OperationCallback operationCallback) {
ChannelClient.getInstance().updateMessageReceiptStatus(conversationType, str, "", j, operationCallback);
}
public void clearMessagesUnreadStatus(Conversation.ConversationType conversationType, String str, long j, IRongCoreCallback.OperationCallback operationCallback) {
ChannelClient.getInstance().clearMessagesUnreadStatus(conversationType, str, "", j, operationCallback);
}
public long getSendTimeByMessageId(int i) {
try {
IHandler iHandler = this.mLibHandler;
if (iHandler == null) {
RLog.e(TAG, "getSendTimeByMessageId mLibHandler is null!");
return 0L;
}
return iHandler.getSendTimeByMessageId(i);
} catch (Exception e) {
RLog.e(TAG, "getSendTimeByMessageId", e);
return 0L;
}
}
public void getNotificationQuietHours(IRongCoreCallback.GetNotificationQuietHoursCallback getNotificationQuietHoursCallback) {
final IpcCallbackProxy ipcCallbackProxy = new IpcCallbackProxy(getNotificationQuietHoursCallback);
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.getNotificationQuietHours(new IGetNotificationQuietHoursCallback.Stub() {
@Override
public void onSuccess(String str, int i) {
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.GetNotificationQuietHoursCallback) ipcCallbackProxy.callback).onCallback(str, i);
ipcCallbackProxy.callback = null;
}
}
@Override
public void onError(int i) {
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.GetNotificationQuietHoursCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.valueOf(i));
ipcCallbackProxy.callback = null;
}
}
});
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "getNotificationQuietHours", e);
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.GetNotificationQuietHoursCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
} else if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.GetNotificationQuietHoursCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
});
}
private void clearToken() {
RLog.d(TAG, "clear token");
this.mToken = null;
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(this.mContext, RongLibConst.SP_STATISTICS, 0);
if (sharedPreferences != null) {
sharedPreferences.edit().remove(RongLibConst.KEY_TOKEN).commit();
}
}
private void handleReadReceiptMessage(final Message message) {
if (message.getMessageDirection().equals(Message.MessageDirection.SEND)) {
ChannelClient.getInstance().clearMessagesUnreadStatus(message.getConversationType(), message.getTargetId(), message.getChannelId(), ((ReadReceiptMessage) message.getContent()).getLastMessageSendTime(), null);
IRongCoreListener.SyncConversationReadStatusListener syncConversationReadStatusListener = this.mSyncConversationReadStatusListener;
if (syncConversationReadStatusListener != null) {
syncConversationReadStatusListener.onSyncConversationReadStatus(message.getConversationType(), message.getTargetId());
}
if (ChannelClient.mConversationChannelSyncConversationReadStatusListener != null) {
ChannelClient.mConversationChannelSyncConversationReadStatusListener.onSyncConversationReadStatus(message.getConversationType(), message.getTargetId(), message.getChannelId());
return;
}
return;
}
ChannelClient.getInstance().updateMessageReceiptStatus(message.getConversationType(), message.getTargetId(), message.getChannelId(), ((ReadReceiptMessage) message.getContent()).getLastMessageSendTime(), new IRongCoreCallback.OperationCallback() {
@Override
public void onSuccess() {
if (RongCoreClient.sReadReceiptListener == null || !TextUtils.isEmpty(message.getChannelId())) {
return;
}
RongCoreClient.sReadReceiptListener.onReadReceiptReceived(message);
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
RLog.e(RongCoreClient.TAG, "RongCoreClient : updateMessageReceiptStatus fail");
}
});
}
public boolean handleCmdMessages(final Message message, final int i, final boolean z, final boolean z2, final int i2) {
IHandler iHandler;
IHandler iHandler2;
boolean routeMessage = ModuleManager.routeMessage(message, i, z2, i2);
boolean onReceiveMessage = !routeMessage ? this.imLibExtensionModuleManager.onReceiveMessage(message, i, z2, i2) : false;
if (routeMessage || onReceiveMessage) {
return true;
}
if (TypingMessageManager.getInstance().isShowMessageTyping() && TypingMessageManager.getInstance().onReceiveMessage(message)) {
return true;
}
if (message.getContent() instanceof ReadReceiptMessage) {
handleReadReceiptMessage(message);
return true;
} else if (message.getContent() instanceof SyncReadStatusMessage) {
if (message.getMessageDirection() == Message.MessageDirection.SEND) {
clearMessagesUnreadStatus(message.getConversationType(), message.getTargetId(), ((SyncReadStatusMessage) message.getContent()).getLastMessageSendTime(), null);
IRongCoreListener.SyncConversationReadStatusListener syncConversationReadStatusListener = this.mSyncConversationReadStatusListener;
if (syncConversationReadStatusListener != null) {
syncConversationReadStatusListener.onSyncConversationReadStatus(message.getConversationType(), message.getTargetId());
}
if (ChannelClient.mConversationChannelSyncConversationReadStatusListener != null) {
ChannelClient.mConversationChannelSyncConversationReadStatusListener.onSyncConversationReadStatus(message.getConversationType(), message.getTargetId(), message.getChannelId());
}
}
return true;
} else if (message.getContent() instanceof ReadReceiptRequestMessage) {
if ((message.getConversationType().equals(Conversation.ConversationType.GROUP) || message.getConversationType().equals(Conversation.ConversationType.DISCUSSION)) && (iHandler2 = this.mLibHandler) != null) {
try {
if (ReadReceiptV2Manager.GroupReadReceiptVersion.valueOf(iHandler2.getCachedReadReceiptVersion()) == ReadReceiptV2Manager.GroupReadReceiptVersion.GROUP_READ_RECEIPT_V2) {
RLog.i(TAG, "ReadReceiptRequestMessage:errorCode=" + IRongCoreEnum.CoreErrorCode.RC_GROUP_READ_RECEIPT_VERSION_NOT_SUPPORT.code);
return true;
}
} catch (Exception e) {
RLog.e(TAG, "handleCmdMessages ReadReceiptRequestMessage ", e);
}
ReadReceiptRequestMessage readReceiptRequestMessage = (ReadReceiptRequestMessage) message.getContent();
try {
Message messageByUid = this.mLibHandler.getMessageByUid(readReceiptRequestMessage.getMessageUId());
if (messageByUid != null) {
ReadReceiptInfo readReceiptInfo = messageByUid.getReadReceiptInfo();
if (readReceiptInfo == null) {
readReceiptInfo = new ReadReceiptInfo();
messageByUid.setReadReceiptInfo(readReceiptInfo);
}
readReceiptInfo.setIsReadReceiptMessage(true);
readReceiptInfo.setHasRespond(false);
this.mLibHandler.updateReadReceiptRequestInfo(readReceiptRequestMessage.getMessageUId(), readReceiptInfo.toJSON().toString());
if (sReadReceiptListener != null && TextUtils.isEmpty(messageByUid.getChannelId())) {
sReadReceiptListener.onMessageReceiptRequest(message.getConversationType(), message.getTargetId(), readReceiptRequestMessage.getMessageUId());
}
}
} catch (Exception e2) {
RLog.e(TAG, "handleCmdMessages", e2);
}
}
return true;
} else if (message.getContent() instanceof ReadReceiptResponseMessage) {
if (message.getMessageDirection().equals(Message.MessageDirection.SEND)) {
return true;
}
if ((message.getConversationType().equals(Conversation.ConversationType.GROUP) || message.getConversationType().equals(Conversation.ConversationType.DISCUSSION)) && (iHandler = this.mLibHandler) != null) {
try {
if (ReadReceiptV2Manager.GroupReadReceiptVersion.valueOf(iHandler.getCachedReadReceiptVersion()) == ReadReceiptV2Manager.GroupReadReceiptVersion.GROUP_READ_RECEIPT_V2) {
RLog.i(TAG, "ReadReceiptResponseMessage:errorCode=" + IRongCoreEnum.CoreErrorCode.RC_GROUP_READ_RECEIPT_VERSION_NOT_SUPPORT.code);
return true;
}
} catch (Exception e3) {
RLog.e(TAG, "handleCmdMessages ReadReceiptResponseMessage ", e3);
}
ArrayList<String> messageUIdListBySenderId = ((ReadReceiptResponseMessage) message.getContent()).getMessageUIdListBySenderId(getCurrentUserId());
String senderUserId = message.getSenderUserId();
if (messageUIdListBySenderId != null) {
Iterator<String> it = messageUIdListBySenderId.iterator();
while (it.hasNext()) {
String next = it.next();
try {
Message messageByUid2 = this.mLibHandler.getMessageByUid(next);
if (messageByUid2 != null) {
ReadReceiptInfo readReceiptInfo2 = messageByUid2.getReadReceiptInfo();
if (readReceiptInfo2 == null) {
readReceiptInfo2 = new ReadReceiptInfo();
messageByUid2.setReadReceiptInfo(readReceiptInfo2);
}
readReceiptInfo2.setIsReadReceiptMessage(true);
HashMap<String, Long> respondUserIdList = readReceiptInfo2.getRespondUserIdList();
if (respondUserIdList == null) {
respondUserIdList = new HashMap<>();
readReceiptInfo2.setRespondUserIdList(respondUserIdList);
}
respondUserIdList.put(senderUserId, Long.valueOf(message.getSentTime()));
this.mLibHandler.updateReadReceiptRequestInfo(next, readReceiptInfo2.toJSON().toString());
if (sReadReceiptListener != null && TextUtils.isEmpty(messageByUid2.getChannelId())) {
sReadReceiptListener.onMessageReceiptResponse(message.getConversationType(), message.getTargetId(), next, respondUserIdList);
}
}
} catch (Exception e4) {
RLog.e(TAG, "#handleCmdMessages", e4);
}
}
}
}
return true;
} else if (message.getContent() instanceof RecallCommandMessage) {
final RecallCommandMessage recallCommandMessage = (RecallCommandMessage) message.getContent();
getMessageByUid(recallCommandMessage.getMessageUId(), new IRongCoreCallback.ResultCallback<Message>() {
@Override
public void onSuccess(final Message message2) {
if (recallCommandMessage.isDelete()) {
if (message2 != null) {
int[] iArr = {message2.getMessageId()};
FwLog.write(4, 1, FwLog.LogTag.P_DELETE_MSG_S.getTag(), "isDelete|messageId|messageUId", Boolean.valueOf(recallCommandMessage.isDelete()), iArr, recallCommandMessage.getMessageUId());
message2.setMessagePushConfig(message.getMessagePushConfig());
RongCoreClient.this.deleteMessages(iArr, new IRongCoreCallback.ResultCallback<Boolean>() {
@Override
public void onSuccess(Boolean bool) {
RLog.i(RongCoreClient.TAG, "deleteMessage success");
if (RongCoreClient.sOnRecallMessageListener != null) {
RongCoreClient.sOnRecallMessageListener.onMessageRecalled(message2, null);
}
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
RLog.e(RongCoreClient.TAG, "deleteMessage when recall, error " + coreErrorCode.code);
}
});
}
} else if (message2 == null) {
RecallNotificationMessage recallNotificationMessage = new RecallNotificationMessage(message.getSenderUserId(), recallCommandMessage.getSentTime(), message.getObjectName(), recallCommandMessage.isAdmin(), recallCommandMessage.isDelete());
recallNotificationMessage.setUserInfo(recallCommandMessage.getUserInfo());
Message obtain = Message.obtain(message.getTargetId(), message.getConversationType(), recallNotificationMessage);
obtain.setSentTime(recallCommandMessage.getSentTime());
obtain.setSenderUserId(message.getSenderUserId());
obtain.setMessageDirection(Message.MessageDirection.SEND);
RongCoreClient.this.insertIncomingMessage(message.getConversationType(), message.getTargetId(), message.getSenderUserId(), new Message.ReceivedStatus(0), recallNotificationMessage, recallCommandMessage.getSentTime(), null);
if (RongCoreClient.sReceiveMessageListener != null) {
if (RongCoreClient.sReceiveMessageListener instanceof IRongCoreListener.OnReceiveMessageWrapperListener) {
((IRongCoreListener.OnReceiveMessageWrapperListener) RongCoreClient.sReceiveMessageListener).onReceived(obtain, i - i2, z, z2);
} else {
RongCoreClient.sReceiveMessageListener.onReceived(obtain, i - i2);
}
}
} else {
RecallNotificationMessage recallNotificationMessage2 = new RecallNotificationMessage(message.getSenderUserId(), recallCommandMessage.getSentTime(), message2.getObjectName(), recallCommandMessage.isAdmin(), recallCommandMessage.isDelete());
message2.setMessagePushConfig(message.getMessagePushConfig());
message2.getReceivedStatus().setRead();
RongCoreClient.this.setMessageReceivedStatus(message2.getMessageId(), message2.getReceivedStatus(), null);
if (message2.getContent().getUserInfo() != null) {
recallNotificationMessage2.setUserInfo(message2.getContent().getUserInfo());
}
if (message2.getContent() instanceof RecallNotificationMessage) {
RecallNotificationMessage recallNotificationMessage3 = (RecallNotificationMessage) message2.getContent();
if (recallNotificationMessage3.getRecallActionTime() > 0) {
recallNotificationMessage2.setRecallActionTime(recallNotificationMessage3.getRecallActionTime());
}
if (!TextUtils.isEmpty(recallNotificationMessage3.getRecallContent())) {
recallNotificationMessage2.setRecallContent(recallNotificationMessage3.getRecallContent());
}
}
try {
RongCoreClient.this.mLibHandler.setMessageContent(message2.getMessageId(), recallNotificationMessage2.encode(), ((MessageTag) RecallNotificationMessage.class.getAnnotation(MessageTag.class)).value());
if (RongCoreClient.sOnRecallMessageListener != null) {
message2.setContent(recallNotificationMessage2);
RongCoreClient.sOnRecallMessageListener.onMessageRecalled(message2, recallNotificationMessage2);
}
} catch (Exception e5) {
RLog.e(RongCoreClient.TAG, "handleCmdMessages", e5);
}
}
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
RLog.e(RongCoreClient.TAG, "recall message received, but getMessageByUid failed");
}
});
return true;
} else if (message.getContent() instanceof DestructionCmdMessage) {
for (String str : ((DestructionCmdMessage) message.getContent()).getBurnMessageUIds()) {
getMessageByUid(str, new IRongCoreCallback.ResultCallback<Message>() {
@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
}
@Override
public void onSuccess(Message message2) {
if (message2 != null) {
RongCoreClient.this.setMessageReadTime(message2.getMessageId(), message.getSentTime(), null);
message2.setReadTime(message.getSentTime());
RongCoreClient.getInstance().deleteRemoteMessages(message2.getConversationType(), message2.getTargetId(), new Message[]{message2}, null);
RongCoreClient.getInstance().deleteMessages(new int[]{message2.getMessageId()}, null);
if (RongCoreClient.this.mOnReceiveDestructionMessageListener != null) {
RongCoreClient.this.mOnReceiveDestructionMessageListener.onReceive(message2);
}
}
}
});
}
return true;
} else {
return this.mCmdObjectNameList.contains(message.getObjectName());
}
}
public void initReceiver() {
RLog.i(TAG, "initMessageReceiver");
try {
if (!TextUtils.isEmpty(mNaviServer)) {
this.mLibHandler.setServerInfo(mNaviServer, TextUtils.isEmpty(mFileServer) ? "" : mFileServer);
}
this.mLibHandler.initHttpDns();
this.mLibHandler.setUserPolicy(userPolicy);
if (this.mStatusListener == null) {
this.mStatusListener = new StatusListener();
}
this.mLibHandler.setConnectionStatusListener(this.mStatusListener);
this.mLibHandler.setReconnectKickEnable(this.kickReconnectDevice);
this.mLibHandler.setOnReceiveMessageListener(new OnReceiveMessageListener.Stub() {
@Override
public boolean onTransact(int i, Parcel parcel, Parcel parcel2, int i2) throws RemoteException {
try {
return super.onTransact(i, parcel, parcel2, i2);
} catch (RuntimeException e) {
RLog.e(RongCoreClient.TAG, "setOnReceiveMessageListener Unexpected remote exception", e);
throw e;
}
}
@Override
public boolean onReceived(final Message message, final int i, final boolean z, final boolean z2, final int i2) throws RemoteException {
RongCoreClient.this.mUpStreamHandler.post(new Runnable() {
@Override
public void run() {
if (message.getContent() == null) {
RLog.e(RongCoreClient.TAG, "message content is null. Return directly!");
return;
}
if (!z2) {
RLog.i(RongCoreClient.TAG, "onReceived : " + message.getTargetId() + " " + message.getObjectName() + ", sender = " + message.getSenderUserId() + ", uid = " + message.getUId() + ", offline:" + z);
}
if (RongCoreClient.this.handleCmdMessages(message, i, z2, z, i2) || RongCoreClient.sReceiveMessageListener == null) {
return;
}
if (RongCoreClient.sReceiveMessageListener instanceof IRongCoreListener.OnReceiveMessageWrapperListener) {
((IRongCoreListener.OnReceiveMessageWrapperListener) RongCoreClient.sReceiveMessageListener).onReceived(message, i - i2, z2, z);
} else {
RongCoreClient.sReceiveMessageListener.onReceived(message, i - i2);
}
}
});
return false;
}
});
this.mLibHandler.setUserProfileListener(new UserProfileSettingListener.Stub() {
@Override
public void OnPushNotificationChanged(long j) throws RemoteException {
RongCoreClient.this.getPushContentShowStatus(new IRongCoreCallback.ResultCallback<Boolean>() {
@Override
public void onSuccess(Boolean bool) {
RLog.i(RongCoreClient.TAG, "OnPushNotificationChanged onSuccess " + bool);
RongPushClient.updatePushContentShowStatus(RongCoreClient.this.mContext, bool.booleanValue());
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
RLog.i(RongCoreClient.TAG, "OnPushNotificationChanged onError " + coreErrorCode);
}
});
if (RongCoreClient.mPushNotificationListener != null) {
RongCoreClient.mPushNotificationListener.OnPushNotificationChanged(j);
}
}
@Override
public void onTagChanged() throws RemoteException {
if (RongCoreClient.this.mTagListener != null) {
RongCoreClient.this.mTagListener.onTagChanged();
}
}
});
this.mLibHandler.setConversationStatusListener(new ConversationStatusListener.Stub() {
@Override
public void OnStatusChanged(ConversationStatus[] conversationStatusArr) {
if (RongCoreClient.sConversationStatusListener != null) {
RongCoreClient.sConversationStatusListener.onStatusChanged(conversationStatusArr);
}
}
@Override
public void onConversationTagChanged() throws RemoteException {
if (RongCoreClient.sConversationTagListener != null) {
RongCoreClient.sConversationTagListener.onConversationTagChanged();
}
}
});
this.mLibHandler.setConversationListener(new IConversationListener.Stub() {
@Override
public void onConversationSync() throws RemoteException {
if (RongCoreClient.conversationListener != null) {
RongCoreClient.conversationListener.onConversationSync();
}
}
});
this.mLibHandler.setMessageExpansionListener(new IMessageExpansionListener.Stub() {
@Override
public void onMessageExpansionUpdate(Map map, Message message) {
if (RongCoreClient.messageExpansionListener != null) {
RongCoreClient.messageExpansionListener.onMessageExpansionUpdate(map, message);
}
}
@Override
public void onMessageExpansionRemove(List<String> list, Message message) {
if (RongCoreClient.messageExpansionListener != null) {
RongCoreClient.messageExpansionListener.onMessageExpansionRemove(list, message);
}
}
});
synchronized (this.mRegCache) {
this.mLibHandler.registerMessageTypes(new ArrayList(this.mRegCache));
}
this.mLibHandler.registerCmdMsgTypes(new ArrayList(this.mCmdObjectNameList));
this.mLibHandler.registerDeleteMessageType(new ArrayList(this.mDeleteObjectNameList));
if (cancelSDKHeartBeatEnabled) {
try {
this.mLibHandler.cancelSDKHeartBeat();
} catch (Exception e) {
RLog.e(TAG, "initReceiver", e);
}
}
} catch (Exception e2) {
RLog.e(TAG, "initReceiver", e2);
}
}
public void setIPCLogListener() {
try {
final IHandler iHandler = this.mLibHandler;
FwLog.setProxyWriter(new IFwLogWriter() {
@Override
public void write(int i, String str, String str2, String str3, long j) {
try {
IHandler iHandler2 = iHandler;
if (iHandler2 != null) {
iHandler2.writeFwLog(i, str, str2, str3, j);
}
} catch (Exception unused) {
}
}
});
if (iHandler != null) {
iHandler.setRLogOtherProgressCallback(new IRLogOtherProgressCallback.Stub() {
@Override
public void write(String str, int i) {
RLog.callbackWrite(str, i);
}
@Override
public void setLogLevel(int i) {
RLog.setLogLevel(i);
}
@Override
public void uploadRLog() {
RLog.uploadRLog();
}
});
iHandler.setNaviContentUpdateListener(new INaviContentUpdateCallBack.Stub() {
@Override
public void naviContentUpdate() {
RongCoreClient.this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
try {
RLog.setUploadUrl(iHandler.getOffLineLogServer());
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "getUploadLogConfigInfo", e);
}
}
});
}
});
}
} catch (Exception e) {
RLog.e(TAG, "setIPCLogListener", e);
}
}
public void getMessageByUid(final String str, final IRongCoreCallback.ResultCallback<Message> resultCallback) {
if (TextUtils.isEmpty(str)) {
RLog.e(TAG, "getMessageByUid uid is empty!");
} else {
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler == null) {
IRongCoreCallback.ResultCallback resultCallback2 = resultCallback;
if (resultCallback2 != null) {
resultCallback2.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
return;
}
return;
}
try {
if (resultCallback != null) {
resultCallback.onCallback(RongCoreClient.this.mLibHandler.getMessageByUid(str));
}
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "getMessageByUid", e);
IRongCoreCallback.ResultCallback resultCallback3 = resultCallback;
if (resultCallback3 != null) {
resultCallback3.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
}
}
});
}
}
public void switchAppKey(String str) {
RLog.d(TAG, "switchAppKey.");
IHandler iHandler = this.mLibHandler;
if (iHandler == null) {
RLog.e(TAG, "IPC_DISCONNECT");
return;
}
try {
iHandler.switchAppKey(str, DeviceUtils.getDeviceId(this.mContext, str));
} catch (Exception e) {
RLog.e(TAG, "switchAppKey", e);
}
mNaviServer = null;
mFileServer = null;
if (isPushEnabled) {
RongPushClient.stopService(this.mContext);
}
}
public Collection<TypingStatus> getTypingUserListFromConversation(Conversation.ConversationType conversationType, String str) {
return ChannelClient.getInstance().getTypingUserListFromConversation(conversationType, str, "");
}
public void sendTypingStatus(Conversation.ConversationType conversationType, String str, String str2) {
ChannelClient.getInstance().sendTypingStatus(conversationType, str, "", str2);
}
public void sendReadReceiptMessage(Conversation.ConversationType conversationType, String str, long j) {
ChannelClient.getInstance().sendReadReceiptMessage(conversationType, str, "", j);
}
public void sendReadReceiptMessage(Conversation.ConversationType conversationType, String str, long j, IRongCoreCallback.ISendMessageCallback iSendMessageCallback) {
ChannelClient.getInstance().sendReadReceiptMessage(conversationType, str, "", j, iSendMessageCallback);
}
public void setOnReceiveDestructionMessageListener(IRongCoreListener.OnReceiveDestructionMessageListener onReceiveDestructionMessageListener) {
this.mOnReceiveDestructionMessageListener = onReceiveDestructionMessageListener;
}
public void recallMessage(final Message message, String str, final IRongCoreCallback.ResultCallback<RecallNotificationMessage> resultCallback) {
if (this.mLibHandler == null) {
RLog.e(TAG, "recallMessage .IPC process is not yet running。");
if (resultCallback != null) {
resultCallback.onError(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
return;
}
return;
}
String value = ((MessageTag) RecallCommandMessage.class.getAnnotation(MessageTag.class)).value();
if (message == null) {
RLog.e(TAG, "recallMessage message is null");
if (resultCallback != null) {
resultCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
return;
}
return;
}
final RecallCommandMessage recallCommandMessage = new RecallCommandMessage(message.getUId());
recallCommandMessage.setConversationType(message.getConversationType().getValue());
recallCommandMessage.setTargetId(message.getTargetId());
recallCommandMessage.setSentTime(message.getSentTime());
recallCommandMessage.setUserInfo(message.getContent().getUserInfo());
try {
this.mLibHandler.recallMessage(value, recallCommandMessage.encode(), str, message, new IOperationCallback.Stub() {
@Override
public void onComplete() throws RemoteException {
RecallNotificationMessage recallNotificationMessage = new RecallNotificationMessage(RongCoreClient.this.getCurrentUserId(), message.getSentTime(), message.getObjectName(), recallCommandMessage.isAdmin(), recallCommandMessage.isDelete());
MessageContent content = message.getContent();
if (content instanceof TextMessage) {
recallNotificationMessage.setRecallContent(((TextMessage) content).getContent());
recallNotificationMessage.setRecallActionTime(System.currentTimeMillis());
}
recallNotificationMessage.setUserInfo(recallCommandMessage.getUserInfo());
try {
RongCoreClient.this.mLibHandler.setMessageContent(message.getMessageId(), recallNotificationMessage.encode(), ((MessageTag) RecallNotificationMessage.class.getAnnotation(MessageTag.class)).value());
IRongCoreCallback.ResultCallback resultCallback2 = resultCallback;
if (resultCallback2 != null) {
resultCallback2.onCallback(recallNotificationMessage);
}
} catch (RemoteException e) {
RLog.e(RongCoreClient.TAG, "recallMessage", e);
IRongCoreCallback.ResultCallback resultCallback3 = resultCallback;
if (resultCallback3 != null) {
resultCallback3.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
}
}
@Override
public void onFailure(int i) throws RemoteException {
IRongCoreCallback.ResultCallback resultCallback2 = resultCallback;
if (resultCallback2 != null) {
resultCallback2.onFail(IRongCoreEnum.CoreErrorCode.valueOf(i));
}
}
});
} catch (RemoteException e) {
RLog.e(TAG, "recallMessage", e);
if (resultCallback != null) {
resultCallback.onError(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
}
}
public void getUnreadMentionedMessages(Conversation.ConversationType conversationType, String str, IRongCoreCallback.ResultCallback<List<Message>> resultCallback) {
ChannelClient.getInstance().getUnreadMentionedMessages(conversationType, str, "", resultCallback);
}
public void sendMediaMessage(Message message, String str, String str2, IRongCoreCallback.ISendMediaMessageCallback iSendMediaMessageCallback) {
IRongCoreEnum.CoreErrorCode filterSendMessage = filterSendMessage(message);
if (filterSendMessage != null) {
if (iSendMediaMessageCallback != null) {
iSendMediaMessageCallback.onError(message, filterSendMessage);
return;
}
return;
}
MediaMessageContent mediaMessageContent = (MediaMessageContent) message.getContent();
if (mediaMessageContent.getMediaUrl() != null) {
sendMessage(message, str, str2, iSendMediaMessageCallback);
return;
}
if (!FileUtils.isFileExistsWithUri(this.mContext, mediaMessageContent.getLocalPath())) {
RLog.e(TAG, "localPath does not exist!");
if (iSendMediaMessageCallback != null) {
iSendMediaMessageCallback.onError(message, IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
return;
}
return;
}
this.mWorkHandler.post(new AnonymousClass52(new IpcCallbackProxy(iSendMediaMessageCallback), message, str, str2));
}
public class AnonymousClass52 implements Runnable {
final IpcCallbackProxy val$ipcCallbackProxy;
final Message val$message;
final String val$pushContent;
final String val$pushData;
AnonymousClass52(IpcCallbackProxy ipcCallbackProxy, Message message, String str, String str2) {
this.val$ipcCallbackProxy = ipcCallbackProxy;
this.val$message = message;
this.val$pushContent = str;
this.val$pushData = str2;
}
@Override
public void run() {
if (RongCoreClient.this.mLibHandler == null) {
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (AnonymousClass52.this.val$ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ISendMediaMessageCallback) AnonymousClass52.this.val$ipcCallbackProxy.callback).onError(AnonymousClass52.this.val$message, IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
AnonymousClass52.this.val$ipcCallbackProxy.callback = null;
}
}
});
return;
}
try {
RongCoreClient.this.mLibHandler.sendMediaMessage(this.val$message, this.val$pushContent, this.val$pushData, new ISendMediaMessageCallback.Stub() {
@Override
public void onAttached(final Message message) throws RemoteException {
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (AnonymousClass52.this.val$ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ISendMediaMessageCallback) AnonymousClass52.this.val$ipcCallbackProxy.callback).onAttached(message);
}
}
});
}
@Override
public void onProgress(final Message message, final int i) throws RemoteException {
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (AnonymousClass52.this.val$ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ISendMediaMessageCallback) AnonymousClass52.this.val$ipcCallbackProxy.callback).onProgress(message, i);
}
}
});
}
@Override
public void onSuccess(final Message message) throws RemoteException {
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (AnonymousClass52.this.val$ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ISendMediaMessageCallback) AnonymousClass52.this.val$ipcCallbackProxy.callback).onSuccess(message);
AnonymousClass52.this.val$ipcCallbackProxy.callback = null;
}
}
});
}
@Override
public void onError(final Message message, final int i) throws RemoteException {
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (AnonymousClass52.this.val$ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ISendMediaMessageCallback) AnonymousClass52.this.val$ipcCallbackProxy.callback).onError(message, IRongCoreEnum.CoreErrorCode.valueOf(i));
AnonymousClass52.this.val$ipcCallbackProxy.callback = null;
}
}
});
}
@Override
public void onCanceled(final Message message) throws RemoteException {
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (AnonymousClass52.this.val$ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ISendMediaMessageCallback) AnonymousClass52.this.val$ipcCallbackProxy.callback).onCanceled(message);
AnonymousClass52.this.val$ipcCallbackProxy.callback = null;
}
}
});
}
});
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "sendMediaMessage", e);
if (this.val$ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ISendMediaMessageCallback) this.val$ipcCallbackProxy.callback).onError(this.val$message, IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
this.val$ipcCallbackProxy.callback = null;
}
}
}
}
public void sendDirectionalMediaMessage(Message message, String[] strArr, String str, String str2, IRongCoreCallback.ISendMediaMessageCallback iSendMediaMessageCallback) {
IRongCoreEnum.CoreErrorCode filterSendMessage = filterSendMessage(message);
if (filterSendMessage != null) {
if (iSendMediaMessageCallback != null) {
iSendMediaMessageCallback.onError(message, filterSendMessage);
return;
}
return;
}
MediaMessageContent mediaMessageContent = (MediaMessageContent) message.getContent();
if (mediaMessageContent.getMediaUrl() != null) {
sendMessage(message, str, str2, iSendMediaMessageCallback);
} else if (mediaMessageContent.getLocalPath() == null) {
RLog.e(TAG, "Media file does not exist!");
if (iSendMediaMessageCallback != null) {
iSendMediaMessageCallback.onError(message, IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
}
} else {
String uri = mediaMessageContent.getLocalPath().toString();
String substring = uri.substring(7);
if (!uri.startsWith(LibStorageUtils.FILE) || !new File(substring).exists()) {
RLog.e(TAG, uri + " does not exist!");
if (iSendMediaMessageCallback != null) {
iSendMediaMessageCallback.onError(message, IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
return;
}
return;
}
this.mWorkHandler.post(new AnonymousClass53(new IpcCallbackProxy(iSendMediaMessageCallback), message, strArr, str, str2));
}
}
public class AnonymousClass53 implements Runnable {
final IpcCallbackProxy val$ipcCallbackProxy;
final Message val$message;
final String val$pushContent;
final String val$pushData;
final String[] val$userIds;
AnonymousClass53(IpcCallbackProxy ipcCallbackProxy, Message message, String[] strArr, String str, String str2) {
this.val$ipcCallbackProxy = ipcCallbackProxy;
this.val$message = message;
this.val$userIds = strArr;
this.val$pushContent = str;
this.val$pushData = str2;
}
@Override
public void run() {
if (RongCoreClient.this.mLibHandler == null) {
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (AnonymousClass53.this.val$ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ISendMediaMessageCallback) AnonymousClass53.this.val$ipcCallbackProxy.callback).onError(AnonymousClass53.this.val$message, IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
AnonymousClass53.this.val$ipcCallbackProxy.callback = null;
}
}
});
return;
}
try {
RongCoreClient.this.mLibHandler.sendDirectionalMediaMessage(this.val$message, this.val$userIds, this.val$pushContent, this.val$pushData, new ISendMediaMessageCallback.Stub() {
@Override
public void onAttached(final Message message) throws RemoteException {
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (AnonymousClass53.this.val$ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ISendMediaMessageCallback) AnonymousClass53.this.val$ipcCallbackProxy.callback).onAttached(message);
}
}
});
}
@Override
public void onProgress(final Message message, final int i) throws RemoteException {
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (AnonymousClass53.this.val$ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ISendMediaMessageCallback) AnonymousClass53.this.val$ipcCallbackProxy.callback).onProgress(message, i);
}
}
});
}
@Override
public void onSuccess(final Message message) throws RemoteException {
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (AnonymousClass53.this.val$ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ISendMediaMessageCallback) AnonymousClass53.this.val$ipcCallbackProxy.callback).onSuccess(message);
AnonymousClass53.this.val$ipcCallbackProxy.callback = null;
}
}
});
}
@Override
public void onError(final Message message, final int i) throws RemoteException {
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (AnonymousClass53.this.val$ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ISendMediaMessageCallback) AnonymousClass53.this.val$ipcCallbackProxy.callback).onError(message, IRongCoreEnum.CoreErrorCode.valueOf(i));
AnonymousClass53.this.val$ipcCallbackProxy.callback = null;
}
}
});
}
@Override
public void onCanceled(final Message message) throws RemoteException {
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (AnonymousClass53.this.val$ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ISendMediaMessageCallback) AnonymousClass53.this.val$ipcCallbackProxy.callback).onCanceled(message);
AnonymousClass53.this.val$ipcCallbackProxy.callback = null;
}
}
});
}
});
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "sendDirectionalMediaMessage", e);
if (this.val$ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ISendMediaMessageCallback) this.val$ipcCallbackProxy.callback).onError(this.val$message, IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
this.val$ipcCallbackProxy.callback = null;
}
}
}
}
public void sendMediaMessage(final Message message, final String str, final String str2, final IRongCoreCallback.ISendMediaMessageCallbackWithUploader iSendMediaMessageCallbackWithUploader) {
IRongCoreEnum.CoreErrorCode filterSendMessage = filterSendMessage(message);
if (filterSendMessage != null) {
if (iSendMediaMessageCallbackWithUploader != null) {
iSendMediaMessageCallbackWithUploader.onError(message, filterSendMessage);
}
} else if (!FileUtils.isFileExistsWithUri(this.mContext, ((MediaMessageContent) message.getContent()).getLocalPath())) {
RLog.e(TAG, "Media file does not exist!");
if (iSendMediaMessageCallbackWithUploader != null) {
iSendMediaMessageCallbackWithUploader.onError(message, IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
}
} else {
insertSettingMessage(message, new IRongCoreCallback.ResultCallback<Message>() {
@Override
public void onSuccess(Message message2) {
message2.setSentStatus(Message.SentStatus.SENDING);
RongCoreClient.this.setMessageSentStatus(message2, null);
IRongCoreCallback.ISendMediaMessageCallbackWithUploader iSendMediaMessageCallbackWithUploader2 = iSendMediaMessageCallbackWithUploader;
if (iSendMediaMessageCallbackWithUploader2 != null) {
iSendMediaMessageCallbackWithUploader2.onAttached(message2, new IRongCoreCallback.MediaMessageUploader(message2, str, str2, iSendMediaMessageCallbackWithUploader2));
}
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
IRongCoreCallback.ISendMediaMessageCallbackWithUploader iSendMediaMessageCallbackWithUploader2 = iSendMediaMessageCallbackWithUploader;
if (iSendMediaMessageCallbackWithUploader2 != null) {
iSendMediaMessageCallbackWithUploader2.onError(message, IRongCoreEnum.CoreErrorCode.RC_MSG_SEND_FAIL);
}
}
});
}
}
public void sendReadReceiptRequest(final Message message, final IRongCoreCallback.OperationCallback operationCallback) {
if (message == null) {
if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
}
} else if (!Conversation.ConversationType.GROUP.equals(message.getConversationType()) && !Conversation.ConversationType.DISCUSSION.equals(message.getConversationType())) {
RLog.w(TAG, "only group and discussion could send read receipt request.");
if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
}
} else if (this.mLibHandler == null) {
if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
} else {
ReadReceiptV2Manager.GroupReadReceiptVersion groupReadReceiptVersion = ReadReceiptV2Manager.GroupReadReceiptVersion.UNKNOWN;
try {
groupReadReceiptVersion = ReadReceiptV2Manager.GroupReadReceiptVersion.valueOf(this.mLibHandler.getCachedReadReceiptVersion());
} catch (RemoteException e) {
RLog.e(TAG, "sendReadReceiptRequest", e);
}
if (groupReadReceiptVersion != ReadReceiptV2Manager.GroupReadReceiptVersion.GROUP_READ_RECEIPT_V2) {
ChannelClient.getInstance().sendMessage(message.getConversationType(), message.getTargetId(), message.getChannelId(), new ReadReceiptRequestMessage(message.getUId()), null, null, new IRongCoreCallback.ISendMessageCallback() {
@Override
public void onAttached(Message message2) {
}
@Override
public void onSuccess(Message message2) {
if (RongCoreClient.this.mLibHandler == null) {
RLog.d(RongCoreClient.TAG, "sendReadReceiptRequest mLibHandler is null");
IRongCoreCallback.OperationCallback operationCallback2 = operationCallback;
if (operationCallback2 != null) {
operationCallback2.onError(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
return;
}
return;
}
try {
ReadReceiptInfo readReceiptInfo = message.getReadReceiptInfo();
if (readReceiptInfo == null) {
readReceiptInfo = new ReadReceiptInfo();
message.setReadReceiptInfo(readReceiptInfo);
}
readReceiptInfo.setIsReadReceiptMessage(true);
RongCoreClient.this.mLibHandler.updateReadReceiptRequestInfo(message.getUId(), readReceiptInfo.toJSON().toString());
IRongCoreCallback.OperationCallback operationCallback3 = operationCallback;
if (operationCallback3 != null) {
operationCallback3.onSuccess();
}
} catch (Exception e2) {
RLog.e(RongCoreClient.TAG, "sendReadReceiptRequest", e2);
IRongCoreCallback.OperationCallback operationCallback4 = operationCallback;
if (operationCallback4 != null) {
operationCallback4.onError(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
}
}
@Override
public void onError(Message message2, IRongCoreEnum.CoreErrorCode coreErrorCode) {
IRongCoreCallback.OperationCallback operationCallback2 = operationCallback;
if (operationCallback2 != null) {
operationCallback2.onError(coreErrorCode);
}
}
});
} else if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.RC_GROUP_READ_RECEIPT_VERSION_NOT_SUPPORT);
}
}
}
public void sendReadReceiptResponse(Conversation.ConversationType conversationType, String str, List<Message> list, IRongCoreCallback.OperationCallback operationCallback) {
ChannelClient.getInstance().sendReadReceiptResponse(conversationType, str, "", list, operationCallback);
}
public void syncConversationReadStatus(Conversation.ConversationType conversationType, String str, long j, IRongCoreCallback.OperationCallback operationCallback) {
ChannelClient.getInstance().syncConversationReadStatus(conversationType, str, "", j, operationCallback);
}
public void setSyncConversationReadStatusListener(IRongCoreListener.SyncConversationReadStatusListener syncConversationReadStatusListener) {
this.mSyncConversationReadStatusListener = syncConversationReadStatusListener;
}
public void searchConversations(String str, Conversation.ConversationType[] conversationTypeArr, String[] strArr, IRongCoreCallback.ResultCallback<List<SearchConversationResult>> resultCallback) {
ChannelClient.getInstance().searchConversations(str, conversationTypeArr, "", strArr, resultCallback);
}
public void searchMessages(Conversation.ConversationType conversationType, String str, String str2, int i, long j, IRongCoreCallback.ResultCallback<List<Message>> resultCallback) {
ChannelClient.getInstance().searchMessages(conversationType, str, "", str2, i, j, resultCallback);
}
public void searchMessages(Conversation.ConversationType conversationType, String str, String str2, long j, long j2, int i, int i2, IRongCoreCallback.ResultCallback<List<Message>> resultCallback) {
ChannelClient.getInstance().searchMessages(conversationType, str, "", str2, j, j2, i, i2, resultCallback);
}
public void searchMessagesByUser(Conversation.ConversationType conversationType, String str, String str2, int i, long j, IRongCoreCallback.ResultCallback<List<Message>> resultCallback) {
ChannelClient.getInstance().searchMessagesByUser(conversationType, str, "", str2, i, j, resultCallback);
}
public void getHistoryMessages(Conversation.ConversationType conversationType, String str, long j, int i, int i2, IRongCoreCallback.ResultCallback<List<Message>> resultCallback) {
ChannelClient.getInstance().getHistoryMessages(conversationType, str, "", j, i, i2, resultCallback);
}
public void getVendorToken(IRongCoreCallback.ResultCallback<String> resultCallback) {
final IpcCallbackProxy ipcCallbackProxy = new IpcCallbackProxy(resultCallback);
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.getVendorToken(new IStringCallback.Stub() {
@Override
public void onComplete(String str) throws RemoteException {
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ResultCallback) ipcCallbackProxy.callback).onCallback(str);
ipcCallbackProxy.callback = null;
}
}
@Override
public void onFailure(int i) throws RemoteException {
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ResultCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.valueOf(i));
ipcCallbackProxy.callback = null;
}
}
});
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "getVendorToken", e);
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ResultCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
} else if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ResultCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
ipcCallbackProxy.callback = null;
}
}
});
}
public void setPushLanguage(IRongCoreEnum.PushLanguage pushLanguage, IRongCoreCallback.OperationCallback operationCallback) {
if (pushLanguage == null) {
RLog.d(TAG, "setPushLanguage language is null");
if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
return;
}
return;
}
setPushSetting(PushSettings.PUSH_SETTINGS_LANGUAGE, pushLanguage.getMsg(), operationCallback);
}
public void setPushLanguageCode(String str, IRongCoreCallback.OperationCallback operationCallback) {
if (TextUtils.isEmpty(str)) {
RLog.d(TAG, "setPushLanguage Code language is empty");
if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
return;
}
return;
}
setPushSetting(PushSettings.PUSH_SETTINGS_LANGUAGE, str, operationCallback);
}
public void setPushContentShowStatus(boolean z, IRongCoreCallback.OperationCallback operationCallback) {
setPushSetting(PushSettings.PUSH_SETTINGS_SHOW_CONTENT, (z ? PushStatus.STATUS_ON : PushStatus.STATUS_OFF).getValue(), operationCallback);
PushCacheHelper.getInstance().setPushContentShowStatus(this.mContext, z);
}
public void setPushReceiveStatus(boolean z, IRongCoreCallback.OperationCallback operationCallback) {
setPushSetting(PushSettings.PUSH_SETTINGS_RECEIVE, (z ? PushStatus.STATUS_ON : PushStatus.STATUS_OFF).getValue(), operationCallback);
}
private void setPushSetting(final PushSettings pushSettings, final String str, IRongCoreCallback.OperationCallback operationCallback) {
if (this.mLibHandler == null) {
RLog.d(TAG, "[PushSetting] setPushSetting mLibHandler is null");
if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
return;
}
return;
}
final IpcCallbackProxy ipcCallbackProxy = new IpcCallbackProxy(operationCallback);
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.setPushSetting(pushSettings.getValue(), str, new ISetPushSettingCallback.Stub() {
@Override
public void onComplete() throws RemoteException {
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onCallback();
ipcCallbackProxy.callback = null;
}
}
@Override
public void onFailure(int i) throws RemoteException {
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.valueOf(i));
ipcCallbackProxy.callback = null;
}
}
});
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "setPushSetting", e);
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
} else if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
});
}
public void getPushLanguage(final IRongCoreCallback.ResultCallback<IRongCoreEnum.PushLanguage> resultCallback) {
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
String str = "";
try {
if (RongCoreClient.this.mLibHandler != null) {
str = RongCoreClient.this.mLibHandler.getPushSetting(PushSettings.PUSH_SETTINGS_LANGUAGE.getValue());
} else {
IRongCoreCallback.ResultCallback resultCallback2 = resultCallback;
if (resultCallback2 != null) {
resultCallback2.onError(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
RLog.e(RongCoreClient.TAG, "getIRongCoreEnum.PushLanguage : mLibHandler is null.");
}
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "getIRongCoreEnum.PushLanguage ", e);
IRongCoreCallback.ResultCallback resultCallback3 = resultCallback;
if (resultCallback3 != null) {
resultCallback3.onError(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
}
IRongCoreCallback.ResultCallback resultCallback4 = resultCallback;
if (resultCallback4 != null) {
if (str == null) {
resultCallback4.onFail(IRongCoreEnum.CoreErrorCode.UNKNOWN);
} else if (str.equals(IRongCoreEnum.PushLanguage.EN_US.getMsg())) {
resultCallback.onCallback(IRongCoreEnum.PushLanguage.EN_US);
} else if (str.equals(IRongCoreEnum.PushLanguage.AR_SA.getMsg())) {
resultCallback.onCallback(IRongCoreEnum.PushLanguage.AR_SA);
} else {
resultCallback.onCallback(IRongCoreEnum.PushLanguage.ZH_CN);
}
}
}
});
}
public void getPushContentShowStatus(final IRongCoreCallback.ResultCallback<Boolean> resultCallback) {
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
String str = "";
try {
if (RongCoreClient.this.mLibHandler != null) {
str = RongCoreClient.this.mLibHandler.getPushSetting(PushSettings.PUSH_SETTINGS_SHOW_CONTENT.getValue());
} else {
IRongCoreCallback.ResultCallback resultCallback2 = resultCallback;
if (resultCallback2 != null) {
resultCallback2.onError(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
RLog.e(RongCoreClient.TAG, "getPushContentShowStatus: mLibHandler is null.");
}
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "getPushContentShowStatus", e);
IRongCoreCallback.ResultCallback resultCallback3 = resultCallback;
if (resultCallback3 != null) {
resultCallback3.onError(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
}
IRongCoreCallback.ResultCallback resultCallback4 = resultCallback;
if (resultCallback4 != null) {
if (str == null) {
resultCallback4.onFail(IRongCoreEnum.CoreErrorCode.UNKNOWN);
} else {
resultCallback4.onCallback(Boolean.valueOf(str.equals(PushStatus.STATUS_ON.getValue())));
}
}
}
});
}
public void getPushReceiveStatus(final IRongCoreCallback.ResultCallback<Boolean> resultCallback) {
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
String str;
if (RongCoreClient.this.mLibHandler != null) {
try {
str = RongCoreClient.this.mLibHandler.getPushSetting(PushSettings.PUSH_SETTINGS_RECEIVE.getValue());
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "getPushReceiveStatus", e);
IRongCoreCallback.ResultCallback resultCallback2 = resultCallback;
if (resultCallback2 != null) {
resultCallback2.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
str = "";
}
IRongCoreCallback.ResultCallback resultCallback3 = resultCallback;
if (resultCallback3 != null) {
if (str == null) {
resultCallback3.onFail(IRongCoreEnum.CoreErrorCode.UNKNOWN);
return;
} else {
resultCallback3.onCallback(Boolean.valueOf(str.equals(PushStatus.STATUS_ON.getValue())));
return;
}
}
return;
}
IRongCoreCallback.ResultCallback resultCallback4 = resultCallback;
if (resultCallback4 != null) {
resultCallback4.onFail(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
}
}
});
}
public void getOfflineMessageDuration(final IRongCoreCallback.ResultCallback<String> resultCallback) {
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
String str;
try {
str = RongCoreClient.this.mLibHandler.getOfflineMessageDuration();
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "getOfflineMessageDuration", e);
str = "";
}
if (str == null) {
resultCallback.onFail(IRongCoreEnum.CoreErrorCode.UNKNOWN);
} else {
resultCallback.onCallback(str);
}
}
});
}
public void setOfflineMessageDuration(final int i, IRongCoreCallback.ResultCallback<Long> resultCallback) {
if (i < 1 || i > 7) {
RLog.e(TAG, "Parameter is error!");
if (resultCallback != null) {
resultCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
return;
}
return;
}
final IpcCallbackProxy ipcCallbackProxy = new IpcCallbackProxy(resultCallback);
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.setOfflineMessageDuration(String.valueOf(i), new ILongCallback.Stub() {
@Override
public void onComplete(long j) throws RemoteException {
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ResultCallback) ipcCallbackProxy.callback).onCallback(Long.valueOf(j));
ipcCallbackProxy.callback = null;
}
}
@Override
public void onFailure(int i2) throws RemoteException {
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ResultCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.valueOf(i2));
ipcCallbackProxy.callback = null;
}
}
});
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "setOfflineMessageDuration", e);
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ResultCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
} else if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.ResultCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
});
}
public void setAppVer(String str) {
FwLog.write(3, 1, FwLog.LogTag.A_APP_VER_S.getTag(), "ver", str);
}
public void supportResumeBrokenTransfer(final String str, final IRongCoreCallback.ResultCallback<Boolean> resultCallback) {
if (TextUtils.isEmpty(str) && resultCallback != null) {
resultCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
} else {
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
boolean supportResumeBrokenTransfer = RongCoreClient.this.mLibHandler.supportResumeBrokenTransfer(str);
IRongCoreCallback.ResultCallback resultCallback2 = resultCallback;
if (resultCallback2 != null) {
resultCallback2.onCallback(Boolean.valueOf(supportResumeBrokenTransfer));
return;
}
return;
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "supportResumeBrokenTransfer", e);
IRongCoreCallback.ResultCallback resultCallback3 = resultCallback;
if (resultCallback3 != null) {
resultCallback3.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
return;
}
return;
}
}
IRongCoreCallback.ResultCallback resultCallback4 = resultCallback;
if (resultCallback4 != null) {
resultCallback4.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
}
});
}
}
private void isFileDownloading(final Object obj, final IRongCoreCallback.ResultCallback<Boolean> resultCallback) {
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (resultCallback == null) {
return;
}
if (RongCoreClient.this.mLibHandler != null) {
try {
resultCallback.onCallback(Boolean.valueOf(RongCoreClient.this.mLibHandler.getFileDownloadingStatus(obj.toString())));
return;
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "isFileDownloading", e);
resultCallback.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
return;
}
}
resultCallback.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
});
}
public void getDownloadInfo(final String str, final IRongCoreCallback.ResultCallback<DownloadInfo> resultCallback) {
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (resultCallback == null) {
return;
}
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.getDownloadInfo(str, new IResultCallback.Stub() {
@Override
public void onComplete(RemoteModelWrap remoteModelWrap) throws RemoteException {
if (remoteModelWrap != null && remoteModelWrap.getContent() != null && (remoteModelWrap.getContent() instanceof DownloadInfo)) {
resultCallback.onCallback(remoteModelWrap.getContent());
} else {
resultCallback.onCallback(null);
}
}
@Override
public void onFailure(int i) throws RemoteException {
resultCallback.onCallback(null);
}
});
return;
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "getFileInfo", e);
resultCallback.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
return;
}
}
resultCallback.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
});
}
public void getTheFirstUnreadMessage(Conversation.ConversationType conversationType, String str, IRongCoreCallback.ResultCallback<Message> resultCallback) {
ChannelClient.getInstance().getTheFirstUnreadMessage(conversationType, str, "", resultCallback);
}
public boolean isFileDownloading(Object obj) {
final CountDownLatch countDownLatch = new CountDownLatch(1);
final IRongCoreCallback.ResultCallback.Result result = new IRongCoreCallback.ResultCallback.Result();
result.t = false;
isFileDownloading(obj, new IRongCoreCallback.SyncCallback<Boolean>() {
@Override
public void onSuccess(Boolean bool) {
if (bool != 0) {
result.t = bool;
} else {
RLog.e(RongCoreClient.TAG, "removeConversation removeConversation is failure!");
}
countDownLatch.countDown();
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
countDownLatch.countDown();
}
});
try {
countDownLatch.await();
} catch (InterruptedException e) {
RLog.e(TAG, "isFileDownloading", e);
Thread.currentThread().interrupt();
}
return ((Boolean) result.t).booleanValue();
}
public void setMessageReadTime(final long j, final long j2, final IRongCoreCallback.OperationCallback operationCallback) {
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
boolean messageReadTime = RongCoreClient.this.mLibHandler.setMessageReadTime(j, j2);
IRongCoreCallback.OperationCallback operationCallback2 = operationCallback;
if (operationCallback2 != null) {
if (messageReadTime) {
operationCallback2.onCallback();
} else {
operationCallback2.onError(IRongCoreEnum.CoreErrorCode.UNKNOWN);
}
}
return;
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "setMessageReadTime", e);
IRongCoreCallback.OperationCallback operationCallback3 = operationCallback;
if (operationCallback3 != null) {
operationCallback3.onError(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
return;
}
return;
}
}
IRongCoreCallback.OperationCallback operationCallback4 = operationCallback;
if (operationCallback4 != null) {
operationCallback4.onError(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
}
});
}
public int getVideoLimitTime() {
IHandler iHandler = this.mLibHandler;
if (iHandler != null) {
try {
return iHandler.getVideoLimitTime();
} catch (Exception e) {
RLog.e(TAG, "getVideoLimitTime", e);
return -1;
}
}
return -1;
}
public int getGIFLimitSize() {
IHandler iHandler = this.mLibHandler;
if (iHandler != null) {
try {
return iHandler.getGIFLimitSize();
} catch (Exception e) {
RLog.e(TAG, "getVideoLimitTime", e);
return -1;
}
}
return -1;
}
public void setReconnectKickEnable(boolean z) {
this.kickReconnectDevice = z;
}
private void updatePushContentShowStatus() {
getPushContentShowStatus(new IRongCoreCallback.ResultCallback<Boolean>() {
@Override
public void onSuccess(Boolean bool) {
RongPushClient.updatePushContentShowStatus(RongCoreClient.this.mContext, bool.booleanValue());
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
RLog.e(RongCoreClient.TAG, "Can't get push content show status!");
}
});
}
public void appOnStart() {
if (this.mContext == null) {
RLog.e(TAG, "Event ignored. Please call this api after init.!");
return;
}
RLog.d(TAG, "appOnStart()");
onAppBackgroundChanged(true);
}
public void setRLogLevel(int i) {
RLog.setLogLevel(i);
}
public void setRLogFileMaxSize(long j) {
RLog.setFileMaxSize(j);
}
public void setUploadCallback(RLogReporter.UploadCallback uploadCallback) {
RLog.setUploadCallback(uploadCallback);
}
public void uploadRLog() {
RLog.uploadRLog();
}
public void beginDestructMessage(Message message, IRongCoreListener.DestructCountDownTimerListener destructCountDownTimerListener) {
if (message == null || message.getContent() == null) {
RLog.e(TAG, "beginDestructMessage : message or content can't be null!");
} else if (message.getContent().isDestruct() && message.getMessageDirection() == Message.MessageDirection.RECEIVE) {
DestructionTaskManager.getInstance().BeginDestruct(message, destructCountDownTimerListener);
}
}
public void stopDestructMessage(Message message) {
if (message == null || message.getContent() == null) {
RLog.e(TAG, "stopDestructMessage : message or content can't be null!");
} else if (message.getContent().isDestruct() && message.getMessageDirection() == Message.MessageDirection.RECEIVE) {
DestructionTaskManager.getInstance().messageStopDestruct(message);
}
}
public IRongCoreEnum.CoreErrorCode filterSendMessage(Message message) {
if (message == null) {
RLog.e(TAG, "filterSendMessage : message can't be null!");
return IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR;
} else if (message.getConversationType() == null) {
RLog.e(TAG, "filterSendMessage : conversation type can't be null!");
return IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR;
} else if (message.getConversationType() == Conversation.ConversationType.SYSTEM) {
RLog.e(TAG, "filterSendMessage : conversation type can't be system!");
return IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR;
} else if (TextUtils.isEmpty(message.getTargetId())) {
RLog.e(TAG, "filterSendMessage : targetId can't be null!");
return IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR;
} else if (message.getContent() == null) {
RLog.e(TAG, "filterSendMessage : content can't be null!");
return IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR;
} else if (ExpansionUtils.filterSendMessage(message) != null) {
return ExpansionUtils.filterSendMessage(message);
} else {
return null;
}
}
public void cancelSDKHeartBeat() {
RLog.d(TAG, "cancelSDKHeartBeat " + cancelSDKHeartBeatEnabled);
cancelSDKHeartBeatEnabled = true;
RongPushClient.cancelPushHeartBeat(this.mContext);
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.cancelSDKHeartBeat();
return;
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "cancelSDKHeartBeat", e);
return;
}
}
RLog.e(RongCoreClient.TAG, "mLibHandler is null");
}
});
}
public void sendPing() {
RLog.d(TAG, "sendPing ");
if (isPushEnabled) {
RongPushClient.sendPushPing(this.mContext);
}
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.sendPing();
return;
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "sendPing", e);
return;
}
}
RLog.e(RongCoreClient.TAG, "mLibHandler is null");
}
});
}
public void setConversationStatusListener(IRongCoreListener.ConversationStatusListener conversationStatusListener) {
sConversationStatusListener = conversationStatusListener;
}
public void setConversationTagListener(IRongCoreListener.ConversationTagListener conversationTagListener) {
sConversationTagListener = conversationTagListener;
}
public void setConversationListener(IRongCoreListener.ConversationListener conversationListener2) {
conversationListener = conversationListener2;
}
public void setMessageExpansionListener(IRongCoreListener.MessageExpansionListener messageExpansionListener2) {
messageExpansionListener = messageExpansionListener2;
}
public void updateMessageExpansion(final Map<String, String> map, final String str, IRongCoreCallback.OperationCallback operationCallback) {
if (judgeMapInvalid(map, operationCallback) || judgeUIDInvalid(str, operationCallback)) {
return;
}
if (ExpansionUtils.judgeKVExceedLimit(map)) {
if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.RC_MSG_EXPANSION_SIZE_LIMIT_EXCEED);
}
} else if (!ExpansionUtils.judgeKVIllegality(map)) {
final IpcCallbackProxy ipcCallbackProxy = new IpcCallbackProxy(operationCallback);
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.updateMessageExpansion(map, str, new IRongCoreCallback.DefaultOperationCallback(ipcCallbackProxy));
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "updateMessageExpansion", e);
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
} else if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
});
} else if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
}
}
private boolean judgeMapInvalid(Map<String, String> map, IRongCoreCallback.OperationCallback operationCallback) {
if ((map instanceof HashMap) || operationCallback == null) {
return false;
}
operationCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
RLog.e(TAG, "expansion should be HashMap!");
return true;
}
private boolean judgeUIDInvalid(String str, IRongCoreCallback.OperationCallback operationCallback) {
if (TextUtils.isEmpty(str)) {
RLog.e(TAG, "messageUId is empty!");
if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
return true;
}
return true;
}
return false;
}
public void removeMessageExpansion(final List<String> list, final String str, IRongCoreCallback.OperationCallback operationCallback) {
if (judgeListInvalid(list, operationCallback) || judgeUIDInvalid(str, operationCallback)) {
return;
}
if (list != null && list.size() != 0) {
final IpcCallbackProxy ipcCallbackProxy = new IpcCallbackProxy(operationCallback);
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.removeMessageExpansion(list, str, new IRongCoreCallback.DefaultOperationCallback(ipcCallbackProxy));
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "removeMessageExpansion", e);
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
} else if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
});
} else if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
}
}
private boolean judgeListInvalid(List<String> list, IRongCoreCallback.OperationCallback operationCallback) {
if ((list instanceof ArrayList) || operationCallback == null) {
return false;
}
operationCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
RLog.e(TAG, "keyArray should be ArrayList!");
return true;
}
public Map doMethod(String str, String str2, Map map) throws RemoteException {
IHandler iHandler = this.mLibHandler;
if (iHandler == null) {
throw new RemoteException();
}
return iHandler.doMethod(str, str2, map);
}
public void registerModule(final Map map) {
if (map == null || map.size() <= 0) {
return;
}
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler == null) {
return;
}
try {
RongCoreClient.this.mLibHandler.registerModule(map);
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
RongCoreClient.this.imLibExtensionModuleManager.onServiceConnected(RongCoreClient.this.mContext, RongCoreClient.this.mLibHandler, RongCoreClient.sReceiveMessageListener);
}
});
} catch (Exception unused) {
}
}
});
}
public void batchInsertMessage(List<Message> list, IRongCoreCallback.ResultCallback<Boolean> resultCallback) {
if ((list == null || list.size() == 0 || list.size() > 500) && resultCallback != null) {
resultCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
RLog.e(TAG, "messages should not be null or exceed 500!");
return;
}
batchTransfer(list, resultCallback);
}
private void batchTransfer(final List<Message> list, final IRongCoreCallback.ResultCallback<Boolean> resultCallback) {
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler == null) {
RLog.e(RongCoreClient.TAG, "mLibHandler is null");
resultCallback.onError(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
return;
}
try {
ArrayList arrayList = new ArrayList();
boolean z = false;
for (Message message : list) {
arrayList.add(message);
if (arrayList.size() % 10 == 0) {
z = RongCoreClient.this.mLibHandler.batchInsertMessage(arrayList);
IRongCoreCallback.ResultCallback resultCallback2 = resultCallback;
if (resultCallback2 != null && !z) {
resultCallback2.onCallback(false);
return;
}
arrayList.clear();
}
}
if (arrayList.size() > 0) {
z = RongCoreClient.this.mLibHandler.batchInsertMessage(arrayList);
}
IRongCoreCallback.ResultCallback resultCallback3 = resultCallback;
if (resultCallback3 != null) {
resultCallback3.onCallback(Boolean.valueOf(z));
}
} catch (RemoteException e) {
RLog.e(RongCoreClient.TAG, "batchInsertMessage", e);
}
}
});
}
public void addTag(final TagInfo tagInfo, IRongCoreCallback.OperationCallback operationCallback) {
if (isTagInfoValid(tagInfo)) {
final IpcCallbackProxy ipcCallbackProxy = new IpcCallbackProxy(operationCallback);
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.addTag(tagInfo, new IRongCoreCallback.DefaultOperationCallback(ipcCallbackProxy));
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "addTag", e);
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
} else if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
});
} else if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
}
}
public void removeTag(final String str, IRongCoreCallback.OperationCallback operationCallback) {
if (isTagIdValid(str)) {
final IpcCallbackProxy ipcCallbackProxy = new IpcCallbackProxy(operationCallback);
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.removeTag(str, new IRongCoreCallback.DefaultOperationCallback(ipcCallbackProxy));
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "removeTag", e);
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
} else if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
});
} else if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
}
}
public void updateTag(final TagInfo tagInfo, IRongCoreCallback.OperationCallback operationCallback) {
if (isTagInfoValid(tagInfo)) {
final IpcCallbackProxy ipcCallbackProxy = new IpcCallbackProxy(operationCallback);
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.updateTag(tagInfo, new IRongCoreCallback.DefaultOperationCallback(ipcCallbackProxy));
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "updateTag", e);
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
} else if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
});
} else if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
}
}
public void getTags(final IRongCoreCallback.ResultCallback<List<TagInfo>> resultCallback) {
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
List<TagInfo> tags = RongCoreClient.this.mLibHandler.getTags();
IRongCoreCallback.ResultCallback resultCallback2 = resultCallback;
if (resultCallback2 != null) {
resultCallback2.onCallback(tags);
return;
}
return;
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "getTags", e);
IRongCoreCallback.ResultCallback resultCallback3 = resultCallback;
if (resultCallback3 != null) {
resultCallback3.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
return;
}
return;
}
}
IRongCoreCallback.ResultCallback resultCallback4 = resultCallback;
if (resultCallback4 != null) {
resultCallback4.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
}
});
}
public void addConversationsToTag(final String str, final List<ConversationIdentifier> list, IRongCoreCallback.OperationCallback operationCallback) {
if (!isTagIdValid(str) || list == null) {
if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
}
} else if (!isTagConversationExceed(list)) {
final IpcCallbackProxy ipcCallbackProxy = new IpcCallbackProxy(operationCallback);
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.addConversationsToTag(str, list, new IRongCoreCallback.DefaultOperationCallback(ipcCallbackProxy));
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "addConversationsToTag", e);
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
} else if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
});
} else if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.RC_CONVERSATION_TAG_LIMIT_EXCEED);
}
}
public void removeConversationsFromTag(final String str, final List<ConversationIdentifier> list, IRongCoreCallback.OperationCallback operationCallback) {
if (!isTagIdValid(str) || list == null) {
if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
}
} else if (!isTagConversationExceed(list)) {
final IpcCallbackProxy ipcCallbackProxy = new IpcCallbackProxy(operationCallback);
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.removeConversationsFromTag(str, list, new IRongCoreCallback.DefaultOperationCallback(ipcCallbackProxy));
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "removeConversationsFromTag", e);
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
} else if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
});
} else if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.RC_CONVERSATION_TAG_LIMIT_EXCEED);
}
}
private boolean isTagConversationExceed(List<ConversationIdentifier> list) {
return list != null && list.size() > 1000;
}
public void removeTagsFromConversation(final ConversationIdentifier conversationIdentifier, final List<String> list, IRongCoreCallback.OperationCallback operationCallback) {
if (isConversationIdentifierValid(conversationIdentifier) && list != null && list.size() != 0 && list.size() <= 20) {
final IpcCallbackProxy ipcCallbackProxy = new IpcCallbackProxy(operationCallback);
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.removeTagsFromConversation(conversationIdentifier, list, new IRongCoreCallback.DefaultOperationCallback(ipcCallbackProxy));
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "removeTagsFromConversation", e);
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
} else if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
});
} else if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
}
}
public void getTagsFromConversation(final ConversationIdentifier conversationIdentifier, final IRongCoreCallback.ResultCallback<List<ConversationTagInfo>> resultCallback) {
if (!isConversationIdentifierValid(conversationIdentifier)) {
if (resultCallback != null) {
resultCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
}
} else if (isConversationTypeValid(conversationIdentifier)) {
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
List<ConversationTagInfo> tagsFromConversation = RongCoreClient.this.mLibHandler.getTagsFromConversation(conversationIdentifier);
IRongCoreCallback.ResultCallback resultCallback2 = resultCallback;
if (resultCallback2 != null) {
resultCallback2.onCallback(tagsFromConversation);
return;
}
return;
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "getTagsFromConversation", e);
IRongCoreCallback.ResultCallback resultCallback3 = resultCallback;
if (resultCallback3 != null) {
resultCallback3.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
return;
}
return;
}
}
IRongCoreCallback.ResultCallback resultCallback4 = resultCallback;
if (resultCallback4 != null) {
resultCallback4.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
}
});
} else if (resultCallback != null) {
resultCallback.onError(IRongCoreEnum.CoreErrorCode.RC_CONVERSATION_TAG_INVALID_CONVERSATION_TYPE);
}
}
public void getConversationTopStatusInTag(final ConversationIdentifier conversationIdentifier, final String str, final IRongCoreCallback.ResultCallback<Boolean> resultCallback) {
if (!isConversationIdentifierValid(conversationIdentifier) || !isTagIdValid(str)) {
if (resultCallback != null) {
resultCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
}
} else if (isConversationTypeValid(conversationIdentifier)) {
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
boolean conversationTopStatusInTag = RongCoreClient.this.mLibHandler.getConversationTopStatusInTag(conversationIdentifier, str);
IRongCoreCallback.ResultCallback resultCallback2 = resultCallback;
if (resultCallback2 != null) {
resultCallback2.onCallback(Boolean.valueOf(conversationTopStatusInTag));
return;
}
return;
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "getTagForConversation", e);
IRongCoreCallback.ResultCallback resultCallback3 = resultCallback;
if (resultCallback3 != null) {
resultCallback3.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
return;
}
return;
}
}
IRongCoreCallback.ResultCallback resultCallback4 = resultCallback;
if (resultCallback4 != null) {
resultCallback4.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
}
});
} else if (resultCallback != null) {
resultCallback.onError(IRongCoreEnum.CoreErrorCode.RC_CONVERSATION_TAG_INVALID_CONVERSATION_TYPE);
}
}
public void getConversationsFromTagByPage(final String str, final long j, int i, final IRongCoreCallback.ResultCallback<List<Conversation>> resultCallback) {
if (!isTagIdValid(str)) {
if (resultCallback != null) {
resultCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
return;
}
return;
}
if (i < 20) {
i = 20;
}
final int i2 = i > 100 ? 100 : i;
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
List<Conversation> conversationsFromTagByPage = RongCoreClient.this.mLibHandler.getConversationsFromTagByPage(str, j, i2);
IRongCoreCallback.ResultCallback resultCallback2 = resultCallback;
if (resultCallback2 != null) {
resultCallback2.onCallback(conversationsFromTagByPage);
return;
}
return;
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "getConversationsFromTagByPage", e);
IRongCoreCallback.ResultCallback resultCallback3 = resultCallback;
if (resultCallback3 != null) {
resultCallback3.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
return;
}
return;
}
}
IRongCoreCallback.ResultCallback resultCallback4 = resultCallback;
if (resultCallback4 != null) {
resultCallback4.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
}
});
}
public void getUnreadCountByTag(final String str, final boolean z, final IRongCoreCallback.ResultCallback<Integer> resultCallback) {
if (isTagIdValid(str)) {
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
int unreadCountByTag = RongCoreClient.this.mLibHandler.getUnreadCountByTag(str, z);
IRongCoreCallback.ResultCallback resultCallback2 = resultCallback;
if (resultCallback2 != null) {
resultCallback2.onCallback(Integer.valueOf(unreadCountByTag));
return;
}
return;
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "getUnreadCountByTag", e);
IRongCoreCallback.ResultCallback resultCallback3 = resultCallback;
if (resultCallback3 != null) {
resultCallback3.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
return;
}
return;
}
}
IRongCoreCallback.ResultCallback resultCallback4 = resultCallback;
if (resultCallback4 != null) {
resultCallback4.onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
}
}
});
} else if (resultCallback != null) {
resultCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
}
}
public void setConversationToTopInTag(final String str, final ConversationIdentifier conversationIdentifier, final boolean z, IRongCoreCallback.OperationCallback operationCallback) {
if (!isTagIdValid(str)) {
if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
}
} else if (!isConversationIdentifierValid(conversationIdentifier)) {
if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.PARAMETER_ERROR);
}
} else if (isConversationTypeValid(conversationIdentifier)) {
final IpcCallbackProxy ipcCallbackProxy = new IpcCallbackProxy(operationCallback);
this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
if (RongCoreClient.this.mLibHandler != null) {
try {
RongCoreClient.this.mLibHandler.setConversationToTopInTag(str, conversationIdentifier, z, new IRongCoreCallback.DefaultOperationCallback(ipcCallbackProxy));
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "setConversationToTopInTag", e);
if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
} else if (ipcCallbackProxy.callback != 0) {
((IRongCoreCallback.OperationCallback) ipcCallbackProxy.callback).onFail(IRongCoreEnum.CoreErrorCode.IPC_DISCONNECT);
ipcCallbackProxy.callback = null;
}
}
});
} else if (operationCallback != null) {
operationCallback.onError(IRongCoreEnum.CoreErrorCode.RC_CONVERSATION_TAG_INVALID_CONVERSATION_TYPE);
}
}
public void getMessages(Conversation.ConversationType conversationType, String str, HistoryMessageOption historyMessageOption, IRongCoreCallback.IGetMessageCallback iGetMessageCallback) {
ChannelClient.getInstance().getMessages(conversationType, str, "", historyMessageOption, iGetMessageCallback);
}
private boolean isConversationTypeValid(ConversationIdentifier conversationIdentifier) {
return conversationIdentifier != null && (Conversation.ConversationType.PRIVATE.equals(conversationIdentifier.getType()) || Conversation.ConversationType.GROUP.equals(conversationIdentifier.getType()) || Conversation.ConversationType.SYSTEM.equals(conversationIdentifier.getType()));
}
private boolean isConversationIdentifierValid(ConversationIdentifier conversationIdentifier) {
return (conversationIdentifier == null || TextUtils.isEmpty(conversationIdentifier.getTargetId()) || conversationIdentifier.getType() == null) ? false : true;
}
public void setPushNotificationListener(IRongCoreListener.PushNotificationListener pushNotificationListener) {
mPushNotificationListener = pushNotificationListener;
}
public void setTagListener(IRongCoreListener.TagListener tagListener) {
this.mTagListener = tagListener;
}
private boolean isTagInfoValid(TagInfo tagInfo) {
return !TextUtils.isEmpty(tagInfo.getTagId()) && tagInfo.getTagId().length() <= 10 && !TextUtils.isEmpty(tagInfo.getTagName()) && tagInfo.getTagName().length() <= 15;
}
private boolean isTagIdValid(String str) {
return !TextUtils.isEmpty(str) && str.length() <= 10;
}
public enum PushSettings {
PUSH_SETTINGS_LANGUAGE(1),
PUSH_SETTINGS_SHOW_CONTENT(2),
PUSH_SETTINGS_RECEIVE(3);
private int value;
PushSettings(int i) {
this.value = i;
}
public int getValue() {
return this.value;
}
}
public enum PushStatus {
STATUS_ON("1"),
STATUS_OFF(AndroidConfig.OPERATE);
private String value;
PushStatus(String str) {
this.value = str;
}
public String getValue() {
return this.value;
}
}
public static class SingletonHolder {
static RongCoreClient sInstance = new RongCoreClient();
private SingletonHolder() {
}
}
public class ConnectRunnable implements Runnable {
String token;
ConnectRunnable(String str) {
RLog.d(RongCoreClient.TAG, "[connect] ConnectRunnable for connect");
this.token = str;
}
@Override
public void run() {
RLog.d(RongCoreClient.TAG, "[connect] ConnectRunnable do connect!");
RongCoreClient.this.connectServer(this.token, false);
}
}
public class AidlConnection implements ServiceConnection {
private AidlConnection() {
}
@Override
public void onServiceConnected(ComponentName componentName, final IBinder iBinder) {
RongCoreClient.this.mWorkHandler.post(new Runnable() {
@Override
public void run() {
FwLog.write(3, 1, FwLog.LogTag.BIND_SERVICE_S.getTag(), "bent", true);
RongCoreClient.this.mLibHandler = IHandler.Stub.asInterface(iBinder);
try {
RongCoreClient.this.mLibHandler.initAppendixModule();
} catch (Exception e) {
RLog.e(RongCoreClient.TAG, "onServiceConnected initAppendix error", e);
}
if (TextUtils.isEmpty(RongCoreClient.this.mToken) && AidlConnection.this.canConnectStatus()) {
RongCoreClient.this.mConnectionStatus = IRongCoreListener.ConnectionStatusListener.ConnectionStatus.UNCONNECTED;
RLog.i(RongCoreClient.TAG, "onServiceConnected token is null;status:" + RongCoreClient.this.mConnectionStatus);
}
try {
RLog.i(RongCoreClient.TAG, "initIPCEnviroment token:" + RongCoreClient.this.mToken + " status:" + RongCoreClient.this.mConnectionStatus);
RongCoreClient.this.mLibHandler.initIPCEnviroment(RongCoreClient.this.mToken, RongCoreClient.this.mConnectionStatus.getValue());
} catch (Exception e2) {
RLog.e(RongCoreClient.TAG, "onServiceConnected initIPCEnviroment error", e2);
}
RongCoreClient.this.setIPCLogListener();
RongCoreClient.this.initReceiver();
ModuleManager.init(RongCoreClient.this.mContext, RongCoreClient.this.mLibHandler, RongCoreClient.sReceiveMessageListener);
RongCoreClient.this.registerModule(RongCoreClient.this.imLibExtensionModuleManager.getExtensionIPCModules());
IMLibRTCClient.getInstance().OnServiceConnected(RongCoreClient.this.mLibHandler);
ChannelClient.getInstance().onServiceConnected(RongCoreClient.this.mLibHandler);
RLog.d(RongCoreClient.TAG, "onServiceConnected mConnectionStatus = " + RongCoreClient.this.mConnectionStatus);
if (RongCoreClient.this.mConnectRunnable != null) {
RongCoreClient.mHandler.post(RongCoreClient.this.mConnectRunnable);
} else if (RongCoreClient.this.mToken != null) {
RongCoreClient.this.connectServer(RongCoreClient.this.mToken, true);
}
}
});
}
@Override
public void onServiceDisconnected(ComponentName componentName) {
FwLog.write(RongCoreClient.isInForeground ? 2 : 3, 1, FwLog.LogTag.BIND_SERVICE_S.getTag(), "bent", false);
ModuleManager.unInit();
RongCoreClient.this.mLibHandler = null;
IMLibRTCClient.getInstance().OnServiceDisconnected();
ChannelClient.getInstance().onServiceDisconnected();
RLog.d(RongCoreClient.TAG, "onServiceDisconnected " + RongCoreClient.this.mConnectionStatus);
if (canConnectStatus()) {
RongCoreClient.this.mStatusListener.onConnectionStatusChange(IRongCoreListener.ConnectionStatusListener.ConnectionStatus.SUSPEND);
}
RongCoreClient.this.initBindService();
}
public boolean canConnectStatus() {
return (RongCoreClient.this.mConnectionStatus.equals(IRongCoreListener.ConnectionStatusListener.ConnectionStatus.SIGN_OUT) || RongCoreClient.this.mConnectionStatus.equals(IRongCoreListener.ConnectionStatusListener.ConnectionStatus.UNCONNECTED) || RongCoreClient.this.mConnectionStatus.equals(IRongCoreListener.ConnectionStatusListener.ConnectionStatus.KICKED_OFFLINE_BY_OTHER_CLIENT) || RongCoreClient.this.mConnectionStatus.equals(IRongCoreListener.ConnectionStatusListener.ConnectionStatus.CONN_USER_BLOCKED) || RongCoreClient.this.mConnectionStatus.equals(IRongCoreListener.ConnectionStatusListener.ConnectionStatus.TOKEN_INCORRECT) || RongCoreClient.this.mConnectionStatus.equals(IRongCoreListener.ConnectionStatusListener.ConnectionStatus.TIMEOUT)) ? false : true;
}
}
public class StatusListener extends IConnectionStatusListener.Stub {
private StatusListener() {
}
@Override
public boolean onTransact(int i, Parcel parcel, Parcel parcel2, int i2) throws RemoteException {
try {
return super.onTransact(i, parcel, parcel2, i2);
} catch (RuntimeException e) {
RLog.e(RongCoreClient.TAG, "StatusListener Unexpected remote exception", e);
throw e;
}
}
@Override
public void onChanged(int i) throws RemoteException {
IRongCoreListener.ConnectionStatusListener.ConnectionStatus valueOf = IRongCoreListener.ConnectionStatusListener.ConnectionStatus.valueOf(i);
RLog.d(RongCoreClient.TAG, "[connect] onChanged cur = " + RongCoreClient.this.mConnectionStatus + ", to = " + valueOf);
onConnectionStatusChange(valueOf);
}
synchronized void onConnectionStatusChange(final IRongCoreListener.ConnectionStatusListener.ConnectionStatus connectionStatus) {
RongCoreClient.this.mConnectionStatus = connectionStatus;
if (connectionStatus.equals(IRongCoreListener.ConnectionStatusListener.ConnectionStatus.CONNECTED)) {
MessageBufferPool.getInstance().retrySendMessages();
}
ModuleManager.connectivityChanged(connectionStatus);
RongCoreClient.this.imLibExtensionModuleManager.onConnectStatusChanged(connectionStatus);
RongCoreClient.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (RongCoreClient.sConnectionListener != null) {
RongCoreClient.sConnectionListener.onChanged(connectionStatus);
}
}
});
}
}
}