• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 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 
17 package com.android.ranging.rtt.backend;
18 
19 import android.net.wifi.rtt.RangingResult;
20 import android.util.Log;
21 
22 import androidx.annotation.NonNull;
23 
24 /**
25  * This class is transform class of RangingResult to fit with RttAdapter.
26  */
27 public class RttRangingPosition {
28     private static final String TAG = RttRangingPosition.class.getName();
29 
30     private double mDistanceMeters;
31     private long mRangingTimestampMillis;
32     private int mRssi;
33     Azimuth mAzimuth;
34     Elevation mElevation;
35 
36     /**
37      * Create Ranging Position for RTT from RangingResult
38      */
RttRangingPosition(@onNull RangingResult rangingResult)39     public RttRangingPosition(@NonNull RangingResult rangingResult) {
40         mDistanceMeters = rangingResult.getDistanceMm() / 1000.0;
41         mRssi = rangingResult.getRssi();
42         mAzimuth = null;
43         mElevation = null;
44         mRangingTimestampMillis = rangingResult.getRangingTimestampMillis();
45     }
46 
47     /**
48      * Gets distance in meter.
49      */
getDistanceMeters()50     public double getDistanceMeters() {
51         return mDistanceMeters;
52     }
53 
54     /**
55      * get Rssi Dbm
56      */
getRssiDbm()57     public int getRssiDbm() {
58         return mRssi;
59     }
60 
61     /**
62      * get Ranging Time stamp(Unit : ms)
63      */
getRangingTimestampMillis()64     public long getRangingTimestampMillis() {
65         return mRangingTimestampMillis;
66     }
67 
68     // WiFi RTT doesn't support Azimuth yet.
69 
70     /**
71      * get Azumith(Not supported yet)
72      */
getAzimuth()73     public Azimuth getAzimuth() {
74         Log.w(TAG, "Azimuth feature is not yet supported in WiFi RTT");
75         return mAzimuth;
76     }
77 
78     // WiFi RTT doesn't support Elevation yet.
79 
80     /**
81      * get Elevation(Not supported yet)
82      */
getElevation()83     public Elevation getElevation() {
84         Log.w(TAG, "Elevation feature is not yet supported in WiFi RTT");
85         return mElevation;
86     }
87 
88     /**
89      * Azimuth data(Not supported yet)
90      */
91     public static class Azimuth {
getValue()92         public int getValue() {
93             return 0;
94         }
95     }
96 
97     /**
98      * Elevation data(Not supported yet)
99      */
100     public static class Elevation {
getValue()101         public int getValue() {
102             return 0;
103         }
104     }
105 }
106