public Set<String> getCurrentSystemApps(IPackageManager ipm, int userId) {
        Set<String> apps = new HashSet<String>();
        List<ApplicationInfo> aInfos = null;
        try {
            aInfos = ipm.getInstalledApplications(
                    PackageManager.GET_UNINSTALLED_PACKAGES, userId).getList();
        } catch (RemoteException neverThrown) {
            ProvisionLogger.loge("This should not happen.", neverThrown);
        }
        for (ApplicationInfo aInfo : aInfos) {
            if ((aInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
                apps.add(aInfo.packageName);
            }
        }
        return apps;
    }
Returns the currently installed system apps on a given user.

<p>Calls into the {@link IPackageManager} to retrieve all installed packages on the given
user and returns the package names of all system apps.

@param ipm an {@link IPackageManager} object
@param userId the id of the user we are interested in
engine/src/main/java/com/oasisfeng/island/provisioning/task/Utils.java