正在查看: Housing v14.7.8 应用的 OtplessViewImpl.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Housing v14.7.8 应用的 OtplessViewImpl.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.otpless.main;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.facebook.GraphResponse;
import com.facebook.internal.NativeProtocol;
import com.facebook.share.internal.ShareConstants;
import com.otpless.authfusion.FacebookSignInSdk;
import com.otpless.authfusion.GoogleCredentialSdk;
import com.otpless.config.Configuration;
import com.otpless.config.OtplessParamKey;
import com.otpless.dto.HeadlessRequest;
import com.otpless.dto.HeadlessResponse;
import com.otpless.dto.OtplessRequest;
import com.otpless.dto.OtplessResponse;
import com.otpless.dto.Triple;
import com.otpless.network.NetworkStatusData;
import com.otpless.network.OnConnectionChangeListener;
import com.otpless.network.OtplessCellularNetwork;
import com.otpless.network.OtplessCellularNetworkImplV2;
import com.otpless.network.OtplessConnectivityManager;
import com.otpless.network.OtplessNetworkManager;
import com.otpless.network.OtplessRepository;
import com.otpless.tesseract.OtplessSecureService;
import com.otpless.utils.OnceUseProp;
import com.otpless.utils.OtpReaderManager;
import com.otpless.utils.OtplessPhoneHintManager;
import com.otpless.utils.OtplessPhoneHintManagerImpl;
import com.otpless.utils.OtplessUtility;
import com.otpless.utils.Utility;
import com.otpless.views.OtplessContainerView;
import com.otpless.views.OtplessUserDetailCallback;
import com.otpless.web.NativeWebManager;
import com.otpless.web.OtplessWebView;
import java.io.Serializable;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Locale;
import java.util.Queue;
import java.util.UUID;
import kq.l;
import kq.q;
import org.json.JSONException;
import org.json.JSONObject;
import zp.j0;
final class OtplessViewImpl implements OtplessView, OtplessViewContract, OnConnectionChangeListener, NativeWebListener {
private static final String BASE_LOADING_URL = "https://otpless.com";
private static final String INSTALL_ID_KEY = "otpless_inid";
private static final String VIEW_TAG_NAME = "OtplessView";
private final Activity activity;
@NonNull
private final OtplessConnectivityManager connectivityManager;
@Nullable
private CountDownTimer countDownTimer;
private OtplessUserDetailCallback detailCallback;
private OtplessEventCallback eventCallback;
@Nullable
private FacebookSignInSdk facebookSignInSdk;
@Nullable
private GoogleCredentialSdk googleSignInSdk;
@Nullable
private HeadlessRequest headlessRequest;
private HeadlessResponseCallback headlessResponseCallback;
@NonNull
String installId;
@Nullable
private String loginUri;
private OtplessRequest mOtplessRequest;
@NonNull
private final WhatsappOtpReader mWhatsappOtpReader;
@NonNull
private final OtplessCellularNetwork otplessCellularNetwork;
@NonNull
String trackingSessionId;
private WeakReference<OtplessContainerView> wContainer = new WeakReference<>(null);
private boolean backSubscription = false;
private boolean isLoaderVisible = true;
private boolean isRetryVisible = true;
private boolean isContainerViewInvisible = false;
private OtplessWebAuthnManager webAuthnManager = null;
private boolean isHeadless = false;
@NonNull
private String appId = "";
private final Queue<ViewGroup> helpQueue = new LinkedList();
OtplessViewRemovalNotifier viewRemovalNotifier = null;
private final OtplessPhoneHintManager phoneHintManager = new OtplessPhoneHintManagerImpl();
@Nullable
private OtplessSecureService secureService = null;
@NonNull
private final OnceUseProp<JSONObject> ssoSdkLowMemData = new OnceUseProp<>();
private long countDownFuture = 30000;
private boolean isPushedToWebHr = false;
private HeadlessInitState initAction = HeadlessInitState.NONE;
public class AnonymousClass1 extends CountDownTimer {
public AnonymousClass1(long j, long j2) {
super(j, j2);
}
public static j0 lambda$onFinish$0(JSONObject jSONObject, String str, String str2) {
Utility.pushEvent("native_headless_timeout", jSONObject, str, str2);
return null;
}
@Override
public void onFinish() {
if (OtplessViewImpl.this.headlessRequest == null) {
Utility.pushEvent("native_headless_request_null_on_timer_finished");
return;
}
OtplessUtility otplessUtility = OtplessUtility.INSTANCE;
HeadlessResponse makeTimeoutError = otplessUtility.makeTimeoutError(OtplessViewImpl.this.headlessRequest);
otplessUtility.convertToEventParamsJson(makeTimeoutError, new a(1));
OtplessViewImpl.this.onHeadlessResult(makeTimeoutError, true);
}
@Override
public void onTick(long j) {
}
}
public OtplessViewImpl(Activity activity) {
this.installId = "";
this.trackingSessionId = "";
this.activity = activity;
SharedPreferences preferences = activity.getPreferences(0);
String string = preferences.getString(INSTALL_ID_KEY, "");
if (Utility.isValid(new String[]{string})) {
this.installId = string;
} else {
this.installId = UUID.randomUUID().toString() + "-" + System.currentTimeMillis();
SharedPreferences.Editor edit = preferences.edit();
edit.putString(INSTALL_ID_KEY, this.installId);
edit.apply();
}
this.trackingSessionId = UUID.randomUUID().toString() + "-" + System.currentTimeMillis();
this.mWhatsappOtpReader = new WhatsappOtpReaderImpl(activity);
OtplessConnectivityManager otplessConnectivityManager = new OtplessConnectivityManager((ConnectivityManager) activity.getSystemService("connectivity"));
this.connectivityManager = otplessConnectivityManager;
OtplessCellularNetworkImplV2 otplessCellularNetworkImplV2 = new OtplessCellularNetworkImplV2(activity, otplessConnectivityManager);
this.otplessCellularNetwork = otplessCellularNetworkImplV2;
if (otplessCellularNetworkImplV2.isCellularDataEnabled()) {
OtplessUtility otplessUtility = OtplessUtility.INSTANCE;
if (otplessUtility.getSnaPrecacheEnableStatus(activity)) {
String[] snaPrecacheUrls = otplessUtility.getSnaPrecacheUrls(activity);
if (snaPrecacheUrls.length > 0) {
SharedPreferences sharedPreferences = activity.getSharedPreferences(Configuration.OtplessPreferenceStore, 0);
OtplessRepository.INSTANCE.warmupSna(otplessConnectivityManager, snaPrecacheUrls, sharedPreferences);
SharedPreferences.Editor edit2 = sharedPreferences.edit();
edit2.putLong(Configuration.URL_CACHE_COMPLETE_TIME, System.currentTimeMillis());
edit2.apply();
}
}
}
Utility.addContextInfo(activity, this);
loadLoginSdkClasses();
}
private void addViewIfNotAdded() {
Window window = this.activity.getWindow();
if (window == null) {
Utility.pushEvent("window_null");
return;
}
if (window.getDecorView() == null) {
Utility.pushEvent("decorview_null");
return;
}
ViewGroup findParentView = findParentView();
if (findParentView == null) {
Utility.pushEvent("parent_null");
return;
}
OtplessContainerView findViewWithTag = findParentView.findViewWithTag(VIEW_TAG_NAME);
if (findViewWithTag != null) {
if (this.isHeadless) {
findViewWithTag.enableHeadlessConfig();
return;
}
OtplessContainerView otplessContainerView = findViewWithTag;
otplessContainerView.disableHeadlessConfig();
otplessContainerView.setUiConfiguration(this.mOtplessRequest.toJsonObj());
return;
}
OtplessContainerView otplessContainerView2 = new OtplessContainerView(this.activity);
otplessContainerView2.setTag(VIEW_TAG_NAME);
otplessContainerView2.setId(View.generateViewId());
otplessContainerView2.setViewContract(this);
if (otplessContainerView2.getWebManager() != null) {
otplessContainerView2.getWebManager().setNativeWebListener(this);
}
otplessContainerView2.isToShowLoader = this.isLoaderVisible;
otplessContainerView2.isToShowRetry = this.isRetryVisible;
if (this.isHeadless) {
otplessContainerView2.enableHeadlessConfig();
} else {
otplessContainerView2.setUiConfiguration(this.mOtplessRequest.toJsonObj());
}
findParentView.addView(otplessContainerView2);
Utility.pushEvent("native_webview_added");
this.wContainer = new WeakReference<>(otplessContainerView2);
OtplessNetworkManager.getInstance().addListeners(this.activity, this);
if (this.isContainerViewInvisible) {
otplessContainerView2.setVisibility(4);
}
}
private ViewGroup findFrameLayout() {
ViewGroup poll = this.helpQueue.poll();
if (poll == null) {
return null;
}
int childCount = poll.getChildCount();
for (int i = 0; i < childCount; i++) {
View childAt = poll.getChildAt(i);
if (childAt.getId() == 16908290) {
return (ViewGroup) childAt;
}
if (childAt instanceof FrameLayout) {
return (FrameLayout) childAt;
}
if (childAt instanceof ViewGroup) {
this.helpQueue.add((ViewGroup) childAt);
}
}
return findFrameLayout();
}
private ViewGroup findParentView() {
Window window = this.activity.getWindow();
if (window == null) {
return null;
}
View decorView = window.getDecorView();
if (!(decorView instanceof ViewGroup)) {
return null;
}
this.helpQueue.clear();
this.helpQueue.add((ViewGroup) decorView);
return findFrameLayout();
}
@Nullable
private String getCustomLoadingUrl() {
return this.isHeadless ? this.loginUri : this.mOtplessRequest.getExtras().get("login_uri");
}
private String getFirstLoadingUrl() {
Uri.Builder buildUpon = Uri.parse(BASE_LOADING_URL).buildUpon();
buildUpon.appendPath("rc4");
buildUpon.appendPath("appid");
buildUpon.appendPath(this.appId);
if (!this.isHeadless) {
JSONObject jsonObj = this.mOtplessRequest.toJsonObj();
try {
if (jsonObj.optString("method").toLowerCase().equals("get")) {
JSONObject jSONObject = jsonObj.getJSONObject(NativeProtocol.WEB_DIALOG_PARAMS);
Iterator<String> keys = jSONObject.keys();
while (keys.hasNext()) {
String next = keys.next();
String optString = jSONObject.optString(next);
if (!optString.isEmpty()) {
buildUpon.appendQueryParameter(next, optString);
}
}
}
} catch (JSONException unused) {
}
}
buildUpon.appendQueryParameter("package", this.activity.getPackageName());
buildUpon.appendQueryParameter("hasWhatsapp", String.valueOf(Utility.isWhatsAppInstalled(this.activity)));
buildUpon.appendQueryParameter("hasOtplessApp", String.valueOf(Utility.isOtplessAppInstalled(this.activity)));
for (Triple triple : Utility.getMessagingInstalledAppStatus(this.activity.getPackageManager())) {
buildUpon.appendQueryParameter("has" + ((String) triple.getFirst()), String.valueOf(triple.getThird()));
}
String customLoadingUrl = getCustomLoadingUrl();
if (customLoadingUrl == null || customLoadingUrl.isEmpty()) {
customLoadingUrl = "otpless." + this.appId.toLowerCase(Locale.US) + "://otpless";
}
buildUpon.appendQueryParameter("login_uri", customLoadingUrl);
buildUpon.appendQueryParameter("nbbs", String.valueOf(this.backSubscription));
buildUpon.appendQueryParameter("inid", this.installId);
buildUpon.appendQueryParameter("tsid", this.trackingSessionId);
buildUpon.appendQueryParameter(OtplessParamKey.IS_SILENT_AUTH_SUPPORTED, String.valueOf(true));
buildUpon.appendQueryParameter(OtplessParamKey.IS_WEB_AUTHN_SUPPORTED, String.valueOf(true));
buildUpon.appendQueryParameter(OtplessParamKey.IS_WHATSAPP_HANDSHAKE, String.valueOf(this.mWhatsappOtpReader.isWhatsAppHandshakeSupported(this.activity)));
buildUpon.appendQueryParameter(OtplessParamKey.IS_GMAIL_SDK_SUPPORTED, String.valueOf(true));
buildUpon.appendQueryParameter(OtplessParamKey.IS_FACEBOOK_SDK_SUPPORTED, String.valueOf(true));
buildUpon.appendQueryParameter(Configuration.URL_CACHE_SUPPORTED, String.valueOf(true));
long j = this.activity.getSharedPreferences(Configuration.OtplessPreferenceStore, 0).getLong(Configuration.URL_CACHE_COMPLETE_TIME, 0L);
if (j != 0) {
buildUpon.appendQueryParameter(Configuration.URL_CACHE_EPOCH, String.valueOf(j));
}
return buildUpon.build().toString();
}
private void initUrlLoading() {
addViewIfNotAdded();
OtplessContainerView otplessContainerView = this.wContainer.get();
if (otplessContainerView == null || otplessContainerView.getWebView() == null) {
return;
}
Uri.Builder buildUpon = Uri.parse(getFirstLoadingUrl()).buildUpon();
buildUpon.appendQueryParameter("isHeadless", String.valueOf(true));
String string = this.activity.getPreferences(0).getString("plov", "");
if (!string.isEmpty()) {
buildUpon.appendQueryParameter("plov", string);
}
otplessContainerView.getWebView().loadWebUrl(buildUpon.build().toString());
}
public static j0 lambda$commitHeadlessResponse$1(JSONObject jSONObject, String str, String str2) {
Utility.pushEvent("native_headless_merchant_commit", jSONObject, str, str2);
return null;
}
public static j0 lambda$handleEmptyWebResponse$2(String str, JSONObject jSONObject, String str2, String str3) {
if (str != null) {
try {
jSONObject.put("web_response", str);
} catch (JSONException unused) {
}
}
Utility.pushEvent("native_headless_empty_response_web", jSONObject, str2, str3);
return null;
}
public static j0 lambda$loadEventCallbackAndDebugLog$3(String str, JSONObject jSONObject) {
Utility.pushEvent(str, jSONObject);
return j0.INSTANCE;
}
public j0 lambda$restoreSavedInstance$0(JSONObject jSONObject) {
this.ssoSdkLowMemData.setData(jSONObject);
OtplessContainerView otplessContainerView = this.wContainer.get();
if (otplessContainerView != null && otplessContainerView.getWebView() != null && otplessContainerView.getWebView().getLoadedUrl() != null) {
Utility.debugLog("send headless callback with facebook sdk response");
otplessContainerView.getWebManager().sendHeadlessRequest();
return null;
}
addViewIfNotAdded();
Utility.debugLog("loading url with facebook sdk response");
loadWebView(null, null);
return null;
}
private void loadEventCallbackAndDebugLog(Class<?> cls, Object obj) throws NoSuchFieldException, IllegalAccessException {
Class<? super Object> superclass = cls.getSuperclass();
if (superclass == null) {
return;
}
Field declaredField = superclass.getDeclaredField("onEventReceivedCallback");
declaredField.setAccessible(true);
d dVar = new d();
Utility.debugLog("event logging loaded");
declaredField.set(obj, dVar);
if (Utility.debugLogging) {
Utility.debugLog("debug logging loaded");
Field declaredField2 = superclass.getDeclaredField("isDebugLogging");
declaredField2.setAccessible(true);
declaredField2.setBoolean(obj, true);
}
}
private void loadLoginSdkClasses() {
try {
Class<?> cls = Class.forName("com.otpless.fusiongoogle.GoogleFusionManager");
Object obj = cls.getField("INSTANCE").get(null);
loadEventCallbackAndDebugLog(cls, obj);
Object invoke = cls.getMethod("getGoogleCredentialSdk", Context.class).invoke(obj, this.activity);
if (invoke instanceof GoogleCredentialSdk) {
this.googleSignInSdk = (GoogleCredentialSdk) invoke;
Utility.debugLog("google signin sdk loaded");
}
} catch (ClassNotFoundException | IllegalAccessException | NoSuchFieldException | NoSuchMethodException | InvocationTargetException e) {
Utility.debugLog(e);
}
try {
Class<?> cls2 = Class.forName("com.otpless.fusionmeta.MetaFusionManager");
Object obj2 = cls2.getField("INSTANCE").get(null);
loadEventCallbackAndDebugLog(cls2, obj2);
Object invoke2 = cls2.getMethod("getFacebookSignInSdk", Activity.class).invoke(obj2, this.activity);
if (invoke2 instanceof FacebookSignInSdk) {
this.facebookSignInSdk = (FacebookSignInSdk) invoke2;
Utility.debugLog("facebook signin sdk loaded");
}
} catch (ClassNotFoundException | IllegalAccessException | NoSuchFieldException | NoSuchMethodException | InvocationTargetException e2) {
Utility.debugLog(e2);
}
}
private void loadWebView(String str, Uri uri) {
OtplessContainerView otplessContainerView = this.wContainer.get();
if (otplessContainerView == null || otplessContainerView.getWebView() == null) {
return;
}
if (!this.isHeadless) {
if (str != null) {
if (uri == null) {
otplessContainerView.getWebView().loadWebUrl(str);
return;
} else {
reloadToVerifyCode(otplessContainerView.getWebView(), uri, str);
return;
}
}
String firstLoadingUrl = getFirstLoadingUrl();
if (uri == null) {
otplessContainerView.getWebView().loadWebUrl(firstLoadingUrl);
return;
} else {
reloadToVerifyCode(otplessContainerView.getWebView(), uri, firstLoadingUrl);
return;
}
}
Uri.Builder buildUpon = Uri.parse(getFirstLoadingUrl()).buildUpon();
buildUpon.appendQueryParameter("isHeadless", String.valueOf(true));
if (uri != null) {
String queryParameter = uri.getQueryParameter("code");
HeadlessRequest headlessRequest = this.headlessRequest;
if (headlessRequest == null) {
Utility.pushEvent("native_headless_null_load_url");
return;
}
headlessRequest.setCode(queryParameter);
if (otplessContainerView.getWebView().getLoadedUrl() != null) {
otplessContainerView.getWebManager().sendHeadlessRequest();
return;
}
}
otplessContainerView.getWebView().loadWebUrl(buildUpon.build().toString());
}
private void reloadToVerifyCode(OtplessWebView otplessWebView, @NonNull Uri uri, @NonNull String str) {
String queryParameter = uri.getQueryParameter("code");
boolean z = (queryParameter == null || queryParameter.length() == 0) ? false : true;
otplessWebView.loadWebUrl(Utility.combineQueries(Uri.parse(str), uri).toString());
sendIntentInEvent(z);
}
private void removeView() {
ViewGroup findParentView;
Window window = this.activity.getWindow();
if (window == null || window.getDecorView() == null || (findParentView = findParentView()) == null) {
return;
}
View findViewWithTag = findParentView.findViewWithTag(VIEW_TAG_NAME);
if (findViewWithTag != null) {
findParentView.removeView(findViewWithTag);
OtplessViewRemovalNotifier otplessViewRemovalNotifier = this.viewRemovalNotifier;
if (otplessViewRemovalNotifier != null) {
otplessViewRemovalNotifier.onOtplessViewRemoved(this);
}
OtplessNetworkManager.getInstance().removeListener(this.activity, this);
this.wContainer.clear();
}
OtpReaderManager.getInstance().stopOtpReader();
this.initAction = HeadlessInitState.NONE;
CountDownTimer countDownTimer = this.countDownTimer;
if (countDownTimer != null) {
countDownTimer.cancel();
}
this.headlessRequest = null;
}
private void restoreSavedInstance(@NonNull Bundle bundle) {
FacebookSignInSdk facebookSignInSdk;
String string = bundle.getString("otpless_app_id");
if (string != null && this.appId.isEmpty()) {
this.appId = string;
}
boolean z = bundle.getBoolean("is_otpless_headless", false);
this.isHeadless = z;
String str = null;
if (z) {
Serializable serializable = bundle.getSerializable("otpless_headless_request");
if (serializable instanceof HeadlessRequest) {
this.initAction = HeadlessInitState.INSTANCE_RESTORED;
this.headlessRequest = (HeadlessRequest) serializable;
Utility.debugLog("headless request is restored: " + this.headlessRequest.makeJson());
}
HeadlessRequest headlessRequest = this.headlessRequest;
if (headlessRequest != null) {
str = headlessRequest.getChannelType();
}
} else if (this.mOtplessRequest == null) {
Serializable serializable2 = bundle.getSerializable("otpless_login_request");
if (serializable2 instanceof OtplessRequest) {
Utility.debugLog("Login request is restored");
this.mOtplessRequest = (OtplessRequest) serializable2;
}
OtplessRequest otplessRequest = this.mOtplessRequest;
if (otplessRequest != null && otplessRequest.getExtras() != null) {
str = this.mOtplessRequest.getExtras().get("channel");
}
}
if (this.loginUri == null) {
this.loginUri = bundle.getString("otpless_login_uri");
}
if (!"FACEBOOK_SDK".equals(str) || (facebookSignInSdk = this.facebookSignInSdk) == null) {
return;
}
facebookSignInSdk.registerCallback(new l() {
public final Object invoke(Object obj) {
j0 lambda$restoreSavedInstance$0;
lambda$restoreSavedInstance$0 = OtplessViewImpl.this.lambda$restoreSavedInstance$0((JSONObject) obj);
return lambda$restoreSavedInstance$0;
}
});
}
private void sendIntentInEvent(boolean z) {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("type", z ? GraphResponse.SUCCESS_KEY : "error");
Utility.pushEvent("intent_redirect_in", jSONObject);
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
private boolean verifyIntent(Intent intent) {
if (this.mWhatsappOtpReader.isAutoReadIntent(intent)) {
Utility.debugLog("whatsapp onetap intent received");
OtplessContainerView otplessContainerView = this.wContainer.get();
if (otplessContainerView != null && otplessContainerView.getWebManager() != null) {
this.mWhatsappOtpReader.processOneTapIntent(intent);
}
return true;
}
Uri data = intent.getData();
if (data == null || !"otpless".equals(data.getHost())) {
return false;
}
if ("headless".equals(data.getQueryParameter("requestType"))) {
this.isHeadless = true;
}
String queryParameter = data.getQueryParameter(ShareConstants.MEDIA_URI);
if (Utility.isValid(new String[]{queryParameter})) {
try {
Uri parse = Uri.parse(queryParameter);
if (parse.getHost() != null) {
if (parse.getHost().contains("otpless")) {
Utility.openChromeCustomTab(this.activity, parse);
this.isPushedToWebHr = false;
return true;
}
}
} catch (Exception unused) {
}
return false;
}
this.isPushedToWebHr = false;
OtplessContainerView otplessContainerView2 = this.wContainer.get();
if (otplessContainerView2 == null || otplessContainerView2.getWebView() == null) {
Utility.debugLog("adding the view in low memory case.");
addViewIfNotAdded();
loadWebView(null, data);
} else {
loadWebView(this.wContainer.get().getWebView().getLoadedUrl(), data);
}
return true;
}
@Override
public void afterHeadlessRequestPushed() {
this.isPushedToWebHr = true;
}
@Override
public void attachOtplessSecureService(OtplessSecureService otplessSecureService) {
this.secureService = otplessSecureService;
}
@Override
public void closeCountDownTimer() {
CountDownTimer countDownTimer = this.countDownTimer;
if (countDownTimer != null) {
countDownTimer.cancel();
}
}
@Override
public void closeView() {
Utility.pushEvent("native_close_view");
removeView();
}
@Override
public void commitHeadlessResponse(HeadlessResponse headlessResponse) {
if (headlessResponse == null) {
Utility.pushEvent("native_headless_merchant_commit");
} else {
OtplessUtility.INSTANCE.convertToEventParamsJson(headlessResponse, new a(0));
}
}
public Activity getActivity() {
return this.activity;
}
@Override
@NonNull
public String getAppId() {
return this.appId;
}
@Override
@NonNull
public OtplessConnectivityManager getConnectivityManager() {
return this.connectivityManager;
}
@Override
@Nullable
public JSONObject getExtraParams() {
JSONObject jsonObj;
if (this.isHeadless) {
HeadlessRequest headlessRequest = this.headlessRequest;
if (headlessRequest == null) {
headlessRequest = new HeadlessRequest();
}
jsonObj = headlessRequest.makeJson();
} else {
jsonObj = this.mOtplessRequest.toJsonObj();
}
JSONObject jSONObject = (JSONObject) this.ssoSdkLowMemData.getData();
if (jSONObject != null) {
try {
jsonObj.put("ssoSdkResponse", jSONObject);
} catch (JSONException unused) {
}
}
return jsonObj;
}
@Override
@Nullable
public FacebookSignInSdk getFacebookSignInSdk() {
return this.facebookSignInSdk;
}
@Override
@Nullable
public GoogleCredentialSdk getGoogleSignInSdk() {
return this.googleSignInSdk;
}
@Override
@NonNull
public String getInstallationId() {
return this.installId;
}
@Override
@NonNull
public OtplessCellularNetwork getOtplessCellularNetwork() {
return this.otplessCellularNetwork;
}
@Override
@Nullable
public OtplessSecureService getOtplessSecureService() {
return this.secureService;
}
public OtplessPhoneHintManager getPhoneHintManager() {
return this.phoneHintManager;
}
@Override
@Nullable
public JSONObject getRequestJsonForEvent() {
if (this.isHeadless) {
HeadlessRequest headlessRequest = this.headlessRequest;
if (headlessRequest != null) {
return headlessRequest.makeJson();
}
return null;
}
OtplessRequest otplessRequest = this.mOtplessRequest;
if (otplessRequest != null) {
return otplessRequest.toJsonObj();
}
return null;
}
@Override
@NonNull
public String getTrackingSessionId() {
return this.trackingSessionId;
}
@Override
public OtplessWebAuthnManager getWebAuthnManager() {
if (this.webAuthnManager == null) {
this.webAuthnManager = new OtplessWebAuthnManagerImpl(this.activity);
}
return this.webAuthnManager;
}
@Override
@NonNull
public WhatsappOtpReader getWhatsAppOtpReader() {
return this.mWhatsappOtpReader;
}
@Override
public void handleEmptyWebResponse(@Nullable final String str) {
CountDownTimer countDownTimer = this.countDownTimer;
if (countDownTimer != null) {
countDownTimer.cancel();
}
HeadlessRequest headlessRequest = this.headlessRequest;
if (headlessRequest == null) {
return;
}
OtplessUtility otplessUtility = OtplessUtility.INSTANCE;
HeadlessResponse makeEmptyWebResponse = otplessUtility.makeEmptyWebResponse(headlessRequest);
otplessUtility.convertToEventParamsJson(makeEmptyWebResponse, new q() {
public final Object invoke(Object obj, Object obj2, Object obj3) {
j0 lambda$handleEmptyWebResponse$2;
lambda$handleEmptyWebResponse$2 = OtplessViewImpl.lambda$handleEmptyWebResponse$2(str, (JSONObject) obj, (String) obj2, (String) obj3);
return lambda$handleEmptyWebResponse$2;
}
});
onHeadlessResult(makeEmptyWebResponse, true);
}
@Override
public void hideContainerView() {
this.isContainerViewInvisible = true;
}
@Override
public void initHeadless(@NonNull String str) {
initHeadless(str, null);
}
@Override
public boolean isHeadlessRequestPushed() {
return this.isPushedToWebHr;
}
@Override
public boolean onActivityResult(int i, int i2, Intent intent) {
FacebookSignInSdk facebookSignInSdk = this.facebookSignInSdk;
if (facebookSignInSdk != null) {
facebookSignInSdk.onActivityResult(i, i2, intent);
}
OtplessContainerView otplessContainerView = this.wContainer.get();
if (otplessContainerView == null || otplessContainerView.getWebView() == null || otplessContainerView.getWebManager() == null) {
return false;
}
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("resultCode", i2);
jSONObject.put("requestCode", i);
} catch (JSONException unused) {
}
Utility.pushEvent("native_activity_result", jSONObject);
return otplessContainerView.getWebManager().onActivityResult(i, i2, intent);
}
public void onActivitySaveInstance(@NonNull Bundle bundle) {
HeadlessRequest headlessRequest;
bundle.putBoolean("is_otpless_headless", this.isHeadless);
if (!this.isHeadless || (headlessRequest = this.headlessRequest) == null) {
OtplessRequest otplessRequest = this.mOtplessRequest;
if (otplessRequest != null) {
bundle.putSerializable("otpless_login_request", otplessRequest);
Utility.debugLog("login request is stored");
}
} else {
bundle.putSerializable("otpless_headless_request", headlessRequest);
Utility.debugLog("headless request is stored");
}
if (!this.appId.isEmpty()) {
bundle.putString("otpless_app_id", this.appId);
}
String str = this.loginUri;
if (str == null || str.isEmpty()) {
return;
}
bundle.putString("otpless_login_uri", this.loginUri);
}
@Override
public boolean onBackPressed() {
NativeWebManager webManager;
OtplessWebView webView;
Utility.pushEvent("native_back_press");
if (this.wContainer.get() == null || (webManager = this.wContainer.get().getWebManager()) == null || (webView = this.wContainer.get().getWebView()) == null) {
return false;
}
if (this.eventCallback != null && this.backSubscription) {
if (webManager.getBackSubscription()) {
webView.callWebJs("onHardBackPressed", new Object[0]);
}
this.eventCallback.onOtplessEvent(new OtplessEventData(2, null));
return true;
}
if (webManager.getBackSubscription()) {
webView.callWebJs("onHardBackPressed", new Object[0]);
} else {
if (this.isHeadless) {
return false;
}
onVerificationResult(0, null);
}
return true;
}
public void onConnectionChange(NetworkStatusData networkStatusData) {
}
@Override
public void onHeadlessResult(HeadlessResponse headlessResponse, boolean z) {
HeadlessRequest headlessRequest;
if (this.headlessResponseCallback != null && (headlessResponse.getStatusCode() != 5002 || ((headlessRequest = this.headlessRequest) != null && headlessRequest.getChannel() != null))) {
this.headlessResponseCallback.onHeadlessResponse(headlessResponse);
}
if (z) {
removeView();
}
}
@Override
public boolean onNewIntent(Intent intent) {
Utility.pushEvent("native_new_intent");
return verifyIntent(intent);
}
@Override
public void onOtplessEvent(OtplessEventData otplessEventData) {
OtplessEventCallback otplessEventCallback = this.eventCallback;
if (otplessEventCallback == null) {
return;
}
otplessEventCallback.onOtplessEvent(otplessEventData);
}
public void onPostActivityCreated(@Nullable Bundle bundle) {
Activity activity = this.activity;
if (activity instanceof androidx.activity.h) {
this.phoneHintManager.register(activity, true);
}
this.initAction = HeadlessInitState.POST_RECREATED;
if (bundle != null) {
restoreSavedInstance(bundle);
if (verifyIntent(this.activity.getIntent())) {
Utility.pushEvent("native_verify_intent_low_mem");
return;
}
return;
}
if (this.isHeadless) {
Utility.debugLog("init otpless in post recreated");
initUrlLoading();
}
}
@Override
public void onVerificationResult(int i, JSONObject jSONObject) {
if (this.detailCallback != null) {
OtplessResponse otplessResponse = new OtplessResponse();
if (i == 0) {
otplessResponse.setErrorMessage("user cancelled");
this.detailCallback.onOtplessUserDetail(otplessResponse);
} else {
String optString = jSONObject.optString("error");
if (optString.isEmpty()) {
otplessResponse.setData(jSONObject);
} else {
otplessResponse.setErrorMessage(optString);
}
this.detailCallback.onOtplessUserDetail(otplessResponse);
}
}
removeView();
}
@Override
public void setBackBackButtonSubscription(boolean z) {
this.backSubscription = z;
}
@Override
public void setCallback(@NonNull OtplessRequest otplessRequest, OtplessUserDetailCallback otplessUserDetailCallback) {
this.appId = otplessRequest.getAppId();
this.mOtplessRequest = otplessRequest;
this.detailCallback = otplessUserDetailCallback;
this.isHeadless = false;
Utility.pushEvent("native_set_login_page_callback");
}
@Override
public void setEventCallback(OtplessEventCallback otplessEventCallback) {
this.eventCallback = otplessEventCallback;
}
@Override
public void setHeadlessCallback(HeadlessResponseCallback headlessResponseCallback) {
Utility.pushEvent("native_set_headless_callback");
this.headlessResponseCallback = headlessResponseCallback;
}
@Override
public void setLoaderVisibility(boolean z) {
this.isLoaderVisible = z;
}
@Override
public void setRetryVisibility(boolean z) {
this.isRetryVisible = z;
}
@Override
public void showOtplessLoginPage(@NonNull OtplessRequest otplessRequest, OtplessUserDetailCallback otplessUserDetailCallback) {
this.appId = otplessRequest.getAppId();
this.detailCallback = otplessUserDetailCallback;
this.mOtplessRequest = otplessRequest;
this.isHeadless = false;
Utility.pushEvent("native_show_login_page");
addViewIfNotAdded();
loadWebView(null, null);
}
@Override
public void startHeadless(@NonNull HeadlessRequest headlessRequest, HeadlessResponseCallback headlessResponseCallback) {
this.isPushedToWebHr = false;
this.headlessRequest = headlessRequest;
this.headlessResponseCallback = headlessResponseCallback;
Utility.pushEvent("native_start_headless");
CountDownTimer countDownTimer = this.countDownTimer;
if (countDownTimer != null) {
countDownTimer.cancel();
}
AnonymousClass1 anonymousClass1 = new AnonymousClass1(this.countDownFuture, 1000L);
this.countDownTimer = anonymousClass1;
anonymousClass1.start();
OtplessContainerView otplessContainerView = this.wContainer.get();
if (otplessContainerView != null && otplessContainerView.getWebView() != null && otplessContainerView.getWebView().getLoadedUrl() != null) {
otplessContainerView.getWebManager().sendHeadlessRequest();
} else {
addViewIfNotAdded();
loadWebView(null, null);
}
}
@Override
public void initHeadless(@NonNull String str, @Nullable String str2) {
initHeadless(str, str2, 30L);
}
@Override
public void initHeadless(@NonNull String str, @Nullable String str2, long j) {
this.appId = str;
this.isHeadless = true;
this.loginUri = str2;
this.countDownFuture = j * 1000;
if (this.initAction == HeadlessInitState.INSTANCE_RESTORED) {
this.initAction = HeadlessInitState.NONE;
Utility.debugLog("returning init in instance restored case");
return;
}
Utility.pushEvent("native_init_headless");
if (this.initAction == HeadlessInitState.POST_RECREATED) {
Utility.debugLog("init otpless after post recreated");
initUrlLoading();
}
}
}