正在查看: Clash Legends v0.0.1 应用的 SnoozeService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Clash Legends v0.0.1 应用的 SnoozeService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.payu.custombrowser.services;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.os.Binder;
import android.os.CountDownTimer;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import androidx.core.app.NotificationCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.onesignal.core.internal.database.impl.OneSignalDbContract;
import com.payu.custombrowser.CBActivity;
import com.payu.custombrowser.R;
import com.payu.custombrowser.bean.CustomBrowserConfig;
import com.payu.payuanalytics.analytics.utils.PayUAnalyticsConstant;
import com.payu.upisdk.util.UpiConstant;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.Random;
import javax.net.ssl.SSLException;
import kotlinx.coroutines.internal.LockFreeTaskQueueCore;
import org.json.JSONException;
public class SnoozeService extends Service {
private static int M;
private boolean A;
private boolean B;
private long C;
private boolean D;
private String E;
private CustomBrowserConfig F;
private String G;
private com.payu.custombrowser.util.c H;
private String I;
private String J;
private String K;
private Runnable L;
private Handler d;
private Runnable e;
private Handler f;
private HandlerThread g;
private CountDownTimer h;
private Looper i;
private e j;
private long k;
private long l;
private long o;
private String w;
private boolean x;
private boolean z;
private int a = 1800000;
private final IBinder b = new f();
String c = com.payu.custombrowser.util.b.MERCHANT_CHECKOUT_ACTIVITY;
private int m = 1000;
private int n = 60000;
private String p = "";
private String q = "";
private String r = "";
private String s = "";
private String t = "";
private String u = "";
private String v = "";
private boolean y = true;
class a implements Runnable {
a() {
}
@Override
public void run() {
throw new UnsupportedOperationException("Method not decompiled: com.payu.custombrowser.services.SnoozeService.a.run():void");
}
}
class b implements Runnable {
b() {
}
@Override
public void run() {
if (SnoozeService.this.y) {
SnoozeService.this.c();
}
}
}
class c extends CountDownTimer {
c(long j, long j2) {
super(j, j2);
}
@Override
public void onFinish() {
cancel();
SnoozeService.this.x = true;
}
@Override
public void onTick(long j) {
}
}
class d implements Runnable {
final String a;
final CountDownTimer b;
d(String str, CountDownTimer countDownTimer) {
this.a = str;
this.b = countDownTimer;
}
@Override
public void run() {
try {
com.payu.custombrowser.util.c unused = SnoozeService.this.H;
if (!com.payu.custombrowser.util.c.g(SnoozeService.this.getApplicationContext())) {
SnoozeService.this.d.postDelayed(SnoozeService.this.e, Math.min(SnoozeService.this.m, SnoozeService.this.n));
return;
}
SnoozeService.this.k = System.currentTimeMillis();
URLConnection openConnection = new URL(this.a).openConnection();
openConnection.setUseCaches(false);
openConnection.connect();
openConnection.getContentLength();
InputStream inputStream = openConnection.getInputStream();
byte[] bArr = new byte[LockFreeTaskQueueCore.MIN_ADD_SPIN_CAPACITY];
while (!SnoozeService.this.x && inputStream.read(bArr) != -1) {
}
if (SnoozeService.this.x) {
this.b.cancel();
inputStream.close();
SnoozeService.this.o = SnoozeService.M + 1;
} else {
this.b.cancel();
SnoozeService.this.l = System.currentTimeMillis();
inputStream.close();
SnoozeService snoozeService = SnoozeService.this;
snoozeService.o = snoozeService.l - SnoozeService.this.k;
}
if (SnoozeService.this.o > SnoozeService.M) {
SnoozeService snoozeService2 = SnoozeService.this;
SnoozeService.a(snoozeService2, snoozeService2.m);
SnoozeService.this.d.postDelayed(SnoozeService.this.e, Math.min(SnoozeService.this.m, SnoozeService.this.n));
return;
}
if (SnoozeService.this.y) {
if (SnoozeService.this.D) {
SnoozeService.this.a("snooze_verify_api_status", "snooze_verify_api_called");
new Thread(SnoozeService.this.L).start();
} else if (CBActivity.g != 1) {
SnoozeService snoozeService3 = SnoozeService.this;
snoozeService3.a(snoozeService3.z);
SnoozeService.this.a("internet_restored_notification", "-1");
} else {
SnoozeService snoozeService4 = SnoozeService.this;
snoozeService4.a(snoozeService4.getString(R.string.internet_restored), SnoozeService.this.getString(R.string.resuming_your_transaction), true);
SnoozeService.this.a("internet_restored_dialog_foreground", "-1");
SnoozeService.this.d();
}
}
} catch (MalformedURLException e) {
SnoozeService.this.o = -1L;
this.b.cancel();
e.printStackTrace();
} catch (SSLException e2) {
SnoozeService.this.d.postDelayed(SnoozeService.this.e, Math.min(SnoozeService.this.m, SnoozeService.this.n));
e2.printStackTrace();
} catch (IOException e3) {
SnoozeService.this.o = -1L;
this.b.cancel();
e3.printStackTrace();
} catch (Exception e4) {
SnoozeService.this.o = -1L;
this.b.cancel();
}
}
}
private final class e extends Handler {
class a extends CountDownTimer {
a(long j, long j2) {
super(j, j2);
}
@Override
public void onFinish() {
if (!SnoozeService.this.A && CBActivity.g == 2) {
SnoozeService.this.e();
SnoozeService.this.a("internet_not_restored_notification", "-1");
} else if (!SnoozeService.this.A && CBActivity.g == 1) {
SnoozeService.this.a("internet_not_restored_dialog_foreground", "-1");
}
if (SnoozeService.this.z && !SnoozeService.this.A) {
Intent intent = new Intent("webview_status_action");
intent.putExtra(com.payu.custombrowser.util.b.SNOOZE_SERVICE_STATUS, com.payu.custombrowser.util.b.SNOOZE_SERVICE_DEAD);
LocalBroadcastManager.getInstance(SnoozeService.this).sendBroadcast(intent);
}
SnoozeService.this.d();
}
@Override
public void onTick(long j) {
SnoozeService.this.C = (r0.a - j) / 1000;
}
}
class b implements Runnable {
b() {
}
@Override
public void run() {
if (SnoozeService.this.y) {
if (SnoozeService.this.p.contentEquals(SnoozeService.this.q)) {
SnoozeService.this.z = true;
} else {
SnoozeService.this.z = false;
if (SnoozeService.this.y && SnoozeService.this.D && SnoozeService.this.A && SnoozeService.this.B) {
SnoozeService snoozeService = SnoozeService.this;
snoozeService.a(snoozeService.G);
} else if (SnoozeService.this.y && SnoozeService.this.A && SnoozeService.this.B) {
SnoozeService snoozeService2 = SnoozeService.this;
snoozeService2.a(snoozeService2.z);
}
}
SnoozeService.this.f.postDelayed(this, 500L);
Intent intent = new Intent("webview_status_action");
SnoozeService.this.p = "" + System.currentTimeMillis();
intent.putExtra("snooze_broad_cast_message", SnoozeService.this.p);
LocalBroadcastManager.getInstance(SnoozeService.this).sendBroadcast(intent);
}
}
}
public e(Looper looper) {
super(looper);
}
@Override
public void handleMessage(Message message) {
SnoozeService.this.y = true;
SnoozeService.this.h = new a(SnoozeService.this.a, PayUAnalyticsConstant.PA_TIMER_DELAY);
SnoozeService.this.h.start();
SnoozeService.this.f = new Handler();
SnoozeService.this.f.postDelayed(new b(), 500L);
SnoozeService.this.b();
}
}
public class f extends Binder {
public f() {
}
public SnoozeService a() {
return SnoozeService.this;
}
}
public SnoozeService() {
this.E = com.payu.custombrowser.a.DEBUG ? "https://mobiletest.payu.in/merchant/postservice?form=2" : "https://info.payu.in/merchant/postservice?form=2";
this.J = null;
this.K = null;
this.L = new a();
}
@Override
public IBinder onBind(Intent intent) {
this.z = true;
return this.b;
}
@Override
public void onCreate() {
HandlerThread handlerThread = new HandlerThread("SnoozeServiceHandlerThread", 10);
this.g = handlerThread;
handlerThread.start();
this.i = this.g.getLooper();
this.j = new e(this.i);
}
@Override
public int onStartCommand(Intent intent, int i, int i2) {
this.H = new com.payu.custombrowser.util.c();
this.w = intent.getStringExtra(this.c);
CustomBrowserConfig customBrowserConfig = (CustomBrowserConfig) intent.getParcelableExtra("cb_config");
this.F = customBrowserConfig;
this.a = customBrowserConfig.getSurePayBackgroundTTL();
this.H.c(this.F.getPayuPostData());
int i3 = com.payu.custombrowser.b.snoozeImageDownloadTimeout;
if (i3 <= 0) {
i3 = UpiConstant.MERCHANT_URL_LOADING_TIMEOUT;
}
M = i3;
if (intent.getExtras().containsKey(com.payu.custombrowser.util.b.VERIFICATION_MSG_RECEIVED) && intent.getExtras().getBoolean(com.payu.custombrowser.util.b.VERIFICATION_MSG_RECEIVED)) {
this.D = true;
if (intent.getExtras().containsKey(com.payu.custombrowser.util.b.VERIFY_ADDON_PARAMS)) {
this.I = intent.getExtras().getString(com.payu.custombrowser.util.b.VERIFY_ADDON_PARAMS);
}
this.r = this.F.getPayuPostData();
this.F.getPostURL();
this.u = intent.getStringExtra(com.payu.custombrowser.util.b.MERCHANTKEY);
this.v = intent.getStringExtra("txnid");
this.J = intent.getStringExtra(com.payu.custombrowser.util.b.PAYUID);
} else {
this.D = false;
this.s = intent.getStringExtra(com.payu.custombrowser.util.b.CURRENT_URL);
this.t = intent.getStringExtra(com.payu.custombrowser.util.b.S2S_RETRY_URL);
}
Message obtainMessage = this.j.obtainMessage();
obtainMessage.arg1 = i2;
this.j.sendMessage(obtainMessage);
return com.payu.custombrowser.b.hasToStart ? 3 : 2;
}
public void e() {
a("snooze_notification_expected_action", "merchant_checkout_page");
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, this.F.getSurePayNotificationChannelId());
builder.setContentTitle(this.F.getSurePayNotificationPoorNetWorkTitle()).setContentText(this.F.getSurePayNotificationPoorNetWorkHeader()).setSmallIcon(this.F.getSurePayNotificationIcon()).setAutoCancel(true).setPriority(1).setDefaults(2).setStyle(new NotificationCompat.BigTextStyle().bigText(this.F.getSurePayNotificationPoorNetWorkHeader() + this.F.getSurePayNotificationPoorNetWorkBody()));
builder.setColor(getResources().getColor(R.color.cb_blue_button, null));
Intent intent = new Intent();
Context applicationContext = getApplicationContext();
String str = this.w;
if (str == null) {
str = "";
}
intent.setClassName(applicationContext, str);
if (intent.resolveActivityInfo(getPackageManager(), 0) == null) {
try {
throw new ActivityNotFoundException("The Activity " + this.w + " is not found, Please set valid activity ");
} catch (ActivityNotFoundException e2) {
e2.printStackTrace();
}
} else {
Intent intent2 = new Intent();
intent2.setClassName(getApplicationContext(), this.w);
intent2.putExtra(com.payu.custombrowser.util.b.POST_TYPE, "sure_pay_payment_data");
intent2.putExtra("postData", this.F.getPayuPostData());
builder.setContentIntent(PendingIntent.getActivity(this, 0, intent2, 134217728));
((NotificationManager) getSystemService(OneSignalDbContract.NotificationTable.TABLE_NAME)).notify(com.payu.custombrowser.util.b.SNOOZE_NOTIFICATION_ID, builder.build());
}
}
static int a(SnoozeService snoozeService, int i) {
int i2 = snoozeService.m + i;
snoozeService.m = i2;
return i2;
}
public void b(String str) {
try {
String b2 = this.H.b(str, getString(R.string.cb_snooze_verify_api_status));
if (CBActivity.g == 2) {
if (b2.contentEquals(com.payu.custombrowser.util.b.TRANSACTION_STATUS_SUCCESS)) {
a("transaction_verified_notification", "-1");
} else {
a("transaction_not_verified_notification", "-1");
}
a(str);
return;
}
if (b2.contentEquals(com.payu.custombrowser.util.b.TRANSACTION_STATUS_SUCCESS)) {
a("transaction_verified_dialog_foreground", "-1");
} else {
a("transaction_not_verified_dialog_foreground", "-1");
}
a(com.payu.custombrowser.util.b.BACKWARD_JOURNEY_STATUS, str, false);
d();
} catch (JSONException e2) {
e2.printStackTrace();
if (CBActivity.g == 2) {
a("transaction_not_verified_notification", "-1");
a(str);
} else {
a("transaction_not_verified_dialog_foreground", "-1");
a(com.payu.custombrowser.util.b.BACKWARD_JOURNEY_STATUS, str, false);
d();
}
}
}
public void c(String str) {
this.q = str;
}
public void d() {
this.y = false;
CountDownTimer countDownTimer = this.h;
if (countDownTimer != null) {
countDownTimer.cancel();
this.h = null;
}
this.g.interrupt();
stopSelf();
}
public void c() {
this.x = false;
String str = com.payu.custombrowser.util.b.SNOOZE_IMAGE_DOWNLOAD_END_POINT + com.payu.custombrowser.util.b.SNOOZE_IMAGE_COLLECTIONS[new Random().nextInt(2)];
c cVar = new c(M, 1000L);
cVar.start();
new Thread(new d(str, cVar)).start();
}
public void a(boolean z) {
boolean z2;
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, this.F.getSurePayNotificationChannelId());
builder.setContentTitle(this.F.getSurePayNotificationGoodNetworkTitle()).setContentText(this.F.getSurePayNotificationGoodNetWorkHeader()).setSmallIcon(this.F.getSurePayNotificationIcon()).setAutoCancel(true).setPriority(1).setDefaults(2).setStyle(new NotificationCompat.BigTextStyle().bigText(this.F.getSurePayNotificationGoodNetWorkHeader() + "\n\n" + this.F.getSurePayNotificationGoodNetWorkBody()));
builder.setColor(getResources().getColor(R.color.cb_blue_button, null));
this.A = true;
Intent intent = new Intent();
intent.putExtra(com.payu.custombrowser.util.b.CURRENT_URL, this.s);
intent.putExtra(com.payu.custombrowser.util.b.S2S_RETRY_URL, this.t);
intent.putExtra(com.payu.custombrowser.util.b.SENDER, com.payu.custombrowser.util.b.SNOOZE_SERVICE);
if (z) {
this.B = true;
intent.setFlags(536870912);
intent.putExtra(com.payu.custombrowser.util.b.CURRENT_URL, this.s);
intent.putExtra("cb_config", this.F);
intent.setClass(getApplicationContext(), CBActivity.class);
z2 = true;
} else {
Intent intent2 = new Intent();
Context applicationContext = getApplicationContext();
String str = this.w;
if (str == null) {
str = "";
}
intent2.setClassName(applicationContext, str);
if (intent2.resolveActivityInfo(getPackageManager(), 0) != null) {
intent.setClassName(getApplicationContext(), this.w);
intent.putExtra(com.payu.custombrowser.util.b.POST_TYPE, "sure_pay_payment_data");
intent.putExtra("postData", this.F.getPayuPostData());
z2 = true;
} else {
z2 = false;
}
a("snooze_notification_expected_action", "merchant_checkout_page");
this.B = false;
d();
}
try {
if (z2) {
builder.setContentIntent(PendingIntent.getActivity(getApplicationContext(), 0, intent, 134217728));
((NotificationManager) getSystemService(OneSignalDbContract.NotificationTable.TABLE_NAME)).notify(com.payu.custombrowser.util.b.SNOOZE_NOTIFICATION_ID, builder.build());
a(com.payu.custombrowser.util.b.GOOD_NETWORK_NOTIFICATION_LAUNCHED, "true", true);
return;
}
throw new ActivityNotFoundException("The Activity " + this.w + " is not found, Please set valid activity ");
} catch (ActivityNotFoundException e2) {
e2.printStackTrace();
}
}
public void b() {
Handler handler = new Handler(this.i);
this.d = handler;
b bVar = new b();
this.e = bVar;
handler.postDelayed(bVar, Math.min(this.m, this.n));
}
public void a(String str, String str2) {
Intent intent = new Intent("webview_status_action");
intent.putExtra("BROAD_CAST_FROM_SNOOZE_SERVICE", true);
intent.putExtra("event_key", str);
intent.putExtra("event_value", str2);
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
}
public void a(String str) {
StringBuilder append;
String surePayNotificationTransactionNotVerifiedBody;
String str2 = "";
try {
String b2 = this.H.b(str, getString(R.string.cb_snooze_verify_api_status));
a("snooze_verify_api_response_received", b2 + "");
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, this.F.getSurePayNotificationChannelId());
if (b2.contentEquals(com.payu.custombrowser.util.b.TRANSACTION_STATUS_SUCCESS)) {
append = new StringBuilder().append(this.F.getSurePayNotificationTransactionVerifiedHeader()).append("\n\n");
surePayNotificationTransactionNotVerifiedBody = this.F.getSurePayNotificationTransactionVerifiedBody();
} else {
append = new StringBuilder().append(this.F.getSurePayNotificationTransactionNotVerifiedHeader()).append("\n\n");
surePayNotificationTransactionNotVerifiedBody = this.F.getSurePayNotificationTransactionNotVerifiedBody();
}
boolean z = true;
builder.setContentTitle(b2.contentEquals(com.payu.custombrowser.util.b.TRANSACTION_STATUS_SUCCESS) ? this.F.getSurePayNotificationTransactionVerifiedTitle() : this.F.getSurePayNotificationTransactionNotVerifiedTitle()).setContentText(b2.contentEquals(com.payu.custombrowser.util.b.TRANSACTION_STATUS_SUCCESS) ? this.F.getSurePayNotificationTransactionVerifiedHeader() : this.F.getSurePayNotificationTransactionNotVerifiedHeader()).setSmallIcon(this.F.getSurePayNotificationIcon()).setAutoCancel(true).setPriority(1).setDefaults(2).setStyle(new NotificationCompat.BigTextStyle().bigText(append.append(surePayNotificationTransactionNotVerifiedBody).toString()));
Intent intent = new Intent();
intent.putExtra("cb_config", this.F);
this.A = true;
intent.putExtra("payu_response", str);
if (this.z) {
intent.setFlags(805306368);
this.B = true;
intent.putExtra(com.payu.custombrowser.util.b.SENDER, com.payu.custombrowser.util.b.SNOOZE_SERVICE);
intent.putExtra(com.payu.custombrowser.util.b.VERIFICATION_MSG_RECEIVED, true);
intent.setClass(getApplicationContext(), CBActivity.class);
} else {
Intent intent2 = new Intent();
Context applicationContext = getApplicationContext();
String str3 = this.w;
if (str3 != null) {
str2 = str3;
}
intent2.setClassName(applicationContext, str2);
if (intent2.resolveActivityInfo(getPackageManager(), 0) != null) {
intent.putExtra("postData", str);
intent.setClassName(getApplicationContext(), this.w);
intent.putExtra(com.payu.custombrowser.util.b.POST_TYPE, "verify_response_post_data");
} else {
z = false;
}
a("snooze_notification_expected_action", "merchant_checkout_page");
this.B = false;
d();
}
try {
if (z) {
builder.setContentIntent(PendingIntent.getActivity(this, 0, intent, 134217728));
((NotificationManager) getSystemService(OneSignalDbContract.NotificationTable.TABLE_NAME)).notify(com.payu.custombrowser.util.b.TRANSACTION_STATUS_NOTIFICATION_ID, builder.build());
a(com.payu.custombrowser.util.b.GOOD_NETWORK_NOTIFICATION_LAUNCHED, str, false);
return;
}
throw new ActivityNotFoundException("The Activity " + this.w + " is not found, Please set valid activity ");
} catch (ActivityNotFoundException e2) {
e2.printStackTrace();
}
} catch (Exception e3) {
e3.printStackTrace();
}
}
public void a(String str, String str2, boolean z) {
Intent intent = new Intent("webview_status_action");
intent.putExtra(com.payu.custombrowser.util.b.BROADCAST_FROM_SERVICE_UPDATE_UI, true);
intent.putExtra("key", str);
intent.putExtra("value", str2);
intent.putExtra(com.payu.custombrowser.util.b.CURRENT_URL, this.s);
intent.putExtra(com.payu.custombrowser.util.b.S2S_RETRY_URL, this.t);
intent.putExtra("cb_config", this.F);
intent.putExtra(com.payu.custombrowser.util.b.IS_FORWARD_JOURNEY, z);
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
}
}