Android: How to preset APK for Android

Source: Internet
Author: User

ZZ: http://blog.csdn.net/sergeycao/article/details/8198205

I. How to preset the APK with source code into the system?
1) Under packages/apps, create a new folder with the name of the apk to be preset, and prefabricate an APK named test as an example.
2) copy the source code of test APK to the test folder and delete the/bin and/GEN directories.
3) create a file named Android. mk in the test directory. The content is as follows:
Local_path: = $ (call my-DIR)
Include $ (clear_vars)
Local_module_tags: = optional
Local_src_files: = $ (call all-subdir-Java-files)
Local_package_name: = test
Include $ (build_package)
 
4) open the file build/target/product/$ {project}. mk ($ {project} indicates the project name)
Add test to product_packages.
5) re-build the entire project
 
2. How can I preset an APK without source code into the system?
1) create a folder under packages/apps with the APK name that needs to be preset, and prefabricate an APK named test as an example.
2) Put test.apk under packages/apps/test
3) Create the Android. mk file under packages/apps/test. The file content is as follows:
Local_path: = $ (call my-DIR)
Include $ (clear_vars)
# Module name shoshould match APK name to be installed
Local_module: = test
Local_module_tags: = optional
Local_src_files: = ((local_moduleapps.apk
Local_module_class: = apps
Local_module_suffix: = $ (common_android_package_suffix)
Local_certificate: = presigned
Include $ (build_prebuilt)
 
4) open the file build/target/product/$ {project}. mk ($ {project} indicates the project name)
Add test to product_packages.
5) copy the so library extracted from test.apk to the directory Alps/vendor/mediatek/$ {project}/artifacts/out/target/product/$ {project}/system/lib, if no so library exists, remove this step;
6) re-build the entire project
 
 
3. How to preset the APK so that users can uninstall it?
There are two methods:
Method 1:
7) under packages/apps, create a folder with the pre-configured APK name, And prefabricate an APK named test as an example.
8) Put test.apk under packages/apps/test;
9) Create the Android. mk file under packages/apps/test. The file content is as follows:
Local_path: = $ (call my-DIR)
Include $ (clear_vars)
# Module name shoshould match APK name to be installed
Local_module: = test
Local_module_tags: = optional
Local_src_files: = ((local_moduleapps.apk
Local_module_class: = apps
Local_module_suffix: = $ (common_android_package_suffix)
Local_certificate: = presigned
Local_module_path: = $ (target_out_data_apps)
Include $ (build_prebuilt)
 
10) open the file build/target/product/$ {project}. mk ($ {project} indicates the project name)
Add test to product_packages.
11) copy the so library extracted from test.apk to the directory Alps/vendor/mediatek/$ {project}/artifacts/out/target/product/$ {project}/system/lib, if no so library exists, remove this step;
12) re-build the entire project
Note: This is more than undetachable.
Local_module_path: = $ (target_out_data_apps)
 
Method 2:
4) copy the required APK:
Vendor/mediatek/$ {project}/artifacts/out/target/product/$ {project}/data/APP/
5) re-build the entire project
NOTE: If no directory exists, you must manually create one.
 
4. How can I restore the preset APK after it is restored to the factory settings?
To enable the user to restore the factory settings after uninstalling the preset APK, we made a feature, but in Alps. GB. tdfd. MP. v1.7 and Alps. GB. fdd2.mp. supported after v4.7. If your version is earlier than this version, apply for Patch alps00092543;
The general practice is:
-Create a new folder named appbackup in the vendor/mediatek/project_name/artifacts/out/target/product/project_name/system directory and copy the APK file of the application to the appbackup folder.
-In the mediatek/config/project_name/projectconfig. mk file, add the definition mtk_special_factory_reset = yes.
-Create a. restore_list under "vendor/mediatek/project_name/artifacts/out/target/product/project_name/data/APP" and add the statement in it:
/System/appbackup/xxx.apk (note that each row in. restore_list must start with "/system)
After the APK under data/APP is uninstalled, the factory settings are restored. read the APK name in restore_list and copy the APK from the appbackup file to data/APP to restore the uninstalled APK under data/app.

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.