Loading src/java/com/android/internal/telephony/PhoneFactory.java +54 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.provider.Settings.SettingNotFoundException; import android.telephony.Rlog; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.util.LocalLog; import com.android.internal.telephony.cdma.CDMALTEPhone; import com.android.internal.telephony.cdma.CDMAPhone; Loading @@ -42,9 +43,11 @@ import com.android.internal.telephony.sip.SipPhone; import com.android.internal.telephony.sip.SipPhoneFactory; import com.android.internal.telephony.uicc.IccCardProxy; import com.android.internal.telephony.uicc.UiccController; import com.android.internal.util.IndentingPrintWriter; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.HashMap; /** * {@hide} Loading Loading @@ -74,6 +77,8 @@ public class PhoneFactory { static private PhoneNotifier sPhoneNotifier; static private Context sContext; static private final HashMap<String, LocalLog>sLocalLogs = new HashMap<String, LocalLog>(); //***** Class Methods public static void makeDefaultPhones(Context context) { Loading Loading @@ -412,6 +417,43 @@ public class PhoneFactory { return ImsPhoneFactory.makePhone(sContext, phoneNotifier, defaultPhone); } /** * Adds a local log category. * * Only used within the telephony process. Use localLog to add log entries. * * TODO - is there a better way to do this? Think about design when we have a minute. * * @param key the name of the category - will be the header in the service dump. * @param size the number of lines to maintain in this category */ public static void addLocalLog(String key, int size) { synchronized(sLocalLogs) { if (sLocalLogs.containsKey(key)) { throw new IllegalArgumentException("key " + key + " already present"); } sLocalLogs.put(key, new LocalLog(size)); } } /** * Add a line to the named Local Log. * * This will appear in the TelephonyDebugService dump. * * @param key the name of the log category to put this in. Must be created * via addLocalLog. * @param log the string to add to the log. */ public static void localLog(String key, String log) { synchronized(sLocalLogs) { if (sLocalLogs.containsKey(key) == false) { throw new IllegalArgumentException("key " + key + " not found"); } sLocalLogs.get(key).log(log); } } public static void dump(FileDescriptor fd, PrintWriter pw, String[] args) { pw.println("PhoneFactory:"); PhoneProxy [] phones = (PhoneProxy[])PhoneFactory.getPhones(); Loading Loading @@ -468,5 +510,17 @@ public class PhoneFactory { e.printStackTrace(); } pw.flush(); pw.println("++++++++++++++++++++++++++++++++"); synchronized (sLocalLogs) { final IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " "); for (String key : sLocalLogs.keySet()) { ipw.println(key); ipw.increaseIndent(); sLocalLogs.get(key).dump(fd, ipw, args); ipw.decreaseIndent(); } ipw.flush(); } } } Loading
src/java/com/android/internal/telephony/PhoneFactory.java +54 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.provider.Settings.SettingNotFoundException; import android.telephony.Rlog; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.util.LocalLog; import com.android.internal.telephony.cdma.CDMALTEPhone; import com.android.internal.telephony.cdma.CDMAPhone; Loading @@ -42,9 +43,11 @@ import com.android.internal.telephony.sip.SipPhone; import com.android.internal.telephony.sip.SipPhoneFactory; import com.android.internal.telephony.uicc.IccCardProxy; import com.android.internal.telephony.uicc.UiccController; import com.android.internal.util.IndentingPrintWriter; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.HashMap; /** * {@hide} Loading Loading @@ -74,6 +77,8 @@ public class PhoneFactory { static private PhoneNotifier sPhoneNotifier; static private Context sContext; static private final HashMap<String, LocalLog>sLocalLogs = new HashMap<String, LocalLog>(); //***** Class Methods public static void makeDefaultPhones(Context context) { Loading Loading @@ -412,6 +417,43 @@ public class PhoneFactory { return ImsPhoneFactory.makePhone(sContext, phoneNotifier, defaultPhone); } /** * Adds a local log category. * * Only used within the telephony process. Use localLog to add log entries. * * TODO - is there a better way to do this? Think about design when we have a minute. * * @param key the name of the category - will be the header in the service dump. * @param size the number of lines to maintain in this category */ public static void addLocalLog(String key, int size) { synchronized(sLocalLogs) { if (sLocalLogs.containsKey(key)) { throw new IllegalArgumentException("key " + key + " already present"); } sLocalLogs.put(key, new LocalLog(size)); } } /** * Add a line to the named Local Log. * * This will appear in the TelephonyDebugService dump. * * @param key the name of the log category to put this in. Must be created * via addLocalLog. * @param log the string to add to the log. */ public static void localLog(String key, String log) { synchronized(sLocalLogs) { if (sLocalLogs.containsKey(key) == false) { throw new IllegalArgumentException("key " + key + " not found"); } sLocalLogs.get(key).log(log); } } public static void dump(FileDescriptor fd, PrintWriter pw, String[] args) { pw.println("PhoneFactory:"); PhoneProxy [] phones = (PhoneProxy[])PhoneFactory.getPhones(); Loading Loading @@ -468,5 +510,17 @@ public class PhoneFactory { e.printStackTrace(); } pw.flush(); pw.println("++++++++++++++++++++++++++++++++"); synchronized (sLocalLogs) { final IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " "); for (String key : sLocalLogs.keySet()) { ipw.println(key); ipw.increaseIndent(); sLocalLogs.get(key).dump(fd, ipw, args); ipw.decreaseIndent(); } ipw.flush(); } } }