1、将目标应用的包名加到如下配置文件中:vendor/mediatek/proprietary/frameworks/base/data/etc/pms_sysapp_removable_system_list.txt
com.android.quicksearchboxcom.android.calendarcom.android.dreams.basiccom.android.musicfxcom.android.calculator2com.android.emailcom.android.exchangecom.joyhealth.intelligencefamilydoctorcom.autonavi.amapauto
2、确保 persist.sys.pms_sys_removable 打开。device/mediatek/common/device.mk
ifeq ($(strip $(MTK_CTA_SET)), yes)PRODUCT_PROPERTY_OVERRIDES += ro.mtk_cta_set=1# Add for PMS support removable system appPRODUCT_PROPERTY_OVERRIDES += persist.sys.pms_sys_removable=1endif
此配置文件在编译脚本中的位置如下:device/mediatek/common/device.mk
# Add for PMS support removable system appifneq ($(strip $(MTK_BASIC_PACKAGE)), yes)PRODUCT_COPY_FILES += $(call add-to-product-copy-files-if-exists,vendor/mediatek/proprietary/frameworks/base/data/etc/pms_sysapp_removable_system_list.txt:system/etc/permissions/pms_sysapp_removable_system_list.txt)PRODUCT_COPY_FILES += $(call add-to-product-copy-files-if-exists,vendor/mediatek/proprietary/frameworks/base/data/etc/pms_sysapp_removable_vendor_list.txt:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/pms_sysapp_removable_vendor_list.txt)endif
此配置文件编译输出到目录:system/etc/permissions
此配置文件在如下文件中引用vendor/mediatek/proprietary/frameworks/base/services/core/java/com/mediatek/server/pm/PmsExtImpl.java
// Removable system appprivate static HashSet<String> sRemovableSystemAppSet = new HashSet<String>();// Define a bak removable sys app list, handle whitelist OTA upgade,// maybe one package is changed from removable to unremovableprivate static HashSet<String> sRemovableSystemAppSetBak = new HashSet<String>();private static boolean sRemovableSysAppEnabled = SystemProperties.getInt("persist.sys.pms_sys_removable", 0) == 1;private static final File REMOVABLE_SYS_APP_LIST_SYSTEM = Environment.buildPath(Environment.getRootDirectory(), "etc", "permissions","pms_sysapp_removable_system_list.txt");private static final File REMOVABLE_SYS_APP_LIST_VENDOR = Environment.buildPath(Environment.getVendorDirectory(), "etc", "permissions","pms_sysapp_removable_vendor_list.txt");// Bak removable sys app file path definitionprivate static final File REMOVABLE_SYS_APP_LIST_BAK = Environment.buildPath(Environment.getDataDirectory(), "system","pms_sysapp_removable_list_bak.txt");private static HashSet<String> sUninstallerAppSet = new HashSet<String>();private void buildRemovableSystemAppSet() {if (sRemovableSysAppEnabled) {if (sLogEnabled)Slog.d(TAG, "BuildRemovableSystemAppSet start");sGetRemovableSystemAppFromFile(sRemovableSystemAppSet,REMOVABLE_SYS_APP_LIST_SYSTEM);sGetRemovableSystemAppFromFile(sRemovableSystemAppSet,REMOVABLE_SYS_APP_LIST_VENDOR);if (sLogEnabled)Slog.d(TAG, "BuildRemovableSystemAppSet end");}}/*** Get removable system app list from config file** @param resultSet* Returned result list* @param file* The config file*/private static void sGetRemovableSystemAppFromFile(HashSet<String> resultSet, File file) {FileReader fr = null;BufferedReader br = null;try {if (file.exists()) {fr = new FileReader(file);} else {Slog.d(TAG, "file in " + file + " does not exist!");return;}br = new BufferedReader(fr);String line;while ((line = br.readLine()) != null) {line = line.trim();if (!TextUtils.isEmpty(line)) {if (sLogEnabled)Slog.d(TAG, "read line " + line);resultSet.add(line);}}} catch (IOException io) {Slog.d(TAG, io.getMessage());} finally {try {if (br != null) {br.close();}if (fr != null) {fr.close();}} catch (IOException io) {Slog.d(TAG, io.getMessage());}}}
