Add color to PhoneAccount objects (3/3)

Change-Id: I05096e9007521d711e4e77c172853119b7a156ed
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index b337622..6980df8 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -35,6 +35,7 @@
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.PhoneFactory;
 import com.android.internal.telephony.PhoneProxy;
+import com.android.internal.telephony.SubscriptionController;
 import com.android.internal.telephony.TelephonyIntents;
 import com.android.phone.R;
 
@@ -92,6 +93,7 @@
 
             // Populate the phone account data.
             long subId = mPhone.getSubId();
+            int color = 0;
             int slotId = SubscriptionManager.INVALID_SLOT_ID;
             String line1Number = mTelephonyManager.getLine1NumberForSubscriber(subId);
             if (line1Number == null) {
@@ -121,6 +123,8 @@
                 if (record != null) {
                     subDisplayName = record.displayName;
                     slotId = record.slotId;
+                    // Assign a "fake" color while the underlying Telephony stuff is refactored
+                    color = makeFakeColor(subId);
                 }
 
                 String slotIdString;
@@ -155,6 +159,7 @@
                             Uri.fromParts(PhoneAccount.SCHEME_TEL, subNumber, null))
                     .setCapabilities(capabilities)
                     .setIconResId(getPhoneAccountIcon(slotId))
+                    .setColor(color)
                     .setShortDescription(description)
                     .setSupportedUriSchemes(Arrays.asList(
                             PhoneAccount.SCHEME_TEL, PhoneAccount.SCHEME_VOICEMAIL))
@@ -170,6 +175,15 @@
         }
     }
 
+    private int makeFakeColor(long subId) {
+        int[] colors = new int[] {
+                0xff0000,
+                0x00ff00,
+                0x0000ff,
+        };
+        return colors[((int) subId) % colors.length];
+    }
+
     private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
         @Override
         public void onReceive(Context context, Intent intent) {