Swiggy v4.51.1版本的 MD5 值为:5af7ec91512a0a8c1510e3f8bac20b8b
以下内容为反编译后的 r.java 源代码,内容仅作参考
package com.clevertap.android.pushtemplates;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.ResolveInfo;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.media.AudioAttributes;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.service.notification.StatusBarNotification;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.widget.RemoteViews;
import android.widget.Toast;
import com.clevertap.android.sdk.CleverTapAPI;
import com.clevertap.android.sdk.CleverTapInstanceConfig;
import com.google.android.gms.search.SearchAuth;
import com.newrelic.agent.android.analytics.EventManagerImpl;
import com.newrelic.agent.android.instrumentation.BitmapFactoryInstrumentation;
import com.newrelic.agent.android.instrumentation.Instrumented;
import com.newrelic.agent.android.instrumentation.URLConnectionInstrumentation;
import in.juspay.hypersdk.core.PaymentConstants;
import in.swiggy.android.tejas.network.HttpRequest;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Callable;
import java.util.zip.GZIPInputStream;
import org.apache.pdfbox.pdmodel.interactive.form.PDRadioButton;
import org.json.JSONArray;
import org.json.JSONObject;
@Instrumented
public class r {
class a implements Callable<Void> {
final String a;
final Context b;
a(String str, Context context) {
this.a = str;
this.b = context;
}
@Override
public Void call() {
if (!TextUtils.isEmpty(this.a)) {
Toast.makeText(this.b, this.a, 0).show();
return null;
}
return null;
}
}
public static ArrayList<String> A(Bundle bundle) {
ArrayList<String> arrayList = new ArrayList<>();
for (String str : bundle.keySet()) {
if (str.contains("pt_st")) {
arrayList.add(bundle.getString(str));
}
}
return arrayList;
}
public static String B(Context context) {
return DateUtils.formatDateTime(context, System.currentTimeMillis(), 1);
}
public static int C(Bundle bundle) {
String str = "-1";
for (String str2 : bundle.keySet()) {
if (str2.contains("pt_timer_end")) {
str = bundle.getString(str2);
}
}
if (str.contains("$D_")) {
str = str.split("\\$D_")[1];
}
int parseLong = (int) (Long.parseLong(str) - (System.currentTimeMillis() / 1000));
if (str.equals("-1")) {
return Integer.MIN_VALUE;
}
return parseLong;
}
public static int D(Bundle bundle) {
String str = "-1";
String str2 = "-1";
for (String str3 : bundle.keySet()) {
if (str3.contains("pt_timer_threshold")) {
str2 = bundle.getString(str3);
}
}
if (str2 != null) {
str = str2;
}
return Integer.parseInt(str);
}
static boolean E(NotificationChannel notificationChannel) {
int importance;
if (Build.VERSION.SDK_INT >= 26 && notificationChannel != null) {
importance = notificationChannel.getImportance();
if (importance == 0) {
return false;
}
return true;
}
return false;
}
public static boolean F(Context context, int i) {
for (StatusBarNotification statusBarNotification : ((NotificationManager) context.getSystemService("notification")).getActiveNotifications()) {
if (statusBarNotification.getId() == i) {
return true;
}
}
return false;
}
public static void G(int i, Bitmap bitmap, RemoteViews remoteViews) {
remoteViews.setImageViewBitmap(i, bitmap);
}
public static void H(int i, int i2, RemoteViews remoteViews) {
remoteViews.setImageViewResource(i, i2);
}
public static void I(int i, String str, RemoteViews remoteViews) {
Bitmap n = n(str);
P(Boolean.FALSE);
if (n != null) {
remoteViews.setImageViewBitmap(i, n);
return;
}
b.a("Image was not perfect. URL:" + str + " hiding image view");
P(Boolean.TRUE);
}
public static void J(int i, String str, RemoteViews remoteViews, Context context) {
Bitmap n = n(str);
P(Boolean.FALSE);
if (n != null) {
remoteViews.setImageViewBitmap(i, n);
return;
}
b.a("Image was not perfect. URL:" + str + " hiding image view");
P(Boolean.TRUE);
}
public static void K(Context context, CleverTapInstanceConfig cleverTapInstanceConfig, Bundle bundle) {
CleverTapAPI A;
if (cleverTapInstanceConfig != null) {
A = CleverTapAPI.N(context, cleverTapInstanceConfig);
} else {
A = CleverTapAPI.A(context);
}
HashMap<String, Object> r = r(bundle);
String q = q(bundle);
if (q != null && !q.isEmpty()) {
if (A != null) {
A.c0(q, r);
} else {
b.a("CleverTap instance is NULL, not raising the event");
}
}
}
public static void L(Context context, CleverTapInstanceConfig cleverTapInstanceConfig, Bundle bundle, String str) {
CleverTapAPI A;
if (cleverTapInstanceConfig != null) {
A = CleverTapAPI.N(context, cleverTapInstanceConfig);
} else {
A = CleverTapAPI.A(context);
}
HashMap<String, Object> s = s(bundle, str, bundle.getString(str));
String q = q(bundle);
if (q != null && !q.isEmpty()) {
if (A != null) {
A.c0(q, s);
} else {
b.a("CleverTap instance is NULL, not raising the event");
}
}
}
public static void M(Context context, CleverTapInstanceConfig cleverTapInstanceConfig, String str, HashMap<String, Object> hashMap) {
CleverTapAPI A;
if (cleverTapInstanceConfig != null) {
A = CleverTapAPI.N(context, cleverTapInstanceConfig);
} else {
A = CleverTapAPI.A(context);
}
if (str != null && !str.isEmpty()) {
if (A != null) {
A.c0(str, hashMap);
} else {
b.a("CleverTap instance is NULL, not raising the event");
}
}
}
public static void N(Context context, Bundle bundle, CleverTapInstanceConfig cleverTapInstanceConfig) {
CleverTapAPI A;
if (cleverTapInstanceConfig != null) {
A = CleverTapAPI.N(context, cleverTapInstanceConfig);
} else {
A = CleverTapAPI.A(context);
}
if (A != null) {
A.e0(bundle);
}
}
public static Bitmap O(Context context, int i, String str) throws NullPointerException {
if (str != null && !str.isEmpty()) {
int o = o(str, "#A6A6A6");
Drawable drawable = androidx.core.content.a.getDrawable(context, i);
Objects.requireNonNull(drawable);
Drawable mutate = drawable.mutate();
mutate.setColorFilter(new PorterDuffColorFilter(o, PorterDuff.Mode.SRC_IN));
return g(mutate);
}
return null;
}
static void P(Boolean bool) {
com.clevertap.android.pushtemplates.a.a = bool.booleanValue();
}
public static void Q(Context context, Intent intent) {
List<ResolveInfo> queryIntentActivities = context.getPackageManager().queryIntentActivities(intent, 0);
String packageName = context.getPackageName();
for (ResolveInfo resolveInfo : queryIntentActivities) {
if (packageName.equals(resolveInfo.activityInfo.packageName)) {
intent.setPackage(packageName);
return;
}
}
}
public static void R(Context context, String str, CleverTapInstanceConfig cleverTapInstanceConfig) {
if (cleverTapInstanceConfig != null) {
com.clevertap.android.sdk.task.a.a(cleverTapInstanceConfig).b().f("PushTemplatesUtils#showToast", new a(str, context));
}
}
public static String a(Bundle bundle, String str) {
try {
Object obj = bundle.get(str);
if (obj == null) {
return null;
}
return obj.toString();
} catch (Throwable unused) {
return null;
}
}
public static void b(Context context, int i) {
((NotificationManager) context.getSystemService("notification")).cancel(i);
}
public static HashMap<String, Object> c(Bundle bundle) {
bundle.remove(PaymentConstants.Category.CONFIG);
HashMap<String, Object> hashMap = new HashMap<>();
for (String str : bundle.keySet()) {
if (str.contains("wzrk_") || str.equals("pt_id")) {
Object obj = bundle.get(str);
if (obj instanceof Bundle) {
hashMap.putAll(c((Bundle) obj));
} else {
hashMap.put(str, bundle.get(str));
}
}
}
return hashMap;
}
public static void d(Context context) {
NotificationChannel notificationChannel;
NotificationChannel notificationChannel2;
NotificationChannel notificationChannel3;
NotificationManager notificationManager = (NotificationManager) context.getSystemService("notification");
if (notificationManager != null && Build.VERSION.SDK_INT >= 26) {
notificationChannel = notificationManager.getNotificationChannel("pt_silent_sound_channel");
if (notificationChannel != null) {
notificationChannel2 = notificationManager.getNotificationChannel("pt_silent_sound_channel");
if (notificationChannel2 != null) {
notificationChannel3 = notificationManager.getNotificationChannel("pt_silent_sound_channel");
if (E(notificationChannel3)) {
return;
}
} else {
return;
}
}
Uri parse = Uri.parse("android.resource://" + context.getPackageName() + "/raw/pt_silent_sound");
l.a();
NotificationChannel a2 = k.a("pt_silent_sound_channel", com.clevertap.android.pushtemplates.a.b, 4);
if (parse != null) {
a2.setSound(parse, new AudioAttributes.Builder().setUsage(5).build());
}
a2.setDescription("A channel to silently update notifications");
a2.setShowBadge(false);
notificationManager.createNotificationChannel(a2);
}
}
public static void e(Context context, Intent intent) {
String stringExtra = intent.getStringExtra("wzrk_pid");
File dir = new ContextWrapper(context.getApplicationContext()).getDir("pt_dir", 0);
String absolutePath = dir.getAbsolutePath();
String[] list = dir.list();
if (list != null) {
for (String str : list) {
if (stringExtra != null && str.contains(stringExtra)) {
if (!new File(absolutePath + "/" + str).delete()) {
b.a("Failed to clean up the following file: " + str);
}
} else if (stringExtra == null && str.contains("null")) {
if (!new File(absolutePath + "/" + str).delete()) {
b.a("Failed to clean up the following file: " + str);
}
}
}
}
}
public static void f(Context context) {
NotificationChannel notificationChannel;
NotificationChannel notificationChannel2;
NotificationManager notificationManager = (NotificationManager) context.getSystemService("notification");
if (notificationManager != null && Build.VERSION.SDK_INT >= 26) {
notificationChannel = notificationManager.getNotificationChannel("pt_silent_sound_channel");
if (notificationChannel != null) {
notificationChannel2 = notificationManager.getNotificationChannel("pt_silent_sound_channel");
if (E(notificationChannel2)) {
notificationManager.deleteNotificationChannel("pt_silent_sound_channel");
}
}
}
}
static Bitmap g(Drawable drawable) throws NullPointerException {
Bitmap createBitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(createBitmap);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);
return createBitmap;
}
public static Bundle h(JSONObject jSONObject) {
Bundle bundle = new Bundle();
Iterator<String> keys = jSONObject.keys();
while (keys.hasNext()) {
String next = keys.next();
JSONArray optJSONArray = jSONObject.optJSONArray(next);
String optString = jSONObject.optString(next);
if (optJSONArray != null && optJSONArray.length() <= 0) {
bundle.putStringArray(next, new String[0]);
} else if (optJSONArray != null && optJSONArray.optString(0) != null) {
String[] strArr = new String[optJSONArray.length()];
for (int i = 0; i < optJSONArray.length(); i++) {
strArr[i] = optJSONArray.optString(i);
}
bundle.putStringArray(next, strArr);
} else if (optString != null) {
bundle.putString(next, optString);
} else {
PrintStream printStream = System.err;
printStream.println("unable to transform json to bundle " + next);
}
}
return bundle;
}
public static JSONArray i(Bundle bundle) {
String string = bundle.getString("wzrk_acts");
if (string != null) {
try {
return new JSONArray(string);
} catch (Throwable th) {
b.a("error parsing notification actions: " + th.getLocalizedMessage());
}
}
return null;
}
private static Bitmap j(Context context) throws NullPointerException {
try {
Drawable applicationLogo = context.getPackageManager().getApplicationLogo(context.getApplicationInfo());
if (applicationLogo != null) {
return g(applicationLogo);
}
throw new Exception("Logo is null");
} catch (Exception unused) {
return g(context.getPackageManager().getApplicationIcon(context.getApplicationInfo()));
}
}
public static int k(Context context) {
return context.getApplicationInfo().icon;
}
public static String l(Context context) {
ApplicationInfo applicationInfo = context.getApplicationInfo();
int i = applicationInfo.labelRes;
if (i == 0) {
return applicationInfo.nonLocalizedLabel.toString();
}
return context.getString(i);
}
public static ArrayList<String> m(Bundle bundle) {
ArrayList<String> arrayList = new ArrayList<>();
for (String str : bundle.keySet()) {
if (str.contains("pt_bt")) {
arrayList.add(bundle.getString(str));
}
}
return arrayList;
}
private static Bitmap n(String str) {
String str2;
Throwable th;
HttpURLConnection httpURLConnection;
String str3;
HttpURLConnection httpURLConnection2;
?? r2;
HttpURLConnection httpURLConnection3;
String str4;
byte[] bArr;
?? r22;
int i;
HttpURLConnection httpURLConnection4;
String str5 = "Couldn't close connection!";
String replace = str.replace("///", "/").replace("//", "/").replace("http:/", "http://").replace("https:/", "https://");
try {
httpURLConnection2 = (HttpURLConnection) URLConnectionInstrumentation.openConnection(new URL(replace).openConnection());
boolean z = true;
try {
try {
httpURLConnection2.setDoInput(true);
httpURLConnection2.setUseCaches(true);
httpURLConnection2.addRequestProperty("Content-Type", "application/json");
httpURLConnection2.addRequestProperty(HttpRequest.HEADER_ACCEPT_ENCODING, "gzip, deflate");
httpURLConnection2.setConnectTimeout(SearchAuth.StatusCodes.AUTH_DISABLED);
httpURLConnection2.connect();
try {
if (httpURLConnection2.getResponseCode() != 200) {
b.a("File not loaded completely not going forward. URL was: " + replace);
try {
httpURLConnection2.disconnect();
} catch (Throwable th2) {
b.d("Couldn't close connection!", th2);
}
return null;
}
long contentLength = httpURLConnection2.getContentLength();
if (httpURLConnection2.getContentEncoding() == null || !httpURLConnection2.getContentEncoding().contains("gzip")) {
z = false;
}
InputStream inputStream = httpURLConnection2.getInputStream();
byte[] bArr2 = new byte[PDRadioButton.FLAG_NO_TOGGLE_TO_OFF];
?? byteArrayOutputStream = new ByteArrayOutputStream();
long j = 0;
while (true) {
httpURLConnection3 = inputStream.read(bArr2);
r2 = -1;
i = -1;
r22 = -1;
if (httpURLConnection3 == -1) {
break;
}
str4 = str5;
j += (long) httpURLConnection3;
try {
byteArrayOutputStream.write(bArr2, 0, httpURLConnection3);
str5 = str4;
} catch (IOException unused) {
str3 = str4;
try {
b.c("Couldn't download the file. URL was: " + replace);
if (httpURLConnection2 != null) {
}
} catch (Throwable th3) {
th = th3;
httpURLConnection = httpURLConnection2;
str2 = str3;
if (httpURLConnection != null) {
try {
httpURLConnection.disconnect();
} catch (Throwable th4) {
b.d(str2, th4);
}
}
throw th;
}
} catch (Throwable th5) {
th = th5;
httpURLConnection4 = httpURLConnection2;
str2 = str4;
httpURLConnection = httpURLConnection4;
if (httpURLConnection != null) {
}
throw th;
}
}
str4 = str5;
try {
bArr = new byte[PDRadioButton.FLAG_NO_TOGGLE_TO_OFF];
} catch (IOException unused2) {
} catch (Throwable th6) {
th = th6;
httpURLConnection3 = httpURLConnection2;
}
try {
if (z) {
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream();
GZIPInputStream gZIPInputStream = new GZIPInputStream(byteArrayInputStream);
long j2 = 0;
while (true) {
int read = gZIPInputStream.read(bArr);
if (read == i) {
break;
}
httpURLConnection4 = httpURLConnection2;
j2 += read;
try {
byteArrayOutputStream2.write(bArr, 0, read);
httpURLConnection2 = httpURLConnection4;
i = -1;
} catch (IOException unused3) {
httpURLConnection2 = httpURLConnection4;
str3 = str4;
b.c("Couldn't download the file. URL was: " + replace);
if (httpURLConnection2 != null) {
try {
httpURLConnection2.disconnect();
return null;
} catch (Throwable th7) {
b.d(str3, th7);
return null;
}
}
return null;
} catch (Throwable th8) {
th = th8;
str2 = str4;
httpURLConnection = httpURLConnection4;
if (httpURLConnection != null) {
}
throw th;
}
}
httpURLConnection3 = httpURLConnection2;
if (contentLength != -1 && contentLength != j) {
try {
b.a("File not loaded completely not going forward. URL was: " + replace);
try {
httpURLConnection3.disconnect();
return null;
} catch (Throwable th9) {
b.d(str4, th9);
return null;
}
} catch (IOException unused4) {
r22 = str4;
httpURLConnection2 = httpURLConnection3;
str3 = r22;
b.c("Couldn't download the file. URL was: " + replace);
if (httpURLConnection2 != null) {
}
} catch (Throwable th10) {
th = th10;
r2 = str4;
th = th;
str2 = r2;
httpURLConnection = httpURLConnection3;
if (httpURLConnection != null) {
}
throw th;
}
} else {
Bitmap decodeByteArray = BitmapFactoryInstrumentation.decodeByteArray(byteArrayOutputStream2.toByteArray(), 0, (int) j2);
try {
httpURLConnection3.disconnect();
} catch (Throwable th11) {
b.d(str4, th11);
}
return decodeByteArray;
}
} else if (contentLength != -1 && contentLength != j) {
b.a("File not loaded completely not going forward. URL was: " + replace);
try {
httpURLConnection2.disconnect();
return null;
} catch (Throwable th12) {
b.d(str4, th12);
return null;
}
} else {
Bitmap decodeByteArray2 = BitmapFactoryInstrumentation.decodeByteArray(byteArrayOutputStream.toByteArray(), 0, (int) j);
try {
httpURLConnection2.disconnect();
} catch (Throwable th13) {
b.d(str4, th13);
}
return decodeByteArray2;
}
} catch (IOException unused5) {
} catch (Throwable th14) {
th = th14;
th = th;
str2 = r2;
httpURLConnection = httpURLConnection3;
if (httpURLConnection != null) {
}
throw th;
}
} catch (IOException unused6) {
str3 = "Couldn't close connection!";
}
} catch (Throwable th15) {
th = th15;
r2 = "Couldn't close connection!";
httpURLConnection3 = httpURLConnection2;
}
} catch (IOException unused7) {
str3 = str5;
}
} catch (IOException unused8) {
str3 = "Couldn't close connection!";
httpURLConnection2 = null;
} catch (Throwable th16) {
str2 = "Couldn't close connection!";
th = th16;
httpURLConnection = null;
}
}
public static int o(String str, String str2) {
try {
return Color.parseColor(str);
} catch (Exception unused) {
b.a("Can not parse colour value: " + str + " Switching to default colour: " + str2);
return Color.parseColor(str2);
}
}
public static ArrayList<String> p(Bundle bundle) {
ArrayList<String> arrayList = new ArrayList<>();
for (String str : bundle.keySet()) {
if (str.contains("pt_dl")) {
arrayList.add(bundle.getString(str));
}
}
return arrayList;
}
static String q(Bundle bundle) {
String str = null;
for (String str2 : bundle.keySet()) {
if (str2.contains("pt_event_name")) {
str = bundle.getString(str2);
}
}
return str;
}
static HashMap<String, Object> r(Bundle bundle) {
HashMap<String, Object> hashMap = new HashMap<>();
for (String str : bundle.keySet()) {
if (str.contains("pt_event_property")) {
if (bundle.getString(str) != null && !bundle.getString(str).isEmpty()) {
if (str.contains("pt_event_property_")) {
hashMap.put(str.split("pt_event_property_")[1], bundle.getString(str));
} else {
b.c("Property " + str + " does not have the separator");
}
} else {
b.c("Property Key is Empty. Skipping Property: " + str);
}
}
}
return hashMap;
}
static HashMap<String, Object> s(Bundle bundle, String str, String str2) {
HashMap<String, Object> hashMap = new HashMap<>();
for (String str3 : bundle.keySet()) {
if (str3.contains("pt_event_property")) {
if (bundle.getString(str3) != null && !bundle.getString(str3).isEmpty()) {
if (str3.contains("pt_event_property_")) {
String[] split = str3.split("pt_event_property_");
if (bundle.getString(str3).equalsIgnoreCase(str)) {
hashMap.put(split[1], str2);
} else {
hashMap.put(split[1], bundle.getString(str3));
}
} else {
b.c("Property " + str3 + " does not have the separator");
}
} else {
b.c("Property Key is Empty. Skipping Property: " + str3);
}
}
}
return hashMap;
}
public static boolean t() {
return com.clevertap.android.pushtemplates.a.a;
}
public static int u(Bundle bundle) {
String string = bundle.getString("pt_flip_interval");
if (string != null) {
try {
return Math.max(Integer.parseInt(string), (int) EventManagerImpl.DEFAULT_MAX_EVENT_BUFFER_SIZE);
} catch (Exception unused) {
b.a("Flip Interval couldn't be converted to number: " + string + " - Defaulting to base value: " + EventManagerImpl.DEFAULT_MAX_EVENT_BUFFER_SIZE);
}
}
return EventManagerImpl.DEFAULT_MAX_EVENT_BUFFER_SIZE;
}
public static ArrayList<String> v(Bundle bundle) {
ArrayList<String> arrayList = new ArrayList<>();
for (String str : bundle.keySet()) {
if (str.contains("pt_img")) {
arrayList.add(bundle.getString(str));
}
}
return arrayList;
}
public static Bitmap w(String str, boolean z, Context context) throws NullPointerException {
if (str != null && !str.equals("")) {
if (!str.startsWith("http")) {
str = "http://static.wizrocket.com/android/ico//" + str;
}
Bitmap n = n(str);
if (n != null) {
return n;
}
if (!z) {
return null;
}
return j(context);
} else if (!z) {
return null;
} else {
return j(context);
}
}
public static Notification x(Context context, int i) {
StatusBarNotification[] activeNotifications;
for (StatusBarNotification statusBarNotification : ((NotificationManager) context.getSystemService("notification")).getActiveNotifications()) {
if (statusBarNotification.getId() == i) {
return statusBarNotification.getNotification();
}
}
return null;
}
public static ArrayList<Integer> y(Context context) {
StatusBarNotification[] activeNotifications;
ArrayList<Integer> arrayList = new ArrayList<>();
for (StatusBarNotification statusBarNotification : ((NotificationManager) context.getSystemService("notification")).getActiveNotifications()) {
if (statusBarNotification.getPackageName().equalsIgnoreCase(context.getPackageName())) {
arrayList.add(Integer.valueOf(statusBarNotification.getId()));
}
}
return arrayList;
}
public static ArrayList<String> z(Bundle bundle) {
ArrayList<String> arrayList = new ArrayList<>();
for (String str : bundle.keySet()) {
if (str.contains("pt_price") && !str.contains("pt_price_list")) {
arrayList.add(bundle.getString(str));
}
}
return arrayList;
}
}