package o; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Paint; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import com.google.zxing.NotFoundException; import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; import java.util.EnumMap; import java.util.EnumSet; import net.sourceforge.zbar.Image; import net.sourceforge.zbar.ImageScanner; import net.sourceforge.zbar.Symbol; import net.sourceforge.zbar.SymbolSet; /* renamed from: o.fKy, reason: case insensitive filesystem */ /* loaded from: classes5.dex */ public final class C12913fKy { private static final InterfaceC13393fZL b; private static final InterfaceC13393fZL d; private C12913fKy() { } static { new C12913fKy(); Sts sts = Sts.c; C14957gcv.e(sts, ""); d = new fZZ(sts); RVV rvv = RVV.a; C14957gcv.e(rvv, ""); b = new fZZ(rvv); } public static final String e(int i, int i2, byte[] bArr) { C14957gcv.e(bArr, ""); Image image = new Image(i, i2, "Y800"); image.setData(bArr); String b2 = b((ImageScanner) d.e(), image); return b2 == null ? "" : b2; } private static Image d(int i, int i2, int[] iArr) { Image image = new Image(i, i2, "RGB4"); image.setData(iArr); long convert = image.convert(image.peer, "Y800"); Image image2 = convert == 0 ? null : new Image(convert); C14957gcv.c(image2, ""); return image2; } private static String b(ImageScanner imageScanner, Image image) { if (imageScanner.scanImage(image) == 0) { return ""; } String str = ""; for (Symbol symbol : new SymbolSet(imageScanner.getResults(imageScanner.peer))) { try { String data = symbol.getData(); C14957gcv.c((Object) data, ""); str = e(data); if (str != null && gdZ.d((CharSequence) str, (CharSequence) "�", false)) { byte[] dataBytes = symbol.getDataBytes(); C14957gcv.c(dataBytes, ""); str = new String(dataBytes, gdP.a); } } catch (UnsupportedEncodingException e) { guQ.e(e, "Error getting data from the barcode", new Object[0]); } } return str; } private static String e(String str) { try { Charset forName = Charset.forName("Shift_JIS"); C14957gcv.c(forName, ""); byte[] bytes = str.getBytes(forName); C14957gcv.c(bytes, ""); return new String(bytes, gdP.a); } catch (UnsupportedEncodingException unused) { return null; } } private static String c(int i, int i2, int[] iArr) { BKc bKc = new BKc(new qgs(new YDE(i, i2, iArr))); Sqh sqh = new Sqh(); try { EnumSet noneOf = EnumSet.noneOf(PTS.class); noneOf.addAll(FvX.f()); noneOf.addAll(FvX.c()); noneOf.addAll(FvX.j()); noneOf.addAll(FvX.a()); noneOf.addAll(FvX.b()); noneOf.addAll(FvX.d()); noneOf.addAll(FvX.e()); EnumMap enumMap = new EnumMap(CGg.class); enumMap.put((EnumMap) CGg.TRY_HARDER, (CGg) Boolean.TRUE); enumMap.put((EnumMap) CGg.CHARACTER_SET, (CGg) "utf-8"); enumMap.put((EnumMap) CGg.POSSIBLE_FORMATS, (CGg) noneOf); sqh.c(enumMap); if (sqh.e == null) { sqh.c(null); } String str = sqh.d(bKc).b; C14957gcv.c((Object) str, ""); return str; } catch (Exception e) { if ((e instanceof NotFoundException) || (e instanceof NullPointerException)) { guQ.e(e); return ""; } throw e; } } /* renamed from: o.fKy$Sts */ /* loaded from: classes5.dex */ static final class Sts extends AbstractC14961gcz implements InterfaceC14890gbN { public static final Sts c = new Sts(); @Override // o.InterfaceC14890gbN public final /* synthetic */ ImageScanner invoke() { ImageScanner imageScanner = new ImageScanner(); imageScanner.setConfig(128, 256, 0); imageScanner.setConfig(128, 257, 0); imageScanner.setConfig(64, 256, 0); imageScanner.setConfig(64, 257, 0); imageScanner.setConfig(128, 0, 1); imageScanner.setConfig(64, 0, 1); return imageScanner; } Sts() { super(0); } } /* renamed from: o.fKy$RVV */ /* loaded from: classes5.dex */ static final class RVV extends AbstractC14961gcz implements InterfaceC14890gbN { public static final RVV a = new RVV(); @Override // o.InterfaceC14890gbN public final /* synthetic */ ImageScanner invoke() { ImageScanner imageScanner = new ImageScanner(); imageScanner.setConfig(128, 256, 0); imageScanner.setConfig(128, 257, 0); imageScanner.setConfig(64, 256, 0); imageScanner.setConfig(64, 257, 0); imageScanner.setConfig(128, 0, 1); imageScanner.setConfig(64, 0, 1); return imageScanner; } RVV() { super(0); } } /* JADX WARN: Multi-variable type inference failed */ public static final String e(byte[] bArr) { C14957gcv.e(bArr, ""); BitmapFactory.Options options = new BitmapFactory.Options(); options.inPurgeable = true; int i = 0; Bitmap decodeByteArray = BitmapFactory.decodeByteArray(bArr, 0, bArr.length, options); int width = decodeByteArray.getWidth(); int height = decodeByteArray.getHeight(); decodeByteArray.getPixels(new int[width * height], 0, width, 0, 0, width, height); C14957gcv.c(decodeByteArray, ""); int width2 = decodeByteArray.getWidth(); int height2 = decodeByteArray.getHeight(); int[] iArr = new int[width2 * height2]; try { decodeByteArray.getPixels(iArr, 0, width2, 0, 0, width2, height2); String b2 = b((ImageScanner) b.e(), d(width2, height2, iArr)); int i2 = 2; while (b2 != null) { if (b2.length() != 0 || i > 3) { break; } Bitmap createScaledBitmap = Bitmap.createScaledBitmap(decodeByteArray, decodeByteArray.getWidth() / i2, decodeByteArray.getHeight() / i2, true); C14957gcv.c(createScaledBitmap, ""); Bitmap createBitmap = Bitmap.createBitmap(createScaledBitmap.getWidth() + 100, createScaledBitmap.getHeight() + 100, Bitmap.Config.ARGB_4444); C14957gcv.c(createBitmap, ""); Canvas canvas = new Canvas(createBitmap); Paint paint = new Paint(); paint.setColor(-1); canvas.drawRect(BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, createBitmap.getWidth(), createBitmap.getHeight(), paint); canvas.drawBitmap(createScaledBitmap, 50.0f, 50.0f, paint); int width3 = createBitmap.getWidth(); int height3 = createBitmap.getHeight(); int[] iArr2 = new int[width3 * height3]; createBitmap.getPixels(iArr2, 0, width3, 0, 0, width3, height3); createBitmap.recycle(); C14860gaa c14860gaa = new C14860gaa(Integer.valueOf(width3), Integer.valueOf(height3), iArr2); int intValue = ((Number) c14860gaa.c).intValue(); int intValue2 = ((Number) c14860gaa.b).intValue(); int[] iArr3 = (int[]) c14860gaa.e; String b3 = b((ImageScanner) b.e(), d(intValue, intValue2, iArr3)); b2 = (b3 == null || b3.length() != 0) ? b3 : c(intValue, intValue2, iArr3); i2++; i++; } return b2 != null ? b2 : ""; } catch (Exception e) { guQ.a(e); return ""; } finally { decodeByteArray.recycle(); } } }