SysCacheUtils.smali

.class public Lcom/cleanmaster/junk/util/SysCacheUtils;
.super Ljava/lang/Object;
.source "SysCacheUtils.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/cleanmaster/junk/util/SysCacheUtils$ICacheSizeCallback;
    }
.end annotation


# direct methods
.method public constructor <init>()V
    .registers 1

    .prologue
    .line 26
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method public static getPackageCache(Ljava/util/List;Landroid/content/Context;Lcom/cleanmaster/junk/util/SysCacheUtils$ICacheSizeCallback;)V
    .registers 13
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/util/List",
            "<",
            "Ljava/lang/String;",
            ">;",
            "Landroid/content/Context;",
            "Lcom/cleanmaster/junk/util/SysCacheUtils$ICacheSizeCallback;",
            ")V"
        }
    .end annotation

    .prologue
    const-wide/16 v2, 0x0

    const/4 v5, 0x1

    const/4 v4, 0x0

    .line 47
    if-eqz p0, :cond_10

    invoke-interface {p0}, Ljava/util/List;->isEmpty()Z

    move-result v0

    if-nez v0, :cond_10

    if-eqz p1, :cond_10

    if-nez p2, :cond_11

    .line 100
    :cond_10
    :goto_10
    return-void

    .line 51
    :cond_11
    sget v0, Landroid/os/Build$VERSION;->SDK_INT:I

    const/16 v1, 0x1a

    if-lt v0, v1, :cond_5b

    .line 54
    :try_start_17
    const-string v0, "storagestats"

    invoke-virtual {p1, v0}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/app/usage/StorageStatsManager;

    .line 55
    invoke-interface {p0}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v4

    :cond_23
    :goto_23
    invoke-interface {v4}, Ljava/util/Iterator;->hasNext()Z

    move-result v1

    if-eqz v1, :cond_52

    invoke-interface {v4}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Ljava/lang/String;

    .line 56
    invoke-static {v1}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v5

    if-nez v5, :cond_23

    .line 59
    invoke-static {p1, v1}, Lcom/cleanmaster/hpsharelib/base/util/system/PackageUtils;->isHasPackage(Landroid/content/Context;Ljava/lang/String;)Z

    move-result v5

    if-eqz v5, :cond_23

    .line 63
    sget-object v5, Landroid/os/storage/StorageManager;->UUID_DEFAULT:Ljava/util/UUID;

    invoke-static {}, Landroid/os/Process;->myUserHandle()Landroid/os/UserHandle;

    move-result-object v6

    invoke-virtual {v0, v5, v1, v6}, Landroid/app/usage/StorageStatsManager;->queryStatsForPackage(Ljava/util/UUID;Ljava/lang/String;Landroid/os/UserHandle;)Landroid/app/usage/StorageStats;

    move-result-object v1

    .line 64
    if-eqz v1, :cond_23

    .line 65
    invoke-virtual {v1}, Landroid/app/usage/StorageStats;->getCacheBytes()J

    move-result-wide v6

    invoke-virtual {v1}, Landroid/app/usage/StorageStats;->getDataBytes()J

    move-result-wide v8

    add-long/2addr v6, v8

    add-long/2addr v2, v6

    goto :goto_23

    .line 68
    :cond_52
    invoke-interface {p2, v2, v3}, Lcom/cleanmaster/junk/util/SysCacheUtils$ICacheSizeCallback;->setSize(J)V
    :try_end_55
    .catch Ljava/lang/Exception; {:try_start_17 .. :try_end_55} :catch_56

    goto :goto_10

    .line 69
    :catch_56
    move-exception v0

    .line 70
    invoke-interface {p2, v2, v3}, Lcom/cleanmaster/junk/util/SysCacheUtils$ICacheSizeCallback;->setSize(J)V

    goto :goto_10

    .line 73
    :cond_5b
    new-array v0, v5, [J

    aput-wide v2, v0, v4

    .line 74
    new-instance v1, Ljava/util/concurrent/atomic/AtomicInteger;

    invoke-direct {v1}, Ljava/util/concurrent/atomic/AtomicInteger;-><init>()V

    .line 75
    invoke-interface {p0}, Ljava/util/List;->size()I

    move-result v2

    invoke-virtual {v1, v2}, Ljava/util/concurrent/atomic/AtomicInteger;->set(I)V

    .line 76
    invoke-virtual {p1}, Landroid/content/Context;->getPackageManager()Landroid/content/pm/PackageManager;

    move-result-object v2

    .line 77
    invoke-static {v2}, Lcom/cleanmaster/junk/util/SysCacheUtils;->getPackageSizeMethod(Landroid/content/pm/PackageManager;)Ljava/lang/reflect/Method;

    move-result-object v3

    .line 79
    new-instance v4, Lcom/cleanmaster/junk/util/SysCacheUtils$1;

    invoke-direct {v4, v1, v0, p2}, Lcom/cleanmaster/junk/util/SysCacheUtils$1;-><init>(Ljava/util/concurrent/atomic/AtomicInteger;[JLcom/cleanmaster/junk/util/SysCacheUtils$ICacheSizeCallback;)V

    .line 93
    invoke-interface {p0}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v1

    :goto_7c
    invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z

    move-result v0

    if-eqz v0, :cond_10

    invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/lang/String;

    .line 95
    const/4 v5, 0x2

    :try_start_89
    new-array v5, v5, [Ljava/lang/Object;

    const/4 v6, 0x0

    aput-object v0, v5, v6

    const/4 v0, 0x1

    aput-object v4, v5, v0

    invoke-virtual {v3, v2, v5}, Ljava/lang/reflect/Method;->invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
    :try_end_94
    .catch Ljava/lang/Exception; {:try_start_89 .. :try_end_94} :catch_95

    goto :goto_7c

    .line 96
    :catch_95
    move-exception v0

    goto :goto_7c
.end method

.method private static getPackageSizeMethod(Landroid/content/pm/PackageManager;)Ljava/lang/reflect/Method;
    .registers 7

    .prologue
    .line 103
    const/4 v0, 0x0

    .line 105
    :try_start_1
    invoke-virtual {p0}, Ljava/lang/Object;->getClass()Ljava/lang/Class;

    move-result-object v1

    const-string v2, "getPackageSizeInfo"

    const/4 v3, 0x2

    new-array v3, v3, [Ljava/lang/Class;

    const/4 v4, 0x0

    const-class v5, Ljava/lang/String;

    aput-object v5, v3, v4

    const/4 v4, 0x1

    const-class v5, Landroid/content/pm/IPackageStatsObserver;

    aput-object v5, v3, v4

    invoke-virtual {v1, v2, v3}, Ljava/lang/Class;->getMethod(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;
    :try_end_17
    .catch Ljava/lang/NoSuchMethodException; {:try_start_1 .. :try_end_17} :catch_19

    move-result-object v0

    .line 111
    :goto_18
    return-object v0

    .line 109
    :catch_19
    move-exception v1

    goto :goto_18
.end method

.method public static hasUsageStatsPermission(Landroid/content/Context;)Z
    .registers 7

    .prologue
    const/4 v1, 0x1

    const/4 v2, 0x0

    .line 32
    sget v0, Landroid/os/Build$VERSION;->SDK_INT:I

    const/16 v3, 0x15

    if-ge v0, v3, :cond_9

    .line 43
    :goto_8
    return v2

    .line 35
    :cond_9
    const-string v0, "appops"

    invoke-virtual {p0, v0}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/app/AppOpsManager;

    .line 36
    const-string v3, "android:get_usage_stats"

    invoke-static {}, Landroid/os/Process;->myUid()I

    move-result v4

    invoke-virtual {p0}, Landroid/content/Context;->getPackageName()Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v0, v3, v4, v5}, Landroid/app/AppOpsManager;->checkOpNoThrow(Ljava/lang/String;ILjava/lang/String;)I

    move-result v0

    .line 38
    const/4 v3, 0x3

    if-ne v0, v3, :cond_2f

    .line 39
    const-string v0, "android.permission.PACKAGE_USAGE_STATS"

    invoke-virtual {p0, v0}, Landroid/content/Context;->checkCallingOrSelfPermission(Ljava/lang/String;)I

    move-result v0

    if-nez v0, :cond_2d

    move v0, v1

    :goto_2b
    move v2, v0

    .line 43
    goto :goto_8

    :cond_2d
    move v0, v2

    .line 39
    goto :goto_2b

    .line 41
    :cond_2f
    if-nez v0, :cond_33

    :goto_31
    move v0, v1

    goto :goto_2b

    :cond_33
    move v1, v2

    goto :goto_31
.end method