赞
踩
这个是本人总结的,mkw的framework面试的资料,需要具体的视频和其他的资料,TB店铺 纳新工作室 中找framework 资料就好哈。
ContextImpl 持有ApplicationPackageManager ,然后ApplicationPackageManager 持有 IPakcageManager.binder,可以和IPackageManager 之间进行通信。
- private void startBootstrapServices(){
- ...
- mSystemServiceManager.startBootPhase(SystemService.PHASE_WAIT_FOR_DEFAULT_DISPLAY);
- ...
- mPackageManagerService = PackageManagerService.main(mSystemContext,installer,mFactoryTestMode!=FactoryTest.FACTORY_TEST_OFF,mOnlyCore);
- mFirstBoot = mPackageManagerService.isFirstBoot();
- mPackageManager = mSystemContext.getPackageManager();
- ...
- }
- private void startOtherServices(){
- ...
- mSystemServiceManager.startBootPhase(SystemService.PHASE_LOCK_SETTINGS_READY);
- mSystemServiceManager.startBootPhase(SystemService.PHASE_SYSTEM_SERVICES_READY);
- ...
- mPackageManagerService.systemReady();
- ...
- mSystemServiceManager.startBootPhase(SystemService.PHASE_ACTIVITY_MANAGER_READY);
- }}
- public static PackageManagerService main(Context context,Installer installer,boolean factoryTest,boolean onlyCore){
- ...
- PackageManagerService m = new PackageManagerService(context,installer,...)
- ...
- ServiceManager.addService("package",m);
- return m;
- }
- public PackageManagerService(Context context,Installer installser,boolean factoryTest,boolean nlyCore){
- ...
- //PMS_START
- //1.创建settings
- mSettings = new Settings(mPackages);
- //2.system phone log nfc bluetooth shell 添加到setting
- mSettings.addSharedUserLPw("android.uid.system",Process.SYSTEM_UID,ApplicationInfo.FLAG_SYSTEM,ApplicationInfo.PRIVATE_FLAG_PRIVILEDGE);
- mSettings.addSharedUserLPw("android.uid.phone",RADIO_UID,
- log nfc bluetooth shell...
-
- //初始化SystemConfig
- SystemConfig systemConfig = SystemConfig.getInstance();
- mGlobalGids = systemConfig.getGlobalGids();
- mSystemPermissions = systemConfig.getSystemPermissions();
- mAvailableFratures = systemConfig.getAvailableFeatures();
-
- synchronized(mInstallLock){
- synchronized(mPackages){
- mHandlerThread = new ServiceThread(TAG,Process.THREAD_PRIORITY_BACKGROUND,true);
- mHandlerThread.start();
- //创建packageHandler
- mHandler = new PackageHandler(mHandlerThread.getLooper());
- Watchdog.getInstance().addThread(mHandler,WATCHDOG_TIMEOUT);
- ...
- ArrayMap<String,String> libConfig = systemConfig.getSharedLibraries();
- for(int i=0;i<libConfig.size();i++){
- mSharedLibraries.put(libConfig.keyAt(i),new SharedLibraryEntry(libConfig.valueAt(i)));
- }
- }
-
- //PM_SYSTEM_SCAN_STSRT
- ...
- final String bootClassPath = System.getenv("BOOTCLASSPATH");
- final String systemServerClassPath = system.getenv("SYSTEMSERVERCLASSPATH");
- ...
- //对满足调价的jar和apk进行dex优化
- mInstaller.dexopt(lib,Process.SYSTEM_UID,dexCodeInstructionSet,
- dexoptNeeded,DEXOPT_PUBLIC/**/)
- ...
- //2扫描system/app system/priv-app
- //Collect ordinary system packages
- final File systemAppDir = new File(Environment.getRootDirectiry(),"app");
- scanDirTracedLI(systemAppDir,mDefParseFlags|PackageParser.PARSE_IS_SYSTEM|
- |PackageParse.PARSE_IS_SYSTEM_DIR,scanFlags,0);
- ...
- //Collect all oem packages
- final File oemAppDir = new File(Environment.getOemDirectory(),"app");
- scanDirTraceLI(oemAppDir,mDefParseFlags|PackageParse.PAESE_IS_SYSTEM|PackageParse.PAESE_IS_SYSTEM_DIR,scanFlags,0);
- ...
- //look for any incomplete package installations
- ArrayList<PackageSetting> deletePkgsList =
- mSettings.getListOfIncompleteInstallPackagesLPr();
-
- for (int i = 0; i < deletePkgsList.size(); i++) {
- // Actual deletion of code and data will be handled by later
- // reconciliation step
- final String packageName = deletePkgsList.get(i).name;
- logCriticalInfo(Log.WARN, "Cleaning up incompletely
- installed app: " + packageName);
- synchronized (mPackages) {
- mSettings.removePackageLPw(packageName);}}
- //处理三方app,太复杂了
- }}} }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。