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 #include "oaid_remote_config_observer_stub.h"
17 #include "oaid_common.h"
18
19 namespace OHOS {
20 namespace Cloud {
21
RemoteConfigObserverStub()22 RemoteConfigObserverStub::RemoteConfigObserverStub()
23 {}
24
~RemoteConfigObserverStub()25 RemoteConfigObserverStub::~RemoteConfigObserverStub()
26 {}
27
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)28 int32_t RemoteConfigObserverStub::OnRemoteRequest(
29 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
30 {
31 std::string bundleName;
32 std::u16string descriptor = RemoteConfigObserverStub::GetDescriptor();
33 std::u16string remoteDescriptor = data.ReadInterfaceToken();
34 if (descriptor != remoteDescriptor) {
35 OAID_HILOGE(OAID_MODULE_SERVICE, "read descriptor failed.");
36 return ERR_INVALID_PARAM;
37 }
38 switch (code) {
39 case static_cast<uint32_t>(RegisterObserverCode::OnOaidUpdated): {
40 return HandleOAIDUpdate(data, reply);
41 }
42 default:
43 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
44 }
45 }
46
HandleOAIDUpdate(MessageParcel & data,MessageParcel & reply)47 int32_t RemoteConfigObserverStub::HandleOAIDUpdate(MessageParcel &data, MessageParcel &reply)
48 {
49 std::string oaid;
50 if (!data.ReadString(oaid)) {
51 OAID_HILOGE(OAID_MODULE_SERVICE, "parcel read value failed.");
52 return ERR_INVALID_PARAM;
53 }
54 OnOaidUpdated(oaid);
55 return ERR_OK;
56 }
57 } // namespace Cloud
58 } // namespace OHOS