Initialize content resolver in ctor

* In ag/16337218 we moved the initialization of the
context into the ctor instead of init(), but not the
content resolver.
* When we add a callback for OverviewProxyService in
the ctor, it might call the onConnectionChanged()
before NavBarHelper#init() is called, which would lead
to use of a null content resolver in
updateAssistantAvailability()

Bug: 208261632
Change-Id: I306cdf27c7870ad72e80ef401367bb0d6dc32f68
This commit is contained in:
Vinit Nayak
2021-12-01 11:42:40 -08:00
parent d4377890cf
commit f936d8290c

View File

@@ -109,6 +109,7 @@ public final class NavBarHelper implements
UserTracker userTracker,
DumpManager dumpManager) {
mContext = context;
mContentResolver = mContext.getContentResolver();
mAccessibilityManager = accessibilityManager;
mAssistManagerLazy = assistManagerLazy;
mStatusBarOptionalLazy = statusBarOptionalLazy;
@@ -124,7 +125,6 @@ public final class NavBarHelper implements
}
public void init() {
mContentResolver = mContext.getContentResolver();
mContentResolver.registerContentObserver(
Settings.Secure.getUriFor(Settings.Secure.ASSISTANT),
false /* notifyForDescendants */, mAssistContentObserver, UserHandle.USER_ALL);