208 lines
8.5 KiB
Java
208 lines
8.5 KiB
Java
package com.franmontiel.persistentcookiejar.persistence;
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.content.Context;
|
|
import android.content.SharedPreferences;
|
|
import android.util.Log;
|
|
import f0.n;
|
|
import java.io.ByteArrayInputStream;
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.ObjectInputStream;
|
|
import java.io.ObjectOutputStream;
|
|
import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
@SuppressLint({"CommitPrefEdits"})
|
|
public class SharedPrefsCookiePersistor implements CookiePersistor {
|
|
public final SharedPreferences a;
|
|
|
|
public SharedPrefsCookiePersistor(Context context) {
|
|
this.a = context.getSharedPreferences("CookiePersistence", 0);
|
|
}
|
|
|
|
public static String b(n nVar) {
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append(nVar.k ? "https" : "http");
|
|
sb.append("://");
|
|
sb.append(nVar.i);
|
|
sb.append(nVar.j);
|
|
sb.append("|");
|
|
sb.append(nVar.f);
|
|
return sb.toString();
|
|
}
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:28:0x0079 A[SYNTHETIC, Splitter:B:28:0x0079] */
|
|
/* JADX WARNING: Removed duplicated region for block: B:34:0x0089 A[SYNTHETIC, Splitter:B:34:0x0089] */
|
|
/* JADX WARNING: Removed duplicated region for block: B:44:0x0083 A[SYNTHETIC] */
|
|
@Override // com.franmontiel.persistentcookiejar.persistence.CookiePersistor
|
|
public void a(Collection<n> collection) {
|
|
Throwable th;
|
|
ObjectOutputStream objectOutputStream;
|
|
IOException e;
|
|
SharedPreferences.Editor edit = this.a.edit();
|
|
for (n nVar : collection) {
|
|
String b = b(nVar);
|
|
SerializableCookie serializableCookie = new SerializableCookie();
|
|
serializableCookie.j = nVar;
|
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
String str = null;
|
|
ObjectOutputStream objectOutputStream2 = null;
|
|
str = null;
|
|
str = null;
|
|
try {
|
|
objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
|
|
try {
|
|
objectOutputStream.writeObject(serializableCookie);
|
|
try {
|
|
objectOutputStream.close();
|
|
} catch (IOException e2) {
|
|
Log.d(SerializableCookie.i, "Stream not closed in encodeCookie", e2);
|
|
}
|
|
byte[] byteArray = byteArrayOutputStream.toByteArray();
|
|
StringBuilder sb = new StringBuilder(byteArray.length * 2);
|
|
for (byte b2 : byteArray) {
|
|
int i = b2 & 255;
|
|
if (i < 16) {
|
|
sb.append('0');
|
|
}
|
|
sb.append(Integer.toHexString(i));
|
|
}
|
|
str = sb.toString();
|
|
} catch (IOException e3) {
|
|
e = e3;
|
|
try {
|
|
Log.d(SerializableCookie.i, "IOException in encodeCookie", e);
|
|
if (objectOutputStream == null) {
|
|
try {
|
|
objectOutputStream.close();
|
|
} catch (IOException e4) {
|
|
Log.d(SerializableCookie.i, "Stream not closed in encodeCookie", e4);
|
|
}
|
|
}
|
|
edit.putString(b, str);
|
|
} catch (Throwable th2) {
|
|
th = th2;
|
|
objectOutputStream2 = objectOutputStream;
|
|
if (objectOutputStream2 != null) {
|
|
try {
|
|
objectOutputStream2.close();
|
|
} catch (IOException e5) {
|
|
Log.d(SerializableCookie.i, "Stream not closed in encodeCookie", e5);
|
|
}
|
|
}
|
|
throw th;
|
|
}
|
|
}
|
|
} catch (IOException e6) {
|
|
e = e6;
|
|
objectOutputStream = null;
|
|
Log.d(SerializableCookie.i, "IOException in encodeCookie", e);
|
|
if (objectOutputStream == null) {
|
|
}
|
|
edit.putString(b, str);
|
|
} catch (Throwable th3) {
|
|
th = th3;
|
|
if (objectOutputStream2 != null) {
|
|
}
|
|
throw th;
|
|
}
|
|
edit.putString(b, str);
|
|
}
|
|
edit.commit();
|
|
}
|
|
|
|
/* JADX DEBUG: Failed to insert an additional move for type inference into block B:7:0x0066 */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/* JADX WARNING: Code restructure failed: missing block: B:28:0x0097, code lost:
|
|
if (r5 != null) goto L_0x0073;
|
|
*/
|
|
/* JADX WARNING: Removed duplicated region for block: B:24:0x008d A[Catch:{ IOException -> 0x008e, ClassNotFoundException -> 0x0082, all -> 0x0080, all -> 0x0079 }] */
|
|
/* JADX WARNING: Removed duplicated region for block: B:33:0x00a8 A[SYNTHETIC, Splitter:B:33:0x00a8] */
|
|
/* JADX WARNING: Removed duplicated region for block: B:39:0x00a1 A[SYNTHETIC] */
|
|
/* JADX WARNING: Removed duplicated region for block: B:42:0x001d A[SYNTHETIC] */
|
|
/* JADX WARNING: Unknown variable types count: 1 */
|
|
public List<n> c() {
|
|
Throwable th;
|
|
ObjectInputStream objectInputStream;
|
|
IOException e;
|
|
ClassNotFoundException e2;
|
|
ObjectInputStream objectInputStream2;
|
|
ArrayList arrayList = new ArrayList(this.a.getAll().size());
|
|
for (Map.Entry<String, ?> entry : this.a.getAll().entrySet()) {
|
|
String str = (String) entry.getValue();
|
|
new SerializableCookie();
|
|
int length = str.length();
|
|
byte[] bArr = new byte[(length / 2)];
|
|
for (int i = 0; i < length; i += 2) {
|
|
bArr[i / 2] = (byte) (Character.digit(str.charAt(i + 1), 16) + (Character.digit(str.charAt(i), 16) << 4));
|
|
}
|
|
?? r4 = null;
|
|
r4 = null;
|
|
r4 = null;
|
|
r4 = null;
|
|
n nVar = null;
|
|
try {
|
|
ObjectInputStream objectInputStream3 = new ObjectInputStream(new ByteArrayInputStream(bArr));
|
|
try {
|
|
nVar = ((SerializableCookie) objectInputStream3.readObject()).j;
|
|
objectInputStream2 = objectInputStream3;
|
|
} catch (IOException e3) {
|
|
e = e3;
|
|
objectInputStream = objectInputStream3;
|
|
Log.d(SerializableCookie.i, "IOException in decodeCookie", e);
|
|
objectInputStream2 = objectInputStream;
|
|
} catch (ClassNotFoundException e4) {
|
|
e2 = e4;
|
|
bArr = objectInputStream3;
|
|
Log.d(SerializableCookie.i, "ClassNotFoundException in decodeCookie", e2);
|
|
if (bArr != null) {
|
|
objectInputStream2 = bArr;
|
|
objectInputStream2.close();
|
|
}
|
|
if (nVar != null) {
|
|
}
|
|
}
|
|
} catch (IOException e5) {
|
|
e = e5;
|
|
objectInputStream = null;
|
|
Log.d(SerializableCookie.i, "IOException in decodeCookie", e);
|
|
objectInputStream2 = objectInputStream;
|
|
} catch (ClassNotFoundException e6) {
|
|
e2 = e6;
|
|
bArr = null;
|
|
Log.d(SerializableCookie.i, "ClassNotFoundException in decodeCookie", e2);
|
|
if (bArr != null) {
|
|
}
|
|
if (nVar != null) {
|
|
}
|
|
} catch (Throwable th2) {
|
|
th = th2;
|
|
r4 = bArr;
|
|
if (r4 != null) {
|
|
}
|
|
throw th;
|
|
}
|
|
try {
|
|
objectInputStream2.close();
|
|
} catch (IOException e7) {
|
|
Log.d(SerializableCookie.i, "Stream not closed in decodeCookie", e7);
|
|
}
|
|
if (nVar != null) {
|
|
arrayList.add(nVar);
|
|
}
|
|
}
|
|
return arrayList;
|
|
}
|
|
|
|
@Override // com.franmontiel.persistentcookiejar.persistence.CookiePersistor
|
|
public void removeAll(Collection<n> collection) {
|
|
SharedPreferences.Editor edit = this.a.edit();
|
|
for (n nVar : collection) {
|
|
edit.remove(b(nVar));
|
|
}
|
|
edit.commit();
|
|
}
|
|
}
|