FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Android: "Error: null" shown when the device has no active SIM · Issue #257 · textbee/textbee · GitHub

Android: "Error: null" shown when the device has no active SIM #257

Description

TextBeeUtils.getAvailableSimSlots() returns the subscription list without a null check:

public static List<SubscriptionInfo> getAvailableSimSlots(Context context) {
    if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
        return new ArrayList<>();
    }
    SubscriptionManager subscriptionManager = SubscriptionManager.from(context);
    return subscriptionManager.getActiveSubscriptionInfoList();
}

getActiveSubscriptionInfoList() is documented to return null when there are no active subscriptions: no SIM inserted, wifi-only tablet, SIM disabled. Both call sites then break on the null:

  • activities/MainActivity.java calls .forEach(...) on the result. The NPE gets caught by the broad catch (Exception e) further down and surfaces to the user as a snackbar that literally reads Error: null, with no SIM options rendered.
  • ui/settings/SettingsViewModel.kt maps over it, the exception is swallowed by catch (e: Exception) { emptyList() }, and the SIM selector is silently empty with no explanation.

The two sibling methods in the same file (collectSimInfo and isValidSubscriptionId) already null-check this exact call, so this one looks like an oversight. Fix is to coalesce the null to an empty list.

android/app/src/main/java/com/vernu/sms/TextBeeUtils.java, line 38.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    androidAndroid appbugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL