@@ -1665,20 +1665,9 @@ private void updateRulesForRestrictBackgroundLocked() {
16651665 updateRulesForAppLocked (appId );
16661666 }
16671667
1668- // and catch system UIDs
1669- // TODO: keep in sync with android_filesystem_config.h
1670- for (int uid = 1000 ; uid <= 1025 ; uid ++) {
1671- updateRulesForUidLocked (uid );
1672- }
1673- for (int uid = 2000 ; uid <= 2002 ; uid ++) {
1674- updateRulesForUidLocked (uid );
1675- }
1676- for (int uid = 3000 ; uid <= 3007 ; uid ++) {
1677- updateRulesForUidLocked (uid );
1678- }
1679- for (int uid = 9998 ; uid <= 9999 ; uid ++) {
1680- updateRulesForUidLocked (uid );
1681- }
1668+ // limit data usage for some internal system services
1669+ updateRulesForUidLocked (android .os .Process .MEDIA_UID );
1670+ updateRulesForUidLocked (android .os .Process .DRM_UID );
16821671 }
16831672
16841673 private void updateRulesForAppLocked (int appId ) {
@@ -1688,7 +1677,19 @@ private void updateRulesForAppLocked(int appId) {
16881677 }
16891678 }
16901679
1680+ private static boolean isUidValidForRules (int uid ) {
1681+ // allow rules on specific system services, and any apps
1682+ if (uid == android .os .Process .MEDIA_UID || uid == android .os .Process .DRM_UID
1683+ || UserId .isApp (uid )) {
1684+ return true ;
1685+ }
1686+
1687+ return false ;
1688+ }
1689+
16911690 private void updateRulesForUidLocked (int uid ) {
1691+ if (!isUidValidForRules (uid )) return ;
1692+
16921693 final int appId = UserId .getAppId (uid );
16931694 final int appPolicy = getAppPolicy (appId );
16941695 final boolean uidForeground = isUidForeground (uid );
0 commit comments