what-the-bank/sources/o/mwP.java

477 lines
17 KiB
Java

package o;
import android.content.SharedPreferences;
import android.util.Pair;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
/* loaded from: classes.dex */
public final class mwP implements SharedPreferences {
final CopyOnWriteArrayList<SharedPreferences.OnSharedPreferenceChangeListener> a = new CopyOnWriteArrayList<>();
final String b;
final String c;
final SharedPreferences d;
final GHh e;
final InterfaceC4280bVg h;
public mwP(String str, String str2, SharedPreferences sharedPreferences, InterfaceC4280bVg interfaceC4280bVg, GHh gHh) {
this.c = str;
this.d = sharedPreferences;
this.b = str2;
this.h = interfaceC4280bVg;
this.e = gHh;
}
/* loaded from: classes.dex */
public enum IeS {
AES256_SIV;
public final String mDeterministicAeadKeyTemplateName;
IeS() {
this.mDeterministicAeadKeyTemplateName = r3;
}
}
/* loaded from: classes.dex */
public enum LWm {
AES256_GCM;
public final String mAeadKeyTemplateName;
LWm() {
this.mAeadKeyTemplateName = r3;
}
}
/* loaded from: classes.dex */
static final class Sts implements SharedPreferences.Editor {
private final SharedPreferences.Editor c;
private final mwP e;
private AtomicBoolean d = new AtomicBoolean(false);
private final List<String> a = new CopyOnWriteArrayList();
Sts(mwP mwp, SharedPreferences.Editor editor) {
this.e = mwp;
this.c = editor;
}
@Override // android.content.SharedPreferences.Editor
public final SharedPreferences.Editor putString(String str, String str2) {
if (str2 == null) {
str2 = "__NULL__";
}
byte[] bytes = str2.getBytes(StandardCharsets.UTF_8);
int length = bytes.length;
ByteBuffer allocate = ByteBuffer.allocate(length + 8);
allocate.putInt(RVV.STRING.mId);
allocate.putInt(length);
allocate.put(bytes);
c(str, allocate.array());
return this;
}
@Override // android.content.SharedPreferences.Editor
public final SharedPreferences.Editor putStringSet(String str, Set<String> set) {
if (set == null) {
set = new wnv<>();
set.add("__NULL__");
}
ArrayList<byte[]> arrayList = new ArrayList(set.size());
int size = set.size() << 2;
Iterator<String> it = set.iterator();
while (it.hasNext()) {
byte[] bytes = it.next().getBytes(StandardCharsets.UTF_8);
arrayList.add(bytes);
size += bytes.length;
}
ByteBuffer allocate = ByteBuffer.allocate(size + 4);
allocate.putInt(RVV.STRING_SET.mId);
for (byte[] bArr : arrayList) {
allocate.putInt(bArr.length);
allocate.put(bArr);
}
c(str, allocate.array());
return this;
}
@Override // android.content.SharedPreferences.Editor
public final SharedPreferences.Editor putInt(String str, int i) {
ByteBuffer allocate = ByteBuffer.allocate(8);
allocate.putInt(RVV.INT.mId);
allocate.putInt(i);
c(str, allocate.array());
return this;
}
@Override // android.content.SharedPreferences.Editor
public final SharedPreferences.Editor putLong(String str, long j) {
ByteBuffer allocate = ByteBuffer.allocate(12);
allocate.putInt(RVV.LONG.mId);
allocate.putLong(j);
c(str, allocate.array());
return this;
}
@Override // android.content.SharedPreferences.Editor
public final SharedPreferences.Editor putFloat(String str, float f) {
ByteBuffer allocate = ByteBuffer.allocate(8);
allocate.putInt(RVV.FLOAT.mId);
allocate.putFloat(f);
c(str, allocate.array());
return this;
}
@Override // android.content.SharedPreferences.Editor
public final SharedPreferences.Editor putBoolean(String str, boolean z) {
ByteBuffer allocate = ByteBuffer.allocate(5);
allocate.putInt(RVV.BOOLEAN.mId);
allocate.put(z ? (byte) 1 : (byte) 0);
c(str, allocate.array());
return this;
}
@Override // android.content.SharedPreferences.Editor
public final SharedPreferences.Editor clear() {
this.d.set(true);
return this;
}
@Override // android.content.SharedPreferences.Editor
public final boolean commit() {
c();
try {
return this.c.commit();
} finally {
e();
this.a.clear();
}
}
@Override // android.content.SharedPreferences.Editor
public final void apply() {
c();
this.c.apply();
e();
this.a.clear();
}
private void c() {
if (this.d.getAndSet(false)) {
for (String str : this.e.getAll().keySet()) {
if (!this.a.contains(str) && !"__androidx_security_crypto_encrypted_prefs_key_keyset__".equals(str) && !"__androidx_security_crypto_encrypted_prefs_value_keyset__".equals(str)) {
this.c.remove(this.e.d(str));
}
}
}
}
private void e() {
Iterator<SharedPreferences.OnSharedPreferenceChangeListener> it = this.e.a.iterator();
while (it.hasNext()) {
SharedPreferences.OnSharedPreferenceChangeListener next = it.next();
Iterator<String> it2 = this.a.iterator();
while (it2.hasNext()) {
next.onSharedPreferenceChanged(this.e, it2.next());
}
}
}
private void c(String str, byte[] bArr) {
if ("__androidx_security_crypto_encrypted_prefs_key_keyset__".equals(str) || "__androidx_security_crypto_encrypted_prefs_value_keyset__".equals(str)) {
StringBuilder sb = new StringBuilder();
sb.append(str);
sb.append(" is a reserved key for the encryption keyset.");
throw new SecurityException(sb.toString());
}
this.a.add(str);
if (str == null) {
str = "__NULL__";
}
try {
mwP mwp = this.e;
String d = mwp.d(str);
Pair pair = new Pair(d, xTi.d(mwp.h.b(bArr, d.getBytes(StandardCharsets.UTF_8))));
this.c.putString((String) pair.first, (String) pair.second);
} catch (GeneralSecurityException e) {
StringBuilder sb2 = new StringBuilder("Could not encrypt data: ");
sb2.append(e.getMessage());
throw new SecurityException(sb2.toString(), e);
}
}
@Override // android.content.SharedPreferences.Editor
public final SharedPreferences.Editor remove(String str) {
if ("__androidx_security_crypto_encrypted_prefs_key_keyset__".equals(str) || "__androidx_security_crypto_encrypted_prefs_value_keyset__".equals(str)) {
StringBuilder sb = new StringBuilder();
sb.append(str);
sb.append(" is a reserved key for the encryption keyset.");
throw new SecurityException(sb.toString());
}
this.c.remove(this.e.d(str));
this.a.add(str);
return this;
}
}
@Override // android.content.SharedPreferences
public final Map<String, ?> getAll() {
HashMap hashMap = new HashMap();
for (Map.Entry<String, ?> entry : this.d.getAll().entrySet()) {
String key = entry.getKey();
if (!"__androidx_security_crypto_encrypted_prefs_key_keyset__".equals(key) && !"__androidx_security_crypto_encrypted_prefs_value_keyset__".equals(key)) {
String a = a(entry.getKey());
hashMap.put(a, e(a));
}
}
return hashMap;
}
@Override // android.content.SharedPreferences
public final String getString(String str, String str2) {
Object e = e(str);
return (e == null || !(e instanceof String)) ? str2 : (String) e;
}
@Override // android.content.SharedPreferences
public final Set<String> getStringSet(String str, Set<String> set) {
Set<String> wnvVar;
Object e = e(str);
if (e instanceof Set) {
wnvVar = (Set) e;
} else {
wnvVar = new wnv<>();
}
return wnvVar.size() > 0 ? wnvVar : set;
}
@Override // android.content.SharedPreferences
public final int getInt(String str, int i) {
Object e = e(str);
return (e == null || !(e instanceof Integer)) ? i : ((Integer) e).intValue();
}
@Override // android.content.SharedPreferences
public final long getLong(String str, long j) {
Object e = e(str);
return (e == null || !(e instanceof Long)) ? j : ((Long) e).longValue();
}
@Override // android.content.SharedPreferences
public final float getFloat(String str, float f) {
Object e = e(str);
return (e == null || !(e instanceof Float)) ? f : ((Float) e).floatValue();
}
@Override // android.content.SharedPreferences
public final boolean getBoolean(String str, boolean z) {
Object e = e(str);
return (e == null || !(e instanceof Boolean)) ? z : ((Boolean) e).booleanValue();
}
@Override // android.content.SharedPreferences
public final SharedPreferences.Editor edit() {
return new Sts(this, this.d.edit());
}
@Override // android.content.SharedPreferences
public final void registerOnSharedPreferenceChangeListener(SharedPreferences.OnSharedPreferenceChangeListener onSharedPreferenceChangeListener) {
this.a.add(onSharedPreferenceChangeListener);
}
@Override // android.content.SharedPreferences
public final void unregisterOnSharedPreferenceChangeListener(SharedPreferences.OnSharedPreferenceChangeListener onSharedPreferenceChangeListener) {
this.a.remove(onSharedPreferenceChangeListener);
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public enum RVV {
STRING(0),
STRING_SET(1),
INT(2),
LONG(3),
FLOAT(4),
BOOLEAN(5);
final int mId;
RVV(int i) {
this.mId = i;
}
public static RVV d(int i) {
if (i == 0) {
return STRING;
}
if (i == 1) {
return STRING_SET;
}
if (i == 2) {
return INT;
}
if (i == 3) {
return LONG;
}
if (i == 4) {
return FLOAT;
}
if (i != 5) {
return null;
}
return BOOLEAN;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* renamed from: o.mwP$4, reason: invalid class name */
/* loaded from: classes.dex */
public static /* synthetic */ class AnonymousClass4 {
static final int[] a;
static {
int[] iArr = new int[RVV.values().length];
a = iArr;
try {
iArr[RVV.STRING.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
a[RVV.INT.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
a[RVV.LONG.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
a[RVV.FLOAT.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
a[RVV.BOOLEAN.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
try {
a[RVV.STRING_SET.ordinal()] = 6;
} catch (NoSuchFieldError unused6) {
}
}
}
final String d(String str) {
if (str == null) {
str = "__NULL__";
}
try {
return xTi.d(this.e.e(str.getBytes(StandardCharsets.UTF_8), this.c.getBytes()));
} catch (GeneralSecurityException e) {
StringBuilder sb = new StringBuilder("Could not encrypt key. ");
sb.append(e.getMessage());
throw new SecurityException(sb.toString(), e);
}
}
private String a(String str) {
try {
String str2 = new String(this.e.a(xTi.e(str), this.c.getBytes()), StandardCharsets.UTF_8);
if (str2.equals("__NULL__")) {
return null;
}
return str2;
} catch (GeneralSecurityException e) {
StringBuilder sb = new StringBuilder("Could not decrypt key. ");
sb.append(e.getMessage());
throw new SecurityException(sb.toString(), e);
}
}
private Object e(String str) throws SecurityException {
if ("__androidx_security_crypto_encrypted_prefs_key_keyset__".equals(str) || "__androidx_security_crypto_encrypted_prefs_value_keyset__".equals(str)) {
StringBuilder sb = new StringBuilder();
sb.append(str);
sb.append(" is a reserved key for the encryption keyset.");
throw new SecurityException(sb.toString());
}
if (str == null) {
str = "__NULL__";
}
try {
String d = d(str);
String string = this.d.getString(d, null);
if (string == null) {
return null;
}
ByteBuffer wrap = ByteBuffer.wrap(this.h.d(xTi.e(string), d.getBytes(StandardCharsets.UTF_8)));
wrap.position(0);
int i = wrap.getInt();
RVV d2 = RVV.d(i);
if (d2 == null) {
StringBuilder sb2 = new StringBuilder("Unknown type ID for encrypted pref value: ");
sb2.append(i);
throw new SecurityException(sb2.toString());
}
switch (AnonymousClass4.a[d2.ordinal()]) {
case 1:
int i2 = wrap.getInt();
ByteBuffer slice = wrap.slice();
wrap.limit(i2);
String obj = StandardCharsets.UTF_8.decode(slice).toString();
if (obj.equals("__NULL__")) {
return null;
}
return obj;
case 2:
return Integer.valueOf(wrap.getInt());
case 3:
return Long.valueOf(wrap.getLong());
case 4:
return Float.valueOf(wrap.getFloat());
case 5:
return Boolean.valueOf(wrap.get() != 0);
case 6:
wnv wnvVar = new wnv();
while (wrap.hasRemaining()) {
int i3 = wrap.getInt();
ByteBuffer slice2 = wrap.slice();
slice2.limit(i3);
wrap.position(wrap.position() + i3);
wnvVar.add(StandardCharsets.UTF_8.decode(slice2).toString());
}
if (wnvVar.size() == 1 && "__NULL__".equals(wnvVar.a[0])) {
return null;
}
return wnvVar;
default:
StringBuilder sb3 = new StringBuilder("Unhandled type for encrypted pref value: ");
sb3.append(d2);
throw new SecurityException(sb3.toString());
}
} catch (GeneralSecurityException e) {
StringBuilder sb4 = new StringBuilder("Could not decrypt value. ");
sb4.append(e.getMessage());
throw new SecurityException(sb4.toString(), e);
}
}
@Override // android.content.SharedPreferences
public final boolean contains(String str) {
if ("__androidx_security_crypto_encrypted_prefs_key_keyset__".equals(str) || "__androidx_security_crypto_encrypted_prefs_value_keyset__".equals(str)) {
StringBuilder sb = new StringBuilder();
sb.append(str);
sb.append(" is a reserved key for the encryption keyset.");
throw new SecurityException(sb.toString());
}
return this.d.contains(d(str));
}
}