{"id":1230,"date":"2023-03-18T09:18:07","date_gmt":"2023-03-18T01:18:07","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1230"},"modified":"2023-04-29T09:35:08","modified_gmt":"2023-04-29T01:35:08","slug":"impact-and-adaptation-of-atlas-after-android-p-prevents-calls-to-non-sdk-apis","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/18\/impact-and-adaptation-of-atlas-after-android-p-prevents-calls-to-non-sdk-apis\/","title":{"rendered":"Android P\u963b\u6b62\u8c03\u7528\u975esdk api\u540e\uff0cAtlas\u7684\u5f71\u54cd\u53ca\u9002\u914d"},"content":{"rendered":"<p>\u81ea\u4eceAndroid P\/9.0\u540e\uff0cAndroid\u5c31\u5df2\u7ecf\u5f00\u59cb\u7740\u624b\u963b\u6b62App\u5f00\u53d1\u8c03\u7528\u975esdk\u7684api\uff0c\u4e5f\u5c31\u662f\u88ab\u6807\u8bb0\u4e3a@hide\u7684\u53d8\u91cf\u3001\u51fd\u6570\u3001\u7c7b\u4e0d\u53ef\u4ee5\u901a\u8fc7\u53cd\u5c04\u8c03\u7528\uff0c\u5426\u5219\u4f1a\u63d0\u793aNoSuchMethod\u5f02\u5e38<\/p>\n<h2>\u5bf9Atlas\u5f71\u54cd<\/h2>\n<p><!-- more --><\/p>\n<p>Atlas\u6709\u8bb8\u591a\u8c03\u7528\u90fd\u662f\u901a\u8fc7\u53cd\u5c04\u7cfb\u7edfapi\u6765\u5b8c\u6210\u7684\uff0c\u5176\u4e2d\u4e0d\u4e4f\u88ab\u6807\u8bb0\u4e3a@hide\u7684\u7c7b\uff0c\u6bd4\u5982\u7528\u6765\u5904\u7406\u63d2\u4ef6\u8d44\u6e90\u7684android.content.res.AssetManager#addAssetPath\uff0c\u8fd8\u6709\u7528\u6765\u5904\u7406\u52a8\u6001\u90e8\u7f72\u7684\u542f\u52a8\u65b0Activity\u7684android.app.ActivityThread<\/p>\n<pre><code class=\"language-java\">\/**\n * Add an additional set of assets to the asset manager.  This can be\n * either a directory or ZIP file.  Not for use by applications.  Returns\n * the cookie of the added asset, or 0 on failure.\n * {@hide}  WARM\uff0c\u8be5\u65b9\u6cd5\u88ab\u6807\u8bb0\u4e3a\u9690\u85cf\n *\/\npublic final int addAssetPath(String path) {\n    synchronized (this) {\n        int res = addAssetPathNative(path);\n        makeStringBlocks(mStringBlocks);\n        return res;\n    }\n}<\/code><\/pre>\n<pre><code class=\"language-java\">\/**\n * This manages the execution of the main thread in an\n * application process, scheduling and executing activities,\n * broadcasts, and other operations on it as the activity\n * manager requests.\n *\n * {@hide}   \u9ad8\u80fd\uff0c\u6574\u4e2a\u7c7b\u90fd\u6807\u8bb0\u4e3a\u9690\u85cf\n *\/\npublic final class ActivityThread {<\/code><\/pre>\n<p>\u5982\u679c<code>android.content.res.AssetManager#addAssetPath<\/code>\u4e0d\u80fd\u4f7f\u7528\uff0c\u8d44\u6e90\u5728\u63d2\u4ef6\u4e2d\u5c31\u65e0\u6cd5\u4f7f\u7528\uff0c\u5982\u679candroid.app.ActivityThread\u6574\u4e2a\u7c7b\u4e0d\u8ba9\u53cd\u5c04\uff0c\u90a3\u52a8\u6001\u90e8\u7f72\u4e2d\u65e0\u6cd5\u6dfb\u52a0\u65b0\u7684Activity\u3001Service<\/p>\n<h2>Android P \u5904\u7406\u975esdk\u8c03\u7528<\/h2>\n<p>\u4f46\u60c5\u51b5\u5e76\u6ca1\u6709\u60f3\u8c61\u7684\u7cdf\u7cd5\uff0cAndroid P \u963b\u6b62\u8c03\u7528\u975esdk\u5e76\u4e0d\u662f\u7edd\u5bf9\u7684\uff0c\u5e76\u4e0d\u662f\u6807\u8bb0\u4e86hide\u5c31\u4e00\u5b9a\u4f1a\u629b\u5f02\u5e38\u3002\u8fd8\u6709\u4e2aX\u56e0\u7d20\u2014\u2014light-greylist\uff0c\u5982\u679c\u88abhide\u7684api\u5728\u91cc\u9762\u5217\u51fa\uff0c\u5c31\u5141\u8bb8\u88ab\u53cd\u5c04\u8c03\u7528\u3002\u8be5\u5217\u8868\u5982\u4e0b\uff1a<\/p>\n<p><a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/github.com\/aosp-mirror\/platform_frameworks_base\/blob\/master\/config\/hiddenapi-p-light-greylist.txt\">https:\/\/github.com\/aosp-mirror\/platform_frameworks_base\/blob\/master\/config\/hiddenapi-p-light-greylist.txt<\/a><\/p>\n<p><a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/github.com\/aosp-mirror\/platform_frameworks_base\/blob\/master\/config\/hiddenapi-light-greylist.txt\">https:\/\/github.com\/aosp-mirror\/platform_frameworks_base\/blob\/master\/config\/hiddenapi-light-greylist.txt<\/a><\/p>\n<p>\u4e4d\u4e00\u770baddAssetPath\u548cActivityThread\u90fd\u5728\u91cc\u9762\uff0c\u770b\u6765Atlas\u8fd8\u662f\u6709\u5e0c\u671b\u7684\uff0c\u4e0d\u8fc7Atlas\u7528\u7684\u53cd\u5c04\u6709\u8bb8\u591a\uff0c\u53ef\u4ee5\u5728Android P\u6a21\u62df\u5668\u4e0a\u8fd0\u884c\u4e0bAtlas Demo\u8bd5\u4e00\u8bd5<\/p>\n<h2>Atlas\u7684\u9002\u914d<\/h2>\n<p>\u73b0\u5728\u5b98\u7f51\u9ed8\u8ba4\u7684master\u5206\u652f\u4e0a\u7684demo\u8fd8\u6ca1\u6cd5\u8fd0\u884c\uff0c\u90a3\u662f\u56e0\u4e3ademo\u91cc\u53cd\u5c04\u8c03\u7528\u4e86hide api\u4e14light-greylist\u6ca1\u58f0\u660e\u7684api: <code>android.app.ActivityThread#performRestartActivity<\/code>\uff0c\u6240\u4ee5\u73b0\u5728\u8981\u8fd0\u884cdemo\u9700\u8981clone\u5206\u652fandroid_p<\/p>\n<pre><code>git clone https:\/\/github.com\/alibaba\/atlas.git -b android_p<\/code><\/pre>\n<p>\u8fd0\u884c\u540e\u53d1\u73b0\u6ca1\u6709\u5f02\u5e38\uff0c\u4f46hide api\u5728light greylist\u4e2d\uff0c\u8c03\u7528\u65f6\u4f1a\u6709\u8b66\u544a\uff0c\u8fd8\u597d\u5927\u90e8\u5206\u90fd\u53ef\u4ee5\u88ab\u53cd\u5c04\u8c03\u7528\u3002<\/p>\n<p>\u5f53\u7136\u4e5f\u6709\u5931\u8d25\u7684\u60c5\u51b5\uff0c\u4e0d\u8fc7\u90fd\u662f\u4e00\u4e9b\u517c\u5bb9\u6027\u5904\u7406\u7684\u53cd\u5c04\u8c03\u7528\uff0c\u4e0d\u4f1a\u5f71\u54cd\u5230\u6574\u4e2aAtlas\u7684\u6846\u67b6\u3002<\/p>\n<p>\u6240\u4ee5\u4ece\u76ee\u524d\u6765\u770bAtlas\u5728Android\u4e0d\u4f1a\u56e0\u4e3ahide api\u9650\u5236\u800c\u4f5c\u5e9f<\/p>\n<h2>hide api \u81ea\u76f8\u77db\u76fe\u7684\u73b0\u72b6<\/h2>\n<p>\u4e3a\u4ec0\u4e48Android\u4f1a\u5f00\u653e\u51falight greylist\u6765\u8fd0\u884c\u53cd\u5c04\u8c03\u7528hide api\u5462\uff1f\u4e3a\u4ec0\u4e48\u6ca1\u6cd5\u7acb\u5373\u6267\u884c\u8fd9\u4e2a\u9650\u5236\u5462\uff1f<\/p>\n<p>\u539f\u56e0\u5f88\u53ef\u80fd\u8fd8\u662fAndroid Studio\u4e2d\u9700\u8981\u4f7f\u7528\uff0cInstant Run\u662f\u4e3b\u8981\u4f7f\u7528\u8005\uff0c\u800cInstant Run\u8fd9\u79cd\u673a\u5236\u8fd8\u4e3b\u8981\u662f\u7528\u7684\u63d2\u4ef6\u5316\u7684\u601d\u60f3\u6765\u5b8c\u6210\u7684(\u4e0d\u6e05\u695a\u7684\u81ea\u884c\u767e\u5ea6instant run\u539f\u7406)\uff0cAtlas\u4e2d\u8c03\u7528\u7684\u5927\u90e8\u5206\u8fd8\u662fInstant Run\u9700\u8981\u7528\u7684\uff0c\u5982\u679cAndroid\u4e00\u5200\u5207\uff0c\u53ef\u80fd\u81ea\u5df1\u7684\u5de5\u5177\u4e5f\u4f1a\u906d\u6b83\uff0c\u6240\u4ee5\u8fd9\u4e2a\u662fAndroid hide api\u4e2d\u77db\u76fe\u7684\u73b0\u72b6\u3002<\/p>\n<h2>\u603b\u7ed3<\/h2>\n<p>\u63d2\u4ef6\u5316\u52a0\u8f7d\u7684\u6838\u5fc3\u8fd8\u662fDexClassLoader\u7684\u4f7f\u7528\u3002\u5c31\u7b97Android\u672a\u6765\u5220\u9664\u4e86light greylist\uff0c\u5c4f\u853d\u4e86\u6240\u6709\u7684hide api\uff0c\u53ea\u8981DexClassLoader\u53ef\u4ee5\u4f7f\u7528\uff0c\u6211\u4eec\u8fd8\u662f\u53ef\u4ee5\u5b9e\u73b0\u63d2\u4ef6\u5316\u5f00\u53d1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u81ea\u4eceAndroid P\/9.0\u540e\uff0cAndroid\u5c31\u5df2\u7ecf\u5f00\u59cb\u7740\u624b\u963b\u6b62App\u5f00\u53d1\u8c03\u7528\u975esdk\u7684api\uff0c\u4e5f\u5c31\u662f\u88ab\u6807\u8bb0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[275],"tags":[],"class_list":["post-1230","post","type-post","status-publish","format-standard","hentry","category-atlas"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1230","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1230"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1230\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1230"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1230"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1230"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}