1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.server.uwb.data;
17 
18 import static com.google.uwb.support.radar.RadarParams.RADAR_DATA_TYPE_RADAR_SWEEP_SAMPLES;
19 
20 import java.util.Arrays;
21 
22 /** Container for UWB radar data based on the Android UWB Radar UCI specification v1.0. */
23 public class UwbRadarData {
24     public long sessionId;
25     public int statusCode;
26     public int radarDataType;
27     public int samplesPerSweep;
28     public int bitsPerSample;
29     public int sweepOffset;
30     public UwbRadarSweepData[] radarSweepData;
31 
UwbRadarData( long sessionId, int statusCode, int radarDataType, int samplesPerSweep, int bitsPerSample, int sweepOffset, UwbRadarSweepData[] radarSweepData)32     public UwbRadarData(
33             long sessionId,
34             int statusCode,
35             int radarDataType,
36             int samplesPerSweep,
37             int bitsPerSample,
38             int sweepOffset,
39             UwbRadarSweepData[] radarSweepData) {
40         this.sessionId = sessionId;
41         this.statusCode = statusCode;
42         this.radarDataType = radarDataType;
43         this.samplesPerSweep = samplesPerSweep;
44         this.bitsPerSample = bitsPerSample;
45         this.sweepOffset = sweepOffset;
46         this.radarSweepData = radarSweepData;
47     }
48 
49     @Override
toString()50     public String toString() {
51         if (radarDataType == RADAR_DATA_TYPE_RADAR_SWEEP_SAMPLES) {
52             return "UwbRadarData { "
53                     + " SessionId = "
54                     + sessionId
55                     + ", StatusCode = "
56                     + statusCode
57                     + ", RadarDataType = "
58                     + radarDataType
59                     + ", SamplesPerSweep = "
60                     + samplesPerSweep
61                     + ", BitsPerSample = "
62                     + bitsPerSample
63                     + ", SweepOffset = "
64                     + sweepOffset
65                     + ", RadarSweepData = "
66                     + Arrays.toString(radarSweepData)
67                     + '}';
68         } else {
69             return "Unknown uwb radar data type";
70         }
71     }
72 }
73