Skip to content

Commit

Permalink
IBluetooth: remove dump(), support arguments
Browse files Browse the repository at this point in the history
Because IBluetooth is a Binder service, we don't need dump() to
support dumpsys, just call the IBinder.dump().

Change-Id: Idcd48f758427b824e0b7eaafd091ba3fb2ff8993
(cherry picked from commit adbb3ff)
  • Loading branch information
jamuraa committed Jan 26, 2016
1 parent 5d269c7 commit 9db28eb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 47 deletions.
2 changes: 0 additions & 2 deletions core/java/android/bluetooth/IBluetooth.aidl
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ interface IBluetooth
void getActivityEnergyInfoFromController();
BluetoothActivityEnergyInfo reportActivityInfo();

// For dumpsys support
void dump(in ParcelFileDescriptor fd);
void onLeServiceUp();
void onBrEdrDown();
}
58 changes: 13 additions & 45 deletions services/core/java/com/android/server/BluetoothManagerService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -242,6 +236,7 @@ public void onReceive(Context context, Intent intent) {

mContext = context;
mBluetooth = null;
mBluetoothBinder = null;
mBluetoothGatt = null;
mBinding = false;
mUnbinding = false;
Expand Down Expand Up @@ -678,6 +673,7 @@ public void unbindAndFinish() {
}

if (DBG) Log.d(TAG, "Sending unbind request.");
mBluetoothBinder = null;
mBluetooth = null;
//Unbind
mContext.unbindService(mConnection);
Expand Down Expand Up @@ -1166,6 +1162,7 @@ public void handleMessage(Message msg) {
mHandler.removeMessages(MESSAGE_TIMEOUT_BIND);

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

try {
Expand Down Expand Up @@ -1674,44 +1671,15 @@ private void recoverBluetoothServiceFromError() {
}

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

0 comments on commit 9db28eb

Please sign in to comment.