Skip to content

Commit 5294a2f

Browse files
committed
Relax global restrict for system services.
Since we control system services, we can ensure they are using little data when data usage is globally restricted. Continue restricting AID_MEDIA and AID_DRM, since they respond to app requests. Bug: 6377903, 5772564 Change-Id: I196bf334f903397ea6a67e6802240ee792e47b54
1 parent af772be commit 5294a2f

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

core/java/android/os/Process.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ public class Process {
9191
*/
9292
public static final int MEDIA_UID = 1013;
9393

94+
/**
95+
* Defines the UID/GID for the DRM process.
96+
* @hide
97+
*/
98+
public static final int DRM_UID = 1019;
99+
94100
/**
95101
* Defines the GID for the group that allows write access to the SD card.
96102
* @hide

services/java/com/android/server/net/NetworkPolicyManagerService.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)