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