导航菜单

页面标题

页面副标题

Cashalo v2.25.0.0 - TelephonyComponent.java 源代码

正在查看: Cashalo v2.25.0.0 应用的 TelephonyComponent.java JAVA 源代码文件

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


package finance.empower.android.app.components;

import android.app.Activity;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Parcelable;
import androidx.activity.result.ActivityResult;
import androidx.activity.result.ActivityResultCallback;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.IntentSenderRequest;
import androidx.activity.result.contract.ActivityResultContract;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.core.content.IntentCompat;
import com.google.android.gms.auth.api.identity.GetPhoneNumberHintIntentRequest;
import com.google.android.gms.auth.api.identity.Identity;
import com.google.android.gms.auth.api.identity.SignInClient;
import com.google.android.gms.auth.api.phone.SmsRetriever;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.tasks.Continuation;
import com.google.android.gms.tasks.Task;
import com.google.firebase.crashlytics.FirebaseCrashlytics;
import com.tom_roush.fontbox.ttf.NamingTable;
import finance.empower.android.app.BaseComponentActivity;
import finance.empower.android.app.components.TelephonyComponent;
import finance.empower.android.app.dagger.ActivityContext;
import finance.empower.android.app.dagger.ScreenScope;
import finance.empower.android.framework.DebugToggle;
import finance.empower.android.framework.ReleaseConfig;
import finance.empower.android.view.components.forms.Country;
import io.ashdavies.rx.rxtasks.SingleTaskKt;
import io.reactivex.Single;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.rxkotlin.DisposableKt;
import io.reactivex.schedulers.Schedulers;
import javax.inject.Inject;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.StringsKt;
import timber.log.Timber;

@ScreenScope
@Metadata(d1 = {"\u0000V\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010\u000e\n\u0002\u0018\u0002\n\u0002\b\u0007\b\u0007\u0018\u00002\u00020\u0001:\u0001\u001fB!\b\u0007\u0012\b\b\u0001\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0005\u0012\u0006\u0010\u0006\u001a\u00020\u0007¢\u0006\u0002\u0010\bJE\u0010\u0014\u001a\u00020\u00152%\b\u0002\u0010\u0016\u001a\u001f\u0012\u0013\u0012\u00110\u0018¢\u0006\f\b\u0019\u0012\b\b\u001a\u0012\u0004\b\b(\u001b\u0012\u0004\u0012\u00020\u0015\u0018\u00010\u00172\u0016\b\u0002\u0010\u001c\u001a\u0010\u0012\u0004\u0012\u00020\u0018\u0012\u0004\u0012\u00020\u0015\u0018\u00010\u0017J\u0006\u0010\u001d\u001a\u00020\u0015J\u0006\u0010\u001e\u001a\u00020\u0015R\u000e\u0010\u0004\u001a\u00020\u0005X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\t\u001a\u00020\nX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u000b\u001a\u00020\fX\u0082\u0004¢\u0006\u0002\n\u0000R\u0016\u0010\r\u001a\n\u0012\u0004\u0012\u00020\u000f\u0018\u00010\u000eX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0010\u001a\u00020\u0011X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0007X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0012\u001a\u00020\u0013X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006 "}, d2 = {"Lfinance/empower/android/app/components/TelephonyComponent;", "", "context", "Landroid/content/Context;", "activity", "Lfinance/empower/android/app/BaseComponentActivity;", "releaseConfig", "Lfinance/empower/android/framework/ReleaseConfig;", "(Landroid/content/Context;Lfinance/empower/android/app/BaseComponentActivity;Lfinance/empower/android/framework/ReleaseConfig;)V", "disposables", "Lio/reactivex/disposables/CompositeDisposable;", "identityClient", "Lcom/google/android/gms/auth/api/identity/SignInClient;", "phoneNumberResultLauncher", "Landroidx/activity/result/ActivityResultLauncher;", "Landroidx/activity/result/IntentSenderRequest;", "registeredReceiver", "", "smsBroadcastReceiver", "Lfinance/empower/android/app/components/TelephonyComponent$SmsBroadcastReceiver;", "bind", "", "onMessageReceived", "Lkotlin/Function1;", "", "Lkotlin/ParameterName;", NamingTable.TAG, "message", "onPhoneNumberSelected", "showPhoneNumberSelection", "unbind", "SmsBroadcastReceiver", "empower-app_release"}, k = 1, mv = {1, 9, 0}, xi = 48)
public final class TelephonyComponent {
    public static final int $stable = 8;
    private final BaseComponentActivity activity;
    private final Context context;
    private final CompositeDisposable disposables;
    private final SignInClient identityClient;
    private ActivityResultLauncher<IntentSenderRequest> phoneNumberResultLauncher;
    private boolean registeredReceiver;
    private final ReleaseConfig releaseConfig;
    private final SmsBroadcastReceiver smsBroadcastReceiver;

    @Inject
    public TelephonyComponent(@ActivityContext Context context, BaseComponentActivity baseComponentActivity, ReleaseConfig releaseConfig) {
        Intrinsics.checkNotNullParameter(context, "context");
        Intrinsics.checkNotNullParameter(baseComponentActivity, "activity");
        Intrinsics.checkNotNullParameter(releaseConfig, "releaseConfig");
        this.context = context;
        this.activity = baseComponentActivity;
        this.releaseConfig = releaseConfig;
        this.smsBroadcastReceiver = new SmsBroadcastReceiver();
        this.disposables = new CompositeDisposable();
        SignInClient signInClient = Identity.getSignInClient((Activity) baseComponentActivity);
        Intrinsics.checkNotNullExpressionValue(signInClient, "getSignInClient(...)");
        this.identityClient = signInClient;
    }

    public final void showPhoneNumberSelection() {
        final ActivityResultLauncher<IntentSenderRequest> activityResultLauncher = this.phoneNumberResultLauncher;
        if (activityResultLauncher != null) {
            Task phoneNumberHintIntent = this.identityClient.getPhoneNumberHintIntent(GetPhoneNumberHintIntentRequest.builder().build());
            Intrinsics.checkNotNullExpressionValue(phoneNumberHintIntent, "getPhoneNumberHintIntent(...)");
            Single single = SingleTaskKt.toSingle(phoneNumberHintIntent);
            final Function1<PendingIntent, Unit> function1 = new Function1<PendingIntent, Unit>() {
                {
                    super(1);
                }

                public Object invoke(Object obj) {
                    invoke((PendingIntent) obj);
                    return Unit.INSTANCE;
                }

                public final void invoke(PendingIntent pendingIntent) {
                    try {
                        ActivityResultLauncher<IntentSenderRequest> activityResultLauncher2 = activityResultLauncher;
                        Intrinsics.checkNotNull(pendingIntent);
                        activityResultLauncher2.launch(new IntentSenderRequest.Builder(pendingIntent).build());
                    } catch (Exception e) {
                        FirebaseCrashlytics.getInstance().recordException(e);
                    }
                }
            };
            Consumer consumer = new Consumer() {
                @Override
                public final void accept(Object obj) {
                    TelephonyComponent.showPhoneNumberSelection$lambda$2$lambda$0(function1, obj);
                }
            };
            final TelephonyComponent$showPhoneNumberSelection$1$2 telephonyComponent$showPhoneNumberSelection$1$2 = new Function1<Throwable, Unit>() {
                public Object invoke(Object obj) {
                    invoke((Throwable) obj);
                    return Unit.INSTANCE;
                }

                public final void invoke(Throwable th) {
                    Intrinsics.checkNotNull(th);
                    FirebaseCrashlytics.getInstance().recordException(th);
                }
            };
            Disposable subscribe = single.subscribe(consumer, new Consumer() {
                @Override
                public final void accept(Object obj) {
                    TelephonyComponent.showPhoneNumberSelection$lambda$2$lambda$1(telephonyComponent$showPhoneNumberSelection$1$2, obj);
                }
            });
            Intrinsics.checkNotNullExpressionValue(subscribe, "subscribe(...)");
            DisposableKt.addTo(subscribe, this.disposables);
        }
    }

    public static final void showPhoneNumberSelection$lambda$2$lambda$0(Function1 function1, Object obj) {
        Intrinsics.checkNotNullParameter(function1, "$tmp0");
        function1.invoke(obj);
    }

    public static final void showPhoneNumberSelection$lambda$2$lambda$1(Function1 function1, Object obj) {
        Intrinsics.checkNotNullParameter(function1, "$tmp0");
        function1.invoke(obj);
    }

    public static void bind$default(TelephonyComponent telephonyComponent, Function1 function1, Function1 function12, int i, Object obj) {
        if ((i & 1) != 0) {
            function1 = null;
        }
        if ((i & 2) != 0) {
            function12 = null;
        }
        telephonyComponent.bind(function1, function12);
    }

    public final void bind(final Function1<? super String, Unit> onMessageReceived, final Function1<? super String, Unit> onPhoneNumberSelected) {
        if (onPhoneNumberSelected != null) {
            this.phoneNumberResultLauncher = this.activity.registerForActivityResult((ActivityResultContract) new ActivityResultContracts.StartIntentSenderForResult(), new ActivityResultCallback() {
                public final void onActivityResult(Object obj) {
                    TelephonyComponent.bind$lambda$4$lambda$3(TelephonyComponent.this, onPhoneNumberSelected, (ActivityResult) obj);
                }
            });
        }
        if (onMessageReceived != null) {
            Task continueWith = SmsRetriever.getClient(this.context).startSmsRetriever().continueWith(new Continuation() {
                public final Object then(Task task) {
                    Unit bind$lambda$8$lambda$5;
                    bind$lambda$8$lambda$5 = TelephonyComponent.bind$lambda$8$lambda$5(task);
                    return bind$lambda$8$lambda$5;
                }
            });
            Intrinsics.checkNotNullExpressionValue(continueWith, "continueWith(...)");
            Single observeOn = SingleTaskKt.toSingle(continueWith).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
            final Function1<Unit, Unit> function1 = new Function1<Unit, Unit>() {
                {
                    super(1);
                }

                public Object invoke(Object obj) {
                    invoke((Unit) obj);
                    return Unit.INSTANCE;
                }

                public final void invoke(Unit unit) {
                    TelephonyComponent.SmsBroadcastReceiver smsBroadcastReceiver;
                    Context context;
                    TelephonyComponent.SmsBroadcastReceiver smsBroadcastReceiver2;
                    smsBroadcastReceiver = TelephonyComponent.this.smsBroadcastReceiver;
                    final Function1<String, Unit> function12 = onMessageReceived;
                    smsBroadcastReceiver.bind(new Function1<String, Unit>() {
                        {
                            super(1);
                        }

                        public Object invoke(Object obj) {
                            invoke((String) obj);
                            return Unit.INSTANCE;
                        }

                        public final void invoke(String str) {
                            Intrinsics.checkNotNullParameter(str, "message");
                            function12.invoke(str);
                        }
                    });
                    context = TelephonyComponent.this.context;
                    smsBroadcastReceiver2 = TelephonyComponent.this.smsBroadcastReceiver;
                    context.registerReceiver(smsBroadcastReceiver2, new IntentFilter("com.google.android.gms.auth.api.phone.SMS_RETRIEVED"));
                    TelephonyComponent.this.registeredReceiver = true;
                }
            };
            Consumer consumer = new Consumer() {
                @Override
                public final void accept(Object obj) {
                    TelephonyComponent.bind$lambda$8$lambda$6(function1, obj);
                }
            };
            final TelephonyComponent$bind$2$3 telephonyComponent$bind$2$3 = new Function1<Throwable, Unit>() {
                public Object invoke(Object obj) {
                    invoke((Throwable) obj);
                    return Unit.INSTANCE;
                }

                public final void invoke(Throwable th) {
                    Intrinsics.checkNotNull(th);
                    FirebaseCrashlytics.getInstance().recordException(th);
                }
            };
            Disposable subscribe = observeOn.subscribe(consumer, new Consumer() {
                @Override
                public final void accept(Object obj) {
                    TelephonyComponent.bind$lambda$8$lambda$7(telephonyComponent$bind$2$3, obj);
                }
            });
            Intrinsics.checkNotNullExpressionValue(subscribe, "subscribe(...)");
            DisposableKt.addTo(subscribe, this.disposables);
        }
    }

    public static final void bind$lambda$4$lambda$3(TelephonyComponent telephonyComponent, Function1 function1, ActivityResult activityResult) {
        Intrinsics.checkNotNullParameter(telephonyComponent, "this$0");
        try {
            String phoneNumberFromIntent = telephonyComponent.identityClient.getPhoneNumberFromIntent(activityResult.getData());
            Intrinsics.checkNotNullExpressionValue(phoneNumberFromIntent, "getPhoneNumberFromIntent(...)");
            Country country = Country.PHILLIPINES;
            if (telephonyComponent.releaseConfig.isDebugToggleEnabled(DebugToggle.OVERRIDE_MOBILE_COUNTRY_CODE)) {
                function1.invoke(StringsKt.takeLast(phoneNumberFromIntent, country.getPhoneNumberLength()));
            } else if (StringsKt.startsWith$default(phoneNumberFromIntent, country.getCountryCode(), false, 2, (Object) null)) {
                function1.invoke(StringsKt.removePrefix(phoneNumberFromIntent, country.getCountryCode()));
            } else {
                Timber.Forest.d("We only support numbers starting with " + country.getCountryCode(), new Object[0]);
            }
        } catch (Exception unused) {
            Timber.Forest.d("Phone Number Hint failed", new Object[0]);
        }
    }

    public static final Unit bind$lambda$8$lambda$5(Task task) {
        Intrinsics.checkNotNullParameter(task, "it");
        return Unit.INSTANCE;
    }

    public static final void bind$lambda$8$lambda$6(Function1 function1, Object obj) {
        Intrinsics.checkNotNullParameter(function1, "$tmp0");
        function1.invoke(obj);
    }

    public static final void bind$lambda$8$lambda$7(Function1 function1, Object obj) {
        Intrinsics.checkNotNullParameter(function1, "$tmp0");
        function1.invoke(obj);
    }

    public final void unbind() {
        this.smsBroadcastReceiver.clear();
        try {
            if (this.registeredReceiver) {
                this.context.unregisterReceiver(this.smsBroadcastReceiver);
            }
            this.registeredReceiver = false;
        } catch (IllegalArgumentException e) {
            FirebaseCrashlytics.getInstance().recordException(e);
        }
        this.disposables.clear();
    }

    @Metadata(d1 = {"\u0000(\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u000e\n\u0002\u0010\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\b\u0002\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J\u001a\u0010\u0007\u001a\u00020\u00062\u0012\u0010\u0003\u001a\u000e\u0012\u0004\u0012\u00020\u0005\u0012\u0004\u0012\u00020\u00060\u0004J\u0006\u0010\b\u001a\u00020\u0006J\u0018\u0010\t\u001a\u00020\u00062\u0006\u0010\n\u001a\u00020\u000b2\u0006\u0010\f\u001a\u00020\rH\u0016R\u001c\u0010\u0003\u001a\u0010\u0012\u0004\u0012\u00020\u0005\u0012\u0004\u0012\u00020\u0006\u0018\u00010\u0004X\u0082\u000e¢\u0006\u0002\n\u0000¨\u0006\u000e"}, d2 = {"Lfinance/empower/android/app/components/TelephonyComponent$SmsBroadcastReceiver;", "Landroid/content/BroadcastReceiver;", "()V", "onSmsReceived", "Lkotlin/Function1;", "", "", "bind", "clear", "onReceive", "context", "Landroid/content/Context;", "intent", "Landroid/content/Intent;", "empower-app_release"}, k = 1, mv = {1, 9, 0}, xi = 48)
    static final class SmsBroadcastReceiver extends BroadcastReceiver {
        private Function1<? super String, Unit> onSmsReceived;

        public final void bind(Function1<? super String, Unit> onSmsReceived) {
            Intrinsics.checkNotNullParameter(onSmsReceived, "onSmsReceived");
            this.onSmsReceived = onSmsReceived;
        }

        public final void clear() {
            this.onSmsReceived = null;
        }

        @Override
        public void onReceive(Context context, Intent intent) {
            Status status;
            Bundle extras;
            String string;
            Function1<? super String, Unit> function1;
            Intrinsics.checkNotNullParameter(context, "context");
            Intrinsics.checkNotNullParameter(intent, "intent");
            if (!Intrinsics.areEqual(intent.getAction(), "com.google.android.gms.auth.api.phone.SMS_RETRIEVED") || (status = (Parcelable) IntentCompat.getParcelableExtra(intent, "com.google.android.gms.auth.api.phone.EXTRA_STATUS", Status.class)) == null || status.getStatusCode() != 0 || (extras = intent.getExtras()) == null || (string = extras.getString("com.google.android.gms.auth.api.phone.EXTRA_SMS_MESSAGE")) == null || (function1 = this.onSmsReceived) == null) {
                return;
            }
            function1.invoke(string);
        }
    }
}