Loading core/java/android/content/IntentFilter.java +17 −14 Original line number Original line Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.os.Parcelable; import android.os.PatternMatcher; import android.os.PatternMatcher; import android.text.TextUtils; import android.text.TextUtils; import android.util.AndroidException; import android.util.AndroidException; import android.util.ArraySet; import android.util.Log; import android.util.Log; import android.util.Printer; import android.util.Printer; import android.util.proto.ProtoOutputStream; import android.util.proto.ProtoOutputStream; Loading Loading @@ -302,7 +303,7 @@ public class IntentFilter implements Parcelable { @UnsupportedAppUsage @UnsupportedAppUsage private int mOrder; private int mOrder; @UnsupportedAppUsage @UnsupportedAppUsage private final ArrayList<String> mActions; private final ArraySet<String> mActions; private ArrayList<String> mCategories = null; private ArrayList<String> mCategories = null; private ArrayList<String> mDataSchemes = null; private ArrayList<String> mDataSchemes = null; private ArrayList<PatternMatcher> mDataSchemeSpecificParts = null; private ArrayList<PatternMatcher> mDataSchemeSpecificParts = null; Loading Loading @@ -433,7 +434,7 @@ public class IntentFilter implements Parcelable { */ */ public IntentFilter() { public IntentFilter() { mPriority = 0; mPriority = 0; mActions = new ArrayList<String>(); mActions = new ArraySet<>(); } } /** /** Loading @@ -445,7 +446,7 @@ public class IntentFilter implements Parcelable { */ */ public IntentFilter(String action) { public IntentFilter(String action) { mPriority = 0; mPriority = 0; mActions = new ArrayList<String>(); mActions = new ArraySet<>(); addAction(action); addAction(action); } } Loading @@ -468,7 +469,7 @@ public class IntentFilter implements Parcelable { public IntentFilter(String action, String dataType) public IntentFilter(String action, String dataType) throws MalformedMimeTypeException { throws MalformedMimeTypeException { mPriority = 0; mPriority = 0; mActions = new ArrayList<String>(); mActions = new ArraySet<>(); addAction(action); addAction(action); addDataType(dataType); addDataType(dataType); } } Loading @@ -481,7 +482,7 @@ public class IntentFilter implements Parcelable { public IntentFilter(IntentFilter o) { public IntentFilter(IntentFilter o) { mPriority = o.mPriority; mPriority = o.mPriority; mOrder = o.mOrder; mOrder = o.mOrder; mActions = new ArrayList<String>(o.mActions); mActions = new ArraySet<>(o.mActions); if (o.mCategories != null) { if (o.mCategories != null) { mCategories = new ArrayList<String>(o.mCategories); mCategories = new ArrayList<String>(o.mCategories); } } Loading Loading @@ -742,10 +743,8 @@ public class IntentFilter implements Parcelable { * @param action Name of the action to match, such as Intent.ACTION_VIEW. * @param action Name of the action to match, such as Intent.ACTION_VIEW. */ */ public final void addAction(String action) { public final void addAction(String action) { if (!mActions.contains(action)) { mActions.add(action.intern()); mActions.add(action.intern()); } } } /** /** * Return the number of actions in the filter. * Return the number of actions in the filter. Loading @@ -758,7 +757,7 @@ public class IntentFilter implements Parcelable { * Return an action in the filter. * Return an action in the filter. */ */ public final String getAction(int index) { public final String getAction(int index) { return mActions.get(index); return mActions.valueAt(index); } } /** /** Loading Loading @@ -797,8 +796,11 @@ public class IntentFilter implements Parcelable { if (ignoreActions == null) { if (ignoreActions == null) { return !mActions.isEmpty(); return !mActions.isEmpty(); } } if (mActions.size() > ignoreActions.size()) { return true; // some actions are definitely not ignored } for (int i = mActions.size() - 1; i >= 0; i--) { for (int i = mActions.size() - 1; i >= 0; i--) { if (!ignoreActions.contains(mActions.get(i))) { if (!ignoreActions.contains(mActions.valueAt(i))) { return true; return true; } } } } Loading Loading @@ -1918,7 +1920,7 @@ public class IntentFilter implements Parcelable { int N = countActions(); int N = countActions(); for (int i=0; i<N; i++) { for (int i=0; i<N; i++) { serializer.startTag(null, ACTION_STR); serializer.startTag(null, ACTION_STR); serializer.attribute(null, NAME_STR, mActions.get(i)); serializer.attribute(null, NAME_STR, mActions.valueAt(i)); serializer.endTag(null, ACTION_STR); serializer.endTag(null, ACTION_STR); } } N = countCategories(); N = countCategories(); Loading Loading @@ -2313,7 +2315,7 @@ public class IntentFilter implements Parcelable { } } public final void writeToParcel(Parcel dest, int flags) { public final void writeToParcel(Parcel dest, int flags) { dest.writeStringList(mActions); dest.writeStringArray(mActions.toArray(new String[mActions.size()])); if (mCategories != null) { if (mCategories != null) { dest.writeInt(1); dest.writeInt(1); dest.writeStringList(mCategories); dest.writeStringList(mCategories); Loading Loading @@ -2407,8 +2409,9 @@ public class IntentFilter implements Parcelable { /** @hide */ /** @hide */ public IntentFilter(Parcel source) { public IntentFilter(Parcel source) { mActions = new ArrayList<String>(); List<String> actions = new ArrayList<>(); source.readStringList(mActions); source.readStringList(actions); mActions = new ArraySet<>(actions); if (source.readInt() != 0) { if (source.readInt() != 0) { mCategories = new ArrayList<String>(); mCategories = new ArrayList<String>(); source.readStringList(mCategories); source.readStringList(mCategories); Loading services/core/java/com/android/server/pm/AppsFilterBase.java +2 −3 Original line number Original line Diff line number Diff line Loading @@ -44,7 +44,6 @@ import com.android.server.pm.pkg.PackageStateInternal; import com.android.server.pm.snapshot.PackageDataSnapshot; import com.android.server.pm.snapshot.PackageDataSnapshot; import com.android.server.utils.SnapshotCache; import com.android.server.utils.SnapshotCache; import com.android.server.utils.Watched; import com.android.server.utils.Watched; import com.android.server.utils.WatchedArrayList; import com.android.server.utils.WatchedArrayMap; import com.android.server.utils.WatchedArrayMap; import com.android.server.utils.WatchedArraySet; import com.android.server.utils.WatchedArraySet; import com.android.server.utils.WatchedSparseBooleanMatrix; import com.android.server.utils.WatchedSparseBooleanMatrix; Loading Loading @@ -179,9 +178,9 @@ public abstract class AppsFilterBase implements AppsFilterSnapshot { @NonNull @NonNull @Watched @Watched protected WatchedArrayList<String> mProtectedBroadcasts; protected WatchedArraySet<String> mProtectedBroadcasts; @NonNull @NonNull protected SnapshotCache<WatchedArrayList<String>> mProtectedBroadcastsSnapshot; protected SnapshotCache<WatchedArraySet<String>> mProtectedBroadcastsSnapshot; /** /** * This structure maps uid -> uid and indicates whether access from the first should be * This structure maps uid -> uid and indicates whether access from the first should be Loading services/core/java/com/android/server/pm/AppsFilterImpl.java +18 −10 Original line number Original line Diff line number Diff line Loading @@ -73,7 +73,6 @@ import com.android.server.utils.Snappable; import com.android.server.utils.SnapshotCache; import com.android.server.utils.SnapshotCache; import com.android.server.utils.Watchable; import com.android.server.utils.Watchable; import com.android.server.utils.WatchableImpl; import com.android.server.utils.WatchableImpl; import com.android.server.utils.WatchedArrayList; import com.android.server.utils.WatchedArraySet; import com.android.server.utils.WatchedArraySet; import com.android.server.utils.WatchedSparseBooleanMatrix; import com.android.server.utils.WatchedSparseBooleanMatrix; import com.android.server.utils.WatchedSparseSetArray; import com.android.server.utils.WatchedSparseSetArray; Loading Loading @@ -223,7 +222,7 @@ public final class AppsFilterImpl extends AppsFilterLocked implements Watchable, mForceQueryable = new WatchedArraySet<>(); mForceQueryable = new WatchedArraySet<>(); mForceQueryableSnapshot = new SnapshotCache.Auto<>( mForceQueryableSnapshot = new SnapshotCache.Auto<>( mForceQueryable, mForceQueryable, "AppsFilter.mForceQueryable"); mForceQueryable, mForceQueryable, "AppsFilter.mForceQueryable"); mProtectedBroadcasts = new WatchedArrayList<>(); mProtectedBroadcasts = new WatchedArraySet<>(); mProtectedBroadcastsSnapshot = new SnapshotCache.Auto<>( mProtectedBroadcastsSnapshot = new SnapshotCache.Auto<>( mProtectedBroadcasts, mProtectedBroadcasts, "AppsFilter.mProtectedBroadcasts"); mProtectedBroadcasts, mProtectedBroadcasts, "AppsFilter.mProtectedBroadcasts"); mPermissionToUids = new HashMap<>(); mPermissionToUids = new HashMap<>(); Loading Loading @@ -573,14 +572,18 @@ public final class AppsFilterImpl extends AppsFilterLocked implements Watchable, return null; return null; } } final List<String> newBroadcasts = newPkg.getProtectedBroadcasts(); if (newBroadcasts.size() != 0) { final boolean protectedBroadcastsChanged; final boolean protectedBroadcastsChanged; synchronized (mProtectedBroadcastsLock) { synchronized (mProtectedBroadcastsLock) { protectedBroadcastsChanged = final int oldSize = mProtectedBroadcasts.size(); mProtectedBroadcasts.addAll(newPkg.getProtectedBroadcasts()); mProtectedBroadcasts.addAll(newBroadcasts); protectedBroadcastsChanged = mProtectedBroadcasts.size() != oldSize; } } if (protectedBroadcastsChanged) { if (protectedBroadcastsChanged) { mQueriesViaComponentRequireRecompute.set(true); mQueriesViaComponentRequireRecompute.set(true); } } } final boolean newIsForceQueryable; final boolean newIsForceQueryable; synchronized (mForceQueryableLock) { synchronized (mForceQueryableLock) { Loading Loading @@ -1149,7 +1152,12 @@ public final class AppsFilterImpl extends AppsFilterLocked implements Watchable, final ArrayList<String> protectedBroadcasts = new ArrayList<>( final ArrayList<String> protectedBroadcasts = new ArrayList<>( mProtectedBroadcasts.untrackedStorage()); mProtectedBroadcasts.untrackedStorage()); collectProtectedBroadcasts(settings, removingPackageName); collectProtectedBroadcasts(settings, removingPackageName); protectedBroadcastsChanged = !mProtectedBroadcasts.containsAll(protectedBroadcasts); for (int i = 0; i < protectedBroadcasts.size(); ++i) { if (!mProtectedBroadcasts.contains(protectedBroadcasts.get(i))) { protectedBroadcastsChanged = true; break; } } } } } } Loading services/core/java/com/android/server/pm/AppsFilterUtils.java +6 −6 Original line number Original line Diff line number Diff line Loading @@ -29,7 +29,7 @@ import com.android.server.pm.pkg.component.ParsedComponent; import com.android.server.pm.pkg.component.ParsedIntentInfo; import com.android.server.pm.pkg.component.ParsedIntentInfo; import com.android.server.pm.pkg.component.ParsedMainComponent; import com.android.server.pm.pkg.component.ParsedMainComponent; import com.android.server.pm.pkg.component.ParsedProvider; import com.android.server.pm.pkg.component.ParsedProvider; import com.android.server.utils.WatchedArrayList; import com.android.server.utils.WatchedArraySet; import java.util.List; import java.util.List; import java.util.Set; import java.util.Set; Loading @@ -45,7 +45,7 @@ final class AppsFilterUtils { /** Returns true if the querying package may query for the potential target package */ /** Returns true if the querying package may query for the potential target package */ public static boolean canQueryViaComponents(AndroidPackage querying, public static boolean canQueryViaComponents(AndroidPackage querying, AndroidPackage potentialTarget, WatchedArrayList<String> protectedBroadcasts) { AndroidPackage potentialTarget, WatchedArraySet<String> protectedBroadcasts) { if (!querying.getQueriesIntents().isEmpty()) { if (!querying.getQueriesIntents().isEmpty()) { for (Intent intent : querying.getQueriesIntents()) { for (Intent intent : querying.getQueriesIntents()) { if (matchesPackage(intent, potentialTarget, protectedBroadcasts)) { if (matchesPackage(intent, potentialTarget, protectedBroadcasts)) { Loading Loading @@ -117,7 +117,7 @@ final class AppsFilterUtils { } } private static boolean matchesPackage(Intent intent, AndroidPackage potentialTarget, private static boolean matchesPackage(Intent intent, AndroidPackage potentialTarget, WatchedArrayList<String> protectedBroadcasts) { WatchedArraySet<String> protectedBroadcasts) { if (matchesAnyComponents( if (matchesAnyComponents( intent, potentialTarget.getServices(), null /*protectedBroadcasts*/)) { intent, potentialTarget.getServices(), null /*protectedBroadcasts*/)) { return true; return true; Loading @@ -138,7 +138,7 @@ final class AppsFilterUtils { private static boolean matchesAnyComponents(Intent intent, private static boolean matchesAnyComponents(Intent intent, List<? extends ParsedMainComponent> components, List<? extends ParsedMainComponent> components, WatchedArrayList<String> protectedBroadcasts) { WatchedArraySet<String> protectedBroadcasts) { for (int i = ArrayUtils.size(components) - 1; i >= 0; i--) { for (int i = ArrayUtils.size(components) - 1; i >= 0; i--) { ParsedMainComponent component = components.get(i); ParsedMainComponent component = components.get(i); if (!component.isExported()) { if (!component.isExported()) { Loading @@ -152,7 +152,7 @@ final class AppsFilterUtils { } } private static boolean matchesAnyFilter(Intent intent, ParsedComponent component, private static boolean matchesAnyFilter(Intent intent, ParsedComponent component, WatchedArrayList<String> protectedBroadcasts) { WatchedArraySet<String> protectedBroadcasts) { List<ParsedIntentInfo> intents = component.getIntents(); List<ParsedIntentInfo> intents = component.getIntents(); for (int i = ArrayUtils.size(intents) - 1; i >= 0; i--) { for (int i = ArrayUtils.size(intents) - 1; i >= 0; i--) { IntentFilter intentFilter = intents.get(i).getIntentFilter(); IntentFilter intentFilter = intents.get(i).getIntentFilter(); Loading @@ -164,7 +164,7 @@ final class AppsFilterUtils { } } private static boolean matchesIntentFilter(Intent intent, IntentFilter intentFilter, private static boolean matchesIntentFilter(Intent intent, IntentFilter intentFilter, @Nullable WatchedArrayList<String> protectedBroadcasts) { @Nullable WatchedArraySet<String> protectedBroadcasts) { return intentFilter.match(intent.getAction(), intent.getType(), intent.getScheme(), return intentFilter.match(intent.getAction(), intent.getType(), intent.getScheme(), intent.getData(), intent.getCategories(), "AppsFilter", true, intent.getData(), intent.getCategories(), "AppsFilter", true, protectedBroadcasts != null ? protectedBroadcasts.untrackedStorage() : null) > 0; protectedBroadcasts != null ? protectedBroadcasts.untrackedStorage() : null) > 0; Loading Loading
core/java/android/content/IntentFilter.java +17 −14 Original line number Original line Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.os.Parcelable; import android.os.PatternMatcher; import android.os.PatternMatcher; import android.text.TextUtils; import android.text.TextUtils; import android.util.AndroidException; import android.util.AndroidException; import android.util.ArraySet; import android.util.Log; import android.util.Log; import android.util.Printer; import android.util.Printer; import android.util.proto.ProtoOutputStream; import android.util.proto.ProtoOutputStream; Loading Loading @@ -302,7 +303,7 @@ public class IntentFilter implements Parcelable { @UnsupportedAppUsage @UnsupportedAppUsage private int mOrder; private int mOrder; @UnsupportedAppUsage @UnsupportedAppUsage private final ArrayList<String> mActions; private final ArraySet<String> mActions; private ArrayList<String> mCategories = null; private ArrayList<String> mCategories = null; private ArrayList<String> mDataSchemes = null; private ArrayList<String> mDataSchemes = null; private ArrayList<PatternMatcher> mDataSchemeSpecificParts = null; private ArrayList<PatternMatcher> mDataSchemeSpecificParts = null; Loading Loading @@ -433,7 +434,7 @@ public class IntentFilter implements Parcelable { */ */ public IntentFilter() { public IntentFilter() { mPriority = 0; mPriority = 0; mActions = new ArrayList<String>(); mActions = new ArraySet<>(); } } /** /** Loading @@ -445,7 +446,7 @@ public class IntentFilter implements Parcelable { */ */ public IntentFilter(String action) { public IntentFilter(String action) { mPriority = 0; mPriority = 0; mActions = new ArrayList<String>(); mActions = new ArraySet<>(); addAction(action); addAction(action); } } Loading @@ -468,7 +469,7 @@ public class IntentFilter implements Parcelable { public IntentFilter(String action, String dataType) public IntentFilter(String action, String dataType) throws MalformedMimeTypeException { throws MalformedMimeTypeException { mPriority = 0; mPriority = 0; mActions = new ArrayList<String>(); mActions = new ArraySet<>(); addAction(action); addAction(action); addDataType(dataType); addDataType(dataType); } } Loading @@ -481,7 +482,7 @@ public class IntentFilter implements Parcelable { public IntentFilter(IntentFilter o) { public IntentFilter(IntentFilter o) { mPriority = o.mPriority; mPriority = o.mPriority; mOrder = o.mOrder; mOrder = o.mOrder; mActions = new ArrayList<String>(o.mActions); mActions = new ArraySet<>(o.mActions); if (o.mCategories != null) { if (o.mCategories != null) { mCategories = new ArrayList<String>(o.mCategories); mCategories = new ArrayList<String>(o.mCategories); } } Loading Loading @@ -742,10 +743,8 @@ public class IntentFilter implements Parcelable { * @param action Name of the action to match, such as Intent.ACTION_VIEW. * @param action Name of the action to match, such as Intent.ACTION_VIEW. */ */ public final void addAction(String action) { public final void addAction(String action) { if (!mActions.contains(action)) { mActions.add(action.intern()); mActions.add(action.intern()); } } } /** /** * Return the number of actions in the filter. * Return the number of actions in the filter. Loading @@ -758,7 +757,7 @@ public class IntentFilter implements Parcelable { * Return an action in the filter. * Return an action in the filter. */ */ public final String getAction(int index) { public final String getAction(int index) { return mActions.get(index); return mActions.valueAt(index); } } /** /** Loading Loading @@ -797,8 +796,11 @@ public class IntentFilter implements Parcelable { if (ignoreActions == null) { if (ignoreActions == null) { return !mActions.isEmpty(); return !mActions.isEmpty(); } } if (mActions.size() > ignoreActions.size()) { return true; // some actions are definitely not ignored } for (int i = mActions.size() - 1; i >= 0; i--) { for (int i = mActions.size() - 1; i >= 0; i--) { if (!ignoreActions.contains(mActions.get(i))) { if (!ignoreActions.contains(mActions.valueAt(i))) { return true; return true; } } } } Loading Loading @@ -1918,7 +1920,7 @@ public class IntentFilter implements Parcelable { int N = countActions(); int N = countActions(); for (int i=0; i<N; i++) { for (int i=0; i<N; i++) { serializer.startTag(null, ACTION_STR); serializer.startTag(null, ACTION_STR); serializer.attribute(null, NAME_STR, mActions.get(i)); serializer.attribute(null, NAME_STR, mActions.valueAt(i)); serializer.endTag(null, ACTION_STR); serializer.endTag(null, ACTION_STR); } } N = countCategories(); N = countCategories(); Loading Loading @@ -2313,7 +2315,7 @@ public class IntentFilter implements Parcelable { } } public final void writeToParcel(Parcel dest, int flags) { public final void writeToParcel(Parcel dest, int flags) { dest.writeStringList(mActions); dest.writeStringArray(mActions.toArray(new String[mActions.size()])); if (mCategories != null) { if (mCategories != null) { dest.writeInt(1); dest.writeInt(1); dest.writeStringList(mCategories); dest.writeStringList(mCategories); Loading Loading @@ -2407,8 +2409,9 @@ public class IntentFilter implements Parcelable { /** @hide */ /** @hide */ public IntentFilter(Parcel source) { public IntentFilter(Parcel source) { mActions = new ArrayList<String>(); List<String> actions = new ArrayList<>(); source.readStringList(mActions); source.readStringList(actions); mActions = new ArraySet<>(actions); if (source.readInt() != 0) { if (source.readInt() != 0) { mCategories = new ArrayList<String>(); mCategories = new ArrayList<String>(); source.readStringList(mCategories); source.readStringList(mCategories); Loading
services/core/java/com/android/server/pm/AppsFilterBase.java +2 −3 Original line number Original line Diff line number Diff line Loading @@ -44,7 +44,6 @@ import com.android.server.pm.pkg.PackageStateInternal; import com.android.server.pm.snapshot.PackageDataSnapshot; import com.android.server.pm.snapshot.PackageDataSnapshot; import com.android.server.utils.SnapshotCache; import com.android.server.utils.SnapshotCache; import com.android.server.utils.Watched; import com.android.server.utils.Watched; import com.android.server.utils.WatchedArrayList; import com.android.server.utils.WatchedArrayMap; import com.android.server.utils.WatchedArrayMap; import com.android.server.utils.WatchedArraySet; import com.android.server.utils.WatchedArraySet; import com.android.server.utils.WatchedSparseBooleanMatrix; import com.android.server.utils.WatchedSparseBooleanMatrix; Loading Loading @@ -179,9 +178,9 @@ public abstract class AppsFilterBase implements AppsFilterSnapshot { @NonNull @NonNull @Watched @Watched protected WatchedArrayList<String> mProtectedBroadcasts; protected WatchedArraySet<String> mProtectedBroadcasts; @NonNull @NonNull protected SnapshotCache<WatchedArrayList<String>> mProtectedBroadcastsSnapshot; protected SnapshotCache<WatchedArraySet<String>> mProtectedBroadcastsSnapshot; /** /** * This structure maps uid -> uid and indicates whether access from the first should be * This structure maps uid -> uid and indicates whether access from the first should be Loading
services/core/java/com/android/server/pm/AppsFilterImpl.java +18 −10 Original line number Original line Diff line number Diff line Loading @@ -73,7 +73,6 @@ import com.android.server.utils.Snappable; import com.android.server.utils.SnapshotCache; import com.android.server.utils.SnapshotCache; import com.android.server.utils.Watchable; import com.android.server.utils.Watchable; import com.android.server.utils.WatchableImpl; import com.android.server.utils.WatchableImpl; import com.android.server.utils.WatchedArrayList; import com.android.server.utils.WatchedArraySet; import com.android.server.utils.WatchedArraySet; import com.android.server.utils.WatchedSparseBooleanMatrix; import com.android.server.utils.WatchedSparseBooleanMatrix; import com.android.server.utils.WatchedSparseSetArray; import com.android.server.utils.WatchedSparseSetArray; Loading Loading @@ -223,7 +222,7 @@ public final class AppsFilterImpl extends AppsFilterLocked implements Watchable, mForceQueryable = new WatchedArraySet<>(); mForceQueryable = new WatchedArraySet<>(); mForceQueryableSnapshot = new SnapshotCache.Auto<>( mForceQueryableSnapshot = new SnapshotCache.Auto<>( mForceQueryable, mForceQueryable, "AppsFilter.mForceQueryable"); mForceQueryable, mForceQueryable, "AppsFilter.mForceQueryable"); mProtectedBroadcasts = new WatchedArrayList<>(); mProtectedBroadcasts = new WatchedArraySet<>(); mProtectedBroadcastsSnapshot = new SnapshotCache.Auto<>( mProtectedBroadcastsSnapshot = new SnapshotCache.Auto<>( mProtectedBroadcasts, mProtectedBroadcasts, "AppsFilter.mProtectedBroadcasts"); mProtectedBroadcasts, mProtectedBroadcasts, "AppsFilter.mProtectedBroadcasts"); mPermissionToUids = new HashMap<>(); mPermissionToUids = new HashMap<>(); Loading Loading @@ -573,14 +572,18 @@ public final class AppsFilterImpl extends AppsFilterLocked implements Watchable, return null; return null; } } final List<String> newBroadcasts = newPkg.getProtectedBroadcasts(); if (newBroadcasts.size() != 0) { final boolean protectedBroadcastsChanged; final boolean protectedBroadcastsChanged; synchronized (mProtectedBroadcastsLock) { synchronized (mProtectedBroadcastsLock) { protectedBroadcastsChanged = final int oldSize = mProtectedBroadcasts.size(); mProtectedBroadcasts.addAll(newPkg.getProtectedBroadcasts()); mProtectedBroadcasts.addAll(newBroadcasts); protectedBroadcastsChanged = mProtectedBroadcasts.size() != oldSize; } } if (protectedBroadcastsChanged) { if (protectedBroadcastsChanged) { mQueriesViaComponentRequireRecompute.set(true); mQueriesViaComponentRequireRecompute.set(true); } } } final boolean newIsForceQueryable; final boolean newIsForceQueryable; synchronized (mForceQueryableLock) { synchronized (mForceQueryableLock) { Loading Loading @@ -1149,7 +1152,12 @@ public final class AppsFilterImpl extends AppsFilterLocked implements Watchable, final ArrayList<String> protectedBroadcasts = new ArrayList<>( final ArrayList<String> protectedBroadcasts = new ArrayList<>( mProtectedBroadcasts.untrackedStorage()); mProtectedBroadcasts.untrackedStorage()); collectProtectedBroadcasts(settings, removingPackageName); collectProtectedBroadcasts(settings, removingPackageName); protectedBroadcastsChanged = !mProtectedBroadcasts.containsAll(protectedBroadcasts); for (int i = 0; i < protectedBroadcasts.size(); ++i) { if (!mProtectedBroadcasts.contains(protectedBroadcasts.get(i))) { protectedBroadcastsChanged = true; break; } } } } } } Loading
services/core/java/com/android/server/pm/AppsFilterUtils.java +6 −6 Original line number Original line Diff line number Diff line Loading @@ -29,7 +29,7 @@ import com.android.server.pm.pkg.component.ParsedComponent; import com.android.server.pm.pkg.component.ParsedIntentInfo; import com.android.server.pm.pkg.component.ParsedIntentInfo; import com.android.server.pm.pkg.component.ParsedMainComponent; import com.android.server.pm.pkg.component.ParsedMainComponent; import com.android.server.pm.pkg.component.ParsedProvider; import com.android.server.pm.pkg.component.ParsedProvider; import com.android.server.utils.WatchedArrayList; import com.android.server.utils.WatchedArraySet; import java.util.List; import java.util.List; import java.util.Set; import java.util.Set; Loading @@ -45,7 +45,7 @@ final class AppsFilterUtils { /** Returns true if the querying package may query for the potential target package */ /** Returns true if the querying package may query for the potential target package */ public static boolean canQueryViaComponents(AndroidPackage querying, public static boolean canQueryViaComponents(AndroidPackage querying, AndroidPackage potentialTarget, WatchedArrayList<String> protectedBroadcasts) { AndroidPackage potentialTarget, WatchedArraySet<String> protectedBroadcasts) { if (!querying.getQueriesIntents().isEmpty()) { if (!querying.getQueriesIntents().isEmpty()) { for (Intent intent : querying.getQueriesIntents()) { for (Intent intent : querying.getQueriesIntents()) { if (matchesPackage(intent, potentialTarget, protectedBroadcasts)) { if (matchesPackage(intent, potentialTarget, protectedBroadcasts)) { Loading Loading @@ -117,7 +117,7 @@ final class AppsFilterUtils { } } private static boolean matchesPackage(Intent intent, AndroidPackage potentialTarget, private static boolean matchesPackage(Intent intent, AndroidPackage potentialTarget, WatchedArrayList<String> protectedBroadcasts) { WatchedArraySet<String> protectedBroadcasts) { if (matchesAnyComponents( if (matchesAnyComponents( intent, potentialTarget.getServices(), null /*protectedBroadcasts*/)) { intent, potentialTarget.getServices(), null /*protectedBroadcasts*/)) { return true; return true; Loading @@ -138,7 +138,7 @@ final class AppsFilterUtils { private static boolean matchesAnyComponents(Intent intent, private static boolean matchesAnyComponents(Intent intent, List<? extends ParsedMainComponent> components, List<? extends ParsedMainComponent> components, WatchedArrayList<String> protectedBroadcasts) { WatchedArraySet<String> protectedBroadcasts) { for (int i = ArrayUtils.size(components) - 1; i >= 0; i--) { for (int i = ArrayUtils.size(components) - 1; i >= 0; i--) { ParsedMainComponent component = components.get(i); ParsedMainComponent component = components.get(i); if (!component.isExported()) { if (!component.isExported()) { Loading @@ -152,7 +152,7 @@ final class AppsFilterUtils { } } private static boolean matchesAnyFilter(Intent intent, ParsedComponent component, private static boolean matchesAnyFilter(Intent intent, ParsedComponent component, WatchedArrayList<String> protectedBroadcasts) { WatchedArraySet<String> protectedBroadcasts) { List<ParsedIntentInfo> intents = component.getIntents(); List<ParsedIntentInfo> intents = component.getIntents(); for (int i = ArrayUtils.size(intents) - 1; i >= 0; i--) { for (int i = ArrayUtils.size(intents) - 1; i >= 0; i--) { IntentFilter intentFilter = intents.get(i).getIntentFilter(); IntentFilter intentFilter = intents.get(i).getIntentFilter(); Loading @@ -164,7 +164,7 @@ final class AppsFilterUtils { } } private static boolean matchesIntentFilter(Intent intent, IntentFilter intentFilter, private static boolean matchesIntentFilter(Intent intent, IntentFilter intentFilter, @Nullable WatchedArrayList<String> protectedBroadcasts) { @Nullable WatchedArraySet<String> protectedBroadcasts) { return intentFilter.match(intent.getAction(), intent.getType(), intent.getScheme(), return intentFilter.match(intent.getAction(), intent.getType(), intent.getScheme(), intent.getData(), intent.getCategories(), "AppsFilter", true, intent.getData(), intent.getCategories(), "AppsFilter", true, protectedBroadcasts != null ? protectedBroadcasts.untrackedStorage() : null) > 0; protectedBroadcasts != null ? protectedBroadcasts.untrackedStorage() : null) > 0; Loading