get ACRA reports without crashing to debug #698

This should be reverted once #698 is fixed.  If execution has gotten this
far into InstallManagerService, there should always be App and Apk
instances.  That is enforced when Intents are received by this Service.
This commit is contained in:
Hans-Christoph Steiner 2016-08-26 11:30:18 +02:00
parent b45f7ba27c
commit 45b083546f

View File

@ -16,6 +16,7 @@ import android.support.v4.app.TaskStackBuilder;
import android.support.v4.content.LocalBroadcastManager; import android.support.v4.content.LocalBroadcastManager;
import android.text.TextUtils; import android.text.TextUtils;
import org.acra.ACRA;
import org.fdroid.fdroid.AppDetails; import org.fdroid.fdroid.AppDetails;
import org.fdroid.fdroid.R; import org.fdroid.fdroid.R;
import org.fdroid.fdroid.Utils; import org.fdroid.fdroid.Utils;
@ -140,6 +141,7 @@ public class InstallManagerService extends Service {
if ((flags & START_FLAG_REDELIVERY) == START_FLAG_REDELIVERY if ((flags & START_FLAG_REDELIVERY) == START_FLAG_REDELIVERY
&& !DownloaderService.isQueuedOrActive(urlString)) { && !DownloaderService.isQueuedOrActive(urlString)) {
// TODO is there a case where we should allow an active urlString to pass through?
Utils.debugLog(TAG, urlString + " finished downloading while InstallManagerService was killed."); Utils.debugLog(TAG, urlString + " finished downloading while InstallManagerService was killed.");
cancelNotification(urlString); cancelNotification(urlString);
return START_NOT_STICKY; return START_NOT_STICKY;
@ -247,6 +249,8 @@ public class InstallManagerService extends Service {
// show notification if app details is not visible // show notification if app details is not visible
if (!TextUtils.isEmpty(errorMessage)) { if (!TextUtils.isEmpty(errorMessage)) {
try {
// temp setup to debug https://gitlab.com/fdroid/fdroidclient/issues/698
App app = getAppFromActive(downloadUrl); App app = getAppFromActive(downloadUrl);
// show notification if app details is not visible // show notification if app details is not visible
@ -258,6 +262,10 @@ public class InstallManagerService extends Service {
app.name); app.name);
notifyError(downloadUrl, title, errorMessage); notifyError(downloadUrl, title, errorMessage);
} }
} catch (NullPointerException e) { //NOPMD
ACRA.getErrorReporter().handleException(
new IllegalStateException(errorMessage, e));
}
} }
removeFromActive(downloadUrl); removeFromActive(downloadUrl);
localBroadcastManager.unregisterReceiver(this); localBroadcastManager.unregisterReceiver(this);