private static void install(final Application app, final String process_name_or_tag, final CondomOptions options) { final int pos_colon = process_name_or_tag.indexOf(':'); final String tag = pos_colon > 0 ? process_name_or_tag.substring(pos_colon + 1) : process_name_or_tag; FULL_TAG = "Condom:" + tag; TAG = CondomCore.asLogTag(FULL_TAG); final CondomCore condom = new CondomCore(app, options, TAG); try { installCondomProcessActivityManager(condom); installCondomProcessPackageManager(condom); Log.d(TAG, "Global condom is installed in current process"); } catch (final Exception e) { condom.logConcern(TAG_INCOMPATIBILITY, e.getMessage()); Log.e(TAG, "Error installing global condom in current process", e); } }
/** * This is the very first (probably only) API you need to wrap the naked {@link Context} under protection of <code>CondomContext</code> * * @param base the original context used before <code>CondomContext</code> is introduced. * @param tag the optional tag to distinguish between multiple instances of <code>CondomContext</code> used parallel. */ public static @CheckResult CondomContext wrap(final Context base, final @Nullable @Size(max=13) String tag, final CondomOptions options) { if (base instanceof CondomContext) { final CondomContext condom = ((CondomContext) base); Log.w("Condom", "The wrapped context is already a CondomContext (tag: " + condom.TAG + "), tag and options specified here will be ignore."); return condom; } final Context app_context = base.getApplicationContext(); final CondomCore condom = new CondomCore(base, options, CondomCore.buildLogTag("Condom", "Condom.", tag)); if (app_context instanceof Application) { // The application context is indeed an Application, this should be preserved semantically. final Application app = (Application) app_context; final CondomApplication condom_app = new CondomApplication(condom, app, tag); // TODO: Application instance should be unique across CondomContext. final CondomContext condom_context = new CondomContext(condom, condom_app, tag); condom_app.attachBaseContext(base == app_context ? condom_context : new CondomContext(condom, app, tag)); return condom_context; } else return new CondomContext(condom, base == app_context ? null : new CondomContext(condom, app_context, tag), tag); }
private static void install(final Application app, final String current_process_name, final CondomOptions options) { final int pos_colon = current_process_name.indexOf(':'); final String tag = pos_colon > 0 ? current_process_name.substring(pos_colon) : current_process_name; FULL_TAG = "Condom:" + tag; TAG = CondomCore.asLogTag(FULL_TAG); final CondomCore condom = new CondomCore(app, options); try { installCondomProcessActivityManager(condom); installCondomProcessPackageManager(condom); Log.d(TAG, "Global condom is installed in current process"); } catch (final Exception e) { condom.logConcern(TAG_INCOMPATIBILITY, e.getMessage()); Log.e(TAG, "Error installing global condom in current process", e); } }
/** * This is the very first (probably only) API you need to wrap the naked {@link Context} under protection of <code>CondomContext</code> * * @param base the original context used before <code>CondomContext</code> is introduced. * @param tag the optional tag to distinguish between multiple instances of <code>CondomContext</code> used parallel. */ public static @CheckResult CondomContext wrap(final Context base, final @Nullable @Size(max=13) String tag, final CondomOptions options) { if (base instanceof CondomContext) { final CondomContext condom = ((CondomContext) base); Log.w("Condom", "The wrapped context is already a CondomContext (tag: " + condom.TAG + "), tag and options specified here will be ignore."); return condom; } final Context app_context = base.getApplicationContext(); final CondomCore condom = new CondomCore(base, options); if (app_context instanceof Application) { // The application context is indeed an Application, this should be preserved semantically. final Application app = (Application) app_context; final CondomApplication condom_app = new CondomApplication(condom, app, tag); final CondomContext condom_context = new CondomContext(condom, condom_app, tag); condom_app.attachBaseContext(base == app_context ? condom_context : new CondomContext(condom, app, tag)); return condom_context; } else return new CondomContext(condom, base == app_context ? null : new CondomContext(condom, app_context, tag), tag); }