Fix updating shared prefs with enrollment information.

1. Replace apply() with commit() for shared preference updates.
Sometimes, the writes were not getting to persistent memory with
apply().  Since the availability of the enrollment related information
is critical to the functioning of the trusted device, change all apply()
to commit() and terminate enrollment on commit failure.
2. Handle various failures during enrollment and report it to the
registered clients as appropriate.

This fixes the problem where a Trusted device cannot be added after
removal.

Bug: 133351179
Test: Add, remove and add the same phone as a trusted device.
Change-Id: I78b0e9e279134c47e3d0e3572087caf9867648e4
3 files changed