Android callcard. Java/updatestate (phone) Analysis

Source: Internet
Author: User

Callcard. java -----> void updatestate (phone) -----> perform the following update functions based on the call status: 1, updateringcall (phone)/2, updateforegroundcall (phone)/3, updatenocallphone ()

1,
Updateringcall (phone) -----> A, displaymaincallstatus (phone, ringingcall) & B, displayonholdingcallstatus (phone, bgcall) & C, displayongoingcallstatus (phone, fgoingcall)
A, displaymaincallstatus (Phone ringingcall) -----> {if there is no incoming call, return and check whether the screen is in landscape or Bluetooth status. If the current phone is connected, obtain the current callcard background image asset> source based on the Landscape status and Bluetooth status, that is, callcardbackgroundresid. Updating the clock information is the clock at the bottom of the screen when a call is made, and if it is in the keep status, disconnected, dialing, alerting, incoming, and waiting also get the corresponding callcardbackgroundresid to cancel the timer, in idle state, do nothing}, set callcardbackgroundresid (that is, the background of the Avatar), and then enter updat
Ecallcardtitlewidgets (phone, call), set some widgets, gettitleforcallcard (CALL), and find a question for the current status, such as "dialing", "Incoming call", and "current call, {if the current call is activated or connected, find an icon for the current call based on the Bluetooth status and set the text color. If the call is in the hanging status, the icons and strings are also configured to be displayed on the screen, and then the clock is displayed based on whether to hang up or not. Until now, the background is displayed. What is the text>, the information of the current caller. For example, if the profile picture name is not found, you can write it. If it is a meeting call, update the meeting interface. Otherwise, you can find personal information, such as photos, phone number, name, etc., displayed on the interface is not explained in detail.
B and C are not explained in detail
2,
Updateforgroundcall (phone). If the current phone is idle and there is a new connection, displaymaincallstatus () and then execute the action in 1
3,
Updatenocallphone is also executed. The three update functions in 1 only have different parameters in different States. For example, when the phone is completely idle, there are no new incoming calls and no pending calls, if no power is removed, the parameters ringcall, bgcall, and ongoingcall are null.

 

The source code is as follows:

Void updatestate (phone ){
If (DBG) log ("updatestate (" + phone + ")...");

// Update some internal state based on the current state of the phone.
// Todo: this code, and updateforegroundcall ()/updateringingcall (),
// Can probably still be simplified some more.

Phone. State state = phone. getstate (); // idle, ringing, or offhook
If (State = phone. state. Ringing ){
// A phone call is ringing * or * Call waiting
// (Ie. Another call may also be active as well .)
Updateringingcall (phone );
} Else if (State = phone. state. offhook ){
// The phone is off Hook. At least one call exists that is
// Dialing, active, or holding, and no callare ringing or waiting.
Updateforegroundcall (phone );
} Else {
// The phone state is idle!
//
// The most common reason for this is if a call just
// Ended: The phone will be idle, but we * will * still
// Have a call in the disconnected state:
Call fgcall = phone. getforegroundcall ();
Call bgcall = phone. getbackgroundcall ();
If (fgcall. getstate () = call. state. Disconnected)
| (Bgcall. getstate () = call. state. Disconnected )){
// In this case, we want the main callcard to display
// The "Call ended" state. The normal "foreground call"
// Code path handles that.
Updateforegroundcall (phone );
} Else {
Updatenocall (phone );
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.