Create ActivityModel directly instead of injecting

There is an initialization order issue with the existing approach:

Within the Hilt framework, the ViewModelComponent is initialized
prior to injecting the Activity. The ViewModel cannot then depend
on any injected values since they will not be available when
required.

Due to another bug, this was not causing a problem because the
value of the injected field was never being checked when the
ViewModel was requested in onCreate. The value was inserted on
the second request for the ViewModel, after onCreate, and this
would mutate the state of the default args Bundle in the already
created instance's SavedStateHandle. (Fixed in ag/26434053)

The @ActivityScoped Module providing the ActivityModel is
replaced with a simple method which creates an instaance
from the Activity. The ActivityModel is then available from
the ViewModel. This method exists to allows for changing the
launchedFromUid, launchedFromPackage, and referrer values
without dependence on the system.

Bug: 300157408
Test: atest IntentResolver-tests-activity:com.android.intentresolver.v2
Change-Id: I297cbd602c13462f0c0614a279655f2852658dc4
7 files changed
tree: d7175c46085da55187dca15e977851f9fbc52285
  1. aconfig/
  2. java/
  3. tests/
  4. Android.bp
  5. AndroidManifest-app.xml
  6. AndroidManifest-lib.xml
  7. OWNERS
  8. PREUPLOAD.cfg
  9. proguard.flags
  10. README.md
  11. TEST_MAPPING
README.md

IntentResolver

About

IntentResolver provides the implementation for Intent ACTION_CHOOSER

See also: ShareCompat.IntentBuilder