package androidx.lifecycle; import android.os.Binder; import android.os.Bundle; import android.os.Parcelable; import android.util.Size; import android.util.SizeF; import android.util.SparseArray; import androidx.savedstate.SavedStateRegistry; import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Set; /* loaded from: classes.dex */ public final class r { /* renamed from: e, reason: collision with root package name */ private static final Class[] f2107e = {Boolean.TYPE, boolean[].class, Double.TYPE, double[].class, Integer.TYPE, int[].class, Long.TYPE, long[].class, String.class, String[].class, Binder.class, Bundle.class, Byte.TYPE, byte[].class, Character.TYPE, char[].class, CharSequence.class, CharSequence[].class, ArrayList.class, Float.TYPE, float[].class, Parcelable.class, Parcelable[].class, Serializable.class, Short.TYPE, short[].class, SparseArray.class, Size.class, SizeF.class}; /* renamed from: a, reason: collision with root package name */ final Map f2108a; /* renamed from: b, reason: collision with root package name */ final Map f2109b; /* renamed from: c, reason: collision with root package name */ private final Map f2110c; /* renamed from: d, reason: collision with root package name */ private final SavedStateRegistry.b f2111d; class a implements SavedStateRegistry.b { a() { } @Override // androidx.savedstate.SavedStateRegistry.b public Bundle a() { for (Map.Entry entry : new HashMap(r.this.f2109b).entrySet()) { r.this.c((String) entry.getKey(), ((SavedStateRegistry.b) entry.getValue()).a()); } Set keySet = r.this.f2108a.keySet(); ArrayList arrayList = new ArrayList<>(keySet.size()); ArrayList arrayList2 = new ArrayList<>(arrayList.size()); for (String str : keySet) { arrayList.add(str); arrayList2.add(r.this.f2108a.get(str)); } Bundle bundle = new Bundle(); bundle.putParcelableArrayList("keys", arrayList); bundle.putParcelableArrayList("values", arrayList2); return bundle; } } public r(Map map) { this.f2109b = new HashMap(); this.f2110c = new HashMap(); this.f2111d = new a(); this.f2108a = new HashMap(map); } static r a(Bundle bundle, Bundle bundle2) { if (bundle == null && bundle2 == null) { return new r(); } HashMap hashMap = new HashMap(); if (bundle2 != null) { for (String str : bundle2.keySet()) { hashMap.put(str, bundle2.get(str)); } } if (bundle == null) { return new r(hashMap); } ArrayList parcelableArrayList = bundle.getParcelableArrayList("keys"); ArrayList parcelableArrayList2 = bundle.getParcelableArrayList("values"); if (parcelableArrayList == null || parcelableArrayList2 == null || parcelableArrayList.size() != parcelableArrayList2.size()) { throw new IllegalStateException("Invalid bundle passed as restored state"); } for (int i10 = 0; i10 < parcelableArrayList.size(); i10++) { hashMap.put((String) parcelableArrayList.get(i10), parcelableArrayList2.get(i10)); } return new r(hashMap); } private static void d(Object obj) { if (obj == null) { return; } for (Class cls : f2107e) { if (cls.isInstance(obj)) { return; } } throw new IllegalArgumentException("Can't put value with type " + obj.getClass() + " into saved state"); } SavedStateRegistry.b b() { return this.f2111d; } public void c(String str, Object obj) { d(obj); m mVar = (m) this.f2110c.get(str); if (mVar != null) { mVar.n(obj); } else { this.f2108a.put(str, obj); } } public r() { this.f2109b = new HashMap(); this.f2110c = new HashMap(); this.f2111d = new a(); this.f2108a = new HashMap(); } }