CondomCore(final Context base, final CondomOptions options, final String tag) {
mBase = base;
DEBUG = (base.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
mExcludeBackgroundReceivers = options.mExcludeBackgroundReceivers;
mExcludeBackgroundServices = SDK_INT < O && options.mExcludeBackgroundServices;
mOutboundJudge = options.mOutboundJudge;
mDryRun = options.mDryRun;
final Lazy<PackageManager> lazy_pm = new Lazy<PackageManager>() { @Override protected PackageManager create() {
return new CondomPackageManager(CondomCore.this, base.getPackageManager(), tag);
}};
final PackageManagerFactory pm_factory = options.mPackageManagerFactory;
mPackageManager = new Lazy<PackageManager>() { @Override protected PackageManager create() {
return pm_factory != null ? pm_factory.getPackageManager(base, lazy_pm.get()) : lazy_pm.get();
}};
mContentResolver = new Lazy<ContentResolver>() { @Override protected ContentResolver create() {
return new CondomContentResolver(CondomCore.this, base, base.getContentResolver());
}};
final List<CondomKit> kits = options.mKits == null ? null : new ArrayList<>(options.mKits);
if (kits != null && ! kits.isEmpty()) {
mKitManager = new CondomKitManager();
for (final CondomKit kit : kits)
kit.onRegister(mKitManager);
} else mKitManager = null;
if (mDryRun) Log.w(tag, "Start dry-run mode, no outbound requests will be blocked actually, despite later stated in log.");
}