Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 201b12dd authored by Ben Gruver's avatar Ben Gruver Committed by Android Git Automerger
Browse files

am f5323fee: Pass in the ComponentName of the resolved service for service intents

* commit 'f5323fee':
  Pass in the ComponentName of the resolved service for service intents
parents 3632f945 f5323fee
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -832,8 +832,8 @@ public final class ActiveServices {
                        + " requires " + r.permission);
                return new ServiceLookupResult(null, r.permission);
            }
            if (!mAm.mIntentFirewall.checkService(service, callingUid, callingPid, resolvedType,
                    r.appInfo)) {
            if (!mAm.mIntentFirewall.checkService(r.name, service, callingUid, callingPid,
                    resolvedType, r.appInfo)) {
                return null;
            }
            return new ServiceLookupResult(r, null);
+5 −4
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.firewall;

import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import org.xmlpull.v1.XmlPullParser;
@@ -25,11 +26,11 @@ import java.io.IOException;

class AndFilter extends FilterList {
    @Override
    public boolean matches(IntentFirewall ifw, Intent intent, int callerUid, int callerPid,
            String resolvedType, ApplicationInfo resolvedApp) {
    public boolean matches(IntentFirewall ifw, ComponentName resolvedComponent, Intent intent,
            int callerUid, int callerPid, String resolvedType, ApplicationInfo resolvedApp) {
        for (int i=0; i<children.size(); i++) {
            if (!children.get(i).matches(ifw, intent, callerUid, callerPid, resolvedType,
                    resolvedApp)) {
            if (!children.get(i).matches(ifw, resolvedComponent, intent, callerUid, callerPid,
                    resolvedType, resolvedApp)) {
                return false;
            }
        }
+3 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.firewall;

import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import org.xmlpull.v1.XmlPullParser;
@@ -34,8 +35,8 @@ class CategoryFilter implements Filter {
    }

    @Override
    public boolean matches(IntentFirewall ifw, Intent intent, int callerUid, int callerPid,
            String resolvedType, ApplicationInfo resolvedApp) {
    public boolean matches(IntentFirewall ifw, ComponentName resolvedComponent, Intent intent,
            int callerUid, int callerPid, String resolvedType, ApplicationInfo resolvedApp) {
        Set<String> categories = intent.getCategories();
        if (categories == null) {
            return false;
+4 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.firewall;

import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.ApplicationInfo;

@@ -24,12 +25,13 @@ interface Filter {
     * Does the given intent + context info match this filter?
     *
     * @param ifw The IntentFirewall instance
     * @param resolvedComponent The actual component that the intent was resolved to
     * @param intent The intent being started/bound/broadcast
     * @param callerUid The uid of the caller
     * @param callerPid The pid of the caller
     * @param resolvedType The resolved mime type of the intent
     * @param resolvedApp The application that contains the resolved component that the intent is
     */
    boolean matches(IntentFirewall ifw, Intent intent, int callerUid, int callerPid,
            String resolvedType, ApplicationInfo resolvedApp);
    boolean matches(IntentFirewall ifw, ComponentName resolvedComponent, Intent intent,
            int callerUid, int callerPid, String resolvedType, ApplicationInfo resolvedApp);
}
+11 −9
Original line number Diff line number Diff line
@@ -120,25 +120,27 @@ public class IntentFirewall {
     */
    public boolean checkStartActivity(Intent intent, int callerUid, int callerPid,
            String resolvedType, ApplicationInfo resolvedApp) {
        return checkIntent(mActivityResolver, TYPE_ACTIVITY, intent, callerUid, callerPid,
                resolvedType, resolvedApp);
        return checkIntent(mActivityResolver, intent.getComponent(), TYPE_ACTIVITY, intent,
                callerUid, callerPid, resolvedType, resolvedApp);
    }

    public boolean checkService(Intent intent, int callerUid, int callerPid, String resolvedType,
            ApplicationInfo resolvedApp) {
        return checkIntent(mServiceResolver, TYPE_SERVICE, intent, callerUid, callerPid,
                resolvedType, resolvedApp);
    public boolean checkService(ComponentName resolvedService, Intent intent, int callerUid,
            int callerPid, String resolvedType, ApplicationInfo resolvedApp) {
        return checkIntent(mServiceResolver, resolvedService, TYPE_SERVICE, intent, callerUid,
                callerPid, resolvedType, resolvedApp);
    }

    public boolean checkIntent(FirewallIntentResolver resolver, int intentType, Intent intent,
            int callerUid, int callerPid, String resolvedType, ApplicationInfo resolvedApp) {
    public boolean checkIntent(FirewallIntentResolver resolver, ComponentName resolvedComponent,
            int intentType, Intent intent, int callerUid, int callerPid, String resolvedType,
            ApplicationInfo resolvedApp) {
        List<Rule> matchingRules = resolver.queryIntent(intent, resolvedType, false, 0);
        boolean log = false;
        boolean block = false;

        for (int i=0; i< matchingRules.size(); i++) {
            Rule rule = matchingRules.get(i);
            if (rule.matches(this, intent, callerUid, callerPid, resolvedType, resolvedApp)) {
            if (rule.matches(this, resolvedComponent, intent, callerUid, callerPid, resolvedType,
                    resolvedApp)) {
                block |= rule.getBlock();
                log |= rule.getLog();

Loading