For general information, you might want to refer to the odex tag-wikitag-wiki and the tag-wikitag-wiki for the dalvik tag. But your question even covers some parts not contained there -- and only now I realized that indeed all .apk
files seem to include .dex
files (I always thought only the "odexed apps" do that), and you seem to be right about what the "O" stands for -- at least it makes much sense. So forgive me, I'm not a developer :)
But still I might be able to answer at least a part of your question.
Yes, your description seems to match how it works (until the question mark, at least). But, to my knowledge, no app should download and install .dex
files separately. If not running with root permissions, that would even be difficult (as the app could not write to /data/dalvik-cache
, lacking the file-permissions). So we can skip the second part as, according to Aristotle's logic, from a wrong assumption one could derive everything :)
Second: Yes, the system keeps the .apk
files. If your device has a Custom Recovery installed, you could manually wipe the Dalvik cache from there -- which would force the Android system to re-generate it on its next boot. Basically, this is even done for the system-apps (.apk
files are located in /system/apps
for those, and thus survive a factory-reset), namely when you do a factory-reset.
Third: Oh, already answered. Yes, by wiping the Dalvik-Cache.