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

Commit 2f3ccd29 authored by Ajay Panicker's avatar Ajay Panicker
Browse files

Limit btsnoop file size (2/9)

Limit btsnoop file size by rotating between snoop files. The rotation occurrs
when a fixed number of packets have been logged and will start overwriting
the older file.

Bug: 35998031
Test: Enable snoop logs from developer options and let logs get large
Merged-In: Idf4dd2ee10d8b8aecf1066115fbb6a53ce8ea04a
Change-Id: Idf4dd2ee10d8b8aecf1066115fbb6a53ce8ea04a
parent 35b94288
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -1147,17 +1147,6 @@ static int createSocketChannelNative(JNIEnv* env, jobject object, jint type,
  return socket_fd;
}

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

  if (!sBluetoothInterface) return JNI_FALSE;

  int ret = sBluetoothInterface->config_hci_snoop_log(enable);

  return (ret == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
}

static int readEnergyInfo() {
  ALOGV("%s", __func__);

@@ -1250,7 +1239,6 @@ static JNINativeMethod sMethods[] = {
    {"connectSocketNative", "([BI[BIII)I", (void*)connectSocketNative},
    {"createSocketChannelNative", "(ILjava/lang/String;[BIII)I",
     (void*)createSocketChannelNative},
    {"configHciSnoopLogNative", "(Z)Z", (void*)configHciSnoopLogNative},
    {"alarmFiredNative", "()V", (void*)alarmFiredNative},
    {"readEnergyInfo", "()I", (void*)readEnergyInfo},
    {"dumpNative", "(Ljava/io/FileDescriptor;[Ljava/lang/String;)V",
+0 −18
Original line number Diff line number Diff line
@@ -1281,18 +1281,6 @@ public class AdapterService extends Service {
            return service.sdpSearch(device,uuid);
        }

        public boolean configHciSnoopLog(boolean enable) {
            if (Binder.getCallingUid() != Process.SYSTEM_UID) {
                EventLog.writeEvent(0x534e4554 /* SNET */, "Bluetooth", Binder.getCallingUid(),
                        "configHciSnoopLog() - Not allowed for non-active user b/18643224");
                return false;
            }

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

        public boolean factoryReset() {
            AdapterService service = getService();
            if (service == null) return false;
@@ -1857,11 +1845,6 @@ public class AdapterService extends Service {
        return ParcelFileDescriptor.adoptFd(fd);
    }

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

    boolean factoryReset() {
        enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED, "Need BLUETOOTH permission");
        return factoryResetNative();
@@ -2288,7 +2271,6 @@ public class AdapterService extends Service {
    private native int createSocketChannelNative(
            int type, String serviceName, byte[] uuid, int port, int flag, int callingUid);

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

    private native void alarmFiredNative();