commit | be63632a01b639a7a169da21f5996796c588fa5d | [log] [tgz] |
---|---|---|
author | mrenouf <mrenouf@google.com> | Sun Mar 03 14:52:03 2024 -0500 |
committer | mrenouf <mrenouf@google.com> | Sun Mar 03 19:36:32 2024 -0500 |
tree | d7175c46085da55187dca15e977851f9fbc52285 | |
parent | 39553a1b848ee573acb306e3297688df096f404f [diff] |
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
IntentResolver
provides the implementation for Intent ACTION_CHOOSER
See also: ShareCompat.IntentBuilder