Loading core/java/com/android/internal/os/ZygoteInit.java +24 −12 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.internal.os; import static android.system.OsConstants.POLLIN; import static android.system.OsConstants.POLLOUT; import static android.system.OsConstants.S_IRWXG; import static android.system.OsConstants.S_IRWXO; Loading Loading @@ -276,6 +275,14 @@ public class ZygoteInit { long startTime = SystemClock.uptimeMillis(); // Drop root perms while running static initializers. final int reuid = Os.getuid(); final int regid = Os.getgid(); // We need to drop root perms only if we're already root. In the case of "wrapped" // processes (see WrapperInit), this function is called from an unprivileged uid // and gid. boolean droppedPriviliges = false; if (reuid == ROOT_UID && regid == ROOT_GID) { try { Os.setregid(ROOT_GID, UNPRIVILEGED_GID); Os.setreuid(ROOT_UID, UNPRIVILEGED_UID); Loading @@ -283,6 +290,9 @@ public class ZygoteInit { throw new RuntimeException("Failed to drop root", ex); } droppedPriviliges = true; } // Alter the target heap utilization. With explicit GCs this // is not likely to have any effect. float defaultUtilization = runtime.getTargetHeapUtilization(); Loading Loading @@ -335,7 +345,8 @@ public class ZygoteInit { // Fill in dex caches with classes, fields, and methods brought in by preloading. runtime.preloadDexCaches(); // Bring back root. We'll need it later. // Bring back root. We'll need it later if we're in the zygote. if (droppedPriviliges) { try { Os.setreuid(ROOT_UID, ROOT_UID); Os.setregid(ROOT_GID, ROOT_GID); Loading @@ -344,6 +355,7 @@ public class ZygoteInit { } } } } /** * Load in commonly used resources, so they can be shared across Loading Loading
core/java/com/android/internal/os/ZygoteInit.java +24 −12 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.internal.os; import static android.system.OsConstants.POLLIN; import static android.system.OsConstants.POLLOUT; import static android.system.OsConstants.S_IRWXG; import static android.system.OsConstants.S_IRWXO; Loading Loading @@ -276,6 +275,14 @@ public class ZygoteInit { long startTime = SystemClock.uptimeMillis(); // Drop root perms while running static initializers. final int reuid = Os.getuid(); final int regid = Os.getgid(); // We need to drop root perms only if we're already root. In the case of "wrapped" // processes (see WrapperInit), this function is called from an unprivileged uid // and gid. boolean droppedPriviliges = false; if (reuid == ROOT_UID && regid == ROOT_GID) { try { Os.setregid(ROOT_GID, UNPRIVILEGED_GID); Os.setreuid(ROOT_UID, UNPRIVILEGED_UID); Loading @@ -283,6 +290,9 @@ public class ZygoteInit { throw new RuntimeException("Failed to drop root", ex); } droppedPriviliges = true; } // Alter the target heap utilization. With explicit GCs this // is not likely to have any effect. float defaultUtilization = runtime.getTargetHeapUtilization(); Loading Loading @@ -335,7 +345,8 @@ public class ZygoteInit { // Fill in dex caches with classes, fields, and methods brought in by preloading. runtime.preloadDexCaches(); // Bring back root. We'll need it later. // Bring back root. We'll need it later if we're in the zygote. if (droppedPriviliges) { try { Os.setreuid(ROOT_UID, ROOT_UID); Os.setregid(ROOT_GID, ROOT_GID); Loading @@ -344,6 +355,7 @@ public class ZygoteInit { } } } } /** * Load in commonly used resources, so they can be shared across Loading