summaryrefslogtreecommitdiffstats
path: root/src/com/android/services/telephony/TelecomAccountRegistry.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/services/telephony/TelecomAccountRegistry.java')
-rw-r--r--src/com/android/services/telephony/TelecomAccountRegistry.java52
1 files changed, 13 insertions, 39 deletions
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index 7bd396b15..352328862 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -18,6 +18,7 @@ package com.android.services.telephony;
import android.content.ComponentName;
import android.content.Context;
+import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.telecom.PhoneAccount;
@@ -47,26 +48,6 @@ import java.util.List;
final class TelecomAccountRegistry {
private static final boolean DBG = false; /* STOP SHIP if true */
- // Slot IDs are zero based indices but the numbered icons represent the first, second,
- // etc... SIM in the device. So that means that index 0 is SIM 1, index 1 is SIM 2 and so on.
-
- private final static int[] phoneAccountIcons = {
- R.drawable.ic_multi_sim1,
- R.drawable.ic_multi_sim2,
- R.drawable.ic_multi_sim3,
- R.drawable.ic_multi_sim4
- };
-
- private final static int[] colors = {
- 0xff00796b,
- 0xff3367d6,
- 0xff303f9f,
- 0xff7b1fa2,
- 0xffc2185b,
- 0xffc53929
- };
-
-
// This icon is the one that is used when the Slot ID that we have for a particular SIM
// is not supported, i.e. SubscriptionManager.INVALID_SLOT_ID or the 5th SIM in a phone.
private final static int defaultPhoneAccountIcon = R.drawable.ic_multi_sim;
@@ -113,6 +94,7 @@ final class TelecomAccountRegistry {
String label;
String description;
+ Bitmap iconBitmap = null;
if (isEmergency) {
label = mContext.getResources().getString(R.string.sim_label_emergency_calls);
@@ -129,10 +111,9 @@ final class TelecomAccountRegistry {
SubscriptionInfo record = SubscriptionManager.getSubscriptionInfoForSubscriber(subId);
if (record != null) {
subDisplayName = record.getDisplayName();
- slotId = record.getSubscriptionId();
-
- // Assign a "fake" color while the underlying Telephony stuff is refactored.
- color = makeFakeColor(subId);
+ slotId = record.getSimSlotIndex();
+ color = record.getIconTint();
+ iconBitmap = record.createIconBitmap(mContext);
}
String slotIdString;
@@ -161,12 +142,19 @@ final class TelecomAccountRegistry {
PhoneAccount.CAPABILITY_CALL_PROVIDER |
PhoneAccount.CAPABILITY_PLACE_EMERGENCY_CALLS;
+ if (iconBitmap == null) {
+ iconBitmap = BitmapFactory.decodeResource(
+ mContext.getResources(),
+ defaultPhoneAccountIcon);
+ }
+
PhoneAccount account = PhoneAccount.builder(phoneAccountHandle, label)
.setAddress(Uri.fromParts(PhoneAccount.SCHEME_TEL, line1Number, null))
.setSubscriptionAddress(
Uri.fromParts(PhoneAccount.SCHEME_TEL, subNumber, null))
.setCapabilities(capabilities)
- .setIcon(mContext, getPhoneAccountIcon(slotId), color)
+ .setIcon(iconBitmap)
+ .setHighlightColor(color)
.setShortDescription(description)
.setSupportedUriSchemes(Arrays.asList(
PhoneAccount.SCHEME_TEL, PhoneAccount.SCHEME_VOICEMAIL))
@@ -182,10 +170,6 @@ final class TelecomAccountRegistry {
}
}
- private int makeFakeColor(long subId) {
- return colors[((int) subId) % colors.length];
- }
-
private final SubscriptionListener mSubscriptionListener = new SubscriptionListener() {
@Override
public void onSubscriptionInfoChanged() {
@@ -322,16 +306,6 @@ final class TelecomAccountRegistry {
cleanupPhoneAccounts();
}
- private int getPhoneAccountIcon(int index) {
- // A valid slot id doesn't necessarily mean that we have an icon for it.
- if (SubscriptionManager.isValidSlotId(index) &&
- index < TelecomAccountRegistry.phoneAccountIcons.length) {
- return TelecomAccountRegistry.phoneAccountIcons[index];
- }
- // Invalid indices get the default icon that has no number associated with it.
- return defaultPhoneAccountIcon;
- }
-
private void tearDownAccounts() {
for (AccountEntry entry : mAccounts) {
entry.teardown();