Consider the size of the reference profile when assessing IsFirstSave

This makes the detection logic for the first profile save much more
precise. It prevents the case where we would return true if
the data was already moved from the current profile to the reference
profile.

At the same time, rework part of the logic for early save. The checks
needed to be moved earlier to encompass the startup class resolution.

Test: run-test & manual
adb shell stop;
adb shell setprop dalvik.vm.ps-min-save-period-ms 300;
adb shell setprop dalvik.vm.extra-opts -verbose:profiler;
adb shell start;
adb shell cmd package compile com.android.systemui -r bg-dexopt
restart & check

Bug: 185979271
Change-Id: Icfec30c6f49c8e03b03ff4bcbc2b869393fdcbfe
8 files changed