导航菜单

页面标题

页面副标题

Biko v2.0.23 - RzpAssist.java 源代码

正在查看: Biko v2.0.23 应用的 RzpAssist.java JAVA 源代码文件

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


package com.razorpay;

import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.pm.PackageManager;
import android.os.Build;
import android.webkit.JavascriptInterface;
import android.webkit.WebView;
import com.razorpay.AnalyticsProperty;
import com.stripe.android.core.networking.AnalyticsFields;
import com.stripe.android.core.networking.AnalyticsRequestV2Factory;
import com.stripe.android.core.networking.NetworkConstantsKt;
import com.stripe.android.core.networking.RequestHeadersFactory;
import java.util.HashMap;
import org.json.JSONObject;

public final class RzpAssist implements SmsAgentInterface {
    private Activity activity;
    private OtpElfData elfData;
    String lastSms;
    private String merchantKey;
    String message;
    private long pageStartTime;
    private String paymentId;
    private String sdkType;
    private String sdkVersion;
    private int sdkVersionCode;
    String sender;
    private m smsAgent;
    private WebView webview;
    private boolean hasOtpPermission = false;
    private String lastURL = "";
    private String currentLoadingUrl = "";
    private boolean isMagic = false;
    private boolean isRazorpayOtpReceived = false;
    private JSONObject otpElfPreferences = new JSONObject();
    private JSONObject paymentData = new JSONObject();
    private boolean isRzpAssistEnabled = false;
    private boolean otpRead = false;
    private boolean jsInsertedInCurrentPage = false;

    public RzpAssist(String str, Activity activity, WebView webView, String str2, int i, String str3) {
        this.sdkType = "standalone";
        if (D$$l_.a().isOTPElfEnabled().booleanValue()) {
            if (str == null || str.isEmpty()) {
                throw new RuntimeException("merchantKey cannot be null or empty");
            }
            this.sdkType = str2;
            this.sdkVersionCode = i;
            this.sdkVersion = str3;
            if (str2.equals("standalone") || str2.equalsIgnoreCase(BuildConfig.SDK_TYPE) || str2.equalsIgnoreCase("custom")) {
                AnalyticsUtil.setup(activity, str, str2, i, str3);
            }
            this.webview = webView;
            this.merchantKey = str;
            this.activity = activity;
            OtpElfData otpElfData = new OtpElfData(activity);
            this.elfData = otpElfData;
            otpElfData.checkForUpdates();
            setup();
            AnalyticsUtil.addProperty("OTPElf Version", new AnalyticsProperty(BaseUtils.getLocalVersion(activity, OtpElfData.versionKey), AnalyticsProperty.Scope.ORDER));
        }
    }

    private void setup() {
        m a = m.a();
        this.smsAgent = a;
        a.a(this);
        this.smsAgent.a(this.activity);
        this.webview.addJavascriptInterface(this, "OTPElfBridge");
        this.webview.getSettings().setUseWideViewPort(true);
    }

    final void enableMagic() {
        this.isMagic = true;
    }

    final void setPaymentData(JSONObject jSONObject) {
        this.paymentData = jSONObject;
    }

    public final void setOtpElfPreferences(JSONObject jSONObject) {
        this.otpElfPreferences = jSONObject;
    }

    public final void onPageFinished(WebView webView, String str) {
        AnalyticsUtil.trackPageLoadEnd(str, System.nanoTime() - this.pageStartTime);
        this.lastURL = str;
        this.currentLoadingUrl = "";
        if (D$$l_.a().isOTPElfEnabled().booleanValue() && !this.jsInsertedInCurrentPage) {
            handleJsInsertion();
            this.jsInsertedInCurrentPage = true;
        }
    }

    private void handleJsInsertion() {
        try {
            JSONObject oTPElfSettings = D$$l_.a().getOTPElfSettings();
            oTPElfSettings.put("merchant_key", this.merchantKey);
            oTPElfSettings.put("otp_permission", this.hasOtpPermission);
            JSONObject jSONObject = new JSONObject();
            jSONObject.put(RequestHeadersFactory.TYPE, this.sdkType);
            jSONObject.put("version", this.sdkVersion);
            jSONObject.put("platform", "android");
            jSONObject.put("framework", AnalyticsRequestV2Factory.PLUGIN_NATIVE);
            jSONObject.put("name", this.sdkType + "_android_native");
            oTPElfSettings.put("sdk", jSONObject);
            JSONObject jSONObject2 = new JSONObject();
            if (!this.isMagic) {
                jSONObject2.put(RequestHeadersFactory.TYPE, "rzpassist");
                jSONObject2.put("version_code", n$_B$.b.intValue());
            } else {
                jSONObject2.put(RequestHeadersFactory.TYPE, "magic");
                jSONObject2.put("version_code", n$_B$.c.intValue());
            }
            oTPElfSettings.put("plugin", jSONObject2);
            oTPElfSettings.put("payment_data", this.paymentData);
            oTPElfSettings.put("preferences", this.otpElfPreferences);
            JSONObject jSONObject3 = new JSONObject();
            jSONObject3.put(AnalyticsRequestV2Factory.PARAM_PACKAGE_NAME, this.activity.getApplicationContext().getPackageName());
            PackageManager packageManager = this.activity.getPackageManager();
            jSONObject3.put(AnalyticsFields.APP_NAME, AnalyticsUtil.returnUndefinedIfNull(packageManager.getPackageInfo(this.activity.getPackageName(), 0).applicationInfo.loadLabel(packageManager)));
            jSONObject3.put("platform", "mobile_sdk");
            jSONObject3.put("os", "android");
            jSONObject3.put(AnalyticsFields.OS_VERSION, Build.VERSION.RELEASE);
            jSONObject3.put("data_network_type", BaseUtils.getDataNetworkType(this.activity).getNetworkTypeName());
            jSONObject3.put("framework", AnalyticsUtil.getFramework());
            jSONObject3.put("library", BuildConfig.SDK_TYPE);
            jSONObject3.put("sdk", jSONObject);
            oTPElfSettings.put("metadata", jSONObject3);
            injectJs("window.__rzp_options = " + oTPElfSettings.toString());
        } catch (Exception e) {
            d__1_.a("Unable to load otpelf settings", e);
        }
        injectJs(this.elfData.getOtpElfJs());
        AnalyticsUtil.trackEvent(AnalyticsEvent.OTPELF_INJECTED);
        String str = this.lastSms;
        if (str != null) {
            injectJs(String.format("OTPElf.showOTP('%s','%s')", str, this.sender));
            this.lastSms = null;
        }
    }

    public final void onProgressChanged(int i) {
        D$$l_.a().isOTPElfEnabled().booleanValue();
    }

    public final void onPageStarted(WebView webView, String str) {
        AnalyticsUtil.trackPageLoadStart(str);
        this.pageStartTime = System.nanoTime();
        this.currentLoadingUrl = str;
        this.jsInsertedInCurrentPage = false;
    }

    public final void paymentFlowEnd() {
        if (this.sdkType.equals("standalone")) {
            AnalyticsUtil.postData();
        }
        if (D$$l_.a().isOTPElfEnabled().booleanValue()) {
            this.smsAgent.b(this.activity);
            this.smsAgent.b(this);
        }
    }

    @Override
    public final void postSms(String str, String str2) {
        if (this.isRzpAssistEnabled) {
            try {
                JSONObject jSONObject = new JSONObject();
                jSONObject.put("sender", str);
                jSONObject.put("message", str2);
                this.sender = str;
                this.message = str2;
                this.lastSms = jSONObject.toString();
                injectJs(String.format("OTPElf.showOTP('%s','%s')", str2, str));
            } catch (Exception e) {
                d__1_.a("Exception", e);
            }
        }
    }

    @Override
    public final void setSmsPermission(boolean z) {
        setOTPEnabled(z);
    }

    final void setPaymentId(String str) {
        this.paymentId = str;
    }

    private void postStatsToAPI() {
        try {
            String constructBasicAuth = BaseUtils.constructBasicAuth(this.merchantKey);
            HashMap hashMap = new HashMap();
            hashMap.put(NetworkConstantsKt.HEADER_AUTHORIZATION, "Basic " + constructBasicAuth);
            hashMap.put(NetworkConstantsKt.HEADER_CONTENT_TYPE, "application/json");
            if (this.paymentId == null) {
                return;
            }
            M$_3_.a("https://api.razorpay.com/v1/payments/" + this.paymentId + "/metadata", E$_j$.a(this.otpRead).toString(), hashMap, new c(this));
        } catch (Exception e) {
            AnalyticsUtil.reportError("RzpAssist", "S0", e.getMessage());
        }
    }

    private void injectJs(String str) {
        this.webview.loadUrl(String.format("javascript: %s", str));
    }

    final void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
        m mVar = this.smsAgent;
        if (i != 1) {
            return;
        }
        if (iArr.length > 0 && iArr[0] == 0) {
            mVar.a(true);
            mVar.b();
            AnalyticsUtil.trackEvent(AnalyticsEvent.SMS_PERMISSION_NOW_GRANTED);
        } else {
            mVar.a(false);
            AnalyticsUtil.trackEvent(AnalyticsEvent.SMS_PERMISSION_NOW_DENIED);
        }
    }

    final String getLastLoadedUrl() {
        return this.lastURL;
    }

    final String getCurrentLoadingUrl() {
        return this.currentLoadingUrl;
    }

    public final void reset() {
        postStatsToAPI();
        this.lastURL = "";
        this.currentLoadingUrl = "";
        this.otpRead = false;
    }

    final boolean isRazorpayOtpReceived() {
        return this.isRazorpayOtpReceived;
    }

    final void setOTPEnabled(boolean z) {
        this.hasOtpPermission = z;
        AnalyticsUtil.addProperty("otp_autoreading_access", new AnalyticsProperty(z, AnalyticsProperty.Scope.ORDER));
    }

    final void setRzpAssistEnabled(boolean z) {
        this.isRzpAssistEnabled = z;
    }

    @JavascriptInterface
    public final void setUseWideViewPort(boolean z) {
        this.activity.runOnUiThread(new d(this, z));
    }

    @JavascriptInterface
    public final void openKeyboard() {
        this.activity.runOnUiThread(new e(this));
    }

    @JavascriptInterface
    public final void toast(String str) {
        this.activity.runOnUiThread(new f(this, str));
    }

    @JavascriptInterface
    public final void trackEvent(String str, String str2) {
        try {
            AnalyticsEvent analyticsEvent = AnalyticsEvent.JS_EVENT;
            analyticsEvent.setEventName(str);
            AnalyticsUtil.trackEvent(analyticsEvent, new JSONObject(str2));
        } catch (Exception e) {
            d__1_.a("Error in tracking JS Event", e);
        }
    }

    @JavascriptInterface
    public final void trackEvent(String str) {
        AnalyticsEvent analyticsEvent = AnalyticsEvent.JS_EVENT;
        analyticsEvent.setEventName(str);
        AnalyticsUtil.trackEvent(analyticsEvent);
    }

    @JavascriptInterface
    public final void onOtpParsed(String str) {
        this.activity.runOnUiThread(new g(this, str));
    }

    @JavascriptInterface
    public final void copyToClipboard(String str) {
        ((ClipboardManager) this.activity.getSystemService("clipboard")).setPrimaryClip(ClipData.newPlainText("rzp_clip_data", str));
    }
}