SystemServer.java revision a4620793038b9a9163b26c6ece882cb454fcbf87
1/* 2 * Copyright (C) 2006 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 17package com.android.server; 18 19import com.android.server.accessibility.AccessibilityManagerService; 20import com.android.server.am.ActivityManagerService; 21import com.android.server.net.NetworkPolicyManagerService; 22import com.android.server.pm.PackageManagerService; 23import com.android.server.usb.UsbService; 24import com.android.server.wm.WindowManagerService; 25import com.android.internal.app.ShutdownThread; 26import com.android.internal.os.BinderInternal; 27import com.android.internal.os.SamplingProfilerIntegration; 28 29import dalvik.system.VMRuntime; 30import dalvik.system.Zygote; 31 32import android.accounts.AccountManagerService; 33import android.app.ActivityManagerNative; 34import android.bluetooth.BluetoothAdapter; 35import android.content.ComponentName; 36import android.content.ContentResolver; 37import android.content.ContentService; 38import android.content.Context; 39import android.content.Intent; 40import android.content.pm.IPackageManager; 41import android.content.res.Configuration; 42import android.database.ContentObserver; 43import android.media.AudioService; 44import android.os.Build; 45import android.os.Looper; 46import android.os.RemoteException; 47import android.os.ServiceManager; 48import android.os.StrictMode; 49import android.os.SystemClock; 50import android.os.SystemProperties; 51import android.provider.Contacts.People; 52import android.provider.Settings; 53import android.server.BluetoothA2dpService; 54import android.server.BluetoothService; 55import android.server.search.SearchManagerService; 56import android.util.DisplayMetrics; 57import android.util.EventLog; 58import android.util.Log; 59import android.util.Slog; 60import android.view.Display; 61import android.view.WindowManager; 62 63import java.io.File; 64import java.util.Timer; 65import java.util.TimerTask; 66 67class ServerThread extends Thread { 68 private static final String TAG = "SystemServer"; 69 70 ContentResolver mContentResolver; 71 72 private class AdbSettingsObserver extends ContentObserver { 73 public AdbSettingsObserver() { 74 super(null); 75 } 76 @Override 77 public void onChange(boolean selfChange) { 78 boolean enableAdb = (Settings.Secure.getInt(mContentResolver, 79 Settings.Secure.ADB_ENABLED, 0) > 0); 80 // setting this secure property will start or stop adbd 81 SystemProperties.set("persist.service.adb.enable", enableAdb ? "1" : "0"); 82 } 83 } 84 85 @Override 86 public void run() { 87 EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_SYSTEM_RUN, 88 SystemClock.uptimeMillis()); 89 90 Looper.prepare(); 91 92 android.os.Process.setThreadPriority( 93 android.os.Process.THREAD_PRIORITY_FOREGROUND); 94 95 BinderInternal.disableBackgroundScheduling(true); 96 android.os.Process.setCanSelfBackground(false); 97 98 // Check whether we failed to shut down last time we tried. 99 { 100 final String shutdownAction = SystemProperties.get( 101 ShutdownThread.SHUTDOWN_ACTION_PROPERTY, ""); 102 if (shutdownAction != null && shutdownAction.length() > 0) { 103 boolean reboot = (shutdownAction.charAt(0) == '1'); 104 105 final String reason; 106 if (shutdownAction.length() > 1) { 107 reason = shutdownAction.substring(1, shutdownAction.length()); 108 } else { 109 reason = null; 110 } 111 112 ShutdownThread.rebootOrShutdown(reboot, reason); 113 } 114 } 115 116 String factoryTestStr = SystemProperties.get("ro.factorytest"); 117 int factoryTest = "".equals(factoryTestStr) ? SystemServer.FACTORY_TEST_OFF 118 : Integer.parseInt(factoryTestStr); 119 120 LightsService lights = null; 121 PowerManagerService power = null; 122 BatteryService battery = null; 123 NetworkPolicyManagerService networkPolicy = null; 124 ConnectivityService connectivity = null; 125 IPackageManager pm = null; 126 Context context = null; 127 WindowManagerService wm = null; 128 BluetoothService bluetooth = null; 129 BluetoothA2dpService bluetoothA2dp = null; 130 WiredAccessoryObserver wiredAccessory = null; 131 DockObserver dock = null; 132 UsbService usb = null; 133 UiModeManagerService uiMode = null; 134 RecognitionManagerService recognition = null; 135 ThrottleService throttle = null; 136 NetworkTimeUpdateService networkTimeUpdater = null; 137 138 // Critical services... 139 try { 140 Slog.i(TAG, "Entropy Service"); 141 ServiceManager.addService("entropy", new EntropyService()); 142 143 Slog.i(TAG, "Power Manager"); 144 power = new PowerManagerService(); 145 ServiceManager.addService(Context.POWER_SERVICE, power); 146 147 Slog.i(TAG, "Activity Manager"); 148 context = ActivityManagerService.main(factoryTest); 149 150 Slog.i(TAG, "Telephony Registry"); 151 ServiceManager.addService("telephony.registry", new TelephonyRegistry(context)); 152 153 AttributeCache.init(context); 154 155 Slog.i(TAG, "Package Manager"); 156 pm = PackageManagerService.main(context, 157 factoryTest != SystemServer.FACTORY_TEST_OFF); 158 159 ActivityManagerService.setSystemProcess(); 160 161 mContentResolver = context.getContentResolver(); 162 163 // The AccountManager must come before the ContentService 164 try { 165 Slog.i(TAG, "Account Manager"); 166 ServiceManager.addService(Context.ACCOUNT_SERVICE, 167 new AccountManagerService(context)); 168 } catch (Throwable e) { 169 Slog.e(TAG, "Failure starting Account Manager", e); 170 } 171 172 Slog.i(TAG, "Content Manager"); 173 ContentService.main(context, 174 factoryTest == SystemServer.FACTORY_TEST_LOW_LEVEL); 175 176 Slog.i(TAG, "System Content Providers"); 177 ActivityManagerService.installSystemProviders(); 178 179 Slog.i(TAG, "Lights Service"); 180 lights = new LightsService(context); 181 182 Slog.i(TAG, "Battery Service"); 183 battery = new BatteryService(context, lights); 184 ServiceManager.addService("battery", battery); 185 186 Slog.i(TAG, "Vibrator Service"); 187 ServiceManager.addService("vibrator", new VibratorService(context)); 188 189 // only initialize the power service after we have started the 190 // lights service, content providers and the battery service. 191 power.init(context, lights, ActivityManagerService.getDefault(), battery); 192 193 Slog.i(TAG, "Alarm Manager"); 194 AlarmManagerService alarm = new AlarmManagerService(context); 195 ServiceManager.addService(Context.ALARM_SERVICE, alarm); 196 197 Slog.i(TAG, "Init Watchdog"); 198 Watchdog.getInstance().init(context, battery, power, alarm, 199 ActivityManagerService.self()); 200 201 Slog.i(TAG, "Window Manager"); 202 wm = WindowManagerService.main(context, power, 203 factoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL); 204 ServiceManager.addService(Context.WINDOW_SERVICE, wm); 205 206 ((ActivityManagerService)ServiceManager.getService("activity")) 207 .setWindowManager(wm); 208 209 // Skip Bluetooth if we have an emulator kernel 210 // TODO: Use a more reliable check to see if this product should 211 // support Bluetooth - see bug 988521 212 if (SystemProperties.get("ro.kernel.qemu").equals("1")) { 213 Slog.i(TAG, "No Bluetooh Service (emulator)"); 214 } else if (factoryTest == SystemServer.FACTORY_TEST_LOW_LEVEL) { 215 Slog.i(TAG, "No Bluetooth Service (factory test)"); 216 } else { 217 Slog.i(TAG, "Bluetooth Service"); 218 bluetooth = new BluetoothService(context); 219 ServiceManager.addService(BluetoothAdapter.BLUETOOTH_SERVICE, bluetooth); 220 bluetooth.initAfterRegistration(); 221 bluetoothA2dp = new BluetoothA2dpService(context, bluetooth); 222 ServiceManager.addService(BluetoothA2dpService.BLUETOOTH_A2DP_SERVICE, 223 bluetoothA2dp); 224 bluetooth.initAfterA2dpRegistration(); 225 226 int bluetoothOn = Settings.Secure.getInt(mContentResolver, 227 Settings.Secure.BLUETOOTH_ON, 0); 228 if (bluetoothOn > 0) { 229 bluetooth.enable(); 230 } 231 } 232 233 } catch (RuntimeException e) { 234 Slog.e("System", "Failure starting core service", e); 235 } 236 237 DevicePolicyManagerService devicePolicy = null; 238 StatusBarManagerService statusBar = null; 239 InputMethodManagerService imm = null; 240 AppWidgetService appWidget = null; 241 NotificationManagerService notification = null; 242 WallpaperManagerService wallpaper = null; 243 LocationManagerService location = null; 244 CountryDetectorService countryDetector = null; 245 246 if (factoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) { 247 try { 248 Slog.i(TAG, "Device Policy"); 249 devicePolicy = new DevicePolicyManagerService(context); 250 ServiceManager.addService(Context.DEVICE_POLICY_SERVICE, devicePolicy); 251 } catch (Throwable e) { 252 Slog.e(TAG, "Failure starting DevicePolicyService", e); 253 } 254 255 try { 256 Slog.i(TAG, "Status Bar"); 257 statusBar = new StatusBarManagerService(context, wm); 258 ServiceManager.addService(Context.STATUS_BAR_SERVICE, statusBar); 259 } catch (Throwable e) { 260 Slog.e(TAG, "Failure starting StatusBarManagerService", e); 261 } 262 263 try { 264 Slog.i(TAG, "Clipboard Service"); 265 ServiceManager.addService(Context.CLIPBOARD_SERVICE, 266 new ClipboardService(context)); 267 } catch (Throwable e) { 268 Slog.e(TAG, "Failure starting Clipboard Service", e); 269 } 270 271 try { 272 Slog.i(TAG, "Input Method Service"); 273 imm = new InputMethodManagerService(context, statusBar); 274 ServiceManager.addService(Context.INPUT_METHOD_SERVICE, imm); 275 } catch (Throwable e) { 276 Slog.e(TAG, "Failure starting Input Manager Service", e); 277 } 278 279 try { 280 Slog.i(TAG, "NetStat Service"); 281 ServiceManager.addService("netstat", new NetStatService(context)); 282 } catch (Throwable e) { 283 Slog.e(TAG, "Failure starting NetStat Service", e); 284 } 285 286 try { 287 Slog.i(TAG, "NetworkPolicy Service"); 288 networkPolicy = new NetworkPolicyManagerService( 289 context, ActivityManagerService.self(), power); 290 ServiceManager.addService(Context.NETWORK_POLICY_SERVICE, networkPolicy); 291 } catch (Throwable e) { 292 Slog.e(TAG, "Failure starting Connectivity Service", e); 293 } 294 295 try { 296 Slog.i(TAG, "NetworkManagement Service"); 297 ServiceManager.addService( 298 Context.NETWORKMANAGEMENT_SERVICE, 299 NetworkManagementService.create(context)); 300 } catch (Throwable e) { 301 Slog.e(TAG, "Failure starting NetworkManagement Service", e); 302 } 303 304 try { 305 Slog.i(TAG, "Connectivity Service"); 306 connectivity = ConnectivityService.getInstance(context); 307 ServiceManager.addService(Context.CONNECTIVITY_SERVICE, connectivity); 308 } catch (Throwable e) { 309 Slog.e(TAG, "Failure starting Connectivity Service", e); 310 } 311 312 try { 313 Slog.i(TAG, "Throttle Service"); 314 throttle = new ThrottleService(context); 315 ServiceManager.addService( 316 Context.THROTTLE_SERVICE, throttle); 317 } catch (Throwable e) { 318 Slog.e(TAG, "Failure starting ThrottleService", e); 319 } 320 321 try { 322 Slog.i(TAG, "Accessibility Manager"); 323 ServiceManager.addService(Context.ACCESSIBILITY_SERVICE, 324 new AccessibilityManagerService(context)); 325 } catch (Throwable e) { 326 Slog.e(TAG, "Failure starting Accessibility Manager", e); 327 } 328 329 try { 330 /* 331 * NotificationManagerService is dependant on MountService, 332 * (for media / usb notifications) so we must start MountService first. 333 */ 334 Slog.i(TAG, "Mount Service"); 335 ServiceManager.addService("mount", new MountService(context)); 336 } catch (Throwable e) { 337 Slog.e(TAG, "Failure starting Mount Service", e); 338 } 339 340 try { 341 Slog.i(TAG, "Notification Manager"); 342 notification = new NotificationManagerService(context, statusBar, lights); 343 ServiceManager.addService(Context.NOTIFICATION_SERVICE, notification); 344 } catch (Throwable e) { 345 Slog.e(TAG, "Failure starting Notification Manager", e); 346 } 347 348 try { 349 Slog.i(TAG, "Device Storage Monitor"); 350 ServiceManager.addService(DeviceStorageMonitorService.SERVICE, 351 new DeviceStorageMonitorService(context)); 352 } catch (Throwable e) { 353 Slog.e(TAG, "Failure starting DeviceStorageMonitor service", e); 354 } 355 356 try { 357 Slog.i(TAG, "Location Manager"); 358 location = new LocationManagerService(context); 359 ServiceManager.addService(Context.LOCATION_SERVICE, location); 360 } catch (Throwable e) { 361 Slog.e(TAG, "Failure starting Location Manager", e); 362 } 363 364 try { 365 Slog.i(TAG, "Country Detector"); 366 countryDetector = new CountryDetectorService(context); 367 ServiceManager.addService(Context.COUNTRY_DETECTOR, countryDetector); 368 } catch (Throwable e) { 369 Slog.e(TAG, "Failure starting Country Detector", e); 370 } 371 372 try { 373 Slog.i(TAG, "Search Service"); 374 ServiceManager.addService(Context.SEARCH_SERVICE, 375 new SearchManagerService(context)); 376 } catch (Throwable e) { 377 Slog.e(TAG, "Failure starting Search Service", e); 378 } 379 380 try { 381 Slog.i(TAG, "DropBox Service"); 382 ServiceManager.addService(Context.DROPBOX_SERVICE, 383 new DropBoxManagerService(context, new File("/data/system/dropbox"))); 384 } catch (Throwable e) { 385 Slog.e(TAG, "Failure starting DropBoxManagerService", e); 386 } 387 388 try { 389 Slog.i(TAG, "Wallpaper Service"); 390 wallpaper = new WallpaperManagerService(context); 391 ServiceManager.addService(Context.WALLPAPER_SERVICE, wallpaper); 392 } catch (Throwable e) { 393 Slog.e(TAG, "Failure starting Wallpaper Service", e); 394 } 395 396 try { 397 Slog.i(TAG, "Audio Service"); 398 ServiceManager.addService(Context.AUDIO_SERVICE, new AudioService(context)); 399 } catch (Throwable e) { 400 Slog.e(TAG, "Failure starting Audio Service", e); 401 } 402 403 try { 404 Slog.i(TAG, "Dock Observer"); 405 // Listen for dock station changes 406 dock = new DockObserver(context, power); 407 } catch (Throwable e) { 408 Slog.e(TAG, "Failure starting DockObserver", e); 409 } 410 411 try { 412 Slog.i(TAG, "Wired Accessory Observer"); 413 // Listen for wired headset changes 414 wiredAccessory = new WiredAccessoryObserver(context); 415 } catch (Throwable e) { 416 Slog.e(TAG, "Failure starting WiredAccessoryObserver", e); 417 } 418 419 try { 420 Slog.i(TAG, "USB Observer"); 421 // Listen for USB changes 422 usb = new UsbService(context); 423 ServiceManager.addService(Context.USB_SERVICE, usb); 424 } catch (Throwable e) { 425 Slog.e(TAG, "Failure starting UsbService", e); 426 } 427 428 try { 429 Slog.i(TAG, "UI Mode Manager Service"); 430 // Listen for UI mode changes 431 uiMode = new UiModeManagerService(context); 432 } catch (Throwable e) { 433 Slog.e(TAG, "Failure starting UiModeManagerService", e); 434 } 435 436 try { 437 Slog.i(TAG, "Backup Service"); 438 ServiceManager.addService(Context.BACKUP_SERVICE, 439 new BackupManagerService(context)); 440 } catch (Throwable e) { 441 Slog.e(TAG, "Failure starting Backup Service", e); 442 } 443 444 try { 445 Slog.i(TAG, "AppWidget Service"); 446 appWidget = new AppWidgetService(context); 447 ServiceManager.addService(Context.APPWIDGET_SERVICE, appWidget); 448 } catch (Throwable e) { 449 Slog.e(TAG, "Failure starting AppWidget Service", e); 450 } 451 452 try { 453 Slog.i(TAG, "Recognition Service"); 454 recognition = new RecognitionManagerService(context); 455 } catch (Throwable e) { 456 Slog.e(TAG, "Failure starting Recognition Service", e); 457 } 458 459 try { 460 Slog.i(TAG, "DiskStats Service"); 461 ServiceManager.addService("diskstats", new DiskStatsService(context)); 462 } catch (Throwable e) { 463 Slog.e(TAG, "Failure starting DiskStats Service", e); 464 } 465 466 try { 467 // need to add this service even if SamplingProfilerIntegration.isEnabled() 468 // is false, because it is this service that detects system property change and 469 // turns on SamplingProfilerIntegration. Plus, when sampling profiler doesn't work, 470 // there is little overhead for running this service. 471 Slog.i(TAG, "SamplingProfiler Service"); 472 ServiceManager.addService("samplingprofiler", 473 new SamplingProfilerService(context)); 474 } catch (Throwable e) { 475 Slog.e(TAG, "Failure starting SamplingProfiler Service", e); 476 } 477 478 try { 479 Slog.i(TAG, "NetworkTimeUpdateService"); 480 networkTimeUpdater = new NetworkTimeUpdateService(context); 481 } catch (Throwable e) { 482 Slog.e(TAG, "Failure starting NetworkTimeUpdate service"); 483 } 484 } 485 486 // make sure the ADB_ENABLED setting value matches the secure property value 487 Settings.Secure.putInt(mContentResolver, Settings.Secure.ADB_ENABLED, 488 "1".equals(SystemProperties.get("persist.service.adb.enable")) ? 1 : 0); 489 490 // register observer to listen for settings changes 491 mContentResolver.registerContentObserver(Settings.Secure.getUriFor(Settings.Secure.ADB_ENABLED), 492 false, new AdbSettingsObserver()); 493 494 // Before things start rolling, be sure we have decided whether 495 // we are in safe mode. 496 final boolean safeMode = wm.detectSafeMode(); 497 if (safeMode) { 498 ActivityManagerService.self().enterSafeMode(); 499 // Post the safe mode state in the Zygote class 500 Zygote.systemInSafeMode = true; 501 // Disable the JIT for the system_server process 502 VMRuntime.getRuntime().disableJitCompilation(); 503 } else { 504 // Enable the JIT for the system_server process 505 VMRuntime.getRuntime().startJitCompilation(); 506 } 507 508 // It is now time to start up the app processes... 509 510 if (devicePolicy != null) { 511 devicePolicy.systemReady(); 512 } 513 514 if (notification != null) { 515 notification.systemReady(); 516 } 517 518 wm.systemReady(); 519 520 if (safeMode) { 521 ActivityManagerService.self().showSafeModeOverlay(); 522 } 523 524 // Update the configuration for this context by hand, because we're going 525 // to start using it before the config change done in wm.systemReady() will 526 // propagate to it. 527 Configuration config = wm.computeNewConfiguration(); 528 DisplayMetrics metrics = new DisplayMetrics(); 529 WindowManager w = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); 530 w.getDefaultDisplay().getMetrics(metrics); 531 context.getResources().updateConfiguration(config, metrics); 532 533 power.systemReady(); 534 try { 535 pm.systemReady(); 536 } catch (RemoteException e) { 537 } 538 539 // These are needed to propagate to the runnable below. 540 final Context contextF = context; 541 final BatteryService batteryF = battery; 542 final NetworkPolicyManagerService networkPolicyF = networkPolicy; 543 final ConnectivityService connectivityF = connectivity; 544 final DockObserver dockF = dock; 545 final UsbService usbF = usb; 546 final ThrottleService throttleF = throttle; 547 final UiModeManagerService uiModeF = uiMode; 548 final AppWidgetService appWidgetF = appWidget; 549 final WallpaperManagerService wallpaperF = wallpaper; 550 final InputMethodManagerService immF = imm; 551 final RecognitionManagerService recognitionF = recognition; 552 final LocationManagerService locationF = location; 553 final CountryDetectorService countryDetectorF = countryDetector; 554 final NetworkTimeUpdateService networkTimeUpdaterF = networkTimeUpdater; 555 556 // We now tell the activity manager it is okay to run third party 557 // code. It will call back into us once it has gotten to the state 558 // where third party code can really run (but before it has actually 559 // started launching the initial applications), for us to complete our 560 // initialization. 561 ((ActivityManagerService)ActivityManagerNative.getDefault()) 562 .systemReady(new Runnable() { 563 public void run() { 564 Slog.i(TAG, "Making services ready"); 565 566 startSystemUi(contextF); 567 if (batteryF != null) batteryF.systemReady(); 568 if (networkPolicyF != null) networkPolicyF.systemReady(); 569 if (connectivityF != null) connectivityF.systemReady(); 570 if (dockF != null) dockF.systemReady(); 571 if (usbF != null) usbF.systemReady(); 572 if (uiModeF != null) uiModeF.systemReady(); 573 if (recognitionF != null) recognitionF.systemReady(); 574 Watchdog.getInstance().start(); 575 576 // It is now okay to let the various system services start their 577 // third party code... 578 579 if (appWidgetF != null) appWidgetF.systemReady(safeMode); 580 if (wallpaperF != null) wallpaperF.systemReady(); 581 if (immF != null) immF.systemReady(); 582 if (locationF != null) locationF.systemReady(); 583 if (countryDetectorF != null) countryDetectorF.systemReady(); 584 if (throttleF != null) throttleF.systemReady(); 585 if (networkTimeUpdaterF != null) networkTimeUpdaterF.systemReady(); 586 } 587 }); 588 589 // For debug builds, log event loop stalls to dropbox for analysis. 590 if (StrictMode.conditionallyEnableDebugLogging()) { 591 Slog.i(TAG, "Enabled StrictMode for system server main thread."); 592 } 593 594 Looper.loop(); 595 Slog.d(TAG, "System ServerThread is exiting!"); 596 } 597 598 static final void startSystemUi(Context context) { 599 Intent intent = new Intent(); 600 intent.setComponent(new ComponentName("com.android.systemui", 601 "com.android.systemui.SystemUIService")); 602 Slog.d(TAG, "Starting service: " + intent); 603 context.startService(intent); 604 } 605} 606 607public class SystemServer { 608 private static final String TAG = "SystemServer"; 609 610 public static final int FACTORY_TEST_OFF = 0; 611 public static final int FACTORY_TEST_LOW_LEVEL = 1; 612 public static final int FACTORY_TEST_HIGH_LEVEL = 2; 613 614 static Timer timer; 615 static final long SNAPSHOT_INTERVAL = 60 * 60 * 1000; // 1hr 616 617 // The earliest supported time. We pick one day into 1970, to 618 // give any timezone code room without going into negative time. 619 private static final long EARLIEST_SUPPORTED_TIME = 86400 * 1000; 620 621 /** 622 * This method is called from Zygote to initialize the system. This will cause the native 623 * services (SurfaceFlinger, AudioFlinger, etc..) to be started. After that it will call back 624 * up into init2() to start the Android services. 625 */ 626 native public static void init1(String[] args); 627 628 public static void main(String[] args) { 629 if (System.currentTimeMillis() < EARLIEST_SUPPORTED_TIME) { 630 // If a device's clock is before 1970 (before 0), a lot of 631 // APIs crash dealing with negative numbers, notably 632 // java.io.File#setLastModified, so instead we fake it and 633 // hope that time from cell towers or NTP fixes it 634 // shortly. 635 Slog.w(TAG, "System clock is before 1970; setting to 1970."); 636 SystemClock.setCurrentTimeMillis(EARLIEST_SUPPORTED_TIME); 637 } 638 639 if (SamplingProfilerIntegration.isEnabled()) { 640 SamplingProfilerIntegration.start(); 641 timer = new Timer(); 642 timer.schedule(new TimerTask() { 643 @Override 644 public void run() { 645 SamplingProfilerIntegration.writeSnapshot("system_server", null); 646 } 647 }, SNAPSHOT_INTERVAL, SNAPSHOT_INTERVAL); 648 } 649 650 // Mmmmmm... more memory! 651 dalvik.system.VMRuntime.getRuntime().clearGrowthLimit(); 652 653 // The system server has to run all of the time, so it needs to be 654 // as efficient as possible with its memory usage. 655 VMRuntime.getRuntime().setTargetHeapUtilization(0.8f); 656 657 System.loadLibrary("android_servers"); 658 init1(args); 659 } 660 661 public static final void init2() { 662 Slog.i(TAG, "Entered the Android system server!"); 663 Thread thr = new ServerThread(); 664 thr.setName("android.server.ServerThread"); 665 thr.start(); 666 } 667} 668