android程序加载过程,Android 桌面加载图标过程分析

LoaderTask.java

可以看到LoaderTask实现了Runnable接口,直接去看该类的run() 方法public void run() {      boolean isUpgrade = false;      synchronized (mLock) {

mIsLoaderTaskRunning = true;

}      // Optimize for end-user experience: if the Launcher is up and // running with the

// All Apps interface in the foreground, load All Apps first. Otherwise, load the

// workspace first (default).

keep_running: {          // Elevate priority when Home launches for the first time to avoid

// starving at boot time. Staring at a blank home is not cool.

synchronized (mLock) {              if (DEBUG_LOADERS) Log.d(TAG, "Setting thread priority to " +

(mIsLaunching ? "DEFAULT" : "BACKGROUND"));

android.os.Process.setThreadPriority(mIsLaunching

? Process.THREAD_PRIORITY_DEFAULT : Process.THREAD_PRIORITY_BACKGROUND);

}          if (DEBUG_LOADERS) Log.d(TAG, "step 1: loading workspace");        //加载一级菜单的方法

isUpgrade = loadAndBindWorkspace();          if (mStopped) {              break keep_running;

}          // Whew! Hard work done.  Slow us down, and wait until the UI thread has

// settled down.

synchronized (mLock) {              if (mIsLaunching) {                  if (DEBUG_LOADERS) Log.d(TAG, "Setting thread priority to BACKGROUND");

android.os.Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);

}

}

waitForIdle();          // second step

if (DEBUG_LOADERS) Log.d(TAG, "step 2: loading all apps");          //加载二级菜单里面的方法

loadAndBindAllApps();          // Restore the default thread priority after we are done loading items

synchronized (mLock) {

android.os.Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT);

}

}      // Update the saved icons if necessary

if (DEBUG_LOADERS) Log.d(TAG, "Comparing loaded icons to database icons");      synchronized (sBgLock) {          for (Object key : sBgDbIconCache.keySet()) {

updateSavedIcon(mContext, (ShortcutInfo) key, sBgDbIconCache.get(key));

}

sBgDbIconCache.clear();

}      if (AppsCustomizePagedView.DISABLE_ALL_APPS) {          // Ensure that all the applications that are in the system are

// represented on the home screen.

if (!UPGRADE_USE_MORE_APPS_FOLDER || !isUpgrade) {

verifyApplications();

}

}      // Clear out this reference, otherwise we end up holding it until all of the

// callback runnables are done.

mContext = null;      synchronized (mLock) {          // If we are still the last one to be scheduled, remove ourselves.

if (mLoaderTask == this) {

mLoaderTask = null;

}

mIsLoaderTaskRunning = false;

}

}

可以看到在该类中主要有两个方法,

下面着重分析下这两个方法的加载流程loadAndBindWorkSpace(), WorkSpace是一级菜单里面的容器类,该方法是加载一及菜单的方法

loadAndBindAllapp() ,这是抽屉内二级菜单的加载方法

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值