A large number of third-party apps are required to be pre-installed in the product. The apk file is larger than MB, and the related resource files are added, totaling 4 GB.
How to Build so many files into the system during installation becomes a problem. Solution 3: 1. Copy Data in update.zip. Write updater-script and copy it by using script. See my other custom updater-script article. Disadvantage: the script must be written by yourself and cannot be generated with make. 2. copy the file in update.zip. Implemented in recovery. c. Disadvantage: SDCARD fat has a limit on the size of zip files. 3. Automatic Installation is enabled after the first system startup. Disadvantage: It is too slow. It takes about 30 minutes. Implementation of Method 2:
650) this. width = 650; "src =" http://img1.51cto.com/attachment/201201/182526857.png "border =" 0 "alt =" "/>
- Implementation of Method 2:
-
- See the image in the process.
- End of the try_update_binary function at the end of install_package (); in src/bootable/recovery/install. c
-
- The specific implementation is as follows:
-
- // Copy some res file to/data/
-
- Static char * res_list [] = {"/sdcard/res1.zip", "/sdcard/res2.zip "};
-
- Static void unzip_res_to_data (void)
- {
- Int I = 0;
-
- For (I = 0; I <sizeof (res_list)/sizeof (char *); ++ I)
- {
- ZipArchive zip_res;
- Int err = mzOpenZipArchive (res_list [I], & zip_res );
- If (err! = 0 ){
- LOGI ("Can't open % s \ n", res_list [I]);
- }
- Else {
- LOGI ("start update % s \ n", res_list [I]);
- // To create a consistent system image, never use the clock for timestamps.
- Struct utimbuf timestamp = {1217592000,121 7592000}; // 8/1/2008 default
- Bool success = mzExtractRecursive (& zip_res, "res-private", "/data/res-private ",
- MZ_EXTRACT_FILES_ONLY, & timestamp,
- NULL, NULL );
- LOGI ("update % s \ n", res_list [I], (success = true )? "Success": "failed "));
- MzCloseZipArchive (& zip_res );
- }
- }
-
- DirSetHierarchyPermissions ("/data/res-private", 1000,100 0, 0777,066 6 );
- }
-
- // Copy some app file to/data/app
- Void cpfiles (){
-
- ZipArchive zip_apps;
- Int err = mzOpenZipArchive ("/sdcard/mydomain.zip", & zip_apps );
- If (err! = 0 ){
- LOGI ("Can't open % s \ n", "/sdcard/mydomain.zip ");
- }
- Else {
- // Here need fix mount for your device
- If (mount ("/dev/block/mmcblk0p13", "/data", "ext4 ",
- MS_NOATIME | MS_NODEV | MS_NODIRATIME, "") <0 ){
- Fprintf (stderr, "% s: failed to mount", strerror (errno ));
- }
-
- LOGI ("start update 3rd-apps \ n ");
- // To create a consistent system image, never use the clock for timestamps.
- Struct utimbuf timestamp = {1217592000,121 7592000}; // 8/1/2008 default
- Bool success = mzExtractRecursive (& zip_appss, "app", "/data/app ",
- MZ_EXTRACT_FILES_ONLY, & timestamp,
- NULL, NULL );
- DirSetHierarchyPermissions ("/data/app", 1000,100 0, 0771,064 4 );
- LOGI ("update myapps % s \ n", (success = true )? "Success": "failed "));
- MzCloseZipArchive (& zip_apps );
-
- // Cp res to/data/
- Unzip_res_to_data ();
-
- Scan_mounted_volumes ();
- Const MountedVolume * vol = find_mounted_volume_by_mount_point ("/data ");
- If (vol = NULL ){
- Fprintf (stderr, "unmount of % s failed; no such volume \ n", "/data ");
- } Else {
- Unmount_mounted_volume (vol );
- }
- }
-
- }
-
-
- // If the package contains an update binary, extract it and run it.
- Static int
- Try_update_binary (const char * path, ZipArchive * zip ){
- .......
-
- Cpfiles ();
- Return INSTALL_SUCCESS;
- }
This article is from the "lhc180" blog. For more information, contact the author!