1 /* 2 * Copyright (C) 2017 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.bluetooth.mapclient; 18 19 20 import com.android.bluetooth.ObexAppParameters; 21 import com.android.obex.ClientSession; 22 import com.android.obex.HeaderSet; 23 24 import java.io.IOException; 25 26 final class RequestSetMessageStatus extends Request { 27 private static final String TAG = RequestSetMessageStatus.class.getSimpleName(); 28 29 public enum StatusIndicator { 30 READ, 31 DELETED 32 } 33 34 private static final String TYPE = "x-bt/messageStatus"; 35 private final StatusIndicator mStatusInd; 36 private final byte mValue; 37 RequestSetMessageStatus(String handle, StatusIndicator statusInd, byte value)38 public RequestSetMessageStatus(String handle, StatusIndicator statusInd, byte value) { 39 mHeaderSet.setHeader(HeaderSet.TYPE, TYPE); 40 mHeaderSet.setHeader(HeaderSet.NAME, handle); 41 42 ObexAppParameters oap = new ObexAppParameters(); 43 oap.add( 44 OAP_TAGID_STATUS_INDICATOR, 45 statusInd == StatusIndicator.READ 46 ? STATUS_INDICATOR_READ 47 : STATUS_INDICATOR_DELETED); 48 oap.add(OAP_TAGID_STATUS_VALUE, value == STATUS_YES ? STATUS_YES : STATUS_NO); 49 oap.addToHeaderSet(mHeaderSet); 50 mStatusInd = statusInd; 51 mValue = value; 52 } 53 getStatusIndicator()54 public StatusIndicator getStatusIndicator() { 55 return mStatusInd; 56 } 57 getValue()58 public byte getValue() { 59 return mValue; 60 } 61 getHandle()62 public String getHandle() { 63 return (String) mHeaderSet.getHeader(HeaderSet.NAME); 64 } 65 66 @Override execute(ClientSession session)67 public void execute(ClientSession session) throws IOException { 68 executePut(session, FILLER_BYTE); 69 } 70 } 71