1 /* 2 * Copyright (c) 2022 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 "expired_callback_proxy.h" 17 18 #include <message_parcel.h> 19 20 #include "transient_task_log.h" 21 22 namespace OHOS { 23 namespace BackgroundTaskMgr { ExpiredCallbackProxy(const sptr<IRemoteObject> & impl)24ExpiredCallbackProxy::ExpiredCallbackProxy(const sptr<IRemoteObject>& impl) 25 : IRemoteProxy<IExpiredCallback>(impl) {} ~ExpiredCallbackProxy()26ExpiredCallbackProxy::~ExpiredCallbackProxy() {} 27 OnExpired()28void ExpiredCallbackProxy::OnExpired() 29 { 30 sptr<IRemoteObject> remote = Remote(); 31 if (remote == nullptr) { 32 BGTASK_LOGE("remote is dead."); 33 return; 34 } 35 36 MessageParcel data; 37 MessageParcel reply; 38 MessageOption option(MessageOption::TF_ASYNC); 39 bool res = data.WriteInterfaceToken(ExpiredCallbackProxy::GetDescriptor()); 40 if (!res) { 41 BGTASK_LOGE("write descriptor failed."); 42 return; 43 } 44 remote->SendRequest(ON_EXPIRED, data, reply, option); 45 } 46 } // namespace BackgroundTaskMgr 47 } // namespace OHOS