1、将目标应用的包名加到如下配置文件中:
    vendor/mediatek/proprietary/frameworks/base/data/etc/pms_sysapp_removable_system_list.txt

    1. com.android.quicksearchbox
    2. com.android.calendar
    3. com.android.dreams.basic
    4. com.android.musicfx
    5. com.android.calculator2
    6. com.android.email
    7. com.android.exchange
    8. com.joyhealth.intelligencefamilydoctor
    9. com.autonavi.amapauto

    2、确保 persist.sys.pms_sys_removable 打开。
    device/mediatek/common/device.mk

    1. ifeq ($(strip $(MTK_CTA_SET)), yes)
    2. PRODUCT_PROPERTY_OVERRIDES += ro.mtk_cta_set=1
    3. # Add for PMS support removable system app
    4. PRODUCT_PROPERTY_OVERRIDES += persist.sys.pms_sys_removable=1
    5. endif

    此配置文件在编译脚本中的位置如下:
    device/mediatek/common/device.mk

    1. # Add for PMS support removable system app
    2. ifneq ($(strip $(MTK_BASIC_PACKAGE)), yes)
    3. 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)
    4. 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)
    5. endif

    此配置文件编译输出到目录:system/etc/permissions

    此配置文件在如下文件中引用
    vendor/mediatek/proprietary/frameworks/base/services/core/java/com/mediatek/server/pm/PmsExtImpl.java

    1. // Removable system app
    2. private static HashSet<String> sRemovableSystemAppSet = new HashSet<String>();
    3. // Define a bak removable sys app list, handle whitelist OTA upgade,
    4. // maybe one package is changed from removable to unremovable
    5. private static HashSet<String> sRemovableSystemAppSetBak = new HashSet<String>();
    6. private static boolean sRemovableSysAppEnabled = SystemProperties.getInt(
    7. "persist.sys.pms_sys_removable", 0) == 1;
    8. private static final File REMOVABLE_SYS_APP_LIST_SYSTEM = Environment
    9. .buildPath(Environment.getRootDirectory(), "etc", "permissions",
    10. "pms_sysapp_removable_system_list.txt");
    11. private static final File REMOVABLE_SYS_APP_LIST_VENDOR = Environment
    12. .buildPath(Environment.getVendorDirectory(), "etc", "permissions",
    13. "pms_sysapp_removable_vendor_list.txt");
    14. // Bak removable sys app file path definition
    15. private static final File REMOVABLE_SYS_APP_LIST_BAK = Environment
    16. .buildPath(Environment.getDataDirectory(), "system",
    17. "pms_sysapp_removable_list_bak.txt");
    18. private static HashSet<String> sUninstallerAppSet = new HashSet<String>();
    19. private void buildRemovableSystemAppSet() {
    20. if (sRemovableSysAppEnabled) {
    21. if (sLogEnabled)
    22. Slog.d(TAG, "BuildRemovableSystemAppSet start");
    23. sGetRemovableSystemAppFromFile(sRemovableSystemAppSet,
    24. REMOVABLE_SYS_APP_LIST_SYSTEM);
    25. sGetRemovableSystemAppFromFile(sRemovableSystemAppSet,
    26. REMOVABLE_SYS_APP_LIST_VENDOR);
    27. if (sLogEnabled)
    28. Slog.d(TAG, "BuildRemovableSystemAppSet end");
    29. }
    30. }
    31. /**
    32. * Get removable system app list from config file
    33. *
    34. * @param resultSet
    35. * Returned result list
    36. * @param file
    37. * The config file
    38. */
    39. private static void sGetRemovableSystemAppFromFile(
    40. HashSet<String> resultSet, File file) {
    41. FileReader fr = null;
    42. BufferedReader br = null;
    43. try {
    44. if (file.exists()) {
    45. fr = new FileReader(file);
    46. } else {
    47. Slog.d(TAG, "file in " + file + " does not exist!");
    48. return;
    49. }
    50. br = new BufferedReader(fr);
    51. String line;
    52. while ((line = br.readLine()) != null) {
    53. line = line.trim();
    54. if (!TextUtils.isEmpty(line)) {
    55. if (sLogEnabled)
    56. Slog.d(TAG, "read line " + line);
    57. resultSet.add(line);
    58. }
    59. }
    60. } catch (IOException io) {
    61. Slog.d(TAG, io.getMessage());
    62. } finally {
    63. try {
    64. if (br != null) {
    65. br.close();
    66. }
    67. if (fr != null) {
    68. fr.close();
    69. }
    70. } catch (IOException io) {
    71. Slog.d(TAG, io.getMessage());
    72. }
    73. }
    74. }