• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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.wifi.aware;
18 
19 import android.net.wifi.aware.Characteristics;
20 import android.os.Bundle;
21 
22 import com.android.server.wifi.DeviceConfigFacade;
23 
24 import org.json.JSONException;
25 import org.json.JSONObject;
26 
27 /**
28  * A container class for Aware (vendor) implementation capabilities (or
29  * limitations). Filled-in by the firmware.
30  */
31 public class Capabilities {
32     public int maxConcurrentAwareClusters;
33     public int maxPublishes;
34     public int maxSubscribes;
35     public int maxServiceNameLen;
36     public int maxMatchFilterLen;
37     public int maxTotalMatchFilterLen;
38     public int maxServiceSpecificInfoLen;
39     public int maxExtendedServiceSpecificInfoLen;
40     public int maxNdiInterfaces;
41     public int maxNdpSessions;
42     public int maxAppInfoLen;
43     public int maxQueuedTransmitMessages;
44     public int maxSubscribeInterfaceAddresses;
45     public int supportedDataPathCipherSuites;
46     public int supportedPairingCipherSuites;
47     public boolean isInstantCommunicationModeSupported;
48     public boolean isNanPairingSupported;
49     public boolean isSetClusterIdSupported;
50     public boolean isSuspensionSupported;
51     public boolean is6gSupported;
52     public boolean isHeSupported;
53     public boolean isPeriodicRangingSupported;
54     public int maxSupportedRangingPktBandWidth;
55     public int maxSupportedRxChains;
56 
57     /**
58      * Converts the internal capabilities to a parcelable & potentially app-facing
59      * characteristics bundle. Only some of the information is exposed.
60      */
toPublicCharacteristics(DeviceConfigFacade deviceConfigFacade)61     public Characteristics toPublicCharacteristics(DeviceConfigFacade deviceConfigFacade) {
62         Bundle bundle = new Bundle();
63         bundle.putInt(Characteristics.KEY_MAX_SERVICE_NAME_LENGTH, maxServiceNameLen);
64         bundle.putInt(
65                 Characteristics.KEY_MAX_SERVICE_SPECIFIC_INFO_LENGTH,
66                 Math.max(maxExtendedServiceSpecificInfoLen, maxServiceSpecificInfoLen));
67         bundle.putInt(Characteristics.KEY_MAX_MATCH_FILTER_LENGTH, maxMatchFilterLen);
68         bundle.putInt(Characteristics.KEY_SUPPORTED_DATA_PATH_CIPHER_SUITES,
69                 supportedDataPathCipherSuites);
70         bundle.putInt(Characteristics.KEY_SUPPORTED_PAIRING_CIPHER_SUITES,
71                 supportedPairingCipherSuites);
72         bundle.putBoolean(Characteristics.KEY_IS_INSTANT_COMMUNICATION_MODE_SUPPORTED,
73                 isInstantCommunicationModeSupported);
74         bundle.putInt(Characteristics.KEY_MAX_NDP_NUMBER, maxNdpSessions);
75         bundle.putInt(Characteristics.KEY_MAX_NDI_NUMBER, maxNdiInterfaces);
76         bundle.putInt(Characteristics.KEY_MAX_PUBLISH_NUMBER, maxPublishes);
77         bundle.putInt(Characteristics.KEY_MAX_SUBSCRIBE_NUMBER, maxSubscribes);
78         bundle.putBoolean(Characteristics.KEY_SUPPORT_NAN_PAIRING, isNanPairingSupported);
79         bundle.putBoolean(Characteristics.KEY_SUPPORT_SUSPENSION,
80                 deviceConfigFacade.isAwareSuspensionEnabled() && isSuspensionSupported);
81         bundle.putBoolean(Characteristics.KEY_SUPPORT_PERIODIC_RANGING, isPeriodicRangingSupported);
82         bundle.putInt(Characteristics.KEY_MAX_SUPPORTED_RANGING_PKT_BANDWIDTH,
83                 maxSupportedRangingPktBandWidth);
84         bundle.putInt(Characteristics.KEY_MAX_SUPPORTED_RX_CHAINS, maxSupportedRxChains);
85         return new Characteristics(bundle);
86     }
87 
toJSON()88     JSONObject toJSON() throws JSONException {
89         JSONObject j = new JSONObject();
90         j.put("maxConcurrentAwareClusters", maxConcurrentAwareClusters);
91         j.put("maxPublishes", maxPublishes);
92         j.put("maxSubscribes", maxSubscribes);
93         j.put("maxServiceNameLen", maxServiceNameLen);
94         j.put("maxMatchFilterLen", maxMatchFilterLen);
95         j.put("maxServiceSpecificInfoLen", maxServiceSpecificInfoLen);
96         j.put("maxExtendedServiceSpecificInfoLen", maxExtendedServiceSpecificInfoLen);
97         j.put("maxNdiInterfaces", maxNdiInterfaces);
98         j.put("maxNdpSessions", maxNdpSessions);
99         j.put("maxAppInfoLen", maxAppInfoLen);
100         j.put("maxQueuedTransmitMessages", maxQueuedTransmitMessages);
101         j.put("maxSubscribeInterfaceAddresses", maxSubscribeInterfaceAddresses);
102         j.put("supportedCipherSuites", supportedDataPathCipherSuites);
103         j.put("isInstantCommunicationModeSupported", isInstantCommunicationModeSupported);
104         j.put("isSetClusterIdSupported", isSetClusterIdSupported);
105         j.put("isNanPairingSupported", isNanPairingSupported);
106         j.put("isSuspensionSupported", isSuspensionSupported);
107         j.put("isPeriodicRangingSupported", isPeriodicRangingSupported);
108         j.put("maxSupportedRangingPktBandWidth", maxSupportedRangingPktBandWidth);
109         j.put("maxSupportedRxChains", maxSupportedRxChains);
110         return j;
111     }
112 
113     @Override
toString()114     public String toString() {
115         return "Capabilities [maxConcurrentAwareClusters="
116                 + maxConcurrentAwareClusters
117                 + ", maxPublishes="
118                 + maxPublishes
119                 + ", maxSubscribes="
120                 + maxSubscribes
121                 + ", maxServiceNameLen="
122                 + maxServiceNameLen
123                 + ", maxMatchFilterLen="
124                 + maxMatchFilterLen
125                 + ", maxTotalMatchFilterLen="
126                 + maxTotalMatchFilterLen
127                 + ", maxServiceSpecificInfoLen="
128                 + maxServiceSpecificInfoLen
129                 + ", maxExtendedServiceSpecificInfoLen="
130                 + maxExtendedServiceSpecificInfoLen
131                 + ", maxNdiInterfaces="
132                 + maxNdiInterfaces
133                 + ", maxNdpSessions="
134                 + maxNdpSessions
135                 + ", maxAppInfoLen="
136                 + maxAppInfoLen
137                 + ", maxQueuedTransmitMessages="
138                 + maxQueuedTransmitMessages
139                 + ", maxSubscribeInterfaceAddresses="
140                 + maxSubscribeInterfaceAddresses
141                 + ", supportedCipherSuites="
142                 + supportedDataPathCipherSuites
143                 + ", isInstantCommunicationModeSupport="
144                 + isInstantCommunicationModeSupported
145                 + ", isNanPairingSupported="
146                 + isNanPairingSupported
147                 + ", isSetClusterIdSupported="
148                 + isSetClusterIdSupported
149                 + ", isSuspensionSupported="
150                 + isSuspensionSupported
151                 + ", is6gSupported="
152                 + is6gSupported
153                 + ", isHeSupported="
154                 + isHeSupported
155                 + ", isPeriodicRangingSupported="
156                 + isPeriodicRangingSupported
157                 + ", maxSupportedRangingPktBandWidth="
158                 + maxSupportedRangingPktBandWidth
159                 + ",maxSupportedRxChains="
160                 + maxSupportedRxChains
161                 + "]";
162     }
163 }
164