CrackMe.apk
Download file
package com.facebook.imagepipeline.nativecode;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.ColorSpace;
import android.graphics.Rect;
import android.os.Build;
import com.facebook.common.internal.Preconditions;
import com.facebook.common.internal.Throwables;
import com.facebook.common.memory.PooledByteBuffer;
import com.facebook.common.references.CloseableReference;
import com.facebook.imagepipeline.common.TooManyBitmapsException;
import com.facebook.imagepipeline.image.EncodedImage;
import com.facebook.imagepipeline.memory.BitmapCounter;
import com.facebook.imagepipeline.memory.BitmapCounterProvider;
import com.facebook.imagepipeline.platform.PlatformDecoder;
import com.facebook.imageutils.BitmapUtil;
import java.util.Locale;
import javax.annotation.Nullable;
public abstract class DalvikPurgeableDecoder implements PlatformDecoder {
protected static final byte[] EOI = {-1, -39};
private final BitmapCounter mUnpooledBitmapsCounter = BitmapCounterProvider.get();
private static native void nativePinBitmap(Bitmap bitmap);
/* access modifiers changed from: protected */
public abstract Bitmap decodeByteArrayAsPurgeable(CloseableReference<PooledByteBuffer> closeableReference, BitmapFactory.Options options);
/* access modifiers changed from: protected */
public abstract Bitmap decodeJPEGByteArrayAsPurgeable(CloseableReference<PooledByteBuffer> closeableReference, int i, BitmapFactory.Options options);
static {
ImagePipelineNativeLoader.load();
}
protected DalvikPurgeableDecoder() {
}
public CloseableReference<Bitmap> decodeFromEncodedImage(EncodedImage encodedImage, Bitmap.Config config, @Nullable Rect rect) {
return decodeFromEncodedImageWithColorSpace(encodedImage, config, rect, (ColorSpace) null);
}
public CloseableReference<Bitmap> decodeJPEGFromEncodedImage(EncodedImage encodedImage, Bitmap.Config config, @Nullable Rect rect, int i) {
return decodeJPEGFromEncodedImageWithColorSpace(encodedImage, config, rect, i, (ColorSpace) null);
}
public CloseableReference<Bitmap> decodeFromEncodedImageWithColorSpace(EncodedImage encodedImage, Bitmap.Config config, @Nullable Rect rect, @Nullable ColorSpace colorSpace) {
BitmapFactory.Options bitmapFactoryOptions = getBitmapFactoryOptions(encodedImage.getSampleSize(), config);
if (Build.VERSION.SDK_INT >= 26) {
OreoUtils.setColorSpace(bitmapFactoryOptions, colorSpace);
}
CloseableReference<PooledByteBuffer> byteBufferRef = encodedImage.getByteBufferRef();
Preconditions.checkNotNull(byteBufferRef);
try {
return pinBitmap(decodeByteArrayAsPurgeable(byteBufferRef, bitmapFactoryOptions));
} finally {
CloseableReference.closeSafely((CloseableReference<?>) byteBufferRef);
}
}
public CloseableReference<Bitmap> decodeJPEGFromEncodedImageWithColorSpace(EncodedImage encodedImage, Bitmap.Config config, @Nullable Rect rect, int i, @Nullable ColorSpace colorSpace) {
BitmapFactory.Options bitmapFactoryOptions = getBitmapFactoryOptions(encodedImage.getSampleSize(), config);
if (Build.VERSION.SDK_INT >= 26) {
OreoUtils.setColorSpace(bitmapFactoryOptions, colorSpace);
}
CloseableReference<PooledByteBuffer> byteBufferRef = encodedImage.getByteBufferRef();
Preconditions.checkNotNull(byteBufferRef);
try {
return pinBitmap(decodeJPEGByteArrayAsPurgeable(byteBufferRef, i, bitmapFactoryOptions));
} finally {
CloseableReference.closeSafely((CloseableReference<?>) byteBufferRef);
}
}
public static BitmapFactory.Options getBitmapFactoryOptions(int i, Bitmap.Config config) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inDither = true;
options.inPreferredConfig = config;
options.inPurgeable = true;
options.inInputShareable = true;
options.inSampleSize = i;
if (Build.VERSION.SDK_INT >= 11) {
options.inMutable = true;
}
return options;
}
public static boolean endsWithEOI(CloseableReference<PooledByteBuffer> closeableReference, int i) {
PooledByteBuffer pooledByteBuffer = closeableReference.get();
if (i >= 2 && pooledByteBuffer.read(i - 2) == -1 && pooledByteBuffer.read(i - 1) == -39) {
return true;
}
return false;
}
private static class OreoUtils {
private OreoUtils() {
}
static void setColorSpace(BitmapFactory.Options options, @Nullable ColorSpace colorSpace) {
if (colorSpace == null) {
colorSpace = ColorSpace.get(ColorSpace.Named.SRGB);
}
options.inPreferredColorSpace = colorSpace;
}
}
public CloseableReference<Bitmap> pinBitmap(Bitmap bitmap) {
Preconditions.checkNotNull(bitmap);
try {
nativePinBitmap(bitmap);
if (this.mUnpooledBitmapsCounter.increase(bitmap)) {
return CloseableReference.of(bitmap, this.mUnpooledBitmapsCounter.getReleaser());
}
int sizeInBytes = BitmapUtil.getSizeInBytes(bitmap);
bitmap.recycle();
throw new TooManyBitmapsException(String.format(Locale.US, "Attempted to pin a bitmap of size %d bytes. The current pool count is %d, the current pool size is %d bytes. The current pool max count is %d, the current pool max size is %d bytes.", new Object[]{Integer.valueOf(sizeInBytes), Integer.valueOf(this.mUnpooledBitmapsCounter.getCount()), Long.valueOf(this.mUnpooledBitmapsCounter.getSize()), Integer.valueOf(this.mUnpooledBitmapsCounter.getMaxCount()), Integer.valueOf(this.mUnpooledBitmapsCounter.getMaxSize())}));
} catch (Exception e) {
bitmap.recycle();
throw Throwables.propagate(e);
}
}
}
Download file