If you want to be able re react to incoming calls, e.g to block them on certain conditions without implementing all the functions the default phone handler has. The Solution is to become the default Call Screening Service.

android/app/main/AndroidManifest.xml

<uses-permission android:name=“android.permission.READ_PHONE_STATE“ />

<uses-permission android:name="android.permission.BIND_SCREENING_SERVICE" tools:ignore="ProtectedPermissions" />
<service
    android:exported="false"
    android:name=".MyCallScreeningService"
    android:permission="android.permission.BIND_SCREENING_SERVICE">
    <intent-filter>
        <action android:name="android.telecom.CallScreeningService" />
    </intent-filter>
</service>

Call screening Servie:

public class MyCallScreeningService extends CallScreeningService {

@Override
public void onScreenCall(@NonNull Call.Details callDetails) {
/// handle incoming call …
}

}

How to check if the Application has the Role Call Screening:

RoleManager roleManager = (RoleManager) getSystemService(ROLE_SERVICE);
roleManager.isRoleHeld(RoleManager.ROLE_CALL_SCREENING);

How to request the user to make the App the Call Screening Service:

RoleManager roleManager = (RoleManager) getSystemService(ROLE_SERVICE);
Intent intent = roleManager.createRequestRoleIntent(RoleManager.ROLE_CALL_SCREENING);
startActivityForResult(intent,CALL_SCREENING_INTENT_CODE);

// CALL_SCREENING_INTENT_CODE can be any int -> used to react to result with:

@Overide
public void onActivityResult(int requestCode, int resultCode, Intent data){
if(requestCode == CALL_SCREENING_INTENT_CODE){
// ... do something
}
}

Further Information: https://developer.android.com/reference/android/telecom/CallScreeningService

de_DEDeutsch