From 61a94d47776a22f479ecb0652140bf1b501c2f5b Mon Sep 17 00:00:00 2001 From: Pavlin Radoslavov Date: Tue, 23 Feb 2016 11:54:37 -0800 Subject: [PATCH] Suppress output for Protobuf data if Bluetooth is disabled If Bluetooth is disabled or there is some other error, don't print anything when extracting the Metrics-related data in Protobuf format. Bug: 27315491 Change-Id: Ic1ec5334fbf0b524909400f080e2eac3ec34edf4 --- .../com/android/server/BluetoothManagerService.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/BluetoothManagerService.java b/services/core/java/com/android/server/BluetoothManagerService.java index a2b1aa84418b6..1e91a2c3a28db 100644 --- a/services/core/java/com/android/server/BluetoothManagerService.java +++ b/services/core/java/com/android/server/BluetoothManagerService.java @@ -1831,14 +1831,21 @@ class BluetoothManagerService extends IBluetoothManager.Stub { @Override public void dump(FileDescriptor fd, PrintWriter writer, String[] args) { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG); + String errorMsg = null; if (mBluetoothBinder == null) { - writer.println("Bluetooth Service not connected"); + errorMsg = "Bluetooth Service not connected"; } else { try { mBluetoothBinder.dump(fd, args); } catch (RemoteException re) { - writer.println("RemoteException while calling Bluetooth Service"); + errorMsg = "RemoteException while calling Bluetooth Service"; } } + if (errorMsg != null) { + // Silently return if we are extracting metrics in Protobuf format + if ((args.length > 0) && args[0].startsWith("--proto")) + return; + writer.println(errorMsg); + } } }