CrackMe.apk
Download file
package androidx.appcompat.widget;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat;
import androidx.appcompat.resources.Compatibility;
import androidx.appcompat.resources.R;
import androidx.collection.LongSparseArray;
import androidx.collection.LruCache;
import androidx.collection.SimpleArrayMap;
import androidx.collection.SparseArrayCompat;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat;
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;
import java.lang.ref.WeakReference;
import java.util.WeakHashMap;
import org.xmlpull.v1.XmlPullParser;
public final class ResourceManagerInternal {
private static final ColorFilterLruCache COLOR_FILTER_CACHE = new ColorFilterLruCache(6);
private static final boolean DEBUG = false;
private static final PorterDuff.Mode DEFAULT_MODE = PorterDuff.Mode.SRC_IN;
private static ResourceManagerInternal INSTANCE = null;
private static final String PLATFORM_VD_CLAZZ = "android.graphics.drawable.VectorDrawable";
private static final String SKIP_DRAWABLE_TAG = "appcompat_skip_skip";
private static final String TAG = "ResourceManagerInternal";
private SimpleArrayMap<String, InflateDelegate> mDelegates;
private final WeakHashMap<Context, LongSparseArray<WeakReference<Drawable.ConstantState>>> mDrawableCaches = new WeakHashMap<>(0);
private boolean mHasCheckedVectorDrawableSetup;
private ResourceManagerHooks mHooks;
private SparseArrayCompat<String> mKnownDrawableIdTags;
private WeakHashMap<Context, SparseArrayCompat<ColorStateList>> mTintLists;
private TypedValue mTypedValue;
private interface InflateDelegate {
Drawable createFromXmlInner(Context context, XmlPullParser xmlPullParser, AttributeSet attributeSet, Resources.Theme theme);
}
public interface ResourceManagerHooks {
Drawable createDrawableFor(ResourceManagerInternal resourceManagerInternal, Context context, int i);
ColorStateList getTintListForDrawableRes(Context context, int i);
PorterDuff.Mode getTintModeForDrawableRes(int i);
boolean tintDrawable(Context context, int i, Drawable drawable);
boolean tintDrawableUsingColorFilter(Context context, int i, Drawable drawable);
}
public static synchronized ResourceManagerInternal get() {
ResourceManagerInternal resourceManagerInternal;
synchronized (ResourceManagerInternal.class) {
if (INSTANCE == null) {
ResourceManagerInternal resourceManagerInternal2 = new ResourceManagerInternal();
INSTANCE = resourceManagerInternal2;
installDefaultInflateDelegates(resourceManagerInternal2);
}
resourceManagerInternal = INSTANCE;
}
return resourceManagerInternal;
}
private static void installDefaultInflateDelegates(ResourceManagerInternal resourceManagerInternal) {
if (Build.VERSION.SDK_INT < 24) {
resourceManagerInternal.addDelegate("vector", new VdcInflateDelegate());
resourceManagerInternal.addDelegate("animated-vector", new AvdcInflateDelegate());
resourceManagerInternal.addDelegate("animated-selector", new AsldcInflateDelegate());
resourceManagerInternal.addDelegate("drawable", new DrawableDelegate());
}
}
public synchronized void setHooks(ResourceManagerHooks resourceManagerHooks) {
this.mHooks = resourceManagerHooks;
}
public synchronized Drawable getDrawable(Context context, int i) {
return getDrawable(context, i, false);
}
/* access modifiers changed from: package-private */
public synchronized Drawable getDrawable(Context context, int i, boolean z) {
Drawable loadDrawableFromDelegates;
checkVectorDrawableSetup(context);
loadDrawableFromDelegates = loadDrawableFromDelegates(context, i);
if (loadDrawableFromDelegates == null) {
loadDrawableFromDelegates = createDrawableIfNeeded(context, i);
}
if (loadDrawableFromDelegates == null) {
loadDrawableFromDelegates = ContextCompat.getDrawable(context, i);
}
if (loadDrawableFromDelegates != null) {
loadDrawableFromDelegates = tintDrawable(context, i, z, loadDrawableFromDelegates);
}
if (loadDrawableFromDelegates != null) {
DrawableUtils.fixDrawable(loadDrawableFromDelegates);
}
return loadDrawableFromDelegates;
}
public synchronized void onConfigurationChanged(Context context) {
LongSparseArray longSparseArray = this.mDrawableCaches.get(context);
if (longSparseArray != null) {
longSparseArray.clear();
}
}
private static long createCacheKey(TypedValue typedValue) {
return (((long) typedValue.assetCookie) << 32) | ((long) typedValue.data);
}
private Drawable createDrawableIfNeeded(Context context, int i) {
Drawable drawable;
if (this.mTypedValue == null) {
this.mTypedValue = new TypedValue();
}
TypedValue typedValue = this.mTypedValue;
context.getResources().getValue(i, typedValue, true);
long createCacheKey = createCacheKey(typedValue);
Drawable cachedDrawable = getCachedDrawable(context, createCacheKey);
if (cachedDrawable != null) {
return cachedDrawable;
}
ResourceManagerHooks resourceManagerHooks = this.mHooks;
if (resourceManagerHooks == null) {
drawable = null;
} else {
drawable = resourceManagerHooks.createDrawableFor(this, context, i);
}
if (drawable != null) {
drawable.setChangingConfigurations(typedValue.changingConfigurations);
addDrawableToCache(context, createCacheKey, drawable);
}
return drawable;
}
private Drawable tintDrawable(Context context, int i, boolean z, Drawable drawable) {
ColorStateList tintList = getTintList(context, i);
if (tintList != null) {
if (DrawableUtils.canSafelyMutateDrawable(drawable)) {
drawable = drawable.mutate();
}
Drawable wrap = DrawableCompat.wrap(drawable);
DrawableCompat.setTintList(wrap, tintList);
PorterDuff.Mode tintMode = getTintMode(i);
if (tintMode == null) {
return wrap;
}
DrawableCompat.setTintMode(wrap, tintMode);
return wrap;
}
ResourceManagerHooks resourceManagerHooks = this.mHooks;
if ((resourceManagerHooks == null || !resourceManagerHooks.tintDrawable(context, i, drawable)) && !tintDrawableUsingColorFilter(context, i, drawable) && z) {
return null;
}
return drawable;
}
/* JADX WARNING: Removed duplicated region for block: B:30:0x0075 A[Catch:{ Exception -> 0x00a4 }] */
/* JADX WARNING: Removed duplicated region for block: B:35:0x009c A[Catch:{ Exception -> 0x00a4 }] */
/* Code decompiled incorrectly, please refer to instructions dump. */
private android.graphics.drawable.Drawable loadDrawableFromDelegates(android.content.Context r11, int r12) {
/*
r10 = this;
androidx.collection.SimpleArrayMap<java.lang.String, androidx.appcompat.widget.ResourceManagerInternal$InflateDelegate> r0 = r10.mDelegates
r1 = 0
if (r0 == 0) goto L_0x00b4
boolean r0 = r0.isEmpty()
if (r0 != 0) goto L_0x00b4
androidx.collection.SparseArrayCompat<java.lang.String> r0 = r10.mKnownDrawableIdTags
java.lang.String r2 = "appcompat_skip_skip"
if (r0 == 0) goto L_0x0028
java.lang.Object r0 = r0.get(r12)
java.lang.String r0 = (java.lang.String) r0
boolean r3 = r2.equals(r0)
if (r3 != 0) goto L_0x0027
if (r0 == 0) goto L_0x002f
androidx.collection.SimpleArrayMap<java.lang.String, androidx.appcompat.widget.ResourceManagerInternal$InflateDelegate> r3 = r10.mDelegates
java.lang.Object r0 = r3.get(r0)
if (r0 != 0) goto L_0x002f
L_0x0027:
return r1
L_0x0028:
androidx.collection.SparseArrayCompat r0 = new androidx.collection.SparseArrayCompat
r0.<init>()
r10.mKnownDrawableIdTags = r0
L_0x002f:
android.util.TypedValue r0 = r10.mTypedValue
if (r0 != 0) goto L_0x003a
android.util.TypedValue r0 = new android.util.TypedValue
r0.<init>()
r10.mTypedValue = r0
L_0x003a:
android.util.TypedValue r0 = r10.mTypedValue
android.content.res.Resources r1 = r11.getResources()
r3 = 1
r1.getValue(r12, r0, r3)
long r4 = createCacheKey(r0)
android.graphics.drawable.Drawable r6 = r10.getCachedDrawable(r11, r4)
if (r6 == 0) goto L_0x004f
return r6
L_0x004f:
java.lang.CharSequence r7 = r0.string
if (r7 == 0) goto L_0x00ac
java.lang.CharSequence r7 = r0.string
java.lang.String r7 = r7.toString()
java.lang.String r8 = ".xml"
boolean r7 = r7.endsWith(r8)
if (r7 == 0) goto L_0x00ac
android.content.res.XmlResourceParser r1 = r1.getXml(r12) // Catch:{ Exception -> 0x00a4 }
android.util.AttributeSet r7 = android.util.Xml.asAttributeSet(r1) // Catch:{ Exception -> 0x00a4 }
L_0x0069:
int r8 = r1.next() // Catch:{ Exception -> 0x00a4 }
r9 = 2
if (r8 == r9) goto L_0x0073
if (r8 == r3) goto L_0x0073
goto L_0x0069
L_0x0073:
if (r8 != r9) goto L_0x009c
java.lang.String r3 = r1.getName() // Catch:{ Exception -> 0x00a4 }
androidx.collection.SparseArrayCompat<java.lang.String> r8 = r10.mKnownDrawableIdTags // Catch:{ Exception -> 0x00a4 }
r8.append(r12, r3) // Catch:{ Exception -> 0x00a4 }
androidx.collection.SimpleArrayMap<java.lang.String, androidx.appcompat.widget.ResourceManagerInternal$InflateDelegate> r8 = r10.mDelegates // Catch:{ Exception -> 0x00a4 }
java.lang.Object r3 = r8.get(r3) // Catch:{ Exception -> 0x00a4 }
androidx.appcompat.widget.ResourceManagerInternal$InflateDelegate r3 = (androidx.appcompat.widget.ResourceManagerInternal.InflateDelegate) r3 // Catch:{ Exception -> 0x00a4 }
if (r3 == 0) goto L_0x0091
android.content.res.Resources$Theme r8 = r11.getTheme() // Catch:{ Exception -> 0x00a4 }
android.graphics.drawable.Drawable r1 = r3.createFromXmlInner(r11, r1, r7, r8) // Catch:{ Exception -> 0x00a4 }
r6 = r1
L_0x0091:
if (r6 == 0) goto L_0x00ac
int r0 = r0.changingConfigurations // Catch:{ Exception -> 0x00a4 }
r6.setChangingConfigurations(r0) // Catch:{ Exception -> 0x00a4 }
r10.addDrawableToCache(r11, r4, r6) // Catch:{ Exception -> 0x00a4 }
goto L_0x00ac
L_0x009c:
org.xmlpull.v1.XmlPullParserException r11 = new org.xmlpull.v1.XmlPullParserException // Catch:{ Exception -> 0x00a4 }
java.lang.String r0 = "No start tag found"
r11.<init>(r0) // Catch:{ Exception -> 0x00a4 }
throw r11 // Catch:{ Exception -> 0x00a4 }
L_0x00a4:
r11 = move-exception
java.lang.String r0 = "ResourceManagerInternal"
java.lang.String r1 = "Exception while inflating drawable"
android.util.Log.e(r0, r1, r11)
L_0x00ac:
if (r6 != 0) goto L_0x00b3
androidx.collection.SparseArrayCompat<java.lang.String> r11 = r10.mKnownDrawableIdTags
r11.append(r12, r2)
L_0x00b3:
return r6
L_0x00b4:
return r1
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.appcompat.widget.ResourceManagerInternal.loadDrawableFromDelegates(android.content.Context, int):android.graphics.drawable.Drawable");
}
/* JADX WARNING: Code restructure failed: missing block: B:18:0x002c, code lost:
return null;
*/
/* Code decompiled incorrectly, please refer to instructions dump. */
private synchronized android.graphics.drawable.Drawable getCachedDrawable(android.content.Context r4, long r5) {
/*
r3 = this;
monitor-enter(r3)
java.util.WeakHashMap<android.content.Context, androidx.collection.LongSparseArray<java.lang.ref.WeakReference<android.graphics.drawable.Drawable$ConstantState>>> r0 = r3.mDrawableCaches // Catch:{ all -> 0x002d }
java.lang.Object r0 = r0.get(r4) // Catch:{ all -> 0x002d }
androidx.collection.LongSparseArray r0 = (androidx.collection.LongSparseArray) r0 // Catch:{ all -> 0x002d }
r1 = 0
if (r0 != 0) goto L_0x000e
monitor-exit(r3)
return r1
L_0x000e:
java.lang.Object r2 = r0.get(r5) // Catch:{ all -> 0x002d }
java.lang.ref.WeakReference r2 = (java.lang.ref.WeakReference) r2 // Catch:{ all -> 0x002d }
if (r2 == 0) goto L_0x002b
java.lang.Object r2 = r2.get() // Catch:{ all -> 0x002d }
android.graphics.drawable.Drawable$ConstantState r2 = (android.graphics.drawable.Drawable.ConstantState) r2 // Catch:{ all -> 0x002d }
if (r2 == 0) goto L_0x0028
android.content.res.Resources r4 = r4.getResources() // Catch:{ all -> 0x002d }
android.graphics.drawable.Drawable r4 = r2.newDrawable(r4) // Catch:{ all -> 0x002d }
monitor-exit(r3)
return r4
L_0x0028:
r0.remove(r5) // Catch:{ all -> 0x002d }
L_0x002b:
monitor-exit(r3)
return r1
L_0x002d:
r4 = move-exception
monitor-exit(r3)
throw r4
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.appcompat.widget.ResourceManagerInternal.getCachedDrawable(android.content.Context, long):android.graphics.drawable.Drawable");
}
private synchronized boolean addDrawableToCache(Context context, long j, Drawable drawable) {
Drawable.ConstantState constantState = drawable.getConstantState();
if (constantState == null) {
return false;
}
LongSparseArray longSparseArray = this.mDrawableCaches.get(context);
if (longSparseArray == null) {
longSparseArray = new LongSparseArray();
this.mDrawableCaches.put(context, longSparseArray);
}
longSparseArray.put(j, new WeakReference(constantState));
return true;
}
/* access modifiers changed from: package-private */
public synchronized Drawable onDrawableLoadedFromResources(Context context, VectorEnabledTintResources vectorEnabledTintResources, int i) {
Drawable loadDrawableFromDelegates = loadDrawableFromDelegates(context, i);
if (loadDrawableFromDelegates == null) {
loadDrawableFromDelegates = vectorEnabledTintResources.getDrawableCanonical(i);
}
if (loadDrawableFromDelegates == null) {
return null;
}
return tintDrawable(context, i, false, loadDrawableFromDelegates);
}
/* access modifiers changed from: package-private */
public boolean tintDrawableUsingColorFilter(Context context, int i, Drawable drawable) {
ResourceManagerHooks resourceManagerHooks = this.mHooks;
return resourceManagerHooks != null && resourceManagerHooks.tintDrawableUsingColorFilter(context, i, drawable);
}
private void addDelegate(String str, InflateDelegate inflateDelegate) {
if (this.mDelegates == null) {
this.mDelegates = new SimpleArrayMap<>();
}
this.mDelegates.put(str, inflateDelegate);
}
/* access modifiers changed from: package-private */
public PorterDuff.Mode getTintMode(int i) {
ResourceManagerHooks resourceManagerHooks = this.mHooks;
if (resourceManagerHooks == null) {
return null;
}
return resourceManagerHooks.getTintModeForDrawableRes(i);
}
/* access modifiers changed from: package-private */
public synchronized ColorStateList getTintList(Context context, int i) {
ColorStateList tintListFromCache;
tintListFromCache = getTintListFromCache(context, i);
if (tintListFromCache == null) {
ResourceManagerHooks resourceManagerHooks = this.mHooks;
tintListFromCache = resourceManagerHooks == null ? null : resourceManagerHooks.getTintListForDrawableRes(context, i);
if (tintListFromCache != null) {
addTintListToCache(context, i, tintListFromCache);
}
}
return tintListFromCache;
}
private ColorStateList getTintListFromCache(Context context, int i) {
SparseArrayCompat sparseArrayCompat;
WeakHashMap<Context, SparseArrayCompat<ColorStateList>> weakHashMap = this.mTintLists;
if (weakHashMap == null || (sparseArrayCompat = weakHashMap.get(context)) == null) {
return null;
}
return (ColorStateList) sparseArrayCompat.get(i);
}
private void addTintListToCache(Context context, int i, ColorStateList colorStateList) {
if (this.mTintLists == null) {
this.mTintLists = new WeakHashMap<>();
}
SparseArrayCompat sparseArrayCompat = this.mTintLists.get(context);
if (sparseArrayCompat == null) {
sparseArrayCompat = new SparseArrayCompat();
this.mTintLists.put(context, sparseArrayCompat);
}
sparseArrayCompat.append(i, colorStateList);
}
private static class ColorFilterLruCache extends LruCache<Integer, PorterDuffColorFilter> {
public ColorFilterLruCache(int i) {
super(i);
}
/* access modifiers changed from: package-private */
public PorterDuffColorFilter get(int i, PorterDuff.Mode mode) {
return (PorterDuffColorFilter) get(Integer.valueOf(generateCacheKey(i, mode)));
}
/* access modifiers changed from: package-private */
public PorterDuffColorFilter put(int i, PorterDuff.Mode mode, PorterDuffColorFilter porterDuffColorFilter) {
return (PorterDuffColorFilter) put(Integer.valueOf(generateCacheKey(i, mode)), porterDuffColorFilter);
}
private static int generateCacheKey(int i, PorterDuff.Mode mode) {
return ((i + 31) * 31) + mode.hashCode();
}
}
static void tintDrawable(Drawable drawable, TintInfo tintInfo, int[] iArr) {
if (!DrawableUtils.canSafelyMutateDrawable(drawable) || drawable.mutate() == drawable) {
if (tintInfo.mHasTintList || tintInfo.mHasTintMode) {
drawable.setColorFilter(createTintFilter(tintInfo.mHasTintList ? tintInfo.mTintList : null, tintInfo.mHasTintMode ? tintInfo.mTintMode : DEFAULT_MODE, iArr));
} else {
drawable.clearColorFilter();
}
if (Build.VERSION.SDK_INT <= 23) {
drawable.invalidateSelf();
return;
}
return;
}
Log.d(TAG, "Mutated drawable is not the same instance as the input.");
}
private static PorterDuffColorFilter createTintFilter(ColorStateList colorStateList, PorterDuff.Mode mode, int[] iArr) {
if (colorStateList == null || mode == null) {
return null;
}
return getPorterDuffColorFilter(colorStateList.getColorForState(iArr, 0), mode);
}
public static synchronized PorterDuffColorFilter getPorterDuffColorFilter(int i, PorterDuff.Mode mode) {
PorterDuffColorFilter porterDuffColorFilter;
synchronized (ResourceManagerInternal.class) {
ColorFilterLruCache colorFilterLruCache = COLOR_FILTER_CACHE;
porterDuffColorFilter = colorFilterLruCache.get(i, mode);
if (porterDuffColorFilter == null) {
porterDuffColorFilter = new PorterDuffColorFilter(i, mode);
colorFilterLruCache.put(i, mode, porterDuffColorFilter);
}
}
return porterDuffColorFilter;
}
private void checkVectorDrawableSetup(Context context) {
if (!this.mHasCheckedVectorDrawableSetup) {
this.mHasCheckedVectorDrawableSetup = true;
Drawable drawable = getDrawable(context, R.drawable.abc_vector_test);
if (drawable == null || !isVectorDrawable(drawable)) {
this.mHasCheckedVectorDrawableSetup = false;
throw new IllegalStateException("This app has been built with an incorrect configuration. Please configure your build for VectorDrawableCompat.");
}
}
}
private static boolean isVectorDrawable(Drawable drawable) {
return (drawable instanceof VectorDrawableCompat) || PLATFORM_VD_CLAZZ.equals(drawable.getClass().getName());
}
private static class VdcInflateDelegate implements InflateDelegate {
VdcInflateDelegate() {
}
public Drawable createFromXmlInner(Context context, XmlPullParser xmlPullParser, AttributeSet attributeSet, Resources.Theme theme) {
try {
return VectorDrawableCompat.createFromXmlInner(context.getResources(), xmlPullParser, attributeSet, theme);
} catch (Exception e) {
Log.e("VdcInflateDelegate", "Exception while inflating <vector>", e);
return null;
}
}
}
private static class AvdcInflateDelegate implements InflateDelegate {
AvdcInflateDelegate() {
}
public Drawable createFromXmlInner(Context context, XmlPullParser xmlPullParser, AttributeSet attributeSet, Resources.Theme theme) {
try {
return AnimatedVectorDrawableCompat.createFromXmlInner(context, context.getResources(), xmlPullParser, attributeSet, theme);
} catch (Exception e) {
Log.e("AvdcInflateDelegate", "Exception while inflating <animated-vector>", e);
return null;
}
}
}
static class AsldcInflateDelegate implements InflateDelegate {
AsldcInflateDelegate() {
}
public Drawable createFromXmlInner(Context context, XmlPullParser xmlPullParser, AttributeSet attributeSet, Resources.Theme theme) {
try {
return AnimatedStateListDrawableCompat.createFromXmlInner(context, context.getResources(), xmlPullParser, attributeSet, theme);
} catch (Exception e) {
Log.e("AsldcInflateDelegate", "Exception while inflating <animated-selector>", e);
return null;
}
}
}
static class DrawableDelegate implements InflateDelegate {
DrawableDelegate() {
}
public Drawable createFromXmlInner(Context context, XmlPullParser xmlPullParser, AttributeSet attributeSet, Resources.Theme theme) {
String classAttribute = attributeSet.getClassAttribute();
if (classAttribute != null) {
try {
Drawable drawable = (Drawable) DrawableDelegate.class.getClassLoader().loadClass(classAttribute).asSubclass(Drawable.class).getDeclaredConstructor(new Class[0]).newInstance(new Object[0]);
if (Build.VERSION.SDK_INT >= 21) {
Compatibility.Api21Impl.inflate(drawable, context.getResources(), xmlPullParser, attributeSet, theme);
} else {
drawable.inflate(context.getResources(), xmlPullParser, attributeSet);
}
return drawable;
} catch (Exception e) {
Log.e("DrawableDelegate", "Exception while inflating <drawable>", e);
}
}
return null;
}
}
}
Download file