class Partner {

    public static synchronized Partner get(Context context) {
        if (!sSearched) {
            PackageManager pm = context.getPackageManager();
            final Intent intent = new Intent(ACTION_PARTNER_CUSTOMIZATION);
            List<ResolveInfo> receivers;
            if (VERSION.SDK_INT >= VERSION_CODES.N) {
                receivers = pm.queryBroadcastReceivers(
                        intent,
                        PackageManager.MATCH_SYSTEM_ONLY
                                | PackageManager.MATCH_DIRECT_BOOT_AWARE
                                | PackageManager.MATCH_DIRECT_BOOT_UNAWARE);
            } else {
                // On versions before N, direct boot doesn't exist. And the MATCH_SYSTEM_ONLY flag
                // doesn't exist so we filter for system apps in code below.
                receivers = pm.queryBroadcastReceivers(intent, 0);
            }

            for (ResolveInfo info : receivers) {
                if (info.activityInfo == null) {
                    continue;
                }
                final ApplicationInfo appInfo = info.activityInfo.applicationInfo;
                if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
                    try {
                        final Resources res = pm.getResourcesForApplication(appInfo);
                        sPartner = new Partner(appInfo.packageName, res);
                        break;
                    } catch (NameNotFoundException e) {
                        Log.w(TAG, "Failed to find resources for " + appInfo.packageName);
                    }
                }
            }
            sSearched = true;
        }
        return sPartner;
    }

    private  Partner(String packageName, Resources res);

}