1 /* 2 * Copyright (C) 2018 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.hotspot2.soap; 18 19 import android.annotation.NonNull; 20 21 import org.ksoap2.serialization.SoapObject; 22 23 /** 24 * Utility to parse the raw soap SPP (Subscription Provisioning Protocol) response message 25 * sent by server and make the instance of {@link SppResponseMessage} 26 */ 27 public class SoapParser { 28 /** 29 * Get a SppResponseMessage from the original SOAP response. 30 * 31 * @param response original SOAP response sent by server 32 * @return {@link SppResponseMessage}, or {@code null} in any failure 33 */ getResponse(@onNull SoapObject response)34 public static SppResponseMessage getResponse(@NonNull SoapObject response) { 35 SppResponseMessage responseMessage; 36 switch (response.getName()) { 37 case "sppPostDevDataResponse": 38 responseMessage = PostDevDataResponse.createInstance(response); 39 break; 40 case "sppExchangeComplete": 41 responseMessage = ExchangeCompleteMessage.createInstance(response); 42 break; 43 default: 44 responseMessage = null; 45 } 46 return responseMessage; 47 } 48 } 49