• 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 
52     /**
53      * Converts the internal capabilities to a parcelable & potentially app-facing
54      * characteristics bundle. Only some of the information is exposed.
55      */
toPublicCharacteristics(DeviceConfigFacade deviceConfigFacade)56     public Characteristics toPublicCharacteristics(DeviceConfigFacade deviceConfigFacade) {
57         Bundle bundle = new Bundle();
58         bundle.putInt(Characteristics.KEY_MAX_SERVICE_NAME_LENGTH, maxServiceNameLen);
59         bundle.putInt(Characteristics.KEY_MAX_SERVICE_SPECIFIC_INFO_LENGTH,
60                 maxServiceSpecificInfoLen);
61         bundle.putInt(Characteristics.KEY_MAX_MATCH_FILTER_LENGTH, maxMatchFilterLen);
62         bundle.putInt(Characteristics.KEY_SUPPORTED_DATA_PATH_CIPHER_SUITES,
63                 supportedDataPathCipherSuites);
64         bundle.putInt(Characteristics.KEY_SUPPORTED_PAIRING_CIPHER_SUITES,
65                 supportedPairingCipherSuites);
66         bundle.putBoolean(Characteristics.KEY_IS_INSTANT_COMMUNICATION_MODE_SUPPORTED,
67                 isInstantCommunicationModeSupported);
68         bundle.putInt(Characteristics.KEY_MAX_NDP_NUMBER, maxNdpSessions);
69         bundle.putInt(Characteristics.KEY_MAX_NDI_NUMBER, maxNdiInterfaces);
70         bundle.putInt(Characteristics.KEY_MAX_PUBLISH_NUMBER, maxPublishes);
71         bundle.putInt(Characteristics.KEY_MAX_SUBSCRIBE_NUMBER, maxSubscribes);
72         bundle.putBoolean(Characteristics.KEY_SUPPORT_NAN_PAIRING, isNanPairingSupported);
73         bundle.putBoolean(Characteristics.KEY_SUPPORT_SUSPENSION,
74                 deviceConfigFacade.isAwareSuspensionEnabled() && isSuspensionSupported);
75         return new Characteristics(bundle);
76     }
77 
toJSON()78     JSONObject toJSON() throws JSONException {
79         JSONObject j = new JSONObject();
80         j.put("maxConcurrentAwareClusters", maxConcurrentAwareClusters);
81         j.put("maxPublishes", maxPublishes);
82         j.put("maxSubscribes", maxSubscribes);
83         j.put("maxServiceNameLen", maxServiceNameLen);
84         j.put("maxMatchFilterLen", maxMatchFilterLen);
85         j.put("maxServiceSpecificInfoLen", maxServiceSpecificInfoLen);
86         j.put("maxExtendedServiceSpecificInfoLen", maxExtendedServiceSpecificInfoLen);
87         j.put("maxNdiInterfaces", maxNdiInterfaces);
88         j.put("maxNdpSessions", maxNdpSessions);
89         j.put("maxAppInfoLen", maxAppInfoLen);
90         j.put("maxQueuedTransmitMessages", maxQueuedTransmitMessages);
91         j.put("maxSubscribeInterfaceAddresses", maxSubscribeInterfaceAddresses);
92         j.put("supportedCipherSuites", supportedDataPathCipherSuites);
93         j.put("isInstantCommunicationModeSupported", isInstantCommunicationModeSupported);
94         j.put("isSetClusterIdSupported", isSetClusterIdSupported);
95         j.put("isNanPairingSupported", isNanPairingSupported);
96         j.put("isSuspensionSupported", isSuspensionSupported);
97         return j;
98     }
99 
100     @Override
toString()101     public String toString() {
102         return "Capabilities [maxConcurrentAwareClusters=" + maxConcurrentAwareClusters
103                 + ", maxPublishes=" + maxPublishes + ", maxSubscribes=" + maxSubscribes
104                 + ", maxServiceNameLen=" + maxServiceNameLen + ", maxMatchFilterLen="
105                 + maxMatchFilterLen + ", maxTotalMatchFilterLen=" + maxTotalMatchFilterLen
106                 + ", maxServiceSpecificInfoLen=" + maxServiceSpecificInfoLen
107                 + ", maxExtendedServiceSpecificInfoLen=" + maxExtendedServiceSpecificInfoLen
108                 + ", maxNdiInterfaces=" + maxNdiInterfaces + ", maxNdpSessions="
109                 + maxNdpSessions + ", maxAppInfoLen=" + maxAppInfoLen
110                 + ", maxQueuedTransmitMessages=" + maxQueuedTransmitMessages
111                 + ", maxSubscribeInterfaceAddresses=" + maxSubscribeInterfaceAddresses
112                 + ", supportedCipherSuites=" + supportedDataPathCipherSuites
113                 + ", isInstantCommunicationModeSupport=" + isInstantCommunicationModeSupported
114                 + ", isNanPairingSupported=" + isNanPairingSupported
115                 + ", isSetClusterIdSupported=" + isSetClusterIdSupported
116                 + ", isSuspensionSupported=" + isSuspensionSupported
117                 + "]";
118     }
119 }
120