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

Commit 82fa82ca authored by Tyler Gunn's avatar Tyler Gunn Committed by Android Partner Code Review
Browse files

Merge "Fix potential NPE in TelephonyEventLog." into mm-wireless-dev

parents caf788f8 e9588c0a
Loading
Loading
Loading
Loading
+25 −9
Original line number Original line Diff line number Diff line
@@ -409,16 +409,15 @@ public class TelephonyEventLog {
            case DISCONNECTING: state = 8; break;
            case DISCONNECTING: state = 8; break;
            default: state = -1; break;
            default: state = -1; break;
        }
        }
        writeEvent(TAG_IMS_CALL_STATE, Integer.parseInt(session.getCallId()), state);
        writeEvent(TAG_IMS_CALL_STATE, getCallId(session), state);
    }
    }


    private void writeImsCallEvent(int tag, ImsCallSession session) {
    private void writeImsCallEvent(int tag, ImsCallSession session) {
        writeEvent(tag, Integer.parseInt(session.getCallId()), -1);
        writeEvent(tag, getCallId(session), -1);
    }
    }


    private void writeImsCallEvent(int tag, ImsCallSession session, ImsReasonInfo reasonInfo) {
    private void writeImsCallEvent(int tag, ImsCallSession session, ImsReasonInfo reasonInfo) {
        writeEvent(tag, Integer.parseInt(session.getCallId()), -1,
        writeEvent(tag, getCallId(session), -1,imsReasonInfoToBundle(reasonInfo));
                imsReasonInfoToBundle(reasonInfo));
    }
    }


    private Bundle imsReasonInfoToBundle(ImsReasonInfo reasonInfo) {
    private Bundle imsReasonInfoToBundle(ImsReasonInfo reasonInfo) {
@@ -435,13 +434,13 @@ public class TelephonyEventLog {
    public void writeOnImsCallStart(ImsCallSession session, String callee) {
    public void writeOnImsCallStart(ImsCallSession session, String callee) {
        Bundle b = new Bundle();
        Bundle b = new Bundle();
        b.putString(DATA_KEY_CALLEE, callee);
        b.putString(DATA_KEY_CALLEE, callee);
        writeEvent(TAG_IMS_CALL_START, Integer.parseInt(session.getCallId()), -1, b);
        writeEvent(TAG_IMS_CALL_START, getCallId(session), -1, b);
    }
    }


    public void writeOnImsCallStartConference(ImsCallSession session, String[] participants) {
    public void writeOnImsCallStartConference(ImsCallSession session, String[] participants) {
        Bundle b = new Bundle();
        Bundle b = new Bundle();
        b.putStringArray(DATA_KEY_PARTICIPANTS, participants);
        b.putStringArray(DATA_KEY_PARTICIPANTS, participants);
        writeEvent(TAG_IMS_CALL_START_CONFERENCE, Integer.parseInt(session.getCallId()), -1, b);
        writeEvent(TAG_IMS_CALL_START_CONFERENCE, getCallId(session), -1, b);
    }
    }


    public void writeOnImsCallReceive(ImsCallSession session) {
    public void writeOnImsCallReceive(ImsCallSession session) {
@@ -511,14 +510,31 @@ public class TelephonyEventLog {
    public void writeOnImsCallHandover(ImsCallSession session,
    public void writeOnImsCallHandover(ImsCallSession session,
            int srcAccessTech, int targetAccessTech, ImsReasonInfo reasonInfo) {
            int srcAccessTech, int targetAccessTech, ImsReasonInfo reasonInfo) {
        Bundle b = imsHandoverToBundle(srcAccessTech, targetAccessTech, reasonInfo);
        Bundle b = imsHandoverToBundle(srcAccessTech, targetAccessTech, reasonInfo);
        writeEvent(TAG_IMS_CALL_HANDOVER, Integer.parseInt(session.getCallId()), -1, b);
        writeEvent(TAG_IMS_CALL_HANDOVER, getCallId(session), -1, b);
    }
    }


    public void writeOnImsCallHandoverFailed(ImsCallSession session,
    public void writeOnImsCallHandoverFailed(ImsCallSession session,
            int srcAccessTech, int targetAccessTech, ImsReasonInfo reasonInfo) {
            int srcAccessTech, int targetAccessTech, ImsReasonInfo reasonInfo) {
        Bundle b = imsHandoverToBundle(srcAccessTech, targetAccessTech, reasonInfo);
        Bundle b = imsHandoverToBundle(srcAccessTech, targetAccessTech, reasonInfo);
        writeEvent(TAG_IMS_CALL_HANDOVER_FAILED,
        writeEvent(TAG_IMS_CALL_HANDOVER_FAILED, getCallId(session), -1, b);
                Integer.parseInt(session.getCallId()), -1, b);
    }

    /**
     * Extracts the call ID from an ImsSession.
     *
     * @param session The session.
     * @return The call ID for the session, or -1 if none was found.
     */
    private int getCallId(ImsCallSession session) {
        if (session == null) {
            return -1;
        }

        try {
            return Integer.parseInt(session.getCallId());
        } catch (NumberFormatException nfe) {
            return -1;
        }
    }
    }


    private Bundle imsHandoverToBundle(int srcAccessTech, int targetAccessTech,
    private Bundle imsHandoverToBundle(int srcAccessTech, int targetAccessTech,