A new call is listened by callnotifier. The callnotifier class inherits from handler. In callnotifier. Java, the message representing the new vertex is phone_new_ringing_connection.
Mphone. registerfornewringingconnection (this, phone_new_ring_connection, null );
Of course, you have to register this signal. When a new call arrives, callnotifier receives the new number and submits it to onnewringingconnection (asyncresult) msg. OBJ) for processing.
In onnewringingconnection,
Boolean provisioned = settings. Secure. getint (mphone. getcontext (). getcontentresolver (),
Settings. Secure. device_provisioned, 0 )! = 0;
Check whether a rejected call is set. If yes, stop the call directly. Then, set the audio to the bell state and query the incoming call information through startincomingcallquery (connection C.
In startincomingcallquery (), first determine whether the query can be performed. If not, directly start the caller interface. Otherwise, continue to query the Caller information, such as the corresponding ringtone. After the query, start the call interface, that is, call displaycallscreen ();
After the call interface is started, the call control is completely transferred to incallscreen. java, but till now, the phone is still not connected, but a call is notified. That is, callnotifier. the task completed by Java is named exactly the same as its name, but plays the role of notify. On the incoming call interface, incallscreen. Java listens to the user's key event. If you press the access key, you will receive the call. If you press the connection key, you will end the call.
When you press the access key, callnotifier receives a phone_state_changed signal. If you press the host key, it receives a phone_state_diconnect. If you answer the call, set the audio status to the phone status and stop the ring, place a phone answer icon on the screen. At the same time, incallscreen also receives a new number, which updates the call interface, such as lighting the screen and making the menu disappear. However, if you stop a call, update the call record and stop the bell.