Android 4.4 Kitkat Phone workflow analysis (2) _ UI Structure Analysis

Source: Internet
Author: User


This article from http://blog.csdn.net/yihongyuelan reprint please be sure to indicate the source

The code in this article takes the MTK platform Android 4.4 as the analysis object, which is somewhat different from Google's native AOSP. Please be aware of it.
Overview I have analyzed the InCallScreen structure (portal) of Android 4.2 before, but Google later published Android 4.4, I .e. Kitkat. Then I decided to reorganize and record the previous article as a template. When there is a call or power-off in 4.4, the interface 1 displayed to the user is called InCallScreen before 4.4, but InCallActivity after 4.4. The dial page we call up in 4.4 is actually DialtactsActivity and belongs to the Dialer application. In 4.4, the interface is divided into three parts: CallCardFragment, CallButtonFragment, and AnswerFragment, as shown below:
 
Figure 1 InCallActivity page (left: connected right: Incoming call) InCallActivity layout analysis

In InCallActivity. java, the interface is initialized. In section 4.4, the layout of the interface is completed through fragment, that is, incall_screen.xml. The Code is as follows:

<FrameLayout xmlns: android = "http://schemas.android.com/apk/res/android" android: layout_width = "match_parent" android: layout_height = "match_parent" android: id = "@ + id/main"> <! -- MTK VideoCall fragment --> <FrameLayout android: id = "@ + id/vtCallFragment" android: layout_width = "match_parent" android: layout_height = "match_parent"/> <LinearLayout android: id = "@ + id/in_call_and_button_container" android: layout_width = "match_parent" android: layout_height = "match_parent" android: orientation = "vertical"> <RelativeLayout android: id = "@ + id/in_call_card_container" android: layout_width = "matc H_parent "android: layout_height =" match_parent "android: layout_weight =" 1 "> <! -- CallCard fragment is used to display the contact information --> <fragment android: name = "com. android. incallui. callCardFragment "android: id =" @ + id/callCardFragment "android: layout_width =" match_parent "android: layout_height =" match_parent "android: layout_alignParentTop =" true "android: layout_alignParentStart = "true"/> <! -- Dial independent and easy to reuse --> <fragment android: name = "com. android. incallui. dialpadFragment "android: id =" @ + id/dialpadFragment "android: layout_width =" match_parent "android: layout_height =" match_parent "android: layout_alignParentTop =" true "android: layout_alignParentStart = "true"/> </RelativeLayout> <! -- Control button is the original InCallTouchUi --> <fragment android: name = "com. android. incallui. callButtonFragment "android: id =" @ + id/callButtonFragment "android: layout_width =" match_parent "android: layout_height =" wrap_content "/> </LinearLayout> <! -- GlowpadView of the original system used by the incoming call/stop control --> <fragment android: name = "com. android. incallui. answerFragment "android: id =" @ + id/answerFragment "android: layout_width =" match_parent "android: layout_height =" wrap_content "android: layout_alignParentBottom =" true "android: layout_centerHorizontal = "true" android: gravity = "top" android: layout_gravity = "bottom | center_horizontal" android: layout_marginBottom = "@ dimen/glowpadvie W_margin_bottom "android: visibility =" gone "/> <! -- Conference telephone management interface --> <fragment android: name = "com. android. incallui. authorization "android: id =" @ + id/ConferenceManagerFragment "android: layout_width =" match_parent "android: layout_height =" match_parent "android: layout_alignParentTop =" true "android: layout_alignParentStart = "true" android: layout_alignParentBottom = "true" android: layout_alignParentEnd = "true"/> </FrameLayout>
From the perspective of the entire layout, fragment is used in 4.4 to replace the original write layout. On the one hand, it can better reflect the modular design, and on the other hand, it is easier to adapt to different screen sizes. According to the layout file, InCallActivity mainly includes the following parts:
  • CallCardFragment: Used to display contact information and call time;
  • CallButtonFragment: The control button at the bottom of the call interface, called InCallTouchUi;
  • ConferenceManagerFragment: Conference Phone interface;
  • VtCallFragment: Visual call control;
  • DialpadFragment: Dial display control.
  • AnswerFragment: Call Control, which is used to receive, reject, and send Short Message replies.
In general, 4.4 of the layout changes little. Instead, they use a more modular layout method. The following describes common basic la s, including callCardFragement, callButtonFragment, and answerFragment.
CallCardFragment the call information display callCardFragment control. In fact, the displayed information mainly includes the call contact information. The entire layout is shown as 2:
Figure 2 callCardFragment page
The callButtonFragment call control interface is no longer called InCallTouchUi in 4.4. Instead, the control buttons below are packaged using fragment. The corresponding layout can be viewed in call_button_fragment.xml. 3:

Figure 3 callButtonFragmentanswerFragment call control interface the Call Control Interface mentioned here is actually the MultiWaveView before 4.4 ,. 4:

Figure 4 answerFragmentInCallActivity initialization process

In the onCreate method of InCallActivity, the initialization of each component (fragment) is completed, mainly in the initializeInCall method. The Code is as follows:

Private void initializeInCall () {if (mCallButtonFragment = null) {mCallButtonFragment = (CallButtonFragment) getFragmentManager (). findFragmentById (R. id. callButtonFragment); mCallButtonFragment. getView (). setVisibility (View. INVISIBLE);} if (mCallCardFragment = null) {mCallCardFragment = (CallCardFragment) getFragmentManager (). findFragmentById (R. id. callCardFragment );}//...... omitted}
Then, the status bar and the close-range sensor status are updated. In addition, MTK adds some customization to AOSP, such as SIMInfoWrapperr, which is used to display and save SIM card information. Compared with the code earlier than 4.4, InCallActivity actually replaces the InCallScreen function. For details about the initialization process, see the code. Here we need to mention the presenter in InCallUI, which is equivalent to a state machine and stores various states, while fragment is used to hold the display. The InCallActivity initialization sequence is shown as follows:
Figure 5 InCallActivity initialization sequence diagram CallButtonFragment Control Process
As code 4.4 changes, we mainly look at the control and update processes of the following controls:
AnswerFragment Sliding Control

AnswerFragment is the original MultiWaveView, which now exists as an independent fragment. The control process sequence diagram is as follows:


Figure 6 anserFragment display/control sequence diagram

DialpadButton display/hide dial
DialpadButton is similar in effect to that before 4.4, but is mutually exclusive with callCardFragment. The sequence diagram is as follows:

Figure 7 sequence of Dial time displayed after the dial is connected

AudioButton enable/disable speaker
AudioButton is used to enable/disable the speaker. After accessing the wire control headset or Bluetooth headset, click the displayed option. The execution sequence is shown as follows:



Figure 8 when the speaker is enabled/disabled, the current control flow is passed from callButtonFragment in InCallUI to CallCommandService In TeleService, and then passed down. MuteButton enable/disable microphone mute
The enabling/disabling of MIC mute is similar to that of audioButton. The execution sequence is as follows:
Figure 9 enable or disable holdButton for Mute microphone
HoldButton is used to enable/disable call persistence. The execution sequence is shown as follows:
Figure 10 call persistence enabling/disabling addButton
AddButton has been changed in the code of MTK 4.4. The addButton is displayed on the condition that it has a physical menu button or "tablet ".
Figure 11 new Call Sequence diagram endButton hangs up the current CALL
After clicking endButton, the execution sequence is shown as follows:
Figure 12 CallCardFragment display of the current Call Sequence

Updated CallCardFragment is more independent and code clearer than before 4.4 (only modified by MTK, ah ......), The update sequence diagram of the entire interface is as follows:


Figure 13 CallCardFragment update sequence diagram Summary

The UI of Android 4.4 Phone has not been greatly changed, but the implementation method of the Code has undergone great changes. Through analysis, the UI update process can be basically clarified.

The link for downloading the source image involving the time sequence graph is attached. The source image is easy to view without distortion. Click here.


Related Article

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.