亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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

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

功能描述

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

需求分析

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

實(shí)現(xiàn)思路

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

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

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

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

3、適配桌面支持的圖標(biāo)類型

loadWorkspace中,從數(shù)據(jù)庫中加載信息:
3.1、app folder 不需要適配
3.2、widget:
widget適配,參考默認(rèn)配置布局中從xml讀取數(shù)據(jù)庫,加載widget流程。
widget默認(rèn)布局能配置上去,就能從數(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會(huì)在系統(tǒng)中注冊(cè)信息
//我們需要根據(jù)數(shù)據(jù)庫里的內(nèi)容,手動(dòng)注冊(cè)到系統(tǒng),讓用戶重啟機(jī)器之后也能正常顯示
//1、查詢已經(jīng)注冊(cè)過的deepshortcut
List<ShortcutInfo> pinnedShortcuts = mShortcutManager.queryForPinnedShortcuts(null, user);
//根據(jù)數(shù)據(jù)庫key獲取pinnedShortcut,這里獲取不到,因?yàn)樾率謾C(jī)沒有注冊(cè)過
} 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,長按圖標(biāo)會(huì)彈出的那種
//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、向底層申請(qǐng)創(chuàng)建快捷方式createShortcutResultIntent的Intent
3、固定快捷方式createWorkspaceItemFromPinItemRequest
1 2 步驟正常應(yīng)該在setting中進(jìn)行,3在launcher中。

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

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

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

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

相關(guān)文章

最新評(píng)論