1 /*
2 * Copyright (c) 2023 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_service_proxy.h"
17 #include "iremote_broker.h"
18 #include "oaid_common.h"
19 #include "oaid_service_interface.h"
20 #include "oaid_service_ipc_interface_code.h"
21
22 namespace OHOS {
23 namespace Cloud {
24 using namespace OHOS::HiviewDFX;
25
OAIDServiceProxy(const sptr<IRemoteObject> & object)26 OAIDServiceProxy::OAIDServiceProxy(const sptr<IRemoteObject>& object) : IRemoteProxy<IOAIDService>(object) {}
27
GetOAID()28 std::string OAIDServiceProxy::GetOAID()
29 {
30 OAID_HILOGI(OAID_MODULE_CLIENT, "GetOAID Begin.");
31 MessageParcel data, reply;
32 MessageOption option;
33
34 if (!data.WriteInterfaceToken(GetDescriptor())) {
35 OAID_HILOGE(OAID_MODULE_CLIENT, "Failed to write parcelable");
36 return "";
37 }
38
39 int32_t result = Remote()->SendRequest(static_cast<uint32_t>(OAIDInterfaceCode::GET_OAID), data, reply, option);
40 if (result != ERR_NONE) {
41 OAID_HILOGE(OAID_MODULE_CLIENT, "Get OAID failed, error code is: %{public}d", result);
42 return "";
43 }
44 auto oaid = reply.ReadString();
45
46 return oaid;
47 }
48
ResetOAID()49 void OAIDServiceProxy::ResetOAID()
50 {
51 OAID_HILOGI(OAID_MODULE_CLIENT, "Reset OAID Begin.");
52 MessageParcel data, reply;
53 MessageOption option;
54
55 if (!data.WriteInterfaceToken(GetDescriptor())) {
56 OAID_HILOGE(OAID_MODULE_CLIENT, "Failed to write parcelable");
57 }
58
59 int32_t result = Remote()->SendRequest(static_cast<uint32_t>(OAIDInterfaceCode::RESET_OAID), data, reply, option);
60 if (result != ERR_NONE) {
61 OAID_HILOGE(OAID_MODULE_CLIENT, "Reset OAID failed, error code is: %{public}d", result);
62 }
63 OAID_HILOGI(OAID_MODULE_CLIENT, "Reset OAID End.");
64 }
65 } // namespace Cloud
66 } // namespace OHOS