diff options
author | Jeff Brown <jeffbrown@google.com> | 2015-07-07 12:40:53 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2015-07-15 11:34:29 -0700 |
commit | 2dbccc1926ea2d3e27c5cfd2d61d2b3d5ed787c0 (patch) | |
tree | 41c3f067057b85e532f719dea89f92c371241f80 /services/usb | |
parent | 539f7ac7a195c405987057ef34e88cfbe8eab5e8 (diff) | |
download | frameworks_base-2dbccc1926ea2d3e27c5cfd2d61d2b3d5ed787c0.zip frameworks_base-2dbccc1926ea2d3e27c5cfd2d61d2b3d5ed787c0.tar.gz frameworks_base-2dbccc1926ea2d3e27c5cfd2d61d2b3d5ed787c0.tar.bz2 |
Clean up USB Manager dump.
Tidy up the dump() implementation in preparation for further work.
Bug: 21615151
Change-Id: If6d94c8dc9457b8e93103541ec1798981eeb5b54
Diffstat (limited to 'services/usb')
6 files changed, 49 insertions, 44 deletions
diff --git a/services/usb/java/com/android/server/usb/UsbAlsaManager.java b/services/usb/java/com/android/server/usb/UsbAlsaManager.java index 638783d..31763e7 100644 --- a/services/usb/java/com/android/server/usb/UsbAlsaManager.java +++ b/services/usb/java/com/android/server/usb/UsbAlsaManager.java @@ -35,6 +35,7 @@ import android.util.Slog; import com.android.internal.alsa.AlsaCardsParser; import com.android.internal.alsa.AlsaDevicesParser; +import com.android.internal.util.IndentingPrintWriter; import com.android.server.audio.AudioService; import libcore.io.IoUtils; @@ -502,14 +503,14 @@ public final class UsbAlsaManager { // // Logging // - public void dump(FileDescriptor fd, PrintWriter pw) { - pw.println(" USB Audio Devices:"); + public void dump(IndentingPrintWriter pw) { + pw.println("USB Audio Devices:"); for (UsbDevice device : mAudioDevices.keySet()) { - pw.println(" " + device.getDeviceName() + ": " + mAudioDevices.get(device)); + pw.println(" " + device.getDeviceName() + ": " + mAudioDevices.get(device)); } - pw.println(" USB MIDI Devices:"); + pw.println("USB MIDI Devices:"); for (UsbDevice device : mMidiDevices.keySet()) { - pw.println(" " + device.getDeviceName() + ": " + mMidiDevices.get(device)); + pw.println(" " + device.getDeviceName() + ": " + mMidiDevices.get(device)); } } diff --git a/services/usb/java/com/android/server/usb/UsbDebuggingManager.java b/services/usb/java/com/android/server/usb/UsbDebuggingManager.java index 9a04e8b..ae17fde 100644 --- a/services/usb/java/com/android/server/usb/UsbDebuggingManager.java +++ b/services/usb/java/com/android/server/usb/UsbDebuggingManager.java @@ -38,6 +38,7 @@ import android.util.Base64; import android.util.Slog; import com.android.internal.R; +import com.android.internal.util.IndentingPrintWriter; import com.android.server.FgThread; import java.io.File; @@ -451,17 +452,17 @@ public class UsbDebuggingManager { mHandler.sendEmptyMessage(UsbDebuggingHandler.MESSAGE_ADB_CLEAR); } - public void dump(FileDescriptor fd, PrintWriter pw) { - pw.println(" USB Debugging State:"); - pw.println(" Connected to adbd: " + (mThread != null)); - pw.println(" Last key received: " + mFingerprints); - pw.println(" User keys:"); + public void dump(IndentingPrintWriter pw) { + pw.println("USB Debugging State:"); + pw.println(" Connected to adbd: " + (mThread != null)); + pw.println(" Last key received: " + mFingerprints); + pw.println(" User keys:"); try { pw.println(FileUtils.readTextFile(new File("/data/misc/adb/adb_keys"), 0, null)); } catch (IOException e) { pw.println("IOException: " + e); } - pw.println(" System keys:"); + pw.println(" System keys:"); try { pw.println(FileUtils.readTextFile(new File("/adb_keys"), 0, null)); } catch (IOException e) { diff --git a/services/usb/java/com/android/server/usb/UsbDeviceManager.java b/services/usb/java/com/android/server/usb/UsbDeviceManager.java index 81b4857..653cbd8 100644 --- a/services/usb/java/com/android/server/usb/UsbDeviceManager.java +++ b/services/usb/java/com/android/server/usb/UsbDeviceManager.java @@ -45,6 +45,7 @@ import android.util.Pair; import android.util.Slog; import com.android.internal.annotations.GuardedBy; +import com.android.internal.util.IndentingPrintWriter; import com.android.server.FgThread; import java.io.File; @@ -807,17 +808,17 @@ public class UsbDeviceManager { UsbManager.USB_FUNCTION_ADB); } - public void dump(FileDescriptor fd, PrintWriter pw) { - pw.println(" USB Device State:"); - pw.println(" mCurrentFunctions: " + mCurrentFunctions); - pw.println(" mCurrentFunctionsApplied: " + mCurrentFunctionsApplied); - pw.println(" mConnected: " + mConnected); - pw.println(" mConfigured: " + mConfigured); - pw.println(" mCurrentAccessory: " + mCurrentAccessory); + public void dump(IndentingPrintWriter pw) { + pw.println("USB Device State:"); + pw.println(" mCurrentFunctions: " + mCurrentFunctions); + pw.println(" mCurrentFunctionsApplied: " + mCurrentFunctionsApplied); + pw.println(" mConnected: " + mConnected); + pw.println(" mConfigured: " + mConfigured); + pw.println(" mCurrentAccessory: " + mCurrentAccessory); try { - pw.println(" Kernel state: " + pw.println(" Kernel state: " + FileUtils.readTextFile(new File(STATE_PATH), 0, null).trim()); - pw.println(" Kernel function list: " + pw.println(" Kernel function list: " + FileUtils.readTextFile(new File(FUNCTIONS_PATH), 0, null).trim()); } catch (IOException e) { pw.println("IOException: " + e); @@ -908,12 +909,12 @@ public class UsbDeviceManager { } } - public void dump(FileDescriptor fd, PrintWriter pw) { + public void dump(IndentingPrintWriter pw) { if (mHandler != null) { - mHandler.dump(fd, pw); + mHandler.dump(pw); } if (mDebuggingManager != null) { - mDebuggingManager.dump(fd, pw); + mDebuggingManager.dump(pw); } } diff --git a/services/usb/java/com/android/server/usb/UsbHostManager.java b/services/usb/java/com/android/server/usb/UsbHostManager.java index f5f2b07..6300a9a 100644 --- a/services/usb/java/com/android/server/usb/UsbHostManager.java +++ b/services/usb/java/com/android/server/usb/UsbHostManager.java @@ -27,6 +27,7 @@ import android.os.ParcelFileDescriptor; import android.util.Slog; import com.android.internal.annotations.GuardedBy; +import com.android.internal.util.IndentingPrintWriter; import java.io.FileDescriptor; import java.io.PrintWriter; @@ -283,11 +284,11 @@ public class UsbHostManager { } } - public void dump(FileDescriptor fd, PrintWriter pw) { + public void dump(IndentingPrintWriter pw) { synchronized (mLock) { - pw.println(" USB Host State:"); + pw.println("USB Host State:"); for (String name : mDevices.keySet()) { - pw.println(" " + name + ": " + mDevices.get(name)); + pw.println(" " + name + ": " + mDevices.get(name)); } } } diff --git a/services/usb/java/com/android/server/usb/UsbService.java b/services/usb/java/com/android/server/usb/UsbService.java index c8b4226..d2ab0b8 100644 --- a/services/usb/java/com/android/server/usb/UsbService.java +++ b/services/usb/java/com/android/server/usb/UsbService.java @@ -348,27 +348,27 @@ public class UsbService extends IUsbManager.Stub { @Override public void dump(FileDescriptor fd, PrintWriter writer, String[] args) { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG); - final IndentingPrintWriter pw = new IndentingPrintWriter(writer, " "); + final IndentingPrintWriter pw = new IndentingPrintWriter(writer, " "); pw.println("USB Manager State:"); + pw.increaseIndent(); if (mDeviceManager != null) { - mDeviceManager.dump(fd, pw); + mDeviceManager.dump(pw); } if (mHostManager != null) { - mHostManager.dump(fd, pw); + mHostManager.dump(pw); } - mAlsaManager.dump(fd, pw); + mAlsaManager.dump(pw); synchronized (mLock) { for (int i = 0; i < mSettingsByUser.size(); i++) { final int userId = mSettingsByUser.keyAt(i); final UsbSettingsManager settings = mSettingsByUser.valueAt(i); - pw.increaseIndent(); pw.println("Settings for user " + userId + ":"); - settings.dump(fd, pw); + pw.increaseIndent(); + settings.dump(pw); pw.decreaseIndent(); } } - pw.decreaseIndent(); } } diff --git a/services/usb/java/com/android/server/usb/UsbSettingsManager.java b/services/usb/java/com/android/server/usb/UsbSettingsManager.java index 2331a8b..2cf42f0 100644 --- a/services/usb/java/com/android/server/usb/UsbSettingsManager.java +++ b/services/usb/java/com/android/server/usb/UsbSettingsManager.java @@ -44,6 +44,7 @@ import android.util.Xml; import com.android.internal.content.PackageMonitor; import com.android.internal.util.FastXmlSerializer; +import com.android.internal.util.IndentingPrintWriter; import com.android.internal.util.XmlUtils; import org.xmlpull.v1.XmlPullParser; @@ -1193,35 +1194,35 @@ class UsbSettingsManager { } } - public void dump(FileDescriptor fd, PrintWriter pw) { + public void dump(IndentingPrintWriter pw) { synchronized (mLock) { - pw.println(" Device permissions:"); + pw.println("Device permissions:"); for (String deviceName : mDevicePermissionMap.keySet()) { - pw.print(" " + deviceName + ": "); + pw.print(" " + deviceName + ": "); SparseBooleanArray uidList = mDevicePermissionMap.get(deviceName); int count = uidList.size(); for (int i = 0; i < count; i++) { pw.print(Integer.toString(uidList.keyAt(i)) + " "); } - pw.println(""); + pw.println(); } - pw.println(" Accessory permissions:"); + pw.println("Accessory permissions:"); for (UsbAccessory accessory : mAccessoryPermissionMap.keySet()) { - pw.print(" " + accessory + ": "); + pw.print(" " + accessory + ": "); SparseBooleanArray uidList = mAccessoryPermissionMap.get(accessory); int count = uidList.size(); for (int i = 0; i < count; i++) { pw.print(Integer.toString(uidList.keyAt(i)) + " "); } - pw.println(""); + pw.println(); } - pw.println(" Device preferences:"); + pw.println("Device preferences:"); for (DeviceFilter filter : mDevicePreferenceMap.keySet()) { - pw.println(" " + filter + ": " + mDevicePreferenceMap.get(filter)); + pw.println(" " + filter + ": " + mDevicePreferenceMap.get(filter)); } - pw.println(" Accessory preferences:"); + pw.println("Accessory preferences:"); for (AccessoryFilter filter : mAccessoryPreferenceMap.keySet()) { - pw.println(" " + filter + ": " + mAccessoryPreferenceMap.get(filter)); + pw.println(" " + filter + ": " + mAccessoryPreferenceMap.get(filter)); } } } |