This article mainly introduces the startup process of Android4.4 default home application Launcher3 and the data loading process of Launcher3. Launcher startup is on when the Activitymanagerservice is ready to start, is its start sequence diagram:
In the Step1,systemserver, Activitymanagerservice is ready for the job.
Step3,
Boolean resumetopactivitieslocked (Activitystack targetstack, Activityrecord target, Bundle targetoptions) { if (Targetstack = = null) { targetstack = Getfocusedstack ();//Get Mhomestack } Boolean result = false; for (int stackndx = Mstacks.size ()-1; stackndx >= 0;--stackndx) { final activitystack stack = mstacks.get (stackn DX); if (Isfrontstack (stack)) { if (stack = = targetstack) { result = stack.resumetopactivitylocked (target, targetoptions); } else { stack.resumetopactivitylocked (null); }}} return result; }
For An introduction to the mhomestack,mstacks that has been added to the Mstacks, see the start-up of the Android4.4 framework analysis--activitymanagerservice and the management of the activity, At present mstacks only mhomestack this activitystack.
STEP6,
Boolean starthomeactivitylocked (int userId) {if (mheadless) {///Added because none of the other CALs LS to ensurebootcompleted seem to fire//when running headless. Ensurebootcompleted (); return false; } Intent Intent = Gethomeintent (); Home intent Activityinfo Ainfo = Resolveactivityinfo (Intent, stock_pm_flags, userId);//Find Home App Info if (ainfo! = null) {intent.setcomponent (New componentname (aInfo.applicationInfo.package Name, Ainfo.name)); Don ' t do this if the Home app is currently being//instrumented. Ainfo = new Activityinfo (ainfo); Ainfo.applicationinfo = Getappinfoforuser (Ainfo.applicationinfo, userId); Processrecord app = getprocessrecordlocked (Ainfo.processname, AInfo.applicationInfo.uid, True);//home application Not started, returns null if (app = = NULL | | app.instrumentationclass = = NULL) { Intent.setflags (Intent.getflags () | Intent.flag_activity_new_task); Mstacksupervisor.starthomeactivity (Intent, ainfo); STEP7}} return true; }
Intent gethomeintent () { Intent Intent = new Intent (mtopaction, mtopdata! = null?) Uri.parse (Mtopdata): null); Intent.setcomponent (mtopcomponent); if (mfactorytest! = systemserver.factory_test_low_level) { intent.addcategory (intent.category_home);// Home App logo } return intent; }
The process of starting an application (startactivity) in the Android4.4 framework analysis--launcher is referenced by the step7~step10,activity startup process
After the STEP14 process.
STEP11~STEP14, starts the asynchronous load app icon, and the worker thread sworkerthread.
STEP15~STEP20, Load workspace icon, step16 read Launcherprovider favorites data, Favorites table data is launcher when database is created from Default_ Workspace.xml parsing read. STEP18 the binding icon information.
Step22, sleep waits for the idle process, and then loads all the app icons on the main menu.
Step23, waking up from sleep, ready to load all app icons, including widgets.
STEP24,
private void Loadallapps () {final long loadtime = debug_loaders? Systemclock.uptimemillis (): 0; ... final packagemanager Packagemanager = Mcontext.getpackagemanager (); Final Intent mainintent = new Intent (intent.action_main, NULL); In Packagemanagerservice query all the app Mainintent.addcategory (Intent.category_launcher) to be displayed on the desktop; Clear the list of apps mbgallappslist.clear (); Query for the set of apps final long qiatime = debug_loaders? Systemclock.uptimemillis (): 0; List<resolveinfo> apps = packagemanager.queryintentactivities (mainintent, 0); if (debug_loaders) {log.d (TAG, "Queryintentactivities took" + (Systemclock.uptimem Illis ()-qiatime) + "MS"); LOG.D (TAG, "Queryintentactivities got" + apps.size () + "apps"); }//Fail If we don ' t have any apps if (apps = = Null | | Apps.isempty ()) {return; }//Sort the applications by name final long Sorttime = debug_loaders? Systemclock.uptimemillis (): 0; Collections.sort (Apps, New Launchermodel.shortcutnamecomparator (Packagemanager, Mlabelcache));//Sort by app name Create the Applicationinfos for (int i = 0; i < apps.size (); i++) {Resolveinf o app = Apps.get (i); This builds the icon bitmaps. Mbgallappslist.add (New AppInfo (Packagemanager, app, Miconcache, Mlabelcache)); }//Huh? Shouldn ' t is inside the Runnable below? Final arraylist<appinfo> added = mbgallappslist.added; mbgallappslist.added = new arraylist<appinfo> (); Post callback on Main thread mhandler.post (new Runnable () {public void run () { Final Long Bindtime= Systemclock.uptimemillis (); Final callbacks callbacks = Trygetcallbacks (oldcallbacks); if (callbacks! = null) {callbacks.bindallapplications (added);//step26, binding I F (debug_loaders) {log.d (TAG, "bound" + added.size () + "apps in" + (Systemclock.uptimemillis ()-Bindtime) + "MS"); }} else {log.i (TAG, "not binding apps:no Launcher activity"); } } }); }
Right-copy the image address and open it in the browser to see a larger image.
Please correct me if there is any wrong place to be continued.
Android4.4 Framework Analysis--android default home application Launcher3 loading process Analysis