requireActivity().contentResolver.query(...) returning 0 elements for API 30

This is the problem, when I try to run the code on the emulator and i choose API level 30, it doesn’t save the contact to the database, while if I try to run the project on a lower API, it works just fine.
Here is the code

pickContactCallback = ActivityResultCallback<Uri?> { contactUri: Uri?->
            val queryFields = arrayOf(ContactsContract.Contacts.DISPLAY_NAME)
            val cursor = contactUri?.let { contactUri ->
                Log.d(TAG, "check if contact exists: ${contactUri.toString()}")
                requireActivity().contentResolver.query(
                    contactUri,
                    queryFields,
                    null,
                    null,
                    null
                )
            }
            Log.d(TAG, "n. of contacts: ${cursor!!.count.toString()}") // this is 0 with API 30, 2 with API 29
            cursor?.use {
                if (it.count == 0){
                    return@ActivityResultCallback
                }

                it.moveToFirst()
                val suspect = it.getString(0)
                Log.d(TAG, "onActivityResult() called - $suspect")
                crime.suspect = suspect
                crimeDetailViewModel.saveCrime(crime)
                suspectButton.text = suspect
            }
        }

I already added permission in the manifest file like so

 <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
        tools:ignore="QueryAllPackagesPermission" />

What am I missing? does anyone knows what I’m doing wrong?
Thanks