简体   繁体   English

如何在 AOSP 版本中设置默认启动器?

[英]How do I set the default launcher in an AOSP build?

I am modifying the AOSP source code because my app needs to run in a kiosk environment.我正在修改 AOSP 源代码,因为我的应用程序需要在自助服务终端环境中运行。

I want Android to boot directly into the app.我想让 Android 直接启动到应用程序中。 I've excluded launcher2 from generic_no_telephony.mk , and added the app there.我已经从generic_no_telephony.mk排除了launcher2 ,并在那里添加了应用程序。 Now Android prompts me all the time to choose default launcher .现在 Android 一直提示我选择默认启动器

The two choices that are available on the pop-up:弹出窗口中提供的两个选项:

  1. Home Sample家庭样品
  2. My app.我的应用程序。

How can I exclude the Android Home Sample Launcher?如何排除 Android Home Sample Launcher? Or is there another way to set the default launcher in an AOSP build?或者是否有另一种方法可以在 AOSP 版本中设置默认启动器?

Instead of modifying the AOSP make files (which is annoying because then you need to track your changes) it is easier to add a LOCAL_OVERRIDES_PACKAGES line to your app's make file.与修改 AOSP 生成文件(这很烦人,因为您需要跟踪更改)相比,将 LOCAL_OVERRIDES_PACKAGES 行添加到应用程序的生成文件会更容易。

For instance:例如:

LOCAL_OVERRIDES_PACKAGES := Launcher2 Launcher3

added to your Android.mk file will ensure that those packages are not added to any build where this package is added.添加到您的 Android.mk 文件将确保这些包不会添加到添加此包的任何构建中。

Following that, you should do a之后,你应该做一个

make installclean

and then start your build the same way you always make your build.然后以与您始终进行构建的方式相同的方式开始构建。 The make installclean is important to remove the packages that are left behind by the previous build. make installclean 对于删除先前构建留下的包很重要。

I also just found a nice answer to how to do this in another question, see: How would I make an embedded Android OS with just one app?我还在另一个问题中找到了一个很好的答案,说明如何做到这一点,请参阅: 如何仅使用一个应用程序制作嵌入式 Android 操作系统?

Unless you do the following steps, you will be prompted for selecting which home launcher you would like to choose.除非您执行以下步骤,否则系统会提示您选择要选择的家庭启动器。

If you would like to have your home launcher truly overwrite the others without having to delete the others from your build, follow these steps.如果您想让您的主启动器真正覆盖其他启动器,而不必从构建中删除其他启动器,请按照以下步骤操作。

Add an override for all other home launchers on your device, to your custom home launcher's Android.mk: (You may have others to override, but here's what were included in mine)将您设备上所有其他家庭启动器的覆盖添加到您的自定义家庭启动器的 Android.mk 中:(您可能需要覆盖其他人,但这是我的)

`LOCAL_OVERRIDES_PACKAGES := Home Launcher2 Launcher3`

Add your custom home launcher application module to the list of product packages.将您的自定义主页启动器应用程序模块添加到产品包列表中。 There are multiple files that add modules to the list of product packages.有多个文件将模块添加到产品包列表中。 They are located in...他们位于...

"/your-aosp-root/build/target/product/" “/your-aosp-root/build/target/product/”

The file I chose to edit and add my module to was "Core.mk".我选择编辑并将我的模块添加到的文件是“Core.mk”。

Add your module to the product packages list:将您的模块添加到产品包列表中:

    PRODUCT_PACKAGES += \
         BasicDreams \
         Browser \
         Calendar \
         .
         .
         .
         MmsService \
         YourModuleHere

Call this to clean out your out directory of any old modules/images(doesn't delete all of out directory):调用它来清除任何旧模块/图像的 out 目录(不会删除所有 out 目录):

make installclean

Call your build script调用您的构建脚本

The above answer is correct.上面的答案是正确的。 LOCAL_OVERRIDES_PACKAGES works. LOCAL_OVERRIDES_PACKAGES 有效。 But to address one of the comments;但要解决其中一项评论; I had to do LOCAL_OVERRIDES_PACKAGES := Home Launcher2 Launcher3我必须做 LOCAL_OVERRIDES_PACKAGES := Home Launcher2 Launcher3

Home is the sample Home app which serves as Launcher if Lancher2 is also not available. Home 是示例 Home 应用程序,如果 Lancher2 也不可用,它可用作启动器。

Only after removing these 3 stock launchers;只有在删除这 3 个股票发射器后; was I able to see my custom launcher launch by default without any dialog box asking user to choose.我是否能够在没有任何对话框要求用户选择的情况下看到我的自定义启动器默认启动。

(my test OS is Android N, ymmv) (我的测试操作系统是 Android N,ymmv)

对于Android Pie,我在Android.mk文件中添加了以下内容:

LOCAL_OVERRIDES_PACKAGES := Home Launcher2 Launcher3 Launcher3QuickStep

As first Answer does, But in Android 9 I use: LOCAL_OVERRIDES_PACKAGES := Home Launcher2 Launcher3 Launcher3QuickStep正如第一个答案一样,但在 Android 9 中我使用:LOCAL_OVERRIDES_PACKAGES := Home Launcher2 Launcher3 Launcher3QuickStep

And it works as expected.它按预期工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM