資源描述:
《將定制的launcher設(shè)置為默認(rèn)》由會員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫。
1、Android如何將定制的Launcher成為系統(tǒng)中唯一的Launcher2011-01-1711:12如果你要定制一個Android系統(tǒng),你想用你自己的Launcher(Home)作主界面來替換Android自己的Home,而且不希望用戶安裝的Launcher來替換掉你的Launcher.我們可以通過修改Framework來實(shí)現(xiàn)這樣的功能。這里以Android2.1的源代碼為例來實(shí)際說明。1)首先了解一下Android的啟動過程。??Android系統(tǒng)的啟動先從Zygote開始啟動,然后……(中間的過程就不說了)…..一直到了SystemServer
2、(framework)這個地方,看到這段代碼:????/**????*ThismethodiscalledfromZygotetoinitializethesystem.Thiswillcausethenative????*services(SurfaceFlinger,AudioFlinger,etc..)tobestarted.Afterthatitwillcallback????*upintoinit2()tostarttheAndroidservices.????*/??nativepublicstaticvoidinit1(String[]a
3、rgs);??publicstaticvoidmain(String[]args){??????if(SamplingProfilerIntegration.isEnabled()){????????SamplingProfilerIntegration.start();????????timer=newTimer();????????timer.schedule(newTimerTask(){??????????@Override??????????publicvoidrun(){??????????????SamplingProfilerInteg
4、ration.writeSnapshot(“system_server”);??????????}????????},SNAPSHOT_INTERVAL,SNAPSHOT_INTERVAL);??????}??????//Thesystemserverhastorunallofthetime,soitneedstobe??????//asefficientaspossiblewithitsmemoryusage.??????VMRuntime.getRuntime().setTargetHeapUtilization(0.8f);??????Syste
5、m.loadLibrary(“android_servers”);??????init1(args);??}??publicstaticfinalvoidinit2(){??????Log.i(TAG,“EnteredtheAndroidsystemserver!”);??????Threadthr=newServerThread();??????thr.setName(“android.server.ServerThread”);??????thr.start();??}}從SystemServer的main函數(shù)開始啟動各種服務(wù)。首先啟動init1,
6、然后啟動init2.從上面的注釋可以看到:init1這個方法時被Zygote調(diào)用來初始化系統(tǒng)的,init1會啟動native的服務(wù)如SurfaceFlinger,AudioFlinger等等,這些工作做完以后會回調(diào)init2來啟動Android的service。這里我們主要來關(guān)注init2的過程。init2中啟動ServerThread線程,ServerThread中啟動了一系列的服務(wù),比如這些:ActivityManagerServiceEntropyServicePowerManagerServiceTelephonyRegistryPackage
7、ManagerServiceAccountManagerServiceBatteryServiceHardwareServiceWatchdogSensorServiceBluetoothServiceStatusBarServiceClipboardServiceInputMethodManagerServiceNetStatServiceConnectivityServiceAccessibilityManagerServiceNotificationManagerServiceMountServiceDeviceStorageMonitorSer
8、viceLocationManagerServiceSearchManagerServiceF