{"id":2554,"date":"2019-02-27T09:27:48","date_gmt":"2019-02-27T01:27:48","guid":{"rendered":"http:\/\/learn-house.idv.tw\/?p=2554"},"modified":"2019-02-27T09:29:15","modified_gmt":"2019-02-27T01:29:15","slug":"%e8%bd%89android%e7%9a%84%e9%96%8b%e6%a9%9f%e6%b5%81%e7%a8%8b%e5%8f%8a%e5%b0%8d%e6%87%89%e7%9a%84%e7%a8%8b%e5%bc%8f%e7%a2%bc%e4%bd%8d%e7%bd%ae","status":"publish","type":"post","link":"https:\/\/learn-house.idv.tw\/?p=2554","title":{"rendered":"[\u8f49]Android\u7684\u958b\u6a5f\u6d41\u7a0b\u53ca\u5c0d\u61c9\u7684\u7a0b\u5f0f\u78bc\u4f4d\u7f6e"},"content":{"rendered":"<p>\u8cc7\u6599\u4f86\u6e90\uff1ahttps:\/\/www.cnblogs.com\/l2rf\/p\/6605987.html<\/p>\n<p><strong>1.\u7cfb\u7d71\u5f15\u5c0ebootloader<\/strong><br \/>\n1)\u6e90\u78bc\uff1abootable\/bootloader\/*<br \/>\n2)\u8aaa\u660e\uff1a\u52a0\u96fb\u5f8c\uff0cCPU\u5c07\u5148\u57f7\u884cbootloader\u7a0b\u5e8f\uff0c\u6b64\u8655\u6709\u4e09\u7a2e\u9078\u64c7<br \/>\na)\u958b\u6a5f\u6309Camera+Power\u555f\u52d5\u5230fastboot\uff0c\u5373\u547d\u4ee4\u6216SD\u5361\u71d2\u5beb\u6a21\u5f0f\uff0c\u4e0d\u52a0\u8f09\u5167\u6838\u53ca\u6587\u4ef6\u7cfb\u7d71\uff0c\u6b64\u8655\u53ef\u4ee5\u9032\u884c\u5de5\u5ee0\u6a21\u5f0f\u7684\u71d2\u5beb<br \/>\nb)\u958b\u6a5f\u6309Home+Power\u555f\u52d5\u5230recovery\u6a21\u5f0f\uff0c\u52a0\u8f09recovery.img\uff0crecovery.img\u5305\u542b\u5167\u6838\uff0c\u57fa\u672c\u7684\u6587\u4ef6\u7cfb\u7d71\uff0c\u7528\u65bc\u5de5\u7a0b\u6a21\u5f0f\u7684\u71d2\u5beb<br \/>\nc)\u958b\u6a5f\u6309Power\uff0c\u6b63\u5e38\u555f\u52d5\u7cfb\u7d71\uff0c\u52a0\u8f09boot.img\uff0cboot.img\u5305\u542b\u5167\u6838\uff0c\u57fa\u672c\u6587\u4ef6\u7cfb\u7d71\uff0c\u7528\u65bc\u6b63\u5e38\u555f\u52d5\u624b\u6a5f\uff08\u4ee5\u4e0b\u53ea\u5206\u6790\u6b63\u5e38\u555f\u52d5\u7684\u60c5\u6cc1\uff09<\/p>\n<p><!--more--><br \/>\n<strong>2.\u5167\u6838kernel<\/strong><br \/>\n1)\u6e90\u78bc\uff1akernel\/*<br \/>\n2)\u8aaa\u660e\uff1akernel\u7531bootloader\u52a0\u8f09<\/p>\n<p><strong>3.\u6587\u4ef6\u7cfb\u7d71\u53ca\u61c9\u7528init<\/strong><br \/>\n1)\u6e90\u78bc\uff1asystem\/core\/init\/*<br \/>\n2)\u914d\u7f6e\u6587\u4ef6\uff1asystem\/rootdir\/init.rc\uff0c<br \/>\n3)\u8aaa\u660e\uff1ainit\u662f\u4e00\u500b\u7531\u5167\u6838\u555f\u52d5\u7684\u7528\u6236\u7d1a\u9032\u7a0b\uff0c\u5b83\u6309\u7167init.rc\u4e2d\u7684\u8a2d\u7f6e\u57f7\u884c\uff1a\u555f\u52d5\u670d\u52d9\uff08\u9019\u88e1\u7684\u670d\u52d9\u6307Linux\u5e95\u5c64\u670d\u52d9\uff0c\u5982adbd\u63d0\u4f9badb\u652f\u6301\uff0cvold\u63d0\u4f9bSD\u5361\u639b\u8f09\u7b49\uff09\uff0c\u57f7\u884c\u547d\u4ee4\u548c\u6309\u5176\u4e2d\u7684\u914d\u7f6e\u8a9e\u53e5\u57f7\u884c\u76f8\u61c9\u529f\u80fd<\/p>\n<p><strong>4.\u91cd\u8981\u7684\u5f8c\u53f0\u7a0b\u5e8fzygote<\/strong><br \/>\n1)\u6e90\u78bc\uff1aframeworks\/base\/cmds\/app_process\/app_main.cpp\u7b49<br \/>\n2)\u8aaa\u660e\uff1azygote\u662f\u4e00\u500b\u5728init.rc\u4e2d\u88ab\u6307\u5b9a\u555f\u52d5\u7684\u670d\u52d9\uff0c\u8a72\u670d\u52d9\u5c0d\u61c9\u7684\u547d\u4ee4\u662f\/system\/bin\/app_process<br \/>\na)\u5efa\u7acbJava Runtime\uff0c\u5efa\u7acb\u865b\u64ec\u6a5f<br \/>\nb)\u5efa\u7acbSocket\u63a5\u6536ActivityManangerService\u7684\u8acb\u6c42\uff0c\u7528\u65bcFork\u61c9\u7528\u7a0b\u5e8f<br \/>\nc)\u555f\u52d5System Server<\/p>\n<p><strong>5.\u7cfb\u7d71\u670d\u52d9system server<\/strong><br \/>\n1)\u6e90\u78bc\uff1aframeworks\/base\/services\/Java\/com\/Android\/server\/SystemServer.java<br \/>\n2)\u8aaa\u660e\uff1a\u88abzygote\u555f\u52d5\uff0c\u901a\u904eSystem Manager\u7ba1\u7406android\u7684\u670d\u52d9\uff08\u9019\u88e1\u7684\u670d\u52d9\u6307frameworks\/base\/services\u4e0b\u7684\u670d\u52d9\uff0c\u5982\u885b\u661f\u5b9a\u4f4d\u670d\u52d9\uff0c\u526a\u5207\u677f\u670d\u52d9\u7b49\uff09<\/p>\n<p>Android 5.1\u4e2dSystemServer.java\u7684\u4ee3\u78bc\u4e2d\u7684startOtherServices\u65b9\u6cd5\u6709\u76f8\u95dc\u8b8a\u91cf\u958b\u95dc\u6c7a\u5b9a\u662f\u5426\u555f\u52d5\u670d\u52d9<\/p>\n<div class=\"cnblogs_code\">\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">boolean disableStorage = SystemProperties.getBoolean(&quot;config.disable_storage&quot;, false);\r\nboolean disableMedia = SystemProperties.getBoolean(&quot;config.disable_media&quot;, false);\r\nboolean disableBluetooth = SystemProperties.getBoolean(&quot;config.disable_bluetooth&quot;, false);\r\nboolean disableTelephony = SystemProperties.getBoolean(&quot;config.disable_telephony&quot;, false);\r\nboolean disableLocation = SystemProperties.getBoolean(&quot;config.disable_location&quot;, false);\r\nboolean disableSystemUI = SystemProperties.getBoolean(&quot;config.disable_systemui&quot;, false);\r\nboolean disableNonCoreServices = SystemProperties.getBoolean(&quot;config.disable_noncore&quot;, false);\r\nboolean disableNetwork = SystemProperties.getBoolean(&quot;config.disable_network&quot;, false);\r\nboolean disableNetworkTime = SystemProperties.getBoolean(&quot;config.disable_networktime&quot;, false);\r\nboolean isEmulator = SystemProperties.get(&quot;ro.kernel.qemu&quot;).equals(&quot;1&quot;);<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p><strong>6.\u684c\u9762launcher<\/strong><br \/>\n1)\u6e90\u78bc\uff1aActivityManagerService.java\u70ba\u5165\u53e3\uff0cpackages\/apps\/launcher*\u5be6\u73fe<br \/>\n2)\u8aaa\u660e\uff1a\u7cfb\u7d71\u555f\u52d5\u6210\u529f\u5f8cSystemServer\u4f7f\u7528xxx.systemReady()\u901a\u77e5\u5404\u500b\u670d\u52d9\uff0c\u7cfb\u7d71\u5df2\u7d93\u5c31\u7dd2\uff0c\u684c\u9762\u7a0b\u5e8fHome\u5c31\u662f\u5728ActivityManagerService.systemReady()\u901a\u77e5\u7684\u904e\u7a0b\u4e2d\u5efa\u7acb\u7684\uff0c\u6700\u7d42\u8abf\u7528startHomeActivityLocked()\u555flauncher<\/p>\n<p><strong>7.\u89e3\u9396<\/strong><br \/>\n1)\u6e90\u78bc\uff1aframeworks\/base\/policy\/src\/com\/android\/internal\/policy\/impl\/keyguard\/KeyguardServiceDelegate.java<br \/>\n2)\u8aaa\u660e\uff1a\u7cfb\u7d71\u555f\u52d5\u6210\u529f\u5f8cSystemServer\u8abf\u7528wm.systemReady()\u901a\u77e5WindowManagerService\uff0c\u9032\u800c\u8abf\u7528PhoneWindowManager\u7684systemReady()<\/p>\n<p>\u5728Android5.1\u4e2d\uff0ckeyguard\u672c\u8eab\u4e0d\u518d\u662f\u4e00\u500b\u7368\u7acb\u7684apk\uff0c\u800c\u662f\u8ddfSystemUI\u9032\u884c\u4e86\u5408\u4f75\uff0c\u4f5c\u70baSystemUI\u7684\u975c\u614b\u5eab\u9032\u884c\u8abf\u7528\u3002\u6240\u4ee5\uff0c\u7cfb\u7d71\u8abf\u8a66\u9396\u5c4f\uff0c\u53ea\u9700\u8981\u55ae\u7368\u7de8\u8b6fSystemUI\u6a21\u584a\uff0c\u7136\u5f8c\u66ff\u63dbSystemUI.apk\u5373\u53ef\u3002<\/p>\n<p>\u53c3\u8003\uff1ahttp:\/\/blog.csdn.net\/wzy_1988\/article\/details\/49659935<\/p>\n<p><strong>8.\u958b\u6a5f\u81ea\u555f\u52d5\u7684\u7b2c\u4e09\u65b9\u61c9\u7528\u7a0b\u5e8f<\/strong><br \/>\n1)\u6e90\u78bc\uff1a<\/p>\n<p>frameworks\/base\/services\/core\/java\/com\/android\/server\/am\/ActivityManagerService.java<\/p>\n<p>2)\u8aaa\u660e\uff1a\u7cfb\u7d71\u555f\u52d5\u6210\u529f\u5f8cSystemServer\u8abf\u7528ActivityManagerNative.getDefault().systemReady()\u901a\u77e5ActivityManager\u555f\u52d5\u6210\u529f\uff0cActivityManager\u6703\u901a\u904e\u7f6e\u8b8a\u91cfmBooting\uff0c\u901a\u77e5\u5b83\u7684\u53e6\u4e00\u7dda\u7a0b\uff0c\u8a72\u7dda\u7a0b\u6703\u767c\u9001\u5ee3\u64adandroid.intent.action.BOOT_COMPLETED\u4ee5\u544a\u77e5\u5df2\u8a3b\u518a\u7684\u7b2c\u4e09\u65b9\u7a0b\u5e8f\u5728\u958b\u6a5f\u6642\u81ea\u52d5\u555f\u52d5\u3002<\/p>\n<p>Android5.1\u4e2d\u7684finishBooting\u65b9\u6cd5\u8a2d\u7f6e\u201csys.boot_completed\u201d\u7cfb\u7d71\u5c6c\u6027\u70ba\u201c1\u201d\uff0c\u4e26\u4e14\u767c\u9001android.intent.action.BOOT_COMPLETED\u5ee3\u64ad<\/p>\n<div class=\"cnblogs_code\">\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">final void finishBooting() {\r\n       ....\r\n       ....\r\n       ....\r\n       ....\r\n\r\n       \r\n                SystemProperties.set(&quot;sys.boot_completed&quot;, &quot;1&quot;);\r\n\r\n                \/\/ And trigger dev.bootcomplete if we are not showing encryption progress\r\n                if (!&quot;trigger_restart_min_framework&quot;.equals(SystemProperties.get(&quot;vold.decrypt&quot;))\r\n                    || &quot;&quot;.equals(SystemProperties.get(&quot;vold.encrypt_progress&quot;))) {\r\n                    SystemProperties.set(&quot;dev.bootcomplete&quot;, &quot;1&quot;);\r\n                }\r\n                for (int i=0; i&lt;mStartedUsers.size(); i++) {\r\n                    UserStartedState uss = mStartedUsers.valueAt(i);\r\n                    if (uss.mState == UserStartedState.STATE_BOOTING) {\r\n                        uss.mState = UserStartedState.STATE_RUNNING;\r\n                        final int userId = mStartedUsers.keyAt(i);\r\n                        Intent intent = new Intent(Intent.ACTION_BOOT_COMPLETED, null);\r\n                        intent.putExtra(Intent.EXTRA_USER_HANDLE, userId);\r\n                        intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);\r\n                        broadcastIntentLocked(null, null, intent, null,\r\n                                new IIntentReceiver.Stub() {\r\n                                    @Override\r\n                                    public void performReceive(Intent intent, int resultCode,\r\n                                            String data, Bundle extras, boolean ordered,\r\n                                            boolean sticky, int sendingUser) {\r\n                                        synchronized (ActivityManagerService.this) {\r\n                                            requestPssAllProcsLocked(SystemClock.uptimeMillis(),\r\n                                                    true, false);\r\n                                        }\r\n                                    }\r\n                                },\r\n                                0, null, null,\r\n                                android.Manifest.permission.RECEIVE_BOOT_COMPLETED,\r\n                                AppOpsManager.OP_BOOT_COMPLETED, true, false,\r\n                                MY_PID, Process.SYSTEM_UID, userId);\r\n                    }\r\n       ....\r\n       ....\r\n       ....\r\n       ....\r\n                \r\n                \r\n            }\r\n        }\r\n    }<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p><strong>9.\u7e3d\u7d50<\/strong><br \/>\n\u7d9c\u4e0a\u6240\u8ff0\uff0c\u7cfb\u7d71\u5c64\u6b21\u95dc\u65bc\u555f\u52d5\u6700\u6838\u5fc3\u7684\u90e8\u5206\u662fzygote(\u5373app_process)\u548csystem server\uff0czygote\u5b83\u8ca0\u8cac\u6700\u57fa\u672c\u7684\u865b\u64ec\u6a5f\u7684\u5efa\u7acb\uff0c\u4ee5\u652f\u6301\u5404\u500b\u61c9\u7528\u7a0b\u5e8f\u7684\u555f\u52d5\uff0c\u800csystem server\u7528\u65bc\u7ba1\u7406android\u5f8c\u53f0\u670d\u52d9\uff0c\u555f\u52d5\u6b65\u9a5f\u53ca\u9806\u5e8f\u3002<\/p>\n<p><strong>10. \u53c3\u8003<\/strong><\/p>\n<p>http:\/\/blog.csdn.net\/basonjiang_sz\/category\/648399.aspx<\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u00a0<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/108817\/201703\/108817-20170323180450533-882172407.gif\" alt=\"\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8cc7\u6599\u4f86\u6e90\uff1ahttps:\/\/www.cnblogs.com\/l2rf\/p\/6605987.html 1.\u7cfb\u7d71\u5f15\u5c0e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-2554","post","type-post","status-publish","format-standard","hentry","category-5"],"_links":{"self":[{"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/2554"}],"collection":[{"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2554"}],"version-history":[{"count":0,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/2554\/revisions"}],"wp:attachment":[{"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2554"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2554"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2554"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}