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-Delivery.Ind Pdu. 27 */ 28 public class DeliveryInd extends GenericPdu { 29 /** 30 * Empty constructor. 31 * Since the Pdu corresponding to this class is constructed 32 * by the Proxy-Relay server, this class is only instantiated 33 * by the Pdu Parser. 34 * 35 * @throws InvalidHeaderValueException if error occurs. 36 */ DeliveryInd()37 public DeliveryInd() throws InvalidHeaderValueException { 38 super(); 39 setMessageType(PduHeaders.MESSAGE_TYPE_DELIVERY_IND); 40 } 41 42 /** 43 * Constructor with given headers. 44 * 45 * @param headers Headers for this PDU. 46 */ 47 @UnsupportedAppUsage DeliveryInd(PduHeaders headers)48 DeliveryInd(PduHeaders headers) { 49 super(headers); 50 } 51 52 /** 53 * Get Date value. 54 * 55 * @return the value 56 */ 57 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) getDate()58 public long getDate() { 59 return mPduHeaders.getLongInteger(PduHeaders.DATE); 60 } 61 62 /** 63 * Set Date value. 64 * 65 * @param value the value 66 */ setDate(long value)67 public void setDate(long value) { 68 mPduHeaders.setLongInteger(value, PduHeaders.DATE); 69 } 70 71 /** 72 * Get Message-ID value. 73 * 74 * @return the value 75 */ 76 @UnsupportedAppUsage getMessageId()77 public byte[] getMessageId() { 78 return mPduHeaders.getTextString(PduHeaders.MESSAGE_ID); 79 } 80 81 /** 82 * Set Message-ID value. 83 * 84 * @param value the value, should not be null 85 * @throws NullPointerException if the value is null. 86 */ setMessageId(byte[] value)87 public void setMessageId(byte[] value) { 88 mPduHeaders.setTextString(value, PduHeaders.MESSAGE_ID); 89 } 90 91 /** 92 * Get Status value. 93 * 94 * @return the value 95 */ 96 @UnsupportedAppUsage getStatus()97 public int getStatus() { 98 return mPduHeaders.getOctet(PduHeaders.STATUS); 99 } 100 101 /** 102 * Set Status value. 103 * 104 * @param value the value 105 * @throws InvalidHeaderValueException if the value is invalid. 106 */ setStatus(int value)107 public void setStatus(int value) throws InvalidHeaderValueException { 108 mPduHeaders.setOctet(value, PduHeaders.STATUS); 109 } 110 111 /** 112 * Get To value. 113 * 114 * @return the value 115 */ 116 @UnsupportedAppUsage getTo()117 public EncodedStringValue[] getTo() { 118 return mPduHeaders.getEncodedStringValues(PduHeaders.TO); 119 } 120 121 /** 122 * set To value. 123 * 124 * @param value the value 125 * @throws NullPointerException if the value is null. 126 */ setTo(EncodedStringValue[] value)127 public void setTo(EncodedStringValue[] value) { 128 mPduHeaders.setEncodedStringValues(value, PduHeaders.TO); 129 } 130 131 /* 132 * Optional, not supported header fields: 133 * 134 * public byte[] getApplicId() {return null;} 135 * public void setApplicId(byte[] value) {} 136 * 137 * public byte[] getAuxApplicId() {return null;} 138 * public void getAuxApplicId(byte[] value) {} 139 * 140 * public byte[] getReplyApplicId() {return 0x00;} 141 * public void setReplyApplicId(byte[] value) {} 142 * 143 * public EncodedStringValue getStatusText() {return null;} 144 * public void setStatusText(EncodedStringValue value) {} 145 */ 146 } 147