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

Commit c38dc545 authored by Nate Myren's avatar Nate Myren
Browse files

Remove invalid source tags in AppOpsPolicy

Ensure that, if present, null, "null", and "" attribution tags are not
considered valid source tags

Test: build
Bug: 189484870
Change-Id: I65601c9bb79399bf0f63fbb540090ed3ed6f8337
parent 1de80b1d
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -43,8 +43,6 @@ import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.function.DecFunction;
import com.android.internal.util.function.HeptFunction;
import com.android.internal.util.function.HexFunction;
import com.android.internal.util.function.NonaFunction;
import com.android.internal.util.function.OctFunction;
import com.android.internal.util.function.QuadFunction;
import com.android.internal.util.function.QuintFunction;
import com.android.internal.util.function.TriFunction;
@@ -313,6 +311,17 @@ public final class AppOpsPolicy implements AppOpsManagerInternal.CheckOpsDelegat
            if (appIdTags == null) {
                appIdTags = new ArrayMap<>();
            }

            // Remove any invalid tags
            boolean nullRemoved = packageTags.remove(null);
            boolean nullStrRemoved = packageTags.remove("null");
            boolean emptyRemoved = packageTags.remove("");
            if (nullRemoved || nullStrRemoved || emptyRemoved) {
                Log.e(LOG_TAG, "Attempted to add invalid source attribution tag, removed "
                        + "null: " + nullRemoved + " removed \"null\": " + nullStrRemoved
                        + " removed empty string: " + emptyRemoved);
            }

            appIdTags.put(packageName, packageTags);
            datastore.put(appId, appIdTags);
        } else if (appIdTags != null) {