avoid leaking data to MessagingController via MessageLoaderHelper after detach

null handling is already present: no ui methods should ever be called
after onDestroy or onDetachChangingConfigurations, and pending result
callbacks are handled by a null-check for the callback field.
This commit is contained in:
Vincent Breitmoser 2016-07-19 17:07:44 +02:00 committed by cketti
parent 0993d91473
commit af5856d28f

View file

@ -69,11 +69,11 @@ public class MessageLoaderHelper {
private static final int DECODE_MESSAGE_LOADER_ID = 2;
// injected state
private final Context context;
private final FragmentManager fragmentManager;
private final LoaderManager loaderManager;
@Nullable // may be cleared
// injected state - all of this may be cleared to avoid data leakage!
private Context context;
private FragmentManager fragmentManager;
private LoaderManager loaderManager;
@Nullable // make this explicitly nullable, make sure to cancel/ignore any operation if this is null
private MessageLoaderCallbacks callback;
@ -126,6 +126,9 @@ public class MessageLoaderHelper {
}
callback = null;
context = null;
fragmentManager = null;
loaderManager = null;
}
/** Prevents future callbacks, but retains loading state to pick up from in a call to
@ -137,6 +140,9 @@ public class MessageLoaderHelper {
}
callback = null;
context = null;
fragmentManager = null;
loaderManager = null;
}
@UiThread