package androidx.lifecycle; import androidx.lifecycle.AbstractC0424i; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @Deprecated /* renamed from: androidx.lifecycle.a */ /* loaded from: classes.dex */ public final class C0397a { /* renamed from: c */ public static C0397a f1603c = new C0397a(); /* renamed from: a */ public final Map, C0398a> f1604a = new HashMap(); /* renamed from: b */ public final Map, Boolean> f1605b = new HashMap(); @Deprecated /* renamed from: androidx.lifecycle.a$a */ /* loaded from: classes.dex */ public static class C0398a { /* renamed from: a */ public final Map> f1606a = new HashMap(); /* renamed from: b */ public final Map f1607b; public C0398a(Map map) { this.f1607b = map; for (Map.Entry entry : map.entrySet()) { AbstractC0424i.EnumC0426b value = entry.getValue(); List list = this.f1606a.get(value); if (list == null) { list = new ArrayList<>(); this.f1606a.put(value, list); } list.add(entry.getKey()); } } /* renamed from: b */ public static void m3734b(List list, InterfaceC0434m interfaceC0434m, AbstractC0424i.EnumC0426b enumC0426b, Object obj) { if (list != null) { for (int size = list.size() - 1; size >= 0; size--) { list.get(size).m3733a(interfaceC0434m, enumC0426b, obj); } } } /* renamed from: a */ public void m3735a(InterfaceC0434m interfaceC0434m, AbstractC0424i.EnumC0426b enumC0426b, Object obj) { m3734b(this.f1606a.get(enumC0426b), interfaceC0434m, enumC0426b, obj); m3734b(this.f1606a.get(AbstractC0424i.EnumC0426b.ON_ANY), interfaceC0434m, enumC0426b, obj); } } @Deprecated /* renamed from: androidx.lifecycle.a$b */ /* loaded from: classes.dex */ public static final class C0399b { /* renamed from: a */ public final int f1608a; /* renamed from: b */ public final Method f1609b; public C0399b(int i, Method method) { this.f1608a = i; this.f1609b = method; method.setAccessible(true); } /* renamed from: a */ public void m3733a(InterfaceC0434m interfaceC0434m, AbstractC0424i.EnumC0426b enumC0426b, Object obj) { try { int i = this.f1608a; if (i == 0) { this.f1609b.invoke(obj, new Object[0]); } else if (i == 1) { this.f1609b.invoke(obj, interfaceC0434m); } else if (i != 2) { } else { this.f1609b.invoke(obj, interfaceC0434m, enumC0426b); } } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e2) { throw new RuntimeException("Failed to call observer method", e2.getCause()); } } public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof C0399b) { C0399b c0399b = (C0399b) obj; return this.f1608a == c0399b.f1608a && this.f1609b.getName().equals(c0399b.f1609b.getName()); } return false; } public int hashCode() { return (this.f1608a * 31) + this.f1609b.getName().hashCode(); } } /* renamed from: a */ public final C0398a m3740a(Class cls, Method[] methodArr) { int i; C0398a m3738c; Class superclass = cls.getSuperclass(); HashMap hashMap = new HashMap(); if (superclass != null && (m3738c = m3738c(superclass)) != null) { hashMap.putAll(m3738c.f1607b); } for (Class cls2 : cls.getInterfaces()) { for (Map.Entry entry : m3738c(cls2).f1607b.entrySet()) { m3736e(hashMap, entry.getKey(), entry.getValue(), cls); } } if (methodArr == null) { methodArr = m3739b(cls); } boolean z = false; for (Method method : methodArr) { InterfaceC0442t interfaceC0442t = (InterfaceC0442t) method.getAnnotation(InterfaceC0442t.class); if (interfaceC0442t != null) { Class[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length <= 0) { i = 0; } else if (!parameterTypes[0].isAssignableFrom(InterfaceC0434m.class)) { throw new IllegalArgumentException("invalid parameter type. Must be one and instanceof LifecycleOwner"); } else { i = 1; } AbstractC0424i.EnumC0426b value = interfaceC0442t.value(); if (parameterTypes.length > 1) { if (!parameterTypes[1].isAssignableFrom(AbstractC0424i.EnumC0426b.class)) { throw new IllegalArgumentException("invalid parameter type. second arg must be an event"); } if (value != AbstractC0424i.EnumC0426b.ON_ANY) { throw new IllegalArgumentException("Second arg is supported only for ON_ANY value"); } i = 2; } if (parameterTypes.length > 2) { throw new IllegalArgumentException("cannot have more than 2 params"); } m3736e(hashMap, new C0399b(i, method), value, cls); z = true; } } C0398a c0398a = new C0398a(hashMap); this.f1604a.put(cls, c0398a); this.f1605b.put(cls, Boolean.valueOf(z)); return c0398a; } /* renamed from: b */ public final Method[] m3739b(Class cls) { try { return cls.getDeclaredMethods(); } catch (NoClassDefFoundError e) { throw new IllegalArgumentException("The observer class has some methods that use newer APIs which are not available in the current OS version. Lifecycles cannot access even other methods so you should make sure that your observer classes only access framework classes that are available in your min API level OR use lifecycle:compiler annotation processor.", e); } } /* renamed from: c */ public C0398a m3738c(Class cls) { C0398a c0398a = this.f1604a.get(cls); return c0398a != null ? c0398a : m3740a(cls, null); } /* renamed from: d */ public boolean m3737d(Class cls) { Boolean bool = this.f1605b.get(cls); if (bool != null) { return bool.booleanValue(); } Method[] m3739b = m3739b(cls); for (Method method : m3739b) { if (((InterfaceC0442t) method.getAnnotation(InterfaceC0442t.class)) != null) { m3740a(cls, m3739b); return true; } } this.f1605b.put(cls, Boolean.FALSE); return false; } /* renamed from: e */ public final void m3736e(Map map, C0399b c0399b, AbstractC0424i.EnumC0426b enumC0426b, Class cls) { AbstractC0424i.EnumC0426b enumC0426b2 = map.get(c0399b); if (enumC0426b2 == null || enumC0426b == enumC0426b2) { if (enumC0426b2 == null) { map.put(c0399b, enumC0426b); return; } return; } Method method = c0399b.f1609b; throw new IllegalArgumentException("Method " + method.getName() + " in " + cls.getName() + " already declared with different @OnLifecycleEvent value: previous value " + enumC0426b2 + ", new value " + enumC0426b); } }