@@ -60,6 +60,8 @@ public class WifiEapTlsCreateDialogFragment extends DialogFragment {
6060 private TextView mUserCertTextView ;
6161 private EditText mCertPasswordEditText ;
6262 private EditText mIdentityEditText ;
63+ private EditText mDomainEditText ;
64+ private EditText mAltSubjectMatchEditText ;
6365
6466 public static WifiEapTlsCreateDialogFragment newInstance (WifiConfiguration config ) {
6567 Bundle arguments = new Bundle ();
@@ -105,6 +107,11 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
105107 mSsidEditText = (EditText ) rootView .findViewById (R .id .ssid );
106108 mCertPasswordEditText = (EditText ) rootView .findViewById (R .id .wifi_client_cert_password );
107109 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 );
108115 populateUi ();
109116 final AlertDialog dialog =
110117 new AlertDialog .Builder (getActivity ())
@@ -165,6 +172,10 @@ private void populateUi() {
165172 // Both ca cert and client are not populated in the WifiConfiguration object.
166173 updateSelectedCert (mCaCertTextView , null , null );
167174 updateSelectedCert (mUserCertTextView , null , null );
175+ if (SDK_INT >= VERSION_CODES .M ) {
176+ mDomainEditText .setText (mWifiConfiguration .enterpriseConfig .getDomainSuffixMatch ());
177+ mAltSubjectMatchEditText .setText (mWifiConfiguration .enterpriseConfig .getAltSubjectMatch ());
178+ }
168179 }
169180
170181 private boolean extractInputDataAndSave () {
@@ -204,11 +215,30 @@ private WifiEnterpriseConfig extractEnterpriseConfig() {
204215 WifiEnterpriseConfig config = new WifiEnterpriseConfig ();
205216 config .setEapMethod (WifiEnterpriseConfig .Eap .TLS );
206217 String identity = mIdentityEditText .getText ().toString ();
218+ String domain = mDomainEditText .getText ().toString ();
219+ String altSubjectMatch = mAltSubjectMatchEditText .getText ().toString ();
207220
208221 if (!TextUtils .isEmpty (identity )) {
209222 config .setIdentity (identity );
210223 }
211224
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+
212242 if (mCaCertUri == null ) {
213243 showToast (R .string .error_missing_ca_cert );
214244 return null ;
0 commit comments