FileDocCategorySizeDatePackage
CallTracker.javaAPI DocAndroid 5.1 API11756Thu Mar 12 22:22:54 GMT 2015com.android.internal.telephony

CallTracker

public abstract class CallTracker extends android.os.Handler
{@hide}

Fields Summary
private static final boolean
DBG_POLL
static final int
POLL_DELAY_MSEC
protected int
mPendingOperations
protected boolean
mNeedsPoll
protected android.os.Message
mLastRelevantPoll
protected ArrayList
mHandoverConnections
public CommandsInterface
mCi
protected boolean
mNumberConverted
private final int
VALID_COMPARE_LENGTH
protected static final int
EVENT_POLL_CALLS_RESULT
protected static final int
EVENT_CALL_STATE_CHANGE
protected static final int
EVENT_REPOLL_AFTER_DELAY
protected static final int
EVENT_OPERATION_COMPLETE
protected static final int
EVENT_GET_LAST_CALL_FAIL_CAUSE
protected static final int
EVENT_SWITCH_RESULT
protected static final int
EVENT_RADIO_AVAILABLE
protected static final int
EVENT_RADIO_NOT_AVAILABLE
protected static final int
EVENT_CONFERENCE_RESULT
protected static final int
EVENT_SEPARATE_RESULT
protected static final int
EVENT_ECT_RESULT
protected static final int
EVENT_EXIT_ECM_RESPONSE_CDMA
protected static final int
EVENT_CALL_WAITING_INFO_CDMA
protected static final int
EVENT_THREE_WAY_DIAL_L2_RESULT_CDMA
protected static final int
EVENT_THREE_WAY_DIAL_BLANK_FLASH
Constructors Summary
Methods Summary
protected java.lang.StringcheckForTestEmergencyNumber(java.lang.String dialString)
Routine called from dial to check if the number is a test Emergency number and if so remap the number. This allows a short emergency number to be remapped to a regular number for testing how the frameworks handles emergency numbers without actually calling an emergency number. This is not a full test and is not a substitute for testing real emergency numbers but can be useful. To use this feature set a system property ril.test.emergencynumber to a pair of numbers separated by a colon. If the first number matches the number parameter this routine returns the second number. Example: ril.test.emergencynumber=112:1-123-123-45678 To test Dial 112 take call then hang up on MO device to enter ECM see RIL#processSolicited RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND

param
dialString to test if it should be remapped
return
the same number or the remapped number.

        String testEn = SystemProperties.get("ril.test.emergencynumber");
        if (DBG_POLL) {
            log("checkForTestEmergencyNumber: dialString=" + dialString +
                " testEn=" + testEn);
        }
        if (!TextUtils.isEmpty(testEn)) {
            String values[] = testEn.split(":");
            log("checkForTestEmergencyNumber: values.length=" + values.length);
            if (values.length == 2) {
                if (values[0].equals(
                        android.telephony.PhoneNumberUtils.stripSeparators(dialString))) {
                    mCi.testingEmergencyCall();
                    log("checkForTestEmergencyNumber: remap " +
                            dialString + " to " + values[1]);
                    dialString = values[1];
                }
            }
        }
        return dialString;
    
private booleancheckNoOperationsPending()

return
true if we're idle or there's a call to getCurrentCalls() pending but nothing else

        if (DBG_POLL) log("checkNoOperationsPending: pendingOperations=" +
                mPendingOperations);
        return mPendingOperations == 0;
    
private booleancompareGid1(PhoneBase phoneBase, java.lang.String serviceGid1)

        String gid1 = phoneBase.getGroupIdLevel1();
        int gid_length = serviceGid1.length();
        boolean ret = true;

        if (serviceGid1 == null || serviceGid1.equals("")) {
            log("compareGid1 serviceGid is empty, return " + ret);
            return ret;
        }
        // Check if gid1 match service GID1
        if (!((gid1 != null) && (gid1.length() >= gid_length) &&
                gid1.substring(0, gid_length).equalsIgnoreCase(serviceGid1))) {
            log(" gid1 " + gid1 + " serviceGid1 " + serviceGid1);
            ret = false;
        }
        log("compareGid1 is " + (ret?"Same":"Different"));
        return ret;
    
protected java.lang.StringconvertNumberIfNecessary(PhoneBase phoneBase, java.lang.String dialNumber)

        if (dialNumber == null) {
            return dialNumber;
        }
        String[] convertMaps = phoneBase.getContext().getResources().getStringArray(
                com.android.internal.R.array.dial_string_replace);
        log("convertNumberIfNecessary Roaming"
            + " convertMaps.length " + convertMaps.length
            + " dialNumber.length() " + dialNumber.length());

        if (convertMaps.length < 1 || dialNumber.length() < VALID_COMPARE_LENGTH) {
            return dialNumber;
        }

        String[] entry;
        String[] tmpArray;
        String outNumber = "";
        boolean needConvert = false;
        for(String convertMap : convertMaps) {
            log("convertNumberIfNecessary: " + convertMap);
            entry = convertMap.split(":");
            if (entry.length > 1) {
                tmpArray = entry[1].split(",");
                if (!TextUtils.isEmpty(entry[0]) && dialNumber.equals(entry[0])) {
                    if (tmpArray.length >= 2 && !TextUtils.isEmpty(tmpArray[1])) {
                        if (compareGid1(phoneBase, tmpArray[1])) {
                            needConvert = true;
                        }
                    } else if (outNumber.isEmpty()) {
                        needConvert = true;
                    }

                    if (needConvert) {
                        if(!TextUtils.isEmpty(tmpArray[0]) && tmpArray[0].endsWith("MDN")) {
                            String mdn = phoneBase.getLine1Number();
                            if (!TextUtils.isEmpty(mdn) ) {
                                if (mdn.startsWith("+")) {
                                    outNumber = mdn;
                                } else {
                                    outNumber = tmpArray[0].substring(0, tmpArray[0].length() -3)
                                            + mdn;
                                }
                            }
                        } else {
                            outNumber = tmpArray[0];
                        }
                        needConvert = false;
                    }
                }
            }
        }

        if (!TextUtils.isEmpty(outNumber)) {
            log("convertNumberIfNecessary: convert service number");
            mNumberConverted = true;
            return outNumber;
        }

        return dialNumber;

    
public voiddump(java.io.FileDescriptor fd, java.io.PrintWriter pw, java.lang.String[] args)

        pw.println("CallTracker:");
        pw.println(" mPendingOperations=" + mPendingOperations);
        pw.println(" mNeedsPoll=" + mNeedsPoll);
        pw.println(" mLastRelevantPoll=" + mLastRelevantPoll);
    
protected ConnectiongetHoConnection(DriverCall dc)

        for (Connection hoConn : mHandoverConnections) {
            log("getHoConnection - compare number: hoConn= " + hoConn.toString());
            if (hoConn.getAddress() != null && hoConn.getAddress().contains(dc.number)) {
                log("getHoConnection: Handover connection match found = " + hoConn.toString());
                return hoConn;
            }
        }
        for (Connection hoConn : mHandoverConnections) {
            log("getHoConnection: compare state hoConn= " + hoConn.toString());
            if (hoConn.getStateBeforeHandover() == Call.stateFromDCState(dc.state)) {
                log("getHoConnection: Handover connection match found = " + hoConn.toString());
                return hoConn;
            }
        }
        return null;
    
public abstract PhoneConstants.StategetState()

public abstract voidhandleMessage(android.os.Message msg)

protected abstract voidhandlePollCalls(android.os.AsyncResult ar)

protected voidhandleRadioAvailable()

        pollCallsWhenSafe();
    
protected booleanisCommandExceptionRadioNotAvailable(java.lang.Throwable e)

        return e != null && e instanceof CommandException
                && ((CommandException)e).getCommandError()
                        == CommandException.Error.RADIO_NOT_AVAILABLE;
    
protected abstract voidlog(java.lang.String msg)

protected voidnotifySrvccState(Call.SrvccState state, java.util.ArrayList c)

        if (state == Call.SrvccState.STARTED && c != null) {
            // SRVCC started. Prepare handover connections list
            mHandoverConnections.addAll(c);
        } else if (state != Call.SrvccState.COMPLETED) {
            // SRVCC FAILED/CANCELED. Clear the handover connections list
            // Individual connections will be removed from the list in handlePollCalls()
            mHandoverConnections.clear();
        }
        log("notifySrvccState: mHandoverConnections= " + mHandoverConnections.toString());
    
protected android.os.MessageobtainNoPollCompleteMessage(int what)
Obtain a complete message that indicates that this operation does not require polling of getCurrentCalls(). However, if other operations that do need getCurrentCalls() are pending or are scheduled while this operation is pending, the invocation of getCurrentCalls() will be postponed until this operation is also complete.

        mPendingOperations++;
        mLastRelevantPoll = null;
        return obtainMessage(what);
    
protected voidpollCallsAfterDelay()

        Message msg = obtainMessage();

        msg.what = EVENT_REPOLL_AFTER_DELAY;
        sendMessageDelayed(msg, POLL_DELAY_MSEC);
    
protected voidpollCallsWhenSafe()


       
        mNeedsPoll = true;

        if (checkNoOperationsPending()) {
            mLastRelevantPoll = obtainMessage(EVENT_POLL_CALLS_RESULT);
            mCi.getCurrentCalls(mLastRelevantPoll);
        }
    
public abstract voidregisterForVoiceCallEnded(android.os.Handler h, int what, java.lang.Object obj)

public abstract voidregisterForVoiceCallStarted(android.os.Handler h, int what, java.lang.Object obj)

public abstract voidunregisterForVoiceCallEnded(android.os.Handler h)

public abstract voidunregisterForVoiceCallStarted(android.os.Handler h)