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

Commit b6223793 authored by Ben Gruver's avatar Ben Gruver
Browse files

Add support for service intents

Change-Id: Ie090896b70bd6860181a021818fa6514d2e57a3f
(cherry picked from commit 8b028a6564d9e3af07e2424dc71d287550ebede7)
parent e64ff1b3
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -832,6 +832,10 @@ public final class ActiveServices {
                        + " requires " + r.permission);
                return new ServiceLookupResult(null, r.permission);
            }
            if (!mAm.mIntentFirewall.checkService(service, callingUid, callingPid, resolvedType,
                    r.appInfo)) {
                return null;
            }
            return new ServiceLookupResult(r, null);
        }
        return null;
+1 −1
Original line number Diff line number Diff line
@@ -1155,7 +1155,7 @@ public final class ActivityStackSupervisor {
        }

        boolean abort = !mService.mIntentFirewall.checkStartActivity(intent, callingUid,
                callingPid, resolvedType, aInfo);
                callingPid, resolvedType, aInfo.applicationInfo);

        if (mService.mController != null) {
            try {
+17 −6
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ import android.app.AppGlobals;
import android.content.ComponentName;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
import android.os.Environment;
@@ -119,15 +119,26 @@ public class IntentFirewall {
     * It is assumed the caller is already holding the global ActivityManagerService lock.
     */
    public boolean checkStartActivity(Intent intent, int callerUid, int callerPid,
            String resolvedType, ActivityInfo resolvedActivity) {
        List<Rule> matchingRules = mActivityResolver.queryIntent(intent, resolvedType, false, 0);
            String resolvedType, ApplicationInfo resolvedApp) {
        return checkIntent(mActivityResolver, 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 checkIntent(FirewallIntentResolver resolver, 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,
                    resolvedActivity.applicationInfo)) {
            if (rule.matches(this, intent, callerUid, callerPid, resolvedType, resolvedApp)) {
                block |= rule.getBlock();
                log |= rule.getLog();

@@ -140,7 +151,7 @@ public class IntentFirewall {
        }

        if (log) {
            logIntent(TYPE_ACTIVITY, intent, callerUid, resolvedType);
            logIntent(intentType, intent, callerUid, resolvedType);
        }

        return !block;