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

Commit a687ce11 authored by Pawit Pornkitprasan's avatar Pawit Pornkitprasan Committed by Ricardo Cerqueira
Browse files

SamsungExynos4RIL: buffer CAT Proactive Command

The RIL sends a CAT proactive command (init) before the registrant
is registered causing the command to be missed and STK menu to
not show up. Buffer it and fire it when the registrant is registered.

Change-Id: I021ce911e55b30c1a2d95d8060f7d9ff72e3b742
parent 2508a98a
Loading
Loading
Loading
Loading
+48 −0
Original line number Diff line number Diff line
@@ -20,10 +20,12 @@ import static com.android.internal.telephony.RILConstants.*;

import android.content.Context;
import android.os.AsyncResult;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.os.Parcel;
import android.os.Registrant;
import android.text.TextUtils;
import android.telephony.Rlog;

@@ -117,6 +119,8 @@ public class SamsungExynos4RIL extends RIL implements CommandsInterface {
    static final int RIL_UNSOL_UTS_GET_UNREAD_SMS_STATUS = 11031;
    static final int RIL_UNSOL_MIP_CONNECT_STATUS = 11032;

    private Object mCatProCmdBuffer;

    public SamsungExynos4RIL(Context context, int networkMode, int cdmaSubscription) {
        super(context, networkMode, cdmaSubscription);
    }
@@ -382,4 +386,48 @@ public class SamsungExynos4RIL extends RIL implements CommandsInterface {

        send(rr);
    }

    @Override
    protected void
    processUnsolicited (Parcel p) {
        int dataPosition = p.dataPosition();
        int response = p.readInt();

        switch(response) {
            case RIL_UNSOL_STK_PROACTIVE_COMMAND: 
                Object ret = responseString(p);
                if (RILJ_LOGD) unsljLogRet(response, ret);

                if (mCatProCmdRegistrant != null) {
                    mCatProCmdRegistrant.notifyRegistrant(
                            new AsyncResult (null, ret, null));
                } else {
                    // The RIL will send a CAT proactive command before the
                    // registrant is registered. Buffer it to make sure it
                    // does not get ignored (and breaks CatService).
                    mCatProCmdBuffer = ret;
                }
                break;

            default:
                // Rewind the Parcel
                p.setDataPosition(dataPosition);

                // Forward responses that we are not overriding to the super class
                super.processUnsolicited(p);
                return;
        }

    }

    @Override
    public void setOnCatProactiveCmd(Handler h, int what, Object obj) {
        mCatProCmdRegistrant = new Registrant (h, what, obj);
        if (mCatProCmdBuffer != null) {
            mCatProCmdRegistrant.notifyRegistrant(
                                new AsyncResult (null, mCatProCmdBuffer, null));
            mCatProCmdBuffer = null;
        }
    }

}