kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fix potential crash when retrieving SIM list.
rodzic
ecea6abeb6
commit
bb90987e7c
|
@ -10,6 +10,7 @@ import android.os.Build;
|
|||
import android.os.PowerManager;
|
||||
import android.os.Vibrator;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.telephony.SubscriptionManager;
|
||||
|
@ -55,7 +56,7 @@ public class ServiceUtil {
|
|||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP_MR1)
|
||||
public static SubscriptionManager getSubscriptionManager(@NonNull Context context) {
|
||||
public static @Nullable SubscriptionManager getSubscriptionManager(@NonNull Context context) {
|
||||
return ContextCompat.getSystemService(context, SubscriptionManager.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.telephony.SubscriptionInfo;
|
|||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.util.ServiceUtil;
|
||||
import org.whispersystems.libsignal.util.guava.Function;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
|
@ -25,6 +26,8 @@ import java.util.Set;
|
|||
|
||||
public final class SubscriptionManagerCompat {
|
||||
|
||||
private static final String TAG = Log.tag(SubscriptionManagerCompat.class);
|
||||
|
||||
private final Context context;
|
||||
|
||||
public SubscriptionManagerCompat(Context context) {
|
||||
|
@ -57,7 +60,14 @@ public final class SubscriptionManagerCompat {
|
|||
|
||||
@RequiresApi(api = 22)
|
||||
private @NonNull Map<Integer, SubscriptionInfoCompat> getActiveSubscriptionInfoMap(boolean excludeUnreadySubscriptions) {
|
||||
List<SubscriptionInfo> subscriptionInfos = ServiceUtil.getSubscriptionManager(context).getActiveSubscriptionInfoList();
|
||||
SubscriptionManager subscriptionManager = ServiceUtil.getSubscriptionManager(context);
|
||||
|
||||
if (subscriptionManager == null) {
|
||||
Log.w(TAG, "Missing SubscriptionManager.");
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
List<SubscriptionInfo> subscriptionInfos = subscriptionManager.getActiveSubscriptionInfoList();
|
||||
|
||||
if (subscriptionInfos == null || subscriptionInfos.isEmpty()) {
|
||||
return Collections.emptyMap();
|
||||
|
|
Ładowanie…
Reference in New Issue