diff --git a/src/org/thoughtcrime/securesms/components/ConversationItemFooter.java b/src/org/thoughtcrime/securesms/components/ConversationItemFooter.java index 69bb4a3ebb..8beda22ff1 100644 --- a/src/org/thoughtcrime/securesms/components/ConversationItemFooter.java +++ b/src/org/thoughtcrime/securesms/components/ConversationItemFooter.java @@ -106,7 +106,7 @@ public class ConversationItemFooter extends LinearLayout { private void presentSimInfo(@NonNull MessageRecord messageRecord) { SubscriptionManagerCompat subscriptionManager = new SubscriptionManagerCompat(getContext()); - if (messageRecord.isPush() || messageRecord.getSubscriptionId() == -1 || !Permissions.hasAll(getContext(), Manifest.permission.READ_PHONE_STATE) || subscriptionManager.getActiveAndReadySubscriptionInfos().size() < 2) { + if (messageRecord.isPush() || messageRecord.getSubscriptionId() == -1 || !Permissions.hasAll(getContext(), Manifest.permission.READ_PHONE_STATE) || !subscriptionManager.isMultiSim()) { simView.setVisibility(View.GONE); } else { Optional subscriptionInfo = subscriptionManager.getActiveSubscriptionInfo(messageRecord.getSubscriptionId()); diff --git a/src/org/thoughtcrime/securesms/util/dualsim/SubscriptionManagerCompat.java b/src/org/thoughtcrime/securesms/util/dualsim/SubscriptionManagerCompat.java index 1d462a9a74..6bffc0b4c1 100644 --- a/src/org/thoughtcrime/securesms/util/dualsim/SubscriptionManagerCompat.java +++ b/src/org/thoughtcrime/securesms/util/dualsim/SubscriptionManagerCompat.java @@ -59,16 +59,9 @@ public final class SubscriptionManagerCompat { @RequiresApi(api = 22) private @NonNull Map getActiveSubscriptionInfoMap(boolean excludeUnreadySubscriptions) { - SubscriptionManager subscriptionManager = ServiceUtil.getSubscriptionManager(context); + List subscriptionInfos = getActiveSubscriptionInfoList(); - if (subscriptionManager == null) { - Log.w(TAG, "Missing SubscriptionManager."); - return Collections.emptyMap(); - } - - List subscriptionInfos = subscriptionManager.getActiveSubscriptionInfoList(); - - if (subscriptionInfos == null || subscriptionInfos.isEmpty()) { + if (subscriptionInfos.isEmpty()) { return Collections.emptyMap(); } @@ -88,6 +81,28 @@ public final class SubscriptionManagerCompat { return map; } + public boolean isMultiSim() { + if (Build.VERSION.SDK_INT < 22) { + return false; + } + + return getActiveSubscriptionInfoList().size() >= 2; + } + + @RequiresApi(api = 22) + private @NonNull List getActiveSubscriptionInfoList() { + SubscriptionManager subscriptionManager = ServiceUtil.getSubscriptionManager(context); + + if (subscriptionManager == null) { + Log.w(TAG, "Missing SubscriptionManager."); + return Collections.emptyList(); + } + + List list = subscriptionManager.getActiveSubscriptionInfoList(); + + return list != null? list : Collections.emptyList(); + } + @RequiresApi(api = 22) private Map getDescriptionsFor(@NonNull Collection subscriptions) { Map descriptions;