Only visit app image classes in class loader

Only update dex cache arrays of added classes since the declaring
class is in image DCHECK fails for other classes in the class loader.

Also some cleanup to prevent app images leaving invalid state if
they get rejected.

Bug: 22858531
Bug: 27431418

(cherry picked from commit 6973100705716bffce3768a8a0908d7ca1d02ec1)

Change-Id: Ib05364c44f2b943e3341ef2b1dd43337833de143
4 files changed