package com.seewo.vcommons.data;

import android.content.Context;
import android.content.Intent;
import android.content.pm.UserInfo;
import android.os.UserManager;
import android.security.KeyStore;
import android.text.TextUtils;
import android.util.Log;
import com.android.internal.widget.LockPatternUtils;
import com.seewo.vcommons.constants.SeewoConstants;
import com.seewo.vcommons.utils.reflect.ContextInsider;
import com.seewo.vcommons.utils.reflect.Reflect;
import com.seewo.vcommons.utils.reflect.UserHandleInsider;
import java.util.Iterator;
import java.util.List;

/* JADX INFO: loaded from: classes.dex */
public class SystemUtils {
    public static final String SYSTEM_PROPERTY_SYSTEM_BRANCH = "ro.cvte.system_branch";
    private static final String TAG = "SystemUtils";

    public static void unLockPin(Context context) {
    }

    private SystemUtils() {
    }

    public static String getReleaseVersion(Context context) {
        String releaseVersion = GlobalSettingUtils.getReleaseVersion(context);
        if (TextUtils.isEmpty(releaseVersion)) {
            releaseVersion = PropertiesUtils.getIncremental();
        }
        String property = PropertiesUtils.getProperty(SYSTEM_PROPERTY_SYSTEM_BRANCH);
        return !TextUtils.isEmpty(property) ? property + "-" + releaseVersion : releaseVersion;
    }

    private static void maybeUpdateKeystore(Context context) {
        UserManager userManager = (UserManager) context.getSystemService("user");
        KeyStore keyStore = KeyStore.getInstance();
        List list = (List) Reflect.on(userManager).call("getProfiles", Integer.valueOf(ContextInsider.getUserId(context))).get();
        boolean z = false;
        if (ContextInsider.getUserId(context) == UserHandleInsider.USER_OWNER && list.size() == 1) {
            String str = TAG;
            Log.d(str, "getUserId");
            if (!keyStore.isEmpty()) {
                Log.d(str, "!ks.isEmpty()");
                if (PropertiesUtils.getProperty("persist.sys.cts.enable").equals(SeewoConstants.VALUE_LOCK_TOUCH_OFF)) {
                    z = true;
                }
            }
        }
        Iterator it = list.iterator();
        while (it.hasNext()) {
            int uid = UserHandleInsider.getUid(((UserInfo) it.next()).id, 1000);
            if (z) {
                Log.d(TAG, "shouldReset");
                Reflect.on(keyStore).call("resetUid", Integer.valueOf(uid));
            } else {
                Log.d(TAG, "not shouldReset");
                Reflect.on(keyStore).call("passwordUid", "com.android.credentials.UNLOCK", Integer.valueOf(uid));
            }
        }
    }

    private static void unLockPinO(Context context) {
        String str = TAG;
        Log.d(str, "unLockPinO: start.");
        KeyStore keyStore = KeyStore.getInstance();
        Log.d(str, "unLockPinO: getUserId=" + ContextInsider.getUserId(context));
        Log.d(str, "unlock: " + ((Boolean) Reflect.on(keyStore).call("unlock", "com.android.credentials.UNLOCK").get()).booleanValue());
        Reflect.on(new LockPatternUtils(context)).call("reportSuccessfulPasswordAttempt", Integer.valueOf(ContextInsider.getUserId(context)));
        context.sendBroadcast(new Intent("android.security.action.KEYCHAIN_CHANGED"));
        Log.d(str, "unLockPinO: end.");
    }
}
