1 /* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.internal.telephony; 18 19 import android.telephony.Rlog; 20 21 import com.android.internal.telephony.uicc.UiccController; 22 import com.android.internal.telephony.uicc.IccCardProxy; 23 24 import java.io.FileDescriptor; 25 import java.io.PrintWriter; 26 27 /** 28 * A debug service that will dump telephony's state 29 * 30 * Currently this "Service" has a proxy in the phone app 31 * com.android.phone.TelephonyDebugService which actually 32 * invokes the dump method. 33 */ 34 public class DebugService { 35 private static String TAG = "DebugService"; 36 37 /** Constructor */ DebugService()38 public DebugService() { 39 log("DebugService:"); 40 } 41 42 /** 43 * Dump the state of various objects, add calls to other objects as desired. 44 */ dump(FileDescriptor fd, PrintWriter pw, String[] args)45 public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { 46 log("dump: +"); 47 PhoneProxy phoneProxy = null; 48 PhoneBase phoneBase = null; 49 50 try { 51 phoneProxy = (PhoneProxy) PhoneFactory.getDefaultPhone(); 52 } catch (Exception e) { 53 pw.println("Telephony DebugService: Could not getDefaultPhone e=" + e); 54 return; 55 } 56 try { 57 phoneBase = (PhoneBase)phoneProxy.getActivePhone(); 58 } catch (Exception e) { 59 pw.println("Telephony DebugService: Could not PhoneBase e=" + e); 60 return; 61 } 62 63 /** 64 * Surround each of the sub dump's with try/catch so even 65 * if one fails we'll be able to dump the next ones. 66 */ 67 pw.println(); 68 pw.println("++++++++++++++++++++++++++++++++"); 69 pw.flush(); 70 try { 71 phoneBase.dump(fd, pw, args); 72 } catch (Exception e) { 73 e.printStackTrace(); 74 } 75 pw.flush(); 76 pw.println("++++++++++++++++++++++++++++++++"); 77 try { 78 phoneBase.mDcTracker.dump(fd, pw, args); 79 } catch (Exception e) { 80 e.printStackTrace(); 81 } 82 pw.flush(); 83 pw.println("++++++++++++++++++++++++++++++++"); 84 try { 85 phoneBase.getServiceStateTracker().dump(fd, pw, args); 86 } catch (Exception e) { 87 e.printStackTrace(); 88 } 89 pw.flush(); 90 pw.println("++++++++++++++++++++++++++++++++"); 91 try { 92 phoneBase.getCallTracker().dump(fd, pw, args); 93 } catch (Exception e) { 94 e.printStackTrace(); 95 } 96 pw.flush(); 97 pw.println("++++++++++++++++++++++++++++++++"); 98 try { 99 ((RIL)phoneBase.mCi).dump(fd, pw, args); 100 } catch (Exception e) { 101 e.printStackTrace(); 102 } 103 pw.flush(); 104 pw.println("++++++++++++++++++++++++++++++++"); 105 try { 106 UiccController.getInstance().dump(fd, pw, args); 107 } catch (Exception e) { 108 e.printStackTrace(); 109 } 110 pw.flush(); 111 pw.println("++++++++++++++++++++++++++++++++"); 112 try { 113 ((IccCardProxy)phoneProxy.getIccCard()).dump(fd, pw, args); 114 } catch (Exception e) { 115 e.printStackTrace(); 116 } 117 pw.flush(); 118 pw.println("++++++++++++++++++++++++++++++++"); 119 log("dump: -"); 120 } 121 log(String s)122 private static void log(String s) { 123 Rlog.d(TAG, "DebugService " + s); 124 } 125 } 126