1 /*
2 * Copyright (c) 2025 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 "sequenceable_posture_data.h"
17
18 #include "devicestatus_common.h"
19
20 namespace OHOS {
21 namespace Msdp {
22 namespace DeviceStatus {
Marshalling(Parcel & parcel) const23 bool SequenceablePostureData::Marshalling(Parcel &parcel) const
24 {
25 WRITEFLOAT(parcel, postureData_.rollRad, false);
26 WRITEFLOAT(parcel, postureData_.pitchRad, false);
27 WRITEFLOAT(parcel, postureData_.yawRad, false);
28 return true;
29 }
30
Unmarshalling(Parcel & parcel)31 SequenceablePostureData* SequenceablePostureData::Unmarshalling(Parcel &parcel)
32 {
33 auto postureData = new (std::nothrow) SequenceablePostureData();
34 if (postureData != nullptr && !postureData->ReadFromParcel(parcel)) {
35 FI_HILOGE("read from parcel is failed");
36 delete postureData;
37 postureData = nullptr;
38 }
39 return postureData;
40 }
41
ReadFromParcel(Parcel & parcel)42 bool SequenceablePostureData::ReadFromParcel(Parcel &parcel)
43 {
44 READFLOAT(parcel, postureData_.rollRad, false);
45 READFLOAT(parcel, postureData_.pitchRad, false);
46 READFLOAT(parcel, postureData_.yawRad, false);
47 return true;
48 }
49
GetPostureData()50 DevicePostureData SequenceablePostureData::GetPostureData()
51 {
52 return postureData_;
53 }
54
SetPostureData(const DevicePostureData & postureData)55 void SequenceablePostureData::SetPostureData(const DevicePostureData &postureData)
56 {
57 postureData_ = postureData;
58 }
59 } // namespace DeviceStatus
60 } // namespace Msdp
61 } // namespace OHOS