1/* 2 * Copyright (C) 2014 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.bluetooth.client.map; 18import android.bluetooth.client.map.utils.ObexAppParameters; 19 20import java.io.IOException; 21import java.io.InputStream; 22import java.util.ArrayList; 23 24import javax.obex.ClientSession; 25import javax.obex.HeaderSet; 26 27final class BluetoothMasRequestGetFolderListing extends BluetoothMasRequest { 28 29 private static final String TYPE = "x-obex/folder-listing"; 30 31 private BluetoothMapFolderListing mResponse = null; 32 33 public BluetoothMasRequestGetFolderListing(int maxListCount, int listStartOffset) { 34 35 if (maxListCount < 0 || maxListCount > 65535) { 36 throw new IllegalArgumentException("maxListCount should be [0..65535]"); 37 } 38 39 if (listStartOffset < 0 || listStartOffset > 65535) { 40 throw new IllegalArgumentException("listStartOffset should be [0..65535]"); 41 } 42 43 mHeaderSet.setHeader(HeaderSet.TYPE, TYPE); 44 45 ObexAppParameters oap = new ObexAppParameters(); 46 47 if (maxListCount > 0) { 48 oap.add(OAP_TAGID_MAX_LIST_COUNT, (short) maxListCount); 49 } 50 51 if (listStartOffset > 0) { 52 oap.add(OAP_TAGID_START_OFFSET, (short) listStartOffset); 53 } 54 55 oap.addToHeaderSet(mHeaderSet); 56 } 57 58 @Override 59 protected void readResponse(InputStream stream) { 60 mResponse = new BluetoothMapFolderListing(stream); 61 } 62 63 public ArrayList<String> getList() { 64 if (mResponse == null) { 65 return null; 66 } 67 68 return mResponse.getList(); 69 } 70 71 @Override 72 public void execute(ClientSession session) throws IOException { 73 executeGet(session); 74 } 75} 76