1 /* 2 * Copyright (C) 2007 Esmertec AG. 3 * Copyright (C) 2007 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package com.google.android.mms.pdu; 19 20 import android.compat.annotation.UnsupportedAppUsage; 21 import android.os.Build; 22 23 import com.google.android.mms.InvalidHeaderValueException; 24 25 /** 26 * M-NofifyResp.ind PDU. 27 */ 28 public class NotifyRespInd extends GenericPdu { 29 /** 30 * Constructor, used when composing a M-NotifyResp.ind pdu. 31 * 32 * @param mmsVersion current version of mms 33 * @param transactionId the transaction-id value 34 * @param status the status value 35 * @throws InvalidHeaderValueException if parameters are invalid. 36 * NullPointerException if transactionId is null. 37 * RuntimeException if an undeclared error occurs. 38 */ 39 @UnsupportedAppUsage NotifyRespInd(int mmsVersion, byte[] transactionId, int status)40 public NotifyRespInd(int mmsVersion, 41 byte[] transactionId, 42 int status) throws InvalidHeaderValueException { 43 super(); 44 setMessageType(PduHeaders.MESSAGE_TYPE_NOTIFYRESP_IND); 45 setMmsVersion(mmsVersion); 46 setTransactionId(transactionId); 47 setStatus(status); 48 } 49 50 /** 51 * Constructor with given headers. 52 * 53 * @param headers Headers for this PDU. 54 */ 55 @UnsupportedAppUsage NotifyRespInd(PduHeaders headers)56 NotifyRespInd(PduHeaders headers) { 57 super(headers); 58 } 59 60 /** 61 * Get X-Mms-Report-Allowed field value. 62 * 63 * @return the X-Mms-Report-Allowed value 64 */ getReportAllowed()65 public int getReportAllowed() { 66 return mPduHeaders.getOctet(PduHeaders.REPORT_ALLOWED); 67 } 68 69 /** 70 * Set X-Mms-Report-Allowed field value. 71 * 72 * @param value the value 73 * @throws InvalidHeaderValueException if the value is invalid. 74 * RuntimeException if an undeclared error occurs. 75 */ 76 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) setReportAllowed(int value)77 public void setReportAllowed(int value) throws InvalidHeaderValueException { 78 mPduHeaders.setOctet(value, PduHeaders.REPORT_ALLOWED); 79 } 80 81 /** 82 * Set X-Mms-Status field value. 83 * 84 * @param value the value 85 * @throws InvalidHeaderValueException if the value is invalid. 86 * RuntimeException if an undeclared error occurs. 87 */ 88 @UnsupportedAppUsage setStatus(int value)89 public void setStatus(int value) throws InvalidHeaderValueException { 90 mPduHeaders.setOctet(value, PduHeaders.STATUS); 91 } 92 93 /** 94 * GetX-Mms-Status field value. 95 * 96 * @return the X-Mms-Status value 97 */ getStatus()98 public int getStatus() { 99 return mPduHeaders.getOctet(PduHeaders.STATUS); 100 } 101 102 /** 103 * Get X-Mms-Transaction-Id field value. 104 * 105 * @return the X-Mms-Report-Allowed value 106 */ getTransactionId()107 public byte[] getTransactionId() { 108 return mPduHeaders.getTextString(PduHeaders.TRANSACTION_ID); 109 } 110 111 /** 112 * Set X-Mms-Transaction-Id field value. 113 * 114 * @param value the value 115 * @throws NullPointerException if the value is null. 116 * RuntimeException if an undeclared error occurs. 117 */ 118 @UnsupportedAppUsage setTransactionId(byte[] value)119 public void setTransactionId(byte[] value) { 120 mPduHeaders.setTextString(value, PduHeaders.TRANSACTION_ID); 121 } 122 } 123