Android系统启动篇
4,《Android SystemServer进程启动流程》
5,《android launcher启动流程》
Android系统开发准备篇
3,《Android Framework代码IDE加载和调试》
Android系统开发实践篇
4,《android单独编译framework模块并push》
Android系统开发核心知识储备篇
1,《Android编译系统-envsetup和lunch代码篇》
3,《android日志系统详解》
6,《Android中Activity、View和Window关系详解》
9,《android 窗口管理机制详解》
11,《android中AMS进程通知Zygote进程fork新进程的通信方式》
Android核心功能详解篇
2,《Android 手势导航(从下往上滑动进入多任务页面)》
3,《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刷新