7 Star 6 Fork 25

HuaweiCloudDeveloper / huaweicloud-cloudPhone-aosp9

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

华为云手机开源项目仓主入口

huaweicloud-cloudPhone-aosp9

介绍

云手机AOSP9开源代码,用于构建运行在华为云手机服务器的Android9镜像

软件架构

本软件基于AOSP 9.0.0_r76开发,支持修改以下路径中的源码

aosp/frameworks
aosp/packages
aosp/vendor

使用说明

1. 申请权限

请按照以下格式发送邮件,成功后可通过客户经理获取专属构建服务器地址和密钥

收件人:
  cphdeveloper@huawei.com
邮件标题:
  申请AOSP9自定义镜像构建权限
邮件内容:
  公司名称:
  联系人:
  联系电话:
  客户经理:
2. 准备开发环境

建议使用Ubuntu 18.04,并安装curl,git,gpg等常用软件,确保开发环境可以联网

3. 修改代码
3.1 fork本仓库,本地修改代码
建议:
1. 在aosp/vendor/common/android 目录下放置新增的代码文件或者预编译产物
2. 在aosp/vendor/common/products/product_extra.mk 中声明构建规则
3. 如无特殊需求,不要修改aosp/vendor目录下的其他文件,否则可能会对镜像的基本功能造成影响
3.2 提交代码,创建tag或branch
  • (必选)tag/branch即版本号,需满足命名规范,见7.版本管理
  • (可选)添加镜像构建账号

如果将代码仓设为私有,请将以下账户添加为只读成员,用于拉取代码和构建镜像

cphdeveloper@huawei.com
  • (可选)本地编译验证

如需本地验证是否存在编译错误,可拉取原生AOSP代码后,复制本地代码到原生目录,执行以下命令进行验证

lunch aosp_arm64-eng
make framework -j
4. 配置脚本

修改build.sh,其中SERVER_ADDR和KEY为在1.申请权限步骤中获取的专属构建服务器地址和密钥

BRANCH_TAG    代码的版本号,例如v1.2.1
KEY           专属构建密钥
IMG_NAME      自定义的镜像产物别名
SERVER_ADDR   专属构建服务器
5. 构建镜像

执行build.sh,支持以下参数

  • 全量构建

会清理中间产物,速度较慢,建议生产环境使用。

./build.sh
  • 增量构建

不清理中间产物,速度较快,建议仅用于调试阶段。

./build.sh -i
  • 查看构建日志

如果构建失败,可通过日志找到错误,修正后重新触发构建。

./build.sh -l

构建成功后,返回镜像ID

6. 自定义系统签名

使用公共的系统签名有安全风险,可通过以下步骤制作私有系统签名,加密后上传,构建系统可保证私有的系统签名不会泄露。

6.1 制作私有系统签名

制作环境:

Distributor ID: Ubuntu
Description:    Ubuntu 18.04.6 LTS
Release:        18.04
Codename:       bionic

请参考

https://android.googlesource.com/platform/build/+/refs/tags/android-security-9.0.0_r76/target/product/security/README

https://blog.csdn.net/langlitaojin/article/details/108045709

Step 1:生成 releasekey platform shared media testkey

cd /path/to/aosp/rootdir/

subject='/C=CN/ST=Guangdong/L=Shengzhen/O=${company}/OU=Compony/CN=AndroidTeam/emailAddress=mobile@${company}.com'
for x in releasekey platform shared media testkey; do
    rm build/target/product/security/${x}*
    ./development/tools/make_key build/target/product/security/$x "$subject"
done

Step 2:生成verity key

cd /path/to/aosp/rootdir/

make generate_verity_key

development/tools/make_key veritykey   '/C=CN/ST=Guangdong/L=Shengzhen/O=Huawei/OU=Compony/CN=AndroidTeam/emailAddress=mobile@huawei.com'

out/host/linux-x86/bin/generate_verity_key -convert veritykey.x509.pem verity_key

mv veritykey.pk8 ./build/target/product/security/veritykey.pk8
mv veritykey.x509.pem ./build/target/product/security/veritykey.x509.pem
mv verity_key.pub ./build/target/product/security/verity_key

生成keystore

cd /path/to/aosp/rootdir/

cd build/target/product/security

# 注意替换客户名
openssl pkcs8 -in platform.pk8 -inform DER -outform PEM -out shared.priv.pem -nocrypt
openssl pkcs12 -export -in platform.x509.pem -inkey shared.priv.pem -out shared.pk12 -name ${customer_name}-system-key

# 此时要求输入密码

keytool -importkeystore -deststorepass "${password}" -destkeypass "${password}" -destkeystore ${customer_name}-AOSP.keystore -srckeystore shared.pk12 -srcstoretype PKCS12 -srcstorepass "${password}" -alias ${customer_name}-system-key

tar cf ${customer_name}-keystore.tar shared.pk12 shared.priv.pem ${customer_name}-AOSP.keystore
6.2 获取定位SDK的Key

系统网络定位和地理编码接口通过一个系统App,集成定位SDK开发实现,且和当前系统签名绑定

根据系统签名申请Key,请参考 https://lbs.amap.com/api/android-location-sdk/guide/create-project/get-key/

系统App包名

com.cph.networklocation

获取安全码SHA1

keytool -printcert -file platform.x509.pem

获取到Key后,将其保存至文件amap_key中构建镜像即可。如果更新了系统签名,更换镜像时需要重置手机才生效。

6.3 打包加密私有系统签名文件

完成以上步骤后,将生成的所有文件放入security文件夹,security文件夹应包含以下文件

.
|-- amap_key
|-- media.pk8
|-- media.x509.pem
|-- platform.pk8
|-- platform.x509.pem
|-- releasekey.pk8
|-- releasekey.x509.pem
|-- shared.pk8
|-- shared.x509.pem
|-- testkey.pk8
|-- testkey.x509.pem
|-- verity_key
|-- veritykey.pk8
`-- veritykey.x509.pem

依次执行以下命令完成打包:

cd security
tar czvf security.tar.gz ./*

下载并导入gpg公钥

gpg --keyserver hkps://keyserver.ubuntu.com --recv-keys c5c7a35662a6f8080e27ab464a8e757d9b31879e

并设置公钥信任等级为5 = I trust ultimate

gpg --edit-key C5C7A35662A6F8080E27AB464A8E757D9B31879E
5

ctrl+D 退出gpg设置界面后执行

gpg --recipient C5C7A35662A6F8080E27AB464A8E757D9B31879E --output security.tar.gz.gpg --encrypt security.tar.gz
6.4 上传私有系统签名文件

将加密后的私有系统签名文件包提交到代码仓的以下路径:

/aosp/vendor/common/android/security/security.tar.gz.gpg
7. 版本管理

本仓库使用tag进行版本管理。命名规则如下,可在本仓库的标签页查看所有tag,例如

v1.0.0
v1.1.0
v1.2.0

fork自本仓库的代码也必须创建tag,前两位必须与本仓库的tag保持一致,用来表示其对应关系,第三位可以设置为任意数字,例如

v1.2.1

也支持使用branch方式替换tag

8. 与原仓库保持同步更新

如果在fork代码后,本仓库的代码又发生了更新,可以使用以下方法同步原仓库的更新。

8.1 进入本地仓库目录
8.2 设置upstream仓库
git remote add upstream git@gitee.com:HuaweiCloudDeveloper/huaweicloud-cloud-phone-aosp9.git

设置后通过以下命令进行查看

git remote -v

显示以下两行表示设置成功

upstream        git@gitee.com:HuaweiCloudDeveloper/huaweicloud-cloud-phone-aosp9.git (fetch)
upstream        git@gitee.com:HuaweiCloudDeveloper/huaweicloud-cloud-phone-aosp9.git (push)
8.3 执行命令git status检查本地是否有未提交的修改。如果有,则把你本地的有效修改,先从本地仓库推送到你gitee的仓库。最后再执行一次git status检查本地已无未提交的修改。
git add -A 或者 git add filename
git commit -m "your note"
git push origin master
git status
8.4 抓取原仓库的指定tag
git pull upstream tag v1.2.0
8.5 切换到master分支
git checkout master
8.6 合并upstream的master分支
git merge upstream/master
8.7 如有冲突,本地处理冲突后提交代码
8.8 创建tag
git tag -a v1.2.1 -m "update tag v1.2.1"
8.9 推送代码
git push --tags
9. 定制webview:将准备好的webview.apk放在aosp/vendor/common/external/webview/webview.apk目录,文件名字固定为webview.apk
10. 线下自定义镜像

支持线下自定义镜像部署;大致分以下三个步骤:

10.1 准备编译环境
10.2 编译环境配置

此处包含代码部署;代码结构主要分四个部分:

一是谷歌开源代码,该代码可以客户自行下载或者通过华为方提供的脚本(脚本下载见tools目录)下载;

二是编译构建执行脚本,该脚本华为方提供;

三是华为方gitee开源代码;

四是预编译包,该包由华为方提供;

代码部署环节可以华为方提供内容,客户自行安装部署,也可以通过obs桶自动安装部署,选择安装方案客户可以根据实际情况选择

10.3 执行构建脚本

详细内容见:https://gitee.com/HuaweiCloudDeveloper/huaweicloud-cloud-phone-aosp9/wikis/%E7%BA%BF%E4%B8%8B%E6%94%AF%E6%8C%81%E5%AE%A2%E6%88%B7%E6%9E%84%E5%BB%BA%E9%95%9C%E5%83%8F

11. 镜像管理

镜像管理API,包含支持查询镜像以及同region不同账号镜像共享功能:

https://support.huaweicloud.com/api-cph/cph_api_0559.html

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] 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.

简介

云手机AOSP9开源代码,用于构建运行在华为云手机服务器的Android9镜像 展开 收起
Java 等 6 种语言
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/HuaweiCloudDeveloper/huaweicloud-cloud-phone-aosp9.git
git@gitee.com:HuaweiCloudDeveloper/huaweicloud-cloud-phone-aosp9.git
HuaweiCloudDeveloper
huaweicloud-cloud-phone-aosp9
huaweicloud-cloudPhone-aosp9
master

搜索帮助