Android implementation silent installation instance code

Silent installation is mainly divided into the following methods:

1、 On the root machine, use the PM install command in the app to install APK:

2、 Modify the source code of the system application packagemanagerintaller.apk and add an installation interface without interface:

principle

When you click an APK in the Android folder, an installation event is triggered. The packageinstaller receives the intent information from the system service packagemanagerservice, which contains some parameters of the APK. The key to implementation is to distinguish between general APK and specific APK. By adding special parameters to the intent passed to packagemanagerservice, the packageinstaller makes a judgment after receiving it and carries out a special hidden installation process. This implementation can only be installed through program calls.

The information window of the installation process is implemented in packageinstallactivity.java. There are four information windows in the installation process:

You need to implement a pakkageinstallactivityhide.java file and remove the dialog and window above.

Concrete implementation

1. The final installed and uninstalled classes are as follows:

2. Declare a specific intent in androidmainfest.xml: android.intent.action.view.hide, which is received by packageinstallactivityhide.java. Note the following two points:

The code is as follows:

3. Implement pakkageinstallactivityhide.java and uninstalleractivityhide.java. Just modify pakkageinstallactivity.java to remove dialog and dialog.

4. The installer caller can send an intent defined above. For example, install / sdcard / hello.apk silently (the uninstallation method is similar).

5. Note that this method requires packageinstall.apk to be compiled with the system. The APK is under the / system / APP / directory; Android.intent.action.view.hide, a silent installation interface, needs to be opened to a third party.

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>