4 package com.smartdevicelink.trace;
\r
6 import java.util.Iterator;
\r
7 import java.util.Set;
\r
9 import com.smartdevicelink.util.DebugTool;
\r
11 import android.bluetooth.BluetoothAdapter;
\r
12 import android.bluetooth.BluetoothDevice;
\r
13 import android.telephony.TelephonyManager;
\r
19 public class TraceDeviceInfo {
\r
20 // http://developer.android.com/guide/topics/data/data-storage.html
\r
22 private static TelephonyManager m_telephonyManager;
\r
25 public TraceDeviceInfo(TelephonyManager telephonyManager) {
\r
26 m_telephonyManager = telephonyManager;
\r
29 public static void setTelephonyManager(TelephonyManager telephonyManager) {
\r
30 m_telephonyManager = telephonyManager;
\r
33 public static TelephonyManager getTelephonyManager() {
\r
34 return m_telephonyManager;
\r
38 static String getTelephonyHeader() {
\r
39 // Telephony manager can tell us a few things...
\r
42 if (m_telephonyManager != null) {
\r
43 try { // getDeviceId() requires android.permission.READ_PHONE_STATE
\r
44 info = "<deviceid>" + m_telephonyManager.getDeviceId() + "</deviceid>";
\r
45 } catch (Exception e1) {
\r
46 DebugTool.logError("Failure getting telephony device ID: " + e1.toString(), e1);
\r
50 switch (m_telephonyManager.getPhoneType()) {
\r
51 case TelephonyManager.PHONE_TYPE_NONE:
\r
54 case TelephonyManager.PHONE_TYPE_GSM:
\r
57 case TelephonyManager.PHONE_TYPE_CDMA:
\r
64 info += "</pt>" + "<nt>";
\r
66 switch (m_telephonyManager.getNetworkType()) {
\r
67 case TelephonyManager.NETWORK_TYPE_UNKNOWN:
\r
70 case TelephonyManager.NETWORK_TYPE_GPRS:
\r
73 case TelephonyManager.NETWORK_TYPE_EDGE:
\r
76 case TelephonyManager.NETWORK_TYPE_UMTS:
\r
79 case TelephonyManager.NETWORK_TYPE_HSDPA:
\r
82 case TelephonyManager.NETWORK_TYPE_HSUPA:
\r
85 case TelephonyManager.NETWORK_TYPE_HSPA:
\r
88 case TelephonyManager.NETWORK_TYPE_CDMA:
\r
91 case TelephonyManager.NETWORK_TYPE_EVDO_0:
\r
94 case TelephonyManager.NETWORK_TYPE_EVDO_A:
\r
97 case TelephonyManager.NETWORK_TYPE_1xRTT:
\r
111 static String getLogHeaderBluetoothPairs() {
\r
112 Set<BluetoothDevice> btDevices = BluetoothAdapter.getDefaultAdapter()
\r
113 .getBondedDevices();
\r
115 StringBuilder write = new StringBuilder("<btpairs>");
\r
116 Iterator<BluetoothDevice> iter = btDevices.iterator();
\r
117 while (iter.hasNext()) {
\r
118 write.append(SmartDeviceLinkTrace.getBTDeviceInfo(iter.next()));
\r
120 write.append("</btpairs>");
\r
122 return write.toString();
\r