正在查看: Namma Yatri v3.3.7 应用的 TrueCallerModule.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Namma Yatri v3.3.7 应用的 TrueCallerModule.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mobility.movingtech.reactNativeBridge;
import Vc.D;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import androidx.fragment.app.FragmentActivity;
import com.facebook.react.bridge.ActivityEventListener;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.WritableNativeMap;
import com.google.firebase.crashlytics.FirebaseCrashlytics;
import com.mobility.movingtech.n;
import com.truecaller.android.sdk.oAuth.TcOAuthCallback;
import com.truecaller.android.sdk.oAuth.TcOAuthData;
import com.truecaller.android.sdk.oAuth.TcOAuthError;
import com.truecaller.android.sdk.oAuth.TcSdk;
import com.truecaller.android.sdk.oAuth.TcSdkOptions;
import com.truecaller.android.sdk.oAuth.b;
import gd.AbstractC0499c;
import in.juspay.hypersdk.core.PaymentConstants;
import java.io.IOException;
import java.math.BigInteger;
import java.security.SecureRandom;
import kotlin.jvm.internal.m;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import org.json.JSONObject;
public final class TrueCallerModule extends ReactContextBaseJavaModule implements ActivityEventListener {
private String TAG;
private ReactApplicationContext reactTrueCallerContext;
public static final class a implements Callback {
final Promise b;
a(Promise promise) {
this.b = promise;
}
@Override
public void onFailure(Call call, IOException e) {
m.i(call, "call");
m.i(e, "e");
Log.e(TrueCallerModule.this.TAG, "Access token API failed " + e);
this.b.reject("ACCESS_TOKEN_FAILED", "Access token API failed");
}
@Override
public void onResponse(Call call, Response response) {
m.i(call, "call");
m.i(response, "response");
TrueCallerModule trueCallerModule = TrueCallerModule.this;
Promise promise = this.b;
try {
if (response.y0()) {
ResponseBody c = response.c();
String w0 = c != null ? c.w0() : null;
if (w0 != null) {
try {
String string = new JSONObject(w0).getString("access_token");
m.f(string);
trueCallerModule.getUserProfile(string, promise);
String unused = trueCallerModule.TAG;
StringBuilder sb2 = new StringBuilder();
sb2.append("getAccessToken Response: ");
sb2.append(w0);
} catch (Exception e) {
Log.e(trueCallerModule.TAG, "Failed to get access_token from body " + e);
promise.reject("ACCESS_TOKEN_PARSE_ERR", "Failed to get access_token from body");
}
}
} else {
Log.e(trueCallerModule.TAG, "getAccessToken Error: " + response.y());
promise.reject("ACCESS_TOKEN_FAILED", "Access token API failed with code " + response.y() + " " + response.c());
}
D d = D.a;
AbstractC0499c.a(response, null);
} finally {
}
}
}
public static final class b implements Callback {
final Promise a;
final TrueCallerModule b;
b(Promise promise, TrueCallerModule trueCallerModule) {
this.a = promise;
this.b = trueCallerModule;
}
@Override
public void onFailure(Call call, IOException e) {
m.i(call, "call");
m.i(e, "e");
this.a.reject("TC_USER_PROFILE_ERR", "TrueCaller profile api failed");
Log.e(this.b.TAG, "TrueCaller profile api failed " + e);
}
@Override
public void onResponse(Call call, Response response) {
m.i(call, "call");
m.i(response, "response");
Promise promise = this.a;
TrueCallerModule trueCallerModule = this.b;
try {
if (response.y0()) {
ResponseBody c = response.c();
String w0 = c != null ? c.w0() : null;
if (w0 == null || w0.length() == 0) {
Log.e(trueCallerModule.TAG, "Empty response from server");
promise.reject("TC_USER_PROFILE_EMPTY", "Empty response from server");
} else {
try {
promise.resolve(n.a.b(new JSONObject(w0)));
} catch (Exception e) {
Log.e(trueCallerModule.TAG, "Failed to parse response " + e);
promise.reject("TC_USER_PROFILE_PARSE_ERR", "Failed to parse response", e);
}
}
} else {
Log.e(trueCallerModule.TAG, "API failed with code " + response.y());
promise.reject("TC_USER_PROFILE_ERR", "API failed with code " + response.y());
}
D d = D.a;
AbstractC0499c.a(response, null);
} finally {
}
}
}
public static final class c implements TcOAuthCallback {
final String b;
final Promise c;
c(String str, Promise promise) {
this.b = str;
this.c = promise;
}
@Override
public void onFailure(TcOAuthError tcOAuthError) {
m.i(tcOAuthError, "tcOAuthError");
Log.e(TrueCallerModule.this.TAG, "initTrueCallerSDK onFailure " + tcOAuthError);
this.c.reject("TC_AUTH_FAILED", "TrueCaller SDK oAuth Failed");
}
@Override
public void onSuccess(TcOAuthData tcOAuthData) {
m.i(tcOAuthData, "tcOAuthData");
String unused = TrueCallerModule.this.TAG;
StringBuilder sb2 = new StringBuilder();
sb2.append("initTrueCallerSDK onSuccess ");
sb2.append(tcOAuthData);
TrueCallerModule.this.getAccessToken(tcOAuthData.getAuthorizationCode(), this.b, this.c);
}
@Override
public void onVerificationRequired(TcOAuthError tcOAuthError) {
Log.e(TrueCallerModule.this.TAG, "initTrueCallerSDK onVerificationRequired " + tcOAuthError);
}
}
public TrueCallerModule(ReactApplicationContext reactContext) {
super(reactContext);
m.i(reactContext, "reactContext");
this.reactTrueCallerContext = reactContext;
this.TAG = "TrueCallerModule";
reactContext.addActivityEventListener(this);
}
public final void getAccessToken(String str, String str2, Promise promise) {
String string = this.reactTrueCallerContext.getString(com.mobility.movingtech.m.b);
m.h(string, "getString(...)");
new OkHttpClient().a(new Request.Builder().l("https://oauth-account-noneu.truecaller.com/v1/token").a("Content-Type", "application/x-www-form-urlencoded").h(new FormBody.Builder(null, 1, null).a("grant_type", "authorization_code").a(PaymentConstants.CLIENT_ID, string).a("code", str).a("code_verifier", str2).c()).b()).r0(new a(promise));
}
public final void getUserProfile(String str, Promise promise) {
new OkHttpClient().a(new Request.Builder().l("https://oauth-account-noneu.truecaller.com/v1/userinfo").a("Authorization", "Bearer " + str).b()).r0(new b(promise, this));
}
public String getName() {
return "TrueCallerModule";
}
@ReactMethod
public final void getSignature(String payload, Promise promise) {
m.i(payload, "payload");
m.i(promise, "promise");
JSONObject jSONObject = new JSONObject(payload);
WritableNativeMap writableNativeMap = new WritableNativeMap();
writableNativeMap.putString(PaymentConstants.SIGNATURE, Db.a.a.a(jSONObject, "private-key.pem", this.reactTrueCallerContext));
promise.resolve(writableNativeMap);
}
@ReactMethod
public final void initTrueCallerSDK(Promise promise) {
m.i(promise, "promise");
try {
b.a aVar = com.truecaller.android.sdk.oAuth.b.a;
String a2 = aVar.a();
TcSdk.init(new TcSdkOptions.Builder(this.reactTrueCallerContext, new c(a2, promise)).build());
if (!TcSdk.getInstance().isOAuthFlowUsable()) {
Log.e(this.TAG, "True caller not found");
promise.reject("TRUE_CALLER_NOT_FOUND", "True caller not found");
}
TcSdk.getInstance().setOAuthState(new BigInteger(130, new SecureRandom()).toString(32));
TcSdk.getInstance().setOAuthScopes(new String[]{"profile", "phone", "email", "openid"});
String b2 = aVar.b(a2);
if (b2 == null) {
Log.e(this.TAG, "Code challenge is Null.Can’t proceed further");
promise.reject("CODE_CHALLENGE_NULL", "Code challenge is Null.Can’t proceed further");
return;
}
TcSdk.getInstance().setCodeChallenge(b2);
FragmentActivity currentActivity = this.reactTrueCallerContext.getCurrentActivity();
m.g(currentActivity, "null cannot be cast to non-null type androidx.fragment.app.FragmentActivity");
TcSdk.getInstance().getAuthorizationCode(currentActivity);
} catch (Exception e) {
promise.reject("TRUE_CALLER_UNKNOWN_ERROR", "True caller failed!");
Log.e(this.TAG, "Something went wrong! " + e);
}
}
public void onActivityResult(Activity activity, int i, int i2, Intent intent) {
if (i == 100) {
try {
TcSdk tcSdk = TcSdk.getInstance();
m.g(activity, "null cannot be cast to non-null type androidx.fragment.app.FragmentActivity");
tcSdk.onActivityResultObtained((FragmentActivity) activity, i, i2, intent);
} catch (Exception e) {
Log.e(this.TAG, "TcSdk not initialized, skipping result handling. " + e);
FirebaseCrashlytics.getInstance().recordException(e);
}
}
}
public void onNewIntent(Intent intent) {
}
}