• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include "ui_extension_ability_connection.h"
16 #include "ability_connect_callback_interface.h"
17 #include "ability_manager_client.h"
18 #include "iam_logger.h"
19 #include "widget_client.h"
20 
21 #define LOG_LABEL UserIam::Common::LABEL_USER_AUTH_SA
22 constexpr int32_t SIGNAL_NUM = 3;
23 
24 namespace OHOS {
25 namespace UserIam {
26 namespace UserAuth {
27 
OnAbilityConnectDone(const AppExecFwk::ElementName & element,const sptr<IRemoteObject> & remoteObject,int32_t resultCode)28 void UIExtensionAbilityConnection::OnAbilityConnectDone(const AppExecFwk::ElementName &element,
29     const sptr<IRemoteObject> &remoteObject, int32_t resultCode)
30 {
31     IAM_LOGI("on ability connected");
32     connectAbilityHitrace_ = nullptr;
33     MessageParcel data;
34     MessageParcel reply;
35     MessageOption option;
36     data.WriteInt32(SIGNAL_NUM);
37     data.WriteString16(u"bundleName");
38     data.WriteString16(u"com.ohos.useriam.authwidget");
39     data.WriteString16(u"abilityName");
40     data.WriteString16(u"userauthuiextensionability");
41     data.WriteString16(u"parameters");
42     data.WriteString16(Str8ToStr16(commandStr_));
43 
44     int32_t errCode = remoteObject->SendRequest(IAbilityConnection::ON_ABILITY_CONNECT_DONE, data, reply, option);
45     IAM_LOGI("AbilityConnectionWrapperProxy::OnAbilityConnectDone result %{public}d", errCode);
46 }
47 
OnAbilityDisconnectDone(const AppExecFwk::ElementName & element,int32_t resultCode)48 void UIExtensionAbilityConnection::OnAbilityDisconnectDone(const AppExecFwk::ElementName &element,
49     int32_t resultCode)
50 {
51     IAM_LOGI("on ability disconnected");
52     connectAbilityHitrace_ = nullptr;
53     WidgetClient::Instance().ForceStopAuth();
54 }
55 } // namespace UserAuth
56 } // namespace UserIam
57 } // namespace OHOS
58