Utility to detect lock inversions in system.

This change adds a new LockGuard utility class that can be used to
detect lock inversions across the system server.  For example, if a
thread is trying to acquire the ActivityManager lock while holding the
PackageManager lock, it will yell.

This class requires no prior knowledge of locks or their ordering; it
derives all of this data at runtime. However, this means the overhead
is substantial and it should not be enabled by default.

Adds overrides to ArrayMap and ArraySet to use identityHashCode()
instead of the hashCode() provided by the object.

Bug: 27336728
Change-Id: I26c31bc99fe8d61ff13c3455aaeddd5517e44433
4 files changed