Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
package com.squareup.haha.guava.base;
/* loaded from: classes.dex */
public interface Function<F, T> {
T apply(F f);
}

View File

@@ -0,0 +1,211 @@
package com.squareup.haha.guava.base;
import com.squareup.haha.guava.collect.ImmutableList;
import com.squareup.haha.guava.collect.Iterators;
import com.squareup.haha.guava.collect.Lists$RandomAccessReverseList;
import com.squareup.haha.guava.collect.Lists$ReverseList;
import com.squareup.haha.guava.collect.Multiset;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.RandomAccess;
import java.util.Set;
/* loaded from: classes.dex */
public class Joiner {
private final String separator;
public static final class MapJoiner {
public /* synthetic */ MapJoiner(Joiner joiner, String str, byte b) {
this(joiner, str);
}
private MapJoiner(Joiner joiner, String str) {
Joiner.checkNotNull(str);
}
}
/* synthetic */ Joiner(Joiner joiner, byte b) {
this(joiner);
}
static String badPositionIndex(int i, int i2, String str) {
if (i < 0) {
return format("%s (%s) must not be negative", str, Integer.valueOf(i));
}
if (i2 >= 0) {
return format("%s (%s) must not be greater than size (%s)", str, Integer.valueOf(i), Integer.valueOf(i2));
}
throw new IllegalArgumentException("negative size: " + i2);
}
public static void checkArgument(boolean z) {
if (!z) {
throw new IllegalArgumentException();
}
}
public static int checkElementIndex(int i, int i2) {
String format;
if (i >= 0 && i < i2) {
return i;
}
if (i < 0) {
format = format("%s (%s) must not be negative", "index", Integer.valueOf(i));
} else {
if (i2 < 0) {
throw new IllegalArgumentException("negative size: " + i2);
}
format = format("%s (%s) must be less than size (%s)", "index", Integer.valueOf(i), Integer.valueOf(i2));
}
throw new IndexOutOfBoundsException(format);
}
public static <T> T checkNotNull(T t) {
if (t != null) {
return t;
}
throw new NullPointerException();
}
public static int checkPositionIndex(int i, int i2) {
if (i < 0 || i > i2) {
throw new IndexOutOfBoundsException(badPositionIndex(i, i2, "index"));
}
return i;
}
public static void checkPositionIndexes(int i, int i2, int i3) {
if (i < 0 || i2 < i || i2 > i3) {
throw new IndexOutOfBoundsException((i < 0 || i > i3) ? badPositionIndex(i, i3, "start index") : (i2 < 0 || i2 > i3) ? badPositionIndex(i2, i3, "end index") : format("end index (%s) must not be less than start index (%s)", Integer.valueOf(i2), Integer.valueOf(i)));
}
}
public static void checkRemove(boolean z) {
if (!z) {
throw new IllegalStateException("no calls to next() since the last call to remove()");
}
}
public static boolean equal(Object obj, Object obj2) {
if (obj != obj2) {
return obj != null && obj.equals(obj2);
}
return true;
}
public static boolean equalsImpl(Set<?> set, Object obj) {
if (set == obj) {
return true;
}
if (obj instanceof Set) {
Set set2 = (Set) obj;
try {
if (set.size() == set2.size()) {
if (set.containsAll(set2)) {
return true;
}
}
} catch (ClassCastException | NullPointerException unused) {
}
}
return false;
}
static String format(String str, Object... objArr) {
int indexOf;
String valueOf = String.valueOf(str);
StringBuilder sb = new StringBuilder(valueOf.length() + (objArr.length * 16));
int i = 0;
int i2 = 0;
while (i < objArr.length && (indexOf = valueOf.indexOf("%s", i2)) != -1) {
sb.append(valueOf.substring(i2, indexOf));
sb.append(objArr[i]);
i2 = indexOf + 2;
i++;
}
sb.append(valueOf.substring(i2));
if (i < objArr.length) {
sb.append(" [");
sb.append(objArr[i]);
for (int i3 = i + 1; i3 < objArr.length; i3++) {
sb.append(", ");
sb.append(objArr[i3]);
}
sb.append(']');
}
return sb.toString();
}
public static boolean removeAllImpl(Set<?> set, Iterator<?> it) {
boolean z = false;
while (it.hasNext()) {
z |= set.remove(it.next());
}
return z;
}
public static <T> List<T> reverse(List<T> list) {
return list instanceof ImmutableList ? ((ImmutableList) list).reverse() : list instanceof Lists$ReverseList ? ((Lists$ReverseList) list).forwardList : list instanceof RandomAccess ? new Lists$RandomAccessReverseList(list) : new Lists$ReverseList(list);
}
public final StringBuilder appendTo(StringBuilder sb, Iterator<?> it) {
try {
checkNotNull(sb);
if (it.hasNext()) {
sb.append(toString(it.next()));
while (it.hasNext()) {
sb.append((CharSequence) this.separator);
sb.append(toString(it.next()));
}
}
return sb;
} catch (IOException e) {
throw new AssertionError(e);
}
}
CharSequence toString(Object obj) {
checkNotNull(obj);
return obj instanceof CharSequence ? (CharSequence) obj : obj.toString();
}
public Joiner useForNull(final String str) {
checkNotNull(str);
return new Joiner(this) { // from class: com.squareup.haha.guava.base.Joiner.1
{
byte b = 0;
}
@Override // com.squareup.haha.guava.base.Joiner
final CharSequence toString(Object obj) {
return obj == null ? str : Joiner.this.toString(obj);
}
@Override // com.squareup.haha.guava.base.Joiner
public final Joiner useForNull(String str2) {
throw new UnsupportedOperationException("already specified useForNull");
}
};
}
public Joiner(String str) {
this.separator = (String) checkNotNull(str);
}
public static boolean removeAllImpl(Set<?> set, Collection<?> collection) {
checkNotNull(collection);
if (collection instanceof Multiset) {
collection = ((Multiset) collection).elementSet();
}
if ((collection instanceof Set) && collection.size() > set.size()) {
return Iterators.removeAll(set.iterator(), collection);
}
return removeAllImpl(set, collection.iterator());
}
private Joiner(Joiner joiner) {
this.separator = joiner.separator;
}
}

View File

@@ -0,0 +1,6 @@
package com.squareup.haha.guava.base;
/* loaded from: classes.dex */
public interface Predicate<T> {
boolean apply(T t);
}

View File

@@ -0,0 +1,52 @@
package com.squareup.haha.guava.base;
import java.io.Serializable;
import java.util.Collection;
/* loaded from: classes.dex */
public final class Predicates {
static class InPredicate<T> implements Predicate<T>, Serializable {
private final Collection<?> target;
/* synthetic */ InPredicate(Collection collection, byte b) {
this(collection);
}
@Override // com.squareup.haha.guava.base.Predicate
public final boolean apply(T t) {
try {
return this.target.contains(t);
} catch (ClassCastException | NullPointerException unused) {
return false;
}
}
public final boolean equals(Object obj) {
if (obj instanceof InPredicate) {
return this.target.equals(((InPredicate) obj).target);
}
return false;
}
public final int hashCode() {
return this.target.hashCode();
}
public final String toString() {
return "Predicates.in(" + this.target + ")";
}
private InPredicate(Collection<?> collection) {
this.target = (Collection) Joiner.checkNotNull(collection);
}
}
static {
new Joiner(",");
}
public static <T> Predicate<T> in(Collection<? extends T> collection) {
return new InPredicate(collection, (byte) 0);
}
}

View File

@@ -0,0 +1,58 @@
package com.squareup.haha.guava.collect;
import com.squareup.haha.guava.base.Joiner;
import java.util.NoSuchElementException;
/* loaded from: classes.dex */
abstract class AbstractIndexedListIterator<E> extends UnmodifiableListIterator<E> {
private int position;
private final int size;
protected AbstractIndexedListIterator(int i, int i2) {
Joiner.checkPositionIndex(i2, i);
this.size = i;
this.position = i2;
}
protected abstract E get(int i);
@Override // java.util.Iterator, java.util.ListIterator
public final boolean hasNext() {
return this.position < this.size;
}
@Override // java.util.ListIterator
public final boolean hasPrevious() {
return this.position > 0;
}
@Override // java.util.Iterator, java.util.ListIterator
public final E next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
int i = this.position;
this.position = i + 1;
return get(i);
}
@Override // java.util.ListIterator
public final int nextIndex() {
return this.position;
}
@Override // java.util.ListIterator
public final E previous() {
if (!hasPrevious()) {
throw new NoSuchElementException();
}
int i = this.position - 1;
this.position = i;
return get(i);
}
@Override // java.util.ListIterator
public final int previousIndex() {
return this.position - 1;
}
}

View File

@@ -0,0 +1,42 @@
package com.squareup.haha.guava.collect;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/* loaded from: classes.dex */
abstract class AbstractListMultimap<K, V> extends AbstractMapBasedMultimap<K, V> implements ListMultimap<K, V> {
protected AbstractListMultimap(Map<K, Collection<V>> map) {
super(map);
}
@Override // com.squareup.haha.guava.collect.AbstractMultimap, com.squareup.haha.guava.collect.Multimap
public Map<K, Collection<V>> asMap() {
return super.asMap();
}
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.squareup.haha.guava.collect.AbstractMapBasedMultimap
public abstract List<V> createCollection();
@Override // com.squareup.haha.guava.collect.AbstractMultimap
public boolean equals(Object obj) {
return super.equals(obj);
}
/* JADX WARN: Multi-variable type inference failed */
@Override // com.squareup.haha.guava.collect.AbstractMapBasedMultimap, com.squareup.haha.guava.collect.Multimap
public final /* bridge */ /* synthetic */ Collection get(Object obj) {
return get((AbstractListMultimap<K, V>) obj);
}
@Override // com.squareup.haha.guava.collect.AbstractMapBasedMultimap, com.squareup.haha.guava.collect.AbstractMultimap, com.squareup.haha.guava.collect.Multimap
public boolean put(K k, V v) {
return super.put(k, v);
}
@Override // com.squareup.haha.guava.collect.AbstractMapBasedMultimap, com.squareup.haha.guava.collect.Multimap
public List<V> get(K k) {
return (List) super.get((AbstractListMultimap<K, V>) k);
}
}

View File

@@ -0,0 +1,949 @@
package com.squareup.haha.guava.collect;
import com.squareup.haha.guava.base.Joiner;
import com.squareup.haha.guava.collect.Maps;
import java.io.Serializable;
import java.util.AbstractCollection;
import java.util.Collection;
import java.util.Comparator;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.RandomAccess;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
/* loaded from: classes.dex */
abstract class AbstractMapBasedMultimap<K, V> extends AbstractMultimap<K, V> implements Serializable {
private transient Map<K, Collection<V>> map;
private transient int totalSize;
class AsMap extends Maps.ImprovedAbstractMap<K, Collection<V>> {
final transient Map<K, Collection<V>> submap;
class AsMapEntries extends Maps.EntrySet<K, Collection<V>> {
AsMapEntries() {
}
@Override // com.squareup.haha.guava.collect.Maps.EntrySet, java.util.AbstractCollection, java.util.Collection, java.util.Set
public final boolean contains(Object obj) {
return Collections2.safeContains(AsMap.this.submap.entrySet(), obj);
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
public final Iterator<Map.Entry<K, Collection<V>>> iterator() {
return AsMap.this.new AsMapIterator();
}
@Override // com.squareup.haha.guava.collect.Maps.EntrySet
final Map<K, Collection<V>> map() {
return AsMap.this;
}
@Override // com.squareup.haha.guava.collect.Maps.EntrySet, java.util.AbstractCollection, java.util.Collection, java.util.Set
public final boolean remove(Object obj) {
if (!contains(obj)) {
return false;
}
AbstractMapBasedMultimap.access$400(AbstractMapBasedMultimap.this, ((Map.Entry) obj).getKey());
return true;
}
}
class AsMapIterator implements Iterator<Map.Entry<K, Collection<V>>> {
private Collection<V> collection;
private Iterator<Map.Entry<K, Collection<V>>> delegateIterator;
AsMapIterator() {
this.delegateIterator = AsMap.this.submap.entrySet().iterator();
}
@Override // java.util.Iterator
public final boolean hasNext() {
return this.delegateIterator.hasNext();
}
@Override // java.util.Iterator
public final /* bridge */ /* synthetic */ Object next() {
Map.Entry<K, Collection<V>> next = this.delegateIterator.next();
this.collection = next.getValue();
AsMap asMap = AsMap.this;
K key = next.getKey();
return Maps.immutableEntry(key, AbstractMapBasedMultimap.this.wrapCollection(key, next.getValue()));
}
@Override // java.util.Iterator
public final void remove() {
this.delegateIterator.remove();
AbstractMapBasedMultimap.access$220(AbstractMapBasedMultimap.this, this.collection.size());
this.collection.clear();
}
}
AsMap(Map<K, Collection<V>> map) {
this.submap = map;
}
@Override // java.util.AbstractMap, java.util.Map
public void clear() {
if (this.submap == AbstractMapBasedMultimap.this.map) {
AbstractMapBasedMultimap.this.clear();
} else {
Iterators.clear(new AsMapIterator());
}
}
@Override // java.util.AbstractMap, java.util.Map
public boolean containsKey(Object obj) {
return Maps.safeContainsKey(this.submap, obj);
}
@Override // com.squareup.haha.guava.collect.Maps.ImprovedAbstractMap
protected final Set<Map.Entry<K, Collection<V>>> createEntrySet() {
return new AsMapEntries();
}
@Override // java.util.AbstractMap, java.util.Map
public boolean equals(Object obj) {
return this == obj || this.submap.equals(obj);
}
@Override // java.util.AbstractMap, java.util.Map
public /* bridge */ /* synthetic */ Object get(Object obj) {
Collection<V> collection = (Collection) Maps.safeGet(this.submap, obj);
if (collection == null) {
return null;
}
return AbstractMapBasedMultimap.this.wrapCollection(obj, collection);
}
@Override // java.util.AbstractMap, java.util.Map
public int hashCode() {
return this.submap.hashCode();
}
@Override // com.squareup.haha.guava.collect.Maps.ImprovedAbstractMap, java.util.AbstractMap, java.util.Map
public Set<K> keySet() {
return AbstractMapBasedMultimap.this.keySet();
}
@Override // java.util.AbstractMap, java.util.Map
public /* bridge */ /* synthetic */ Object remove(Object obj) {
Collection<V> remove = this.submap.remove(obj);
if (remove == null) {
return null;
}
Collection<V> createCollection = AbstractMapBasedMultimap.this.createCollection();
createCollection.addAll(remove);
AbstractMapBasedMultimap.access$220(AbstractMapBasedMultimap.this, remove.size());
remove.clear();
return createCollection;
}
@Override // java.util.AbstractMap, java.util.Map
public int size() {
return this.submap.size();
}
@Override // java.util.AbstractMap
public String toString() {
return this.submap.toString();
}
}
abstract class Itr<T> implements Iterator<T> {
private Iterator<Map.Entry<K, Collection<V>>> keyIterator;
private K key = null;
private Collection<V> collection = null;
private Iterator<V> valueIterator = Iterators.emptyModifiableIterator();
Itr() {
this.keyIterator = AbstractMapBasedMultimap.this.map.entrySet().iterator();
}
@Override // java.util.Iterator
public boolean hasNext() {
return this.keyIterator.hasNext() || this.valueIterator.hasNext();
}
@Override // java.util.Iterator
public T next() {
if (!this.valueIterator.hasNext()) {
Map.Entry<K, Collection<V>> next = this.keyIterator.next();
this.key = next.getKey();
this.collection = next.getValue();
this.valueIterator = this.collection.iterator();
}
return output(this.key, this.valueIterator.next());
}
abstract T output(K k, V v);
@Override // java.util.Iterator
public void remove() {
this.valueIterator.remove();
if (this.collection.isEmpty()) {
this.keyIterator.remove();
}
AbstractMapBasedMultimap.access$210(AbstractMapBasedMultimap.this);
}
}
class KeySet extends Maps.KeySet<K, Collection<V>> {
KeySet(Map<K, Collection<V>> map) {
super(map);
}
@Override // com.squareup.haha.guava.collect.Maps.KeySet, java.util.AbstractCollection, java.util.Collection, java.util.Set
public void clear() {
Iterators.clear(iterator());
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean containsAll(Collection<?> collection) {
return this.map.keySet().containsAll(collection);
}
@Override // java.util.AbstractSet, java.util.Collection, java.util.Set
public boolean equals(Object obj) {
return this == obj || this.map.keySet().equals(obj);
}
@Override // java.util.AbstractSet, java.util.Collection, java.util.Set
public int hashCode() {
return this.map.keySet().hashCode();
}
@Override // com.squareup.haha.guava.collect.Maps.KeySet, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
public Iterator<K> iterator() {
final Iterator<Map.Entry<K, V>> it = this.map.entrySet().iterator();
return new Iterator<K>() { // from class: com.squareup.haha.guava.collect.AbstractMapBasedMultimap.KeySet.1
private Map.Entry<K, Collection<V>> entry;
@Override // java.util.Iterator
public final boolean hasNext() {
return it.hasNext();
}
@Override // java.util.Iterator
public final K next() {
this.entry = (Map.Entry) it.next();
return this.entry.getKey();
}
@Override // java.util.Iterator
public final void remove() {
Joiner.checkRemove(this.entry != null);
Collection<V> value = this.entry.getValue();
it.remove();
AbstractMapBasedMultimap.access$220(AbstractMapBasedMultimap.this, value.size());
value.clear();
}
};
}
@Override // com.squareup.haha.guava.collect.Maps.KeySet, java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean remove(Object obj) {
int i;
Collection collection = (Collection) this.map.remove(obj);
if (collection != null) {
i = collection.size();
collection.clear();
AbstractMapBasedMultimap.access$220(AbstractMapBasedMultimap.this, i);
} else {
i = 0;
}
return i > 0;
}
}
class RandomAccessWrappedList extends WrappedList implements RandomAccess {
RandomAccessWrappedList(AbstractMapBasedMultimap abstractMapBasedMultimap, Object obj, List list, WrappedCollection wrappedCollection) {
super(obj, list, wrappedCollection);
}
}
class SortedAsMap extends AsMap implements SortedMap {
private SortedSet<K> sortedKeySet;
SortedAsMap(SortedMap<K, Collection<V>> sortedMap) {
super(sortedMap);
}
@Override // java.util.SortedMap
public final Comparator<? super K> comparator() {
return ((SortedMap) this.submap).comparator();
}
@Override // java.util.SortedMap
public final K firstKey() {
return (K) ((SortedMap) this.submap).firstKey();
}
@Override // java.util.SortedMap
public final SortedMap<K, Collection<V>> headMap(K k) {
return new SortedAsMap(((SortedMap) this.submap).headMap(k));
}
@Override // com.squareup.haha.guava.collect.AbstractMapBasedMultimap.AsMap, com.squareup.haha.guava.collect.Maps.ImprovedAbstractMap, java.util.AbstractMap, java.util.Map
public final /* bridge */ /* synthetic */ Set keySet() {
SortedSet<K> sortedSet = this.sortedKeySet;
if (sortedSet != null) {
return sortedSet;
}
SortedSet<K> mo16createKeySet = mo16createKeySet();
this.sortedKeySet = mo16createKeySet;
return mo16createKeySet;
}
@Override // java.util.SortedMap
public final K lastKey() {
return (K) ((SortedMap) this.submap).lastKey();
}
@Override // java.util.SortedMap
public final SortedMap<K, Collection<V>> subMap(K k, K k2) {
return new SortedAsMap(((SortedMap) this.submap).subMap(k, k2));
}
@Override // java.util.SortedMap
public final SortedMap<K, Collection<V>> tailMap(K k) {
return new SortedAsMap(((SortedMap) this.submap).tailMap(k));
}
/* JADX INFO: Access modifiers changed from: private */
@Override // com.squareup.haha.guava.collect.Maps.ImprovedAbstractMap
/* renamed from: createKeySet, reason: merged with bridge method [inline-methods] */
public SortedSet<K> mo16createKeySet() {
return new SortedKeySet((SortedMap) this.submap);
}
}
class SortedKeySet extends KeySet implements SortedSet {
SortedKeySet(SortedMap<K, Collection<V>> sortedMap) {
super(sortedMap);
}
private SortedMap<K, Collection<V>> sortedMap() {
return (SortedMap) this.map;
}
@Override // java.util.SortedSet
public final Comparator<? super K> comparator() {
return sortedMap().comparator();
}
@Override // java.util.SortedSet
public final K first() {
return sortedMap().firstKey();
}
@Override // java.util.SortedSet
public final SortedSet<K> headSet(K k) {
return new SortedKeySet(sortedMap().headMap(k));
}
@Override // java.util.SortedSet
public final K last() {
return sortedMap().lastKey();
}
@Override // java.util.SortedSet
public final SortedSet<K> subSet(K k, K k2) {
return new SortedKeySet(sortedMap().subMap(k, k2));
}
@Override // java.util.SortedSet
public final SortedSet<K> tailSet(K k) {
return new SortedKeySet(sortedMap().tailMap(k));
}
}
class WrappedSet extends WrappedCollection implements Set {
WrappedSet(K k, Set<V> set) {
super(k, set, null);
}
@Override // com.squareup.haha.guava.collect.AbstractMapBasedMultimap.WrappedCollection, java.util.AbstractCollection, java.util.Collection
public final boolean removeAll(Collection<?> collection) {
if (collection.isEmpty()) {
return false;
}
int size = size();
boolean removeAllImpl = Joiner.removeAllImpl((Set<?>) this.delegate, collection);
if (removeAllImpl) {
AbstractMapBasedMultimap.access$212(AbstractMapBasedMultimap.this, this.delegate.size() - size);
removeIfEmpty();
}
return removeAllImpl;
}
}
class WrappedSortedSet extends WrappedCollection implements SortedSet {
WrappedSortedSet(Object obj, SortedSet sortedSet, WrappedCollection wrappedCollection) {
super(obj, sortedSet, wrappedCollection);
}
private SortedSet<V> getSortedSetDelegate() {
return (SortedSet) this.delegate;
}
@Override // java.util.SortedSet
public final Comparator<? super V> comparator() {
return getSortedSetDelegate().comparator();
}
@Override // java.util.SortedSet
public final V first() {
refreshIfEmpty();
return getSortedSetDelegate().first();
}
@Override // java.util.SortedSet
public final SortedSet<V> headSet(V v) {
refreshIfEmpty();
AbstractMapBasedMultimap abstractMapBasedMultimap = AbstractMapBasedMultimap.this;
K k = this.key;
SortedSet<V> headSet = getSortedSetDelegate().headSet(v);
WrappedCollection wrappedCollection = this.ancestor;
if (wrappedCollection == null) {
wrappedCollection = this;
}
return new WrappedSortedSet(k, headSet, wrappedCollection);
}
@Override // java.util.SortedSet
public final V last() {
refreshIfEmpty();
return getSortedSetDelegate().last();
}
@Override // java.util.SortedSet
public final SortedSet<V> subSet(V v, V v2) {
refreshIfEmpty();
AbstractMapBasedMultimap abstractMapBasedMultimap = AbstractMapBasedMultimap.this;
K k = this.key;
SortedSet<V> subSet = getSortedSetDelegate().subSet(v, v2);
WrappedCollection wrappedCollection = this.ancestor;
if (wrappedCollection == null) {
wrappedCollection = this;
}
return new WrappedSortedSet(k, subSet, wrappedCollection);
}
@Override // java.util.SortedSet
public final SortedSet<V> tailSet(V v) {
refreshIfEmpty();
AbstractMapBasedMultimap abstractMapBasedMultimap = AbstractMapBasedMultimap.this;
K k = this.key;
SortedSet<V> tailSet = getSortedSetDelegate().tailSet(v);
WrappedCollection wrappedCollection = this.ancestor;
if (wrappedCollection == null) {
wrappedCollection = this;
}
return new WrappedSortedSet(k, tailSet, wrappedCollection);
}
}
protected AbstractMapBasedMultimap(Map<K, Collection<V>> map) {
Joiner.checkArgument(map.isEmpty());
this.map = map;
}
static /* synthetic */ Iterator access$100(AbstractMapBasedMultimap abstractMapBasedMultimap, Collection collection) {
return collection instanceof List ? ((List) collection).listIterator() : collection.iterator();
}
static /* synthetic */ int access$208(AbstractMapBasedMultimap abstractMapBasedMultimap) {
int i = abstractMapBasedMultimap.totalSize;
abstractMapBasedMultimap.totalSize = i + 1;
return i;
}
static /* synthetic */ int access$210(AbstractMapBasedMultimap abstractMapBasedMultimap) {
int i = abstractMapBasedMultimap.totalSize;
abstractMapBasedMultimap.totalSize = i - 1;
return i;
}
static /* synthetic */ int access$212(AbstractMapBasedMultimap abstractMapBasedMultimap, int i) {
int i2 = abstractMapBasedMultimap.totalSize + i;
abstractMapBasedMultimap.totalSize = i2;
return i2;
}
static /* synthetic */ int access$220(AbstractMapBasedMultimap abstractMapBasedMultimap, int i) {
int i2 = abstractMapBasedMultimap.totalSize - i;
abstractMapBasedMultimap.totalSize = i2;
return i2;
}
static /* synthetic */ int access$400(AbstractMapBasedMultimap abstractMapBasedMultimap, Object obj) {
Collection collection = (Collection) Maps.safeRemove(abstractMapBasedMultimap.map, obj);
if (collection == null) {
return 0;
}
int size = collection.size();
collection.clear();
abstractMapBasedMultimap.totalSize -= size;
return size;
}
/* JADX INFO: Access modifiers changed from: private */
public List wrapList(Object obj, List list, WrappedCollection wrappedCollection) {
return list instanceof RandomAccess ? new RandomAccessWrappedList(this, obj, list, wrappedCollection) : new WrappedList(obj, list, wrappedCollection);
}
@Override // com.squareup.haha.guava.collect.Multimap
public void clear() {
Iterator<Collection<V>> it = this.map.values().iterator();
while (it.hasNext()) {
it.next().clear();
}
this.map.clear();
this.totalSize = 0;
}
@Override // com.squareup.haha.guava.collect.AbstractMultimap
final Map<K, Collection<V>> createAsMap() {
Map<K, Collection<V>> map = this.map;
return map instanceof SortedMap ? new SortedAsMap((SortedMap) map) : new AsMap(map);
}
abstract Collection<V> createCollection();
@Override // com.squareup.haha.guava.collect.AbstractMultimap
final Set<K> createKeySet() {
Map<K, Collection<V>> map = this.map;
return map instanceof SortedMap ? new SortedKeySet((SortedMap) map) : new KeySet(map);
}
@Override // com.squareup.haha.guava.collect.AbstractMultimap
public Collection<Map.Entry<K, V>> entries() {
return super.entries();
}
@Override // com.squareup.haha.guava.collect.AbstractMultimap
final Iterator<Map.Entry<K, V>> entryIterator() {
return new Itr(this) { // from class: com.squareup.haha.guava.collect.AbstractMapBasedMultimap.2
@Override // com.squareup.haha.guava.collect.AbstractMapBasedMultimap.Itr
final /* bridge */ /* synthetic */ Object output(Object obj, Object obj2) {
return Maps.immutableEntry(obj, obj2);
}
};
}
@Override // com.squareup.haha.guava.collect.Multimap
public Collection<V> get(K k) {
Collection<V> collection = this.map.get(k);
if (collection == null) {
collection = createCollection();
}
return wrapCollection(k, collection);
}
@Override // com.squareup.haha.guava.collect.AbstractMultimap, com.squareup.haha.guava.collect.Multimap
public boolean put(K k, V v) {
Collection<V> collection = this.map.get(k);
if (collection != null) {
if (!collection.add(v)) {
return false;
}
this.totalSize++;
return true;
}
Collection<V> createCollection = createCollection();
if (!createCollection.add(v)) {
throw new AssertionError("New Collection violated the Collection spec");
}
this.totalSize++;
this.map.put(k, createCollection);
return true;
}
@Override // com.squareup.haha.guava.collect.Multimap
public int size() {
return this.totalSize;
}
@Override // com.squareup.haha.guava.collect.AbstractMultimap
final Iterator<V> valueIterator() {
return new Itr(this) { // from class: com.squareup.haha.guava.collect.AbstractMapBasedMultimap.1
@Override // com.squareup.haha.guava.collect.AbstractMapBasedMultimap.Itr
final V output(K k, V v) {
return v;
}
};
}
@Override // com.squareup.haha.guava.collect.AbstractMultimap, com.squareup.haha.guava.collect.Multimap
public Collection<V> values() {
return super.values();
}
final Collection<V> wrapCollection(K k, Collection<V> collection) {
return collection instanceof SortedSet ? new WrappedSortedSet(k, (SortedSet) collection, null) : collection instanceof Set ? new WrappedSet(k, (Set) collection) : collection instanceof List ? wrapList(k, (List) collection, null) : new WrappedCollection(k, collection, null);
}
class WrappedCollection extends AbstractCollection<V> {
final WrappedCollection ancestor;
private Collection<V> ancestorDelegate;
Collection<V> delegate;
final K key;
/* JADX WARN: Multi-variable type inference failed */
WrappedCollection(Object obj, Collection collection, WrappedCollection wrappedCollection) {
this.key = obj;
this.delegate = collection;
this.ancestor = wrappedCollection;
this.ancestorDelegate = wrappedCollection == null ? null : wrappedCollection.delegate;
}
@Override // java.util.AbstractCollection, java.util.Collection
public boolean add(V v) {
refreshIfEmpty();
boolean isEmpty = this.delegate.isEmpty();
boolean add = this.delegate.add(v);
if (add) {
AbstractMapBasedMultimap.access$208(AbstractMapBasedMultimap.this);
if (isEmpty) {
addToMap();
}
}
return add;
}
@Override // java.util.AbstractCollection, java.util.Collection
public boolean addAll(Collection<? extends V> collection) {
if (collection.isEmpty()) {
return false;
}
int size = size();
boolean addAll = this.delegate.addAll(collection);
if (addAll) {
AbstractMapBasedMultimap.access$212(AbstractMapBasedMultimap.this, this.delegate.size() - size);
if (size == 0) {
addToMap();
}
}
return addAll;
}
final void addToMap() {
WrappedCollection wrappedCollection = this.ancestor;
if (wrappedCollection != null) {
wrappedCollection.addToMap();
} else {
AbstractMapBasedMultimap.this.map.put(this.key, this.delegate);
}
}
@Override // java.util.AbstractCollection, java.util.Collection
public void clear() {
int size = size();
if (size == 0) {
return;
}
this.delegate.clear();
AbstractMapBasedMultimap.access$220(AbstractMapBasedMultimap.this, size);
removeIfEmpty();
}
@Override // java.util.AbstractCollection, java.util.Collection
public boolean contains(Object obj) {
refreshIfEmpty();
return this.delegate.contains(obj);
}
@Override // java.util.AbstractCollection, java.util.Collection
public boolean containsAll(Collection<?> collection) {
refreshIfEmpty();
return this.delegate.containsAll(collection);
}
@Override // java.util.Collection
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
refreshIfEmpty();
return this.delegate.equals(obj);
}
@Override // java.util.Collection
public int hashCode() {
refreshIfEmpty();
return this.delegate.hashCode();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
public Iterator<V> iterator() {
refreshIfEmpty();
return new WrappedIterator();
}
final void refreshIfEmpty() {
Collection<V> collection;
WrappedCollection wrappedCollection = this.ancestor;
if (wrappedCollection != null) {
wrappedCollection.refreshIfEmpty();
if (this.ancestor.delegate != this.ancestorDelegate) {
throw new ConcurrentModificationException();
}
} else {
if (!this.delegate.isEmpty() || (collection = (Collection) AbstractMapBasedMultimap.this.map.get(this.key)) == null) {
return;
}
this.delegate = collection;
}
}
@Override // java.util.AbstractCollection, java.util.Collection
public boolean remove(Object obj) {
refreshIfEmpty();
boolean remove = this.delegate.remove(obj);
if (remove) {
AbstractMapBasedMultimap.access$210(AbstractMapBasedMultimap.this);
removeIfEmpty();
}
return remove;
}
@Override // java.util.AbstractCollection, java.util.Collection
public boolean removeAll(Collection<?> collection) {
if (collection.isEmpty()) {
return false;
}
int size = size();
boolean removeAll = this.delegate.removeAll(collection);
if (removeAll) {
AbstractMapBasedMultimap.access$212(AbstractMapBasedMultimap.this, this.delegate.size() - size);
removeIfEmpty();
}
return removeAll;
}
final void removeIfEmpty() {
WrappedCollection wrappedCollection = this.ancestor;
if (wrappedCollection != null) {
wrappedCollection.removeIfEmpty();
} else if (this.delegate.isEmpty()) {
AbstractMapBasedMultimap.this.map.remove(this.key);
}
}
@Override // java.util.AbstractCollection, java.util.Collection
public boolean retainAll(Collection<?> collection) {
Joiner.checkNotNull(collection);
int size = size();
boolean retainAll = this.delegate.retainAll(collection);
if (retainAll) {
AbstractMapBasedMultimap.access$212(AbstractMapBasedMultimap.this, this.delegate.size() - size);
removeIfEmpty();
}
return retainAll;
}
@Override // java.util.AbstractCollection, java.util.Collection
public int size() {
refreshIfEmpty();
return this.delegate.size();
}
@Override // java.util.AbstractCollection
public String toString() {
refreshIfEmpty();
return this.delegate.toString();
}
class WrappedIterator implements Iterator<V> {
final Iterator<V> delegateIterator;
private Collection<V> originalDelegate;
WrappedIterator() {
this.originalDelegate = WrappedCollection.this.delegate;
this.delegateIterator = AbstractMapBasedMultimap.access$100(AbstractMapBasedMultimap.this, WrappedCollection.this.delegate);
}
@Override // java.util.Iterator
public boolean hasNext() {
validateIterator();
return this.delegateIterator.hasNext();
}
@Override // java.util.Iterator
public V next() {
validateIterator();
return this.delegateIterator.next();
}
@Override // java.util.Iterator
public void remove() {
this.delegateIterator.remove();
AbstractMapBasedMultimap.access$210(AbstractMapBasedMultimap.this);
WrappedCollection.this.removeIfEmpty();
}
final void validateIterator() {
WrappedCollection.this.refreshIfEmpty();
if (WrappedCollection.this.delegate != this.originalDelegate) {
throw new ConcurrentModificationException();
}
}
WrappedIterator(Iterator<V> it) {
this.originalDelegate = WrappedCollection.this.delegate;
this.delegateIterator = it;
}
}
}
class WrappedList extends WrappedCollection implements List {
class WrappedListIterator extends WrappedCollection.WrappedIterator implements ListIterator {
WrappedListIterator() {
super();
}
private ListIterator<V> getDelegateListIterator() {
validateIterator();
return (ListIterator) this.delegateIterator;
}
@Override // java.util.ListIterator
public final void add(V v) {
boolean isEmpty = WrappedList.this.isEmpty();
getDelegateListIterator().add(v);
AbstractMapBasedMultimap.access$208(AbstractMapBasedMultimap.this);
if (isEmpty) {
WrappedList.this.addToMap();
}
}
@Override // java.util.ListIterator
public final boolean hasPrevious() {
return getDelegateListIterator().hasPrevious();
}
@Override // java.util.ListIterator
public final int nextIndex() {
return getDelegateListIterator().nextIndex();
}
@Override // java.util.ListIterator
public final V previous() {
return getDelegateListIterator().previous();
}
@Override // java.util.ListIterator
public final int previousIndex() {
return getDelegateListIterator().previousIndex();
}
@Override // java.util.ListIterator
public final void set(V v) {
getDelegateListIterator().set(v);
}
public WrappedListIterator(int i) {
super(WrappedList.this.getListDelegate().listIterator(i));
}
}
WrappedList(Object obj, List list, WrappedCollection wrappedCollection) {
super(obj, list, wrappedCollection);
}
@Override // java.util.List
public void add(int i, V v) {
refreshIfEmpty();
boolean isEmpty = this.delegate.isEmpty();
getListDelegate().add(i, v);
AbstractMapBasedMultimap.access$208(AbstractMapBasedMultimap.this);
if (isEmpty) {
addToMap();
}
}
@Override // java.util.List
public boolean addAll(int i, Collection<? extends V> collection) {
if (collection.isEmpty()) {
return false;
}
int size = size();
boolean addAll = getListDelegate().addAll(i, collection);
if (addAll) {
AbstractMapBasedMultimap.access$212(AbstractMapBasedMultimap.this, this.delegate.size() - size);
if (size == 0) {
addToMap();
}
}
return addAll;
}
@Override // java.util.List
public V get(int i) {
refreshIfEmpty();
return getListDelegate().get(i);
}
final List<V> getListDelegate() {
return (List) this.delegate;
}
@Override // java.util.List
public int indexOf(Object obj) {
refreshIfEmpty();
return getListDelegate().indexOf(obj);
}
@Override // java.util.List
public int lastIndexOf(Object obj) {
refreshIfEmpty();
return getListDelegate().lastIndexOf(obj);
}
@Override // java.util.List
public ListIterator<V> listIterator() {
refreshIfEmpty();
return new WrappedListIterator();
}
@Override // java.util.List
public V remove(int i) {
refreshIfEmpty();
V remove = getListDelegate().remove(i);
AbstractMapBasedMultimap.access$210(AbstractMapBasedMultimap.this);
removeIfEmpty();
return remove;
}
@Override // java.util.List
public V set(int i, V v) {
refreshIfEmpty();
return getListDelegate().set(i, v);
}
@Override // java.util.List
public List<V> subList(int i, int i2) {
refreshIfEmpty();
AbstractMapBasedMultimap abstractMapBasedMultimap = AbstractMapBasedMultimap.this;
K k = this.key;
List<V> subList = getListDelegate().subList(i, i2);
WrappedCollection wrappedCollection = this.ancestor;
if (wrappedCollection == null) {
wrappedCollection = this;
}
return abstractMapBasedMultimap.wrapList(k, subList, wrappedCollection);
}
@Override // java.util.List
public ListIterator<V> listIterator(int i) {
refreshIfEmpty();
return new WrappedListIterator(i);
}
}
}

View File

@@ -0,0 +1,43 @@
package com.squareup.haha.guava.collect;
import com.squareup.haha.guava.base.Joiner;
import java.util.Map;
/* loaded from: classes.dex */
abstract class AbstractMapEntry<K, V> implements Map.Entry<K, V> {
AbstractMapEntry() {
}
@Override // java.util.Map.Entry
public boolean equals(Object obj) {
if (obj instanceof Map.Entry) {
Map.Entry entry = (Map.Entry) obj;
if (Joiner.equal(getKey(), entry.getKey()) && Joiner.equal(getValue(), entry.getValue())) {
return true;
}
}
return false;
}
@Override // java.util.Map.Entry
public abstract K getKey();
@Override // java.util.Map.Entry
public abstract V getValue();
@Override // java.util.Map.Entry
public int hashCode() {
K key = getKey();
V value = getValue();
return (key == null ? 0 : key.hashCode()) ^ (value != null ? value.hashCode() : 0);
}
@Override // java.util.Map.Entry
public V setValue(V v) {
throw new UnsupportedOperationException();
}
public String toString() {
return getKey() + "=" + getValue();
}
}

View File

@@ -0,0 +1,189 @@
package com.squareup.haha.guava.collect;
import com.squareup.haha.guava.base.Joiner;
import com.squareup.haha.guava.collect.Maps;
import java.util.AbstractCollection;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
/* loaded from: classes.dex */
abstract class AbstractMultimap<K, V> implements Multimap<K, V> {
private transient Map<K, Collection<V>> asMap;
private transient Collection<Map.Entry<K, V>> entries;
private transient Set<K> keySet;
private transient Collection<V> values;
class Entries extends Multimaps$Entries<K, V> {
private Entries() {
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
public Iterator<Map.Entry<K, V>> iterator() {
return AbstractMultimap.this.entryIterator();
}
@Override // com.squareup.haha.guava.collect.Multimaps$Entries
final Multimap<K, V> multimap() {
return AbstractMultimap.this;
}
/* synthetic */ Entries(AbstractMultimap abstractMultimap, byte b) {
this();
}
}
class EntrySet extends Entries implements Set {
private EntrySet(AbstractMultimap abstractMultimap) {
super(abstractMultimap, (byte) 0);
}
@Override // java.util.Collection, java.util.Set
public final boolean equals(Object obj) {
return Joiner.equalsImpl(this, obj);
}
@Override // java.util.Collection, java.util.Set
public final int hashCode() {
Iterator it = iterator();
int i = 0;
while (it.hasNext()) {
Object next = it.next();
i = ~(~(i + (next != null ? next.hashCode() : 0)));
}
return i;
}
/* synthetic */ EntrySet(AbstractMultimap abstractMultimap, byte b) {
this(abstractMultimap);
}
}
class Values extends AbstractCollection<V> {
Values() {
}
@Override // java.util.AbstractCollection, java.util.Collection
public final void clear() {
AbstractMultimap.this.clear();
}
@Override // java.util.AbstractCollection, java.util.Collection
public final boolean contains(Object obj) {
return AbstractMultimap.this.containsValue(obj);
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
public final Iterator<V> iterator() {
return AbstractMultimap.this.valueIterator();
}
@Override // java.util.AbstractCollection, java.util.Collection
public final int size() {
return AbstractMultimap.this.size();
}
}
AbstractMultimap() {
}
@Override // com.squareup.haha.guava.collect.Multimap
public Map<K, Collection<V>> asMap() {
Map<K, Collection<V>> map = this.asMap;
if (map != null) {
return map;
}
Map<K, Collection<V>> createAsMap = createAsMap();
this.asMap = createAsMap;
return createAsMap;
}
@Override // com.squareup.haha.guava.collect.Multimap
public boolean containsEntry(Object obj, Object obj2) {
Collection<V> collection = asMap().get(obj);
return collection != null && collection.contains(obj2);
}
public boolean containsValue(Object obj) {
Iterator<Collection<V>> it = asMap().values().iterator();
while (it.hasNext()) {
if (it.next().contains(obj)) {
return true;
}
}
return false;
}
abstract Map<K, Collection<V>> createAsMap();
Set<K> createKeySet() {
return new Maps.KeySet(asMap());
}
public Collection<Map.Entry<K, V>> entries() {
Collection<Map.Entry<K, V>> collection = this.entries;
if (collection == null) {
byte b = 0;
collection = this instanceof SetMultimap ? new EntrySet(this, b) : new Entries(this, b);
this.entries = collection;
}
return collection;
}
abstract Iterator<Map.Entry<K, V>> entryIterator();
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof Multimap) {
return asMap().equals(((Multimap) obj).asMap());
}
return false;
}
public int hashCode() {
return asMap().hashCode();
}
public Set<K> keySet() {
Set<K> set = this.keySet;
if (set != null) {
return set;
}
Set<K> createKeySet = createKeySet();
this.keySet = createKeySet;
return createKeySet;
}
@Override // com.squareup.haha.guava.collect.Multimap
public boolean put(K k, V v) {
return get(k).add(v);
}
@Override // com.squareup.haha.guava.collect.Multimap
public boolean remove(Object obj, Object obj2) {
Collection<V> collection = asMap().get(obj);
return collection != null && collection.remove(obj2);
}
public String toString() {
return asMap().toString();
}
Iterator<V> valueIterator() {
return Maps.valueIterator(entries().iterator());
}
@Override // com.squareup.haha.guava.collect.Multimap
public Collection<V> values() {
Collection<V> collection = this.values;
if (collection != null) {
return collection;
}
Values values = new Values();
this.values = values;
return values;
}
}

View File

@@ -0,0 +1,100 @@
package com.squareup.haha.guava.collect;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
/* loaded from: classes.dex */
public final class ArrayListMultimap<K, V> extends AbstractListMultimap<K, V> {
private transient int expectedValuesPerKey;
private ArrayListMultimap() {
super(new HashMap());
this.expectedValuesPerKey = 3;
}
public static <K, V> ArrayListMultimap<K, V> create() {
return new ArrayListMultimap<>();
}
@Override // com.squareup.haha.guava.collect.AbstractListMultimap, com.squareup.haha.guava.collect.AbstractMultimap, com.squareup.haha.guava.collect.Multimap
public final /* bridge */ /* synthetic */ Map asMap() {
return super.asMap();
}
@Override // com.squareup.haha.guava.collect.AbstractMapBasedMultimap, com.squareup.haha.guava.collect.Multimap
public final /* bridge */ /* synthetic */ void clear() {
super.clear();
}
@Override // com.squareup.haha.guava.collect.AbstractMultimap, com.squareup.haha.guava.collect.Multimap
public final /* bridge */ /* synthetic */ boolean containsEntry(Object obj, Object obj2) {
return super.containsEntry(obj, obj2);
}
@Override // com.squareup.haha.guava.collect.AbstractMultimap
public final /* bridge */ /* synthetic */ boolean containsValue(Object obj) {
return super.containsValue(obj);
}
@Override // com.squareup.haha.guava.collect.AbstractMapBasedMultimap, com.squareup.haha.guava.collect.AbstractMultimap
public final /* bridge */ /* synthetic */ Collection entries() {
return super.entries();
}
@Override // com.squareup.haha.guava.collect.AbstractListMultimap, com.squareup.haha.guava.collect.AbstractMultimap
public final /* bridge */ /* synthetic */ boolean equals(Object obj) {
return super.equals(obj);
}
/* JADX WARN: Multi-variable type inference failed */
@Override // com.squareup.haha.guava.collect.AbstractListMultimap, com.squareup.haha.guava.collect.AbstractMapBasedMultimap, com.squareup.haha.guava.collect.Multimap
public final /* bridge */ /* synthetic */ List get(Object obj) {
return super.get((ArrayListMultimap<K, V>) obj);
}
@Override // com.squareup.haha.guava.collect.AbstractMultimap
public final /* bridge */ /* synthetic */ int hashCode() {
return super.hashCode();
}
@Override // com.squareup.haha.guava.collect.AbstractMultimap
public final /* bridge */ /* synthetic */ Set keySet() {
return super.keySet();
}
/* JADX WARN: Multi-variable type inference failed */
@Override // com.squareup.haha.guava.collect.AbstractListMultimap, com.squareup.haha.guava.collect.AbstractMapBasedMultimap, com.squareup.haha.guava.collect.AbstractMultimap, com.squareup.haha.guava.collect.Multimap
public final /* bridge */ /* synthetic */ boolean put(Object obj, Object obj2) {
return super.put(obj, obj2);
}
@Override // com.squareup.haha.guava.collect.AbstractMultimap, com.squareup.haha.guava.collect.Multimap
public final /* bridge */ /* synthetic */ boolean remove(Object obj, Object obj2) {
return super.remove(obj, obj2);
}
@Override // com.squareup.haha.guava.collect.AbstractMapBasedMultimap, com.squareup.haha.guava.collect.Multimap
public final /* bridge */ /* synthetic */ int size() {
return super.size();
}
@Override // com.squareup.haha.guava.collect.AbstractMultimap
public final /* bridge */ /* synthetic */ String toString() {
return super.toString();
}
@Override // com.squareup.haha.guava.collect.AbstractMapBasedMultimap, com.squareup.haha.guava.collect.AbstractMultimap, com.squareup.haha.guava.collect.Multimap
public final /* bridge */ /* synthetic */ Collection values() {
return super.values();
}
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.squareup.haha.guava.collect.AbstractListMultimap, com.squareup.haha.guava.collect.AbstractMapBasedMultimap
public final List<V> createCollection() {
return new ArrayList(this.expectedValuesPerKey);
}
}

View File

@@ -0,0 +1,18 @@
package com.squareup.haha.guava.collect;
import com.squareup.haha.guava.base.Joiner;
import java.util.Collection;
/* loaded from: classes.dex */
public final class Collections2 {
static final Joiner STANDARD_JOINER = new Joiner(", ").useForNull("null");
static boolean safeContains(Collection<?> collection, Object obj) {
Joiner.checkNotNull(collection);
try {
return collection.contains(obj);
} catch (ClassCastException | NullPointerException unused) {
return false;
}
}
}

View File

@@ -0,0 +1,13 @@
package com.squareup.haha.guava.collect;
/* loaded from: classes.dex */
public abstract class FluentIterable<E> implements Iterable<E> {
private final Iterable<E> iterable = this;
protected FluentIterable() {
}
public String toString() {
return Iterables.toString(this.iterable);
}
}

View File

@@ -0,0 +1,29 @@
package com.squareup.haha.guava.collect;
/* loaded from: classes.dex */
abstract class ImmutableAsList<E> extends ImmutableList<E> {
ImmutableAsList() {
}
@Override // com.squareup.haha.guava.collect.ImmutableList, com.squareup.haha.guava.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.util.List
public boolean contains(Object obj) {
return delegateCollection().contains(obj);
}
abstract ImmutableCollection<E> delegateCollection();
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
public boolean isEmpty() {
return delegateCollection().isEmpty();
}
@Override // com.squareup.haha.guava.collect.ImmutableCollection
final boolean isPartialView() {
return delegateCollection().isPartialView();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
public int size() {
return delegateCollection().size();
}
}

View File

@@ -0,0 +1,103 @@
package com.squareup.haha.guava.collect;
import com.squareup.haha.guava.base.Joiner;
import java.io.Serializable;
import java.util.AbstractCollection;
import java.util.Collection;
import java.util.Iterator;
/* loaded from: classes.dex */
public abstract class ImmutableCollection<E> extends AbstractCollection<E> implements Serializable {
private transient ImmutableList<E> asList;
ImmutableCollection() {
}
@Override // java.util.AbstractCollection, java.util.Collection
@Deprecated
public final boolean add(E e) {
throw new UnsupportedOperationException();
}
@Override // java.util.AbstractCollection, java.util.Collection
@Deprecated
public final boolean addAll(Collection<? extends E> collection) {
throw new UnsupportedOperationException();
}
public ImmutableList<E> asList() {
ImmutableList<E> immutableList = this.asList;
if (immutableList == null) {
int size = size();
immutableList = size != 0 ? size != 1 ? new RegularImmutableAsList<>(this, toArray()) : ImmutableList.of((Object) iterator().next()) : ImmutableList.of();
this.asList = immutableList;
}
return immutableList;
}
@Override // java.util.AbstractCollection, java.util.Collection
@Deprecated
public final void clear() {
throw new UnsupportedOperationException();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
public boolean contains(Object obj) {
return obj != null && super.contains(obj);
}
int copyIntoArray(Object[] objArr, int i) {
Iterator it = iterator();
while (it.hasNext()) {
objArr[i] = it.next();
i++;
}
return i;
}
abstract boolean isPartialView();
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
public abstract UnmodifiableIterator<E> iterator();
@Override // java.util.AbstractCollection, java.util.Collection
@Deprecated
public final boolean remove(Object obj) {
throw new UnsupportedOperationException();
}
@Override // java.util.AbstractCollection, java.util.Collection
@Deprecated
public final boolean removeAll(Collection<?> collection) {
throw new UnsupportedOperationException();
}
@Override // java.util.AbstractCollection, java.util.Collection
@Deprecated
public final boolean retainAll(Collection<?> collection) {
throw new UnsupportedOperationException();
}
@Override // java.util.AbstractCollection, java.util.Collection
public final Object[] toArray() {
if (size() == 0) {
return ObjectArrays.EMPTY_ARRAY;
}
Object[] objArr = new Object[size()];
copyIntoArray(objArr, 0);
return objArr;
}
@Override // java.util.AbstractCollection, java.util.Collection
public final <T> T[] toArray(T[] tArr) {
Joiner.checkNotNull(tArr);
int size = size();
if (tArr.length < size) {
tArr = (T[]) ObjectArrays.newArray(tArr, size);
} else if (tArr.length > size) {
tArr[size] = null;
}
copyIntoArray(tArr, 0);
return tArr;
}
}

View File

@@ -0,0 +1,29 @@
package com.squareup.haha.guava.collect;
import java.io.Serializable;
/* loaded from: classes.dex */
final class ImmutableEntry<K, V> extends AbstractMapEntry<K, V> implements Serializable {
private K key;
private V value;
ImmutableEntry(K k, V v) {
this.key = k;
this.value = v;
}
@Override // com.squareup.haha.guava.collect.AbstractMapEntry, java.util.Map.Entry
public final K getKey() {
return this.key;
}
@Override // com.squareup.haha.guava.collect.AbstractMapEntry, java.util.Map.Entry
public final V getValue() {
return this.value;
}
@Override // com.squareup.haha.guava.collect.AbstractMapEntry, java.util.Map.Entry
public final V setValue(V v) {
throw new UnsupportedOperationException();
}
}

View File

@@ -0,0 +1,304 @@
package com.squareup.haha.guava.collect;
import com.squareup.haha.guava.base.Joiner;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.RandomAccess;
/* loaded from: classes.dex */
public abstract class ImmutableList<E> extends ImmutableCollection<E> implements List<E>, RandomAccess {
static final ImmutableList<Object> EMPTY = new RegularImmutableList(ObjectArrays.EMPTY_ARRAY);
static class ReverseImmutableList<E> extends ImmutableList<E> {
private final transient ImmutableList<E> forwardList;
ReverseImmutableList(ImmutableList<E> immutableList) {
this.forwardList = immutableList;
}
private int reverseIndex(int i) {
return (size() - 1) - i;
}
@Override // com.squareup.haha.guava.collect.ImmutableList, com.squareup.haha.guava.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.util.List
public final boolean contains(Object obj) {
return this.forwardList.contains(obj);
}
@Override // java.util.List
public final E get(int i) {
Joiner.checkElementIndex(i, size());
return this.forwardList.get(reverseIndex(i));
}
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
public final int indexOf(Object obj) {
int lastIndexOf = this.forwardList.lastIndexOf(obj);
if (lastIndexOf >= 0) {
return reverseIndex(lastIndexOf);
}
return -1;
}
@Override // com.squareup.haha.guava.collect.ImmutableCollection
final boolean isPartialView() {
return this.forwardList.isPartialView();
}
@Override // com.squareup.haha.guava.collect.ImmutableList, com.squareup.haha.guava.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
public final /* bridge */ /* synthetic */ Iterator iterator() {
return super.iterator();
}
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
public final int lastIndexOf(Object obj) {
int indexOf = this.forwardList.indexOf(obj);
if (indexOf >= 0) {
return reverseIndex(indexOf);
}
return -1;
}
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
public final /* bridge */ /* synthetic */ ListIterator listIterator(int i) {
return super.listIterator(i);
}
@Override // com.squareup.haha.guava.collect.ImmutableList
public final ImmutableList<E> reverse() {
return this.forwardList;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
public final int size() {
return this.forwardList.size();
}
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
public final /* bridge */ /* synthetic */ ListIterator listIterator() {
return listIterator(0);
}
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
public final ImmutableList<E> subList(int i, int i2) {
Joiner.checkPositionIndexes(i, i2, size());
return this.forwardList.subList(size() - i2, size() - i).reverse();
}
}
class SubList extends ImmutableList<E> {
private transient int length;
private transient int offset;
SubList(int i, int i2) {
this.offset = i;
this.length = i2;
}
@Override // java.util.List
public final E get(int i) {
Joiner.checkElementIndex(i, this.length);
return ImmutableList.this.get(i + this.offset);
}
@Override // com.squareup.haha.guava.collect.ImmutableCollection
final boolean isPartialView() {
return true;
}
@Override // com.squareup.haha.guava.collect.ImmutableList, com.squareup.haha.guava.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
public final /* bridge */ /* synthetic */ Iterator iterator() {
return super.iterator();
}
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
public final /* bridge */ /* synthetic */ ListIterator listIterator(int i) {
return super.listIterator(i);
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
public final int size() {
return this.length;
}
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
public final /* bridge */ /* synthetic */ ListIterator listIterator() {
return listIterator(0);
}
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
public final ImmutableList<E> subList(int i, int i2) {
Joiner.checkPositionIndexes(i, i2, this.length);
ImmutableList immutableList = ImmutableList.this;
int i3 = this.offset;
return immutableList.subList(i + i3, i2 + i3);
}
}
ImmutableList() {
}
static <E> ImmutableList<E> asImmutableList(Object[] objArr) {
int length = objArr.length;
if (length == 0) {
return (ImmutableList<E>) EMPTY;
}
if (length == 1) {
return new SingletonImmutableList(objArr[0]);
}
if (length < objArr.length) {
objArr = ObjectArrays.arraysCopyOf(objArr, length);
}
return new RegularImmutableList(objArr);
}
public static <E> ImmutableList<E> copyOf(Collection<? extends E> collection) {
if (!(collection instanceof ImmutableCollection)) {
return asImmutableList(ObjectArrays.checkElementsNotNull(collection.toArray()));
}
ImmutableList<E> asList = ((ImmutableCollection) collection).asList();
return asList.isPartialView() ? asImmutableList(asList.toArray()) : asList;
}
public static <E> ImmutableList<E> of() {
return (ImmutableList<E>) EMPTY;
}
@Override // java.util.List
@Deprecated
public final void add(int i, E e) {
throw new UnsupportedOperationException();
}
@Override // java.util.List
@Deprecated
public final boolean addAll(int i, Collection<? extends E> collection) {
throw new UnsupportedOperationException();
}
@Override // com.squareup.haha.guava.collect.ImmutableCollection
public final ImmutableList<E> asList() {
return this;
}
@Override // com.squareup.haha.guava.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.util.List
public boolean contains(Object obj) {
return indexOf(obj) >= 0;
}
@Override // com.squareup.haha.guava.collect.ImmutableCollection
int copyIntoArray(Object[] objArr, int i) {
int size = size();
for (int i2 = 0; i2 < size; i2++) {
objArr[i + i2] = get(i2);
}
return i + size;
}
@Override // java.util.Collection, java.util.List
public boolean equals(Object obj) {
if (obj == Joiner.checkNotNull(this)) {
return true;
}
if (!(obj instanceof List)) {
return false;
}
List list = (List) obj;
return size() == list.size() && Iterators.elementsEqual(iterator(), list.iterator());
}
@Override // java.util.Collection, java.util.List
public int hashCode() {
int size = size();
int i = 1;
for (int i2 = 0; i2 < size; i2++) {
i = ~(~((i * 31) + get(i2).hashCode()));
}
return i;
}
@Override // java.util.List
public int indexOf(Object obj) {
if (obj == null) {
return -1;
}
ListIterator<E> listIterator = listIterator();
while (listIterator.hasNext()) {
if (Joiner.equal(obj, listIterator.next())) {
return listIterator.previousIndex();
}
}
return -1;
}
@Override // java.util.List
public int lastIndexOf(Object obj) {
if (obj == null) {
return -1;
}
ListIterator<E> listIterator = listIterator(size());
while (listIterator.hasPrevious()) {
if (Joiner.equal(obj, listIterator.previous())) {
return listIterator.nextIndex();
}
}
return -1;
}
@Override // java.util.List
@Deprecated
public final E remove(int i) {
throw new UnsupportedOperationException();
}
public ImmutableList<E> reverse() {
return new ReverseImmutableList(this);
}
@Override // java.util.List
@Deprecated
public final E set(int i, E e) {
throw new UnsupportedOperationException();
}
ImmutableList<E> subListUnchecked(int i, int i2) {
return new SubList(i, i2 - i);
}
public static <E> ImmutableList<E> of(E e) {
return new SingletonImmutableList(e);
}
@Override // com.squareup.haha.guava.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
public UnmodifiableIterator<E> iterator() {
return listIterator(0);
}
@Override // java.util.List
public UnmodifiableListIterator<E> listIterator(int i) {
return new AbstractIndexedListIterator<E>(size(), i) { // from class: com.squareup.haha.guava.collect.ImmutableList.1
@Override // com.squareup.haha.guava.collect.AbstractIndexedListIterator
protected final E get(int i2) {
return ImmutableList.this.get(i2);
}
};
}
@Override // java.util.List
public ImmutableList<E> subList(int i, int i2) {
Joiner.checkPositionIndexes(i, i2, size());
int i3 = i2 - i;
return i3 != 0 ? i3 != 1 ? subListUnchecked(i, i2) : of((Object) get(i)) : (ImmutableList<E>) EMPTY;
}
public static <E> ImmutableList<E> of(E e, E e2) {
return asImmutableList(ObjectArrays.checkElementsNotNull(e, e2));
}
@Override // java.util.List
public /* bridge */ /* synthetic */ ListIterator listIterator() {
return listIterator(0);
}
}

View File

@@ -0,0 +1,31 @@
package com.squareup.haha.guava.collect;
import com.squareup.haha.guava.base.Joiner;
import java.util.Iterator;
/* loaded from: classes.dex */
public final class Iterables {
static /* synthetic */ Iterator access$100(Iterable iterable) {
return new TransformedIterator<Iterable<? extends T>, Iterator<? extends T>>(iterable.iterator()) { // from class: com.squareup.haha.guava.collect.Iterables.3
@Override // com.squareup.haha.guava.collect.TransformedIterator
final /* bridge */ /* synthetic */ Object transform(Object obj) {
return ((Iterable) obj).iterator();
}
};
}
public static <T> Iterable<T> concat(Iterable<? extends T> iterable, Iterable<? extends T> iterable2) {
final ImmutableList of = ImmutableList.of(iterable, iterable2);
Joiner.checkNotNull(of);
return new FluentIterable<T>() { // from class: com.squareup.haha.guava.collect.Iterables.2
@Override // java.lang.Iterable
public final Iterator<T> iterator() {
return Iterators.concat(Iterables.access$100(of));
}
};
}
public static String toString(Iterable<?> iterable) {
return Iterators.toString(iterable.iterator());
}
}

View File

@@ -0,0 +1,184 @@
package com.squareup.haha.guava.collect;
import com.squareup.haha.guava.base.Function;
import com.squareup.haha.guava.base.Joiner;
import com.squareup.haha.guava.base.Predicate;
import com.squareup.haha.guava.base.Predicates;
import java.util.Collection;
import java.util.Iterator;
import java.util.NoSuchElementException;
/* loaded from: classes.dex */
public final class Iterators {
private static UnmodifiableListIterator<Object> EMPTY_LIST_ITERATOR = new UnmodifiableListIterator<Object>() { // from class: com.squareup.haha.guava.collect.Iterators.1
@Override // java.util.Iterator, java.util.ListIterator
public final boolean hasNext() {
return false;
}
@Override // java.util.ListIterator
public final boolean hasPrevious() {
return false;
}
@Override // java.util.Iterator, java.util.ListIterator
public final Object next() {
throw new NoSuchElementException();
}
@Override // java.util.ListIterator
public final int nextIndex() {
return 0;
}
@Override // java.util.ListIterator
public final Object previous() {
throw new NoSuchElementException();
}
@Override // java.util.ListIterator
public final int previousIndex() {
return -1;
}
};
private static final Iterator<Object> EMPTY_MODIFIABLE_ITERATOR = new Iterator<Object>() { // from class: com.squareup.haha.guava.collect.Iterators.2
@Override // java.util.Iterator
public final boolean hasNext() {
return false;
}
@Override // java.util.Iterator
public final Object next() {
throw new NoSuchElementException();
}
@Override // java.util.Iterator
public final void remove() {
Joiner.checkRemove(false);
}
};
static void clear(Iterator<?> it) {
Joiner.checkNotNull(it);
while (it.hasNext()) {
it.next();
it.remove();
}
}
public static <T> Iterator<T> concat(final Iterator<? extends Iterator<? extends T>> it) {
Joiner.checkNotNull(it);
return new Iterator<T>() { // from class: com.squareup.haha.guava.collect.Iterators.5
private Iterator<? extends T> current = Iterators.emptyIterator();
private Iterator<? extends T> removeFrom;
@Override // java.util.Iterator
public final boolean hasNext() {
boolean hasNext;
while (true) {
hasNext = ((Iterator) Joiner.checkNotNull(this.current)).hasNext();
if (hasNext || !it.hasNext()) {
break;
}
this.current = (Iterator) it.next();
}
return hasNext;
}
@Override // java.util.Iterator
public final T next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
Iterator<? extends T> it2 = this.current;
this.removeFrom = it2;
return it2.next();
}
@Override // java.util.Iterator
public final void remove() {
Joiner.checkRemove(this.removeFrom != null);
this.removeFrom.remove();
this.removeFrom = null;
}
};
}
public static boolean elementsEqual(Iterator<?> it, Iterator<?> it2) {
while (it.hasNext()) {
if (!it2.hasNext() || !Joiner.equal(it.next(), it2.next())) {
return false;
}
}
return !it2.hasNext();
}
public static <T> UnmodifiableIterator<T> emptyIterator() {
return EMPTY_LIST_ITERATOR;
}
static <T> Iterator<T> emptyModifiableIterator() {
return (Iterator<T>) EMPTY_MODIFIABLE_ITERATOR;
}
static <T> UnmodifiableListIterator<T> forArray(final T[] tArr, final int i, int i2, int i3) {
Joiner.checkArgument(i2 >= 0);
Joiner.checkPositionIndexes(i, i + i2, tArr.length);
Joiner.checkPositionIndex(i3, i2);
return i2 == 0 ? (UnmodifiableListIterator<T>) EMPTY_LIST_ITERATOR : new AbstractIndexedListIterator<T>(i2, i3) { // from class: com.squareup.haha.guava.collect.Iterators.11
@Override // com.squareup.haha.guava.collect.AbstractIndexedListIterator
protected final T get(int i4) {
return (T) tArr[i + i4];
}
};
}
public static boolean removeAll(Iterator<?> it, Collection<?> collection) {
Predicate in = Predicates.in(collection);
Joiner.checkNotNull(in);
boolean z = false;
while (it.hasNext()) {
if (in.apply(it.next())) {
it.remove();
z = true;
}
}
return z;
}
public static <T> UnmodifiableIterator<T> singletonIterator(final T t) {
return new UnmodifiableIterator<T>() { // from class: com.squareup.haha.guava.collect.Iterators.12
private boolean done;
@Override // java.util.Iterator
public final boolean hasNext() {
return !this.done;
}
@Override // java.util.Iterator
public final T next() {
if (this.done) {
throw new NoSuchElementException();
}
this.done = true;
return (T) t;
}
};
}
public static String toString(Iterator<?> it) {
StringBuilder appendTo = Collections2.STANDARD_JOINER.appendTo(new StringBuilder("["), it);
appendTo.append(']');
return appendTo.toString();
}
public static <F, T> Iterator<T> transform(Iterator<F> it, final Function<? super F, ? extends T> function) {
Joiner.checkNotNull(function);
return new TransformedIterator<F, T>(it) { // from class: com.squareup.haha.guava.collect.Iterators.8
@Override // com.squareup.haha.guava.collect.TransformedIterator
final T transform(F f) {
return (T) function.apply(f);
}
};
}
}

View File

@@ -0,0 +1,5 @@
package com.squareup.haha.guava.collect;
/* loaded from: classes.dex */
public interface ListMultimap extends Multimap {
}

View File

@@ -0,0 +1,11 @@
package com.squareup.haha.guava.collect;
import java.util.List;
import java.util.RandomAccess;
/* loaded from: classes.dex */
public final class Lists$RandomAccessReverseList<T> extends Lists$ReverseList<T> implements RandomAccess {
public Lists$RandomAccessReverseList(List<T> list) {
super(list);
}
}

View File

@@ -0,0 +1,144 @@
package com.squareup.haha.guava.collect;
import com.squareup.haha.guava.base.Joiner;
import java.util.AbstractList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.NoSuchElementException;
/* loaded from: classes.dex */
public class Lists$ReverseList<T> extends AbstractList<T> {
public final List<T> forwardList;
public Lists$ReverseList(List<T> list) {
this.forwardList = (List) Joiner.checkNotNull(list);
}
private int reverseIndex(int i) {
int size = size();
Joiner.checkElementIndex(i, size);
return (size - 1) - i;
}
/* JADX INFO: Access modifiers changed from: private */
public int reversePosition(int i) {
int size = size();
Joiner.checkPositionIndex(i, size);
return size - i;
}
@Override // java.util.AbstractList, java.util.List
public void add(int i, T t) {
this.forwardList.add(reversePosition(i), t);
}
@Override // java.util.AbstractList, java.util.AbstractCollection, java.util.Collection, java.util.List
public void clear() {
this.forwardList.clear();
}
@Override // java.util.AbstractList, java.util.List
public T get(int i) {
return this.forwardList.get(reverseIndex(i));
}
@Override // java.util.AbstractList, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.List
public Iterator<T> iterator() {
return listIterator();
}
@Override // java.util.AbstractList, java.util.List
public ListIterator<T> listIterator(int i) {
final ListIterator<T> listIterator = this.forwardList.listIterator(reversePosition(i));
return new ListIterator<T>() { // from class: com.squareup.haha.guava.collect.Lists$ReverseList.1
private boolean canRemoveOrSet;
@Override // java.util.ListIterator
public final void add(T t) {
listIterator.add(t);
listIterator.previous();
this.canRemoveOrSet = false;
}
@Override // java.util.ListIterator, java.util.Iterator
public final boolean hasNext() {
return listIterator.hasPrevious();
}
@Override // java.util.ListIterator
public final boolean hasPrevious() {
return listIterator.hasNext();
}
@Override // java.util.ListIterator, java.util.Iterator
public final T next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
this.canRemoveOrSet = true;
return (T) listIterator.previous();
}
@Override // java.util.ListIterator
public final int nextIndex() {
return Lists$ReverseList.this.reversePosition(listIterator.nextIndex());
}
@Override // java.util.ListIterator
public final T previous() {
if (!hasPrevious()) {
throw new NoSuchElementException();
}
this.canRemoveOrSet = true;
return (T) listIterator.next();
}
@Override // java.util.ListIterator
public final int previousIndex() {
return nextIndex() - 1;
}
@Override // java.util.ListIterator, java.util.Iterator
public final void remove() {
Joiner.checkRemove(this.canRemoveOrSet);
listIterator.remove();
this.canRemoveOrSet = false;
}
@Override // java.util.ListIterator
public final void set(T t) {
if (!this.canRemoveOrSet) {
throw new IllegalStateException();
}
listIterator.set(t);
}
};
}
@Override // java.util.AbstractList, java.util.List
public T remove(int i) {
return this.forwardList.remove(reverseIndex(i));
}
@Override // java.util.AbstractList
protected void removeRange(int i, int i2) {
subList(i, i2).clear();
}
@Override // java.util.AbstractList, java.util.List
public T set(int i, T t) {
return this.forwardList.set(reverseIndex(i), t);
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
public int size() {
return this.forwardList.size();
}
@Override // java.util.AbstractList, java.util.List
public List<T> subList(int i, int i2) {
Joiner.checkPositionIndexes(i, i2, size());
return Joiner.reverse(this.forwardList.subList(reversePosition(i2), reversePosition(i)));
}
}

View File

@@ -0,0 +1,349 @@
package com.squareup.haha.guava.collect;
import com.squareup.haha.guava.base.Function;
import com.squareup.haha.guava.base.Joiner;
import java.util.AbstractCollection;
import java.util.AbstractMap;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
/* loaded from: classes.dex */
public final class Maps {
/* JADX WARN: $VALUES field not found */
/* JADX WARN: Failed to restore enum class, 'enum' modifier and super class removed */
static abstract class EntryFunction implements Function<Map.Entry<?, ?>, Object> {
public static final EntryFunction KEY = new EntryFunction("KEY", 0) { // from class: com.squareup.haha.guava.collect.Maps.EntryFunction.1
{
byte b = 0;
}
@Override // com.squareup.haha.guava.base.Function
public final /* bridge */ /* synthetic */ Object apply(Map.Entry<?, ?> entry) {
return entry.getKey();
}
};
public static final EntryFunction VALUE = new EntryFunction("VALUE", 1) { // from class: com.squareup.haha.guava.collect.Maps.EntryFunction.2
{
int i = 1;
byte b = 0;
}
@Override // com.squareup.haha.guava.base.Function
public final /* bridge */ /* synthetic */ Object apply(Map.Entry<?, ?> entry) {
return entry.getValue();
}
};
static {
EntryFunction[] entryFunctionArr = {KEY, VALUE};
}
private EntryFunction(String str, int i) {
}
/* synthetic */ EntryFunction(String str, int i, byte b) {
this(str, i);
}
}
static abstract class EntrySet<K, V> extends Sets$ImprovedAbstractSet<Map.Entry<K, V>> {
EntrySet() {
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public void clear() {
map().clear();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean contains(Object obj) {
if (obj instanceof Map.Entry) {
Map.Entry entry = (Map.Entry) obj;
Object key = entry.getKey();
Object safeGet = Maps.safeGet(map(), key);
if (Joiner.equal(safeGet, entry.getValue()) && (safeGet != null || map().containsKey(key))) {
return true;
}
}
return false;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean isEmpty() {
return map().isEmpty();
}
abstract Map<K, V> map();
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean remove(Object obj) {
if (contains(obj)) {
return map().keySet().remove(((Map.Entry) obj).getKey());
}
return false;
}
@Override // com.squareup.haha.guava.collect.Sets$ImprovedAbstractSet, java.util.AbstractSet, java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean removeAll(Collection<?> collection) {
try {
return super.removeAll((Collection) Joiner.checkNotNull(collection));
} catch (UnsupportedOperationException unused) {
return Joiner.removeAllImpl(this, collection.iterator());
}
}
@Override // com.squareup.haha.guava.collect.Sets$ImprovedAbstractSet, java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean retainAll(Collection<?> collection) {
try {
return super.retainAll((Collection) Joiner.checkNotNull(collection));
} catch (UnsupportedOperationException unused) {
HashSet hashSet = new HashSet(Maps.capacity(collection.size()));
for (Object obj : collection) {
if (contains(obj)) {
hashSet.add(((Map.Entry) obj).getKey());
}
}
return map().keySet().retainAll(hashSet);
}
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public int size() {
return map().size();
}
}
static abstract class ImprovedAbstractMap<K, V> extends AbstractMap<K, V> {
private transient Set<Map.Entry<K, V>> entrySet;
private transient Set<K> keySet;
private transient Collection<V> values;
ImprovedAbstractMap() {
}
abstract Set<Map.Entry<K, V>> createEntrySet();
/* renamed from: createKeySet */
Set<K> mo16createKeySet() {
return new KeySet(this);
}
@Override // java.util.AbstractMap, java.util.Map
public Set<Map.Entry<K, V>> entrySet() {
Set<Map.Entry<K, V>> set = this.entrySet;
if (set != null) {
return set;
}
Set<Map.Entry<K, V>> createEntrySet = createEntrySet();
this.entrySet = createEntrySet;
return createEntrySet;
}
@Override // java.util.AbstractMap, java.util.Map
public Set<K> keySet() {
Set<K> set = this.keySet;
if (set != null) {
return set;
}
Set<K> mo16createKeySet = mo16createKeySet();
this.keySet = mo16createKeySet;
return mo16createKeySet;
}
@Override // java.util.AbstractMap, java.util.Map
public Collection<V> values() {
Collection<V> collection = this.values;
if (collection != null) {
return collection;
}
Values values = new Values(this);
this.values = values;
return values;
}
}
static class KeySet<K, V> extends Sets$ImprovedAbstractSet<K> {
final Map<K, V> map;
KeySet(Map<K, V> map) {
this.map = (Map) Joiner.checkNotNull(map);
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public void clear() {
this.map.clear();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean contains(Object obj) {
return this.map.containsKey(obj);
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean isEmpty() {
return this.map.isEmpty();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
public Iterator<K> iterator() {
return Maps.keyIterator(this.map.entrySet().iterator());
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean remove(Object obj) {
if (!contains(obj)) {
return false;
}
this.map.remove(obj);
return true;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public int size() {
return this.map.size();
}
}
static class Values<K, V> extends AbstractCollection<V> {
private Map<K, V> map;
Values(Map<K, V> map) {
this.map = (Map) Joiner.checkNotNull(map);
}
@Override // java.util.AbstractCollection, java.util.Collection
public final void clear() {
this.map.clear();
}
@Override // java.util.AbstractCollection, java.util.Collection
public final boolean contains(Object obj) {
return this.map.containsValue(obj);
}
@Override // java.util.AbstractCollection, java.util.Collection
public final boolean isEmpty() {
return this.map.isEmpty();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
public final Iterator<V> iterator() {
return Maps.valueIterator(this.map.entrySet().iterator());
}
@Override // java.util.AbstractCollection, java.util.Collection
public final boolean remove(Object obj) {
try {
return super.remove(obj);
} catch (UnsupportedOperationException unused) {
for (Map.Entry<K, V> entry : this.map.entrySet()) {
if (Joiner.equal(obj, entry.getValue())) {
this.map.remove(entry.getKey());
return true;
}
}
return false;
}
}
@Override // java.util.AbstractCollection, java.util.Collection
public final boolean removeAll(Collection<?> collection) {
try {
return super.removeAll((Collection) Joiner.checkNotNull(collection));
} catch (UnsupportedOperationException unused) {
HashSet hashSet = new HashSet();
for (Map.Entry<K, V> entry : this.map.entrySet()) {
if (collection.contains(entry.getValue())) {
hashSet.add(entry.getKey());
}
}
return this.map.keySet().removeAll(hashSet);
}
}
@Override // java.util.AbstractCollection, java.util.Collection
public final boolean retainAll(Collection<?> collection) {
try {
return super.retainAll((Collection) Joiner.checkNotNull(collection));
} catch (UnsupportedOperationException unused) {
HashSet hashSet = new HashSet();
for (Map.Entry<K, V> entry : this.map.entrySet()) {
if (collection.contains(entry.getValue())) {
hashSet.add(entry.getKey());
}
}
return this.map.keySet().retainAll(hashSet);
}
}
@Override // java.util.AbstractCollection, java.util.Collection
public final int size() {
return this.map.size();
}
}
static {
new Joiner.MapJoiner(Collections2.STANDARD_JOINER, "=", (byte) 0);
}
public static int capacity(int i) {
if (i >= 3) {
if (i < 1073741824) {
return i + (i / 3);
}
return Integer.MAX_VALUE;
}
if (i >= 0) {
return i + 1;
}
throw new IllegalArgumentException("expectedSize cannot be negative but was: " + i);
}
public static <K, V> Map.Entry<K, V> immutableEntry(K k, V v) {
return new ImmutableEntry(k, v);
}
static <K, V> Iterator<K> keyIterator(Iterator<Map.Entry<K, V>> it) {
return Iterators.transform(it, EntryFunction.KEY);
}
public static <K, V> HashMap<K, V> newHashMap() {
return new HashMap<>();
}
static boolean safeContainsKey(Map<?, ?> map, Object obj) {
Joiner.checkNotNull(map);
try {
return map.containsKey(obj);
} catch (ClassCastException | NullPointerException unused) {
return false;
}
}
static <V> V safeGet(Map<?, V> map, Object obj) {
Joiner.checkNotNull(map);
try {
return map.get(obj);
} catch (ClassCastException | NullPointerException unused) {
return null;
}
}
static <V> V safeRemove(Map<?, V> map, Object obj) {
Joiner.checkNotNull(map);
try {
return map.remove(obj);
} catch (ClassCastException | NullPointerException unused) {
return null;
}
}
static <K, V> Iterator<V> valueIterator(Iterator<Map.Entry<K, V>> it) {
return Iterators.transform(it, EntryFunction.VALUE);
}
}

View File

@@ -0,0 +1,23 @@
package com.squareup.haha.guava.collect;
import java.util.Collection;
import java.util.Map;
/* loaded from: classes.dex */
public interface Multimap<K, V> {
Map<K, Collection<V>> asMap();
void clear();
boolean containsEntry(Object obj, Object obj2);
Collection<V> get(K k);
boolean put(K k, V v);
boolean remove(Object obj, Object obj2);
int size();
Collection<V> values();
}

View File

@@ -0,0 +1,9 @@
package com.squareup.haha.guava.collect;
import java.util.Collection;
import java.util.Set;
/* loaded from: classes.dex */
public interface Multiset<E> extends Collection<E> {
Set<E> elementSet();
}

View File

@@ -0,0 +1,28 @@
package com.squareup.haha.guava.collect;
import java.lang.reflect.Array;
/* loaded from: classes.dex */
public final class ObjectArrays {
static final Object[] EMPTY_ARRAY = new Object[0];
static <T> T[] arraysCopyOf(T[] tArr, int i) {
T[] tArr2 = (T[]) newArray(tArr, i);
System.arraycopy(tArr, 0, tArr2, 0, Math.min(tArr.length, i));
return tArr2;
}
static Object[] checkElementsNotNull(Object... objArr) {
int length = objArr.length;
for (int i = 0; i < length; i++) {
if (objArr[i] == null) {
throw new NullPointerException("at index " + i);
}
}
return objArr;
}
public static <T> T[] newArray(T[] tArr, int i) {
return (T[]) ((Object[]) Array.newInstance(tArr.getClass().getComponentType(), i));
}
}

View File

@@ -0,0 +1,36 @@
package com.squareup.haha.guava.collect;
/* loaded from: classes.dex */
final class RegularImmutableAsList<E> extends ImmutableAsList<E> {
private final ImmutableCollection<E> delegate;
private final ImmutableList<? extends E> delegateList;
private RegularImmutableAsList(ImmutableCollection<E> immutableCollection, ImmutableList<? extends E> immutableList) {
this.delegate = immutableCollection;
this.delegateList = immutableList;
}
@Override // com.squareup.haha.guava.collect.ImmutableList, com.squareup.haha.guava.collect.ImmutableCollection
final int copyIntoArray(Object[] objArr, int i) {
return this.delegateList.copyIntoArray(objArr, i);
}
@Override // com.squareup.haha.guava.collect.ImmutableAsList
final ImmutableCollection<E> delegateCollection() {
return this.delegate;
}
@Override // java.util.List
public final E get(int i) {
return this.delegateList.get(i);
}
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
public final UnmodifiableListIterator<E> listIterator(int i) {
return this.delegateList.listIterator(i);
}
RegularImmutableAsList(ImmutableCollection<E> immutableCollection, Object[] objArr) {
this(immutableCollection, ImmutableList.asImmutableList(objArr));
}
}

View File

@@ -0,0 +1,78 @@
package com.squareup.haha.guava.collect;
import com.squareup.haha.guava.base.Joiner;
/* loaded from: classes.dex */
final class RegularImmutableList<E> extends ImmutableList<E> {
private final transient Object[] array;
private final transient int offset;
private final transient int size;
private RegularImmutableList(Object[] objArr, int i, int i2) {
this.offset = i;
this.size = i2;
this.array = objArr;
}
@Override // com.squareup.haha.guava.collect.ImmutableList, com.squareup.haha.guava.collect.ImmutableCollection
final int copyIntoArray(Object[] objArr, int i) {
System.arraycopy(this.array, this.offset, objArr, i, this.size);
return i + this.size;
}
@Override // java.util.List
public final E get(int i) {
Joiner.checkElementIndex(i, this.size);
return (E) this.array[i + this.offset];
}
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
public final int indexOf(Object obj) {
if (obj == null) {
return -1;
}
for (int i = 0; i < this.size; i++) {
if (this.array[this.offset + i].equals(obj)) {
return i;
}
}
return -1;
}
@Override // com.squareup.haha.guava.collect.ImmutableCollection
final boolean isPartialView() {
return this.size != this.array.length;
}
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
public final int lastIndexOf(Object obj) {
if (obj == null) {
return -1;
}
for (int i = this.size - 1; i >= 0; i--) {
if (this.array[this.offset + i].equals(obj)) {
return i;
}
}
return -1;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
public final int size() {
return this.size;
}
@Override // com.squareup.haha.guava.collect.ImmutableList
final ImmutableList<E> subListUnchecked(int i, int i2) {
return new RegularImmutableList(this.array, this.offset + i, i2 - i);
}
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
public final UnmodifiableListIterator<E> listIterator(int i) {
return Iterators.forArray(this.array, this.offset, this.size, i);
}
RegularImmutableList(Object[] objArr) {
this(objArr, 0, objArr.length);
}
}

View File

@@ -0,0 +1,5 @@
package com.squareup.haha.guava.collect;
/* loaded from: classes.dex */
public interface SetMultimap<K, V> extends Multimap<K, V> {
}

View File

@@ -0,0 +1,21 @@
package com.squareup.haha.guava.collect;
import com.squareup.haha.guava.base.Joiner;
import java.util.AbstractSet;
import java.util.Collection;
/* loaded from: classes.dex */
abstract class Sets$ImprovedAbstractSet<E> extends AbstractSet<E> {
Sets$ImprovedAbstractSet() {
}
@Override // java.util.AbstractSet, java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean removeAll(Collection<?> collection) {
return Joiner.removeAllImpl(this, collection);
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean retainAll(Collection<?> collection) {
return super.retainAll((Collection) Joiner.checkNotNull(collection));
}
}

View File

@@ -0,0 +1,106 @@
package com.squareup.haha.guava.collect;
import com.squareup.haha.guava.base.Joiner;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes.dex */
final class SingletonImmutableList<E> extends ImmutableList<E> {
private transient E element;
SingletonImmutableList(E e) {
this.element = (E) Joiner.checkNotNull(e);
}
@Override // com.squareup.haha.guava.collect.ImmutableList, com.squareup.haha.guava.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.util.List
public final boolean contains(Object obj) {
return this.element.equals(obj);
}
@Override // com.squareup.haha.guava.collect.ImmutableList, com.squareup.haha.guava.collect.ImmutableCollection
final int copyIntoArray(Object[] objArr, int i) {
objArr[i] = this.element;
return i + 1;
}
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.Collection, java.util.List
public final boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof List) {
List list = (List) obj;
if (list.size() == 1 && this.element.equals(list.get(0))) {
return true;
}
}
return false;
}
@Override // java.util.List
public final E get(int i) {
Joiner.checkElementIndex(i, 1);
return this.element;
}
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.Collection, java.util.List
public final int hashCode() {
return this.element.hashCode() + 31;
}
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
public final int indexOf(Object obj) {
return this.element.equals(obj) ? 0 : -1;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
public final boolean isEmpty() {
return false;
}
@Override // com.squareup.haha.guava.collect.ImmutableCollection
final boolean isPartialView() {
return false;
}
@Override // com.squareup.haha.guava.collect.ImmutableList, com.squareup.haha.guava.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
public final UnmodifiableIterator<E> iterator() {
return Iterators.singletonIterator(this.element);
}
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
public final int lastIndexOf(Object obj) {
return indexOf(obj);
}
@Override // com.squareup.haha.guava.collect.ImmutableList
public final ImmutableList<E> reverse() {
return this;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
public final int size() {
return 1;
}
@Override // java.util.AbstractCollection
public final String toString() {
String obj = this.element.toString();
StringBuilder sb = new StringBuilder(obj.length() + 2);
sb.append('[');
sb.append(obj);
sb.append(']');
return sb.toString();
}
@Override // com.squareup.haha.guava.collect.ImmutableList, com.squareup.haha.guava.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
public final /* bridge */ /* synthetic */ Iterator iterator() {
return Iterators.singletonIterator(this.element);
}
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
public final ImmutableList<E> subList(int i, int i2) {
Joiner.checkPositionIndexes(i, i2, 1);
return i == i2 ? (ImmutableList<E>) ImmutableList.EMPTY : this;
}
}

View File

@@ -0,0 +1,30 @@
package com.squareup.haha.guava.collect;
import com.squareup.haha.guava.base.Joiner;
import java.util.Iterator;
/* loaded from: classes.dex */
abstract class TransformedIterator<F, T> implements Iterator<T> {
private Iterator<? extends F> backingIterator;
TransformedIterator(Iterator<? extends F> it) {
this.backingIterator = (Iterator) Joiner.checkNotNull(it);
}
@Override // java.util.Iterator
public final boolean hasNext() {
return this.backingIterator.hasNext();
}
@Override // java.util.Iterator
public final T next() {
return transform(this.backingIterator.next());
}
@Override // java.util.Iterator
public final void remove() {
this.backingIterator.remove();
}
abstract T transform(F f);
}

View File

@@ -0,0 +1,15 @@
package com.squareup.haha.guava.collect;
import java.util.Iterator;
/* loaded from: classes.dex */
public abstract class UnmodifiableIterator<E> implements Iterator<E> {
protected UnmodifiableIterator() {
}
@Override // java.util.Iterator
@Deprecated
public final void remove() {
throw new UnsupportedOperationException();
}
}

View File

@@ -0,0 +1,21 @@
package com.squareup.haha.guava.collect;
import java.util.ListIterator;
/* loaded from: classes.dex */
public abstract class UnmodifiableListIterator<E> extends UnmodifiableIterator<E> implements ListIterator<E> {
protected UnmodifiableListIterator() {
}
@Override // java.util.ListIterator
@Deprecated
public final void add(E e) {
throw new UnsupportedOperationException();
}
@Override // java.util.ListIterator
@Deprecated
public final void set(E e) {
throw new UnsupportedOperationException();
}
}

View File

@@ -0,0 +1,82 @@
package com.squareup.haha.perflib;
import com.squareup.haha.perflib.io.HprofBuffer;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
/* loaded from: classes.dex */
public class ArrayInstance extends Instance {
static final /* synthetic */ boolean $assertionsDisabled = false;
private final int mLength;
private final Type mType;
private final long mValuesOffset;
public ArrayInstance(long j, StackTrace stackTrace, Type type, int i, long j2) {
super(j, stackTrace);
this.mType = type;
this.mLength = i;
this.mValuesOffset = j2;
}
private byte[] asRawByteArray(int i, int i2) {
getBuffer().setPosition(this.mValuesOffset);
byte[] bArr = new byte[this.mType.getSize() * i2];
getBuffer().readSubSequence(bArr, i * this.mType.getSize(), i2 * this.mType.getSize());
return bArr;
}
@Override // com.squareup.haha.perflib.Instance
public final void accept(Visitor visitor) {
visitor.visitArrayInstance(this);
if (this.mType == Type.OBJECT) {
for (Object obj : getValues()) {
if (obj instanceof Instance) {
if (!this.mReferencesAdded) {
((Instance) obj).addReference(null, this);
}
visitor.visitLater(this, (Instance) obj);
}
}
this.mReferencesAdded = true;
}
}
public char[] asCharArray(int i, int i2) {
CharBuffer asCharBuffer = ByteBuffer.wrap(asRawByteArray(i, i2)).order(HprofBuffer.HPROF_BYTE_ORDER).asCharBuffer();
char[] cArr = new char[i2];
asCharBuffer.get(cArr);
return cArr;
}
public Type getArrayType() {
return this.mType;
}
@Override // com.squareup.haha.perflib.Instance
public ClassObj getClassObj() {
Type type = this.mType;
return type == Type.OBJECT ? super.getClassObj() : this.mHeap.mSnapshot.findClass(Type.getClassNameOfPrimitiveArray(type));
}
@Override // com.squareup.haha.perflib.Instance
public final int getSize() {
return this.mLength * this.mHeap.mSnapshot.getTypeSize(this.mType);
}
public Object[] getValues() {
Object[] objArr = new Object[this.mLength];
getBuffer().setPosition(this.mValuesOffset);
for (int i = 0; i < this.mLength; i++) {
objArr[i] = readValue(this.mType);
}
return objArr;
}
public final String toString() {
String className = getClassObj().getClassName();
if (className.endsWith("[]")) {
className = className.substring(0, className.length() - 2);
}
return String.format("%s[%d]@%d (0x%x)", className, Integer.valueOf(this.mLength), Long.valueOf(getUniqueId()), Long.valueOf(getUniqueId()));
}
}

View File

@@ -0,0 +1,76 @@
package com.squareup.haha.perflib;
import java.util.ArrayList;
import java.util.List;
/* loaded from: classes.dex */
public class ClassInstance extends Instance {
private final long mValuesOffset;
public static class FieldValue {
private Field mField;
private Object mValue;
public FieldValue(Field field, Object obj) {
this.mField = field;
this.mValue = obj;
}
public Field getField() {
return this.mField;
}
public Object getValue() {
return this.mValue;
}
}
public ClassInstance(long j, StackTrace stackTrace, long j2) {
super(j, stackTrace);
this.mValuesOffset = j2;
}
@Override // com.squareup.haha.perflib.Instance
public final void accept(Visitor visitor) {
visitor.visitClassInstance(this);
for (FieldValue fieldValue : getValues()) {
if (fieldValue.getValue() instanceof Instance) {
if (!this.mReferencesAdded) {
((Instance) fieldValue.getValue()).addReference(fieldValue.getField(), this);
}
visitor.visitLater(this, (Instance) fieldValue.getValue());
}
}
this.mReferencesAdded = true;
}
List<FieldValue> getFields(String str) {
ArrayList arrayList = new ArrayList();
for (FieldValue fieldValue : getValues()) {
if (fieldValue.getField().getName().equals(str)) {
arrayList.add(fieldValue);
}
}
return arrayList;
}
@Override // com.squareup.haha.perflib.Instance
public boolean getIsSoftReference() {
return getClassObj().getIsSoftReference();
}
public List<FieldValue> getValues() {
ArrayList arrayList = new ArrayList();
getBuffer().setPosition(this.mValuesOffset);
for (ClassObj classObj = getClassObj(); classObj != null; classObj = classObj.getSuperClassObj()) {
for (Field field : classObj.getFields()) {
arrayList.add(new FieldValue(field, readValue(field.getType())));
}
}
return arrayList;
}
public final String toString() {
return String.format("%s@%d (0x%x)", getClassObj().getClassName(), Long.valueOf(getUniqueId()), Long.valueOf(getUniqueId()));
}
}

View File

@@ -0,0 +1,260 @@
package com.squareup.haha.perflib;
import gnu.trove.TIntObjectHashMap;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Stack;
/* loaded from: classes.dex */
public class ClassObj extends Instance implements Comparable<ClassObj> {
long mClassLoaderId;
final String mClassName;
Field[] mFields;
TIntObjectHashMap<HeapData> mHeapData;
private int mInstanceSize;
private boolean mIsSoftReference;
Field[] mStaticFields;
private final long mStaticFieldsOffset;
Set<ClassObj> mSubclasses;
long mSuperClassId;
public static class HeapData {
public int mShallowSize = 0;
public List<Instance> mInstances = new ArrayList();
}
public ClassObj(long j, StackTrace stackTrace, String str, long j2) {
super(j, stackTrace);
this.mIsSoftReference = false;
this.mHeapData = new TIntObjectHashMap<>();
this.mSubclasses = new HashSet();
this.mClassName = str;
this.mStaticFieldsOffset = j2;
}
public static String getReferenceClassName() {
return "java.lang.ref.Reference";
}
@Override // com.squareup.haha.perflib.Instance
public final void accept(Visitor visitor) {
visitor.visitClassObj(this);
for (Map.Entry<Field, Object> entry : getStaticFieldValues().entrySet()) {
Object value = entry.getValue();
if (value instanceof Instance) {
if (!this.mReferencesAdded) {
((Instance) value).addReference(entry.getKey(), this);
}
visitor.visitLater(this, (Instance) value);
}
}
this.mReferencesAdded = true;
}
public final void addInstance(int i, Instance instance) {
if (instance instanceof ClassInstance) {
instance.setSize(this.mInstanceSize);
}
HeapData heapData = this.mHeapData.get(i);
if (heapData == null) {
heapData = new HeapData();
this.mHeapData.put(i, heapData);
}
heapData.mInstances.add(instance);
heapData.mShallowSize += instance.getSize();
}
public final void addSubclass(ClassObj classObj) {
this.mSubclasses.add(classObj);
}
public final void dump() {
ClassObj classObj = this;
while (true) {
System.out.println("+---------- ClassObj dump for: " + classObj.mClassName);
System.out.println("+----- Static fields");
Map<Field, Object> staticFieldValues = classObj.getStaticFieldValues();
for (Field field : staticFieldValues.keySet()) {
System.out.println(field.getName() + ": " + field.getType() + " = " + staticFieldValues.get(field));
}
System.out.println("+----- Instance fields");
for (Field field2 : classObj.mFields) {
System.out.println(field2.getName() + ": " + field2.getType());
}
if (classObj.getSuperClassObj() == null) {
return;
} else {
classObj = classObj.getSuperClassObj();
}
}
}
public final void dumpSubclasses() {
for (ClassObj classObj : this.mSubclasses) {
System.out.println(" " + classObj.mClassName);
}
}
public final boolean equals(Object obj) {
return (obj instanceof ClassObj) && compareTo((ClassObj) obj) == 0;
}
public int getAllFieldsCount() {
int i = 0;
for (ClassObj classObj = this; classObj != null; classObj = classObj.getSuperClassObj()) {
i += classObj.getFields().length;
}
return i;
}
public Instance getClassLoader() {
return this.mHeap.mSnapshot.findInstance(this.mClassLoaderId);
}
public final String getClassName() {
return this.mClassName;
}
public List<ClassObj> getDescendantClasses() {
ArrayList arrayList = new ArrayList();
Stack stack = new Stack();
stack.push(this);
while (!stack.isEmpty()) {
ClassObj classObj = (ClassObj) stack.pop();
arrayList.add(classObj);
Iterator<ClassObj> it = classObj.getSubclasses().iterator();
while (it.hasNext()) {
stack.push(it.next());
}
}
return arrayList;
}
public Field[] getFields() {
return this.mFields;
}
public List<Instance> getHeapInstances(int i) {
HeapData heapData = this.mHeapData.get(i);
return heapData == null ? new ArrayList(0) : heapData.mInstances;
}
public int getHeapInstancesCount(int i) {
HeapData heapData = this.mHeapData.get(i);
if (heapData == null) {
return 0;
}
return heapData.mInstances.size();
}
public int getInstanceCount() {
int i = 0;
for (Object obj : this.mHeapData.getValues()) {
i += ((HeapData) obj).mInstances.size();
}
return i;
}
public int getInstanceSize() {
return this.mInstanceSize;
}
public List<Instance> getInstancesList() {
ArrayList arrayList = new ArrayList(getInstanceCount());
for (int i : this.mHeapData.keys()) {
arrayList.addAll(getHeapInstances(i));
}
return arrayList;
}
@Override // com.squareup.haha.perflib.Instance
public boolean getIsSoftReference() {
return this.mIsSoftReference;
}
public int getShallowSize(int i) {
if (this.mHeapData.get(i) == null) {
return 0;
}
return this.mHeapData.get(i).mShallowSize;
}
Object getStaticField(Type type, String str) {
return getStaticFieldValues().get(new Field(type, str));
}
public Map<Field, Object> getStaticFieldValues() {
HashMap hashMap = new HashMap();
getBuffer().setPosition(this.mStaticFieldsOffset);
int readUnsignedShort = readUnsignedShort();
for (int i = 0; i < readUnsignedShort; i++) {
Field field = this.mStaticFields[i];
readId();
readUnsignedByte();
hashMap.put(field, readValue(field.getType()));
}
return hashMap;
}
public final Set<ClassObj> getSubclasses() {
return this.mSubclasses;
}
public ClassObj getSuperClassObj() {
return this.mHeap.mSnapshot.findClass(this.mSuperClassId);
}
public int hashCode() {
return this.mClassName.hashCode();
}
public final void setClassLoaderId(long j) {
this.mClassLoaderId = j;
}
public void setFields(Field[] fieldArr) {
this.mFields = fieldArr;
}
public void setInstanceSize(int i) {
this.mInstanceSize = i;
}
public void setIsSoftReference() {
this.mIsSoftReference = true;
}
public void setStaticFields(Field[] fieldArr) {
this.mStaticFields = fieldArr;
}
public final void setSuperClassId(long j) {
this.mSuperClassId = j;
}
public final String toString() {
return this.mClassName.replace('/', '.');
}
@Override // java.lang.Comparable
public final int compareTo(ClassObj classObj) {
if (getId() == classObj.getId()) {
return 0;
}
int compareTo = this.mClassName.compareTo(classObj.mClassName);
return compareTo != 0 ? compareTo : getId() - classObj.getId() > 0 ? 1 : -1;
}
public int getShallowSize() {
int i = 0;
for (Object obj : this.mHeapData.getValues()) {
i += ((HeapData) obj).mShallowSize;
}
return i;
}
}

View File

@@ -0,0 +1,37 @@
package com.squareup.haha.perflib;
import java.util.Arrays;
/* loaded from: classes.dex */
public final class Field {
private final String mName;
private final Type mType;
public Field(Type type, String str) {
this.mType = type;
this.mName = str;
}
public final boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Field)) {
return false;
}
Field field = (Field) obj;
return this.mType == field.mType && this.mName.equals(field.mName);
}
public final String getName() {
return this.mName;
}
public final Type getType() {
return this.mType;
}
public final int hashCode() {
return Arrays.hashCode(new Object[]{this.mType, this.mName});
}
}

View File

@@ -0,0 +1,26 @@
package com.squareup.haha.perflib;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
/* loaded from: classes.dex */
public final class HahaSpy {
private HahaSpy() {
throw new AssertionError();
}
public static Set<RootObj> allGcRoots(Snapshot snapshot) {
HashSet hashSet = new HashSet();
Iterator<Heap> it = snapshot.getHeaps().iterator();
while (it.hasNext()) {
hashSet.addAll(it.next().mRoots);
}
return hashSet;
}
public static Instance allocatingThread(Instance instance) {
Snapshot snapshot = instance.mHeap.mSnapshot;
return snapshot.findInstance(snapshot.getThread(instance instanceof RootObj ? ((RootObj) instance).mThread : instance.mStack.mThreadSerialNumber).mId);
}
}

View File

@@ -0,0 +1,154 @@
package com.squareup.haha.perflib;
import com.squareup.haha.guava.collect.ArrayListMultimap;
import com.squareup.haha.guava.collect.Multimap;
import gnu.trove.TIntObjectHashMap;
import gnu.trove.TLongObjectHashMap;
import gnu.trove.TObjectProcedure;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
/* loaded from: classes.dex */
public class Heap {
private final int mId;
private final String mName;
Snapshot mSnapshot;
TLongObjectHashMap<StackFrame> mFrames = new TLongObjectHashMap<>();
TIntObjectHashMap<StackTrace> mTraces = new TIntObjectHashMap<>();
ArrayList<RootObj> mRoots = new ArrayList<>();
TIntObjectHashMap<ThreadObj> mThreads = new TIntObjectHashMap<>();
TLongObjectHashMap<ClassObj> mClassesById = new TLongObjectHashMap<>();
Multimap<String, ClassObj> mClassesByName = ArrayListMultimap.create();
private final TLongObjectHashMap<Instance> mInstances = new TLongObjectHashMap<>();
public Heap(int i, String str) {
this.mId = i;
this.mName = str;
}
public final void addClass(long j, ClassObj classObj) {
this.mClassesById.put(j, classObj);
this.mClassesByName.put(classObj.mClassName, classObj);
}
public final void addInstance(long j, Instance instance) {
this.mInstances.put(j, instance);
}
public final void addRoot(RootObj rootObj) {
rootObj.mIndex = this.mRoots.size();
this.mRoots.add(rootObj);
}
public final void addStackFrame(StackFrame stackFrame) {
this.mFrames.put(stackFrame.mId, stackFrame);
}
public final void addStackTrace(StackTrace stackTrace) {
this.mTraces.put(stackTrace.mSerialNumber, stackTrace);
}
public final void addThread(ThreadObj threadObj, int i) {
this.mThreads.put(i, threadObj);
}
public final void dumpInstanceCounts() {
for (Object obj : this.mClassesById.getValues()) {
ClassObj classObj = (ClassObj) obj;
int instanceCount = classObj.getInstanceCount();
if (instanceCount > 0) {
System.out.println(classObj + ": " + instanceCount);
}
}
}
public final void dumpSizes() {
for (Object obj : this.mClassesById.getValues()) {
ClassObj classObj = (ClassObj) obj;
Iterator<Instance> it = classObj.getHeapInstances(getId()).iterator();
int i = 0;
while (it.hasNext()) {
i += it.next().getCompositeSize();
}
if (i > 0) {
System.out.println(classObj + ": base " + classObj.getSize() + ", composite " + i);
}
}
}
public final void dumpSubclasses() {
for (Object obj : this.mClassesById.getValues()) {
ClassObj classObj = (ClassObj) obj;
if (classObj.mSubclasses.size() > 0) {
System.out.println(classObj);
classObj.dumpSubclasses();
}
}
}
public final ClassObj getClass(long j) {
return this.mClassesById.get(j);
}
public final Collection<ClassObj> getClasses(String str) {
return this.mClassesByName.get(str);
}
public int getId() {
return this.mId;
}
public final Instance getInstance(long j) {
return this.mInstances.get(j);
}
public Collection<Instance> getInstances() {
final ArrayList arrayList = new ArrayList(this.mInstances.size());
this.mInstances.forEachValue(new TObjectProcedure<Instance>() { // from class: com.squareup.haha.perflib.Heap.1
@Override // gnu.trove.TObjectProcedure
public boolean execute(Instance instance) {
arrayList.add(instance);
return true;
}
});
return arrayList;
}
public int getInstancesCount() {
return this.mInstances.size();
}
public String getName() {
return this.mName;
}
public final StackFrame getStackFrame(long j) {
return this.mFrames.get(j);
}
public final StackTrace getStackTrace(int i) {
return this.mTraces.get(i);
}
public final StackTrace getStackTraceAtDepth(int i, int i2) {
StackTrace stackTrace = this.mTraces.get(i);
return stackTrace != null ? stackTrace.fromDepth(i2) : stackTrace;
}
public final ThreadObj getThread(int i) {
return this.mThreads.get(i);
}
public final ClassObj getClass(String str) {
Collection<ClassObj> collection = this.mClassesByName.get(str);
if (collection.size() == 1) {
return collection.iterator().next();
}
return null;
}
public Collection<ClassObj> getClasses() {
return this.mClassesByName.values();
}
}

View File

@@ -0,0 +1,402 @@
package com.squareup.haha.perflib;
import com.squareup.haha.perflib.io.HprofBuffer;
import gnu.trove.TLongObjectHashMap;
import java.io.EOFException;
import java.io.IOException;
/* loaded from: classes.dex */
public class HprofParser {
private static final int ALLOC_SITES = 6;
private static final int CONTROL_SETTINGS = 14;
private static final int CPU_SAMPLES = 13;
private static final int END_THREAD = 11;
private static final int HEAP_DUMP = 12;
private static final int HEAP_DUMP_END = 44;
private static final int HEAP_DUMP_SEGMENT = 28;
private static final int HEAP_SUMMARY = 7;
private static final int LOAD_CLASS = 2;
private static final int ROOT_CLASS_DUMP = 32;
private static final int ROOT_DEBUGGER = 139;
private static final int ROOT_FINALIZING = 138;
private static final int ROOT_HEAP_DUMP_INFO = 254;
private static final int ROOT_INSTANCE_DUMP = 33;
private static final int ROOT_INTERNED_STRING = 137;
private static final int ROOT_JAVA_FRAME = 3;
private static final int ROOT_JNI_GLOBAL = 1;
private static final int ROOT_JNI_LOCAL = 2;
private static final int ROOT_JNI_MONITOR = 142;
private static final int ROOT_MONITOR_USED = 7;
private static final int ROOT_NATIVE_STACK = 4;
private static final int ROOT_OBJECT_ARRAY_DUMP = 34;
private static final int ROOT_PRIMITIVE_ARRAY_DUMP = 35;
private static final int ROOT_PRIMITIVE_ARRAY_NODATA = 195;
private static final int ROOT_REFERENCE_CLEANUP = 140;
private static final int ROOT_STICKY_CLASS = 5;
private static final int ROOT_THREAD_BLOCK = 6;
private static final int ROOT_THREAD_OBJECT = 8;
private static final int ROOT_UNKNOWN = 255;
private static final int ROOT_UNREACHABLE = 144;
private static final int ROOT_VM_INTERNAL = 141;
private static final int STACK_FRAME = 4;
private static final int STACK_TRACE = 5;
private static final int START_THREAD = 10;
private static final int STRING_IN_UTF8 = 1;
private static final int UNLOAD_CLASS = 3;
int mIdSize;
private final HprofBuffer mInput;
Snapshot mSnapshot;
TLongObjectHashMap<String> mStrings = new TLongObjectHashMap<>();
TLongObjectHashMap<String> mClassNames = new TLongObjectHashMap<>();
public HprofParser(HprofBuffer hprofBuffer) {
this.mInput = hprofBuffer;
}
private int loadBasicObj(RootType rootType) throws IOException {
this.mSnapshot.addRoot(new RootObj(rootType, readId()));
return this.mIdSize;
}
private void loadClass() throws IOException {
this.mInput.readInt();
long readId = readId();
this.mInput.readInt();
this.mClassNames.put(readId, this.mStrings.get(readId()));
}
private int loadClassDump() throws IOException {
long readId = readId();
StackTrace stackTrace = this.mSnapshot.getStackTrace(this.mInput.readInt());
long readId2 = readId();
long readId3 = readId();
readId();
readId();
readId();
readId();
int readInt = this.mInput.readInt();
int i = (this.mIdSize * 7) + 4 + 4;
int readUnsignedShort = readUnsignedShort();
int i2 = i + 2;
for (int i3 = 0; i3 < readUnsignedShort; i3++) {
readUnsignedShort();
i2 += skipValue() + 2;
}
ClassObj classObj = new ClassObj(readId, stackTrace, this.mClassNames.get(readId), this.mInput.position());
classObj.setSuperClassId(readId2);
classObj.setClassLoaderId(readId3);
int readUnsignedShort2 = readUnsignedShort();
int i4 = i2 + 2;
Field[] fieldArr = new Field[readUnsignedShort2];
for (int i5 = 0; i5 < readUnsignedShort2; i5++) {
String str = this.mStrings.get(readId());
Type type = Type.getType(this.mInput.readByte());
fieldArr[i5] = new Field(type, str);
skipFully(this.mSnapshot.getTypeSize(type));
i4 += this.mIdSize + 1 + this.mSnapshot.getTypeSize(type);
}
classObj.setStaticFields(fieldArr);
int readUnsignedShort3 = readUnsignedShort();
int i6 = i4 + 2;
Field[] fieldArr2 = new Field[readUnsignedShort3];
for (int i7 = 0; i7 < readUnsignedShort3; i7++) {
fieldArr2[i7] = new Field(Type.getType(readUnsignedByte()), this.mStrings.get(readId()));
i6 += this.mIdSize + 1;
}
classObj.setFields(fieldArr2);
classObj.setInstanceSize(readInt);
this.mSnapshot.addClass(readId, classObj);
return i6;
}
private void loadHeapDump(long j) throws IOException {
int loadBasicObj;
while (j > 0) {
int readUnsignedByte = readUnsignedByte();
long j2 = j - 1;
if (readUnsignedByte == ROOT_UNREACHABLE) {
loadBasicObj = loadBasicObj(RootType.UNREACHABLE);
} else {
if (readUnsignedByte == ROOT_PRIMITIVE_ARRAY_NODATA) {
System.err.println("+--- PRIMITIVE ARRAY NODATA DUMP");
loadPrimitiveArrayDump();
throw new IllegalArgumentException("Don't know how to load a nodata array");
}
if (readUnsignedByte == ROOT_HEAP_DUMP_INFO) {
this.mSnapshot.setHeapTo(this.mInput.readInt(), this.mStrings.get(readId()));
loadBasicObj = this.mIdSize + 4;
} else if (readUnsignedByte != ROOT_UNKNOWN) {
switch (readUnsignedByte) {
case 1:
j2 -= loadBasicObj(RootType.NATIVE_STATIC);
readId();
loadBasicObj = this.mIdSize;
break;
case 2:
loadBasicObj = loadJniLocal();
break;
case 3:
loadBasicObj = loadJavaFrame();
break;
case 4:
loadBasicObj = loadNativeStack();
break;
case 5:
loadBasicObj = loadBasicObj(RootType.SYSTEM_CLASS);
break;
case 6:
loadBasicObj = loadThreadBlock();
break;
case 7:
loadBasicObj = loadBasicObj(RootType.BUSY_MONITOR);
break;
case 8:
loadBasicObj = loadThreadObject();
break;
default:
switch (readUnsignedByte) {
case 32:
loadBasicObj = loadClassDump();
break;
case 33:
loadBasicObj = loadInstanceDump();
break;
case 34:
loadBasicObj = loadObjectArrayDump();
break;
case 35:
loadBasicObj = loadPrimitiveArrayDump();
break;
default:
switch (readUnsignedByte) {
case ROOT_INTERNED_STRING /* 137 */:
loadBasicObj = loadBasicObj(RootType.INTERNED_STRING);
break;
case ROOT_FINALIZING /* 138 */:
loadBasicObj = loadBasicObj(RootType.FINALIZING);
break;
case ROOT_DEBUGGER /* 139 */:
loadBasicObj = loadBasicObj(RootType.DEBUGGER);
break;
case 140:
loadBasicObj = loadBasicObj(RootType.REFERENCE_CLEANUP);
break;
case ROOT_VM_INTERNAL /* 141 */:
loadBasicObj = loadBasicObj(RootType.VM_INTERNAL);
break;
case ROOT_JNI_MONITOR /* 142 */:
loadBasicObj = loadJniMonitor();
break;
default:
throw new IllegalArgumentException("loadHeapDump loop with unknown tag " + readUnsignedByte + " with " + this.mInput.remaining() + " bytes possibly remaining");
}
}
}
} else {
loadBasicObj = loadBasicObj(RootType.UNKNOWN);
}
}
j = j2 - loadBasicObj;
}
}
private int loadInstanceDump() throws IOException {
long readId = readId();
StackTrace stackTrace = this.mSnapshot.getStackTrace(this.mInput.readInt());
long readId2 = readId();
int readInt = this.mInput.readInt();
ClassInstance classInstance = new ClassInstance(readId, stackTrace, this.mInput.position());
classInstance.setClassId(readId2);
this.mSnapshot.addInstance(readId, classInstance);
skipFully(readInt);
int i = this.mIdSize;
return i + 4 + i + 4 + readInt;
}
private int loadJavaFrame() throws IOException {
long readId = readId();
int readInt = this.mInput.readInt();
this.mSnapshot.addRoot(new RootObj(RootType.JAVA_LOCAL, readId, readInt, this.mSnapshot.getStackTraceAtDepth(this.mSnapshot.getThread(readInt).mStackTrace, this.mInput.readInt())));
return this.mIdSize + 4 + 4;
}
private int loadJniLocal() throws IOException {
long readId = readId();
int readInt = this.mInput.readInt();
this.mSnapshot.addRoot(new RootObj(RootType.NATIVE_LOCAL, readId, readInt, this.mSnapshot.getStackTraceAtDepth(this.mSnapshot.getThread(readInt).mStackTrace, this.mInput.readInt())));
return this.mIdSize + 4 + 4;
}
private int loadJniMonitor() throws IOException {
long readId = readId();
int readInt = this.mInput.readInt();
this.mSnapshot.addRoot(new RootObj(RootType.NATIVE_MONITOR, readId, readInt, this.mSnapshot.getStackTraceAtDepth(this.mSnapshot.getThread(readInt).mStackTrace, this.mInput.readInt())));
return this.mIdSize + 4 + 4;
}
private int loadNativeStack() throws IOException {
long readId = readId();
int readInt = this.mInput.readInt();
this.mSnapshot.addRoot(new RootObj(RootType.NATIVE_STACK, readId, readInt, this.mSnapshot.getStackTrace(this.mSnapshot.getThread(readInt).mStackTrace)));
return this.mIdSize + 4;
}
private int loadObjectArrayDump() throws IOException {
long readId = readId();
StackTrace stackTrace = this.mSnapshot.getStackTrace(this.mInput.readInt());
int readInt = this.mInput.readInt();
long readId2 = readId();
ArrayInstance arrayInstance = new ArrayInstance(readId, stackTrace, Type.OBJECT, readInt, this.mInput.position());
arrayInstance.setClassId(readId2);
this.mSnapshot.addInstance(readId, arrayInstance);
int i = readInt * this.mIdSize;
skipFully(i);
int i2 = this.mIdSize;
return i2 + 4 + 4 + i2 + i;
}
private int loadPrimitiveArrayDump() throws IOException {
long readId = readId();
StackTrace stackTrace = this.mSnapshot.getStackTrace(this.mInput.readInt());
int readInt = this.mInput.readInt();
Type type = Type.getType(readUnsignedByte());
int typeSize = this.mSnapshot.getTypeSize(type);
this.mSnapshot.addInstance(readId, new ArrayInstance(readId, stackTrace, type, readInt, this.mInput.position()));
int i = readInt * typeSize;
skipFully(i);
return this.mIdSize + 4 + 4 + 1 + i;
}
private void loadStackFrame() throws IOException {
this.mSnapshot.addStackFrame(new StackFrame(readId(), this.mStrings.get(readId()), this.mStrings.get(readId()), this.mStrings.get(readId()), this.mInput.readInt(), this.mInput.readInt()));
}
private void loadStackTrace() throws IOException {
int readInt = this.mInput.readInt();
int readInt2 = this.mInput.readInt();
int readInt3 = this.mInput.readInt();
StackFrame[] stackFrameArr = new StackFrame[readInt3];
for (int i = 0; i < readInt3; i++) {
stackFrameArr[i] = this.mSnapshot.getStackFrame(readId());
}
this.mSnapshot.addStackTrace(new StackTrace(readInt, readInt2, stackFrameArr));
}
private void loadString(int i) throws IOException {
this.mStrings.put(readId(), readUTF8(i));
}
private int loadThreadBlock() throws IOException {
long readId = readId();
int readInt = this.mInput.readInt();
this.mSnapshot.addRoot(new RootObj(RootType.THREAD_BLOCK, readId, readInt, this.mSnapshot.getStackTrace(this.mSnapshot.getThread(readInt).mStackTrace)));
return this.mIdSize + 4;
}
private int loadThreadObject() throws IOException {
long readId = readId();
int readInt = this.mInput.readInt();
this.mSnapshot.addThread(new ThreadObj(readId, this.mInput.readInt()), readInt);
return this.mIdSize + 4 + 4;
}
private long readId() throws IOException {
int i = this.mIdSize;
if (i == 1) {
return this.mInput.readByte();
}
if (i == 2) {
return this.mInput.readShort();
}
if (i == 4) {
return this.mInput.readInt();
}
if (i == 8) {
return this.mInput.readLong();
}
throw new IllegalArgumentException("ID Length must be 1, 2, 4, or 8");
}
private String readNullTerminatedString() throws IOException {
StringBuilder sb = new StringBuilder();
while (true) {
byte readByte = this.mInput.readByte();
if (readByte == 0) {
return sb.toString();
}
sb.append((char) readByte);
}
}
private String readUTF8(int i) throws IOException {
byte[] bArr = new byte[i];
this.mInput.read(bArr);
return new String(bArr, "utf-8");
}
private int readUnsignedByte() throws IOException {
return this.mInput.readByte() & 255;
}
private long readUnsignedInt() throws IOException {
return this.mInput.readInt() & 4294967295L;
}
private int readUnsignedShort() throws IOException {
return this.mInput.readShort() & 65535;
}
private void skipFully(long j) throws IOException {
HprofBuffer hprofBuffer = this.mInput;
hprofBuffer.setPosition(hprofBuffer.position() + j);
}
private int skipValue() throws IOException {
int typeSize = this.mSnapshot.getTypeSize(Type.getType(readUnsignedByte()));
skipFully(typeSize);
return typeSize + 1;
}
public final Snapshot parse() {
Snapshot snapshot = new Snapshot(this.mInput);
this.mSnapshot = snapshot;
try {
try {
readNullTerminatedString();
this.mIdSize = this.mInput.readInt();
this.mSnapshot.setIdSize(this.mIdSize);
this.mInput.readLong();
while (this.mInput.hasRemaining()) {
int readUnsignedByte = readUnsignedByte();
this.mInput.readInt();
long readUnsignedInt = readUnsignedInt();
if (readUnsignedByte == 1) {
loadString(((int) readUnsignedInt) - this.mIdSize);
} else if (readUnsignedByte == 2) {
loadClass();
} else if (readUnsignedByte == 4) {
loadStackFrame();
} else if (readUnsignedByte == 5) {
loadStackTrace();
} else if (readUnsignedByte == 12) {
loadHeapDump(readUnsignedInt);
this.mSnapshot.setToDefaultHeap();
} else if (readUnsignedByte != 28) {
skipFully(readUnsignedInt);
} else {
loadHeapDump(readUnsignedInt);
this.mSnapshot.setToDefaultHeap();
}
}
} catch (EOFException unused) {
}
this.mSnapshot.resolveClasses();
this.mSnapshot.resolveReferences();
} catch (Exception e) {
e.printStackTrace();
}
this.mClassNames.clear();
this.mStrings.clear();
return snapshot;
}
}

View File

@@ -0,0 +1,267 @@
package com.squareup.haha.perflib;
import com.squareup.haha.guava.collect.ImmutableList;
import com.squareup.haha.perflib.io.HprofBuffer;
import java.util.ArrayList;
import java.util.Arrays;
/* loaded from: classes.dex */
public abstract class Instance {
static final /* synthetic */ boolean $assertionsDisabled = false;
long mClassId;
Heap mHeap;
protected final long mId;
private Instance mImmediateDominator;
private long[] mRetainedSizes;
int mSize;
protected final StackTrace mStack;
int mTopologicalOrder;
int mDistanceToGcRoot = Integer.MAX_VALUE;
boolean mReferencesAdded = false;
Instance mNextInstanceToGcRoot = null;
private final ArrayList<Instance> mHardReferences = new ArrayList<>();
private ArrayList<Instance> mSoftReferences = null;
/* renamed from: com.squareup.haha.perflib.Instance$1, reason: invalid class name */
static /* synthetic */ class AnonymousClass1 {
static final /* synthetic */ int[] $SwitchMap$com$android$tools$perflib$heap$Type = new int[Type.values().length];
static {
try {
$SwitchMap$com$android$tools$perflib$heap$Type[Type.OBJECT.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$com$android$tools$perflib$heap$Type[Type.BOOLEAN.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$com$android$tools$perflib$heap$Type[Type.CHAR.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
$SwitchMap$com$android$tools$perflib$heap$Type[Type.FLOAT.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
$SwitchMap$com$android$tools$perflib$heap$Type[Type.DOUBLE.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
try {
$SwitchMap$com$android$tools$perflib$heap$Type[Type.BYTE.ordinal()] = 6;
} catch (NoSuchFieldError unused6) {
}
try {
$SwitchMap$com$android$tools$perflib$heap$Type[Type.SHORT.ordinal()] = 7;
} catch (NoSuchFieldError unused7) {
}
try {
$SwitchMap$com$android$tools$perflib$heap$Type[Type.INT.ordinal()] = 8;
} catch (NoSuchFieldError unused8) {
}
try {
$SwitchMap$com$android$tools$perflib$heap$Type[Type.LONG.ordinal()] = 9;
} catch (NoSuchFieldError unused9) {
}
}
}
public static class CompositeSizeVisitor extends NonRecursiveVisitor {
int mSize = 0;
@Override // com.squareup.haha.perflib.NonRecursiveVisitor
protected void defaultAction(Instance instance) {
this.mSize += instance.getSize();
}
public int getCompositeSize() {
return this.mSize;
}
}
Instance(long j, StackTrace stackTrace) {
this.mId = j;
this.mStack = stackTrace;
}
public abstract void accept(Visitor visitor);
public void addReference(Field field, Instance instance) {
if (!instance.getIsSoftReference() || field == null || !field.getName().equals("referent")) {
this.mHardReferences.add(instance);
return;
}
if (this.mSoftReferences == null) {
this.mSoftReferences = new ArrayList<>();
}
this.mSoftReferences.add(instance);
}
public void addRetainedSize(int i, long j) {
long[] jArr = this.mRetainedSizes;
jArr[i] = jArr[i] + j;
}
protected HprofBuffer getBuffer() {
return this.mHeap.mSnapshot.mBuffer;
}
public ClassObj getClassObj() {
return this.mHeap.mSnapshot.findClass(this.mClassId);
}
public final int getCompositeSize() {
CompositeSizeVisitor compositeSizeVisitor = new CompositeSizeVisitor();
compositeSizeVisitor.doVisit(ImmutableList.of(this));
return compositeSizeVisitor.getCompositeSize();
}
public int getDistanceToGcRoot() {
return this.mDistanceToGcRoot;
}
public ArrayList<Instance> getHardReferences() {
return this.mHardReferences;
}
public Heap getHeap() {
return this.mHeap;
}
public long getId() {
return this.mId;
}
public Instance getImmediateDominator() {
return this.mImmediateDominator;
}
public boolean getIsSoftReference() {
return false;
}
public Instance getNextInstanceToGcRoot() {
return this.mNextInstanceToGcRoot;
}
public long getRetainedSize(int i) {
return this.mRetainedSizes[i];
}
public int getSize() {
return this.mSize;
}
public ArrayList<Instance> getSoftReferences() {
return this.mSoftReferences;
}
public int getTopologicalOrder() {
return this.mTopologicalOrder;
}
public long getTotalRetainedSize() {
long[] jArr = this.mRetainedSizes;
long j = 0;
if (jArr == null) {
return 0L;
}
for (long j2 : jArr) {
j += j2;
}
return j;
}
public long getUniqueId() {
return getId() & this.mHeap.mSnapshot.getIdSizeMask();
}
protected long readId() {
int typeSize = this.mHeap.mSnapshot.getTypeSize(Type.OBJECT);
if (typeSize == 1) {
return getBuffer().readByte();
}
if (typeSize == 2) {
return getBuffer().readShort();
}
if (typeSize == 4) {
return getBuffer().readInt();
}
if (typeSize != 8) {
return 0L;
}
return getBuffer().readLong();
}
protected int readUnsignedByte() {
return getBuffer().readByte() & 255;
}
protected int readUnsignedShort() {
return getBuffer().readShort() & 65535;
}
protected Object readValue(Type type) {
switch (AnonymousClass1.$SwitchMap$com$android$tools$perflib$heap$Type[type.ordinal()]) {
case 1:
return this.mHeap.mSnapshot.findInstance(readId());
case 2:
return Boolean.valueOf(getBuffer().readByte() != 0);
case 3:
return Character.valueOf(getBuffer().readChar());
case 4:
return Float.valueOf(getBuffer().readFloat());
case 5:
return Double.valueOf(getBuffer().readDouble());
case 6:
return Byte.valueOf(getBuffer().readByte());
case 7:
return Short.valueOf(getBuffer().readShort());
case 8:
return Integer.valueOf(getBuffer().readInt());
case 9:
return Long.valueOf(getBuffer().readLong());
default:
return null;
}
}
public void resetRetainedSize() {
ArrayList<Heap> arrayList = this.mHeap.mSnapshot.mHeaps;
long[] jArr = this.mRetainedSizes;
if (jArr == null) {
this.mRetainedSizes = new long[arrayList.size()];
} else {
Arrays.fill(jArr, 0L);
}
this.mRetainedSizes[arrayList.indexOf(this.mHeap)] = getSize();
}
public void setClassId(long j) {
this.mClassId = j;
}
public void setDistanceToGcRoot(int i) {
this.mDistanceToGcRoot = i;
}
public void setHeap(Heap heap) {
this.mHeap = heap;
}
public void setImmediateDominator(Instance instance) {
this.mImmediateDominator = instance;
}
public void setNextInstanceToGcRoot(Instance instance) {
this.mNextInstanceToGcRoot = instance;
}
public void setSize(int i) {
this.mSize = i;
}
public void setTopologicalOrder(int i) {
this.mTopologicalOrder = i;
}
}

View File

@@ -0,0 +1,54 @@
package com.squareup.haha.perflib;
import com.squareup.haha.perflib.io.MemoryMappedFileBuffer;
import java.io.File;
import java.util.Map;
import java.util.Set;
/* loaded from: classes.dex */
public class Main {
public static void main(String[] strArr) {
try {
long nanoTime = System.nanoTime();
Snapshot parse = new HprofParser(new MemoryMappedFileBuffer(new File(strArr[0]))).parse();
testClassesQuery(parse);
testAllClassesQuery(parse);
testFindInstancesOf(parse);
testFindAllInstancesOf(parse);
System.out.println("Memory stats: free=" + Runtime.getRuntime().freeMemory() + " / total=" + Runtime.getRuntime().totalMemory());
System.out.println("Time: " + ((System.nanoTime() - nanoTime) / 1000000) + "ms");
} catch (Exception e) {
e.printStackTrace();
}
}
private static void testAllClassesQuery(Snapshot snapshot) {
Map<String, Set<ClassObj>> allClasses = Queries.allClasses(snapshot);
for (String str : allClasses.keySet()) {
System.out.println("------------------- " + str);
for (ClassObj classObj : allClasses.get(str)) {
System.out.println(" " + classObj.mClassName);
}
}
}
private static void testClassesQuery(Snapshot snapshot) {
Map<String, Set<ClassObj>> classes = Queries.classes(snapshot, new String[]{"char[", "javax.", "org.xml.sax"});
for (String str : classes.keySet()) {
System.out.println("------------------- " + str);
for (ClassObj classObj : classes.get(str)) {
System.out.println(" " + classObj.mClassName);
}
}
}
private static void testFindAllInstancesOf(Snapshot snapshot) {
Instance[] allInstancesOf = Queries.allInstancesOf(snapshot, "android.graphics.drawable.Drawable");
System.out.println("There are " + allInstancesOf.length + " instances of Drawables and its subclasses.");
}
private static void testFindInstancesOf(Snapshot snapshot) {
Instance[] instancesOf = Queries.instancesOf(snapshot, "java.lang.String");
System.out.println("There are " + instancesOf.length + " Strings.");
}
}

View File

@@ -0,0 +1,55 @@
package com.squareup.haha.perflib;
import gnu.trove.TLongHashSet;
import java.util.ArrayDeque;
import java.util.Deque;
/* loaded from: classes.dex */
public class NonRecursiveVisitor implements Visitor {
public final Deque<Instance> mStack = new ArrayDeque();
public final TLongHashSet mSeen = new TLongHashSet();
protected void defaultAction(Instance instance) {
}
public void doVisit(Iterable<? extends Instance> iterable) {
for (Instance instance : iterable) {
if (instance instanceof RootObj) {
instance.accept(this);
} else {
visitLater(null, instance);
}
}
while (!this.mStack.isEmpty()) {
Instance pop = this.mStack.pop();
if (this.mSeen.add(pop.getId())) {
pop.accept(this);
}
}
}
@Override // com.squareup.haha.perflib.Visitor
public void visitArrayInstance(ArrayInstance arrayInstance) {
defaultAction(arrayInstance);
}
@Override // com.squareup.haha.perflib.Visitor
public void visitClassInstance(ClassInstance classInstance) {
defaultAction(classInstance);
}
@Override // com.squareup.haha.perflib.Visitor
public void visitClassObj(ClassObj classObj) {
defaultAction(classObj);
}
@Override // com.squareup.haha.perflib.Visitor
public void visitLater(Instance instance, Instance instance2) {
this.mStack.push(instance2);
}
@Override // com.squareup.haha.perflib.Visitor
public void visitRootObj(RootObj rootObj) {
defaultAction(rootObj);
}
}

View File

@@ -0,0 +1,142 @@
package com.squareup.haha.perflib;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
/* loaded from: classes.dex */
public class Queries {
private static final String DEFAULT_PACKAGE = "<default>";
public static Map<String, Set<ClassObj>> allClasses(Snapshot snapshot) {
return classes(snapshot, null);
}
public static Instance[] allInstancesOf(Snapshot snapshot, String str) {
ClassObj findClass = snapshot.findClass(str);
if (findClass == null) {
throw new IllegalArgumentException("Class not found: " + str);
}
ArrayList arrayList = new ArrayList();
arrayList.add(findClass);
arrayList.addAll(traverseSubclasses(findClass));
ArrayList arrayList2 = new ArrayList();
Iterator it = arrayList.iterator();
while (it.hasNext()) {
arrayList2.addAll(((ClassObj) it.next()).getInstancesList());
}
Instance[] instanceArr = new Instance[arrayList2.size()];
arrayList2.toArray(instanceArr);
return instanceArr;
}
public static Map<String, Set<ClassObj>> classes(Snapshot snapshot, String[] strArr) {
TreeMap treeMap = new TreeMap();
TreeSet<ClassObj> treeSet = new TreeSet();
Iterator<Heap> it = snapshot.mHeaps.iterator();
while (it.hasNext()) {
treeSet.addAll(it.next().getClasses());
}
if (strArr != null) {
int length = strArr.length;
Iterator it2 = treeSet.iterator();
while (it2.hasNext()) {
String classObj = ((ClassObj) it2.next()).toString();
int i = 0;
while (true) {
if (i >= length) {
break;
}
if (classObj.startsWith(strArr[i])) {
it2.remove();
break;
}
i++;
}
}
}
for (ClassObj classObj2 : treeSet) {
int lastIndexOf = classObj2.mClassName.lastIndexOf(46);
String substring = lastIndexOf != -1 ? classObj2.mClassName.substring(0, lastIndexOf) : DEFAULT_PACKAGE;
Set set = (Set) treeMap.get(substring);
if (set == null) {
set = new TreeSet();
treeMap.put(substring, set);
}
set.add(classObj2);
}
return treeMap;
}
public static Collection<ClassObj> commonClasses(Snapshot snapshot, Snapshot snapshot2) {
ArrayList arrayList = new ArrayList();
Iterator<Heap> it = snapshot.getHeaps().iterator();
while (it.hasNext()) {
for (ClassObj classObj : it.next().getClasses()) {
if (snapshot2.findClass(classObj.getClassName()) != null) {
arrayList.add(classObj);
}
}
}
return arrayList;
}
public static ClassObj findClass(Snapshot snapshot, String str) {
return snapshot.findClass(str);
}
public static Instance findObject(Snapshot snapshot, String str) {
return snapshot.findInstance(Long.parseLong(str, 16));
}
public static Collection<RootObj> getRoots(Snapshot snapshot) {
HashSet hashSet = new HashSet();
Iterator<Heap> it = snapshot.mHeaps.iterator();
while (it.hasNext()) {
hashSet.addAll(it.next().mRoots);
}
return hashSet;
}
public static Instance[] instancesOf(Snapshot snapshot, String str) {
ClassObj findClass = snapshot.findClass(str);
if (findClass != null) {
List<Instance> instancesList = findClass.getInstancesList();
return (Instance[]) instancesList.toArray(new Instance[instancesList.size()]);
}
throw new IllegalArgumentException("Class not found: " + str);
}
public static final Instance[] newInstances(Snapshot snapshot, Snapshot snapshot2) {
ArrayList arrayList = new ArrayList();
Iterator<Heap> it = snapshot2.mHeaps.iterator();
while (it.hasNext()) {
Heap next = it.next();
Heap heap = snapshot.getHeap(next.getName());
if (heap != null) {
for (Instance instance : next.getInstances()) {
Instance heap2 = heap.getInstance(instance.mId);
if (heap2 == null || instance.getClassObj() != heap2.getClassObj()) {
arrayList.add(instance);
}
}
}
}
return (Instance[]) arrayList.toArray(new Instance[arrayList.size()]);
}
private static ArrayList<ClassObj> traverseSubclasses(ClassObj classObj) {
ArrayList<ClassObj> arrayList = new ArrayList<>();
for (ClassObj classObj2 : classObj.mSubclasses) {
arrayList.add(classObj2);
arrayList.addAll(traverseSubclasses(classObj2));
}
return arrayList;
}
}

View File

@@ -0,0 +1,50 @@
package com.squareup.haha.perflib;
/* loaded from: classes.dex */
public class RootObj extends Instance {
public static final String UNDEFINED_CLASS_NAME = "no class defined!!";
int mIndex;
int mThread;
RootType mType;
public RootObj(RootType rootType) {
this(rootType, 0L, 0, null);
}
@Override // com.squareup.haha.perflib.Instance
public final void accept(Visitor visitor) {
visitor.visitRootObj(this);
Instance referredInstance = getReferredInstance();
if (referredInstance != null) {
visitor.visitLater(null, referredInstance);
}
}
public final String getClassName(Snapshot snapshot) {
ClassObj findClass = this.mType == RootType.SYSTEM_CLASS ? snapshot.findClass(this.mId) : snapshot.findInstance(this.mId).getClassObj();
return findClass == null ? UNDEFINED_CLASS_NAME : findClass.mClassName;
}
public Instance getReferredInstance() {
return this.mType == RootType.SYSTEM_CLASS ? this.mHeap.mSnapshot.findClass(this.mId) : this.mHeap.mSnapshot.findInstance(this.mId);
}
public RootType getRootType() {
return this.mType;
}
public final String toString() {
return String.format("%s@0x%08x", this.mType.getName(), Long.valueOf(this.mId));
}
public RootObj(RootType rootType, long j) {
this(rootType, j, 0, null);
}
public RootObj(RootType rootType, long j, int i, StackTrace stackTrace) {
super(j, stackTrace);
this.mType = RootType.UNKNOWN;
this.mType = rootType;
this.mThread = i;
}
}

View File

@@ -0,0 +1,40 @@
package com.squareup.haha.perflib;
import com.ubt.jimu.diy.model.CategoryModel;
/* loaded from: classes.dex */
public enum RootType {
UNREACHABLE(0, "unreachable object"),
INVALID_TYPE(1, "invalid type"),
INTERNED_STRING(2, "interned string"),
UNKNOWN(3, CategoryModel.unknown),
SYSTEM_CLASS(4, "system class"),
VM_INTERNAL(5, "vm internal"),
DEBUGGER(6, "debugger"),
NATIVE_LOCAL(7, "native local"),
NATIVE_STATIC(8, "native static"),
THREAD_BLOCK(9, "thread block"),
BUSY_MONITOR(10, "busy monitor"),
NATIVE_MONITOR(11, "native monitor"),
REFERENCE_CLEANUP(12, "reference cleanup"),
FINALIZING(13, "finalizing"),
JAVA_LOCAL(14, "java local"),
NATIVE_STACK(15, "native stack"),
JAVA_STATIC(16, "java static");
private final String mName;
private final int mType;
RootType(int i, String str) {
this.mType = i;
this.mName = str;
}
public final String getName() {
return this.mName;
}
public final int getType() {
return this.mType;
}
}

View File

@@ -0,0 +1,278 @@
package com.squareup.haha.perflib;
import com.squareup.haha.guava.collect.ImmutableList;
import com.squareup.haha.guava.collect.UnmodifiableIterator;
import com.squareup.haha.perflib.analysis.Dominators;
import com.squareup.haha.perflib.analysis.ShortestDistanceVisitor;
import com.squareup.haha.perflib.analysis.TopologicalSort;
import com.squareup.haha.perflib.io.HprofBuffer;
import gnu.trove.THashSet;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes.dex */
public class Snapshot {
static final /* synthetic */ boolean $assertionsDisabled = false;
private static final int DEFAULT_HEAP_ID = 0;
private static final String JAVA_LANG_CLASS = "java.lang.Class";
public static final Instance SENTINEL_ROOT = new RootObj(RootType.UNKNOWN);
final HprofBuffer mBuffer;
Heap mCurrentHeap;
private Dominators mDominators;
private ImmutableList<Instance> mTopSort;
private int[] mTypeSizes;
ArrayList<Heap> mHeaps = new ArrayList<>();
private THashSet<ClassObj> mReferenceClasses = new THashSet<>();
private long mIdSizeMask = 4294967295L;
public Snapshot(HprofBuffer hprofBuffer) {
this.mBuffer = hprofBuffer;
setToDefaultHeap();
}
public final void addClass(long j, ClassObj classObj) {
this.mCurrentHeap.addClass(j, classObj);
classObj.setHeap(this.mCurrentHeap);
}
public final void addInstance(long j, Instance instance) {
this.mCurrentHeap.addInstance(j, instance);
instance.setHeap(this.mCurrentHeap);
}
public final void addRoot(RootObj rootObj) {
this.mCurrentHeap.addRoot(rootObj);
rootObj.setHeap(this.mCurrentHeap);
}
public final void addStackFrame(StackFrame stackFrame) {
this.mCurrentHeap.addStackFrame(stackFrame);
}
public final void addStackTrace(StackTrace stackTrace) {
this.mCurrentHeap.addStackTrace(stackTrace);
}
public final void addThread(ThreadObj threadObj, int i) {
this.mCurrentHeap.addThread(threadObj, i);
}
public void computeDominators() {
if (this.mDominators == null) {
this.mTopSort = TopologicalSort.compute(getGCRoots());
this.mDominators = new Dominators(this, this.mTopSort);
this.mDominators.computeRetainedSizes();
new ShortestDistanceVisitor().doVisit(getGCRoots());
}
}
public final void dumpInstanceCounts() {
Iterator<Heap> it = this.mHeaps.iterator();
while (it.hasNext()) {
Heap next = it.next();
System.out.println("+------------------ instance counts for heap: " + next.getName());
next.dumpInstanceCounts();
}
}
public final void dumpSizes() {
Iterator<Heap> it = this.mHeaps.iterator();
while (it.hasNext()) {
Heap next = it.next();
System.out.println("+------------------ sizes for heap: " + next.getName());
next.dumpSizes();
}
}
public final void dumpSubclasses() {
Iterator<Heap> it = this.mHeaps.iterator();
while (it.hasNext()) {
Heap next = it.next();
System.out.println("+------------------ subclasses for heap: " + next.getName());
next.dumpSubclasses();
}
}
public List<ClassObj> findAllDescendantClasses(String str) {
Collection<ClassObj> findClasses = findClasses(str);
ArrayList arrayList = new ArrayList();
Iterator<ClassObj> it = findClasses.iterator();
while (it.hasNext()) {
arrayList.addAll(it.next().getDescendantClasses());
}
return arrayList;
}
public final ClassObj findClass(long j) {
for (int i = 0; i < this.mHeaps.size(); i++) {
ClassObj classObj = this.mHeaps.get(i).getClass(j);
if (classObj != null) {
return classObj;
}
}
return null;
}
public final Collection<ClassObj> findClasses(String str) {
ArrayList arrayList = new ArrayList();
for (int i = 0; i < this.mHeaps.size(); i++) {
arrayList.addAll(this.mHeaps.get(i).getClasses(str));
}
return arrayList;
}
public final Instance findInstance(long j) {
for (int i = 0; i < this.mHeaps.size(); i++) {
Instance heap = this.mHeaps.get(i).getInstance(j);
if (heap != null) {
return heap;
}
}
return findClass(j);
}
public Collection<RootObj> getGCRoots() {
return this.mHeaps.get(0).mRoots;
}
public Heap getHeap(int i) {
for (int i2 = 0; i2 < this.mHeaps.size(); i2++) {
if (this.mHeaps.get(i2).getId() == i) {
return this.mHeaps.get(i2);
}
}
return null;
}
public int getHeapIndex(Heap heap) {
return this.mHeaps.indexOf(heap);
}
public Collection<Heap> getHeaps() {
return this.mHeaps;
}
public final long getIdSizeMask() {
return this.mIdSizeMask;
}
public List<Instance> getReachableInstances() {
ArrayList arrayList = new ArrayList(this.mTopSort.size());
UnmodifiableIterator<Instance> it = this.mTopSort.iterator();
while (it.hasNext()) {
Instance next = it.next();
if (next.getImmediateDominator() != null) {
arrayList.add(next);
}
}
return arrayList;
}
public final StackFrame getStackFrame(long j) {
return this.mCurrentHeap.getStackFrame(j);
}
public final StackTrace getStackTrace(int i) {
return this.mCurrentHeap.getStackTrace(i);
}
public final StackTrace getStackTraceAtDepth(int i, int i2) {
return this.mCurrentHeap.getStackTraceAtDepth(i, i2);
}
public final ThreadObj getThread(int i) {
return this.mCurrentHeap.getThread(i);
}
public ImmutableList<Instance> getTopologicalOrdering() {
return this.mTopSort;
}
public final int getTypeSize(Type type) {
return this.mTypeSizes[type.getTypeId()];
}
public void resolveClasses() {
ClassObj findClass = findClass(JAVA_LANG_CLASS);
int instanceSize = findClass != null ? findClass.getInstanceSize() : 0;
Iterator<Heap> it = this.mHeaps.iterator();
while (it.hasNext()) {
Heap next = it.next();
for (ClassObj classObj : next.getClasses()) {
ClassObj superClassObj = classObj.getSuperClassObj();
if (superClassObj != null) {
superClassObj.addSubclass(classObj);
}
int i = instanceSize;
for (Field field : classObj.mStaticFields) {
i += getTypeSize(field.getType());
}
classObj.setSize(i);
}
for (Instance instance : next.getInstances()) {
ClassObj classObj2 = instance.getClassObj();
if (classObj2 != null) {
classObj2.addInstance(next.getId(), instance);
}
}
}
}
public void resolveReferences() {
for (ClassObj classObj : findAllDescendantClasses(ClassObj.getReferenceClassName())) {
classObj.setIsSoftReference();
this.mReferenceClasses.add(classObj);
}
}
public Heap setHeapTo(int i, String str) {
Heap heap = getHeap(i);
if (heap == null) {
heap = new Heap(i, str);
heap.mSnapshot = this;
this.mHeaps.add(heap);
}
this.mCurrentHeap = heap;
return this.mCurrentHeap;
}
public final void setIdSize(int i) {
int i2 = -1;
for (int i3 = 0; i3 < Type.values().length; i3++) {
i2 = Math.max(Type.values()[i3].getTypeId(), i2);
}
this.mTypeSizes = new int[i2 + 1];
Arrays.fill(this.mTypeSizes, -1);
for (int i4 = 0; i4 < Type.values().length; i4++) {
this.mTypeSizes[Type.values()[i4].getTypeId()] = Type.values()[i4].getSize();
}
this.mTypeSizes[Type.OBJECT.getTypeId()] = i;
this.mIdSizeMask = (-1) >>> ((8 - i) << 3);
}
public Heap setToDefaultHeap() {
return setHeapTo(0, "default");
}
public final ClassObj findClass(String str) {
for (int i = 0; i < this.mHeaps.size(); i++) {
ClassObj classObj = this.mHeaps.get(i).getClass(str);
if (classObj != null) {
return classObj;
}
}
return null;
}
public Heap getHeap(String str) {
for (int i = 0; i < this.mHeaps.size(); i++) {
if (str.equals(this.mHeaps.get(i).getName())) {
return this.mHeaps.get(i);
}
}
return null;
}
}

View File

@@ -0,0 +1,33 @@
package com.squareup.haha.perflib;
/* loaded from: classes.dex */
public class StackFrame {
public static final int COMPILED_METHOD = -2;
public static final int NATIVE_METHOD = -3;
public static final int NO_LINE_NUMBER = 0;
public static final int UNKNOWN_LOCATION = -1;
String mFilename;
long mId;
int mLineNumber;
String mMethodName;
int mSerialNumber;
String mSignature;
public StackFrame(long j, String str, String str2, String str3, int i, int i2) {
this.mId = j;
this.mMethodName = str;
this.mSignature = str2;
this.mFilename = str3;
this.mSerialNumber = i;
this.mLineNumber = i2;
}
private String lineNumberString() {
int i = this.mLineNumber;
return i != -3 ? i != -2 ? i != -1 ? i != 0 ? String.valueOf(i) : "No line number" : "Unknown line number" : "Compiled method" : "Native method";
}
public final String toString() {
return this.mMethodName + this.mSignature.replace('/', '.') + " - " + this.mFilename + ":" + lineNumberString();
}
}

View File

@@ -0,0 +1,38 @@
package com.squareup.haha.perflib;
/* loaded from: classes.dex */
public class StackTrace {
StackFrame[] mFrames;
int mSerialNumber;
int mThreadSerialNumber;
StackTrace mParent = null;
int mOffset = 0;
private StackTrace() {
}
public final void dump() {
int length = this.mFrames.length;
for (int i = 0; i < length; i++) {
System.out.println(this.mFrames[i].toString());
}
}
public final StackTrace fromDepth(int i) {
StackTrace stackTrace = new StackTrace();
StackTrace stackTrace2 = this.mParent;
if (stackTrace2 != null) {
stackTrace.mParent = stackTrace2;
} else {
stackTrace.mParent = this;
}
stackTrace.mOffset = i + this.mOffset;
return stackTrace;
}
public StackTrace(int i, int i2, StackFrame[] stackFrameArr) {
this.mSerialNumber = i;
this.mThreadSerialNumber = i2;
this.mFrames = stackFrameArr;
}
}

View File

@@ -0,0 +1,12 @@
package com.squareup.haha.perflib;
/* loaded from: classes.dex */
public class ThreadObj {
long mId;
int mStackTrace;
public ThreadObj(long j, int i) {
this.mId = j;
this.mStackTrace = i;
}
}

View File

@@ -0,0 +1,107 @@
package com.squareup.haha.perflib;
import com.squareup.haha.guava.collect.Maps;
import java.util.Map;
/* loaded from: classes.dex */
public enum Type {
OBJECT(2, 0),
BOOLEAN(4, 1),
CHAR(5, 2),
FLOAT(6, 4),
DOUBLE(7, 8),
BYTE(8, 1),
SHORT(9, 2),
INT(10, 4),
LONG(11, 8);
private static Map<Integer, Type> sTypeMap = Maps.newHashMap();
private int mId;
private int mSize;
/* renamed from: com.squareup.haha.perflib.Type$1, reason: invalid class name */
static /* synthetic */ class AnonymousClass1 {
static final /* synthetic */ int[] $SwitchMap$com$android$tools$perflib$heap$Type = new int[Type.values().length];
static {
try {
$SwitchMap$com$android$tools$perflib$heap$Type[Type.BOOLEAN.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$com$android$tools$perflib$heap$Type[Type.CHAR.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$com$android$tools$perflib$heap$Type[Type.FLOAT.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
$SwitchMap$com$android$tools$perflib$heap$Type[Type.DOUBLE.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
$SwitchMap$com$android$tools$perflib$heap$Type[Type.BYTE.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
try {
$SwitchMap$com$android$tools$perflib$heap$Type[Type.SHORT.ordinal()] = 6;
} catch (NoSuchFieldError unused6) {
}
try {
$SwitchMap$com$android$tools$perflib$heap$Type[Type.INT.ordinal()] = 7;
} catch (NoSuchFieldError unused7) {
}
try {
$SwitchMap$com$android$tools$perflib$heap$Type[Type.LONG.ordinal()] = 8;
} catch (NoSuchFieldError unused8) {
}
}
}
static {
for (Type type : values()) {
sTypeMap.put(Integer.valueOf(type.mId), type);
}
}
Type(int i, int i2) {
this.mId = i;
this.mSize = i2;
}
public static String getClassNameOfPrimitiveArray(Type type) {
switch (AnonymousClass1.$SwitchMap$com$android$tools$perflib$heap$Type[type.ordinal()]) {
case 1:
return "boolean[]";
case 2:
return "char[]";
case 3:
return "float[]";
case 4:
return "double[]";
case 5:
return "byte[]";
case 6:
return "short[]";
case 7:
return "int[]";
case 8:
return "long[]";
default:
throw new IllegalArgumentException("OBJECT type is not a primitive type");
}
}
public static Type getType(int i) {
return sTypeMap.get(Integer.valueOf(i));
}
public final int getSize() {
return this.mSize;
}
public final int getTypeId() {
return this.mId;
}
}

View File

@@ -0,0 +1,22 @@
package com.squareup.haha.perflib;
/* loaded from: classes.dex */
public class Value {
private final Instance instance;
private Object mValue;
public Value(Instance instance) {
this.instance = instance;
}
public Object getValue() {
return this.mValue;
}
public void setValue(Object obj) {
this.mValue = obj;
if (obj instanceof Instance) {
((Instance) obj).addReference(null, this.instance);
}
}
}

View File

@@ -0,0 +1,14 @@
package com.squareup.haha.perflib;
/* loaded from: classes.dex */
public interface Visitor {
void visitArrayInstance(ArrayInstance arrayInstance);
void visitClassInstance(ClassInstance classInstance);
void visitClassObj(ClassObj classObj);
void visitLater(Instance instance, Instance instance2);
void visitRootObj(RootObj rootObj);
}

View File

@@ -0,0 +1,76 @@
package com.squareup.haha.perflib.analysis;
import com.squareup.haha.guava.collect.ImmutableList;
import com.squareup.haha.guava.collect.Iterables;
import com.squareup.haha.perflib.Heap;
import com.squareup.haha.perflib.Instance;
import com.squareup.haha.perflib.RootObj;
import com.squareup.haha.perflib.Snapshot;
import java.util.Iterator;
/* loaded from: classes.dex */
public class Dominators {
private final Snapshot mSnapshot;
private final ImmutableList<Instance> mTopSort;
public Dominators(Snapshot snapshot, ImmutableList<Instance> immutableList) {
this.mSnapshot = snapshot;
this.mTopSort = immutableList;
Iterator<RootObj> it = snapshot.getGCRoots().iterator();
while (it.hasNext()) {
Instance referredInstance = it.next().getReferredInstance();
if (referredInstance != null) {
referredInstance.setImmediateDominator(Snapshot.SENTINEL_ROOT);
}
}
}
private void computeDominators() {
boolean z;
for (boolean z2 = true; z2; z2 = z) {
z = false;
for (int i = 0; i < this.mTopSort.size(); i++) {
Instance instance = this.mTopSort.get(i);
if (instance.getImmediateDominator() != Snapshot.SENTINEL_ROOT) {
Instance instance2 = null;
for (int i2 = 0; i2 < instance.getHardReferences().size(); i2++) {
Instance instance3 = instance.getHardReferences().get(i2);
if (instance3.getImmediateDominator() != null) {
if (instance2 == null) {
instance2 = instance3;
} else {
while (instance2 != instance3) {
if (instance2.getTopologicalOrder() < instance3.getTopologicalOrder()) {
instance3 = instance3.getImmediateDominator();
} else {
instance2 = instance2.getImmediateDominator();
}
}
}
}
}
if (instance.getImmediateDominator() != instance2) {
instance.setImmediateDominator(instance2);
z = true;
}
}
}
}
}
public void computeRetainedSizes() {
for (Heap heap : this.mSnapshot.getHeaps()) {
Iterator it = Iterables.concat(heap.getClasses(), heap.getInstances()).iterator();
while (it.hasNext()) {
((Instance) it.next()).resetRetainedSize();
}
}
computeDominators();
for (Instance instance : this.mSnapshot.getReachableInstances()) {
int heapIndex = this.mSnapshot.getHeapIndex(instance.getHeap());
for (Instance immediateDominator = instance.getImmediateDominator(); immediateDominator != Snapshot.SENTINEL_ROOT; immediateDominator = immediateDominator.getImmediateDominator()) {
immediateDominator.addRetainedSize(heapIndex, instance.getSize());
}
}
}
}

View File

@@ -0,0 +1,45 @@
package com.squareup.haha.perflib.analysis;
import com.ijm.dataencryption.de.DataDecryptTool;
import com.squareup.haha.perflib.Instance;
import com.squareup.haha.perflib.NonRecursiveVisitor;
import java.util.Comparator;
import java.util.Iterator;
import java.util.PriorityQueue;
/* loaded from: classes.dex */
public class ShortestDistanceVisitor extends NonRecursiveVisitor {
private PriorityQueue<Instance> mPriorityQueue = new PriorityQueue<>(DataDecryptTool.DECRYPT_SP_FILE, new Comparator<Instance>() { // from class: com.squareup.haha.perflib.analysis.ShortestDistanceVisitor.1
@Override // java.util.Comparator
public int compare(Instance instance, Instance instance2) {
return instance.getDistanceToGcRoot() - instance2.getDistanceToGcRoot();
}
});
private Instance mPreviousInstance = null;
private int mVisitDistance = 0;
@Override // com.squareup.haha.perflib.NonRecursiveVisitor
public void doVisit(Iterable<? extends Instance> iterable) {
Iterator<? extends Instance> it = iterable.iterator();
while (it.hasNext()) {
it.next().accept(this);
}
while (!this.mPriorityQueue.isEmpty()) {
Instance poll = this.mPriorityQueue.poll();
this.mVisitDistance = poll.getDistanceToGcRoot() + 1;
this.mPreviousInstance = poll;
poll.accept(this);
}
}
@Override // com.squareup.haha.perflib.NonRecursiveVisitor, com.squareup.haha.perflib.Visitor
public void visitLater(Instance instance, Instance instance2) {
if (this.mVisitDistance < instance2.getDistanceToGcRoot()) {
if (instance == null || instance2.getSoftReferences() == null || !instance2.getSoftReferences().contains(instance) || instance2.getIsSoftReference()) {
instance2.setDistanceToGcRoot(this.mVisitDistance);
instance2.setNextInstanceToGcRoot(this.mPreviousInstance);
this.mPriorityQueue.add(instance2);
}
}
}
}

View File

@@ -0,0 +1,73 @@
package com.squareup.haha.perflib.analysis;
import com.squareup.haha.guava.base.Joiner;
import com.squareup.haha.guava.collect.ImmutableList;
import com.squareup.haha.guava.collect.UnmodifiableIterator;
import com.squareup.haha.perflib.Instance;
import com.squareup.haha.perflib.NonRecursiveVisitor;
import com.squareup.haha.perflib.RootObj;
import com.squareup.haha.perflib.Snapshot;
import gnu.trove.TLongHashSet;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes.dex */
public class TopologicalSort {
static class TopologicalSortVisitor extends NonRecursiveVisitor {
private final List<Instance> mPostorder;
private final TLongHashSet mVisited;
private TopologicalSortVisitor() {
this.mVisited = new TLongHashSet();
this.mPostorder = new ArrayList();
}
@Override // com.squareup.haha.perflib.NonRecursiveVisitor
public void doVisit(Iterable<? extends Instance> iterable) {
Iterator<? extends Instance> it = iterable.iterator();
while (it.hasNext()) {
it.next().accept(this);
}
while (!this.mStack.isEmpty()) {
Instance peek = this.mStack.peek();
if (this.mSeen.add(peek.getId())) {
peek.accept(this);
} else {
this.mStack.pop();
if (this.mVisited.add(peek.getId())) {
this.mPostorder.add(peek);
}
}
}
}
ImmutableList<Instance> getOrderedInstances() {
return ImmutableList.copyOf((Collection) Joiner.reverse(this.mPostorder));
}
@Override // com.squareup.haha.perflib.NonRecursiveVisitor, com.squareup.haha.perflib.Visitor
public void visitLater(Instance instance, Instance instance2) {
if (this.mSeen.contains(instance2.getId())) {
return;
}
this.mStack.push(instance2);
}
}
public static ImmutableList<Instance> compute(Iterable<RootObj> iterable) {
TopologicalSortVisitor topologicalSortVisitor = new TopologicalSortVisitor();
topologicalSortVisitor.doVisit(iterable);
ImmutableList<Instance> orderedInstances = topologicalSortVisitor.getOrderedInstances();
int i = 0;
Snapshot.SENTINEL_ROOT.setTopologicalOrder(0);
UnmodifiableIterator<Instance> it = orderedInstances.iterator();
while (it.hasNext()) {
i++;
it.next().setTopologicalOrder(i);
}
return orderedInstances;
}
}

View File

@@ -0,0 +1,34 @@
package com.squareup.haha.perflib.io;
import java.nio.ByteOrder;
/* loaded from: classes.dex */
public interface HprofBuffer {
public static final ByteOrder HPROF_BYTE_ORDER = ByteOrder.BIG_ENDIAN;
boolean hasRemaining();
long position();
void read(byte[] bArr);
byte readByte();
char readChar();
double readDouble();
float readFloat();
int readInt();
long readLong();
short readShort();
void readSubSequence(byte[] bArr, int i, int i2);
long remaining();
void setPosition(long j);
}

View File

@@ -0,0 +1,171 @@
package com.squareup.haha.perflib.io;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
/* loaded from: classes.dex */
public class MemoryMappedFileBuffer implements HprofBuffer {
static final /* synthetic */ boolean $assertionsDisabled = false;
private static final int DEFAULT_PADDING = 1024;
private static final int DEFAULT_SIZE = 1073741824;
private final int mBufferSize;
private final ByteBuffer[] mByteBuffers;
private long mCurrentPosition;
private final long mLength;
private final int mPadding;
MemoryMappedFileBuffer(File file, int i, int i2) throws IOException {
this.mBufferSize = i;
this.mPadding = i2;
this.mLength = file.length();
int i3 = ((int) (this.mLength / this.mBufferSize)) + 1;
this.mByteBuffers = new ByteBuffer[i3];
FileInputStream fileInputStream = new FileInputStream(file);
long j = 0;
for (int i4 = 0; i4 < i3; i4++) {
try {
this.mByteBuffers[i4] = fileInputStream.getChannel().map(FileChannel.MapMode.READ_ONLY, j, Math.min(this.mLength - j, this.mBufferSize + this.mPadding));
this.mByteBuffers[i4].order(HprofBuffer.HPROF_BYTE_ORDER);
j += this.mBufferSize;
} finally {
fileInputStream.close();
}
}
this.mCurrentPosition = 0L;
}
private int getIndex() {
return (int) (this.mCurrentPosition / this.mBufferSize);
}
private int getOffset() {
return (int) (this.mCurrentPosition % this.mBufferSize);
}
public void dispose() {
for (int i = 0; i < this.mByteBuffers.length; i++) {
try {
this.mByteBuffers[i].cleaner().clean();
} catch (Exception unused) {
return;
}
}
}
@Override // com.squareup.haha.perflib.io.HprofBuffer
public boolean hasRemaining() {
return this.mCurrentPosition < this.mLength;
}
@Override // com.squareup.haha.perflib.io.HprofBuffer
public long position() {
return this.mCurrentPosition;
}
@Override // com.squareup.haha.perflib.io.HprofBuffer
public void read(byte[] bArr) {
int index = getIndex();
this.mByteBuffers[index].position(getOffset());
if (bArr.length <= this.mByteBuffers[index].remaining()) {
this.mByteBuffers[index].get(bArr, 0, bArr.length);
} else {
int position = this.mBufferSize - this.mByteBuffers[index].position();
this.mByteBuffers[index].get(bArr, 0, position);
int i = index + 1;
this.mByteBuffers[i].position(0);
this.mByteBuffers[i].get(bArr, position, bArr.length - position);
}
this.mCurrentPosition += bArr.length;
}
@Override // com.squareup.haha.perflib.io.HprofBuffer
public byte readByte() {
byte b = this.mByteBuffers[getIndex()].get(getOffset());
this.mCurrentPosition++;
return b;
}
@Override // com.squareup.haha.perflib.io.HprofBuffer
public char readChar() {
char c = this.mByteBuffers[getIndex()].getChar(getOffset());
this.mCurrentPosition += 2;
return c;
}
@Override // com.squareup.haha.perflib.io.HprofBuffer
public double readDouble() {
double d = this.mByteBuffers[getIndex()].getDouble(getOffset());
this.mCurrentPosition += 8;
return d;
}
@Override // com.squareup.haha.perflib.io.HprofBuffer
public float readFloat() {
float f = this.mByteBuffers[getIndex()].getFloat(getOffset());
this.mCurrentPosition += 4;
return f;
}
@Override // com.squareup.haha.perflib.io.HprofBuffer
public int readInt() {
int i = this.mByteBuffers[getIndex()].getInt(getOffset());
this.mCurrentPosition += 4;
return i;
}
@Override // com.squareup.haha.perflib.io.HprofBuffer
public long readLong() {
long j = this.mByteBuffers[getIndex()].getLong(getOffset());
this.mCurrentPosition += 8;
return j;
}
@Override // com.squareup.haha.perflib.io.HprofBuffer
public short readShort() {
short s = this.mByteBuffers[getIndex()].getShort(getOffset());
this.mCurrentPosition += 2;
return s;
}
@Override // com.squareup.haha.perflib.io.HprofBuffer
public void readSubSequence(byte[] bArr, int i, int i2) {
this.mCurrentPosition += i;
int index = getIndex();
this.mByteBuffers[index].position(getOffset());
if (bArr.length <= this.mByteBuffers[index].remaining()) {
this.mByteBuffers[index].get(bArr, 0, bArr.length);
} else {
int position = this.mBufferSize - this.mByteBuffers[index].position();
this.mByteBuffers[index].get(bArr, 0, position);
int min = Math.min(i2 - position, bArr.length - position);
int i3 = ((min + r3) - 1) / this.mBufferSize;
int i4 = position;
for (int i5 = 0; i5 < i3; i5++) {
int min2 = Math.min(min, this.mBufferSize);
int i6 = index + 1 + i5;
this.mByteBuffers[i6].position(0);
this.mByteBuffers[i6].get(bArr, i4, min2);
i4 += min2;
min -= min2;
}
}
this.mCurrentPosition += Math.min(bArr.length, i2);
}
@Override // com.squareup.haha.perflib.io.HprofBuffer
public long remaining() {
return this.mLength - this.mCurrentPosition;
}
@Override // com.squareup.haha.perflib.io.HprofBuffer
public void setPosition(long j) {
this.mCurrentPosition = j;
}
public MemoryMappedFileBuffer(File file) throws IOException {
this(file, DEFAULT_SIZE, 1024);
}
}

View File

@@ -0,0 +1,64 @@
package com.squareup.leakcanary;
import android.content.Context;
import android.content.Intent;
import androidx.core.content.ContextCompat;
import com.squareup.leakcanary.internal.ForegroundService;
import java.io.File;
/* loaded from: classes.dex */
public abstract class AbstractAnalysisResultService extends ForegroundService {
private static final String ANALYZED_HEAP_PATH_EXTRA = "analyzed_heap_path_extra";
public AbstractAnalysisResultService() {
super(AbstractAnalysisResultService.class.getName(), R.string.leak_canary_notification_reporting);
}
public static void sendResultToListener(Context context, String str, HeapDump heapDump, AnalysisResult analysisResult) {
try {
Intent intent = new Intent(context, Class.forName(str));
File save = AnalyzedHeap.save(heapDump, analysisResult);
if (save != null) {
intent.putExtra(ANALYZED_HEAP_PATH_EXTRA, save.getAbsolutePath());
}
ContextCompat.a(context, intent);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
protected void onAnalysisResultFailure(String str) {
CanaryLog.d(str, new Object[0]);
}
@Override // com.squareup.leakcanary.internal.ForegroundService
protected final void onHandleIntentInForeground(Intent intent) {
if (intent == null) {
CanaryLog.d("AbstractAnalysisResultService received a null intent, ignoring.", new Object[0]);
return;
}
if (!intent.hasExtra(ANALYZED_HEAP_PATH_EXTRA)) {
onAnalysisResultFailure(getString(R.string.leak_canary_result_failure_no_disk_space));
return;
}
AnalyzedHeap load = AnalyzedHeap.load(new File(intent.getStringExtra(ANALYZED_HEAP_PATH_EXTRA)));
if (load == null) {
onAnalysisResultFailure(getString(R.string.leak_canary_result_failure_no_file));
return;
}
try {
onHeapAnalyzed(load);
} finally {
load.heapDump.heapDumpFile.delete();
load.selfFile.delete();
}
}
protected void onHeapAnalyzed(AnalyzedHeap analyzedHeap) {
onHeapAnalyzed(analyzedHeap.heapDump, analyzedHeap.result);
}
@Deprecated
protected void onHeapAnalyzed(HeapDump heapDump, AnalysisResult analysisResult) {
}
}

View File

@@ -0,0 +1,42 @@
package com.squareup.leakcanary;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import com.squareup.leakcanary.internal.ActivityLifecycleCallbacksAdapter;
@Deprecated
/* loaded from: classes.dex */
public final class ActivityRefWatcher {
private final Application application;
private final Application.ActivityLifecycleCallbacks lifecycleCallbacks = new ActivityLifecycleCallbacksAdapter() { // from class: com.squareup.leakcanary.ActivityRefWatcher.1
@Override // com.squareup.leakcanary.internal.ActivityLifecycleCallbacksAdapter, android.app.Application.ActivityLifecycleCallbacks
public void onActivityDestroyed(Activity activity) {
ActivityRefWatcher.this.refWatcher.watch(activity);
}
};
private final RefWatcher refWatcher;
private ActivityRefWatcher(Application application, RefWatcher refWatcher) {
this.application = application;
this.refWatcher = refWatcher;
}
public static void install(Context context, RefWatcher refWatcher) {
Application application = (Application) context.getApplicationContext();
application.registerActivityLifecycleCallbacks(new ActivityRefWatcher(application, refWatcher).lifecycleCallbacks);
}
public static void installOnIcsPlus(Application application, RefWatcher refWatcher) {
install(application, refWatcher);
}
public void stopWatchingActivities() {
this.application.unregisterActivityLifecycleCallbacks(this.lifecycleCallbacks);
}
public void watchActivities() {
stopWatchingActivities();
this.application.registerActivityLifecycleCallbacks(this.lifecycleCallbacks);
}
}

View File

@@ -0,0 +1,63 @@
package com.squareup.leakcanary;
import java.io.Serializable;
/* loaded from: classes.dex */
public final class AnalysisResult implements Serializable {
public static final long RETAINED_HEAP_SKIPPED = -1;
public final long analysisDurationMs;
public final String className;
public final boolean excludedLeak;
public final Throwable failure;
public final boolean leakFound;
public final LeakTrace leakTrace;
public final long retainedHeapSize;
private AnalysisResult(boolean z, boolean z2, String str, LeakTrace leakTrace, Throwable th, long j, long j2) {
this.leakFound = z;
this.excludedLeak = z2;
this.className = str;
this.leakTrace = leakTrace;
this.failure = th;
this.retainedHeapSize = j;
this.analysisDurationMs = j2;
}
private String classSimpleName(String str) {
int lastIndexOf = str.lastIndexOf(46);
return lastIndexOf == -1 ? str : str.substring(lastIndexOf + 1);
}
public static AnalysisResult failure(Throwable th, long j) {
return new AnalysisResult(false, false, null, null, th, 0L, j);
}
public static AnalysisResult leakDetected(boolean z, String str, LeakTrace leakTrace, long j, long j2) {
return new AnalysisResult(true, z, str, leakTrace, null, j, j2);
}
public static AnalysisResult noLeak(String str, long j) {
return new AnalysisResult(false, false, str, null, null, 0L, j);
}
public RuntimeException leakTraceAsFakeException() {
if (!this.leakFound) {
throw new UnsupportedOperationException("leakTraceAsFakeException() can only be called when leakFound is true");
}
int i = 0;
LeakTraceElement leakTraceElement = this.leakTrace.elements.get(0);
String classSimpleName = classSimpleName(leakTraceElement.className);
RuntimeException runtimeException = new RuntimeException(classSimpleName(this.className) + " leak from " + classSimpleName + " (holder=" + leakTraceElement.holder + ", type=" + leakTraceElement.type + ")");
StackTraceElement[] stackTraceElementArr = new StackTraceElement[this.leakTrace.elements.size()];
for (LeakTraceElement leakTraceElement2 : this.leakTrace.elements) {
String str = leakTraceElement2.referenceName;
if (str == null) {
str = "leaking";
}
stackTraceElementArr[i] = new StackTraceElement(leakTraceElement2.className, str, classSimpleName(leakTraceElement2.className) + ".java", 42);
i++;
}
runtimeException.setStackTrace(stackTraceElementArr);
return runtimeException;
}
}

View File

@@ -0,0 +1,151 @@
package com.squareup.leakcanary;
import java.io.File;
/* loaded from: classes.dex */
public final class AnalyzedHeap {
public final HeapDump heapDump;
public final boolean heapDumpFileExists;
public final AnalysisResult result;
public final File selfFile;
public final long selfLastModified;
public AnalyzedHeap(HeapDump heapDump, AnalysisResult analysisResult, File file) {
this.heapDump = heapDump;
this.result = analysisResult;
this.selfFile = file;
this.heapDumpFileExists = heapDump.heapDumpFile.exists();
this.selfLastModified = file.lastModified();
}
/* JADX WARN: Removed duplicated region for block: B:17:0x0033 A[Catch: all -> 0x004c, TryCatch #7 {all -> 0x004c, blocks: (B:6:0x0006, B:15:0x002b, B:17:0x0033, B:24:0x003d), top: B:2:0x0001 }] */
/* JADX WARN: Removed duplicated region for block: B:20:0x0048 A[EXC_TOP_SPLITTER, SYNTHETIC] */
/* JADX WARN: Removed duplicated region for block: B:24:0x003d A[Catch: all -> 0x004c, TRY_LEAVE, TryCatch #7 {all -> 0x004c, blocks: (B:6:0x0006, B:15:0x002b, B:17:0x0033, B:24:0x003d), top: B:2:0x0001 }] */
/* JADX WARN: Removed duplicated region for block: B:29:0x004f A[EXC_TOP_SPLITTER, SYNTHETIC] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
public static com.squareup.leakcanary.AnalyzedHeap load(java.io.File r6) {
/*
r0 = 0
java.io.FileInputStream r1 = new java.io.FileInputStream // Catch: java.lang.Throwable -> L24 java.lang.ClassNotFoundException -> L27 java.io.IOException -> L29
r1.<init>(r6) // Catch: java.lang.Throwable -> L24 java.lang.ClassNotFoundException -> L27 java.io.IOException -> L29
java.io.ObjectInputStream r2 = new java.io.ObjectInputStream // Catch: java.lang.ClassNotFoundException -> L20 java.io.IOException -> L22 java.lang.Throwable -> L4c
r2.<init>(r1) // Catch: java.lang.ClassNotFoundException -> L20 java.io.IOException -> L22 java.lang.Throwable -> L4c
java.lang.Object r3 = r2.readObject() // Catch: java.lang.ClassNotFoundException -> L20 java.io.IOException -> L22 java.lang.Throwable -> L4c
com.squareup.leakcanary.HeapDump r3 = (com.squareup.leakcanary.HeapDump) r3 // Catch: java.lang.ClassNotFoundException -> L20 java.io.IOException -> L22 java.lang.Throwable -> L4c
java.lang.Object r2 = r2.readObject() // Catch: java.lang.ClassNotFoundException -> L20 java.io.IOException -> L22 java.lang.Throwable -> L4c
com.squareup.leakcanary.AnalysisResult r2 = (com.squareup.leakcanary.AnalysisResult) r2 // Catch: java.lang.ClassNotFoundException -> L20 java.io.IOException -> L22 java.lang.Throwable -> L4c
com.squareup.leakcanary.AnalyzedHeap r4 = new com.squareup.leakcanary.AnalyzedHeap // Catch: java.lang.ClassNotFoundException -> L20 java.io.IOException -> L22 java.lang.Throwable -> L4c
r4.<init>(r3, r2, r6) // Catch: java.lang.ClassNotFoundException -> L20 java.io.IOException -> L22 java.lang.Throwable -> L4c
r1.close() // Catch: java.io.IOException -> L1f
L1f:
return r4
L20:
r2 = move-exception
goto L2b
L22:
r2 = move-exception
goto L2b
L24:
r6 = move-exception
r1 = r0
goto L4d
L27:
r2 = move-exception
goto L2a
L29:
r2 = move-exception
L2a:
r1 = r0
L2b:
boolean r3 = r6.delete() // Catch: java.lang.Throwable -> L4c
r4 = 0
r5 = 1
if (r3 == 0) goto L3d
java.lang.String r3 = "Could not read result file %s, deleted it."
java.lang.Object[] r5 = new java.lang.Object[r5] // Catch: java.lang.Throwable -> L4c
r5[r4] = r6 // Catch: java.lang.Throwable -> L4c
com.squareup.leakcanary.CanaryLog.d(r2, r3, r5) // Catch: java.lang.Throwable -> L4c
goto L46
L3d:
java.lang.String r3 = "Could not read result file %s, could not delete it either."
java.lang.Object[] r5 = new java.lang.Object[r5] // Catch: java.lang.Throwable -> L4c
r5[r4] = r6 // Catch: java.lang.Throwable -> L4c
com.squareup.leakcanary.CanaryLog.d(r2, r3, r5) // Catch: java.lang.Throwable -> L4c
L46:
if (r1 == 0) goto L4b
r1.close() // Catch: java.io.IOException -> L4b
L4b:
return r0
L4c:
r6 = move-exception
L4d:
if (r1 == 0) goto L52
r1.close() // Catch: java.io.IOException -> L52
L52:
throw r6
*/
throw new UnsupportedOperationException("Method not decompiled: com.squareup.leakcanary.AnalyzedHeap.load(java.io.File):com.squareup.leakcanary.AnalyzedHeap");
}
/* JADX WARN: Removed duplicated region for block: B:25:0x004f A[EXC_TOP_SPLITTER, SYNTHETIC] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
public static java.io.File save(com.squareup.leakcanary.HeapDump r4, com.squareup.leakcanary.AnalysisResult r5) {
/*
java.io.File r0 = new java.io.File
java.io.File r1 = r4.heapDumpFile
java.io.File r1 = r1.getParentFile()
java.lang.StringBuilder r2 = new java.lang.StringBuilder
r2.<init>()
java.io.File r3 = r4.heapDumpFile
java.lang.String r3 = r3.getName()
r2.append(r3)
java.lang.String r3 = ".result"
r2.append(r3)
java.lang.String r2 = r2.toString()
r0.<init>(r1, r2)
r1 = 0
java.io.FileOutputStream r2 = new java.io.FileOutputStream // Catch: java.lang.Throwable -> L39 java.io.IOException -> L3c
r2.<init>(r0) // Catch: java.lang.Throwable -> L39 java.io.IOException -> L3c
java.io.ObjectOutputStream r3 = new java.io.ObjectOutputStream // Catch: java.io.IOException -> L37 java.lang.Throwable -> L4c
r3.<init>(r2) // Catch: java.io.IOException -> L37 java.lang.Throwable -> L4c
r3.writeObject(r4) // Catch: java.io.IOException -> L37 java.lang.Throwable -> L4c
r3.writeObject(r5) // Catch: java.io.IOException -> L37 java.lang.Throwable -> L4c
r2.close() // Catch: java.io.IOException -> L36
L36:
return r0
L37:
r4 = move-exception
goto L3e
L39:
r4 = move-exception
r2 = r1
goto L4d
L3c:
r4 = move-exception
r2 = r1
L3e:
java.lang.String r5 = "Could not save leak analysis result to disk."
r0 = 0
java.lang.Object[] r0 = new java.lang.Object[r0] // Catch: java.lang.Throwable -> L4c
com.squareup.leakcanary.CanaryLog.d(r4, r5, r0) // Catch: java.lang.Throwable -> L4c
if (r2 == 0) goto L4b
r2.close() // Catch: java.io.IOException -> L4b
L4b:
return r1
L4c:
r4 = move-exception
L4d:
if (r2 == 0) goto L52
r2.close() // Catch: java.io.IOException -> L52
L52:
throw r4
*/
throw new UnsupportedOperationException("Method not decompiled: com.squareup.leakcanary.AnalyzedHeap.save(com.squareup.leakcanary.HeapDump, com.squareup.leakcanary.AnalysisResult):java.io.File");
}
}

View File

@@ -0,0 +1,23 @@
package com.squareup.leakcanary;
/* loaded from: classes.dex */
public interface AnalyzerProgressListener {
public static final AnalyzerProgressListener NONE = new AnalyzerProgressListener() { // from class: com.squareup.leakcanary.AnalyzerProgressListener.1
@Override // com.squareup.leakcanary.AnalyzerProgressListener
public void onProgressUpdate(Step step) {
}
};
public enum Step {
READING_HEAP_DUMP_FILE,
PARSING_HEAP_DUMP,
DEDUPLICATING_GC_ROOTS,
FINDING_LEAKING_REF,
FINDING_SHORTEST_PATH,
BUILDING_LEAK_TRACE,
COMPUTING_DOMINATORS,
COMPUTING_BITMAP_SIZE
}
void onProgressUpdate(Step step);
}

View File

@@ -0,0 +1,11 @@
package com.squareup.leakcanary;
import android.os.Debug;
/* loaded from: classes.dex */
public final class AndroidDebuggerControl implements DebuggerControl {
@Override // com.squareup.leakcanary.DebuggerControl
public boolean isDebuggerAttached() {
return Debug.isDebuggerConnected();
}
}

View File

@@ -0,0 +1,441 @@
package com.squareup.leakcanary;
import android.os.Build;
import com.squareup.leakcanary.ExcludedRefs;
import com.squareup.leakcanary.internal.LeakCanaryInternals;
import java.lang.ref.PhantomReference;
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import java.util.EnumSet;
import java.util.Iterator;
/* JADX WARN: Enum visitor error
jadx.core.utils.exceptions.JadxRuntimeException: Init of enum field 'ACTIVITY_CLIENT_RECORD__NEXT_IDLE' uses external variables
at jadx.core.dex.visitors.EnumVisitor.createEnumFieldByConstructor(EnumVisitor.java:451)
at jadx.core.dex.visitors.EnumVisitor.processEnumFieldByField(EnumVisitor.java:372)
at jadx.core.dex.visitors.EnumVisitor.processEnumFieldByWrappedInsn(EnumVisitor.java:337)
at jadx.core.dex.visitors.EnumVisitor.extractEnumFieldsFromFilledArray(EnumVisitor.java:322)
at jadx.core.dex.visitors.EnumVisitor.extractEnumFieldsFromInsn(EnumVisitor.java:262)
at jadx.core.dex.visitors.EnumVisitor.convertToEnum(EnumVisitor.java:151)
at jadx.core.dex.visitors.EnumVisitor.visit(EnumVisitor.java:100)
*/
/* JADX WARN: Failed to restore enum class, 'enum' modifier and super class removed */
/* loaded from: classes.dex */
public abstract class AndroidExcludedRefs {
private static final /* synthetic */ AndroidExcludedRefs[] $VALUES;
public static final AndroidExcludedRefs ACCESSIBILITY_NODE_INFO__MORIGINALTEXT;
public static final AndroidExcludedRefs ACCOUNT_MANAGER;
public static final AndroidExcludedRefs ACTIVITY_CHOOSE_MODEL;
public static final AndroidExcludedRefs ACTIVITY_CLIENT_RECORD__NEXT_IDLE;
public static final AndroidExcludedRefs ACTIVITY_MANAGER_MCONTEXT;
public static final AndroidExcludedRefs APP_WIDGET_HOST_CALLBACKS;
public static final AndroidExcludedRefs AUDIO_MANAGER;
public static final AndroidExcludedRefs AUDIO_MANAGER__MCONTEXT_STATIC;
public static final AndroidExcludedRefs AW_RESOURCE__SRESOURCES;
public static final AndroidExcludedRefs BACKDROP_FRAME_RENDERER__MDECORVIEW;
public static final AndroidExcludedRefs BLOCKING_QUEUE;
public static final AndroidExcludedRefs BUBBLE_POPUP_HELPER__SHELPER;
public static final AndroidExcludedRefs CLIPBOARD_UI_MANAGER__SINSTANCE;
public static final AndroidExcludedRefs CONNECTIVITY_MANAGER__SINSTANCE;
public static final AndroidExcludedRefs DEVICE_POLICY_MANAGER__SETTINGS_OBSERVER;
public static final AndroidExcludedRefs EDITTEXT_BLINK_MESSAGEQUEUE;
public static final AndroidExcludedRefs EVENT_RECEIVER__MMESSAGE_QUEUE;
public static final AndroidExcludedRefs FINALIZER_WATCHDOG_DAEMON;
public static final AndroidExcludedRefs GESTURE_BOOST_MANAGER;
public static final AndroidExcludedRefs INPUT_METHOD_MANAGER__LAST_SERVED_VIEW;
public static final AndroidExcludedRefs INPUT_METHOD_MANAGER__ROOT_VIEW;
public static final AndroidExcludedRefs INPUT_METHOD_MANAGER__SERVED_VIEW;
public static final AndroidExcludedRefs INSTRUMENTATION_RECOMMEND_ACTIVITY;
public static final AndroidExcludedRefs LAYOUT_TRANSITION;
public static final AndroidExcludedRefs LEAK_CANARY_THREAD;
public static final AndroidExcludedRefs LGCONTEXT__MCONTEXT;
public static final AndroidExcludedRefs MAIN;
public static final AndroidExcludedRefs MAPPER_CLIENT;
public static final AndroidExcludedRefs MEDIA_SCANNER_CONNECTION;
public static final AndroidExcludedRefs MEDIA_SESSION_LEGACY_HELPER__SINSTANCE;
public static final AndroidExcludedRefs PERSONA_MANAGER;
public static final AndroidExcludedRefs RESOURCES__MCONTEXT;
public static final AndroidExcludedRefs SEM_CLIPBOARD_MANAGER__MCONTEXT;
public static final AndroidExcludedRefs SEM_EMERGENCY_MANAGER__MCONTEXT;
public static final AndroidExcludedRefs SOFT_REFERENCES;
public static final AndroidExcludedRefs SPAN_CONTROLLER;
public static final AndroidExcludedRefs SPEECH_RECOGNIZER;
public static final AndroidExcludedRefs SPELL_CHECKER;
public static final AndroidExcludedRefs SPELL_CHECKER_SESSION;
public static final AndroidExcludedRefs SPEN_GESTURE_MANAGER;
public static final AndroidExcludedRefs SYSTEM_SENSOR_MANAGER__MAPPCONTEXTIMPL;
public static final AndroidExcludedRefs TEXT_LINE__SCACHED;
public static final AndroidExcludedRefs TEXT_VIEW__MLAST_HOVERED_VIEW;
public static final AndroidExcludedRefs USER_MANAGER__SINSTANCE;
public static final AndroidExcludedRefs VIEWLOCATIONHOLDER_ROOT;
public static final AndroidExcludedRefs VIEW_CONFIGURATION__MCONTEXT;
final boolean applies;
static {
int i;
int i2;
int i3;
int i4;
int i5;
int i6;
int i7;
int i8;
int i9;
int i10 = Build.VERSION.SDK_INT;
int i11 = 21;
int i12 = 19;
int i13 = 1;
ACTIVITY_CLIENT_RECORD__NEXT_IDLE = new AndroidExcludedRefs("ACTIVITY_CLIENT_RECORD__NEXT_IDLE", 0, i10 >= 19 && i10 <= 21) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.1
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("android.app.ActivityThread$ActivityClientRecord", "nextIdle").reason("Android AOSP sometimes keeps a reference to a destroyed activity as a nextIdle client record in the android.app.ActivityThread.mActivities map. Not sure what's going on there, input welcome.");
}
};
SPAN_CONTROLLER = new AndroidExcludedRefs("SPAN_CONTROLLER", i13, Build.VERSION.SDK_INT <= 19) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.2
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("android.widget.Editor$EasyEditSpanController", "this$0").reason("Editor inserts a special span, which has a reference to the EditText. That span is a NoCopySpan, which makes sure it gets dropped when creating a new SpannableStringBuilder from a given CharSequence. TextView.onSaveInstanceState() does a copy of its mText before saving it in the bundle. Prior to KitKat, that copy was done using the SpannableString constructor, instead of SpannableStringBuilder. The SpannableString constructor does not drop NoCopySpan spans. So we end up with a saved state that holds a reference to the textview and therefore the entire view hierarchy & activity context. Fix: https://github.com/android/platform_frameworks_base/commit/af7dcdf35a37d7a7dbaad7d9869c1c91bce2272b . To fix this, you could override TextView.onSaveInstanceState(), and then use reflection to access TextView.SavedState.mText and clear the NoCopySpan spans.");
builder.instanceField("android.widget.Editor$SpanController", "this$0").reason("Editor inserts a special span, which has a reference to the EditText. That span is a NoCopySpan, which makes sure it gets dropped when creating a new SpannableStringBuilder from a given CharSequence. TextView.onSaveInstanceState() does a copy of its mText before saving it in the bundle. Prior to KitKat, that copy was done using the SpannableString constructor, instead of SpannableStringBuilder. The SpannableString constructor does not drop NoCopySpan spans. So we end up with a saved state that holds a reference to the textview and therefore the entire view hierarchy & activity context. Fix: https://github.com/android/platform_frameworks_base/commit/af7dcdf35a37d7a7dbaad7d9869c1c91bce2272b . To fix this, you could override TextView.onSaveInstanceState(), and then use reflection to access TextView.SavedState.mText and clear the NoCopySpan spans.");
}
};
MEDIA_SESSION_LEGACY_HELPER__SINSTANCE = new AndroidExcludedRefs("MEDIA_SESSION_LEGACY_HELPER__SINSTANCE", 2, Build.VERSION.SDK_INT == 21) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.3
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.staticField("android.media.session.MediaSessionLegacyHelper", "sInstance").reason("MediaSessionLegacyHelper is a static singleton that is lazily instantiated and keeps a reference to the context it's given the first time MediaSessionLegacyHelper.getHelper() is called. This leak was introduced in android-5.0.1_r1 and fixed in Android 5.1.0_r1 by calling context.getApplicationContext(). Fix: https://github.com/android/platform_frameworks_base/commit/9b5257c9c99c4cb541d8e8e78fb04f008b1a9091 To fix this, you could call MediaSessionLegacyHelper.getHelper() early in Application.onCreate() and pass it the application context.");
}
};
int i14 = 22;
TEXT_LINE__SCACHED = new AndroidExcludedRefs("TEXT_LINE__SCACHED", 3, Build.VERSION.SDK_INT <= 22) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.4
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.staticField("android.text.TextLine", "sCached").reason("TextLine.sCached is a pool of 3 TextLine instances. TextLine.recycle() has had at least two bugs that created memory leaks by not correctly clearing the recycled TextLine instances. The first was fixed in android-5.1.0_r1: https://github.com/android/platform_frameworks_base/commit/893d6fe48d37f71e683f722457bea646994a10 The second was fixed, not released yet: https://github.com/android/platform_frameworks_base/commit/b3a9bc038d3a218b1dbdf7b5668e3d6c12be5e To fix this, you could access TextLine.sCached and clear the pool every now and then (e.g. on activity destroy).");
}
};
BLOCKING_QUEUE = new AndroidExcludedRefs("BLOCKING_QUEUE", 4) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.5
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("android.os.Message", "obj").reason("A thread waiting on a blocking queue will leak the last dequeued object as a stack local reference. So when a HandlerThread becomes idle, it keeps a local reference to the last message it received. That message then gets recycled and can be used again. As long as all messages are recycled after being used, this won't be a problem, because these references are cleared when being recycled. However, dialogs create template Message instances to be copied when a message needs to be sent. These Message templates holds references to the dialog listeners, which most likely leads to holding a reference onto the activity in some way. Dialogs never recycle their template Message, assuming these Message instances will get GCed when the dialog is GCed. The combination of these two things creates a high potential for memory leaks as soon as you use dialogs. These memory leaks might be temporary, but some handler threads sleep for a long time. To fix this, you could post empty messages to the idle handler threads from time to time. This won't be easy because you cannot access all handler threads, but a library that is widely used should consider doing this for its own handler threads. This leaks has been shown to happen in both Dalvik and ART.");
builder.instanceField("android.os.Message", "next").reason("A thread waiting on a blocking queue will leak the last dequeued object as a stack local reference. So when a HandlerThread becomes idle, it keeps a local reference to the last message it received. That message then gets recycled and can be used again. As long as all messages are recycled after being used, this won't be a problem, because these references are cleared when being recycled. However, dialogs create template Message instances to be copied when a message needs to be sent. These Message templates holds references to the dialog listeners, which most likely leads to holding a reference onto the activity in some way. Dialogs never recycle their template Message, assuming these Message instances will get GCed when the dialog is GCed. The combination of these two things creates a high potential for memory leaks as soon as you use dialogs. These memory leaks might be temporary, but some handler threads sleep for a long time. To fix this, you could post empty messages to the idle handler threads from time to time. This won't be easy because you cannot access all handler threads, but a library that is widely used should consider doing this for its own handler threads. This leaks has been shown to happen in both Dalvik and ART.");
builder.instanceField("android.os.Message", "target").reason("A thread waiting on a blocking queue will leak the last dequeued object as a stack local reference. So when a HandlerThread becomes idle, it keeps a local reference to the last message it received. That message then gets recycled and can be used again. As long as all messages are recycled after being used, this won't be a problem, because these references are cleared when being recycled. However, dialogs create template Message instances to be copied when a message needs to be sent. These Message templates holds references to the dialog listeners, which most likely leads to holding a reference onto the activity in some way. Dialogs never recycle their template Message, assuming these Message instances will get GCed when the dialog is GCed. The combination of these two things creates a high potential for memory leaks as soon as you use dialogs. These memory leaks might be temporary, but some handler threads sleep for a long time. To fix this, you could post empty messages to the idle handler threads from time to time. This won't be easy because you cannot access all handler threads, but a library that is widely used should consider doing this for its own handler threads. This leaks has been shown to happen in both Dalvik and ART.");
}
};
int i15 = 5;
int i16 = Build.VERSION.SDK_INT;
int i17 = 15;
int i18 = 27;
INPUT_METHOD_MANAGER__SERVED_VIEW = new AndroidExcludedRefs("INPUT_METHOD_MANAGER__SERVED_VIEW", i15, i16 >= 15 && i16 <= 27) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.6
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("android.view.inputmethod.InputMethodManager", "mNextServedView").reason("When we detach a view that receives keyboard input, the InputMethodManager leaks a reference to it until a new view asks for keyboard input. Tracked here: https://code.google.com/p/android/issues/detail?id=171190 Hack: https://gist.github.com/pyricau/4df64341cc978a7de414");
builder.instanceField("android.view.inputmethod.InputMethodManager", "mServedView").reason("When we detach a view that receives keyboard input, the InputMethodManager leaks a reference to it until a new view asks for keyboard input. Tracked here: https://code.google.com/p/android/issues/detail?id=171190 Hack: https://gist.github.com/pyricau/4df64341cc978a7de414");
builder.instanceField("android.view.inputmethod.InputMethodManager", "mServedInputConnection").reason("When we detach a view that receives keyboard input, the InputMethodManager leaks a reference to it until a new view asks for keyboard input. Tracked here: https://code.google.com/p/android/issues/detail?id=171190 Hack: https://gist.github.com/pyricau/4df64341cc978a7de414");
}
};
int i19 = 6;
int i20 = Build.VERSION.SDK_INT;
INPUT_METHOD_MANAGER__ROOT_VIEW = new AndroidExcludedRefs("INPUT_METHOD_MANAGER__ROOT_VIEW", i19, i20 >= 15 && i20 <= 27) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.7
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("android.view.inputmethod.InputMethodManager", "mCurRootView").reason("The singleton InputMethodManager is holding a reference to mCurRootView long after the activity has been destroyed. Observed on ICS MR1: https://github.com/square/leakcanary/issues/1#issuecomment-100579429 Hack: https://gist.github.com/pyricau/4df64341cc978a7de414");
}
};
int i21 = 7;
int i22 = Build.VERSION.SDK_INT;
int i23 = 14;
LAYOUT_TRANSITION = new AndroidExcludedRefs("LAYOUT_TRANSITION", i21, i22 >= 14 && i22 <= 22) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.8
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("android.animation.LayoutTransition$1", "val$parent").reason("LayoutTransition leaks parent ViewGroup through ViewTreeObserver.OnPreDrawListener When triggered, this leaks stays until the window is destroyed. Tracked here: https://code.google.com/p/android/issues/detail?id=171830");
}
};
int i24 = 8;
int i25 = Build.VERSION.SDK_INT;
int i26 = 16;
int i27 = 24;
SPELL_CHECKER_SESSION = new AndroidExcludedRefs("SPELL_CHECKER_SESSION", i24, i25 >= 16 && i25 <= 24) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.9
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("android.view.textservice.SpellCheckerSession$1", "this$0").reason("SpellCheckerSessionListenerImpl.mHandler is leaking destroyed Activity when the SpellCheckerSession is closed before the service is connected. Tracked here: https://code.google.com/p/android/issues/detail?id=172542");
}
};
SPELL_CHECKER = new AndroidExcludedRefs("SPELL_CHECKER", 9, Build.VERSION.SDK_INT == 22) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.10
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("android.widget.SpellChecker$1", "this$0").reason("SpellChecker holds on to a detached view that points to a destroyed activity. mSpellRunnable is being enqueued, and that callback should be removed when closeSession() is called. Maybe closeSession() wasn't called, or maybe it was called after the view was detached.");
}
};
int i28 = 10;
int i29 = Build.VERSION.SDK_INT;
ACTIVITY_CHOOSE_MODEL = new AndroidExcludedRefs("ACTIVITY_CHOOSE_MODEL", i28, i29 > 14 && i29 <= 22) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.11
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("androidx.appcompat.internal.widget.ActivityChooserModel", "mActivityChoserModelPolicy").reason("ActivityChooserModel holds a static reference to the last set ActivityChooserModelPolicy which can be an activity context. Tracked here: https://code.google.com/p/android/issues/detail?id=172659 Hack: https://gist.github.com/andaag/b05ab66ed0f06167d6e0");
builder.instanceField("android.widget.ActivityChooserModel", "mActivityChoserModelPolicy").reason("ActivityChooserModel holds a static reference to the last set ActivityChooserModelPolicy which can be an activity context. Tracked here: https://code.google.com/p/android/issues/detail?id=172659 Hack: https://gist.github.com/andaag/b05ab66ed0f06167d6e0");
}
};
SPEECH_RECOGNIZER = new AndroidExcludedRefs("SPEECH_RECOGNIZER", 11, Build.VERSION.SDK_INT < 21) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.12
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("android.speech.SpeechRecognizer$InternalListener", "this$0").reason("Prior to Android 5, SpeechRecognizer.InternalListener was a non static inner class and leaked the SpeechRecognizer which leaked an activity context. Fixed in AOSP: https://github.com/android/platform_frameworks_base/commit /b37866db469e81aca534ff6186bdafd44352329b");
}
};
ACCOUNT_MANAGER = new AndroidExcludedRefs("ACCOUNT_MANAGER", 12, Build.VERSION.SDK_INT <= 27) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.13
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("android.accounts.AccountManager$AmsTask$Response", "this$1").reason("AccountManager$AmsTask$Response is a stub and is held in memory by native code, probably because the reference to the response in the other process hasn't been cleared. AccountManager$AmsTask is holding on to the activity reference to use for launching a new sub- Activity. Tracked here: https://code.google.com/p/android/issues/detail?id=173689 Fix: Pass a null activity reference to the AccountManager methods and then deal with the returned future to to get the result and correctly start an activity when it's available.");
}
};
MEDIA_SCANNER_CONNECTION = new AndroidExcludedRefs("MEDIA_SCANNER_CONNECTION", 13, Build.VERSION.SDK_INT <= 22) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.14
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("android.media.MediaScannerConnection", "mContext").reason("The static method MediaScannerConnection.scanFile() takes an activity context but the service might not disconnect after the activity has been destroyed. Tracked here: https://code.google.com/p/android/issues/detail?id=173788 Fix: Create an instance of MediaScannerConnection yourself and pass in the application context. Call connect() and disconnect() manually.");
}
};
int i30 = Build.VERSION.SDK_INT;
int i31 = 18;
int i32 = 26;
USER_MANAGER__SINSTANCE = new AndroidExcludedRefs("USER_MANAGER__SINSTANCE", i23, i30 >= 18 && i30 < 26) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.15
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("android.os.UserManager", "mContext").reason("UserManager has a static sInstance field that creates an instance and caches it the first time UserManager.get() is called. This instance is created with the outer context (which is an activity base context). Tracked here: https://code.google.com/p/android/issues/detail?id=173789 Introduced by: https://github.com/android/platform_frameworks_base/commit/27db46850b708070452c0ce49daf5f79503fbde6 Fix: trigger a call to UserManager.get() in Application.onCreate(), so that the UserManager instance gets cached with a reference to the application context.");
}
};
APP_WIDGET_HOST_CALLBACKS = new AndroidExcludedRefs("APP_WIDGET_HOST_CALLBACKS", i17, Build.VERSION.SDK_INT < 22) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.16
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("android.appwidget.AppWidgetHost$Callbacks", "this$0").reason("android.appwidget.AppWidgetHost$Callbacks is a stub and is held in memory native code. The reference to the `mContext` was not being cleared, which caused the Callbacks instance to retain this reference Fixed in AOSP: https://github.com/android/platform_frameworks_base/commit/7a96f3c917e0001ee739b65da37b2fadec7d7765");
}
};
AUDIO_MANAGER = new AndroidExcludedRefs("AUDIO_MANAGER", i26, Build.VERSION.SDK_INT <= 22) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.17
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("android.media.AudioManager$1", "this$0").reason("Prior to Android M, VideoView required audio focus from AudioManager and never abandoned it, which leaks the Activity context through the AudioManager. The root of the problem is that AudioManager uses whichever context it receives, which in the case of the VideoView example is an Activity, even though it only needs the application's context. The issue is fixed in Android M, and the AudioManager now uses the application's context. Tracked here: https://code.google.com/p/android/issues/detail?id=152173 Fix: https://gist.github.com/jankovd/891d96f476f7a9ce24e2");
}
};
EDITTEXT_BLINK_MESSAGEQUEUE = new AndroidExcludedRefs("EDITTEXT_BLINK_MESSAGEQUEUE", 17, Build.VERSION.SDK_INT <= 22) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.18
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("android.widget.Editor$Blink", "this$0").reason("The EditText Blink of the Cursor is implemented using a callback and Messages, which trigger the display of the Cursor. If an AlertDialog or DialogFragment that contains a blinking cursor is detached, a message is posted with a delay after the dialog has been closed and as a result leaks the Activity. This can be fixed manually by calling TextView.setCursorVisible(false) in the dismiss() method of the dialog. Tracked here: https://code.google.com/p/android/issues/detail?id=188551 Fixed in AOSP: https://android.googlesource.com/platform/frameworks/base/+/5b734f2430e9f26c769d6af8ea5645e390fcf5af%5E%21/");
}
};
int i33 = 23;
CONNECTIVITY_MANAGER__SINSTANCE = new AndroidExcludedRefs("CONNECTIVITY_MANAGER__SINSTANCE", i31, Build.VERSION.SDK_INT <= 23) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.19
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("android.net.ConnectivityManager", "sInstance").reason("ConnectivityManager has a sInstance field that is set when the first ConnectivityManager instance is created. ConnectivityManager has a mContext field. When calling activity.getSystemService(Context.CONNECTIVITY_SERVICE) , the first ConnectivityManager instance is created with the activity context and stored in sInstance. That activity context then leaks forever. Until this is fixed, app developers can prevent this leak by making sure the ConnectivityManager is first created with an App Context. E.g. in some static init do: context.getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE) Tracked here: https://code.google.com/p/android/issues/detail?id=198852 Introduced here: https://github.com/android/platform_frameworks_base/commit/e0bef71662d81caaaa0d7214fb0bef5d39996a69");
}
};
int i34 = Build.VERSION.SDK_INT;
ACCESSIBILITY_NODE_INFO__MORIGINALTEXT = new AndroidExcludedRefs("ACCESSIBILITY_NODE_INFO__MORIGINALTEXT", i12, i34 >= 26 && i34 <= 27) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.20
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("android.view.accessibility.AccessibilityNodeInfo", "mOriginalText").reason("AccessibilityNodeInfo has a static sPool of AccessibilityNodeInfo. When AccessibilityNodeInfo instances are released back in the pool, AccessibilityNodeInfo.clear() does not clear the mOriginalText field, which causes spans to leak which in turns causes TextView.ChangeWatcher to leak and the whole view hierarchy. Introduced here: https://android.googlesource.com/platform/frameworks/base/+/193520e3dff5248ddcf8435203bf99d2ba667219%5E%21/core/java/android/view/accessibility/AccessibilityNodeInfo.java");
}
};
int i35 = 20;
int i36 = Build.VERSION.SDK_INT;
BACKDROP_FRAME_RENDERER__MDECORVIEW = new AndroidExcludedRefs("BACKDROP_FRAME_RENDERER__MDECORVIEW", i35, i36 >= 24 && i36 <= 26) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.21
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("com.android.internal.policy.BackdropFrameRenderer", "mDecorView").reason("When BackdropFrameRenderer.releaseRenderer() is called, there's an unknown case where mRenderer becomes null but mChoreographer doesn't and the thread doesn't stop and ends up leaking mDecorView which itself holds on to a destroyed activity");
}
};
INSTRUMENTATION_RECOMMEND_ACTIVITY = new AndroidExcludedRefs("INSTRUMENTATION_RECOMMEND_ACTIVITY", i11, LeakCanaryInternals.MEIZU.equals(Build.MANUFACTURER) && (i9 = Build.VERSION.SDK_INT) >= 21 && i9 <= 22) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.22
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.staticField("android.app.Instrumentation", "mRecommendActivity").reason("Instrumentation would leak com.android.internal.app.RecommendActivity (in framework.jar) in Meizu FlymeOS 4.5 and above, which is based on Android 5.0 and above");
}
};
DEVICE_POLICY_MANAGER__SETTINGS_OBSERVER = new AndroidExcludedRefs("DEVICE_POLICY_MANAGER__SETTINGS_OBSERVER", i14, LeakCanaryInternals.MOTOROLA.equals(Build.MANUFACTURER) && (i8 = Build.VERSION.SDK_INT) >= 19 && i8 <= 22) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.23
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
if (LeakCanaryInternals.MOTOROLA.equals(Build.MANUFACTURER) && Build.VERSION.SDK_INT == 19) {
builder.instanceField("android.app.admin.DevicePolicyManager$SettingsObserver", "this$0").reason("DevicePolicyManager keeps a reference to the context it has been created with instead of extracting the application context. In this Motorola build, DevicePolicyManager has an inner SettingsObserver class that is a content observer, which is held into memory by a binder transport object.");
}
}
};
SPEN_GESTURE_MANAGER = new AndroidExcludedRefs("SPEN_GESTURE_MANAGER", i33, "samsung".equals(Build.MANUFACTURER) && Build.VERSION.SDK_INT == 19) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.24
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.staticField("com.samsung.android.smartclip.SpenGestureManager", "mContext").reason("SpenGestureManager has a static mContext field that leaks a reference to the activity. Yes, a STATIC mContext field.");
}
};
int i37 = 25;
GESTURE_BOOST_MANAGER = new AndroidExcludedRefs("GESTURE_BOOST_MANAGER", i27, LeakCanaryInternals.HUAWEI.equals(Build.MANUFACTURER) && (i7 = Build.VERSION.SDK_INT) >= 24 && i7 <= 25) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.25
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.staticField("android.gestureboost.GestureBoostManager", "mContext").reason("GestureBoostManager is a static singleton that leaks an activity context. Fix: https://github.com/square/leakcanary/issues/696#issuecomment-296420756");
}
};
INPUT_METHOD_MANAGER__LAST_SERVED_VIEW = new AndroidExcludedRefs("INPUT_METHOD_MANAGER__LAST_SERVED_VIEW", i37, LeakCanaryInternals.HUAWEI.equals(Build.MANUFACTURER) && (i6 = Build.VERSION.SDK_INT) >= 23 && i6 <= 27) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.26
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("android.view.inputmethod.InputMethodManager", "mLastSrvView").reason("HUAWEI added a mLastSrvView field to InputMethodManager that leaks a reference to the last served view.");
}
};
CLIPBOARD_UI_MANAGER__SINSTANCE = new AndroidExcludedRefs("CLIPBOARD_UI_MANAGER__SINSTANCE", i32, "samsung".equals(Build.MANUFACTURER) && (i5 = Build.VERSION.SDK_INT) >= 19 && i5 <= 21) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.27
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("android.sec.clipboard.ClipboardUIManager", "mContext").reason("ClipboardUIManager is a static singleton that leaks an activity context. Fix: trigger a call to ClipboardUIManager.getInstance() in Application.onCreate() , so that the ClipboardUIManager instance gets cached with a reference to the application context. Example: https://gist.github.com/cypressious/91c4fb1455470d803a602838dfcd5774");
}
};
SEM_CLIPBOARD_MANAGER__MCONTEXT = new AndroidExcludedRefs("SEM_CLIPBOARD_MANAGER__MCONTEXT", i18, "samsung".equals(Build.MANUFACTURER) && (i4 = Build.VERSION.SDK_INT) >= 19 && i4 <= 24) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.28
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("com.samsung.android.content.clipboard.SemClipboardManager", "mContext").reason("SemClipboardManager is held in memory by an anonymous inner class implementation of android.os.Binder, thereby leaking an activity context.");
}
};
SEM_EMERGENCY_MANAGER__MCONTEXT = new AndroidExcludedRefs("SEM_EMERGENCY_MANAGER__MCONTEXT", 28, "samsung".equals(Build.MANUFACTURER) && (i3 = Build.VERSION.SDK_INT) >= 19 && i3 <= 24) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.29
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("com.samsung.android.emergencymode.SemEmergencyManager", "mContext").reason("SemEmergencyManager is a static singleton that leaks a DecorContext. Fix: https://gist.github.com/jankovd/a210460b814c04d500eb12025902d60d");
}
};
BUBBLE_POPUP_HELPER__SHELPER = new AndroidExcludedRefs("BUBBLE_POPUP_HELPER__SHELPER", 29, LeakCanaryInternals.LG.equals(Build.MANUFACTURER) && (i2 = Build.VERSION.SDK_INT) >= 19 && i2 <= 21) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.30
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.staticField("android.widget.BubblePopupHelper", "sHelper").reason("A static helper for EditText bubble popups leaks a reference to the latest focused view.");
}
};
LGCONTEXT__MCONTEXT = new AndroidExcludedRefs("LGCONTEXT__MCONTEXT", 30, LeakCanaryInternals.LG.equals(Build.MANUFACTURER) && Build.VERSION.SDK_INT == 21) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.31
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("com.lge.systemservice.core.LGContext", "mContext").reason("LGContext is a static singleton that leaks an activity context.");
}
};
AW_RESOURCE__SRESOURCES = new AndroidExcludedRefs("AW_RESOURCE__SRESOURCES", 31, "samsung".equals(Build.MANUFACTURER) && Build.VERSION.SDK_INT == 19) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.32
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.staticField("com.android.org.chromium.android_webview.AwResource", "sResources");
}
};
MAPPER_CLIENT = new AndroidExcludedRefs("MAPPER_CLIENT", 32, LeakCanaryInternals.NVIDIA.equals(Build.MANUFACTURER) && Build.VERSION.SDK_INT == 19) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.33
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("com.nvidia.ControllerMapper.MapperClient$ServiceClient", "this$0").reason("Not sure exactly what ControllerMapper is about, but there is an anonymous Handler in ControllerMapper.MapperClient.ServiceClient, which leaks ControllerMapper.MapperClient which leaks the activity context.");
}
};
TEXT_VIEW__MLAST_HOVERED_VIEW = new AndroidExcludedRefs("TEXT_VIEW__MLAST_HOVERED_VIEW", 33, "samsung".equals(Build.MANUFACTURER) && (i = Build.VERSION.SDK_INT) >= 19 && i <= 26) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.34
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.staticField("android.widget.TextView", "mLastHoveredView").reason("mLastHoveredView is a static field in TextView that leaks the last hovered view.");
}
};
PERSONA_MANAGER = new AndroidExcludedRefs("PERSONA_MANAGER", 34, "samsung".equals(Build.MANUFACTURER) && Build.VERSION.SDK_INT == 19) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.35
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("android.os.PersonaManager", "mContext").reason("android.app.LoadedApk.mResources has a reference to android.content.res.Resources.mPersonaManager which has a reference to android.os.PersonaManager.mContext which is an activity.");
}
};
RESOURCES__MCONTEXT = new AndroidExcludedRefs("RESOURCES__MCONTEXT", 35, "samsung".equals(Build.MANUFACTURER) && Build.VERSION.SDK_INT == 19) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.36
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("android.content.res.Resources", "mContext").reason("In AOSP the Resources class does not have a context. Here we have ZygoteInit.mResources (static field) holding on to a Resources instance that has a context that is the activity. Observed here: https://github.com/square/leakcanary/issues/1#issue-74450184");
}
};
VIEW_CONFIGURATION__MCONTEXT = new AndroidExcludedRefs("VIEW_CONFIGURATION__MCONTEXT", 36, "samsung".equals(Build.MANUFACTURER) && Build.VERSION.SDK_INT == 19) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.37
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("android.view.ViewConfiguration", "mContext").reason("In AOSP the ViewConfiguration class does not have a context. Here we have ViewConfiguration.sConfigurations (static field) holding on to a ViewConfiguration instance that has a context that is the activity. Observed here: https://github.com/square/leakcanary/issues/1#issuecomment-100324683");
}
};
SYSTEM_SENSOR_MANAGER__MAPPCONTEXTIMPL = new AndroidExcludedRefs("SYSTEM_SENSOR_MANAGER__MAPPCONTEXTIMPL", 37, (LeakCanaryInternals.LENOVO.equals(Build.MANUFACTURER) && Build.VERSION.SDK_INT == 19) || ("vivo".equals(Build.MANUFACTURER) && Build.VERSION.SDK_INT == 22)) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.38
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.staticField("android.hardware.SystemSensorManager", "mAppContextImpl").reason("SystemSensorManager stores a reference to context in a static field in its constructor. Fix: use application context to get SensorManager");
}
};
AUDIO_MANAGER__MCONTEXT_STATIC = new AndroidExcludedRefs("AUDIO_MANAGER__MCONTEXT_STATIC", 38, "samsung".equals(Build.MANUFACTURER) && Build.VERSION.SDK_INT == 19) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.39
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.staticField("android.media.AudioManager", "mContext_static").reason("Samsung added a static mContext_static field to AudioManager, holds a reference to the activity. Observed here: https://github.com/square/leakcanary/issues/32");
}
};
ACTIVITY_MANAGER_MCONTEXT = new AndroidExcludedRefs("ACTIVITY_MANAGER_MCONTEXT", 39, "samsung".equals(Build.MANUFACTURER) && Build.VERSION.SDK_INT == 22) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.40
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.staticField("android.app.ActivityManager", "mContext").reason("Samsung added a static mContext field to ActivityManager, holds a reference to the activity. Observed here: https://github.com/square/leakcanary/issues/177 Fix in comment: https://github.com/square/leakcanary/issues/177#issuecomment-222724283");
}
};
SOFT_REFERENCES = new AndroidExcludedRefs("SOFT_REFERENCES", 40) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.41
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.clazz(WeakReference.class.getName()).alwaysExclude();
builder.clazz(SoftReference.class.getName()).alwaysExclude();
builder.clazz(PhantomReference.class.getName()).alwaysExclude();
builder.clazz("java.lang.ref.Finalizer").alwaysExclude();
builder.clazz("java.lang.ref.FinalizerReference").alwaysExclude();
}
};
FINALIZER_WATCHDOG_DAEMON = new AndroidExcludedRefs("FINALIZER_WATCHDOG_DAEMON", 41) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.42
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.thread("FinalizerWatchdogDaemon").alwaysExclude();
}
};
MAIN = new AndroidExcludedRefs("MAIN", 42) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.43
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.thread("main").alwaysExclude();
}
};
LEAK_CANARY_THREAD = new AndroidExcludedRefs("LEAK_CANARY_THREAD", 43) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.44
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.thread("LeakCanary-Heap-Dump").alwaysExclude();
}
};
EVENT_RECEIVER__MMESSAGE_QUEUE = new AndroidExcludedRefs("EVENT_RECEIVER__MMESSAGE_QUEUE", 44) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.45
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("android.view.Choreographer$FrameDisplayEventReceiver", "mMessageQueue").alwaysExclude();
}
};
VIEWLOCATIONHOLDER_ROOT = new AndroidExcludedRefs("VIEWLOCATIONHOLDER_ROOT", 45, Build.VERSION.SDK_INT == 28) { // from class: com.squareup.leakcanary.AndroidExcludedRefs.46
@Override // com.squareup.leakcanary.AndroidExcludedRefs
void add(ExcludedRefs.Builder builder) {
builder.instanceField("android.view.ViewGroup$ViewLocationHolder", "mRoot");
}
};
$VALUES = new AndroidExcludedRefs[]{ACTIVITY_CLIENT_RECORD__NEXT_IDLE, SPAN_CONTROLLER, MEDIA_SESSION_LEGACY_HELPER__SINSTANCE, TEXT_LINE__SCACHED, BLOCKING_QUEUE, INPUT_METHOD_MANAGER__SERVED_VIEW, INPUT_METHOD_MANAGER__ROOT_VIEW, LAYOUT_TRANSITION, SPELL_CHECKER_SESSION, SPELL_CHECKER, ACTIVITY_CHOOSE_MODEL, SPEECH_RECOGNIZER, ACCOUNT_MANAGER, MEDIA_SCANNER_CONNECTION, USER_MANAGER__SINSTANCE, APP_WIDGET_HOST_CALLBACKS, AUDIO_MANAGER, EDITTEXT_BLINK_MESSAGEQUEUE, CONNECTIVITY_MANAGER__SINSTANCE, ACCESSIBILITY_NODE_INFO__MORIGINALTEXT, BACKDROP_FRAME_RENDERER__MDECORVIEW, INSTRUMENTATION_RECOMMEND_ACTIVITY, DEVICE_POLICY_MANAGER__SETTINGS_OBSERVER, SPEN_GESTURE_MANAGER, GESTURE_BOOST_MANAGER, INPUT_METHOD_MANAGER__LAST_SERVED_VIEW, CLIPBOARD_UI_MANAGER__SINSTANCE, SEM_CLIPBOARD_MANAGER__MCONTEXT, SEM_EMERGENCY_MANAGER__MCONTEXT, BUBBLE_POPUP_HELPER__SHELPER, LGCONTEXT__MCONTEXT, AW_RESOURCE__SRESOURCES, MAPPER_CLIENT, TEXT_VIEW__MLAST_HOVERED_VIEW, PERSONA_MANAGER, RESOURCES__MCONTEXT, VIEW_CONFIGURATION__MCONTEXT, SYSTEM_SENSOR_MANAGER__MAPPCONTEXTIMPL, AUDIO_MANAGER__MCONTEXT_STATIC, ACTIVITY_MANAGER_MCONTEXT, SOFT_REFERENCES, FINALIZER_WATCHDOG_DAEMON, MAIN, LEAK_CANARY_THREAD, EVENT_RECEIVER__MMESSAGE_QUEUE, VIEWLOCATIONHOLDER_ROOT};
}
public static ExcludedRefs.Builder createAndroidDefaults() {
return createBuilder(EnumSet.of(SOFT_REFERENCES, FINALIZER_WATCHDOG_DAEMON, MAIN, LEAK_CANARY_THREAD, EVENT_RECEIVER__MMESSAGE_QUEUE));
}
public static ExcludedRefs.Builder createAppDefaults() {
return createBuilder(EnumSet.allOf(AndroidExcludedRefs.class));
}
public static ExcludedRefs.Builder createBuilder(EnumSet<AndroidExcludedRefs> enumSet) {
ExcludedRefs.Builder builder = ExcludedRefs.builder();
Iterator it = enumSet.iterator();
while (it.hasNext()) {
AndroidExcludedRefs androidExcludedRefs = (AndroidExcludedRefs) it.next();
if (androidExcludedRefs.applies) {
androidExcludedRefs.add(builder);
((ExcludedRefs.BuilderWithParams) builder).named(androidExcludedRefs.name());
}
}
return builder;
}
public static AndroidExcludedRefs valueOf(String str) {
return (AndroidExcludedRefs) Enum.valueOf(AndroidExcludedRefs.class, str);
}
public static AndroidExcludedRefs[] values() {
return (AndroidExcludedRefs[]) $VALUES.clone();
}
abstract void add(ExcludedRefs.Builder builder);
private AndroidExcludedRefs(String str, int i) {
this(str, i, true);
}
private AndroidExcludedRefs(String str, int i, boolean z) {
this.applies = z;
}
}

View File

@@ -0,0 +1,111 @@
package com.squareup.leakcanary;
import android.app.Activity;
import android.app.Application;
import android.app.Notification;
import android.app.NotificationManager;
import android.content.Context;
import android.os.Debug;
import android.os.Handler;
import android.os.Looper;
import android.os.MessageQueue;
import android.os.SystemClock;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.Toast;
import com.squareup.leakcanary.internal.ActivityLifecycleCallbacksAdapter;
import com.squareup.leakcanary.internal.FutureResult;
import com.squareup.leakcanary.internal.LeakCanaryInternals;
import java.io.File;
import java.util.concurrent.TimeUnit;
/* loaded from: classes.dex */
public final class AndroidHeapDumper implements HeapDumper {
private final Context context;
private final LeakDirectoryProvider leakDirectoryProvider;
private final Handler mainHandler = new Handler(Looper.getMainLooper());
private Activity resumedActivity;
public AndroidHeapDumper(Context context, LeakDirectoryProvider leakDirectoryProvider) {
this.leakDirectoryProvider = leakDirectoryProvider;
this.context = context.getApplicationContext();
((Application) context.getApplicationContext()).registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacksAdapter() { // from class: com.squareup.leakcanary.AndroidHeapDumper.1
@Override // com.squareup.leakcanary.internal.ActivityLifecycleCallbacksAdapter, android.app.Application.ActivityLifecycleCallbacks
public void onActivityPaused(Activity activity) {
if (AndroidHeapDumper.this.resumedActivity == activity) {
AndroidHeapDumper.this.resumedActivity = null;
}
}
@Override // com.squareup.leakcanary.internal.ActivityLifecycleCallbacksAdapter, android.app.Application.ActivityLifecycleCallbacks
public void onActivityResumed(Activity activity) {
AndroidHeapDumper.this.resumedActivity = activity;
}
});
}
private void cancelToast(final Toast toast) {
if (toast == null) {
return;
}
this.mainHandler.post(new Runnable() { // from class: com.squareup.leakcanary.AndroidHeapDumper.3
@Override // java.lang.Runnable
public void run() {
toast.cancel();
}
});
}
private void showToast(final FutureResult<Toast> futureResult) {
this.mainHandler.post(new Runnable() { // from class: com.squareup.leakcanary.AndroidHeapDumper.2
@Override // java.lang.Runnable
public void run() {
if (AndroidHeapDumper.this.resumedActivity == null) {
futureResult.set(null);
return;
}
final Toast toast = new Toast(AndroidHeapDumper.this.resumedActivity);
toast.setGravity(16, 0, 0);
toast.setDuration(1);
toast.setView(LayoutInflater.from(AndroidHeapDumper.this.resumedActivity).inflate(R.layout.leak_canary_heap_dump_toast, (ViewGroup) null));
toast.show();
Looper.myQueue().addIdleHandler(new MessageQueue.IdleHandler() { // from class: com.squareup.leakcanary.AndroidHeapDumper.2.1
@Override // android.os.MessageQueue.IdleHandler
public boolean queueIdle() {
futureResult.set(toast);
return false;
}
});
}
});
}
@Override // com.squareup.leakcanary.HeapDumper
public File dumpHeap() {
File newHeapDumpFile = this.leakDirectoryProvider.newHeapDumpFile();
File file = HeapDumper.RETRY_LATER;
if (newHeapDumpFile == file) {
return file;
}
FutureResult<Toast> futureResult = new FutureResult<>();
showToast(futureResult);
if (!futureResult.wait(5L, TimeUnit.SECONDS)) {
CanaryLog.d("Did not dump heap, too much time waiting for Toast.", new Object[0]);
return HeapDumper.RETRY_LATER;
}
Notification buildNotification = LeakCanaryInternals.buildNotification(this.context, new Notification.Builder(this.context).setContentTitle(this.context.getString(R.string.leak_canary_notification_dumping)));
NotificationManager notificationManager = (NotificationManager) this.context.getSystemService("notification");
int uptimeMillis = (int) SystemClock.uptimeMillis();
notificationManager.notify(uptimeMillis, buildNotification);
Toast toast = futureResult.get();
try {
Debug.dumpHprofData(newHeapDumpFile.getAbsolutePath());
cancelToast(toast);
notificationManager.cancel(uptimeMillis);
return newHeapDumpFile;
} catch (Exception e) {
CanaryLog.d(e, "Could not dump heap", new Object[0]);
return HeapDumper.RETRY_LATER;
}
}
}

View File

@@ -0,0 +1,146 @@
package com.squareup.leakcanary;
import android.app.Activity;
import android.app.Application;
import android.app.Dialog;
import android.app.Fragment;
import android.os.MessageQueue;
import android.view.View;
import com.squareup.leakcanary.Reachability;
import com.unity3d.ads.metadata.MediationMetaData;
import java.util.ArrayList;
import java.util.List;
/* loaded from: classes.dex */
public enum AndroidReachabilityInspectors {
VIEW(ViewInspector.class),
ACTIVITY(ActivityInspector.class),
DIALOG(DialogInspector.class),
APPLICATION(ApplicationInspector.class),
FRAGMENT(FragmentInspector.class),
SUPPORT_FRAGMENT(SupportFragmentInspector.class),
MESSAGE_QUEUE(MessageQueueInspector.class),
MORTAR_PRESENTER(MortarPresenterInspector.class),
VIEW_ROOT_IMPL(ViewImplInspector.class),
MAIN_THEAD(MainThreadInspector.class),
WINDOW(WindowInspector.class);
private final Class<? extends Reachability.Inspector> inspectorClass;
public static class ActivityInspector implements Reachability.Inspector {
@Override // com.squareup.leakcanary.Reachability.Inspector
public Reachability expectedReachability(LeakTraceElement leakTraceElement) {
if (!leakTraceElement.isInstanceOf(Activity.class)) {
return Reachability.UNKNOWN;
}
String fieldReferenceValue = leakTraceElement.getFieldReferenceValue("mDestroyed");
return fieldReferenceValue == null ? Reachability.UNKNOWN : fieldReferenceValue.equals("true") ? Reachability.UNREACHABLE : Reachability.REACHABLE;
}
}
public static class ApplicationInspector implements Reachability.Inspector {
@Override // com.squareup.leakcanary.Reachability.Inspector
public Reachability expectedReachability(LeakTraceElement leakTraceElement) {
return leakTraceElement.isInstanceOf(Application.class) ? Reachability.REACHABLE : Reachability.UNKNOWN;
}
}
public static class DialogInspector implements Reachability.Inspector {
@Override // com.squareup.leakcanary.Reachability.Inspector
public Reachability expectedReachability(LeakTraceElement leakTraceElement) {
if (!leakTraceElement.isInstanceOf(Dialog.class)) {
return Reachability.UNKNOWN;
}
String fieldReferenceValue = leakTraceElement.getFieldReferenceValue("mDecor");
return fieldReferenceValue == null ? Reachability.UNKNOWN : fieldReferenceValue.equals("null") ? Reachability.UNREACHABLE : Reachability.REACHABLE;
}
}
public static class FragmentInspector implements Reachability.Inspector {
@Override // com.squareup.leakcanary.Reachability.Inspector
public Reachability expectedReachability(LeakTraceElement leakTraceElement) {
if (!leakTraceElement.isInstanceOf(Fragment.class)) {
return Reachability.UNKNOWN;
}
String fieldReferenceValue = leakTraceElement.getFieldReferenceValue("mDetached");
return fieldReferenceValue == null ? Reachability.UNKNOWN : fieldReferenceValue.equals("true") ? Reachability.UNREACHABLE : Reachability.REACHABLE;
}
}
public static class MainThreadInspector implements Reachability.Inspector {
@Override // com.squareup.leakcanary.Reachability.Inspector
public Reachability expectedReachability(LeakTraceElement leakTraceElement) {
return !leakTraceElement.isInstanceOf(Thread.class) ? Reachability.UNKNOWN : "main".equals(leakTraceElement.getFieldReferenceValue(MediationMetaData.KEY_NAME)) ? Reachability.REACHABLE : Reachability.UNKNOWN;
}
}
public static class MessageQueueInspector implements Reachability.Inspector {
@Override // com.squareup.leakcanary.Reachability.Inspector
public Reachability expectedReachability(LeakTraceElement leakTraceElement) {
return !leakTraceElement.isInstanceOf(MessageQueue.class) ? Reachability.UNKNOWN : "true".equals(leakTraceElement.getFieldReferenceValue("mQuitting")) ? Reachability.UNREACHABLE : Reachability.UNKNOWN;
}
}
public static class MortarPresenterInspector implements Reachability.Inspector {
@Override // com.squareup.leakcanary.Reachability.Inspector
public Reachability expectedReachability(LeakTraceElement leakTraceElement) {
return !leakTraceElement.isInstanceOf("mortar.Presenter") ? Reachability.UNKNOWN : "null".equals(leakTraceElement.getFieldReferenceValue("view")) ? Reachability.UNREACHABLE : Reachability.UNKNOWN;
}
}
public static class SupportFragmentInspector implements Reachability.Inspector {
@Override // com.squareup.leakcanary.Reachability.Inspector
public Reachability expectedReachability(LeakTraceElement leakTraceElement) {
if (!leakTraceElement.isInstanceOf("androidx.fragment.app.Fragment")) {
return Reachability.UNKNOWN;
}
String fieldReferenceValue = leakTraceElement.getFieldReferenceValue("mDetached");
return fieldReferenceValue == null ? Reachability.UNKNOWN : fieldReferenceValue.equals("true") ? Reachability.UNREACHABLE : Reachability.REACHABLE;
}
}
public static class ViewImplInspector implements Reachability.Inspector {
@Override // com.squareup.leakcanary.Reachability.Inspector
public Reachability expectedReachability(LeakTraceElement leakTraceElement) {
if (!leakTraceElement.isInstanceOf("android.view.ViewRootImpl")) {
return Reachability.UNKNOWN;
}
String fieldReferenceValue = leakTraceElement.getFieldReferenceValue("mView");
return fieldReferenceValue == null ? Reachability.UNKNOWN : fieldReferenceValue.equals("null") ? Reachability.UNREACHABLE : Reachability.REACHABLE;
}
}
public static class ViewInspector implements Reachability.Inspector {
@Override // com.squareup.leakcanary.Reachability.Inspector
public Reachability expectedReachability(LeakTraceElement leakTraceElement) {
if (!leakTraceElement.isInstanceOf(View.class)) {
return Reachability.UNKNOWN;
}
String fieldReferenceValue = leakTraceElement.getFieldReferenceValue("mAttachInfo");
return fieldReferenceValue == null ? Reachability.UNKNOWN : fieldReferenceValue.equals("null") ? Reachability.UNREACHABLE : Reachability.REACHABLE;
}
}
public static class WindowInspector implements Reachability.Inspector {
@Override // com.squareup.leakcanary.Reachability.Inspector
public Reachability expectedReachability(LeakTraceElement leakTraceElement) {
if (!leakTraceElement.isInstanceOf("android.view.Window")) {
return Reachability.UNKNOWN;
}
String fieldReferenceValue = leakTraceElement.getFieldReferenceValue("mDestroyed");
return fieldReferenceValue == null ? Reachability.UNKNOWN : fieldReferenceValue.equals("true") ? Reachability.UNREACHABLE : Reachability.REACHABLE;
}
}
AndroidReachabilityInspectors(Class cls) {
this.inspectorClass = cls;
}
public static List<Class<? extends Reachability.Inspector>> defaultAndroidInspectors() {
ArrayList arrayList = new ArrayList();
for (AndroidReachabilityInspectors androidReachabilityInspectors : values()) {
arrayList.add(androidReachabilityInspectors.inspectorClass);
}
return arrayList;
}
}

View File

@@ -0,0 +1,102 @@
package com.squareup.leakcanary;
import android.content.Context;
import com.squareup.leakcanary.HeapDump;
import com.squareup.leakcanary.Reachability;
import com.squareup.leakcanary.internal.DisplayLeakActivity;
import com.squareup.leakcanary.internal.FragmentRefWatcher;
import com.squareup.leakcanary.internal.LeakCanaryInternals;
import java.util.List;
import java.util.concurrent.TimeUnit;
/* loaded from: classes.dex */
public final class AndroidRefWatcherBuilder extends RefWatcherBuilder<AndroidRefWatcherBuilder> {
private static final long DEFAULT_WATCH_DELAY_MILLIS = TimeUnit.SECONDS.toMillis(5);
private final Context context;
private boolean watchActivities = true;
private boolean watchFragments = true;
private boolean enableDisplayLeakActivity = false;
AndroidRefWatcherBuilder(Context context) {
this.context = context.getApplicationContext();
}
public RefWatcher buildAndInstall() {
if (LeakCanaryInternals.installedRefWatcher != null) {
throw new UnsupportedOperationException("buildAndInstall() should only be called once.");
}
RefWatcher build = build();
if (build != RefWatcher.DISABLED) {
if (this.enableDisplayLeakActivity) {
LeakCanaryInternals.setEnabledAsync(this.context, DisplayLeakActivity.class, true);
}
if (this.watchActivities) {
ActivityRefWatcher.install(this.context, build);
}
if (this.watchFragments) {
FragmentRefWatcher.Helper.install(this.context, build);
}
}
LeakCanaryInternals.installedRefWatcher = build;
return build;
}
@Override // com.squareup.leakcanary.RefWatcherBuilder
protected DebuggerControl defaultDebuggerControl() {
return new AndroidDebuggerControl();
}
@Override // com.squareup.leakcanary.RefWatcherBuilder
protected ExcludedRefs defaultExcludedRefs() {
return AndroidExcludedRefs.createAppDefaults().build();
}
@Override // com.squareup.leakcanary.RefWatcherBuilder
protected HeapDump.Listener defaultHeapDumpListener() {
return new ServiceHeapDumpListener(this.context, DisplayLeakService.class);
}
@Override // com.squareup.leakcanary.RefWatcherBuilder
protected HeapDumper defaultHeapDumper() {
return new AndroidHeapDumper(this.context, LeakCanaryInternals.getLeakDirectoryProvider(this.context));
}
@Override // com.squareup.leakcanary.RefWatcherBuilder
protected List<Class<? extends Reachability.Inspector>> defaultReachabilityInspectorClasses() {
return AndroidReachabilityInspectors.defaultAndroidInspectors();
}
@Override // com.squareup.leakcanary.RefWatcherBuilder
protected WatchExecutor defaultWatchExecutor() {
return new AndroidWatchExecutor(DEFAULT_WATCH_DELAY_MILLIS);
}
@Override // com.squareup.leakcanary.RefWatcherBuilder
protected boolean isDisabled() {
return LeakCanary.isInAnalyzerProcess(this.context);
}
public AndroidRefWatcherBuilder listenerServiceClass(Class<? extends AbstractAnalysisResultService> cls) {
this.enableDisplayLeakActivity = DisplayLeakService.class.isAssignableFrom(cls);
return heapDumpListener(new ServiceHeapDumpListener(this.context, cls));
}
public AndroidRefWatcherBuilder maxStoredHeapDumps(int i) {
LeakCanary.setLeakDirectoryProvider(new DefaultLeakDirectoryProvider(this.context, i));
return self();
}
public AndroidRefWatcherBuilder watchActivities(boolean z) {
this.watchActivities = z;
return this;
}
public AndroidRefWatcherBuilder watchDelay(long j, TimeUnit timeUnit) {
return watchExecutor(new AndroidWatchExecutor(timeUnit.toMillis(j)));
}
public AndroidRefWatcherBuilder watchFragments(boolean z) {
this.watchFragments = z;
return this;
}
}

View File

@@ -0,0 +1,66 @@
package com.squareup.leakcanary;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.MessageQueue;
import com.squareup.leakcanary.Retryable;
/* loaded from: classes.dex */
public final class AndroidWatchExecutor implements WatchExecutor {
static final String LEAK_CANARY_THREAD_NAME = "LeakCanary-Heap-Dump";
private final Handler backgroundHandler;
private final long initialDelayMillis;
private final Handler mainHandler = new Handler(Looper.getMainLooper());
private final long maxBackoffFactor;
public AndroidWatchExecutor(long j) {
HandlerThread handlerThread = new HandlerThread(LEAK_CANARY_THREAD_NAME);
handlerThread.start();
this.backgroundHandler = new Handler(handlerThread.getLooper());
this.initialDelayMillis = j;
this.maxBackoffFactor = Long.MAX_VALUE / j;
}
/* JADX INFO: Access modifiers changed from: private */
public void postToBackgroundWithDelay(final Retryable retryable, final int i) {
this.backgroundHandler.postDelayed(new Runnable() { // from class: com.squareup.leakcanary.AndroidWatchExecutor.3
@Override // java.lang.Runnable
public void run() {
if (retryable.run() == Retryable.Result.RETRY) {
AndroidWatchExecutor.this.postWaitForIdle(retryable, i + 1);
}
}
}, this.initialDelayMillis * ((long) Math.min(Math.pow(2.0d, i), this.maxBackoffFactor)));
}
/* JADX INFO: Access modifiers changed from: private */
public void postWaitForIdle(final Retryable retryable, final int i) {
this.mainHandler.post(new Runnable() { // from class: com.squareup.leakcanary.AndroidWatchExecutor.1
@Override // java.lang.Runnable
public void run() {
AndroidWatchExecutor.this.waitForIdle(retryable, i);
}
});
}
/* JADX INFO: Access modifiers changed from: private */
public void waitForIdle(final Retryable retryable, final int i) {
Looper.myQueue().addIdleHandler(new MessageQueue.IdleHandler() { // from class: com.squareup.leakcanary.AndroidWatchExecutor.2
@Override // android.os.MessageQueue.IdleHandler
public boolean queueIdle() {
AndroidWatchExecutor.this.postToBackgroundWithDelay(retryable, i);
return false;
}
});
}
@Override // com.squareup.leakcanary.WatchExecutor
public void execute(Retryable retryable) {
if (Looper.getMainLooper().getThread() == Thread.currentThread()) {
waitForIdle(retryable, 0);
} else {
postWaitForIdle(retryable, 0);
}
}
}

View File

@@ -0,0 +1,13 @@
package com.squareup.leakcanary;
/* loaded from: classes.dex */
public final class BuildConfig {
public static final String APPLICATION_ID = "com.squareup.leakcanary";
public static final String BUILD_TYPE = "release";
public static final boolean DEBUG = false;
public static final String FLAVOR = "";
public static final String GIT_SHA = "31007b4";
public static final String LIBRARY_VERSION = "1.6.3";
public static final int VERSION_CODE = -1;
public static final String VERSION_NAME = "";
}

View File

@@ -0,0 +1,60 @@
package com.squareup.leakcanary;
import android.util.Log;
/* loaded from: classes.dex */
public final class CanaryLog {
private static volatile Logger logger = new DefaultLogger();
public interface Logger {
void d(String str, Object... objArr);
void d(Throwable th, String str, Object... objArr);
}
private CanaryLog() {
throw new AssertionError();
}
public static void d(String str, Object... objArr) {
Logger logger2 = logger;
if (logger2 == null) {
return;
}
logger2.d(str, objArr);
}
public static void setLogger(Logger logger2) {
logger = logger2;
}
public static void d(Throwable th, String str, Object... objArr) {
Logger logger2 = logger;
if (logger2 == null) {
return;
}
logger2.d(th, str, objArr);
}
private static class DefaultLogger implements Logger {
DefaultLogger() {
}
@Override // com.squareup.leakcanary.CanaryLog.Logger
public void d(String str, Object... objArr) {
String format = String.format(str, objArr);
if (format.length() < 4000) {
Log.d("LeakCanary", format);
return;
}
for (String str2 : format.split("\n", -1)) {
Log.d("LeakCanary", str2);
}
}
@Override // com.squareup.leakcanary.CanaryLog.Logger
public void d(Throwable th, String str, Object... objArr) {
d(String.format(str, objArr) + '\n' + Log.getStackTraceString(th), new Object[0]);
}
}
}

View File

@@ -0,0 +1,13 @@
package com.squareup.leakcanary;
/* loaded from: classes.dex */
public interface DebuggerControl {
public static final DebuggerControl NONE = new DebuggerControl() { // from class: com.squareup.leakcanary.DebuggerControl.1
@Override // com.squareup.leakcanary.DebuggerControl
public boolean isDebuggerAttached() {
return false;
}
};
boolean isDebuggerAttached();
}

View File

@@ -0,0 +1,164 @@
package com.squareup.leakcanary;
import android.annotation.TargetApi;
import android.app.PendingIntent;
import android.content.Context;
import android.os.Build;
import android.os.Environment;
import com.squareup.leakcanary.internal.LeakCanaryInternals;
import com.squareup.leakcanary.internal.RequestStoragePermissionActivity;
import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
/* loaded from: classes.dex */
public final class DefaultLeakDirectoryProvider implements LeakDirectoryProvider {
private static final int ANALYSIS_MAX_DURATION_MS = 600000;
private static final int DEFAULT_MAX_STORED_HEAP_DUMPS = 7;
private static final String HPROF_SUFFIX = ".hprof";
private static final String PENDING_HEAPDUMP_SUFFIX = "_pending.hprof";
private final Context context;
private final int maxStoredHeapDumps;
private volatile boolean permissionNotificationDisplayed;
private volatile boolean writeExternalStorageGranted;
public DefaultLeakDirectoryProvider(Context context) {
this(context, 7);
}
private File appStorageDirectory() {
return new File(this.context.getFilesDir(), "leakcanary");
}
private void cleanupOldHeapDumps() {
List<File> listFiles = listFiles(new FilenameFilter() { // from class: com.squareup.leakcanary.DefaultLeakDirectoryProvider.3
@Override // java.io.FilenameFilter
public boolean accept(File file, String str) {
return str.endsWith(DefaultLeakDirectoryProvider.HPROF_SUFFIX);
}
});
int size = listFiles.size() - this.maxStoredHeapDumps;
if (size > 0) {
CanaryLog.d("Removing %d heap dumps", Integer.valueOf(size));
Collections.sort(listFiles, new Comparator<File>() { // from class: com.squareup.leakcanary.DefaultLeakDirectoryProvider.4
@Override // java.util.Comparator
public int compare(File file, File file2) {
return Long.valueOf(file.lastModified()).compareTo(Long.valueOf(file2.lastModified()));
}
});
for (int i = 0; i < size; i++) {
if (!listFiles.get(i).delete()) {
CanaryLog.d("Could not delete old hprof file %s", listFiles.get(i).getPath());
}
}
}
}
private boolean directoryWritableAfterMkdirs(File file) {
return (file.mkdirs() || file.exists()) && file.canWrite();
}
private File externalStorageDirectory() {
return new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "leakcanary-" + this.context.getPackageName());
}
@TargetApi(23)
private boolean hasStoragePermission() {
if (Build.VERSION.SDK_INT < 23 || this.writeExternalStorageGranted) {
return true;
}
this.writeExternalStorageGranted = this.context.checkSelfPermission("android.permission.WRITE_EXTERNAL_STORAGE") == 0;
return this.writeExternalStorageGranted;
}
private void requestWritePermissionNotification() {
if (this.permissionNotificationDisplayed) {
return;
}
this.permissionNotificationDisplayed = true;
PendingIntent createPendingIntent = RequestStoragePermissionActivity.createPendingIntent(this.context);
LeakCanaryInternals.showNotification(this.context, this.context.getString(R.string.leak_canary_permission_notification_title), this.context.getString(R.string.leak_canary_permission_notification_text, this.context.getPackageName()), createPendingIntent, -558907665);
}
@Override // com.squareup.leakcanary.LeakDirectoryProvider
public void clearLeakDirectory() {
for (File file : listFiles(new FilenameFilter() { // from class: com.squareup.leakcanary.DefaultLeakDirectoryProvider.2
@Override // java.io.FilenameFilter
public boolean accept(File file2, String str) {
return !str.endsWith(DefaultLeakDirectoryProvider.PENDING_HEAPDUMP_SUFFIX);
}
})) {
if (!file.delete()) {
CanaryLog.d("Could not delete file %s", file.getPath());
}
}
}
@Override // com.squareup.leakcanary.LeakDirectoryProvider
public List<File> listFiles(FilenameFilter filenameFilter) {
if (!hasStoragePermission()) {
requestWritePermissionNotification();
}
ArrayList arrayList = new ArrayList();
File[] listFiles = externalStorageDirectory().listFiles(filenameFilter);
if (listFiles != null) {
arrayList.addAll(Arrays.asList(listFiles));
}
File[] listFiles2 = appStorageDirectory().listFiles(filenameFilter);
if (listFiles2 != null) {
arrayList.addAll(Arrays.asList(listFiles2));
}
return arrayList;
}
@Override // com.squareup.leakcanary.LeakDirectoryProvider
public File newHeapDumpFile() {
Iterator<File> it = listFiles(new FilenameFilter() { // from class: com.squareup.leakcanary.DefaultLeakDirectoryProvider.1
@Override // java.io.FilenameFilter
public boolean accept(File file, String str) {
return str.endsWith(DefaultLeakDirectoryProvider.PENDING_HEAPDUMP_SUFFIX);
}
}).iterator();
while (it.hasNext()) {
if (System.currentTimeMillis() - it.next().lastModified() < 600000) {
CanaryLog.d("Could not dump heap, previous analysis still is in progress.", new Object[0]);
return HeapDumper.RETRY_LATER;
}
}
cleanupOldHeapDumps();
File externalStorageDirectory = externalStorageDirectory();
if (!directoryWritableAfterMkdirs(externalStorageDirectory)) {
if (hasStoragePermission()) {
String externalStorageState = Environment.getExternalStorageState();
if ("mounted".equals(externalStorageState)) {
CanaryLog.d("Could not create heap dump directory in external storage: [%s]", externalStorageDirectory.getAbsolutePath());
} else {
CanaryLog.d("External storage not mounted, state: %s", externalStorageState);
}
} else {
CanaryLog.d("WRITE_EXTERNAL_STORAGE permission not granted", new Object[0]);
requestWritePermissionNotification();
}
externalStorageDirectory = appStorageDirectory();
if (!directoryWritableAfterMkdirs(externalStorageDirectory)) {
CanaryLog.d("Could not create heap dump directory in app storage: [%s]", externalStorageDirectory.getAbsolutePath());
return HeapDumper.RETRY_LATER;
}
}
return new File(externalStorageDirectory, UUID.randomUUID().toString() + PENDING_HEAPDUMP_SUFFIX);
}
public DefaultLeakDirectoryProvider(Context context, int i) {
if (i < 1) {
throw new IllegalArgumentException("maxStoredHeapDumps must be at least 1");
}
this.context = context.getApplicationContext();
this.maxStoredHeapDumps = i;
}
}

View File

@@ -0,0 +1,72 @@
package com.squareup.leakcanary;
import android.app.PendingIntent;
import android.os.SystemClock;
import android.text.format.Formatter;
import com.squareup.leakcanary.internal.DisplayLeakActivity;
import com.squareup.leakcanary.internal.LeakCanaryInternals;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
/* loaded from: classes.dex */
public class DisplayLeakService extends AbstractAnalysisResultService {
private HeapDump renameHeapdump(HeapDump heapDump) {
File file = new File(heapDump.heapDumpFile.getParent(), new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss_SSS'.hprof'", Locale.US).format(new Date()));
if (!heapDump.heapDumpFile.renameTo(file)) {
CanaryLog.d("Could not rename heap dump file %s to %s", heapDump.heapDumpFile.getPath(), file.getPath());
}
return heapDump.buildUpon().heapDumpFile(file).build();
}
private boolean saveResult(HeapDump heapDump, AnalysisResult analysisResult) {
return AnalyzedHeap.save(heapDump, analysisResult) != null;
}
private void showNotification(PendingIntent pendingIntent, String str, String str2) {
LeakCanaryInternals.showNotification(this, str, str2, pendingIntent, (int) (SystemClock.uptimeMillis() / 1000));
}
protected void afterDefaultHandling(HeapDump heapDump, AnalysisResult analysisResult, String str) {
}
@Override // com.squareup.leakcanary.AbstractAnalysisResultService
protected final void onAnalysisResultFailure(String str) {
super.onAnalysisResultFailure(str);
showNotification(null, getString(R.string.leak_canary_result_failure_title), str);
}
@Override // com.squareup.leakcanary.AbstractAnalysisResultService
protected final void onHeapAnalyzed(AnalyzedHeap analyzedHeap) {
String string;
HeapDump heapDump = analyzedHeap.heapDump;
AnalysisResult analysisResult = analyzedHeap.result;
String leakInfo = LeakCanary.leakInfo(this, heapDump, analysisResult, true);
CanaryLog.d("%s", leakInfo);
HeapDump renameHeapdump = renameHeapdump(heapDump);
if (saveResult(renameHeapdump, analysisResult)) {
PendingIntent createPendingIntent = DisplayLeakActivity.createPendingIntent(this, renameHeapdump.referenceKey);
if (analysisResult.failure != null) {
string = getString(R.string.leak_canary_analysis_failed);
} else {
String classSimpleName = LeakCanaryInternals.classSimpleName(analysisResult.className);
if (analysisResult.leakFound) {
long j = analysisResult.retainedHeapSize;
if (j == -1) {
string = analysisResult.excludedLeak ? getString(R.string.leak_canary_leak_excluded, new Object[]{classSimpleName}) : getString(R.string.leak_canary_class_has_leaked, new Object[]{classSimpleName});
} else {
String formatShortFileSize = Formatter.formatShortFileSize(this, j);
string = analysisResult.excludedLeak ? getString(R.string.leak_canary_leak_excluded_retaining, new Object[]{classSimpleName, formatShortFileSize}) : getString(R.string.leak_canary_class_has_leaked_retaining, new Object[]{classSimpleName, formatShortFileSize});
}
} else {
string = getString(R.string.leak_canary_class_no_leak, new Object[]{classSimpleName});
}
}
showNotification(createPendingIntent, string, getString(R.string.leak_canary_notification_message));
} else {
onAnalysisResultFailure(getString(R.string.leak_canary_could_not_save_text));
}
afterDefaultHandling(renameHeapdump, analysisResult, leakInfo);
}
}

View File

@@ -0,0 +1,162 @@
package com.squareup.leakcanary;
import java.io.Serializable;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
/* loaded from: classes.dex */
public final class ExcludedRefs implements Serializable {
public final Map<String, Exclusion> classNames;
public final Map<String, Map<String, Exclusion>> fieldNameByClassName;
public final Map<String, Map<String, Exclusion>> staticFieldNameByClassName;
public final Map<String, Exclusion> threadNames;
public interface Builder {
ExcludedRefs build();
BuilderWithParams clazz(String str);
BuilderWithParams instanceField(String str, String str2);
BuilderWithParams staticField(String str, String str2);
BuilderWithParams thread(String str);
}
public static final class BuilderWithParams implements Builder {
private ParamsBuilder lastParams;
private final Map<String, Map<String, ParamsBuilder>> fieldNameByClassName = new LinkedHashMap();
private final Map<String, Map<String, ParamsBuilder>> staticFieldNameByClassName = new LinkedHashMap();
private final Map<String, ParamsBuilder> threadNames = new LinkedHashMap();
private final Map<String, ParamsBuilder> classNames = new LinkedHashMap();
BuilderWithParams() {
}
public BuilderWithParams alwaysExclude() {
this.lastParams.alwaysExclude = true;
return this;
}
@Override // com.squareup.leakcanary.ExcludedRefs.Builder
public ExcludedRefs build() {
return new ExcludedRefs(this);
}
@Override // com.squareup.leakcanary.ExcludedRefs.Builder
public BuilderWithParams clazz(String str) {
Preconditions.checkNotNull(str, "className");
this.lastParams = new ParamsBuilder("any subclass of " + str);
this.classNames.put(str, this.lastParams);
return this;
}
@Override // com.squareup.leakcanary.ExcludedRefs.Builder
public BuilderWithParams instanceField(String str, String str2) {
Preconditions.checkNotNull(str, "className");
Preconditions.checkNotNull(str2, "fieldName");
Map<String, ParamsBuilder> map = this.fieldNameByClassName.get(str);
if (map == null) {
map = new LinkedHashMap<>();
this.fieldNameByClassName.put(str, map);
}
this.lastParams = new ParamsBuilder("field " + str + "#" + str2);
map.put(str2, this.lastParams);
return this;
}
public BuilderWithParams named(String str) {
this.lastParams.name = str;
return this;
}
public BuilderWithParams reason(String str) {
this.lastParams.reason = str;
return this;
}
@Override // com.squareup.leakcanary.ExcludedRefs.Builder
public BuilderWithParams staticField(String str, String str2) {
Preconditions.checkNotNull(str, "className");
Preconditions.checkNotNull(str2, "fieldName");
Map<String, ParamsBuilder> map = this.staticFieldNameByClassName.get(str);
if (map == null) {
map = new LinkedHashMap<>();
this.staticFieldNameByClassName.put(str, map);
}
this.lastParams = new ParamsBuilder("static field " + str + "#" + str2);
map.put(str2, this.lastParams);
return this;
}
@Override // com.squareup.leakcanary.ExcludedRefs.Builder
public BuilderWithParams thread(String str) {
Preconditions.checkNotNull(str, "threadName");
this.lastParams = new ParamsBuilder("any threads named " + str);
this.threadNames.put(str, this.lastParams);
return this;
}
}
static final class ParamsBuilder {
boolean alwaysExclude;
final String matching;
String name;
String reason;
ParamsBuilder(String str) {
this.matching = str;
}
}
ExcludedRefs(BuilderWithParams builderWithParams) {
this.fieldNameByClassName = unmodifiableRefStringMap(builderWithParams.fieldNameByClassName);
this.staticFieldNameByClassName = unmodifiableRefStringMap(builderWithParams.staticFieldNameByClassName);
this.threadNames = unmodifiableRefMap(builderWithParams.threadNames);
this.classNames = unmodifiableRefMap(builderWithParams.classNames);
}
public static Builder builder() {
return new BuilderWithParams();
}
private Map<String, Exclusion> unmodifiableRefMap(Map<String, ParamsBuilder> map) {
LinkedHashMap linkedHashMap = new LinkedHashMap();
for (Map.Entry<String, ParamsBuilder> entry : map.entrySet()) {
linkedHashMap.put(entry.getKey(), new Exclusion(entry.getValue()));
}
return Collections.unmodifiableMap(linkedHashMap);
}
private Map<String, Map<String, Exclusion>> unmodifiableRefStringMap(Map<String, Map<String, ParamsBuilder>> map) {
LinkedHashMap linkedHashMap = new LinkedHashMap();
for (Map.Entry<String, Map<String, ParamsBuilder>> entry : map.entrySet()) {
linkedHashMap.put(entry.getKey(), unmodifiableRefMap(entry.getValue()));
}
return Collections.unmodifiableMap(linkedHashMap);
}
public String toString() {
String str = "";
for (Map.Entry<String, Map<String, Exclusion>> entry : this.fieldNameByClassName.entrySet()) {
String key = entry.getKey();
for (Map.Entry<String, Exclusion> entry2 : entry.getValue().entrySet()) {
str = str + "| Field: " + key + "." + entry2.getKey() + (entry2.getValue().alwaysExclude ? " (always)" : "") + "\n";
}
}
for (Map.Entry<String, Map<String, Exclusion>> entry3 : this.staticFieldNameByClassName.entrySet()) {
String key2 = entry3.getKey();
for (Map.Entry<String, Exclusion> entry4 : entry3.getValue().entrySet()) {
str = str + "| Static field: " + key2 + "." + entry4.getKey() + (entry4.getValue().alwaysExclude ? " (always)" : "") + "\n";
}
}
for (Map.Entry<String, Exclusion> entry5 : this.threadNames.entrySet()) {
str = str + "| Thread:" + entry5.getKey() + (entry5.getValue().alwaysExclude ? " (always)" : "") + "\n";
}
for (Map.Entry<String, Exclusion> entry6 : this.classNames.entrySet()) {
str = str + "| Class:" + entry6.getKey() + (entry6.getValue().alwaysExclude ? " (always)" : "") + "\n";
}
return str;
}
}

View File

@@ -0,0 +1,19 @@
package com.squareup.leakcanary;
import com.squareup.leakcanary.ExcludedRefs;
import java.io.Serializable;
/* loaded from: classes.dex */
public final class Exclusion implements Serializable {
public final boolean alwaysExclude;
public final String matching;
public final String name;
public final String reason;
Exclusion(ExcludedRefs.ParamsBuilder paramsBuilder) {
this.name = paramsBuilder.name;
this.reason = paramsBuilder.reason;
this.alwaysExclude = paramsBuilder.alwaysExclude;
this.matching = paramsBuilder.matching;
}
}

View File

@@ -0,0 +1,23 @@
package com.squareup.leakcanary;
/* loaded from: classes.dex */
public interface GcTrigger {
public static final GcTrigger DEFAULT = new GcTrigger() { // from class: com.squareup.leakcanary.GcTrigger.1
private void enqueueReferences() {
try {
Thread.sleep(100L);
} catch (InterruptedException unused) {
throw new AssertionError();
}
}
@Override // com.squareup.leakcanary.GcTrigger
public void runGc() {
Runtime.getRuntime().gc();
enqueueReferences();
System.runFinalization();
}
};
void runGc();
}

View File

@@ -0,0 +1,140 @@
package com.squareup.leakcanary;
import com.baidu.cloud.media.player.BDCloudMediaPlayer;
import com.squareup.haha.perflib.ArrayInstance;
import com.squareup.haha.perflib.ClassInstance;
import com.squareup.haha.perflib.ClassObj;
import com.squareup.haha.perflib.Instance;
import com.squareup.haha.perflib.Type;
import com.unity3d.ads.metadata.MediationMetaData;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
/* loaded from: classes.dex */
public final class HahaHelper {
private static final Set<String> WRAPPER_TYPES = new HashSet(Arrays.asList(Boolean.class.getName(), Character.class.getName(), Float.class.getName(), Double.class.getName(), Byte.class.getName(), Short.class.getName(), Integer.class.getName(), Long.class.getName()));
private HahaHelper() {
throw new AssertionError();
}
static String asString(Object obj) {
Preconditions.checkNotNull(obj, "stringObject");
Instance instance = (Instance) obj;
List<ClassInstance.FieldValue> classInstanceValues = classInstanceValues(instance);
Integer num = (Integer) fieldValue(classInstanceValues, "count");
Preconditions.checkNotNull(num, "count");
if (num.intValue() == 0) {
return "";
}
Object fieldValue = fieldValue(classInstanceValues, "value");
Preconditions.checkNotNull(fieldValue, "value");
if (isCharArray(fieldValue)) {
ArrayInstance arrayInstance = (ArrayInstance) fieldValue;
Integer num2 = 0;
if (hasField(classInstanceValues, BDCloudMediaPlayer.OnNativeInvokeListener.ARG_OFFSET)) {
num2 = (Integer) fieldValue(classInstanceValues, BDCloudMediaPlayer.OnNativeInvokeListener.ARG_OFFSET);
Preconditions.checkNotNull(num2, BDCloudMediaPlayer.OnNativeInvokeListener.ARG_OFFSET);
}
return new String(arrayInstance.asCharArray(num2.intValue(), num.intValue()));
}
if (!isByteArray(fieldValue)) {
throw new UnsupportedOperationException("Could not find char array in " + instance);
}
ArrayInstance arrayInstance2 = (ArrayInstance) fieldValue;
try {
Method declaredMethod = ArrayInstance.class.getDeclaredMethod("asRawByteArray", Integer.TYPE, Integer.TYPE);
declaredMethod.setAccessible(true);
return new String((byte[]) declaredMethod.invoke(arrayInstance2, 0, num), Charset.forName("UTF-8"));
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (NoSuchMethodException e2) {
throw new RuntimeException(e2);
} catch (InvocationTargetException e3) {
throw new RuntimeException(e3);
}
}
static List<ClassInstance.FieldValue> classInstanceValues(Instance instance) {
return ((ClassInstance) instance).getValues();
}
static boolean extendsThread(ClassObj classObj) {
while (classObj.getSuperClassObj() != null) {
if (classObj.getClassName().equals(Thread.class.getName())) {
return true;
}
classObj = classObj.getSuperClassObj();
}
return false;
}
static <T> T fieldValue(List<ClassInstance.FieldValue> list, String str) {
for (ClassInstance.FieldValue fieldValue : list) {
if (fieldValue.getField().getName().equals(str)) {
return (T) fieldValue.getValue();
}
}
throw new IllegalArgumentException("Field " + str + " does not exists");
}
static boolean hasField(List<ClassInstance.FieldValue> list, String str) {
Iterator<ClassInstance.FieldValue> it = list.iterator();
while (it.hasNext()) {
if (it.next().getField().getName().equals(str)) {
return true;
}
}
return false;
}
private static boolean isByteArray(Object obj) {
return (obj instanceof ArrayInstance) && ((ArrayInstance) obj).getArrayType() == Type.BYTE;
}
private static boolean isCharArray(Object obj) {
return (obj instanceof ArrayInstance) && ((ArrayInstance) obj).getArrayType() == Type.CHAR;
}
public static boolean isPrimitiveOrWrapperArray(Object obj) {
if (!(obj instanceof ArrayInstance)) {
return false;
}
ArrayInstance arrayInstance = (ArrayInstance) obj;
if (arrayInstance.getArrayType() != Type.OBJECT) {
return true;
}
return WRAPPER_TYPES.contains(arrayInstance.getClassObj().getClassName());
}
public static boolean isPrimitiveWrapper(Object obj) {
if (obj instanceof ClassInstance) {
return WRAPPER_TYPES.contains(((ClassInstance) obj).getClassObj().getClassName());
}
return false;
}
static String threadName(Instance instance) {
Object fieldValue = fieldValue(classInstanceValues(instance), MediationMetaData.KEY_NAME);
return fieldValue == null ? "Thread name not available" : asString(fieldValue);
}
static String valueAsString(Object obj) {
if (obj == null) {
return "null";
}
if (!(obj instanceof ClassInstance)) {
return obj.toString();
}
if (!((ClassInstance) obj).getClassObj().getClassName().equals(String.class.getName())) {
return obj.toString();
}
return '\"' + asString(obj) + '\"';
}
}

View File

@@ -0,0 +1,352 @@
package com.squareup.leakcanary;
import android.os.Build;
import com.squareup.haha.perflib.ArrayInstance;
import com.squareup.haha.perflib.ClassInstance;
import com.squareup.haha.perflib.ClassObj;
import com.squareup.haha.perflib.Field;
import com.squareup.haha.perflib.HprofParser;
import com.squareup.haha.perflib.Instance;
import com.squareup.haha.perflib.RootObj;
import com.squareup.haha.perflib.RootType;
import com.squareup.haha.perflib.Snapshot;
import com.squareup.haha.perflib.Type;
import com.squareup.haha.perflib.io.MemoryMappedFileBuffer;
import com.squareup.leakcanary.AnalyzerProgressListener;
import com.squareup.leakcanary.LeakTraceElement;
import com.squareup.leakcanary.Reachability;
import com.squareup.leakcanary.ShortestPathFinder;
import com.unity3d.ads.metadata.MediationMetaData;
import gnu.trove.THashMap;
import gnu.trove.TObjectProcedure;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/* loaded from: classes.dex */
public final class HeapAnalyzer {
private static final String ANONYMOUS_CLASS_NAME_PATTERN = "^.+\\$\\d+$";
private final ExcludedRefs excludedRefs;
private final AnalyzerProgressListener listener;
private final List<Reachability.Inspector> reachabilityInspectors;
@Deprecated
public HeapAnalyzer(ExcludedRefs excludedRefs) {
this(excludedRefs, AnalyzerProgressListener.NONE, Collections.emptyList());
}
private LeakTraceElement buildLeakElement(LeakNode leakNode) {
LeakTraceElement.Holder holder;
String str;
LeakTraceElement.Holder holder2;
LeakNode leakNode2 = leakNode.parent;
String str2 = null;
if (leakNode2 == null) {
return null;
}
Instance instance = leakNode2.instance;
if (instance instanceof RootObj) {
return null;
}
List<LeakReference> describeFields = describeFields(instance);
String className = getClassName(instance);
ArrayList arrayList = new ArrayList();
arrayList.add(className);
String name = Object.class.getName();
if (instance instanceof ClassInstance) {
ClassObj classObj = instance.getClassObj();
while (true) {
classObj = classObj.getSuperClassObj();
if (classObj.getClassName().equals(name)) {
break;
}
arrayList.add(classObj.getClassName());
}
}
if (instance instanceof ClassObj) {
holder = LeakTraceElement.Holder.CLASS;
} else if (instance instanceof ArrayInstance) {
holder = LeakTraceElement.Holder.ARRAY;
} else {
ClassObj classObj2 = instance.getClassObj();
if (HahaHelper.extendsThread(classObj2)) {
LeakTraceElement.Holder holder3 = LeakTraceElement.Holder.THREAD;
str = "(named '" + HahaHelper.threadName(instance) + "')";
holder2 = holder3;
return new LeakTraceElement(leakNode.leakReference, holder2, arrayList, str, leakNode.exclusion, describeFields);
}
if (className.matches(ANONYMOUS_CLASS_NAME_PATTERN)) {
String className2 = classObj2.getSuperClassObj().getClassName();
if (name.equals(className2)) {
holder = LeakTraceElement.Holder.OBJECT;
try {
Class<?>[] interfaces = Class.forName(classObj2.getClassName()).getInterfaces();
if (interfaces.length > 0) {
str2 = "(anonymous implementation of " + interfaces[0].getName() + ")";
} else {
str2 = "(anonymous subclass of java.lang.Object)";
}
} catch (ClassNotFoundException unused) {
}
} else {
str2 = "(anonymous subclass of " + className2 + ")";
holder = LeakTraceElement.Holder.OBJECT;
}
} else {
holder = LeakTraceElement.Holder.OBJECT;
}
}
holder2 = holder;
str = str2;
return new LeakTraceElement(leakNode.leakReference, holder2, arrayList, str, leakNode.exclusion, describeFields);
}
private LeakTrace buildLeakTrace(LeakNode leakNode) {
ArrayList arrayList = new ArrayList();
for (LeakNode leakNode2 = new LeakNode(null, null, leakNode, null); leakNode2 != null; leakNode2 = leakNode2.parent) {
LeakTraceElement buildLeakElement = buildLeakElement(leakNode2);
if (buildLeakElement != null) {
arrayList.add(0, buildLeakElement);
}
}
return new LeakTrace(arrayList, computeExpectedReachability(arrayList));
}
private List<Reachability> computeExpectedReachability(List<LeakTraceElement> list) {
Reachability expectedReachability;
int i = 1;
int size = list.size() - 1;
int i2 = 0;
int i3 = 0;
loop0: while (true) {
if (i >= size) {
break;
}
LeakTraceElement leakTraceElement = list.get(i);
Iterator<Reachability.Inspector> it = this.reachabilityInspectors.iterator();
do {
if (!it.hasNext()) {
break;
}
expectedReachability = it.next().expectedReachability(leakTraceElement);
if (expectedReachability == Reachability.REACHABLE) {
i3 = i;
}
i++;
} while (expectedReachability != Reachability.UNREACHABLE);
size = i;
break loop0;
}
ArrayList arrayList = new ArrayList();
while (i2 < list.size()) {
arrayList.add(i2 <= i3 ? Reachability.REACHABLE : i2 >= size ? Reachability.UNREACHABLE : Reachability.UNKNOWN);
i2++;
}
return arrayList;
}
private long computeIgnoredBitmapRetainedSize(Snapshot snapshot, Instance instance) {
ArrayInstance arrayInstance;
long j = 0;
for (Instance instance2 : snapshot.findClass("android.graphics.Bitmap").getInstancesList()) {
if (isIgnoredDominator(instance, instance2) && (arrayInstance = (ArrayInstance) HahaHelper.fieldValue(HahaHelper.classInstanceValues(instance2), "mBuffer")) != null) {
long totalRetainedSize = arrayInstance.getTotalRetainedSize();
long totalRetainedSize2 = instance2.getTotalRetainedSize();
if (totalRetainedSize2 < totalRetainedSize) {
totalRetainedSize2 += totalRetainedSize;
}
j += totalRetainedSize2;
}
}
return j;
}
private List<LeakReference> describeFields(Instance instance) {
ArrayList arrayList = new ArrayList();
if (instance instanceof ClassObj) {
for (Map.Entry<Field, Object> entry : ((ClassObj) instance).getStaticFieldValues().entrySet()) {
arrayList.add(new LeakReference(LeakTraceElement.Type.STATIC_FIELD, entry.getKey().getName(), HahaHelper.valueAsString(entry.getValue())));
}
} else if (instance instanceof ArrayInstance) {
ArrayInstance arrayInstance = (ArrayInstance) instance;
if (arrayInstance.getArrayType() == Type.OBJECT) {
Object[] values = arrayInstance.getValues();
for (int i = 0; i < values.length; i++) {
arrayList.add(new LeakReference(LeakTraceElement.Type.ARRAY_ENTRY, Integer.toString(i), HahaHelper.valueAsString(values[i])));
}
}
} else {
for (Map.Entry<Field, Object> entry2 : instance.getClassObj().getStaticFieldValues().entrySet()) {
arrayList.add(new LeakReference(LeakTraceElement.Type.STATIC_FIELD, entry2.getKey().getName(), HahaHelper.valueAsString(entry2.getValue())));
}
for (ClassInstance.FieldValue fieldValue : ((ClassInstance) instance).getValues()) {
arrayList.add(new LeakReference(LeakTraceElement.Type.INSTANCE_FIELD, fieldValue.getField().getName(), HahaHelper.valueAsString(fieldValue.getValue())));
}
}
return arrayList;
}
private AnalysisResult findLeakTrace(long j, Snapshot snapshot, Instance instance, boolean z) {
long j2;
this.listener.onProgressUpdate(AnalyzerProgressListener.Step.FINDING_SHORTEST_PATH);
ShortestPathFinder.Result findPath = new ShortestPathFinder(this.excludedRefs).findPath(snapshot, instance);
String className = instance.getClassObj().getClassName();
if (findPath.leakingNode == null) {
return AnalysisResult.noLeak(className, since(j));
}
this.listener.onProgressUpdate(AnalyzerProgressListener.Step.BUILDING_LEAK_TRACE);
LeakTrace buildLeakTrace = buildLeakTrace(findPath.leakingNode);
if (z) {
this.listener.onProgressUpdate(AnalyzerProgressListener.Step.COMPUTING_DOMINATORS);
snapshot.computeDominators();
Instance instance2 = findPath.leakingNode.instance;
j2 = instance2.getTotalRetainedSize();
if (Build.VERSION.SDK_INT <= 25) {
this.listener.onProgressUpdate(AnalyzerProgressListener.Step.COMPUTING_BITMAP_SIZE);
j2 += computeIgnoredBitmapRetainedSize(snapshot, instance2);
}
} else {
j2 = -1;
}
return AnalysisResult.leakDetected(findPath.excludingKnownLeaks, className, buildLeakTrace, j2, since(j));
}
private Instance findLeakingReference(String str, Snapshot snapshot) {
ClassObj findClass = snapshot.findClass(KeyedWeakReference.class.getName());
if (findClass == null) {
throw new IllegalStateException("Could not find the " + KeyedWeakReference.class.getName() + " class in the heap dump.");
}
ArrayList arrayList = new ArrayList();
Iterator<Instance> it = findClass.getInstancesList().iterator();
while (it.hasNext()) {
List<ClassInstance.FieldValue> classInstanceValues = HahaHelper.classInstanceValues(it.next());
Object fieldValue = HahaHelper.fieldValue(classInstanceValues, "key");
if (fieldValue == null) {
arrayList.add(null);
} else {
String asString = HahaHelper.asString(fieldValue);
if (asString.equals(str)) {
return (Instance) HahaHelper.fieldValue(classInstanceValues, "referent");
}
arrayList.add(asString);
}
}
throw new IllegalStateException("Could not find weak reference with key " + str + " in " + arrayList);
}
private String generateRootKey(RootObj rootObj) {
return String.format("%s@0x%08x", rootObj.getRootType().getName(), Long.valueOf(rootObj.getId()));
}
private String getClassName(Instance instance) {
return instance instanceof ClassObj ? ((ClassObj) instance).getClassName() : instance instanceof ArrayInstance ? ((ArrayInstance) instance).getClassObj().getClassName() : instance.getClassObj().getClassName();
}
private boolean isIgnoredDominator(Instance instance, Instance instance2) {
boolean z = false;
do {
Instance immediateDominator = instance2.getImmediateDominator();
if ((immediateDominator instanceof RootObj) && ((RootObj) immediateDominator).getRootType() == RootType.UNKNOWN) {
instance2 = instance2.getNextInstanceToGcRoot();
z = true;
} else {
instance2 = immediateDominator;
}
if (instance2 == null) {
return false;
}
} while (instance2 != instance);
return z;
}
private long since(long j) {
return TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - j);
}
@Deprecated
public AnalysisResult checkForLeak(File file, String str) {
return checkForLeak(file, str, true);
}
void deduplicateGcRoots(Snapshot snapshot) {
final THashMap tHashMap = new THashMap();
final Collection<RootObj> gCRoots = snapshot.getGCRoots();
for (RootObj rootObj : gCRoots) {
String generateRootKey = generateRootKey(rootObj);
if (!tHashMap.containsKey(generateRootKey)) {
tHashMap.put(generateRootKey, rootObj);
}
}
gCRoots.clear();
tHashMap.forEach(new TObjectProcedure<String>() { // from class: com.squareup.leakcanary.HeapAnalyzer.1
@Override // gnu.trove.TObjectProcedure
public boolean execute(String str) {
return gCRoots.add(tHashMap.get(str));
}
});
}
public List<TrackedReference> findTrackedReferences(File file) {
if (!file.exists()) {
throw new IllegalArgumentException("File does not exist: " + file);
}
try {
Snapshot parse = new HprofParser(new MemoryMappedFileBuffer(file)).parse();
deduplicateGcRoots(parse);
ClassObj findClass = parse.findClass(KeyedWeakReference.class.getName());
ArrayList arrayList = new ArrayList();
Iterator<Instance> it = findClass.getInstancesList().iterator();
while (it.hasNext()) {
List<ClassInstance.FieldValue> classInstanceValues = HahaHelper.classInstanceValues(it.next());
String asString = HahaHelper.asString(HahaHelper.fieldValue(classInstanceValues, "key"));
String asString2 = HahaHelper.hasField(classInstanceValues, MediationMetaData.KEY_NAME) ? HahaHelper.asString(HahaHelper.fieldValue(classInstanceValues, MediationMetaData.KEY_NAME)) : "(No name field)";
Instance instance = (Instance) HahaHelper.fieldValue(classInstanceValues, "referent");
if (instance != null) {
arrayList.add(new TrackedReference(asString, asString2, getClassName(instance), describeFields(instance)));
}
}
return arrayList;
} catch (Throwable th) {
throw new RuntimeException(th);
}
}
public AnalysisResult checkForLeak(File file, String str, boolean z) {
long nanoTime = System.nanoTime();
if (!file.exists()) {
return AnalysisResult.failure(new IllegalArgumentException("File does not exist: " + file), since(nanoTime));
}
try {
this.listener.onProgressUpdate(AnalyzerProgressListener.Step.READING_HEAP_DUMP_FILE);
HprofParser hprofParser = new HprofParser(new MemoryMappedFileBuffer(file));
this.listener.onProgressUpdate(AnalyzerProgressListener.Step.PARSING_HEAP_DUMP);
Snapshot parse = hprofParser.parse();
this.listener.onProgressUpdate(AnalyzerProgressListener.Step.DEDUPLICATING_GC_ROOTS);
deduplicateGcRoots(parse);
this.listener.onProgressUpdate(AnalyzerProgressListener.Step.FINDING_LEAKING_REF);
Instance findLeakingReference = findLeakingReference(str, parse);
return findLeakingReference == null ? AnalysisResult.noLeak(findLeakingReference.getClassObj().getClassName(), since(nanoTime)) : findLeakTrace(nanoTime, parse, findLeakingReference, z);
} catch (Throwable th) {
return AnalysisResult.failure(th, since(nanoTime));
}
}
public HeapAnalyzer(ExcludedRefs excludedRefs, AnalyzerProgressListener analyzerProgressListener, List<Class<? extends Reachability.Inspector>> list) {
this.excludedRefs = excludedRefs;
this.listener = analyzerProgressListener;
this.reachabilityInspectors = new ArrayList();
Iterator<Class<? extends Reachability.Inspector>> it = list.iterator();
while (it.hasNext()) {
try {
this.reachabilityInspectors.add(it.next().getDeclaredConstructor(new Class[0]).newInstance(new Object[0]));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
}

View File

@@ -0,0 +1,146 @@
package com.squareup.leakcanary;
import com.squareup.leakcanary.Reachability;
import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/* loaded from: classes.dex */
public final class HeapDump implements Serializable {
public final boolean computeRetainedHeapSize;
public final ExcludedRefs excludedRefs;
public final long gcDurationMs;
public final long heapDumpDurationMs;
public final File heapDumpFile;
public final List<Class<? extends Reachability.Inspector>> reachabilityInspectorClasses;
public final String referenceKey;
public final String referenceName;
public final long watchDurationMs;
public interface Listener {
public static final Listener NONE = new Listener() { // from class: com.squareup.leakcanary.HeapDump.Listener.1
@Override // com.squareup.leakcanary.HeapDump.Listener
public void analyze(HeapDump heapDump) {
}
};
void analyze(HeapDump heapDump);
}
@Deprecated
public HeapDump(File file, String str, String str2, ExcludedRefs excludedRefs, long j, long j2, long j3) {
this(new Builder().heapDumpFile(file).referenceKey(str).referenceName(str2).excludedRefs(excludedRefs).computeRetainedHeapSize(true).watchDurationMs(j).gcDurationMs(j2).heapDumpDurationMs(j3));
}
public static Builder builder() {
return new Builder();
}
public Builder buildUpon() {
return new Builder(this);
}
public static final class Builder {
boolean computeRetainedHeapSize;
ExcludedRefs excludedRefs;
long gcDurationMs;
long heapDumpDurationMs;
File heapDumpFile;
List<Class<? extends Reachability.Inspector>> reachabilityInspectorClasses;
String referenceKey;
String referenceName;
long watchDurationMs;
Builder() {
this.heapDumpFile = null;
this.referenceKey = null;
this.referenceName = "";
this.excludedRefs = null;
this.watchDurationMs = 0L;
this.gcDurationMs = 0L;
this.heapDumpDurationMs = 0L;
this.computeRetainedHeapSize = false;
this.reachabilityInspectorClasses = null;
}
public HeapDump build() {
Preconditions.checkNotNull(this.excludedRefs, "excludedRefs");
Preconditions.checkNotNull(this.heapDumpFile, "heapDumpFile");
Preconditions.checkNotNull(this.referenceKey, "referenceKey");
Preconditions.checkNotNull(this.reachabilityInspectorClasses, "reachabilityInspectorClasses");
return new HeapDump(this);
}
public Builder computeRetainedHeapSize(boolean z) {
this.computeRetainedHeapSize = z;
return this;
}
public Builder excludedRefs(ExcludedRefs excludedRefs) {
this.excludedRefs = (ExcludedRefs) Preconditions.checkNotNull(excludedRefs, "excludedRefs");
return this;
}
public Builder gcDurationMs(long j) {
this.gcDurationMs = j;
return this;
}
public Builder heapDumpDurationMs(long j) {
this.heapDumpDurationMs = j;
return this;
}
public Builder heapDumpFile(File file) {
this.heapDumpFile = (File) Preconditions.checkNotNull(file, "heapDumpFile");
return this;
}
public Builder reachabilityInspectorClasses(List<Class<? extends Reachability.Inspector>> list) {
Preconditions.checkNotNull(list, "reachabilityInspectorClasses");
this.reachabilityInspectorClasses = Collections.unmodifiableList(new ArrayList(list));
return this;
}
public Builder referenceKey(String str) {
this.referenceKey = (String) Preconditions.checkNotNull(str, "referenceKey");
return this;
}
public Builder referenceName(String str) {
this.referenceName = (String) Preconditions.checkNotNull(str, "referenceName");
return this;
}
public Builder watchDurationMs(long j) {
this.watchDurationMs = j;
return this;
}
Builder(HeapDump heapDump) {
this.heapDumpFile = heapDump.heapDumpFile;
this.referenceKey = heapDump.referenceKey;
this.referenceName = heapDump.referenceName;
this.excludedRefs = heapDump.excludedRefs;
this.computeRetainedHeapSize = heapDump.computeRetainedHeapSize;
this.watchDurationMs = heapDump.watchDurationMs;
this.gcDurationMs = heapDump.gcDurationMs;
this.heapDumpDurationMs = heapDump.heapDumpDurationMs;
this.reachabilityInspectorClasses = heapDump.reachabilityInspectorClasses;
}
}
HeapDump(Builder builder) {
this.heapDumpFile = builder.heapDumpFile;
this.referenceKey = builder.referenceKey;
this.referenceName = builder.referenceName;
this.excludedRefs = builder.excludedRefs;
this.computeRetainedHeapSize = builder.computeRetainedHeapSize;
this.watchDurationMs = builder.watchDurationMs;
this.gcDurationMs = builder.gcDurationMs;
this.heapDumpDurationMs = builder.heapDumpDurationMs;
this.reachabilityInspectorClasses = builder.reachabilityInspectorClasses;
}
}

View File

@@ -0,0 +1,16 @@
package com.squareup.leakcanary;
import java.io.File;
/* loaded from: classes.dex */
public interface HeapDumper {
public static final HeapDumper NONE = new HeapDumper() { // from class: com.squareup.leakcanary.HeapDumper.1
@Override // com.squareup.leakcanary.HeapDumper
public File dumpHeap() {
return HeapDumper.RETRY_LATER;
}
};
public static final File RETRY_LATER = null;
File dumpHeap();
}

View File

@@ -0,0 +1,17 @@
package com.squareup.leakcanary;
import com.unity3d.ads.metadata.MediationMetaData;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
/* loaded from: classes.dex */
final class KeyedWeakReference extends WeakReference<Object> {
public final String key;
public final String name;
KeyedWeakReference(Object obj, String str, String str2, ReferenceQueue<Object> referenceQueue) {
super(Preconditions.checkNotNull(obj, "referent"), (ReferenceQueue) Preconditions.checkNotNull(referenceQueue, "referenceQueue"));
this.key = (String) Preconditions.checkNotNull(str, "key");
this.name = (String) Preconditions.checkNotNull(str2, MediationMetaData.KEY_NAME);
}
}

View File

@@ -0,0 +1,91 @@
package com.squareup.leakcanary;
import android.app.Application;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.text.format.Formatter;
import android.util.Log;
import com.squareup.leakcanary.internal.DisplayLeakActivity;
import com.squareup.leakcanary.internal.HeapAnalyzerService;
import com.squareup.leakcanary.internal.LeakCanaryInternals;
/* loaded from: classes.dex */
public final class LeakCanary {
private LeakCanary() {
throw new AssertionError();
}
public static void enableDisplayLeakActivity(Context context) {
LeakCanaryInternals.setEnabledBlocking(context, DisplayLeakActivity.class, true);
}
public static RefWatcher install(Application application) {
return refWatcher(application).listenerServiceClass(DisplayLeakService.class).excludedRefs(AndroidExcludedRefs.createAppDefaults().build()).buildAndInstall();
}
public static RefWatcher installedRefWatcher() {
RefWatcher refWatcher = LeakCanaryInternals.installedRefWatcher;
return refWatcher == null ? RefWatcher.DISABLED : refWatcher;
}
public static boolean isInAnalyzerProcess(Context context) {
Boolean bool = LeakCanaryInternals.isInAnalyzerProcess;
if (bool == null) {
bool = Boolean.valueOf(LeakCanaryInternals.isInServiceProcess(context, HeapAnalyzerService.class));
LeakCanaryInternals.isInAnalyzerProcess = bool;
}
return bool.booleanValue();
}
public static String leakInfo(Context context, HeapDump heapDump, AnalysisResult analysisResult, boolean z) {
String str;
PackageManager packageManager = context.getPackageManager();
String packageName = context.getPackageName();
try {
PackageInfo packageInfo = packageManager.getPackageInfo(packageName, 0);
String str2 = "In " + packageName + ":" + packageInfo.versionName + ":" + packageInfo.versionCode + ".\n";
String str3 = "";
if (analysisResult.leakFound) {
if (analysisResult.excludedLeak) {
str2 = str2 + "* EXCLUDED LEAK.\n";
}
String str4 = str2 + "* " + analysisResult.className;
if (!heapDump.referenceName.equals("")) {
str4 = str4 + " (" + heapDump.referenceName + ")";
}
str = str4 + " has leaked:\n" + analysisResult.leakTrace.toString() + "\n";
if (analysisResult.retainedHeapSize != -1) {
str = str + "* Retaining: " + Formatter.formatShortFileSize(context, analysisResult.retainedHeapSize) + ".\n";
}
if (z) {
str3 = "\n* Details:\n" + analysisResult.leakTrace.toDetailedString();
}
} else if (analysisResult.failure != null) {
str = str2 + "* FAILURE in 1.6.3 31007b4:" + Log.getStackTraceString(analysisResult.failure) + "\n";
} else {
str = str2 + "* NO LEAK FOUND.\n\n";
}
if (z) {
str3 = str3 + "* Excluded Refs:\n" + heapDump.excludedRefs;
}
return str + "* Reference Key: " + heapDump.referenceKey + "\n* Device: " + Build.MANUFACTURER + " " + Build.BRAND + " " + Build.MODEL + " " + Build.PRODUCT + "\n* Android Version: " + Build.VERSION.RELEASE + " API: " + Build.VERSION.SDK_INT + " LeakCanary: " + BuildConfig.LIBRARY_VERSION + " " + BuildConfig.GIT_SHA + "\n* Durations: watch=" + heapDump.watchDurationMs + "ms, gc=" + heapDump.gcDurationMs + "ms, heap dump=" + heapDump.heapDumpDurationMs + "ms, analysis=" + analysisResult.analysisDurationMs + "ms\n" + str3;
} catch (PackageManager.NameNotFoundException e) {
throw new RuntimeException(e);
}
}
public static AndroidRefWatcherBuilder refWatcher(Context context) {
return new AndroidRefWatcherBuilder(context);
}
@Deprecated
public static void setDisplayLeakActivityDirectoryProvider(LeakDirectoryProvider leakDirectoryProvider) {
setLeakDirectoryProvider(leakDirectoryProvider);
}
public static void setLeakDirectoryProvider(LeakDirectoryProvider leakDirectoryProvider) {
LeakCanaryInternals.setLeakDirectoryProvider(leakDirectoryProvider);
}
}

View File

@@ -0,0 +1,14 @@
package com.squareup.leakcanary;
import java.io.File;
import java.io.FilenameFilter;
import java.util.List;
/* loaded from: classes.dex */
public interface LeakDirectoryProvider {
void clearLeakDirectory();
List<File> listFiles(FilenameFilter filenameFilter);
File newHeapDumpFile();
}

View File

@@ -0,0 +1,18 @@
package com.squareup.leakcanary;
import com.squareup.haha.perflib.Instance;
/* loaded from: classes.dex */
final class LeakNode {
final Exclusion exclusion;
final Instance instance;
final LeakReference leakReference;
final LeakNode parent;
LeakNode(Exclusion exclusion, Instance instance, LeakNode leakNode, LeakReference leakReference) {
this.exclusion = exclusion;
this.instance = instance;
this.parent = leakNode;
this.leakReference = leakReference;
}
}

View File

@@ -0,0 +1,71 @@
package com.squareup.leakcanary;
import com.squareup.leakcanary.LeakTraceElement;
import java.io.Serializable;
/* loaded from: classes.dex */
public final class LeakReference implements Serializable {
public final String name;
public final LeakTraceElement.Type type;
public final String value;
/* renamed from: com.squareup.leakcanary.LeakReference$1, reason: invalid class name */
static /* synthetic */ class AnonymousClass1 {
static final /* synthetic */ int[] $SwitchMap$com$squareup$leakcanary$LeakTraceElement$Type = new int[LeakTraceElement.Type.values().length];
static {
try {
$SwitchMap$com$squareup$leakcanary$LeakTraceElement$Type[LeakTraceElement.Type.ARRAY_ENTRY.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$com$squareup$leakcanary$LeakTraceElement$Type[LeakTraceElement.Type.STATIC_FIELD.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$com$squareup$leakcanary$LeakTraceElement$Type[LeakTraceElement.Type.INSTANCE_FIELD.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
$SwitchMap$com$squareup$leakcanary$LeakTraceElement$Type[LeakTraceElement.Type.LOCAL.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
}
}
public LeakReference(LeakTraceElement.Type type, String str, String str2) {
this.type = type;
this.name = str;
this.value = str2;
}
public String getDisplayName() {
int i = AnonymousClass1.$SwitchMap$com$squareup$leakcanary$LeakTraceElement$Type[this.type.ordinal()];
if (i == 1) {
return "[" + this.name + "]";
}
if (i == 2 || i == 3) {
return this.name;
}
if (i == 4) {
return "<Java Local>";
}
throw new IllegalStateException("Unexpected type " + this.type + " name = " + this.name + " value = " + this.value);
}
public String toString() {
int i = AnonymousClass1.$SwitchMap$com$squareup$leakcanary$LeakTraceElement$Type[this.type.ordinal()];
if (i != 1) {
if (i == 2) {
return "static " + getDisplayName() + " = " + this.value;
}
if (i != 3) {
if (i == 4) {
return getDisplayName();
}
throw new IllegalStateException("Unexpected type " + this.type + " name = " + this.name + " value = " + this.value);
}
}
return getDisplayName() + " = " + this.value;
}
}

View File

@@ -0,0 +1,44 @@
package com.squareup.leakcanary;
import java.io.Serializable;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes.dex */
public final class LeakTrace implements Serializable {
public final List<LeakTraceElement> elements;
public final List<Reachability> expectedReachability;
LeakTrace(List<LeakTraceElement> list, List<Reachability> list2) {
this.elements = list;
this.expectedReachability = list2;
}
public String toDetailedString() {
Iterator<LeakTraceElement> it = this.elements.iterator();
String str = "";
while (it.hasNext()) {
str = str + it.next().toDetailedString();
}
return str;
}
public String toString() {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < this.elements.size(); i++) {
LeakTraceElement leakTraceElement = this.elements.get(i);
sb.append("* ");
if (i != 0) {
sb.append("");
}
Reachability reachability = this.expectedReachability.get(i);
boolean z = true;
if (reachability != Reachability.UNKNOWN && (reachability != Reachability.REACHABLE || (i < this.elements.size() - 1 && this.expectedReachability.get(i + 1) == Reachability.REACHABLE))) {
z = false;
}
sb.append(leakTraceElement.toString(z));
sb.append("\n");
}
return sb.toString();
}
}

View File

@@ -0,0 +1,138 @@
package com.squareup.leakcanary;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
/* loaded from: classes.dex */
public final class LeakTraceElement implements Serializable {
public final List<String> classHierarchy;
public final String className;
public final Exclusion exclusion;
public final String extra;
public final List<LeakReference> fieldReferences;
@Deprecated
public final List<String> fields;
public final Holder holder;
public final LeakReference reference;
@Deprecated
public final String referenceName;
@Deprecated
public final Type type;
public enum Holder {
OBJECT,
CLASS,
THREAD,
ARRAY
}
public enum Type {
INSTANCE_FIELD,
STATIC_FIELD,
LOCAL,
ARRAY_ENTRY
}
LeakTraceElement(LeakReference leakReference, Holder holder, List<String> list, String str, Exclusion exclusion, List<LeakReference> list2) {
this.reference = leakReference;
this.referenceName = leakReference == null ? null : leakReference.getDisplayName();
this.type = leakReference != null ? leakReference.type : null;
this.holder = holder;
this.classHierarchy = Collections.unmodifiableList(new ArrayList(list));
this.className = list.get(0);
this.extra = str;
this.exclusion = exclusion;
this.fieldReferences = Collections.unmodifiableList(new ArrayList(list2));
ArrayList arrayList = new ArrayList();
Iterator<LeakReference> it = list2.iterator();
while (it.hasNext()) {
arrayList.add(it.next().toString());
}
this.fields = Collections.unmodifiableList(arrayList);
}
public String getFieldReferenceValue(String str) {
for (LeakReference leakReference : this.fieldReferences) {
if (leakReference.name.equals(str)) {
return leakReference.value;
}
}
return null;
}
public String getSimpleClassName() {
int lastIndexOf = this.className.lastIndexOf(46);
return lastIndexOf == -1 ? this.className : this.className.substring(lastIndexOf + 1);
}
public boolean isInstanceOf(Class<?> cls) {
return isInstanceOf(cls.getName());
}
public String toDetailedString() {
String str;
Holder holder = this.holder;
if (holder == Holder.ARRAY) {
str = "* Array of";
} else if (holder == Holder.CLASS) {
str = "* Class";
} else {
str = "* Instance of";
}
String str2 = str + " " + this.className + "\n";
Iterator<LeakReference> it = this.fieldReferences.iterator();
while (it.hasNext()) {
str2 = str2 + "| " + it.next() + "\n";
}
return str2;
}
public String toString() {
return toString(false);
}
public boolean isInstanceOf(String str) {
Iterator<String> it = this.classHierarchy.iterator();
while (it.hasNext()) {
if (it.next().equals(str)) {
return true;
}
}
return false;
}
public String toString(boolean z) {
LeakReference leakReference = this.reference;
String str = "";
if (leakReference != null && leakReference.type == Type.STATIC_FIELD) {
str = "static ";
}
Holder holder = this.holder;
if (holder == Holder.ARRAY || holder == Holder.THREAD) {
str = str + this.holder.name().toLowerCase(Locale.US) + " ";
}
String str2 = str + getSimpleClassName();
LeakReference leakReference2 = this.reference;
if (leakReference2 != null) {
String displayName = leakReference2.getDisplayName();
if (z) {
displayName = "!(" + displayName + ")!";
}
str2 = str2 + "." + displayName;
}
if (this.extra != null) {
str2 = str2 + " " + this.extra;
}
if (this.exclusion == null) {
return str2;
}
return str2 + " , matching exclusion " + this.exclusion.matching;
}
}

View File

@@ -0,0 +1,15 @@
package com.squareup.leakcanary;
/* loaded from: classes.dex */
final class Preconditions {
private Preconditions() {
throw new AssertionError();
}
static <T> T checkNotNull(T t, String str) {
if (t != null) {
return t;
}
throw new NullPointerException(str + " must not be null");
}
}

View File

@@ -0,0 +1,271 @@
package com.squareup.leakcanary;
/* loaded from: classes.dex */
public final class R {
public static final class attr {
public static final int font = 0x7f0400fb;
public static final int fontProviderAuthority = 0x7f0400fd;
public static final int fontProviderCerts = 0x7f0400fe;
public static final int fontProviderFetchStrategy = 0x7f0400ff;
public static final int fontProviderFetchTimeout = 0x7f040100;
public static final int fontProviderPackage = 0x7f040101;
public static final int fontProviderQuery = 0x7f040102;
public static final int fontStyle = 0x7f040103;
public static final int fontWeight = 0x7f040105;
public static final int leak_canary_plus_color = 0x7f040195;
private attr() {
}
}
public static final class bool {
public static final int abc_action_bar_embed_tabs = 0x7f050000;
private bool() {
}
}
public static final class color {
public static final int leak_canary_background_color = 0x7f0600e4;
public static final int leak_canary_class_name = 0x7f0600e5;
public static final int leak_canary_extra = 0x7f0600e6;
public static final int leak_canary_help = 0x7f0600e7;
public static final int leak_canary_icon_background = 0x7f0600e8;
public static final int leak_canary_leak = 0x7f0600e9;
public static final int leak_canary_reference = 0x7f0600ea;
public static final int notification_action_color_filter = 0x7f060116;
public static final int notification_icon_bg_color = 0x7f060117;
public static final int ripple_material_light = 0x7f06012a;
public static final int secondary_text_default_material_light = 0x7f06012c;
private color() {
}
}
public static final class dimen {
public static final int compat_button_inset_horizontal_material = 0x7f07013f;
public static final int compat_button_inset_vertical_material = 0x7f070140;
public static final int compat_button_padding_horizontal_material = 0x7f070141;
public static final int compat_button_padding_vertical_material = 0x7f070142;
public static final int compat_control_corner_material = 0x7f070143;
public static final int leak_canary_connector_center_y = 0x7f071275;
public static final int leak_canary_connector_leak_dash_gap = 0x7f071276;
public static final int leak_canary_connector_leak_dash_line = 0x7f071277;
public static final int leak_canary_connector_stroke_size = 0x7f071278;
public static final int leak_canary_connector_width = 0x7f071279;
public static final int leak_canary_more_margin_top = 0x7f07127a;
public static final int leak_canary_more_size = 0x7f07127b;
public static final int leak_canary_more_stroke_width = 0x7f07127c;
public static final int leak_canary_row_margins = 0x7f07127d;
public static final int leak_canary_row_min = 0x7f07127e;
public static final int leak_canary_row_title_margin_top = 0x7f07127f;
public static final int leak_canary_squiggly_span_amplitude = 0x7f071280;
public static final int leak_canary_squiggly_span_period_degrees = 0x7f071281;
public static final int leak_canary_squiggly_span_stroke_width = 0x7f071282;
public static final int notification_action_icon_size = 0x7f071aaa;
public static final int notification_action_text_size = 0x7f071aab;
public static final int notification_big_circle_margin = 0x7f071aac;
public static final int notification_content_margin_start = 0x7f071aad;
public static final int notification_large_icon_height = 0x7f071aae;
public static final int notification_large_icon_width = 0x7f071aaf;
public static final int notification_main_column_padding_top = 0x7f071ab0;
public static final int notification_media_narrow_margin = 0x7f071ab1;
public static final int notification_right_icon_size = 0x7f071ab2;
public static final int notification_right_side_padding_top = 0x7f071ab3;
public static final int notification_small_icon_background_padding = 0x7f071ab4;
public static final int notification_small_icon_size_as_large = 0x7f071ab5;
public static final int notification_subtext_size = 0x7f071ab6;
public static final int notification_top_pad = 0x7f071ab7;
public static final int notification_top_pad_large_text = 0x7f071ab8;
private dimen() {
}
}
public static final class drawable {
public static final int leak_canary_icon_foreground = 0x7f0802fb;
public static final int leak_canary_notification = 0x7f0802fc;
public static final int leak_canary_toast_background = 0x7f0802fd;
public static final int notification_action_background = 0x7f080330;
public static final int notification_bg = 0x7f080331;
public static final int notification_bg_low = 0x7f080332;
public static final int notification_bg_low_normal = 0x7f080333;
public static final int notification_bg_low_pressed = 0x7f080334;
public static final int notification_bg_normal = 0x7f080335;
public static final int notification_bg_normal_pressed = 0x7f080336;
public static final int notification_icon_background = 0x7f080337;
public static final int notification_template_icon_bg = 0x7f080338;
public static final int notification_template_icon_low_bg = 0x7f080339;
public static final int notification_tile_bg = 0x7f08033a;
public static final int notify_panel_notification_icon_bg = 0x7f08033b;
private drawable() {
}
}
public static final class id {
public static final int action_container = 0x7f090017;
public static final int action_divider = 0x7f090019;
public static final int action_image = 0x7f09001a;
public static final int action_text = 0x7f090020;
public static final int actions = 0x7f090021;
public static final int async = 0x7f090046;
public static final int blocking = 0x7f090057;
public static final int chronometer = 0x7f0900c4;
public static final int forever = 0x7f090184;
public static final int icon = 0x7f0901bd;
public static final int icon_group = 0x7f0901be;
public static final int info = 0x7f0902cb;
public static final int italic = 0x7f0902d4;
public static final int leak_canary_action = 0x7f090325;
public static final int leak_canary_display_leak_failure = 0x7f090326;
public static final int leak_canary_display_leak_list = 0x7f090327;
public static final int leak_canary_row_connector = 0x7f090328;
public static final int leak_canary_row_details = 0x7f090329;
public static final int leak_canary_row_layout = 0x7f09032a;
public static final int leak_canary_row_more = 0x7f09032b;
public static final int leak_canary_row_text = 0x7f09032c;
public static final int leak_canary_row_time = 0x7f09032d;
public static final int leak_canary_row_title = 0x7f09032e;
public static final int line1 = 0x7f09033f;
public static final int line3 = 0x7f090340;
public static final int normal = 0x7f0903aa;
public static final int notification_background = 0x7f0903ab;
public static final int notification_main_column = 0x7f0903ac;
public static final int notification_main_column_container = 0x7f0903ad;
public static final int right_icon = 0x7f09041c;
public static final int right_side = 0x7f09041d;
public static final int text = 0x7f090501;
public static final int text2 = 0x7f090502;
public static final int time = 0x7f09050f;
public static final int title = 0x7f090513;
private id() {
}
}
public static final class integer {
public static final int status_bar_notification_info_maxnum = 0x7f0a0011;
private integer() {
}
}
public static final class layout {
public static final int leak_canary_display_leak = 0x7f0c0199;
public static final int leak_canary_heap_dump_toast = 0x7f0c019a;
public static final int leak_canary_leak_row = 0x7f0c019b;
public static final int leak_canary_ref_row = 0x7f0c019c;
public static final int leak_canary_ref_top_row = 0x7f0c019d;
public static final int notification_action = 0x7f0c01a8;
public static final int notification_action_tombstone = 0x7f0c01a9;
public static final int notification_template_custom_big = 0x7f0c01b0;
public static final int notification_template_icon_group = 0x7f0c01b1;
public static final int notification_template_part_chronometer = 0x7f0c01b5;
public static final int notification_template_part_time = 0x7f0c01b6;
private layout() {
}
}
public static final class mipmap {
public static final int leak_canary_icon = 0x7f0e008a;
private mipmap() {
}
}
public static final class string {
public static final int leak_canary_analysis_failed = 0x7f110281;
public static final int leak_canary_class_has_leaked = 0x7f110282;
public static final int leak_canary_class_has_leaked_retaining = 0x7f110283;
public static final int leak_canary_class_no_leak = 0x7f110284;
public static final int leak_canary_could_not_save_text = 0x7f110285;
public static final int leak_canary_delete = 0x7f110286;
public static final int leak_canary_delete_all = 0x7f110287;
public static final int leak_canary_delete_all_leaks_title = 0x7f110288;
public static final int leak_canary_display_activity_label = 0x7f110289;
public static final int leak_canary_download_dump = 0x7f11028a;
public static final int leak_canary_excluded_row = 0x7f11028b;
public static final int leak_canary_failure_report = 0x7f11028c;
public static final int leak_canary_help_detail = 0x7f11028d;
public static final int leak_canary_help_title = 0x7f11028e;
public static final int leak_canary_leak_excluded = 0x7f11028f;
public static final int leak_canary_leak_excluded_retaining = 0x7f110290;
public static final int leak_canary_leak_list_title = 0x7f110291;
public static final int leak_canary_no_leak_details = 0x7f110292;
public static final int leak_canary_notification_analysing = 0x7f110293;
public static final int leak_canary_notification_channel = 0x7f110294;
public static final int leak_canary_notification_dumping = 0x7f110295;
public static final int leak_canary_notification_foreground_text = 0x7f110296;
public static final int leak_canary_notification_message = 0x7f110297;
public static final int leak_canary_notification_reporting = 0x7f110298;
public static final int leak_canary_permission_not_granted = 0x7f110299;
public static final int leak_canary_permission_notification_text = 0x7f11029a;
public static final int leak_canary_permission_notification_title = 0x7f11029b;
public static final int leak_canary_result_failure_no_disk_space = 0x7f11029c;
public static final int leak_canary_result_failure_no_file = 0x7f11029d;
public static final int leak_canary_result_failure_title = 0x7f11029e;
public static final int leak_canary_share_heap_dump = 0x7f11029f;
public static final int leak_canary_share_leak = 0x7f1102a0;
public static final int leak_canary_share_with = 0x7f1102a1;
public static final int leak_canary_storage_permission_activity_label = 0x7f1102a2;
public static final int leak_canary_toast_heap_dump = 0x7f1102a3;
public static final int status_bar_notification_info_overflow = 0x7f110427;
private string() {
}
}
public static final class style {
public static final int TextAppearance_Compat_Notification = 0x7f12013b;
public static final int TextAppearance_Compat_Notification_Info = 0x7f12013c;
public static final int TextAppearance_Compat_Notification_Line2 = 0x7f12013e;
public static final int TextAppearance_Compat_Notification_Time = 0x7f120141;
public static final int TextAppearance_Compat_Notification_Title = 0x7f120143;
public static final int Widget_Compat_NotificationActionContainer = 0x7f1201ee;
public static final int Widget_Compat_NotificationActionText = 0x7f1201ef;
public static final int leak_canary_LeakCanary_Base = 0x7f120267;
public static final int leak_canary_Theme_Transparent = 0x7f120268;
private style() {
}
}
public static final class styleable {
public static final int FontFamilyFont_android_font = 0x00000000;
public static final int FontFamilyFont_android_fontStyle = 0x00000002;
public static final int FontFamilyFont_android_fontVariationSettings = 0x00000004;
public static final int FontFamilyFont_android_fontWeight = 0x00000001;
public static final int FontFamilyFont_android_ttcIndex = 0x00000003;
public static final int FontFamilyFont_font = 0x00000005;
public static final int FontFamilyFont_fontStyle = 0x00000006;
public static final int FontFamilyFont_fontVariationSettings = 0x00000007;
public static final int FontFamilyFont_fontWeight = 0x00000008;
public static final int FontFamilyFont_ttcIndex = 0x00000009;
public static final int FontFamily_fontProviderAuthority = 0x00000000;
public static final int FontFamily_fontProviderCerts = 0x00000001;
public static final int FontFamily_fontProviderFetchStrategy = 0x00000002;
public static final int FontFamily_fontProviderFetchTimeout = 0x00000003;
public static final int FontFamily_fontProviderPackage = 0x00000004;
public static final int FontFamily_fontProviderQuery = 0x00000005;
public static final int leak_canary_MoreDetailsView_leak_canary_plus_color = 0;
public static final int[] FontFamily = {com.ubt.jimu.R.attr.fontProviderAuthority, com.ubt.jimu.R.attr.fontProviderCerts, com.ubt.jimu.R.attr.fontProviderFetchStrategy, com.ubt.jimu.R.attr.fontProviderFetchTimeout, com.ubt.jimu.R.attr.fontProviderPackage, com.ubt.jimu.R.attr.fontProviderQuery};
public static final int[] FontFamilyFont = {android.R.attr.font, android.R.attr.fontWeight, android.R.attr.fontStyle, android.R.attr.ttcIndex, android.R.attr.fontVariationSettings, com.ubt.jimu.R.attr.font, com.ubt.jimu.R.attr.fontStyle, com.ubt.jimu.R.attr.fontVariationSettings, com.ubt.jimu.R.attr.fontWeight, com.ubt.jimu.R.attr.ttcIndex};
public static final int[] leak_canary_MoreDetailsView = {com.ubt.jimu.R.attr.leak_canary_plus_color};
private styleable() {
}
}
public static final class xml {
public static final int leak_canary_file_paths = 0x7f150001;
private xml() {
}
}
private R() {
}
}

View File

@@ -0,0 +1,12 @@
package com.squareup.leakcanary;
/* loaded from: classes.dex */
public enum Reachability {
REACHABLE,
UNREACHABLE,
UNKNOWN;
public interface Inspector {
Reachability expectedReachability(LeakTraceElement leakTraceElement);
}
}

View File

@@ -0,0 +1,114 @@
package com.squareup.leakcanary;
import com.squareup.leakcanary.HeapDump;
import com.squareup.leakcanary.Retryable;
import java.io.File;
import java.lang.ref.ReferenceQueue;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.TimeUnit;
/* loaded from: classes.dex */
public final class RefWatcher {
public static final RefWatcher DISABLED = new RefWatcherBuilder().build();
private final DebuggerControl debuggerControl;
private final GcTrigger gcTrigger;
private final HeapDump.Builder heapDumpBuilder;
private final HeapDumper heapDumper;
private final HeapDump.Listener heapdumpListener;
private final WatchExecutor watchExecutor;
private final Set<String> retainedKeys = new CopyOnWriteArraySet();
private final ReferenceQueue<Object> queue = new ReferenceQueue<>();
RefWatcher(WatchExecutor watchExecutor, DebuggerControl debuggerControl, GcTrigger gcTrigger, HeapDumper heapDumper, HeapDump.Listener listener, HeapDump.Builder builder) {
this.watchExecutor = (WatchExecutor) Preconditions.checkNotNull(watchExecutor, "watchExecutor");
this.debuggerControl = (DebuggerControl) Preconditions.checkNotNull(debuggerControl, "debuggerControl");
this.gcTrigger = (GcTrigger) Preconditions.checkNotNull(gcTrigger, "gcTrigger");
this.heapDumper = (HeapDumper) Preconditions.checkNotNull(heapDumper, "heapDumper");
this.heapdumpListener = (HeapDump.Listener) Preconditions.checkNotNull(listener, "heapdumpListener");
this.heapDumpBuilder = builder;
}
private void ensureGoneAsync(final long j, final KeyedWeakReference keyedWeakReference) {
this.watchExecutor.execute(new Retryable() { // from class: com.squareup.leakcanary.RefWatcher.1
@Override // com.squareup.leakcanary.Retryable
public Retryable.Result run() {
return RefWatcher.this.ensureGone(keyedWeakReference, j);
}
});
}
private boolean gone(KeyedWeakReference keyedWeakReference) {
return !this.retainedKeys.contains(keyedWeakReference.key);
}
private void removeWeaklyReachableReferences() {
while (true) {
KeyedWeakReference keyedWeakReference = (KeyedWeakReference) this.queue.poll();
if (keyedWeakReference == null) {
return;
} else {
this.retainedKeys.remove(keyedWeakReference.key);
}
}
}
public void clearWatchedReferences() {
this.retainedKeys.clear();
}
Retryable.Result ensureGone(KeyedWeakReference keyedWeakReference, long j) {
long nanoTime = System.nanoTime();
long millis = TimeUnit.NANOSECONDS.toMillis(nanoTime - j);
removeWeaklyReachableReferences();
if (this.debuggerControl.isDebuggerAttached()) {
return Retryable.Result.RETRY;
}
if (gone(keyedWeakReference)) {
return Retryable.Result.DONE;
}
this.gcTrigger.runGc();
removeWeaklyReachableReferences();
if (!gone(keyedWeakReference)) {
long nanoTime2 = System.nanoTime();
long millis2 = TimeUnit.NANOSECONDS.toMillis(nanoTime2 - nanoTime);
File dumpHeap = this.heapDumper.dumpHeap();
if (dumpHeap == HeapDumper.RETRY_LATER) {
return Retryable.Result.RETRY;
}
this.heapdumpListener.analyze(this.heapDumpBuilder.heapDumpFile(dumpHeap).referenceKey(keyedWeakReference.key).referenceName(keyedWeakReference.name).watchDurationMs(millis).gcDurationMs(millis2).heapDumpDurationMs(TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - nanoTime2)).build());
}
return Retryable.Result.DONE;
}
HeapDump.Builder getHeapDumpBuilder() {
return this.heapDumpBuilder;
}
Set<String> getRetainedKeys() {
return new HashSet(this.retainedKeys);
}
boolean isEmpty() {
removeWeaklyReachableReferences();
return this.retainedKeys.isEmpty();
}
public void watch(Object obj) {
watch(obj, "");
}
public void watch(Object obj, String str) {
if (this == DISABLED) {
return;
}
Preconditions.checkNotNull(obj, "watchedReference");
Preconditions.checkNotNull(str, "referenceName");
long nanoTime = System.nanoTime();
String uuid = UUID.randomUUID().toString();
this.retainedKeys.add(uuid);
ensureGoneAsync(nanoTime, new KeyedWeakReference(obj, uuid, str, this.queue));
}
}

View File

@@ -0,0 +1,133 @@
package com.squareup.leakcanary;
import com.squareup.leakcanary.HeapDump;
import com.squareup.leakcanary.Reachability;
import com.squareup.leakcanary.RefWatcherBuilder;
import java.util.Collections;
import java.util.List;
/* loaded from: classes.dex */
public class RefWatcherBuilder<T extends RefWatcherBuilder<T>> {
private DebuggerControl debuggerControl;
private GcTrigger gcTrigger;
private final HeapDump.Builder heapDumpBuilder = new HeapDump.Builder();
private HeapDump.Listener heapDumpListener;
private HeapDumper heapDumper;
private WatchExecutor watchExecutor;
public final RefWatcher build() {
if (isDisabled()) {
return RefWatcher.DISABLED;
}
HeapDump.Builder builder = this.heapDumpBuilder;
if (builder.excludedRefs == null) {
builder.excludedRefs(defaultExcludedRefs());
}
HeapDump.Listener listener = this.heapDumpListener;
if (listener == null) {
listener = defaultHeapDumpListener();
}
HeapDump.Listener listener2 = listener;
DebuggerControl debuggerControl = this.debuggerControl;
if (debuggerControl == null) {
debuggerControl = defaultDebuggerControl();
}
DebuggerControl debuggerControl2 = debuggerControl;
HeapDumper heapDumper = this.heapDumper;
if (heapDumper == null) {
heapDumper = defaultHeapDumper();
}
HeapDumper heapDumper2 = heapDumper;
WatchExecutor watchExecutor = this.watchExecutor;
if (watchExecutor == null) {
watchExecutor = defaultWatchExecutor();
}
WatchExecutor watchExecutor2 = watchExecutor;
GcTrigger gcTrigger = this.gcTrigger;
if (gcTrigger == null) {
gcTrigger = defaultGcTrigger();
}
GcTrigger gcTrigger2 = gcTrigger;
HeapDump.Builder builder2 = this.heapDumpBuilder;
if (builder2.reachabilityInspectorClasses == null) {
builder2.reachabilityInspectorClasses(defaultReachabilityInspectorClasses());
}
return new RefWatcher(watchExecutor2, debuggerControl2, gcTrigger2, heapDumper2, listener2, this.heapDumpBuilder);
}
public final T computeRetainedHeapSize(boolean z) {
this.heapDumpBuilder.computeRetainedHeapSize(z);
return self();
}
public final T debuggerControl(DebuggerControl debuggerControl) {
this.debuggerControl = debuggerControl;
return self();
}
protected DebuggerControl defaultDebuggerControl() {
return DebuggerControl.NONE;
}
protected ExcludedRefs defaultExcludedRefs() {
return ExcludedRefs.builder().build();
}
protected GcTrigger defaultGcTrigger() {
return GcTrigger.DEFAULT;
}
protected HeapDump.Listener defaultHeapDumpListener() {
return HeapDump.Listener.NONE;
}
protected HeapDumper defaultHeapDumper() {
return HeapDumper.NONE;
}
protected List<Class<? extends Reachability.Inspector>> defaultReachabilityInspectorClasses() {
return Collections.emptyList();
}
protected WatchExecutor defaultWatchExecutor() {
return WatchExecutor.NONE;
}
public final T excludedRefs(ExcludedRefs excludedRefs) {
this.heapDumpBuilder.excludedRefs(excludedRefs);
return self();
}
public final T gcTrigger(GcTrigger gcTrigger) {
this.gcTrigger = gcTrigger;
return self();
}
public final T heapDumpListener(HeapDump.Listener listener) {
this.heapDumpListener = listener;
return self();
}
public final T heapDumper(HeapDumper heapDumper) {
this.heapDumper = heapDumper;
return self();
}
protected boolean isDisabled() {
return false;
}
protected final T self() {
return this;
}
public final T stethoscopeClasses(List<Class<? extends Reachability.Inspector>> list) {
this.heapDumpBuilder.reachabilityInspectorClasses(list);
return self();
}
public final T watchExecutor(WatchExecutor watchExecutor) {
this.watchExecutor = watchExecutor;
return self();
}
}

View File

@@ -0,0 +1,12 @@
package com.squareup.leakcanary;
/* loaded from: classes.dex */
public interface Retryable {
public enum Result {
DONE,
RETRY
}
Result run();
}

View File

@@ -0,0 +1,22 @@
package com.squareup.leakcanary;
import android.content.Context;
import com.squareup.leakcanary.HeapDump;
import com.squareup.leakcanary.internal.HeapAnalyzerService;
/* loaded from: classes.dex */
public final class ServiceHeapDumpListener implements HeapDump.Listener {
private final Context context;
private final Class<? extends AbstractAnalysisResultService> listenerServiceClass;
public ServiceHeapDumpListener(Context context, Class<? extends AbstractAnalysisResultService> cls) {
this.listenerServiceClass = (Class) Preconditions.checkNotNull(cls, "listenerServiceClass");
this.context = ((Context) Preconditions.checkNotNull(context, "context")).getApplicationContext();
}
@Override // com.squareup.leakcanary.HeapDump.Listener
public void analyze(HeapDump heapDump) {
Preconditions.checkNotNull(heapDump, "heapDump");
HeapAnalyzerService.runAnalysis(this.context, heapDump, this.listenerServiceClass);
}
}

View File

@@ -0,0 +1,382 @@
package com.squareup.leakcanary;
import com.squareup.haha.perflib.ArrayInstance;
import com.squareup.haha.perflib.ClassInstance;
import com.squareup.haha.perflib.ClassObj;
import com.squareup.haha.perflib.Field;
import com.squareup.haha.perflib.HahaSpy;
import com.squareup.haha.perflib.Instance;
import com.squareup.haha.perflib.RootObj;
import com.squareup.haha.perflib.RootType;
import com.squareup.haha.perflib.Snapshot;
import com.squareup.haha.perflib.Type;
import com.squareup.leakcanary.LeakTraceElement;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
/* loaded from: classes.dex */
final class ShortestPathFinder {
private boolean canIgnoreStrings;
private final ExcludedRefs excludedRefs;
private final Deque<LeakNode> toVisitQueue = new ArrayDeque();
private final Deque<LeakNode> toVisitIfNoPathQueue = new ArrayDeque();
private final LinkedHashSet<Instance> toVisitSet = new LinkedHashSet<>();
private final LinkedHashSet<Instance> toVisitIfNoPathSet = new LinkedHashSet<>();
private final LinkedHashSet<Instance> visitedSet = new LinkedHashSet<>();
/* renamed from: com.squareup.leakcanary.ShortestPathFinder$1, reason: invalid class name */
static /* synthetic */ class AnonymousClass1 {
static final /* synthetic */ int[] $SwitchMap$com$squareup$haha$perflib$RootType = new int[RootType.values().length];
static {
try {
$SwitchMap$com$squareup$haha$perflib$RootType[RootType.JAVA_LOCAL.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$com$squareup$haha$perflib$RootType[RootType.INTERNED_STRING.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$com$squareup$haha$perflib$RootType[RootType.DEBUGGER.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
$SwitchMap$com$squareup$haha$perflib$RootType[RootType.INVALID_TYPE.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
$SwitchMap$com$squareup$haha$perflib$RootType[RootType.UNREACHABLE.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
try {
$SwitchMap$com$squareup$haha$perflib$RootType[RootType.UNKNOWN.ordinal()] = 6;
} catch (NoSuchFieldError unused6) {
}
try {
$SwitchMap$com$squareup$haha$perflib$RootType[RootType.FINALIZING.ordinal()] = 7;
} catch (NoSuchFieldError unused7) {
}
try {
$SwitchMap$com$squareup$haha$perflib$RootType[RootType.SYSTEM_CLASS.ordinal()] = 8;
} catch (NoSuchFieldError unused8) {
}
try {
$SwitchMap$com$squareup$haha$perflib$RootType[RootType.VM_INTERNAL.ordinal()] = 9;
} catch (NoSuchFieldError unused9) {
}
try {
$SwitchMap$com$squareup$haha$perflib$RootType[RootType.NATIVE_LOCAL.ordinal()] = 10;
} catch (NoSuchFieldError unused10) {
}
try {
$SwitchMap$com$squareup$haha$perflib$RootType[RootType.NATIVE_STATIC.ordinal()] = 11;
} catch (NoSuchFieldError unused11) {
}
try {
$SwitchMap$com$squareup$haha$perflib$RootType[RootType.THREAD_BLOCK.ordinal()] = 12;
} catch (NoSuchFieldError unused12) {
}
try {
$SwitchMap$com$squareup$haha$perflib$RootType[RootType.BUSY_MONITOR.ordinal()] = 13;
} catch (NoSuchFieldError unused13) {
}
try {
$SwitchMap$com$squareup$haha$perflib$RootType[RootType.NATIVE_MONITOR.ordinal()] = 14;
} catch (NoSuchFieldError unused14) {
}
try {
$SwitchMap$com$squareup$haha$perflib$RootType[RootType.REFERENCE_CLEANUP.ordinal()] = 15;
} catch (NoSuchFieldError unused15) {
}
try {
$SwitchMap$com$squareup$haha$perflib$RootType[RootType.NATIVE_STACK.ordinal()] = 16;
} catch (NoSuchFieldError unused16) {
}
try {
$SwitchMap$com$squareup$haha$perflib$RootType[RootType.JAVA_STATIC.ordinal()] = 17;
} catch (NoSuchFieldError unused17) {
}
}
}
static final class Result {
final boolean excludingKnownLeaks;
final LeakNode leakingNode;
Result(LeakNode leakNode, boolean z) {
this.leakingNode = leakNode;
this.excludingKnownLeaks = z;
}
}
ShortestPathFinder(ExcludedRefs excludedRefs) {
this.excludedRefs = excludedRefs;
}
private boolean checkSeen(LeakNode leakNode) {
return !this.visitedSet.add(leakNode.instance);
}
private void clearState() {
this.toVisitQueue.clear();
this.toVisitIfNoPathQueue.clear();
this.toVisitSet.clear();
this.toVisitIfNoPathSet.clear();
this.visitedSet.clear();
}
private void enqueue(Exclusion exclusion, LeakNode leakNode, Instance instance, LeakReference leakReference) {
if (instance == null || HahaHelper.isPrimitiveOrWrapperArray(instance) || HahaHelper.isPrimitiveWrapper(instance) || this.toVisitSet.contains(instance)) {
return;
}
boolean z = exclusion == null;
if (z || !this.toVisitIfNoPathSet.contains(instance)) {
if ((this.canIgnoreStrings && isString(instance)) || this.visitedSet.contains(instance)) {
return;
}
LeakNode leakNode2 = new LeakNode(exclusion, instance, leakNode, leakReference);
if (z) {
this.toVisitSet.add(instance);
this.toVisitQueue.add(leakNode2);
} else {
this.toVisitIfNoPathSet.add(instance);
this.toVisitIfNoPathQueue.add(leakNode2);
}
}
}
private void enqueueGcRoots(Snapshot snapshot) {
for (RootObj rootObj : HahaSpy.allGcRoots(snapshot)) {
switch (AnonymousClass1.$SwitchMap$com$squareup$haha$perflib$RootType[rootObj.getRootType().ordinal()]) {
case 1:
Exclusion exclusion = this.excludedRefs.threadNames.get(HahaHelper.threadName(HahaSpy.allocatingThread(rootObj)));
if (exclusion == null || !exclusion.alwaysExclude) {
enqueue(exclusion, null, rootObj, null);
break;
} else {
break;
}
break;
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
break;
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
enqueue(null, null, rootObj, null);
break;
default:
throw new UnsupportedOperationException("Unknown root type:" + rootObj.getRootType());
}
}
}
private boolean isString(Instance instance) {
return instance.getClassObj() != null && instance.getClassObj().getClassName().equals(String.class.getName());
}
private void visitArrayInstance(LeakNode leakNode) {
ArrayInstance arrayInstance = (ArrayInstance) leakNode.instance;
if (arrayInstance.getArrayType() == Type.OBJECT) {
Object[] values = arrayInstance.getValues();
for (int i = 0; i < values.length; i++) {
Instance instance = (Instance) values[i];
enqueue(null, leakNode, instance, new LeakReference(LeakTraceElement.Type.ARRAY_ENTRY, Integer.toString(i), instance == null ? "null" : instance.toString()));
}
}
}
private void visitClassInstance(LeakNode leakNode) {
ClassInstance classInstance = (ClassInstance) leakNode.instance;
LinkedHashMap linkedHashMap = new LinkedHashMap();
Exclusion exclusion = null;
for (ClassObj classObj = classInstance.getClassObj(); classObj != null; classObj = classObj.getSuperClassObj()) {
Exclusion exclusion2 = this.excludedRefs.classNames.get(classObj.getClassName());
if (exclusion2 != null && (exclusion == null || !exclusion.alwaysExclude)) {
exclusion = exclusion2;
}
Map<String, Exclusion> map = this.excludedRefs.fieldNameByClassName.get(classObj.getClassName());
if (map != null) {
linkedHashMap.putAll(map);
}
}
if (exclusion == null || !exclusion.alwaysExclude) {
for (ClassInstance.FieldValue fieldValue : classInstance.getValues()) {
Field field = fieldValue.getField();
if (field.getType() == Type.OBJECT) {
Instance instance = (Instance) fieldValue.getValue();
String name = field.getName();
Exclusion exclusion3 = (Exclusion) linkedHashMap.get(name);
if (exclusion3 == null || (exclusion != null && (!exclusion3.alwaysExclude || exclusion.alwaysExclude))) {
exclusion3 = exclusion;
}
enqueue(exclusion3, leakNode, instance, new LeakReference(LeakTraceElement.Type.INSTANCE_FIELD, name, fieldValue.getValue() == null ? "null" : fieldValue.getValue().toString()));
}
}
}
}
private void visitClassObj(LeakNode leakNode) {
Exclusion exclusion;
ClassObj classObj = (ClassObj) leakNode.instance;
Map<String, Exclusion> map = this.excludedRefs.staticFieldNameByClassName.get(classObj.getClassName());
for (Map.Entry<Field, Object> entry : classObj.getStaticFieldValues().entrySet()) {
Field key = entry.getKey();
if (key.getType() == Type.OBJECT) {
String name = key.getName();
if (!name.equals("$staticOverhead")) {
Instance instance = (Instance) entry.getValue();
boolean z = true;
LeakReference leakReference = new LeakReference(LeakTraceElement.Type.STATIC_FIELD, name, entry.getValue() == null ? "null" : entry.getValue().toString());
if (map != null && (exclusion = map.get(name)) != null) {
z = false;
if (!exclusion.alwaysExclude) {
enqueue(exclusion, leakNode, instance, leakReference);
}
}
if (z) {
enqueue(null, leakNode, instance, leakReference);
}
}
}
}
}
private void visitRootObj(LeakNode leakNode) {
RootObj rootObj = (RootObj) leakNode.instance;
Instance referredInstance = rootObj.getReferredInstance();
if (rootObj.getRootType() != RootType.JAVA_LOCAL) {
enqueue(null, leakNode, referredInstance, null);
return;
}
Instance allocatingThread = HahaSpy.allocatingThread(rootObj);
Exclusion exclusion = leakNode.exclusion;
if (exclusion == null) {
exclusion = null;
}
enqueue(exclusion, new LeakNode(null, allocatingThread, null, null), referredInstance, new LeakReference(LeakTraceElement.Type.LOCAL, null, null));
}
/* JADX WARN: Code restructure failed: missing block: B:9:0x004e, code lost:
return new com.squareup.leakcanary.ShortestPathFinder.Result(r7, r2);
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
com.squareup.leakcanary.ShortestPathFinder.Result findPath(com.squareup.haha.perflib.Snapshot r7, com.squareup.haha.perflib.Instance r8) {
/*
r6 = this;
r6.clearState()
boolean r0 = r6.isString(r8)
r1 = 1
r0 = r0 ^ r1
r6.canIgnoreStrings = r0
r6.enqueueGcRoots(r7)
r7 = 0
r0 = 0
L10:
java.util.Deque<com.squareup.leakcanary.LeakNode> r2 = r6.toVisitQueue
boolean r2 = r2.isEmpty()
if (r2 == 0) goto L24
java.util.Deque<com.squareup.leakcanary.LeakNode> r2 = r6.toVisitIfNoPathQueue
boolean r2 = r2.isEmpty()
if (r2 != 0) goto L21
goto L24
L21:
r2 = r7
r7 = r0
goto L49
L24:
java.util.Deque<com.squareup.leakcanary.LeakNode> r2 = r6.toVisitQueue
boolean r2 = r2.isEmpty()
if (r2 != 0) goto L38
java.util.Deque<com.squareup.leakcanary.LeakNode> r2 = r6.toVisitQueue
java.lang.Object r2 = r2.poll()
com.squareup.leakcanary.LeakNode r2 = (com.squareup.leakcanary.LeakNode) r2
r5 = r2
r2 = r7
r7 = r5
goto L45
L38:
java.util.Deque<com.squareup.leakcanary.LeakNode> r7 = r6.toVisitIfNoPathQueue
java.lang.Object r7 = r7.poll()
com.squareup.leakcanary.LeakNode r7 = (com.squareup.leakcanary.LeakNode) r7
com.squareup.leakcanary.Exclusion r2 = r7.exclusion
if (r2 == 0) goto L92
r2 = 1
L45:
com.squareup.haha.perflib.Instance r3 = r7.instance
if (r3 != r8) goto L4f
L49:
com.squareup.leakcanary.ShortestPathFinder$Result r8 = new com.squareup.leakcanary.ShortestPathFinder$Result
r8.<init>(r7, r2)
return r8
L4f:
boolean r3 = r6.checkSeen(r7)
if (r3 == 0) goto L56
goto L77
L56:
com.squareup.haha.perflib.Instance r3 = r7.instance
boolean r4 = r3 instanceof com.squareup.haha.perflib.RootObj
if (r4 == 0) goto L60
r6.visitRootObj(r7)
goto L77
L60:
boolean r4 = r3 instanceof com.squareup.haha.perflib.ClassObj
if (r4 == 0) goto L68
r6.visitClassObj(r7)
goto L77
L68:
boolean r4 = r3 instanceof com.squareup.haha.perflib.ClassInstance
if (r4 == 0) goto L70
r6.visitClassInstance(r7)
goto L77
L70:
boolean r3 = r3 instanceof com.squareup.haha.perflib.ArrayInstance
if (r3 == 0) goto L79
r6.visitArrayInstance(r7)
L77:
r7 = r2
goto L10
L79:
java.lang.IllegalStateException r8 = new java.lang.IllegalStateException
java.lang.StringBuilder r0 = new java.lang.StringBuilder
r0.<init>()
java.lang.String r1 = "Unexpected type for "
r0.append(r1)
com.squareup.haha.perflib.Instance r7 = r7.instance
r0.append(r7)
java.lang.String r7 = r0.toString()
r8.<init>(r7)
throw r8
L92:
java.lang.IllegalStateException r8 = new java.lang.IllegalStateException
java.lang.StringBuilder r0 = new java.lang.StringBuilder
r0.<init>()
java.lang.String r1 = "Expected node to have an exclusion "
r0.append(r1)
r0.append(r7)
java.lang.String r7 = r0.toString()
r8.<init>(r7)
throw r8
*/
throw new UnsupportedOperationException("Method not decompiled: com.squareup.leakcanary.ShortestPathFinder.findPath(com.squareup.haha.perflib.Snapshot, com.squareup.haha.perflib.Instance):com.squareup.leakcanary.ShortestPathFinder$Result");
}
}

View File

@@ -0,0 +1,20 @@
package com.squareup.leakcanary;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/* loaded from: classes.dex */
public class TrackedReference {
public final String className;
public final List<LeakReference> fields;
public final String key;
public final String name;
public TrackedReference(String str, String str2, String str3, List<LeakReference> list) {
this.key = str;
this.name = str2;
this.className = str3;
this.fields = Collections.unmodifiableList(new ArrayList(list));
}
}

View File

@@ -0,0 +1,12 @@
package com.squareup.leakcanary;
/* loaded from: classes.dex */
public interface WatchExecutor {
public static final WatchExecutor NONE = new WatchExecutor() { // from class: com.squareup.leakcanary.WatchExecutor.1
@Override // com.squareup.leakcanary.WatchExecutor
public void execute(Retryable retryable) {
}
};
void execute(Retryable retryable);
}

View File

@@ -0,0 +1,7 @@
package com.squareup.leakcanary.analyzer;
/* loaded from: classes.dex */
public final class R {
private R() {
}
}

View File

@@ -0,0 +1,36 @@
package com.squareup.leakcanary.internal;
import android.app.Activity;
import android.app.Application;
import android.os.Bundle;
/* loaded from: classes.dex */
public abstract class ActivityLifecycleCallbacksAdapter implements Application.ActivityLifecycleCallbacks {
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityCreated(Activity activity, Bundle bundle) {
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityDestroyed(Activity activity) {
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityPaused(Activity activity) {
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityResumed(Activity activity) {
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityStarted(Activity activity) {
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityStopped(Activity activity) {
}
}

Some files were not shown because too many files have changed in this diff Show More