欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android數(shù)據(jù)轉(zhuǎn)移之Launcher導(dǎo)出數(shù)據(jù)庫給另一臺機器加載

 更新時間:2021年11月04日 09:17:16   作者:縱容_伊人倩影  
這篇文章主要介紹了Android系統(tǒng)中Launcher導(dǎo)出數(shù)據(jù)庫給另一臺機器加載的詳細流程,數(shù)據(jù)轉(zhuǎn)移是少見但早晚要用到的功能,感興趣的朋友快來提前掌握吧

功能描述

1、導(dǎo)出當(dāng)前l(fā)auncher布局。
2、把布局文件拷貝到另一個機器。(模擬上傳下載服務(wù)器布局文件)
3、更新launcher布局。

需求分析

1、數(shù)據(jù)庫拷貝
2、導(dǎo)入數(shù)據(jù)庫
3、對桌面圖標進行分類:
app folder不需要修改,可以直接顯示;
widget、deepshortcut、1*1shortcut需要適配后才能顯示。

實現(xiàn)思路

1、導(dǎo)出launcher布局

只需要將launcher數(shù)據(jù)庫copy出去即可

2、導(dǎo)入數(shù)據(jù)庫

將數(shù)據(jù)庫文件copy到launcher data/data/包名/database/launcher.db
要注意的是,因為launcher在運行過程中,替換數(shù)據(jù)庫文件會導(dǎo)致舊的數(shù)據(jù)庫對象DatabaseHelper無法操作新數(shù)據(jù)庫,如果不做處理,再次操作數(shù)據(jù)庫會有crash;需要重新初始化數(shù)據(jù)庫對象或者重啟launcher,在數(shù)據(jù)庫初始化之前完成copy動作。

3、適配桌面支持的圖標類型

loadWorkspace中,從數(shù)據(jù)庫中加載信息:
3.1、app folder 不需要適配
3.2、widget:
widget適配,參考默認配置布局中從xml讀取數(shù)據(jù)庫,加載widget流程。
widget默認布局能配置上去,就能從數(shù)據(jù)庫中讀取包類名適配上去,只要保證他們走同一套流程即可。

case LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET:
//widget需要更新widgetID和widget status
if (copySuccess){
	c.restoreFlag = LauncherAppWidgetInfo.FLAG_ID_NOT_VALID |
	LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY |
	LauncherAppWidgetInfo.FLAG_DIRECT_CONFIG;
}

3.3、deep shortcut:

case LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT:
//deep shortcut會在系統(tǒng)中注冊信息
//我們需要根據(jù)數(shù)據(jù)庫里的內(nèi)容,手動注冊到系統(tǒng),讓用戶重啟機器之后也能正常顯示
//1、查詢已經(jīng)注冊過的deepshortcut
List<ShortcutInfo> pinnedShortcuts = mShortcutManager.queryForPinnedShortcuts(null, user);
//根據(jù)數(shù)據(jù)庫key獲取pinnedShortcut,這里獲取不到,因為新手機沒有注冊過
} else if (c.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
	ShortcutKey key = ShortcutKey.fromIntent(intent, c.user);
	if (unlockedUsers.get(c.serialNumber)) {
	ShortcutInfo pinnedShortcut =shortcutKeyToPinnedShortcuts.get(key);
//
//快捷方式分二種,manifest里寫的 CREATE_SHORTCUT,長按圖標會彈出的那種
//LauncherApps.ShortcutQuery.FLAG_MATCH_DYNAMIC
//LauncherApps.ShortcutQuery.FLAG_MATCH_MANIFEST
//LauncherApps.ShortcutQuery.FLAG_MATCH_PINNED
//固定界面的deepShortCut可以正常顯示,例如setting的BatterySaver,key為com.android.settings/manifest-shortcut-batterySaver#UserHandle{0}
//和
//widget列表里的1*1 未適配
if (pinnedShortcut == null && copySuccess){
    DeepShortcutManager sm = DeepShortcutManager.getInstance(context);
    List<ShortcutInfo> si = sm.queryForFullDetails(intent.getPackage(),null, c.user);
    shortcutKeyToPinnedShortcuts_copyDbFile.clear();
    Log.i(TAG,"key : "+key);
    for (ShortcutInfo shortcut : si) {
        ShortcutKey shortcutKey = ShortcutKey.fromInfo(shortcut);
        shortcutKeyToPinnedShortcuts_copyDbFile.put(shortcutKey,
                shortcut);
        Log.d(TAG,"shortcutKey : "+shortcutKey);
    }
    pinnedShortcut =
            shortcutKeyToPinnedShortcuts_copyDbFile.get(key);
    if (pinnedShortcut != null){
        copyDbFileNeedAddTo = true;
    }
}

//向底層綁定shortcut
com/tblenovo/launcher/model/BgDataModel.java
// Since this is a new item, pin the shortcut in the system server.
//ccsDeepShortCut need pinShortcut
if ((newItem || ccsDeepShortCUTItem) && count.value == 1) {
	DeepShortcutManager.getInstance(context).pinShortcut(pinnedShortcut);
}

3.4、11widget:
//widget列表里的1
1 未適配
長按添加setting中的1*1插件流程:
1、創(chuàng)建快捷方式屬性shortcutInfo
2、向底層申請創(chuàng)建快捷方式createShortcutResultIntent的Intent
3、固定快捷方式createWorkspaceItemFromPinItemRequest
1 2 步驟正常應(yīng)該在setting中進行,3在launcher中。

全部放在launcher中執(zhí)行,無法達到預(yù)期效果
啟動快捷方式時,需要根據(jù)包名和id進行啟動
如果是launcher的包名,只能打開設(shè)置主頁,無法跳到對應(yīng)的快捷方式界面。

1*1widget向底層綁定只是用pinShortcut是不行的,無法成功綁定。

//向系統(tǒng)注冊shortcut
//注冊失敗,會檢測包名和data中的包名
WorkspaceItemInfo infoinfo = LauncherAppsCompatVO.createWorkspaceItemFromPinItemRequest(
context, LauncherAppsCompatVO.getPinItemRequest(data), 0);
//再走上面的pinShortcut完成

到此這篇關(guān)于Android數(shù)據(jù)轉(zhuǎn)移之Launcher導(dǎo)出數(shù)據(jù)庫給另一臺機器加載的文章就介紹到這了,更多相關(guān)Android 數(shù)據(jù)轉(zhuǎn)移內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論