Android system application hiding and application prohibition uninstallation

 

1. App hiding and disabling

The app manager in the Android settings provides a function, the "app disable" function, which is for some system applications. When the application is disabled, the icon of the application will be hidden, but the apk still exists and will not be deleted. The core interface is PackageManager.setComponentEnabledSetting(ComponentName, int, int)方法

The specific code can be viewed in the settings module: com.android.settings.applications.InstalledAppDetails.java

 

2. The application is forbidden to uninstall

It is necessary to prohibit the uninstallation of the specified application. In addition to placing the application under system/app to become a system-level application, there are other methods. This method is suitable for third-party applications.

Modify the PackageInstaller module of Android. The source code is located in the pakages/apps directory. The specific code is located in: com.android.packageinstaller.UninstallerActivity.java

When Android pops up whether to uninstall the window, it is this class that enters, and this class can prevent the uninstallation of the application according to the package name.

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326646440&siteId=291194637