• AOSP10 替换系统launcher


    本文实现将原生的launcher 移除,替换成我们自己写的launcher。

    分以下几个步骤:

    一、新建一个自己的launcher项目。

    1.直接使用android studio 新建一个项目。

    2.修改AndroidManifest.xml 

    1. <application
    2. android:persistent="true"
    3. android:allowBackup="true"
    4. android:dataExtractionRules="@xml/data_extraction_rules"
    5. android:fullBackupContent="@xml/backup_rules"
    6. android:icon="@mipmap/ic_launcher"
    7. android:label="@string/app_name"
    8. android:roundIcon="@mipmap/ic_launcher_round"
    9. android:supportsRtl="true"
    10. android:theme="@style/Theme.AngeLauncher"
    11. tools:targetApi="31">
    12. <activity
    13. android:name=".MainActivity"
    14. android:exported="true"
    15. android:label="@string/app_name"
    16. android:theme="@style/Theme.AngeLauncher">
    17. <intent-filter>
    18. <action android:name="android.intent.action.MAIN" />
    19. <category android:name="android.intent.category.LAUNCHER" />
    20. <category android:name="android.intent.category.HOME" />
    21. <category android:name="android.intent.category.DEFAULT" />
    22. <category android:name="android.intent.category.MONKEY"/>
    23. <category android:name="android.intent.category.LAUNCHER_APP" />
    24. intent-filter>
    25. activity>
    26. application>

    2.生成系统的签名并添加到新建的launcher 项目中

    接着我们需要制作系统签名,这里使用 keytool-importkeypair 签名工具。

    keytool-importkeypair clone 到本地,并将其中的 keytool-importkeypair 文件添加到 PATH 路径。

    接着进入系统源码下的 build/target/product/security 路径,接着执行:

    keytool-importkeypair -k ./platform.keystore -p android -pk8 platform.pk8 -cert platform.x509.pem -alias platform
    

    k 表示要生成的 keystore 文件的名字,这里命名为 platform.keystore -p 表示要生成的 keystore 的密码,这里是 android -pk8 表示要导入的 platform.pk8 文件 -cert 表示要导入的platform.x509.pem -alias 表示给生成的 platform.keystore 取一个别名,这是命名为 platform

    接着,把生成的签名文件 platform.keystore 拷贝到 Android Studio 项目的 app 目录下,然后在 app/build.gradle 中添加签名的配置信息:

    1. signingConfigs {
    2. sign {
    3. storeFile file('platform.keystore')
    4. storePassword 'android'
    5. keyAlias = 'platform'
    6. keyPassword 'android'
    7. }
    8. }
    9. buildTypes {
    10. release {
    11. signingConfig signingConfigs.sign
    12. minifyEnabled false
    13. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    14. }
    15. }

    3.编译生成apk。

    二、添加product

    1.在device 目录下添加ange/lqa 文件夹,并新建文件 AndroidProducts.mk 

    1. PRODUCT_MAKEFILES := \
    2. $(LOCAL_DIR)/lqa.mk
    3. COMMON_LUNCH_CHOICES := \
    4. lqa-eng \
    5. lqa-userdebug \
    6. lqa-user \

    2.拷贝 build/target/board/generic_x86_64/BoardConfig.mk 到ange/lqa 文件夹下

    3.拷贝 build/target/product/aosp_x86_64.mk并重命名为lqa.mk到ange/lqa 文件夹下,并作修改如下:

    1. #
    2. # Copyright 2013 The Android Open-Source Project
    3. #
    4. # Licensed under the Apache License, Version 2.0 (the "License");
    5. # you may not use this file except in compliance with the License.
    6. # You may obtain a copy of the License at
    7. #
    8. # http://www.apache.org/licenses/LICENSE-2.0
    9. #
    10. # Unless required by applicable law or agreed to in writing, software
    11. # distributed under the License is distributed on an "AS IS" BASIS,
    12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13. # See the License for the specific language governing permissions and
    14. # limitations under the License.
    15. #
    16. PRODUCT_USE_DYNAMIC_PARTITIONS := true
    17. # The system image of aosp_x86_64-userdebug is a GSI for the devices with:
    18. # - x86 64 bits user space
    19. # - 64 bits binder interface
    20. # - system-as-root
    21. # - VNDK enforcement
    22. # - compatible property override enabled
    23. # This is a build configuration for a full-featured build of the
    24. # Open-Source part of the tree. It's geared toward a US-centric
    25. # build quite specifically for the emulator, and might not be
    26. # entirely appropriate to inherit from for on-device configurations.
    27. # GSI for system/product
    28. $(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
    29. $(call inherit-product, $(SRC_TARGET_DIR)/product/gsi_common.mk)
    30. # Emulator for vendor
    31. $(call inherit-product-if-exists, device/generic/goldfish/x86_64-vendor.mk)
    32. $(call inherit-product, $(SRC_TARGET_DIR)/product/emulator_vendor.mk)
    33. $(call inherit-product, $(SRC_TARGET_DIR)/board/generic_x86_64/device.mk)
    34. # Enable mainline checking for excat this product name
    35. #ifeq (aosp_x86_64,$(TARGET_PRODUCT))
    36. PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS := relaxed
    37. #endif
    38. PRODUCT_ARTIFACT_PATH_REQUIREMENT_WHITELIST += \
    39. root/init.zygote32_64.rc \
    40. root/init.zygote64_32.rc \
    41. # Copy different zygote settings for vendor.img to select by setting property
    42. # ro.zygote=zygote64_32 or ro.zygote=zygote32_64:
    43. # 1. 64-bit primary, 32-bit secondary OR
    44. # 2. 32-bit primary, 64-bit secondary
    45. # init.zygote64_32.rc is in the core_64_bit.mk below
    46. PRODUCT_COPY_FILES += \
    47. system/core/rootdir/init.zygote32_64.rc:root/init.zygote32_64.rc
    48. PRODUCT_NAME := lqa
    49. PRODUCT_DEVICE := lqa
    50. PRODUCT_BRAND := ange
    51. PRODUCT_MODEL := Android sdk build for x86_64 lqa
    52. PRODUCT_PACKAGES +=AngeLauncher

    三、在aosp10/packages/apps/ 下创建文件夹AngeLauncher  ,把编译好的apkf复制到该目录 ,命名为AngeLauncher.apk,并新增Android.mk 文件

    1. LOCAL_PATH := $(call my-dir)
    2. include $(CLEAR_VARS)
    3. LOCAL_MODULE := AngeLauncher
    4. LOCAL_MODULE_TAGS := optional
    5. LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
    6. LOCAL_MODULE_CLASS := APPS
    7. LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
    8. LOCAL_DEX_PREOPT := false
    9. USE_PLATFORM_LAUNCHER3 := false
    10. LOCAL_PRODUCT_MODULE := true
    11. LOCAL_OVERRIDES_PACKAGES := Home Launcher2 Launcher3 Launcher3Go Launcher3QuickStep
    12. LOCAL_CERTIFICATE := PRESIGNED
    13. include $(BUILD_PREBUILT)

    四、编译&运行

    1. source build/envsetup.sh
    2. lunch lqa-eng
    3. make -j4
    4. emulator

    启动后即可看到launcher已替换。

  • 相关阅读:
    【实操日记】使用 PyQt5 设计下载远程服务器日志文件程序
    路由策略简介
    高NA (数值孔径)物镜的分析
    quill富文本编辑器——修改默认图片、视频上传功能
    【Spark】spark中的thread.sleep
    云 ERP:企业业务增长的关键
    接口测试场景:怎么实现登录之后,需要进行昵称修改?
    [手写spring](5)实现AOP机制(完结)
    每天五分钟机器学习算法:拉格朗日乘数法和KKT条件
    [NAS] Synology (群晖) DSM相关服务及套件安装
  • 原文地址:https://blog.csdn.net/ange_li/article/details/136211839