• 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.hardware.wifi.V1_0.NanCipherSuiteType;
20 import android.net.wifi.aware.Characteristics;
21 import android.os.Bundle;
22 
23 /**
24  * A container class for Aware (vendor) implementation capabilities (or
25  * limitations). Filled-in by the firmware.
26  */
27 public class Capabilities {
28     public int maxConcurrentAwareClusters;
29     public int maxPublishes;
30     public int maxSubscribes;
31     public int maxServiceNameLen;
32     public int maxMatchFilterLen;
33     public int maxTotalMatchFilterLen;
34     public int maxServiceSpecificInfoLen;
35     public int maxExtendedServiceSpecificInfoLen;
36     public int maxNdiInterfaces;
37     public int maxNdpSessions;
38     public int maxAppInfoLen;
39     public int maxQueuedTransmitMessages;
40     public int maxSubscribeInterfaceAddresses;
41     public int supportedCipherSuites;
42     public boolean isInstantCommunicationModeSupported;
43 
44     /**
45      * Converts the internal capabilities to a parcelable & potentially app-facing
46      * characteristics bundle. Only some of the information is exposed.
47      */
toPublicCharacteristics()48     public Characteristics toPublicCharacteristics() {
49         Bundle bundle = new Bundle();
50         bundle.putInt(Characteristics.KEY_MAX_SERVICE_NAME_LENGTH, maxServiceNameLen);
51         bundle.putInt(Characteristics.KEY_MAX_SERVICE_SPECIFIC_INFO_LENGTH,
52                 maxServiceSpecificInfoLen);
53         bundle.putInt(Characteristics.KEY_MAX_MATCH_FILTER_LENGTH, maxMatchFilterLen);
54         bundle.putInt(Characteristics.KEY_SUPPORTED_CIPHER_SUITES,
55                 toPublicCipherSuites(supportedCipherSuites));
56         bundle.putBoolean(Characteristics.KEY_IS_INSTANT_COMMUNICATION_MODE_SUPPORTED,
57                 isInstantCommunicationModeSupported);
58         return new Characteristics(bundle);
59     }
60 
toPublicCipherSuites(int nativeCipherSuites)61     private int toPublicCipherSuites(int nativeCipherSuites) {
62         int publicCipherSuites = 0;
63 
64         if ((nativeCipherSuites & NanCipherSuiteType.SHARED_KEY_128_MASK) != 0) {
65             publicCipherSuites |= Characteristics.WIFI_AWARE_CIPHER_SUITE_NCS_SK_128;
66         }
67         if ((nativeCipherSuites & NanCipherSuiteType.SHARED_KEY_256_MASK) != 0) {
68             publicCipherSuites |= Characteristics.WIFI_AWARE_CIPHER_SUITE_NCS_SK_256;
69         }
70 
71         return publicCipherSuites;
72     }
73 
74     @Override
toString()75     public String toString() {
76         return "Capabilities [maxConcurrentAwareClusters=" + maxConcurrentAwareClusters
77                 + ", maxPublishes=" + maxPublishes + ", maxSubscribes=" + maxSubscribes
78                 + ", maxServiceNameLen=" + maxServiceNameLen + ", maxMatchFilterLen="
79                 + maxMatchFilterLen + ", maxTotalMatchFilterLen=" + maxTotalMatchFilterLen
80                 + ", maxServiceSpecificInfoLen=" + maxServiceSpecificInfoLen
81                 + ", maxExtendedServiceSpecificInfoLen=" + maxExtendedServiceSpecificInfoLen
82                 + ", maxNdiInterfaces=" + maxNdiInterfaces + ", maxNdpSessions="
83                 + maxNdpSessions + ", maxAppInfoLen=" + maxAppInfoLen
84                 + ", maxQueuedTransmitMessages=" + maxQueuedTransmitMessages
85                 + ", maxSubscribeInterfaceAddresses=" + maxSubscribeInterfaceAddresses
86                 + ", supportedCipherSuites=" + supportedCipherSuites
87                 + ", isInstantCommunicationModeSupport=" + isInstantCommunicationModeSupported
88                 + "]";
89     }
90 }
91