- 拷贝test.apk到 /system/app/ 目录底下,并且执行chmod 777 test.apk,不然的话会安装不成功
- Android每次启动的时候会自动安装位于特定目录下的APK,这个过程会在packageManagerService这个类的构造方法中进行,这里会创建多个目录用于预查找:
[java] view plain copy
- public PackageManagerService(Context context, boolean factoryTest) {
- …
- mFrameworkDir = new File(Environment.getRootDirectory(), “framework”); // system/framework
- mSystemAppDir = new File(Environment.getRootDirectory(), “app”); // system/app
- mAppInstallDir = new File(dataDir, “app”); // data/app
- mDrmAppPrivateInstallDir = new File(dataDir, “app-private”); // data/app-private
- mAppDataDir = new File(dataDir, “data”); // data/data
- …
- }
它会在这5个地方寻找APK并通过Installer这个类来安装
以下转自:http://ricston.com/blog/explaining-behavior-android-application-system-apps-nonsystem-apps/
Explaining the behavior of an Android application: System apps vs Non-System apps
There exists a lot of contrariety on the web when it comes to the description of an Android System application. I will therefore explain the correct methodology here, which will hopefully enlighten you on whether you should place your Android application as a System application or not.
A System application is NOT an application which is signed by the OS’s platform signatures. This is a common mistake believed by many and we shall come to this later on. A System application is merely an application which is placed under /system/app folder in an Android device. An application can only be installed in that folder if we have access to the OS’s ROM (system.img). The application is placed under /app folder after the ROM has been extracted. A device which loads the custom ROM will have the new System application added. The benefit of a System application is that the application cannot be removed from the device (cannot be uninstalled by the user). This is only because /system/app is a read-only folder.
A non-System application is an ordinary application, which will be installed under /data/app folder, and which is read-write. A user can uninstall such applications normally from the Settings application. One can check if an application is a System application or not using “ApplicationInfo.FLAG_SYSTEM”. If the constant returns true, then the application in question is a System application.
Finally we shall explain the benefits of an application being signed by a particular ROM’s platform signatures. Certain permissions are protected under the “signatureOrSystem” protection level. Such permissions are not available to every application because they will grant risky privileges such as control over other applications, background installation and un-installation, among others. Such permissions can be utilized for malicious purposes, therefore Android will only grant them for System applications or Ordinary applications signed by platform signatures. System applications do not require signing by a platform signature to access these permissions. However, it is necessary for Ordinary applications to be signed before they can utilise these permissions.
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!