InfocLog.smali
.class public Lcom/sdk/orion/ui/baselibrary/report/InfocLog;
.super Ljava/lang/Object;
# annotations
.annotation system Ldalvik/annotation/MemberClasses;
value = {
Lcom/sdk/orion/ui/baselibrary/report/InfocLog$LogItem;
}
.end annotation
# static fields
.field private static final LOG_DIR_PATH:Ljava/lang/String; = "/infoc/log"
.field private static final LOG_FILE_NAME_FIRST:Ljava/lang/String; = "log.0"
.field private static final LOG_FILE_NAME_SECOND:Ljava/lang/String; = "log.1"
.field private static final LOG_FMT:Ljava/lang/String; = "%s!@#$#@!%s!@#$#@!%s%n"
.field private static final MAX_FILE_SIZE:J = 0x80000L
.field private static final SEM:[B
.field private static final THREAD_RETAIN_TIME:J = 0x7530L
.field private static mInstance:Lcom/sdk/orion/ui/baselibrary/report/InfocLog;
# instance fields
.field private filesDirPath:Ljava/lang/String;
.field private mCurrentLogFile:Ljava/io/File;
.field private mDateFormat:Ljava/text/SimpleDateFormat;
.field private final mLogItemList:Ljava/util/LinkedList;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/util/LinkedList",
"<",
"Lcom/sdk/orion/ui/baselibrary/report/InfocLog$LogItem;",
">;"
}
.end annotation
.end field
.field private mRunnable:Ljava/lang/Runnable;
.field private mWriteThread:Ljava/lang/Thread;
# direct methods
.method static constructor <clinit>()V
.registers 1
const/4 v0, 0x1
new-array v0, v0, [B
sput-object v0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->SEM:[B
new-instance v0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;
invoke-direct {v0}, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;-><init>()V
sput-object v0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mInstance:Lcom/sdk/orion/ui/baselibrary/report/InfocLog;
return-void
.end method
.method private constructor <init>()V
.registers 5
const/4 v3, 0x0
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
new-instance v0, Ljava/text/SimpleDateFormat;
const-string/jumbo v1, "yyyy-MM-dd HH:mm:ss"
invoke-static {}, Ljava/util/Locale;->getDefault()Ljava/util/Locale;
move-result-object v2
invoke-direct {v0, v1, v2}, Ljava/text/SimpleDateFormat;-><init>(Ljava/lang/String;Ljava/util/Locale;)V
iput-object v0, p0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mDateFormat:Ljava/text/SimpleDateFormat;
iput-object v3, p0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mWriteThread:Ljava/lang/Thread;
iput-object v3, p0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mCurrentLogFile:Ljava/io/File;
new-instance v0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog$1;
invoke-direct {v0, p0}, Lcom/sdk/orion/ui/baselibrary/report/InfocLog$1;-><init>(Lcom/sdk/orion/ui/baselibrary/report/InfocLog;)V
iput-object v0, p0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mRunnable:Ljava/lang/Runnable;
new-instance v0, Ljava/util/LinkedList;
invoke-direct {v0}, Ljava/util/LinkedList;-><init>()V
iput-object v0, p0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mLogItemList:Ljava/util/LinkedList;
return-void
.end method
.method static synthetic access$000(Lcom/sdk/orion/ui/baselibrary/report/InfocLog;)Lcom/sdk/orion/ui/baselibrary/report/InfocLog$LogItem;
.registers 2
invoke-direct {p0}, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->getItemFromList()Lcom/sdk/orion/ui/baselibrary/report/InfocLog$LogItem;
move-result-object v0
return-object v0
.end method
.method static synthetic access$100(Lcom/sdk/orion/ui/baselibrary/report/InfocLog;)V
.registers 1
invoke-direct {p0}, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->waitForNewWrite()V
return-void
.end method
.method static synthetic access$200(Lcom/sdk/orion/ui/baselibrary/report/InfocLog;Lcom/sdk/orion/ui/baselibrary/report/InfocLog$LogItem;)V
.registers 2
invoke-direct {p0, p1}, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->writeDataToFile(Lcom/sdk/orion/ui/baselibrary/report/InfocLog$LogItem;)V
return-void
.end method
.method private closeOutputStream(Ljava/io/OutputStream;)V
.registers 3
if-nez p1, :cond_3
:goto_2
return-void
:cond_3
:try_start_3
invoke-virtual {p1}, Ljava/io/OutputStream;->close()V
:try_end_6
.catch Ljava/lang/Exception; {:try_start_3 .. :try_end_6} :catch_7
goto :goto_2
:catch_7
move-exception v0
invoke-virtual {v0}, Ljava/lang/Exception;->printStackTrace()V
goto :goto_2
.end method
.method private getItemFromList()Lcom/sdk/orion/ui/baselibrary/report/InfocLog$LogItem;
.registers 4
const/4 v0, 0x0
iget-object v1, p0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mLogItemList:Ljava/util/LinkedList;
monitor-enter v1
:try_start_4
iget-object v2, p0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mLogItemList:Ljava/util/LinkedList;
invoke-virtual {v2}, Ljava/util/LinkedList;->isEmpty()Z
move-result v2
if-nez v2, :cond_14
iget-object v0, p0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mLogItemList:Ljava/util/LinkedList;
invoke-virtual {v0}, Ljava/util/LinkedList;->remove()Ljava/lang/Object;
move-result-object v0
check-cast v0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog$LogItem;
:cond_14
monitor-exit v1
return-object v0
:catchall_16
move-exception v0
monitor-exit v1
:try_end_18
.catchall {:try_start_4 .. :try_end_18} :catchall_16
throw v0
.end method
.method private getLogFile()Ljava/io/File;
.registers 3
iget-object v0, p0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mCurrentLogFile:Ljava/io/File;
if-eqz v0, :cond_f
iget-object v0, p0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mCurrentLogFile:Ljava/io/File;
invoke-virtual {v0}, Ljava/io/File;->canWrite()Z
move-result v0
if-eqz v0, :cond_f
iget-object v0, p0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mCurrentLogFile:Ljava/io/File;
:goto_e
return-object v0
:cond_f
new-instance v0, Ljava/lang/StringBuilder;
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
sget-object v1, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mInstance:Lcom/sdk/orion/ui/baselibrary/report/InfocLog;
iget-object v1, v1, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->filesDirPath:Ljava/lang/String;
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v0
const-string/jumbo v1, "/infoc/log"
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v0
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v0
invoke-direct {p0, v0}, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->parentDirsExist(Ljava/lang/String;)Z
move-result v1
if-nez v1, :cond_2f
const/4 v0, 0x0
goto :goto_e
:cond_2f
invoke-direct {p0, v0}, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->getRightLogFile(Ljava/lang/String;)Ljava/io/File;
move-result-object v0
iput-object v0, p0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mCurrentLogFile:Ljava/io/File;
iget-object v0, p0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mCurrentLogFile:Ljava/io/File;
goto :goto_e
.end method
.method private getRightLogFile(Ljava/lang/String;)Ljava/io/File;
.registers 5
new-instance v0, Ljava/io/File;
const-string/jumbo v1, "log.0"
invoke-direct {v0, p1, v1}, Ljava/io/File;-><init>(Ljava/lang/String;Ljava/lang/String;)V
invoke-direct {p0, v0}, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->isLogFileValid(Ljava/io/File;)Z
move-result v1
if-eqz v1, :cond_f
:goto_e
return-object v0
:cond_f
new-instance v1, Ljava/io/File;
const-string/jumbo v2, "log.1"
invoke-direct {v1, p1, v2}, Ljava/io/File;-><init>(Ljava/lang/String;Ljava/lang/String;)V
invoke-direct {p0, v1}, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->isLogFileValid(Ljava/io/File;)Z
move-result v2
if-eqz v2, :cond_1f
move-object v0, v1
goto :goto_e
:cond_1f
invoke-direct {p0, v0}, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->isFileOverSize(Ljava/io/File;)Z
move-result v2
if-eqz v2, :cond_34
invoke-direct {p0, v1}, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->isFileOverSize(Ljava/io/File;)Z
move-result v2
if-eqz v2, :cond_34
invoke-virtual {v0}, Ljava/io/File;->delete()Z
invoke-virtual {v1, v0}, Ljava/io/File;->renameTo(Ljava/io/File;)Z
:try_start_31
invoke-virtual {v1}, Ljava/io/File;->createNewFile()Z
:try_end_34
.catch Ljava/io/IOException; {:try_start_31 .. :try_end_34} :catch_36
:cond_34
move-object v0, v1
goto :goto_e
:catch_36
move-exception v0
invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V
const/4 v0, 0x0
goto :goto_e
.end method
.method private isFileOverSize(Ljava/io/File;)Z
.registers 6
if-eqz p1, :cond_15
invoke-virtual {p1}, Ljava/io/File;->exists()Z
move-result v0
if-eqz v0, :cond_15
invoke-virtual {p1}, Ljava/io/File;->length()J
move-result-wide v0
const-wide/32 v2, 0x80000
cmp-long v0, v0, v2
if-ltz v0, :cond_15
const/4 v0, 0x1
:goto_14
return v0
:cond_15
const/4 v0, 0x0
goto :goto_14
.end method
.method private isLogFileValid(Ljava/io/File;)Z
.registers 8
const/4 v0, 0x0
if-nez p1, :cond_4
:cond_3
:goto_3
return v0
:cond_4
invoke-virtual {p1}, Ljava/io/File;->exists()Z
move-result v1
if-nez v1, :cond_d
:try_start_a
invoke-virtual {p1}, Ljava/io/File;->createNewFile()Z
:try_end_d
.catch Ljava/io/IOException; {:try_start_a .. :try_end_d} :catch_20
:cond_d
invoke-virtual {p1}, Ljava/io/File;->exists()Z
move-result v1
if-eqz v1, :cond_3
invoke-virtual {p1}, Ljava/io/File;->length()J
move-result-wide v2
const-wide/32 v4, 0x80000
cmp-long v1, v2, v4
if-gez v1, :cond_3
const/4 v0, 0x1
goto :goto_3
:catch_20
move-exception v1
invoke-virtual {v1}, Ljava/io/IOException;->printStackTrace()V
goto :goto_3
.end method
.method public static log(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)V
.registers 6
invoke-static {p1}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z
move-result v0
if-nez v0, :cond_c
invoke-static {p2}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z
move-result v0
if-eqz v0, :cond_d
:cond_c
:goto_c
return-void
:cond_d
sget-object v0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mInstance:Lcom/sdk/orion/ui/baselibrary/report/InfocLog;
iget-object v1, v0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mLogItemList:Ljava/util/LinkedList;
monitor-enter v1
:try_start_12
new-instance v0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog$LogItem;
invoke-direct {v0}, Lcom/sdk/orion/ui/baselibrary/report/InfocLog$LogItem;-><init>()V
iput-object p1, v0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog$LogItem;->tableName:Ljava/lang/String;
iput-object p2, v0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog$LogItem;->data:Ljava/lang/String;
sget-object v2, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mInstance:Lcom/sdk/orion/ui/baselibrary/report/InfocLog;
iget-object v2, v2, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mLogItemList:Ljava/util/LinkedList;
invoke-virtual {v2, v0}, Ljava/util/LinkedList;->addLast(Ljava/lang/Object;)V
monitor-exit v1
:try_end_23
.catchall {:try_start_12 .. :try_end_23} :catchall_3f
sget-object v0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mInstance:Lcom/sdk/orion/ui/baselibrary/report/InfocLog;
iget-object v0, v0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->filesDirPath:Ljava/lang/String;
invoke-static {v0}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z
move-result v0
if-eqz v0, :cond_39
sget-object v0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mInstance:Lcom/sdk/orion/ui/baselibrary/report/InfocLog;
invoke-virtual {p0}, Landroid/content/Context;->getFilesDir()Ljava/io/File;
move-result-object v1
invoke-virtual {v1}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;
move-result-object v1
iput-object v1, v0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->filesDirPath:Ljava/lang/String;
:cond_39
sget-object v0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mInstance:Lcom/sdk/orion/ui/baselibrary/report/InfocLog;
invoke-virtual {v0}, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->sendWriteLogMsg()V
goto :goto_c
:catchall_3f
move-exception v0
:try_start_40
monitor-exit v1
:try_end_41
.catchall {:try_start_40 .. :try_end_41} :catchall_3f
throw v0
.end method
.method private parentDirsExist(Ljava/lang/String;)Z
.registers 5
const/4 v0, 0x0
invoke-static {p1}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z
move-result v1
if-eqz v1, :cond_8
:cond_7
:goto_7
return v0
:cond_8
new-instance v1, Ljava/io/File;
invoke-direct {v1, p1}, Ljava/io/File;-><init>(Ljava/lang/String;)V
invoke-virtual {v1}, Ljava/io/File;->exists()Z
move-result v2
if-nez v2, :cond_19
invoke-virtual {v1}, Ljava/io/File;->mkdirs()Z
move-result v1
if-eqz v1, :cond_7
:cond_19
const/4 v0, 0x1
goto :goto_7
.end method
.method private waitForNewWrite()V
.registers 5
sget-object v1, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->SEM:[B
monitor-enter v1
:try_start_3
sget-object v0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->SEM:[B
const-wide/16 v2, 0x7530
invoke-virtual {v0, v2, v3}, Ljava/lang/Object;->wait(J)V
:try_end_a
.catch Ljava/lang/InterruptedException; {:try_start_3 .. :try_end_a} :catch_c
.catchall {:try_start_3 .. :try_end_a} :catchall_11
:goto_a
:try_start_a
monitor-exit v1
return-void
:catch_c
move-exception v0
invoke-virtual {v0}, Ljava/lang/InterruptedException;->printStackTrace()V
goto :goto_a
:catchall_11
move-exception v0
monitor-exit v1
:try_end_13
.catchall {:try_start_a .. :try_end_13} :catchall_11
throw v0
.end method
.method private declared-synchronized writeDataToFile(Lcom/sdk/orion/ui/baselibrary/report/InfocLog$LogItem;)V
.registers 8
const/4 v2, 0x0
monitor-enter p0
:try_start_2
invoke-direct {p0}, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->getLogFile()Ljava/io/File;
:try_end_5
.catchall {:try_start_2 .. :try_end_5} :catchall_4e
move-result-object v0
if-nez v0, :cond_a
:goto_8
monitor-exit p0
return-void
:cond_a
:try_start_a
iget-object v1, p0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mDateFormat:Ljava/text/SimpleDateFormat;
new-instance v3, Ljava/util/Date;
invoke-direct {v3}, Ljava/util/Date;-><init>()V
invoke-virtual {v1, v3}, Ljava/text/SimpleDateFormat;->format(Ljava/util/Date;)Ljava/lang/String;
move-result-object v1
const-string/jumbo v3, "%s!@#$#@!%s!@#$#@!%s%n"
const/4 v4, 0x3
new-array v4, v4, [Ljava/lang/Object;
const/4 v5, 0x0
aput-object v1, v4, v5
const/4 v1, 0x1
iget-object v5, p1, Lcom/sdk/orion/ui/baselibrary/report/InfocLog$LogItem;->tableName:Ljava/lang/String;
aput-object v5, v4, v1
const/4 v1, 0x2
iget-object v5, p1, Lcom/sdk/orion/ui/baselibrary/report/InfocLog$LogItem;->data:Ljava/lang/String;
aput-object v5, v4, v1
invoke-static {v3, v4}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
:try_end_2b
.catchall {:try_start_a .. :try_end_2b} :catchall_4e
move-result-object v3
:try_start_2c
new-instance v1, Ljava/io/FileOutputStream;
const/4 v4, 0x1
invoke-direct {v1, v0, v4}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;Z)V
:try_end_32
.catch Ljava/lang/Exception; {:try_start_2c .. :try_end_32} :catch_51
.catchall {:try_start_2c .. :try_end_32} :catchall_5a
:try_start_32
invoke-virtual {v3}, Ljava/lang/String;->getBytes()[B
move-result-object v2
invoke-virtual {v1, v2}, Ljava/io/FileOutputStream;->write([B)V
invoke-virtual {v1}, Ljava/io/FileOutputStream;->flush()V
invoke-virtual {v0}, Ljava/io/File;->length()J
move-result-wide v2
const-wide/32 v4, 0x80000
cmp-long v0, v2, v4
if-ltz v0, :cond_4a
const/4 v0, 0x0
iput-object v0, p0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mCurrentLogFile:Ljava/io/File;
:try_end_4a
.catch Ljava/lang/Exception; {:try_start_32 .. :try_end_4a} :catch_62
.catchall {:try_start_32 .. :try_end_4a} :catchall_60
:cond_4a
:try_start_4a
invoke-direct {p0, v1}, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->closeOutputStream(Ljava/io/OutputStream;)V
:try_end_4d
.catchall {:try_start_4a .. :try_end_4d} :catchall_4e
goto :goto_8
:catchall_4e
move-exception v0
monitor-exit p0
throw v0
:catch_51
move-exception v0
move-object v1, v2
:goto_53
:try_start_53
invoke-virtual {v0}, Ljava/lang/Exception;->printStackTrace()V
:try_end_56
.catchall {:try_start_53 .. :try_end_56} :catchall_60
:try_start_56
invoke-direct {p0, v1}, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->closeOutputStream(Ljava/io/OutputStream;)V
goto :goto_8
:catchall_5a
move-exception v0
move-object v1, v2
:goto_5c
invoke-direct {p0, v1}, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->closeOutputStream(Ljava/io/OutputStream;)V
throw v0
:try_end_60
.catchall {:try_start_56 .. :try_end_60} :catchall_4e
:catchall_60
move-exception v0
goto :goto_5c
:catch_62
move-exception v0
goto :goto_53
.end method
# virtual methods
.method public declared-synchronized sendWriteLogMsg()V
.registers 4
monitor-enter p0
:try_start_1
iget-object v0, p0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mWriteThread:Ljava/lang/Thread;
if-eqz v0, :cond_d
iget-object v0, p0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mWriteThread:Ljava/lang/Thread;
invoke-virtual {v0}, Ljava/lang/Thread;->isAlive()Z
move-result v0
if-nez v0, :cond_1e
:cond_d
new-instance v0, Ljava/lang/Thread;
iget-object v1, p0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mRunnable:Ljava/lang/Runnable;
const-string/jumbo v2, "InfocLog:writeThread"
invoke-direct {v0, v1, v2}, Ljava/lang/Thread;-><init>(Ljava/lang/Runnable;Ljava/lang/String;)V
iput-object v0, p0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mWriteThread:Ljava/lang/Thread;
iget-object v0, p0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->mWriteThread:Ljava/lang/Thread;
invoke-virtual {v0}, Ljava/lang/Thread;->start()V
:cond_1e
sget-object v1, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->SEM:[B
monitor-enter v1
:try_end_21
.catchall {:try_start_1 .. :try_end_21} :catchall_2c
:try_start_21
sget-object v0, Lcom/sdk/orion/ui/baselibrary/report/InfocLog;->SEM:[B
invoke-virtual {v0}, Ljava/lang/Object;->notifyAll()V
monitor-exit v1
:try_end_27
.catchall {:try_start_21 .. :try_end_27} :catchall_29
monitor-exit p0
return-void
:catchall_29
move-exception v0
:try_start_2a
monitor-exit v1
:try_end_2b
.catchall {:try_start_2a .. :try_end_2b} :catchall_29
:try_start_2b
throw v0
:try_end_2c
.catchall {:try_start_2b .. :try_end_2c} :catchall_2c
:catchall_2c
move-exception v0
monitor-exit p0
throw v0
.end method