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

Commit 6e8fafff authored by Pavlin Radoslavov's avatar Pavlin Radoslavov
Browse files

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
parent 8a6aea04
Loading
Loading
Loading
Loading
+17 −10
Original line number Diff line number Diff line
@@ -1671,16 +1671,23 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
    }

    @Override
    public void dump(FileDescriptor fd, PrintWriter writer, String args[]) {
    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);
        }
    }
}