Don't display gateway number on bluetooth
Display actual contact phone number instead of the Google voice
gateway number when there is a bluetooth connection with eg a car display.
Bug:11881222
Change-Id: I1a5b9d3dee4a490905e6e4b52745972fd63d81a1
(cherry picked from commit 21a7534fa69c1cc10809ae33fa0bfa84c5ac1309)
diff --git a/src/com/android/phone/BluetoothPhoneService.java b/src/com/android/phone/BluetoothPhoneService.java
index ed6f37e..be6c1cc 100644
--- a/src/com/android/phone/BluetoothPhoneService.java
+++ b/src/com/android/phone/BluetoothPhoneService.java
@@ -42,6 +42,8 @@
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.CallManager;
+import com.android.phone.CallGatewayManager.RawGatewayInfo;
+
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
@@ -60,6 +62,7 @@
private BluetoothAdapter mAdapter;
private CallManager mCM;
+ private CallGatewayManager mCallGatewayManager;
private BluetoothHeadset mBluetoothHeadset;
@@ -104,6 +107,7 @@
if (VDBG) Log.d(TAG, "mAdapter null");
return;
}
+ mCallGatewayManager = CallGatewayManager.getInstance();
mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
mStartCallWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
@@ -521,16 +525,26 @@
mpty = call.isMultiparty();
}
- int direction = connection.isIncoming() ? 1 : 0;
+ boolean isIncoming = connection.isIncoming();
+ // For GV outgoing calls send the contact phone #, not the gateway #.
String number = connection.getAddress();
+ if (!isIncoming) {
+ RawGatewayInfo rawInfo = mCallGatewayManager.getGatewayInfo(connection);
+ if (!rawInfo.isEmpty()) {
+ number = rawInfo.trueNumber;
+ }
+ }
int type = -1;
if (number != null) {
type = PhoneNumberUtils.toaFromString(number);
+ } else {
+ number = "";
}
if (mBluetoothHeadset != null) {
- mBluetoothHeadset.clccResponse(index + 1, direction, state, 0, mpty, number, type);
+ mBluetoothHeadset.clccResponse(index + 1, isIncoming ? 1 : 0,
+ state, 0, mpty, number, type);
}
}
@@ -654,9 +668,16 @@
// as per Bluetooth SIG PTS
}
- int direction = connection.isIncoming() ? 1 : 0;
+ boolean isIncoming = connection.isIncoming();
+ // For GV outgoing calls send the contact phone #, not the gateway #.
String number = connection.getAddress();
+ if (!isIncoming) {
+ RawGatewayInfo rawInfo = mCallGatewayManager.getGatewayInfo(connection);
+ if (!rawInfo.isEmpty()) {
+ number = rawInfo.trueNumber;
+ }
+ }
int type = -1;
if (number != null) {
type = PhoneNumberUtils.toaFromString(number);
@@ -665,7 +686,8 @@
}
if (mBluetoothHeadset != null) {
- mBluetoothHeadset.clccResponse(index + 1, direction, state, 0, mpty, number, type);
+ mBluetoothHeadset.clccResponse(index + 1, isIncoming ? 1 : 0,
+ state, 0, mpty, number, type);
}
}