Swiggy v4.51.1版本的 MD5 值为:5af7ec91512a0a8c1510e3f8bac20b8b

以下内容为反编译后的 p0.java 源代码,内容仅作参考


package com.clevertap.android.sdk;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import com.newrelic.agent.android.instrumentation.BitmapFactoryInstrumentation;
import com.newrelic.agent.android.instrumentation.Instrumented;
import com.newrelic.agent.android.instrumentation.URLConnectionInstrumentation;
import in.swiggy.android.tejas.network.HttpRequest;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import javax.net.ssl.HttpsURLConnection;
import org.apache.pdfbox.pdmodel.interactive.form.PDRadioButton;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@Instrumented
public final class p0 {
    public static boolean a = a();

    private static boolean a() {
        throw new UnsupportedOperationException("Method not decompiled: com.clevertap.android.sdk.p0.a():boolean");
    }

    public static boolean b(Collection<String> collection, String str) {
        if (collection != null && str != null) {
            for (String str2 : collection) {
                if (str.equalsIgnoreCase(str2)) {
                    return true;
                }
            }
        }
        return false;
    }

    public static HashMap<String, Object> c(@NonNull Bundle bundle) {
        HashMap<String, Object> hashMap = new HashMap<>();
        for (String str : bundle.keySet()) {
            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 ArrayList<HashMap<String, Object>> d(JSONArray jSONArray) {
        ArrayList<HashMap<String, Object>> arrayList = new ArrayList<>();
        if (jSONArray != null) {
            for (int i = 0; i < jSONArray.length(); i++) {
                try {
                    arrayList.add(f(jSONArray.getJSONObject(i)));
                } catch (JSONException e) {
                    f0.n("Could not convert JSONArray of JSONObjects to ArrayList of HashMaps - " + e.getMessage());
                }
            }
        }
        return arrayList;
    }

    public static ArrayList<String> e(JSONArray jSONArray) {
        ArrayList<String> arrayList = new ArrayList<>();
        if (jSONArray != null) {
            for (int i = 0; i < jSONArray.length(); i++) {
                try {
                    arrayList.add(jSONArray.getString(i));
                } catch (JSONException e) {
                    f0.n("Could not convert JSONArray to ArrayList - " + e.getMessage());
                }
            }
        }
        return arrayList;
    }

    public static HashMap<String, Object> f(JSONObject jSONObject) {
        HashMap<String, Object> hashMap = new HashMap<>();
        Iterator<String> keys = jSONObject.keys();
        while (keys.hasNext()) {
            try {
                String next = keys.next();
                Object obj = jSONObject.get(next);
                if (obj instanceof JSONObject) {
                    hashMap.putAll(f((JSONObject) obj));
                } else {
                    hashMap.put(next, jSONObject.get(next));
                }
            } catch (Throwable unused) {
            }
        }
        return hashMap;
    }

    public static String g(String str) {
        char[] charArray;
        if (str != null && !str.isEmpty()) {
            StringBuilder sb = new StringBuilder();
            boolean z = true;
            for (char c : str.toCharArray()) {
                if (Character.isSpaceChar(c)) {
                    z = true;
                } else if (z) {
                    c = Character.toTitleCase(c);
                    z = false;
                } else {
                    c = Character.toLowerCase(c);
                }
                sb.append(c);
            }
            return sb.toString();
        }
        return str;
    }

    static Bitmap h(@NonNull Drawable drawable) throws NullPointerException {
        if (drawable instanceof BitmapDrawable) {
            return ((BitmapDrawable) drawable).getBitmap();
        }
        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;
    }

    private static Bitmap i(Context context) throws NullPointerException {
        try {
            Drawable applicationLogo = context.getPackageManager().getApplicationLogo(context.getApplicationInfo());
            if (applicationLogo != null) {
                return h(applicationLogo);
            }
            throw new Exception("Logo is null");
        } catch (Exception e) {
            e.printStackTrace();
            return h(context.getPackageManager().getApplicationIcon(context.getApplicationInfo()));
        }
    }

    public static Bitmap j(@NonNull String str) {
        HttpURLConnection httpURLConnection;
        String replace = str.replace("///", "/").replace("//", "/").replace("http:/", "http://").replace("https:/", "https://");
        HttpURLConnection httpURLConnection2 = null;
        try {
            try {
                httpURLConnection = (HttpURLConnection) URLConnectionInstrumentation.openConnection(new URL(replace).openConnection());
                try {
                    httpURLConnection.setDoInput(true);
                    httpURLConnection.connect();
                    Bitmap decodeStream = BitmapFactoryInstrumentation.decodeStream(httpURLConnection.getInputStream());
                    try {
                        httpURLConnection.disconnect();
                    } catch (Throwable th) {
                        f0.q("Couldn't close connection!", th);
                    }
                    return decodeStream;
                } catch (IOException e) {
                    e = e;
                    f0.n("Couldn't download the notification icon. URL was: " + replace);
                    e.printStackTrace();
                    if (httpURLConnection != null) {
                        try {
                            httpURLConnection.disconnect();
                        } catch (Throwable th2) {
                            f0.q("Couldn't close connection!", th2);
                        }
                    }
                    return null;
                }
            } catch (Throwable th3) {
                th = th3;
                httpURLConnection2 = "https://";
                if (httpURLConnection2 != null) {
                    try {
                        httpURLConnection2.disconnect();
                    } catch (Throwable th4) {
                        f0.q("Couldn't close connection!", th4);
                    }
                }
                throw th;
            }
        } catch (IOException e2) {
            e = e2;
            httpURLConnection = null;
        } catch (Throwable th5) {
            th = th5;
            if (httpURLConnection2 != null) {
            }
            throw th;
        }
    }

    public static Bitmap k(String str, int i) {
        Throwable th;
        HttpURLConnection httpURLConnection;
        HttpURLConnection httpURLConnection2;
        boolean z;
        String str2;
        Bitmap decodeByteArray;
        Bitmap decodeByteArray2;
        String replace = str.replace("///", "/").replace("//", "/").replace("http:/", "http://").replace("https:/", "https://");
        try {
            try {
                httpURLConnection2 = (HttpURLConnection) URLConnectionInstrumentation.openConnection(new URL(replace).openConnection());
                z = true;
                try {
                    try {
                        httpURLConnection2.setDoInput(true);
                        httpURLConnection2.setUseCaches(true);
                        httpURLConnection2.addRequestProperty(HttpRequest.HEADER_ACCEPT_ENCODING, "gzip, deflate");
                        httpURLConnection2.connect();
                        try {
                        } catch (IOException e) {
                            e = e;
                        }
                    } catch (IOException e2) {
                        e = e2;
                    }
                } catch (Throwable th2) {
                    th = th2;
                    HttpURLConnection httpURLConnection3 = httpURLConnection2;
                }
            } catch (Throwable th3) {
                th = th3;
                httpURLConnection = "https://";
            }
        } catch (IOException e3) {
            e = e3;
            httpURLConnection2 = null;
        } catch (Throwable th4) {
            th = th4;
            httpURLConnection = null;
        }
        if (httpURLConnection2.getResponseCode() != 200) {
            f0.a("File not loaded completely not going forward. URL was: " + replace);
            try {
                httpURLConnection2.disconnect();
            } catch (Throwable th5) {
                f0.q("Couldn't close connection!", th5);
            }
            return null;
        }
        long contentLength = httpURLConnection2.getContentLength();
        if (httpURLConnection2.getContentEncoding() == null || !httpURLConnection2.getContentEncoding().contains("gzip")) {
            z = false;
        }
        InputStream inputStream = httpURLConnection2.getInputStream();
        byte[] bArr = new byte[PDRadioButton.FLAG_NO_TOGGLE_TO_OFF];
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        f0.n("Downloading " + replace + "....");
        long j = 0;
        while (true) {
            int read = inputStream.read(bArr);
            int i2 = -1;
            if (read == -1) {
                break;
            }
            str2 = replace;
            j += read;
            try {
                byteArrayOutputStream.write(bArr, 0, read);
                if (j > i) {
                    f0.n("Image size is larger than " + i + " bytes. Cancelling download!");
                    try {
                        httpURLConnection2.disconnect();
                        return null;
                    } catch (Throwable th6) {
                        f0.q("Couldn't close connection!", th6);
                        return null;
                    }
                }
                f0.n("Downloaded " + j + " bytes");
                replace = str2;
            } catch (IOException e4) {
                e = e4;
            }
            replace = str2;
            e.printStackTrace();
            f0.n("Couldn't download the file. URL was: " + replace);
            if (httpURLConnection2 == null) {
                try {
                    httpURLConnection2.disconnect();
                    return null;
                } catch (Throwable th7) {
                    f0.q("Couldn't close connection!", th7);
                    return null;
                }
            }
            return null;
        }
        return decodeByteArray;
        return decodeByteArray2;
    }

    public static byte[] l(String str) {
        HttpsURLConnection httpsURLConnection;
        String replace = str.replace("///", "/").replace("//", "/").replace("http:/", "http://").replace("https:/", "https://");
        HttpURLConnection httpURLConnection = null;
        try {
            try {
                httpsURLConnection = (HttpsURLConnection) URLConnectionInstrumentation.openConnection(new URL(replace).openConnection());
                try {
                    InputStream inputStream = httpsURLConnection.getInputStream();
                    byte[] bArr = new byte[8192];
                    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                    while (true) {
                        int read = inputStream.read(bArr);
                        if (read == -1) {
                            break;
                        }
                        byteArrayOutputStream.write(bArr, 0, read);
                    }
                    byte[] byteArray = byteArrayOutputStream.toByteArray();
                    try {
                        httpsURLConnection.disconnect();
                    } catch (Throwable th) {
                        f0.q("Couldn't close connection!", th);
                    }
                    return byteArray;
                } catch (IOException unused) {
                    f0.n("Error processing image bytes from url: " + replace);
                    if (httpsURLConnection != null) {
                        try {
                            httpsURLConnection.disconnect();
                        } catch (Throwable th2) {
                            f0.q("Couldn't close connection!", th2);
                        }
                    }
                    return null;
                }
            } catch (Throwable th3) {
                th = th3;
                httpURLConnection = "https://";
                if (httpURLConnection != null) {
                    try {
                        httpURLConnection.disconnect();
                    } catch (Throwable th4) {
                        f0.q("Couldn't close connection!", th4);
                    }
                }
                throw th;
            }
        } catch (IOException unused2) {
            httpsURLConnection = null;
        } catch (Throwable th5) {
            th = th5;
            if (httpURLConnection != null) {
            }
            throw th;
        }
    }

    @SuppressLint({"MissingPermission"})
    public static String m(Context context) {
        try {
            ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
            if (connectivityManager == null) {
                return "Unavailable";
            }
            NetworkInfo networkInfo = connectivityManager.getNetworkInfo(1);
            if (networkInfo != null && networkInfo.isConnected()) {
                return "WiFi";
            }
            return n(context);
        } catch (Throwable unused) {
            return "Unavailable";
        }
    }

    @SuppressLint({"MissingPermission"})
    public static String n(@NonNull Context context) {
        int networkType;
        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
        if (telephonyManager == null) {
            return "Unavailable";
        }
        if (Build.VERSION.SDK_INT >= 30) {
            if (t(context, "android.permission.READ_PHONE_STATE")) {
                try {
                    networkType = telephonyManager.getDataNetworkType();
                } catch (SecurityException e) {
                    f0.a("Security Exception caught while fetch network type" + e.getMessage());
                }
            } else {
                f0.a("READ_PHONE_STATE permission not asked by the app or not granted by the user");
            }
            networkType = 0;
        } else {
            networkType = telephonyManager.getNetworkType();
        }
        if (networkType != 20) {
            switch (networkType) {
                case 1:
                case 2:
                case 4:
                case 7:
                case 11:
                    return "2G";
                case 3:
                case 5:
                case 6:
                case 8:
                case 9:
                case 10:
                case 12:
                case 14:
                case 15:
                    return "3G";
                case 13:
                    return "4G";
                default:
                    return "Unknown";
            }
        }
        return "5G";
    }

    public static long o() {
        return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
    }

    public static Bitmap p(String str, boolean z, Context context) throws NullPointerException {
        return q(str, z, context, -1);
    }

    public static Bitmap q(String str, boolean z, Context context, int i) throws NullPointerException {
        Bitmap k;
        if (str != null && !str.equals("")) {
            if (!str.startsWith("http")) {
                str = "http://static.wizrocket.com/android/ico//" + str;
            }
            if (i == -1) {
                k = j(str);
            } else {
                k = k(str, i);
            }
            if (k != null) {
                return k;
            }
            if (!z) {
                return null;
            }
            return i(context);
        } else if (!z) {
            return null;
        } else {
            return i(context);
        }
    }

    public static int r() {
        return (int) (System.currentTimeMillis() / 1000);
    }

    public static int s(Context context, String str) {
        if (context != null) {
            return context.getResources().getIdentifier(str, "drawable", context.getPackageName());
        }
        return -1;
    }

    public static boolean t(@NonNull Context context, @NonNull String str) {
        try {
            if (androidx.core.content.a.checkSelfPermission(context, str) != 0) {
                return false;
            }
            return true;
        } catch (Throwable unused) {
            return false;
        }
    }

    public static boolean u(Activity activity) {
        if (activity == null || activity.isFinishing() || activity.isDestroyed()) {
            return true;
        }
        return false;
    }

    public static boolean v(@NonNull Context context, Class cls) {
        if (cls == null) {
            return false;
        }
        try {
            for (ServiceInfo serviceInfo : context.getPackageManager().getPackageInfo(context.getPackageName(), 4).services) {
                if (serviceInfo.name.equals(cls.getName())) {
                    f0.n("Service " + serviceInfo.name + " found");
                    return true;
                }
            }
        } catch (PackageManager.NameNotFoundException e) {
            f0.a("Intent Service name not found exception - " + e.getLocalizedMessage());
        }
        return false;
    }

    public static void w(Runnable runnable) {
        if (runnable != null) {
            if (Looper.myLooper() == Looper.getMainLooper()) {
                runnable.run();
            } else {
                new Handler(Looper.getMainLooper()).post(runnable);
            }
        }
    }

    public static void x(Context context, Intent intent) {
        List<ResolveInfo> queryIntentActivities = context.getPackageManager().queryIntentActivities(intent, 0);
        if (queryIntentActivities != null) {
            String packageName = context.getPackageName();
            for (ResolveInfo resolveInfo : queryIntentActivities) {
                if (packageName.equals(resolveInfo.activityInfo.packageName)) {
                    intent.setPackage(packageName);
                    return;
                }
            }
        }
    }

    public static Bundle y(String str) throws JSONException {
        Bundle bundle = new Bundle();
        if (!TextUtils.isEmpty(str)) {
            JSONObject jSONObject = new JSONObject(str);
            Iterator<String> keys = jSONObject.keys();
            while (keys.hasNext()) {
                String next = keys.next();
                bundle.putString(next, jSONObject.getString(next));
            }
        }
        return bundle;
    }

    public static boolean z(String str) {
        if (str == null) {
            f0.j("CLEVERTAP_USE_CUSTOM_ID has been set as 1 in AndroidManifest.xml but custom CleverTap ID passed is NULL.");
            return false;
        } else if (str.isEmpty()) {
            f0.j("CLEVERTAP_USE_CUSTOM_ID has been set as 1 in AndroidManifest.xml but custom CleverTap ID passed is empty.");
            return false;
        } else if (str.length() > 64) {
            f0.j("Custom CleverTap ID passed is greater than 64 characters. ");
            return false;
        } else if (!str.matches("[=|<>;+.A-Za-z0-9()!:$@_-]*")) {
            f0.j("Custom CleverTap ID cannot contain special characters apart from : =,(,),_,!,@,$,|<,>,;,+,. and - ");
            return false;
        } else {
            return true;
        }
    }
}