mirror of
https://gitee.com/openharmony/applications_launcher
synced 2024-11-26 16:41:58 +00:00
回退async/await
Signed-off-by: zhengyongjie <15531316327@163.com>
This commit is contained in:
parent
3dc2bf9e88
commit
bd0f2b73c2
@ -50,17 +50,18 @@ class AmsMissionManager {
|
||||
* @return {Array} missions
|
||||
*/
|
||||
async getOriginRecentMissionsList(): Promise<Array<missionManager.MissionInfo>> {
|
||||
try {
|
||||
let arrayMissionInfo = new Array<missionManager.MissionInfo>();
|
||||
let res = await missionManager.getMissionInfos('', AmsMissionManager.RECENT_MISSIONS_LIMIT_NUM);
|
||||
if (!CheckEmptyUtils.isEmptyArr(res)) {
|
||||
Log.showDebug(TAG, `getOriginRecentMissionsList res.length: ${res.length}`);
|
||||
arrayMissionInfo = res;
|
||||
return arrayMissionInfo;
|
||||
}
|
||||
} catch (err) {
|
||||
Log.showError(TAG, `getOriginRecentMissionsList error: ${JSON.stringify(err)}`);
|
||||
}
|
||||
let missionInfos = new Array<missionManager.MissionInfo>();
|
||||
await missionManager.getMissionInfos('', AmsMissionManager.RECENT_MISSIONS_LIMIT_NUM)
|
||||
.then((res) => {
|
||||
if (!CheckEmptyUtils.isEmptyArr(res)) {
|
||||
Log.showDebug(TAG, `getOriginRecentMissionsList res.length: ${res.length}`);
|
||||
missionInfos = res;
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
Log.showError(TAG, `getOriginRecentMissionsList error: ${JSON.stringify(err)}`);
|
||||
});
|
||||
return missionInfos;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -148,12 +149,13 @@ class AmsMissionManager {
|
||||
*/
|
||||
async clearMission(missionId: number): Promise<void> {
|
||||
Log.showInfo(TAG, `clearMission Id:${missionId}`);
|
||||
try {
|
||||
await missionManager.clearMission(missionId);
|
||||
Log.showDebug(TAG, 'clearMission success');
|
||||
} catch (err) {
|
||||
Log.showError(TAG, `clearMission err:${JSON.stringify(err)}`);
|
||||
}
|
||||
await missionManager.clearMission(missionId)
|
||||
.then((data) => {
|
||||
Log.showDebug(TAG, `clearMission data:${JSON.stringify(data)}`);
|
||||
})
|
||||
.catch((err) => {
|
||||
Log.showError(TAG, `clearMission err:${JSON.stringify(err)}`);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -163,12 +165,13 @@ class AmsMissionManager {
|
||||
* @return nothing.
|
||||
*/
|
||||
async clearAllMissions(): Promise<void> {
|
||||
try {
|
||||
await missionManager.clearAllMissions();
|
||||
Log.showDebug(TAG, 'clearAllMissions success');
|
||||
} catch (err) {
|
||||
Log.showError(TAG, `clearAllMissions err: ${JSON.stringify(err)}`);
|
||||
}
|
||||
await missionManager.clearAllMissions()
|
||||
.then((data) => {
|
||||
Log.showDebug(TAG, `clearAllMissions data: ${JSON.stringify(data)}`);
|
||||
})
|
||||
.catch((err) => {
|
||||
Log.showError(TAG, `clearAllMissions err: ${JSON.stringify(err)}`);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -224,15 +227,22 @@ class AmsMissionManager {
|
||||
Log.showInfo(TAG, `getMissionSnapShot start! missionId: ${missionId}`);
|
||||
try {
|
||||
let missionSnapshot: missionManager.MissionSnapshot = null;
|
||||
missionSnapshot = await missionManager.getMissionSnapShot('', missionId);
|
||||
await missionManager.getMissionSnapShot('', missionId)
|
||||
.then((res) => {
|
||||
Log.showDebug(TAG, `getMissionSnapShot ${missionId} success ${JSON.stringify(res)}`);
|
||||
missionSnapshot = res;
|
||||
})
|
||||
.catch((err) => {
|
||||
Log.showError(TAG, `getMissionSnapShot error: ${JSON.stringify(err)}`);
|
||||
});
|
||||
const imageInfo = await missionSnapshot.snapshot.getImageInfo();
|
||||
Log.showDebug(TAG, `getMissionSnapShot ${missionId} success ${JSON.stringify(imageInfo)}`);
|
||||
Log.showDebug(TAG, `getMissionSnapShot success ${JSON.stringify(imageInfo)}`);
|
||||
snapShotInfo.missionId = missionId;
|
||||
snapShotInfo.snapShotImage = missionSnapshot.snapshot;
|
||||
snapShotInfo.snapShotImageWidth = imageInfo.size.width;
|
||||
snapShotInfo.snapShotImageHeight = imageInfo.size.height;
|
||||
} catch (err) {
|
||||
Log.showError(TAG, `missionManager.getMissionSnapShot, missionId:${missionId} err: ${JSON.stringify(err)}`);
|
||||
Log.showError(TAG, `missionManager.getMissionSnapShot err: ${err}`);
|
||||
}
|
||||
return snapShotInfo;
|
||||
}
|
||||
@ -244,13 +254,13 @@ class AmsMissionManager {
|
||||
*/
|
||||
async moveMissionToFront(missionId: number, winMode?: number) {
|
||||
Log.showInfo(TAG, `moveMissionToFront missionId: ${missionId}`);
|
||||
try {
|
||||
winMode ? await missionManager.moveMissionToFront(missionId, { windowMode: winMode }) :
|
||||
await missionManager.moveMissionToFront(missionId);
|
||||
Log.showDebug(TAG, 'moveMissionToFront missionId end success');
|
||||
} catch (err) {
|
||||
let promise = winMode ? missionManager.moveMissionToFront(missionId, { windowMode: winMode }) :
|
||||
missionManager.moveMissionToFront(missionId);
|
||||
const res = await promise.catch(err => {
|
||||
Log.showError(TAG, `moveMissionToFront err: ${JSON.stringify(err)}`);
|
||||
}
|
||||
});
|
||||
Log.showDebug(TAG, `moveMissionToFront missionId end: ${JSON.stringify(res)}`);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,9 +72,14 @@ class CommonBundleManager {
|
||||
entities : ['entity.system.home']
|
||||
};
|
||||
try {
|
||||
let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_WITH_APPLICATION;
|
||||
abilityList = await bundleManager.queryAbilityInfo(want, abilityFlags, this.mUserId);
|
||||
Log.showInfo(TAG, `getAllAbilityList success, abilityList length: ${abilityList.length}`);
|
||||
await bundleManager.queryAbilityInfo(want, bundleManager.AbilityFlag.GET_ABILITY_INFO_WITH_APPLICATION, this.mUserId)
|
||||
.then((res: Array<bundleManager.AbilityInfo>) => {
|
||||
Log.showInfo(TAG, `getAllAbilityList res length: ${res.length}`);
|
||||
abilityList = res;
|
||||
})
|
||||
.catch((err) => {
|
||||
Log.showError(TAG, `getAllAbilityList error: ${JSON.stringify(err)}`);
|
||||
});
|
||||
} catch (err) {
|
||||
Log.showError(TAG, `getAllAbilityList bundleManager.queryAbilityInfo error: ${JSON.stringify(err)}`);
|
||||
}
|
||||
@ -102,12 +107,18 @@ class CommonBundleManager {
|
||||
}
|
||||
let bundleInfo: bundleManager.BundleInfo = undefined;
|
||||
try {
|
||||
bundleInfo = await bundleManager.getBundleInfo(bundleName,
|
||||
await bundleManager.getBundleInfo(bundleName,
|
||||
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION |
|
||||
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE |
|
||||
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY,
|
||||
this.mUserId);
|
||||
Log.showInfo(TAG, `getBundleInfoByBundleName success, bundleInfo length:${bundleInfo?.hapModulesInfo.length}`);
|
||||
this.mUserId)
|
||||
.then((res: bundleManager.BundleInfo) => {
|
||||
Log.showInfo(TAG, `getBundleInfoByBundleName res:${JSON.stringify(res.hapModulesInfo.length)}`);
|
||||
bundleInfo = res;
|
||||
})
|
||||
.catch((err) => {
|
||||
Log.showError(TAG, `getBundleInfoByBundleName error: ${JSON.stringify(err)}, bundleName:${bundleName}`);
|
||||
});
|
||||
} catch (err) {
|
||||
Log.showError(TAG, `getBundleInfoByBundleName bundleManager.getBundleInfo error: ${JSON.stringify(err)}, bundleName:${bundleName}`);
|
||||
}
|
||||
@ -129,7 +140,7 @@ class CommonBundleManager {
|
||||
* @returns ability信息
|
||||
*/
|
||||
async getAbilityInfoByAbilityName(bundleName: string, abilityName: string,
|
||||
bundleType?: bundleManager.BundleType): Promise<bundleManager.AbilityInfo | undefined> {
|
||||
bundleType?: bundleManager.BundleType): Promise<bundleManager.AbilityInfo | undefined> {
|
||||
if (CheckEmptyUtils.checkStrIsEmpty(bundleName) || CheckEmptyUtils.checkStrIsEmpty(abilityName)) {
|
||||
Log.showError(TAG, 'getAbilityInfoByAbilityName reqParam bundleName or abilityName is empty');
|
||||
return undefined;
|
||||
@ -141,13 +152,16 @@ class CommonBundleManager {
|
||||
abilityName: abilityName
|
||||
};
|
||||
try {
|
||||
let res: Array<bundleManager.AbilityInfo>;
|
||||
let abilityFlags: bundleManager.AbilityFlag = bundleManager.AbilityFlag.GET_ABILITY_INFO_WITH_APPLICATION;
|
||||
res = await bundleManager.queryAbilityInfo(want, abilityFlags, this.mUserId);
|
||||
if (res !== undefined) {
|
||||
Log.showInfo(TAG, `getAbilityInfoByAbilityName success, res length: ${res.length}`);
|
||||
abilityList = res;
|
||||
}
|
||||
await bundleManager.queryAbilityInfo(want, bundleManager.AbilityFlag.GET_ABILITY_INFO_WITH_APPLICATION, this.mUserId)
|
||||
.then((res: Array<bundleManager.AbilityInfo>)=>{
|
||||
if (res !== undefined) {
|
||||
Log.showInfo(TAG, `getAbilityInfoByAbilityName res length: ${res.length}`);
|
||||
abilityList = res;
|
||||
}
|
||||
})
|
||||
.catch((err)=>{
|
||||
Log.showError(TAG, `getAbilityInfoByAbilityName error: ${JSON.stringify(err)}`);
|
||||
});
|
||||
} catch (err) {
|
||||
Log.showError(TAG, `getAbilityInfoByAbilityName bundleManager.queryAbilityInfo error: ${JSON.stringify(err)}`);
|
||||
}
|
||||
|
@ -35,13 +35,13 @@ export default class FileManager {
|
||||
|
||||
private async getBaseDir(): Promise<void> {
|
||||
const context = featureAbility.getContext();
|
||||
try {
|
||||
let data: string = await context.getFilesDir();
|
||||
Log.showDebug(TAG, `getFilesDir File directory obtained. Data: ${JSON.stringify(data)}`);
|
||||
this.baseDir = data + '/';
|
||||
} catch (err) {
|
||||
Log.showError(TAG, `getFilesDir Failed to obtain the file directory. Cause: ${JSON.stringify(err)}`);
|
||||
}
|
||||
await context.getFilesDir()
|
||||
.then((data) => {
|
||||
Log.showDebug(TAG, `getFilesDir File directory obtained. Data: ${JSON.stringify(data)}`);
|
||||
this.baseDir = data + '/';
|
||||
}).catch((error) => {
|
||||
Log.showError(TAG, `getFilesDir Failed to obtain the file directory. Cause: ${JSON.stringify(error)}`);
|
||||
});
|
||||
}
|
||||
|
||||
async getFileContent(fpath: string): Promise<string> {
|
||||
|
@ -116,7 +116,7 @@ class LauncherAbilityManager {
|
||||
*
|
||||
* @params listener: listening object
|
||||
*/
|
||||
async registerLauncherAbilityChangeListener(listener: any):Promise<void> {
|
||||
async registerLauncherAbilityChangeListener(listener: any):Promise<void> {
|
||||
if (listener != null) {
|
||||
if (this.mLauncherAbilityChangeListeners.length == 0) {
|
||||
try {
|
||||
@ -178,11 +178,13 @@ class LauncherAbilityManager {
|
||||
*/
|
||||
async getLauncherAbilityList(): Promise<AppItemInfo[]> {
|
||||
let abilityList = null;
|
||||
try {
|
||||
abilityList = await launcherBundleManager.getAllLauncherAbilityInfo(LauncherAbilityManager.CURRENT_USER_ID);
|
||||
} catch (err) {
|
||||
Log.showError(TAG, `getLauncherAbilityList error: ${JSON.stringify(err)}`);
|
||||
}
|
||||
await launcherBundleManager.getAllLauncherAbilityInfo(LauncherAbilityManager.CURRENT_USER_ID)
|
||||
.then((res) => {
|
||||
abilityList = res;
|
||||
})
|
||||
.catch((err) => {
|
||||
Log.showError(TAG, `getLauncherAbilityList error: ${JSON.stringify(err)}`);
|
||||
});
|
||||
const appItemInfoList = new Array<AppItemInfo>();
|
||||
if (CheckEmptyUtils.isEmpty(abilityList)) {
|
||||
Log.showDebug(TAG, 'getLauncherAbilityList Empty');
|
||||
@ -203,11 +205,13 @@ class LauncherAbilityManager {
|
||||
*/
|
||||
async getLauncherAbilityInfo(bundleName: string): Promise<AppItemInfo[]> {
|
||||
let abilityInfos: launcherBundleManager.LauncherAbilityInfo[];
|
||||
try {
|
||||
abilityInfos = await launcherBundleManager.getLauncherAbilityInfo(bundleName, this.mUserId);
|
||||
} catch (err) {
|
||||
Log.showError(TAG, `getLauncherAbilityInfo error: ${JSON.stringify(err)}`);
|
||||
}
|
||||
await launcherBundleManager.getLauncherAbilityInfo(bundleName, this.mUserId)
|
||||
.then((res) => {
|
||||
abilityInfos = res;
|
||||
})
|
||||
.catch((err) => {
|
||||
Log.showError(TAG, `getLauncherAbilityInfo error: ${JSON.stringify(err)}`);
|
||||
});
|
||||
const appItemInfoList = new Array<AppItemInfo>();
|
||||
if (CheckEmptyUtils.isEmpty(abilityInfos) || abilityInfos.length === 0) {
|
||||
Log.showDebug(TAG, 'getLauncherAbilityInfo Empty');
|
||||
@ -236,15 +240,15 @@ class LauncherAbilityManager {
|
||||
}
|
||||
// get from system
|
||||
let abilityInfos = new Array<launcherBundleManager.LauncherAbilityInfo>();
|
||||
try {
|
||||
let res: launcherBundleManager.LauncherAbilityInfo[];
|
||||
res = await launcherBundleManager.getLauncherAbilityInfo(bundleName, LauncherAbilityManager.CURRENT_USER_ID);
|
||||
if (res && res.length) {
|
||||
abilityInfos = res;
|
||||
}
|
||||
} catch (err) {
|
||||
Log.showError(TAG, `getAppInfoByBundleName getLauncherAbilityInfo error: ${JSON.stringify(err)}`);
|
||||
}
|
||||
await launcherBundleManager.getLauncherAbilityInfo(bundleName, LauncherAbilityManager.CURRENT_USER_ID)
|
||||
.then((res)=>{
|
||||
if (res && res.length) {
|
||||
abilityInfos = res;
|
||||
}
|
||||
})
|
||||
.catch((err)=>{
|
||||
Log.showError(TAG, `getAppInfoByBundleName getLauncherAbilityInfo error: ${JSON.stringify(err)}`);
|
||||
});
|
||||
if (!abilityInfos || abilityInfos.length === 0) {
|
||||
Log.showDebug(TAG, `${bundleName} has no launcher ability`);
|
||||
return undefined;
|
||||
@ -350,7 +354,7 @@ class LauncherAbilityManager {
|
||||
} else {
|
||||
Log.showDebug(TAG, `startApplication hiSysEvent write success: ${value}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
Log.showDebug(TAG, 'performanceMonitor begin');
|
||||
performanceMonitor.begin('LAUNCHER_APP_LAUNCH_FROM_ICON', performanceMonitor.ActionType.LAST_UP,
|
||||
paramBundleName);
|
||||
@ -369,9 +373,9 @@ class LauncherAbilityManager {
|
||||
abilityName: paramAbilityName,
|
||||
moduleName: paramModuleName,
|
||||
parameters:
|
||||
{
|
||||
formId: paramCardId.toString()
|
||||
}
|
||||
{
|
||||
formId: paramCardId.toString()
|
||||
}
|
||||
}).then((ret) => {
|
||||
Log.showDebug(TAG, `startAbility ret: ${JSON.stringify(ret)}`);
|
||||
}, (err) => {
|
||||
|
@ -83,17 +83,19 @@ export class FormModel {
|
||||
*/
|
||||
async getFormsInfoByBundleName(bundleName: string, callback?) {
|
||||
Log.showDebug(TAG, `getFormsInfoByBundleName bundleName: ${bundleName}`);
|
||||
let currentBundleFormsInfo: CardItemInfo[];
|
||||
try {
|
||||
currentBundleFormsInfo = await this.mFormManager.getFormsInfoByApp(bundleName);
|
||||
if (callback != undefined) {
|
||||
callback(bundleName, currentBundleFormsInfo);
|
||||
}
|
||||
AppStorage.setOrCreate('formMgrItem', currentBundleFormsInfo);
|
||||
return currentBundleFormsInfo;
|
||||
} catch (err) {
|
||||
Log.showError(TAG, `getFormsInfoByBundleName bundleName:${bundleName} err: ${JSON.stringify(err)}`);
|
||||
}
|
||||
let currentBundleFormsInfo: any;
|
||||
await this.mFormManager.getFormsInfoByApp(bundleName)
|
||||
.then(bundleFormsInfo => {
|
||||
currentBundleFormsInfo = bundleFormsInfo;
|
||||
if (callback != undefined) {
|
||||
callback(bundleName, bundleFormsInfo);
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
Log.showError(TAG, `getFormsInfoByBundleName err: ${JSON.stringify(err)}`);
|
||||
});
|
||||
AppStorage.setOrCreate('formMgrItem', currentBundleFormsInfo);
|
||||
return currentBundleFormsInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -132,7 +132,7 @@ export default class SmartDockModel {
|
||||
dockItemInfo.isSystemApp = typeof (dockDataList[i].isSystemApp) === 'undefined' ? true : dockDataList[i].isSystemApp;
|
||||
dockItemInfo.isUninstallAble = typeof (dockDataList[i].isUninstallAble) === 'undefined' ? true : dockDataList[i].isUninstallAble;
|
||||
dockItemInfo.badgeNumber = typeof (dockDataList[i].badgeNumber) === 'undefined' ?
|
||||
CommonConstants.BADGE_DISPLAY_HIDE : dockDataList[i].badgeNumber;
|
||||
CommonConstants.BADGE_DISPLAY_HIDE : dockDataList[i].badgeNumber;
|
||||
const loadAppName = await this.mResourceManager
|
||||
.getAppNameSync(dockItemInfo.appLabelId, dockItemInfo.bundleName, dockItemInfo.moduleName, '');
|
||||
dockItemInfo.appName = loadAppName;
|
||||
@ -295,7 +295,7 @@ export default class SmartDockModel {
|
||||
*/
|
||||
addToPageDesk(appInfo: DockItemInfo): void {
|
||||
if (appInfo.itemType == CommonConstants.TYPE_APP) {
|
||||
localEventManager.sendLocalEventSticky(EventConstants.EVENT_REQUEST_PAGEDESK_ITEM_ADD, appInfo);
|
||||
localEventManager.sendLocalEventSticky(EventConstants.EVENT_REQUEST_PAGEDESK_ITEM_ADD, appInfo).then(()=>{}, ()=>{});
|
||||
} else {
|
||||
Prompt.showToast({
|
||||
message: $r('app.string.disable_add_to_dock')
|
||||
|
Loading…
Reference in New Issue
Block a user