How are the default AOSP launcher shortcuts instal

2019-07-23 03:55发布

问题:

I'm building my own version of AOSP (using code from the Code Aurora repos for a custom device) and trying to determine how shortcuts to certain apps are being added automatically to the launcher's db (Launcher3 on Marshmallow to be more specific). I want to change these around and remove/reposition some of them. (In this particular instance the apps in question are those from the GMS suite.)

I understand that apps can try to get their shortcuts onto the launcher's workspace by sending a ACTION_CREATE_SHORTCUT intent. Are some of these apps sending these intents after first boot but before the launcher launches for the first time?

I couldn't find any steps or code that adds these values to the db as a prestep at build time.

回答1:

What you're looking for is the "workspace" of the launcher which located under platform/packages/apps/Launcher3/res/xml/default_workspace_*.xml.(here)
You will notice there are different workspace for different screen sizes (e.g 4X4 / 5X5 / 5X6).
To add new apps just add the next tag:

<favorite
    launcher:packageName="com.android.gallery3d" //Your app name
    launcher:className="com.android.gallery3d.app.Gallery" // Your launcher Activity
    launcher:screen="3" // The screen number
    launcher:x="1" // X Location on screen
    launcher:y="3" /> // Y Location on screen

Xml tags -
1. favorite - Specific app.
2. resolve - Resolve default app (e.g default messages app)
3. appwidget - Widget...

AOSP original link