系统启动后, 会查找并运行Launcher,

有源码的情况下,可以通过修改Intent-filter中的android:priorty="N" N >=1; 一般我会设置 N=100;

没有源码的情况下, 要将第三方Launcher默认启动, 则需要在些过程做点修改.

 

 frameworks/base/services/java/com/android/server/am/ActivityManagerService.java

    boolean startHomeActivityLocked(int userId) {        if (mHeadless) {            // Added because none of the other calls to ensureBootCompleted seem to fire            // when running headless.            ensureBootCompleted();            return false;        }        if (mFactoryTest == SystemServer.FACTORY_TEST_LOW_LEVEL                && mTopAction == null) {            // We are running in factory test mode, but unable to find            // the factory test app, so just sit around displaying the            // error message and don't try to start anything.            return false;        }        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);        }   /** AnsonCode 2013.8.5 add Code**/try{final String specialPkg = "com.android.launcherX";mContext.getPackageManager().getApplicationEnabledSetting(specialPkg);intent.setPackage(specialPkg);}catch(Exception e){e.printStackTrace();}   /** AnsonCode End **/        ActivityInfo aInfo =            resolveActivityInfo(intent, STOCK_PM_FLAGS, userId);        if (aInfo != null) {            intent.setComponent(new ComponentName(                    aInfo.applicationInfo.packageName, 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);            if (app == null || app.instrumentationClass == null) {                intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK);                mMainStack.startActivityLocked(null, intent, null, aInfo,                        null, null, 0, 0, 0, 0, null, false, null);            }        }        return true;    }

 

 

 

 

更多相关文章

  1. LeakCanary源码分析
  2. Linux下Android内核源码下载
  3. 最全的Android源码目录结构详解
  4. Android framework源码之JNI实现过程分析
  5. Android开机启动过程
  6. android 进阶之如何阅读源码
  7. Android 源码之OpenGL 人物走动源码
  8. android 水平滚动源码

随机推荐

  1. 《商君书》白话解读——14章 修权
  2. Python和C语言有什么区别?分析!
  3. Harbor的基本使用
  4. Docker企业级镜像仓库Harbor
  5. 世纪联华的 Serverless 之路
  6. Nginx Ingress的一些奇巧淫技
  7. kubernetes中用NFS做后端存储支不支持PVC
  8. 在kubernetes中用Glusterfs做持久化存储
  9. 纳税申报、发票识别验真:解析RPA如何应用
  10. 带你深入熟悉你所不知道的ICMP