return result;
}
-static void dumpNative(JNIEnv *env, jobject obj, jobject fdObj)
+static void dumpNative(JNIEnv *env, jobject obj, jobject fdObj,
+ jobjectArray argArray)
{
ALOGV("%s()", __FUNCTION__);
if (!sBluetoothInterface) return;
int fd = jniGetFDFromFileDescriptor(env, fdObj);
if (fd < 0) return;
- sBluetoothInterface->dump(fd);
+ int numArgs = env->GetArrayLength(argArray);
+
+ jstring *argObjs = new jstring[numArgs];
+ const char **args = new const char*[numArgs];
+
+ for (int i = 0; i < numArgs; i++) {
+ argObjs[i] = (jstring) env->GetObjectArrayElement(argArray, i);
+ args[i] = env->GetStringUTFChars(argObjs[i], NULL);
+ }
+
+ sBluetoothInterface->dump(fd, args);
+
+ for (int i = 0; i < numArgs; i++) {
+ env->ReleaseStringUTFChars(argObjs[i], args[i]);
+ }
+
+ delete[] args;
+ delete[] argObjs;
}
static jboolean factoryResetNative(JNIEnv *env, jobject obj) {
{"configHciSnoopLogNative", "(Z)Z", (void*) configHciSnoopLogNative},
{"alarmFiredNative", "()V", (void *) alarmFiredNative},
{"readEnergyInfo", "()I", (void*) readEnergyInfo},
- {"dumpNative", "(Ljava/io/FileDescriptor;)V", (void*) dumpNative},
+ {"dumpNative", "(Ljava/io/FileDescriptor;[Ljava/lang/String;)V", (void*) dumpNative},
{"factoryResetNative", "()Z", (void*)factoryResetNative}
};
import com.android.bluetooth.btservice.RemoteDevices.DeviceProperties;
import java.io.FileDescriptor;
+import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
+import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
private static final int ADAPTER_SERVICE_TYPE=Service.START_STICKY;
+ private static final String[] DEVICE_TYPE_NAMES = new String[] {
+ "???",
+ "BR/EDR",
+ "LE",
+ "DUAL"
+ };
+
static {
classInitNative();
}
return service.reportActivityInfo();
}
- public void dump(ParcelFileDescriptor fd) {
- AdapterService service = getService();
- if (service == null) return;
- service.dump(fd.getFileDescriptor());
- }
-
public void onLeServiceUp(){
AdapterService service = getService();
if (service == null) return;
if (service == null) return;
service.onBrEdrDown();
}
+
+ public void dump(FileDescriptor fd, String[] args) {
+ PrintWriter writer = new PrintWriter(new FileOutputStream(fd));
+ AdapterService service = getService();
+ service.dump(fd, writer, args);
+ }
};
// ----API Methods--------
return getResources().getInteger(R.integer.config_bluetooth_operating_voltage_mv) / 1000.0;
}
- private void dump(FileDescriptor fd) {
- // Collect profile information
+ @Override
+ protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
+ enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG);
+
+ writer.println("Bluetooth Status");
+ writer.println(" enabled: " + isEnabled());
+ writer.println(" state: " + getState());
+ writer.println(" address: " + getAddress());
+ writer.println(" name: " + getName() + "\n");
+
+ writer.println("Bonded devices:");
+ for (BluetoothDevice device : getBondedDevices()) {
+ writer.println(" " + device.getAddress() +
+ " [" + DEVICE_TYPE_NAMES[device.getType()] + "] " +
+ device.getName());
+ }
+
+ // Dump profile information
StringBuilder sb = new StringBuilder();
synchronized (mProfiles) {
for (ProfileService profile : mProfiles) {
}
}
- // Dump Java based profiles first
- FileWriter fw = null;
- try {
- fw = new FileWriter(fd);
- fw.write(sb.toString());
- } catch (IOException ex) {
- errorLog("IOException writing profile status!");
- } finally {
- if (fw != null) {
- try {
- fw.close();
- } catch (IOException ex) {
- debugLog("IOException closing a file after writing the profile status");
- }
- }
- }
+ writer.write(sb.toString());
+ writer.flush();
// Add native logs
- dumpNative(fd);
+ dumpNative(fd, args);
}
private void debugLog(String msg) {
/*package*/ native boolean factoryResetNative();
private native void alarmFiredNative();
- private native void dumpNative(FileDescriptor fd);
+ private native void dumpNative(FileDescriptor fd, String[] arguments);
protected void finalize() {
cleanup();