package com.seewo.libsvendors.utils;

import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log;

/* JADX INFO: compiled from: PreferencesUtils.java */
/* JADX INFO: loaded from: classes.dex */
public class c {
    private static UserContentResolver a;
    private static final Uri b = Uri.parse("content://com.seewo.osservice.provider.VCommonContentProvider/key");

    private static boolean a(Context context, String str, boolean z) {
        String strE = e(context, str);
        return TextUtils.isEmpty(strE) ? z : "true".equals(strE);
    }

    private static boolean b(Context context, String str, int i2) {
        return "true".equals(f(context, str, i2));
    }

    public static String c(Context context) {
        return f(context, "HOST_DEVICE_IP", 0);
    }

    private static String d(ContentResolver contentResolver, String str) {
        String string = "";
        Cursor cursorQuery = null;
        try {
            try {
                cursorQuery = contentResolver.query(b, new String[]{str}, null, null, null);
                if (cursorQuery != null && cursorQuery.moveToFirst()) {
                    string = cursorQuery.getString(0);
                }
            } catch (Exception e2) {
                Log.e("PreferencesUtils", "Preferences#getString error, maybe URI is wrong.", e2);
                if (cursorQuery != null) {
                }
            }
            return string;
        } finally {
            if (cursorQuery != null) {
                cursorQuery.close();
            }
        }
    }

    private static String e(Context context, String str) {
        return d(context.getContentResolver(), str);
    }

    private static String f(Context context, String str, int i2) {
        if (Build.VERSION.SDK_INT < 25) {
            return d(context.getContentResolver(), str);
        }
        UserContentResolver userContentResolver = a;
        if (userContentResolver == null) {
            a = new UserContentResolver(context, i2);
        } else {
            userContentResolver.setUserId(i2);
        }
        return d(a, str);
    }

    public static boolean g(Context context) {
        return b(context, "IS_ONE_NET_MACHINE", 0);
    }

    public static boolean h(Context context) {
        return a(context, "slot_eth0", false);
    }
}
