package com.tencent.mm.plugin.music.f.a;

import android.text.TextUtils;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.sdk.g.d;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.qqmusic.mediaplayer.AudioPlayerConfigure;
import com.tencent.qqmusic.mediaplayer.NativeLibs;
import java.util.HashMap;

public class a {
    private static boolean aIA = false;
    private static c oNN = new a();
    private static boolean oNO = false;

    static class a implements c {
        private HashMap<String, Boolean> oNP;

        private a() {
            AppMethodBeat.i(137642);
            this.oNP = new HashMap();
            AppMethodBeat.o(137642);
        }

        /* synthetic */ a(byte b) {
            this();
        }

        public final boolean load(String str) {
            AppMethodBeat.i(137643);
            if (TextUtils.isEmpty(str)) {
                ab.e("MicroMsg.Audio.AudioPlayerUtils", "LoadLibrary lib_name is null");
                AppMethodBeat.o(137643);
                return false;
            } else if (this.oNP.containsKey(str) && ((Boolean) this.oNP.get(str)).booleanValue()) {
                ab.e("MicroMsg.Audio.AudioPlayerUtils", "LoadLibrary lib_name %s is loaded", new Object[]{str});
                AppMethodBeat.o(137643);
                return true;
            } else {
                this.oNP.put(str, Boolean.TRUE);
                System.loadLibrary(str);
                AppMethodBeat.o(137643);
                return true;
            }
        }

        public final String findLibPath(String str) {
            AppMethodBeat.i(137644);
            ab.i("MicroMsg.Audio.AudioPlayerUtils", "findLibPath %s", new Object[]{str});
            if (!str.startsWith("lib")) {
                str = "lib".concat(String.valueOf(str));
            }
            if (!str.endsWith(".so")) {
                str = str + ".so";
            }
            AppMethodBeat.o(137644);
            return str;
        }

        public final boolean Tn(String str) {
            AppMethodBeat.i(137645);
            if (this.oNP.containsKey(str)) {
                AppMethodBeat.o(137645);
                return true;
            }
            AppMethodBeat.o(137645);
            return false;
        }
    }

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

    public static void bUE() {
        AppMethodBeat.i(137646);
        ab.i("MicroMsg.Audio.AudioPlayerUtils", "configQQMusicSdkConfig");
        AudioPlayerConfigure.setLog(new 1());
        AudioPlayerConfigure.setSoLibraryLoader(new 2());
        if (!(oNO || aIA)) {
            aIA = true;
            d.post(new 3(), "audio load NLog");
        }
        AppMethodBeat.o(137646);
    }

    public static synchronized boolean bUF() {
        boolean z = false;
        synchronized (a.class) {
            AppMethodBeat.i(137647);
            if (oNO) {
                z = true;
                AppMethodBeat.o(137647);
            } else if (oNN == null) {
                AppMethodBeat.o(137647);
            } else {
                oNN.load(NativeLibs.nlog.getName());
                if (oNN.Tn(NativeLibs.nlog.getName())) {
                    try {
                        oNO = AudioPlayerConfigure.enableNativeLog(null);
                    } catch (Throwable th) {
                        ab.printErrStackTrace("MicroMsg.Audio.AudioPlayerUtils", th, "checkNLogLoad", new Object[0]);
                        if (com.tencent.mm.compatible.util.d.fP(20)) {
                            oNO = AudioPlayerConfigure.enableNativeLog(null);
                        } else {
                            AppMethodBeat.o(137647);
                        }
                    }
                    if (oNO) {
                        ab.i("MicroMsg.Audio.AudioPlayerUtils", "enableNativeLog success");
                    }
                    z = oNO;
                    AppMethodBeat.o(137647);
                } else {
                    ab.i("MicroMsg.Audio.AudioPlayerUtils", "enableNativeLog fail");
                    AppMethodBeat.o(137647);
                }
            }
        }
        return z;
    }

    public static void a(c cVar) {
        oNN = cVar;
    }
}
