正在查看: bbinstant v6.24.0 应用的 KapchatHelper.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: bbinstant v6.24.0 应用的 KapchatHelper.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.adjetter.kapchatsdk;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.text.Spannable;
import android.text.format.DateFormat;
import android.text.style.URLSpan;
import android.util.Base64;
import com.adjetter.kapchatsdk.activity.KapChatWebView;
import com.adjetter.kapchatsdk.activity.KapchatRegistrationActivity;
import com.adjetter.kapchatsdk.activity.KapchatScreenActivity;
import com.adjetter.kapchatsdk.database.KapchatDatabaseInstance;
import com.adjetter.kapchatsdk.encryption.EncUtil;
import com.adjetter.kapchatsdk.interfaces.CallBackResponse;
import com.adjetter.kapchatsdk.structure.KapchatTemplateMessage;
import com.amazon.identity.auth.device.authorization.AuthorizationResponseParser;
import com.amazonaws.services.s3.Headers;
import com.amazonaws.services.s3.internal.crypto.JceEncryptionConstants;
import com.bigbasket.bbinstant.core.payments.activity.ZetaSodexoActivity;
import com.google.gson.Gson;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.security.AlgorithmParameters;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Random;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import org.jivesoftware.smack.tcp.XMPPTCPConnection;
import org.jivesoftware.smackx.time.EntityTimeManager;
import org.jivesoftware.smackx.time.packet.Time;
import org.json.JSONObject;
public class KapchatHelper {
public static String Host = "chat.kapdesk.com";
public static final String KAPCHAT_VERSION_CODE = "2.0.7";
public static final String NOTIFICATION_CHANNEL_ID = "0101";
public static final String QUESTION_ANSWER_JSON = "QUESTION_ANSWER_JSON";
public static final String SUPPORT_TYPE = "SUPPORT";
public static final String TRIGGER_TYPE = "TRIGGER";
public static CallBackResponse callResponse = null;
public static final boolean isChatInitializationWithPhoneNo = false;
public static final boolean isCustomerCodeEncoded = true;
public static final boolean isEndChatEnabled = false;
public static Calendar mCalendar = null;
public static String mServiceName = "@xmpp.adjetter.com";
public static String serviceName = "xmpp.adjetter.com";
public static Context stopContext = null;
public static String supportMessageMapping = "{\"key\":\"mXoPQltfyvuB7EhEtNgjqo0MpjU3aq92WWMIBy2y\"";
public static String supportmessagekey = "mXoPQltfyvuB7EhEtNgjqo0MpjU3aq92WWMIBy2y";
public static String supporttype = "SUPPORT";
public static int unreadcount = 0;
public static String url = "https://www.adjetter.com";
private class KapchatLogin extends AsyncTask<Void, Void, String> {
Context context;
String customerCode;
private String customerSecretKey;
private byte[] key;
private SecretKeySpec secretKey;
private String supportKey;
public KapchatLogin(Context context, String str, String str2, String str3) {
this.supportKey = "";
this.customerSecretKey = "";
this.context = context;
PrintStream printStream = System.out;
printStream.println("####### value Cust code is : " + str);
printStream.println("####### value enc key is : " + str3);
printStream.println("####### value support key is : " + str2);
this.customerCode = str;
this.supportKey = str2;
this.customerSecretKey = str3;
}
private String decrypt(String str, String str2) {
try {
setKey(str2);
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING");
cipher.init(2, this.secretKey);
return new String(cipher.doFinal(Base64.decode(str, 0)));
} catch (Exception e) {
e.toString();
return null;
}
}
private String encrypt(String str, String str2) {
try {
setKey(str2);
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(1, this.secretKey);
return Base64.encodeToString(cipher.doFinal(str.getBytes("UTF-8")), 0);
} catch (Exception e) {
e.toString();
return null;
}
}
private String encryptWithAESCBC(String str, String str2, String str3) {
try {
if (str2.length() > 16) {
str2 = str2.substring(0, 16);
}
byte[] bytes = str2.getBytes();
byte[] bytes2 = str.getBytes();
byte[] bytes3 = str3.getBytes("UTF-8");
SecretKeySpec secretKeySpec = new SecretKeySpec(bytes, JceEncryptionConstants.SYMMETRIC_KEY_ALGORITHM);
Cipher cipher = Cipher.getInstance(JceEncryptionConstants.SYMMETRIC_CIPHER_METHOD);
AlgorithmParameters algorithmParameters = AlgorithmParameters.getInstance(JceEncryptionConstants.SYMMETRIC_KEY_ALGORITHM);
algorithmParameters.init(new IvParameterSpec(bytes2));
cipher.init(1, secretKeySpec, algorithmParameters);
return Base64.encodeToString(cipher.doFinal(bytes3), 0);
} catch (Exception unused) {
return null;
}
}
private String makeRequest(String str) throws Exception {
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setRequestProperty(Headers.CONTENT_LANGUAGE, "en-US");
httpURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
httpURLConnection.setDoInput(true);
httpURLConnection.setDoOutput(true);
httpURLConnection.connect();
JSONObject jSONObject = new JSONObject(readInputStreamToString(httpURLConnection));
KapchatLoginResponse kapchatLoginResponse = (KapchatLoginResponse) new Gson().fromJson(decryptUsingAESCBC(Uri.parse(str).getQueryParameter("iv_code"), this.customerSecretKey, jSONObject.get("response").toString()), KapchatLoginResponse.class);
if (kapchatLoginResponse == null || jSONObject.get("status") == null || !jSONObject.get("status").toString().equalsIgnoreCase(ZetaSodexoActivity.ZETA_SDXO_TPIN_SUCCESS_TXT)) {
if (kapchatLoginResponse == null || kapchatLoginResponse.getStatus() == null || !kapchatLoginResponse.getStatus().equalsIgnoreCase(AuthorizationResponseParser.ERROR)) {
KapchatHelper.logoutKapchat(this.context);
return "KS203";
}
KapchatHelper.logoutKapchat(this.context);
return kapchatLoginResponse.getErrorCode();
}
Bundle bundle = new Bundle();
SharedPreferences.Editor edit = this.context.getSharedPreferences("kapchatpreference", 0).edit();
String obj = jSONObject.get("response").toString();
EncUtil.generateKey(this.context);
edit.putString("initLoginResponse", EncUtil.encrypt(this.context, obj));
edit.putString("userName", "");
edit.putString("password", "");
edit.putString("resourcePrefix", "" + kapchatLoginResponse.getResourcePrefix());
edit.putString("leadId", "" + kapchatLoginResponse.getLeadId());
edit.putString("guestsession", "false");
edit.apply();
XMPPTCPConnection xMPPTCPConnection = KapchatConnection.mConnection;
if (xMPPTCPConnection != null && xMPPTCPConnection.isConnected()) {
KapchatConnection.mConnection.disconnect();
}
bundle.putString("userName", "" + kapchatLoginResponse.getChatUserName());
bundle.putString("password", "" + kapchatLoginResponse.getChatPassword());
bundle.putString("contactName", "" + kapchatLoginResponse.getCustomerName());
bundle.putString("supportId", "" + kapchatLoginResponse.getSupportId());
bundle.putString("bucketName", "" + kapchatLoginResponse.getBucketName());
bundle.putString("uploadSecretKey", "" + kapchatLoginResponse.getUploadSecretKey());
bundle.putString("uploadAccessKey", "" + kapchatLoginResponse.getUploadAccessKey());
KapchatConnection.mConnection = null;
Intent intent = new Intent(this.context, (Class<?>) KapchatService.class);
intent.putExtras(bundle);
if (Build.VERSION.SDK_INT >= 26) {
this.context.startService(intent);
} else {
this.context.startService(intent);
}
httpURLConnection.disconnect();
return ZetaSodexoActivity.ZETA_SDXO_TPIN_SUCCESS_TXT;
}
private String randomHexString(int i) {
Random random = new Random();
StringBuilder sb = new StringBuilder();
while (sb.length() < i) {
sb.append(Integer.toHexString(random.nextInt()));
}
return sb.toString().substring(0, i);
}
private java.lang.String readInputStreamToString(java.net.HttpURLConnection r5) {
throw new UnsupportedOperationException("Method not decompiled: com.adjetter.kapchatsdk.KapchatHelper.KapchatLogin.readInputStreamToString(java.net.HttpURLConnection):java.lang.String");
}
private void setKey(String str) {
try {
this.key = str.getBytes("UTF-8");
byte[] digest = MessageDigest.getInstance("SHA-1").digest(this.key);
this.key = digest;
this.key = Arrays.copyOf(digest, 16);
this.secretKey = new SecretKeySpec(this.key, JceEncryptionConstants.SYMMETRIC_KEY_ALGORITHM);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e2) {
e2.printStackTrace();
}
}
public String customerCodeDecoder(String str) {
String str2;
try {
str2 = new String(Base64.decode(str, 0), "UTF-8");
} catch (Exception e) {
e.printStackTrace();
str2 = "";
}
StringBuilder sb = new StringBuilder();
sb.append("after decoding customercode ");
sb.append(str2);
return str2;
}
public String customerCodeEncoder(String str) {
String str2;
try {
str2 = new String(Base64.encode(str.getBytes(), 0), "UTF-8");
} catch (Exception e) {
e.printStackTrace();
str2 = "";
}
StringBuilder sb = new StringBuilder();
sb.append("after decoding customercode ");
sb.append(str2);
return str2;
}
public String decryptUsingAESCBC(String str, String str2, String str3) {
try {
if (str2.length() > 16) {
str2 = str2.substring(0, 16);
}
if (str.length() > 16) {
str = str.substring(0, 16);
}
byte[] bytes = str2.getBytes();
byte[] bytes2 = str.getBytes();
SecretKeySpec secretKeySpec = new SecretKeySpec(bytes, JceEncryptionConstants.SYMMETRIC_KEY_ALGORITHM);
Cipher cipher = Cipher.getInstance(JceEncryptionConstants.SYMMETRIC_CIPHER_METHOD);
AlgorithmParameters algorithmParameters = AlgorithmParameters.getInstance(JceEncryptionConstants.SYMMETRIC_KEY_ALGORITHM);
algorithmParameters.init(new IvParameterSpec(bytes2));
cipher.init(2, secretKeySpec, algorithmParameters);
return new String(cipher.doFinal(Base64.decode(str3, 0)), "UTF-8");
} catch (UnsupportedEncodingException e) {
e = e;
e.toString();
return null;
} catch (InvalidKeyException e2) {
e = e2;
e.toString();
return null;
} catch (NoSuchAlgorithmException e3) {
e = e3;
e.toString();
return null;
} catch (BadPaddingException e4) {
e = e4;
e.toString();
return null;
} catch (IllegalBlockSizeException e5) {
e = e5;
e.toString();
return null;
} catch (NoSuchPaddingException e6) {
e = e6;
e.toString();
return null;
} catch (Exception e7) {
e7.toString();
return null;
}
}
@Override
public String doInBackground(Void... voidArr) {
PackageInfo packageInfo;
try {
String randomHexString = randomHexString(16);
String encryptWithAESCBC = encryptWithAESCBC(randomHexString, this.customerSecretKey, this.customerCode);
PrintStream printStream = System.out;
printStream.println("####### value iv is : " + randomHexString);
printStream.println("####### value encrypted is : " + encryptWithAESCBC);
printStream.println("####### value CC decrypt is : " + decryptUsingAESCBC(randomHexString, this.customerSecretKey, this.customerCode));
StringBuilder sb = new StringBuilder();
sb.append("encoded cc ");
sb.append(encryptWithAESCBC);
try {
packageInfo = this.context.getPackageManager().getPackageInfo(this.context.getPackageName(), 0);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
packageInfo = null;
}
String str = KapchatHelper.url + "/home/init-ticket-for-registered-user?key=" + URLEncoder.encode(this.supportKey) + "&customer_code=" + URLEncoder.encode(encryptWithAESCBC) + "&iv_code=" + randomHexString + "&is_check_recent_ticket=true&app_version=" + packageInfo.versionName + "&api_version=2.0";
SharedPreferences.Editor edit = this.context.getSharedPreferences("kapchatnewRef", 0).edit();
edit.putString("ccEncoded", encryptWithAESCBC);
edit.putString("iv", randomHexString);
edit.apply();
StringBuilder sb2 = new StringBuilder();
sb2.append("test sk ");
sb2.append(this.supportKey);
StringBuilder sb3 = new StringBuilder();
sb3.append("test cc ");
sb3.append(encryptWithAESCBC);
StringBuilder sb4 = new StringBuilder();
sb4.append("test iv ");
sb4.append(randomHexString);
String makeRequest = makeRequest(str);
return !makeRequest.equalsIgnoreCase(ZetaSodexoActivity.ZETA_SDXO_TPIN_SUCCESS_TXT) ? makeRequest : ZetaSodexoActivity.ZETA_SDXO_TPIN_SUCCESS_TXT;
} catch (Exception e2) {
e2.printStackTrace();
return "KS0202";
}
}
@Override
public void onPostExecute(String str) {
super.onPostExecute((KapchatLogin) str);
KapchatHelper.callResponse.intialiseResponse(str);
}
}
public static boolean foregrounded() {
ActivityManager.RunningAppProcessInfo runningAppProcessInfo = new ActivityManager.RunningAppProcessInfo();
ActivityManager.getMyMemoryState(runningAppProcessInfo);
int i = runningAppProcessInfo.importance;
return i == 100 || i == 200;
}
public static long getCurrentTimeInMillis() {
if (mCalendar != null) {
mCalendar = Calendar.getInstance();
}
return mCalendar.getTimeInMillis();
}
public static String getFormattedDate(Context context, long j2) {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(j2);
Calendar calendar2 = Calendar.getInstance();
return (calendar2.get(5) == calendar.get(5) && calendar2.get(2) == calendar.get(2) && calendar2.get(1) == calendar.get(1)) ? "Today" : (calendar2.get(5) - calendar.get(5) == 1 && calendar2.get(2) == calendar.get(2) && calendar2.get(1) == calendar.get(1)) ? "Yesterday" : calendar2.get(1) == calendar.get(1) ? DateFormat.format("MMMM d", calendar).toString() : DateFormat.format("MMMM dd yyyy", calendar).toString();
}
public static String getFormattedTime(Context context, long j2) {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(j2);
Calendar.getInstance();
return "" + ((Object) DateFormat.format("h:mm aa", calendar));
}
public static long getServerTime(Context context) {
XMPPTCPConnection xMPPTCPConnection = KapchatConnection.mConnection;
if (xMPPTCPConnection != null && xMPPTCPConnection.isConnected()) {
try {
Time time = EntityTimeManager.getInstanceFor(KapchatConnection.mConnection).getTime(KapchatConnection.mConnection.getXMPPServiceDomain());
if (time != null) {
return time.getTime().getTime();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return new Date().getTime();
}
public static int getUnreadCount(Context context) {
int i = context.getSharedPreferences("kapchatnewRef", 0).getInt("unreadCount", 0);
unreadcount = i;
return i;
}
public static void initialise(Context context, String str, String str2, String str3, CallBackResponse callBackResponse) {
boolean z;
callResponse = callBackResponse;
stopContext = context;
KapchatDatabaseInstance.getDbInstance(context);
if (str == null || str.equalsIgnoreCase("")) {
callResponse.intialiseResponse("KS0201");
return;
}
if (!context.getSharedPreferences("kapchatpreference", 0).getString("supportId", "").equalsIgnoreCase("") && context.getSharedPreferences("kapchatpreference", 0).getString("customerCode", "").equalsIgnoreCase(str)) {
PrintStream printStream = System.out;
printStream.println("#### value in this context 1 is : " + context.getSharedPreferences("kapchatpreference", 0).getString("customerCode", ""));
printStream.println("#### value in this context 2 is : " + str);
SharedPreferences.Editor edit = context.getSharedPreferences("kapchatpreference", 0).edit();
if (context.getSharedPreferences("kapchatpreference", 0).getString("lastcustomerCode", "").equalsIgnoreCase(str)) {
z = false;
} else {
edit.putString("lastLogout", "");
edit.putString("kapchatNotificationList", "");
edit.putString("kapchatresource", "");
edit.putString("firstIndex", "");
z = true;
}
edit.putString("lastcustomerCode", str);
edit.putString("customerCode", str);
edit.putString("supportKey", str2);
edit.putString("kapchatNotificationList", "");
edit.putString("encryptionKey", "" + str3);
edit.apply();
if (z) {
return;
}
if (context.getSharedPreferences("kapchatpreference", 0).getString("guestsession", "").equalsIgnoreCase("true")) {
logoutKapchat(context);
}
new KapchatHelper().new KapchatLogin(context, str, str2, str3).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[0]);
return;
}
PrintStream printStream2 = System.out;
printStream2.println("#### value in this context 1 is : " + context.getSharedPreferences("kapchatpreference", 0).getString("customerCode", ""));
printStream2.println("#### value in this context 2 is : " + str);
Boolean bool = Boolean.FALSE;
SharedPreferences.Editor edit2 = context.getSharedPreferences("kapchatpreference", 0).edit();
if (!context.getSharedPreferences("kapchatpreference", 0).getString("lastcustomerCode", "").equalsIgnoreCase(str)) {
bool = Boolean.TRUE;
edit2.putString("lastLogout", "");
edit2.putString("kapchatNotificationList", "");
edit2.putString("kapchatresource", "");
edit2.putString("firstIndex", "");
}
edit2.putString("lastcustomerCode", str);
edit2.putString("customerCode", str);
edit2.putString("supportKey", str2);
edit2.putString("kapchatNotificationList", "");
edit2.putString("encryptionKey", "" + str3);
edit2.apply();
if (bool.booleanValue()) {
return;
}
if (context.getSharedPreferences("kapchatpreference", 0).getString("guestsession", "").equalsIgnoreCase("true")) {
logoutKapchat(context);
}
new KapchatHelper().new KapchatLogin(context, str, str2, str3).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[0]);
}
public static boolean isOnline(Context context) {
NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.isConnectedOrConnecting();
}
public static Boolean logoutKapchat(Context context) {
try {
if (!context.getSharedPreferences("kapchatpreference", 0).getString("customerCode", "").equalsIgnoreCase("")) {
SharedPreferences.Editor edit = context.getSharedPreferences("kapchatpreference", 0).edit();
edit.putString("customerCode", "");
edit.putString("supportKey", "");
edit.putString("kapchatNotificationList", "");
edit.putString("encryptionKey", "");
edit.putString("userName", "");
edit.putString("password", "");
edit.putString("contactName", "");
edit.putString("supportId", "");
edit.putString("leadId", "");
edit.putString("guestsession", "");
edit.apply();
XMPPTCPConnection xMPPTCPConnection = KapchatConnection.mConnection;
if (xMPPTCPConnection != null && xMPPTCPConnection.isConnected()) {
KapchatConnection.mConnection.disconnect();
}
stopKapService(context);
} else {
if (!context.getSharedPreferences("kapchatpreference", 0).getString("guestsession", "").equalsIgnoreCase("true")) {
return Boolean.FALSE;
}
SharedPreferences.Editor edit2 = context.getSharedPreferences("kapchatpreference", 0).edit();
edit2.putString("customerCode", "");
edit2.putString("supportKey", "");
edit2.putString("kapchatNotificationList", "");
edit2.putString("encryptionKey", "");
edit2.putString("userName", "");
edit2.putString("password", "");
edit2.putString("contactName", "");
edit2.putString("supportId", "");
edit2.putString("leadId", "");
edit2.putString("guestsession", "");
edit2.putString("taskId", "");
edit2.putString("ticketId", "");
edit2.apply();
XMPPTCPConnection xMPPTCPConnection2 = KapchatConnection.mConnection;
if (xMPPTCPConnection2 != null && xMPPTCPConnection2.isConnected()) {
KapchatConnection.mConnection.disconnect();
}
stopKapService(context);
}
SharedPreferences.Editor edit3 = context.getSharedPreferences("kapchatnewRef", 0).edit();
edit3.putString("ccEncoded", "");
edit3.putString("iv", "");
edit3.putString("returnExchangeJson", "");
edit3.putString("order_id_web", "");
edit3.putString("initLoginResponse", "");
edit3.putString("ticket_id_web", "");
edit3.putInt("unreadCount", 0);
edit3.apply();
} catch (Exception e) {
e.printStackTrace();
}
return Boolean.TRUE;
}
public static void removeUnderlines(Spannable spannable) {
for (URLSpan uRLSpan : (URLSpan[]) spannable.getSpans(0, spannable.length(), URLSpan.class)) {
int spanStart = spannable.getSpanStart(uRLSpan);
int spanEnd = spannable.getSpanEnd(uRLSpan);
spannable.removeSpan(uRLSpan);
spannable.setSpan(new URLSpanNoUnderline(uRLSpan.getURL()), spanStart, spanEnd, 0);
}
}
public static void startChatScreen(Activity activity, int i) {
unreadcount = 0;
SharedPreferences.Editor edit = activity.getSharedPreferences("kapchatnewRef", 0).edit();
edit.putInt("unreadCount", unreadcount);
edit.apply();
new Util(activity).startTest(i);
}
public static void startChatScreenWithTemplate(Context context, KapchatTemplateMessage kapchatTemplateMessage) {
if (kapchatTemplateMessage == null || kapchatTemplateMessage.getMessage().equalsIgnoreCase("")) {
context.startActivity(new Intent(context, (Class<?>) KapchatScreenActivity.class));
return;
}
Bundle bundle = new Bundle();
bundle.putString("templateMessage", kapchatTemplateMessage.getMessage());
Intent intent = new Intent(context, (Class<?>) KapchatScreenActivity.class);
intent.putExtras(bundle);
context.startActivity(intent);
}
public static void startRegistrationActivity(Context context, String str) {
if (context.getSharedPreferences("kapchatpreference", 0).getString("guestsession", "").equalsIgnoreCase("true")) {
Intent intent = new Intent(context, (Class<?>) KapchatService.class);
if (Build.VERSION.SDK_INT >= 26) {
context.startService(intent);
} else {
context.startService(intent);
}
startChatScreen(context);
return;
}
Bundle bundle = new Bundle();
bundle.putString("supportKey", str);
Intent intent2 = new Intent(context, (Class<?>) KapchatRegistrationActivity.class);
intent2.putExtras(bundle);
context.startActivity(intent2);
}
public static void startWebViewChatScreen(Activity activity, boolean z) {
Intent intent = new Intent(activity, (Class<?>) KapChatWebView.class);
intent.addFlags(131072);
intent.putExtra("flag", z);
activity.startActivity(intent);
}
public static void startWebViewChatScreenWithResult(Activity activity, String str, int i, boolean z) {
Intent intent = new Intent(activity, (Class<?>) KapChatWebView.class);
intent.addFlags(131072);
intent.putExtra("message", str);
intent.putExtra("flag", z);
activity.startActivityForResult(intent, i);
}
public static void stopKapService(Context context) {
context.stopService(new Intent(context, (Class<?>) KapchatService.class));
}
public void kapchatRelogin(Context context) {
SharedPreferences.Editor edit = context.getSharedPreferences("kapchatpreference", 0).edit();
edit.putString("customerCode", "");
edit.putString("supportKey", "");
edit.putString("encryptionKey", "");
try {
XMPPTCPConnection xMPPTCPConnection = KapchatConnection.mConnection;
if ((xMPPTCPConnection == null || (xMPPTCPConnection != null && !xMPPTCPConnection.isConnected())) && !KapchatService.isConnecting.booleanValue()) {
Intent intent = new Intent(context, (Class<?>) KapchatService.class);
if (Build.VERSION.SDK_INT >= 26) {
context.startService(intent);
} else {
context.startService(intent);
}
}
} catch (Exception unused) {
}
XMPPTCPConnection xMPPTCPConnection2 = KapchatConnection.mConnection;
if ((xMPPTCPConnection2 == null || !xMPPTCPConnection2.isConnected()) && !KapchatService.isConnecting.booleanValue()) {
Intent intent2 = new Intent(context, (Class<?>) KapchatService.class);
if (Build.VERSION.SDK_INT >= 26) {
context.startService(intent2);
} else {
context.startService(intent2);
}
}
String str = "" + context.getSharedPreferences("kapchatpreference", 0).getString("customerCode", "");
String str2 = "" + context.getSharedPreferences("kapchatpreference", 0).getString("supportKey", "");
String str3 = "" + context.getSharedPreferences("kapchatpreference", 0).getString("encryptionKey", "");
if (str.equalsIgnoreCase("") || str2.equalsIgnoreCase("") || str3.equalsIgnoreCase("")) {
callResponse.intialiseResponse("KS0201");
} else {
new KapchatHelper().new KapchatLogin(context, str, str2, str3).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[0]);
}
}
public static void startChatScreen(Context context) {
unreadcount = 0;
SharedPreferences.Editor edit = context.getSharedPreferences("kapchatnewRef", 0).edit();
edit.putInt("unreadCount", unreadcount);
edit.apply();
context.startActivity(new Intent(context, (Class<?>) KapchatScreenActivity.class));
}
}