Fix potential ANR in CallLogNotificationsService
Lazily initialize instance of VoicemailQueryHandler,
to avoid blocking the main thread in onCreate
Bug: 25627946
Change-Id: I35efb459897251f0157accac129c0abe5f5a8df7
diff --git a/src/com/android/dialer/calllog/CallLogNotificationsService.java b/src/com/android/dialer/calllog/CallLogNotificationsService.java
index 9a67b61..d2a494d 100644
--- a/src/com/android/dialer/calllog/CallLogNotificationsService.java
+++ b/src/com/android/dialer/calllog/CallLogNotificationsService.java
@@ -67,12 +67,6 @@
}
@Override
- public void onCreate() {
- super.onCreate();
- mVoicemailQueryHandler = new VoicemailQueryHandler(this, getContentResolver());
- }
-
- @Override
protected void onHandleIntent(Intent intent) {
if (intent == null) {
Log.d(TAG, "onHandleIntent: could not handle null intent");
@@ -84,6 +78,9 @@
}
if (ACTION_MARK_NEW_VOICEMAILS_AS_OLD.equals(intent.getAction())) {
+ if (mVoicemailQueryHandler == null) {
+ mVoicemailQueryHandler = new VoicemailQueryHandler(this, getContentResolver());
+ }
mVoicemailQueryHandler.markNewVoicemailsAsOld();
} else if (ACTION_UPDATE_NOTIFICATIONS.equals(intent.getAction())) {
Uri voicemailUri = (Uri) intent.getParcelableExtra(EXTRA_NEW_VOICEMAIL_URI);