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

Commit f4ca0771 authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by android-build-merger
Browse files

Merge "JNI: Return early when there are no filters"

am: 7aee7160

Change-Id: Ifef8c183ed7a05ef2fdc3438d78825b0564166b9
parents 4cc2c65f 7aee7160
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -1265,12 +1265,6 @@ static void gattClientScanFilterAddNative(JNIEnv* env, jobject object,
                                          jint filter_index) {
  if (!sGattIf) return;

  int numFilters = env->GetArrayLength(filters);

  jclass entryClazz = NULL;
  if (numFilters > 0)
    entryClazz = env->GetObjectClass(env->GetObjectArrayElement(filters, 0));

  jclass uuidClazz = env->FindClass("java/util/UUID");
  jmethodID uuidGetMsb =
      env->GetMethodID(uuidClazz, "getMostSignificantBits", "()J");
@@ -1279,6 +1273,16 @@ static void gattClientScanFilterAddNative(JNIEnv* env, jobject object,

  std::vector<ApcfCommand> native_filters;

  int numFilters = env->GetArrayLength(filters);
  if (numFilters == 0) {
    sGattIf->scanner->ScanFilterAdd(filter_index, std::move(native_filters),
                                    base::Bind(&scan_filter_cfg_cb, client_if));
    return;
  }

  jclass entryClazz =
      env->GetObjectClass(env->GetObjectArrayElement(filters, 0));

  jfieldID typeFid = env->GetFieldID(entryClazz, "type", "B");
  jfieldID addressFid =
      env->GetFieldID(entryClazz, "address", "Ljava/lang/String;");