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

Commit d370415b authored by Danny Baumann's avatar Danny Baumann Committed by Matt Garnes
Browse files

Proper supplementary service notification handling (2/5).

Allow registering SSN listeners, and add missing constants.

Change-Id: I339a395fda5cca7617e7619cfc93312a1282f60e
(cherry picked from commit cd50fa78)
parent a78901c3
Loading
Loading
Loading
Loading
+40 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ public final class CallManager {
    private static final int EVENT_SERVICE_STATE_CHANGED = 118;
    private static final int EVENT_POST_DIAL_CHARACTER = 119;
    private static final int EVENT_ONHOLD_TONE = 120;
    private static final int EVENT_SUPP_SERVICE_NOTIFY = 121;

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

    protected final RegistrantList mSuppServiceNotifyRegistrants
    = new RegistrantList();

    protected final RegistrantList mSuppServiceFailedRegistrants
    = new RegistrantList();

@@ -550,6 +554,11 @@ public final class CallManager {
        phone.registerForSuppServiceFailed(handler, EVENT_SUPP_SERVICE_FAILED, null);
        phone.registerForServiceStateChanged(handler, EVENT_SERVICE_STATE_CHANGED, 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 ||
@@ -597,6 +606,11 @@ public final class CallManager {
        phone.unregisterForSuppServiceFailed(handler);
        phone.unregisterForServiceStateChanged(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 ||
@@ -1490,6 +1504,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.
@@ -2253,6 +2289,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
@@ -35,6 +35,9 @@ public class SuppServiceNotification {
    /** TS 27.007 7.17 "number" (MT only) */
    public String number;

    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;
@@ -61,7 +64,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
            + " \""