what-the-bank/sources/o/SharedPreferencesC12958fMf....

308 lines
11 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package o;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Base64;
import com.huawei.hms.android.HwBuildEx;
import java.io.UnsupportedEncodingException;
import java.security.GeneralSecurityException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import o.fOS;
import org.bouncycastle.pqc.jcajce.spec.McElieceCCA2KeyGenParameterSpec;
/* renamed from: o.fMf, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public class SharedPreferencesC12958fMf implements SharedPreferences {
private String a;
private fOS.LWm c;
SharedPreferences d;
private String e;
public SharedPreferencesC12958fMf(Context context, String str, String str2) {
this(context, str, null, str2);
}
public SharedPreferencesC12958fMf(Context context, String str, String str2, String str3) {
this(context, str, str2, str3, (byte) 0);
}
private SharedPreferencesC12958fMf(Context context, String str, String str2, String str3, byte b) {
SharedPreferences sharedPreferences;
if (this.d == null) {
this.e = str3;
if (TextUtils.isEmpty(str3)) {
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
} else {
sharedPreferences = context.getSharedPreferences(str3, 0);
}
this.d = sharedPreferences;
}
this.a = str2;
if (!TextUtils.isEmpty(str)) {
try {
this.c = fOS.d(str, (TextUtils.isEmpty(this.a) ? d(context) : this.a).getBytes(), HwBuildEx.VersionCodes.CUR_DEVELOPMENT);
return;
} catch (GeneralSecurityException e) {
throw new IllegalStateException(e);
}
}
try {
String c = c(fOS.d(context.getPackageName(), (TextUtils.isEmpty(this.a) ? d(context) : this.a).getBytes(), HwBuildEx.VersionCodes.CUR_DEVELOPMENT).toString());
String string = this.d.getString(c, null);
if (string == null) {
this.c = fOS.c();
this.d.edit().putString(c, this.c.toString()).commit();
} else {
this.c = fOS.e(string);
}
if (this.c != null) {
} else {
throw new GeneralSecurityException("Problem generating Key");
}
} catch (GeneralSecurityException e2) {
throw new IllegalStateException(e2);
}
}
private static String d(Context context) {
try {
String str = (String) Build.class.getField("SERIAL").get(null);
return TextUtils.isEmpty(str) ? Settings.Secure.getString(context.getContentResolver(), "android_id") : str;
} catch (Exception unused) {
return Settings.Secure.getString(context.getContentResolver(), "android_id");
}
}
public static String c(String str) {
try {
MessageDigest messageDigest = MessageDigest.getInstance(McElieceCCA2KeyGenParameterSpec.SHA256);
byte[] bytes = str.getBytes("UTF-8");
messageDigest.update(bytes, 0, bytes.length);
return Base64.encodeToString(messageDigest.digest(), 2);
} catch (UnsupportedEncodingException | NoSuchAlgorithmException unused) {
return null;
}
}
final String e(String str) {
if (TextUtils.isEmpty(str)) {
return str;
}
try {
return fOS.d(str, this.c).toString();
} catch (UnsupportedEncodingException | GeneralSecurityException unused) {
return null;
}
}
private String b(String str) {
if (TextUtils.isEmpty(str)) {
return str;
}
try {
return fOS.d(new fOS.RVV(str), this.c);
} catch (UnsupportedEncodingException | GeneralSecurityException unused) {
return null;
}
}
@Override // android.content.SharedPreferences
public Map<String, String> getAll() {
Map<String, ?> all = this.d.getAll();
HashMap hashMap = new HashMap(all.size());
for (Map.Entry<String, ?> entry : all.entrySet()) {
try {
Object value = entry.getValue();
if (value != null && !value.equals(this.c.toString())) {
hashMap.put(entry.getKey(), b(value.toString()));
}
} catch (Exception unused) {
hashMap.put(entry.getKey(), entry.getValue().toString());
}
}
return hashMap;
}
@Override // android.content.SharedPreferences
public String getString(String str, String str2) {
String string = this.d.getString(c(str), null);
String b = b(string);
return (string == null || b == null) ? str2 : b;
}
@Override // android.content.SharedPreferences
public Set<String> getStringSet(String str, Set<String> set) {
Set<String> stringSet = this.d.getStringSet(c(str), null);
if (stringSet == null) {
return set;
}
HashSet hashSet = new HashSet(stringSet.size());
Iterator<String> it = stringSet.iterator();
while (it.hasNext()) {
hashSet.add(b(it.next()));
}
return hashSet;
}
@Override // android.content.SharedPreferences
public int getInt(String str, int i) {
String string = this.d.getString(c(str), null);
if (string == null) {
return i;
}
try {
return Integer.parseInt(b(string));
} catch (NumberFormatException e) {
throw new ClassCastException(e.getMessage());
}
}
@Override // android.content.SharedPreferences
public long getLong(String str, long j) {
String string = this.d.getString(c(str), null);
if (string == null) {
return j;
}
try {
return Long.parseLong(b(string));
} catch (NumberFormatException e) {
throw new ClassCastException(e.getMessage());
}
}
@Override // android.content.SharedPreferences
public float getFloat(String str, float f) {
String string = this.d.getString(c(str), null);
if (string == null) {
return f;
}
try {
return Float.parseFloat(b(string));
} catch (NumberFormatException e) {
throw new ClassCastException(e.getMessage());
}
}
@Override // android.content.SharedPreferences
public boolean getBoolean(String str, boolean z) {
String string = this.d.getString(c(str), null);
if (string == null) {
return z;
}
try {
return Boolean.parseBoolean(b(string));
} catch (NumberFormatException e) {
throw new ClassCastException(e.getMessage());
}
}
@Override // android.content.SharedPreferences
public boolean contains(String str) {
return this.d.contains(c(str));
}
/* renamed from: o.fMf$RVV */
/* loaded from: classes.dex */
public final class RVV implements SharedPreferences.Editor {
private SharedPreferences.Editor a;
private SharedPreferencesC12958fMf b;
/* synthetic */ RVV(SharedPreferencesC12958fMf sharedPreferencesC12958fMf, byte b) {
this(sharedPreferencesC12958fMf);
}
private RVV(SharedPreferencesC12958fMf sharedPreferencesC12958fMf) {
this.b = sharedPreferencesC12958fMf;
this.a = sharedPreferencesC12958fMf.d.edit();
}
@Override // android.content.SharedPreferences.Editor
public final SharedPreferences.Editor putString(String str, String str2) {
this.a.putString(SharedPreferencesC12958fMf.c(str), this.b.e(str2));
return this;
}
@Override // android.content.SharedPreferences.Editor
public final SharedPreferences.Editor putStringSet(String str, Set<String> set) {
HashSet hashSet = new HashSet(set.size());
Iterator<String> it = set.iterator();
while (it.hasNext()) {
hashSet.add(this.b.e(it.next()));
}
this.a.putStringSet(SharedPreferencesC12958fMf.c(str), hashSet);
return this;
}
@Override // android.content.SharedPreferences.Editor
public final SharedPreferences.Editor putInt(String str, int i) {
this.a.putString(SharedPreferencesC12958fMf.c(str), this.b.e(Integer.toString(i)));
return this;
}
@Override // android.content.SharedPreferences.Editor
public final SharedPreferences.Editor putLong(String str, long j) {
this.a.putString(SharedPreferencesC12958fMf.c(str), this.b.e(Long.toString(j)));
return this;
}
@Override // android.content.SharedPreferences.Editor
public final SharedPreferences.Editor putFloat(String str, float f) {
this.a.putString(SharedPreferencesC12958fMf.c(str), this.b.e(Float.toString(f)));
return this;
}
@Override // android.content.SharedPreferences.Editor
public final SharedPreferences.Editor putBoolean(String str, boolean z) {
this.a.putString(SharedPreferencesC12958fMf.c(str), this.b.e(Boolean.toString(z)));
return this;
}
@Override // android.content.SharedPreferences.Editor
public final SharedPreferences.Editor remove(String str) {
this.a.remove(SharedPreferencesC12958fMf.c(str));
return this;
}
@Override // android.content.SharedPreferences.Editor
public final SharedPreferences.Editor clear() {
this.a.clear();
return this;
}
@Override // android.content.SharedPreferences.Editor
public final boolean commit() {
return this.a.commit();
}
@Override // android.content.SharedPreferences.Editor
public final void apply() {
this.a.apply();
}
}
@Override // android.content.SharedPreferences
public void registerOnSharedPreferenceChangeListener(SharedPreferences.OnSharedPreferenceChangeListener onSharedPreferenceChangeListener) {
this.d.registerOnSharedPreferenceChangeListener(onSharedPreferenceChangeListener);
}
@Override // android.content.SharedPreferences
public void unregisterOnSharedPreferenceChangeListener(SharedPreferences.OnSharedPreferenceChangeListener onSharedPreferenceChangeListener) {
this.d.unregisterOnSharedPreferenceChangeListener(onSharedPreferenceChangeListener);
}
@Override // android.content.SharedPreferences
public /* synthetic */ SharedPreferences.Editor edit() {
return new RVV(this, (byte) 0);
}
}