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

Commit 554bc800 authored by Marie Janssen's avatar Marie Janssen Committed by Android (Google) Code Review
Browse files

Merge "IBluetooth: remove dump(), support arguments"

parents 86d4372c 9db28ebe
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -104,8 +104,6 @@ interface IBluetooth
    void getActivityEnergyInfoFromController();
    BluetoothActivityEnergyInfo reportActivityInfo();

    // For dumpsys support
    void dump(in ParcelFileDescriptor fd);
    void onLeServiceUp();
    void onBrEdrDown();
}
+13 −45
Original line number Diff line number Diff line
@@ -114,13 +114,6 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
    private static final int SERVICE_IBLUETOOTH = 1;
    private static final int SERVICE_IBLUETOOTHGATT = 2;

    private static final String[] DEVICE_TYPE_NAMES = new String[] {
            "???",
            "BR/EDR",
            "LE",
            "DUAL"
        };

    private final Context mContext;
    private static int mBleAppCount = 0;

@@ -131,6 +124,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
    private final ContentResolver mContentResolver;
    private final RemoteCallbackList<IBluetoothManagerCallback> mCallbacks;
    private final RemoteCallbackList<IBluetoothStateChangeCallback> mStateChangeCallbacks;
    private IBinder mBluetoothBinder;
    private IBluetooth mBluetooth;
    private IBluetoothGatt mBluetoothGatt;
    private boolean mBinding;
@@ -242,6 +236,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub {

        mContext = context;
        mBluetooth = null;
        mBluetoothBinder = null;
        mBluetoothGatt = null;
        mBinding = false;
        mUnbinding = false;
@@ -678,6 +673,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
                }

                if (DBG) Log.d(TAG, "Sending unbind request.");
                mBluetoothBinder = null;
                mBluetooth = null;
                //Unbind
                mContext.unbindService(mConnection);
@@ -1166,6 +1162,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
                        mHandler.removeMessages(MESSAGE_TIMEOUT_BIND);

                        mBinding = false;
                        mBluetoothBinder = service;
                        mBluetooth = IBluetooth.Stub.asInterface(service);

                        try {
@@ -1674,43 +1671,14 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
    }

    @Override
    public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
        mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG);

        writer.println("Bluetooth Status");
        writer.println("  enabled: " + mEnable);
        writer.println("  state: " + mState);
        writer.println("  address: " + mAddress);
        writer.println("  name: " + mName + "\n");
        writer.flush();

        if (mBluetooth == null) {
    public void dump(FileDescriptor fd, PrintWriter writer, String args[]) {
      if (mBluetoothBinder == null) {
        writer.println("Bluetooth Service not connected");
      } else {
            ParcelFileDescriptor pfd = null;
        try {
                writer.println("Bonded devices:");
                for (BluetoothDevice device : mBluetooth.getBondedDevices()) {
                    writer.println("  " + device.getAddress() +
                            " [" + DEVICE_TYPE_NAMES[device.getType()] + "] " +
                            device.getName());
                }
                writer.flush();

                pfd = ParcelFileDescriptor.dup(fd);
                mBluetooth.dump(pfd);
          mBluetoothBinder.dump(fd, args);
        } catch (RemoteException re) {
          writer.println("RemoteException while calling Bluetooth Service");
            } catch (IOException ioe) {
                writer.println("IOException attempting to dup() fd");
            } finally {
                if (pfd != null) {
                    try {
                        pfd.close();
                    } catch (IOException ioe) {
                        writer.println("IOException attempting to close() fd");
                    }
                }
        }
      }
    }