private Set<String> getPackagesToDelete() {
        Set<String> packagesToDelete = getCurrentAppsWithLauncher();
        // Newly installed system apps are uninstalled when they are not required and are either
        // disallowed or have a launcher icon.
        packagesToDelete.removeAll(getRequiredApps());
        // Don't delete the system input method packages in case of Device owner provisioning.
        if (mProvisioningType == DEVICE_OWNER || mProvisioningType == MANAGED_USER) {
            packagesToDelete.removeAll(getSystemInputMethods());
        }
        packagesToDelete.addAll(getDisallowedApps());

        // Only consider new system apps.
        packagesToDelete.retainAll(getNewSystemApps());
        return packagesToDelete;
    }
Provisioning type should be either {@link #DEVICE_OWNER}, {@link #PROFILE_OWNER} or
{@link #MANAGED_USER}.
engine/src/main/java/com/oasisfeng/island/provisioning/task/DeleteNonRequiredAppsTask.java