Enable icon selection in call log

Originally the call log was not hooked up with the PhoneAccount API,
this change hooks that part up.

Bug: 15473965

Change-Id: I96bdde927473abcdf7493573be29bf4979cf2696
diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java
index 3ef78af..42e4659 100644
--- a/src/com/android/dialer/CallDetailActivity.java
+++ b/src/com/android/dialer/CallDetailActivity.java
@@ -17,6 +17,7 @@
 package com.android.dialer;
 
 import android.app.Activity;
+import android.content.ComponentName;
 import android.content.ContentResolver;
 import android.content.ContentUris;
 import android.content.ContentValues;
@@ -32,6 +33,8 @@
 import android.provider.CallLog.Calls;
 import android.provider.ContactsContract.CommonDataKinds.Phone;
 import android.provider.VoicemailContract.Voicemails;
+import android.telecomm.PhoneAccount;
+import android.telecomm.TelecommManager;
 import android.telephony.TelephonyManager;
 import android.text.TextUtils;
 import android.util.Log;
@@ -54,6 +57,7 @@
 import com.android.dialer.calllog.CallTypeHelper;
 import com.android.dialer.calllog.ContactInfo;
 import com.android.dialer.calllog.ContactInfoHelper;
+import com.android.dialer.calllog.PhoneAccountUtils;
 import com.android.dialer.calllog.PhoneNumberDisplayHelper;
 import com.android.dialer.calllog.PhoneNumberUtilsWrapper;
 import com.android.dialer.util.AsyncTaskExecutor;
@@ -491,7 +495,11 @@
             final int callType = callCursor.getInt(CALL_TYPE_COLUMN_INDEX);
             String countryIso = callCursor.getString(COUNTRY_ISO_COLUMN_INDEX);
             final String geocode = callCursor.getString(GEOCODED_LOCATION_COLUMN_INDEX);
-            final Drawable accountIcon = getAccountIcon(callCursor);
+
+            final Drawable accountIcon = PhoneAccountUtils.getAccountIcon(this,
+                    PhoneAccountUtils.getAccount(
+                    callCursor.getString(ACCOUNT_COMPONENT_NAME),
+                    callCursor.getString(ACCOUNT_ID)));
 
             if (TextUtils.isEmpty(countryIso)) {
                 countryIso = mDefaultCountryIso;
@@ -547,17 +555,6 @@
         }
     }
 
-    /**
-     * Generate account object from data in Telecomm database
-     */
-    private Drawable getAccountIcon(Cursor c) {
-        final String component_name = c.getString(ACCOUNT_COMPONENT_NAME);
-        final String account_id = c.getString(ACCOUNT_ID);
-
-        // TODO: actually pull data from the database
-        return null;
-    }
-
     /** Load the contact photos and places them in the corresponding views. */
     private void loadContactPhotos(Uri contactUri, Uri photoUri, String displayName,
             String lookupKey, int contactType) {