• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (c) 2025 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 
16 #include "ability_start_with_wait_observer_proxy.h"
17 
18 #include "hilog_tag_wrapper.h"
19 #include "parcel_util.h"
20 
21 namespace OHOS {
22 namespace AAFwk {
AbilityStartWithWaitObserverProxy(const sptr<IRemoteObject> & impl)23 AbilityStartWithWaitObserverProxy::AbilityStartWithWaitObserverProxy(const sptr<IRemoteObject> &impl)
24     : IRemoteProxy<IAbilityStartWithWaitObserver>(impl) {}
25 
WriteInterfaceToken(MessageParcel & data)26 bool AbilityStartWithWaitObserverProxy::WriteInterfaceToken(MessageParcel &data)
27 {
28     if (!data.WriteInterfaceToken(AbilityStartWithWaitObserverProxy::GetDescriptor())) {
29         TAG_LOGE(AAFwkTag::ABILITYMGR, "Write token failed");
30         return false;
31     }
32     return true;
33 }
34 
NotifyAATerminateWait(const AbilityStartWithWaitObserverData & abilityStartWithWaitObserverData)35 int32_t AbilityStartWithWaitObserverProxy::NotifyAATerminateWait(
36     const AbilityStartWithWaitObserverData &abilityStartWithWaitObserverData)
37 {
38     MessageParcel data;
39     MessageParcel reply;
40     MessageOption option(MessageOption::TF_ASYNC);
41     if (!WriteInterfaceToken(data)) {
42         TAG_LOGE(AAFwkTag::ABILITYMGR, "Write Token failed");
43         return ERR_FLATTEN_OBJECT;
44     }
45     if (!data.WriteParcelable(&abilityStartWithWaitObserverData)) {
46         TAG_LOGE(AAFwkTag::ABILITYMGR, "write abilityFirstFrameStateData failed");
47         return ERR_FLATTEN_OBJECT;
48     }
49     sptr<IRemoteObject> remote = Remote();
50     if (remote == nullptr) {
51         TAG_LOGE(AAFwkTag::ABILITYMGR, "null remote");
52         return ERR_NULL_OBJECT;
53     }
54 
55     int32_t ret = remote->SendRequest(
56         static_cast<uint32_t>(IAbilityStartWithWaitObserver::Message::NOTIFY_AA_TERMINATE_WAIT),
57         data, reply, option);
58     if (ret != NO_ERROR) {
59         TAG_LOGE(AAFwkTag::ABILITYMGR, "SendRequest error: %{public}d", ret);
60     }
61     return ret;
62 }
63 } // namespace AAFwk
64 } // namespace OHOS