Implement "pm compile".

This keeps compatibility while having the following differences:
1. It allows both "-m" and "-r" to be omitted. (Uses the default reason
   "cmdline" and the default compiler filter "speed-profile".)
2. It allows both "-m" and "-r" to be specified. (Uses the specified
   reason with an override compiler filter.)
3. It supports a new flag "-p". (Sets the priority class.)
4. It supports a new flag "--primary-dex". (Compiles primary dex files
   only.)
5. It supports a new flag "--include-dependencies", to be used together
   with "--primary-dex" or "--secondary-dex".
6. It supports a new flag "--full".
7. "--split" prefers a real split name. (A filename of a split is still
   supported but discouraged.)
8. "--reset" ignores all other flags except "-a".
9. It is cancellable.

Bug: 263247832
Test: adb shell pm compile com.google.android.gms (warning)
Test: adb shell pm compile --full com.google.android.gms
Test: adb shell pm compile --full -r first-boot com.google.android.gms
Test: adb shell pm compile --full -r first-boot -m speed com.google.android.gms
Test: adb shell pm compile --full -r first-boot -p PRIORITY_BACKGROUND com.google.android.gms
Test: adb shell pm compile --full -r inactive com.google.android.gms (warning)
Test: adb shell pm compile --secondary-dex --split \"\" com.google.android.gms (error)
Test: adb shell pm compile --split \"\" -f com.google.android.gms
Test: adb shell pm compile --split PrebuiltGmsCoreNext.apk -f com.google.android.gms (warning)
Test: adb shell pm compile --reset com.google.android.gms
Test: adb shell pm compile -c com.google.android.gms (warning)
Test: adb shell pm compile --full --check-prof false com.google.android.gms (warning)
Test: adb shell pm compile --full -a
Test: adb shell pm compile -a --secondary-dex -f
Test: adb shell pm compile -a --reset
Test: adb shell pm compile -a --split \"\" (error)
Test: adb shell pm art clear-app-profiles com.google.android.gms
Ignore-AOSP-First: ART Services.
Change-Id: I1b01922d2a2fa9e14eb8119866c6192c84fa3ac3
5 files changed