Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1dd62283 authored by Marcus Hagerott's avatar Marcus Hagerott
Browse files

Add method to check if SimContacts are available

Also added some better docs for the SimCard class. See
I3c5e6542908260a24ab77cc59fc96beadc23132a for motivation of this
change.

Test
see I3c5e6542908260a24ab77cc59fc96beadc23132a

Bug 32143935

Change-Id: Ibf227f88289ed9826f6d03677af7c85772225da1
parent c0ab1383
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -118,6 +118,18 @@ public class SimCard {
        return mCountryCode;
    }

    /**
     * Returns whether the contacts for this SIM card have been initialized.
     */
    public boolean areContactsAvailable() {
        return mContacts != null;
    }

    /**
     * Returns whether this SIM card has any SIM contacts.
     *
     * A precondition of this method is that the contacts have been initialized.
     */
    public boolean hasContacts() {
        if (mContacts == null) {
            throw new IllegalStateException("Contacts not loaded.");
@@ -125,6 +137,11 @@ public class SimCard {
        return !mContacts.isEmpty();
    }

    /**
     * Returns the number of contacts stored on this SIM card.
     *
     * A precondition of this method is that the contacts have been initialized.
     */
    public int getContactCount() {
        if (mContacts == null) {
            throw new IllegalStateException("Contacts not loaded.");
@@ -148,6 +165,9 @@ public class SimCard {
        return !isDismissed() && !isImported() && hasContacts();
    }

    /**
     * Returns the contacts for this SIM card or null if the contacts have not been initialized.
     */
    public List<SimContact> getContacts() {
        return mContacts;
    }