Commit 96d623e0 authored by shaktisahu's avatar shaktisahu Committed by Commit bot

Fixed download notification crash caused by uninitialized browser process

If browser process is killed, tapping on download notification leads to
a crash. Currently this is happening due to an early call to
getLastUsedProfile() used by FeatureEngagementTracker. This can be
prevented by adding an extra check for browser statup complete.

Also reordered the openDownloadedContent function to open the
downloaded item instead of download home in that scenario. That alone
should also prevent the crash.

BUG=715442

Review-Url: https://codereview.chromium.org/2876973002
Cr-Commit-Position: refs/heads/master@{#471195}
parent 212c2894
...@@ -1159,14 +1159,18 @@ public class DownloadManagerService extends BroadcastReceiver implements ...@@ -1159,14 +1159,18 @@ public class DownloadManagerService extends BroadcastReceiver implements
@Override @Override
protected void onPostExecute(Intent intent) { protected void onPostExecute(Intent intent) {
if (intent == null || !ExternalNavigationDelegateImpl.resolveIntent(intent, true) boolean didLaunchIntent = intent != null
|| !DownloadUtils.fireOpenIntentForDownload(context, intent) && ExternalNavigationDelegateImpl.resolveIntent(intent, true)
|| !hasDownloadManagerService()) { && DownloadUtils.fireOpenIntentForDownload(context, intent);
if (!didLaunchIntent) {
openDownloadsPage(context); openDownloadsPage(context);
} else { return;
DownloadManagerService service = }
DownloadManagerService.getDownloadManagerService();
service.updateLastAccessTime(downloadGuid, isOffTheRecord); if (didLaunchIntent && hasDownloadManagerService()) {
DownloadManagerService.getDownloadManagerService().updateLastAccessTime(
downloadGuid, isOffTheRecord);
} }
} }
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
......
...@@ -27,6 +27,7 @@ import org.chromium.base.ContextUtils; ...@@ -27,6 +27,7 @@ import org.chromium.base.ContextUtils;
import org.chromium.base.FileUtils; import org.chromium.base.FileUtils;
import org.chromium.base.Log; import org.chromium.base.Log;
import org.chromium.base.VisibleForTesting; import org.chromium.base.VisibleForTesting;
import org.chromium.base.library_loader.LibraryProcessType;
import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.metrics.RecordUserAction;
import org.chromium.chrome.R; import org.chromium.chrome.R;
...@@ -54,6 +55,7 @@ import org.chromium.components.feature_engagement_tracker.EventConstants; ...@@ -54,6 +55,7 @@ import org.chromium.components.feature_engagement_tracker.EventConstants;
import org.chromium.components.feature_engagement_tracker.FeatureEngagementTracker; import org.chromium.components.feature_engagement_tracker.FeatureEngagementTracker;
import org.chromium.components.offline_items_collection.OfflineItem.Progress; import org.chromium.components.offline_items_collection.OfflineItem.Progress;
import org.chromium.components.offline_items_collection.OfflineItemProgressUnit; import org.chromium.components.offline_items_collection.OfflineItemProgressUnit;
import org.chromium.content.browser.BrowserStartupController;
import org.chromium.content_public.browser.DownloadState; import org.chromium.content_public.browser.DownloadState;
import org.chromium.content_public.browser.LoadUrlParams; import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.ui.base.DeviceFormFactor; import org.chromium.ui.base.DeviceFormFactor;
...@@ -170,10 +172,13 @@ public class DownloadUtils { ...@@ -170,10 +172,13 @@ public class DownloadUtils {
} }
} }
Profile profile = (tab == null ? Profile.getLastUsedProfile() : tab.getProfile()); if (BrowserStartupController.get(LibraryProcessType.PROCESS_BROWSER)
FeatureEngagementTracker tracker = .isStartupSuccessfullyCompleted()) {
FeatureEngagementTrackerFactory.getFeatureEngagementTrackerForProfile(profile); Profile profile = (tab == null ? Profile.getLastUsedProfile() : tab.getProfile());
tracker.notifyEvent(EventConstants.DOWNLOAD_HOME_OPENED); FeatureEngagementTracker tracker =
FeatureEngagementTrackerFactory.getFeatureEngagementTrackerForProfile(profile);
tracker.notifyEvent(EventConstants.DOWNLOAD_HOME_OPENED);
}
return true; return true;
} }
......
Markdown is supported
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