diff options
Diffstat (limited to 'zh-cn/devices/tech/config/namespaces_libraries.html')
-rw-r--r-- | zh-cn/devices/tech/config/namespaces_libraries.html | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/zh-cn/devices/tech/config/namespaces_libraries.html b/zh-cn/devices/tech/config/namespaces_libraries.html new file mode 100644 index 00000000..acf8971c --- /dev/null +++ b/zh-cn/devices/tech/config/namespaces_libraries.html @@ -0,0 +1,51 @@ +<html devsite><head> + <title>原生库的命名空间</title> + <meta name="project_path" value="/_project.yaml"/> + <meta name="book_path" value="/_book.yaml"/> + </head> + <body> + <!-- + Copyright 2017 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --> + +<p> +Android 7.0 推出了针对原生库的命名空间,旨在限制内部 API 可见性,并解决应用在使用平台库(而非它们自己的库)时意外终止的问题。请参阅<a href="http://android-developers.blogspot.com/2016/06/improving-stability-with-private-cc.html">通过 Android 7.0 中的私有 C/C++ 符号限制提升稳定性</a>这篇 Android 开发者博文,了解针对应用的更改。</p> + +<h2 id="architecture">架构</h2> + +<p>这项更改会将系统库与应用库分离开来,这样可以极大地避免意外使用内部系统库(反之亦然)。 +</p> + +<img src="images/namespace-libraries.png" alt="原生库的命名空间" id="namespace-libraries"/> +<p class="img-caption"> + <strong>图 1.</strong> 原生库的命名空间</p> + +<p> +原生库的命名空间可防止应用使用私有平台的原生 API(例如使用 OpenSSL)。它还可以避免应用在使用平台库(而非它们自己的库)时出现意外终止的情况(如使用 <code>libpng</code> 时)。 +</p> + +<h2 id="adding-additional-native-libraries">添加其他原生库</h2> + +<p> +除了标准的公共原生库之外,供应商还可以选择提供可供应用访问的其他原生库,方法是将它们放在 <code>/vendor</code> 库文件夹(如果是 32 位的库,则为 /vendor/lib;如果是 64 位的库,则为 /vendor/lib64)下,并将其列于 <code>/vendor/etc/public.libraries.txt</code> 中 +</p> + +<h2 id="updating-app-non-public">将应用更新为不使用非公共原生库</h2> + +<p> +该功能仅适用于 SDK 版本为 24 或更高版本的应用;要了解向后兼容性,请参阅<a href="http://android-developers.blogspot.com/2016/06/improving-stability-with-private-cc.html">表 1. 当您的应用链接到非公共原生库时会发生什么情况</a>。可供应用访问的 Android 原生库(又称为公共原生库)列表列于 CDD 部分 3.1.1。适用于版本 24 或更高版本且使用任何非公共库的应用应进行更新。如需了解详情,请参阅<a href="https://developer.android.com/preview/behavior-changes.html#ndk">链接到平台库的 NDK 应用</a>。 +</p> + +</body></html>
\ No newline at end of file |