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 d {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private static UserContentResolver f2460a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private static final Uri f2461b = Uri.parse("content://com.seewo.osservice.provider.VCommonContentProvider/key");

    private static boolean a(Context context, String str) {
        return "true".equals(g(context, str));
    }

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

    private static boolean c(Context context, String str, int i) {
        return "true".equals(h(context, str, i));
    }

    public static boolean d(Context context) {
        return a(context, "hisi_wifi_status");
    }

    public static String e(Context context) {
        return h(context, "HOST_DEVICE_IP", 0);
    }

    private static String f(ContentResolver contentResolver, String str) {
        String string = "";
        Cursor cursorQuery = null;
        try {
            try {
                cursorQuery = contentResolver.query(f2461b, 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 g(Context context, String str) {
        return f(context.getContentResolver(), str);
    }

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

    public static boolean i(Context context) {
        return c(context, "IS_ONE_NET_MACHINE", 0);
    }

    public static boolean j(Context context) {
        return b(context, "slot_eth0", false);
    }
}
