package com.seewo.vcommons.data;

import Z0.f;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.content.pm.UserInfo;
import android.os.Build;
import android.os.UserManager;
import android.security.KeyStore;
import android.text.TextUtils;
import android.util.Log;
import com.android.internal.widget.LockPatternUtils;
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";

    private SystemUtils() {
    }

    public static String getReleaseVersion(Context context) {
        String strB = b.b(context);
        if (TextUtils.isEmpty(strB)) {
            strB = d.b();
        }
        String strD = d.d(SYSTEM_PROPERTY_SYSTEM_BRANCH);
        if (TextUtils.isEmpty(strD)) {
            return strB;
        }
        return strD + "-" + strB;
    }

    private static void maybeUpdateKeystore(Context context) {
        UserManager userManager = (UserManager) context.getSystemService("user");
        KeyStore keyStore = KeyStore.getInstance();
        List list = (List) Z0.c.l(userManager).c("getProfiles", Integer.valueOf(Z0.a.a(context))).g();
        boolean z2 = false;
        if (Z0.a.a(context) == f.f1916b && list.size() == 1) {
            String str = TAG;
            Log.d(str, "getUserId");
            if (!keyStore.isEmpty()) {
                Log.d(str, "!ks.isEmpty()");
                if (d.d("persist.sys.cts.enable").equals("true")) {
                    z2 = true;
                }
            }
        }
        Iterator it = list.iterator();
        while (it.hasNext()) {
            int iB = f.b(((UserInfo) it.next()).id, 1000);
            if (z2) {
                Log.d(TAG, "shouldReset");
                Z0.c.l(keyStore).c("resetUid", Integer.valueOf(iB));
            } else {
                Log.d(TAG, "not shouldReset");
                Z0.c.l(keyStore).c("passwordUid", "com.android.credentials.UNLOCK", Integer.valueOf(iB));
            }
        }
    }

    public static void unLockPin(Context context) {
        if (Build.VERSION.SDK_INT == 26) {
            unLockPinO(context);
        }
    }

    @TargetApi(26)
    private static void unLockPinO(Context context) {
        String str = TAG;
        Log.d(str, "unLockPinO: start.");
        KeyStore keyStore = KeyStore.getInstance();
        Log.d(str, "unLockPinO: getUserId=" + Z0.a.a(context));
        Log.d(str, "unlock: " + ((Boolean) Z0.c.l(keyStore).c("unlock", "com.android.credentials.UNLOCK").g()).booleanValue());
        Z0.c.l(new LockPatternUtils(context)).c("reportSuccessfulPasswordAttempt", Integer.valueOf(Z0.a.a(context)));
        context.sendBroadcast(new Intent("android.security.action.KEYCHAIN_CHANGED"));
        Log.d(str, "unLockPinO: end.");
    }
}
