1 // Copyright (C) 2024 Huawei Device Co., Ltd. 2 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // you may not use this file except in compliance with the License. 4 // You may obtain a copy of the License at 5 // 6 // http://www.apache.org/licenses/LICENSE-2.0 7 // 8 // Unless required by applicable law or agreed to in writing, software 9 // distributed under the License is distributed on an "AS IS" BASIS, 10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 use ipc::parcel::MsgParcel; 15 use ipc::remote::RemoteObj; 16 use ipc::{IpcResult, IpcStatusCode}; 17 18 use crate::error::ErrorCode; 19 use crate::service::RequestServiceStub; 20 21 impl RequestServiceStub { subscribe_run_count( &self, data: &mut MsgParcel, reply: &mut MsgParcel, ) -> IpcResult<()>22 pub(crate) fn subscribe_run_count( 23 &self, 24 data: &mut MsgParcel, 25 reply: &mut MsgParcel, 26 ) -> IpcResult<()> { 27 let pid = ipc::Skeleton::calling_pid(); 28 info!("Service run_count subscribe pid {}", pid); 29 30 let obj: RemoteObj = data.read_remote()?; 31 let ret = self.run_count_manager.subscribe_run_count(pid, obj); 32 33 reply.write(&(ret as i32))?; 34 if ret != ErrorCode::ErrOk { 35 error!("End Service run_count subscribe, failed:{}", ret as i32); 36 return Err(IpcStatusCode::Failed); 37 } 38 Ok(()) 39 } 40 } 41