package p138.p176.p177.p242.p246.p253;

import android.content.Context;
import android.os.Build;
import android.os.Process;
import android.os.WorkSource;
import android.util.Log;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import p138.p176.p177.p242.p246.p255.C4322;

/* JADX INFO: renamed from: ދ.ހ.֏.ހ.ހ.ލ.ބ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public class C4316 {

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static final Method f13608;

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public static final Method f13609;

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public static final Method f13610;

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public static final Method f13611;

    static {
        Method method;
        Method method2;
        Method method3;
        Process.myUid();
        Method method4 = null;
        try {
            method = WorkSource.class.getMethod("add", Integer.TYPE);
        } catch (Exception unused) {
            method = null;
        }
        f13608 = method;
        try {
            method2 = WorkSource.class.getMethod("add", Integer.TYPE, String.class);
        } catch (Exception unused2) {
            method2 = null;
        }
        f13609 = method2;
        try {
            method3 = WorkSource.class.getMethod("size", new Class[0]);
        } catch (Exception unused3) {
            method3 = null;
        }
        f13610 = method3;
        try {
            WorkSource.class.getMethod("get", Integer.TYPE);
        } catch (Exception unused4) {
        }
        try {
            method4 = WorkSource.class.getMethod("getName", Integer.TYPE);
        } catch (Exception unused5) {
        }
        f13611 = method4;
        if (Build.VERSION.SDK_INT >= 28) {
            try {
                WorkSource.class.getMethod("createWorkChain", new Class[0]);
            } catch (Exception e) {
                Log.w("WorkSourceUtil", "Missing WorkChain API createWorkChain", e);
            }
        }
        if (Build.VERSION.SDK_INT >= 28) {
            try {
                Class.forName("android.os.WorkSource$WorkChain").getMethod("addNode", Integer.TYPE, String.class);
            } catch (Exception e2) {
                Log.w("WorkSourceUtil", "Missing WorkChain class", e2);
            }
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static List<String> m7215(WorkSource workSource) {
        Method method;
        int iIntValue;
        String str;
        if (workSource == null || (method = f13610) == null) {
            iIntValue = 0;
        } else {
            try {
                iIntValue = ((Integer) method.invoke(workSource, new Object[0])).intValue();
            } catch (Exception e) {
                Log.wtf("WorkSourceUtil", "Unable to assign blame through WorkSource", e);
                iIntValue = 0;
            }
        }
        if (iIntValue == 0) {
            return Collections.emptyList();
        }
        ArrayList arrayList = new ArrayList();
        for (int i = 0; i < iIntValue; i++) {
            Method method2 = f13611;
            if (method2 != null) {
                try {
                    str = (String) method2.invoke(workSource, Integer.valueOf(i));
                } catch (Exception e2) {
                    Log.wtf("WorkSourceUtil", "Unable to assign blame through WorkSource", e2);
                    str = null;
                }
            } else {
                str = null;
            }
            if (!C4315.m7214(str)) {
                arrayList.add(str);
            }
        }
        return arrayList;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static boolean m7216(Context context) {
        if (context == null || context.getPackageManager() == null) {
            return false;
        }
        return C4322.m7223(context).f13621.getPackageManager().checkPermission("android.permission.UPDATE_DEVICE_STATS", context.getPackageName()) == 0;
    }
}
