summaryrefslogtreecommitdiffstats
path: root/wifi/java/android/net/wifi/passpoint/PasspointInfo.java
blob: 4997aa9bf2f6f2fb7e6002c103ef001e3cc49f81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
/*
 * Copyright (C) 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.net.wifi.passpoint;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.ArrayList;
import java.util.List;

/**
 * TODO: doc
 */
public class PasspointInfo implements Parcelable {

    /** TODO doc */
    public static final int ANQP_CAPABILITY             = 1 << 0;

    /** TODO doc */
    public static final int VENUE_NAME                  = 1 << 1;

    /** TODO doc */
    public static final int NETWORK_AUTH_TYPE           = 1 << 2;

    /** TODO doc */
    public static final int ROAMING_CONSORTIUM          = 1 << 3;

    /** TODO doc */
    public static final int IP_ADDR_TYPE_AVAILABILITY   = 1 << 4;

    /** TODO doc */
    public static final int NAI_REALM                   = 1 << 5;

    /** TODO doc */
    public static final int CELLULAR_NETWORK            = 1 << 6;

    /** TODO doc */
    public static final int DOMAIN_NAME                 = 1 << 7;

    /** TODO doc */
    public static final int HOTSPOT_CAPABILITY          = 1 << 8;

    /** TODO doc */
    public static final int OPERATOR_FRIENDLY_NAME      = 1 << 9;

    /** TODO doc */
    public static final int WAN_METRICS                 = 1 << 10;

    /** TODO doc */
    public static final int CONNECTION_CAPABILITY       = 1 << 11;

    /** TODO doc */
    public static final int OSU_PROVIDER                = 1 << 12;

    /** TODO doc */
    public static final int PRESET_CRED_MATCH =
            ANQP_CAPABILITY |
            HOTSPOT_CAPABILITY |
            NAI_REALM |
            CELLULAR_NETWORK |
            DOMAIN_NAME;

    /** TODO doc */
    public static final int PRESET_ALL =
            ANQP_CAPABILITY |
            VENUE_NAME |
            NETWORK_AUTH_TYPE |
            ROAMING_CONSORTIUM |
            IP_ADDR_TYPE_AVAILABILITY |
            NAI_REALM |
            CELLULAR_NETWORK |
            DOMAIN_NAME |
            HOTSPOT_CAPABILITY |
            OPERATOR_FRIENDLY_NAME |
            WAN_METRICS |
            CONNECTION_CAPABILITY |
            OSU_PROVIDER;


    /** TODO doc */
    public String bssid;

    /** TODO doc */
    public String venueName;

    /** TODO doc */
    public String networkAuthType;

    /** TODO doc */
    public String roamingConsortium;

    /** TODO doc */
    public String ipAddrTypeAvaibility;

    /** TODO doc */
    public String naiRealm;

    /** TODO doc */
    public String cellularNetwork;

    /** TODO doc */
    public String domainName;

    /** TODO doc */
    public String operatorFriendlyName;

    /** TODO doc */
    public String wanMetrics;

    /** TODO doc */
    public String connectionCapability;

    /** TODO doc */
    public List<PasspointOsuProvider> osuProviderList;


    /** default constructor @hide */
    public PasspointInfo() {
//        osuProviderList = new ArrayList<OsuProvider>();
    }

    /** copy constructor @hide */
    public PasspointInfo(PasspointInfo source) {
        // TODO
        bssid = source.bssid;
        venueName = source.venueName;
        networkAuthType = source.networkAuthType;
        roamingConsortium = source.roamingConsortium;
        ipAddrTypeAvaibility = source.ipAddrTypeAvaibility;
        naiRealm = source.naiRealm;
        cellularNetwork = source.cellularNetwork;
        domainName = source.domainName;
        operatorFriendlyName = source.operatorFriendlyName;
        wanMetrics = source.wanMetrics;
        connectionCapability = source.connectionCapability;
        if (source.osuProviderList != null) {
            osuProviderList = new ArrayList<PasspointOsuProvider>();
            for (PasspointOsuProvider osu : source.osuProviderList)
                osuProviderList.add(new PasspointOsuProvider(osu));
        }
    }

    /**
     * Convert mask to ANQP subtypes, for supplicant command use.
     *
     * @param mask The ANQP subtypes mask.
     * @return String of ANQP subtypes, good for supplicant command use
     * @hide
     */
    public static String toAnqpSubtypes(int mask) {
        StringBuilder sb = new StringBuilder();
        if ((mask & ANQP_CAPABILITY) != 0) sb.append("257,");
        if ((mask & VENUE_NAME) != 0) sb.append("258,");
        if ((mask & NETWORK_AUTH_TYPE) != 0) sb.append("260,");
        if ((mask & ROAMING_CONSORTIUM) != 0) sb.append("261,");
        if ((mask & IP_ADDR_TYPE_AVAILABILITY) != 0) sb.append("262,");
        if ((mask & NAI_REALM) != 0) sb.append("263,");
        if ((mask & CELLULAR_NETWORK) != 0) sb.append("264,");
        if ((mask & DOMAIN_NAME) != 0) sb.append("268,");
        if ((mask & HOTSPOT_CAPABILITY) != 0) sb.append("hs20:2,");
        if ((mask & OPERATOR_FRIENDLY_NAME) != 0) sb.append("hs20:3,");
        if ((mask & WAN_METRICS) != 0) sb.append("hs20:4,");
        if ((mask & CONNECTION_CAPABILITY) != 0) sb.append("hs20:5,");
        if ((mask & OSU_PROVIDER) != 0) sb.append("hs20:8,");
        if (sb.length() > 0) sb.deleteCharAt(sb.length() - 1);
        return sb.toString();
    }

    @Override
    public String toString() {
        // TODO
        return "PasspointInfo";
    }

    /** Implement the Parcelable interface {@hide} */
    @Override
    public void writeToParcel(Parcel out, int flags) {
        // TODO
        out.writeValue(bssid);
        out.writeValue(venueName);
    }

    /** Implement the Parcelable interface {@hide} */
    @Override
    public int describeContents() {
        return 0;
    }

    /** Implement the Parcelable interface {@hide} */
    public static final Parcelable.Creator<PasspointInfo> CREATOR =
            new Parcelable.Creator<PasspointInfo>() {
        @Override
        public PasspointInfo createFromParcel(Parcel in) {
            PasspointInfo pi = new PasspointInfo();
            pi.bssid = (String) in.readValue(String.class.getClassLoader());
            pi.venueName = (String) in.readValue(String.class.getClassLoader());
            // TODO
            return pi;
        }

        @Override
        public PasspointInfo[] newArray(int size) {
            return new PasspointInfo[size];
        }
    };
}