package com.tencent.mm.plugin.notification.d;

import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.compatible.util.e;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.ytcommon.BuildConfig;
import java.io.File;
import java.io.IOException;

public final class b {
    private static final String oVS = (e.eSn + "FailMsgFileCache");

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

    public static void init() {
        AppMethodBeat.i(23124);
        ab.d("MicroMsg.FailMsgFileCache", "init FailMsgFileCache");
        new File(oVS).mkdirs();
        AppMethodBeat.o(23124);
    }

    public static void a(int i, a aVar) {
        AppMethodBeat.i(23125);
        String str = null;
        if (i == 1) {
            str = oVS + File.separator + "normalMsg";
        } else if (i == 2) {
            str = oVS + File.separator + "snsMsg";
        }
        if (bo.isNullOrNil(str)) {
            ab.e("MicroMsg.FailMsgFileCache", "flushToDisk error, cannot find filename");
            AppMethodBeat.o(23125);
            return;
        }
        ab.d("MicroMsg.FailMsgFileCache", "flushToDisk, filename:%s", new Object[]{str});
        String bWO = aVar.bWO();
        ab.d("MicroMsg.FailMsgFileCache", "flushToDisk, cacheContent:%s", new Object[]{bWO});
        if (bo.isNullOrNil(bWO)) {
            ab.d("MicroMsg.FailMsgFileCache", "flushToDisk, content is empty");
            AppMethodBeat.o(23125);
            return;
        }
        com.tencent.mm.a.e.b(str, bWO.getBytes(), bWO.length());
        AppMethodBeat.o(23125);
    }

    public static a Ar(int i) {
        String str;
        AppMethodBeat.i(23126);
        if (i == 1) {
            str = oVS + File.separator + "normalMsg";
        } else if (i == 2) {
            str = oVS + File.separator + "snsMsg";
        } else {
            str = null;
        }
        if (bo.isNullOrNil(str)) {
            ab.e("MicroMsg.FailMsgFileCache", "extractFromDisk error, cannot find filename");
            AppMethodBeat.o(23126);
            return null;
        }
        ab.d("MicroMsg.FailMsgFileCache", "extractFromDisk, filename:%s", new Object[]{str});
        try {
            ab.d("MicroMsg.FailMsgFileCache", "extractFromDisk, cacheContent:%s", new Object[]{com.tencent.mm.a.e.cy(str)});
            a aVar = new a();
            aVar.TT(r2);
            AppMethodBeat.o(23126);
            return aVar;
        } catch (IOException e) {
            ab.printErrStackTrace("MicroMsg.FailMsgFileCache", e, BuildConfig.FLAVOR, new Object[0]);
            ab.d("MicroMsg.FailMsgFileCache", "extractFromDisk error:%s", new Object[]{e.toString()});
            AppMethodBeat.o(23126);
            return null;
        }
    }

    public static void As(int i) {
        AppMethodBeat.i(23127);
        String str = null;
        if (i == 1) {
            str = oVS + File.separator + "normalMsg";
        } else if (i == 2) {
            str = oVS + File.separator + "snsMsg";
        }
        if (bo.isNullOrNil(str)) {
            ab.e("MicroMsg.FailMsgFileCache", "removeFile error, cannot find filename");
            AppMethodBeat.o(23127);
            return;
        }
        ab.d("MicroMsg.FailMsgFileCache", "removeFile, filename:%s", new Object[]{str});
        if (com.tencent.mm.a.e.ct(str)) {
            new File(str).delete();
        }
        AppMethodBeat.o(23127);
    }
}
