Optimization: remove duplicated flags computations for getInstalledPackages

Below are some test runs that show 100 iterations of getInstalledPackages ran
at activity startup of touchlatency app to demonstrate the perf cost.

R Baseline:
https://screenshot.googleplex.com/PnVi5APraJo
https://pprof.corp.google.com/?id=dc105ca9592f8367c381e2dcf7f1847d

R Optimized:
https://pprof.corp.google.com/?id=2d1d9fadc20bcc61d41bd52116bd94e3
https://screenshot.googleplex.com/OAwJnvwPqPH

Savings: 8% of system_server binder response time when the call is executed.

In terms total binder transaction time. Savings are 2% of the total
binder call time.

Exempt-From-Owner-Approval: CP to correct branch for R

Bug: 153656459

Test: atest FrameworksServicesTests:PackageParserTest
Test: atest FrameworksServicesTests:PackageParserLegacyCoreTest
Test: atest FrameworksServicesTests:ScanTests
Test: atest FrameworksServicesTests:ParallelPackageParserTest

Merged-In: I2de9cf1f754a505239d4416e1fc70bf77932c5db
Change-Id: I2de9cf1f754a505239d4416e1fc70bf77932c5db
(cherry picked from commit 7cb9e5f671dc02c15efcbceadb764026e0e70855)
6 files changed