Initial commit
This commit is contained in:
307
sources/com/tencent/mm/opensdk/openapi/MMSharedPreferences.java
Normal file
307
sources/com/tencent/mm/opensdk/openapi/MMSharedPreferences.java
Normal file
@@ -0,0 +1,307 @@
|
||||
package com.tencent.mm.opensdk.openapi;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import com.liulishuo.filedownloader.model.FileDownloadModel;
|
||||
import com.tencent.mm.opensdk.utils.Log;
|
||||
import com.tencent.mm.opensdk.utils.c;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class MMSharedPreferences implements SharedPreferences {
|
||||
private static final String TAG = "MicroMsg.SDK.SharedPreferences";
|
||||
private final ContentResolver cr;
|
||||
private final String[] columns = {FileDownloadModel.ID, "key", "type", "value"};
|
||||
private final HashMap<String, Object> values = new HashMap<>();
|
||||
private REditor editor = null;
|
||||
|
||||
private static class REditor implements SharedPreferences.Editor {
|
||||
private ContentResolver cr;
|
||||
private Map<String, Object> values = new HashMap();
|
||||
private Set<String> remove = new HashSet();
|
||||
private boolean clear = false;
|
||||
|
||||
public REditor(ContentResolver contentResolver) {
|
||||
this.cr = contentResolver;
|
||||
}
|
||||
|
||||
@Override // android.content.SharedPreferences.Editor
|
||||
public void apply() {
|
||||
}
|
||||
|
||||
@Override // android.content.SharedPreferences.Editor
|
||||
public SharedPreferences.Editor clear() {
|
||||
this.clear = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/* JADX WARN: Removed duplicated region for block: B:17:0x0097 */
|
||||
/* JADX WARN: Removed duplicated region for block: B:19:0x00ae A[SYNTHETIC] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:23:0x003f A[SYNTHETIC] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:24:0x0099 */
|
||||
@Override // android.content.SharedPreferences.Editor
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public boolean commit() {
|
||||
/*
|
||||
r10 = this;
|
||||
android.content.ContentValues r0 = new android.content.ContentValues
|
||||
r0.<init>()
|
||||
boolean r1 = r10.clear
|
||||
r2 = 0
|
||||
if (r1 == 0) goto L14
|
||||
android.content.ContentResolver r1 = r10.cr
|
||||
android.net.Uri r3 = com.tencent.mm.opensdk.utils.c.b.CONTENT_URI
|
||||
r4 = 0
|
||||
r1.delete(r3, r4, r4)
|
||||
r10.clear = r2
|
||||
L14:
|
||||
java.util.Set<java.lang.String> r1 = r10.remove
|
||||
java.util.Iterator r1 = r1.iterator()
|
||||
L1a:
|
||||
boolean r3 = r1.hasNext()
|
||||
java.lang.String r4 = "key = ?"
|
||||
r5 = 1
|
||||
if (r3 == 0) goto L35
|
||||
java.lang.Object r3 = r1.next()
|
||||
java.lang.String r3 = (java.lang.String) r3
|
||||
android.content.ContentResolver r6 = r10.cr
|
||||
android.net.Uri r7 = com.tencent.mm.opensdk.utils.c.b.CONTENT_URI
|
||||
java.lang.String[] r5 = new java.lang.String[r5]
|
||||
r5[r2] = r3
|
||||
r6.delete(r7, r4, r5)
|
||||
goto L1a
|
||||
L35:
|
||||
java.util.Map<java.lang.String, java.lang.Object> r1 = r10.values
|
||||
java.util.Set r1 = r1.entrySet()
|
||||
java.util.Iterator r1 = r1.iterator()
|
||||
L3f:
|
||||
boolean r3 = r1.hasNext()
|
||||
if (r3 == 0) goto Lc1
|
||||
java.lang.Object r3 = r1.next()
|
||||
java.util.Map$Entry r3 = (java.util.Map.Entry) r3
|
||||
java.lang.Object r6 = r3.getValue()
|
||||
java.lang.String r7 = "MicroMsg.SDK.PluginProvider.Resolver"
|
||||
if (r6 != 0) goto L5a
|
||||
java.lang.String r8 = "unresolve failed, null value"
|
||||
L55:
|
||||
com.tencent.mm.opensdk.utils.Log.e(r7, r8)
|
||||
r7 = 0
|
||||
goto L95
|
||||
L5a:
|
||||
boolean r8 = r6 instanceof java.lang.Integer
|
||||
if (r8 == 0) goto L60
|
||||
r7 = 1
|
||||
goto L95
|
||||
L60:
|
||||
boolean r8 = r6 instanceof java.lang.Long
|
||||
if (r8 == 0) goto L66
|
||||
r7 = 2
|
||||
goto L95
|
||||
L66:
|
||||
boolean r8 = r6 instanceof java.lang.String
|
||||
if (r8 == 0) goto L6c
|
||||
r7 = 3
|
||||
goto L95
|
||||
L6c:
|
||||
boolean r8 = r6 instanceof java.lang.Boolean
|
||||
if (r8 == 0) goto L72
|
||||
r7 = 4
|
||||
goto L95
|
||||
L72:
|
||||
boolean r8 = r6 instanceof java.lang.Float
|
||||
if (r8 == 0) goto L78
|
||||
r7 = 5
|
||||
goto L95
|
||||
L78:
|
||||
boolean r8 = r6 instanceof java.lang.Double
|
||||
if (r8 == 0) goto L7e
|
||||
r7 = 6
|
||||
goto L95
|
||||
L7e:
|
||||
java.lang.StringBuilder r8 = new java.lang.StringBuilder
|
||||
java.lang.String r9 = "unresolve failed, unknown type="
|
||||
r8.<init>(r9)
|
||||
java.lang.Class r9 = r6.getClass()
|
||||
java.lang.String r9 = r9.toString()
|
||||
r8.append(r9)
|
||||
java.lang.String r8 = r8.toString()
|
||||
goto L55
|
||||
L95:
|
||||
if (r7 != 0) goto L99
|
||||
r6 = 0
|
||||
goto Lac
|
||||
L99:
|
||||
java.lang.Integer r7 = java.lang.Integer.valueOf(r7)
|
||||
java.lang.String r8 = "type"
|
||||
r0.put(r8, r7)
|
||||
java.lang.String r6 = r6.toString()
|
||||
java.lang.String r7 = "value"
|
||||
r0.put(r7, r6)
|
||||
r6 = 1
|
||||
Lac:
|
||||
if (r6 == 0) goto L3f
|
||||
android.content.ContentResolver r6 = r10.cr
|
||||
android.net.Uri r7 = com.tencent.mm.opensdk.utils.c.b.CONTENT_URI
|
||||
java.lang.String[] r8 = new java.lang.String[r5]
|
||||
java.lang.Object r3 = r3.getKey()
|
||||
java.lang.String r3 = (java.lang.String) r3
|
||||
r8[r2] = r3
|
||||
r6.update(r7, r0, r4, r8)
|
||||
goto L3f
|
||||
Lc1:
|
||||
return r5
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.opensdk.openapi.MMSharedPreferences.REditor.commit():boolean");
|
||||
}
|
||||
|
||||
@Override // android.content.SharedPreferences.Editor
|
||||
public SharedPreferences.Editor putBoolean(String str, boolean z) {
|
||||
this.values.put(str, Boolean.valueOf(z));
|
||||
this.remove.remove(str);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.content.SharedPreferences.Editor
|
||||
public SharedPreferences.Editor putFloat(String str, float f) {
|
||||
this.values.put(str, Float.valueOf(f));
|
||||
this.remove.remove(str);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.content.SharedPreferences.Editor
|
||||
public SharedPreferences.Editor putInt(String str, int i) {
|
||||
this.values.put(str, Integer.valueOf(i));
|
||||
this.remove.remove(str);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.content.SharedPreferences.Editor
|
||||
public SharedPreferences.Editor putLong(String str, long j) {
|
||||
this.values.put(str, Long.valueOf(j));
|
||||
this.remove.remove(str);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.content.SharedPreferences.Editor
|
||||
public SharedPreferences.Editor putString(String str, String str2) {
|
||||
this.values.put(str, str2);
|
||||
this.remove.remove(str);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.content.SharedPreferences.Editor
|
||||
public SharedPreferences.Editor putStringSet(String str, Set<String> set) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // android.content.SharedPreferences.Editor
|
||||
public SharedPreferences.Editor remove(String str) {
|
||||
this.remove.add(str);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public MMSharedPreferences(Context context) {
|
||||
this.cr = context.getContentResolver();
|
||||
}
|
||||
|
||||
private Object getValue(String str) {
|
||||
try {
|
||||
Cursor query = this.cr.query(c.b.CONTENT_URI, this.columns, "key = ?", new String[]{str}, null);
|
||||
if (query == null) {
|
||||
return null;
|
||||
}
|
||||
Object a = query.moveToFirst() ? c.a.a(query.getInt(query.getColumnIndex("type")), query.getString(query.getColumnIndex("value"))) : null;
|
||||
query.close();
|
||||
return a;
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "getValue exception:" + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.content.SharedPreferences
|
||||
public boolean contains(String str) {
|
||||
return getValue(str) != null;
|
||||
}
|
||||
|
||||
@Override // android.content.SharedPreferences
|
||||
public SharedPreferences.Editor edit() {
|
||||
if (this.editor == null) {
|
||||
this.editor = new REditor(this.cr);
|
||||
}
|
||||
return this.editor;
|
||||
}
|
||||
|
||||
@Override // android.content.SharedPreferences
|
||||
public Map<String, ?> getAll() {
|
||||
try {
|
||||
Cursor query = this.cr.query(c.b.CONTENT_URI, this.columns, null, null, null);
|
||||
if (query == null) {
|
||||
return null;
|
||||
}
|
||||
int columnIndex = query.getColumnIndex("key");
|
||||
int columnIndex2 = query.getColumnIndex("type");
|
||||
int columnIndex3 = query.getColumnIndex("value");
|
||||
while (query.moveToNext()) {
|
||||
this.values.put(query.getString(columnIndex), c.a.a(query.getInt(columnIndex2), query.getString(columnIndex3)));
|
||||
}
|
||||
query.close();
|
||||
return this.values;
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "getAll exception:" + e.getMessage());
|
||||
return this.values;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.content.SharedPreferences
|
||||
public boolean getBoolean(String str, boolean z) {
|
||||
Object value = getValue(str);
|
||||
return (value == null || !(value instanceof Boolean)) ? z : ((Boolean) value).booleanValue();
|
||||
}
|
||||
|
||||
@Override // android.content.SharedPreferences
|
||||
public float getFloat(String str, float f) {
|
||||
Object value = getValue(str);
|
||||
return (value == null || !(value instanceof Float)) ? f : ((Float) value).floatValue();
|
||||
}
|
||||
|
||||
@Override // android.content.SharedPreferences
|
||||
public int getInt(String str, int i) {
|
||||
Object value = getValue(str);
|
||||
return (value == null || !(value instanceof Integer)) ? i : ((Integer) value).intValue();
|
||||
}
|
||||
|
||||
@Override // android.content.SharedPreferences
|
||||
public long getLong(String str, long j) {
|
||||
Object value = getValue(str);
|
||||
return (value == null || !(value instanceof Long)) ? j : ((Long) value).longValue();
|
||||
}
|
||||
|
||||
@Override // android.content.SharedPreferences
|
||||
public String getString(String str, String str2) {
|
||||
Object value = getValue(str);
|
||||
return (value == null || !(value instanceof String)) ? str2 : (String) value;
|
||||
}
|
||||
|
||||
@Override // android.content.SharedPreferences
|
||||
public Set<String> getStringSet(String str, Set<String> set) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // android.content.SharedPreferences
|
||||
public void registerOnSharedPreferenceChangeListener(SharedPreferences.OnSharedPreferenceChangeListener onSharedPreferenceChangeListener) {
|
||||
}
|
||||
|
||||
@Override // android.content.SharedPreferences
|
||||
public void unregisterOnSharedPreferenceChangeListener(SharedPreferences.OnSharedPreferenceChangeListener onSharedPreferenceChangeListener) {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user