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