The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.internal.os; |
| 18 | |
Elliott Hughes | a9569ff | 2014-04-28 20:53:52 -0700 | [diff] [blame] | 19 | import static android.system.OsConstants.S_IRWXG; |
| 20 | import static android.system.OsConstants.S_IRWXO; |
Kenny Root | 4c74f8c | 2012-08-17 08:45:55 -0700 | [diff] [blame] | 21 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 22 | import android.content.res.Resources; |
| 23 | import android.content.res.TypedArray; |
Neil Fuller | 4f41f61 | 2016-05-09 16:55:36 +0100 | [diff] [blame] | 24 | import android.icu.impl.CacheValue; |
| 25 | import android.icu.text.DecimalFormatSymbols; |
| 26 | import android.icu.util.ULocale; |
Jesse Hall | ba0370e | 2017-02-09 14:43:14 -0800 | [diff] [blame] | 27 | import android.opengl.EGL14; |
Mathieu Chartier | b3eeceb | 2017-03-30 21:00:18 -0700 | [diff] [blame] | 28 | import android.os.Build; |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 29 | import android.os.IInstalld; |
Mathieu Chartier | b3eeceb | 2017-03-30 21:00:18 -0700 | [diff] [blame] | 30 | import android.os.Environment; |
Jeff Brown | ebed7d6 | 2011-05-16 17:08:42 -0700 | [diff] [blame] | 31 | import android.os.Process; |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 32 | import android.os.RemoteException; |
Paul Lawrence | ef85477 | 2017-01-31 09:54:31 -0800 | [diff] [blame] | 33 | import android.os.Seccomp; |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 34 | import android.os.ServiceManager; |
| 35 | import android.os.ServiceSpecificException; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | import android.os.SystemClock; |
Romain Guy | c5e3638 | 2013-05-09 11:08:17 -0700 | [diff] [blame] | 37 | import android.os.SystemProperties; |
Jamie Gennis | 6ad0452 | 2013-04-15 18:53:24 -0700 | [diff] [blame] | 38 | import android.os.Trace; |
Robert Sesek | 8f8d187 | 2016-03-18 16:52:57 -0400 | [diff] [blame] | 39 | import android.os.ZygoteProcess; |
Jeff Sharkey | c98c7bc | 2016-12-07 14:57:34 -0700 | [diff] [blame] | 40 | import android.os.storage.StorageManager; |
Sergio Giro | 69de320 | 2016-05-17 16:52:33 +0100 | [diff] [blame] | 41 | import android.security.keystore.AndroidKeyStoreProvider; |
Bill Yi | 9a76e9b | 2014-04-29 18:52:48 -0700 | [diff] [blame] | 42 | import android.system.ErrnoException; |
Elliott Hughes | 860c591 | 2014-04-28 19:19:13 -0700 | [diff] [blame] | 43 | import android.system.Os; |
| 44 | import android.system.OsConstants; |
Luis Hector Chavez | 72042c9 | 2017-07-12 10:03:30 -0700 | [diff] [blame] | 45 | import android.system.StructCapUserData; |
| 46 | import android.system.StructCapUserHeader; |
Raph Levien | c3dd1c1 | 2015-04-06 10:37:57 -0700 | [diff] [blame] | 47 | import android.text.Hyphenator; |
Fyodor Kupolov | 3235e0c | 2016-11-17 11:44:49 -0800 | [diff] [blame] | 48 | import android.util.BootTimingsTraceLog; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 49 | import android.util.EventLog; |
| 50 | import android.util.Log; |
Andreas Gampe | 76d4fc8 | 2017-02-07 19:44:37 -0800 | [diff] [blame] | 51 | import android.util.Slog; |
Torne (Richard Coles) | 08cfaf6 | 2014-05-08 16:07:05 +0100 | [diff] [blame] | 52 | import android.webkit.WebViewFactory; |
Andreas Gampe | ddc1397 | 2016-02-26 16:54:59 -0800 | [diff] [blame] | 53 | import android.widget.TextView; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 54 | |
Fyodor Kupolov | 3235e0c | 2016-11-17 11:44:49 -0800 | [diff] [blame] | 55 | import com.android.internal.logging.MetricsLogger; |
Jeff Sharkey | fdeeeea | 2016-01-11 17:34:24 -0700 | [diff] [blame] | 56 | |
Narayan Kamath | 669afcc | 2017-02-06 20:24:08 +0000 | [diff] [blame] | 57 | import com.android.internal.util.Preconditions; |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 58 | import dalvik.system.DexFile; |
| 59 | import dalvik.system.PathClassLoader; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 60 | import dalvik.system.VMRuntime; |
Andreas Gampe | 1ef8aef | 2016-04-11 08:39:52 -0700 | [diff] [blame] | 61 | import dalvik.system.ZygoteHooks; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 62 | |
Brian Carlstrom | 46703b0 | 2011-04-06 15:41:29 -0700 | [diff] [blame] | 63 | import libcore.io.IoUtils; |
| 64 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 65 | import java.io.BufferedReader; |
Mathieu Chartier | b3eeceb | 2017-03-30 21:00:18 -0700 | [diff] [blame] | 66 | import java.io.File; |
Ying Wang | d0c4535 | 2014-11-13 15:22:47 -0800 | [diff] [blame] | 67 | import java.io.FileInputStream; |
| 68 | import java.io.FileNotFoundException; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 69 | import java.io.IOException; |
| 70 | import java.io.InputStream; |
| 71 | import java.io.InputStreamReader; |
Sergio Giro | 6cb7b1c | 2016-05-13 16:34:46 +0100 | [diff] [blame] | 72 | import java.security.Security; |
| 73 | import java.security.Provider; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 74 | |
| 75 | /** |
| 76 | * Startup class for the zygote process. |
| 77 | * |
| 78 | * Pre-initializes some classes, and then waits for commands on a UNIX domain |
Elliott Hughes | e1dfcb7 | 2011-07-08 11:08:07 -0700 | [diff] [blame] | 79 | * socket. Based on these commands, forks off child processes that inherit |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 80 | * the initial state of the VM. |
| 81 | * |
| 82 | * Please see {@link ZygoteConnection.Arguments} for documentation on the |
| 83 | * client protocol. |
| 84 | * |
| 85 | * @hide |
| 86 | */ |
| 87 | public class ZygoteInit { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 88 | private static final String TAG = "Zygote"; |
| 89 | |
Jesse Hall | 2852a28 | 2017-01-17 10:17:41 -0800 | [diff] [blame] | 90 | private static final String PROPERTY_DISABLE_OPENGL_PRELOADING = "ro.zygote.disable_gl_preload"; |
Jesse Hall | ba0370e | 2017-02-09 14:43:14 -0800 | [diff] [blame] | 91 | private static final String PROPERTY_GFX_DRIVER = "ro.gfx.driver.0"; |
Romain Guy | c5e3638 | 2013-05-09 11:08:17 -0700 | [diff] [blame] | 92 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 93 | private static final int LOG_BOOT_PROGRESS_PRELOAD_START = 3020; |
| 94 | private static final int LOG_BOOT_PROGRESS_PRELOAD_END = 3030; |
| 95 | |
| 96 | /** when preloading, GC after allocating this many bytes */ |
| 97 | private static final int PRELOAD_GC_THRESHOLD = 50000; |
| 98 | |
Narayan Kamath | c41638c | 2014-04-07 13:56:15 +0100 | [diff] [blame] | 99 | private static final String ABI_LIST_ARG = "--abi-list="; |
| 100 | |
| 101 | private static final String SOCKET_NAME_ARG = "--socket-name="; |
Barry Hayes | 0b3533a | 2010-01-20 12:46:47 -0800 | [diff] [blame] | 102 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 103 | /** |
Tobias Sargeant | dd4bb31 | 2016-01-19 16:34:54 +0000 | [diff] [blame] | 104 | * Used to pre-load resources. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 105 | */ |
| 106 | private static Resources mResources; |
Bob Lee | e540833 | 2009-09-04 18:31:17 -0700 | [diff] [blame] | 107 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 108 | /** |
Ying Wang | d0c4535 | 2014-11-13 15:22:47 -0800 | [diff] [blame] | 109 | * The path of a file that contains classes to preload. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 110 | */ |
Ying Wang | d0c4535 | 2014-11-13 15:22:47 -0800 | [diff] [blame] | 111 | private static final String PRELOADED_CLASSES = "/system/etc/preloaded-classes"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 112 | |
| 113 | /** Controls whether we should preload resources during zygote init. */ |
Steve Paik | 3c27a23 | 2015-06-10 18:25:44 -0700 | [diff] [blame] | 114 | public static final boolean PRELOAD_RESOURCES = true; |
Andy McFadden | 599c918 | 2009-04-08 00:35:56 -0700 | [diff] [blame] | 115 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 116 | private static final int UNPRIVILEGED_UID = 9999; |
| 117 | private static final int UNPRIVILEGED_GID = 9999; |
| 118 | |
| 119 | private static final int ROOT_UID = 0; |
| 120 | private static final int ROOT_GID = 0; |
| 121 | |
Narayan Kamath | 5a3d0c6 | 2016-11-09 15:35:18 +0000 | [diff] [blame] | 122 | private static boolean sPreloadComplete; |
| 123 | |
Fyodor Kupolov | 3235e0c | 2016-11-17 11:44:49 -0800 | [diff] [blame] | 124 | static void preload(BootTimingsTraceLog bootTimingsTraceLog) { |
Bill Yi | 9a76e9b | 2014-04-29 18:52:48 -0700 | [diff] [blame] | 125 | Log.d(TAG, "begin preload"); |
Fyodor Kupolov | 3235e0c | 2016-11-17 11:44:49 -0800 | [diff] [blame] | 126 | bootTimingsTraceLog.traceBegin("BeginIcuCachePinning"); |
Neil Fuller | 4f41f61 | 2016-05-09 16:55:36 +0100 | [diff] [blame] | 127 | beginIcuCachePinning(); |
Fyodor Kupolov | 3235e0c | 2016-11-17 11:44:49 -0800 | [diff] [blame] | 128 | bootTimingsTraceLog.traceEnd(); // BeginIcuCachePinning |
| 129 | bootTimingsTraceLog.traceBegin("PreloadClasses"); |
Yasuhiro Matsuda | 25878b2 | 2015-09-03 16:18:21 +0900 | [diff] [blame] | 130 | preloadClasses(); |
Fyodor Kupolov | 3235e0c | 2016-11-17 11:44:49 -0800 | [diff] [blame] | 131 | bootTimingsTraceLog.traceEnd(); // PreloadClasses |
| 132 | bootTimingsTraceLog.traceBegin("PreloadResources"); |
Yasuhiro Matsuda | 25878b2 | 2015-09-03 16:18:21 +0900 | [diff] [blame] | 133 | preloadResources(); |
Fyodor Kupolov | 3235e0c | 2016-11-17 11:44:49 -0800 | [diff] [blame] | 134 | bootTimingsTraceLog.traceEnd(); // PreloadResources |
Jesse Hall | 42cf26e | 2017-07-06 15:30:39 -0700 | [diff] [blame] | 135 | Trace.traceBegin(Trace.TRACE_TAG_DALVIK, "PreloadAppProcessHALs"); |
| 136 | nativePreloadAppProcessHALs(); |
| 137 | Trace.traceEnd(Trace.TRACE_TAG_DALVIK); |
Jesse Hall | ba0370e | 2017-02-09 14:43:14 -0800 | [diff] [blame] | 138 | Trace.traceBegin(Trace.TRACE_TAG_DALVIK, "PreloadOpenGL"); |
| 139 | preloadOpenGL(); |
| 140 | Trace.traceEnd(Trace.TRACE_TAG_DALVIK); |
Brian Carlstrom | 6c9af96 | 2014-09-11 15:36:00 -0700 | [diff] [blame] | 141 | preloadSharedLibraries(); |
Raph Levien | c3dd1c1 | 2015-04-06 10:37:57 -0700 | [diff] [blame] | 142 | preloadTextResources(); |
Torne (Richard Coles) | 08cfaf6 | 2014-05-08 16:07:05 +0100 | [diff] [blame] | 143 | // Ask the WebViewFactory to do any initialization that must run in the zygote process, |
| 144 | // for memory sharing purposes. |
| 145 | WebViewFactory.prepareWebViewInZygote(); |
Neil Fuller | 4f41f61 | 2016-05-09 16:55:36 +0100 | [diff] [blame] | 146 | endIcuCachePinning(); |
Sergio Giro | 6cb7b1c | 2016-05-13 16:34:46 +0100 | [diff] [blame] | 147 | warmUpJcaProviders(); |
Bill Yi | 9a76e9b | 2014-04-29 18:52:48 -0700 | [diff] [blame] | 148 | Log.d(TAG, "end preload"); |
Narayan Kamath | 5a3d0c6 | 2016-11-09 15:35:18 +0000 | [diff] [blame] | 149 | |
| 150 | sPreloadComplete = true; |
| 151 | } |
| 152 | |
Narayan Kamath | 669afcc | 2017-02-06 20:24:08 +0000 | [diff] [blame] | 153 | public static void lazyPreload() { |
| 154 | Preconditions.checkState(!sPreloadComplete); |
| 155 | Log.i(TAG, "Lazily preloading resources."); |
| 156 | |
| 157 | preload(new BootTimingsTraceLog("ZygoteInitTiming_lazy", Trace.TRACE_TAG_DALVIK)); |
Romain Guy | 74c6912 | 2013-05-08 17:54:20 -0700 | [diff] [blame] | 158 | } |
| 159 | |
Neil Fuller | 4f41f61 | 2016-05-09 16:55:36 +0100 | [diff] [blame] | 160 | private static void beginIcuCachePinning() { |
| 161 | // Pin ICU data in memory from this point that would normally be held by soft references. |
| 162 | // Without this, any references created immediately below or during class preloading |
| 163 | // would be collected when the Zygote GC runs in gcAndFinalize(). |
| 164 | Log.i(TAG, "Installing ICU cache reference pinning..."); |
| 165 | |
| 166 | CacheValue.setStrength(CacheValue.Strength.STRONG); |
| 167 | |
| 168 | Log.i(TAG, "Preloading ICU data..."); |
| 169 | // Explicitly exercise code to cache data apps are likely to need. |
| 170 | ULocale[] localesToPin = { ULocale.ROOT, ULocale.US, ULocale.getDefault() }; |
| 171 | for (ULocale uLocale : localesToPin) { |
| 172 | new DecimalFormatSymbols(uLocale); |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | private static void endIcuCachePinning() { |
| 177 | // All cache references created by ICU from this point will be soft. |
| 178 | CacheValue.setStrength(CacheValue.Strength.SOFT); |
| 179 | |
| 180 | Log.i(TAG, "Uninstalled ICU cache reference pinning..."); |
| 181 | } |
| 182 | |
Brian Carlstrom | 6c9af96 | 2014-09-11 15:36:00 -0700 | [diff] [blame] | 183 | private static void preloadSharedLibraries() { |
| 184 | Log.i(TAG, "Preloading shared libraries..."); |
| 185 | System.loadLibrary("android"); |
| 186 | System.loadLibrary("compiler_rt"); |
| 187 | System.loadLibrary("jnigraphics"); |
| 188 | } |
| 189 | |
Jesse Hall | 42cf26e | 2017-07-06 15:30:39 -0700 | [diff] [blame] | 190 | native private static void nativePreloadAppProcessHALs(); |
| 191 | |
Jesse Hall | ba0370e | 2017-02-09 14:43:14 -0800 | [diff] [blame] | 192 | private static void preloadOpenGL() { |
| 193 | String driverPackageName = SystemProperties.get(PROPERTY_GFX_DRIVER); |
Jesse Hall | 5d911fe | 2017-04-13 15:44:24 -0700 | [diff] [blame] | 194 | if (!SystemProperties.getBoolean(PROPERTY_DISABLE_OPENGL_PRELOADING, false) && |
| 195 | (driverPackageName == null || driverPackageName.isEmpty())) { |
Jesse Hall | ba0370e | 2017-02-09 14:43:14 -0800 | [diff] [blame] | 196 | EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY); |
| 197 | } |
| 198 | } |
| 199 | |
Raph Levien | c3dd1c1 | 2015-04-06 10:37:57 -0700 | [diff] [blame] | 200 | private static void preloadTextResources() { |
| 201 | Hyphenator.init(); |
Andreas Gampe | ddc1397 | 2016-02-26 16:54:59 -0800 | [diff] [blame] | 202 | TextView.preloadFontCache(); |
Raph Levien | c3dd1c1 | 2015-04-06 10:37:57 -0700 | [diff] [blame] | 203 | } |
| 204 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 205 | /** |
Sergio Giro | 69de320 | 2016-05-17 16:52:33 +0100 | [diff] [blame] | 206 | * Register AndroidKeyStoreProvider and warm up the providers that are already registered. |
Sergio Giro | 6cb7b1c | 2016-05-13 16:34:46 +0100 | [diff] [blame] | 207 | * |
| 208 | * By doing it here we avoid that each app does it when requesting a service from the |
| 209 | * provider for the first time. |
| 210 | */ |
| 211 | private static void warmUpJcaProviders() { |
| 212 | long startTime = SystemClock.uptimeMillis(); |
| 213 | Trace.traceBegin( |
Sergio Giro | 69de320 | 2016-05-17 16:52:33 +0100 | [diff] [blame] | 214 | Trace.TRACE_TAG_DALVIK, "Starting installation of AndroidKeyStoreProvider"); |
| 215 | // AndroidKeyStoreProvider.install() manipulates the list of JCA providers to insert |
| 216 | // preferred providers. Note this is not done via security.properties as the JCA providers |
| 217 | // are not on the classpath in the case of, for example, raw dalvikvm runtimes. |
| 218 | AndroidKeyStoreProvider.install(); |
| 219 | Log.i(TAG, "Installed AndroidKeyStoreProvider in " |
| 220 | + (SystemClock.uptimeMillis() - startTime) + "ms."); |
| 221 | Trace.traceEnd(Trace.TRACE_TAG_DALVIK); |
| 222 | |
| 223 | startTime = SystemClock.uptimeMillis(); |
| 224 | Trace.traceBegin( |
Sergio Giro | 6cb7b1c | 2016-05-13 16:34:46 +0100 | [diff] [blame] | 225 | Trace.TRACE_TAG_DALVIK, "Starting warm up of JCA providers"); |
| 226 | for (Provider p : Security.getProviders()) { |
| 227 | p.warmUpServiceProvision(); |
| 228 | } |
| 229 | Log.i(TAG, "Warmed up JCA providers in " |
Sergio Giro | 69de320 | 2016-05-17 16:52:33 +0100 | [diff] [blame] | 230 | + (SystemClock.uptimeMillis() - startTime) + "ms."); |
Sergio Giro | 6cb7b1c | 2016-05-13 16:34:46 +0100 | [diff] [blame] | 231 | Trace.traceEnd(Trace.TRACE_TAG_DALVIK); |
| 232 | } |
| 233 | |
| 234 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 235 | * Performs Zygote process initialization. Loads and initializes |
| 236 | * commonly used classes. |
| 237 | * |
| 238 | * Most classes only cause a few hundred bytes to be allocated, but |
| 239 | * a few will allocate a dozen Kbytes (in one case, 500+K). |
| 240 | */ |
| 241 | private static void preloadClasses() { |
| 242 | final VMRuntime runtime = VMRuntime.getRuntime(); |
Bob Lee | e540833 | 2009-09-04 18:31:17 -0700 | [diff] [blame] | 243 | |
Ying Wang | d0c4535 | 2014-11-13 15:22:47 -0800 | [diff] [blame] | 244 | InputStream is; |
| 245 | try { |
| 246 | is = new FileInputStream(PRELOADED_CLASSES); |
| 247 | } catch (FileNotFoundException e) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 248 | Log.e(TAG, "Couldn't find " + PRELOADED_CLASSES + "."); |
Ying Wang | d0c4535 | 2014-11-13 15:22:47 -0800 | [diff] [blame] | 249 | return; |
| 250 | } |
Bob Lee | e540833 | 2009-09-04 18:31:17 -0700 | [diff] [blame] | 251 | |
Ying Wang | d0c4535 | 2014-11-13 15:22:47 -0800 | [diff] [blame] | 252 | Log.i(TAG, "Preloading classes..."); |
| 253 | long startTime = SystemClock.uptimeMillis(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 254 | |
Ying Wang | d0c4535 | 2014-11-13 15:22:47 -0800 | [diff] [blame] | 255 | // Drop root perms while running static initializers. |
Narayan Kamath | 23e6878 | 2015-01-16 17:22:41 +0000 | [diff] [blame] | 256 | final int reuid = Os.getuid(); |
| 257 | final int regid = Os.getgid(); |
| 258 | |
| 259 | // We need to drop root perms only if we're already root. In the case of "wrapped" |
| 260 | // processes (see WrapperInit), this function is called from an unprivileged uid |
| 261 | // and gid. |
| 262 | boolean droppedPriviliges = false; |
| 263 | if (reuid == ROOT_UID && regid == ROOT_GID) { |
| 264 | try { |
| 265 | Os.setregid(ROOT_GID, UNPRIVILEGED_GID); |
| 266 | Os.setreuid(ROOT_UID, UNPRIVILEGED_UID); |
| 267 | } catch (ErrnoException ex) { |
| 268 | throw new RuntimeException("Failed to drop root", ex); |
| 269 | } |
| 270 | |
| 271 | droppedPriviliges = true; |
Elliott Hughes | 26b56e6 | 2014-12-17 12:28:29 -0800 | [diff] [blame] | 272 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 273 | |
Ying Wang | d0c4535 | 2014-11-13 15:22:47 -0800 | [diff] [blame] | 274 | // Alter the target heap utilization. With explicit GCs this |
| 275 | // is not likely to have any effect. |
| 276 | float defaultUtilization = runtime.getTargetHeapUtilization(); |
| 277 | runtime.setTargetHeapUtilization(0.8f); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 278 | |
Ying Wang | d0c4535 | 2014-11-13 15:22:47 -0800 | [diff] [blame] | 279 | try { |
| 280 | BufferedReader br |
| 281 | = new BufferedReader(new InputStreamReader(is), 256); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 282 | |
Ying Wang | d0c4535 | 2014-11-13 15:22:47 -0800 | [diff] [blame] | 283 | int count = 0; |
| 284 | String line; |
| 285 | while ((line = br.readLine()) != null) { |
| 286 | // Skip comments and blank lines. |
| 287 | line = line.trim(); |
| 288 | if (line.startsWith("#") || line.equals("")) { |
| 289 | continue; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 290 | } |
| 291 | |
Andreas Gampe | c425362 | 2016-10-28 18:19:30 -0700 | [diff] [blame] | 292 | Trace.traceBegin(Trace.TRACE_TAG_DALVIK, line); |
Ying Wang | d0c4535 | 2014-11-13 15:22:47 -0800 | [diff] [blame] | 293 | try { |
| 294 | if (false) { |
| 295 | Log.v(TAG, "Preloading " + line + "..."); |
| 296 | } |
Andreas Gampe | dd8e5fb | 2015-04-21 09:01:51 -0700 | [diff] [blame] | 297 | // Load and explicitly initialize the given class. Use |
| 298 | // Class.forName(String, boolean, ClassLoader) to avoid repeated stack lookups |
| 299 | // (to derive the caller's class-loader). Use true to force initialization, and |
| 300 | // null for the boot classpath class-loader (could as well cache the |
| 301 | // class-loader of this class in a variable). |
Andreas Gampe | c917f74 | 2015-04-20 19:16:37 -0700 | [diff] [blame] | 302 | Class.forName(line, true, null); |
Ying Wang | d0c4535 | 2014-11-13 15:22:47 -0800 | [diff] [blame] | 303 | count++; |
| 304 | } catch (ClassNotFoundException e) { |
| 305 | Log.w(TAG, "Class not found for preloading: " + line); |
| 306 | } catch (UnsatisfiedLinkError e) { |
| 307 | Log.w(TAG, "Problem preloading " + line + ": " + e); |
| 308 | } catch (Throwable t) { |
| 309 | Log.e(TAG, "Error preloading " + line + ".", t); |
| 310 | if (t instanceof Error) { |
| 311 | throw (Error) t; |
| 312 | } |
| 313 | if (t instanceof RuntimeException) { |
| 314 | throw (RuntimeException) t; |
| 315 | } |
| 316 | throw new RuntimeException(t); |
| 317 | } |
Yasuhiro Matsuda | 25878b2 | 2015-09-03 16:18:21 +0900 | [diff] [blame] | 318 | Trace.traceEnd(Trace.TRACE_TAG_DALVIK); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 319 | } |
Ying Wang | d0c4535 | 2014-11-13 15:22:47 -0800 | [diff] [blame] | 320 | |
| 321 | Log.i(TAG, "...preloaded " + count + " classes in " |
| 322 | + (SystemClock.uptimeMillis()-startTime) + "ms."); |
| 323 | } catch (IOException e) { |
| 324 | Log.e(TAG, "Error reading " + PRELOADED_CLASSES + ".", e); |
| 325 | } finally { |
| 326 | IoUtils.closeQuietly(is); |
| 327 | // Restore default. |
| 328 | runtime.setTargetHeapUtilization(defaultUtilization); |
| 329 | |
| 330 | // Fill in dex caches with classes, fields, and methods brought in by preloading. |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 331 | Trace.traceBegin(Trace.TRACE_TAG_DALVIK, "PreloadDexCaches"); |
Ying Wang | d0c4535 | 2014-11-13 15:22:47 -0800 | [diff] [blame] | 332 | runtime.preloadDexCaches(); |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 333 | Trace.traceEnd(Trace.TRACE_TAG_DALVIK); |
Ying Wang | d0c4535 | 2014-11-13 15:22:47 -0800 | [diff] [blame] | 334 | |
Narayan Kamath | 23e6878 | 2015-01-16 17:22:41 +0000 | [diff] [blame] | 335 | // Bring back root. We'll need it later if we're in the zygote. |
| 336 | if (droppedPriviliges) { |
| 337 | try { |
| 338 | Os.setreuid(ROOT_UID, ROOT_UID); |
| 339 | Os.setregid(ROOT_GID, ROOT_GID); |
| 340 | } catch (ErrnoException ex) { |
| 341 | throw new RuntimeException("Failed to restore root", ex); |
| 342 | } |
Elliott Hughes | 26b56e6 | 2014-12-17 12:28:29 -0800 | [diff] [blame] | 343 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 344 | } |
| 345 | } |
| 346 | |
| 347 | /** |
| 348 | * Load in commonly used resources, so they can be shared across |
| 349 | * processes. |
| 350 | * |
| 351 | * These tend to be a few Kbytes, but are frequently in the 20-40K |
| 352 | * range, and occasionally even larger. |
| 353 | */ |
| 354 | private static void preloadResources() { |
| 355 | final VMRuntime runtime = VMRuntime.getRuntime(); |
Bob Lee | e540833 | 2009-09-04 18:31:17 -0700 | [diff] [blame] | 356 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 357 | try { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 358 | mResources = Resources.getSystem(); |
| 359 | mResources.startPreloading(); |
| 360 | if (PRELOAD_RESOURCES) { |
| 361 | Log.i(TAG, "Preloading resources..."); |
| 362 | |
| 363 | long startTime = SystemClock.uptimeMillis(); |
| 364 | TypedArray ar = mResources.obtainTypedArray( |
| 365 | com.android.internal.R.array.preloaded_drawables); |
Filip Gruszczynski | 811dc3b | 2015-11-23 12:34:22 -0800 | [diff] [blame] | 366 | int N = preloadDrawables(ar); |
Jeff Brown | 14577c4 | 2012-03-08 16:40:14 -0800 | [diff] [blame] | 367 | ar.recycle(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 368 | Log.i(TAG, "...preloaded " + N + " resources in " |
| 369 | + (SystemClock.uptimeMillis()-startTime) + "ms."); |
| 370 | |
| 371 | startTime = SystemClock.uptimeMillis(); |
| 372 | ar = mResources.obtainTypedArray( |
| 373 | com.android.internal.R.array.preloaded_color_state_lists); |
Filip Gruszczynski | 811dc3b | 2015-11-23 12:34:22 -0800 | [diff] [blame] | 374 | N = preloadColorStateLists(ar); |
Jeff Brown | 14577c4 | 2012-03-08 16:40:14 -0800 | [diff] [blame] | 375 | ar.recycle(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 376 | Log.i(TAG, "...preloaded " + N + " resources in " |
| 377 | + (SystemClock.uptimeMillis()-startTime) + "ms."); |
Filip Gruszczynski | 811dc3b | 2015-11-23 12:34:22 -0800 | [diff] [blame] | 378 | |
| 379 | if (mResources.getBoolean( |
| 380 | com.android.internal.R.bool.config_freeformWindowManagement)) { |
| 381 | startTime = SystemClock.uptimeMillis(); |
| 382 | ar = mResources.obtainTypedArray( |
| 383 | com.android.internal.R.array.preloaded_freeform_multi_window_drawables); |
| 384 | N = preloadDrawables(ar); |
| 385 | ar.recycle(); |
| 386 | Log.i(TAG, "...preloaded " + N + " resource in " |
| 387 | + (SystemClock.uptimeMillis() - startTime) + "ms."); |
| 388 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 389 | } |
| 390 | mResources.finishPreloading(); |
| 391 | } catch (RuntimeException e) { |
| 392 | Log.w(TAG, "Failure preloading resources", e); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 393 | } |
| 394 | } |
| 395 | |
Filip Gruszczynski | 811dc3b | 2015-11-23 12:34:22 -0800 | [diff] [blame] | 396 | private static int preloadColorStateLists(TypedArray ar) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 397 | int N = ar.length(); |
| 398 | for (int i=0; i<N; i++) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 399 | int id = ar.getResourceId(i, 0); |
Joe Onorato | 43a1765 | 2011-04-06 19:22:23 -0700 | [diff] [blame] | 400 | if (false) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 401 | Log.v(TAG, "Preloading resource #" + Integer.toHexString(id)); |
| 402 | } |
| 403 | if (id != 0) { |
Alan Viverette | 77bb6f1 | 2015-02-11 17:24:33 -0800 | [diff] [blame] | 404 | if (mResources.getColorStateList(id, null) == null) { |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame] | 405 | throw new IllegalArgumentException( |
| 406 | "Unable to find preloaded color resource #0x" |
| 407 | + Integer.toHexString(id) |
| 408 | + " (" + ar.getString(i) + ")"); |
| 409 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 410 | } |
| 411 | } |
| 412 | return N; |
| 413 | } |
| 414 | |
| 415 | |
Filip Gruszczynski | 811dc3b | 2015-11-23 12:34:22 -0800 | [diff] [blame] | 416 | private static int preloadDrawables(TypedArray ar) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 417 | int N = ar.length(); |
| 418 | for (int i=0; i<N; i++) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 419 | int id = ar.getResourceId(i, 0); |
Joe Onorato | 43a1765 | 2011-04-06 19:22:23 -0700 | [diff] [blame] | 420 | if (false) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 421 | Log.v(TAG, "Preloading resource #" + Integer.toHexString(id)); |
| 422 | } |
| 423 | if (id != 0) { |
Alan Viverette | 84e001a | 2014-09-22 00:04:22 -0700 | [diff] [blame] | 424 | if (mResources.getDrawable(id, null) == null) { |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame] | 425 | throw new IllegalArgumentException( |
| 426 | "Unable to find preloaded drawable resource #0x" |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 427 | + Integer.toHexString(id) |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame] | 428 | + " (" + ar.getString(i) + ")"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 429 | } |
| 430 | } |
| 431 | } |
| 432 | return N; |
| 433 | } |
| 434 | |
| 435 | /** |
| 436 | * Runs several special GCs to try to clean up a few generations of |
| 437 | * softly- and final-reachable objects, along with any other garbage. |
| 438 | * This is only useful just before a fork(). |
| 439 | */ |
Mathieu Chartier | 9a88f10 | 2014-08-20 10:24:11 -0700 | [diff] [blame] | 440 | /*package*/ static void gcAndFinalize() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 441 | final VMRuntime runtime = VMRuntime.getRuntime(); |
| 442 | |
| 443 | /* runFinalizationSync() lets finalizers be called in Zygote, |
| 444 | * which doesn't have a HeapWorker thread. |
| 445 | */ |
Brian Carlstrom | 08065b9 | 2011-04-01 15:49:41 -0700 | [diff] [blame] | 446 | System.gc(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 447 | runtime.runFinalizationSync(); |
Brian Carlstrom | 08065b9 | 2011-04-01 15:49:41 -0700 | [diff] [blame] | 448 | System.gc(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | /** |
| 452 | * Finish remaining work for the newly forked system server process. |
| 453 | */ |
Narayan Kamath | ac0b4be | 2017-07-05 14:45:38 +0100 | [diff] [blame] | 454 | private static Runnable handleSystemServerProcess(ZygoteConnection.Arguments parsedArgs) { |
Mike Lockwood | 90960e8 | 2010-08-06 09:15:25 -0400 | [diff] [blame] | 455 | // set umask to 0077 so new files and directories will default to owner-only permissions. |
Elliott Hughes | 860c591 | 2014-04-28 19:19:13 -0700 | [diff] [blame] | 456 | Os.umask(S_IRWXG | S_IRWXO); |
Mike Lockwood | 90960e8 | 2010-08-06 09:15:25 -0400 | [diff] [blame] | 457 | |
Jeff Brown | ebed7d6 | 2011-05-16 17:08:42 -0700 | [diff] [blame] | 458 | if (parsedArgs.niceName != null) { |
| 459 | Process.setArgV0(parsedArgs.niceName); |
| 460 | } |
| 461 | |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 462 | final String systemServerClasspath = Os.getenv("SYSTEMSERVERCLASSPATH"); |
| 463 | if (systemServerClasspath != null) { |
| 464 | performSystemServerDexOpt(systemServerClasspath); |
Mathieu Chartier | b3eeceb | 2017-03-30 21:00:18 -0700 | [diff] [blame] | 465 | // Capturing profiles is only supported for debug or eng builds since selinux normally |
| 466 | // prevents it. |
| 467 | boolean profileSystemServer = SystemProperties.getBoolean( |
| 468 | "dalvik.vm.profilesystemserver", false); |
| 469 | if (profileSystemServer && (Build.IS_USERDEBUG || Build.IS_ENG)) { |
| 470 | try { |
| 471 | File profileDir = Environment.getDataProfilesDePackageDirectory( |
| 472 | Process.SYSTEM_UID, "system_server"); |
| 473 | File profile = new File(profileDir, "primary.prof"); |
| 474 | profile.getParentFile().mkdirs(); |
| 475 | profile.createNewFile(); |
| 476 | String[] codePaths = systemServerClasspath.split(":"); |
| 477 | VMRuntime.registerAppInfo(profile.getPath(), codePaths); |
| 478 | } catch (Exception e) { |
| 479 | Log.wtf(TAG, "Failed to set up system server profile", e); |
| 480 | } |
| 481 | } |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 482 | } |
| 483 | |
Jeff Brown | ebed7d6 | 2011-05-16 17:08:42 -0700 | [diff] [blame] | 484 | if (parsedArgs.invokeWith != null) { |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 485 | String[] args = parsedArgs.remainingArgs; |
| 486 | // If we have a non-null system server class path, we'll have to duplicate the |
| 487 | // existing arguments and append the classpath to it. ART will handle the classpath |
| 488 | // correctly when we exec a new process. |
| 489 | if (systemServerClasspath != null) { |
| 490 | String[] amendedArgs = new String[args.length + 2]; |
| 491 | amendedArgs[0] = "-cp"; |
| 492 | amendedArgs[1] = systemServerClasspath; |
tony.ys_liu | 3473817 | 2016-12-14 18:50:29 +0800 | [diff] [blame] | 493 | System.arraycopy(args, 0, amendedArgs, 2, args.length); |
| 494 | args = amendedArgs; |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 495 | } |
| 496 | |
Jeff Brown | ebed7d6 | 2011-05-16 17:08:42 -0700 | [diff] [blame] | 497 | WrapperInit.execApplication(parsedArgs.invokeWith, |
Elliott Hughes | e1dfcb7 | 2011-07-08 11:08:07 -0700 | [diff] [blame] | 498 | parsedArgs.niceName, parsedArgs.targetSdkVersion, |
Narayan Kamath | 37ad4b0 | 2015-01-19 16:05:24 +0000 | [diff] [blame] | 499 | VMRuntime.getCurrentInstructionSet(), null, args); |
Narayan Kamath | ac0b4be | 2017-07-05 14:45:38 +0100 | [diff] [blame] | 500 | |
| 501 | throw new IllegalStateException("Unexpected return from WrapperInit.execApplication"); |
Jeff Brown | ebed7d6 | 2011-05-16 17:08:42 -0700 | [diff] [blame] | 502 | } else { |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 503 | ClassLoader cl = null; |
| 504 | if (systemServerClasspath != null) { |
tony.ys_liu | 3473817 | 2016-12-14 18:50:29 +0800 | [diff] [blame] | 505 | cl = createPathClassLoader(systemServerClasspath, parsedArgs.targetSdkVersion); |
Dimitry Ivanov | 89dad33 | 2016-04-20 16:02:00 -0700 | [diff] [blame] | 506 | |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 507 | Thread.currentThread().setContextClassLoader(cl); |
| 508 | } |
| 509 | |
Jeff Brown | ebed7d6 | 2011-05-16 17:08:42 -0700 | [diff] [blame] | 510 | /* |
| 511 | * Pass the remaining arguments to SystemServer. |
| 512 | */ |
Narayan Kamath | ac0b4be | 2017-07-05 14:45:38 +0100 | [diff] [blame] | 513 | return ZygoteInit.zygoteInit(parsedArgs.targetSdkVersion, parsedArgs.remainingArgs, cl); |
Jeff Brown | ebed7d6 | 2011-05-16 17:08:42 -0700 | [diff] [blame] | 514 | } |
| 515 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 516 | /* should never reach here */ |
| 517 | } |
| 518 | |
| 519 | /** |
tony.ys_liu | 3473817 | 2016-12-14 18:50:29 +0800 | [diff] [blame] | 520 | * Creates a PathClassLoader for the given class path that is associated with a shared |
| 521 | * namespace, i.e., this classloader can access platform-private native libraries. The |
| 522 | * classloader will use java.library.path as the native library path. |
Dimitry Ivanov | 89dad33 | 2016-04-20 16:02:00 -0700 | [diff] [blame] | 523 | */ |
tony.ys_liu | 3473817 | 2016-12-14 18:50:29 +0800 | [diff] [blame] | 524 | static PathClassLoader createPathClassLoader(String classPath, int targetSdkVersion) { |
Dimitry Ivanov | 9e9061f | 2016-09-20 10:50:40 -0700 | [diff] [blame] | 525 | String libraryPath = System.getProperty("java.library.path"); |
Dimitry Ivanov | 89dad33 | 2016-04-20 16:02:00 -0700 | [diff] [blame] | 526 | |
tony.ys_liu | 3473817 | 2016-12-14 18:50:29 +0800 | [diff] [blame] | 527 | return PathClassLoaderFactory.createClassLoader(classPath, |
Dimitry Ivanov | 9e9061f | 2016-09-20 10:50:40 -0700 | [diff] [blame] | 528 | libraryPath, |
| 529 | libraryPath, |
Dimitry Ivanov | 89dad33 | 2016-04-20 16:02:00 -0700 | [diff] [blame] | 530 | ClassLoader.getSystemClassLoader(), |
| 531 | targetSdkVersion, |
| 532 | true /* isNamespaceShared */); |
| 533 | } |
| 534 | |
| 535 | /** |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 536 | * Performs dex-opt on the elements of {@code classPath}, if needed. We |
| 537 | * choose the instruction set of the current runtime. |
| 538 | */ |
| 539 | private static void performSystemServerDexOpt(String classPath) { |
| 540 | final String[] classPathElements = classPath.split(":"); |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 541 | final IInstalld installd = IInstalld.Stub |
| 542 | .asInterface(ServiceManager.getService("installd")); |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 543 | final String instructionSet = VMRuntime.getRuntime().vmInstructionSet(); |
| 544 | |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 545 | String sharedLibraries = ""; |
| 546 | for (String classPathElement : classPathElements) { |
| 547 | // System server is fully AOTed and never profiled |
| 548 | // for profile guided compilation. |
| 549 | // TODO: Make this configurable between INTERPRET_ONLY, SPEED, SPACE and EVERYTHING? |
Andreas Gampe | e7bc152 | 2016-08-09 20:44:04 -0700 | [diff] [blame] | 550 | |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 551 | int dexoptNeeded; |
| 552 | try { |
| 553 | dexoptNeeded = DexFile.getDexOptNeeded( |
| 554 | classPathElement, instructionSet, "speed", |
Shubham Ajmera | 52c8620 | 2017-07-24 15:21:04 -0700 | [diff] [blame] | 555 | false /* newProfile */, false /* downgrade */); |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 556 | } catch (FileNotFoundException ignored) { |
| 557 | // Do not add to the classpath. |
| 558 | Log.w(TAG, "Missing classpath element for system server: " + classPathElement); |
| 559 | continue; |
| 560 | } catch (IOException e) { |
| 561 | // Not fully clear what to do here as we don't know the cause of the |
| 562 | // IO exception. Add to the classpath to be conservative, but don't |
| 563 | // attempt to compile it. |
| 564 | Log.w(TAG, "Error checking classpath element for system server: " |
| 565 | + classPathElement, e); |
| 566 | dexoptNeeded = DexFile.NO_DEXOPT_NEEDED; |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 567 | } |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 568 | |
| 569 | if (dexoptNeeded != DexFile.NO_DEXOPT_NEEDED) { |
| 570 | final String packageName = "*"; |
| 571 | final String outputPath = null; |
| 572 | final int dexFlags = 0; |
| 573 | final String compilerFilter = "speed"; |
| 574 | final String uuid = StorageManager.UUID_PRIVATE_INTERNAL; |
Calin Juravle | 811a75a | 2017-04-05 22:49:38 -0700 | [diff] [blame] | 575 | final String seInfo = null; |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 576 | try { |
| 577 | installd.dexopt(classPathElement, Process.SYSTEM_UID, packageName, |
| 578 | instructionSet, dexoptNeeded, outputPath, dexFlags, compilerFilter, |
Calin Juravle | 811a75a | 2017-04-05 22:49:38 -0700 | [diff] [blame] | 579 | uuid, sharedLibraries, seInfo); |
Jeff Sharkey | 740f523 | 2016-12-09 14:31:26 -0700 | [diff] [blame] | 580 | } catch (RemoteException | ServiceSpecificException e) { |
| 581 | // Ignore (but log), we need this on the classpath for fallback mode. |
| 582 | Log.w(TAG, "Failed compiling classpath element for system server: " |
| 583 | + classPathElement, e); |
| 584 | } |
| 585 | } |
| 586 | |
| 587 | if (!sharedLibraries.isEmpty()) { |
| 588 | sharedLibraries += ":"; |
| 589 | } |
| 590 | sharedLibraries += classPathElement; |
Narayan Kamath | 29564cd | 2014-08-07 10:57:40 +0100 | [diff] [blame] | 591 | } |
| 592 | } |
| 593 | |
| 594 | /** |
Narayan Kamath | ac0b4be | 2017-07-05 14:45:38 +0100 | [diff] [blame] | 595 | * Prepare the arguments and forks for the system server process. |
| 596 | * |
| 597 | * Returns an {@code Runnable} that provides an entrypoint into system_server code in the |
| 598 | * child process, and {@code null} in the parent. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 599 | */ |
Narayan Kamath | ac0b4be | 2017-07-05 14:45:38 +0100 | [diff] [blame] | 600 | private static Runnable forkSystemServer(String abiList, String socketName, |
| 601 | ZygoteServer zygoteServer) { |
Alex Klyubin | 48a06e7 | 2013-04-19 10:01:42 -0700 | [diff] [blame] | 602 | long capabilities = posixCapabilitiesAsBits( |
Philip Cuadra | 7bd0fdd | 2016-04-28 15:26:49 -0700 | [diff] [blame] | 603 | OsConstants.CAP_IPC_LOCK, |
Alex Klyubin | 48a06e7 | 2013-04-19 10:01:42 -0700 | [diff] [blame] | 604 | OsConstants.CAP_KILL, |
| 605 | OsConstants.CAP_NET_ADMIN, |
| 606 | OsConstants.CAP_NET_BIND_SERVICE, |
| 607 | OsConstants.CAP_NET_BROADCAST, |
| 608 | OsConstants.CAP_NET_RAW, |
Alex Klyubin | 48a06e7 | 2013-04-19 10:01:42 -0700 | [diff] [blame] | 609 | OsConstants.CAP_SYS_MODULE, |
| 610 | OsConstants.CAP_SYS_NICE, |
Nick Kralevich | 3082eb7 | 2017-02-15 15:12:31 -0800 | [diff] [blame] | 611 | OsConstants.CAP_SYS_PTRACE, |
Alex Klyubin | 48a06e7 | 2013-04-19 10:01:42 -0700 | [diff] [blame] | 612 | OsConstants.CAP_SYS_TIME, |
John Stultz | 5733f38 | 2016-07-28 12:35:31 -0700 | [diff] [blame] | 613 | OsConstants.CAP_SYS_TTY_CONFIG, |
Luis Hector Chavez | 72042c9 | 2017-07-12 10:03:30 -0700 | [diff] [blame] | 614 | OsConstants.CAP_WAKE_ALARM, |
| 615 | OsConstants.CAP_BLOCK_SUSPEND |
Alex Klyubin | 48a06e7 | 2013-04-19 10:01:42 -0700 | [diff] [blame] | 616 | ); |
Luis Hector Chavez | 72042c9 | 2017-07-12 10:03:30 -0700 | [diff] [blame] | 617 | /* Containers run without some capabilities, so drop any caps that are not available. */ |
| 618 | StructCapUserHeader header = new StructCapUserHeader( |
| 619 | OsConstants._LINUX_CAPABILITY_VERSION_3, 0); |
| 620 | StructCapUserData[] data; |
| 621 | try { |
| 622 | data = Os.capget(header); |
| 623 | } catch (ErrnoException ex) { |
| 624 | throw new RuntimeException("Failed to capget()", ex); |
Luis Hector Chavez | 5dd239a | 2015-10-06 14:01:45 -0700 | [diff] [blame] | 625 | } |
Luis Hector Chavez | 72042c9 | 2017-07-12 10:03:30 -0700 | [diff] [blame] | 626 | capabilities &= ((long) data[0].effective) | (((long) data[1].effective) << 32); |
| 627 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 628 | /* Hardcoded command line to start the system server */ |
| 629 | String args[] = { |
| 630 | "--setuid=1000", |
| 631 | "--setgid=1000", |
Jeff Sharkey | 053a909 | 2016-12-02 13:17:49 -0700 | [diff] [blame] | 632 | "--setgroups=1001,1002,1003,1004,1005,1006,1007,1008,1009,1010,1018,1021,1023,1032,3001,3002,3003,3006,3007,3009,3010", |
Alex Klyubin | 48a06e7 | 2013-04-19 10:01:42 -0700 | [diff] [blame] | 633 | "--capabilities=" + capabilities + "," + capabilities, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 634 | "--nice-name=system_server", |
Narayan Kamath | b6b044a | 2015-02-13 17:31:25 +0000 | [diff] [blame] | 635 | "--runtime-args", |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 636 | "com.android.server.SystemServer", |
| 637 | }; |
| 638 | ZygoteConnection.Arguments parsedArgs = null; |
| 639 | |
| 640 | int pid; |
| 641 | |
| 642 | try { |
| 643 | parsedArgs = new ZygoteConnection.Arguments(args); |
Jeff Brown | ebed7d6 | 2011-05-16 17:08:42 -0700 | [diff] [blame] | 644 | ZygoteConnection.applyDebuggerSystemProperty(parsedArgs); |
| 645 | ZygoteConnection.applyInvokeWithSystemProperty(parsedArgs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 646 | |
| 647 | /* Request to fork the system server process */ |
| 648 | pid = Zygote.forkSystemServer( |
| 649 | parsedArgs.uid, parsedArgs.gid, |
Elliott Hughes | e1dfcb7 | 2011-07-08 11:08:07 -0700 | [diff] [blame] | 650 | parsedArgs.gids, |
Nicolas Geoffray | 81edac4 | 2017-09-07 14:13:29 +0100 | [diff] [blame] | 651 | parsedArgs.runtimeFlags, |
Elliott Hughes | e1dfcb7 | 2011-07-08 11:08:07 -0700 | [diff] [blame] | 652 | null, |
Andy McFadden | 1b4c796 | 2010-10-27 11:26:05 -0700 | [diff] [blame] | 653 | parsedArgs.permittedCapabilities, |
| 654 | parsedArgs.effectiveCapabilities); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 655 | } catch (IllegalArgumentException ex) { |
| 656 | throw new RuntimeException(ex); |
Bob Lee | e540833 | 2009-09-04 18:31:17 -0700 | [diff] [blame] | 657 | } |
| 658 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 659 | /* For child process */ |
| 660 | if (pid == 0) { |
Narayan Kamath | 64cd907 | 2014-05-13 13:35:14 +0100 | [diff] [blame] | 661 | if (hasSecondZygote(abiList)) { |
| 662 | waitForSecondaryZygote(socketName); |
| 663 | } |
| 664 | |
Tobias Sargeant | dd4bb31 | 2016-01-19 16:34:54 +0000 | [diff] [blame] | 665 | zygoteServer.closeServerSocket(); |
Narayan Kamath | ac0b4be | 2017-07-05 14:45:38 +0100 | [diff] [blame] | 666 | return handleSystemServerProcess(parsedArgs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 667 | } |
| 668 | |
Narayan Kamath | ac0b4be | 2017-07-05 14:45:38 +0100 | [diff] [blame] | 669 | return null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 670 | } |
| 671 | |
Alex Klyubin | 48a06e7 | 2013-04-19 10:01:42 -0700 | [diff] [blame] | 672 | /** |
| 673 | * Gets the bit array representation of the provided list of POSIX capabilities. |
| 674 | */ |
| 675 | private static long posixCapabilitiesAsBits(int... capabilities) { |
| 676 | long result = 0; |
| 677 | for (int capability : capabilities) { |
| 678 | if ((capability < 0) || (capability > OsConstants.CAP_LAST_CAP)) { |
| 679 | throw new IllegalArgumentException(String.valueOf(capability)); |
| 680 | } |
| 681 | result |= (1L << capability); |
| 682 | } |
| 683 | return result; |
| 684 | } |
| 685 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 686 | public static void main(String argv[]) { |
Tobias Sargeant | dd4bb31 | 2016-01-19 16:34:54 +0000 | [diff] [blame] | 687 | ZygoteServer zygoteServer = new ZygoteServer(); |
| 688 | |
Andreas Gampe | 1ef8aef | 2016-04-11 08:39:52 -0700 | [diff] [blame] | 689 | // Mark zygote start. This ensures that thread creation will throw |
| 690 | // an error. |
| 691 | ZygoteHooks.startZygoteNoThreadCreation(); |
| 692 | |
Robert Sesek | e4f8d69 | 2016-09-13 19:13:01 -0400 | [diff] [blame] | 693 | // Zygote goes into its own process group. |
| 694 | try { |
| 695 | Os.setpgid(0, 0); |
| 696 | } catch (ErrnoException ex) { |
| 697 | throw new RuntimeException("Failed to setpgid(0,0)", ex); |
| 698 | } |
| 699 | |
Narayan Kamath | ac0b4be | 2017-07-05 14:45:38 +0100 | [diff] [blame] | 700 | final Runnable caller; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 701 | try { |
Fyodor Kupolov | 6733e6c | 2017-01-06 18:27:05 -0800 | [diff] [blame] | 702 | // Report Zygote start time to tron unless it is a runtime restart |
| 703 | if (!"1".equals(SystemProperties.get("sys.boot_completed"))) { |
| 704 | MetricsLogger.histogram(null, "boot_zygote_init", |
| 705 | (int) SystemClock.elapsedRealtime()); |
| 706 | } |
Fyodor Kupolov | 3235e0c | 2016-11-17 11:44:49 -0800 | [diff] [blame] | 707 | |
| 708 | String bootTimeTag = Process.is64Bit() ? "Zygote64Timing" : "Zygote32Timing"; |
| 709 | BootTimingsTraceLog bootTimingsTraceLog = new BootTimingsTraceLog(bootTimeTag, |
| 710 | Trace.TRACE_TAG_DALVIK); |
| 711 | bootTimingsTraceLog.traceBegin("ZygoteInit"); |
Yasuhiro Matsuda | 25878b2 | 2015-09-03 16:18:21 +0900 | [diff] [blame] | 712 | RuntimeInit.enableDdms(); |
Yasuhiro Matsuda | 25878b2 | 2015-09-03 16:18:21 +0900 | [diff] [blame] | 713 | |
Narayan Kamath | c41638c | 2014-04-07 13:56:15 +0100 | [diff] [blame] | 714 | boolean startSystemServer = false; |
| 715 | String socketName = "zygote"; |
| 716 | String abiList = null; |
Narayan Kamath | 5a3d0c6 | 2016-11-09 15:35:18 +0000 | [diff] [blame] | 717 | boolean enableLazyPreload = false; |
Yasuhiro Matsuda | 25878b2 | 2015-09-03 16:18:21 +0900 | [diff] [blame] | 718 | for (int i = 1; i < argv.length; i++) { |
| 719 | if ("start-system-server".equals(argv[i])) { |
| 720 | startSystemServer = true; |
Narayan Kamath | 5a3d0c6 | 2016-11-09 15:35:18 +0000 | [diff] [blame] | 721 | } else if ("--enable-lazy-preload".equals(argv[i])) { |
| 722 | enableLazyPreload = true; |
Yasuhiro Matsuda | 25878b2 | 2015-09-03 16:18:21 +0900 | [diff] [blame] | 723 | } else if (argv[i].startsWith(ABI_LIST_ARG)) { |
| 724 | abiList = argv[i].substring(ABI_LIST_ARG.length()); |
| 725 | } else if (argv[i].startsWith(SOCKET_NAME_ARG)) { |
| 726 | socketName = argv[i].substring(SOCKET_NAME_ARG.length()); |
| 727 | } else { |
| 728 | throw new RuntimeException("Unknown command line argument: " + argv[i]); |
Narayan Kamath | c41638c | 2014-04-07 13:56:15 +0100 | [diff] [blame] | 729 | } |
| 730 | } |
| 731 | |
Yasuhiro Matsuda | 25878b2 | 2015-09-03 16:18:21 +0900 | [diff] [blame] | 732 | if (abiList == null) { |
| 733 | throw new RuntimeException("No ABI list supplied."); |
| 734 | } |
| 735 | |
Tobias Sargeant | dd4bb31 | 2016-01-19 16:34:54 +0000 | [diff] [blame] | 736 | zygoteServer.registerServerSocket(socketName); |
Narayan Kamath | 5a3d0c6 | 2016-11-09 15:35:18 +0000 | [diff] [blame] | 737 | // In some configurations, we avoid preloading resources and classes eagerly. |
| 738 | // In such cases, we will preload things prior to our first fork. |
| 739 | if (!enableLazyPreload) { |
| 740 | bootTimingsTraceLog.traceBegin("ZygotePreload"); |
| 741 | EventLog.writeEvent(LOG_BOOT_PROGRESS_PRELOAD_START, |
| 742 | SystemClock.uptimeMillis()); |
| 743 | preload(bootTimingsTraceLog); |
| 744 | EventLog.writeEvent(LOG_BOOT_PROGRESS_PRELOAD_END, |
| 745 | SystemClock.uptimeMillis()); |
| 746 | bootTimingsTraceLog.traceEnd(); // ZygotePreload |
Narayan Kamath | b49996d | 2017-02-06 20:24:08 +0000 | [diff] [blame] | 747 | } else { |
Hiroshi Yamauchi | 1e3db87 | 2017-03-02 13:39:07 -0800 | [diff] [blame] | 748 | Zygote.resetNicePriority(); |
Narayan Kamath | 5a3d0c6 | 2016-11-09 15:35:18 +0000 | [diff] [blame] | 749 | } |
Yasuhiro Matsuda | 25878b2 | 2015-09-03 16:18:21 +0900 | [diff] [blame] | 750 | |
Yasuhiro Matsuda | 25878b2 | 2015-09-03 16:18:21 +0900 | [diff] [blame] | 751 | // Do an initial gc to clean up after startup |
Fyodor Kupolov | 3235e0c | 2016-11-17 11:44:49 -0800 | [diff] [blame] | 752 | bootTimingsTraceLog.traceBegin("PostZygoteInitGC"); |
Yasuhiro Matsuda | 25878b2 | 2015-09-03 16:18:21 +0900 | [diff] [blame] | 753 | gcAndFinalize(); |
Fyodor Kupolov | 3235e0c | 2016-11-17 11:44:49 -0800 | [diff] [blame] | 754 | bootTimingsTraceLog.traceEnd(); // PostZygoteInitGC |
Yasuhiro Matsuda | 25878b2 | 2015-09-03 16:18:21 +0900 | [diff] [blame] | 755 | |
Fyodor Kupolov | 3235e0c | 2016-11-17 11:44:49 -0800 | [diff] [blame] | 756 | bootTimingsTraceLog.traceEnd(); // ZygoteInit |
Jamie Gennis | 6ad0452 | 2013-04-15 18:53:24 -0700 | [diff] [blame] | 757 | // Disable tracing so that forked processes do not inherit stale tracing tags from |
| 758 | // Zygote. |
John Reck | 62cc119 | 2017-05-12 15:39:51 -0700 | [diff] [blame] | 759 | Trace.setTracingEnabled(false, 0); |
Jamie Gennis | 6ad0452 | 2013-04-15 18:53:24 -0700 | [diff] [blame] | 760 | |
doheon1.lee | 885b742 | 2016-01-20 13:07:27 +0900 | [diff] [blame] | 761 | // Zygote process unmounts root storage spaces. |
| 762 | Zygote.nativeUnmountStorageOnInit(); |
| 763 | |
Paul Lawrence | ef85477 | 2017-01-31 09:54:31 -0800 | [diff] [blame] | 764 | // Set seccomp policy |
| 765 | Seccomp.setPolicy(); |
| 766 | |
Andreas Gampe | 1ef8aef | 2016-04-11 08:39:52 -0700 | [diff] [blame] | 767 | ZygoteHooks.stopZygoteNoThreadCreation(); |
| 768 | |
Narayan Kamath | c41638c | 2014-04-07 13:56:15 +0100 | [diff] [blame] | 769 | if (startSystemServer) { |
Narayan Kamath | ac0b4be | 2017-07-05 14:45:38 +0100 | [diff] [blame] | 770 | Runnable r = forkSystemServer(abiList, socketName, zygoteServer); |
| 771 | |
| 772 | // {@code r == null} in the parent (zygote) process, and {@code r != null} in the |
| 773 | // child (system_server) process. |
| 774 | if (r != null) { |
| 775 | r.run(); |
| 776 | return; |
| 777 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 778 | } |
| 779 | |
| 780 | Log.i(TAG, "Accepting command socket connections"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 781 | |
Narayan Kamath | ac0b4be | 2017-07-05 14:45:38 +0100 | [diff] [blame] | 782 | // The select loop returns early in the child process after a fork and |
| 783 | // loops forever in the zygote. |
| 784 | caller = zygoteServer.runSelectLoop(abiList); |
Christopher Ferris | ea8b5de | 2016-06-17 15:29:58 -0700 | [diff] [blame] | 785 | } catch (Throwable ex) { |
Tobias Sargeant | dd4bb31 | 2016-01-19 16:34:54 +0000 | [diff] [blame] | 786 | Log.e(TAG, "System zygote died with exception", ex); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 787 | throw ex; |
Narayan Kamath | ac0b4be | 2017-07-05 14:45:38 +0100 | [diff] [blame] | 788 | } finally { |
| 789 | zygoteServer.closeServerSocket(); |
| 790 | } |
| 791 | |
| 792 | // We're in the child process and have exited the select loop. Proceed to execute the |
| 793 | // command. |
| 794 | if (caller != null) { |
| 795 | caller.run(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 796 | } |
| 797 | } |
| 798 | |
| 799 | /** |
Narayan Kamath | 64cd907 | 2014-05-13 13:35:14 +0100 | [diff] [blame] | 800 | * Return {@code true} if this device configuration has another zygote. |
| 801 | * |
| 802 | * We determine this by comparing the device ABI list with this zygotes |
| 803 | * list. If this zygote supports all ABIs this device supports, there won't |
| 804 | * be another zygote. |
| 805 | */ |
| 806 | private static boolean hasSecondZygote(String abiList) { |
| 807 | return !SystemProperties.get("ro.product.cpu.abilist").equals(abiList); |
| 808 | } |
| 809 | |
| 810 | private static void waitForSecondaryZygote(String socketName) { |
| 811 | String otherZygoteName = Process.ZYGOTE_SOCKET.equals(socketName) ? |
| 812 | Process.SECONDARY_ZYGOTE_SOCKET : Process.ZYGOTE_SOCKET; |
Gustav Sennton | f0c52b5 | 2017-04-27 17:00:50 +0100 | [diff] [blame] | 813 | ZygoteProcess.waitForConnectionToZygote(otherZygoteName); |
Narayan Kamath | 64cd907 | 2014-05-13 13:35:14 +0100 | [diff] [blame] | 814 | } |
| 815 | |
Narayan Kamath | 669afcc | 2017-02-06 20:24:08 +0000 | [diff] [blame] | 816 | static boolean isPreloadComplete() { |
| 817 | return sPreloadComplete; |
| 818 | } |
| 819 | |
Narayan Kamath | 64cd907 | 2014-05-13 13:35:14 +0100 | [diff] [blame] | 820 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 821 | * Class not instantiable. |
| 822 | */ |
| 823 | private ZygoteInit() { |
| 824 | } |
Andreas Gampe | 76d4fc8 | 2017-02-07 19:44:37 -0800 | [diff] [blame] | 825 | |
| 826 | /** |
| 827 | * The main function called when started through the zygote process. This |
| 828 | * could be unified with main(), if the native code in nativeFinishInit() |
| 829 | * were rationalized with Zygote startup.<p> |
| 830 | * |
| 831 | * Current recognized args: |
| 832 | * <ul> |
| 833 | * <li> <code> [--] <start class name> <args> |
| 834 | * </ul> |
| 835 | * |
| 836 | * @param targetSdkVersion target SDK version |
| 837 | * @param argv arg strings |
| 838 | */ |
Narayan Kamath | ac0b4be | 2017-07-05 14:45:38 +0100 | [diff] [blame] | 839 | public static final Runnable zygoteInit(int targetSdkVersion, String[] argv, ClassLoader classLoader) { |
Andreas Gampe | 76d4fc8 | 2017-02-07 19:44:37 -0800 | [diff] [blame] | 840 | if (RuntimeInit.DEBUG) { |
| 841 | Slog.d(RuntimeInit.TAG, "RuntimeInit: Starting application from zygote"); |
| 842 | } |
| 843 | |
| 844 | Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "ZygoteInit"); |
| 845 | RuntimeInit.redirectLogStreams(); |
| 846 | |
| 847 | RuntimeInit.commonInit(); |
| 848 | ZygoteInit.nativeZygoteInit(); |
Narayan Kamath | ac0b4be | 2017-07-05 14:45:38 +0100 | [diff] [blame] | 849 | return RuntimeInit.applicationInit(targetSdkVersion, argv, classLoader); |
Andreas Gampe | 76d4fc8 | 2017-02-07 19:44:37 -0800 | [diff] [blame] | 850 | } |
| 851 | |
| 852 | private static final native void nativeZygoteInit(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 853 | } |