apkfuckery/com.discord/smali/androidx/appcompat/app/ResourcesFlusher.smali
2019-07-24 13:27:29 +02:00

504 lines
14 KiB
Smali

.class Landroidx/appcompat/app/ResourcesFlusher;
.super Ljava/lang/Object;
.source "ResourcesFlusher.java"
# static fields
.field private static final TAG:Ljava/lang/String; = "ResourcesFlusher"
.field private static sDrawableCacheField:Ljava/lang/reflect/Field;
.field private static sDrawableCacheFieldFetched:Z
.field private static sResourcesImplField:Ljava/lang/reflect/Field;
.field private static sResourcesImplFieldFetched:Z
.field private static sThemedResourceCacheClazz:Ljava/lang/Class;
.field private static sThemedResourceCacheClazzFetched:Z
.field private static sThemedResourceCache_mUnthemedEntriesField:Ljava/lang/reflect/Field;
.field private static sThemedResourceCache_mUnthemedEntriesFieldFetched:Z
# direct methods
.method private constructor <init>()V
.locals 0
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
.method static flush(Landroid/content/res/Resources;)V
.locals 2
.param p0 # Landroid/content/res/Resources;
.annotation build Landroidx/annotation/NonNull;
.end annotation
.end param
sget v0, Landroid/os/Build$VERSION;->SDK_INT:I
const/16 v1, 0x1c
if-lt v0, v1, :cond_0
return-void
:cond_0
sget v0, Landroid/os/Build$VERSION;->SDK_INT:I
const/16 v1, 0x18
if-lt v0, v1, :cond_1
invoke-static {p0}, Landroidx/appcompat/app/ResourcesFlusher;->flushNougats(Landroid/content/res/Resources;)V
return-void
:cond_1
sget v0, Landroid/os/Build$VERSION;->SDK_INT:I
const/16 v1, 0x17
if-lt v0, v1, :cond_2
invoke-static {p0}, Landroidx/appcompat/app/ResourcesFlusher;->flushMarshmallows(Landroid/content/res/Resources;)V
return-void
:cond_2
sget v0, Landroid/os/Build$VERSION;->SDK_INT:I
const/16 v1, 0x15
if-lt v0, v1, :cond_3
invoke-static {p0}, Landroidx/appcompat/app/ResourcesFlusher;->flushLollipops(Landroid/content/res/Resources;)V
:cond_3
return-void
.end method
.method private static flushLollipops(Landroid/content/res/Resources;)V
.locals 4
.param p0 # Landroid/content/res/Resources;
.annotation build Landroidx/annotation/NonNull;
.end annotation
.end param
.annotation build Landroidx/annotation/RequiresApi;
value = 0x15
.end annotation
sget-boolean v0, Landroidx/appcompat/app/ResourcesFlusher;->sDrawableCacheFieldFetched:Z
const-string v1, "ResourcesFlusher"
if-nez v0, :cond_0
const/4 v0, 0x1
:try_start_0
const-class v2, Landroid/content/res/Resources;
const-string v3, "mDrawableCache"
invoke-virtual {v2, v3}, Ljava/lang/Class;->getDeclaredField(Ljava/lang/String;)Ljava/lang/reflect/Field;
move-result-object v2
sput-object v2, Landroidx/appcompat/app/ResourcesFlusher;->sDrawableCacheField:Ljava/lang/reflect/Field;
invoke-virtual {v2, v0}, Ljava/lang/reflect/Field;->setAccessible(Z)V
:try_end_0
.catch Ljava/lang/NoSuchFieldException; {:try_start_0 .. :try_end_0} :catch_0
goto :goto_0
:catch_0
move-exception v2
const-string v3, "Could not retrieve Resources#mDrawableCache field"
invoke-static {v1, v3, v2}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
:goto_0
sput-boolean v0, Landroidx/appcompat/app/ResourcesFlusher;->sDrawableCacheFieldFetched:Z
:cond_0
sget-object v0, Landroidx/appcompat/app/ResourcesFlusher;->sDrawableCacheField:Ljava/lang/reflect/Field;
if-eqz v0, :cond_1
const/4 v2, 0x0
:try_start_1
invoke-virtual {v0, p0}, Ljava/lang/reflect/Field;->get(Ljava/lang/Object;)Ljava/lang/Object;
move-result-object p0
check-cast p0, Ljava/util/Map;
:try_end_1
.catch Ljava/lang/IllegalAccessException; {:try_start_1 .. :try_end_1} :catch_1
goto :goto_1
:catch_1
move-exception p0
const-string v0, "Could not retrieve value from Resources#mDrawableCache"
invoke-static {v1, v0, p0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
move-object p0, v2
:goto_1
if-eqz p0, :cond_1
invoke-interface {p0}, Ljava/util/Map;->clear()V
:cond_1
return-void
.end method
.method private static flushMarshmallows(Landroid/content/res/Resources;)V
.locals 4
.param p0 # Landroid/content/res/Resources;
.annotation build Landroidx/annotation/NonNull;
.end annotation
.end param
.annotation build Landroidx/annotation/RequiresApi;
value = 0x17
.end annotation
sget-boolean v0, Landroidx/appcompat/app/ResourcesFlusher;->sDrawableCacheFieldFetched:Z
const-string v1, "ResourcesFlusher"
if-nez v0, :cond_0
const/4 v0, 0x1
:try_start_0
const-class v2, Landroid/content/res/Resources;
const-string v3, "mDrawableCache"
invoke-virtual {v2, v3}, Ljava/lang/Class;->getDeclaredField(Ljava/lang/String;)Ljava/lang/reflect/Field;
move-result-object v2
sput-object v2, Landroidx/appcompat/app/ResourcesFlusher;->sDrawableCacheField:Ljava/lang/reflect/Field;
invoke-virtual {v2, v0}, Ljava/lang/reflect/Field;->setAccessible(Z)V
:try_end_0
.catch Ljava/lang/NoSuchFieldException; {:try_start_0 .. :try_end_0} :catch_0
goto :goto_0
:catch_0
move-exception v2
const-string v3, "Could not retrieve Resources#mDrawableCache field"
invoke-static {v1, v3, v2}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
:goto_0
sput-boolean v0, Landroidx/appcompat/app/ResourcesFlusher;->sDrawableCacheFieldFetched:Z
:cond_0
const/4 v0, 0x0
sget-object v2, Landroidx/appcompat/app/ResourcesFlusher;->sDrawableCacheField:Ljava/lang/reflect/Field;
if-eqz v2, :cond_1
:try_start_1
invoke-virtual {v2, p0}, Ljava/lang/reflect/Field;->get(Ljava/lang/Object;)Ljava/lang/Object;
move-result-object v0
:try_end_1
.catch Ljava/lang/IllegalAccessException; {:try_start_1 .. :try_end_1} :catch_1
goto :goto_1
:catch_1
move-exception p0
const-string v2, "Could not retrieve value from Resources#mDrawableCache"
invoke-static {v1, v2, p0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
:cond_1
:goto_1
if-nez v0, :cond_2
return-void
:cond_2
invoke-static {v0}, Landroidx/appcompat/app/ResourcesFlusher;->flushThemedResourcesCache(Ljava/lang/Object;)V
return-void
.end method
.method private static flushNougats(Landroid/content/res/Resources;)V
.locals 5
.param p0 # Landroid/content/res/Resources;
.annotation build Landroidx/annotation/NonNull;
.end annotation
.end param
.annotation build Landroidx/annotation/RequiresApi;
value = 0x18
.end annotation
sget-boolean v0, Landroidx/appcompat/app/ResourcesFlusher;->sResourcesImplFieldFetched:Z
const/4 v1, 0x1
const-string v2, "ResourcesFlusher"
if-nez v0, :cond_0
:try_start_0
const-class v0, Landroid/content/res/Resources;
const-string v3, "mResourcesImpl"
invoke-virtual {v0, v3}, Ljava/lang/Class;->getDeclaredField(Ljava/lang/String;)Ljava/lang/reflect/Field;
move-result-object v0
sput-object v0, Landroidx/appcompat/app/ResourcesFlusher;->sResourcesImplField:Ljava/lang/reflect/Field;
invoke-virtual {v0, v1}, Ljava/lang/reflect/Field;->setAccessible(Z)V
:try_end_0
.catch Ljava/lang/NoSuchFieldException; {:try_start_0 .. :try_end_0} :catch_0
goto :goto_0
:catch_0
move-exception v0
const-string v3, "Could not retrieve Resources#mResourcesImpl field"
invoke-static {v2, v3, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
:goto_0
sput-boolean v1, Landroidx/appcompat/app/ResourcesFlusher;->sResourcesImplFieldFetched:Z
:cond_0
sget-object v0, Landroidx/appcompat/app/ResourcesFlusher;->sResourcesImplField:Ljava/lang/reflect/Field;
if-nez v0, :cond_1
return-void
:cond_1
const/4 v3, 0x0
:try_start_1
invoke-virtual {v0, p0}, Ljava/lang/reflect/Field;->get(Ljava/lang/Object;)Ljava/lang/Object;
move-result-object p0
:try_end_1
.catch Ljava/lang/IllegalAccessException; {:try_start_1 .. :try_end_1} :catch_1
goto :goto_1
:catch_1
move-exception p0
const-string v0, "Could not retrieve value from Resources#mResourcesImpl"
invoke-static {v2, v0, p0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
move-object p0, v3
:goto_1
if-nez p0, :cond_2
return-void
:cond_2
sget-boolean v0, Landroidx/appcompat/app/ResourcesFlusher;->sDrawableCacheFieldFetched:Z
if-nez v0, :cond_3
:try_start_2
invoke-virtual {p0}, Ljava/lang/Object;->getClass()Ljava/lang/Class;
move-result-object v0
const-string v4, "mDrawableCache"
invoke-virtual {v0, v4}, Ljava/lang/Class;->getDeclaredField(Ljava/lang/String;)Ljava/lang/reflect/Field;
move-result-object v0
sput-object v0, Landroidx/appcompat/app/ResourcesFlusher;->sDrawableCacheField:Ljava/lang/reflect/Field;
invoke-virtual {v0, v1}, Ljava/lang/reflect/Field;->setAccessible(Z)V
:try_end_2
.catch Ljava/lang/NoSuchFieldException; {:try_start_2 .. :try_end_2} :catch_2
goto :goto_2
:catch_2
move-exception v0
const-string v4, "Could not retrieve ResourcesImpl#mDrawableCache field"
invoke-static {v2, v4, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
:goto_2
sput-boolean v1, Landroidx/appcompat/app/ResourcesFlusher;->sDrawableCacheFieldFetched:Z
:cond_3
sget-object v0, Landroidx/appcompat/app/ResourcesFlusher;->sDrawableCacheField:Ljava/lang/reflect/Field;
if-eqz v0, :cond_4
:try_start_3
invoke-virtual {v0, p0}, Ljava/lang/reflect/Field;->get(Ljava/lang/Object;)Ljava/lang/Object;
move-result-object v3
:try_end_3
.catch Ljava/lang/IllegalAccessException; {:try_start_3 .. :try_end_3} :catch_3
goto :goto_3
:catch_3
move-exception p0
const-string v0, "Could not retrieve value from ResourcesImpl#mDrawableCache"
invoke-static {v2, v0, p0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
:cond_4
:goto_3
if-eqz v3, :cond_5
invoke-static {v3}, Landroidx/appcompat/app/ResourcesFlusher;->flushThemedResourcesCache(Ljava/lang/Object;)V
:cond_5
return-void
.end method
.method private static flushThemedResourcesCache(Ljava/lang/Object;)V
.locals 4
.param p0 # Ljava/lang/Object;
.annotation build Landroidx/annotation/NonNull;
.end annotation
.end param
.annotation build Landroidx/annotation/RequiresApi;
value = 0x10
.end annotation
sget-boolean v0, Landroidx/appcompat/app/ResourcesFlusher;->sThemedResourceCacheClazzFetched:Z
const/4 v1, 0x1
const-string v2, "ResourcesFlusher"
if-nez v0, :cond_0
:try_start_0
const-string v0, "android.content.res.ThemedResourceCache"
invoke-static {v0}, Ljava/lang/Class;->forName(Ljava/lang/String;)Ljava/lang/Class;
move-result-object v0
sput-object v0, Landroidx/appcompat/app/ResourcesFlusher;->sThemedResourceCacheClazz:Ljava/lang/Class;
:try_end_0
.catch Ljava/lang/ClassNotFoundException; {:try_start_0 .. :try_end_0} :catch_0
goto :goto_0
:catch_0
move-exception v0
const-string v3, "Could not find ThemedResourceCache class"
invoke-static {v2, v3, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
:goto_0
sput-boolean v1, Landroidx/appcompat/app/ResourcesFlusher;->sThemedResourceCacheClazzFetched:Z
:cond_0
sget-object v0, Landroidx/appcompat/app/ResourcesFlusher;->sThemedResourceCacheClazz:Ljava/lang/Class;
if-nez v0, :cond_1
return-void
:cond_1
sget-boolean v3, Landroidx/appcompat/app/ResourcesFlusher;->sThemedResourceCache_mUnthemedEntriesFieldFetched:Z
if-nez v3, :cond_2
:try_start_1
const-string v3, "mUnthemedEntries"
invoke-virtual {v0, v3}, Ljava/lang/Class;->getDeclaredField(Ljava/lang/String;)Ljava/lang/reflect/Field;
move-result-object v0
sput-object v0, Landroidx/appcompat/app/ResourcesFlusher;->sThemedResourceCache_mUnthemedEntriesField:Ljava/lang/reflect/Field;
invoke-virtual {v0, v1}, Ljava/lang/reflect/Field;->setAccessible(Z)V
:try_end_1
.catch Ljava/lang/NoSuchFieldException; {:try_start_1 .. :try_end_1} :catch_1
goto :goto_1
:catch_1
move-exception v0
const-string v3, "Could not retrieve ThemedResourceCache#mUnthemedEntries field"
invoke-static {v2, v3, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
:goto_1
sput-boolean v1, Landroidx/appcompat/app/ResourcesFlusher;->sThemedResourceCache_mUnthemedEntriesFieldFetched:Z
:cond_2
sget-object v0, Landroidx/appcompat/app/ResourcesFlusher;->sThemedResourceCache_mUnthemedEntriesField:Ljava/lang/reflect/Field;
if-nez v0, :cond_3
return-void
:cond_3
const/4 v1, 0x0
:try_start_2
invoke-virtual {v0, p0}, Ljava/lang/reflect/Field;->get(Ljava/lang/Object;)Ljava/lang/Object;
move-result-object p0
check-cast p0, Landroid/util/LongSparseArray;
:try_end_2
.catch Ljava/lang/IllegalAccessException; {:try_start_2 .. :try_end_2} :catch_2
goto :goto_2
:catch_2
move-exception p0
const-string v0, "Could not retrieve value from ThemedResourceCache#mUnthemedEntries"
invoke-static {v2, v0, p0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
move-object p0, v1
:goto_2
if-eqz p0, :cond_4
invoke-virtual {p0}, Landroid/util/LongSparseArray;->clear()V
:cond_4
return-void
.end method