Many times, after we connect the phone to the computer, we will find a drive letter similar to the CR-ROM drive, which contains the content of the phone. The procedure is as follows:
(1) Add cell phone partitions
Adjust the MTD Partition Table of the bootloader (pass the parameter to the kernel) or kernel. Add a partition to store the CDROM image.
(2) create a cdrom image and burn it to the partition.
Copy the content of the optical drive to a Linux directory, use mkisofs-r-o CDROM. ISO/your-CDROM-Dir to create an image, and use the burning and writing tools provided by the manufacturer to burn the phone.
(3) Development of USB Gadget support
A. Source Code support
Kernel provides Drivers/USB/gadget/f_mass_storage.c by default to support mass storage (disk or CDROM). Android modifies f_mass_storage.c to support mounting sdcard to mass storage, f_mass_storage.c registers a bunch of Virtual Volume lun0-lunX, each of which is set to a common disk. Android only uses lun0 to mount the sdcard to the PC, and directly adds the mass storage initialization to this file. To support CDROM, you must manually set CDROM for one of the Luns.
Flag (such as lun1), refer to the fsg_probe function in this file to set the Lun attribute row.
#ifdef SUPPORT_CDROM_BLOCKif(i == 1)fsg_cfg.luns[i].cdrom = 1;#endif
B. User-Layer Control
Volumemanager in the system \ vold directory. CPP, Android uses vold to control the mount of mass storage to the device and share it to the PC. The principle is to operate the control node/sys/devices/platform/usb_mass_storage after the mass storage gadget is run. Set enable to 1, and the file under lun0 points to the device node to be shared. If the added partition is/dev/block/mtdblock14, enter the node in the file.
if( mUsbConnected ) { char nodepath[255];memset(nodepath,0 ,255);snprintf(nodepath, sizeof(nodepath), "/dev/block/mtdblock14"); LOGD(" name = usb_configuration"); int fd2; if ((fd2 = open("/sys/devices/platform/usb_mass_storage/lun1/file", O_WRONLY)) < 0) { LOGE("Unable to open ums lunfile (%s)", strerror(errno)); return ; } if (write(fd2, nodepath, strlen(nodepath)) < 0) { LOGE("Unable to write to ums lunfile (%s)", strerror(errno)); close(fd2); return ; } close(fd2);}else{ int fd2; char ch = 0; LOGD(" name = usb_configuration remove "); if ((fd2 = open("/sys/devices/platform/usb_mass_storage/lun1/file", O_WRONLY)) < 0) { SLOGE("Unable to open ums lunfile (%s)", strerror(errno)); return ; } if (write(fd2, &ch, 1) < 0) { SLOGE("Unable to write to ums lunfile (%s)", strerror(errno)); close(fd2); return ; } close(fd2);}
(4) then, you can directly see the mounted CD-ROM in XP. The basic process is like this, and there are many other details, such as how the CD should be compatible with ADB support, but the optical drive can be popped up by default.
========================================================== ========================================================== ======================================
In Android 4.0, there are two ways to synchronize time through the network: nitz and NTP. They use different conditions and can obtain different information. After you select this function, the mobile phone first tries the nitz method. If the acquisition time fails, the NTP method is used.
(1) nitz (network identity and Time Zone) Synchronization time
Nitz is a GSM/WCDMA base station. SIM cards must be inserted and supported by operator. Time and time zone information can be provided. Carriers in mainland China are basically not supported.
(3) NTP (Network Time Protocol) Synchronization time
NTP is used when no SIM card or operator does not support nitz. It only obtains time information through the network (GPRS/WiFi), and only provides time information without time zone information (therefore, nitz is not supported, the Automatic Time Zone retrieval function is actually invalid ). There is also a caching mechanism for NTP: The current acquired time is saved, and the next time you enable the automatic update time function, the time is updated with the mobile phone clock. This is why the mobile phone can automatically update the time when there is no network. In addition, because NTP is obtained by the server at the time of synchronization, when the synchronization time fails, you can check whether the server at the time of synchronization is valid and replace it with another server.