diff options
17 files changed, 261 insertions, 8 deletions
diff --git a/src/com/android/bluetooth/a2dp/A2dpService.java b/src/com/android/bluetooth/a2dp/A2dpService.java index 808ec9890..bae637398 100755 --- a/src/com/android/bluetooth/a2dp/A2dpService.java +++ b/src/com/android/bluetooth/a2dp/A2dpService.java @@ -297,4 +297,15 @@ public class A2dpService extends ProfileService { return service.isA2dpPlaying(device); } }; + + @Override + public void dump(StringBuilder sb) { + super.dump(sb); + if (mStateMachine != null) { + mStateMachine.dump(sb); + } + if (mAvrcp != null) { + mAvrcp.dump(sb); + } + } } diff --git a/src/com/android/bluetooth/a2dp/A2dpSinkService.java b/src/com/android/bluetooth/a2dp/A2dpSinkService.java index bd27952d2..5dcec7347 100644 --- a/src/com/android/bluetooth/a2dp/A2dpSinkService.java +++ b/src/com/android/bluetooth/a2dp/A2dpSinkService.java @@ -210,4 +210,12 @@ public class A2dpSinkService extends ProfileService { return service.getAudioConfig(device); } }; + + @Override + public void dump(StringBuilder sb) { + super.dump(sb); + if (mStateMachine != null) { + mStateMachine.dump(sb); + } + } } diff --git a/src/com/android/bluetooth/a2dp/A2dpSinkStateMachine.java b/src/com/android/bluetooth/a2dp/A2dpSinkStateMachine.java index 929676fdf..d57a0ca95 100644 --- a/src/com/android/bluetooth/a2dp/A2dpSinkStateMachine.java +++ b/src/com/android/bluetooth/a2dp/A2dpSinkStateMachine.java @@ -156,7 +156,14 @@ final class A2dpSinkStateMachine extends StateMachine { mAudioConfigs.clear(); } - private class Disconnected extends State { + public void dump(StringBuilder sb) { + ProfileService.println(sb, "mCurrentDevice: " + mCurrentDevice); + ProfileService.println(sb, "mTargetDevice: " + mTargetDevice); + ProfileService.println(sb, "mIncomingDevice: " + mIncomingDevice); + ProfileService.println(sb, "StateMachine: " + this.toString()); + } + + private class Disconnected extends State { @Override public void enter() { log("Enter Disconnected: " + getCurrentMessage().what); diff --git a/src/com/android/bluetooth/a2dp/A2dpStateMachine.java b/src/com/android/bluetooth/a2dp/A2dpStateMachine.java index 94cc391a1..19d4ebdde 100755 --- a/src/com/android/bluetooth/a2dp/A2dpStateMachine.java +++ b/src/com/android/bluetooth/a2dp/A2dpStateMachine.java @@ -134,7 +134,6 @@ final class A2dpStateMachine extends StateMachine { mIntentBroadcastHandler = new IntentBroadcastHandler(); mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); - } static A2dpStateMachine make(A2dpService svc, Context context) { @@ -753,6 +752,13 @@ final class A2dpStateMachine extends StateMachine { } } + public void dump(StringBuilder sb) { + ProfileService.println(sb, "mCurrentDevice: " + mCurrentDevice); + ProfileService.println(sb, "mTargetDevice: " + mTargetDevice); + ProfileService.println(sb, "mIncomingDevice: " + mIncomingDevice); + ProfileService.println(sb, "mPlayingA2dpDevice: " + mPlayingA2dpDevice); + ProfileService.println(sb, "StateMachine: " + this.toString()); + } // Event types for STACK_EVENT message final private static int EVENT_TYPE_NONE = 0; diff --git a/src/com/android/bluetooth/avrcp/Avrcp.java b/src/com/android/bluetooth/avrcp/Avrcp.java index 618ff8f33..f514b6cdf 100755 --- a/src/com/android/bluetooth/avrcp/Avrcp.java +++ b/src/com/android/bluetooth/avrcp/Avrcp.java @@ -832,6 +832,33 @@ public final class Avrcp { mHandler.sendMessage(msg); } + public void dump(StringBuilder sb) { + sb.append("AVRCP:\n"); + ProfileService.println(sb, "mMetadata: " + mMetadata); + ProfileService.println(sb, "mTransportControlFlags: " + mTransportControlFlags); + ProfileService.println(sb, "mCurrentPlayState: " + mCurrentPlayState); + ProfileService.println(sb, "mPlayStatusChangedNT: " + mPlayStatusChangedNT); + ProfileService.println(sb, "mTrackChangedNT: " + mTrackChangedNT); + ProfileService.println(sb, "mTrackNumber: " + mTrackNumber); + ProfileService.println(sb, "mCurrentPosMs: " + mCurrentPosMs); + ProfileService.println(sb, "mPlayStartTimeMs: " + mPlayStartTimeMs); + ProfileService.println(sb, "mSongLengthMs: " + mSongLengthMs); + ProfileService.println(sb, "mPlaybackIntervalMs: " + mPlaybackIntervalMs); + ProfileService.println(sb, "mPlayPosChangedNT: " + mPlayPosChangedNT); + ProfileService.println(sb, "mNextPosMs: " + mNextPosMs); + ProfileService.println(sb, "mPrevPosMs: " + mPrevPosMs); + ProfileService.println(sb, "mSkipStartTime: " + mSkipStartTime); + ProfileService.println(sb, "mFeatures: " + mFeatures); + ProfileService.println(sb, "mAbsoluteVolume: " + mAbsoluteVolume); + ProfileService.println(sb, "mLastSetVolume: " + mLastSetVolume); + ProfileService.println(sb, "mLastDirection: " + mLastDirection); + ProfileService.println(sb, "mVolumeStep: " + mVolumeStep); + ProfileService.println(sb, "mAudioStreamMax: " + mAudioStreamMax); + ProfileService.println(sb, "mVolCmdInProgress: " + mVolCmdInProgress); + ProfileService.println(sb, "mAbsVolRetryTimes: " + mAbsVolRetryTimes); + ProfileService.println(sb, "mSkipAmount: " + mSkipAmount); + } + // Do not modify without updating the HAL bt_rc.h files. // match up with btrc_play_status_t enum of bt_rc.h diff --git a/src/com/android/bluetooth/avrcp/AvrcpControllerService.java b/src/com/android/bluetooth/avrcp/AvrcpControllerService.java index b7275d694..0c7e0b6cb 100644 --- a/src/com/android/bluetooth/avrcp/AvrcpControllerService.java +++ b/src/com/android/bluetooth/avrcp/AvrcpControllerService.java @@ -265,6 +265,11 @@ public class AvrcpControllerService extends ProfileService { return Utils.getBytesFromAddress(device.getAddress()); } + @Override + public void dump(StringBuilder sb) { + super.dump(sb); + } + private native static void classInitNative(); private native void initNative(); private native void cleanupNative(); diff --git a/src/com/android/bluetooth/btservice/AdapterService.java b/src/com/android/bluetooth/btservice/AdapterService.java index 9141d3eb8..ca2ff19c7 100644 --- a/src/com/android/bluetooth/btservice/AdapterService.java +++ b/src/com/android/bluetooth/btservice/AdapterService.java @@ -93,6 +93,8 @@ public class AdapterService extends Service { private int mIdleTimeTotalMs; private int mEnergyUsedTotalVoltAmpSecMicro; + private final ArrayList<ProfileService> mProfiles = new ArrayList<ProfileService>(); + public static final String ACTION_LOAD_ADAPTER_PROPERTIES = "com.android.bluetooth.btservice.action.LOAD_ADAPTER_PROPERTIES"; public static final String ACTION_SERVICE_STATE_CHANGED = @@ -257,6 +259,18 @@ public class AdapterService extends Service { } } + public void addProfile(ProfileService profile) { + synchronized (mProfiles) { + mProfiles.add(profile); + } + } + + public void removeProfile(ProfileService profile) { + synchronized (mProfiles) { + mProfiles.remove(profile); + } + } + public void onProfileServiceStateChanged(String serviceName, int state) { Message m = mHandler.obtainMessage(MESSAGE_PROFILE_SERVICE_STATE_CHANGED); m.obj=serviceName; @@ -1114,6 +1128,14 @@ public class AdapterService extends Service { if (service == null) return null; return service.reportActivityInfo(); } + + public String dump() { + AdapterService service = getService(); + if (service == null) { + return "AdapterService is null"; + } + return service.dump(); + } }; @@ -1696,6 +1718,16 @@ public class AdapterService extends Service { return info; } + private String dump() { + StringBuilder sb = new StringBuilder(); + synchronized (mProfiles) { + for (ProfileService profile : mProfiles) { + profile.dump(sb); + } + } + return sb.toString(); + } + private static int convertScanModeToHal(int mode) { switch (mode) { case BluetoothAdapter.SCAN_MODE_NONE: diff --git a/src/com/android/bluetooth/btservice/ProfileService.java b/src/com/android/bluetooth/btservice/ProfileService.java index 0c1b70e3f..1dcb7fb25 100644 --- a/src/com/android/bluetooth/btservice/ProfileService.java +++ b/src/com/android/bluetooth/btservice/ProfileService.java @@ -53,6 +53,8 @@ public abstract class ProfileService extends Service { protected boolean mStartError=false; private boolean mCleaningUp = false; + private AdapterService mAdapterService; + protected String getName() { return getClass().getSimpleName(); } @@ -105,6 +107,8 @@ public abstract class ProfileService extends Service { super.onCreate(); mAdapter = BluetoothAdapter.getDefaultAdapter(); mBinder = initBinder(); + mAdapterService = AdapterService.getAdapterService(); + mAdapterService.addProfile(this); } public int onStartCommand(Intent intent, int flags, int startId) { @@ -149,9 +153,22 @@ public abstract class ProfileService extends Service { return super.onUnbind(intent); } + // for dumpsys support + public void dump(StringBuilder sb) { + sb.append("Profile: " + mName + "\n"); + } + + // with indenting for subclasses + public static void println(StringBuilder sb, String s) { + sb.append(" "); + sb.append(s); + sb.append("\n"); + } + @Override public void onDestroy() { if (DBG) log("Destroying service."); + mAdapterService.removeProfile(this); if (mCleaningUp) { if (DBG) log("Cleanup already started... Skipping cleanup()..."); } else { @@ -194,17 +211,15 @@ public abstract class ProfileService extends Service { protected void notifyProfileServiceStateChanged(int state) { //Notify adapter service - AdapterService sAdapter = AdapterService.getAdapterService(); - if (sAdapter!= null) { - sAdapter.onProfileServiceStateChanged(getClass().getName(), state); + if (mAdapterService != null) { + mAdapterService.onProfileServiceStateChanged(getClass().getName(), state); } } public void notifyProfileConnectionStateChanged(BluetoothDevice device, int profileId, int newState, int prevState) { - AdapterService svc = AdapterService.getAdapterService(); - if (svc != null) { - svc.onProfileConnectionStateChanged(device, profileId, newState, prevState); + if (mAdapterService != null) { + mAdapterService.onProfileConnectionStateChanged(device, profileId, newState, prevState); } } diff --git a/src/com/android/bluetooth/gatt/GattService.java b/src/com/android/bluetooth/gatt/GattService.java index b2bccb50c..ce257d69a 100644 --- a/src/com/android/bluetooth/gatt/GattService.java +++ b/src/com/android/bluetooth/gatt/GattService.java @@ -2180,6 +2180,24 @@ public class GattService extends ProfileService { return uuids; } + @Override + public void dump(StringBuilder sb) { + super.dump(sb); + println(sb, "mAdvertisingServiceUuids:"); + for (UUID uuid : mAdvertisingServiceUuids) { + println(sb, " " + uuid); + } + println(sb, "mOnFoundResults:"); + for (ScanResult result : mOnFoundResults.values()) { + println(sb, " " + result); + } + println(sb, "mOnFoundResults:"); + for (ServiceDeclaration declaration : mServiceDeclarations) { + println(sb, " " + declaration); + } + println(sb, "mMaxScanFilters: " + mMaxScanFilters); + } + /************************************************************************** * GATT Test functions *************************************************************************/ diff --git a/src/com/android/bluetooth/hdp/HealthService.java b/src/com/android/bluetooth/hdp/HealthService.java index 21846c677..8d8eff7f0 100644 --- a/src/com/android/bluetooth/hdp/HealthService.java +++ b/src/com/android/bluetooth/hdp/HealthService.java @@ -788,6 +788,23 @@ public class HealthService extends ProfileService { return healthDevices; } + @Override + public void dump(StringBuilder sb) { + super.dump(sb); + println(sb, "mHealthChannels:"); + for (HealthChannel channel : mHealthChannels) { + println(sb, " " + channel); + } + println(sb, "mApps:"); + for (BluetoothHealthAppConfiguration conf : mApps.keySet()) { + println(sb, " " + conf + " : " + mApps.get(conf)); + } + println(sb, "mHealthDevices:"); + for (BluetoothDevice device : mHealthDevices.keySet()) { + println(sb, " " + device + " : " + mHealthDevices.get(device)); + } + } + private static class AppInfo { private IBluetoothHealthCallback mCallback; private BluetoothHealthDeathRecipient mRcpObj; diff --git a/src/com/android/bluetooth/hfp/HeadsetService.java b/src/com/android/bluetooth/hfp/HeadsetService.java index ae2954e56..0755c357a 100755 --- a/src/com/android/bluetooth/hfp/HeadsetService.java +++ b/src/com/android/bluetooth/hfp/HeadsetService.java @@ -557,4 +557,11 @@ public class HeadsetService extends ProfileService { return true; } + @Override + public void dump(StringBuilder sb) { + super.dump(sb); + if (mStateMachine != null) { + mStateMachine.dump(sb); + } + } } diff --git a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java index c7c2fcd36..ba8f80a94 100644 --- a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java +++ b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java @@ -58,6 +58,7 @@ import android.telephony.PhoneNumberUtils; import android.util.Log; import com.android.bluetooth.Utils; import com.android.bluetooth.btservice.AdapterService; +import com.android.bluetooth.btservice.ProfileService; import com.android.internal.util.IState; import com.android.internal.util.State; import com.android.internal.util.StateMachine; @@ -297,6 +298,20 @@ final class HeadsetStateMachine extends StateMachine { } } + public void dump(StringBuilder sb) { + ProfileService.println(sb, "mCurrentDevice: " + mCurrentDevice); + ProfileService.println(sb, "mTargetDevice: " + mTargetDevice); + ProfileService.println(sb, "mIncomingDevice: " + mIncomingDevice); + ProfileService.println(sb, "mActiveScoDevice: " + mActiveScoDevice); + ProfileService.println(sb, "mMultiDisconnectDevice: " + mMultiDisconnectDevice); + ProfileService.println(sb, "mVirtualCallStarted: " + mVirtualCallStarted); + ProfileService.println(sb, "mVoiceRecognitionStarted: " + mVoiceRecognitionStarted); + ProfileService.println(sb, "mWaitingForVoiceRecognition: " + mWaitingForVoiceRecognition); + ProfileService.println(sb, "StateMachine: " + this.toString()); + ProfileService.println(sb, "mPhoneState: " + mPhoneState); + ProfileService.println(sb, "mAudioState: " + mAudioState); + } + private class Disconnected extends State { @Override public void enter() { diff --git a/src/com/android/bluetooth/hfpclient/HeadsetClientService.java b/src/com/android/bluetooth/hfpclient/HeadsetClientService.java index aaf715665..d7eb12d91 100644 --- a/src/com/android/bluetooth/hfpclient/HeadsetClientService.java +++ b/src/com/android/bluetooth/hfpclient/HeadsetClientService.java @@ -734,4 +734,12 @@ public class HeadsetClientService extends ProfileService { } return mStateMachine.getCurrentAgFeatures(); } + + @Override + public void dump(StringBuilder sb) { + super.dump(sb); + if (mStateMachine != null) { + mStateMachine.dump(sb); + } + } } diff --git a/src/com/android/bluetooth/hfpclient/HeadsetClientStateMachine.java b/src/com/android/bluetooth/hfpclient/HeadsetClientStateMachine.java index d50602acf..b3e4b0ae9 100644 --- a/src/com/android/bluetooth/hfpclient/HeadsetClientStateMachine.java +++ b/src/com/android/bluetooth/hfpclient/HeadsetClientStateMachine.java @@ -158,6 +158,35 @@ final class HeadsetClientStateMachine extends StateMachine { classInitNative(); } + public void dump(StringBuilder sb) { + ProfileService.println(sb, "mCurrentDevice: " + mCurrentDevice); + ProfileService.println(sb, "mAudioOn: " + mAudioOn); + ProfileService.println(sb, "mAudioState: " + mAudioState); + ProfileService.println(sb, "mAudioWbs: " + mAudioWbs); + ProfileService.println(sb, "mIndicatorNetworkState: " + mIndicatorNetworkState); + ProfileService.println(sb, "mIndicatorNetworkType: " + mIndicatorNetworkType); + ProfileService.println(sb, "mIndicatorNetworkSignal: " + mIndicatorNetworkSignal); + ProfileService.println(sb, "mIndicatorBatteryLevel: " + mIndicatorBatteryLevel); + ProfileService.println(sb, "mIndicatorCall: " + mIndicatorCall); + ProfileService.println(sb, "mIndicatorCallSetup: " + mIndicatorCallSetup); + ProfileService.println(sb, "mIndicatorCallHeld: " + mIndicatorCallHeld); + ProfileService.println(sb, "mVgsFromStack: " + mVgsFromStack); + ProfileService.println(sb, "mVgmFromStack: " + mVgmFromStack); + ProfileService.println(sb, "mRingtone: " + mRingtone); + ProfileService.println(sb, "mOperatorName: " + mOperatorName); + ProfileService.println(sb, "mSubscriberInfo: " + mSubscriberInfo); + ProfileService.println(sb, "mVoiceRecognitionActive: " + mVoiceRecognitionActive); + ProfileService.println(sb, "mInBandRingtone: " + mInBandRingtone); + ProfileService.println(sb, "mCalls:"); + for (BluetoothHeadsetClientCall call : mCalls.values()) { + ProfileService.println(sb, " " + call); + } + ProfileService.println(sb, "mCallsUpdate:"); + for (BluetoothHeadsetClientCall call : mCallsUpdate.values()) { + ProfileService.println(sb, " " + call); + } + } + private void clearPendingAction() { mPendingAction = new Pair<Integer, Object>(NO_ACTION, 0); } diff --git a/src/com/android/bluetooth/hid/HidService.java b/src/com/android/bluetooth/hid/HidService.java index 219332e94..418c13b7d 100755 --- a/src/com/android/bluetooth/hid/HidService.java +++ b/src/com/android/bluetooth/hid/HidService.java @@ -680,6 +680,16 @@ public class HidService extends ProfileService { } } + @Override + public void dump(StringBuilder sb) { + super.dump(sb); + println(sb, "mTargetDevice: " + mTargetDevice); + println(sb, "mInputDevices:"); + for (BluetoothDevice device : mInputDevices.keySet()) { + println(sb, " " + device + " : " + mInputDevices.get(device)); + } + } + // Constants matching Hal header file bt_hh.h // bthh_connection_state_t private final static int CONN_STATE_CONNECTED = 0; diff --git a/src/com/android/bluetooth/map/BluetoothMapService.java b/src/com/android/bluetooth/map/BluetoothMapService.java index f016fb162..e407bbf26 100755 --- a/src/com/android/bluetooth/map/BluetoothMapService.java +++ b/src/com/android/bluetooth/map/BluetoothMapService.java @@ -1084,4 +1084,26 @@ public class BluetoothMapService extends ProfileService { return service.getPriority(device); } } + + @Override + public void dump(StringBuilder sb) { + super.dump(sb); + println(sb, "mRemoteDevice: " + mRemoteDevice); + println(sb, "sRemoteDeviceName: " + sRemoteDeviceName); + println(sb, "mState: " + mState); + println(sb, "mAppObserver: " + mAppObserver); + println(sb, "mIsWaitingAuthorization: " + mIsWaitingAuthorization); + println(sb, "mRemoveTimeoutMsg: " + mRemoveTimeoutMsg); + println(sb, "mPermission: " + mPermission); + println(sb, "mAccountChanged: " + mAccountChanged); + println(sb, "mBluetoothMnsObexClient: " + mBluetoothMnsObexClient); + println(sb, "mMasInstanceMap:"); + for (BluetoothMapEmailSettingsItem key : mMasInstanceMap.keySet()) { + println(sb, " " + key + " : " + mMasInstanceMap.get(key)); + } + println(sb, "mEnabledAccounts:"); + for (BluetoothMapEmailSettingsItem account : mEnabledAccounts) { + println(sb, " " + account); + } + } } diff --git a/src/com/android/bluetooth/pan/PanService.java b/src/com/android/bluetooth/pan/PanService.java index 5d1bc308a..3b484284e 100755 --- a/src/com/android/bluetooth/pan/PanService.java +++ b/src/com/android/bluetooth/pan/PanService.java @@ -576,6 +576,22 @@ public class PanService extends ProfileService { return panDevice.mState; } + @Override + public void dump(StringBuilder sb) { + super.dump(sb); + println(sb, "mMaxPanDevices: " + mMaxPanDevices); + println(sb, "mPanIfName: " + mPanIfName); + println(sb, "mTetherOn: " + mTetherOn); + println(sb, "mPanDevices:"); + for (BluetoothDevice device : mPanDevices.keySet()) { + println(sb, " " + device + " : " + mPanDevices.get(device)); + } + println(sb, "mBluetoothIfaceAddresses:"); + for (String address : mBluetoothIfaceAddresses) { + println(sb, " " + address); + } + } + private class BluetoothPanDevice { private int mState; private String mIfaceAddr; |