From f87dbfbf35f996738cb3f5436b654f615b1c1b27 Mon Sep 17 00:00:00 2001 From: wangqi Date: Fri, 27 Oct 2017 16:47:14 -0700 Subject: Roll forward cl/172154863: Do not load every DialtactsActivity fragment on app open With this change we now only load the Favorites and Call Log Fragments when the app opens. Paging to the CallLogFragment makes the ContactsFragment load as we would want. This should result in a faster app start time. I'll need to verify the impact of this using the same method as http://cl/170422671 I verified the change in behavior by adding my own log line to the onCreate of each Fragment. I saw all of them get created before the change, and only the expected 2 with this change. This change also fixes flaky test of voicemailTabVisibleNotVisible_volumeStreamCorrect. Bug: 64541209,65460373,67297718 Test: DialtactsActivityIntegrationTest PiperOrigin-RevId: 173734472 Change-Id: Ifd4a3064a6fdcffe5a373eaad6ee4aeebdadda1e --- .../android/dialer/databasepopulator/VoicemailPopulator.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'java/com/android/dialer/databasepopulator') diff --git a/java/com/android/dialer/databasepopulator/VoicemailPopulator.java b/java/com/android/dialer/databasepopulator/VoicemailPopulator.java index e99f7c7d4..9e0f45345 100644 --- a/java/com/android/dialer/databasepopulator/VoicemailPopulator.java +++ b/java/com/android/dialer/databasepopulator/VoicemailPopulator.java @@ -19,9 +19,12 @@ package com.android.dialer.databasepopulator; import android.content.ComponentName; import android.content.ContentValues; import android.content.Context; +import android.os.Build.VERSION; +import android.os.Build.VERSION_CODES; import android.provider.VoicemailContract.Status; import android.provider.VoicemailContract.Voicemails; import android.support.annotation.NonNull; +import android.support.annotation.VisibleForTesting; import android.support.annotation.WorkerThread; import android.telecom.PhoneAccountHandle; import android.telephony.TelephonyManager; @@ -98,13 +101,16 @@ public final class VoicemailPopulator { .delete(Voicemails.buildSourceUri(context.getPackageName()), "", new String[] {}); } - private static void enableVoicemail(@NonNull Context context) { + @VisibleForTesting + public static void enableVoicemail(@NonNull Context context) { PhoneAccountHandle handle = new PhoneAccountHandle(new ComponentName(context, VoicemailPopulator.class), ACCOUNT_ID); ContentValues values = new ContentValues(); values.put(Status.SOURCE_PACKAGE, handle.getComponentName().getPackageName()); - values.put(Status.SOURCE_TYPE, TelephonyManager.VVM_TYPE_OMTP); + if (VERSION.SDK_INT >= VERSION_CODES.N_MR1) { + values.put(Status.SOURCE_TYPE, TelephonyManager.VVM_TYPE_OMTP); + } values.put(Status.PHONE_ACCOUNT_COMPONENT_NAME, handle.getComponentName().flattenToString()); values.put(Status.PHONE_ACCOUNT_ID, handle.getId()); values.put(Status.CONFIGURATION_STATE, Status.CONFIGURATION_STATE_OK); -- cgit v1.2.3