As mentioned in my previous blog, all the desktop item data of launcher is stored in the launcher. DB/favorites table.
When launcher is started, the loadeworkspace function will query all the data in the database and display it. The data loading process of this desktop item is described in detail in my blog launcher-startup process, in this blog, I will focus on adding, changing, and deleting launcher desktop items. Next I will go to the topic
1. Add launcher desktop items: From the Perspective of user operations, we can add desktop items in two ways.
-- 1. drag from the All app View to the desktop, and find out from the call stack below through launcherprovider. insert adds the dragged desktop item to the desktop and executes it at the end of the drag and drop (launcher2.workspace. ondrop ).
At com. Android. launcher2.launcherprovider. insert (launcherprovider. Java: 129)
At Android. content. contentprovider $ transport. insert (contentprovider. Java: 174)
At Android. content. contentresolver. insert (contentresolver. Java: 587)
At com. Android. launcher2.launchermodel. additemtodatabase (launchermodel. Java: 242)
At com. Android. launcher2.launchermodel. addormoveitemindatabase (launchermodel. Java: 133)
At com. Android. launcher2.workspace. ondropexternal (workspace. Java: 1203)
At com. Android. launcher2.workspace. ondropexternal (workspace. Java: 1165)
At com. Android. launcher2.workspace. ondrop (workspace. Java: 1125)
-- 2. open a dialog by pressing the desktop to add a desktop item, add a desktop item through the object box, and finally call the same method launcherprovider. insert to implement the operation, but the previous initiating action is different. It returns to launcher after the activity of the application is selected. onactivityresult.
At com. Android. launcher2.launcherprovider. insert (launcherprovider. Java: 129)
At Android. content. contentprovider $ transport. insert (contentprovider. Java: 174)
At Android. content. contentresolver. insert (contentresolver. Java: 587)
At com. Android. launcher2.launchermodel. additemtodatabase (launchermodel. Java: 242)
At com. Android. launcher2.launchermodel. addormoveitemindatabase (launchermodel. Java: 133)
At com. Android. launcher2.workspace. ondropexternal (workspace. Java: 1203)
At com. Android. launcher2.workspace. addapplicationshortcut (workspace. Java: 1117)
At com. Android. launcher2.launcher. completeaddapp (launcher. Java: 931)
At com. Android. launcher2.launcher. onactivityresult (launcher. Java: 579)
2. change of launcher desktop items: the change of the launcher desktop items only involves dragging the desktop items and changing the location of the desktop items. When the drag-and-drop operation ends, the launcherprovider is called. UPDATE function to modify launcher. the records in the DB/favorites table are used to change the location information of desktop items.
At com. Android. launcher2.launcherprovider. Update (launcherprovider. Java: 185)
At Android. content. contentprovider $ transport. Update (contentprovider. Java: 204)
At Android. content. contentresolver. Update (contentresolver. Java: 707)
At com. Android. launcher2.launchermodel. moveitemindatabase (launchermodel. Java: 159)
At com. Android. launcher2.workspace. ondrop (workspace. Java: 1144)
3. Delete the launcher desktop item: It will be executed when you drag the desktop item to the recycle bin. If you don't talk much about it, you will understand the call stack. deletezone is the constructor class corresponding to the Recycle Bin object.
At com. Android. launcher2.launcherprovider. Delete (launcherprovider. Java: 168)
At Android. content. contentprovider $ transport. Delete (contentprovider. Java: 198)
At Android. content. contentresolver. Delete (contentresolver. Java: 675)
At com. Android. launcher2.launchermodel. deleteitemfromdatabase (launchermodel. Java: 271)
At com. Android. launcher2.deletezone. ondrop (deletezone. Java: 123)