HQVoiceMsgDownloadManager.smali

.class public Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;
.super Ljava/lang/Object;
.source "HQVoiceMsgDownloadManager.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager$HQVoiceMsgDownloadManagerHolder;
    }
.end annotation


# static fields
.field private static final REQUEST_MSG_DOWNLOAD_PERMISSION:I = 0x3e9

.field private static final TAG:Ljava/lang/String; = "HQVoiceMsgDownloadManager"


# instance fields
.field private final autoDownloadQueue:Lio/rong/imkit/voiceMessageDownload/AutoDownloadQueue;

.field private errorList:Ljava/util/List;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/List<",
            "Lio/rong/imkit/voiceMessageDownload/AutoDownloadEntry;",
            ">;"
        }
    .end annotation
.end field

.field private executorService:Ljava/util/concurrent/ExecutorService;

.field private future:Ljava/util/concurrent/Future;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/concurrent/Future<",
            "*>;"
        }
    .end annotation
.end field

.field private mContext:Landroid/content/Context;


# direct methods
.method static constructor <clinit>()V
    .registers 0

    return-void
.end method

.method private constructor <init>()V
    .registers 2

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

    .line 3
    new-instance v0, Lio/rong/imkit/voiceMessageDownload/AutoDownloadQueue;

    invoke-direct {v0}, Lio/rong/imkit/voiceMessageDownload/AutoDownloadQueue;-><init>()V

    iput-object v0, p0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->autoDownloadQueue:Lio/rong/imkit/voiceMessageDownload/AutoDownloadQueue;

    const/4 v0, 0x0

    .line 4
    iput-object v0, p0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->future:Ljava/util/concurrent/Future;

    .line 5
    iput-object v0, p0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->errorList:Ljava/util/List;

    return-void
.end method

.method synthetic constructor <init>(Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager$1;)V
    .registers 2

    .line 1
    invoke-direct {p0}, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;-><init>()V

    return-void
.end method

.method static synthetic access$200(Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;)Lio/rong/imkit/voiceMessageDownload/AutoDownloadQueue;
    .registers 1

    .line 1
    iget-object p0, p0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->autoDownloadQueue:Lio/rong/imkit/voiceMessageDownload/AutoDownloadQueue;

    return-object p0
.end method

.method static synthetic access$300()Ljava/lang/String;
    .registers 1

    .line 1
    sget-object v0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->TAG:Ljava/lang/String;

    return-object v0
.end method

.method static synthetic access$400(Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;)Lio/rong/imlib/model/Message;
    .registers 1

    .line 1
    invoke-direct {p0}, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->dequeue()Lio/rong/imlib/model/Message;

    move-result-object p0

    return-object p0
.end method

.method static synthetic access$500(Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;)Ljava/util/List;
    .registers 1

    .line 1
    iget-object p0, p0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->errorList:Ljava/util/List;

    return-object p0
.end method

.method static synthetic access$600(Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;Lio/rong/imlib/model/Message;)Lio/rong/imkit/voiceMessageDownload/AutoDownloadEntry;
    .registers 2

    .line 1
    invoke-direct {p0, p1}, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->getMsgEntry(Lio/rong/imlib/model/Message;)Lio/rong/imkit/voiceMessageDownload/AutoDownloadEntry;

    move-result-object p0

    return-object p0
.end method

.method static synthetic access$700(Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;Ljava/lang/String;)V
    .registers 2

    .line 1
    invoke-direct {p0, p1}, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->removeUidInHashMap(Ljava/lang/String;)V

    return-void
.end method

.method private dequeue()Lio/rong/imlib/model/Message;
    .registers 2

    .line 1
    iget-object v0, p0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->autoDownloadQueue:Lio/rong/imkit/voiceMessageDownload/AutoDownloadQueue;

    invoke-virtual {v0}, Lio/rong/imkit/voiceMessageDownload/AutoDownloadQueue;->dequeue()Lio/rong/imlib/model/Message;

    move-result-object v0

    return-object v0
.end method

.method private downloadHQVoiceMessage()V
    .registers 3

    .line 1
    iget-object v0, p0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->executorService:Ljava/util/concurrent/ExecutorService;

    new-instance v1, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager$1;

    invoke-direct {v1, p0}, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager$1;-><init>(Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;)V

    invoke-interface {v0, v1}, Ljava/util/concurrent/ExecutorService;->submit(Ljava/lang/Runnable;)Ljava/util/concurrent/Future;

    move-result-object v0

    iput-object v0, p0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->future:Ljava/util/concurrent/Future;

    return-void
.end method

.method private enqueue(Lio/rong/imkit/voiceMessageDownload/AutoDownloadEntry;)V
    .registers 3

    const/4 v0, 0x0

    .line 18
    invoke-virtual {p0, v0, p1}, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->enqueue(Landroidx/fragment/app/Fragment;Lio/rong/imkit/voiceMessageDownload/AutoDownloadEntry;)V

    return-void
.end method

.method public static getInstance()Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;
    .registers 1

    .line 1
    # getter for: Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager$HQVoiceMsgDownloadManagerHolder;->instance:Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;
    invoke-static {}, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager$HQVoiceMsgDownloadManagerHolder;->access$100()Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;

    move-result-object v0

    return-object v0
.end method

.method private getMsgEntry(Lio/rong/imlib/model/Message;)Lio/rong/imkit/voiceMessageDownload/AutoDownloadEntry;
    .registers 5

    const/4 v0, 0x0

    if-nez p1, :cond_4

    return-object v0

    .line 1
    :cond_4
    iget-object v1, p0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->autoDownloadQueue:Lio/rong/imkit/voiceMessageDownload/AutoDownloadQueue;

    invoke-virtual {v1}, Lio/rong/imkit/voiceMessageDownload/AutoDownloadQueue;->getAutoDownloadEntryHashMap()Ljava/util/HashMap;

    move-result-object v1

    invoke-virtual {p1}, Lio/rong/imlib/model/Message;->getUId()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Ljava/util/HashMap;->containsKey(Ljava/lang/Object;)Z

    move-result v1

    if-eqz v1, :cond_25

    .line 2
    iget-object v0, p0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->autoDownloadQueue:Lio/rong/imkit/voiceMessageDownload/AutoDownloadQueue;

    invoke-virtual {v0}, Lio/rong/imkit/voiceMessageDownload/AutoDownloadQueue;->getAutoDownloadEntryHashMap()Ljava/util/HashMap;

    move-result-object v0

    invoke-virtual {p1}, Lio/rong/imlib/model/Message;->getUId()Ljava/lang/String;

    move-result-object p1

    invoke-virtual {v0, p1}, Ljava/util/HashMap;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object p1

    move-object v0, p1

    check-cast v0, Lio/rong/imkit/voiceMessageDownload/AutoDownloadEntry;

    :cond_25
    return-object v0
.end method

.method private ifMsgInHashMap(Lio/rong/imlib/model/Message;)Z
    .registers 3

    .line 1
    iget-object v0, p0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->autoDownloadQueue:Lio/rong/imkit/voiceMessageDownload/AutoDownloadQueue;

    invoke-virtual {v0, p1}, Lio/rong/imkit/voiceMessageDownload/AutoDownloadQueue;->ifMsgInHashMap(Lio/rong/imlib/model/Message;)Z

    move-result p1

    return p1
.end method

.method private removeUidInHashMap(Ljava/lang/String;)V
    .registers 3

    .line 1
    iget-object v0, p0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->autoDownloadQueue:Lio/rong/imkit/voiceMessageDownload/AutoDownloadQueue;

    invoke-virtual {v0}, Lio/rong/imkit/voiceMessageDownload/AutoDownloadQueue;->getAutoDownloadEntryHashMap()Ljava/util/HashMap;

    move-result-object v0

    invoke-virtual {v0, p1}, Ljava/util/HashMap;->remove(Ljava/lang/Object;)Ljava/lang/Object;

    return-void
.end method


# virtual methods
.method public enqueue(Landroidx/fragment/app/Fragment;Lio/rong/imkit/voiceMessageDownload/AutoDownloadEntry;)V
    .registers 7

    if-nez p2, :cond_3

    return-void

    .line 1
    :cond_3
    invoke-virtual {p2}, Lio/rong/imkit/voiceMessageDownload/AutoDownloadEntry;->getMessage()Lio/rong/imlib/model/Message;

    move-result-object v0

    .line 2
    invoke-virtual {v0}, Lio/rong/imlib/model/Message;->getContent()Lio/rong/imlib/model/MessageContent;

    move-result-object v1

    instance-of v1, v1, Lio/rong/message/HQVoiceMessage;

    if-eqz v1, :cond_7f

    .line 3
    invoke-direct {p0, v0}, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->ifMsgInHashMap(Lio/rong/imlib/model/Message;)Z

    move-result v1

    if-eqz v1, :cond_18

    if-eqz p1, :cond_18

    goto :goto_7f

    :cond_18
    const/4 v1, 0x1

    .line 4
    new-array v1, v1, [Ljava/lang/String;

    const/4 v2, 0x0

    const-string v3, "android.permission.WRITE_EXTERNAL_STORAGE"

    aput-object v3, v1, v2

    if-eqz p1, :cond_37

    .line 5
    invoke-virtual {p1}, Landroidx/fragment/app/Fragment;->isAdded()Z

    move-result v2

    if-eqz v2, :cond_37

    .line 6
    invoke-virtual {p1}, Landroidx/fragment/app/Fragment;->getActivity()Landroidx/fragment/app/FragmentActivity;

    move-result-object v2

    invoke-static {v2, v1}, Lio/rong/imkit/utilities/PermissionCheckUtil;->checkPermissions(Landroid/content/Context;[Ljava/lang/String;)Z

    move-result v2

    if-nez v2, :cond_37

    const/16 v2, 0x3e9

    .line 7
    invoke-static {p1, v1, v2}, Lio/rong/imkit/utilities/PermissionCheckUtil;->requestPermissions(Landroidx/fragment/app/Fragment;[Ljava/lang/String;I)Z

    .line 8
    :cond_37
    invoke-virtual {v0}, Lio/rong/imlib/model/Message;->getContent()Lio/rong/imlib/model/MessageContent;

    move-result-object p1

    check-cast p1, Lio/rong/message/HQVoiceMessage;

    .line 9
    invoke-virtual {p1}, Lio/rong/message/MediaMessageContent;->getLocalPath()Landroid/net/Uri;

    move-result-object v0

    if-eqz v0, :cond_52

    .line 10
    invoke-virtual {p1}, Lio/rong/message/MediaMessageContent;->getLocalPath()Landroid/net/Uri;

    move-result-object p1

    invoke-virtual {p1}, Landroid/net/Uri;->toString()Ljava/lang/String;

    move-result-object p1

    invoke-static {p1}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result p1

    if-nez p1, :cond_52

    return-void

    .line 11
    :cond_52
    iget-object p1, p0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->autoDownloadQueue:Lio/rong/imkit/voiceMessageDownload/AutoDownloadQueue;

    monitor-enter p1

    .line 12
    :try_start_55
    iget-object v0, p0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->autoDownloadQueue:Lio/rong/imkit/voiceMessageDownload/AutoDownloadQueue;

    invoke-virtual {v0}, Lio/rong/imkit/voiceMessageDownload/AutoDownloadQueue;->isEmpty()Z

    move-result v0

    .line 13
    iget-object v1, p0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->autoDownloadQueue:Lio/rong/imkit/voiceMessageDownload/AutoDownloadQueue;

    invoke-virtual {v1, p2}, Lio/rong/imkit/voiceMessageDownload/AutoDownloadQueue;->enqueue(Lio/rong/imkit/voiceMessageDownload/AutoDownloadEntry;)V

    if-eqz v0, :cond_67

    .line 14
    iget-object p2, p0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->autoDownloadQueue:Lio/rong/imkit/voiceMessageDownload/AutoDownloadQueue;

    invoke-virtual {p2}, Ljava/lang/Object;->notify()V

    .line 15
    :cond_67
    iget-object p2, p0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->future:Ljava/util/concurrent/Future;

    invoke-interface {p2}, Ljava/util/concurrent/Future;->isDone()Z

    move-result p2

    if-eqz p2, :cond_7a

    iget-object p2, p0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->mContext:Landroid/content/Context;

    invoke-static {p2}, Lio/rong/imlib/common/NetUtils;->isNetWorkAvailable(Landroid/content/Context;)Z

    move-result p2

    if-eqz p2, :cond_7a

    .line 16
    invoke-direct {p0}, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->downloadHQVoiceMessage()V

    .line 17
    :cond_7a
    monitor-exit p1

    return-void

    :catchall_7c
    move-exception p2

    monitor-exit p1
    :try_end_7e
    .catchall {:try_start_55 .. :try_end_7e} :catchall_7c

    throw p2

    :cond_7f
    :goto_7f
    return-void
.end method

.method public init(Landroid/content/Context;)V
    .registers 5

    .line 1
    new-instance v0, Lio/rong/imkit/voiceMessageDownload/AutoDownloadNetWorkChangeReceiver;

    invoke-direct {v0}, Lio/rong/imkit/voiceMessageDownload/AutoDownloadNetWorkChangeReceiver;-><init>()V

    .line 2
    invoke-virtual {p1}, Landroid/content/Context;->getApplicationContext()Landroid/content/Context;

    move-result-object v1

    iput-object v1, p0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->mContext:Landroid/content/Context;

    .line 3
    invoke-static {}, Ljava/util/concurrent/Executors;->newSingleThreadExecutor()Ljava/util/concurrent/ExecutorService;

    move-result-object v1

    iput-object v1, p0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->executorService:Ljava/util/concurrent/ExecutorService;

    .line 4
    new-instance v1, Ljava/util/ArrayList;

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

    iput-object v1, p0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->errorList:Ljava/util/List;

    .line 5
    :try_start_18
    new-instance v1, Landroid/content/IntentFilter;

    invoke-direct {v1}, Landroid/content/IntentFilter;-><init>()V

    const-string v2, "android.net.conn.CONNECTIVITY_CHANGE"

    .line 6
    invoke-virtual {v1, v2}, Landroid/content/IntentFilter;->addAction(Ljava/lang/String;)V

    .line 7
    invoke-virtual {p1}, Landroid/content/Context;->getApplicationContext()Landroid/content/Context;

    move-result-object p1

    invoke-virtual {p1, v0, v1}, Landroid/content/Context;->registerReceiver(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;
    :try_end_29
    .catch Ljava/lang/Exception; {:try_start_18 .. :try_end_29} :catch_2a

    goto :goto_32

    :catch_2a
    move-exception p1

    .line 8
    sget-object v0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->TAG:Ljava/lang/String;

    const-string v1, "registerReceiver Exception"

    invoke-static {v0, v1, p1}, Lio/rong/common/RLog;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    .line 9
    :goto_32
    invoke-direct {p0}, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->downloadHQVoiceMessage()V

    return-void
.end method

.method pauseDownloadService()V
    .registers 1

    return-void
.end method

.method public resumeDownloadService()V
    .registers 3

    .line 1
    iget-object v0, p0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->errorList:Ljava/util/List;

    if-eqz v0, :cond_36

    invoke-interface {v0}, Ljava/util/List;->size()I

    move-result v0

    if-nez v0, :cond_b

    goto :goto_36

    .line 2
    :cond_b
    iget-object v0, p0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->future:Ljava/util/concurrent/Future;

    invoke-interface {v0}, Ljava/util/concurrent/Future;->isDone()Z

    move-result v0

    if-eqz v0, :cond_1e

    iget-object v0, p0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->mContext:Landroid/content/Context;

    invoke-static {v0}, Lio/rong/imlib/common/NetUtils;->isNetWorkAvailable(Landroid/content/Context;)Z

    move-result v0

    if-eqz v0, :cond_1e

    .line 3
    invoke-direct {p0}, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->downloadHQVoiceMessage()V

    .line 4
    :cond_1e
    iget-object v0, p0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->errorList:Ljava/util/List;

    invoke-interface {v0}, Ljava/util/List;->size()I

    move-result v0

    add-int/lit8 v0, v0, -0x1

    :goto_26
    if-ltz v0, :cond_36

    .line 5
    iget-object v1, p0, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->errorList:Ljava/util/List;

    invoke-interface {v1, v0}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lio/rong/imkit/voiceMessageDownload/AutoDownloadEntry;

    invoke-direct {p0, v1}, Lio/rong/imkit/voiceMessageDownload/HQVoiceMsgDownloadManager;->enqueue(Lio/rong/imkit/voiceMessageDownload/AutoDownloadEntry;)V

    add-int/lit8 v0, v0, -0x1

    goto :goto_26

    :cond_36
    :goto_36
    return-void
.end method