Always show the SIM on the footer of a multi-SIM device, even if one SIM is disabled.

This commit is contained in:
Alan Evans 2019-05-07 12:25:11 -03:00 committed by GitHub
parent 8cf2654c5b
commit d1b8e77fdc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 10 deletions

View File

@ -106,7 +106,7 @@ public class ConversationItemFooter extends LinearLayout {
private void presentSimInfo(@NonNull MessageRecord messageRecord) { private void presentSimInfo(@NonNull MessageRecord messageRecord) {
SubscriptionManagerCompat subscriptionManager = new SubscriptionManagerCompat(getContext()); 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); simView.setVisibility(View.GONE);
} else { } else {
Optional<SubscriptionInfoCompat> subscriptionInfo = subscriptionManager.getActiveSubscriptionInfo(messageRecord.getSubscriptionId()); Optional<SubscriptionInfoCompat> subscriptionInfo = subscriptionManager.getActiveSubscriptionInfo(messageRecord.getSubscriptionId());

View File

@ -59,16 +59,9 @@ public final class SubscriptionManagerCompat {
@RequiresApi(api = 22) @RequiresApi(api = 22)
private @NonNull Map<Integer, SubscriptionInfoCompat> getActiveSubscriptionInfoMap(boolean excludeUnreadySubscriptions) { private @NonNull Map<Integer, SubscriptionInfoCompat> getActiveSubscriptionInfoMap(boolean excludeUnreadySubscriptions) {
SubscriptionManager subscriptionManager = ServiceUtil.getSubscriptionManager(context); List<SubscriptionInfo> subscriptionInfos = getActiveSubscriptionInfoList();
if (subscriptionManager == null) { if (subscriptionInfos.isEmpty()) {
Log.w(TAG, "Missing SubscriptionManager.");
return Collections.emptyMap();
}
List<SubscriptionInfo> subscriptionInfos = subscriptionManager.getActiveSubscriptionInfoList();
if (subscriptionInfos == null || subscriptionInfos.isEmpty()) {
return Collections.emptyMap(); return Collections.emptyMap();
} }
@ -88,6 +81,28 @@ public final class SubscriptionManagerCompat {
return map; return map;
} }
public boolean isMultiSim() {
if (Build.VERSION.SDK_INT < 22) {
return false;
}
return getActiveSubscriptionInfoList().size() >= 2;
}
@RequiresApi(api = 22)
private @NonNull List<SubscriptionInfo> getActiveSubscriptionInfoList() {
SubscriptionManager subscriptionManager = ServiceUtil.getSubscriptionManager(context);
if (subscriptionManager == null) {
Log.w(TAG, "Missing SubscriptionManager.");
return Collections.emptyList();
}
List<SubscriptionInfo> list = subscriptionManager.getActiveSubscriptionInfoList();
return list != null? list : Collections.emptyList();
}
@RequiresApi(api = 22) @RequiresApi(api = 22)
private Map<SubscriptionInfo, CharSequence> getDescriptionsFor(@NonNull Collection<SubscriptionInfo> subscriptions) { private Map<SubscriptionInfo, CharSequence> getDescriptionsFor(@NonNull Collection<SubscriptionInfo> subscriptions) {
Map<SubscriptionInfo, CharSequence> descriptions; Map<SubscriptionInfo, CharSequence> descriptions;