New watchables for PackageManagerService

Bug: 161323622

Add WatchedArrayList, WatchedArraySet, and WatchedSparseIntArray to
the server utilities.  Test code is added to the frameworks test.

The watched "collections" offer some consistent APIs.  Every
collection includes a copy constructor for itself and for the
unwatched type.  Every collection offers a copyIn() from, and
copyOut() to, the unwatched type, to support runtime conversion.

Add the Watched annotation interface.  This annotation marks
attributes that are watched for change detection; generally, any
change invalidates a snapshot.  It is also generally true that Watched
attributes must be included in the snapshot.

A bug in Snapshots.java is also fixed.

Test: atest
 * FrameworksServicesTests:WatcherTest

Change-Id: I9b6ad0b3f6a901e77c342c5a3e45c86bed510db6
12 files changed