#111
#112 if (qemu [0])
#113 import_kernel_cmdline (1 );
This code is used to determine whether a simulator is used for running. If so, the kernel command line parameters are loaded.
#114
#115 if (! Strcmp (bootmode, "factory "))
#116 property_set ("ro. factorytest", "1 ");
#117 else if (! Strcmp (bootmode, "factory2 "))
#118 property_set ("ro. factorytest", "2 ");
#119 else
#120 property_set ("ro. factorytest", "0 ");
This Code sets the factory mode test according to the kernel command line parameters. For example, you can perform special processing based on this flag if you need to automate the demonstration function during the factory production of mobile phones.
#121
#122 property_set ("ro. serialno", serialno [0]? Serialno :"");
This Code sets the mobile phone serial number to be saved in the property so that upper-layer applications can recognize this mobile phone.
#123 property_set ("ro. bootmode", bootmode [0]? Bootmode: "unknown ");
This code saves the startup mode to the attributes.
#124 property_set ("ro. baseband", baseband [0]? Baseband: "unknown ");
This code saves the cell phone baseband frequency to the attribute.
#125 property_set ("ro. carrier", carrier [0]? Carrier: "unknown ");
This code is used to save the hardware carrier of the mobile phone to the property.
#126 property_set ("ro. bootloader", bootloader [0]? Bootloader: "unknown ");
Here is to save the version number of the Bootstrap program to the property so that the system knows what features the Bootstrap program has.
#127
#128 property_set ("ro. hardware", hardware );
The hardware information is saved to the attribute, and the CPU information is actually obtained.
#129 snprintf (tmp, PROP_VALUE_MAX, "% d", revision );
#130 property_set ("ro. revision", tmp );
Here, the version number of the hardware revision is saved to the attribute, so that the application can distinguish different hardware versions.
#131
#132/* execute all the boot actions to get us started */
#133 action_for_each_trigger ("init", action_add_queue_tail );
#134 drain_action_queue ();
This code first adds all the init commands to the queue and then executes it.
#135
#136/* read any property files on system or data and
#137 * fire up the property service. This must happen
#138 * after the ro. foo properties are set above so
#139 * that/data/local. prop cannot interfere with them.
#140 */
#141 property_set_fd = start_property_service ();
This code loads the attributes in the system and data directories and starts the property listening service.
#142
#143/* create a signalling mechanic for the sigchld handler */
#144 if (socketpair (AF_UNIX, SOCK_STREAM, 0, s) = 0 ){
#145 signal_fd = s [0];
#146 signal_recv_fd = s [1];
#147 fcntl (s [0], F_SETFD, FD_CLOEXEC );
#148 fcntl (s [0], F_SETFL, O_NONBLOCK );
#149 fcntl (s [1], F_SETFD, FD_CLOEXEC );
#150 fcntl (s [1], F_SETFL, O_NONBLOCK );
#151}
This Code creates two sockets for a full-duplex communication mechanism. signals can communicate in signal_fd and signal_recv_fd in two-way, thus establishing a communication pipeline. In fact, this signal management is used for the init process to communicate with its sub-process. The sub-process writes information from signal_fd, And the init process receives information from signal_recv_fd and then processes it.
#152
#153/* make sure we actually have all the pieces we need */
#154 if (device_fd <0) |
#155 (property_set_fd <0) |
#156 (signal_recv_fd <0 )){
#157 ERROR ("init startup failure ");
#158 return 1;
#159}
This code is used to determine whether the key components are successfully initialized. It mainly refers to whether the device file system is successfully initialized, whether the property service is successfully initialized, and whether the signal communication mechanism is successfully initialized.
#160
#161/* execute all the boot actions to get us started */
#162 action_for_each_trigger ("early-boot", action_add_queue_tail );
#163 action_for_each_trigger ("boot", action_add_queue_tail );
#164 drain_action_queue ();
This code is the command for executing the early-boot and boot attributes.
#165
#166/* run all property triggers based on current state of the properties */
#167 queue_all_property_triggers ();
#168 drain_action_queue ();
This code runs the attribute command based on the current attribute.
#169
#170/* enable property triggers */
#171 property_triggers_enabled = 1;
This Code indicates that the property trigger has been initialized.
#172
#173 ufds [0]. fd = device_fd;
#174 ufds [0]. events = POLLIN;
#175 ufds [1]. fd = property_set_fd;
#176 ufds [1]. events = POLLIN;
#177 ufds [2]. fd = signal_recv_fd;
#178 ufds [2]. events = POLLIN;
#179 fd_count = 3;
This code saves three important service Sockets for later polling.
#180
#181 if (keychord_fd> 0 ){
#182 ufds [3]. fd = keychord_fd;
#183 ufds [3]. events = POLLIN;
#184 fd_count +++;
#185} else {
#186 ufds [3]. events = 0;
#187 ufds [3]. revents = 0;
#188}
This code is used to determine whether to process the combined key round robin.
#189
#190 # if BOOTCHART
#191 bootchart_count = bootchart_init ();
#192 if (bootchart_count <0 ){
#193 & nbs