WifiP2pUpnpServiceRequest.java revision 21ba8153325e010224c6bc75a0acdc98b6ca82e8
1/* 2 * Copyright (C) 2012 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 17package android.net.wifi.p2p.nsd; 18 19/** 20 * The class for a request of upnp service discovery. 21 * @hide 22 */ 23public class WifiP2pUpnpServiceRequest extends WifiP2pServiceRequest { 24 25 /** 26 * This constructor is only used in newInstance(). 27 * 28 * @param query The part of service specific query. 29 * @hide 30 */ 31 protected WifiP2pUpnpServiceRequest(String query) { 32 super(WifiP2pServiceInfo.SERVICE_TYPE_UPNP, query); 33 } 34 35 /** 36 * This constructor is only used in newInstance(). 37 * @hide 38 */ 39 protected WifiP2pUpnpServiceRequest() { 40 super(WifiP2pServiceInfo.SERVICE_TYPE_UPNP, null); 41 } 42 43 /** 44 * Create a service discovery request to search all UPnP services. 45 * 46 * @return service request for UPnP. 47 */ 48 public static WifiP2pUpnpServiceRequest newInstance() { 49 return new WifiP2pUpnpServiceRequest(); 50 } 51 /** 52 * Create a service discovery request to search specified UPnP services. 53 * 54 * @param st ssdp search target. Cannot be null.<br> 55 * e.g ) <br> 56 * <ul> 57 * <li>"ssdp:all" 58 * <li>"upnp:rootdevice" 59 * <li>"urn:schemas-upnp-org:device:MediaServer:2" 60 * <li>"urn:schemas-upnp-org:service:ContentDirectory:2" 61 * <li>"uuid:6859dede-8574-59ab-9332-123456789012" 62 * </ul> 63 * @return service request for UPnP. 64 */ 65 public static WifiP2pUpnpServiceRequest newInstance(String st) { 66 if (st == null) { 67 throw new IllegalArgumentException("search target cannot be null"); 68 } 69 StringBuffer sb = new StringBuffer(); 70 sb.append(String.format("%02x", WifiP2pUpnpServiceInfo.VERSION_1_0)); 71 sb.append(WifiP2pServiceInfo.bin2HexStr(st.getBytes())); 72 return new WifiP2pUpnpServiceRequest(sb.toString()); 73 } 74} 75