@CheckResult <R, T extends Throwable> R proceed(final OutboundType type, final @Nullable Intent intent, final @Nullable R negative_value, final WrappedValueProcedureThrows<R, T> procedure) throws T { final String target_pkg = intent != null ? getTargetPackage(intent) : null; if (target_pkg != null) { if (mBase.getPackageName().equals(target_pkg)) return procedure.proceed(); // Self-targeting request is allowed unconditionally if (shouldBlockRequestTarget(type, intent, target_pkg)) return negative_value; } final int original_flags = intent != null ? adjustIntentFlags(type, intent) : 0; try { return procedure.proceed(); } finally { if (intent != null) intent.setFlags(original_flags); } }
@SuppressWarnings("TypeParameterHidesVisibleType") @CheckResult <R, T extends Throwable> R proceed(final OutboundType type, final Intent intent, final @Nullable R negative_value, final CondomCore.WrappedValueProcedureThrows<R, T> procedure) throws T { final String target_pkg = getTargetPackage(intent); if (target_pkg != null) { if (mBase.getPackageName().equals(target_pkg)) return procedure.proceed(); // Self-targeting request is allowed unconditionally if (shouldBlockRequestTarget(type, intent, target_pkg)) return negative_value; } final int original_flags = adjustIntentFlags(type, intent); try { return procedure.proceed(); } finally { intent.setFlags(original_flags); } }
return proceed(type, intent, Collections.<ResolveInfo>emptyList(), new CondomCore.WrappedValueProcedureThrows<List<ResolveInfo>, T>() { @Override public List<ResolveInfo> proceed() throws T { final List<ResolveInfo> candidates = procedure.proceed(); if (mOutboundJudge != null && getTargetPackage(intent) == null) { // Package-targeted intent is already filtered by OutboundJudge in proceed(). final Iterator<ResolveInfo> iterator = candidates.iterator(); while (iterator.hasNext()) { final ResolveInfo candidate = iterator.next(); final String pkg = type == OutboundType.QUERY_SERVICES ? candidate.serviceInfo.packageName : (type == OutboundType.QUERY_RECEIVERS ? candidate.activityInfo.packageName : null); if (pkg != null && shouldBlockRequestTarget(type, intent, pkg)) // Dry-run is checked inside shouldBlockRequestTarget() iterator.remove(); // TODO: Not safe to assume the list returned from PackageManager is modifiable. } } return candidates; }}); }
return proceed(type, intent, Collections.<T>emptyList(), new WrappedValueProcedureThrows<List<T>, E>() { @Override public List<T> proceed() throws E { final List<T> candidates = procedure.proceed(); if (candidates != null && mOutboundJudge != null && (intent == null || getTargetPackage(intent) == null)) { // Package-targeted intent is already filtered by OutboundJudge in proceed(). final Iterator<T> iterator = candidates.iterator(); while (iterator.hasNext()) { final T candidate = iterator.next(); final String pkg = pkg_getter.apply(candidate); if (pkg != null && shouldBlockRequestTarget(type, intent, pkg)) // Dry-run is checked inside shouldBlockRequestTarget() iterator.remove(); // TODO: Not safe to assume the list returned from PackageManager is modifiable. } } return candidates; }}); }
@CheckResult <R, T extends Throwable> R proceed(final OutboundType type, final String target_pkg, final @Nullable R negative_value, final WrappedValueProcedureThrows<R, T> procedure) throws T { if (mBase.getPackageName().equals(target_pkg)) return procedure.proceed(); // Self-targeting request is allowed unconditionally if (shouldBlockRequestTarget(type, null, target_pkg)) return negative_value; return procedure.proceed(); }