update hdcd_user_permit/src/main.cpp.

Signed-off-by: liupeng298 <liupeng298@huawei.com>
This commit is contained in:
liupeng298 2024-08-08 07:46:29 +00:00 committed by Gitee
parent ba7ff20686
commit 96ba3eefeb
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -26,13 +26,13 @@ using namespace OHOS;
using namespace OHOS::HDC::AUTH; using namespace OHOS::HDC::AUTH;
using namespace OHOS::AAFwk; using namespace OHOS::AAFwk;
static HdcdConnection *ConnectExtensionAbility(void) static sptr<HdcdConnection> ConnectExtensionAbility(void)
{ {
Want want; Want want;
string bundle; string bundle;
string ability; string ability;
auto con = new HdcdConnection(); sptr<HdcdConnection> con = new(std::nothrow) HdcdConnection();
if (!con) { if (!con) {
AUTH_LOGE("alloc mem failed"); AUTH_LOGE("alloc mem failed");
return nullptr; return nullptr;
@ -75,19 +75,13 @@ static int GetUserPermit(void)
} }
if (!con->GetShowDialogResult()) { if (!con->GetShowDialogResult()) {
AUTH_LOGE("show dialog failed"); AUTH_LOGE("show dialog failed");
delete con;
con = nullptr;
return USER_PERMIT_ERR_SHOW_DIALOG_FAIL; return USER_PERMIT_ERR_SHOW_DIALOG_FAIL;
} }
if (!WaitDialogResult()) { if (!WaitDialogResult()) {
AUTH_LOGE("wait ability result failed"); AUTH_LOGE("wait ability result failed");
delete con;
con = nullptr;
return USER_PERMIT_ERR_WAIT_DIALOG_FAIL; return USER_PERMIT_ERR_WAIT_DIALOG_FAIL;
} }
delete con;
con = nullptr;
return USER_PERMIT_SUCCESS; return USER_PERMIT_SUCCESS;
} }