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

Commit c7238acc authored by Danny Baumann's avatar Danny Baumann Committed by Gerrit Code Review
Browse files

Proper supplementary service notification handling (2/5).

Allow registering SSN listeners, and add missing constants.

Change-Id: I339a395fda5cca7617e7619cfc93312a1282f60e
parent f44be149
Loading
Loading
Loading
Loading
+40 −0
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ public final class CallManager {
    // FIXME Taken from klp-sprout-dev but setAudioMode was removed in L.
    //private static final int EVENT_RADIO_OFF_OR_NOT_AVAILABLE = 121;
    private static final int EVENT_TTY_MODE_RECEIVED = 122;
    private static final int EVENT_SUPP_SERVICE_NOTIFY = 123;

    // Singleton instance
    private static final CallManager INSTANCE = new CallManager();
@@ -175,6 +176,9 @@ public final class CallManager {
    protected final RegistrantList mSubscriptionInfoReadyRegistrants
    = new RegistrantList();

    protected final RegistrantList mSuppServiceNotifyRegistrants
    = new RegistrantList();

    protected final RegistrantList mSuppServiceFailedRegistrants
    = new RegistrantList();

@@ -651,6 +655,11 @@ public final class CallManager {
        // FIXME Taken from klp-sprout-dev but setAudioMode was removed in L.
        //phone.registerForRadioOffOrNotAvailable(handler, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null);

        // for events supported only by GSM phone
        if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM) {
            phone.registerForSuppServiceNotification(handler, EVENT_SUPP_SERVICE_NOTIFY, null);
        }

        // for events supported only by GSM, CDMA and IMS phone
        if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM ||
                phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA ||
@@ -703,6 +712,11 @@ public final class CallManager {
        // FIXME Taken from klp-sprout-dev but setAudioMode was removed in L.
        //phone.unregisterForRadioOffOrNotAvailable(handler);

        // for events supported only by GSM phone
        if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM) {
            phone.unregisterForSuppServiceNotification(handler);
        }

        // for events supported only by GSM, CDMA and IMS phone
        if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM ||
                phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA ||
@@ -1600,6 +1614,28 @@ public final class CallManager {
        mServiceStateChangedRegistrants.remove(h);
    }

    /**
     * Register for supplementary service notifications.
     * Message.obj will contain an AsyncResult.
     *
     * @param h Handler that receives the notification message.
     * @param what User-defined message code.
     * @param obj User object.
     */
    public void registerForSuppServiceNotification(Handler h, int what, Object obj) {
        mSuppServiceNotifyRegistrants.addUnique(h, what, obj);
    }

    /**
     * Unregister for supplementary service notifications.
     * Extraneous calls are tolerated silently
     *
     * @param h Handler to be removed from the registrant list.
     */
    public void unregisterForSuppServiceNotification(Handler h) {
        mSuppServiceNotifyRegistrants.remove(h);
    }

    /**
     * Register for notifications when a supplementary service attempt fails.
     * Message.obj will contain an AsyncResult.
@@ -2390,6 +2426,10 @@ public final class CallManager {
                    if (VDBG) Rlog.d(LOG_TAG, " handleMessage (EVENT_SUBSCRIPTION_INFO_READY)");
                    mSubscriptionInfoReadyRegistrants.notifyRegistrants((AsyncResult) msg.obj);
                    break;
                case EVENT_SUPP_SERVICE_NOTIFY:
                    if (VDBG) Rlog.d(LOG_TAG, " handleMessage (EVENT_SUPP_SERVICE_NOTIFY)");
                    mSuppServiceNotifyRegistrants.notifyRegistrants((AsyncResult) msg.obj);
                    break;
                case EVENT_SUPP_SERVICE_FAILED:
                    if (VDBG) Rlog.d(LOG_TAG, " handleMessage (EVENT_SUPP_SERVICE_FAILED)");
                    mSuppServiceFailedRegistrants.notifyRegistrants((AsyncResult) msg.obj);
+4 −1
Original line number Diff line number Diff line
@@ -38,6 +38,9 @@ public class SuppServiceNotification {
    /** List of forwarded numbers, if any */
    public String[] history;

    static public final int NOTIFICATION_TYPE_MO = 0;
    static public final int NOTIFICATION_TYPE_MT = 1;

    static public final int MO_CODE_UNCONDITIONAL_CF_ACTIVE     = 0;
    static public final int MO_CODE_SOME_CF_ACTIVE              = 1;
    static public final int MO_CODE_CALL_FORWARDED              = 2;
@@ -64,7 +67,7 @@ public class SuppServiceNotification {
    public String toString()
    {
        return super.toString() + " mobile"
            + (notificationType == 0 ? " originated " : " terminated ")
            + (notificationType == NOTIFICATION_TYPE_MO ? " originated " : " terminated ")
            + " code: " + code
            + " index: " + index
            + " history: " + history