How to preset Android phone APK

Source: Internet
Author: User

There are 4 types of pre-fabricated apk:

1, how to put the source code APK preset into the system?
2, how to pre-set the passive apk into the system?
3, how to preset apk so that users can uninstall, restore factory settings can not be restored?
4, how to preset apk so that users can uninstall. And can be restored when factory settings are restored?


Pre-fabricated APK implementation methods such as the following;

First, how to put the source code apk preset into the system? 1) under Packages/apps, create a new directory with the name of the apk that you need to preset to preset a apk named test as an example
2) Copy the test apk source code to the test folder and delete the/bin and/gen folders
3) Create a file named Android.mk under the Test folder. The contents are as follows:

4) Open File Build/target/product/${project}.mk (${project} indicates Project name)
Add Test to Product_packages.


5) Build the entire project again

Second, how to put the passive APK pre-set into the system? 1) under Packages/apps, create a directory with the APK name that you need to preset to preset a apk named test as an example
2) Place the test.apk below the Packages/apps/test
3) Create file android.mk below Packages/apps/test, file contents such as the following:

Local_path: = $ (call My-dir) include $ (clear_vars) # Module name should match apk name to be installedlocal_module: = Testlo Cal_module_tags: = optionallocal_src_files: = $ (local_module). Apklocal_module_class: = Appslocal_module_suffix: = $ ( Common_android_package_suffix) Local_certificate: = Presignedinclude $ (build_prebuilt)

4) Open File Build/target/product/${project}.mk (${project} indicates Project name)
Add Test to Product_packages.
5) Copy the so library extracted from test.apk to the alps/vendor/mediatek/${project}/artifacts/out/target/product/${project}/system/lib/folder. If there is no so library. This step is removed;
6) Build the entire project again
Note: Google changed the permission control mechanism of protection level to system on KK
Suppose the app uses the permission of the system level. It needs to be placed under the/system/priv-app (formerly in/system/app).


For example:
Case about getting write permission for the secondary SD card. App needs to androidmanifest.xml write_media_storage permission to get write access to the secondary card


(Ref:kk/alps/frameworks/base/core/res/androidmanifest.xml)
Known Android.permission.WRITE_MEDIA_STORAGE belongs to the permission of the systemorsignature level, defined as the following:


KK, you need to use the following method to obtain the permission:
Change android.mk, add local_privileged_module: = True to declare that the app needs to be placed under/system/priv-app.

Third, how to preset apk so that users can uninstall. Not recoverable when factory reset is restored? 1) under Packages/apps, create a directory with the APK name that you need to preset to preset a apk named test as an example
2) Place the test.apk below the packages/apps/test.
3) Create file android.mk below Packages/apps/test, file contents such as the following

Local_path: = $ (call My-dir) include $ (clear_vars) # Module name should match apk name to be installedlocal_module: = Testlo Cal_module_tags: = optionallocal_src_files: = $ (local_module). Apklocal_module_class: = Appslocal_module_suffix: = $ ( Common_android_package_suffix) Local_certificate: = Presignedlocal_module_path: = $ (TARGET_OUT_DATA_APPS) include $ ( Build_prebuilt)

4) Open File Build/target/product/${project}.mk (${project} indicates Project name)
Add Test to Product_packages.


5) Build the entire project again
Note: This is more than the one that can't be uninstalled.
Local_module_path: = $ (Target_out_data_apps)

Iv. how to preset apk so that users can uninstall, and restore the factory settings can be restored? Method One: Preset apk to system/vendor/operator following detailed procedures such as the following:
Under Packages/apps, create a directory with the APK name that you need to preset to preset a apk named Test as an example:
1) Place the test.apk below the packages/apps/test.
2) Create file android.mk below Packages/apps/test, file contents such as the following:
3) Open File Build/target/product/${project}.mk (${project} indicates Project name), add Test to Product_packages
4) Build the entire project again


How to preset Android phone APK

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.