| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
package com.google.android.mms.pdu; |
| 19 |
|
| 20 |
import android.compat.annotation.UnsupportedAppUsage; |
| 21 |
import android.os.Build; |
| 22 |
|
| 23 |
import java.util.HashMap; |
| 24 |
import java.util.Map; |
| 25 |
import java.util.Vector; |
| 26 |
|
| 27 |
public class PduBody { |
| 28 |
private Vector<PduPart> mParts = null; |
| 29 |
|
| 30 |
private Map<String, PduPart> mPartMapByContentId = null; |
| 31 |
private Map<String, PduPart> mPartMapByContentLocation = null; |
| 32 |
private Map<String, PduPart> mPartMapByName = null; |
| 33 |
private Map<String, PduPart> mPartMapByFileName = null; |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
@UnsupportedAppUsage |
| 39 |
public PduBody() { |
| 40 |
mParts = new Vector<PduPart>(); |
| 41 |
|
| 42 |
mPartMapByContentId = new HashMap<String, PduPart>(); |
| 43 |
mPartMapByContentLocation = new HashMap<String, PduPart>(); |
| 44 |
mPartMapByName = new HashMap<String, PduPart>(); |
| 45 |
mPartMapByFileName = new HashMap<String, PduPart>(); |
| 46 |
} |
| 47 |
|
| 48 |
private void putPartToMaps(PduPart part) { |
| 49 |
|
| 50 |
byte[] contentId = part.getContentId(); |
| 51 |
if(null != contentId) { |
| 52 |
mPartMapByContentId.put(new String(contentId), part); |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
byte[] contentLocation = part.getContentLocation(); |
| 57 |
if(null != contentLocation) { |
| 58 |
String clc = new String(contentLocation); |
| 59 |
mPartMapByContentLocation.put(clc, part); |
| 60 |
} |
| 61 |
|
| 62 |
|
| 63 |
byte[] name = part.getName(); |
| 64 |
if(null != name) { |
| 65 |
String clc = new String(name); |
| 66 |
mPartMapByName.put(clc, part); |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
byte[] fileName = part.getFilename(); |
| 71 |
if(null != fileName) { |
| 72 |
String clc = new String(fileName); |
| 73 |
mPartMapByFileName.put(clc, part); |
| 74 |
} |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
@UnsupportedAppUsage |
| 85 |
public boolean addPart(PduPart part) { |
| 86 |
if(null == part) { |
| 87 |
throw new NullPointerException(); |
| 88 |
} |
| 89 |
|
| 90 |
putPartToMaps(part); |
| 91 |
return mParts.add(part); |
| 92 |
} |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
@UnsupportedAppUsage |
| 102 |
public void addPart(int index, PduPart part) { |
| 103 |
if(null == part) { |
| 104 |
throw new NullPointerException(); |
| 105 |
} |
| 106 |
|
| 107 |
putPartToMaps(part); |
| 108 |
mParts.add(index, part); |
| 109 |
} |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 118 |
public PduPart removePart(int index) { |
| 119 |
return mParts.remove(index); |
| 120 |
} |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
public void removeAll() { |
| 126 |
mParts.clear(); |
| 127 |
} |
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
@UnsupportedAppUsage |
| 136 |
public PduPart getPart(int index) { |
| 137 |
return mParts.get(index); |
| 138 |
} |
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 147 |
public int getPartIndex(PduPart part) { |
| 148 |
return mParts.indexOf(part); |
| 149 |
} |
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
@UnsupportedAppUsage |
| 157 |
public int getPartsNum() { |
| 158 |
return mParts.size(); |
| 159 |
} |
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
@UnsupportedAppUsage |
| 168 |
public PduPart getPartByContentId(String cid) { |
| 169 |
return mPartMapByContentId.get(cid); |
| 170 |
} |
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
@UnsupportedAppUsage |
| 180 |
public PduPart getPartByContentLocation(String contentLocation) { |
| 181 |
return mPartMapByContentLocation.get(contentLocation); |
| 182 |
} |
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
@UnsupportedAppUsage |
| 191 |
public PduPart getPartByName(String name) { |
| 192 |
return mPartMapByName.get(name); |
| 193 |
} |
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
@UnsupportedAppUsage |
| 202 |
public PduPart getPartByFileName(String filename) { |
| 203 |
return mPartMapByFileName.get(filename); |
| 204 |
} |
| 205 |
} |