597 lines
15 KiB
Smali
597 lines
15 KiB
Smali
.class public Lcom/franmontiel/persistentcookiejar/persistence/SharedPrefsCookiePersistor;
|
|
.super Ljava/lang/Object;
|
|
.source "SharedPrefsCookiePersistor.java"
|
|
|
|
# interfaces
|
|
.implements Lcom/franmontiel/persistentcookiejar/persistence/CookiePersistor;
|
|
|
|
|
|
# annotations
|
|
.annotation build Landroid/annotation/SuppressLint;
|
|
value = {
|
|
"CommitPrefEdits"
|
|
}
|
|
.end annotation
|
|
|
|
|
|
# instance fields
|
|
.field public final a:Landroid/content/SharedPreferences;
|
|
|
|
|
|
# direct methods
|
|
.method public constructor <init>(Landroid/content/Context;)V
|
|
.locals 2
|
|
|
|
const-string v0, "CookiePersistence"
|
|
|
|
const/4 v1, 0x0
|
|
|
|
invoke-virtual {p1, v0, v1}, Landroid/content/Context;->getSharedPreferences(Ljava/lang/String;I)Landroid/content/SharedPreferences;
|
|
|
|
move-result-object p1
|
|
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
iput-object p1, p0, Lcom/franmontiel/persistentcookiejar/persistence/SharedPrefsCookiePersistor;->a:Landroid/content/SharedPreferences;
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public static c(Ld0/o;)Ljava/lang/String;
|
|
.locals 2
|
|
|
|
new-instance v0, Ljava/lang/StringBuilder;
|
|
|
|
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
|
|
|
|
iget-boolean v1, p0, Ld0/o;->f:Z
|
|
|
|
if-eqz v1, :cond_0
|
|
|
|
const-string v1, "https"
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
const-string v1, "http"
|
|
|
|
:goto_0
|
|
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
const-string v1, "://"
|
|
|
|
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
iget-object v1, p0, Ld0/o;->d:Ljava/lang/String;
|
|
|
|
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
iget-object v1, p0, Ld0/o;->e:Ljava/lang/String;
|
|
|
|
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
const-string v1, "|"
|
|
|
|
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
iget-object p0, p0, Ld0/o;->a:Ljava/lang/String;
|
|
|
|
invoke-virtual {v0, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
.end method
|
|
|
|
|
|
# virtual methods
|
|
.method public a()Ljava/util/List;
|
|
.locals 11
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"()",
|
|
"Ljava/util/List<",
|
|
"Ld0/o;",
|
|
">;"
|
|
}
|
|
.end annotation
|
|
|
|
new-instance v0, Ljava/util/ArrayList;
|
|
|
|
iget-object v1, p0, Lcom/franmontiel/persistentcookiejar/persistence/SharedPrefsCookiePersistor;->a:Landroid/content/SharedPreferences;
|
|
|
|
invoke-interface {v1}, Landroid/content/SharedPreferences;->getAll()Ljava/util/Map;
|
|
|
|
move-result-object v1
|
|
|
|
invoke-interface {v1}, Ljava/util/Map;->size()I
|
|
|
|
move-result v1
|
|
|
|
invoke-direct {v0, v1}, Ljava/util/ArrayList;-><init>(I)V
|
|
|
|
iget-object v1, p0, Lcom/franmontiel/persistentcookiejar/persistence/SharedPrefsCookiePersistor;->a:Landroid/content/SharedPreferences;
|
|
|
|
invoke-interface {v1}, Landroid/content/SharedPreferences;->getAll()Ljava/util/Map;
|
|
|
|
move-result-object v1
|
|
|
|
invoke-interface {v1}, Ljava/util/Map;->entrySet()Ljava/util/Set;
|
|
|
|
move-result-object v1
|
|
|
|
invoke-interface {v1}, Ljava/util/Set;->iterator()Ljava/util/Iterator;
|
|
|
|
move-result-object v1
|
|
|
|
:cond_0
|
|
:goto_0
|
|
invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z
|
|
|
|
move-result v2
|
|
|
|
if-eqz v2, :cond_4
|
|
|
|
invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
|
|
|
|
move-result-object v2
|
|
|
|
check-cast v2, Ljava/util/Map$Entry;
|
|
|
|
invoke-interface {v2}, Ljava/util/Map$Entry;->getValue()Ljava/lang/Object;
|
|
|
|
move-result-object v2
|
|
|
|
check-cast v2, Ljava/lang/String;
|
|
|
|
new-instance v3, Lcom/franmontiel/persistentcookiejar/persistence/SerializableCookie;
|
|
|
|
invoke-direct {v3}, Lcom/franmontiel/persistentcookiejar/persistence/SerializableCookie;-><init>()V
|
|
|
|
const-string v3, "Stream not closed in decodeCookie"
|
|
|
|
invoke-virtual {v2}, Ljava/lang/String;->length()I
|
|
|
|
move-result v4
|
|
|
|
div-int/lit8 v5, v4, 0x2
|
|
|
|
new-array v5, v5, [B
|
|
|
|
const/4 v6, 0x0
|
|
|
|
:goto_1
|
|
if-ge v6, v4, :cond_1
|
|
|
|
div-int/lit8 v7, v6, 0x2
|
|
|
|
invoke-virtual {v2, v6}, Ljava/lang/String;->charAt(I)C
|
|
|
|
move-result v8
|
|
|
|
const/16 v9, 0x10
|
|
|
|
invoke-static {v8, v9}, Ljava/lang/Character;->digit(CI)I
|
|
|
|
move-result v8
|
|
|
|
shl-int/lit8 v8, v8, 0x4
|
|
|
|
add-int/lit8 v10, v6, 0x1
|
|
|
|
invoke-virtual {v2, v10}, Ljava/lang/String;->charAt(I)C
|
|
|
|
move-result v10
|
|
|
|
invoke-static {v10, v9}, Ljava/lang/Character;->digit(CI)I
|
|
|
|
move-result v9
|
|
|
|
add-int/2addr v9, v8
|
|
|
|
int-to-byte v8, v9
|
|
|
|
aput-byte v8, v5, v7
|
|
|
|
add-int/lit8 v6, v6, 0x2
|
|
|
|
goto :goto_1
|
|
|
|
:cond_1
|
|
new-instance v2, Ljava/io/ByteArrayInputStream;
|
|
|
|
invoke-direct {v2, v5}, Ljava/io/ByteArrayInputStream;-><init>([B)V
|
|
|
|
const/4 v4, 0x0
|
|
|
|
:try_start_0
|
|
new-instance v5, Ljava/io/ObjectInputStream;
|
|
|
|
invoke-direct {v5, v2}, Ljava/io/ObjectInputStream;-><init>(Ljava/io/InputStream;)V
|
|
:try_end_0
|
|
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_4
|
|
.catch Ljava/lang/ClassNotFoundException; {:try_start_0 .. :try_end_0} :catch_3
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_1
|
|
|
|
:try_start_1
|
|
invoke-virtual {v5}, Ljava/io/ObjectInputStream;->readObject()Ljava/lang/Object;
|
|
|
|
move-result-object v2
|
|
|
|
check-cast v2, Lcom/franmontiel/persistentcookiejar/persistence/SerializableCookie;
|
|
|
|
iget-object v4, v2, Lcom/franmontiel/persistentcookiejar/persistence/SerializableCookie;->d:Ld0/o;
|
|
:try_end_1
|
|
.catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_2
|
|
.catch Ljava/lang/ClassNotFoundException; {:try_start_1 .. :try_end_1} :catch_1
|
|
.catchall {:try_start_1 .. :try_end_1} :catchall_0
|
|
|
|
:goto_2
|
|
:try_start_2
|
|
invoke-virtual {v5}, Ljava/io/ObjectInputStream;->close()V
|
|
:try_end_2
|
|
.catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_0
|
|
|
|
goto :goto_6
|
|
|
|
:catch_0
|
|
move-exception v2
|
|
|
|
goto :goto_5
|
|
|
|
:catchall_0
|
|
move-exception v0
|
|
|
|
move-object v4, v5
|
|
|
|
goto :goto_7
|
|
|
|
:catch_1
|
|
move-exception v2
|
|
|
|
goto :goto_3
|
|
|
|
:catch_2
|
|
move-exception v2
|
|
|
|
goto :goto_4
|
|
|
|
:catchall_1
|
|
move-exception v0
|
|
|
|
goto :goto_7
|
|
|
|
:catch_3
|
|
move-exception v2
|
|
|
|
move-object v5, v4
|
|
|
|
:goto_3
|
|
:try_start_3
|
|
sget-object v6, Lcom/franmontiel/persistentcookiejar/persistence/SerializableCookie;->e:Ljava/lang/String;
|
|
|
|
const-string v7, "ClassNotFoundException in decodeCookie"
|
|
|
|
invoke-static {v6, v7, v2}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
|
|
|
|
if-eqz v5, :cond_2
|
|
|
|
goto :goto_2
|
|
|
|
:catch_4
|
|
move-exception v2
|
|
|
|
move-object v5, v4
|
|
|
|
:goto_4
|
|
sget-object v6, Lcom/franmontiel/persistentcookiejar/persistence/SerializableCookie;->e:Ljava/lang/String;
|
|
|
|
const-string v7, "IOException in decodeCookie"
|
|
|
|
invoke-static {v6, v7, v2}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
|
|
:try_end_3
|
|
.catchall {:try_start_3 .. :try_end_3} :catchall_0
|
|
|
|
if-eqz v5, :cond_2
|
|
|
|
goto :goto_2
|
|
|
|
:goto_5
|
|
sget-object v5, Lcom/franmontiel/persistentcookiejar/persistence/SerializableCookie;->e:Ljava/lang/String;
|
|
|
|
invoke-static {v5, v3, v2}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
|
|
|
|
:cond_2
|
|
:goto_6
|
|
if-eqz v4, :cond_0
|
|
|
|
invoke-virtual {v0, v4}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
|
|
|
|
goto/16 :goto_0
|
|
|
|
:goto_7
|
|
if-eqz v4, :cond_3
|
|
|
|
:try_start_4
|
|
invoke-virtual {v4}, Ljava/io/ObjectInputStream;->close()V
|
|
:try_end_4
|
|
.catch Ljava/io/IOException; {:try_start_4 .. :try_end_4} :catch_5
|
|
|
|
goto :goto_8
|
|
|
|
:catch_5
|
|
move-exception v1
|
|
|
|
sget-object v2, Lcom/franmontiel/persistentcookiejar/persistence/SerializableCookie;->e:Ljava/lang/String;
|
|
|
|
invoke-static {v2, v3, v1}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
|
|
|
|
:cond_3
|
|
:goto_8
|
|
throw v0
|
|
|
|
:cond_4
|
|
return-object v0
|
|
.end method
|
|
|
|
.method public b(Ljava/util/Collection;)V
|
|
.locals 8
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"(",
|
|
"Ljava/util/Collection<",
|
|
"Ld0/o;",
|
|
">;)V"
|
|
}
|
|
.end annotation
|
|
|
|
iget-object v0, p0, Lcom/franmontiel/persistentcookiejar/persistence/SharedPrefsCookiePersistor;->a:Landroid/content/SharedPreferences;
|
|
|
|
invoke-interface {v0}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-interface {p1}, Ljava/util/Collection;->iterator()Ljava/util/Iterator;
|
|
|
|
move-result-object p1
|
|
|
|
:goto_0
|
|
invoke-interface {p1}, Ljava/util/Iterator;->hasNext()Z
|
|
|
|
move-result v1
|
|
|
|
if-eqz v1, :cond_4
|
|
|
|
invoke-interface {p1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
|
|
|
|
move-result-object v1
|
|
|
|
check-cast v1, Ld0/o;
|
|
|
|
invoke-static {v1}, Lcom/franmontiel/persistentcookiejar/persistence/SharedPrefsCookiePersistor;->c(Ld0/o;)Ljava/lang/String;
|
|
|
|
move-result-object v2
|
|
|
|
new-instance v3, Lcom/franmontiel/persistentcookiejar/persistence/SerializableCookie;
|
|
|
|
invoke-direct {v3}, Lcom/franmontiel/persistentcookiejar/persistence/SerializableCookie;-><init>()V
|
|
|
|
const-string v4, "Stream not closed in encodeCookie"
|
|
|
|
iput-object v1, v3, Lcom/franmontiel/persistentcookiejar/persistence/SerializableCookie;->d:Ld0/o;
|
|
|
|
new-instance v1, Ljava/io/ByteArrayOutputStream;
|
|
|
|
invoke-direct {v1}, Ljava/io/ByteArrayOutputStream;-><init>()V
|
|
|
|
const/4 v5, 0x0
|
|
|
|
:try_start_0
|
|
new-instance v6, Ljava/io/ObjectOutputStream;
|
|
|
|
invoke-direct {v6, v1}, Ljava/io/ObjectOutputStream;-><init>(Ljava/io/OutputStream;)V
|
|
:try_end_0
|
|
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_2
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_1
|
|
|
|
:try_start_1
|
|
invoke-virtual {v6, v3}, Ljava/io/ObjectOutputStream;->writeObject(Ljava/lang/Object;)V
|
|
:try_end_1
|
|
.catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_1
|
|
.catchall {:try_start_1 .. :try_end_1} :catchall_0
|
|
|
|
:try_start_2
|
|
invoke-virtual {v6}, Ljava/io/ObjectOutputStream;->close()V
|
|
:try_end_2
|
|
.catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_0
|
|
|
|
goto :goto_1
|
|
|
|
:catch_0
|
|
move-exception v3
|
|
|
|
sget-object v5, Lcom/franmontiel/persistentcookiejar/persistence/SerializableCookie;->e:Ljava/lang/String;
|
|
|
|
invoke-static {v5, v4, v3}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
|
|
|
|
:goto_1
|
|
invoke-virtual {v1}, Ljava/io/ByteArrayOutputStream;->toByteArray()[B
|
|
|
|
move-result-object v1
|
|
|
|
new-instance v3, Ljava/lang/StringBuilder;
|
|
|
|
array-length v4, v1
|
|
|
|
mul-int/lit8 v4, v4, 0x2
|
|
|
|
invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(I)V
|
|
|
|
array-length v4, v1
|
|
|
|
const/4 v5, 0x0
|
|
|
|
:goto_2
|
|
if-ge v5, v4, :cond_1
|
|
|
|
aget-byte v6, v1, v5
|
|
|
|
and-int/lit16 v6, v6, 0xff
|
|
|
|
const/16 v7, 0x10
|
|
|
|
if-ge v6, v7, :cond_0
|
|
|
|
const/16 v7, 0x30
|
|
|
|
invoke-virtual {v3, v7}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder;
|
|
|
|
:cond_0
|
|
invoke-static {v6}, Ljava/lang/Integer;->toHexString(I)Ljava/lang/String;
|
|
|
|
move-result-object v6
|
|
|
|
invoke-virtual {v3, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
add-int/lit8 v5, v5, 0x1
|
|
|
|
goto :goto_2
|
|
|
|
:cond_1
|
|
invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object v5
|
|
|
|
goto :goto_4
|
|
|
|
:catchall_0
|
|
move-exception p1
|
|
|
|
move-object v5, v6
|
|
|
|
goto :goto_5
|
|
|
|
:catch_1
|
|
move-exception v1
|
|
|
|
goto :goto_3
|
|
|
|
:catchall_1
|
|
move-exception p1
|
|
|
|
goto :goto_5
|
|
|
|
:catch_2
|
|
move-exception v1
|
|
|
|
move-object v6, v5
|
|
|
|
:goto_3
|
|
:try_start_3
|
|
sget-object v3, Lcom/franmontiel/persistentcookiejar/persistence/SerializableCookie;->e:Ljava/lang/String;
|
|
|
|
const-string v7, "IOException in encodeCookie"
|
|
|
|
invoke-static {v3, v7, v1}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
|
|
:try_end_3
|
|
.catchall {:try_start_3 .. :try_end_3} :catchall_0
|
|
|
|
if-eqz v6, :cond_2
|
|
|
|
:try_start_4
|
|
invoke-virtual {v6}, Ljava/io/ObjectOutputStream;->close()V
|
|
:try_end_4
|
|
.catch Ljava/io/IOException; {:try_start_4 .. :try_end_4} :catch_3
|
|
|
|
goto :goto_4
|
|
|
|
:catch_3
|
|
move-exception v1
|
|
|
|
sget-object v3, Lcom/franmontiel/persistentcookiejar/persistence/SerializableCookie;->e:Ljava/lang/String;
|
|
|
|
invoke-static {v3, v4, v1}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
|
|
|
|
:cond_2
|
|
:goto_4
|
|
invoke-interface {v0, v2, v5}, Landroid/content/SharedPreferences$Editor;->putString(Ljava/lang/String;Ljava/lang/String;)Landroid/content/SharedPreferences$Editor;
|
|
|
|
goto :goto_0
|
|
|
|
:goto_5
|
|
if-eqz v5, :cond_3
|
|
|
|
:try_start_5
|
|
invoke-virtual {v5}, Ljava/io/ObjectOutputStream;->close()V
|
|
:try_end_5
|
|
.catch Ljava/io/IOException; {:try_start_5 .. :try_end_5} :catch_4
|
|
|
|
goto :goto_6
|
|
|
|
:catch_4
|
|
move-exception v0
|
|
|
|
sget-object v1, Lcom/franmontiel/persistentcookiejar/persistence/SerializableCookie;->e:Ljava/lang/String;
|
|
|
|
invoke-static {v1, v4, v0}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
|
|
|
|
:cond_3
|
|
:goto_6
|
|
throw p1
|
|
|
|
:cond_4
|
|
invoke-interface {v0}, Landroid/content/SharedPreferences$Editor;->commit()Z
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public removeAll(Ljava/util/Collection;)V
|
|
.locals 2
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"(",
|
|
"Ljava/util/Collection<",
|
|
"Ld0/o;",
|
|
">;)V"
|
|
}
|
|
.end annotation
|
|
|
|
iget-object v0, p0, Lcom/franmontiel/persistentcookiejar/persistence/SharedPrefsCookiePersistor;->a:Landroid/content/SharedPreferences;
|
|
|
|
invoke-interface {v0}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-interface {p1}, Ljava/util/Collection;->iterator()Ljava/util/Iterator;
|
|
|
|
move-result-object p1
|
|
|
|
:goto_0
|
|
invoke-interface {p1}, Ljava/util/Iterator;->hasNext()Z
|
|
|
|
move-result v1
|
|
|
|
if-eqz v1, :cond_0
|
|
|
|
invoke-interface {p1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
|
|
|
|
move-result-object v1
|
|
|
|
check-cast v1, Ld0/o;
|
|
|
|
invoke-static {v1}, Lcom/franmontiel/persistentcookiejar/persistence/SharedPrefsCookiePersistor;->c(Ld0/o;)Ljava/lang/String;
|
|
|
|
move-result-object v1
|
|
|
|
invoke-interface {v0, v1}, Landroid/content/SharedPreferences$Editor;->remove(Ljava/lang/String;)Landroid/content/SharedPreferences$Editor;
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
invoke-interface {v0}, Landroid/content/SharedPreferences$Editor;->commit()Z
|
|
|
|
return-void
|
|
.end method
|