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