Commit b2bf8527 authored by Jay Shrauner's avatar Jay Shrauner
Browse files

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 21a7534f)
parent 1c09481b
......@@ -42,6 +42,8 @@ import com.android.internal.telephony.PhoneConstants;
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 @@ public class BluetoothPhoneService extends Service {
private BluetoothAdapter mAdapter;
private CallManager mCM;
private CallGatewayManager mCallGatewayManager;
private BluetoothHeadset mBluetoothHeadset;
......@@ -104,6 +107,7 @@ public class BluetoothPhoneService extends Service {
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 @@ public class BluetoothPhoneService extends Service {
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 @@ public class BluetoothPhoneService extends Service {
// 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 @@ public class BluetoothPhoneService extends Service {
}
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);
}
}
......
......@@ -25,7 +25,7 @@ import android.util.Log;
import com.android.internal.telephony.Connection;
import com.google.android.collect.Maps;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
/**
* This class manages gateway information for outgoing calls. When calls are made, they may contain
......@@ -68,9 +68,19 @@ public class CallGatewayManager {
public static final RawGatewayInfo EMPTY_INFO = new RawGatewayInfo(null, null, null);
private final HashMap<Connection, RawGatewayInfo> mMap = Maps.newHashMap();
private final ConcurrentHashMap<Connection, RawGatewayInfo> mMap =
new ConcurrentHashMap<Connection, RawGatewayInfo>(4, 0.9f, 1);
public CallGatewayManager() {
private static CallGatewayManager sSingleton;
public static synchronized CallGatewayManager getInstance() {
if (sSingleton == null) {
sSingleton = new CallGatewayManager();
}
return sSingleton;
}
private CallGatewayManager() {
}
/**
......
......@@ -447,7 +447,7 @@ public class PhoneGlobals extends ContextWrapper implements WiredHeadsetListener
CallLogger callLogger = new CallLogger(this, new CallLogAsync());
callGatewayManager = new CallGatewayManager();
callGatewayManager = CallGatewayManager.getInstance();
// Create the CallController singleton, which is the interface
// to the telephony layer for user-initiated telephony functionality
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment