Android sourcecode for PackageManagerService has following lines:
mIsUpgrade = !Build.FINGERPRINT.equals(ver.fingerprint);
... some other code
if (mIsUpgrade && !onlyCore) {
Slog.i(TAG, "Build fingerprint changed; clearing code caches");
... cache clearing logic
ver.fingerprint = Build.FINGERPRINT;
}
That is, code caches will be cleared if build fingerprint is changed. Uncleared cache means package info for your app will seem the same (version info, flags etc.).
This problem might occur because your OTA package has same fingerprint as the system it is installed on.
Check your makefile and make sure you are generating a unique fingerprint for each build.
Fingerprint value can be found in "system/buildprops" file. So you can check if that is the problem.