package com.tencent.mm.plugin.voip.model;

import android.app.ActivityManager;
import android.app.ActivityManager.RunningTaskInfo;
import android.app.KeyguardManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.graphics.Point;
import android.os.Looper;
import com.google.android.gms.common.util.CrashUtils.ErrorDialogData;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.a.f;
import com.tencent.mm.g.a.iq;
import com.tencent.mm.g.a.ui;
import com.tencent.mm.kernel.g;
import com.tencent.mm.memory.a.c;
import com.tencent.mm.network.n;
import com.tencent.mm.plugin.messenger.foundation.a.j;
import com.tencent.mm.plugin.voip.b;
import com.tencent.mm.plugin.voip.model.o.a;
import com.tencent.mm.plugin.voip.ui.VideoActivity;
import com.tencent.mm.protocal.protobuf.SKBuiltinBuffer_t;
import com.tencent.mm.protocal.protobuf.axg;
import com.tencent.mm.protocal.protobuf.cfz;
import com.tencent.mm.protocal.protobuf.cph;
import com.tencent.mm.protocal.protobuf.cpi;
import com.tencent.mm.protocal.protobuf.cpm;
import com.tencent.mm.protocal.protobuf.cpx;
import com.tencent.mm.protocal.protobuf.cqi;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.ah;
import com.tencent.mm.sdk.platformtools.al;
import com.tencent.mm.sdk.platformtools.ap;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.ui.base.h;
import com.tencent.ytcommon.BuildConfig;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

public final class r {
    private static final f<Integer, a> emX = new c(5);
    public boolean con;
    public ap oGx;
    private n qbK;
    public String sRK;
    public s sSP;
    public VoipMgr sSQ;
    public boolean sSR;
    public boolean sSS;
    private long sST;
    public Map<Integer, Long> sSU;
    public int sSV;
    public long sSW;
    public long sSX;
    public Point sSY;
    public boolean sSZ;
    public boolean sTa;
    public boolean sTb;
    public cpm sTc;
    public long sTd;
    public boolean sTe;
    List<a> sTf;
    public String talker;

    static /* synthetic */ boolean fc(Context context) {
        AppMethodBeat.i(4641);
        boolean eA = eA(context);
        AppMethodBeat.o(4641);
        return eA;
    }

    public r() {
        AppMethodBeat.i(4605);
        this.con = false;
        this.sSR = false;
        this.sSS = false;
        this.talker = null;
        this.sST = 0;
        this.sSU = new HashMap();
        this.sSV = -1;
        this.sSW = 0;
        this.sSX = 0;
        this.sSZ = false;
        this.sTa = false;
        this.sTb = false;
        this.sTc = null;
        this.sTd = 0;
        this.sRK = null;
        this.sTe = false;
        this.qbK = new 1(this);
        this.oGx = new ap(Looper.getMainLooper(), new 3(this), true);
        this.sTf = null;
        this.sSP = new s();
        this.con = false;
        this.sSR = false;
        this.sSS = false;
        this.talker = null;
        this.sRK = null;
        g.RO().a(this.qbK);
        AppMethodBeat.o(4605);
    }

    /* Access modifiers changed, original: protected|final */
    public final void finalize() {
        AppMethodBeat.i(4606);
        this.sSP.stop();
        this.sSP = null;
        g.RO().b(this.qbK);
        super.finalize();
        AppMethodBeat.o(4606);
    }

    public final void b(boolean z, boolean z2, String str) {
        AppMethodBeat.i(4607);
        ab.i("MicroMsg.Voip.VoipService", "setCalling " + z + "  videoCall " + z2 + "username " + str);
        this.con = z;
        if (z2) {
            this.sSR = z;
            this.sSP.sNl.sPp.sUl = 0;
        } else {
            this.sSP.sNl.sPp.sUl = 1;
            this.sSS = z;
        }
        this.talker = str;
        this.sSP.sNl.sPp.sVH.gfj = str;
        AppMethodBeat.o(4607);
    }

    public final void Q(boolean z, boolean z2) {
        AppMethodBeat.i(4608);
        this.sTa = z;
        this.sTb = z2;
        ab.d("MicroMsg.Voip.VoipService", "isMinimize: %b, miniOnlyHideVoip: %b", new Object[]{Boolean.valueOf(z), Boolean.valueOf(z2)});
        AppMethodBeat.o(4608);
    }

    public final void ba(Context context, String str) {
        AppMethodBeat.i(4609);
        ab.i("MicroMsg.Voip.VoipService", "startVoiceCall, toUser:".concat(String.valueOf(str)));
        if (bo.isNullOrNil(str) || (System.currentTimeMillis() - this.sST < 2000 && System.currentTimeMillis() - this.sST > 0)) {
            AppMethodBeat.o(4609);
        } else if (System.currentTimeMillis() - this.sSW >= this.sSX || System.currentTimeMillis() - this.sSW <= 0) {
            this.sST = System.currentTimeMillis();
            if (((j) g.K(j.class)).XM().aoO(str) == null) {
                AppMethodBeat.o(4609);
                return;
            }
            a(context, str, true, false, false);
            cJY();
            AppMethodBeat.o(4609);
        } else {
            ab.i("MicroMsg.Voip.VoipService", "fail! cuz overloadInterval fail!");
            h.a(context, 2131304466, 2131304499, null);
            AppMethodBeat.o(4609);
        }
    }

    public final void bb(Context context, String str) {
        AppMethodBeat.i(4610);
        ab.i("MicroMsg.Voip.VoipService", "startVideoCall, toUser:".concat(String.valueOf(str)));
        if (bo.isNullOrNil(str) || (System.currentTimeMillis() - this.sST < 2000 && System.currentTimeMillis() - this.sST > 0)) {
            AppMethodBeat.o(4610);
        } else if (System.currentTimeMillis() - this.sSW >= this.sSX || System.currentTimeMillis() - this.sSW <= 0) {
            this.sST = System.currentTimeMillis();
            if (((j) g.K(j.class)).XM().aoO(str) == null) {
                AppMethodBeat.o(4610);
                return;
            }
            a(context, str, true, true, false);
            cJY();
            AppMethodBeat.o(4610);
        } else {
            ab.i("MicroMsg.Voip.VoipService", "fail! cuz overloadInterval fail!");
            h.a(context, 2131304466, 2131304499, null);
            AppMethodBeat.o(4610);
        }
    }

    private static void cJY() {
        AppMethodBeat.i(4611);
        ui uiVar = new ui();
        uiVar.cQx.cAd = 7;
        com.tencent.mm.sdk.b.a.xxA.m(uiVar);
        AppMethodBeat.o(4611);
    }

    public final void ad(int i, long j) {
        AppMethodBeat.i(4612);
        al.d(new 2(this, i, j));
        AppMethodBeat.o(4612);
    }

    public final void b(cpm cpm) {
        AppMethodBeat.i(4613);
        if (com.tencent.mm.m.f.ME() || eA(ah.getContext())) {
            String str = cpm.xmT;
            String Yz = com.tencent.mm.model.r.Yz();
            int i = cpm.xmL;
            ab.i("MicroMsg.Voip.VoipService", "doTaskCallin self:%s talker:%s type:%d roomid:%d", new Object[]{Yz, str, Integer.valueOf(i), Integer.valueOf(cpm.wem)});
            if (this.sSP.cIJ()) {
                s.a(cpm.wem, cpm.wen, 2, null, null, str);
                ab.d("MicroMsg.Voip.VoipService", "doTaskCallin invite ignor because voip busy:roomid " + cpm.wem);
                com.tencent.mm.plugin.report.service.h.pYm.a(11525, true, true, new Object[]{Integer.valueOf(cpm.wem), Long.valueOf(cpm.wen), Integer.valueOf(cpm.xmL), Integer.valueOf(2), Integer.valueOf(com.tencent.mm.plugin.voip.a.a.getNetType(ah.getContext())), Long.valueOf(System.currentTimeMillis())});
                com.tencent.mm.plugin.report.service.h.pYm.a(11526, true, true, new Object[]{Integer.valueOf(b.cIj().sSP.sNl.sPp.nwu), Long.valueOf(b.cIj().sSP.sNl.sPp.nwv), Long.valueOf(b.cIj().sSP.sNl.cIK()), Integer.valueOf(7)});
                com.tencent.mm.plugin.voip.a.a.GI(0);
                AppMethodBeat.o(4613);
                return;
            } else if (s.cKh()) {
                s.a(cpm.wem, cpm.wen, 3, null, null, str);
                ab.e("MicroMsg.Voip.VoipService", "doTaskCallin invite ignor because telephone busy:roomid " + cpm.wem);
                com.tencent.mm.plugin.report.service.h.pYm.a(11525, true, true, new Object[]{Integer.valueOf(cpm.wem), Long.valueOf(cpm.wen), Integer.valueOf(cpm.xmL), Integer.valueOf(3), Integer.valueOf(com.tencent.mm.plugin.voip.a.a.getNetType(ah.getContext())), Long.valueOf(System.currentTimeMillis())});
                com.tencent.mm.plugin.report.service.h.pYm.a(11526, true, true, new Object[]{Integer.valueOf(b.cIj().sSP.sNl.sPp.nwu), Long.valueOf(b.cIj().sSP.sNl.sPp.nwv), Long.valueOf(b.cIj().sSP.sNl.cIK()), Integer.valueOf(7)});
                com.tencent.mm.plugin.voip.a.a.GI(0);
                AppMethodBeat.o(4613);
                return;
            } else {
                this.sSP.cKi();
                if (this.sSP.a(cpm)) {
                    Context context = ah.getContext();
                    if (((j) g.K(j.class)).XM().aoO(str) == null) {
                        s.a(cpm.wem, cpm.wen, 4, null, null, str);
                        ab.d("MicroMsg.Voip.VoipService", "doTaskCallin invite ignor because talker nil:roomid " + cpm.wem);
                        com.tencent.mm.plugin.report.service.h.pYm.a(11525, true, true, new Object[]{Integer.valueOf(cpm.wem), Long.valueOf(cpm.wen), Integer.valueOf(cpm.xmL), Integer.valueOf(4), Integer.valueOf(com.tencent.mm.plugin.voip.a.a.getNetType(ah.getContext())), Long.valueOf(System.currentTimeMillis())});
                        com.tencent.mm.plugin.report.service.h.pYm.a(11526, true, true, new Object[]{Integer.valueOf(b.cIj().sSP.sNl.sPp.nwu), Long.valueOf(b.cIj().sSP.sNl.sPp.nwv), Long.valueOf(b.cIj().sSP.sNl.cIK()), Integer.valueOf(7)});
                        com.tencent.mm.plugin.voip.a.a.GI(0);
                        AppMethodBeat.o(4613);
                        return;
                    }
                    if (1 == i || i == 0) {
                        try {
                            a(context, str, false, i == 0, true);
                            if (this.sSP != null) {
                                this.sSP.Gy(cpm.wem);
                            }
                            ab.d("MicroMsg.Voip.VoipService", "doTaskCallin invite startActivity VideoActivity");
                        } catch (Exception e) {
                            com.tencent.mm.plugin.voip.a.a.GI(2);
                        }
                    }
                    s.a(cpm.wem, cpm.wen, 1, this.sSP.sNl.sPp.field_peerId, this.sSP.sNl.sPp.field_capInfo, str);
                    com.tencent.mm.plugin.report.service.h.pYm.a(11525, true, true, new Object[]{Integer.valueOf(cpm.wem), Long.valueOf(cpm.wen), Integer.valueOf(cpm.xmL), Integer.valueOf(1), Integer.valueOf(com.tencent.mm.plugin.voip.a.a.getNetType(ah.getContext())), Long.valueOf(System.currentTimeMillis())});
                    AppMethodBeat.o(4613);
                    return;
                }
                ab.e("MicroMsg.Voip.VoipService", "doTaskCallin setInviteContent failed!");
                com.tencent.mm.plugin.report.service.h.pYm.a(11525, true, true, new Object[]{Integer.valueOf(cpm.wem), Long.valueOf(cpm.wen), Integer.valueOf(cpm.xmL), Integer.valueOf(5), Integer.valueOf(com.tencent.mm.plugin.voip.a.a.getNetType(ah.getContext())), Long.valueOf(System.currentTimeMillis())});
                com.tencent.mm.plugin.report.service.h.pYm.a(11526, true, true, new Object[]{Integer.valueOf(b.cIj().sSP.sNl.sPp.nwu), Long.valueOf(b.cIj().sSP.sNl.sPp.nwv), Long.valueOf(b.cIj().sSP.sNl.cIK()), Integer.valueOf(7)});
                com.tencent.mm.plugin.voip.a.a.GI(0);
                AppMethodBeat.o(4613);
                return;
            }
        }
        ab.i("MicroMsg.Voip.VoipService", "NotificationConfig.isNewVoipMsgNotification() is false and is not in foreground, now return.");
        if (this.sTc == null && this.oGx.doT()) {
            ab.i("MicroMsg.Voip.VoipService", "voipGetRoomInfoResp is null and time is stopped.");
            this.sTc = cpm;
            this.oGx.ae(2000, 2000);
            this.sTd = System.currentTimeMillis();
            com.tencent.mm.plugin.report.service.h.pYm.a(500, 4, 1, false);
            com.tencent.mm.plugin.voip.a.a.GI(0);
        }
        AppMethodBeat.o(4613);
    }

    public final void Gv(int i) {
        AppMethodBeat.i(4614);
        if (this.sTf == null || this.sTf.isEmpty()) {
            AppMethodBeat.o(4614);
            return;
        }
        for (a aVar : this.sTf) {
            if (aVar != null && aVar.sTh != null && aVar.sTh.wem == i) {
                aVar.cancelled = true;
                AppMethodBeat.o(4614);
                return;
            }
        }
        AppMethodBeat.o(4614);
    }

    static {
        AppMethodBeat.i(4642);
        AppMethodBeat.o(4642);
    }

    public static a abW(String str) {
        AppMethodBeat.i(4615);
        if (str == null || str.length() == 0) {
            AppMethodBeat.o(4615);
            return null;
        }
        int hashCode = str.hashCode();
        a aVar = (a) emX.get(Integer.valueOf(hashCode));
        if (aVar != null) {
            AppMethodBeat.o(4615);
            return aVar;
        }
        aVar = new a();
        if (aVar.parse(str)) {
            emX.k(Integer.valueOf(hashCode), aVar);
            AppMethodBeat.o(4615);
            return aVar;
        }
        AppMethodBeat.o(4615);
        return null;
    }

    private static Map<Integer, Long> br(byte[] bArr) {
        AppMethodBeat.i(4616);
        if (bo.cb(bArr)) {
            AppMethodBeat.o(4616);
            return null;
        }
        try {
            cfz cfz = (cfz) new cfz().parseFrom(bArr);
            if (cfz == null) {
                AppMethodBeat.o(4616);
                return null;
            }
            ab.d("MicroMsg.Voip.VoipService", "dkpush : keyCount:" + cfz.wYL);
            LinkedList linkedList = cfz.wYM;
            if (linkedList.size() != cfz.wYL) {
                AppMethodBeat.o(4616);
                return null;
            }
            HashMap hashMap = new HashMap();
            int i = 0;
            while (true) {
                int i2 = i;
                if (i2 >= cfz.wYL) {
                    break;
                }
                hashMap.put(Integer.valueOf(((axg) linkedList.get(i2)).pXC), Long.valueOf(4294967295L & ((long) ((axg) linkedList.get(i2)).wBo)));
                i = i2 + 1;
            }
            if (hashMap.size() != cfz.wYL) {
                AppMethodBeat.o(4616);
                return null;
            }
            AppMethodBeat.o(4616);
            return hashMap;
        } catch (Exception e) {
            AppMethodBeat.o(4616);
            return null;
        }
    }

    private static byte[] ai(Map<Integer, Long> map) {
        AppMethodBeat.i(4617);
        cfz cfz = new cfz();
        LinkedList linkedList = new LinkedList();
        for (Integer num : map.keySet()) {
            axg axg = new axg();
            axg.pXC = num.intValue();
            axg.wBo = ((Long) map.get(num)).intValue();
            linkedList.push(axg);
        }
        cfz.wYM = linkedList;
        cfz.wYL = linkedList.size();
        try {
            byte[] toByteArray = cfz.toByteArray();
            AppMethodBeat.o(4617);
            return toByteArray;
        } catch (IOException e) {
            ab.printErrStackTrace("MicroMsg.Voip.VoipService", e, BuildConfig.FLAVOR, new Object[0]);
            AppMethodBeat.o(4617);
            return null;
        }
    }

    private static String bs(byte[] bArr) {
        AppMethodBeat.i(4618);
        String str = BuildConfig.FLAVOR;
        for (byte b : bArr) {
            String toHexString = Integer.toHexString(b & 255);
            if (toHexString.length() == 1) {
                toHexString = "0".concat(String.valueOf(toHexString));
            }
            str = str + toHexString.toUpperCase();
        }
        AppMethodBeat.o(4618);
        return str;
    }

    public final int b(byte[] bArr, int i, long j) {
        long j2;
        long j3;
        AppMethodBeat.i(4619);
        long j4 = 0;
        long j5 = 0;
        long j6 = 0;
        long j7 = 0;
        long j8 = 0;
        ab.i("MicroMsg.Voip.VoipService", "__parse voip notify begin");
        Map br = br(this.sSP.sNl.sPt);
        if (br == null) {
            ab.i("MicroMsg.Voip.VoipService", "local voipsynckey buff nil");
            j2 = 0;
        } else {
            j3 = 0;
            for (Integer num : br.keySet()) {
                Long l = (Long) br.get(num);
                switch (num.intValue()) {
                    case 1:
                        j4 = l.longValue();
                        break;
                    case 2:
                        j5 = l.longValue();
                        break;
                    case 3:
                        j3 = l.longValue();
                        break;
                    default:
                        String str = "MicroMsg.Voip.VoipService";
                        ab.i(str, "parse local voipsynckey:" + num.intValue() + ",value:" + l);
                        break;
                }
            }
            j2 = j3;
        }
        ab.i("MicroMsg.Voip.VoipService", "local voip synckey: statuskey:" + j4 + " relayData key:" + j5 + " connectingStatusKey:" + j2);
        try {
            cpi cpi = (cpi) new cpi().parseFrom(bArr);
            int i2 = 0;
            while (true) {
                int i3 = i2;
                if (i3 < cpi.xmM.size()) {
                    cph cph = (cph) cpi.xmM.get(i3);
                    ab.i("MicroMsg.Voip.VoipService", "__parse voip notify, item cmdid:" + cph.wat);
                    StringBuilder stringBuilder;
                    if (cph.wat == 1) {
                        cqi cqi;
                        try {
                            cqi = (cqi) new cqi().parseFrom(cph.vJd.getBufferToBytes());
                        } catch (IOException e) {
                            ab.i("MicroMsg.Voip.VoipService", "parse Voip notify status item fail");
                            ab.printErrStackTrace("MicroMsg.Voip.VoipService", e, BuildConfig.FLAVOR, new Object[0]);
                            cqi = null;
                        }
                        if (cqi != null) {
                            ab.i("MicroMsg.Voip.VoipService", "voip notify status:" + cqi.jBT);
                            if (j6 < ((long) cph.pXC)) {
                                j3 = (long) cph.pXC;
                            } else {
                                j3 = j6;
                            }
                            if (((long) cph.pXC) > j4) {
                                ab.i("MicroMsg.Voip.VoipService", "voiop notify status key[" + cph.pXC + "] > local status key[" + j4 + "] status[" + cqi.jBT + "]");
                                this.sSP.sNl.sPs.a(cqi, 1);
                                j6 = j3;
                            }
                        } else {
                            ab.i("MicroMsg.Voip.VoipService", "parse Voip notify status item fail");
                            j3 = j6;
                        }
                        j6 = j3;
                    } else if (cph.wat == 2) {
                        cpx cpx;
                        try {
                            cpx = (cpx) new cpx().parseFrom(cph.vJd.getBufferToBytes());
                        } catch (IOException e2) {
                            ab.i("MicroMsg.Voip.VoipService", "parse Voip notify relaydata item fail");
                            ab.printErrStackTrace("MicroMsg.Voip.VoipService", e2, BuildConfig.FLAVOR, new Object[0]);
                            cpx = null;
                        }
                        if (cpx != null) {
                            ab.i("MicroMsg.Voip.VoipService", "notify relay data type:" + cpx.jCt);
                            if (j7 < ((long) cph.pXC)) {
                                j3 = (long) cph.pXC;
                            } else {
                                j3 = j7;
                            }
                            if (((long) cph.pXC) > j5) {
                                stringBuilder = new StringBuilder("notify relaydata key:[");
                                ab.i("MicroMsg.Voip.VoipService", stringBuilder.append(cph.pXC).append("] > local relaydata key[").append(j5).append("]").toString());
                                if (cpx.jCt == 5) {
                                    this.sSP.sNl.sPs.a(cpx);
                                    j7 = j3;
                                } else if (cpx.jCt == 1) {
                                    this.sSP.sNl.sPs.b(cpx);
                                    j7 = j3;
                                } else {
                                    ab.i("MicroMsg.Voip.VoipService", "notify relaydata unknown type:" + cpx.jCt);
                                    j7 = j3;
                                }
                            } else {
                                stringBuilder = new StringBuilder("notify relaydata item key[");
                                ab.i("MicroMsg.Voip.VoipService", stringBuilder.append(cph.pXC).append("] <=local relaydatakey[").append(j5).append("]").toString());
                                j7 = j3;
                            }
                        } else {
                            ab.i("MicroMsg.Voip.VoipService", "parse Voip notify relaydata item fail");
                        }
                    } else if (cph.wat == 3) {
                        SKBuiltinBuffer_t parseFrom;
                        try {
                            parseFrom = new SKBuiltinBuffer_t().parseFrom(cph.vJd.getBufferToBytes());
                        } catch (IOException e22) {
                            ab.printErrStackTrace("MicroMsg.Voip.VoipService", e22, BuildConfig.FLAVOR, new Object[0]);
                            parseFrom = null;
                        }
                        if (parseFrom != null) {
                            if (j8 < ((long) cph.pXC)) {
                                j3 = (long) cph.pXC;
                            } else {
                                j3 = j8;
                            }
                            if (((long) cph.pXC) > j2) {
                                stringBuilder = new StringBuilder("notify connectingStatkey[");
                                ab.i("MicroMsg.Voip.VoipService", stringBuilder.append(cph.pXC).append("]> local connectingstatus key[").append(j2).append("]").toString());
                                this.sSP.sNl.sPs.c(parseFrom);
                                if (this.sTc != null && (com.tencent.mm.plugin.voip.a.a.bv(parseFrom.getBuffer().toByteArray()) & 255) == 1) {
                                    this.sTc.xmL = 1;
                                }
                            }
                            j8 = j3;
                        }
                    }
                    i2 = i3 + 1;
                } else {
                    if (j6 <= j4) {
                        j6 = j4;
                    }
                    if (j7 <= j5) {
                        j7 = j5;
                    }
                    if (j8 <= j2) {
                        j8 = j2;
                    }
                    HashMap hashMap = new HashMap();
                    hashMap.put(Integer.valueOf(1), Long.valueOf(j6));
                    hashMap.put(Integer.valueOf(2), Long.valueOf(j7));
                    hashMap.put(Integer.valueOf(3), Long.valueOf(j8));
                    byte[] ai = ai(hashMap);
                    if (i == this.sSP.sNl.sPp.nwu && j == this.sSP.sNl.sPp.nwv) {
                        this.sSP.sNl.sPt = ai;
                        ab.i("MicroMsg.Voip.VoipService", "voipNotify:ext notify data new keys:" + j6 + ", " + j7 + ", " + j8);
                    }
                    ab.i("MicroMsg.Voip.VoipService", "__parse voip notify end");
                    AppMethodBeat.o(4619);
                    return 0;
                }
            }
        } catch (Exception e3) {
            ab.printErrStackTrace("MicroMsg.Voip.VoipService", e3, BuildConfig.FLAVOR, new Object[0]);
            ab.i("MicroMsg.Voip.VoipService", "parse voip extNotifyData fail extNotifyData size " + bArr.length + " first byte " + bs(bArr));
            AppMethodBeat.o(4619);
            return 0;
        }
    }

    public static byte[] U(byte[] bArr, int i) {
        byte[] bArr2 = new byte[i];
        for (int i2 = 12; i2 < i + 12; i2++) {
            bArr2[i2 - 12] = bArr[i2];
        }
        return bArr2;
    }

    public final int R(boolean z, boolean z2) {
        AppMethodBeat.i(4620);
        int R = this.sSP.R(z, z2);
        AppMethodBeat.o(4620);
        return R;
    }

    public final void Gh(int i) {
        AppMethodBeat.i(4621);
        this.sSP.Gh(i);
        AppMethodBeat.o(4621);
    }

    public final int cJZ() {
        return this.sSP.sNl.sPp.nwu;
    }

    public final long cKa() {
        return this.sSP.sNl.sPp.nwv;
    }

    public final long cIK() {
        AppMethodBeat.i(138370);
        long cIK = this.sSP.sNl.cIK();
        AppMethodBeat.o(138370);
        return cIK;
    }

    public final int cIt() {
        AppMethodBeat.i(138371);
        int cIt = this.sSP.sNl.cIt();
        AppMethodBeat.o(138371);
        return cIt;
    }

    public final void Gw(int i) {
        AppMethodBeat.i(4624);
        ab.d("MicroMsg.Voip.VoipService", "devin: camera errcode: %d", new Object[]{Integer.valueOf(i)});
        this.sSP.Gw(i);
        AppMethodBeat.o(4624);
    }

    public final void cKb() {
        AppMethodBeat.i(4625);
        ab.d("MicroMsg.Voip.VoipService", "devin: setCallResult: %d", new Object[]{Integer.valueOf(1)});
        this.sSP.sNl.sPp.sVH.sQq = 1;
        AppMethodBeat.o(4625);
    }

    public final int a(byte[] bArr, int i, int i2, int i3, int i4, int[] iArr, boolean z) {
        AppMethodBeat.i(4626);
        m mVar = this.sSP.sNl.sPr;
        if (((!z ? 1 : 0) & (mVar.kzf == m.kze ? 1 : 0)) != 0) {
            AppMethodBeat.o(4626);
            return -1;
        } else if (mVar.sNl.sPp.cKK()) {
            int videoEncodeToLocal = mVar.sNl.sPp.videoEncodeToLocal(bArr, i, i3, i4, i2, 0, 75, iArr);
            AppMethodBeat.o(4626);
            return videoEncodeToLocal;
        } else {
            AppMethodBeat.o(4626);
            return -1;
        }
    }

    public final boolean mj(boolean z) {
        AppMethodBeat.i(4627);
        boolean mj = this.sSP.mj(z);
        AppMethodBeat.o(4627);
        return mj;
    }

    public final int mo(boolean z) {
        AppMethodBeat.i(4628);
        int mo = this.sSP.mo(z);
        AppMethodBeat.o(4628);
        return mo;
    }

    public final int mp(boolean z) {
        AppMethodBeat.i(4629);
        int mp = this.sSP.mp(z);
        AppMethodBeat.o(4629);
        return mp;
    }

    public final void an(int i, boolean z) {
        AppMethodBeat.i(4630);
        s sVar = this.sSP;
        if (sVar.sTj != null) {
            sVar.sTj.ao(i, z);
        }
        AppMethodBeat.o(4630);
    }

    public final void Gx(int i) {
        AppMethodBeat.i(4631);
        this.sSP.Gx(i);
        AppMethodBeat.o(4631);
    }

    public final boolean cKc() {
        boolean z = false;
        AppMethodBeat.i(4632);
        try {
            if (!(this.sSP.sNl.sPp == null || (this.sSP.sNl.sPp.sUI & 8) == 0)) {
                z = true;
            }
        } catch (Exception e) {
            ab.e("MicroMsg.Voip.VoipService", "steve:cannot get CPU usage! error: " + e.getMessage());
        }
        AppMethodBeat.o(4632);
        return z;
    }

    public static void a(Context context, String str, boolean z, boolean z2, boolean z3) {
        AppMethodBeat.i(4633);
        if (context == null) {
            context = ah.getContext();
        }
        long currentTimeMillis = System.currentTimeMillis();
        iq iqVar = new iq();
        iqVar.cDO.cDR = false;
        iqVar.cDO.cDQ = currentTimeMillis;
        iqVar.cDO.cDP = context;
        com.tencent.mm.sdk.b.a.xxA.m(iqVar);
        ab.i("MicroMsg.Voip.VoipService", "start VideoActivity");
        Intent intent = new Intent(context, VideoActivity.class);
        intent.putExtra("Voip_User", str);
        intent.putExtra("Voip_Outcall", z);
        intent.putExtra("Voip_VideoCall", z2);
        intent.putExtra("Voip_LastPage_Hash", currentTimeMillis);
        if (z3) {
            intent.setFlags(603979776);
            intent.addFlags(ErrorDialogData.BINDER_CRASH);
        }
        context.startActivity(intent);
        AppMethodBeat.o(4633);
    }

    /* JADX WARNING: Removed duplicated region for block: B:96:0x0344  */
    /* JADX WARNING: Removed duplicated region for block: B:96:0x0344  */
    public final com.tencent.mm.plugin.voip.model.VoipMgr a(android.content.Context r10, com.tencent.mm.pointers.PString r11, com.tencent.mm.pointers.PBool r12, com.tencent.mm.pointers.PBool r13, com.tencent.mm.pointers.PInt r14) {
        /*
        r9 = this;
        r0 = 4634; // 0x121a float:6.494E-42 double:2.2895E-320;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r0);
        r0 = r9.sSQ;
        if (r0 == 0) goto L_0x0034;
    L_0x0009:
        r0 = "MicroMsg.Voip.VoipService";
        r1 = "voipMgr is not null";
        com.tencent.mm.sdk.platformtools.ab.i(r0, r1);
        r0 = r9.sSQ;
        r0 = r0.edV;
        r11.value = r0;
        r0 = r9.sSQ;
        r0 = r0.sRm;
        r12.value = r0;
        r0 = r9.sSQ;
        r0 = r0.sRn;
        r13.value = r0;
        r0 = r9.sSQ;
        r0 = r0.sRc;
        r0 = r0.mState;
        r14.value = r0;
        r0 = r9.sSQ;
        r1 = 4634; // 0x121a float:6.494E-42 double:2.2895E-320;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r1);
    L_0x0033:
        return r0;
    L_0x0034:
        r0 = r11.value;
        if (r0 != 0) goto L_0x0048;
    L_0x0038:
        r0 = "MicroMsg.Voip.VoipService";
        r1 = "username is null, can't start voip";
        com.tencent.mm.sdk.platformtools.ab.e(r0, r1);
        r0 = 0;
        r1 = 4634; // 0x121a float:6.494E-42 double:2.2895E-320;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r1);
        goto L_0x0033;
    L_0x0048:
        r0 = r12.value;
        if (r0 != 0) goto L_0x0085;
    L_0x004c:
        r0 = r9.sSP;
        r0 = r0.cIJ();
        if (r0 != 0) goto L_0x0085;
    L_0x0054:
        r0 = "MicroMsg.Voip.VoipService";
        r1 = "is out call, but kenerl is not working";
        com.tencent.mm.sdk.platformtools.ab.e(r0, r1);
        r2 = r11.value;
        r0 = r13.value;
        if (r0 == 0) goto L_0x0080;
    L_0x0063:
        r0 = com.tencent.mm.storage.bi.xZc;
    L_0x0065:
        r1 = r12.value;
        if (r1 == 0) goto L_0x0083;
    L_0x0069:
        r1 = 1;
    L_0x006a:
        r3 = 4;
        r4 = com.tencent.mm.sdk.platformtools.ah.getContext();
        r5 = 2131304355; // 0x7f091fa3 float:1.822685E38 double:1.0530042626E-314;
        r4 = r4.getString(r5);
        com.tencent.mm.plugin.voip.model.q.a(r2, r0, r1, r3, r4);
        r0 = 0;
        r1 = 4634; // 0x121a float:6.494E-42 double:2.2895E-320;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r1);
        goto L_0x0033;
    L_0x0080:
        r0 = com.tencent.mm.storage.bi.xZb;
        goto L_0x0065;
    L_0x0083:
        r1 = 0;
        goto L_0x006a;
    L_0x0085:
        r0 = new com.tencent.mm.plugin.voip.model.VoipMgr;
        r0.<init>();
        r9.sSQ = r0;
        r6 = r9.sSQ;
        r0 = r11.value;
        r1 = r12.value;
        r2 = r13.value;
        r3 = "MicroMsg.Voip.VoipMgr";
        r4 = "start VoIP, userName: %s, isOutCall: %b, isVideoCall: %b";
        r5 = 3;
        r5 = new java.lang.Object[r5];
        r7 = 0;
        r5[r7] = r0;
        r7 = 1;
        r8 = java.lang.Boolean.valueOf(r1);
        r5[r7] = r8;
        r7 = 2;
        r8 = java.lang.Boolean.valueOf(r2);
        r5[r7] = r8;
        com.tencent.mm.sdk.platformtools.ab.i(r3, r4, r5);
        r3 = 1;
        r6.sRG = r3;
        r6.edV = r0;
        r6.sRm = r1;
        r6.sRn = r2;
        r0 = com.tencent.mm.plugin.messenger.foundation.a.j.class;
        r0 = com.tencent.mm.kernel.g.K(r0);
        r0 = (com.tencent.mm.plugin.messenger.foundation.a.j) r0;
        r0 = r0.XM();
        r3 = r6.edV;
        r0 = r0.aoO(r3);
        r6.sRl = r0;
        r0 = new com.tencent.mm.sdk.platformtools.ak;
        r3 = android.os.Looper.getMainLooper();
        r0.<init>(r3);
        r6.iGP = r0;
        r0 = r6.sRM;
        if (r0 != 0) goto L_0x00e4;
    L_0x00dd:
        r0 = new com.tencent.mm.plugin.voip.video.e;
        r0.<init>();
        r6.sRM = r0;
    L_0x00e4:
        r0 = 0;
        r6.sRN = r0;
        r0 = 0;
        r6.sRO = r0;
        r0 = "VOIPCameraSwitch";
        r3 = com.tencent.mm.m.g.Nu();
        r0 = r3.getValue(r0);
        r3 = 1;
        r0 = com.tencent.mm.sdk.platformtools.bo.getInt(r0, r3);
        if (r0 != 0) goto L_0x0208;
    L_0x00fc:
        r0 = 1;
    L_0x00fd:
        r6.sRo = r0;
        r0 = r6.sRn;
        if (r0 != 0) goto L_0x0106;
    L_0x0103:
        r0 = 0;
        r6.sRo = r0;
    L_0x0106:
        r0 = com.tencent.mm.plugin.voip.a.b.T(r1, r2);
        r2 = r6.sRo;
        if (r2 == 0) goto L_0x0111;
    L_0x010e:
        if (r0 != 0) goto L_0x020b;
    L_0x0110:
        r0 = 1;
    L_0x0111:
        if (r1 == 0) goto L_0x0213;
    L_0x0113:
        r0 = com.tencent.mm.plugin.voip.a.b.GM(r0);
        r6.sRc = r0;
    L_0x0119:
        r3 = com.tencent.mm.compatible.f.b.Mi();
        r4 = com.tencent.mm.compatible.f.b.Mj();
        r0 = android.os.Build.MANUFACTURER;
        r1 = "meizu";
        r0 = r0.equalsIgnoreCase(r1);
        if (r0 == 0) goto L_0x016c;
    L_0x012c:
        if (r3 != 0) goto L_0x014c;
    L_0x012e:
        r1 = com.tencent.mm.plugin.report.service.h.pYm;
        r2 = 11306; // 0x2c2a float:1.5843E-41 double:5.586E-320;
        r0 = 2;
        r5 = new java.lang.Object[r0];
        r7 = 0;
        r0 = r6.sRn;
        if (r0 == 0) goto L_0x021b;
    L_0x013a:
        r0 = 0;
    L_0x013b:
        r0 = java.lang.Integer.valueOf(r0);
        r5[r7] = r0;
        r0 = 1;
        r7 = 1;
        r7 = java.lang.Integer.valueOf(r7);
        r5[r0] = r7;
        r1.e(r2, r5);
    L_0x014c:
        if (r4 != 0) goto L_0x016c;
    L_0x014e:
        r1 = com.tencent.mm.plugin.report.service.h.pYm;
        r2 = 11306; // 0x2c2a float:1.5843E-41 double:5.586E-320;
        r0 = 2;
        r5 = new java.lang.Object[r0];
        r7 = 0;
        r0 = r6.sRn;
        if (r0 == 0) goto L_0x021e;
    L_0x015a:
        r0 = 0;
    L_0x015b:
        r0 = java.lang.Integer.valueOf(r0);
        r5[r7] = r0;
        r0 = 1;
        r7 = 0;
        r7 = java.lang.Integer.valueOf(r7);
        r5[r0] = r7;
        r1.e(r2, r5);
    L_0x016c:
        if (r4 == 0) goto L_0x0170;
    L_0x016e:
        if (r3 != 0) goto L_0x0195;
    L_0x0170:
        r1 = 0;
        r2 = 0;
        if (r3 != 0) goto L_0x0221;
    L_0x0174:
        if (r4 != 0) goto L_0x0221;
    L_0x0176:
        r0 = 2131304470; // 0x7f092016 float:1.8227084E38 double:1.0530043195E-314;
        r1 = r10.getString(r0);
        r0 = 2131304440; // 0x7f091ff8 float:1.8227023E38 double:1.0530043046E-314;
        r2 = r10.getString(r0);
    L_0x0184:
        r0 = 2131304443; // 0x7f091ffb float:1.8227029E38 double:1.053004306E-314;
        r3 = r10.getString(r0);
        r4 = 1;
        r5 = new com.tencent.mm.plugin.voip.model.VoipMgr$14;
        r5.<init>(r6, r10);
        r0 = r10;
        com.tencent.mm.ui.base.h.a(r0, r1, r2, r3, r4, r5);
    L_0x0195:
        r0 = "MicroMsg.Voip.VoipMgr";
        r1 = "initMgr";
        com.tencent.mm.sdk.platformtools.ab.i(r0, r1);
        r0 = com.tencent.mm.booter.a.Ib();
        r0.Id();
        r0 = com.tencent.mm.compatible.b.g.KK();
        r0.b(r6);
        r0 = com.tencent.mm.compatible.b.g.KK();
        r0.a(r6);
        r0 = com.tencent.mm.compatible.b.g.KK();
        r0.KM();
        r0 = new com.tencent.mm.compatible.util.b;
        r1 = com.tencent.mm.sdk.platformtools.ah.getContext();
        r0.<init>(r1);
        r6.cqx = r0;
        r0 = r6.cqx;
        r0.requestFocus();
        r0 = r6.sRn;
        if (r0 == 0) goto L_0x0245;
    L_0x01ce:
        r0 = com.tencent.mm.plugin.voip.b.cIj();
        r1 = 1;
        r2 = 1;
        r3 = r6.edV;
        r0.b(r1, r2, r3);
    L_0x01d9:
        r0 = r6.sRm;
        if (r0 == 0) goto L_0x0261;
    L_0x01dd:
        r0 = com.tencent.mm.plugin.voip.b.cIj();
        r0 = r0.sSP;
        r0.cKi();
        r0 = r6.sRn;
        if (r0 == 0) goto L_0x0251;
    L_0x01ea:
        r0 = com.tencent.mm.plugin.voip.b.cIj();
        r1 = r6.sRl;
        r1 = r1.field_username;
        r0 = r0.sSP;
        r2 = 0;
        r0 = r0.dp(r1, r2);
    L_0x01f9:
        if (r0 >= 0) goto L_0x0261;
    L_0x01fb:
        r0 = 0;
        r6.mu(r0);
    L_0x01ff:
        r0 = r9.sSQ;
        r1 = 4634; // 0x121a float:6.494E-42 double:2.2895E-320;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r1);
        goto L_0x0033;
    L_0x0208:
        r0 = 0;
        goto L_0x00fd;
    L_0x020b:
        r2 = 256; // 0x100 float:3.59E-43 double:1.265E-321;
        if (r2 != r0) goto L_0x0111;
    L_0x020f:
        r0 = 257; // 0x101 float:3.6E-43 double:1.27E-321;
        goto L_0x0111;
    L_0x0213:
        r0 = com.tencent.mm.plugin.voip.a.b.GL(r0);
        r6.sRc = r0;
        goto L_0x0119;
    L_0x021b:
        r0 = 1;
        goto L_0x013b;
    L_0x021e:
        r0 = 1;
        goto L_0x015b;
    L_0x0221:
        if (r3 != 0) goto L_0x0233;
    L_0x0223:
        r0 = 2131304472; // 0x7f092018 float:1.8227088E38 double:1.0530043204E-314;
        r1 = r10.getString(r0);
        r0 = 2131304441; // 0x7f091ff9 float:1.8227025E38 double:1.053004305E-314;
        r2 = r10.getString(r0);
        goto L_0x0184;
    L_0x0233:
        if (r4 != 0) goto L_0x0184;
    L_0x0235:
        r0 = 2131304471; // 0x7f092017 float:1.8227086E38 double:1.05300432E-314;
        r1 = r10.getString(r0);
        r0 = 2131304442; // 0x7f091ffa float:1.8227027E38 double:1.0530043056E-314;
        r2 = r10.getString(r0);
        goto L_0x0184;
    L_0x0245:
        r0 = com.tencent.mm.plugin.voip.b.cIj();
        r1 = 1;
        r2 = 0;
        r3 = r6.edV;
        r0.b(r1, r2, r3);
        goto L_0x01d9;
    L_0x0251:
        r0 = com.tencent.mm.plugin.voip.b.cIj();
        r1 = r6.sRl;
        r1 = r1.field_username;
        r0 = r0.sSP;
        r2 = 1;
        r0 = r0.dp(r1, r2);
        goto L_0x01f9;
    L_0x0261:
        r0 = new com.tencent.mm.plugin.voip.HeadsetPlugReceiver;
        r0.<init>();
        r6.sRd = r0;
        r0 = r6.sRd;
        r1 = com.tencent.mm.sdk.platformtools.ah.getContext();
        r2 = r6.sSk;
        r0.a(r1, r2);
        r0 = com.tencent.mm.plugin.voip.b.cIj();
        r1 = com.tencent.mm.sdk.platformtools.ah.getContext();
        r0 = r0.sSP;
        r2 = r0.sNl;
        r2.jiq = r1;
        r0 = r0.sNl;
        r0.sPq = r6;
        r0 = "MicroMsg.Voip.VoipServiceEx";
        r1 = "attach ui........";
        com.tencent.mm.plugin.voip.a.a.Logd(r0, r1);
        com.tencent.mm.plugin.voip.a.a.cLs();
        r0 = com.tencent.mm.sdk.platformtools.ah.getContext();
        r1 = "phone";
        r0 = r0.getSystemService(r1);
        r0 = (android.telephony.TelephonyManager) r0;
        r6.nva = r0;
        r0 = r6.nva;
        r1 = r6.nvb;
        r2 = 32;
        r0.listen(r1, r2);
        r0 = r6.sRn;
        if (r0 == 0) goto L_0x0384;
    L_0x02ad:
        r0 = 0;
    L_0x02ae:
        r1 = com.tencent.mm.plugin.voip.b.cIj();
        r2 = r6.sRm;
        r1.an(r0, r2);
        r0 = com.tencent.mm.compatible.b.g.KK();
        r0 = r0.KV();
        if (r0 == 0) goto L_0x0387;
    L_0x02c1:
        r0 = 3;
        r1 = r6;
    L_0x02c3:
        r1.sRr = r0;
        r0 = 0;
        r6.sRL = r0;
        r0 = r6.sRn;
        r6.sRu = r0;
        r0 = new java.lang.StringBuilder;
        r1 = "voip_recent_contact";
        r0.<init>(r1);
        r1 = com.tencent.mm.model.r.Yz();
        r0 = r0.append(r1);
        r0 = r0.toString();
        r1 = com.tencent.mm.sdk.platformtools.ah.getContext();
        r2 = "voip_plugin_prefs";
        r3 = 0;
        r1 = r1.getSharedPreferences(r2, r3);
        r2 = 0;
        r2 = r1.getString(r0, r2);
        if (r2 == 0) goto L_0x03ab;
    L_0x02f3:
        r3 = ";";
        r2 = r2.split(r3);
        r2 = com.tencent.mm.sdk.platformtools.bo.P(r2);
        if (r2 == 0) goto L_0x03ab;
    L_0x0300:
        r3 = r2.size();
        r4 = r6.edV;
        r4 = r2.contains(r4);
        if (r4 == 0) goto L_0x03a1;
    L_0x030c:
        r4 = 1;
        if (r3 <= r4) goto L_0x031a;
    L_0x030f:
        r3 = r6.edV;
        r2.remove(r3);
    L_0x0314:
        r3 = 0;
        r4 = r6.edV;
        r2.add(r3, r4);
    L_0x031a:
        r3 = ";";
        r2 = com.tencent.mm.sdk.platformtools.bo.c(r2, r3);
        r1 = r1.edit();
        r0 = r1.putString(r0, r2);
        r0.commit();
    L_0x032c:
        r0 = com.tencent.mm.sdk.b.a.xxA;
        r1 = r6.sSm;
        r0.c(r1);
        r0 = com.tencent.mm.sdk.b.a.xxA;
        r1 = r6.nvc;
        r0.c(r1);
        r0 = r6.sRz;
        r1 = r0.jFO;
        r1 = r1.contains(r6);
        if (r1 != 0) goto L_0x0349;
    L_0x0344:
        r0 = r0.jFO;
        r0.add(r6);
    L_0x0349:
        r0 = new android.content.IntentFilter;
        r0.<init>();
        r1 = "android.intent.action.SCREEN_ON";
        r0.addAction(r1);
        r1 = "android.intent.action.SCREEN_OFF";
        r0.addAction(r1);
        r1 = "android.intent.action.USER_PRESENT";
        r0.addAction(r1);
        r1 = com.tencent.mm.sdk.platformtools.ah.getContext();
        r2 = r6.sSj;
        r1.registerReceiver(r2, r0);
        r0 = new com.tencent.mm.sdk.platformtools.SensorController;
        r1 = r6.getContext();
        r0.<init>(r1);
        r6.mfW = r0;
        r0 = "MicroMsg.Voip.VoipMgr";
        r1 = "initMgr setSensorCallBack";
        com.tencent.mm.sdk.platformtools.ab.i(r0, r1);
        r0 = r6.mfW;
        r0.a(r6);
        goto L_0x01ff;
    L_0x0384:
        r0 = 1;
        goto L_0x02ae;
    L_0x0387:
        r0 = com.tencent.mm.compatible.b.g.KK();
        r0 = r0.KP();
        if (r0 == 0) goto L_0x0395;
    L_0x0391:
        r0 = 4;
        r1 = r6;
        goto L_0x02c3;
    L_0x0395:
        r0 = r6.sRn;
        if (r0 == 0) goto L_0x039d;
    L_0x0399:
        r0 = 1;
        r1 = r6;
        goto L_0x02c3;
    L_0x039d:
        r0 = 2;
        r1 = r6;
        goto L_0x02c3;
    L_0x03a1:
        r4 = 4;
        if (r4 != r3) goto L_0x0314;
    L_0x03a4:
        r3 = r3 + -1;
        r2.remove(r3);
        goto L_0x0314;
    L_0x03ab:
        r2 = new java.util.ArrayList;
        r2.<init>();
        r3 = 0;
        r4 = r6.edV;
        r2.add(r3, r4);
        r3 = ";";
        r2 = com.tencent.mm.sdk.platformtools.bo.c(r2, r3);
        r1 = r1.edit();
        r0 = r1.putString(r0, r2);
        r0.commit();
        goto L_0x032c;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.plugin.voip.model.r.a(android.content.Context, com.tencent.mm.pointers.PString, com.tencent.mm.pointers.PBool, com.tencent.mm.pointers.PBool, com.tencent.mm.pointers.PInt):com.tencent.mm.plugin.voip.model.VoipMgr");
    }

    public static float mw(boolean z) {
        AppMethodBeat.i(4635);
        float f = 0.74766356f;
        try {
            byte[] bArr;
            r cIj = b.cIj();
            if (z) {
                bArr = cIj.sSP.sNl.sPp.field_capInfo;
            } else {
                bArr = cIj.sSP.sNl.sPp.sUb;
            }
            if (bArr != null) {
                ByteBuffer wrap = ByteBuffer.wrap(bArr);
                if (wrap.getInt() > 65535) {
                    wrap.order(ByteOrder.LITTLE_ENDIAN);
                }
                wrap.getShort();
                wrap.getShort();
                float f2 = ((float) wrap.getInt()) / 100.0f;
                if (f2 != 0.0f) {
                    f = f2;
                }
                ab.d("MicroMsg.Voip.VoipService", "use rate: %s, changed: %s", new Object[]{Float.valueOf(f), Boolean.valueOf(z)});
            }
        } catch (Exception e) {
            ab.e("MicroMsg.Voip.VoipService", "update failed: " + e.getMessage());
        }
        AppMethodBeat.o(4635);
        return f;
    }

    public final void cKd() {
        AppMethodBeat.i(4636);
        this.sSP.sTt.ae(1000, 1000);
        AppMethodBeat.o(4636);
    }

    private static boolean eA(Context context) {
        AppMethodBeat.i(4637);
        List runningTasks = ((ActivityManager) context.getSystemService("activity")).getRunningTasks(1);
        if (!(runningTasks == null || runningTasks.isEmpty())) {
            ComponentName componentName = ((RunningTaskInfo) runningTasks.get(0)).topActivity;
            ab.d("MicroMsg.Voip.VoipService", "topActivity:" + componentName.flattenToString());
            if (!componentName.getPackageName().equals(context.getPackageName())) {
                ab.i("MicroMsg.Voip.VoipService", "is in backGround.");
                AppMethodBeat.o(4637);
                return false;
            }
        }
        if (((KeyguardManager) ah.getContext().getSystemService("keyguard")).inKeyguardRestrictedInputMode()) {
            AppMethodBeat.o(4637);
            return false;
        }
        ab.i("MicroMsg.Voip.VoipService", "is in foreGround.");
        AppMethodBeat.o(4637);
        return true;
    }

    public final void Gj(int i) {
        AppMethodBeat.i(4638);
        this.sSP.sNl.Gj(i);
        AppMethodBeat.o(4638);
    }

    public final void cKe() {
        AppMethodBeat.i(4639);
        this.sSP.sNl.sPr.cIZ();
        AppMethodBeat.o(4639);
    }

    public final void jj(boolean z) {
        int i;
        AppMethodBeat.i(4640);
        ab.c("MicroMsg.Voip.VoipService", "setEngineHeadsetPlugged, %s", new Object[]{Boolean.valueOf(z)});
        byte[] bArr = new byte[1];
        if (z) {
            i = 1;
        } else {
            i = 0;
        }
        bArr[0] = (byte) i;
        this.sSP.sNl.sPp.setAppCmd(425, bArr, 1);
        AppMethodBeat.o(4640);
    }
}
