PackageManager: Fix reference profile canonicalization.

Foreign dex markers are named in the runtime by calling realpath(3) on the input
dexfile path and replacing "/" with "@". On the Java side, we're using
File.getCanonicalPath, which is similar but isn't quite the same. It tries
to call realpath() directly, but if that fails, it resorts to a series of
increasingly desperate measures to calculate a "canonical path". We just
use realpath instead.

Also, don't attempt to delete a profile if canonicalization fails.

bug: 28740848
Change-Id: Ie5d5af590187e793db633342a42b923865e5c005
3 files changed