Android S dynamically removes irrelevant applications

Android remove related apps

prospect

The same set of code can customize multiple client projects, and different projects and different needs need to be customized separately.
For example: the android platform integrates the cell broadcast function (CellBroadCast) by default, but this application is not used by some customers and needs to be removed.

There are two ways to refer to the operation

Option One

Find the system source code, find the corresponding code location, and modify mk so that it does not compile to the system.

When searching for application compilation, you need to carefully check multiple mk files to avoid missing modifications, which will cause the function to not take effect.

Some are shown below 内联代码片.

vendor/odm/product_name/mx/configs.mk
#add by hhuiming on 2023-02-08
FEATURE_CELLBROAD_DISABLED := yes
#add by hhuiming end

Some are shown below 内联代码片.

build/make/target/product/telephony_system.mk
#add by hhuiming on 2023-02-08
ifeq ($(strip $(FEATURE_CELLBROAD_DISABLED)), yes)
  PRODUCT_PACKAGES := \
  	CallLogBackup \
else
 PRODUCT_PACKAGES := \
 	CallLogBackup \
  	com.android.cellbroadcast \
  	CellBroadcastLegacyApp \
endif
#add by hhuiming end

Option II

All projects compile this app, but at system startup, for special projects, the installation is skipped.

In order to avoid the confusion of requirements before the project, it can usually be controlled by feature. When compiling different projects, load the configs.mk files of different projects. Add a new feature in the configs.mk file, judge in mk, and control application integration.

Take solution 2 as an example:
modify the file directory as follows:

Some are shown below 内联代码片.

vendor/odm/product_name/mx/configs.mk
//增加自定义feature,控制此功能,如果其他项目有相同需求,只需要在对应项目下增加此feature,而无需在公共仓库通过brand_name的方式进行区分和新增
#add by hhuiming on 2023-02-08
PRODUCT_PRODUCT_PROPERTIES += ro.feature.cellbroad_disable=true
#add by hhuiming end
framework/base/services/core/java/com/android/server/pm/PackageManagerService.java
vendor/odm/product_name/mx/configs.mk
	//引用自定义feature
    //add by hhuiming on 2023-02-08
    private static final boolean FEATURE_CELLBROAD_DISABLE = SystemProperties.getBoolean("ro.feature.cellbroad_disable", false);
    private static final String CELLBROAD_PACKAGE_NAME = "com.android.cellbroadcastreceiver";
    //add by hhuiming end
	
	//scanDirLI 扫描安装
    private void scanDirLI(File scanDir, int parseFlags, int scanFlags, long currentTime,
            PackageParser2 packageParser, ExecutorService executorService) {
    
    
	/*省略*/
        if (throwable == null) {
    
    
        //add by hhuiming on 2023-02-08 
			if(FEATURE_CELLBROAD_DISABLE){
    
    
		    	if(CELLBROAD_PACKAGE_NAME.equals(parseResult.parsedPackage.getPackageName())
					&& (parseResult.scanFile.getAbsolutePath().startsWith("/system/")
					|| parseResult.scanFile.getAbsolutePath().startsWith("/system_ext/")
					|| parseResult.scanFile.getAbsolutePath().startsWith("/vendor/")
					|| parseResult.scanFile.getAbsolutePath().startsWith("/product/"))){
    
    
				continue;
		    }
		}
		//add by hhuiming end
	/*省略*/
    }

Guess you like

Origin blog.csdn.net/weixin_45080805/article/details/128938034