Commit b15df396 authored by Romain Bertozzi's avatar Romain Bertozzi
Browse files

localservice: fix several npes

This patch fixes some NPEs occuring in the onReceive method of
LocalService.java.
A user reported that it crashed when the system was closing the app.
It is a clue that tells that we were accessing elements from onReceive
being triggered, after these elements were deallocated.

Change-Id: I1ef4cdb56904ba0ebd7bd7839b83ea9243d78cbc
Tuleap: #859
parent 5b3c462c
......@@ -1185,7 +1185,7 @@ public class LocalService extends Service implements SharedPreferences.OnSharedP
boolean connected = intent.getBooleanExtra("connected", false);
if (connected) {
dringStarted = true;
if (mService != null) {
if (mService != null && mAccountLoader != null) {
mAccountLoader.startLoading();
mAccountLoader.onContentChanged();
}
......@@ -1244,7 +1244,7 @@ public class LocalService extends Service implements SharedPreferences.OnSharedP
break;
case ConfigurationManagerCallback.ACCOUNT_STATE_CHANGED:
Log.w(TAG, "Received " + intent.getAction() + " " + intent.getStringExtra("account") + " " + intent.getStringExtra("state") + " " + intent.getIntExtra("code", 0));
if (mAccountLoader.isStarted()) {
if (mAccountLoader != null && mAccountLoader.isStarted()) {
mAccountLoader.cancelLoad();
mAccountLoader.stopLoading();
mAccountLoader.startLoading();
......@@ -1260,8 +1260,10 @@ public class LocalService extends Service implements SharedPreferences.OnSharedP
}
break;
case ConfigurationManagerCallback.ACCOUNTS_CHANGED:
mAccountLoader.startLoading();
mAccountLoader.onContentChanged();
if (mAccountLoader != null) {
mAccountLoader.startLoading();
mAccountLoader.onContentChanged();
}
break;
case CallManagerCallBack.INCOMING_TEXT:
case ConfigurationManagerCallback.INCOMING_TEXT: {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment