• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
22 import com.google.android.mms.InvalidHeaderValueException;
23 
24 public class GenericPdu {
25     /**
26      * The headers of pdu.
27      */
28     @UnsupportedAppUsage
29     PduHeaders mPduHeaders = null;
30 
31     /**
32      * Constructor.
33      */
34     @UnsupportedAppUsage
GenericPdu()35     public GenericPdu() {
36         mPduHeaders = new PduHeaders();
37     }
38 
39     /**
40      * Constructor.
41      *
42      * @param headers Headers for this PDU.
43      */
GenericPdu(PduHeaders headers)44     GenericPdu(PduHeaders headers) {
45         mPduHeaders = headers;
46     }
47 
48     /**
49      * Get the headers of this PDU.
50      *
51      * @return A PduHeaders of this PDU.
52      */
53     @UnsupportedAppUsage
getPduHeaders()54     PduHeaders getPduHeaders() {
55         return mPduHeaders;
56     }
57 
58     /**
59      * Get X-Mms-Message-Type field value.
60      *
61      * @return the X-Mms-Report-Allowed value
62      */
63     @UnsupportedAppUsage
getMessageType()64     public int getMessageType() {
65         return mPduHeaders.getOctet(PduHeaders.MESSAGE_TYPE);
66     }
67 
68     /**
69      * Set X-Mms-Message-Type field value.
70      *
71      * @param value the value
72      * @throws InvalidHeaderValueException if the value is invalid.
73      *         RuntimeException if field's value is not Octet.
74      */
75     @UnsupportedAppUsage
setMessageType(int value)76     public void setMessageType(int value) throws InvalidHeaderValueException {
77         mPduHeaders.setOctet(value, PduHeaders.MESSAGE_TYPE);
78     }
79 
80     /**
81      * Get X-Mms-MMS-Version field value.
82      *
83      * @return the X-Mms-MMS-Version value
84      */
getMmsVersion()85     public int getMmsVersion() {
86         return mPduHeaders.getOctet(PduHeaders.MMS_VERSION);
87     }
88 
89     /**
90      * Set X-Mms-MMS-Version field value.
91      *
92      * @param value the value
93      * @throws InvalidHeaderValueException if the value is invalid.
94      *         RuntimeException if field's value is not Octet.
95      */
setMmsVersion(int value)96     public void setMmsVersion(int value) throws InvalidHeaderValueException {
97         mPduHeaders.setOctet(value, PduHeaders.MMS_VERSION);
98     }
99 
100     /**
101      * Get From value.
102      * From-value = Value-length
103      *      (Address-present-token Encoded-string-value | Insert-address-token)
104      *
105      * @return the value
106      */
107     @UnsupportedAppUsage
getFrom()108     public EncodedStringValue getFrom() {
109        return mPduHeaders.getEncodedStringValue(PduHeaders.FROM);
110     }
111 
112     /**
113      * Set From value.
114      *
115      * @param value the value
116      * @throws NullPointerException if the value is null.
117      */
118     @UnsupportedAppUsage
setFrom(EncodedStringValue value)119     public void setFrom(EncodedStringValue value) {
120         mPduHeaders.setEncodedStringValue(value, PduHeaders.FROM);
121     }
122 }
123