• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 #include "device_info_proxy.h"
16 
17 #include "beget_ext.h"
18 #include "idevice_info.h"
19 #include "parcel.h"
20 #include "string_ex.h"
21 
22 namespace OHOS {
23 namespace device_info {
GetUdid(std::string & result)24 int32_t DeviceInfoProxy::GetUdid(std::string& result)
25 {
26     MessageParcel data;
27     MessageParcel reply;
28     MessageOption option { MessageOption::TF_SYNC };
29     data.WriteInterfaceToken(DeviceInfoProxy::GetDescriptor());
30     int32_t ret = Remote()->SendRequest(COMMAND_GET_UDID, data, reply, option);
31     DINFO_CHECK(ret == ERR_NONE, return ret, "getUdid failed, error code is %d", ret);
32     result = Str16ToStr8(reply.ReadString16());
33     return ERR_OK;
34 }
35 
GetSerialID(std::string & result)36 int32_t DeviceInfoProxy::GetSerialID(std::string& result)
37 {
38     MessageParcel data;
39     MessageParcel reply;
40     MessageOption option { MessageOption::TF_SYNC };
41 
42     data.WriteInterfaceToken(DeviceInfoProxy::GetDescriptor());
43     int32_t ret = Remote()->SendRequest(COMMAND_GET_SERIAL_ID, data, reply, option);
44     DINFO_CHECK(ret == ERR_NONE, return ret, "GetSerial failed, error code is %d", ret);
45     result = Str16ToStr8(reply.ReadString16());
46     return ERR_OK;
47 }
48 } // namespace device_info
49 } // namespace OHOS
50