{"id":14066,"date":"2024-07-27T15:13:21","date_gmt":"2024-07-27T07:13:21","guid":{"rendered":"http:\/\/xinyiworld.top\/wordpress_it\/?p=14066"},"modified":"2024-07-27T17:15:30","modified_gmt":"2024-07-27T09:15:30","slug":"activitythread-java","status":"publish","type":"post","link":"http:\/\/xinyiworld.top\/wordpress_it\/?p=14066","title":{"rendered":"ActivityThread.java"},"content":{"rendered":"<p>\u6e90\u7801\u4f4d\u7f6e\uff1a<code>frameworks\/base\/core\/java\/android\/app\/ActivityThread.java<\/code><\/p>\n<p>\u6ce8\u610fActivityThread\u7ee7\u627f\u81eaClientTransactionHandler\u7c7b<\/p>\n<ul>\n<li>\n<p>systemMain\u65b9\u6cd5<\/p>\n<pre><code class=\"language-java\">7187     @UnsupportedAppUsage\n7188     public static ActivityThread systemMain() {\n7189         \/\/ The system process on low-memory devices do not get to use hardware\n7190         \/\/ accelerated drawing, since this can add too much overhead to the\n7191         \/\/ process.\n7192         if (!ActivityManager.isHighEndGfx()) {\n7193             ThreadedRenderer.disable(true);\n7194         } else {\n7195             ThreadedRenderer.enableForegroundTrimming();\n7196         }\n7197         ActivityThread thread = new ActivityThread();\n7198         thread.attach(true, 0);\n7199         return thread;\n7200     }<\/code><\/pre>\n<p>\u6b64\u65b9\u6cd5\u9664\u4e86SystemServer.java\u4f1a\u8c03\u7528\uff0c<code>frameworks\/base\/cmds\/media\/src\/com\/android\/commands\/media\/Media.java<\/code>\u4e5f\u4f1a\u8c03\u7528\u5230\u3002<\/p>\n<\/li>\n<li>\n<p>attach\u65b9\u6cd5<\/p>\n<pre><code class=\"language-java\">7111     @UnsupportedAppUsage\n7112     private void attach(boolean system, long startSeq) {\n7113         sCurrentActivityThread = this;\n7114         mSystemThread = system;\n7115         if (!system) {\n            ...\n7147         } else {\n7148             \/\/ Don&#039;t set application object here -- if the system crashes,\n7149             \/\/ we can&#039;t display an alert, we just want to die die die.\n7150             android.ddm.DdmHandleAppName.setAppName(&quot;system_process&quot;,\n7151                     UserHandle.myUserId());\n7152             try {\n7153                 mInstrumentation = new Instrumentation();\n7154                 mInstrumentation.basicInit(this);\n7155                 ContextImpl context = ContextImpl.createAppContext(\n7156                         this, getSystemContext().mPackageInfo);\n7157                 mInitialApplication = context.mPackageInfo.makeApplication(true, null);\n7158                 mInitialApplication.onCreate();\n7159             } catch (Exception e) {\n7160                 throw new RuntimeException(\n7161                         &quot;Unable to instantiate Application():&quot; + e.toString(), e);\n7162             }\n7163         }<\/code><\/pre>\n<\/li>\n<li>\n<p>getSystemContext\u65b9\u6cd5<\/p>\n<pre><code class=\"language-java\">2390     @UnsupportedAppUsage\n2391     public ContextImpl getSystemContext() {\n2392         synchronized (this) {\n2393             if (mSystemContext == null) {\n2394                 mSystemContext = ContextImpl.createSystemContext(this);\n2395             }\n2396             return mSystemContext;\n2397         }\n2398     }<\/code><\/pre>\n<\/li>\n<li>\n<p>getSystemUiContext<\/p>\n<pre><code class=\"language-java\">2400     public ContextImpl getSystemUiContext() {\n2401         synchronized (this) {\n2402             if (mSystemUiContext == null) {\n2403                 mSystemUiContext = ContextImpl.createSystemUiContext(getSystemContext());\n2404             }\n2405             return mSystemUiContext;\n2406         }\n2407     }<\/code><\/pre>\n<\/li>\n<\/ul>\n<button class=\"simplefavorite-button\" data-postid=\"14066\" data-siteid=\"1\" data-groupid=\"1\" data-favoritecount=\"0\" style=\"\">\u6536\u85cf <i class=\"sf-icon-star-empty\"><\/i><\/button>","protected":false},"excerpt":{"rendered":"<p>\u6e90\u7801\u4f4d\u7f6e\uff1aframeworks\/base\/core\/java\/android\/app\/Activit [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1074],"tags":[],"_links":{"self":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/14066"}],"collection":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=14066"}],"version-history":[{"count":6,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/14066\/revisions"}],"predecessor-version":[{"id":14072,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/14066\/revisions\/14072"}],"wp:attachment":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14066"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14066"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14066"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}