Fix null pointer exception when surveys are turned off

Under certain conditions the provider could be null on
download completion which could lead to a
NPE if surveys are disabled. The method to remove
the receiver has been made static so an instance
is no longer required.

Test: robotests
Bug: 33707203
Change-Id: Icfb545697f24172db734dd7dad421796edf68186
This commit is contained in:
Salvador Martinez
2016-12-16 17:34:11 -08:00
parent d9d463be8b
commit d7fe1fb958
3 changed files with 25 additions and 9 deletions

View File

@@ -74,9 +74,8 @@ public class SurveyMixin implements LifecycleObserver, OnResume, OnPause {
public void onPause() {
Activity activity = mFragment.getActivity();
if (mReceiver != null && activity != null) {
SurveyFeatureProvider provider =
FeatureFactory.getFactory(activity).getSurveyFeatureProvider(activity);
provider.unregisterReceiver(activity, mReceiver);
SurveyFeatureProvider.unregisterReceiver(activity, mReceiver);
mReceiver = null;
}
}
}