Change launcher in AOSP 11

Viewed 507

I am building AOSP 11 for emulator x86_64 and trying to change Default Launcher with third party launcher.

I am using raspberry pi's launcher downloaded from here

when I manually compile this launcher and install using adb It works, like it gives prompt to choose launcher.

but I need to add in source code.

I have found that I need to override default launcher.

So I have modified raspberry pi's launcher's Android.bp file

  • add override section

  • add system_ext_specific: true.( because this is default launcher's path.)

     android_app {
     name: "RpLauncher",
     overrides: ["Home Launcher2 Launcher3 Launcher3QuickStep"],
     platform_apis: true,
     certificate: "platform",
     privileged: true,
     system_ext_specific: true,
    
     static_libs: [
       "androidx.legacy_legacy-support-v4",
       "androidx.recyclerview_recyclerview",
       "androidx.leanback_leanback",
       "kotlinx-coroutines-core",
     ],
    
     srcs: ["src/**/*.kt"],
     resource_dirs: ["res"],
    

    }

Added package name "RpLauncher" in build/target/product/handheld_system_ext.mk where default launcher(Launcher3QuickStep) package added.

PRODUCT_PACKAGES += \
Launcher3QuickStep \
Provision \
Settings \
StorageManager \
SystemUI \
WallpaperCropper \
RpLauncher \

After this when start the emulator only bootanimation appears and it never ends. Anyone have any idea about this ?

2 Answers

@Ashok Mutyala, thanks for your help.Now I can add launcher as privileged app Below are final changes

launcher's Android.bp

android_app {
name: "RpLauncher",
overrides: ["Home Launcher2 Launcher3 Launcher3QuickStep"],
platform_apis: true,
certificate: "platform",
privileged: true,
system_ext_specific: true,

static_libs: [
  "androidx.legacy_legacy-support-v4",
  "androidx.recyclerview_recyclerview",
  "androidx.leanback_leanback",
  "kotlinx-coroutines-core",
],

srcs: ["src/**/*.kt"],
resource_dirs: ["res"],
required: ["privapp_whitelist_com.arpi.rplauncher"],

}

create new file frameworks/base/data/etc/com.arpi.rplauncher.xml --> this is copy of frameworks/base/data/etc/com.android.launcher3.xml only change package name.

    <?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2019 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
  -->
<permissions>
    <privapp-permissions package="com.arpi.rplauncher">
        <permission name="android.permission.BIND_APPWIDGET"/>
        <permission name="android.permission.CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS"/>
        <permission name="android.permission.GET_ACCOUNTS_PRIVILEGED"/>
        <permission name="android.permission.WRITE_SECURE_SETTINGS"/>
    </privapp-permissions>
</permissions>

In frameworks/base/data/etc/Android.bp Add following.

prebuilt_etc {
    name: "privapp_whitelist_com.arpi.rplauncher",
    system_ext_specific: true,
    sub_dir: "permissions",
    src: "com.arpi.rplauncher.xml",
    filename_from_src: true,
}
Related