导航菜单

页面标题

页面副标题

Zepto v25.1.4 - UPIUtils.java 源代码

正在查看: Zepto v25.1.4 应用的 UPIUtils.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package in.juspay.hyperupi;

import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import androidx.media3.exoplayer.audio.h;
import in.juspay.hyper.constants.Labels;
import in.juspay.hyper.constants.LogLevel;
import in.juspay.hyper.constants.LogSubCategory;
import in.juspay.hyper.core.BridgeComponents;
import in.juspay.hyper.core.JsCallback;
import in.juspay.hyper.core.TrackerInterface;
import in.juspay.hyperupi.UPIUtils;
import java.util.Iterator;
import java.util.List;
import kotlin.Metadata;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.json.JSONArray;
import org.json.JSONObject;
import org.npci.upi.security.pinactivitycomponent.CLConstants;

@Metadata
public final class UPIUtils {

    @NotNull
    public static final Companion Companion = new Companion(null);
    private static final String LOG_TAG = "UPIUtils";

    @NotNull
    private final BridgeComponents bridgeComponents;

    @NotNull
    private final Context context;
    private final int deliveryFailedCode;
    private boolean isBindStarted;
    private int smsSendingTryCount;

    @Metadata
    public static final class Companion {
        public Companion(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        private Companion() {
        }
    }

    @Metadata
    public final class SendSmsThread extends Thread {
        private boolean bindDeviceOnDeliveryIntent;

        @Nullable
        private final String callback;
        private int counter;
        private boolean isInterrupted;
        private final int length;

        @NotNull
        private final String mobileNumber;

        @NotNull
        private final OnRegisterCallback onRegisterCallback;

        @NotNull
        private final String simSlot;

        @Nullable
        private Thread smsTimeoutThread;
        final UPIUtils this$0;

        @Nullable
        private final String token;
        private final int tries;

        @Metadata
        public abstract class SMSBroadcastReceiver extends BroadcastReceiver implements ResetCallback {
            private boolean isRegistered;

            public SMSBroadcastReceiver() {
            }

            public final synchronized void registerWithFlag(@NotNull OnRegisterCallback onRegisterCallback) {
                try {
                    Intrinsics.checkNotNullParameter(onRegisterCallback, "onRegisterCallback");
                    int i2 = Build.VERSION.SDK_INT;
                    if (i2 >= 33) {
                        com.google.android.material.appbar.a.z(SendSmsThread.this.this$0.context, this, new IntentFilter(UPIConstants.SMS_SENT + SendSmsThread.this.getMobileNumber()));
                    } else {
                        SendSmsThread.this.this$0.context.registerReceiver(this, new IntentFilter(UPIConstants.SMS_SENT + SendSmsThread.this.getMobileNumber()));
                    }
                    if (SendSmsThread.this.getBindDeviceOnDeliveryIntent()) {
                        if (i2 >= 33) {
                            com.google.android.material.appbar.a.z(SendSmsThread.this.this$0.context, this, new IntentFilter(UPIConstants.SMS_DELIVERY + SendSmsThread.this.getMobileNumber()));
                        } else {
                            SendSmsThread.this.this$0.context.registerReceiver(this, new IntentFilter(UPIConstants.SMS_DELIVERY + SendSmsThread.this.getMobileNumber()));
                        }
                    }
                    this.isRegistered = true;
                    onRegisterCallback.onRegistered(this);
                } catch (Throwable th) {
                    throw th;
                }
            }

            @Override
            public void reset() {
                unregisterWithFlag();
            }

            public final synchronized void unregisterWithFlag() {
                if (this.isRegistered) {
                    this.isRegistered = false;
                    SendSmsThread.this.this$0.context.unregisterReceiver(this);
                }
            }
        }

        public SendSmsThread(@NotNull UPIUtils uPIUtils, @NotNull String simSlot, @Nullable String mobileNumber, @Nullable String str, String str2, int i2, @NotNull int i3, OnRegisterCallback onRegisterCallback) {
            Intrinsics.checkNotNullParameter(simSlot, "simSlot");
            Intrinsics.checkNotNullParameter(mobileNumber, "mobileNumber");
            Intrinsics.checkNotNullParameter(onRegisterCallback, "onRegisterCallback");
            this.this$0 = uPIUtils;
            this.simSlot = simSlot;
            this.mobileNumber = mobileNumber;
            this.token = str;
            this.callback = str2;
            this.tries = i2;
            this.length = i3;
            this.onRegisterCallback = onRegisterCallback;
        }

        public final void sendCallback(SMSBroadcastReceiver sMSBroadcastReceiver, int i2, int i3) {
            String s;
            this.this$0.bridgeComponents.getTrackerInterface().trackAction(LogSubCategory.ApiCall.SDK, "info", Labels.System.UPI_UTILS, "SMS Callback", android.support.v4.media.a.i("resultCode : ", i2, ", errorCode : ", i3));
            sMSBroadcastReceiver.unregisterWithFlag();
            if (this.callback == null) {
                return;
            }
            if (i2 == -1) {
                s = android.support.v4.media.a.s(new StringBuilder("window.callUICallback(\""), this.callback, "\", \"SUCCESS\")");
            } else if (i2 == 1) {
                StringBuilder sb = new StringBuilder("window.callUICallback(\"");
                sb.append(this.callback);
                sb.append("\", \"GENERIC_FAILURE");
                s = android.support.v4.media.a.s(sb, i3 == 0 ? "" : android.support.v4.media.a.f("_", i3), "\", \"837\")");
            } else {
                s = i2 == 4 ? android.support.v4.media.a.s(new StringBuilder("window.callUICallback(\""), this.callback, "\", \"NO_SERVICE\", \"838\")") : i2 == 3 ? android.support.v4.media.a.s(new StringBuilder("window.callUICallback(\""), this.callback, "\", \"NULL_PDU\", \"839\")") : i2 == 2 ? android.support.v4.media.a.s(new StringBuilder("window.callUICallback(\""), this.callback, "\", \"RADIO_OFF\", \"840\")") : i3 == this.this$0.deliveryFailedCode ? android.support.v4.media.a.s(new StringBuilder("window.callUICallback(\""), this.callback, "\", \"DELIVERY_FAILED\", \"841\")") : android.support.v4.media.a.s(new StringBuilder("window.callUICallback(\""), this.callback, "\", \"EXCEPTION\", \"837\")");
            }
            JsCallback jsCallback = this.this$0.bridgeComponents.getJsCallback();
            if (jsCallback != null) {
                jsCallback.addJsToWebView(s);
            }
        }

        public final void sendSMS(final PendingIntent pendingIntent, final PendingIntent pendingIntent2, final SMSBroadcastReceiver sMSBroadcastReceiver) {
            this.counter++;
            this.isInterrupted = false;
            SimUtils.INSTANCE.sendSMS(this.this$0.context, this.this$0.bridgeComponents.getTrackerInterface(), Integer.parseInt(this.simSlot), this.mobileNumber, this.token + ' ' + this.mobileNumber, pendingIntent, pendingIntent2);
            Thread thread = this.smsTimeoutThread;
            if (thread != null) {
                thread.interrupt();
            }
            final UPIUtils uPIUtils = this.this$0;
            Thread thread2 = new Thread() {
                @Override
                public void run() {
                    String LOG_TAG;
                    int i2;
                    String LOG_TAG2;
                    super.run();
                    try {
                        Thread.sleep(15000L);
                    } catch (InterruptedException e2) {
                        TrackerInterface trackerInterface = UPIUtils.this.bridgeComponents.getTrackerInterface();
                        LOG_TAG = UPIUtils.LOG_TAG;
                        Intrinsics.checkNotNullExpressionValue(LOG_TAG, "LOG_TAG");
                        trackerInterface.trackAndLogException(LOG_TAG, "action", LogSubCategory.Action.SYSTEM, Labels.System.UPI_UTILS, "SendSMS InterruptedException", e2);
                    }
                    if (isInterrupted()) {
                        return;
                    }
                    i2 = this.counter;
                    if (i2 < this.getTries()) {
                        this.sendSMS(pendingIntent, pendingIntent2, sMSBroadcastReceiver);
                        return;
                    }
                    if (!UPIUtils.this.isBindStarted() && UPIUtils.this.getSmsSendingTryCount() == this.getLength()) {
                        this.sendCallback(sMSBroadcastReceiver, 0, UPIUtils.this.deliveryFailedCode);
                        return;
                    }
                    UPIUtils uPIUtils2 = UPIUtils.this;
                    synchronized (this) {
                        uPIUtils2.setSmsSendingTryCount(uPIUtils2.getSmsSendingTryCount() + 1);
                    }
                    try {
                        sMSBroadcastReceiver.unregisterWithFlag();
                    } catch (Exception e3) {
                        TrackerInterface trackerInterface2 = UPIUtils.this.bridgeComponents.getTrackerInterface();
                        LOG_TAG2 = UPIUtils.LOG_TAG;
                        Intrinsics.checkNotNullExpressionValue(LOG_TAG2, "LOG_TAG");
                        trackerInterface2.trackAndLogException(LOG_TAG2, "action", LogSubCategory.Action.SYSTEM, Labels.System.UPI_UTILS, "SendSMS Unregistering Receiver Exception", e3);
                    }
                }
            };
            this.smsTimeoutThread = thread2;
            thread2.start();
        }

        public final boolean getBindDeviceOnDeliveryIntent() {
            return this.bindDeviceOnDeliveryIntent;
        }

        @Nullable
        public final String getCallback() {
            return this.callback;
        }

        public final int getLength() {
            return this.length;
        }

        @NotNull
        public final String getMobileNumber() {
            return this.mobileNumber;
        }

        @Nullable
        public final String getToken() {
            return this.token;
        }

        public final int getTries() {
            return this.tries;
        }

        @Override
        public void run() {
            final PendingIntent pendingIntent;
            this.bindDeviceOnDeliveryIntent = this.this$0.bridgeComponents.getSdkConfig().optBoolean(UPIConstants.DELIVERY_INTENT_BINDING, false);
            int i2 = Build.VERSION.SDK_INT >= 23 ? 67108864 : 0;
            final PendingIntent broadcast = PendingIntent.getBroadcast(this.this$0.context, 0, new Intent(UPIConstants.SMS_SENT + this.mobileNumber), i2);
            if (this.bindDeviceOnDeliveryIntent) {
                pendingIntent = PendingIntent.getBroadcast(this.this$0.context, 0, new Intent(UPIConstants.SMS_DELIVERY + this.mobileNumber), i2);
            } else {
                pendingIntent = null;
            }
            final UPIUtils uPIUtils = this.this$0;
            SMSBroadcastReceiver sMSBroadcastReceiver = new SMSBroadcastReceiver() {
                {
                    super();
                }

                @Override
                public void onReceive(@NotNull Context context, @Nullable Intent intent) {
                    int i3;
                    Bundle extras;
                    Intrinsics.checkNotNullParameter(context, "context");
                    int resultCode = getResultCode();
                    int i4 = 0;
                    if (intent != null && intent.getExtras() != null && (extras = intent.getExtras()) != null) {
                        i4 = extras.getInt(CLConstants.FIELD_ERROR_CODE);
                    }
                    if (resultCode == -1 && !uPIUtils.isBindStarted() && !UPIUtils.SendSmsThread.this.getBindDeviceOnDeliveryIntent()) {
                        uPIUtils.setBindStarted(true);
                        UPIUtils.SendSmsThread.this.sendCallback(this, resultCode, i4);
                        return;
                    }
                    if (resultCode != -1) {
                        i3 = UPIUtils.SendSmsThread.this.counter;
                        if (i3 < UPIUtils.SendSmsThread.this.getTries()) {
                            UPIUtils.SendSmsThread.this.sendSMS(broadcast, pendingIntent, this);
                            return;
                        }
                    }
                    if (!uPIUtils.isBindStarted() && uPIUtils.getSmsSendingTryCount() == UPIUtils.SendSmsThread.this.getLength()) {
                        UPIUtils.SendSmsThread.this.sendCallback(this, resultCode, i4);
                        return;
                    }
                    UPIUtils uPIUtils2 = uPIUtils;
                    synchronized (this) {
                        uPIUtils2.setSmsSendingTryCount(uPIUtils2.getSmsSendingTryCount() + 1);
                    }
                    unregisterWithFlag();
                }
            };
            sMSBroadcastReceiver.registerWithFlag(this.onRegisterCallback);
            sendSMS(broadcast, pendingIntent, sMSBroadcastReceiver);
            if (this.bindDeviceOnDeliveryIntent) {
                final UPIUtils uPIUtils2 = this.this$0;
                new SMSBroadcastReceiver() {
                    {
                        super();
                    }

                    @Override
                    public void onReceive(@NotNull Context context, @NotNull Intent intent) {
                        String LOG_TAG;
                        int i3;
                        Intrinsics.checkNotNullParameter(context, "context");
                        Intrinsics.checkNotNullParameter(intent, "intent");
                        int resultCode = getResultCode();
                        UPIUtils.SendSmsThread.this.isInterrupted = true;
                        if (resultCode == -1 && !uPIUtils2.isBindStarted()) {
                            uPIUtils2.setBindStarted(true);
                            UPIUtils.SendSmsThread.this.sendCallback(this, -1, 0);
                            return;
                        }
                        if (resultCode != -1) {
                            i3 = UPIUtils.SendSmsThread.this.counter;
                            if (i3 < UPIUtils.SendSmsThread.this.getTries()) {
                                UPIUtils.SendSmsThread.this.sendSMS(broadcast, pendingIntent, this);
                                return;
                            }
                        }
                        if (!uPIUtils2.isBindStarted() && uPIUtils2.getSmsSendingTryCount() == UPIUtils.SendSmsThread.this.getLength()) {
                            UPIUtils.SendSmsThread.this.sendCallback(this, resultCode, uPIUtils2.deliveryFailedCode);
                            return;
                        }
                        UPIUtils uPIUtils3 = uPIUtils2;
                        synchronized (this) {
                            uPIUtils3.setSmsSendingTryCount(uPIUtils3.getSmsSendingTryCount() + 1);
                        }
                        try {
                            unregisterWithFlag();
                        } catch (Exception e2) {
                            TrackerInterface trackerInterface = uPIUtils2.bridgeComponents.getTrackerInterface();
                            LOG_TAG = UPIUtils.LOG_TAG;
                            Intrinsics.checkNotNullExpressionValue(LOG_TAG, "LOG_TAG");
                            trackerInterface.trackAndLogException(LOG_TAG, "action", LogSubCategory.Action.SYSTEM, Labels.System.UPI_UTILS, "Unregistering Receiver Exception", e2);
                        }
                    }
                }.registerWithFlag(this.onRegisterCallback);
            }
        }

        public final void setBindDeviceOnDeliveryIntent(boolean z) {
            this.bindDeviceOnDeliveryIntent = z;
        }
    }

    public UPIUtils(@NotNull BridgeComponents bridgeComponents) {
        Intrinsics.checkNotNullParameter(bridgeComponents, "bridgeComponents");
        this.bridgeComponents = bridgeComponents;
        this.deliveryFailedCode = 9999;
        this.context = bridgeComponents.getContext();
    }

    private final String getSubscriberId() {
        SubscriptionManager subscriptionManager;
        int i2 = Build.VERSION.SDK_INT;
        String str = "SIM_CARD_NOT_AVAILABLE";
        if (i2 >= 22) {
            JSONArray jSONArray = new JSONArray();
            if (i2 >= 23) {
                subscriptionManager = android.support.v4.media.session.a.k(h.q(this.context, android.support.v4.media.session.a.m()));
            } else {
                this.bridgeComponents.getTrackerInterface().trackLifecycle(LogSubCategory.Action.USER, LogLevel.CRITICAL, Labels.System.UPI_UTILS, "subscriberId Failed", "Cannot get mSubscriptionManager because API level is below 23");
                subscriptionManager = null;
            }
            List n2 = subscriptionManager != null ? android.support.v4.media.session.a.n(subscriptionManager) : null;
            if (n2 != null) {
                Iterator it = n2.iterator();
                while (it.hasNext()) {
                    jSONArray.put(String.valueOf(android.support.v4.media.session.a.a(android.support.v4.media.session.a.i(it.next()))));
                }
                str = jSONArray.toString();
            }
            Intrinsics.checkNotNullExpressionValue(str, "{\n            val simDet…\"\n            }\n        }");
        } else {
            this.bridgeComponents.getTrackerInterface().trackLifecycle(LogSubCategory.Action.USER, LogLevel.CRITICAL, Labels.System.UPI_UTILS, "subscriberId Failed", "Failed because API level is below 22");
        }
        return str;
    }

    @NotNull
    public final String getDeviceDetails() {
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("os", "ANDROID");
            jSONObject.put("androidAPILevel", String.valueOf(Build.VERSION.SDK_INT));
            jSONObject.put("version", Build.VERSION.RELEASE);
            jSONObject.put("appVersion", this.context.getPackageManager().getPackageInfo(this.context.getPackageName(), 0).versionName);
            jSONObject.put("model", Build.MODEL);
            jSONObject.put("manufacturer", Build.MANUFACTURER);
            jSONObject.put("geocode", "");
            jSONObject.put("location", "");
            jSONObject.put("capability", "");
            jSONObject.put("ip", "");
            jSONObject.put("packageName", this.context.getPackageName());
            jSONObject.put(CLConstants.SALT_FIELD_DEVICE_ID, this.bridgeComponents.getSessionInfoInterface().getDeviceId());
            jSONObject.put("subscriberId", getSubscriberId());
        } catch (Exception e2) {
            TrackerInterface trackerInterface = this.bridgeComponents.getTrackerInterface();
            String LOG_TAG2 = LOG_TAG;
            Intrinsics.checkNotNullExpressionValue(LOG_TAG2, "LOG_TAG");
            trackerInterface.trackAndLogException(LOG_TAG2, "action", LogSubCategory.Action.SYSTEM, Labels.System.UPI_UTILS, "GetDeviceDetails Exception", e2);
        }
        String jSONObject2 = jSONObject.toString();
        Intrinsics.checkNotNullExpressionValue(jSONObject2, "deviceDetails.toString()");
        return jSONObject2;
    }

    @Nullable
    public final String getSimOperators() {
        SubscriptionManager subscriptionManager;
        try {
            JSONArray jSONArray = new JSONArray();
            int i2 = Build.VERSION.SDK_INT;
            if (i2 < 22) {
                this.bridgeComponents.getTrackerInterface().trackLifecycle(LogSubCategory.Action.USER, LogLevel.CRITICAL, Labels.System.UPI_UTILS, "GetSIMOperators Failed", "Failed because API level is below 22");
                return "SIM_CARD_NOT_AVAILABLE";
            }
            if (i2 >= 23) {
                subscriptionManager = android.support.v4.media.session.a.k(h.q(this.context, android.support.v4.media.session.a.m()));
            } else {
                this.bridgeComponents.getTrackerInterface().trackLifecycle(LogSubCategory.Action.USER, LogLevel.CRITICAL, Labels.System.UPI_UTILS, "GetSIMOperators Failed", "Cannot get mSubscriptionManager as API level is below 23");
                subscriptionManager = null;
            }
            List n2 = subscriptionManager != null ? android.support.v4.media.session.a.n(subscriptionManager) : null;
            if (n2 == null) {
                return "SIM_CARD_NOT_AVAILABLE";
            }
            Iterator it = n2.iterator();
            int i3 = 0;
            while (it.hasNext()) {
                SubscriptionInfo i4 = android.support.v4.media.session.a.i(it.next());
                JSONObject jSONObject = new JSONObject();
                jSONObject.put(CLConstants.SHARED_PREFERENCE_ITEM_ID, String.valueOf(i3));
                jSONObject.put("simSerialNo", String.valueOf(android.support.v4.media.session.a.a(i4)));
                jSONObject.put("provider", android.support.v4.media.session.a.l(i4));
                jSONArray.put(jSONObject);
                i3++;
            }
            JSONObject jSONObject2 = new JSONObject();
            jSONObject2.put("simDetails", jSONArray);
            return jSONObject2.toString();
        } catch (Exception e2) {
            TrackerInterface trackerInterface = this.bridgeComponents.getTrackerInterface();
            String LOG_TAG2 = LOG_TAG;
            Intrinsics.checkNotNullExpressionValue(LOG_TAG2, "LOG_TAG");
            trackerInterface.trackAndLogException(LOG_TAG2, "action", LogSubCategory.Action.SYSTEM, Labels.System.UPI_UTILS, "GetSIMOperators Exception", e2);
            return null;
        }
    }

    public final int getSmsSendingTryCount() {
        return this.smsSendingTryCount;
    }

    public final boolean isAirplaneModeOn() {
        return Settings.Global.getInt(this.context.getContentResolver(), "airplane_mode_on", 0) != 0;
    }

    public final boolean isBindStarted() {
        return this.isBindStarted;
    }

    public final boolean isSimActive(int i2) {
        SubscriptionInfo i3;
        TelephonyManager g2;
        SubscriptionInfo i4;
        int i5 = Build.VERSION.SDK_INT;
        if (i5 < 23) {
            this.bridgeComponents.getTrackerInterface().trackLifecycle(LogSubCategory.Action.USER, LogLevel.CRITICAL, Labels.System.UPI_UTILS, "isSimActive Failed", "Failed because API level is below 23");
            return false;
        }
        if (i5 >= 26) {
            SubscriptionManager k2 = android.support.v4.media.session.a.k(h.q(this.context, android.support.v4.media.session.a.m()));
            List n2 = k2 != null ? android.support.v4.media.session.a.n(k2) : null;
            if (n2 == null || (i4 = android.support.v4.media.session.a.i(n2.get(i2))) == null) {
                return false;
            }
            int u = android.support.v4.media.session.a.u(i4);
            Object systemService = this.context.getSystemService("phone");
            g2 = systemService instanceof TelephonyManager ? (TelephonyManager) systemService : null;
            return g2 != null && com.google.firebase.heartbeatinfo.c.a(g2, u) == 5;
        }
        if (i5 < 24) {
            return true;
        }
        SubscriptionManager k3 = android.support.v4.media.session.a.k(h.q(this.context, android.support.v4.media.session.a.m()));
        List n3 = k3 != null ? android.support.v4.media.session.a.n(k3) : null;
        if (n3 == null || (i3 = android.support.v4.media.session.a.i(n3.get(i2))) == null) {
            return false;
        }
        int a = android.support.v4.media.session.a.a(i3);
        Object systemService2 = this.context.getSystemService("phone");
        TelephonyManager telephonyManager = systemService2 instanceof TelephonyManager ? (TelephonyManager) systemService2 : null;
        g2 = telephonyManager != null ? com.google.common.collect.a.g(telephonyManager, a) : null;
        return g2 != null && g2.getSimState() == 5;
    }

    public final void sendSms(@NotNull String simSlot, @NotNull String[] mobileNumbers, @Nullable String str, @NotNull String tries, @Nullable String str2, @NotNull OnRegisterCallback onRegisterCallback) {
        Intrinsics.checkNotNullParameter(simSlot, "simSlot");
        Intrinsics.checkNotNullParameter(mobileNumbers, "mobileNumbers");
        Intrinsics.checkNotNullParameter(tries, "tries");
        Intrinsics.checkNotNullParameter(onRegisterCallback, "onRegisterCallback");
        this.isBindStarted = false;
        this.smsSendingTryCount = 1;
        int length = mobileNumbers.length;
        for (String str3 : mobileNumbers) {
            new SendSmsThread(this, simSlot, str3, str, str2, Integer.parseInt(tries), length, onRegisterCallback).start();
        }
    }

    public final void setBindStarted(boolean z) {
        this.isBindStarted = z;
    }

    public final void setSmsSendingTryCount(int i2) {
        this.smsSendingTryCount = i2;
    }
}