PushMessageUtils.smali
.class public Lcom/tradplus/ads/pushcenter/utils/PushMessageUtils;
.super Ljava/lang/Object;
# annotations
.annotation system Ldalvik/annotation/MemberClasses;
value = {
Lcom/tradplus/ads/pushcenter/utils/PushMessageUtils$Type;,
Lcom/tradplus/ads/pushcenter/utils/PushMessageUtils$PushStatus;
}
.end annotation
# static fields
.field public static final MAXMESSAGELENGTH:I = 0x64
.field public static final PUSHMESSAGEARRAY:Ljava/lang/String; = "push_message_array"
.field private static a:Lcom/tradplus/ads/pushcenter/utils/PushMessageUtils;
# direct methods
.method public constructor <init>()V
.registers 1
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
.method public static getInstance()Lcom/tradplus/ads/pushcenter/utils/PushMessageUtils;
.registers 1
sget-object v0, Lcom/tradplus/ads/pushcenter/utils/PushMessageUtils;->a:Lcom/tradplus/ads/pushcenter/utils/PushMessageUtils;
if-nez v0, :cond_b
new-instance v0, Lcom/tradplus/ads/pushcenter/utils/PushMessageUtils;
invoke-direct {v0}, Lcom/tradplus/ads/pushcenter/utils/PushMessageUtils;-><init>()V
sput-object v0, Lcom/tradplus/ads/pushcenter/utils/PushMessageUtils;->a:Lcom/tradplus/ads/pushcenter/utils/PushMessageUtils;
:cond_b
sget-object v0, Lcom/tradplus/ads/pushcenter/utils/PushMessageUtils;->a:Lcom/tradplus/ads/pushcenter/utils/PushMessageUtils;
return-object v0
.end method
# virtual methods
.method public getCacheType(I)Ljava/lang/String;
.registers 3
sget v0, Lcom/tradplus/ads/mobileads/util/TradPlusDataConstants;->CACHETRADPLUSTYPE:I
if-ne p1, v0, :cond_7
const-string p1, "TradPlus"
return-object p1
:cond_7
sget v0, Lcom/tradplus/ads/mobileads/util/TradPlusDataConstants;->CACHETYPE:I
if-ne p1, v0, :cond_e
const-string p1, "CrossPro"
return-object p1
:cond_e
sget v0, Lcom/tradplus/ads/mobileads/util/TradPlusDataConstants;->TRACKTYPE:I
if-ne p1, v0, :cond_15
const-string p1, "Track"
return-object p1
:cond_15
const-string p1, ""
return-object p1
.end method
.method public getPushMessageArray(Landroid/content/Context;I)Lorg/json/JSONArray;
.registers 4
invoke-static {p1, p2}, Lcom/tradplus/ads/mobileads/util/ACache;->get(Landroid/content/Context;I)Lcom/tradplus/ads/mobileads/util/ACache;
move-result-object v0
if-nez v0, :cond_c
new-instance p1, Lorg/json/JSONArray;
invoke-direct {p1}, Lorg/json/JSONArray;-><init>()V
return-object p1
:cond_c
if-nez p1, :cond_10
const/4 p1, 0x0
return-object p1
:cond_10
invoke-static {p1, p2}, Lcom/tradplus/ads/mobileads/util/ACache;->get(Landroid/content/Context;I)Lcom/tradplus/ads/mobileads/util/ACache;
move-result-object p1
const-string p2, "push_message_array"
invoke-virtual {p1, p2}, Lcom/tradplus/ads/mobileads/util/ACache;->getAsJSONArray(Ljava/lang/String;)Lorg/json/JSONArray;
move-result-object p1
if-nez p1, :cond_21
new-instance p1, Lorg/json/JSONArray;
invoke-direct {p1}, Lorg/json/JSONArray;-><init>()V
:cond_21
return-object p1
.end method
.method public getTradPlusErrorCode(Lcom/tradplus/ads/mobileads/TradPlusErrorCode;Ljava/lang/String;)Lcom/tradplus/ads/mobileads/TradPlusErrorCode;
.registers 3
invoke-virtual {p1, p2}, Lcom/tradplus/ads/mobileads/TradPlusErrorCode;->setErrormessage(Ljava/lang/String;)V
return-object p1
.end method
.method public initPushMessageArray(Landroid/content/Context;I)V
.registers 5
invoke-static {p1, p2}, Lcom/tradplus/ads/mobileads/util/ACache;->get(Landroid/content/Context;I)Lcom/tradplus/ads/mobileads/util/ACache;
move-result-object p1
if-nez p1, :cond_7
return-void
:cond_7
new-instance p1, Lorg/json/JSONArray;
invoke-direct {p1}, Lorg/json/JSONArray;-><init>()V
invoke-static {}, Lcom/tradplus/ads/pushcenter/PushCenter;->getInstance()Lcom/tradplus/ads/pushcenter/PushCenter;
move-result-object v0
const-string v1, "push_message_array"
invoke-virtual {v0, v1, p1, p2}, Lcom/tradplus/ads/pushcenter/PushCenter;->saveMessageToLocal(Ljava/lang/String;Lorg/json/JSONArray;I)V
return-void
.end method
.method public initPushMessageArray(Landroid/content/Context;Lorg/json/JSONArray;I)V
.registers 5
invoke-static {p1, p3}, Lcom/tradplus/ads/mobileads/util/ACache;->get(Landroid/content/Context;I)Lcom/tradplus/ads/mobileads/util/ACache;
move-result-object p1
if-nez p1, :cond_7
return-void
:cond_7
invoke-static {}, Lcom/tradplus/ads/pushcenter/PushCenter;->getInstance()Lcom/tradplus/ads/pushcenter/PushCenter;
move-result-object p1
const-string v0, "push_message_array"
invoke-virtual {p1, v0, p2, p3}, Lcom/tradplus/ads/pushcenter/PushCenter;->saveMessageToLocal(Ljava/lang/String;Lorg/json/JSONArray;I)V
return-void
.end method
.method public readyToSendMessage(Landroid/content/Context;Lorg/json/JSONArray;I)Lorg/json/JSONArray;
.registers 12
new-instance v0, Lorg/json/JSONArray;
invoke-direct {v0}, Lorg/json/JSONArray;-><init>()V
const/4 v1, 0x0
:goto_6
invoke-virtual {p2}, Lorg/json/JSONArray;->length()I
move-result v2
if-ge v1, v2, :cond_2e
:try_start_c
invoke-virtual {p2, v1}, Lorg/json/JSONArray;->getJSONObject(I)Lorg/json/JSONObject;
move-result-object v2
const-string v3, "createtime"
invoke-virtual {v2, v3}, Lorg/json/JSONObject;->getLong(Ljava/lang/String;)J
move-result-wide v3
const-string v5, "time"
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v6
sub-long/2addr v6, v3
const-wide/16 v3, 0x3e8
div-long/2addr v6, v3
invoke-virtual {v2, v5, v6, v7}, Lorg/json/JSONObject;->put(Ljava/lang/String;J)Lorg/json/JSONObject;
invoke-virtual {v0, v2}, Lorg/json/JSONArray;->put(Ljava/lang/Object;)Lorg/json/JSONArray;
:try_end_26
.catch Lorg/json/JSONException; {:try_start_c .. :try_end_26} :catch_27
goto :goto_2b
:catch_27
move-exception v2
invoke-virtual {v2}, Lorg/json/JSONException;->printStackTrace()V
:goto_2b
add-int/lit8 v1, v1, 0x1
goto :goto_6
:cond_2e
invoke-virtual {p0, p1, p3}, Lcom/tradplus/ads/pushcenter/utils/PushMessageUtils;->initPushMessageArray(Landroid/content/Context;I)V
return-object v0
.end method
.method public setPushMessageArray(Landroid/content/Context;Lorg/json/JSONObject;I)V
.registers 7
invoke-virtual {p2}, Lorg/json/JSONObject;->toString()Ljava/lang/String;
move-result-object v0
new-instance v1, Ljava/lang/StringBuilder;
invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
invoke-virtual {p0, p3}, Lcom/tradplus/ads/pushcenter/utils/PushMessageUtils;->getCacheType(I)Ljava/lang/String;
move-result-object v2
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
const-string v2, " : PUSHMESSAGEARRAY"
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v1
invoke-static {v0, v1}, Lcom/tradplus/ads/common/util/LogUtil;->ownShow(Ljava/lang/String;Ljava/lang/String;)V
invoke-static {p1, p3}, Lcom/tradplus/ads/mobileads/util/ACache;->get(Landroid/content/Context;I)Lcom/tradplus/ads/mobileads/util/ACache;
move-result-object v0
if-nez v0, :cond_23
return-void
:cond_23
invoke-virtual {p0, p1, p3}, Lcom/tradplus/ads/pushcenter/utils/PushMessageUtils;->getPushMessageArray(Landroid/content/Context;I)Lorg/json/JSONArray;
move-result-object v0
if-eqz v0, :cond_35
invoke-virtual {v0, p2}, Lorg/json/JSONArray;->put(Ljava/lang/Object;)Lorg/json/JSONArray;
invoke-static {p1, p3}, Lcom/tradplus/ads/mobileads/util/ACache;->get(Landroid/content/Context;I)Lcom/tradplus/ads/mobileads/util/ACache;
move-result-object p1
const-string p2, "push_message_array"
invoke-virtual {p1, p2, v0}, Lcom/tradplus/ads/mobileads/util/ACache;->put(Ljava/lang/String;Lorg/json/JSONArray;)V
:cond_35
return-void
.end method
.method public setTradPlusErrorMessage(Lcom/tradplus/ads/mobileads/TradPlusErrorCode;)Ljava/lang/String;
.registers 5
invoke-virtual {p1}, Lcom/tradplus/ads/mobileads/TradPlusErrorCode;->getCode()Ljava/lang/String;
move-result-object v0
invoke-static {v0}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z
move-result v0
const-string v1, ""
if-nez v0, :cond_11
invoke-virtual {p1}, Lcom/tradplus/ads/mobileads/TradPlusErrorCode;->getCode()Ljava/lang/String;
move-result-object v0
goto :goto_12
:cond_11
move-object v0, v1
:goto_12
invoke-virtual {p1}, Lcom/tradplus/ads/mobileads/TradPlusErrorCode;->getErrormessage()Ljava/lang/String;
move-result-object v2
invoke-static {v2}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z
move-result v2
if-nez v2, :cond_20
invoke-virtual {p1}, Lcom/tradplus/ads/mobileads/TradPlusErrorCode;->getErrormessage()Ljava/lang/String;
move-result-object v1
:cond_20
invoke-static {v1}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z
move-result p1
if-eqz p1, :cond_2f
invoke-static {v0}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z
move-result p1
if-eqz p1, :cond_2f
const-string p1, "errCode:0,errMsg:unknown error"
return-object p1
:cond_2f
new-instance p1, Ljava/lang/StringBuilder;
invoke-direct {p1}, Ljava/lang/StringBuilder;-><init>()V
const-string v2, "errCode:"
invoke-virtual {p1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {p1, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
const-string v0, ",errMsg:"
invoke-virtual {p1, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {p1, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {p1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p1
return-object p1
.end method
.method public sortAndReadyToSendMessage(Landroid/content/Context;Lorg/json/JSONArray;I)Lorg/json/JSONArray;
.registers 14
new-instance v0, Lorg/json/JSONArray;
invoke-direct {v0}, Lorg/json/JSONArray;-><init>()V
new-instance v1, Lorg/json/JSONArray;
invoke-direct {v1}, Lorg/json/JSONArray;-><init>()V
const/16 v2, 0x64
const/16 v3, 0x64
:goto_e
invoke-virtual {p2}, Lorg/json/JSONArray;->length()I
move-result v4
if-ge v3, v4, :cond_23
:try_start_14
invoke-virtual {p2, v3}, Lorg/json/JSONArray;->getJSONObject(I)Lorg/json/JSONObject;
move-result-object v4
invoke-virtual {v0, v4}, Lorg/json/JSONArray;->put(Ljava/lang/Object;)Lorg/json/JSONArray;
:try_end_1b
.catch Lorg/json/JSONException; {:try_start_14 .. :try_end_1b} :catch_1c
goto :goto_20
:catch_1c
move-exception v4
invoke-virtual {v4}, Lorg/json/JSONException;->printStackTrace()V
:goto_20
add-int/lit8 v3, v3, 0x1
goto :goto_e
:cond_23
const/4 v3, 0x0
:goto_24
if-ge v3, v2, :cond_48
:try_start_26
invoke-virtual {p2, v3}, Lorg/json/JSONArray;->getJSONObject(I)Lorg/json/JSONObject;
move-result-object v4
const-string v5, "createtime"
invoke-virtual {v4, v5}, Lorg/json/JSONObject;->getLong(Ljava/lang/String;)J
move-result-wide v5
const-string v7, "time"
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v8
sub-long/2addr v8, v5
const-wide/16 v5, 0x3e8
div-long/2addr v8, v5
invoke-virtual {v4, v7, v8, v9}, Lorg/json/JSONObject;->put(Ljava/lang/String;J)Lorg/json/JSONObject;
invoke-virtual {v1, v4}, Lorg/json/JSONArray;->put(Ljava/lang/Object;)Lorg/json/JSONArray;
:try_end_40
.catch Lorg/json/JSONException; {:try_start_26 .. :try_end_40} :catch_41
goto :goto_45
:catch_41
move-exception v4
invoke-virtual {v4}, Lorg/json/JSONException;->printStackTrace()V
:goto_45
add-int/lit8 v3, v3, 0x1
goto :goto_24
:cond_48
invoke-virtual {p0, p1, v0, p3}, Lcom/tradplus/ads/pushcenter/utils/PushMessageUtils;->initPushMessageArray(Landroid/content/Context;Lorg/json/JSONArray;I)V
return-object v1
.end method
.method public sortPushMessageArray(Landroid/content/Context;I)Lorg/json/JSONArray;
.registers 6
invoke-virtual {p0, p1, p2}, Lcom/tradplus/ads/pushcenter/utils/PushMessageUtils;->getPushMessageArray(Landroid/content/Context;I)Lorg/json/JSONArray;
move-result-object v0
invoke-virtual {v0}, Lorg/json/JSONArray;->length()I
move-result v1
if-nez v1, :cond_10
new-instance p1, Lorg/json/JSONArray;
invoke-direct {p1}, Lorg/json/JSONArray;-><init>()V
return-object p1
:cond_10
const/16 v2, 0x64
if-gt v1, v2, :cond_19
invoke-virtual {p0, p1, v0, p2}, Lcom/tradplus/ads/pushcenter/utils/PushMessageUtils;->readyToSendMessage(Landroid/content/Context;Lorg/json/JSONArray;I)Lorg/json/JSONArray;
move-result-object p1
return-object p1
:cond_19
invoke-virtual {p0, p1, v0, p2}, Lcom/tradplus/ads/pushcenter/utils/PushMessageUtils;->sortAndReadyToSendMessage(Landroid/content/Context;Lorg/json/JSONArray;I)Lorg/json/JSONArray;
move-result-object p1
return-object p1
.end method