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

Commit 14775f33 authored by Zhihai Xu's avatar Zhihai Xu Committed by Android (Google) Code Review
Browse files

Merge "Add debug menu to enable btsnoop"

parents fc68b229 729b3852
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -904,6 +904,20 @@ Fail:
    return -1;
}

static jboolean configHciSnoopLogNative(JNIEnv* env, jobject obj, jboolean enable) {
    ALOGV("%s:",__FUNCTION__);

    jboolean result = JNI_FALSE;

    if (!sBluetoothInterface) return result;

    int ret = sBluetoothInterface->config_hci_snoop_log(enable);

    result = (ret == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;

    return result;
}

static JNINativeMethod sMethods[] = {
    /* name, signature, funcPtr */
    {"classInitNative", "()V", (void *) classInitNative},
@@ -926,7 +940,8 @@ static JNINativeMethod sMethods[] = {
    {"getRemoteServicesNative", "([B)Z", (void*) getRemoteServicesNative},
    {"connectSocketNative", "([BI[BII)I", (void*) connectSocketNative},
    {"createSocketChannelNative", "(ILjava/lang/String;[BII)I",
     (void*) createSocketChannelNative}
     (void*) createSocketChannelNative},
    {"configHciSnoopLogNative", "(Z)Z", (void*) configHciSnoopLogNative}
};

int register_com_android_bluetooth_btservice_AdapterService(JNIEnv* env)
+19 −0
Original line number Diff line number Diff line
@@ -872,6 +872,18 @@ public class AdapterService extends Service {
            return service.createSocketChannel(type, serviceName, uuid, port, flag);
        }

        public boolean configHciSnoopLog(boolean enable) {
            if ((Binder.getCallingUid() != Process.SYSTEM_UID) &&
                (!Utils.checkCaller())) {
                Log.w(TAG,"configHciSnoopLog(): not allowed for non-active user");
                return false;
            }

            AdapterService service = getService();
            if (service == null) return false;
            return service.configHciSnoopLog(enable);
        }

        public void registerCallback(IBluetoothCallback cb) {
            AdapterService service = getService();
            if (service == null) return ;
@@ -1322,6 +1334,11 @@ public class AdapterService extends Service {
        return ParcelFileDescriptor.adoptFd(fd);
    }

    boolean configHciSnoopLog(boolean enable) {
        enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        return configHciSnoopLogNative(enable);
    }

     void registerCallback(IBluetoothCallback cb) {
         mCallbacks.register(cb);
      }
@@ -1396,6 +1413,8 @@ public class AdapterService extends Service {
    private native int createSocketChannelNative(int type, String serviceName,
                                                 byte[] uuid, int port, int flag);

    /*package*/ native boolean configHciSnoopLogNative(boolean enable);

    protected void finalize() {
        cleanup();
        if (TRACE_REF) {