Reduce the frequency of calls to isDexOptNeededInternal.

The package manager maintains a set of dexopted instruction
sets as a fast path to avoid calling expensive code. We were
correctly adding elements to that list while performing dexopt,
but were *not* adding elements to the list when isDexOptNeededInternal
told us things were up to date. As a result, we'd hit the slow path
100% of the time on userdebug builds in the steady state, i.e, when
the system did not dexopt anything since boot.

With this change, we make sure isDexOptNeededInternal is called
precisely once per boot in such case.

This patch also fixes broken logic for apps that have multiple
code paths. We must mark the paths as dexopted only if we've
processed all paths.

bug: 16828525
bug: 16868741
Change-Id: Icb59121fe915d892e677d9b7e9a4efd11555ae27
1 file changed