导航菜单

页面标题

页面副标题

Dostt v1.0.89 - VoiceConnectionService.java 源代码

正在查看: Dostt v1.0.89 应用的 VoiceConnectionService.java JAVA 源代码文件

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


package io.wazo.callkeep;

import L1.s;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.telecom.Connection;
import android.telecom.ConnectionRequest;
import android.telecom.ConnectionService;
import android.telecom.DisconnectCause;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.util.Log;
import androidx.core.app.n;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap;
import com.razorpay.rn.RazorpayModule;
import com.truecaller.android.sdk.legacy.TruecallerSdkScope;
import com.truecaller.android.sdk.oAuth.TcSdkOptions;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

@TargetApi(TcSdkOptions.SDK_CONSENT_HEADING_GET_NEW_UPDATES_FROM)
public class VoiceConnectionService extends ConnectionService {
    private static Boolean a;
    private static Boolean b;
    private static Boolean c;
    private static Boolean d;
    private static String e;
    private static ConnectionRequest f;
    private static PhoneAccountHandle o;
    private static String p;
    private static int q;
    private static List r;
    public static Map s;
    public static Boolean t;
    public static VoiceConnectionService u;

    class a implements Runnable {
        final VoiceConnectionService a;

        a(VoiceConnectionService voiceConnectionService) {
            this.a = voiceConnectionService;
        }

        @Override
        public void run() {
            this.a.D(VoiceConnectionService.f);
        }
    }

    class b implements Runnable {
        b() {
        }

        @Override
        public void run() {
            int size = VoiceConnectionService.r.size();
            Log.d(VoiceConnectionService.p, "[VoiceConnectionService] startObserving, event count: " + size);
            for (Bundle bundle : VoiceConnectionService.r) {
                VoiceConnectionService.u.t(bundle.getString("action"), (HashMap) bundle.getSerializable("attributeMap"), false);
            }
            VoiceConnectionService.r = new ArrayList();
        }
    }

    class c implements Runnable {
        final String a;
        final HashMap b;
        final VoiceConnectionService c;
        final boolean d;

        c(String str, HashMap hashMap, VoiceConnectionService voiceConnectionService, boolean z) {
            this.a = str;
            this.b = hashMap;
            this.c = voiceConnectionService;
            this.d = z;
        }

        @Override
        public void run() {
            Intent intent = new Intent(this.a);
            Bundle bundle = new Bundle();
            bundle.putString("action", this.a);
            HashMap hashMap = this.b;
            if (hashMap != null) {
                bundle.putSerializable("attributeMap", hashMap);
                intent.putExtras(bundle);
            }
            if (h1.a.b(this.c).d(intent) || !this.d) {
                return;
            }
            VoiceConnectionService.r.add(bundle);
        }
    }

    class d implements Runnable {
        final VoiceConnectionService a;
        final String b;
        final Integer c;

        d(VoiceConnectionService voiceConnectionService, String str, Integer num) {
            this.a = voiceConnectionService;
            this.b = str;
            this.c = num;
        }

        @Override
        public void run() {
            if (VoiceConnectionService.c.booleanValue()) {
                return;
            }
            Connection n = VoiceConnectionService.n(this.b);
            Log.w(VoiceConnectionService.p, "[VoiceConnectionService] checkForAppReachability timeout after " + this.c + " ms, isReachable:" + VoiceConnectionService.c + ", uuid: " + this.b);
            if (n != null) {
                n.onDisconnect();
                return;
            }
            Log.w(VoiceConnectionService.p, "[VoiceConnectionService] checkForAppReachability timeout, no connection to close with uuid: " + this.b);
        }
    }

    static {
        Boolean bool = Boolean.FALSE;
        a = bool;
        b = bool;
        c = bool;
        d = Boolean.TRUE;
        p = "RNCallKeep";
        q = -4567;
        r = new ArrayList();
        s = new HashMap();
        t = bool;
        u = null;
    }

    public VoiceConnectionService() {
        Log.d(p, "[VoiceConnectionService] Constructor");
        f = null;
        u = this;
    }

    private void A() {
        if (Build.VERSION.SDK_INT < 26) {
            return;
        }
        Log.d(p, "[VoiceConnectionService] startForegroundService");
        ReadableMap o2 = o(null);
        if (!q()) {
            Log.w(p, "[VoiceConnectionService] Not creating foregroundService because not configured");
            return;
        }
        String string = o2.getString("channelId");
        NotificationChannel a2 = L1.i.a(string, o2.getString("channelName"), 0);
        s.a(a2, 0);
        C8.f.a((NotificationManager) getSystemService("notification"), a2);
        n.e eVar = new n.e(this, string);
        eVar.D(true).p(o2.getString("notificationTitle")).F(1).i("service");
        Activity currentReactActivity = RNCallKeepModule.instance.getCurrentReactActivity();
        if (currentReactActivity != null) {
            Intent intent = new Intent(this, currentReactActivity.getClass());
            intent.addFlags(536870912);
            eVar.n(PendingIntent.getActivity(this, q, intent, 201326592));
        }
        if (o2.hasKey("notificationIcon")) {
            Context applicationContext = getApplicationContext();
            eVar.L(applicationContext.getResources().getIdentifier(o2.getString("notificationIcon"), "mipmap", applicationContext.getPackageName()));
        }
        Log.d(p, "[VoiceConnectionService] Starting foreground service");
        try {
            startForeground(128, eVar.d());
        } catch (Exception e2) {
            Log.w(p, "[VoiceConnectionService] Can't start foreground service : " + e2.toString());
        }
    }

    public static void B() {
        new Handler(Looper.getMainLooper()).post(new b());
    }

    private void C() {
        Log.d(p, "[VoiceConnectionService] stopForegroundService");
        o(null);
        if (!q()) {
            Log.w(p, "[VoiceConnectionService] Not creating foregroundService because not configured");
            return;
        }
        try {
            stopForeground(128);
        } catch (Exception e2) {
            Log.w(p, "[VoiceConnectionService] can't stop foreground service :" + e2.toString());
        }
    }

    public void D(ConnectionRequest connectionRequest) {
        if (f == null) {
            return;
        }
        Bundle extras = connectionRequest.getExtras();
        String schemeSpecificPart = connectionRequest.getAddress().getSchemeSpecificPart();
        String string = extras.getString("EXTRA_CALLER_NAME");
        Log.d(p, "[VoiceConnectionService] checkReachability timeout, force wakeup, number :" + schemeSpecificPart + ", displayName: " + string);
        E(e, schemeSpecificPart, string);
        f = null;
    }

    private void E(String str, String str2, String str3) {
        Log.d(p, "[VoiceConnectionService] wakeUpApplication, uuid:" + str + ", number :" + str2 + ", displayName:" + str3);
        f = null;
        try {
            Intent intent = new Intent(getApplicationContext(), (Class<?>) RNCallKeepBackgroundMessagingService.class);
            intent.putExtra("callUUID", str);
            intent.putExtra(RazorpayModule.MAP_KEY_WALLET_NAME, str3);
            intent.putExtra("handle", str2);
            ComponentName startService = getApplicationContext().startService(intent);
            if (startService != null) {
                Log.d(p, "[VoiceConnectionService] wakeUpApplication, acquiring lock for application:" + startService);
                com.facebook.react.h.e(getApplicationContext());
            }
        } catch (Exception e2) {
            Log.w(p, "[VoiceConnectionService] wakeUpApplication, error" + e2.toString());
        }
    }

    private HashMap h(Bundle bundle) {
        HashMap hashMap = new HashMap();
        for (String str : bundle.keySet()) {
            if (bundle.get(str) != null) {
                hashMap.put(str, bundle.get(str).toString());
            }
        }
        return hashMap;
    }

    private Boolean i() {
        return a;
    }

    private void j(String str, Integer num) {
        new Handler().postDelayed(new d(this, str, num), num.intValue());
    }

    private void k() {
        Log.d(p, "[VoiceConnectionService] checkReachability");
        t("ACTION_CHECK_REACHABILITY", null, true);
        new Handler().postDelayed(new a(this), 2000L);
    }

    private Connection l(ConnectionRequest connectionRequest) {
        Bundle extras = connectionRequest.getExtras();
        if (connectionRequest.getAddress() == null) {
            return null;
        }
        HashMap h = h(extras);
        String uri = connectionRequest.getAddress().toString();
        Log.d(p, "[VoiceConnectionService] createConnection, callerNumber:" + uri);
        if (uri.contains(":")) {
            int indexOf = uri.indexOf(":");
            String substring = uri.substring(indexOf + 1);
            String substring2 = uri.substring(0, indexOf);
            h.put("EXTRA_CALL_NUMBER", substring);
            h.put("EXTRA_CALL_NUMBER_SCHEMA", substring2);
        } else {
            h.put("EXTRA_CALL_NUMBER", uri);
        }
        i iVar = new i(this, h);
        iVar.setConnectionCapabilities(66);
        if (Build.VERSION.SDK_INT >= 26) {
            if ((((TelecomManager) getApplicationContext().getSystemService("telecom")).getPhoneAccount(connectionRequest.getAccountHandle()).getCapabilities() & TruecallerSdkScope.BUTTON_SHAPE_RECTANGLE) == 2048) {
                Log.d(p, "[VoiceConnectionService] PhoneAccount is SELF_MANAGED, so connection will be too");
                iVar.setConnectionProperties(128);
            } else {
                Log.d(p, "[VoiceConnectionService] PhoneAccount is not SELF_MANAGED, so connection won't be either");
            }
        }
        iVar.setInitializing();
        iVar.setExtras(extras);
        s.put(extras.getString("EXTRA_CALL_UUID"), iVar);
        HashMap hashMap = new HashMap();
        for (Map.Entry entry : s.entrySet()) {
            if (!extras.getString("EXTRA_CALL_UUID").equals(entry.getKey())) {
                hashMap.put((String) entry.getKey(), (i) entry.getValue());
            }
        }
        iVar.setConferenceableConnections(new ArrayList(hashMap.values()));
        return iVar;
    }

    public static void m(String str) {
        Log.d(p, "[VoiceConnectionService] deinitConnection:" + str);
        t = Boolean.FALSE;
        u.C();
        if (s.containsKey(str)) {
            s.remove(str);
        }
    }

    public static Connection n(String str) {
        if (s.containsKey(str)) {
            return (Connection) s.get(str);
        }
        return null;
    }

    public static ReadableMap o(Context context) {
        WritableMap p2 = p(context);
        if (p2 == null) {
            return null;
        }
        return p2.getMap("foregroundService");
    }

    public static WritableMap p(Context context) {
        return RNCallKeepModule.getSettings(context);
    }

    private boolean q() {
        ReadableMap o2 = o(null);
        if (o2 == null) {
            return false;
        }
        try {
            return o2.hasKey("channelId");
        } catch (Exception e2) {
            Log.w(p, "[VoiceConnectionService] Not creating foregroundService due to configuration retrieval error" + e2.toString());
            return false;
        }
    }

    public static boolean r(Context context) {
        ComponentName componentName;
        for (ActivityManager.RunningTaskInfo runningTaskInfo : ((ActivityManager) context.getSystemService("activity")).getRunningTasks(Integer.MAX_VALUE)) {
            String packageName = context.getPackageName();
            componentName = runningTaskInfo.baseActivity;
            if (packageName.equalsIgnoreCase(componentName.getPackageName())) {
                return true;
            }
        }
        Log.d(p, "[VoiceConnectionService] isRunning: no running package found.");
        return false;
    }

    private Connection s(ConnectionRequest connectionRequest, String str, Boolean bool) {
        Bundle extras = connectionRequest.getExtras();
        String schemeSpecificPart = connectionRequest.getAddress().getSchemeSpecificPart();
        String string = extras.getString("EXTRA_CALL_NUMBER");
        String string2 = extras.getString("EXTRA_CALLER_NAME");
        boolean r2 = r(getApplicationContext());
        Log.d(p, "[VoiceConnectionService] makeOutgoingCall, uuid:" + str + ", number: " + schemeSpecificPart + ", displayName:" + string2);
        if (!r2 || bool.booleanValue()) {
            Log.d(p, "[VoiceConnectionService] onCreateOutgoingConnection: Waking up application");
            E(str, schemeSpecificPart, string2);
        } else if (!i().booleanValue() && c.booleanValue()) {
            Log.d(p, "[VoiceConnectionService] onCreateOutgoingConnection: not available");
            return Connection.createFailedConnection(new DisconnectCause(2));
        }
        if (string == null || !string.equals(schemeSpecificPart)) {
            extras.putString("EXTRA_CALL_UUID", str);
            extras.putString("EXTRA_CALLER_NAME", string2);
            extras.putString("EXTRA_CALL_NUMBER", schemeSpecificPart);
        }
        if (!d.booleanValue()) {
            Log.d(p, "[VoiceConnectionService] onCreateOutgoingConnection: disabling multi calls");
            extras.putBoolean("android.telecom.extra.DISABLE_ADD_CALL", true);
        }
        Connection l = l(connectionRequest);
        l.setDialing();
        l.setAudioModeIsVoip(true);
        l.setCallerDisplayName(string2, 1);
        A();
        if (!Build.MANUFACTURER.equalsIgnoreCase("Samsung")) {
            Log.d(p, "[VoiceConnectionService] onCreateOutgoingConnection: initializing connection on non-Samsung device");
            l.setInitialized();
        }
        HashMap h = h(extras);
        t("ACTION_ONGOING_CALL", h, true);
        t("ACTION_AUDIO_SESSION", h, true);
        Log.d(p, "[VoiceConnectionService] onCreateOutgoingConnection: done");
        return l;
    }

    public void t(String str, HashMap hashMap, boolean z) {
        Handler handler = new Handler();
        Log.d(p, "[VoiceConnectionService] sendCallRequestToActivity, action:" + str);
        handler.post(new c(str, hashMap, this, z));
    }

    public static void u(Boolean bool) {
        String str = p;
        StringBuilder sb2 = new StringBuilder();
        sb2.append("[VoiceConnectionService] setAvailable: ");
        sb2.append(bool.booleanValue() ? "true" : "false");
        Log.d(str, sb2.toString());
        if (bool.booleanValue()) {
            w(true);
        }
        a = bool;
    }

    public static void v(Boolean bool) {
        String str = p;
        StringBuilder sb2 = new StringBuilder();
        sb2.append("[VoiceConnectionService] setCanMakeMultipleCalls: ");
        sb2.append(bool.booleanValue() ? "true" : "false");
        Log.d(str, sb2.toString());
        d = bool;
    }

    public static void w(boolean z) {
        String str = p;
        StringBuilder sb2 = new StringBuilder();
        sb2.append("[VoiceConnectionService] setInitialized: ");
        sb2.append(z ? "true" : "false");
        Log.d(str, sb2.toString());
        b = Boolean.valueOf(z);
    }

    public static void x(PhoneAccountHandle phoneAccountHandle) {
        o = phoneAccountHandle;
    }

    public static void y() {
        Log.d(p, "[VoiceConnectionService] setReachable");
        c = Boolean.TRUE;
        f = null;
    }

    public static void z(String str, int i) {
        Connection n = n(str);
        if (n == null) {
            Log.w(p, "[VoiceConnectionService] setState ignored because no connection found, uuid: " + str);
            return;
        }
        if (i == 0) {
            n.setInitializing();
            return;
        }
        if (i == 2) {
            n.setRinging();
            return;
        }
        if (i == 3) {
            n.setDialing();
        } else if (i == 4) {
            n.setActive();
        } else {
            if (i != 5) {
                return;
            }
            n.setOnHold();
        }
    }

    @Override
    public void onConference(Connection connection, Connection connection2) {
        Log.d(p, "[VoiceConnectionService] onConference");
        super.onConference(connection, connection2);
        h hVar = new h(o);
        hVar.addConnection((i) connection);
        hVar.addConnection((i) connection2);
        connection.onUnhold();
        connection2.onUnhold();
        addConference(hVar);
    }

    @Override
    public Connection onCreateIncomingConnection(PhoneAccountHandle phoneAccountHandle, ConnectionRequest connectionRequest) {
        Bundle extras = connectionRequest.getExtras();
        Uri address = connectionRequest.getAddress();
        String string = extras.getString("EXTRA_CALLER_NAME");
        String string2 = extras.getString("EXTRA_CALL_UUID");
        Boolean valueOf = Boolean.valueOf(r(getApplicationContext()));
        WritableMap p2 = p(this);
        Integer valueOf2 = p2.hasKey("displayCallReachabilityTimeout") ? Integer.valueOf(p2.getInt("displayCallReachabilityTimeout")) : null;
        Log.d(p, "[VoiceConnectionService] onCreateIncomingConnection, name:" + string + ", number" + address + ", isForeground: " + valueOf + ", isReachable:" + c + ", timeout: " + valueOf2);
        Connection l = l(connectionRequest);
        l.setRinging();
        l.setInitialized();
        A();
        if (valueOf2 != null) {
            j(string2, valueOf2);
        }
        return l;
    }

    @Override
    public void onCreateIncomingConnectionFailed(PhoneAccountHandle phoneAccountHandle, ConnectionRequest connectionRequest) {
        super.onCreateIncomingConnectionFailed(phoneAccountHandle, connectionRequest);
        Log.w(p, "[VoiceConnectionService] onCreateIncomingConnectionFailed: " + connectionRequest);
        HashMap h = h(connectionRequest.getExtras());
        String uri = connectionRequest.getAddress().toString();
        if (uri.contains(":")) {
            int indexOf = uri.indexOf(":");
            String substring = uri.substring(indexOf + 1);
            String substring2 = uri.substring(0, indexOf);
            h.put("EXTRA_CALL_NUMBER", substring);
            h.put("EXTRA_CALL_NUMBER_SCHEMA", substring2);
        } else {
            h.put("EXTRA_CALL_NUMBER", uri);
        }
        t("ACTION_ON_CREATE_CONNECTION_FAILED", h, true);
    }

    @Override
    public Connection onCreateOutgoingConnection(PhoneAccountHandle phoneAccountHandle, ConnectionRequest connectionRequest) {
        t = Boolean.TRUE;
        String string = connectionRequest.getExtras().getString("EXTRA_CALL_UUID");
        if (string == null || string == "") {
            string = UUID.randomUUID().toString();
        }
        Log.d(p, "[VoiceConnectionService] onCreateOutgoingConnection, uuid:" + string);
        if (!b.booleanValue() && !c.booleanValue()) {
            e = string;
            f = connectionRequest;
            k();
        }
        return s(connectionRequest, string, Boolean.FALSE);
    }
}