Messaging: Further code improvements

* Remove redundant casts
* getParcelable(ArrayList|Exra) without class argument is deprecated
* ViewPager.setOnPageChangeListener -> addOnPageChangeListener
* RecyclerView.setOnScrollListener -> addOnScrollListener
* Remove unused initializations
* Remove unused code

Change-Id: I21beb6c90c675a4f2cfd7e3d5ebbd18b745f5911
This commit is contained in:
Michael W
2025-03-04 18:52:05 +01:00
parent 47f5533a73
commit b2f5e3190e
110 changed files with 289 additions and 561 deletions
@@ -96,22 +96,22 @@ public class PduComposer {
/**
* The output message.
*/
protected ByteArrayOutputStream mMessage = null;
protected ByteArrayOutputStream mMessage;
/**
* The PDU.
*/
private GenericPdu mPdu = null;
private GenericPdu mPdu;
/**
* Current visiting position of the mMessage.
*/
protected int mPosition = 0;
protected int mPosition;
/**
* Message compose buffer stack.
*/
private BufferStack mStack = null;
private BufferStack mStack;
/**
* Content resolver.
@@ -121,12 +121,12 @@ public class PduComposer {
/**
* Header of this pdu.
*/
private PduHeaders mPduHeader = null;
private PduHeaders mPduHeader;
/**
* Map of all content type
*/
private static SimpleArrayMap<String, Integer> mContentTypeMap = null;
private static SimpleArrayMap<String, Integer> mContentTypeMap;
static {
mContentTypeMap = new SimpleArrayMap<>();
@@ -469,7 +469,7 @@ public class PduComposer {
}
private EncodedStringValue appendAddressType(final EncodedStringValue address) {
EncodedStringValue temp = null;
EncodedStringValue temp;
try {
final int addressType = checkAddressType(address.getString());
@@ -1065,7 +1065,7 @@ public class PduComposer {
try {
final byte[] buffer = new byte[PDU_COMPOSER_BLOCK_SIZE];
cr = mResolver.openInputStream(part.getDataUri());
int len = 0;
int len;
while ((len = cr.read(buffer)) != -1) {
mMessage.write(buffer, 0, len);
mPosition += len;
@@ -373,7 +373,7 @@ public class PduPersister {
Uri.parse("content://mms/" + msgId + "/part"),
PART_PROJECTION, null, null, null);
PduPart[] parts = null;
PduPart[] parts;
try {
if ((c == null) || (c.getCount() == 0)) {
@@ -560,7 +560,7 @@ public class PduPersister {
*/
public GenericPdu load(final Uri uri) throws MmsException {
GenericPdu pdu = null;
PduCacheEntry cacheEntry = null;
PduCacheEntry cacheEntry;
int msgBox = 0;
final long threadId = -1;
try {
@@ -859,7 +859,7 @@ public class PduPersister {
OutputStream os = null;
InputStream is = null;
DrmConvertSession drmConvertSession = null;
Uri dataUri = null;
Uri dataUri;
String path = null;
try {
@@ -936,7 +936,7 @@ public class PduPersister {
}
final byte[] buffer = new byte[8192];
for (int len = 0; (len = is.read(buffer)) != -1; ) {
for (int len; (len = is.read(buffer)) != -1; ) {
if (!isDrm) {
os.write(buffer, 0, len);
} else {
@@ -955,7 +955,6 @@ public class PduPersister {
if (!isDrm) {
os.write(data);
} else {
dataUri = uri;
final byte[] convertedData = drmConvertSession.convert(data, data.length);
if (convertedData != null) {
os.write(convertedData, 0, convertedData.length);
@@ -1093,7 +1092,7 @@ public class PduPersister {
PDU_CACHE_INSTANCE.purge(uri);
final PduHeaders header = pdu.getPduHeaders();
PduBody body = null;
PduBody body;
ContentValues values = new ContentValues();
// Mark new messages as seen in the telephony database so that we don't have to
@@ -86,7 +86,7 @@ public class DrmConvertSession {
public byte[] convert(byte[] inBuffer, int size) {
byte[] result = null;
if (inBuffer != null) {
DrmConvertedStatus convertedStatus = null;
DrmConvertedStatus convertedStatus;
try {
if (size != inBuffer.length) {
byte[] buf = new byte[size];
@@ -125,7 +125,7 @@ public class DrmConvertSession {
* Downloads.Impl.STATUS_UNKNOWN_ERROR if a general error occurred.
*/
public int close(String filename) {
DrmConvertedStatus convertedStatus = null;
DrmConvertedStatus convertedStatus;
int result = Downloads.Impl.STATUS_UNKNOWN_ERROR;
if (mDrmClient != null && mConvertSessionId >= 0) {
try {
@@ -188,7 +188,7 @@ public final class PduCache extends AbstractCache<Uri, PduCacheEntry> {
*/
private Uri normalizeKey(Uri uri) {
int match = URI_MATCHER.match(uri);
Uri normalizedKey = null;
Uri normalizedKey;
switch (match) {
case MMS_ALL_ID: