修复加密分享输入华为账号点击确认,概率卡在加密分享页面

Signed-off-by: pupupu <zhangfeiyu6@huawei.com>
This commit is contained in:
pupupu 2024-11-19 07:37:31 +00:00 committed by Gitee
parent 4a2685d5f0
commit 30cd09ecd9
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 24 additions and 21 deletions

View File

@ -2,8 +2,8 @@
"app": {
"bundleName": "com.ohos.dlpmanager",
"vendor": "example",
"versionCode": 1000121,
"versionName": "1.0.1.21",
"versionCode": 1000122,
"versionName": "1.0.1.22",
"icon": "$media:app_icon",
"label": "$string:app_name",
"minAPIVersion": 12,

View File

@ -16,8 +16,8 @@
"app": {
"bundleName": "com.ohos.dlpmanager",
"vendor": "example",
"versionCode": 1000121,
"versionName": "1.0.1.21",
"versionCode": 1000122,
"versionName": "1.0.1.22",
"icon": "$media:app_icon",
"label": "$string:app_name",
"minAPIVersion": 12,

View File

@ -24,10 +24,11 @@ const TAG = 'ConnectService';
export default class ConnectService {
private service: CredCallbackStub = new CredCallbackStub('CredCallbackStub');
private context: ESObject;
private connection = -1;
private optionsSearchUser: common.ConnectOptions;
private optionsGetAccount: common.ConnectOptions;
static connections = new Array<number>();
constructor(context: ESObject) {
this.context = context;
this.optionsSearchUser = {
@ -36,10 +37,10 @@ export default class ConnectService {
this.service.searchUserInfo(remote);
},
onDisconnect: () => {
HiLog.info(TAG, `onDisconnect`);
HiLog.info(TAG, `onDisconnect: SearchUser`);
},
onFailed: () => {
HiLog.info(TAG, `onFailed`);
HiLog.info(TAG, `onFailed: SearchUser`);
}
}
this.optionsGetAccount = {
@ -48,10 +49,10 @@ export default class ConnectService {
this.service.getAccountInfo(remote);
},
onDisconnect: () => {
HiLog.info(TAG, `onDisconnect`);
HiLog.info(TAG, `onDisconnect: GetAccount`);
},
onFailed: () => {
HiLog.info(TAG, `onFailed`);
HiLog.info(TAG, `onFailed: GetAccount`);
}
}
}
@ -62,25 +63,28 @@ export default class ConnectService {
bundleName: 'com.huawei.hmos.dlpcredmgr',
abilityName: 'DlpCredDataExtAbility',
};
let connectionId: number | undefined;
try {
switch (code) {
case Constants.COMMAND_SEARCH_USER_INFO: {
this.connection = this.context.connectServiceExtensionAbility(want, this.optionsSearchUser);
AppStorage.setOrCreate('connection', this.connection);
connectionId = this.context.connectServiceExtensionAbility(want, this.optionsSearchUser);
AppStorage.setOrCreate(`connection_${Constants.COMMAND_SEARCH_USER_INFO}`, connectionId);
break;
}
case Constants.COMMAND_GET_ACCOUNT_INFO: {
this.connection = this.context.connectServiceExtensionAbility(want, this.optionsGetAccount);
AppStorage.setOrCreate('connection', this.connection);
connectionId = this.context.connectServiceExtensionAbility(want, this.optionsGetAccount);
AppStorage.setOrCreate(`connection_${Constants.COMMAND_GET_ACCOUNT_INFO}`, connectionId);
break;
}
default: {
HiLog.error(TAG, `code is not exist ${code}`);
}
}
if (connectionId !== undefined) {
HiLog.info(TAG, `connectServiceExtAbility result: ${connectionId}`);
}
} catch (err) {
HiLog.error(TAG, `connectServiceExtAbility failed: ${JSON.stringify(err)}`);
}
HiLog.info(TAG, `connectServiceExtAbility result: ${this.connection}`);
}
}

View File

@ -54,7 +54,7 @@ export default class CredCallbackStub extends rpc.RemoteObject {
return false;
}
storage.setOrCreate('commandSearchUserInfo', resultVar);
this.disconnectServiceShareAbility();
this.disconnectServiceShareAbility(`connection_${Constants.COMMAND_SEARCH_USER_INFO}`);
return true;
}
case Constants.COMMAND_GET_ACCOUNT_INFO: {
@ -68,12 +68,11 @@ export default class CredCallbackStub extends rpc.RemoteObject {
return false;
}
storage.setOrCreate('commandGetAccountInfo', resultVar);
this.disconnectServiceShareAbility();
this.disconnectServiceShareAbility(`connection_${Constants.COMMAND_GET_ACCOUNT_INFO}`);
return true;
}
default: {
HiLog.error(TAG, `invalid request code: ${code}`);
this.disconnectServiceShareAbility();
break;
}
}
@ -130,12 +129,12 @@ export default class CredCallbackStub extends rpc.RemoteObject {
});
}
disconnectServiceShareAbility() {
HiLog.info(TAG, `disconnectServiceShareAbility: ${AppStorage.get('connection')}`);
let connectionNum: number | undefined = AppStorage.get('connection');
disconnectServiceShareAbility(connectionKey: string) {
let connectionId: number | undefined = AppStorage.get(connectionKey);
HiLog.info(TAG, `disconnectServiceShareAbility: ${connectionId}`);
let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
try {
context.disconnectServiceExtensionAbility(connectionNum);
context.disconnectServiceExtensionAbility(connectionId);
HiLog.info(TAG, `disconnectServiceExtensionAbility success.`);
} catch (error) {
HiLog.error(TAG, `disconnectServiceExtensionAbility failed. Error: ${JSON.stringify(error)}`);