package com.mediatek.extservice;

import android.os.SystemProperties;
import android.util.Log;

/* JADX INFO: loaded from: classes.dex */
public class CommonLogUtils {
    private static final int LOG_LEVEL_DEBUG = 2;
    private static final String LOG_LEVEL_DEFAULT = "E";
    private static final int LOG_LEVEL_DUMB = Integer.MAX_VALUE;
    private static final int LOG_LEVEL_ERROR = 5;
    private static final int LOG_LEVEL_INFO = 3;
    private static final int LOG_LEVEL_VERBOSE = 1;
    private static final int LOG_LEVEL_WARNING = 4;
    private static final String LOG_PROP_NAME = "vendor.mtk.extservice.loglevel";

    public static void d(String str, String str2) {
        if (isDebugLoggable()) {
            Log.d(str, str2);
        }
    }

    public static void d(String str, String str2, Throwable th) {
        if (isDebugLoggable()) {
            Log.d(str, str2, th);
        }
    }

    public static void e(String str, String str2) {
        if (isErrorLoggable()) {
            Log.e(str, str2);
        }
    }

    public static void e(String str, String str2, Throwable th) {
        if (isErrorLoggable()) {
            Log.e(str, str2, th);
        }
    }

    private static int getLogLevel() {
        String str = SystemProperties.get(LOG_PROP_NAME, LOG_LEVEL_DEFAULT);
        if (str == null || str.isEmpty()) {
            return Integer.MAX_VALUE;
        }
        char cCharAt = str.toUpperCase().charAt(0);
        if (cCharAt == 'D') {
            return 2;
        }
        if (cCharAt == 'E') {
            return 5;
        }
        if (cCharAt == 'I') {
            return 3;
        }
        if (cCharAt != 'V') {
            return cCharAt != 'W' ? Integer.MAX_VALUE : 4;
        }
        return 1;
    }

    public static void i(String str, String str2) {
        if (isInfoLoggable()) {
            Log.i(str, str2);
        }
    }

    public static void i(String str, String str2, Throwable th) {
        if (isInfoLoggable()) {
            Log.i(str, str2, th);
        }
    }

    private static boolean isDebugLoggable() {
        return getLogLevel() <= 2;
    }

    private static boolean isErrorLoggable() {
        return getLogLevel() <= 5;
    }

    private static boolean isInfoLoggable() {
        return getLogLevel() <= 3;
    }

    private static boolean isVerboseLoggable() {
        return getLogLevel() <= 1;
    }

    private static boolean isWarningLoggable() {
        return getLogLevel() <= 4;
    }

    public static void v(String str, String str2) {
        if (isVerboseLoggable()) {
            Log.v(str, str2);
        }
    }

    public static void v(String str, String str2, Throwable th) {
        if (isVerboseLoggable()) {
            Log.v(str, str2, th);
        }
    }

    public static void w(String str, String str2) {
        if (isWarningLoggable()) {
            Log.w(str, str2);
        }
    }

    public static void w(String str, String str2, Throwable th) {
        if (isWarningLoggable()) {
            Log.w(str, str2, th);
        }
    }

    public static void w(String str, Throwable th) {
        if (isWarningLoggable()) {
            Log.w(str, th);
        }
    }
}
