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."); }
private CondomContext(final CondomCore condom, final @Nullable Context app_context, final @Nullable @Size(max=16) String tag) { super(condom.mBase); final Context base = condom.mBase; mCondom = condom; mApplicationContext = app_context != null ? app_context : this; mBaseContext = new Lazy<Context>() { @Override protected Context create() { return new PseudoContextImpl(CondomContext.this); }}; mPackageManager = new Lazy<PackageManager>() { @Override protected PackageManager create() { return new CondomPackageManager(base.getPackageManager()); }}; mContentResolver = new Lazy<ContentResolver>() { @Override protected ContentResolver create() { return new CondomContentResolver(base, base.getContentResolver()); }}; final List<CondomKit> kits = condom.mKits; if (kits != null && ! kits.isEmpty()) { mKitManager = new KitManager(); for (final CondomKit kit : kits) kit.onRegister(mKitManager); } else mKitManager = null; TAG = CondomCore.buildLogTag("Condom", "Condom.", tag); }