Loading core/java/android/app/admin/DevicePolicyCache.java +11 −0 Original line number Original line Diff line number Diff line Loading @@ -43,6 +43,12 @@ public abstract class DevicePolicyCache { */ */ public abstract boolean getScreenCaptureDisabled(@UserIdInt int userHandle); public abstract boolean getScreenCaptureDisabled(@UserIdInt int userHandle); /** * Caches {@link DevicePolicyManager#getPasswordQuality(android.content.ComponentName)} of the * given user with {@code null} passed in as argument. */ public abstract int getPasswordQuality(@UserIdInt int userHandle); /** /** * Empty implementation. * Empty implementation. */ */ Loading @@ -53,5 +59,10 @@ public abstract class DevicePolicyCache { public boolean getScreenCaptureDisabled(int userHandle) { public boolean getScreenCaptureDisabled(int userHandle) { return false; return false; } } @Override public int getPasswordQuality(int userHandle) { return DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED; } } } } } core/java/android/provider/BlockedNumberContract.java +26 −3 Original line number Original line Diff line number Diff line Loading @@ -156,6 +156,8 @@ public class BlockedNumberContract { /** A content:// style uri to the authority for the blocked number provider */ /** A content:// style uri to the authority for the blocked number provider */ public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY); public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY); private static final String LOG_TAG = BlockedNumberContract.class.getSimpleName(); /** /** * Constants to interact with the blocked numbers list. * Constants to interact with the blocked numbers list. */ */ Loading Loading @@ -326,7 +328,10 @@ public class BlockedNumberContract { try { try { final Bundle res = context.getContentResolver().call( final Bundle res = context.getContentResolver().call( AUTHORITY_URI, METHOD_IS_BLOCKED, phoneNumber, null); AUTHORITY_URI, METHOD_IS_BLOCKED, phoneNumber, null); return res != null && res.getBoolean(RES_NUMBER_IS_BLOCKED, false); boolean isBlocked = res != null && res.getBoolean(RES_NUMBER_IS_BLOCKED, false); Log.d(LOG_TAG, "isBlocked: phoneNumber=%s, isBlocked=%b", Log.piiHandle(phoneNumber), isBlocked); return isBlocked; } catch (NullPointerException | IllegalArgumentException ex) { } catch (NullPointerException | IllegalArgumentException ex) { // The content resolver can throw an NPE or IAE; we don't want to crash Telecom if // The content resolver can throw an NPE or IAE; we don't want to crash Telecom if // either of these happen. // either of these happen. Loading Loading @@ -354,6 +359,7 @@ public class BlockedNumberContract { */ */ @WorkerThread @WorkerThread public static int unblock(Context context, String phoneNumber) { public static int unblock(Context context, String phoneNumber) { Log.d(LOG_TAG, "unblock: phoneNumber=%s", Log.piiHandle(phoneNumber)); final Bundle res = context.getContentResolver().call( final Bundle res = context.getContentResolver().call( AUTHORITY_URI, METHOD_UNBLOCK, phoneNumber, null); AUTHORITY_URI, METHOD_UNBLOCK, phoneNumber, null); return res.getInt(RES_NUM_ROWS_DELETED, 0); return res.getInt(RES_NUM_ROWS_DELETED, 0); Loading Loading @@ -445,6 +451,7 @@ public class BlockedNumberContract { */ */ public static void notifyEmergencyContact(Context context) { public static void notifyEmergencyContact(Context context) { try { try { Log.i(LOG_TAG, "notifyEmergencyContact; caller=%s", context.getOpPackageName()); context.getContentResolver().call( context.getContentResolver().call( AUTHORITY_URI, METHOD_NOTIFY_EMERGENCY_CONTACT, null, null); AUTHORITY_URI, METHOD_NOTIFY_EMERGENCY_CONTACT, null, null); } catch (NullPointerException | IllegalArgumentException ex) { } catch (NullPointerException | IllegalArgumentException ex) { Loading @@ -459,6 +466,8 @@ public class BlockedNumberContract { * contacted recently at all, calling this method is a no-op. * contacted recently at all, calling this method is a no-op. */ */ public static void endBlockSuppression(Context context) { public static void endBlockSuppression(Context context) { String caller = context.getOpPackageName(); Log.i(LOG_TAG, "endBlockSuppression: caller=%s", caller); context.getContentResolver().call( context.getContentResolver().call( AUTHORITY_URI, METHOD_END_BLOCK_SUPPRESSION, null, null); AUTHORITY_URI, METHOD_END_BLOCK_SUPPRESSION, null, null); } } Loading @@ -480,10 +489,14 @@ public class BlockedNumberContract { public static int shouldSystemBlockNumber(Context context, String phoneNumber, public static int shouldSystemBlockNumber(Context context, String phoneNumber, Bundle extras) { Bundle extras) { try { try { String caller = context.getOpPackageName(); final Bundle res = context.getContentResolver().call( final Bundle res = context.getContentResolver().call( AUTHORITY_URI, METHOD_SHOULD_SYSTEM_BLOCK_NUMBER, phoneNumber, extras); AUTHORITY_URI, METHOD_SHOULD_SYSTEM_BLOCK_NUMBER, phoneNumber, extras); return res != null ? res.getInt(RES_BLOCK_STATUS, STATUS_NOT_BLOCKED) : int blockResult = res != null ? res.getInt(RES_BLOCK_STATUS, STATUS_NOT_BLOCKED) : BlockedNumberContract.STATUS_NOT_BLOCKED; BlockedNumberContract.STATUS_NOT_BLOCKED; Log.d(LOG_TAG, "shouldSystemBlockNumber: number=%s, caller=%s, result=%s", Log.piiHandle(phoneNumber), caller, blockStatusToString(blockResult)); return blockResult; } catch (NullPointerException | IllegalArgumentException ex) { } catch (NullPointerException | IllegalArgumentException ex) { // The content resolver can throw an NPE or IAE; we don't want to crash Telecom if // The content resolver can throw an NPE or IAE; we don't want to crash Telecom if // either of these happen. // either of these happen. Loading @@ -498,8 +511,12 @@ public class BlockedNumberContract { public static BlockSuppressionStatus getBlockSuppressionStatus(Context context) { public static BlockSuppressionStatus getBlockSuppressionStatus(Context context) { final Bundle res = context.getContentResolver().call( final Bundle res = context.getContentResolver().call( AUTHORITY_URI, METHOD_GET_BLOCK_SUPPRESSION_STATUS, null, null); AUTHORITY_URI, METHOD_GET_BLOCK_SUPPRESSION_STATUS, null, null); return new BlockSuppressionStatus(res.getBoolean(RES_IS_BLOCKING_SUPPRESSED, false), BlockSuppressionStatus blockSuppressionStatus = new BlockSuppressionStatus( res.getBoolean(RES_IS_BLOCKING_SUPPRESSED, false), res.getLong(RES_BLOCKING_SUPPRESSED_UNTIL_TIMESTAMP, 0)); res.getLong(RES_BLOCKING_SUPPRESSED_UNTIL_TIMESTAMP, 0)); Log.d(LOG_TAG, "getBlockSuppressionStatus: caller=%s, status=%s", context.getOpPackageName(), blockSuppressionStatus); return blockSuppressionStatus; } } /** /** Loading Loading @@ -607,6 +624,12 @@ public class BlockedNumberContract { this.isSuppressed = isSuppressed; this.isSuppressed = isSuppressed; this.untilTimestampMillis = untilTimestampMillis; this.untilTimestampMillis = untilTimestampMillis; } } @Override public String toString() { return "[BlockSuppressionStatus; isSuppressed=" + isSuppressed + ", until=" + untilTimestampMillis + "]"; } } } } } } } core/java/com/android/internal/os/Zygote.java +17 −30 Original line number Original line Diff line number Diff line Loading @@ -172,11 +172,6 @@ public final class Zygote { */ */ public static final int SOCKET_BUFFER_SIZE = 256; public static final int SOCKET_BUFFER_SIZE = 256; /** * @hide for internal use only */ private static final int PRIORITY_MAX = -20; /** a prototype instance for a future List.toArray() */ /** a prototype instance for a future List.toArray() */ protected static final int[][] INT_ARRAY_2D = new int[0][0]; protected static final int[][] INT_ARRAY_2D = new int[0][0]; Loading Loading @@ -241,7 +236,8 @@ public final class Zygote { int[] fdsToIgnore, boolean startChildZygote, String instructionSet, String appDataDir, int[] fdsToIgnore, boolean startChildZygote, String instructionSet, String appDataDir, int targetSdkVersion) { int targetSdkVersion) { ZygoteHooks.preFork(); ZygoteHooks.preFork(); // Resets nice priority for zygote process. resetNicePriority(); int pid = nativeForkAndSpecialize( int pid = nativeForkAndSpecialize( uid, gid, gids, runtimeFlags, rlimits, mountExternal, seInfo, niceName, fdsToClose, uid, gid, gids, runtimeFlags, rlimits, mountExternal, seInfo, niceName, fdsToClose, fdsToIgnore, startChildZygote, instructionSet, appDataDir); fdsToIgnore, startChildZygote, instructionSet, appDataDir); Loading @@ -253,7 +249,6 @@ public final class Zygote { // Note that this event ends at the end of handleChildProc, // Note that this event ends at the end of handleChildProc, Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "PostFork"); Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "PostFork"); } } ZygoteHooks.postForkCommon(); ZygoteHooks.postForkCommon(); return pid; return pid; } } Loading Loading @@ -340,16 +335,15 @@ public final class Zygote { public static int forkSystemServer(int uid, int gid, int[] gids, int runtimeFlags, public static int forkSystemServer(int uid, int gid, int[] gids, int runtimeFlags, int[][] rlimits, long permittedCapabilities, long effectiveCapabilities) { int[][] rlimits, long permittedCapabilities, long effectiveCapabilities) { ZygoteHooks.preFork(); ZygoteHooks.preFork(); // Resets nice priority for zygote process. resetNicePriority(); int pid = nativeForkSystemServer( int pid = nativeForkSystemServer( uid, gid, gids, runtimeFlags, rlimits, uid, gid, gids, runtimeFlags, rlimits, permittedCapabilities, effectiveCapabilities); permittedCapabilities, effectiveCapabilities); // Enable tracing as soon as we enter the system_server. // Enable tracing as soon as we enter the system_server. if (pid == 0) { if (pid == 0) { Trace.setTracingEnabled(true, runtimeFlags); Trace.setTracingEnabled(true, runtimeFlags); } } ZygoteHooks.postForkCommon(); ZygoteHooks.postForkCommon(); return pid; return pid; } } Loading Loading @@ -467,16 +461,13 @@ public final class Zygote { /** /** * Fork a new unspecialized app process from the zygote * Fork a new unspecialized app process from the zygote * * * @param usapPoolSocket The server socket the USAP will call accept on * @param sessionSocketRawFDs Anonymous session sockets that are currently open * @param sessionSocketRawFDs Anonymous session sockets that are currently open * @param isPriorityFork Value controlling the process priority level until accept is called * @return In the Zygote process this function will always return null; in unspecialized app * @return In the Zygote process this function will always return null; in unspecialized app * processes this function will return a Runnable object representing the new * processes this function will return a Runnable object representing the new * application that is passed up from usapMain. * application that is passed up from usapMain. */ */ static Runnable forkUsap(LocalServerSocket usapPoolSocket, static Runnable forkUsap(LocalServerSocket usapPoolSocket, int[] sessionSocketRawFDs, int[] sessionSocketRawFDs) { boolean isPriorityFork) { FileDescriptor[] pipeFDs = null; FileDescriptor[] pipeFDs = null; try { try { Loading @@ -486,8 +477,7 @@ public final class Zygote { } } int pid = int pid = nativeForkUsap(pipeFDs[0].getInt$(), pipeFDs[1].getInt$(), nativeForkUsap(pipeFDs[0].getInt$(), pipeFDs[1].getInt$(), sessionSocketRawFDs); sessionSocketRawFDs, isPriorityFork); if (pid == 0) { if (pid == 0) { IoUtils.closeQuietly(pipeFDs[0]); IoUtils.closeQuietly(pipeFDs[0]); Loading @@ -502,8 +492,7 @@ public final class Zygote { private static native int nativeForkUsap(int readPipeFD, private static native int nativeForkUsap(int readPipeFD, int writePipeFD, int writePipeFD, int[] sessionSocketRawFDs, int[] sessionSocketRawFDs); boolean isPriorityFork); /** /** * This function is used by unspecialized app processes to wait for specialization requests from * This function is used by unspecialized app processes to wait for specialization requests from Loading @@ -526,11 +515,6 @@ public final class Zygote { // Load resources // Load resources ZygoteInit.nativePreloadGraphicsDriver(); ZygoteInit.nativePreloadGraphicsDriver(); // Change the priority to max before calling accept so we can respond to new specialization // requests as quickly as possible. This will be reverted to the default priority in the // native specialization code. boostUsapPriority(); while (true) { while (true) { try { try { sessionSocket = usapPoolSocket.accept(); sessionSocket = usapPoolSocket.accept(); Loading Loading @@ -634,12 +618,6 @@ public final class Zygote { null /* classLoader */); null /* classLoader */); } } private static void boostUsapPriority() { nativeBoostUsapPriority(); } private static native void nativeBoostUsapPriority(); private static final String USAP_ERROR_PREFIX = "Invalid command to USAP: "; private static final String USAP_ERROR_PREFIX = "Invalid command to USAP: "; /** /** Loading Loading @@ -879,6 +857,15 @@ public final class Zygote { ZygoteHooks.postForkChild(runtimeFlags, isSystemServer, isZygote, instructionSet); ZygoteHooks.postForkChild(runtimeFlags, isSystemServer, isZygote, instructionSet); } } /** * Resets the calling thread priority to the default value (Thread.NORM_PRIORITY * or nice value 0). This updates both the priority value in java.lang.Thread and * the nice value (setpriority). */ static void resetNicePriority() { Thread.currentThread().setPriority(Thread.NORM_PRIORITY); } /** /** * Executes "/system/bin/sh -c <command>" using the exec() system call. * Executes "/system/bin/sh -c <command>" using the exec() system call. * This method throws a runtime exception if exec() failed, otherwise, this * This method throws a runtime exception if exec() failed, otherwise, this Loading core/java/com/android/internal/os/ZygoteConnection.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -346,7 +346,7 @@ class ZygoteConnection { if (zygoteServer.isUsapPoolEnabled()) { if (zygoteServer.isUsapPoolEnabled()) { Runnable fpResult = Runnable fpResult = zygoteServer.fillUsapPool( zygoteServer.fillUsapPool( new int[]{mSocket.getFileDescriptor().getInt$()}, false); new int[]{mSocket.getFileDescriptor().getInt$()}); if (fpResult != null) { if (fpResult != null) { zygoteServer.setForkChild(); zygoteServer.setForkChild(); Loading core/java/com/android/internal/os/ZygoteInit.java +2 −3 Original line number Original line Diff line number Diff line Loading @@ -822,9 +822,6 @@ public class ZygoteInit { public static void main(String argv[]) { public static void main(String argv[]) { ZygoteServer zygoteServer = null; ZygoteServer zygoteServer = null; // Set the initial thread priority to the "normal" value. Thread.currentThread().setPriority(Thread.NORM_PRIORITY); // Mark zygote start. This ensures that thread creation will throw // Mark zygote start. This ensures that thread creation will throw // an error. // an error. ZygoteHooks.startZygoteNoThreadCreation(); ZygoteHooks.startZygoteNoThreadCreation(); Loading Loading @@ -884,6 +881,8 @@ public class ZygoteInit { EventLog.writeEvent(LOG_BOOT_PROGRESS_PRELOAD_END, EventLog.writeEvent(LOG_BOOT_PROGRESS_PRELOAD_END, SystemClock.uptimeMillis()); SystemClock.uptimeMillis()); bootTimingsTraceLog.traceEnd(); // ZygotePreload bootTimingsTraceLog.traceEnd(); // ZygotePreload } else { Zygote.resetNicePriority(); } } // Do an initial gc to clean up after startup // Do an initial gc to clean up after startup Loading Loading
core/java/android/app/admin/DevicePolicyCache.java +11 −0 Original line number Original line Diff line number Diff line Loading @@ -43,6 +43,12 @@ public abstract class DevicePolicyCache { */ */ public abstract boolean getScreenCaptureDisabled(@UserIdInt int userHandle); public abstract boolean getScreenCaptureDisabled(@UserIdInt int userHandle); /** * Caches {@link DevicePolicyManager#getPasswordQuality(android.content.ComponentName)} of the * given user with {@code null} passed in as argument. */ public abstract int getPasswordQuality(@UserIdInt int userHandle); /** /** * Empty implementation. * Empty implementation. */ */ Loading @@ -53,5 +59,10 @@ public abstract class DevicePolicyCache { public boolean getScreenCaptureDisabled(int userHandle) { public boolean getScreenCaptureDisabled(int userHandle) { return false; return false; } } @Override public int getPasswordQuality(int userHandle) { return DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED; } } } } }
core/java/android/provider/BlockedNumberContract.java +26 −3 Original line number Original line Diff line number Diff line Loading @@ -156,6 +156,8 @@ public class BlockedNumberContract { /** A content:// style uri to the authority for the blocked number provider */ /** A content:// style uri to the authority for the blocked number provider */ public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY); public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY); private static final String LOG_TAG = BlockedNumberContract.class.getSimpleName(); /** /** * Constants to interact with the blocked numbers list. * Constants to interact with the blocked numbers list. */ */ Loading Loading @@ -326,7 +328,10 @@ public class BlockedNumberContract { try { try { final Bundle res = context.getContentResolver().call( final Bundle res = context.getContentResolver().call( AUTHORITY_URI, METHOD_IS_BLOCKED, phoneNumber, null); AUTHORITY_URI, METHOD_IS_BLOCKED, phoneNumber, null); return res != null && res.getBoolean(RES_NUMBER_IS_BLOCKED, false); boolean isBlocked = res != null && res.getBoolean(RES_NUMBER_IS_BLOCKED, false); Log.d(LOG_TAG, "isBlocked: phoneNumber=%s, isBlocked=%b", Log.piiHandle(phoneNumber), isBlocked); return isBlocked; } catch (NullPointerException | IllegalArgumentException ex) { } catch (NullPointerException | IllegalArgumentException ex) { // The content resolver can throw an NPE or IAE; we don't want to crash Telecom if // The content resolver can throw an NPE or IAE; we don't want to crash Telecom if // either of these happen. // either of these happen. Loading Loading @@ -354,6 +359,7 @@ public class BlockedNumberContract { */ */ @WorkerThread @WorkerThread public static int unblock(Context context, String phoneNumber) { public static int unblock(Context context, String phoneNumber) { Log.d(LOG_TAG, "unblock: phoneNumber=%s", Log.piiHandle(phoneNumber)); final Bundle res = context.getContentResolver().call( final Bundle res = context.getContentResolver().call( AUTHORITY_URI, METHOD_UNBLOCK, phoneNumber, null); AUTHORITY_URI, METHOD_UNBLOCK, phoneNumber, null); return res.getInt(RES_NUM_ROWS_DELETED, 0); return res.getInt(RES_NUM_ROWS_DELETED, 0); Loading Loading @@ -445,6 +451,7 @@ public class BlockedNumberContract { */ */ public static void notifyEmergencyContact(Context context) { public static void notifyEmergencyContact(Context context) { try { try { Log.i(LOG_TAG, "notifyEmergencyContact; caller=%s", context.getOpPackageName()); context.getContentResolver().call( context.getContentResolver().call( AUTHORITY_URI, METHOD_NOTIFY_EMERGENCY_CONTACT, null, null); AUTHORITY_URI, METHOD_NOTIFY_EMERGENCY_CONTACT, null, null); } catch (NullPointerException | IllegalArgumentException ex) { } catch (NullPointerException | IllegalArgumentException ex) { Loading @@ -459,6 +466,8 @@ public class BlockedNumberContract { * contacted recently at all, calling this method is a no-op. * contacted recently at all, calling this method is a no-op. */ */ public static void endBlockSuppression(Context context) { public static void endBlockSuppression(Context context) { String caller = context.getOpPackageName(); Log.i(LOG_TAG, "endBlockSuppression: caller=%s", caller); context.getContentResolver().call( context.getContentResolver().call( AUTHORITY_URI, METHOD_END_BLOCK_SUPPRESSION, null, null); AUTHORITY_URI, METHOD_END_BLOCK_SUPPRESSION, null, null); } } Loading @@ -480,10 +489,14 @@ public class BlockedNumberContract { public static int shouldSystemBlockNumber(Context context, String phoneNumber, public static int shouldSystemBlockNumber(Context context, String phoneNumber, Bundle extras) { Bundle extras) { try { try { String caller = context.getOpPackageName(); final Bundle res = context.getContentResolver().call( final Bundle res = context.getContentResolver().call( AUTHORITY_URI, METHOD_SHOULD_SYSTEM_BLOCK_NUMBER, phoneNumber, extras); AUTHORITY_URI, METHOD_SHOULD_SYSTEM_BLOCK_NUMBER, phoneNumber, extras); return res != null ? res.getInt(RES_BLOCK_STATUS, STATUS_NOT_BLOCKED) : int blockResult = res != null ? res.getInt(RES_BLOCK_STATUS, STATUS_NOT_BLOCKED) : BlockedNumberContract.STATUS_NOT_BLOCKED; BlockedNumberContract.STATUS_NOT_BLOCKED; Log.d(LOG_TAG, "shouldSystemBlockNumber: number=%s, caller=%s, result=%s", Log.piiHandle(phoneNumber), caller, blockStatusToString(blockResult)); return blockResult; } catch (NullPointerException | IllegalArgumentException ex) { } catch (NullPointerException | IllegalArgumentException ex) { // The content resolver can throw an NPE or IAE; we don't want to crash Telecom if // The content resolver can throw an NPE or IAE; we don't want to crash Telecom if // either of these happen. // either of these happen. Loading @@ -498,8 +511,12 @@ public class BlockedNumberContract { public static BlockSuppressionStatus getBlockSuppressionStatus(Context context) { public static BlockSuppressionStatus getBlockSuppressionStatus(Context context) { final Bundle res = context.getContentResolver().call( final Bundle res = context.getContentResolver().call( AUTHORITY_URI, METHOD_GET_BLOCK_SUPPRESSION_STATUS, null, null); AUTHORITY_URI, METHOD_GET_BLOCK_SUPPRESSION_STATUS, null, null); return new BlockSuppressionStatus(res.getBoolean(RES_IS_BLOCKING_SUPPRESSED, false), BlockSuppressionStatus blockSuppressionStatus = new BlockSuppressionStatus( res.getBoolean(RES_IS_BLOCKING_SUPPRESSED, false), res.getLong(RES_BLOCKING_SUPPRESSED_UNTIL_TIMESTAMP, 0)); res.getLong(RES_BLOCKING_SUPPRESSED_UNTIL_TIMESTAMP, 0)); Log.d(LOG_TAG, "getBlockSuppressionStatus: caller=%s, status=%s", context.getOpPackageName(), blockSuppressionStatus); return blockSuppressionStatus; } } /** /** Loading Loading @@ -607,6 +624,12 @@ public class BlockedNumberContract { this.isSuppressed = isSuppressed; this.isSuppressed = isSuppressed; this.untilTimestampMillis = untilTimestampMillis; this.untilTimestampMillis = untilTimestampMillis; } } @Override public String toString() { return "[BlockSuppressionStatus; isSuppressed=" + isSuppressed + ", until=" + untilTimestampMillis + "]"; } } } } } } }
core/java/com/android/internal/os/Zygote.java +17 −30 Original line number Original line Diff line number Diff line Loading @@ -172,11 +172,6 @@ public final class Zygote { */ */ public static final int SOCKET_BUFFER_SIZE = 256; public static final int SOCKET_BUFFER_SIZE = 256; /** * @hide for internal use only */ private static final int PRIORITY_MAX = -20; /** a prototype instance for a future List.toArray() */ /** a prototype instance for a future List.toArray() */ protected static final int[][] INT_ARRAY_2D = new int[0][0]; protected static final int[][] INT_ARRAY_2D = new int[0][0]; Loading Loading @@ -241,7 +236,8 @@ public final class Zygote { int[] fdsToIgnore, boolean startChildZygote, String instructionSet, String appDataDir, int[] fdsToIgnore, boolean startChildZygote, String instructionSet, String appDataDir, int targetSdkVersion) { int targetSdkVersion) { ZygoteHooks.preFork(); ZygoteHooks.preFork(); // Resets nice priority for zygote process. resetNicePriority(); int pid = nativeForkAndSpecialize( int pid = nativeForkAndSpecialize( uid, gid, gids, runtimeFlags, rlimits, mountExternal, seInfo, niceName, fdsToClose, uid, gid, gids, runtimeFlags, rlimits, mountExternal, seInfo, niceName, fdsToClose, fdsToIgnore, startChildZygote, instructionSet, appDataDir); fdsToIgnore, startChildZygote, instructionSet, appDataDir); Loading @@ -253,7 +249,6 @@ public final class Zygote { // Note that this event ends at the end of handleChildProc, // Note that this event ends at the end of handleChildProc, Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "PostFork"); Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "PostFork"); } } ZygoteHooks.postForkCommon(); ZygoteHooks.postForkCommon(); return pid; return pid; } } Loading Loading @@ -340,16 +335,15 @@ public final class Zygote { public static int forkSystemServer(int uid, int gid, int[] gids, int runtimeFlags, public static int forkSystemServer(int uid, int gid, int[] gids, int runtimeFlags, int[][] rlimits, long permittedCapabilities, long effectiveCapabilities) { int[][] rlimits, long permittedCapabilities, long effectiveCapabilities) { ZygoteHooks.preFork(); ZygoteHooks.preFork(); // Resets nice priority for zygote process. resetNicePriority(); int pid = nativeForkSystemServer( int pid = nativeForkSystemServer( uid, gid, gids, runtimeFlags, rlimits, uid, gid, gids, runtimeFlags, rlimits, permittedCapabilities, effectiveCapabilities); permittedCapabilities, effectiveCapabilities); // Enable tracing as soon as we enter the system_server. // Enable tracing as soon as we enter the system_server. if (pid == 0) { if (pid == 0) { Trace.setTracingEnabled(true, runtimeFlags); Trace.setTracingEnabled(true, runtimeFlags); } } ZygoteHooks.postForkCommon(); ZygoteHooks.postForkCommon(); return pid; return pid; } } Loading Loading @@ -467,16 +461,13 @@ public final class Zygote { /** /** * Fork a new unspecialized app process from the zygote * Fork a new unspecialized app process from the zygote * * * @param usapPoolSocket The server socket the USAP will call accept on * @param sessionSocketRawFDs Anonymous session sockets that are currently open * @param sessionSocketRawFDs Anonymous session sockets that are currently open * @param isPriorityFork Value controlling the process priority level until accept is called * @return In the Zygote process this function will always return null; in unspecialized app * @return In the Zygote process this function will always return null; in unspecialized app * processes this function will return a Runnable object representing the new * processes this function will return a Runnable object representing the new * application that is passed up from usapMain. * application that is passed up from usapMain. */ */ static Runnable forkUsap(LocalServerSocket usapPoolSocket, static Runnable forkUsap(LocalServerSocket usapPoolSocket, int[] sessionSocketRawFDs, int[] sessionSocketRawFDs) { boolean isPriorityFork) { FileDescriptor[] pipeFDs = null; FileDescriptor[] pipeFDs = null; try { try { Loading @@ -486,8 +477,7 @@ public final class Zygote { } } int pid = int pid = nativeForkUsap(pipeFDs[0].getInt$(), pipeFDs[1].getInt$(), nativeForkUsap(pipeFDs[0].getInt$(), pipeFDs[1].getInt$(), sessionSocketRawFDs); sessionSocketRawFDs, isPriorityFork); if (pid == 0) { if (pid == 0) { IoUtils.closeQuietly(pipeFDs[0]); IoUtils.closeQuietly(pipeFDs[0]); Loading @@ -502,8 +492,7 @@ public final class Zygote { private static native int nativeForkUsap(int readPipeFD, private static native int nativeForkUsap(int readPipeFD, int writePipeFD, int writePipeFD, int[] sessionSocketRawFDs, int[] sessionSocketRawFDs); boolean isPriorityFork); /** /** * This function is used by unspecialized app processes to wait for specialization requests from * This function is used by unspecialized app processes to wait for specialization requests from Loading @@ -526,11 +515,6 @@ public final class Zygote { // Load resources // Load resources ZygoteInit.nativePreloadGraphicsDriver(); ZygoteInit.nativePreloadGraphicsDriver(); // Change the priority to max before calling accept so we can respond to new specialization // requests as quickly as possible. This will be reverted to the default priority in the // native specialization code. boostUsapPriority(); while (true) { while (true) { try { try { sessionSocket = usapPoolSocket.accept(); sessionSocket = usapPoolSocket.accept(); Loading Loading @@ -634,12 +618,6 @@ public final class Zygote { null /* classLoader */); null /* classLoader */); } } private static void boostUsapPriority() { nativeBoostUsapPriority(); } private static native void nativeBoostUsapPriority(); private static final String USAP_ERROR_PREFIX = "Invalid command to USAP: "; private static final String USAP_ERROR_PREFIX = "Invalid command to USAP: "; /** /** Loading Loading @@ -879,6 +857,15 @@ public final class Zygote { ZygoteHooks.postForkChild(runtimeFlags, isSystemServer, isZygote, instructionSet); ZygoteHooks.postForkChild(runtimeFlags, isSystemServer, isZygote, instructionSet); } } /** * Resets the calling thread priority to the default value (Thread.NORM_PRIORITY * or nice value 0). This updates both the priority value in java.lang.Thread and * the nice value (setpriority). */ static void resetNicePriority() { Thread.currentThread().setPriority(Thread.NORM_PRIORITY); } /** /** * Executes "/system/bin/sh -c <command>" using the exec() system call. * Executes "/system/bin/sh -c <command>" using the exec() system call. * This method throws a runtime exception if exec() failed, otherwise, this * This method throws a runtime exception if exec() failed, otherwise, this Loading
core/java/com/android/internal/os/ZygoteConnection.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -346,7 +346,7 @@ class ZygoteConnection { if (zygoteServer.isUsapPoolEnabled()) { if (zygoteServer.isUsapPoolEnabled()) { Runnable fpResult = Runnable fpResult = zygoteServer.fillUsapPool( zygoteServer.fillUsapPool( new int[]{mSocket.getFileDescriptor().getInt$()}, false); new int[]{mSocket.getFileDescriptor().getInt$()}); if (fpResult != null) { if (fpResult != null) { zygoteServer.setForkChild(); zygoteServer.setForkChild(); Loading
core/java/com/android/internal/os/ZygoteInit.java +2 −3 Original line number Original line Diff line number Diff line Loading @@ -822,9 +822,6 @@ public class ZygoteInit { public static void main(String argv[]) { public static void main(String argv[]) { ZygoteServer zygoteServer = null; ZygoteServer zygoteServer = null; // Set the initial thread priority to the "normal" value. Thread.currentThread().setPriority(Thread.NORM_PRIORITY); // Mark zygote start. This ensures that thread creation will throw // Mark zygote start. This ensures that thread creation will throw // an error. // an error. ZygoteHooks.startZygoteNoThreadCreation(); ZygoteHooks.startZygoteNoThreadCreation(); Loading Loading @@ -884,6 +881,8 @@ public class ZygoteInit { EventLog.writeEvent(LOG_BOOT_PROGRESS_PRELOAD_END, EventLog.writeEvent(LOG_BOOT_PROGRESS_PRELOAD_END, SystemClock.uptimeMillis()); SystemClock.uptimeMillis()); bootTimingsTraceLog.traceEnd(); // ZygotePreload bootTimingsTraceLog.traceEnd(); // ZygotePreload } else { Zygote.resetNicePriority(); } } // Do an initial gc to clean up after startup // Do an initial gc to clean up after startup Loading