package c.o.a.r; import android.annotation.SuppressLint; import android.media.CamcorderProfile; import androidx.annotation.NonNull; import c.o.a.b; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.Map; /* compiled from: CamcorderProfiles */ public class a { public static final b a = new b(a.class.getSimpleName()); @SuppressLint({"UseSparseArrays"}) public static Map b; /* compiled from: CamcorderProfiles */ /* renamed from: c.o.a.r.a$a reason: collision with other inner class name */ public static class C0166a implements Comparator { public final /* synthetic */ long i; public C0166a(long j) { this.i = j; } /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object, java.lang.Object] */ @Override // java.util.Comparator public int compare(c.o.a.x.b bVar, c.o.a.x.b bVar2) { c.o.a.x.b bVar3 = bVar; c.o.a.x.b bVar4 = bVar2; int i = (Math.abs(((long) (bVar3.i * bVar3.j)) - this.i) > Math.abs(((long) (bVar4.i * bVar4.j)) - this.i) ? 1 : (Math.abs(((long) (bVar3.i * bVar3.j)) - this.i) == Math.abs(((long) (bVar4.i * bVar4.j)) - this.i) ? 0 : -1)); if (i < 0) { return -1; } return i == 0 ? 0 : 1; } } static { HashMap hashMap = new HashMap(); b = hashMap; hashMap.put(new c.o.a.x.b(176, 144), 2); b.put(new c.o.a.x.b(320, 240), 7); b.put(new c.o.a.x.b(352, 288), 3); b.put(new c.o.a.x.b(720, 480), 4); b.put(new c.o.a.x.b(1280, 720), 5); b.put(new c.o.a.x.b(1920, 1080), 6); b.put(new c.o.a.x.b(3840, 2160), 8); } @NonNull public static CamcorderProfile a(int i, @NonNull c.o.a.x.b bVar) { long j = ((long) bVar.i) * ((long) bVar.j); ArrayList arrayList = new ArrayList(b.keySet()); Collections.sort(arrayList, new C0166a(j)); while (arrayList.size() > 0) { int intValue = b.get((c.o.a.x.b) arrayList.remove(0)).intValue(); if (CamcorderProfile.hasProfile(i, intValue)) { return CamcorderProfile.get(i, intValue); } } return CamcorderProfile.get(i, 0); } @NonNull public static CamcorderProfile b(@NonNull String str, @NonNull c.o.a.x.b bVar) { try { return a(Integer.parseInt(str), bVar); } catch (NumberFormatException unused) { a.a(2, "NumberFormatException for Camera2 id:", str); return CamcorderProfile.get(0); } } }