package com.d.b.a; import android.app.ActivityManager; import android.content.Context; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.BitmapRegionDecoder; import android.graphics.Matrix; import android.graphics.Point; import android.graphics.Rect; import android.os.Looper; import android.util.DisplayMetrics; import android.util.Log; import android.view.WindowManager; import com.d.a.f.g; import com.d.b.k; import com.meizu.cloud.pushsdk.constants.PushConstants; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; /* compiled from: IonBitmapCache */ public class d { /* renamed from: ˈ reason: contains not printable characters */ static final /* synthetic */ boolean f5453 = (!d.class.desiredAssertionStatus()); /* renamed from: ʻ reason: contains not printable characters */ Resources f5454; /* renamed from: ʼ reason: contains not printable characters */ DisplayMetrics f5455; /* renamed from: ʽ reason: contains not printable characters */ e f5456; /* renamed from: ʾ reason: contains not printable characters */ k f5457; /* renamed from: ʿ reason: contains not printable characters */ long f5458 = 30000; /* renamed from: ˆ reason: contains not printable characters */ double f5459 = 0.14285714285714285d; public d(k kVar) { Context applicationContext = kVar.m7784().getApplicationContext(); this.f5457 = kVar; this.f5455 = new DisplayMetrics(); ((WindowManager) applicationContext.getSystemService("window")).getDefaultDisplay().getMetrics(this.f5455); this.f5454 = new Resources(applicationContext.getAssets(), this.f5455, applicationContext.getResources().getConfiguration()); this.f5456 = new e(m7615(applicationContext) / 7); } /* renamed from: ʻ reason: contains not printable characters */ public void m7629(b bVar) { if (f5453 || Thread.currentThread() == Looper.getMainLooper().getThread()) { double r0 = (double) m7615(this.f5457.m7784()); double d = this.f5459; Double.isNaN(r0); long j = (long) ((int) (r0 * d)); if (j != this.f5456.m7413()) { this.f5456.m7416(j); } this.f5456.m7419((Object) bVar.f5444, (Object) bVar); return; } throw new AssertionError(); } /* renamed from: ʼ reason: contains not printable characters */ public void m7630(b bVar) { if (f5453 || Thread.currentThread() == Looper.getMainLooper().getThread()) { this.f5456.m7633(bVar.f5444, bVar); return; } throw new AssertionError(); } /* renamed from: ʻ reason: contains not printable characters */ public b m7628(String str) { b r1; if (str == null || (r1 = this.f5456.m7632(str)) == null) { return null; } if (r1.f5446 != null && r1.f5446.isRecycled()) { Log.w("ION", "Cached bitmap was recycled."); Log.w("ION", "This may happen if passing Ion bitmaps directly to notification builders or remote media clients."); Log.w("ION", "Create a deep copy before doing this."); this.f5456.m7418(str); return null; } else if (r1.f5447 == null || r1.f5442 + this.f5458 > System.currentTimeMillis()) { return r1; } else { this.f5456.m7418(str); return null; } } /* renamed from: ʻ reason: contains not printable characters */ private Point m7623(int i, int i2) { if (i == 0) { i = this.f5455.widthPixels; } int i3 = Integer.MAX_VALUE; if (i <= 0) { i = Integer.MAX_VALUE; } if (i2 == 0) { i2 = this.f5455.heightPixels; } if (i2 > 0) { i3 = i2; } return new Point(i, i3); } /* renamed from: ʻ reason: contains not printable characters */ private BitmapFactory.Options m7622(BitmapFactory.Options options, int i, int i2) throws a { if (options.outWidth < 0 || options.outHeight < 0) { throw new a(options.outWidth, options.outHeight); } Point r3 = m7623(i, i2); int round = Math.round(Math.max(((float) options.outWidth) / ((float) r3.x), ((float) options.outHeight) / ((float) r3.y))); BitmapFactory.Options options2 = new BitmapFactory.Options(); options2.inSampleSize = round; options2.outWidth = options.outWidth; options2.outHeight = options.outHeight; options2.outMimeType = options.outMimeType; return options2; } /* renamed from: ʻ reason: contains not printable characters */ public BitmapFactory.Options m7625(File file, int i, int i2) throws a { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(file.toString(), options); return m7622(options, i, i2); } /* renamed from: ʻ reason: contains not printable characters */ public BitmapFactory.Options m7627(byte[] bArr, int i, int i2, int i3, int i4) throws a { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeByteArray(bArr, i, i2, options); return m7622(options, i3, i4); } /* renamed from: ʻ reason: contains not printable characters */ public BitmapFactory.Options m7624(Resources resources, int i, int i2, int i3) throws a { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(resources, i, options); return m7622(options, i2, i3); } /* renamed from: ʻ reason: contains not printable characters */ public BitmapFactory.Options m7626(InputStream inputStream, int i, int i2) throws a { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeStream(inputStream, null, options); return m7622(options, i, i2); } /* renamed from: ʻ reason: contains not printable characters */ private static Bitmap m7617(Bitmap bitmap, int i) { if (bitmap == null) { return null; } if (i == 0) { return bitmap; } Matrix matrix = new Matrix(); matrix.postRotate((float) i); return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); } /* renamed from: ʻ reason: contains not printable characters */ public static Bitmap m7621(byte[] bArr, int i, int i2, BitmapFactory.Options options) { if (f5453 || Thread.currentThread() != Looper.getMainLooper().getThread()) { Bitmap decodeByteArray = BitmapFactory.decodeByteArray(bArr, i, i2, options); if (decodeByteArray == null) { return null; } return m7617(decodeByteArray, c.m7613(bArr, i, i2)); } throw new AssertionError(); } /* renamed from: ʻ reason: contains not printable characters */ public static Bitmap m7618(BitmapRegionDecoder bitmapRegionDecoder, Rect rect, int i) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = i; return bitmapRegionDecoder.decodeRegion(rect, options); } /* renamed from: ʻ reason: contains not printable characters */ public static Bitmap m7616(Resources resources, int i, BitmapFactory.Options options) { int i2; if (f5453 || Thread.currentThread() != Looper.getMainLooper().getThread()) { InputStream inputStream = null; try { inputStream = resources.openRawResource(i); byte[] bArr = new byte[50000]; i2 = c.m7613(bArr, 0, inputStream.read(bArr)); } catch (Exception unused) { i2 = 0; } g.m7421(inputStream); return m7617(BitmapFactory.decodeResource(resources, i, options), i2); } throw new AssertionError(); } /* renamed from: ʻ reason: contains not printable characters */ public static Bitmap m7620(InputStream inputStream, BitmapFactory.Options options) throws IOException { if (f5453 || Thread.currentThread() != Looper.getMainLooper().getThread()) { f fVar = new f(inputStream); fVar.mark(50000); int i = 0; try { byte[] bArr = new byte[50000]; i = c.m7613(bArr, 0, fVar.read(bArr)); } catch (Exception unused) { } fVar.reset(); return m7617(BitmapFactory.decodeStream(fVar, null, options), i); } throw new AssertionError(); } /* renamed from: ʻ reason: contains not printable characters */ public static Bitmap m7619(File file, BitmapFactory.Options options) { FileInputStream fileInputStream; int i; if (f5453 || Thread.currentThread() != Looper.getMainLooper().getThread()) { FileInputStream fileInputStream2 = null; try { fileInputStream = new FileInputStream(file); try { byte[] bArr = new byte[50000]; i = c.m7613(bArr, 0, fileInputStream.read(bArr)); } catch (Exception unused) { fileInputStream2 = fileInputStream; } } catch (Exception unused2) { fileInputStream = fileInputStream2; i = 0; g.m7421(fileInputStream); return m7617(BitmapFactory.decodeFile(file.toString(), options), i); } g.m7421(fileInputStream); return m7617(BitmapFactory.decodeFile(file.toString(), options), i); } throw new AssertionError(); } /* renamed from: ʻ reason: contains not printable characters */ private static int m7615(Context context) { return ((ActivityManager) context.getSystemService(PushConstants.INTENT_ACTIVITY_NAME)).getMemoryClass() * 1024 * 1024; } }