1 /*
2  * Copyright (C) 2022 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.pm;
18 
19 import static com.android.server.uwb.data.UwbConfig.CENTRAL;
20 import static com.android.server.uwb.data.UwbConfig.CONTROLEE_AND_RESPONDER;
21 import static com.android.server.uwb.data.UwbConfig.CONTROLLER_AND_INITIATOR;
22 import static com.android.server.uwb.data.UwbConfig.OOB_TYPE_BLE;
23 import static com.android.server.uwb.data.UwbConfig.PERIPHERAL;
24 
25 import static com.google.uwb.support.fira.FiraParams.MULTI_NODE_MODE_ONE_TO_MANY;
26 import static com.google.uwb.support.fira.FiraParams.RFRAME_CONFIG_SP1;
27 import static com.google.uwb.support.fira.FiraParams.RFRAME_CONFIG_SP3;
28 import static com.google.uwb.support.fira.FiraParams.STS_CONFIG_DYNAMIC;
29 import static com.google.uwb.support.fira.FiraParams.STS_CONFIG_DYNAMIC_FOR_CONTROLEE_INDIVIDUAL_KEY;
30 import static com.google.uwb.support.fira.FiraParams.STS_CONFIG_PROVISIONED_FOR_CONTROLEE_INDIVIDUAL_KEY;
31 
32 
33 import com.android.server.uwb.data.UwbConfig;
34 
35 public class PacsProfile {
36 
37     /** PACS Controlee config */
38     private static UwbConfig sControlee;
39 
40     /** PACS controller config */
41     private static UwbConfig sController;
42 
43     private static UwbConfig sControleeForDynamicSts;
44 
45     private static UwbConfig sControleeForProvisionedSts;
46 
getPacsControleeProfile()47     public static UwbConfig getPacsControleeProfile() {
48         if (sControlee == null) {
49             UwbConfig.Builder builder = new UwbConfig.Builder();
50             sControlee = builder
51                     .setUwbRole(CONTROLEE_AND_RESPONDER)
52                     .setStsConfig(STS_CONFIG_DYNAMIC)
53                     .setMultiNodeMode(MULTI_NODE_MODE_ONE_TO_MANY)
54                     .setRframeConfig(RFRAME_CONFIG_SP3)
55                     .setTofReport(true)
56                     .setOobType(OOB_TYPE_BLE)
57                     .setOobBleRole(PERIPHERAL)
58                     .build();
59         }
60         return sControlee;
61     }
62 
63     /** Used for testing, only PACS controlee profile is supported for applications */
getPacsControllerProfile()64     public static UwbConfig getPacsControllerProfile() {
65         if (sController == null) {
66             UwbConfig.Builder builder = new UwbConfig.Builder();
67             sController = builder
68                     .setUwbRole(CONTROLLER_AND_INITIATOR)
69                     .setStsConfig(STS_CONFIG_DYNAMIC)
70                     .setMultiNodeMode(MULTI_NODE_MODE_ONE_TO_MANY)
71                     .setRframeConfig(RFRAME_CONFIG_SP3)
72                     .setTofReport(true)
73                     .setOobType(OOB_TYPE_BLE)
74                     .setOobBleRole(CENTRAL)
75                     .build();
76         }
77         return sController;
78     }
79 
80     /**
81       * Used for testing, PACS controlee profile for
82       * STS_CONFIG_DYNAMIC_FOR_CONTROLEE_INDIVIDUAL_KEY.
83       */
getPacsControlleeProfileForDynamicStsInd()84     public static UwbConfig getPacsControlleeProfileForDynamicStsInd() {
85         if (sControleeForDynamicSts == null) {
86             UwbConfig.Builder builder = new UwbConfig.Builder();
87             sControleeForDynamicSts = builder
88                     .setUwbRole(CONTROLEE_AND_RESPONDER)
89                     .setStsConfig(STS_CONFIG_DYNAMIC_FOR_CONTROLEE_INDIVIDUAL_KEY)
90                     .setMultiNodeMode(MULTI_NODE_MODE_ONE_TO_MANY)
91                     .setRframeConfig(RFRAME_CONFIG_SP1)
92                     .setTofReport(true)
93                     .setOobType(OOB_TYPE_BLE)
94                     .setOobBleRole(CENTRAL)
95                     .build();
96         }
97         return sControleeForDynamicSts;
98     }
99 
100     /**
101       * Used for testing, PACS controlee profile for
102       * STS_CONFIG_PROVISIONED_FOR_CONTROLEE_INDIVIDUAL_KEY.
103       */
getPacsControlleeProfileForProvSTSInd()104     public static UwbConfig getPacsControlleeProfileForProvSTSInd() {
105         if (sControleeForProvisionedSts == null) {
106             UwbConfig.Builder builder = new UwbConfig.Builder();
107             sControleeForProvisionedSts = builder
108                     .setUwbRole(CONTROLEE_AND_RESPONDER)
109                     .setStsConfig(STS_CONFIG_PROVISIONED_FOR_CONTROLEE_INDIVIDUAL_KEY)
110                     .setMultiNodeMode(MULTI_NODE_MODE_ONE_TO_MANY)
111                     .setRframeConfig(RFRAME_CONFIG_SP1)
112                     .setTofReport(true)
113                     .setOobType(OOB_TYPE_BLE)
114                     .setOobBleRole(CENTRAL)
115                     .build();
116         }
117         return sControleeForProvisionedSts;
118     }
119 }
120