1/* 2 * Copyright (c) 2021-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#include "user_callback_stub.h" 17 18#include "hilog_tag_wrapper.h" 19 20namespace OHOS { 21namespace AAFwk { 22UserCallbackStub::UserCallbackStub() {} 23 24int UserCallbackStub::OnStopUserDoneInner(MessageParcel &data, MessageParcel &reply) 25{ 26 auto accountId = data.ReadInt32(); 27 auto errCode = data.ReadInt32(); 28 OnStopUserDone(accountId, errCode); 29 return NO_ERROR; 30} 31 32int UserCallbackStub::OnStartUserDoneInner(MessageParcel &data, MessageParcel &reply) 33{ 34 auto accountId = data.ReadInt32(); 35 auto errCode = data.ReadInt32(); 36 OnStartUserDone(accountId, errCode); 37 return NO_ERROR; 38} 39 40int UserCallbackStub::OnRemoteRequest( 41 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) 42{ 43 std::u16string descriptor = UserCallbackStub::GetDescriptor(); 44 std::u16string remoteDescriptor = data.ReadInterfaceToken(); 45 if (descriptor != remoteDescriptor) { 46 TAG_LOGI(AAFwkTag::ABILITYMGR, "local descriptor invalid"); 47 return ERR_INVALID_STATE; 48 } 49 50 if (code < UserCallbackCmd::CMD_MAX && code >= 0) { 51 switch (code) { 52 case UserCallbackCmd::ON_STOP_USER_DONE: 53 return OnStopUserDoneInner(data, reply); 54 break; 55 case UserCallbackCmd::ON_START_USER_DONE: 56 return OnStartUserDoneInner(data, reply); 57 break; 58 } 59 } 60 61 return IPCObjectStub::OnRemoteRequest(code, data, reply, option); 62} 63} // namespace AAFwk 64} // namespace OHOS 65