Loading services/core/java/com/android/server/am/BroadcastFilter.java +0 −3 Original line number Diff line number Diff line Loading @@ -132,9 +132,6 @@ public final class BroadcastFilter extends IntentFilter { @VisibleForTesting static int calculateAdjustedPriority(int owningUid, int priority, ApplicationInfo applicationInfo, PlatformCompat platformCompat) { if (!Flags.restrictPriorityValues()) { return priority; } final long token = Binder.clearCallingIdentity(); try { if (!platformCompat.isChangeEnabledInternalNoLogging( Loading services/core/java/com/android/server/am/broadcasts_flags.aconfig +0 −8 Original line number Diff line number Diff line package: "com.android.server.am" container: "system" flag { name: "restrict_priority_values" namespace: "backstage_power" description: "Restrict priority values defined by non-system apps" is_fixed_read_only: true bug: "369487976" } flag { name: "limit_priority_scope" namespace: "backstage_power" Loading services/tests/mockingservicestests/src/com/android/server/am/BroadcastFilterTest.java +0 −76 Original line number Diff line number Diff line Loading @@ -21,15 +21,12 @@ import static android.content.IntentFilter.SYSTEM_LOW_PRIORITY; import static com.google.common.truth.Truth.assertWithMessage; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import android.content.pm.ApplicationInfo; import android.os.Process; import android.platform.test.annotations.DisableFlags; import android.platform.test.annotations.EnableFlags; import android.platform.test.flag.junit.SetFlagsRule; import android.util.Pair; Loading Loading @@ -62,7 +59,6 @@ public class BroadcastFilterTest { } @Test @EnableFlags(Flags.FLAG_RESTRICT_PRIORITY_VALUES) public void testCalculateAdjustedPriority() { { // Pairs of {initial-priority, expected-adjusted-priority} Loading Loading @@ -96,7 +92,6 @@ public class BroadcastFilterTest { } @Test @EnableFlags(Flags.FLAG_RESTRICT_PRIORITY_VALUES) public void testCalculateAdjustedPriority_withChangeIdDisabled() { doReturn(false).when(mPlatformCompat).isChangeEnabledInternalNoLogging( eq(BroadcastFilter.RESTRICT_PRIORITY_VALUES), any(ApplicationInfo.class)); Loading Loading @@ -132,77 +127,6 @@ public class BroadcastFilterTest { } } @Test @DisableFlags(Flags.FLAG_RESTRICT_PRIORITY_VALUES) public void testCalculateAdjustedPriority_withFlagDisabled() { { // Pairs of {initial-priority, expected-adjusted-priority} final Pair<Integer, Integer>[] priorities = new Pair[] { Pair.create(SYSTEM_HIGH_PRIORITY, SYSTEM_HIGH_PRIORITY), Pair.create(SYSTEM_LOW_PRIORITY, SYSTEM_LOW_PRIORITY), Pair.create(SYSTEM_HIGH_PRIORITY + 1, SYSTEM_HIGH_PRIORITY + 1), Pair.create(SYSTEM_LOW_PRIORITY - 1, SYSTEM_LOW_PRIORITY - 1), Pair.create(SYSTEM_HIGH_PRIORITY - 2, SYSTEM_HIGH_PRIORITY - 2), Pair.create(SYSTEM_LOW_PRIORITY + 2, SYSTEM_LOW_PRIORITY + 2) }; for (Pair<Integer, Integer> priorityPair : priorities) { assertAdjustedPriorityForSystemUid(priorityPair.first, priorityPair.second); } } { // Pairs of {initial-priority, expected-adjusted-priority} final Pair<Integer, Integer>[] priorities = new Pair[] { Pair.create(SYSTEM_HIGH_PRIORITY, SYSTEM_HIGH_PRIORITY), Pair.create(SYSTEM_LOW_PRIORITY, SYSTEM_LOW_PRIORITY), Pair.create(SYSTEM_HIGH_PRIORITY + 1, SYSTEM_HIGH_PRIORITY + 1), Pair.create(SYSTEM_LOW_PRIORITY - 1, SYSTEM_LOW_PRIORITY - 1), Pair.create(SYSTEM_HIGH_PRIORITY - 2, SYSTEM_HIGH_PRIORITY - 2), Pair.create(SYSTEM_LOW_PRIORITY + 2, SYSTEM_LOW_PRIORITY + 2) }; for (Pair<Integer, Integer> priorityPair : priorities) { assertAdjustedPriorityForAppUid(priorityPair.first, priorityPair.second); } } } @Test @DisableFlags(Flags.FLAG_RESTRICT_PRIORITY_VALUES) public void testCalculateAdjustedPriority_withFlagDisabled_withChangeIdDisabled() { doReturn(false).when(mPlatformCompat).isChangeEnabledByUidInternalNoLogging( eq(BroadcastFilter.RESTRICT_PRIORITY_VALUES), anyInt()); { // Pairs of {initial-priority, expected-adjusted-priority} final Pair<Integer, Integer>[] priorities = new Pair[] { Pair.create(SYSTEM_HIGH_PRIORITY, SYSTEM_HIGH_PRIORITY), Pair.create(SYSTEM_LOW_PRIORITY, SYSTEM_LOW_PRIORITY), Pair.create(SYSTEM_HIGH_PRIORITY + 1, SYSTEM_HIGH_PRIORITY + 1), Pair.create(SYSTEM_LOW_PRIORITY - 1, SYSTEM_LOW_PRIORITY - 1), Pair.create(SYSTEM_HIGH_PRIORITY - 2, SYSTEM_HIGH_PRIORITY - 2), Pair.create(SYSTEM_LOW_PRIORITY + 2, SYSTEM_LOW_PRIORITY + 2) }; for (Pair<Integer, Integer> priorityPair : priorities) { assertAdjustedPriorityForSystemUid(priorityPair.first, priorityPair.second); } } { // Pairs of {initial-priority, expected-adjusted-priority} final Pair<Integer, Integer>[] priorities = new Pair[] { Pair.create(SYSTEM_HIGH_PRIORITY, SYSTEM_HIGH_PRIORITY), Pair.create(SYSTEM_LOW_PRIORITY, SYSTEM_LOW_PRIORITY), Pair.create(SYSTEM_HIGH_PRIORITY + 1, SYSTEM_HIGH_PRIORITY + 1), Pair.create(SYSTEM_LOW_PRIORITY - 1, SYSTEM_LOW_PRIORITY - 1), Pair.create(SYSTEM_HIGH_PRIORITY - 2, SYSTEM_HIGH_PRIORITY - 2), Pair.create(SYSTEM_LOW_PRIORITY + 2, SYSTEM_LOW_PRIORITY + 2) }; for (Pair<Integer, Integer> priorityPair : priorities) { assertAdjustedPriorityForAppUid(priorityPair.first, priorityPair.second); } } } private void assertAdjustedPriorityForSystemUid(int priority, int expectedAdjustedPriority) { assertAdjustedPriority(Process.SYSTEM_UID, priority, expectedAdjustedPriority); } Loading Loading
services/core/java/com/android/server/am/BroadcastFilter.java +0 −3 Original line number Diff line number Diff line Loading @@ -132,9 +132,6 @@ public final class BroadcastFilter extends IntentFilter { @VisibleForTesting static int calculateAdjustedPriority(int owningUid, int priority, ApplicationInfo applicationInfo, PlatformCompat platformCompat) { if (!Flags.restrictPriorityValues()) { return priority; } final long token = Binder.clearCallingIdentity(); try { if (!platformCompat.isChangeEnabledInternalNoLogging( Loading
services/core/java/com/android/server/am/broadcasts_flags.aconfig +0 −8 Original line number Diff line number Diff line package: "com.android.server.am" container: "system" flag { name: "restrict_priority_values" namespace: "backstage_power" description: "Restrict priority values defined by non-system apps" is_fixed_read_only: true bug: "369487976" } flag { name: "limit_priority_scope" namespace: "backstage_power" Loading
services/tests/mockingservicestests/src/com/android/server/am/BroadcastFilterTest.java +0 −76 Original line number Diff line number Diff line Loading @@ -21,15 +21,12 @@ import static android.content.IntentFilter.SYSTEM_LOW_PRIORITY; import static com.google.common.truth.Truth.assertWithMessage; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import android.content.pm.ApplicationInfo; import android.os.Process; import android.platform.test.annotations.DisableFlags; import android.platform.test.annotations.EnableFlags; import android.platform.test.flag.junit.SetFlagsRule; import android.util.Pair; Loading Loading @@ -62,7 +59,6 @@ public class BroadcastFilterTest { } @Test @EnableFlags(Flags.FLAG_RESTRICT_PRIORITY_VALUES) public void testCalculateAdjustedPriority() { { // Pairs of {initial-priority, expected-adjusted-priority} Loading Loading @@ -96,7 +92,6 @@ public class BroadcastFilterTest { } @Test @EnableFlags(Flags.FLAG_RESTRICT_PRIORITY_VALUES) public void testCalculateAdjustedPriority_withChangeIdDisabled() { doReturn(false).when(mPlatformCompat).isChangeEnabledInternalNoLogging( eq(BroadcastFilter.RESTRICT_PRIORITY_VALUES), any(ApplicationInfo.class)); Loading Loading @@ -132,77 +127,6 @@ public class BroadcastFilterTest { } } @Test @DisableFlags(Flags.FLAG_RESTRICT_PRIORITY_VALUES) public void testCalculateAdjustedPriority_withFlagDisabled() { { // Pairs of {initial-priority, expected-adjusted-priority} final Pair<Integer, Integer>[] priorities = new Pair[] { Pair.create(SYSTEM_HIGH_PRIORITY, SYSTEM_HIGH_PRIORITY), Pair.create(SYSTEM_LOW_PRIORITY, SYSTEM_LOW_PRIORITY), Pair.create(SYSTEM_HIGH_PRIORITY + 1, SYSTEM_HIGH_PRIORITY + 1), Pair.create(SYSTEM_LOW_PRIORITY - 1, SYSTEM_LOW_PRIORITY - 1), Pair.create(SYSTEM_HIGH_PRIORITY - 2, SYSTEM_HIGH_PRIORITY - 2), Pair.create(SYSTEM_LOW_PRIORITY + 2, SYSTEM_LOW_PRIORITY + 2) }; for (Pair<Integer, Integer> priorityPair : priorities) { assertAdjustedPriorityForSystemUid(priorityPair.first, priorityPair.second); } } { // Pairs of {initial-priority, expected-adjusted-priority} final Pair<Integer, Integer>[] priorities = new Pair[] { Pair.create(SYSTEM_HIGH_PRIORITY, SYSTEM_HIGH_PRIORITY), Pair.create(SYSTEM_LOW_PRIORITY, SYSTEM_LOW_PRIORITY), Pair.create(SYSTEM_HIGH_PRIORITY + 1, SYSTEM_HIGH_PRIORITY + 1), Pair.create(SYSTEM_LOW_PRIORITY - 1, SYSTEM_LOW_PRIORITY - 1), Pair.create(SYSTEM_HIGH_PRIORITY - 2, SYSTEM_HIGH_PRIORITY - 2), Pair.create(SYSTEM_LOW_PRIORITY + 2, SYSTEM_LOW_PRIORITY + 2) }; for (Pair<Integer, Integer> priorityPair : priorities) { assertAdjustedPriorityForAppUid(priorityPair.first, priorityPair.second); } } } @Test @DisableFlags(Flags.FLAG_RESTRICT_PRIORITY_VALUES) public void testCalculateAdjustedPriority_withFlagDisabled_withChangeIdDisabled() { doReturn(false).when(mPlatformCompat).isChangeEnabledByUidInternalNoLogging( eq(BroadcastFilter.RESTRICT_PRIORITY_VALUES), anyInt()); { // Pairs of {initial-priority, expected-adjusted-priority} final Pair<Integer, Integer>[] priorities = new Pair[] { Pair.create(SYSTEM_HIGH_PRIORITY, SYSTEM_HIGH_PRIORITY), Pair.create(SYSTEM_LOW_PRIORITY, SYSTEM_LOW_PRIORITY), Pair.create(SYSTEM_HIGH_PRIORITY + 1, SYSTEM_HIGH_PRIORITY + 1), Pair.create(SYSTEM_LOW_PRIORITY - 1, SYSTEM_LOW_PRIORITY - 1), Pair.create(SYSTEM_HIGH_PRIORITY - 2, SYSTEM_HIGH_PRIORITY - 2), Pair.create(SYSTEM_LOW_PRIORITY + 2, SYSTEM_LOW_PRIORITY + 2) }; for (Pair<Integer, Integer> priorityPair : priorities) { assertAdjustedPriorityForSystemUid(priorityPair.first, priorityPair.second); } } { // Pairs of {initial-priority, expected-adjusted-priority} final Pair<Integer, Integer>[] priorities = new Pair[] { Pair.create(SYSTEM_HIGH_PRIORITY, SYSTEM_HIGH_PRIORITY), Pair.create(SYSTEM_LOW_PRIORITY, SYSTEM_LOW_PRIORITY), Pair.create(SYSTEM_HIGH_PRIORITY + 1, SYSTEM_HIGH_PRIORITY + 1), Pair.create(SYSTEM_LOW_PRIORITY - 1, SYSTEM_LOW_PRIORITY - 1), Pair.create(SYSTEM_HIGH_PRIORITY - 2, SYSTEM_HIGH_PRIORITY - 2), Pair.create(SYSTEM_LOW_PRIORITY + 2, SYSTEM_LOW_PRIORITY + 2) }; for (Pair<Integer, Integer> priorityPair : priorities) { assertAdjustedPriorityForAppUid(priorityPair.first, priorityPair.second); } } } private void assertAdjustedPriorityForSystemUid(int priority, int expectedAdjustedPriority) { assertAdjustedPriority(Process.SYSTEM_UID, priority, expectedAdjustedPriority); } Loading