1 /*
2 * Copyright (c) 2021-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 "account_log_wrapper.h"
17
18 #include "os_account_event_stub.h"
19
20 namespace OHOS {
21 namespace AccountSA {
OsAccountEventStub()22 OsAccountEventStub::OsAccountEventStub()
23 {}
24
~OsAccountEventStub()25 OsAccountEventStub::~OsAccountEventStub()
26 {}
27
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)28 int OsAccountEventStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
29 {
30 if (data.ReadInterfaceToken() != GetDescriptor()) {
31 ACCOUNT_LOGE("check descriptor failed! code %{public}u.", code);
32 return ERR_ACCOUNT_COMMON_CHECK_DESCRIPTOR_ERROR;
33 }
34
35 switch (code) {
36 case static_cast<uint32_t>(IOsAccountEvent::Message::ACCOUNT_CHANGED): {
37 int id;
38 if (!data.ReadInt32(id)) {
39 ACCOUNT_LOGE("failed to read localId");
40 return ERR_OSACCOUNT_KIT_READ_IN_LOCAL_ID_ERROR;
41 }
42 OnAccountsChanged(id);
43 break;
44 }
45 default:
46 ACCOUNT_LOGI("default, code = %{public}u, flags = %{public}u", code, option.GetFlags());
47 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
48 }
49
50 return ERR_OK;
51 }
52 } // namespace AccountSA
53 } // namespace OHOS
54