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