导航菜单

页面标题

页面副标题

Minits v4.9.3.32 - SmsService.java 源代码

正在查看: Minits v4.9.3.32 应用的 SmsService.java JAVA 源代码文件

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


package com.xone.android.sms;

import Q8.k;
import Wa.d;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentSender;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.net.Uri;
import android.os.Build;
import android.telephony.SmsManager;
import android.text.TextUtils;
import android.util.Base64;
import androidx.annotation.Keep;
import androidx.fragment.app.j;
import ba.g;
import ba.h;
import com.google.android.gms.auth.api.credentials.Credential;
import com.google.android.gms.auth.api.credentials.HintRequest;
import com.xone.android.javascript.XOneJavascript;
import com.xone.android.utils.Utils;
import com.xone.annotations.ScriptAllowed;
import com.xone.interfaces.IRuntimeObject;
import com.xone.interfaces.IXoneApp;
import com.xone.interfaces.IXoneObject;
import fa.ThreadFactoryC0686d;
import fb.q;
import fb.t;
import ha.AbstractC0751f;
import j3.c;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import k3.b;
import m4.o;
import m5.x0;
import org.mozilla.javascript.BaseFunction;
import org.mozilla.javascript.C0893d0;
import org.mozilla.javascript.C0932x0;
import org.mozilla.javascript.Q0;
import org.mozilla.javascript.Scriptable;
import qa.EnumC0975b;
import ua.InterfaceC1016b0;
import ua.InterfaceC1038m0;
import ua.O0;
import ua.V;
import ua.W;

@ScriptAllowed
@Keep
public final class SmsService extends BaseFunction implements IRuntimeObject {
    private static final Map<String, W> mapTypeInfo = createTypeInfoData();
    private final InterfaceC1038m0 app;
    private ExecutorService executor;
    private long nRetryInterval = 30;

    public static class a extends BroadcastReceiver {
        public final ExecutorService a;
        public final IXoneObject b;
        public final Object c;
        public final Object d;

        public a(ExecutorService executorService, IXoneObject iXoneObject, Object obj, Object obj2) {
            this.a = executorService;
            this.b = iXoneObject;
            this.c = obj;
            this.d = obj2;
        }

        @Override
        public void onReceive(android.content.Context r9, android.content.Intent r10) {
            throw new UnsupportedOperationException("Method not decompiled: com.xone.android.sms.SmsService.a.onReceive(android.content.Context, android.content.Intent):void");
        }
    }

    @Keep
    public SmsService(Context context, IXoneApp iXoneApp) {
        this.app = (InterfaceC1038m0) context.getApplicationContext();
        XOneJavascript.addFunctions(this);
    }

    private static Map<String, W> createTypeInfoData() {
        Hashtable hashtable = new Hashtable();
        d dVar = new d("SetRetryInterval", O0.a);
        dVar.c("interval", 3, false);
        hashtable.put(dVar.getName().toLowerCase(), dVar);
        d dVar2 = new d("GetRetryInterval", O0.a);
        hashtable.put(dVar2.getName().toLowerCase(), dVar2);
        d dVar3 = new d("Send", O0.a);
        dVar3.c("phone", 1, false);
        dVar3.c("text", 1, false);
        dVar3.c("showSelector", 6, true);
        String name = dVar3.getName();
        Locale locale = Locale.US;
        hashtable.put(name.toLowerCase(locale), dVar3);
        d dVar4 = new d("SendRetry", O0.a);
        dVar4.c("phone", 1, false);
        dVar4.c("text", 1, false);
        hashtable.put(dVar4.getName().toLowerCase(locale), dVar4);
        d dVar5 = new d("DeleteUnsentSms", O0.a);
        hashtable.put(dVar5.getName().toLowerCase(locale), dVar5);
        return hashtable;
    }

    private Activity getLastEditOrMainEntry() {
        InterfaceC1038m0 app = getApp();
        Activity I0 = app.I0();
        if (I0 != null) {
            return I0;
        }
        j g = app.g();
        if (g != null) {
            return g;
        }
        Object S = app.S();
        if (S != null) {
            return (Activity) S;
        }
        return null;
    }

    private static Intent getNewSendSmsIntent(String str, String str2) {
        Intent intent = new Intent("android.intent.action.VIEW");
        intent.setData(Uri.parse("sms:"));
        intent.putExtra("sms_body", str2);
        if (!TextUtils.isEmpty(str)) {
            intent.putExtra("address", str);
        }
        return intent;
    }

    private static Intent getOldSendSmsIntent(String str, String str2) {
        Intent intent = new Intent("android.intent.action.VIEW");
        intent.putExtra("sms_body", str2);
        if (!TextUtils.isEmpty(str)) {
            intent.putExtra("address", str);
        }
        intent.setType("vnd.android-dir/mms-sms");
        return intent;
    }

    private IXoneObject getSelfObject() {
        Q0 m = XOneJavascript.m();
        if (m == null) {
            return null;
        }
        Object obj = m.get("self");
        if (obj instanceof IXoneObject) {
            return (IXoneObject) obj;
        }
        return null;
    }

    private static MessageDigest getSha256() {
        try {
            return MessageDigest.getInstance("SHA-256");
        } catch (NoSuchAlgorithmException e) {
            throw AbstractC0751f.e(e);
        }
    }

    private static List<Signature> getSignaturesClean(Signature[] signatureArr) {
        if (signatureArr == null) {
            return new ArrayList();
        }
        ArrayList arrayList = new ArrayList();
        for (Signature signature : signatureArr) {
            if (signature != null) {
                arrayList.add(signature);
            }
        }
        return arrayList;
    }

    @Override
    public Object GetPropertyManager(String str, Object[] objArr) {
        return null;
    }

    @Override
    public W GetTypeInfo(String str) {
        String lowerCase = str.toLowerCase();
        Map<String, W> map = mapTypeInfo;
        if (map.containsKey(lowerCase)) {
            return map.get(lowerCase);
        }
        return null;
    }

    @Override
    public Object Invoke(String str, EnumC0975b enumC0975b, Object[] objArr) {
        String lowerCase = str.toLowerCase(Locale.US);
        lowerCase.getClass();
        switch (lowerCase) {
            case "deleteunsentsms":
                return Integer.valueOf(deleteUnsentSms());
            case "setretryinterval":
                return Boolean.valueOf(setRetryInterval(objArr));
            case "send":
                return Integer.valueOf(send(objArr));
            case "sendretry":
                return Integer.valueOf(sendRetry(objArr));
            case "getretryinterval":
                return Long.valueOf(getRetryInterval());
            default:
                throw new IllegalArgumentException(getName() + ": Function/method/property " + str + " not implemented.");
        }
    }

    @Override
    public Object call(org.mozilla.javascript.Context context, Scriptable scriptable, Scriptable scriptable2, Object[] objArr) {
        return new SmsService((Context) getApp(), null);
    }

    @ScriptAllowed
    public int deleteUnsentSms() {
        h d = h.d(getApp(), true);
        if (d == null) {
            return 0;
        }
        return d.c();
    }

    public InterfaceC1038m0 getApp() {
        return this.app;
    }

    @ScriptAllowed
    @SuppressLint({"PackageManagerGetSignatures"})
    public C0893d0 getAppSmsSignatureHashes(Object... objArr) {
        Utils.h("GetAppSmsSignatureHashes", objArr, 0, 1);
        InterfaceC1038m0 app = getApp();
        String str = (String) Utils.w(objArr, 0, app.getPackageName());
        if (TextUtils.isEmpty(str)) {
            throw new IllegalArgumentException("GetAppSmsSignatureHashes(): Invalid package name argument");
        }
        try {
            List<Signature> signaturesClean = getSignaturesClean(app.getPackageManager().getPackageInfo(str, 64).signatures);
            long size = signaturesClean.size();
            C0893d0 c0893d0 = new C0893d0(size);
            for (int i = 0; i < size; i++) {
                byte[] S = t.S(str + " " + signaturesClean.get(i).toCharsString());
                MessageDigest sha256 = getSha256();
                sha256.update(S);
                String substring = Base64.encodeToString(Arrays.copyOfRange(sha256.digest(), 0, 9), 3).substring(0, 11);
                if (TextUtils.isEmpty(substring)) {
                    throw new IllegalArgumentException("Cannot compute signature hash");
                }
                Q0.putProperty(c0893d0, i, substring);
            }
            return c0893d0;
        } catch (PackageManager.NameNotFoundException e) {
            throw AbstractC0751f.e(e);
        }
    }

    @Override
    public String getDefaultMethod() {
        return null;
    }

    @Override
    public String getName() {
        return "SmsService";
    }

    @ScriptAllowed
    public long getRetryInterval() {
        return this.nRetryInterval;
    }

    @Override
    public V getScope() {
        return null;
    }

    @ScriptAllowed
    public String requestPhoneNumber() {
        InterfaceC1038m0 app = getApp();
        InterfaceC1016b0 g = app.g();
        if (g == null) {
            throw new IllegalStateException("RequestPhoneNumber(): No edit view is visible");
        }
        if (Build.VERSION.SDK_INT >= 34 && Utils.H2((Context) app) >= 34) {
            return "";
        }
        c a2 = j3.a.a((Context) app);
        HintRequest.a aVar = new HintRequest.a();
        aVar.b(true);
        PendingIntent B = a2.B(aVar.a());
        g gVar = new g();
        g.q(gVar);
        try {
            g.startIntentSenderForResult(B.getIntentSender(), gVar.getRequestCode(), (Intent) null, 0, 0, 0);
            Credential a3 = gVar.a();
            if (a3 == null) {
                return "";
            }
            String id = a3.getId();
            return TextUtils.isEmpty(id) ? "" : id;
        } catch (ActivityNotFoundException e) {
            Utils.l("XOneAndroidFramework", "ActivityNotFoundException when requesting phone number. SmsRetriever API may not be available on this device");
            e.printStackTrace();
            return "";
        } catch (IntentSender.SendIntentException e2) {
            e = e2;
            throw AbstractC0751f.e(e);
        } catch (InterruptedException e3) {
            e = e3;
            throw AbstractC0751f.e(e);
        }
    }

    @ScriptAllowed
    public void requestSmsVerification(Object... objArr) {
        Utils.g("RequestSmsVerification", objArr, 1);
        Object obj = objArr[0];
        InterfaceC1038m0 app = getApp();
        Context context = (Context) app;
        IXoneObject selfObject = getSelfObject();
        b a2 = k3.a.a(context);
        IntentFilter intentFilter = new IntentFilter("com.google.android.gms.auth.api.phone.SMS_RETRIEVED");
        ba.j jVar = new ba.j(app, selfObject, obj);
        if (Build.VERSION.SDK_INT >= 33) {
            x0.a(context, jVar, intentFilter, 2);
        } else {
            context.registerReceiver(jVar, intentFilter);
        }
        try {
            o.a(a2.B());
        } catch (Exception e) {
            e = e;
            if (e instanceof ExecutionException) {
                e = AbstractC0751f.i((ExecutionException) e);
            }
            Utils.l("XOneAndroidFramework", "Exception when requesting sms verification. SmsRetriever API may not be available on this device");
            e.printStackTrace();
        }
    }

    @ScriptAllowed
    public int send(Object... objArr) {
        Utils.j("Send", objArr);
        String y = t.y(objArr[0]);
        String y2 = t.y(objArr[1]);
        boolean parseBoolean = objArr.length == 3 ? Boolean.parseBoolean(t.y(objArr[2])) : false;
        if (TextUtils.isEmpty(y) || parseBoolean) {
            Intent oldSendSmsIntent = getOldSendSmsIntent(y, y2);
            Activity lastEditOrMainEntry = getLastEditOrMainEntry();
            if (lastEditOrMainEntry == null) {
                throw new IllegalStateException("Send(): Cannot find suitable activity to send SMS");
            }
            try {
                lastEditOrMainEntry.startActivity(oldSendSmsIntent);
            } catch (ActivityNotFoundException unused) {
                lastEditOrMainEntry.startActivity(getNewSendSmsIntent(y, y2));
            }
        }
        SmsManager smsManager = SmsManager.getDefault();
        ArrayList<String> divideMessage = smsManager.divideMessage(y2);
        int size = divideMessage.size();
        Utils.l("XOneAndroidFramework", "Sending SMS in " + size + " parts");
        smsManager.sendMultipartTextMessage(y, null, divideMessage, null, null);
        return size;
    }

    @ScriptAllowed
    public int sendData(Object... objArr) {
        Utils.j("SendData", objArr);
        Utils.g("SendData", objArr, 1);
        C0932x0 c0932x0 = (C0932x0) objArr[0];
        String E = k.E(c0932x0, "phoneNumber", "");
        String E2 = k.E(c0932x0, "serviceCenterAddress", null);
        short C = k.C(c0932x0, "port", (short) 0);
        byte[] c = k.c(c0932x0, "data", null);
        Object z = k.z(c0932x0, "onDataMessageSent", null);
        Object z2 = k.z(c0932x0, "onDataMessageDelivered", null);
        IXoneObject selfObject = getSelfObject();
        if (TextUtils.isEmpty(E)) {
            throw new IllegalArgumentException("SendData(): Empty phone number");
        }
        if (c == null || c.length == 0) {
            throw new IllegalArgumentException("SendData(): Empty data buffer");
        }
        Context context = (Context) getApp();
        if (z != null || z2 != null) {
            if (this.executor == null) {
                this.executor = Executors.newSingleThreadExecutor(new ThreadFactoryC0686d("SmsServiceExecutor"));
            }
            a aVar = new a(this.executor, selfObject, z, z2);
            IntentFilter intentFilter = new IntentFilter();
            intentFilter.addAction("data_message_sent");
            intentFilter.addAction("data_message_delivered");
            if (Build.VERSION.SDK_INT >= 33) {
                x0.a(context, aVar, intentFilter, 4);
            } else {
                context.registerReceiver(aVar, intentFilter);
            }
        }
        SmsManager.getDefault().sendDataMessage(E, E2, C, c, PendingIntent.getBroadcast(context, 4660, new Intent("data_message_sent"), Utils.l2(false, 268435456)), PendingIntent.getBroadcast(context, 4660, new Intent("data_message_delivered"), Utils.l2(false, 268435456)));
        return 0;
    }

    @ScriptAllowed
    public int sendRetry(Object... objArr) {
        Utils.j("SendRetry", objArr);
        Utils.g("SendRetry", objArr, 2);
        String y = t.y(objArr[0]);
        String y2 = t.y(objArr[1]);
        InterfaceC1038m0 app = getApp();
        h d = h.d(app, false);
        if (d == null) {
            throw AbstractC0751f.c("Database cannot be null");
        }
        d.a(y, y2);
        SmsSenderService.l(app, false, 0L);
        return 0;
    }

    @ScriptAllowed
    public boolean setRetryInterval(Object... objArr) {
        Utils.j("SetRetryInterval", objArr);
        Utils.g("SetRetryInterval", objArr, 1);
        this.nRetryInterval = q.t(objArr[0], 30L);
        return true;
    }
}