There are five conditions that proximity sensor disable during a phone call.
These conditions is default settings of Phone application in android.
You can find the source code in PhoneApp.java,
boolean screenOnImmediately = (isHeadsetPlugged()
|| ((mBtHandsfree != null) && mBtHandsfree.isAudioOn())
|| mOrientation == AccelerometerListener.ORIENTATION_HORIZONTAL);
(1) isHeadsetPlugged(): When user headset is plugged, proximity sensor will be disable
(2) isSpeakerOn: When user turn on the speaker, proximity sensor will be disable
(3) BT device is connected and audio path is On
(4) Hardware Keyboard is opened.
(5) DUT is at Horizional state.
You can check the code in PhoneApp.java and customize what you want.
Check it out.