From 6e8fafff7731e6a2c13342eebc9b5078b7d5021f 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. [Cherry-pick from AOSP] Bug: 27315491 Change-Id: Ic1ec5334fbf0b524909400f080e2eac3ec34edf4 --- .../android/server/BluetoothManagerService.java | 27 ++++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/services/core/java/com/android/server/BluetoothManagerService.java b/services/core/java/com/android/server/BluetoothManagerService.java index 6d0d9e9090f6..8cfeb748ccee 100644 --- a/services/core/java/com/android/server/BluetoothManagerService.java +++ b/services/core/java/com/android/server/BluetoothManagerService.java @@ -1671,16 +1671,23 @@ class BluetoothManagerService extends IBluetoothManager.Stub { } @Override - public void dump(FileDescriptor fd, PrintWriter writer, String args[]) { - mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG); - if (mBluetoothBinder == null) { - writer.println("Bluetooth Service not connected"); - } else { - try { - mBluetoothBinder.dump(fd, args); - } catch (RemoteException re) { - writer.println("RemoteException while calling Bluetooth Service"); + public void dump(FileDescriptor fd, PrintWriter writer, String[] args) { + mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG); + String errorMsg = null; + if (mBluetoothBinder == null) { + errorMsg = "Bluetooth Service not connected"; + } else { + try { + mBluetoothBinder.dump(fd, args); + } catch (RemoteException re) { + 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); } - } } } -- 2.11.0