Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 30ccade7 authored by Wink Saville's avatar Wink Saville
Browse files

Add DebugService.

This will dump the state of the telephony stack using:

  adb shell dumpsys activity service android.phone.TelephonyDebugService

The service is located in packages/app/Phone and TelephonyDebugService
instantiates DebugService and calls its dump method when asked
via the dumpsys command above.

Change-Id: I4d34c741544cafdadce2532de8b9c117a4d435a5
parent ecc395a5
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -17,6 +17,9 @@
package com.android.internal.telephony;

import android.util.Log;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
@@ -207,4 +210,19 @@ public class ApnContext {
    protected void log(String s) {
        Log.d(LOG_TAG, "[ApnContext] " + s);
    }

    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("ApnContext:");
        pw.println(" mApnType=" + mApnType);
        pw.println(" mState=" + mState);
        pw.println(" mWaitingApns=" + mWaitingApns);
        pw.println(" mWaitingApnsPermanentFailureCountDown=" +
                            mWaitingApnsPermanentFailureCountDown);
        pw.println(" mApnSetting=" + mApnSetting);
        pw.println(" mDataConnection=" + mDataConnection);
        pw.println(" mDataConnectionAc=" + mDataConnectionAc);
        pw.println(" mReason=" + mReason);
        pw.println(" mDataEnabled=" + mDataEnabled);
        pw.println(" mDependencyMet=" + mDependencyMet);
    }
}
+9 −0
Original line number Diff line number Diff line
@@ -25,6 +25,9 @@ import android.util.Log;

import com.android.internal.telephony.CommandException;

import java.io.FileDescriptor;
import java.io.PrintWriter;


/**
 * {@hide}
@@ -170,4 +173,10 @@ public abstract class CallTracker extends Handler {

    protected abstract void log(String msg);

    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("CallTracker:");
        pw.println(" pendingOperations=" + pendingOperations);
        pw.println(" needsPoll=" + needsPoll);
        pw.println(" lastRelevantPoll=" + lastRelevantPoll);
    }
}
+25 −0
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@ import android.os.Message;
import android.os.SystemProperties;
import android.text.TextUtils;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -1185,4 +1187,27 @@ public abstract class DataConnection extends StateMachine {
        sendMessage(obtainMessage(EVENT_DISCONNECT_ALL,
                new DisconnectParams(reason, onCompletedMsg)));
    }

    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("DataConnection name=" + getName() + ":");
        pw.println(" mApnList=" + mApnList);
        pw.println(" mDataConnectionTracker=" + mDataConnectionTracker);
        pw.println(" mApn=" + mApn);
        pw.println(" mTag=" + mTag);
        pw.println(" phone=" + phone);
        pw.println(" mRilVersion=" + mRilVersion);
        pw.println(" cid=" + cid);
        pw.println(" mLinkProperties=" + mLinkProperties);
        pw.println(" mCapabilities=" + mCapabilities);
        pw.println(" createTime=" + createTime);
        pw.println(" lastFailTime=" + lastFailTime);
        pw.println(" lastFailCause=" + lastFailCause);
        pw.println(" mRetryOverride=" + mRetryOverride);
        pw.println(" mRefCount=" + mRefCount);
        pw.println(" userData=" + userData);
        pw.println(" total messages=" + getProcessedMessagesCount());
        for (int i=0; i < getProcessedMessagesSize(); i++) {
            pw.printf("  msg[%d]=%s\n", i, getProcessedMessageInfo(i));
        }
    }
}
+80 −0
Original line number Diff line number Diff line
@@ -49,8 +49,12 @@ import com.android.internal.telephony.DataConnection.FailCause;
import com.android.internal.util.AsyncChannel;
import com.android.internal.util.Protocol;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;

@@ -1193,4 +1197,80 @@ public abstract class DataConnectionTracker extends Handler {
            dc.resetRetryCount();
        }
    }

    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("DataConnectionTracker:");
        pw.println(" mInternalDataEnabled=" + mInternalDataEnabled);
        pw.println(" mUserDataEnabled=" + mUserDataEnabled);
        pw.println(" sPolicyDataEnabed=" + sPolicyDataEnabled);
        pw.println(" dataEnabled:");
        for(int i=0; i < dataEnabled.length; i++) {
            pw.printf("  dataEnabled[%d]=%b\n", i, dataEnabled[i]);
        }
        pw.flush();
        pw.println(" enabledCount=" + enabledCount);
        pw.println(" mRequestedApnType=" + mRequestedApnType);
        pw.println(" mPhone=" + mPhone.getPhoneName());
        pw.println(" mActivity=" + mActivity);
        pw.println(" mState=" + mState);
        pw.println(" mTxPkts=" + mTxPkts);
        pw.println(" mRxPkts=" + mRxPkts);
        pw.println(" mNetStatPollPeriod=" + mNetStatPollPeriod);
        pw.println(" mNetStatPollEnabled=" + mNetStatPollEnabled);
        pw.println(" mDataStallTxRxSum=" + mDataStallTxRxSum);
        pw.println(" mDataStallAlarmTag=" + mDataStallAlarmTag);
        pw.println(" mSentSinceLastRecv=" + mSentSinceLastRecv);
        pw.println(" mNoRecvPollCount=" + mNoRecvPollCount);
        pw.println(" mIsWifiConnected=" + mIsWifiConnected);
        pw.println(" mReconnectIntent=" + mReconnectIntent);
        pw.println(" mCidActive=" + mCidActive);
        pw.println(" mAutoAttachOnCreation=" + mAutoAttachOnCreation);
        pw.println(" mIsScreenOn=" + mIsScreenOn);
        pw.println(" mUniqueIdGenerator=" + mUniqueIdGenerator);
        pw.flush();
        pw.println(" ***************************************");
        Set<Entry<Integer, DataConnection> > mDcSet = mDataConnections.entrySet();
        pw.println(" mDataConnections: count=" + mDcSet.size());
        for (Entry<Integer, DataConnection> entry : mDcSet) {
            pw.printf(" *** mDataConnection[%d] \n", entry.getKey());
            entry.getValue().dump(fd, pw, args);
        }
        pw.println(" ***************************************");
        pw.flush();
        Set<Entry<String, Integer>> mApnToDcIdSet = mApnToDataConnectionId.entrySet();
        pw.println(" mApnToDataConnectonId size=" + mApnToDcIdSet.size());
        for (Entry<String, Integer> entry : mApnToDcIdSet) {
            pw.printf(" mApnToDataConnectonId[%s]=%d\n", entry.getKey(), entry.getValue());
        }
        pw.println(" ***************************************");
        pw.flush();
        if (mApnContexts != null) {
            Set<Entry<String, ApnContext>> mApnContextsSet = mApnContexts.entrySet();
            pw.println(" mApnContexts size=" + mApnContextsSet.size());
            for (Entry<String, ApnContext> entry : mApnContextsSet) {
                pw.printf(" *** mApnContexts[%s]:\n", entry.getKey());
                entry.getValue().dump(fd, pw, args);
            }
            pw.println(" ***************************************");
        } else {
            pw.println(" mApnContexts=null");
        }
        pw.flush();
        pw.println(" mActiveApn=" + mActiveApn);
        if (mAllApns != null) {
            pw.println(" mAllApns size=" + mAllApns.size());
            for (int i=0; i < mAllApns.size(); i++) {
                pw.printf(" mAllApns[%d]: %s\n", i, mAllApns.get(i));
            }
            pw.flush();
        } else {
            pw.println(" mAllApns=null");
        }
        pw.println(" mPreferredApn=" + mPreferredApn);
        pw.println(" mIsPsRestricted=" + mIsPsRestricted);
        pw.println(" mIsDisposed=" + mIsDisposed);
        pw.println(" mIntentReceiver=" + mIntentReceiver);
        pw.println(" mDataRoamingSettingObserver=" + mDataRoamingSettingObserver);
        pw.flush();
    }
}
+108 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2012 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.internal.telephony;

import android.util.Log;

import java.io.FileDescriptor;
import java.io.PrintWriter;

/**
 * A debug service that will dump telephony's state
 *
 * Currently this "Service" has a proxy in the phone app
 * com.android.phone.TelephonyDebugService which actually
 * invokes the dump method.
 */
public class DebugService {
    private static String TAG = "DebugService";

    /** Constructor */
    public DebugService() {
        log("DebugService:");
    }

    /**
     * Dump the state of various objects, add calls to other objects as desired.
     */
    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        log("dump: +");
        PhoneProxy phoneProxy = null;
        PhoneBase phoneBase = null;

        try {
            phoneProxy = (PhoneProxy) PhoneFactory.getDefaultPhone();
        } catch (Exception e) {
            pw.println("Telephony DebugService: Could not getDefaultPhone e=" + e);
            return;
        }
        try {
            phoneBase = (PhoneBase)phoneProxy.getActivePhone();
        } catch (Exception e) {
            pw.println("Telephony DebugService: Could not PhoneBase e=" + e);
            return;
        }

        /**
         * Surround each of the sub dump's with try/catch so even
         * if one fails we'll be able to dump the next ones.
         */
        pw.println();
        pw.println("++++++++++++++++++++++++++++++++");
        pw.flush();
        try {
            phoneBase.dump(fd, pw, args);
        } catch (Exception e) {
            e.printStackTrace();
        }
        pw.flush();
        pw.println("++++++++++++++++++++++++++++++++");
        try {
            phoneBase.mDataConnectionTracker.dump(fd, pw, args);
        } catch (Exception e) {
            e.printStackTrace();
        }
        pw.flush();
        pw.println("++++++++++++++++++++++++++++++++");
        try {
            phoneBase.getServiceStateTracker().dump(fd, pw, args);
        } catch (Exception e) {
            e.printStackTrace();
        }
        pw.flush();
        pw.println("++++++++++++++++++++++++++++++++");
        try {
            phoneBase.getCallTracker().dump(fd, pw, args);
        } catch (Exception e) {
            e.printStackTrace();
        }
        pw.flush();
        pw.println("++++++++++++++++++++++++++++++++");
        try {
            ((RIL)phoneBase.mCM).dump(fd, pw, args);
        } catch (Exception e) {
            e.printStackTrace();
        }
        pw.flush();
        pw.println("++++++++++++++++++++++++++++++++");
        log("dump: -");
    }

    private static void log(String s) {
        Log.d(TAG, "DebugService " + s);
    }
}
Loading