Messaging: Language cleanup

No unnecessary boxing, enhanced for loops, redundant checks and throws,
imports (removal, reordering), possible void returns

Change-Id: I7a8e1b2007e3b0906e01b41785c518d02c2f3fab
This commit is contained in:
Michael W
2024-12-26 15:54:37 +01:00
parent e335f6bec8
commit e128bff457
77 changed files with 202 additions and 334 deletions
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2008 Esmertec AG.
* Copyright (C) 2008 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,10 +39,7 @@ public final class SqliteWrapper {
String[] projection, String selection, String[] selectionArgs, String sortOrder) {
try {
return resolver.query(uri, projection, selection, selectionArgs, sortOrder);
} catch (SQLiteException e) {
LogUtil.e(TAG, "SqliteWrapper: catch an exception when query", e);
return null;
} catch (IllegalArgumentException e) {
} catch (SQLiteException | IllegalArgumentException e) {
LogUtil.e(TAG, "SqliteWrapper: catch an exception when query", e);
return null;
}
@@ -51,10 +49,7 @@ public final class SqliteWrapper {
ContentValues values, String where, String[] selectionArgs) {
try {
return resolver.update(uri, values, where, selectionArgs);
} catch (SQLiteException e) {
LogUtil.e(TAG, "SqliteWrapper: catch an exception when update", e);
return -1;
} catch (IllegalArgumentException e) {
} catch (SQLiteException | IllegalArgumentException e) {
LogUtil.e(TAG, "SqliteWrapper: catch an exception when update", e);
return -1;
}
@@ -64,10 +59,7 @@ public final class SqliteWrapper {
String where, String[] selectionArgs) {
try {
return resolver.delete(uri, where, selectionArgs);
} catch (SQLiteException e) {
LogUtil.e(TAG, "SqliteWrapper: catch an exception when delete", e);
return -1;
} catch (IllegalArgumentException e) {
} catch (SQLiteException | IllegalArgumentException e) {
LogUtil.e(TAG, "SqliteWrapper: catch an exception when delete", e);
return -1;
}
@@ -77,10 +69,7 @@ public final class SqliteWrapper {
Uri uri, ContentValues values) {
try {
return resolver.insert(uri, values);
} catch (SQLiteException e) {
LogUtil.e(TAG, "SqliteWrapper: catch an exception when insert", e);
return null;
} catch (IllegalArgumentException e) {
} catch (SQLiteException | IllegalArgumentException e) {
LogUtil.e(TAG, "SqliteWrapper: catch an exception when insert", e);
return null;
}
@@ -522,8 +522,8 @@ public class PduComposer {
}
EncodedStringValue temp;
for (int i = 0; i < addr.length; i++) {
temp = appendAddressType(addr[i]);
for (EncodedStringValue encodedStringValue : addr) {
temp = appendAddressType(encodedStringValue);
if (temp == null) {
return PDU_COMPOSE_CONTENT_ERROR;
}
@@ -23,6 +23,7 @@ import android.util.SparseArray;
import com.android.messaging.mmslib.InvalidHeaderValueException;
import java.util.ArrayList;
import java.util.Collections;
public class PduHeaders {
/**
@@ -648,9 +649,7 @@ public class PduHeaders {
}
ArrayList<EncodedStringValue> list = new ArrayList<>();
for (int i = 0; i < value.length; i++) {
list.add(value[i]);
}
Collections.addAll(list, value);
mHeaderMap.put(field, list);
}
@@ -31,7 +31,6 @@ import android.provider.Telephony.Mms.Addr;
import android.provider.Telephony.Mms.Part;
import android.provider.Telephony.MmsSms;
import android.provider.Telephony.MmsSms.PendingMessages;
import androidx.collection.ArrayMap;
import androidx.collection.SimpleArrayMap;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
@@ -694,9 +693,8 @@ public class PduPersister {
|| (msgType == PduHeaders.MESSAGE_TYPE_SEND_REQ)) {
final PduPart[] parts = loadParts(msgId);
if (parts != null) {
final int partsNum = parts.length;
for (int i = 0; i < partsNum; i++) {
body.addPart(parts[i]);
for (PduPart part : parts) {
body.addPart(part);
}
}
}
@@ -1223,7 +1221,7 @@ public class PduPersister {
values.put(Mms.TEXT_ONLY, textOnly ? 1 : 0);
values.put(Mms.SUBSCRIPTION_ID, subId);
Uri res = null;
Uri res;
if (existingUri) {
res = uri;
SqliteWrapper.update(mContext, mContentResolver, res, values, null, null);
@@ -1279,10 +1277,7 @@ public class PduPersister {
for (final EncodedStringValue v : array) {
if (v != null) {
final String number = v.getString();
if (!recipients.contains(number)) {
// Only add numbers which aren't already included.
recipients.add(number);
}
recipients.add(number);
}
}
}
@@ -1325,10 +1320,7 @@ public class PduPersister {
for (final String number : numbers) {
// Only add numbers which aren't my own number.
if (isSelfNumberUnavailable || !PhoneNumberUtils.compare(number, selfNumber)) {
if (!recipients.contains(number)) {
// Only add numbers which aren't already included.
recipients.add(number);
}
recipients.add(number);
}
}
}