APK反编译源代码展示 - 南明离火平台提供

应用版本信息
应用名称:Gizmo
版本号:1.7.0
包名称:ai.saveall.app

MD5 校验值:51aae3247d6bd20bca268c4c9a4dd21c

反编译源代码说明

P.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。


package V1;

import E1.C0275n;
import V1.C0309n;
import V1.P;
import a2.C0325a;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.database.Cursor;
import android.hardware.display.DisplayManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Parcel;
import android.os.StatFs;
import android.telephony.TelephonyManager;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.autofill.AutofillManager;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import com.facebook.AccessToken;
import com.facebook.GraphRequest;
import java.io.BufferedInputStream;
import java.io.Closeable;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.math.BigInteger;
import java.net.HttpURLConnection;
import java.net.URLConnection;
import java.net.URLDecoder;
import java.nio.charset.Charset;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.TimeZone;
import java.util.regex.Pattern;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.Regex;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;

public final class P {

    private static int f3637b;

    public static final P f3636a = new P();

    private static long f3638c = -1;

    private static long f3639d = -1;

    private static long f3640e = -1;

    private static String f3641f = "";

    private static String f3642g = "";

    private static String f3643h = "NoCarrier";

    public interface a {
        void a(JSONObject jSONObject);

        void b(C0275n c0275n);
    }

    private P() {
    }

    public static final JSONObject A() {
        if (C0325a.d(P.class)) {
            return null;
        }
        try {
            String string = E1.z.l().getSharedPreferences("com.facebook.sdk.DataProcessingOptions", 0).getString("data_processing_options", null);
            if (string != null) {
                try {
                    return new JSONObject(string);
                } catch (JSONException unused) {
                }
            }
            return null;
        } catch (Throwable th) {
            C0325a.b(th, P.class);
            return null;
        }
    }

    public static final String A0(String str) {
        if (str == null) {
            return null;
        }
        return f3636a.M("SHA-256", str);
    }

    public static final String B(String str) {
        int i5;
        Object obj;
        String str2;
        String str3;
        String u5 = E1.z.u();
        if (str == null) {
            return u5;
        }
        if (Intrinsics.a(str, "gaming")) {
            i5 = 4;
            obj = null;
            str2 = "facebook.com";
            str3 = "fb.gg";
        } else if (Intrinsics.a(str, "instagram")) {
            i5 = 4;
            obj = null;
            str2 = "facebook.com";
            str3 = "instagram.com";
        } else {
            return u5;
        }
        return kotlin.text.g.q(u5, str2, str3, false, i5, obj);
    }

    public static final void B0(Parcel parcel, Map map) {
        Intrinsics.checkNotNullParameter(parcel, "parcel");
        if (map == null) {
            parcel.writeInt(-1);
            return;
        }
        parcel.writeInt(map.size());
        for (Map.Entry entry : map.entrySet()) {
            String str = (String) entry.getKey();
            String str2 = (String) entry.getValue();
            parcel.writeString(str);
            parcel.writeString(str2);
        }
    }

    private final GraphRequest C(String str) {
        Bundle bundle = new Bundle();
        bundle.putString("fields", I(z()));
        bundle.putString("access_token", str);
        GraphRequest y5 = GraphRequest.f10649n.y(null, null);
        y5.I(bundle);
        y5.H(E1.I.GET);
        return y5;
    }

    public static final void C0(Parcel parcel, Map map) {
        Intrinsics.checkNotNullParameter(parcel, "parcel");
        if (map == null) {
            parcel.writeInt(-1);
            return;
        }
        parcel.writeInt(map.size());
        for (Map.Entry entry : map.entrySet()) {
            String str = (String) entry.getKey();
            String str2 = (String) entry.getValue();
            parcel.writeString(str);
            parcel.writeString(str2);
        }
    }

    public static final void D(final String accessToken, final a callback) {
        Intrinsics.checkNotNullParameter(accessToken, "accessToken");
        Intrinsics.checkNotNullParameter(callback, "callback");
        JSONObject a5 = G.a(accessToken);
        if (a5 != null) {
            callback.a(a5);
            return;
        }
        GraphRequest.b bVar = new GraphRequest.b() {
            @Override
            public final void a(E1.H h5) {
                P.E(P.a.this, accessToken, h5);
            }
        };
        GraphRequest C5 = f3636a.C(accessToken);
        C5.E(bVar);
        C5.l();
    }

    public static final void E(a callback, String accessToken, E1.H response) {
        Intrinsics.checkNotNullParameter(callback, "$callback");
        Intrinsics.checkNotNullParameter(accessToken, "$accessToken");
        Intrinsics.checkNotNullParameter(response, "response");
        if (response.b() != null) {
            callback.b(response.b().g());
            return;
        }
        G g5 = G.f3623a;
        JSONObject d5 = response.d();
        if (d5 != null) {
            G.b(accessToken, d5);
            callback.a(response.d());
            return;
        }
        throw new IllegalStateException("Required value was null.".toString());
    }

    public static final String F(Context context) {
        Q.j(context, "context");
        return E1.z.m();
    }

    public static final Method G(Class clazz, String methodName, Class... parameterTypes) {
        Intrinsics.checkNotNullParameter(clazz, "clazz");
        Intrinsics.checkNotNullParameter(methodName, "methodName");
        Intrinsics.checkNotNullParameter(parameterTypes, "parameterTypes");
        try {
            return clazz.getMethod(methodName, (Class[]) Arrays.copyOf(parameterTypes, parameterTypes.length));
        } catch (NoSuchMethodException unused) {
            return null;
        }
    }

    public static final Method H(String className, String methodName, Class... parameterTypes) {
        Intrinsics.checkNotNullParameter(className, "className");
        Intrinsics.checkNotNullParameter(methodName, "methodName");
        Intrinsics.checkNotNullParameter(parameterTypes, "parameterTypes");
        try {
            Class<?> clazz = Class.forName(className);
            Intrinsics.checkNotNullExpressionValue(clazz, "clazz");
            return G(clazz, methodName, (Class[]) Arrays.copyOf(parameterTypes, parameterTypes.length));
        } catch (ClassNotFoundException unused) {
            return null;
        }
    }

    private final String I(String str) {
        if (Intrinsics.a(str, "instagram")) {
            return "id,name,profile_picture";
        }
        return "id,name,first_name,middle_name,last_name";
    }

    public static final Locale J() {
        try {
            return E1.z.l().getResources().getConfiguration().locale;
        } catch (Exception unused) {
            return null;
        }
    }

    public static final Object K(JSONObject jsonObject, String str, String str2) {
        Intrinsics.checkNotNullParameter(jsonObject, "jsonObject");
        Object opt = jsonObject.opt(str);
        if (opt != null && (opt instanceof String)) {
            opt = new JSONTokener((String) opt).nextValue();
        }
        if (opt != null && !(opt instanceof JSONObject) && !(opt instanceof JSONArray)) {
            if (str2 != null) {
                JSONObject jSONObject = new JSONObject();
                jSONObject.putOpt(str2, opt);
                return jSONObject;
            }
            throw new C0275n("Got an unexpected non-JSON object.");
        }
        return opt;
    }

    private final String L(MessageDigest messageDigest, byte[] bArr) {
        messageDigest.update(bArr);
        byte[] digest = messageDigest.digest();
        StringBuilder sb = new StringBuilder();
        Intrinsics.checkNotNullExpressionValue(digest, "digest");
        int length = digest.length;
        int i5 = 0;
        while (i5 < length) {
            byte b5 = digest[i5];
            i5++;
            sb.append(Integer.toHexString((b5 >> 4) & 15));
            sb.append(Integer.toHexString(b5 & 15));
        }
        String sb2 = sb.toString();
        Intrinsics.checkNotNullExpressionValue(sb2, "builder.toString()");
        return sb2;
    }

    private final String M(String str, String str2) {
        Charset charset = kotlin.text.b.f15693b;
        if (str2 != null) {
            byte[] bytes = str2.getBytes(charset);
            Intrinsics.checkNotNullExpressionValue(bytes, "(this as java.lang.String).getBytes(charset)");
            return N(str, bytes);
        }
        throw new NullPointerException("null cannot be cast to non-null type java.lang.String");
    }

    private final String N(String str, byte[] bArr) {
        try {
            MessageDigest hash = MessageDigest.getInstance(str);
            Intrinsics.checkNotNullExpressionValue(hash, "hash");
            return L(hash, bArr);
        } catch (NoSuchAlgorithmException unused) {
            return null;
        }
    }

    public static final Object O(Object obj, Method method, Object... args) {
        Intrinsics.checkNotNullParameter(method, "method");
        Intrinsics.checkNotNullParameter(args, "args");
        try {
            return method.invoke(obj, Arrays.copyOf(args, args.length));
        } catch (IllegalAccessException | InvocationTargetException unused) {
            return null;
        }
    }

    public static final boolean P() {
        try {
            Intent intent = new Intent("android.intent.action.VIEW");
            kotlin.jvm.internal.y yVar = kotlin.jvm.internal.y.f15635a;
            String format = String.format("fb%s://applinks", Arrays.copyOf(new Object[]{E1.z.m()}, 1));
            Intrinsics.checkNotNullExpressionValue(format, "java.lang.String.format(format, *args)");
            intent.setData(Uri.parse(format));
            Context l5 = E1.z.l();
            PackageManager packageManager = l5.getPackageManager();
            String packageName = l5.getPackageName();
            List<ResolveInfo> queryIntentActivities = packageManager.queryIntentActivities(intent, 65536);
            Intrinsics.checkNotNullExpressionValue(queryIntentActivities, "packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY)");
            Iterator<ResolveInfo> it = queryIntentActivities.iterator();
            while (it.hasNext()) {
                if (Intrinsics.a(packageName, it.next().activityInfo.packageName)) {
                    return true;
                }
            }
        } catch (Exception unused) {
        }
        return false;
    }

    public static final boolean Q(Context context) {
        AutofillManager a5;
        boolean isAutofillSupported;
        boolean isEnabled;
        Intrinsics.checkNotNullParameter(context, "context");
        if (Build.VERSION.SDK_INT >= 26 && (a5 = K.a(context.getSystemService(J.a()))) != null) {
            isAutofillSupported = a5.isAutofillSupported();
            if (isAutofillSupported) {
                isEnabled = a5.isEnabled();
                if (!isEnabled) {
                    return false;
                }
                return true;
            }
            return false;
        }
        return false;
    }

    public static final boolean R(Context context) {
        Intrinsics.checkNotNullParameter(context, "context");
        if (Build.VERSION.SDK_INT >= 27) {
            return context.getPackageManager().hasSystemFeature("android.hardware.type.pc");
        }
        String DEVICE = Build.DEVICE;
        if (DEVICE != null) {
            Intrinsics.checkNotNullExpressionValue(DEVICE, "DEVICE");
            if (new Regex(".+_cheets|cheets_.+").c(DEVICE)) {
                return true;
            }
        }
        return false;
    }

    public static final boolean S(Uri uri) {
        if (uri != null && kotlin.text.g.l("content", uri.getScheme(), true)) {
            return true;
        }
        return false;
    }

    public static final boolean T(AccessToken accessToken) {
        if (accessToken != null && Intrinsics.a(accessToken, AccessToken.f10554r.e())) {
            return true;
        }
        return false;
    }

    public static final boolean U() {
        if (C0325a.d(P.class)) {
            return false;
        }
        try {
            JSONObject A5 = A();
            if (A5 == null) {
                return false;
            }
            try {
                JSONArray jSONArray = A5.getJSONArray("data_processing_options");
                int length = jSONArray.length();
                if (length > 0) {
                    int i5 = 0;
                    while (true) {
                        int i6 = i5 + 1;
                        String string = jSONArray.getString(i5);
                        Intrinsics.checkNotNullExpressionValue(string, "options.getString(i)");
                        String lowerCase = string.toLowerCase();
                        Intrinsics.checkNotNullExpressionValue(lowerCase, "(this as java.lang.String).toLowerCase()");
                        if (Intrinsics.a(lowerCase, "ldu")) {
                            return true;
                        }
                        if (i6 >= length) {
                            break;
                        }
                        i5 = i6;
                    }
                }
            } catch (Exception unused) {
            }
            return false;
        } catch (Throwable th) {
            C0325a.b(th, P.class);
            return false;
        }
    }

    public static final boolean V(Uri uri) {
        if (uri != null && kotlin.text.g.l("file", uri.getScheme(), true)) {
            return true;
        }
        return false;
    }

    private final boolean W(Context context) {
        Method H5 = H("com.google.android.gms.common.GooglePlayServicesUtil", "isGooglePlayServicesAvailable", Context.class);
        if (H5 == null) {
            return false;
        }
        Object O5 = O(null, H5, context);
        if ((O5 instanceof Integer) && Intrinsics.a(O5, 0)) {
            return true;
        }
        return false;
    }

    public static final boolean X(String str) {
        if (str != null && str.length() != 0) {
            return false;
        }
        return true;
    }

    public static final boolean Y(Collection collection) {
        if (collection != null && !collection.isEmpty()) {
            return false;
        }
        return true;
    }

    public static final boolean Z(Uri uri) {
        if (uri != null && (kotlin.text.g.l("http", uri.getScheme(), true) || kotlin.text.g.l("https", uri.getScheme(), true) || kotlin.text.g.l("fbstaging", uri.getScheme(), true))) {
            return true;
        }
        return false;
    }

    public static final Set a0(JSONArray jsonArray) {
        Intrinsics.checkNotNullParameter(jsonArray, "jsonArray");
        HashSet hashSet = new HashSet();
        int length = jsonArray.length();
        if (length > 0) {
            int i5 = 0;
            while (true) {
                int i6 = i5 + 1;
                String string = jsonArray.getString(i5);
                Intrinsics.checkNotNullExpressionValue(string, "jsonArray.getString(i)");
                hashSet.add(string);
                if (i6 >= length) {
                    break;
                }
                i5 = i6;
            }
        }
        return hashSet;
    }

    public static final List b0(JSONArray jsonArray) {
        Intrinsics.checkNotNullParameter(jsonArray, "jsonArray");
        ArrayList arrayList = new ArrayList();
        int length = jsonArray.length();
        if (length > 0) {
            int i5 = 0;
            while (true) {
                int i6 = i5 + 1;
                arrayList.add(jsonArray.getString(i5));
                if (i6 >= length) {
                    break;
                }
                i5 = i6;
            }
        }
        return arrayList;
    }

    private final void c(JSONObject jSONObject, C0296a c0296a, String str, Context context) {
        if (Build.VERSION.SDK_INT < 31 || !W(context) || !c0296a.l()) {
            jSONObject.put("anon_id", str);
        }
    }

    public static final Map c0(String str) {
        Intrinsics.checkNotNullParameter(str, "str");
        if (str.length() == 0) {
            return new HashMap();
        }
        try {
            HashMap hashMap = new HashMap();
            JSONObject jSONObject = new JSONObject(str);
            Iterator<String> keys = jSONObject.keys();
            while (keys.hasNext()) {
                String key = keys.next();
                Intrinsics.checkNotNullExpressionValue(key, "key");
                String string = jSONObject.getString(key);
                Intrinsics.checkNotNullExpressionValue(string, "jsonObject.getString(key)");
                hashMap.put(key, string);
            }
            return hashMap;
        } catch (JSONException unused) {
            return new HashMap();
        }
    }

    private final void d(JSONObject jSONObject, C0296a c0296a, Context context) {
        if (Build.VERSION.SDK_INT < 31 || !W(context) || !c0296a.l()) {
            jSONObject.put("attribution", c0296a.j());
        }
    }

    public static final void d0(String str, Exception exc) {
        if (E1.z.D() && str != null && exc != null) {
            Log.d(str, exc.getClass().getSimpleName() + ": " + ((Object) exc.getMessage()));
        }
    }

    public static final boolean e(Object obj, Object obj2) {
        if (obj == null) {
            if (obj2 == null) {
                return true;
            }
            return false;
        }
        return Intrinsics.a(obj, obj2);
    }

    public static final void e0(String str, String str2) {
        if (E1.z.D() && str != null && str2 != null) {
            Log.d(str, str2);
        }
    }

    public static final JSONObject f(String accessToken) {
        Intrinsics.checkNotNullParameter(accessToken, "accessToken");
        JSONObject a5 = G.a(accessToken);
        if (a5 != null) {
            return a5;
        }
        E1.H k5 = f3636a.C(accessToken).k();
        if (k5.b() != null) {
            return null;
        }
        return k5.d();
    }

    public static final void f0(String str, String str2, Throwable th) {
        if (E1.z.D() && !X(str)) {
            Log.d(str, str2, th);
        }
    }

    public static final Uri g(String str, String str2, Bundle bundle) {
        Uri.Builder builder = new Uri.Builder();
        builder.scheme("https");
        builder.authority(str);
        builder.path(str2);
        if (bundle != null) {
            for (String str3 : bundle.keySet()) {
                Object obj = bundle.get(str3);
                if (obj instanceof String) {
                    builder.appendQueryParameter(str3, (String) obj);
                }
            }
        }
        Uri build = builder.build();
        Intrinsics.checkNotNullExpressionValue(build, "builder.build()");
        return build;
    }

    public static final String g0(Map map) {
        Intrinsics.checkNotNullParameter(map, "map");
        String str = "";
        if (!map.isEmpty()) {
            try {
                JSONObject jSONObject = new JSONObject();
                for (Map.Entry entry : map.entrySet()) {
                    jSONObject.put((String) entry.getKey(), (String) entry.getValue());
                }
                str = jSONObject.toString();
            } catch (JSONException unused) {
            }
            Intrinsics.checkNotNullExpressionValue(str, "{\n      try {\n        val jsonObject = JSONObject()\n        for ((key, value) in map) {\n          jsonObject.put(key, value)\n        }\n        jsonObject.toString()\n      } catch (_e: JSONException) {\n        \"\"\n      }\n    }");
        }
        return str;
    }

    private final void h(Context context, String str) {
        int i5;
        boolean z5;
        CookieSyncManager.createInstance(context).sync();
        CookieManager cookieManager = CookieManager.getInstance();
        String cookie = cookieManager.getCookie(str);
        if (cookie == null) {
            return;
        }
        Object[] array = kotlin.text.g.T(cookie, new String[]{";"}, false, 0, 6, null).toArray(new String[0]);
        if (array != null) {
            String[] strArr = (String[]) array;
            int length = strArr.length;
            int i6 = 0;
            while (i6 < length) {
                String str2 = strArr[i6];
                i6++;
                Object[] array2 = kotlin.text.g.T(str2, new String[]{"="}, false, 0, 6, null).toArray(new String[0]);
                if (array2 != null) {
                    String[] strArr2 = (String[]) array2;
                    if (strArr2.length > 0) {
                        String str3 = strArr2[0];
                        int length2 = str3.length() - 1;
                        int i7 = 0;
                        boolean z6 = false;
                        while (i7 <= length2) {
                            if (!z6) {
                                i5 = i7;
                            } else {
                                i5 = length2;
                            }
                            if (Intrinsics.d(str3.charAt(i5), 32) <= 0) {
                                z5 = true;
                            } else {
                                z5 = false;
                            }
                            if (!z6) {
                                if (!z5) {
                                    z6 = true;
                                } else {
                                    i7++;
                                }
                            } else if (!z5) {
                                break;
                            } else {
                                length2--;
                            }
                        }
                        cookieManager.setCookie(str, Intrinsics.i(str3.subSequence(i7, length2 + 1).toString(), "=;expires=Sat, 1 Jan 2000 00:00:01 UTC;"));
                    }
                } else {
                    throw new NullPointerException("null cannot be cast to non-null type kotlin.Array<T>");
                }
            }
            cookieManager.removeExpiredCookie();
            return;
        }
        throw new NullPointerException("null cannot be cast to non-null type kotlin.Array<T>");
    }

    public static final String h0(String key) {
        Intrinsics.checkNotNullParameter(key, "key");
        return f3636a.M("MD5", key);
    }

    public static final void i(Context context) {
        Intrinsics.checkNotNullParameter(context, "context");
        try {
            P p5 = f3636a;
            p5.h(context, "facebook.com");
            p5.h(context, ".facebook.com");
            p5.h(context, "https://facebook.com");
            p5.h(context, "https://.facebook.com");
        } catch (Exception unused) {
        }
    }

    public static final boolean i0(Context context) {
        Intrinsics.checkNotNullParameter(context, "context");
        return Q(context);
    }

    public static final void j(Closeable closeable) {
        if (closeable != null) {
            try {
                closeable.close();
            } catch (IOException unused) {
            }
        }
    }

    public static final Bundle j0(String str) {
        Bundle bundle = new Bundle();
        if (!X(str)) {
            if (str != null) {
                Object[] array = kotlin.text.g.T(str, new String[]{"&"}, false, 0, 6, null).toArray(new String[0]);
                if (array != null) {
                    String[] strArr = (String[]) array;
                    int length = strArr.length;
                    int i5 = 0;
                    while (i5 < length) {
                        String str2 = strArr[i5];
                        i5++;
                        Object[] array2 = kotlin.text.g.T(str2, new String[]{"="}, false, 0, 6, null).toArray(new String[0]);
                        if (array2 != null) {
                            String[] strArr2 = (String[]) array2;
                            try {
                                if (strArr2.length == 2) {
                                    bundle.putString(URLDecoder.decode(strArr2[0], "UTF-8"), URLDecoder.decode(strArr2[1], "UTF-8"));
                                } else if (strArr2.length == 1) {
                                    bundle.putString(URLDecoder.decode(strArr2[0], "UTF-8"), "");
                                }
                            } catch (UnsupportedEncodingException e5) {
                                d0("FacebookSDK", e5);
                            }
                        } else {
                            throw new NullPointerException("null cannot be cast to non-null type kotlin.Array<T>");
                        }
                    }
                } else {
                    throw new NullPointerException("null cannot be cast to non-null type kotlin.Array<T>");
                }
            } else {
                throw new IllegalStateException("Required value was null.".toString());
            }
        }
        return bundle;
    }

    public static final String k(String str, String str2) {
        if (X(str)) {
            return str2;
        }
        return str;
    }

    public static final boolean k0(Bundle bundle, String str, Object obj) {
        String jSONObject;
        Intrinsics.checkNotNullParameter(bundle, "bundle");
        if (obj == null) {
            bundle.remove(str);
            return true;
        }
        if (obj instanceof Boolean) {
            bundle.putBoolean(str, ((Boolean) obj).booleanValue());
            return true;
        }
        if (obj instanceof boolean[]) {
            bundle.putBooleanArray(str, (boolean[]) obj);
            return true;
        }
        if (obj instanceof Double) {
            bundle.putDouble(str, ((Number) obj).doubleValue());
            return true;
        }
        if (obj instanceof double[]) {
            bundle.putDoubleArray(str, (double[]) obj);
            return true;
        }
        if (obj instanceof Integer) {
            bundle.putInt(str, ((Number) obj).intValue());
            return true;
        }
        if (obj instanceof int[]) {
            bundle.putIntArray(str, (int[]) obj);
            return true;
        }
        if (obj instanceof Long) {
            bundle.putLong(str, ((Number) obj).longValue());
            return true;
        }
        if (obj instanceof long[]) {
            bundle.putLongArray(str, (long[]) obj);
            return true;
        }
        if (obj instanceof String) {
            jSONObject = (String) obj;
        } else if (obj instanceof JSONArray) {
            jSONObject = ((JSONArray) obj).toString();
        } else if (obj instanceof JSONObject) {
            jSONObject = ((JSONObject) obj).toString();
        } else {
            return false;
        }
        bundle.putString(str, jSONObject);
        return true;
    }

    private final long l(double d5) {
        return Math.round(d5 / 1.073741824E9d);
    }

    public static final void l0(Bundle b5, String str, String str2) {
        Intrinsics.checkNotNullParameter(b5, "b");
        if (!X(str2)) {
            b5.putString(str, str2);
        }
    }

    public static final List m(JSONArray jsonArray) {
        Intrinsics.checkNotNullParameter(jsonArray, "jsonArray");
        try {
            ArrayList arrayList = new ArrayList();
            int length = jsonArray.length();
            if (length > 0) {
                int i5 = 0;
                while (true) {
                    int i6 = i5 + 1;
                    String string = jsonArray.getString(i5);
                    Intrinsics.checkNotNullExpressionValue(string, "jsonArray.getString(i)");
                    arrayList.add(string);
                    if (i6 < length) {
                        i5 = i6;
                    } else {
                        return arrayList;
                    }
                }
            } else {
                return arrayList;
            }
        } catch (JSONException unused) {
            return new ArrayList();
        }
    }

    public static final Map m0(Parcel parcel) {
        Intrinsics.checkNotNullParameter(parcel, "parcel");
        int readInt = parcel.readInt();
        if (readInt < 0) {
            return null;
        }
        HashMap hashMap = new HashMap();
        if (readInt > 0) {
            int i5 = 0;
            do {
                i5++;
                String readString = parcel.readString();
                String readString2 = parcel.readString();
                if (readString != null && readString2 != null) {
                    hashMap.put(readString, readString2);
                }
            } while (i5 < readInt);
        }
        return hashMap;
    }

    public static final Map n(JSONObject jsonObject) {
        Intrinsics.checkNotNullParameter(jsonObject, "jsonObject");
        HashMap hashMap = new HashMap();
        JSONArray names = jsonObject.names();
        if (names == null) {
            return hashMap;
        }
        int length = names.length();
        if (length > 0) {
            int i5 = 0;
            while (true) {
                int i6 = i5 + 1;
                try {
                    String string = names.getString(i5);
                    Intrinsics.checkNotNullExpressionValue(string, "keys.getString(i)");
                    Object value = jsonObject.get(string);
                    if (value instanceof JSONObject) {
                        value = n((JSONObject) value);
                    }
                    Intrinsics.checkNotNullExpressionValue(value, "value");
                    hashMap.put(string, value);
                } catch (JSONException unused) {
                }
                if (i6 >= length) {
                    break;
                }
                i5 = i6;
            }
        }
        return hashMap;
    }

    public static final String n0(InputStream inputStream) {
        BufferedInputStream bufferedInputStream;
        Throwable th;
        InputStreamReader inputStreamReader;
        try {
            bufferedInputStream = new BufferedInputStream(inputStream);
            try {
                inputStreamReader = new InputStreamReader(bufferedInputStream);
                try {
                    StringBuilder sb = new StringBuilder();
                    char[] cArr = new char[2048];
                    while (true) {
                        int read = inputStreamReader.read(cArr);
                        if (read != -1) {
                            sb.append(cArr, 0, read);
                        } else {
                            String sb2 = sb.toString();
                            Intrinsics.checkNotNullExpressionValue(sb2, "{\n      bufferedInputStream = BufferedInputStream(inputStream)\n      reader = InputStreamReader(bufferedInputStream)\n      val stringBuilder = StringBuilder()\n      val bufferSize = 1024 * 2\n      val buffer = CharArray(bufferSize)\n      var n = 0\n      while (reader.read(buffer).also { n = it } != -1) {\n        stringBuilder.append(buffer, 0, n)\n      }\n      stringBuilder.toString()\n    }");
                            j(bufferedInputStream);
                            j(inputStreamReader);
                            return sb2;
                        }
                    }
                } catch (Throwable th2) {
                    th = th2;
                    j(bufferedInputStream);
                    j(inputStreamReader);
                    throw th;
                }
            } catch (Throwable th3) {
                th = th3;
                inputStreamReader = null;
            }
        } catch (Throwable th4) {
            bufferedInputStream = null;
            th = th4;
            inputStreamReader = null;
        }
    }

    public static final Map o(JSONObject jsonObject) {
        Intrinsics.checkNotNullParameter(jsonObject, "jsonObject");
        HashMap hashMap = new HashMap();
        Iterator<String> keys = jsonObject.keys();
        while (keys.hasNext()) {
            String key = keys.next();
            String optString = jsonObject.optString(key);
            if (optString != null) {
                Intrinsics.checkNotNullExpressionValue(key, "key");
                hashMap.put(key, optString);
            }
        }
        return hashMap;
    }

    public static final Map o0(Parcel parcel) {
        Intrinsics.checkNotNullParameter(parcel, "parcel");
        int readInt = parcel.readInt();
        if (readInt < 0) {
            return null;
        }
        HashMap hashMap = new HashMap();
        if (readInt > 0) {
            int i5 = 0;
            do {
                i5++;
                hashMap.put(parcel.readString(), parcel.readString());
            } while (i5 < readInt);
        }
        return hashMap;
    }

    public static final int p(InputStream inputStream, OutputStream outputStream) {
        BufferedInputStream bufferedInputStream;
        Intrinsics.checkNotNullParameter(outputStream, "outputStream");
        BufferedInputStream bufferedInputStream2 = null;
        try {
            bufferedInputStream = new BufferedInputStream(inputStream);
        } catch (Throwable th) {
            th = th;
        }
        try {
            byte[] bArr = new byte[8192];
            int i5 = 0;
            while (true) {
                int read = bufferedInputStream.read(bArr);
                if (read == -1) {
                    break;
                }
                outputStream.write(bArr, 0, read);
                i5 += read;
            }
            bufferedInputStream.close();
            if (inputStream != null) {
                inputStream.close();
            }
            return i5;
        } catch (Throwable th2) {
            th = th2;
            bufferedInputStream2 = bufferedInputStream;
            if (bufferedInputStream2 != null) {
                bufferedInputStream2.close();
            }
            if (inputStream != null) {
                inputStream.close();
            }
            throw th;
        }
    }

    private final void p0() {
        try {
            if (r()) {
                StatFs statFs = new StatFs(Environment.getExternalStorageDirectory().getPath());
                f3640e = statFs.getAvailableBlocks() * statFs.getBlockSize();
            }
            f3640e = l(f3640e);
        } catch (Exception unused) {
        }
    }

    public static final void q(URLConnection uRLConnection) {
        if (uRLConnection != null && (uRLConnection instanceof HttpURLConnection)) {
            ((HttpURLConnection) uRLConnection).disconnect();
        }
    }

    private final int q0() {
        int i5 = f3637b;
        if (i5 > 0) {
            return i5;
        }
        try {
            File[] listFiles = new File("/sys/devices/system/cpu/").listFiles(new FilenameFilter() {
                @Override
                public final boolean accept(File file, String str) {
                    boolean r02;
                    r02 = P.r0(file, str);
                    return r02;
                }
            });
            if (listFiles != null) {
                f3637b = listFiles.length;
            }
        } catch (Exception unused) {
        }
        if (f3637b <= 0) {
            f3637b = Math.max(Runtime.getRuntime().availableProcessors(), 1);
        }
        return f3637b;
    }

    private final boolean r() {
        return Intrinsics.a("mounted", Environment.getExternalStorageState());
    }

    public static final boolean r0(File file, String str) {
        return Pattern.matches("cpu[0-9]+", str);
    }

    public static final String s(int i5) {
        String bigInteger = new BigInteger(i5 * 5, new Random()).toString(32);
        Intrinsics.checkNotNullExpressionValue(bigInteger, "BigInteger(length * 5, r).toString(32)");
        return bigInteger;
    }

    private final void s0(Context context) {
        if (Intrinsics.a(f3643h, "NoCarrier")) {
            try {
                Object systemService = context.getSystemService("phone");
                if (systemService != null) {
                    String networkOperatorName = ((TelephonyManager) systemService).getNetworkOperatorName();
                    Intrinsics.checkNotNullExpressionValue(networkOperatorName, "telephonyManager.networkOperatorName");
                    f3643h = networkOperatorName;
                    return;
                }
                throw new NullPointerException("null cannot be cast to non-null type android.telephony.TelephonyManager");
            } catch (Exception unused) {
            }
        }
    }

    public static final String t(Context context) {
        if (context == null) {
            return "null";
        }
        if (context == context.getApplicationContext()) {
            return "unknown";
        }
        String simpleName = context.getClass().getSimpleName();
        Intrinsics.checkNotNullExpressionValue(simpleName, "{\n      context.javaClass.simpleName\n    }");
        return simpleName;
    }

    private final void t0(Context context) {
        if (f3638c == -1 || System.currentTimeMillis() - f3638c >= 1800000) {
            f3638c = System.currentTimeMillis();
            u0();
            s0(context);
            v0();
            p0();
        }
    }

    public static final String u(Context context) {
        String string;
        Intrinsics.checkNotNullParameter(context, "context");
        try {
            String n5 = E1.z.n();
            if (n5 != null) {
                return n5;
            }
            ApplicationInfo applicationInfo = context.getApplicationInfo();
            int i5 = applicationInfo.labelRes;
            if (i5 == 0) {
                string = applicationInfo.nonLocalizedLabel.toString();
            } else {
                string = context.getString(i5);
                Intrinsics.checkNotNullExpressionValue(string, "context.getString(stringId)");
            }
            return string;
        } catch (Exception unused) {
            return "";
        }
    }

    private final void u0() {
        try {
            TimeZone timeZone = TimeZone.getDefault();
            String displayName = timeZone.getDisplayName(timeZone.inDaylightTime(new Date()), 0);
            Intrinsics.checkNotNullExpressionValue(displayName, "tz.getDisplayName(tz.inDaylightTime(Date()), TimeZone.SHORT)");
            f3641f = displayName;
            String id = timeZone.getID();
            Intrinsics.checkNotNullExpressionValue(id, "tz.id");
            f3642g = id;
        } catch (AssertionError | Exception unused) {
        }
    }

    public static final String v() {
        Context l5 = E1.z.l();
        if (l5 == null) {
            return null;
        }
        try {
            PackageInfo packageInfo = l5.getPackageManager().getPackageInfo(l5.getPackageName(), 0);
            if (packageInfo == null) {
                return null;
            }
            return packageInfo.versionName;
        } catch (PackageManager.NameNotFoundException unused) {
            return null;
        }
    }

    private final void v0() {
        try {
            if (r()) {
                StatFs statFs = new StatFs(Environment.getExternalStorageDirectory().getPath());
                f3639d = statFs.getBlockCount() * statFs.getBlockSize();
            }
            f3639d = l(f3639d);
        } catch (Exception unused) {
        }
    }

    public static final Date w(Bundle bundle, String str, Date dateBase) {
        long parseLong;
        Intrinsics.checkNotNullParameter(dateBase, "dateBase");
        if (bundle == null) {
            return null;
        }
        Object obj = bundle.get(str);
        if (obj instanceof Long) {
            parseLong = ((Number) obj).longValue();
        } else {
            if (obj instanceof String) {
                try {
                    parseLong = Long.parseLong((String) obj);
                } catch (NumberFormatException unused) {
                }
            }
            return null;
        }
        if (parseLong == 0) {
            return new Date(Long.MAX_VALUE);
        }
        return new Date(dateBase.getTime() + (parseLong * 1000));
    }

    public static final void w0(Runnable runnable) {
        try {
            E1.z.t().execute(runnable);
        } catch (Exception unused) {
        }
    }

    public static final long x(Uri contentUri) {
        Intrinsics.checkNotNullParameter(contentUri, "contentUri");
        Cursor cursor = null;
        try {
            cursor = E1.z.l().getContentResolver().query(contentUri, null, null, null, null);
            if (cursor == null) {
                return 0L;
            }
            int columnIndex = cursor.getColumnIndex("_size");
            cursor.moveToFirst();
            long j5 = cursor.getLong(columnIndex);
            cursor.close();
            return j5;
        } catch (Throwable th) {
            if (cursor != null) {
                cursor.close();
            }
            throw th;
        }
    }

    public static final void x0(JSONObject params, C0296a c0296a, String str, boolean z5, Context context) {
        Intrinsics.checkNotNullParameter(params, "params");
        Intrinsics.checkNotNullParameter(context, "context");
        C0309n c0309n = C0309n.f3743a;
        C0309n.b bVar = C0309n.b.ServiceUpdateCompliance;
        if (!C0309n.g(bVar)) {
            params.put("anon_id", str);
        }
        params.put("application_tracking_enabled", !z5);
        params.put("advertiser_id_collection_enabled", E1.z.k());
        if (c0296a != null) {
            if (C0309n.g(bVar)) {
                f3636a.c(params, c0296a, str, context);
            }
            if (c0296a.j() != null) {
                if (C0309n.g(bVar)) {
                    f3636a.d(params, c0296a, context);
                } else {
                    params.put("attribution", c0296a.j());
                }
            }
            if (c0296a.h() != null) {
                params.put("advertiser_id", c0296a.h());
                params.put("advertiser_tracking_enabled", !c0296a.l());
            }
            if (!c0296a.l()) {
                String b5 = F1.G.b();
                if (b5.length() != 0) {
                    params.put("ud", b5);
                }
            }
            if (c0296a.i() != null) {
                params.put("installer_package", c0296a.i());
            }
        }
    }

    public static final Locale y() {
        Locale J5 = J();
        if (J5 == null) {
            Locale locale = Locale.getDefault();
            Intrinsics.checkNotNullExpressionValue(locale, "getDefault()");
            return locale;
        }
        return J5;
    }

    public static final void y0(JSONObject params, Context appContext) {
        String str;
        Locale locale;
        int i5;
        Display display;
        DisplayManager displayManager;
        PackageInfo packageInfo;
        Intrinsics.checkNotNullParameter(params, "params");
        Intrinsics.checkNotNullParameter(appContext, "appContext");
        JSONArray jSONArray = new JSONArray();
        jSONArray.put("a2");
        f3636a.t0(appContext);
        String packageName = appContext.getPackageName();
        int i6 = 0;
        int i7 = -1;
        try {
            packageInfo = appContext.getPackageManager().getPackageInfo(packageName, 0);
        } catch (PackageManager.NameNotFoundException unused) {
            str = "";
        }
        if (packageInfo == null) {
            return;
        }
        i7 = packageInfo.versionCode;
        str = packageInfo.versionName;
        jSONArray.put(packageName);
        jSONArray.put(i7);
        jSONArray.put(str);
        jSONArray.put(Build.VERSION.RELEASE);
        jSONArray.put(Build.MODEL);
        try {
            locale = appContext.getResources().getConfiguration().locale;
        } catch (Exception unused2) {
            locale = Locale.getDefault();
        }
        jSONArray.put(locale.getLanguage() + '_' + ((Object) locale.getCountry()));
        jSONArray.put(f3641f);
        jSONArray.put(f3643h);
        double d5 = 0.0d;
        try {
            Object systemService = appContext.getSystemService("display");
            display = null;
            if (systemService instanceof DisplayManager) {
                displayManager = (DisplayManager) systemService;
            } else {
                displayManager = null;
            }
            if (displayManager != null) {
                display = displayManager.getDisplay(0);
            }
        } catch (Exception unused3) {
        }
        if (display != null) {
            DisplayMetrics displayMetrics = new DisplayMetrics();
            display.getMetrics(displayMetrics);
            int i8 = displayMetrics.widthPixels;
            try {
                i6 = displayMetrics.heightPixels;
                d5 = displayMetrics.density;
            } catch (Exception unused4) {
            }
            i5 = i6;
            i6 = i8;
            jSONArray.put(i6);
            jSONArray.put(i5);
            jSONArray.put(new DecimalFormat("#.##").format(d5));
            jSONArray.put(f3636a.q0());
            jSONArray.put(f3639d);
            jSONArray.put(f3640e);
            jSONArray.put(f3642g);
            params.put("extinfo", jSONArray.toString());
        }
        i5 = 0;
        jSONArray.put(i6);
        jSONArray.put(i5);
        jSONArray.put(new DecimalFormat("#.##").format(d5));
        jSONArray.put(f3636a.q0());
        jSONArray.put(f3639d);
        jSONArray.put(f3640e);
        jSONArray.put(f3642g);
        params.put("extinfo", jSONArray.toString());
    }

    private final String z() {
        AccessToken e5 = AccessToken.f10554r.e();
        if (e5 != null && e5.k() != null) {
            return e5.k();
        }
        return "facebook";
    }

    public static final String z0(byte[] bytes) {
        Intrinsics.checkNotNullParameter(bytes, "bytes");
        return f3636a.N("SHA-1", bytes);
    }
}