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

Commit e550ed7c authored by Andre Eisenbach's avatar Andre Eisenbach Committed by Tucker Sylvestro
Browse files

DO NOT MERGE ANYWHERE Bluetooth native dumpsys logging support (4/4)

Bug: 18508263
Change-Id: Ib9546ff2cf64d2e085e27e691032749e869e0795
parent 0e81b717
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -1214,6 +1214,17 @@ static int readEnergyInfo()
    return result;
}

static void dumpNative(JNIEnv *env, jobject obj, jobject fdObj)
{
    ALOGV("%s()", __FUNCTION__);
    if (!sBluetoothInterface) return;

    int fd = jniGetFDFromFileDescriptor(env, fdObj);
    if (fd < 0) return;

    sBluetoothInterface->dump(fd);
}

static JNINativeMethod sMethods[] = {
    /* name, signature, funcPtr */
    {"classInitNative", "()V", (void *) classInitNative},
@@ -1242,6 +1253,7 @@ static JNINativeMethod sMethods[] = {
    {"configHciSnoopLogNative", "(Z)Z", (void*) configHciSnoopLogNative},
    {"alarmFiredNative", "()V", (void *) alarmFiredNative},
    {"readEnergyInfo", "()I", (void*) readEnergyInfo},
    {"dumpNative", "(Ljava/io/FileDescriptor;)V", (void*) dumpNative},
};

int register_com_android_bluetooth_btservice_AdapterService(JNIEnv* env)
+20 −7
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ import com.android.bluetooth.btservice.RemoteDevices.DeviceProperties;
import com.android.internal.R;

import java.io.FileDescriptor;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -1141,12 +1142,10 @@ public class AdapterService extends Service {
             return service.reportActivityInfo();
         }

         public String dump() {
         public void dump(ParcelFileDescriptor fd) {
            AdapterService service = getService();
            if (service == null) {
                return "AdapterService is null";
            }
            return service.dump();
            if (service == null) return;
            service.dump(fd.getFileDescriptor());
         }
    };

@@ -1730,14 +1729,27 @@ public class AdapterService extends Service {
        return info;
    }

    private String dump() {
    private void dump(FileDescriptor fd) {
        // Collect profile information
        StringBuilder sb = new StringBuilder();
        synchronized (mProfiles) {
            for (ProfileService profile : mProfiles) {
                profile.dump(sb);
            }
        }
        return sb.toString();

        // Dump Java based profiles first
        try {
            FileWriter fw = new FileWriter(fd);
            fw.write(sb.toString());
            fw.flush();
            fw.close();
        } catch (IOException ex) {
            errorLog("IOException writing profile status!");
        }

        // Add native logs
        dumpNative(fd);
    }

    private static int convertScanModeToHal(int mode) {
@@ -1911,6 +1923,7 @@ public class AdapterService extends Service {
    /*package*/ native boolean configHciSnoopLogNative(boolean enable);

    private native void alarmFiredNative();
    private native void dumpNative(FileDescriptor fd);

    protected void finalize() {
        cleanup();
+1 −1
Original line number Diff line number Diff line
@@ -161,7 +161,7 @@ public abstract class ProfileService extends Service {

    // for dumpsys support
    public void dump(StringBuilder sb) {
        sb.append("Profile: " + mName + "\n");
        sb.append("\nProfile: " + mName + "\n");
    }

    // with indenting for subclasses