{"id":310797,"date":"2020-10-01T09:00:57","date_gmt":"2020-10-01T09:00:57","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=310797"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=310797","title":{"rendered":"\u00ab\u0425\u043e\u043b\u043e\u0434\u043d\u044b\u0439\u00bb \u0437\u0430\u043f\u0443\u0441\u043a Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/521522\/\">\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442\u044a! \u0414\u0430\u0432\u043d\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u0438\u0441\u0430\u043b=) <br \/>  \u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0441\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u043c \u0441\u0442\u0430\u0442\u044c\u0438 \u0441 \u043c\u043e\u0438\u043c\u0438 \u0432\u0441\u0442\u0430\u0432\u043a\u0430\u043c\u0438 =)<br \/>  \u042d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0435\u0440\u0438\u044f \u043f\u043e\u0441\u0442\u043e\u0432 \u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u00ab\u0445\u043e\u043b\u043e\u0434\u043d\u043e\u0433\u043e\u00bb \u0437\u0430\u043f\u0443\u0441\u043a\u0430 Android \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0441 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043d\u0430 \u0438\u043a\u043e\u043d\u043a\u0443 \u0438 \u0434\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/d07\/13f\/603\/d0713f603786397ce72b135e16cb7c12.jpg\" alt=\"image\"><br \/>  <a name=\"habracut\"><\/a><\/p>\n<h2>\u041e\u0431\u0449\u0430\u044f \u0441\u0445\u0435\u043c\u0430<\/h2>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/375\/e95\/f2d\/375e95f2d557161150dff3978fd097a8.png\" alt=\"image\"><\/p>\n<h2>\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u044f \u00ab\u043e\u043a\u043d\u043e\u00bb\u2026<\/h2>\n<p>  \u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c \u043a\u0430\u043a \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, <b>system_server<\/b> \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u043e\u0435 \u043e\u043a\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043c\u0435\u0442\u043e\u0434 PhoneWindowManager<b>.addSplashScreen()<\/b>:  <\/p>\n<pre><code class=\"java\">public class PhoneWindowManager implements WindowManagerPolicy {    public StartingSurface addSplashScreen(...) {     ...     PhoneWindow win = new PhoneWindow(context);     win.setIsStartingWindow(true);     win.setType(TYPE_APPLICATION_STARTING);     win.setTitle(label);     win.setDefaultIcon(icon);     win.setDefaultLogo(logo);     win.setLayout(MATCH_PARENT, MATCH_PARENT);      addSplashscreenContent(win, context);      WindowManager wm = (WindowManager) context.getSystemService(       WINDOW_SERVICE     );     View view = win.getDecorView();     wm.addView(view, params);     ...   }    private void addSplashscreenContent(PhoneWindow win,       Context ctx) {     TypedArray a = ctx.obtainStyledAttributes(R.styleable.Window);     int resId = a.getResourceId(       R.styleable.Window_windowSplashscreenContent,       0     );     a.recycle();     Drawable drawable = ctx.getDrawable(resId);     View v = new View(ctx);     v.setBackground(drawable);     win.setContentView(v);   } }<\/code><\/pre>\n<p>  <b>\u0421\u0442\u0430\u0440\u0442\u043e\u0432\u043e\u0435 \u043e\u043a\u043d\u043e<\/b> \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0434\u0435\u0442\u044c \u043f\u043e\u043a\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u041e\u043a\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440 \u043f\u043e\u043a\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u0430 <b>Activity<\/b> \u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u043d \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u0430\u0434\u0440. \u0422\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u043a\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d <b>\u00ab\u0445\u043e\u043b\u043e\u0434\u043d\u044b\u0439\u00bb \u0437\u0430\u043f\u0443\u0441\u043a<\/b>. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0432\u0438\u0434\u0435\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0435 \u043e\u043a\u043d\u043e \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u0439\u0442\u0435\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u043c =).<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c64\/3a4\/f5e\/c643a4f5ea3c7f6e4c35d6b37c34bed3.png\" alt=\"image\"><\/p>\n<p>  \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u043e\u0433\u043e \u043e\u043a\u043d\u0430 \u0431\u0435\u0440\u0435\u0442\u0441\u044f \u0438\u0437 drawable-\u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 <b>windowSplashscreenContent<\/b> \u0438 <b>windowBackground<\/b> \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u043e\u0433\u043e <b>Activity<\/b>. \u0411\u0430\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u043e\u0433\u043e \u043e\u043a\u043d\u0430:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a5a\/79b\/70d\/a5a79b70df1e58bcf967b9216140863d.png\" alt=\"image\"><\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 Activity \u0438\u0437 \u0440\u0435\u0436\u0438\u043c\u0430 <b>\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u044d\u043a\u0440\u0430\u043d\u0430(Recent screen)<\/b>, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0430 \u043d\u0430\u0436\u0438\u043c\u0430\u044f \u043d\u0430 \u0438\u043a\u043e\u043d\u043a\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0442\u043e <b>system_server<\/b> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 TaskSnapshotSurface<b>.create()<\/b>, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u043e\u0435 \u043e\u043a\u043d\u043e \u0438\u0437 \u0443\u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u0430.<\/p>\n<p>  \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u043e\u0435 \u043e\u043a\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e, <b>system_server<\/b> \u0433\u043e\u0442\u043e\u0432 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 ZygoteProcess.<b>startViaZygote()<\/b>:  <\/p>\n<pre><code class=\"java\">public class ZygoteProcess {   private Process.ProcessStartResult startViaZygote(...) {     ArrayList&lt;String&gt; argsForZygote = new ArrayList&lt;&gt;();     argsForZygote.add(&quot;--runtime-args&quot;);     argsForZygote.add(&quot;--setuid=&quot; + uid);     argsForZygote.add(&quot;--setgid=&quot; + gid);     argsForZygote.add(&quot;--runtime-flags=&quot; + runtimeFlags);     ...     return zygoteSendArgsAndGetResult(openZygoteSocketIfNeeded(abi),                                           zygotePolicyFlags,                                           argsForZygote);   } }<\/code><\/pre>\n<p>  \u0412 \u043a\u043e\u0434\u0435 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 ZygoteProcess.<b>zygoteSendArgsAndGetResult()<\/b> \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u0441\u043e\u043a\u0435\u0442 <b>Zygote-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443<\/b>.<\/p>\n<h2>\u00ab\u0420\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u00bb Zygote-\u044b<\/h2>\n<p>  \u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Android-\u0430 \u043e\u0431 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u0441\u043b\u0435\u0434\u0443\u0435\u0442:  <\/p>\n<blockquote><p>\u041a\u0430\u0436\u0434\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u043e\u0440\u043a\u0430\u043d\u0438\u044f(\u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f) \u043e\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e Zygote-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u2026<\/p><\/blockquote>\n<p>  \u0412\u043a\u0440\u0430\u0442\u0446\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c \u044f \u043f\u0438\u0441\u0430\u043b \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"https:\/\/nurlandroid.com\/?p=321\" rel=\"nofollow\">\u043f\u0440\u043e \u0437\u0430\u043f\u0443\u0441\u043a Android-\u0430<\/a>. \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0433\u043b\u0443\u0431\u0436\u0435 \u043d\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b.<\/p>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441 <b>Zygote<\/b> \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 ZygoteInit<b>.main()<\/b>:  <\/p>\n<pre><code class=\"java\">public class ZygoteInit {    public static void main(String argv[]) {     ...     if (!enableLazyPreload) {         preload(bootTimingsTraceLog);     }     \/\/ The select loop returns early in the child process after     \/\/ a fork and loops forever in the zygote.     caller = zygoteServer.runSelectLoop(abiList);     \/\/ We're in the child process and have exited the     \/\/ select loop. Proceed to execute the command.     if (caller != null) {       caller.run();     }   }    static void preload(TimingsTraceLog bootTimingsTraceLog) {     preloadClasses();     cacheNonBootClasspathClassLoaders();     preloadResources();     nativePreloadAppProcessHALs();     maybePreloadGraphicsDriver();     preloadSharedLibraries();     preloadTextResources();     WebViewFactory.prepareWebViewInZygote();     warmUpJcaProviders();   } }<\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435 \u043c\u0435\u0442\u043e\u0434 ZygoteInit.<b>main()<\/b> \u0434\u0435\u043b\u0430\u0435\u0442 2 \u0432\u0430\u0436\u043d\u044b\u0435 \u0432\u0435\u0449\u0438:  <\/p>\n<ul>\n<li>\u041f\u043e\u0434\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u044b Android-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430. \u041f\u043e\u0434\u043e\u0431\u043d\u0430\u044f \u043f\u0440\u0435\u0434\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442 \u043f\u0430\u043c\u044f\u0442\u044c \u043d\u043e \u0435\u0449\u0435 \u0438 \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442 \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. <\/li>\n<li>\u0414\u0430\u043b\u0435\u0435 \u043e\u043d \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 ZygoteServer.runSelectLoop(), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0441\u043e\u043a\u0435\u0442 \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0441\u043b\u0443\u0448\u0430\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u044b \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043e\u043a\u0435\u0442\u0430.<\/li>\n<\/ul>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u0436\u0435 \u043d\u0430 \u0441\u043e\u043a\u0435\u0442 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043d\u0430 \u0444\u043e\u0440\u043a\u0438\u043d\u0433 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u043c\u0435\u0442\u043e\u0434 ZygoteConnection.<b>processOneCommand()<\/b> \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043c\u0435\u0442\u043e\u0434 ZygoteArguments.<b>parseArgs()<\/b> \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 Zygote.<b>forkAndSpecialize()<\/b>:  <\/p>\n<pre><code class=\"java\">public final class Zygote {    public static int forkAndSpecialize(...) {     ZygoteHooks.preFork();      int pid = nativeForkAndSpecialize(...);      \/\/ Set the Java Language thread priority to the default value.     Thread.currentThread().setPriority(Thread.NORM_PRIORITY);      ZygoteHooks.postForkCommon();     return pid;   } } <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/d1c\/438\/c31\/d1c438c315d708fa0a29a3ceb1332e24.png\" alt=\"image\"><\/p>\n<p>  <b>\u041d\u0430 \u0437\u0430\u043c\u0435\u0442\u043a\u0443:<\/b> \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Android 10 \u0435\u0441\u0442\u044c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0444\u0438\u0447\u0430 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <b>Unspecialized App Process<\/b>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u043c\u0435\u0435\u0442 \u043f\u0443\u043b \u043d\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 Zygote-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u0434\u043b\u044f \u0435\u0449\u0435 \u0431\u043e\u043b\u0435\u0435 \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439.<\/p>\n<h2>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u043e\u0441\u044c!<\/h2>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0444\u043e\u0440\u043a\u0430 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 RuntimeInit.<b>commonInit()<\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0439 <b>UncaughtExceptionHandler<\/b>. \u0414\u0430\u043b\u0435\u0435, \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 ActivityThread.<b>main()<\/b>:  <\/p>\n<pre><code class=\"java\">public final class ActivityThread {    public static void main(String[] args) {     Looper.prepareMainLooper();      ActivityThread thread = new ActivityThread();     thread.attach(false, startSeq);      Looper.loop();   }    final ApplicationThread mAppThread = new ApplicationThread();    private void attach(boolean system, long startSeq) {     if (!system) {       IActivityManager mgr = ActivityManager.getService();       mgr.attachApplication(mAppThread, startSeq);     }   } }<\/code><\/pre>\n<p>  \u0422\u0443\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0434\u0432\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0432\u0435\u0449\u0438:  <\/p>\n<ul>\n<li>\u041c\u0435\u0442\u043e\u0434 ActivityThread.<b>main()<\/b> \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u043f\u043e\u0442\u043e\u043a(Thread) \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 Looper.<b>loop()<\/b>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u043d\u043e\u0432\u044b\u0439 \u0438\u043d\u0441\u0442\u0430\u043d\u0441 <b>Looper<\/b>-\u0430. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d \u043a \u043d\u043e\u0432\u043e\u043c\u0443 \u043f\u043e\u0442\u043e\u043a\u0443(\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f <b>MainThread<\/b>-\u043e\u043c aka UiThread) \u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c(\u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438) \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e. <b>Looper<\/b> \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u0432\u0448\u0438\u0441\u044c, \u0431\u0443\u0434\u0435\u0442 \u043e\u0436\u0438\u0434\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0438\u0445 \u043a \u0441\u0432\u043e\u0435\u043c\u0443 <b>MessageQueue<\/b>.<\/li>\n<li>\u0414\u0430\u043b\u0435\u0435, \u043c\u0435\u0442\u043e\u0434 ActivityThread.<b>attach()<\/b> \u0434\u0435\u043b\u0430\u0435\u0442 IPC-\u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u043c\u0435\u0442\u043e\u0434\u0443 ActivityManagerService.<b>attachApplication()<\/b> <b>system_server<\/b>-\u0430, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0434\u0430\u0432\u0430\u044f \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e <b>MainThread<\/b> \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u0438 \u0433\u043e\u0442\u043e\u0432 \u043a \u0440\u0430\u0431\u043e\u0442\u0435.<\/li>\n<\/ul>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e08\/6b9\/e08\/e086b9e080d94b92b1ba354002725c90.png\" alt=\"image\"><\/p>\n<h2>\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u043d\u0430\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c<\/h2>\n<p>  \u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 <b>system_server<\/b> \u043c\u0435\u0442\u043e\u0434 ActivityManagerService.<b>attachApplication()<\/b> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 ActivityManagerService.<b>attachApplicationLocked()<\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:  <\/p>\n<pre><code class=\"java\">public class ActivityManagerService extends IActivityManager.Stub {    private boolean attachApplicationLocked(       IApplicationThread thread, int pid, int callingUid,       long startSeq) {     thread.bindApplication(...);      \/\/ See if the top visible activity is waiting to run     \/\/  in this process...     mAtmInternal.attachApplication(...);      \/\/ Find any services that should be running in this process...     mServices.attachApplicationLocked(app, processName);      \/\/ Check if a next-broadcast receiver is in this process...     if (isPendingBroadcastProcessLocked(pid)) {         sendPendingBroadcastsLocked(app);     }     return true;   } }<\/code><\/pre>\n<p>  \u041f\u0430\u0440\u043e\u0447\u043a\u0430 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0432\u044b\u0432\u043e\u0434\u043e\u0432:  <\/p>\n<ul>\n<li>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 <b>system_server<\/b> \u0434\u0435\u043b\u0430\u0435\u0442 IPC-\u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u043c\u0435\u0442\u043e\u0434\u0443 ActivityThread.<b>bindApplication()<\/b> \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u043c\u0435\u0442\u043e\u0434\u0443 ActivityThread.<b>handleBindApplication()<\/b> \u0432 <b>MainThread<\/b>-\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/li>\n<li>\u0421\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e, <b>system_server<\/b> \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a Pending Activity, Service \u0438 BroadcastReciever-\u043e\u0432 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/li>\n<li>\u041c\u0435\u0442\u043e\u0434 ActivityThread.<b>handleBindApplication()<\/b> \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 APK-\u0444\u0430\u0439\u043b \u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/li>\n<li>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0438\u043c\u0435\u044e\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0430 ActivityThread.<b>handleBindApplication()<\/b>, \u0442\u0430\u043a \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0437\u0434\u0435\u0441\u044c \u0434\u043e\u043b\u0436\u0435\u043d \u043d\u0430\u0447\u0430\u0442\u044c\u0441\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0445\u043e\u043b\u043e\u0434\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/li>\n<\/ul>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/70c\/90a\/8d6\/70c90a8d6a3ad8d1170a88a18ba9ee8a.png\" alt=\"image\"><\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c 3-\u0438\u0439 \u043f\u0443\u043d\u043a\u0442 \u0438 \u0443\u0437\u043d\u0430\u0435\u043c \u0447\u0442\u043e \u0438 \u043a\u0430\u043a \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041f\u043e\u0440\u044f\u0434\u043e\u043a \u0448\u0430\u0433\u043e\u0432 \u0442\u0430\u043a\u043e\u0439:  <\/p>\n<ul>\n<li>\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 <b>AppComponentFactory<\/b>.<\/li>\n<li>\u0412\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 AppComponentFactory.<b>instantiateClassLoader()<\/b>.<\/li>\n<li>\u0412\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 AppComponentFactory.<b>instantiateApplication()<\/b> \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 <b>Application<\/b>.<\/li>\n<li>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e <b>ContentProvider<\/b>-\u0430, \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0430, \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 AppComponentFactory.<b>instantiateProvider()<\/b> \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430, \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 ContentProvider.<b>onCreate()<\/b>.<\/li>\n<li>\u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 Application.<b>onCreate()<\/b>.<\/li>\n<\/ul>\n<h2>\u042d\u043f\u0438\u043b\u043e\u0433<\/h2>\n<p>  \u041c\u044b \u043d\u0430\u0447\u0430\u043b\u0438 \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u00ab\u0445\u043e\u043b\u043e\u0434\u043d\u0443\u044e\u00bb \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0441 \u043e\u0447\u0435\u043d\u044c \u043e\u0431\u0449\u0435-\u0430\u0431\u0441\u0442\u0440\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/375\/e95\/f2d\/375e95f2d557161150dff3978fd097a8.png\" alt=\"image\"><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u00ab\u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c\u00bb:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/3b2\/50c\/487\/3b250c4875ad5bf69bb953b81b924fae.png\" alt=\"image\"><\/p>\n<p>  \u041d\u0443 \u0447\u0442\u043e \u0436\u0435, \u044d\u0442\u043e \u0431\u044b\u043b \u0434\u043b\u0438\u043d\u043d\u044b\u0439 \u043f\u043e\u0441\u0442 =) \u041d\u043e \u044d\u0442\u043e \u043d\u0435 \u0432\u0441\u0435! \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043f\u043e\u0441\u0442\u0430\u0445 \u043c\u044b \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0435 \u043f\u043e\u0433\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041e\u0441\u0442\u0430\u0432\u0430\u0439\u0442\u0435\u0441\u044c \u0441 \u043d\u0430\u043c\u0438!<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/521522\/\"> https:\/\/habr.com\/ru\/post\/521522\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/521522\/\">\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442\u044a! \u0414\u0430\u0432\u043d\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u0438\u0441\u0430\u043b=) <br \/>  \u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0441\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u043c \u0441\u0442\u0430\u0442\u044c\u0438 \u0441 \u043c\u043e\u0438\u043c\u0438 \u0432\u0441\u0442\u0430\u0432\u043a\u0430\u043c\u0438 =)<br \/>  \u042d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0435\u0440\u0438\u044f \u043f\u043e\u0441\u0442\u043e\u0432 \u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u00ab\u0445\u043e\u043b\u043e\u0434\u043d\u043e\u0433\u043e\u00bb \u0437\u0430\u043f\u0443\u0441\u043a\u0430 Android \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0441 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043d\u0430 \u0438\u043a\u043e\u043d\u043a\u0443 \u0438 \u0434\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/d07\/13f\/603\/d0713f603786397ce72b135e16cb7c12.jpg\" alt=\"image\">  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-310797","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/310797","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=310797"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/310797\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=310797"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=310797"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=310797"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}