@@ -60,6 +60,8 @@ public class WifiEapTlsCreateDialogFragment extends DialogFragment {
60
60
private TextView mUserCertTextView ;
61
61
private EditText mCertPasswordEditText ;
62
62
private EditText mIdentityEditText ;
63
+ private EditText mDomainEditText ;
64
+ private EditText mAltSubjectMatchEditText ;
63
65
64
66
public static WifiEapTlsCreateDialogFragment newInstance (WifiConfiguration config ) {
65
67
Bundle arguments = new Bundle ();
@@ -105,6 +107,11 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
105
107
mSsidEditText = (EditText ) rootView .findViewById (R .id .ssid );
106
108
mCertPasswordEditText = (EditText ) rootView .findViewById (R .id .wifi_client_cert_password );
107
109
mIdentityEditText = (EditText ) rootView .findViewById (R .id .wifi_identity );
110
+ mDomainEditText = (EditText ) rootView .findViewById (R .id .wifi_domain );
111
+ mAltSubjectMatchEditText = (EditText ) rootView .findViewById (R .id .wifi_alt_subject_match );
112
+ // These config options are not available before API 23
113
+ mDomainEditText .setEnabled (SDK_INT >= VERSION_CODES .M );
114
+ mAltSubjectMatchEditText .setEnabled (SDK_INT >= VERSION_CODES .M );
108
115
populateUi ();
109
116
final AlertDialog dialog =
110
117
new AlertDialog .Builder (getActivity ())
@@ -165,6 +172,10 @@ private void populateUi() {
165
172
// Both ca cert and client are not populated in the WifiConfiguration object.
166
173
updateSelectedCert (mCaCertTextView , null , null );
167
174
updateSelectedCert (mUserCertTextView , null , null );
175
+ if (SDK_INT >= VERSION_CODES .M ) {
176
+ mDomainEditText .setText (mWifiConfiguration .enterpriseConfig .getDomainSuffixMatch ());
177
+ mAltSubjectMatchEditText .setText (mWifiConfiguration .enterpriseConfig .getAltSubjectMatch ());
178
+ }
168
179
}
169
180
170
181
private boolean extractInputDataAndSave () {
@@ -204,11 +215,30 @@ private WifiEnterpriseConfig extractEnterpriseConfig() {
204
215
WifiEnterpriseConfig config = new WifiEnterpriseConfig ();
205
216
config .setEapMethod (WifiEnterpriseConfig .Eap .TLS );
206
217
String identity = mIdentityEditText .getText ().toString ();
218
+ String domain = mDomainEditText .getText ().toString ();
219
+ String altSubjectMatch = mAltSubjectMatchEditText .getText ().toString ();
207
220
208
221
if (!TextUtils .isEmpty (identity )) {
209
222
config .setIdentity (identity );
210
223
}
211
224
225
+ if (SDK_INT >= VERSION_CODES .S
226
+ && TextUtils .isEmpty (domain )
227
+ && TextUtils .isEmpty (altSubjectMatch )) {
228
+ showToast (R .string .error_domain_and_alt_subject_match_both_unset );
229
+ return null ;
230
+ }
231
+
232
+ if (SDK_INT >= VERSION_CODES .M ) {
233
+ if (!TextUtils .isEmpty (domain )) {
234
+ config .setDomainSuffixMatch (domain );
235
+ }
236
+
237
+ if (!TextUtils .isEmpty (altSubjectMatch )) {
238
+ config .setAltSubjectMatch (altSubjectMatch );
239
+ }
240
+ }
241
+
212
242
if (mCaCertUri == null ) {
213
243
showToast (R .string .error_missing_ca_cert );
214
244
return null ;
0 commit comments