Merge "DO NOT MERGE ANYWHERE Bluetooth native dumpsys logging support (3/4)" into lmp-mr1-modular-dev

This commit is contained in:
Tucker Sylvestro
2015-03-05 00:15:06 +00:00
committed by Android (Google) Code Review
2 changed files with 16 additions and 7 deletions

View File

@@ -99,6 +99,6 @@ interface IBluetooth
void getActivityEnergyInfoFromController(); void getActivityEnergyInfoFromController();
BluetoothActivityEnergyInfo reportActivityInfo(); BluetoothActivityEnergyInfo reportActivityInfo();
// for dumpsys support // For dumpsys support
String dump(); void dump(in ParcelFileDescriptor fd);
} }

View File

@@ -41,6 +41,7 @@ import android.os.Handler;
import android.os.IBinder; import android.os.IBinder;
import android.os.Looper; import android.os.Looper;
import android.os.Message; import android.os.Message;
import android.os.ParcelFileDescriptor;
import android.os.Process; import android.os.Process;
import android.os.RemoteCallbackList; import android.os.RemoteCallbackList;
import android.os.RemoteException; import android.os.RemoteException;
@@ -51,6 +52,7 @@ import android.provider.Settings;
import android.util.Log; import android.util.Log;
import java.io.FileDescriptor; import java.io.FileDescriptor;
import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.HashMap; import java.util.HashMap;
@@ -1523,17 +1525,24 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
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); mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG);
writer.println("Bluetooth Status");
writer.println(" enabled: " + mEnable); writer.println(" enabled: " + mEnable);
writer.println(" state: " + mState); writer.println(" state: " + mState);
writer.println(" address: " + mAddress); writer.println(" address: " + mAddress);
writer.println("name: " + mName); writer.println(" name: " + mName + "\n");
writer.flush();
if (mBluetooth == null) { if (mBluetooth == null) {
writer.println("Bluetooth Service not connected"); writer.println("Bluetooth Service not connected");
} else { } else {
try { try {
writer.println(mBluetooth.dump()); ParcelFileDescriptor pfd = ParcelFileDescriptor.dup(fd);
mBluetooth.dump(pfd);
pfd.close();
} catch (RemoteException re) { } catch (RemoteException re) {
writer.println("RemoteException while calling Bluetooth Service"); writer.println("RemoteException while calling Bluetooth Service");
} catch (IOException re) {
writer.println("IOException attempting to dup() fd");
} }
} }
} }