fix crash when UpdateService receives null Intent

I have no idea what would send UpdateService a null Intent, but there have
been reports from ACRA:

ANDROID_VERSION=5.1.1
APP_VERSION_NAME=0.99.2
BRAND=samsung
PHONE_MODEL=SM-G901F
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Intent.getStringExtra(java.lang.String)' on a null object reference
	at org.fdroid.fdroid.UpdateService.onHandleIntent(UpdateService.java:342)
	at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loop(Looper.java:135)
	at android.os.HandlerThread.run(HandlerThread.java:61)
This commit is contained in:
Hans-Christoph Steiner 2016-05-30 11:15:35 +02:00
parent 01de14f84e
commit 198ad843c1

View File

@ -314,8 +314,12 @@ public class UpdateService extends IntentService {
Process.setThreadPriority(Process.THREAD_PRIORITY_LOWEST); Process.setThreadPriority(Process.THREAD_PRIORITY_LOWEST);
final long startTime = System.currentTimeMillis(); final long startTime = System.currentTimeMillis();
String address = intent.getStringExtra(EXTRA_ADDRESS); boolean manualUpdate = false;
boolean manualUpdate = intent.getBooleanExtra(EXTRA_MANUAL_UPDATE, false); String address = null;
if (intent != null) {
address = intent.getStringExtra(EXTRA_ADDRESS);
manualUpdate = intent.getBooleanExtra(EXTRA_MANUAL_UPDATE, false);
}
try { try {
// See if it's time to actually do anything yet... // See if it's time to actually do anything yet...