package com.tencent.mm.ah;

import android.net.Uri;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.jni.utils.UtilsJni;
import com.tencent.mm.kernel.g;
import com.tencent.mm.plugin.emoji.b.c;
import com.tencent.mm.plugin.report.service.h;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.az.a;
import com.tencent.mm.sdk.platformtools.r;
import com.tencent.mm.vfs.e;

class e$a implements a {
    boolean aAR = true;
    String frH;
    String frI;
    final /* synthetic */ e frJ;
    h fro;
    boolean frq;

    public e$a(e eVar, h hVar, String str, String str2) {
        this.frJ = eVar;
        this.fro = hVar;
        this.frH = str;
        this.frI = str2;
        this.frq = false;
    }

    public final boolean acf() {
        AppMethodBeat.i(77905);
        if (this.frq) {
            h.pYm.k(138, 61, 1);
            ab.i("MicroMsg.GetHDHeadImgHelper", "DecryptAvatar: decrypt %s", new Object[]{this.frI});
            byte[] DecryptAvatar = UtilsJni.DecryptAvatar(e.e(this.frI, 0, -1));
            if (DecryptAvatar == null || DecryptAvatar.length <= 0) {
                h.pYm.k(138, 62, 1);
                ab.i("MicroMsg.GetHDHeadImgHelper", "DecryptAvatar: decrypt failed");
                AppMethodBeat.o(77905);
                return true;
            }
            e.deleteFile(this.frI);
            e.b(this.frI, DecryptAvatar, DecryptAvatar.length);
        }
        if (r.amp(this.frI)) {
            ab.i("MicroMsg.GetHDHeadImgHelper", "DecryptAvatar: hevc to pic start");
            h.pYm.k(138, 63, 1);
            String str = this.frI + "_hevc";
            e.aQ(this.frI, str);
            e.atc(this.frI);
            Uri asY = e.asY(this.frI);
            Uri asY2 = e.asY(str);
            if (asY == null || asY2 == null) {
                ab.i("MicroMsg.GetHDHeadImgHelper", "DecryptAvatar: uri is null %s, %s", new Object[]{asY, asY2});
                AppMethodBeat.o(77905);
                return true;
            }
            String path = asY.getPath();
            int nativeWxam2Pic = ((c) g.K(c.class)).nativeWxam2Pic(asY2.getPath(), path);
            e.deleteFile(str);
            if (nativeWxam2Pic != 0) {
                h.pYm.k(138, 64, 1);
                ab.i("MicroMsg.GetHDHeadImgHelper", "DecryptAvatar: hevc to pic failed");
                AppMethodBeat.o(77905);
                return true;
            }
        }
        this.aAR = false;
        AppMethodBeat.o(77905);
        return true;
    }

    public final boolean acg() {
        AppMethodBeat.i(77906);
        if (this.frJ.frF) {
            AppMethodBeat.o(77906);
            return false;
        } else if (this.aAR) {
            this.frJ.frD.cr(3, -1);
            AppMethodBeat.o(77906);
            return false;
        } else {
            e.deleteFile(this.frH);
            e.aQ(this.frI, this.frH);
            k.av(this.frH, this.fro.getUsername());
            this.frJ.frD.cr(0, 0);
            AppMethodBeat.o(77906);
            return true;
        }
    }
}
