Sony Experia Z5 Screen Goes Black Whan Making Calls

A friend and I both purchased Sony Experia Z5 phones last year. He started having an issue of the screen going black when making a call and being unable to select the external speaker function. The charging port on my phone went bad and after replacing it I started having the same issue. I can place calls but the screen goes black and I have to hold the phone up to my ear to hear. It doesn’t make any difference if the phone is held at an angle or if it is laying flat when dialing. It doesn’t do it every time. It’s an intermittent problem. Any ideas what may be causing this?

Regain your privacy! Adopt /e/ the unGoogled mobile OS and online servicesphone

Sounds like a proximity sensor issue, which would explain why it goes black during a phone call.
The fact it’s happening since a repair suggests it has not been made correctly.

The charge port I installed allows my phone to be recharged with an A/C charger but not with the USB port of a computer. My computer does not detect my phone when plugged into the USB port and won’t allow data transfer so the replacement charge port must be defective. Perhaps that’s causing black screen problem. Why can’t corporations build reliable products that work?