Android系统启动篇

1,《android系统启动流程简介》

2,《android init进程启动流程》

3,《android zygote进程启动流程》

4,《Android SystemServer进程启动流程》

5,《android launcher启动流程》

6,《Android Activity启动过程详解》

Android系统开发准备篇

1,《Android 源码下载和编译》

2,《android 11源码编译和pixel3 刷机》

3,《Android Framework代码IDE加载和调试》

Android系统开发实践篇

1,《android设置默认输入法》

2,《android framework预制APK应用》

3,《Android系统层面限制应用开机自启动详解》

4,《android单独编译framework模块并push》

5,《Android Framework开发系统问题分析》

Android系统开发核心知识储备篇

1,《Android编译系统-envsetup和lunch代码篇》

2,《Android编译系统-概念篇》

3,《android日志系统详解》

4,《Android系统Handler详解》

5,《Android系统Binder详解》

6,《Android中Activity、View和Window关系详解》

7,《android view绘制流程详解》

8,《Android读取系统属性详解》

9,《android 窗口管理机制详解》

10,《初识Android系统》

11,《android中AMS进程通知Zygote进程fork新进程的通信方式》

Android核心功能详解篇

1,《android应用市场点击下载APK安装详解》

2,《Android 手势导航(从下往上滑动进入多任务页面)》

3,《android手势分析(应用界面左往右边滑动退出应用)》

4,《android应用安装流程详解》

5,《android11安装应用触发桌面图标刷新流程》

6,《Android系统多任务Recents详解》

7,《android系统导航栏视图分析》

———————————————————————————————————————————

应用安装调用流程:

1, 注册监听 LauncherAppState.java

public LauncherAppState(Context context) {

    mInstallSessionTracker = InstallSessionHelper.INSTANCE.get(context)

    .registerInstallTracker(mModel, MODEL_EXECUTOR);



}

InstallSessionHelper.java

public InstallSessionTracker registerInstallTracker(

InstallSessionTracker.Callback callback, LooperExecutor executor) {



//创建跟踪器

InstallSessionTracker tracker = new InstallSessionTracker(this, callback);



if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {

mInstaller.registerSessionCallback(tracker, executor.getHandler());

} else {

//注册应用安装回调,当系统安装应用时会回调注册的tracker

mLauncherApps.registerPackageInstallerSessionCallback(executor, tracker);

}

return tracker;

}

LauncherApps.java

public void registerPackageInstallerSessionCallback(

@NonNull @CallbackExecutor Executor executor, @NonNull SessionCallback callback) {

if (executor == null) {

throw new NullPointerException("Executor must not be null");

}



synchronized (mDelegates) {

final SessionCallbackDelegate delegate = new SessionCallbackDelegate(callback,

executor);

try {

mService.registerPackageInstallerCallback(mContext.getPackageName(),

delegate);

} catch (RemoteException e) {

throw e.rethrowFromSystemServer();

}

mDelegates.add(delegate);

}

}

2,安装事件回调

PackageInstaller.java

PackageInstaller#SessionCallbackDelegate#onSessionProgressChanged

public void onSessionProgressChanged(int sessionId, float progress) {

mExecutor.execute(PooledLambda.obtainRunnable(SessionCallback::onProgressChanged,

mCallback, sessionId, progress).recycleOnUse());

}

InstallSessionTracker.java

public void onProgressChanged(int sessionId, float progress) {

SessionInfo session = mInstallerCompat.getVerifiedSessionInfo(sessionId);

if (session != null && session.getAppPackageName() != null) {

mCallback.onPackageStateChanged(PackageInstallInfo.fromInstallingState(session));

}

}

LauncherModel.java

public void onPackageStateChanged(PackageInstallInfo installInfo) {

enqueueModelUpdateTask(new PackageInstallStateChangedTask(installInfo));

}

BaseModelUpdateTask.java

//起新线程执行

public final void run() {

if (!mModel.isModelLoaded()) {

if (DEBUG_TASKS) {

Log.d(TAG, "Ignoring model task since loader is pending=" + this);

}

// Loader has not yet run.

return;

}

execute(mApp, mDataModel, mAllAppsList);

}

PackageUpdatedTask.java

public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList appsList) {

//mAllAppsList新增同步修改数据

switch (mOp) {

case OP_ADD: {

for (int i = 0; i < N; i++) {

if (DEBUG) Log.d(TAG, "mAllAppsList.addPackage " + packages[i]);

iconCache.updateIconsForPkg(packages[i], mUser);

if (FeatureFlags.PROMISE_APPS_IN_ALL_APPS.get()) {

appsList.removePackage(packages[i], mUser);

}

appsList.addPackage(context, packages[i], mUser);



// Automatically add homescreen icon for work profile apps for below O device.

if (!Utilities.ATLEAST_OREO && !Process.myUserHandle().equals(mUser)) {

SessionCommitReceiver.queueAppIconAddition(context, packages[i], mUser);

}

}

flagOp = FlagOp.removeFlag(WorkspaceItemInfo.FLAG_DISABLED_NOT_AVAILABLE);

break;

}





bindApplicationsIfNeeded();



}

BaseModelUpdateTask.java

public void bindApplicationsIfNeeded() {

if (mAllAppsList.getAndResetChangeFlag()) {

AppInfo[] apps = mAllAppsList.copyData();

int flags = mAllAppsList.getFlags();

scheduleCallbackTask(c -> c.bindAllApplications(apps, flags));

}

}





Launcher.java

public void bindAllApplications(AppInfo[] apps, int flags) {

mAppsView.getAppsStore().setApps(apps, flags);

}

AllAppsStore.java

public void setApps(AppInfo[] apps, int flags) {

mApps = apps;

mModelFlags = flags;

notifyUpdate();

}

桌面应用list刷新