Loading android/app/src/com/android/bluetooth/tbs/TbsCall.java +90 −2 Original line number Diff line number Diff line Loading @@ -18,8 +18,7 @@ package com.android.bluetooth.tbs; import android.bluetooth.BluetoothLeCall; import java.util.UUID; import android.net.Uri; public class TbsCall { Loading @@ -32,6 +31,62 @@ public class TbsCall { private int mFlags; private String mFriendlyName; /** * Converts state value to human readable state string * * @param state state of call * @return converted to string state */ public static String stateToString(Integer state) { if (state.equals(BluetoothLeCall.STATE_INCOMING)) { return "INCOMING"; } else if (state.equals(BluetoothLeCall.STATE_DIALING)) { return "DIALING"; } else if (state.equals(BluetoothLeCall.STATE_ALERTING)) { return "ALERTING"; } else if (state.equals(BluetoothLeCall.STATE_ACTIVE)) { return "ACTIVE"; } else if (state.equals(BluetoothLeCall.STATE_LOCALLY_HELD)) { return "LOCALLY HELD"; } else if (state.equals(BluetoothLeCall.STATE_REMOTELY_HELD)) { return "REMOTELY HELD"; } else if (state.equals(BluetoothLeCall.STATE_LOCALLY_AND_REMOTELY_HELD)) { return "LOCALLY AND REMOTELY HELD"; } else { return "UNKNOWN(" + state + ")"; } } /** * Converts call flags value to human readable flag string * * @param flags call flags * @return converted to string flags */ public static String flagsToString(Integer flags) { String string = ""; if (flags.equals(BluetoothLeCall.FLAG_OUTGOING_CALL)) { if (string.isEmpty()) { string += "OUTGOING"; } } if (flags.equals(BluetoothLeCall.FLAG_WITHHELD_BY_SERVER)) { if (!string.isEmpty()) { string += "|"; } string += "WITHELD BY SERVER"; } if (flags.equals(BluetoothLeCall.FLAG_WITHHELD_BY_NETWORK)) { if (!string.isEmpty()) { string += "|"; } string += "WITHELD BY NETWORK"; } return string; } private TbsCall(int state, String uri, int flags, String friendlyName) { mState = state; mUri = uri; Loading Loading @@ -67,6 +122,10 @@ public class TbsCall { return mUri; } public String getSafeUri() { return Uri.parse(mUri).toSafeString(); } public int getFlags() { return mFlags; } Loading @@ -78,4 +137,33 @@ public class TbsCall { public String getFriendlyName() { return mFriendlyName; } /** * Converts Friendly Name to safe string (every second letter is replaced by '.') * * @return safe Friendly Name */ public String getSafeFriendlyName() {; if (mFriendlyName == null) { return null; } /* Don't anonymize short names */ if (mFriendlyName.length() < 3) { return mFriendlyName; } final StringBuilder builder = new StringBuilder(); for (int i = 0; i < mFriendlyName.length(); i++) { final char c = mFriendlyName.charAt(i); /* Anonymize every second letter */ if ((i % 2) == 0) { builder.append(c); } else { builder.append('.'); } } return builder.toString(); } } android/app/src/com/android/bluetooth/tbs/TbsGatt.java +47 −0 Original line number Diff line number Diff line Loading @@ -153,6 +153,40 @@ public class TbsGatt { private HashMap<BluetoothDevice, HashMap<UUID, Short>> mCccDescriptorValues; private TbsService mTbsService; private static String tbsUuidToString(UUID uuid) { if (uuid.equals(UUID_BEARER_PROVIDER_NAME)) { return "BEARER_PROVIDER_NAME"; } else if (uuid.equals(UUID_BEARER_UCI)) { return "BEARER_UCI"; } else if (uuid.equals(UUID_BEARER_TECHNOLOGY)) { return "BEARER_TECHNOLOGY"; } else if (uuid.equals(UUID_BEARER_URI_SCHEMES_SUPPORTED_LIST)) { return "BEARER_URI_SCHEMES_SUPPORTED_LIST"; } else if (uuid.equals(UUID_BEARER_LIST_CURRENT_CALLS)) { return "BEARER_LIST_CURRENT_CALLS"; } else if (uuid.equals(UUID_CONTENT_CONTROL_ID)) { return "CONTENT_CONTROL_ID"; } else if (uuid.equals(UUID_STATUS_FLAGS)) { return "STATUS_FLAGS"; } else if (uuid.equals(UUID_CALL_STATE)) { return "CALL_STATE"; } else if (uuid.equals(UUID_CALL_CONTROL_POINT)) { return "CALL_CONTROL_POINT"; } else if (uuid.equals(UUID_CALL_CONTROL_POINT_OPTIONAL_OPCODES)) { return "CALL_CONTROL_POINT_OPTIONAL_OPCODES"; } else if (uuid.equals(UUID_TERMINATION_REASON)) { return "TERMINATION_REASON"; } else if (uuid.equals(UUID_INCOMING_CALL)) { return "INCOMING_CALL"; } else if (uuid.equals(UUID_CALL_FRIENDLY_NAME)) { return "CALL_FRIENDLY_NAME"; } else if (uuid.equals(UUID_CLIENT_CHARACTERISTIC_CONFIGURATION)) { return "CLIENT_CHARACTERISTIC_CONFIGURATION"; } else { return "UNKNOWN(" + uuid + ")"; } } public static abstract class Callback { public abstract void onServiceAdded(boolean success); Loading Loading @@ -1080,4 +1114,17 @@ public class TbsGatt { } } }; public void dump(StringBuilder sb) { sb.append("\n\tSilent mode: " + mSilentMode); for (Map.Entry<BluetoothDevice, HashMap<UUID, Short>> deviceEntry : mCccDescriptorValues.entrySet()) { sb.append("\n\tCCC states for device: " + deviceEntry.getKey()); for (Map.Entry<UUID, Short> entry : deviceEntry.getValue().entrySet()) { sb.append("\n\t\tCharacteristic: " + tbsUuidToString(entry.getKey()) + ", value: " + Utils.cccIntToStr(entry.getValue())); } } } } android/app/src/com/android/bluetooth/tbs/TbsGeneric.java +19 −0 Original line number Diff line number Diff line Loading @@ -1148,4 +1148,23 @@ public class TbsGeneric { return false; } /** * Dump status of TBS service along with related objects * * @param sb string builder object that TBS module will be appending */ public void dump(StringBuilder sb) { sb.append("\tRinger Mode: " + mStoredRingerMode); sb.append("\n\tCurrent call list:"); for (TbsCall call : mCurrentCallsList.values()) { sb.append("\n\t\tFriendly name: " + call.getSafeFriendlyName()); sb.append("\n\t\t\tState: " + TbsCall.stateToString(call.getState())); sb.append("\n\t\t\tURI: " + call.getSafeUri()); sb.append("\n\t\t\tFlags: " + TbsCall.flagsToString(call.getFlags())); } mTbsGatt.dump(sb); } } android/app/src/com/android/bluetooth/tbs/TbsService.java +15 −0 Original line number Diff line number Diff line Loading @@ -442,5 +442,20 @@ public class TbsService extends ProfileService { @Override public void dump(StringBuilder sb) { super.dump(sb); sb.append("TbsService instance:\n"); mTbsGeneric.dump(sb); for (Map.Entry<BluetoothDevice, Integer> entry : mDeviceAuthorizations.entrySet()) { String accessString; if (entry.getValue() == BluetoothDevice.ACCESS_REJECTED) { accessString = "ACCESS_REJECTED"; } else if (entry.getValue() == BluetoothDevice.ACCESS_ALLOWED) { accessString = "ACCESS_ALLOWED"; } else { accessString = "ACCESS_UNKNOWN"; } sb.append("\n\tDevice: " + entry.getKey() + ", access: " + accessString); } } } Loading
android/app/src/com/android/bluetooth/tbs/TbsCall.java +90 −2 Original line number Diff line number Diff line Loading @@ -18,8 +18,7 @@ package com.android.bluetooth.tbs; import android.bluetooth.BluetoothLeCall; import java.util.UUID; import android.net.Uri; public class TbsCall { Loading @@ -32,6 +31,62 @@ public class TbsCall { private int mFlags; private String mFriendlyName; /** * Converts state value to human readable state string * * @param state state of call * @return converted to string state */ public static String stateToString(Integer state) { if (state.equals(BluetoothLeCall.STATE_INCOMING)) { return "INCOMING"; } else if (state.equals(BluetoothLeCall.STATE_DIALING)) { return "DIALING"; } else if (state.equals(BluetoothLeCall.STATE_ALERTING)) { return "ALERTING"; } else if (state.equals(BluetoothLeCall.STATE_ACTIVE)) { return "ACTIVE"; } else if (state.equals(BluetoothLeCall.STATE_LOCALLY_HELD)) { return "LOCALLY HELD"; } else if (state.equals(BluetoothLeCall.STATE_REMOTELY_HELD)) { return "REMOTELY HELD"; } else if (state.equals(BluetoothLeCall.STATE_LOCALLY_AND_REMOTELY_HELD)) { return "LOCALLY AND REMOTELY HELD"; } else { return "UNKNOWN(" + state + ")"; } } /** * Converts call flags value to human readable flag string * * @param flags call flags * @return converted to string flags */ public static String flagsToString(Integer flags) { String string = ""; if (flags.equals(BluetoothLeCall.FLAG_OUTGOING_CALL)) { if (string.isEmpty()) { string += "OUTGOING"; } } if (flags.equals(BluetoothLeCall.FLAG_WITHHELD_BY_SERVER)) { if (!string.isEmpty()) { string += "|"; } string += "WITHELD BY SERVER"; } if (flags.equals(BluetoothLeCall.FLAG_WITHHELD_BY_NETWORK)) { if (!string.isEmpty()) { string += "|"; } string += "WITHELD BY NETWORK"; } return string; } private TbsCall(int state, String uri, int flags, String friendlyName) { mState = state; mUri = uri; Loading Loading @@ -67,6 +122,10 @@ public class TbsCall { return mUri; } public String getSafeUri() { return Uri.parse(mUri).toSafeString(); } public int getFlags() { return mFlags; } Loading @@ -78,4 +137,33 @@ public class TbsCall { public String getFriendlyName() { return mFriendlyName; } /** * Converts Friendly Name to safe string (every second letter is replaced by '.') * * @return safe Friendly Name */ public String getSafeFriendlyName() {; if (mFriendlyName == null) { return null; } /* Don't anonymize short names */ if (mFriendlyName.length() < 3) { return mFriendlyName; } final StringBuilder builder = new StringBuilder(); for (int i = 0; i < mFriendlyName.length(); i++) { final char c = mFriendlyName.charAt(i); /* Anonymize every second letter */ if ((i % 2) == 0) { builder.append(c); } else { builder.append('.'); } } return builder.toString(); } }
android/app/src/com/android/bluetooth/tbs/TbsGatt.java +47 −0 Original line number Diff line number Diff line Loading @@ -153,6 +153,40 @@ public class TbsGatt { private HashMap<BluetoothDevice, HashMap<UUID, Short>> mCccDescriptorValues; private TbsService mTbsService; private static String tbsUuidToString(UUID uuid) { if (uuid.equals(UUID_BEARER_PROVIDER_NAME)) { return "BEARER_PROVIDER_NAME"; } else if (uuid.equals(UUID_BEARER_UCI)) { return "BEARER_UCI"; } else if (uuid.equals(UUID_BEARER_TECHNOLOGY)) { return "BEARER_TECHNOLOGY"; } else if (uuid.equals(UUID_BEARER_URI_SCHEMES_SUPPORTED_LIST)) { return "BEARER_URI_SCHEMES_SUPPORTED_LIST"; } else if (uuid.equals(UUID_BEARER_LIST_CURRENT_CALLS)) { return "BEARER_LIST_CURRENT_CALLS"; } else if (uuid.equals(UUID_CONTENT_CONTROL_ID)) { return "CONTENT_CONTROL_ID"; } else if (uuid.equals(UUID_STATUS_FLAGS)) { return "STATUS_FLAGS"; } else if (uuid.equals(UUID_CALL_STATE)) { return "CALL_STATE"; } else if (uuid.equals(UUID_CALL_CONTROL_POINT)) { return "CALL_CONTROL_POINT"; } else if (uuid.equals(UUID_CALL_CONTROL_POINT_OPTIONAL_OPCODES)) { return "CALL_CONTROL_POINT_OPTIONAL_OPCODES"; } else if (uuid.equals(UUID_TERMINATION_REASON)) { return "TERMINATION_REASON"; } else if (uuid.equals(UUID_INCOMING_CALL)) { return "INCOMING_CALL"; } else if (uuid.equals(UUID_CALL_FRIENDLY_NAME)) { return "CALL_FRIENDLY_NAME"; } else if (uuid.equals(UUID_CLIENT_CHARACTERISTIC_CONFIGURATION)) { return "CLIENT_CHARACTERISTIC_CONFIGURATION"; } else { return "UNKNOWN(" + uuid + ")"; } } public static abstract class Callback { public abstract void onServiceAdded(boolean success); Loading Loading @@ -1080,4 +1114,17 @@ public class TbsGatt { } } }; public void dump(StringBuilder sb) { sb.append("\n\tSilent mode: " + mSilentMode); for (Map.Entry<BluetoothDevice, HashMap<UUID, Short>> deviceEntry : mCccDescriptorValues.entrySet()) { sb.append("\n\tCCC states for device: " + deviceEntry.getKey()); for (Map.Entry<UUID, Short> entry : deviceEntry.getValue().entrySet()) { sb.append("\n\t\tCharacteristic: " + tbsUuidToString(entry.getKey()) + ", value: " + Utils.cccIntToStr(entry.getValue())); } } } }
android/app/src/com/android/bluetooth/tbs/TbsGeneric.java +19 −0 Original line number Diff line number Diff line Loading @@ -1148,4 +1148,23 @@ public class TbsGeneric { return false; } /** * Dump status of TBS service along with related objects * * @param sb string builder object that TBS module will be appending */ public void dump(StringBuilder sb) { sb.append("\tRinger Mode: " + mStoredRingerMode); sb.append("\n\tCurrent call list:"); for (TbsCall call : mCurrentCallsList.values()) { sb.append("\n\t\tFriendly name: " + call.getSafeFriendlyName()); sb.append("\n\t\t\tState: " + TbsCall.stateToString(call.getState())); sb.append("\n\t\t\tURI: " + call.getSafeUri()); sb.append("\n\t\t\tFlags: " + TbsCall.flagsToString(call.getFlags())); } mTbsGatt.dump(sb); } }
android/app/src/com/android/bluetooth/tbs/TbsService.java +15 −0 Original line number Diff line number Diff line Loading @@ -442,5 +442,20 @@ public class TbsService extends ProfileService { @Override public void dump(StringBuilder sb) { super.dump(sb); sb.append("TbsService instance:\n"); mTbsGeneric.dump(sb); for (Map.Entry<BluetoothDevice, Integer> entry : mDeviceAuthorizations.entrySet()) { String accessString; if (entry.getValue() == BluetoothDevice.ACCESS_REJECTED) { accessString = "ACCESS_REJECTED"; } else if (entry.getValue() == BluetoothDevice.ACCESS_ALLOWED) { accessString = "ACCESS_ALLOWED"; } else { accessString = "ACCESS_UNKNOWN"; } sb.append("\n\tDevice: " + entry.getKey() + ", access: " + accessString); } } }