package com.ifpdos.certinstaller;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.util.Log;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Iterator;

/* JADX INFO: compiled from: Util.java */
/* JADX INFO: loaded from: classes.dex */
class b {
    static <T> T a(byte[] bArr) {
        if (bArr == null) {
            return null;
        }
        try {
            return (T) new ObjectInputStream(new ByteArrayInputStream(bArr)).readObject();
        } catch (Exception e3) {
            Log.w("certinstaller.Util", "fromBytes(): " + e3);
            return null;
        }
    }

    public static boolean b(Context context, String str) {
        Iterator<PackageInfo> it = context.getPackageManager().getInstalledPackages(0).iterator();
        while (it.hasNext()) {
            if (str.equals(it.next().applicationInfo.packageName)) {
                return true;
            }
        }
        return false;
    }

    static byte[] c(Object obj) {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        try {
            ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
            objectOutputStream.writeObject(obj);
            objectOutputStream.close();
        } catch (Exception e3) {
            Log.w("certinstaller.Util", "toBytes(): " + e3 + ": " + obj);
        }
        return byteArrayOutputStream.toByteArray();
    }
}
