1 /*
2  * Copyright (C) 2021 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.server.uwb.params;
18 
19 import com.android.server.uwb.UwbInjector;
20 
21 import com.google.uwb.support.aliro.AliroParams;
22 import com.google.uwb.support.base.Params;
23 import com.google.uwb.support.base.ProtocolVersion;
24 import com.google.uwb.support.ccc.CccParams;
25 import com.google.uwb.support.fira.FiraParams;
26 import com.google.uwb.support.generic.GenericParams;
27 import com.google.uwb.support.radar.RadarParams;
28 
29 public abstract class TlvDecoder {
getDecoder(String protocolName, UwbInjector uwbInjector)30     public static TlvDecoder getDecoder(String protocolName, UwbInjector uwbInjector) {
31         if (protocolName.equals(FiraParams.PROTOCOL_NAME)) {
32             return new FiraDecoder(uwbInjector);
33         }
34         if (protocolName.equals(CccParams.PROTOCOL_NAME)) {
35             return new CccDecoder(uwbInjector);
36         }
37         if (protocolName.equals(AliroParams.PROTOCOL_NAME)) {
38             return new AliroDecoder(uwbInjector);
39         }
40         if (protocolName.equals(RadarParams.PROTOCOL_NAME)) {
41             return new RadarDecoder();
42         }
43         if (protocolName.equals(GenericParams.PROTOCOL_NAME)) {
44             return new GenericDecoder(uwbInjector);
45         }
46         return null;
47     }
48 
getParams(TlvDecoderBuffer tlvs, Class<T> paramType, ProtocolVersion protocolVersion)49     public abstract <T extends Params> T getParams(TlvDecoderBuffer tlvs, Class<T> paramType,
50             ProtocolVersion protocolVersion);
51 }
52