Uses Call object to reject a call.
Bug: 11111553
Change-Id: I56d1349bbf088b1cc89d9a799916d2dcb3c6b1d3
diff --git a/src/com/android/phone/CallCommandService.java b/src/com/android/phone/CallCommandService.java
index f26fff7..5238911 100644
--- a/src/com/android/phone/CallCommandService.java
+++ b/src/com/android/phone/CallCommandService.java
@@ -26,7 +26,6 @@
import com.android.internal.telephony.PhoneConstants;
import com.android.phone.CallModeler.CallResult;
import com.android.phone.NotificationMgr.StatusBarHelper;
-import com.android.services.telephony.common.AudioMode;
import com.android.services.telephony.common.Call;
import com.android.services.telephony.common.ICallCommandService;
@@ -73,20 +72,26 @@
* TODO: Add a confirmation callback parameter.
*/
@Override
- public void rejectCall(int callId, boolean rejectWithMessage, String message) {
+ public void rejectCall(Call call, boolean rejectWithMessage, String message) {
try {
+ int callId = Call.INVALID_CALL_ID;
+ String phoneNumber = "";
+ if (call != null) {
+ callId = call.getCallId();
+ phoneNumber = call.getNumber();
+ }
CallResult result = mCallModeler.getCallWithId(callId);
- if (result != null) {
- final String number = result.getConnection().getAddress();
- if (rejectWithMessage) {
- RejectWithTextMessageManager.rejectCallWithMessage(
- result.getConnection().getCall(), message);
- }
+ if (result != null) {
+ phoneNumber = result.getConnection().getAddress();
Log.v(TAG, "Hanging up");
PhoneUtils.hangupRingingCall(result.getConnection().getCall());
}
+
+ if (rejectWithMessage && !phoneNumber.isEmpty()) {
+ RejectWithTextMessageManager.rejectCallWithMessage(phoneNumber, message);
+ }
} catch (Exception e) {
Log.e(TAG, "Error during rejectCall().", e);
}
diff --git a/src/com/android/phone/RejectWithTextMessageManager.java b/src/com/android/phone/RejectWithTextMessageManager.java
index 8f8b8cb..dd4fe17 100644
--- a/src/com/android/phone/RejectWithTextMessageManager.java
+++ b/src/com/android/phone/RejectWithTextMessageManager.java
@@ -143,10 +143,8 @@
/**
* Reject the call with the specified message. If message is null this call is ignored.
*/
- public static void rejectCallWithMessage(Call call, String message) {
- Connection conn = call.getLatestConnection();
- if (conn != null && message != null) {
- final String phoneNumber = conn.getAddress();
+ public static void rejectCallWithMessage(String phoneNumber, String message) {
+ if (message != null) {
final ComponentName component =
SmsApplication.getDefaultRespondViaMessageApplication(
PhoneGlobals.getInstance(), true /*updateIfNeeded*/);