package o; import android.app.ActivityManager; import android.content.Context; import android.content.pm.PackageManager; import android.content.res.Resources; import android.graphics.Bitmap; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.os.Process; import android.os.StatFs; import android.provider.Settings; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.util.List; import java.util.concurrent.ThreadFactory; import org.bouncycastle.asn1.cmp.PKIFailureInfo; /* renamed from: o.fOf, reason: case insensitive filesystem */ /* loaded from: classes.dex */ public final class C13025fOf { private static StringBuilder b = new StringBuilder(); private static final C15155gij a = C15155gij.a("RIFF"); private static final C15155gij c = C15155gij.a("WEBP"); /* JADX INFO: Access modifiers changed from: package-private */ public static int aBG_(Bitmap bitmap) { int allocationByteCount = bitmap.getAllocationByteCount(); if (allocationByteCount >= 0) { return allocationByteCount; } throw new IllegalStateException("Negative size: ".concat(String.valueOf(bitmap))); } /* JADX INFO: Access modifiers changed from: package-private */ public static T d(T t, String str) { if (t != null) { return t; } throw new NullPointerException(str); } /* JADX INFO: Access modifiers changed from: package-private */ public static String e(RunnableC13011fNx runnableC13011fNx) { return e(runnableC13011fNx, ""); } /* JADX INFO: Access modifiers changed from: package-private */ public static String e(RunnableC13011fNx runnableC13011fNx, String str) { StringBuilder sb = new StringBuilder(str); AbstractC13013fNz abstractC13013fNz = runnableC13011fNx.e; if (abstractC13013fNz != null) { sb.append(abstractC13013fNz.g.c()); } List list = runnableC13011fNx.a; if (list != null) { int size = list.size(); for (int i = 0; i < size; i++) { if (i > 0 || abstractC13013fNz != null) { sb.append(", "); } sb.append(list.get(i).g.c()); } } return sb.toString(); } public static void d(String str, String str2, String str3) { new Object[]{str, str2, str3, ""}; } public static void d(String str, String str2, String str3, String str4) { new Object[]{str, str2, str3, str4}; } /* JADX INFO: Access modifiers changed from: package-private */ public static String e(fNW fnw) { StringBuilder sb = b; String c2 = c(fnw, sb); sb.setLength(0); return c2; } /* JADX INFO: Access modifiers changed from: package-private */ public static String c(fNW fnw, StringBuilder sb) { if (fnw.n != null) { sb.ensureCapacity(fnw.n.length() + 50); sb.append(fnw.n); } else if (fnw.r != null) { String obj = fnw.r.toString(); sb.ensureCapacity(obj.length() + 50); sb.append(obj); } else { sb.ensureCapacity(50); sb.append(fnw.k); } sb.append('\n'); if (fnw.l != BitmapDescriptorFactory.HUE_RED) { sb.append("rotation:"); sb.append(fnw.l); if (fnw.b) { sb.append('@'); sb.append(fnw.f9099o); sb.append('x'); sb.append(fnw.m); } sb.append('\n'); } if (fnw.p != 0 || fnw.s != 0) { sb.append("resize:"); sb.append(fnw.p); sb.append('x'); sb.append(fnw.s); sb.append('\n'); } if (fnw.e) { sb.append("centerCrop:"); sb.append(fnw.c); sb.append('\n'); } else if (fnw.d) { sb.append("centerInside\n"); } if (fnw.t != null) { int size = fnw.t.size(); for (int i = 0; i < size; i++) { sb.append(fnw.t.get(i).d()); sb.append('\n'); } } return sb.toString(); } /* JADX INFO: Access modifiers changed from: package-private */ public static File b(Context context) { File file = new File(context.getApplicationContext().getCacheDir(), "picasso-cache"); if (!file.exists()) { file.mkdirs(); } return file; } /* JADX INFO: Access modifiers changed from: package-private */ public static long a(File file) { long j; try { StatFs statFs = new StatFs(file.getAbsolutePath()); j = (statFs.getBlockCountLong() * statFs.getBlockSizeLong()) / 50; } catch (IllegalArgumentException unused) { j = 5242880; } return Math.max(Math.min(j, 52428800L), 5242880L); } /* JADX INFO: Access modifiers changed from: package-private */ public static int d(Context context) { ActivityManager activityManager = (ActivityManager) context.getSystemService("activity"); return (int) ((((context.getApplicationInfo().flags & PKIFailureInfo.badCertTemplate) != 0 ? activityManager.getLargeMemoryClass() : activityManager.getMemoryClass()) * 1048576) / 7); } /* JADX INFO: Access modifiers changed from: package-private */ public static boolean a(Context context) { try { return Settings.Global.getInt(context.getContentResolver(), "airplane_mode_on", 0) != 0; } catch (NullPointerException | SecurityException unused) { return false; } } /* JADX INFO: Access modifiers changed from: package-private */ public static T b(Context context, String str) { return (T) context.getSystemService(str); } /* JADX INFO: Access modifiers changed from: package-private */ public static boolean d(Context context, String str) { return context.checkCallingOrSelfPermission(str) == 0; } /* JADX INFO: Access modifiers changed from: package-private */ public static boolean c(InterfaceC15149gid interfaceC15149gid) throws IOException { return interfaceC15149gid.e(0L, a) && interfaceC15149gid.e(8L, c); } /* JADX INFO: Access modifiers changed from: package-private */ public static int aBH_(Resources resources, fNW fnw) throws FileNotFoundException { if (fnw.k != 0 || fnw.r == null) { return fnw.k; } String authority = fnw.r.getAuthority(); if (authority == null) { StringBuilder sb = new StringBuilder("No package provided: "); sb.append(fnw.r); throw new FileNotFoundException(sb.toString()); } List pathSegments = fnw.r.getPathSegments(); if (pathSegments == null || pathSegments.isEmpty()) { StringBuilder sb2 = new StringBuilder("No path segments: "); sb2.append(fnw.r); throw new FileNotFoundException(sb2.toString()); } if (pathSegments.size() == 1) { try { return Integer.parseInt(pathSegments.get(0)); } catch (NumberFormatException unused) { StringBuilder sb3 = new StringBuilder("Last path segment is not a resource ID: "); sb3.append(fnw.r); throw new FileNotFoundException(sb3.toString()); } } if (pathSegments.size() == 2) { return resources.getIdentifier(pathSegments.get(1), pathSegments.get(0), authority); } StringBuilder sb4 = new StringBuilder("More than two path segments: "); sb4.append(fnw.r); throw new FileNotFoundException(sb4.toString()); } /* JADX INFO: Access modifiers changed from: package-private */ public static Resources aBI_(Context context, fNW fnw) throws FileNotFoundException { if (fnw.k != 0 || fnw.r == null) { return context.getResources(); } String authority = fnw.r.getAuthority(); if (authority == null) { StringBuilder sb = new StringBuilder("No package provided: "); sb.append(fnw.r); throw new FileNotFoundException(sb.toString()); } try { return context.getPackageManager().getResourcesForApplication(authority); } catch (PackageManager.NameNotFoundException unused) { StringBuilder sb2 = new StringBuilder("Unable to obtain resources for package: "); sb2.append(fnw.r); throw new FileNotFoundException(sb2.toString()); } } /* JADX INFO: Access modifiers changed from: package-private */ public static void aBF_(Looper looper) { Handler handler = new Handler(looper) { // from class: o.fOf.2 @Override // android.os.Handler public final void handleMessage(Message message) { sendMessageDelayed(obtainMessage(), 1000L); } }; handler.sendMessageDelayed(handler.obtainMessage(), 1000L); } /* renamed from: o.fOf$LWm */ /* loaded from: classes.dex */ static class LWm implements ThreadFactory { @Override // java.util.concurrent.ThreadFactory public final Thread newThread(Runnable runnable) { return new HBt(runnable); } } /* renamed from: o.fOf$HBt */ /* loaded from: classes.dex */ static class HBt extends Thread { HBt(Runnable runnable) { super(runnable); } @Override // java.lang.Thread, java.lang.Runnable public final void run() { Process.setThreadPriority(10); super.run(); } } public static void b() { if (Looper.getMainLooper().getThread() != Thread.currentThread()) { throw new IllegalStateException("Method call should happen from the main thread."); } } /* JADX INFO: Access modifiers changed from: package-private */ public static void e() { if (Looper.getMainLooper().getThread() == Thread.currentThread()) { throw new IllegalStateException("Method call should not happen from the main thread."); } } }