Add ril.test.emergency system property.
This allows testing of emergency numbers by dialing an emergency number but having it remapped to another number. Bug: 5479306 Change-Id: Ia9bb53e2e2e47f78dc9f75d3add6f785d10e4b2a
This commit is contained in:
@@ -715,4 +715,7 @@ public abstract class BaseCommands implements CommandsInterface {
|
||||
"' lteOnCdmaProductType='" + sLteOnCdmaProductType + "'");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testingEmergencyCall() {}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ package com.android.internal.telephony;
|
||||
import android.os.AsyncResult;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.SystemProperties;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.telephony.CommandException;
|
||||
@@ -116,6 +118,48 @@ public abstract class CallTracker extends Handler {
|
||||
return pendingOperations == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 number to test if it should be remapped
|
||||
* @return the same number or the remapped number.
|
||||
*/
|
||||
protected String checkForTestEmergencyNumber(String dialString) {
|
||||
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))) {
|
||||
cm.testingEmergencyCall();
|
||||
log("checkForTestEmergencyNumber: remap " +
|
||||
dialString + " to " + values[1]);
|
||||
dialString = values[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return dialString;
|
||||
}
|
||||
|
||||
//***** Overridden from Handler
|
||||
public abstract void handleMessage (Message msg);
|
||||
|
||||
@@ -1559,4 +1559,9 @@ public interface CommandsInterface {
|
||||
* @param response a callback message with the String response in the obj field
|
||||
*/
|
||||
public void requestIsimAuthentication(String nonce, Message response);
|
||||
|
||||
/**
|
||||
* Notifiy that we are testing an emergency call
|
||||
*/
|
||||
public void testingEmergencyCall();
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* {@hide}
|
||||
@@ -231,6 +232,9 @@ public final class RIL extends BaseCommands implements CommandsInterface {
|
||||
|
||||
Object mLastNITZTimeInfo;
|
||||
|
||||
// When we are testing emergency calls
|
||||
AtomicBoolean mTestingEmergencyCall = new AtomicBoolean(false);
|
||||
|
||||
//***** Events
|
||||
|
||||
static final int EVENT_SEND = 1;
|
||||
@@ -2194,7 +2198,16 @@ public final class RIL extends BaseCommands implements CommandsInterface {
|
||||
case RIL_REQUEST_GET_IMSI: ret = responseString(p); break;
|
||||
case RIL_REQUEST_HANGUP: ret = responseVoid(p); break;
|
||||
case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: ret = responseVoid(p); break;
|
||||
case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: ret = responseVoid(p); break;
|
||||
case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: {
|
||||
if (mTestingEmergencyCall.getAndSet(false)) {
|
||||
if (mEmergencyCallbackModeRegistrant != null) {
|
||||
riljLog("testing emergency call, notify ECM Registrants");
|
||||
mEmergencyCallbackModeRegistrant.notifyRegistrant();
|
||||
}
|
||||
}
|
||||
ret = responseVoid(p);
|
||||
break;
|
||||
}
|
||||
case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: ret = responseVoid(p); break;
|
||||
case RIL_REQUEST_CONFERENCE: ret = responseVoid(p); break;
|
||||
case RIL_REQUEST_UDUB: ret = responseVoid(p); break;
|
||||
@@ -2985,6 +2998,11 @@ public final class RIL extends BaseCommands implements CommandsInterface {
|
||||
num = p.readInt();
|
||||
response = new ArrayList<DriverCall>(num);
|
||||
|
||||
if (RILJ_LOGV) {
|
||||
riljLog("responseCallList: num=" + num +
|
||||
" mEmergencyCallbackModeRegistrant=" + mEmergencyCallbackModeRegistrant +
|
||||
" mTestingEmergencyCall=" + mTestingEmergencyCall.get());
|
||||
}
|
||||
for (int i = 0 ; i < num ; i++) {
|
||||
dc = new DriverCall();
|
||||
|
||||
@@ -3036,6 +3054,14 @@ public final class RIL extends BaseCommands implements CommandsInterface {
|
||||
|
||||
Collections.sort(response);
|
||||
|
||||
if ((num == 0) && mTestingEmergencyCall.getAndSet(false)) {
|
||||
if (mEmergencyCallbackModeRegistrant != null) {
|
||||
riljLog("responseCallList: call ended, testing emergency call," +
|
||||
" notify ECM Registrants");
|
||||
mEmergencyCallbackModeRegistrant.notifyRegistrant();
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -3762,4 +3788,13 @@ public final class RIL extends BaseCommands implements CommandsInterface {
|
||||
|
||||
send(rr);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.android.internal.telephony.BaseCommands#testingEmergencyCall()
|
||||
*/
|
||||
@Override
|
||||
public void testingEmergencyCall() {
|
||||
if (RILJ_LOGD) riljLog("testingEmergencyCall");
|
||||
mTestingEmergencyCall.set(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,7 +210,8 @@ public final class CdmaCallTracker extends CallTracker {
|
||||
return dialThreeWay(dialString);
|
||||
}
|
||||
|
||||
pendingMO = new CdmaConnection(phone.getContext(), dialString, this, foregroundCall);
|
||||
pendingMO = new CdmaConnection(phone.getContext(), checkForTestEmergencyNumber(dialString),
|
||||
this, foregroundCall);
|
||||
hangupPendingMO = false;
|
||||
|
||||
if (pendingMO.address == null || pendingMO.address.length() == 0
|
||||
@@ -259,7 +260,7 @@ public final class CdmaCallTracker extends CallTracker {
|
||||
|
||||
// Attach the new connection to foregroundCall
|
||||
pendingMO = new CdmaConnection(phone.getContext(),
|
||||
dialString, this, foregroundCall);
|
||||
checkForTestEmergencyNumber(dialString), this, foregroundCall);
|
||||
cm.sendCDMAFeatureCode(pendingMO.address,
|
||||
obtainMessage(EVENT_THREE_WAY_DIAL_L2_RESULT_CDMA));
|
||||
return pendingMO;
|
||||
|
||||
@@ -198,7 +198,8 @@ public final class GsmCallTracker extends CallTracker {
|
||||
throw new CallStateException("cannot dial in current state");
|
||||
}
|
||||
|
||||
pendingMO = new GsmConnection(phone.getContext(), dialString, this, foregroundCall);
|
||||
pendingMO = new GsmConnection(phone.getContext(), checkForTestEmergencyNumber(dialString),
|
||||
this, foregroundCall);
|
||||
hangupPendingMO = false;
|
||||
|
||||
if (pendingMO.address == null || pendingMO.address.length() == 0
|
||||
|
||||
Reference in New Issue
Block a user