package com.swiftcleaner.chovey.model.tool;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;

import java.util.List;

public class AppUtils {
    public static int getNonSystemAppCount(Context context) {
        PackageManager packageManager = context.getPackageManager();
        List<ApplicationInfo> installedApps = packageManager.getInstalledApplications(PackageManager.GET_META_DATA);

        int nonSystemAppCount = 0;

        for (ApplicationInfo appInfo : installedApps) {
            if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
                // 非系统应用
                nonSystemAppCount++;
            }
        }

        return nonSystemAppCount;
    }
}
