ActivityManagerService boot up sequence analysis,

Source: Internet
Author: User

ActivityManagerService boot up sequence analysis,
ActivityManagerService (AMS) is the core service in the android system. It is mainly responsible for the startup, switching, scheduling, and application management and scheduling of four major components, its responsibilities are similar to the process management and scheduling modules in the operating system.

The call track of ActivityManagerService in system server is divided into the following four parts:

Part 1: AMS. main
Part 2: AMS. setSystemProcess

Part 3: AMS. installSystemProviders

Part 4: AMS. self (). systemReady

Start Process 1


The secondary image is reprinted from the network. Note:

Start Process 2

Part 1: AMS Main Function

1. created an AMS object.
2. Create an ActivityThread object that represents
Main thread
3. Get a context object, which corresponds to the application environment and
Framework-res.apk related;

This function creates an android runtime environment for the system_server process, which is the same as the application process.

Part 1-1: Create AMS object



Part 1-2: Create ActivityThread & context



Part 1-2: Create ActivityThread & Context



Part 1-2: Create ActivityThread & Context


Part 1-3: Create ActivityStack


Part 2: setSystemProcess


1. register the following services, such as ActivityManagerService, meminfo, and gfxinfo, to ServiceManager.


ServiceManager. addService ("activity", m, true );
ServiceManager. addService ("meminfo", new MemBinder (m ));
ServiceManager. addService ("gfxinfo", new GraphicsBinder (m ));
ServiceManager. addService ("dbinfo", new DbBinder (m ));
ServiceManager. addService ("cpuinfo", new CpuBinder (m ));
ServiceManager. addService ("permission", new PermissionController (m ));




2. query ApplicationInfo about the framework-res.apk through PKMS and use this to initialize the anroid Runtime Environment
// Query the ApplicationInfo with the package name "android" from PKMS. PKMS and AMS are in the same process,
However, the android runtime environment context (AMS-> binder-> PKMS) is used for implementation,
Ensures interface uniformity and scalability
ApplicationInfo info = mSelf. mContext. getPackageManager (). getApplicationInfo (
"Android", STOCK_PM_FLAGS );


// Perform secondary Initialization on the context and bind it with the obtained applicatoninfo.
MSystemThread. installSystemApplicationInfo (info );


3. Create the ProcessRecord management structure representing the system_server process, and merge the systemserver process
AMS Management
ProcessRecord app = mSelf. newProcessRecordLocked (
MSystemThread. getApplicationThread (), info,
Info. processName, false); creates a processrecord that contains power statistics and application information,
Process name (system), oom_adj, IApplicationThread, and application process communication information.


App. persistent = true; (Resident Process)
App. pid = MY_PID; process ID of system_server
App. maxAdj = ProcessList. SYSTEM_ADJ; (-16) highest priority


The two member variable structures used to save and manage processRecord in AMS.
MSelf. mProcessNames. put (app. processName, app. uid, app );
MSelf. mPidsSelfLocked. put (app. pid, app );
Adjust the scheduling priority and OOM_ADJ according to the current status of the system.
MSelf. updateLruProcessLocked (app, true );

Part 3: installSystemProviders

SettingsProvider.apk contains SettingsProvider, which is placed in system_serever for convenient query of configuration information for each service




1 In android, data inventory is usually stored in/data/[application package name]/databases
Directory
2. perform operations through URI, for example, data with the ID specified as 1 contact in content: // contacts/people/1
3. Related operations include query, insert, update, and delete operations.






Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.