1 /*
2  * Copyright (C) 2017 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 android.net.wifi.hotspot2;
18 
19 import android.annotation.IntDef;
20 import android.annotation.SystemApi;
21 import android.net.wifi.WifiManager;
22 import android.os.Handler;
23 
24 import java.lang.annotation.Retention;
25 import java.lang.annotation.RetentionPolicy;
26 
27 /**
28  * Base class for provisioning callbacks. Should be extended by applications and set when calling
29  * {@link WifiManager#startSubscriptionProvisioning(OsuProvider, ProvisioningCallback, Handler)}.
30  *
31  * @hide
32  */
33 @SystemApi
34 public abstract class ProvisioningCallback {
35 
36     /**
37      * OSU Failure error codes
38      * @hide
39      */
40     @Retention(RetentionPolicy.SOURCE)
41     @IntDef(prefix = { "OSU_FAILURE_" }, value = {
42             OSU_FAILURE_AP_CONNECTION,
43             OSU_FAILURE_SERVER_URL_INVALID,
44             OSU_FAILURE_SERVER_CONNECTION,
45             OSU_FAILURE_SERVER_VALIDATION,
46             OSU_FAILURE_SERVICE_PROVIDER_VERIFICATION,
47             OSU_FAILURE_PROVISIONING_ABORTED,
48             OSU_FAILURE_PROVISIONING_NOT_AVAILABLE,
49             OSU_FAILURE_INVALID_URL_FORMAT_FOR_OSU,
50             OSU_FAILURE_UNEXPECTED_COMMAND_TYPE,
51             OSU_FAILURE_UNEXPECTED_SOAP_MESSAGE_TYPE,
52             OSU_FAILURE_SOAP_MESSAGE_EXCHANGE,
53             OSU_FAILURE_START_REDIRECT_LISTENER,
54             OSU_FAILURE_TIMED_OUT_REDIRECT_LISTENER,
55             OSU_FAILURE_NO_OSU_ACTIVITY_FOUND,
56             OSU_FAILURE_UNEXPECTED_SOAP_MESSAGE_STATUS,
57             OSU_FAILURE_NO_PPS_MO,
58             OSU_FAILURE_NO_AAA_SERVER_TRUST_ROOT_NODE,
59             OSU_FAILURE_NO_REMEDIATION_SERVER_TRUST_ROOT_NODE,
60             OSU_FAILURE_NO_POLICY_SERVER_TRUST_ROOT_NODE,
61             OSU_FAILURE_RETRIEVE_TRUST_ROOT_CERTIFICATES,
62             OSU_FAILURE_NO_AAA_TRUST_ROOT_CERTIFICATE,
63             OSU_FAILURE_ADD_PASSPOINT_CONFIGURATION,
64             OSU_FAILURE_OSU_PROVIDER_NOT_FOUND})
65     public @interface OsuFailure {}
66 
67     /**
68      * The reason code for Provisioning Failure due to connection failure to OSU AP.
69      */
70     public static final int OSU_FAILURE_AP_CONNECTION = 1;
71 
72     /**
73      * The reason code for invalid server URL address.
74      */
75     public static final int OSU_FAILURE_SERVER_URL_INVALID = 2;
76 
77     /**
78      * The reason code for provisioning failure due to connection failure to the server.
79      */
80     public static final int OSU_FAILURE_SERVER_CONNECTION = 3;
81 
82     /**
83      * The reason code for provisioning failure due to invalid server certificate.
84      */
85     public static final int OSU_FAILURE_SERVER_VALIDATION = 4;
86 
87     /**
88      * The reason code for provisioning failure due to invalid service provider.
89      */
90     public static final int OSU_FAILURE_SERVICE_PROVIDER_VERIFICATION = 5;
91 
92     /**
93      * The reason code for provisioning failure when a provisioning flow is aborted.
94      */
95     public static final int OSU_FAILURE_PROVISIONING_ABORTED = 6;
96 
97     /**
98      * The reason code for provisioning failure when a provisioning flow is not possible.
99      */
100     public static final int OSU_FAILURE_PROVISIONING_NOT_AVAILABLE = 7;
101 
102     /**
103      * The reason code for provisioning failure due to invalid web url format for an OSU web page.
104      */
105     public static final int OSU_FAILURE_INVALID_URL_FORMAT_FOR_OSU = 8;
106 
107     /**
108      * The reason code for provisioning failure when a command received is not the expected command
109      * type.
110      */
111     public static final int OSU_FAILURE_UNEXPECTED_COMMAND_TYPE = 9;
112 
113     /**
114      * The reason code for provisioning failure when a SOAP message is not the expected message
115      * type.
116      */
117     public static final int OSU_FAILURE_UNEXPECTED_SOAP_MESSAGE_TYPE = 10;
118 
119     /**
120      * The reason code for provisioning failure when a SOAP message exchange fails.
121      */
122     public static final int OSU_FAILURE_SOAP_MESSAGE_EXCHANGE = 11;
123 
124     /**
125      * The reason code for provisioning failure when a redirect listener fails to start.
126      */
127     public static final int OSU_FAILURE_START_REDIRECT_LISTENER = 12;
128 
129     /**
130      * The reason code for provisioning failure when a redirect listener timed out to receive a HTTP
131      * redirect response.
132      */
133     public static final int OSU_FAILURE_TIMED_OUT_REDIRECT_LISTENER = 13;
134 
135     /**
136      * The reason code for provisioning failure when there is no OSU activity to listen to
137      * {@link WifiManager#ACTION_PASSPOINT_LAUNCH_OSU_VIEW} intent.
138      */
139     public static final int OSU_FAILURE_NO_OSU_ACTIVITY_FOUND = 14;
140 
141     /**
142      * The reason code for provisioning failure when the status of a SOAP message is not the
143      * expected message status.
144      */
145     public static final int OSU_FAILURE_UNEXPECTED_SOAP_MESSAGE_STATUS = 15;
146 
147     /**
148      * The reason code for provisioning failure when there is no PPS MO.
149      * MO.
150      */
151     public static final int OSU_FAILURE_NO_PPS_MO = 16;
152 
153     /**
154      * The reason code for provisioning failure when there is no AAAServerTrustRoot node in a PPS
155      * MO.
156      */
157     public static final int OSU_FAILURE_NO_AAA_SERVER_TRUST_ROOT_NODE = 17;
158 
159     /**
160      * The reason code for provisioning failure when there is no TrustRoot node for remediation
161      * server in a PPS MO.
162      */
163     public static final int OSU_FAILURE_NO_REMEDIATION_SERVER_TRUST_ROOT_NODE = 18;
164 
165     /**
166      * The reason code for provisioning failure when there is no TrustRoot node for policy server in
167      * a PPS MO.
168      */
169     public static final int OSU_FAILURE_NO_POLICY_SERVER_TRUST_ROOT_NODE = 19;
170 
171     /**
172      * The reason code for provisioning failure when failing to retrieve trust root certificates
173      * used for validating server certificate for AAA, Remediation and Policy server.
174      */
175     public static final int OSU_FAILURE_RETRIEVE_TRUST_ROOT_CERTIFICATES = 20;
176 
177     /**
178      * The reason code for provisioning failure when there is no trust root certificate for AAA
179      * server.
180      */
181     public static final int OSU_FAILURE_NO_AAA_TRUST_ROOT_CERTIFICATE = 21;
182 
183     /**
184      * The reason code for provisioning failure when a {@link PasspointConfiguration} is failed to
185      * install.
186      */
187     public static final int OSU_FAILURE_ADD_PASSPOINT_CONFIGURATION = 22;
188 
189     /**
190      * The reason code for provisioning failure when an {@link OsuProvider} is not found for
191      * provisioning.
192      */
193     public static final int OSU_FAILURE_OSU_PROVIDER_NOT_FOUND = 23;
194 
195     /**
196      * OSU Status error codes
197      * @hide
198      */
199     @Retention(RetentionPolicy.SOURCE)
200     @IntDef(prefix = { "OSU_FAILURE_" }, value = {
201             OSU_STATUS_AP_CONNECTING,
202             OSU_STATUS_AP_CONNECTED,
203             OSU_STATUS_SERVER_CONNECTING,
204             OSU_STATUS_SERVER_VALIDATED,
205             OSU_STATUS_SERVER_CONNECTED,
206             OSU_STATUS_INIT_SOAP_EXCHANGE,
207             OSU_STATUS_WAITING_FOR_REDIRECT_RESPONSE,
208             OSU_STATUS_REDIRECT_RESPONSE_RECEIVED,
209             OSU_STATUS_SECOND_SOAP_EXCHANGE,
210             OSU_STATUS_THIRD_SOAP_EXCHANGE,
211             OSU_STATUS_RETRIEVING_TRUST_ROOT_CERTS})
212     public @interface OsuStatus {}
213 
214     /**
215      * The status code for provisioning flow to indicate connecting to OSU AP
216      */
217     public static final int OSU_STATUS_AP_CONNECTING = 1;
218 
219     /**
220      * The status code for provisioning flow to indicate the OSU AP is connected.
221      */
222     public static final int OSU_STATUS_AP_CONNECTED = 2;
223 
224     /**
225      * The status code for provisioning flow to indicate connecting to the server.
226      */
227     public static final int OSU_STATUS_SERVER_CONNECTING = 3;
228 
229     /**
230      * The status code for provisioning flow to indicate the server certificate is validated.
231      */
232     public static final int OSU_STATUS_SERVER_VALIDATED = 4;
233 
234     /**
235      * The status code for provisioning flow to indicate the server is connected
236      */
237     public static final int OSU_STATUS_SERVER_CONNECTED = 5;
238 
239     /**
240      * The status code for provisioning flow to indicate starting the first SOAP exchange.
241      */
242     public static final int OSU_STATUS_INIT_SOAP_EXCHANGE = 6;
243 
244     /**
245      * The status code for provisioning flow to indicate waiting for a HTTP redirect response.
246      */
247     public static final int OSU_STATUS_WAITING_FOR_REDIRECT_RESPONSE = 7;
248 
249     /**
250      * The status code for provisioning flow to indicate a HTTP redirect response is received.
251      */
252     public static final int OSU_STATUS_REDIRECT_RESPONSE_RECEIVED = 8;
253 
254     /**
255      * The status code for provisioning flow to indicate starting the second SOAP exchange.
256      */
257     public static final int OSU_STATUS_SECOND_SOAP_EXCHANGE = 9;
258 
259     /**
260      * The status code for provisioning flow to indicate starting the third SOAP exchange.
261      */
262     public static final int OSU_STATUS_THIRD_SOAP_EXCHANGE = 10;
263 
264     /**
265      * The status code for provisioning flow to indicate starting a step retrieving trust root
266      * certs.
267      */
268     public static final int OSU_STATUS_RETRIEVING_TRUST_ROOT_CERTS = 11;
269 
270     /**
271      * Provisioning status for OSU failure
272      *
273      * @param status indicates error condition
274      */
onProvisioningFailure(@suFailure int status)275     public abstract void onProvisioningFailure(@OsuFailure int status);
276 
277     /**
278      * Provisioning status when OSU is in progress
279      *
280      * @param status indicates status of OSU flow
281      */
onProvisioningStatus(@suStatus int status)282     public abstract void onProvisioningStatus(@OsuStatus int status);
283 
284     /**
285      * Provisioning complete when provisioning/remediation flow completes
286      */
onProvisioningComplete()287     public abstract void onProvisioningComplete();
288 }
289