自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数HarmonyOS鸿蒙开发工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年HarmonyOS鸿蒙开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上HarmonyOS鸿蒙开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新
如果你觉得这些内容对你有帮助,可以添加VX:vip204888 (备注鸿蒙获取)
一个人可以走的很快,但一群人才能走的更远。不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
作者:新小梦
在系统启动流程中,Zygote进程通过fork自己来创建SystemServer进程。SystemServer进程的主要职责之一就是创建SystemServiceManger,使自己成为服务的注册中心,并启动三种不同类型的服务:引导服务、核心服务、其他服务。
WMS被划分到其他服务。我们以SystemServer的main函数为入口来分析WMS的启动流程。
1、SystemServer.main
public static void main(String[] args) {
new SystemServer().run();
}
2、SystemServer.run
如下所见,SystemServer先加载android_servers动态库,创建SystemServiceManager对象,将服务划分为三种类型的服务引导服务、核心服务、其他服务。
private void run() {
// 初始化本地服务
System.loadLibrary("android_servers");
...
//创建系统服务管理
mSystemServiceManager = new SystemServiceManager(mSystemContext);
...
//启动三种类型的服务
try {
startBootstrapServices(t);
startCoreServices(t);
startOtherServices(t);
} catch (Throwable ex) {
...
} finally {
...
}
}
3、SystemServer.startOtherServices
startOtherServices函数会创建非常多的服务,这里重点关注WMS的创建,先创建了InputManagerService,再调用WindowManagerService的main函数。
...
inputManager = new InputManagerService(context);
...
wm = WindowManagerService.main(context, inputManager, !mFirstBoot, mOnlyCore,
new PhoneWindowManager(), mActivityManagerService.mActivityTaskManager);
...
ServiceManager.addService(Context.WINDOW_SERVICE, wm, /* allowIsolated= */ false,
DUMP_FLAG_PRIORITY_CRITICAL | DUMP_FLAG_PROTO);
ServiceManager.addService(Context.INPUT_SERVICE, inputManager,
...
//初始化PhoneWindowManager和添加WatchDog监听
wm.onInitReady();
...
wm.displayReady();
...
wm.systemReady();
4、WindowManagerService.main
public static WindowManagerService main(final Context context, final InputManagerService im,
final boolean showBootMsgs, final boolean onlyCore, WindowManagerPolicy policy,
ActivityTaskManagerService atm, Supplier<SurfaceControl.Transaction> transactionFactory,
Supplier<Surface> surfaceFactory,
Function<SurfaceSession, SurfaceControl.Builder> surfaceControlFactory) {
DisplayThread.getHandler().runWithScissors(() ->
sInstance = new WindowManagerService(context, im, showBootMsgs, onlyCore, policy,
atm, transactionFactory, surfaceFactory, surfaceControlFactory), 0);
return sInstance;
}
DisplayThread继承自ServiceThread类,ServiceThread又继承自HandlerThread类。是一个前台系统共享的单例线程,主要服务于WindowManager、DisplayManager、InputManager快速实时执行显示相关的操作。
5、Handler.runWithScissors
public final boolean runWithScissors(@NonNull Runnable r, long timeout) {
if (r == null) {
throw new IllegalArgumentException("runnable must not be null");
}
if (timeout < 0) {
throw new IllegalArgumentException("timeout must be non-negative");
}
if (Looper.myLooper() == mLooper) {
r.run();
return true;
}
BlockingRunnable br = new BlockingRunnable(r);
return br.postAndWait(this, timeout);
}
当前代码是运行在SystemServer的主线程,runWithScissors函数使得Runable对象的run函数切换到DisplayThread代码执行。创建了BlockingRunnable类型的对象r,并调用其他postAndWait函数。此时参数timeout是0,this是自身Handler对象。
行在SystemServer的主线程,runWithScissors函数使得Runable对象的run函数切换到DisplayThread代码执行。创建了BlockingRunnable类型的对象r,并调用其他postAndWait函数。此时参数timeout是0,this是自身Handler对象。