Messaging: Replace explicit types

Change-Id: I2165b3dec73973a2a82d8b3c7c364b5f011e597d
This commit is contained in:
Michael W
2024-12-26 15:54:37 +01:00
parent 9538179c75
commit 0069df879a
124 changed files with 278 additions and 277 deletions
@@ -114,8 +114,7 @@ class DownloadRequest extends MmsRequest {
return false; return false;
} }
public static final Parcelable.Creator<DownloadRequest> CREATOR public static final Parcelable.Creator<DownloadRequest> CREATOR = new Parcelable.Creator<>() {
= new Parcelable.Creator<DownloadRequest>() {
public DownloadRequest createFromParcel(Parcel in) { public DownloadRequest createFromParcel(Parcel in) {
return new DownloadRequest(in); return new DownloadRequest(in);
} }
+1 -2
View File
@@ -145,8 +145,7 @@ class SendRequest extends MmsRequest {
return null; return null;
} }
public static final Parcelable.Creator<SendRequest> CREATOR public static final Parcelable.Creator<SendRequest> CREATOR = new Parcelable.Creator<>() {
= new Parcelable.Creator<SendRequest>() {
public SendRequest createFromParcel(Parcel in) { public SendRequest createFromParcel(Parcel in) {
return new SendRequest(in); return new SendRequest(in);
} }
@@ -122,8 +122,8 @@ public class CharacterSets {
static { static {
// Create the HashMaps. // Create the HashMaps.
MIBENUM_TO_NAME_MAP = new HashMap<Integer, String>(); MIBENUM_TO_NAME_MAP = new HashMap<>();
NAME_TO_MIBENUM_MAP = new HashMap<String, Integer>(); NAME_TO_MIBENUM_MAP = new HashMap<>();
assert(MIBENUM_NUMBERS.length == MIME_NAMES.length); assert(MIBENUM_NUMBERS.length == MIME_NAMES.length);
int count = MIBENUM_NUMBERS.length - 1; int count = MIBENUM_NUMBERS.length - 1;
for(int i = 0; i <= count; i++) { for(int i = 0; i <= count; i++) {
@@ -78,10 +78,10 @@ public class ContentType {
public static final String APP_DRM_CONTENT = "application/vnd.oma.drm.content"; public static final String APP_DRM_CONTENT = "application/vnd.oma.drm.content";
public static final String APP_DRM_MESSAGE = "application/vnd.oma.drm.message"; public static final String APP_DRM_MESSAGE = "application/vnd.oma.drm.message";
private static final ArrayList<String> sSupportedContentTypes = new ArrayList<String>(); private static final ArrayList<String> sSupportedContentTypes = new ArrayList<>();
private static final ArrayList<String> sSupportedImageTypes = new ArrayList<String>(); private static final ArrayList<String> sSupportedImageTypes = new ArrayList<>();
private static final ArrayList<String> sSupportedAudioTypes = new ArrayList<String>(); private static final ArrayList<String> sSupportedAudioTypes = new ArrayList<>();
private static final ArrayList<String> sSupportedVideoTypes = new ArrayList<String>(); private static final ArrayList<String> sSupportedVideoTypes = new ArrayList<>();
static { static {
sSupportedContentTypes.add(TEXT_PLAIN); sSupportedContentTypes.add(TEXT_PLAIN);
@@ -230,7 +230,7 @@ public class EncodedStringValue implements Cloneable {
public static EncodedStringValue[] extract(String src) { public static EncodedStringValue[] extract(String src) {
String[] values = src.split(";"); String[] values = src.split(";");
ArrayList<EncodedStringValue> list = new ArrayList<EncodedStringValue>(); ArrayList<EncodedStringValue> list = new ArrayList<>();
for (int i = 0; i < values.length; i++) { for (int i = 0; i < values.length; i++) {
if (values[i].length() > 0) { if (values[i].length() > 0) {
list.add(new EncodedStringValue(values[i])); list.add(new EncodedStringValue(values[i]));
+5 -5
View File
@@ -34,12 +34,12 @@ public class PduBody {
* Constructor. * Constructor.
*/ */
public PduBody() { public PduBody() {
mParts = new Vector<PduPart>(); mParts = new Vector<>();
mPartMapByContentId = new HashMap<String, PduPart>(); mPartMapByContentId = new HashMap<>();
mPartMapByContentLocation = new HashMap<String, PduPart>(); mPartMapByContentLocation = new HashMap<>();
mPartMapByName = new HashMap<String, PduPart>(); mPartMapByName = new HashMap<>();
mPartMapByFileName = new HashMap<String, PduPart>(); mPartMapByFileName = new HashMap<>();
} }
private void putPartToMaps(PduPart part) { private void putPartToMaps(PduPart part) {
@@ -327,7 +327,7 @@ public class PduHeaders {
* Constructor of PduHeaders. * Constructor of PduHeaders.
*/ */
public PduHeaders() { public PduHeaders() {
mHeaderMap = new HashMap<Integer, Object>(); mHeaderMap = new HashMap<>();
} }
/** /**
@@ -633,7 +633,7 @@ public class PduHeaders {
throw new RuntimeException("Invalid header field!"); throw new RuntimeException("Invalid header field!");
} }
ArrayList<EncodedStringValue> list = new ArrayList<EncodedStringValue>(); ArrayList<EncodedStringValue> list = new ArrayList<>();
for (int i = 0; i < value.length; i++) { for (int i = 0; i < value.length; i++) {
list.add(value[i]); list.add(value[i]);
} }
@@ -665,7 +665,7 @@ public class PduHeaders {
ArrayList<EncodedStringValue> list = ArrayList<EncodedStringValue> list =
(ArrayList<EncodedStringValue>) mHeaderMap.get(field); (ArrayList<EncodedStringValue>) mHeaderMap.get(field);
if (null == list) { if (null == list) {
list = new ArrayList<EncodedStringValue>(); list = new ArrayList<>();
} }
list.add(value); list.add(value);
mHeaderMap.put(field, list); mHeaderMap.put(field, list);
@@ -779,8 +779,7 @@ public class PduParser {
} }
case PduHeaders.CONTENT_TYPE: { case PduHeaders.CONTENT_TYPE: {
HashMap<Integer, Object> map = HashMap<Integer, Object> map = new HashMap<>();
new HashMap<Integer, Object>();
byte[] contentType = byte[] contentType =
parseContentType(pduDataStream, map); parseContentType(pduDataStream, map);
@@ -849,7 +848,7 @@ public class PduParser {
} }
/* parse part's content-type */ /* parse part's content-type */
HashMap<Integer, Object> map = new HashMap<Integer, Object>(); HashMap<Integer, Object> map = new HashMap<>();
byte[] contentType = parseContentType(pduDataStream, map); byte[] contentType = parseContentType(pduDataStream, map);
if (null != contentType) { if (null != contentType) {
part.setContentType(contentType); part.setContentType(contentType);
+1 -1
View File
@@ -126,7 +126,7 @@ public class PduPart {
* Empty Constructor. * Empty Constructor.
*/ */
public PduPart() { public PduPart() {
mPartHeader = new HashMap<Integer, Object>(); mPartHeader = new HashMap<>();
} }
/** /**
+1 -1
View File
@@ -92,7 +92,7 @@ class FactoryImpl extends Factory {
factory.mUIIntents = new UIIntentsImpl(); factory.mUIIntents = new UIIntentsImpl();
factory.mContactContentObserver = new ContactContentObserver(); factory.mContactContentObserver = new ContactContentObserver();
factory.mMediaUtil = new MediaUtilImpl(); factory.mMediaUtil = new MediaUtilImpl();
factory.mSubscriptionPrefs = new SparseArray<BugleSubscriptionPrefs>(); factory.mSubscriptionPrefs = new SparseArray<>();
factory.mCarrierConfigValuesLoader = new BugleCarrierConfigValuesLoader(applicationContext); factory.mCarrierConfigValuesLoader = new BugleCarrierConfigValuesLoader(applicationContext);
if (OsUtil.hasRequiredPermissions()) { if (OsUtil.hasRequiredPermissions()) {
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -87,7 +88,7 @@ public class BitmapPool implements MemoryCache {
Assert.isTrue(!TextUtils.isEmpty(name)); Assert.isTrue(!TextUtils.isEmpty(name));
mPoolName = name; mPoolName = name;
mMaxSize = maxSize; mMaxSize = maxSize;
mPool = new SparseArray<SingleSizePool>(); mPool = new SparseArray<>();
} }
@Override @Override
@@ -67,7 +67,7 @@ public class BugleDatabaseOperations {
// Global cache of phone numbers -> participant id mapping since this call is expensive. // Global cache of phone numbers -> participant id mapping since this call is expensive.
private static final ArrayMap<String, String> sNormalizedPhoneNumberToParticipantIdCache = private static final ArrayMap<String, String> sNormalizedPhoneNumberToParticipantIdCache =
new ArrayMap<String, String>(); new ArrayMap<>();
/** /**
* Convert list of recipient strings (email/phone number) into list of ConversationParticipants * Convert list of recipient strings (email/phone number) into list of ConversationParticipants
@@ -78,8 +78,7 @@ public class BugleDatabaseOperations {
static ArrayList<ParticipantData> getConversationParticipantsFromRecipients( static ArrayList<ParticipantData> getConversationParticipantsFromRecipients(
final List<String> recipients, final int refSubId) { final List<String> recipients, final int refSubId) {
// Generate a list of partially formed participants // Generate a list of partially formed participants
final ArrayList<ParticipantData> participants = new final ArrayList<ParticipantData> participants = new ArrayList<>();
ArrayList<ParticipantData>();
if (recipients != null) { if (recipients != null) {
for (final String recipient : recipients) { for (final String recipient : recipients) {
@@ -98,7 +97,7 @@ public class BugleDatabaseOperations {
Assert.isNotMainThread(); Assert.isNotMainThread();
if (participants.size() > 0) { if (participants.size() > 0) {
// First remove redundant phone numbers // First remove redundant phone numbers
final HashSet<String> recipients = new HashSet<String>(); final HashSet<String> recipients = new HashSet<>();
for (int i = participants.size() - 1; i >= 0; i--) { for (int i = participants.size() - 1; i >= 0; i--) {
final String recipient = participants.get(i).getNormalizedDestination(); final String recipient = participants.get(i).getNormalizedDestination();
if (!recipients.contains(recipient)) { if (!recipients.contains(recipient)) {
@@ -141,7 +140,7 @@ public class BugleDatabaseOperations {
final List<ParticipantData> participants) { final List<ParticipantData> participants) {
Assert.isNotMainThread(); Assert.isNotMainThread();
// First find the thread id for this list of participants. // First find the thread id for this list of participants.
final ArrayList<String> recipients = new ArrayList<String>(); final ArrayList<String> recipients = new ArrayList<>();
for (final ParticipantData participant : participants) { for (final ParticipantData participant : participants) {
recipients.add(participant.getSendDestination()); recipients.add(participant.getSendDestination());
@@ -854,7 +853,7 @@ public class BugleDatabaseOperations {
final ArrayList<ParticipantData> participants = final ArrayList<ParticipantData> participants =
getParticipantsForConversation(dbWrapper, conversationId); getParticipantsForConversation(dbWrapper, conversationId);
final ArrayList<String> recipients = new ArrayList<String>(); final ArrayList<String> recipients = new ArrayList<>();
for (final ParticipantData participant : participants) { for (final ParticipantData participant : participants) {
recipients.add(participant.getSendDestination()); recipients.add(participant.getSendDestination());
} }
@@ -913,8 +912,7 @@ public class BugleDatabaseOperations {
public static ArrayList<ParticipantData> getParticipantsForConversation( public static ArrayList<ParticipantData> getParticipantsForConversation(
final DatabaseWrapper dbWrapper, final String conversationId) { final DatabaseWrapper dbWrapper, final String conversationId) {
Assert.isNotMainThread(); Assert.isNotMainThread();
final ArrayList<ParticipantData> participants = final ArrayList<ParticipantData> participants = new ArrayList<>();
new ArrayList<ParticipantData>();
try (Cursor cursor = dbWrapper.query(DatabaseHelper.PARTICIPANTS_TABLE, try (Cursor cursor = dbWrapper.query(DatabaseHelper.PARTICIPANTS_TABLE,
ParticipantData.ParticipantsQuery.PROJECTION, ParticipantData.ParticipantsQuery.PROJECTION,
ParticipantColumns._ID + " IN ( " + "SELECT " ParticipantColumns._ID + " IN ( " + "SELECT "
@@ -1684,7 +1682,7 @@ public class BugleDatabaseOperations {
private static HashSet<String> getConversationsForParticipants( private static HashSet<String> getConversationsForParticipants(
final ArrayList<String> participantIds) { final ArrayList<String> participantIds) {
final DatabaseWrapper db = DataModel.get().getDatabase(); final DatabaseWrapper db = DataModel.get().getDatabase();
final HashSet<String> conversationIds = new HashSet<String>(); final HashSet<String> conversationIds = new HashSet<>();
final String selection = ConversationParticipantsColumns.PARTICIPANT_ID + "=?"; final String selection = ConversationParticipantsColumns.PARTICIPANT_ID + "=?";
for (final String participantId : participantIds) { for (final String participantId : participantIds) {
@@ -1734,7 +1732,7 @@ public class BugleDatabaseOperations {
@DoesNotRunOnMainThread @DoesNotRunOnMainThread
public static void refreshConversationsForParticipant(final String participantId) { public static void refreshConversationsForParticipant(final String participantId) {
Assert.isNotMainThread(); Assert.isNotMainThread();
final ArrayList<String> participantList = new ArrayList<String>(1); final ArrayList<String> participantList = new ArrayList<>(1);
participantList.add(participantId); participantList.add(participantId);
refreshConversationsForParticipants(participantList); refreshConversationsForParticipants(participantList);
} }
@@ -1764,7 +1762,7 @@ public class BugleDatabaseOperations {
final String rowKey, final String rowId, final ContentValues values) { final String rowKey, final String rowId, final ContentValues values) {
Assert.isNotMainThread(); Assert.isNotMainThread();
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
final ArrayList<String> whereValues = new ArrayList<String>(values.size() + 1); final ArrayList<String> whereValues = new ArrayList<>(values.size() + 1);
whereValues.add(rowId); whereValues.add(rowId);
for (final String key : values.keySet()) { for (final String key : values.keySet()) {
@@ -119,8 +119,7 @@ public class BugleNotifications {
private static final String WEARABLE_COMPANION_APP_PACKAGE = "com.google.android.wearable.app"; private static final String WEARABLE_COMPANION_APP_PACKAGE = "com.google.android.wearable.app";
private static final Set<NotificationState> sPendingNotifications = private static final Set<NotificationState> sPendingNotifications = new HashSet<>();
new HashSet<NotificationState>();
private static int sWearableImageWidth; private static int sWearableImageWidth;
private static int sWearableImageHeight; private static int sWearableImageHeight;
@@ -134,8 +133,7 @@ public class BugleNotifications {
// sLastMessageDingTime is a map between a conversation id and a time. It's used to keep track // sLastMessageDingTime is a map between a conversation id and a time. It's used to keep track
// of the time we last dinged a message for this conversation. When messages are coming in // of the time we last dinged a message for this conversation. When messages are coming in
// at flurry, we don't want to over-ding the user. // at flurry, we don't want to over-ding the user.
private static final SimpleArrayMap<String, Long> sLastMessageDingTime = private static final SimpleArrayMap<String, Long> sLastMessageDingTime = new SimpleArrayMap<>();
new SimpleArrayMap<String, Long>();
private static int sTimeBetweenDingsMs; private static int sTimeBetweenDingsMs;
/** /**
@@ -57,7 +57,7 @@ public class DatabaseWrapper {
// track transaction on a per thread basis // track transaction on a per thread basis
private static final ThreadLocal<Stack<TransactionData>> sTransactionDepth = private static final ThreadLocal<Stack<TransactionData>> sTransactionDepth =
ThreadLocal.withInitial(() -> new Stack<TransactionData>()); ThreadLocal.withInitial(() -> new Stack<>());
private static final String[] sFormatStrings = new String[] { private static final String[] sFormatStrings = new String[] {
"took %d ms to %s", "took %d ms to %s",
@@ -69,7 +69,7 @@ public class DatabaseWrapper {
mLog = LogUtil.isLoggable(LogUtil.BUGLE_DATABASE_PERF_TAG, LogUtil.VERBOSE); mLog = LogUtil.isLoggable(LogUtil.BUGLE_DATABASE_PERF_TAG, LogUtil.VERBOSE);
mDatabase = db; mDatabase = db;
mContext = context; mContext = context;
mCompiledStatements = new SparseArray<SQLiteStatement>(); mCompiledStatements = new SparseArray<>();
} }
public SQLiteStatement getStatementInTransaction(final int index, final String statement) { public SQLiteStatement getStatementInTransaction(final int index, final String statement) {
@@ -86,8 +86,7 @@ public class FrequentContactsCursorBuilder {
// First, go through the frequents cursor and take note of all lookup keys and their // First, go through the frequents cursor and take note of all lookup keys and their
// corresponding rank in the frequents list. // corresponding rank in the frequents list.
final SimpleArrayMap<String, Integer> lookupKeyToRankMap = final SimpleArrayMap<String, Integer> lookupKeyToRankMap = new SimpleArrayMap<>();
new SimpleArrayMap<String, Integer>();
int oldPosition = mFrequentContactsCursor.getPosition(); int oldPosition = mFrequentContactsCursor.getPosition();
int rank = 0; int rank = 0;
mFrequentContactsCursor.moveToPosition(-1); mFrequentContactsCursor.moveToPosition(-1);
@@ -102,8 +101,7 @@ public class FrequentContactsCursorBuilder {
// (multiple phone numbers etc.) and store that in an array list. Since the all // (multiple phone numbers etc.) and store that in an array list. Since the all
// contacts list only contains phone contacts, this step will ensure that we filter // contacts list only contains phone contacts, this step will ensure that we filter
// out any invalid/email contacts in the frequents list. // out any invalid/email contacts in the frequents list.
final ArrayList<Object[]> rows = final ArrayList<Object[]> rows = new ArrayList<>(mFrequentContactsCursor.getCount());
new ArrayList<Object[]>(mFrequentContactsCursor.getCount());
oldPosition = mAllContactsCursor.getPosition(); oldPosition = mAllContactsCursor.getPosition();
mAllContactsCursor.moveToPosition(-1); mAllContactsCursor.moveToPosition(-1);
while (mAllContactsCursor.moveToNext()) { while (mAllContactsCursor.moveToNext()) {
@@ -44,8 +44,7 @@ import java.util.List;
public class MediaScratchFileProvider extends FileProvider { public class MediaScratchFileProvider extends FileProvider {
private static final String TAG = LogUtil.BUGLE_TAG; private static final String TAG = LogUtil.BUGLE_TAG;
private static final SimpleArrayMap<Uri, String> sUriToDisplayNameMap = private static final SimpleArrayMap<Uri, String> sUriToDisplayNameMap = new SimpleArrayMap<>();
new SimpleArrayMap<Uri, String>();
@VisibleForTesting @VisibleForTesting
public static final String AUTHORITY = public static final String AUTHORITY =
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -25,7 +26,7 @@ import java.util.HashSet;
* is memory pressure provide a callback to reclaim the memory in the caches. * is memory pressure provide a callback to reclaim the memory in the caches.
*/ */
public class MemoryCacheManager { public class MemoryCacheManager {
private final HashSet<MemoryCache> mMemoryCaches = new HashSet<MemoryCache>(); private final HashSet<MemoryCache> mMemoryCaches = new HashSet<>();
private final Object mMemoryCacheLock = new Object(); private final Object mMemoryCacheLock = new Object();
public static MemoryCacheManager get() { public static MemoryCacheManager get() {
@@ -226,7 +226,7 @@ public abstract class MessageNotificationState extends NotificationState {
mIncludeEmailAddress = includeEmailAddress; mIncludeEmailAddress = includeEmailAddress;
mReceivedTimestamp = receivedTimestamp; mReceivedTimestamp = receivedTimestamp;
mSelfParticipantId = selfParticipantId; mSelfParticipantId = selfParticipantId;
mLineInfos = new ArrayList<NotificationLineInfo>(); mLineInfos = new ArrayList<>();
mTotalMessageCount = 0; mTotalMessageCount = 0;
mAvatarUri = avatarUri; mAvatarUri = avatarUri;
mContactUri = contactUri; mContactUri = contactUri;
@@ -340,8 +340,7 @@ public abstract class MessageNotificationState extends NotificationState {
*/ */
public static class MultiConversationNotificationState extends MessageNotificationState { public static class MultiConversationNotificationState extends MessageNotificationState {
public final List<MessageNotificationState> public final List<MessageNotificationState> mChildren = new ArrayList<>();
mChildren = new ArrayList<MessageNotificationState>();
public MultiConversationNotificationState( public MultiConversationNotificationState(
final ConversationInfoList convList, final MessageNotificationState state) { final ConversationInfoList convList, final MessageNotificationState state) {
@@ -618,7 +617,7 @@ public abstract class MessageNotificationState extends NotificationState {
final Iterator<ParticipantData> iter = participantsData.iterator(); final Iterator<ParticipantData> iter = participantsData.iterator();
final HashMap<String, Integer> firstNames = new HashMap<String, Integer>(); final HashMap<String, Integer> firstNames = new HashMap<>();
boolean seenSelf = false; boolean seenSelf = false;
while (iter.hasNext()) { while (iter.hasNext()) {
final ParticipantData participant = iter.next(); final ParticipantData participant = iter.next();
@@ -1040,13 +1039,13 @@ public abstract class MessageNotificationState extends NotificationState {
// For now, only show avatars for notifications for a single conversation. // For now, only show avatars for notifications for a single conversation.
if (convInfo.mAvatarUri != null) { if (convInfo.mAvatarUri != null) {
if (state.mParticipantAvatarsUris == null) { if (state.mParticipantAvatarsUris == null) {
state.mParticipantAvatarsUris = new ArrayList<Uri>(1); state.mParticipantAvatarsUris = new ArrayList<>(1);
} }
state.mParticipantAvatarsUris.add(convInfo.mAvatarUri); state.mParticipantAvatarsUris.add(convInfo.mAvatarUri);
} }
if (convInfo.mContactUri != null) { if (convInfo.mContactUri != null) {
if (state.mParticipantContactUris == null) { if (state.mParticipantContactUris == null) {
state.mParticipantContactUris = new ArrayList<Uri>(1); state.mParticipantContactUris = new ArrayList<>(1);
} }
state.mParticipantContactUris.add(convInfo.mContactUri); state.mParticipantContactUris.add(convInfo.mContactUri);
} }
@@ -1160,11 +1159,11 @@ public abstract class MessageNotificationState extends NotificationState {
if (messageDataCursor != null) { if (messageDataCursor != null) {
final MessageData messageData = new MessageData(); final MessageData messageData = new MessageData();
final HashSet<String> conversationsWithFailedMessages = new HashSet<String>(); final HashSet<String> conversationsWithFailedMessages = new HashSet<>();
// track row ids in case we want to display something that requires this // track row ids in case we want to display something that requires this
// information // information
final ArrayList<Integer> failedMessages = new ArrayList<Integer>(); final ArrayList<Integer> failedMessages = new ArrayList<>();
int cursorPosition = -1; int cursorPosition = -1;
final long when = 0; final long when = 0;
@@ -71,7 +71,7 @@ public abstract class NotificationState {
NotificationState(final ConversationIdSet conversationIds) { NotificationState(final ConversationIdSet conversationIds) {
mConversationIds = conversationIds; mConversationIds = conversationIds;
mPeople = new HashSet<String>(); mPeople = new HashSet<>();
} }
/** /**
@@ -234,7 +234,7 @@ public class ParticipantRefresh {
refreshSelfParticipantList(); refreshSelfParticipantList();
} }
final ArrayList<String> changedParticipants = new ArrayList<String>(); final ArrayList<String> changedParticipants = new ArrayList<>();
String selection = null; String selection = null;
String[] selectionArgs = null; String[] selectionArgs = null;
@@ -306,7 +306,7 @@ public class ParticipantRefresh {
private static Set<Integer> getExistingSubIds() { private static Set<Integer> getExistingSubIds() {
final DatabaseWrapper db = DataModel.get().getDatabase(); final DatabaseWrapper db = DataModel.get().getDatabase();
final HashSet<Integer> existingSubIds = new HashSet<Integer>(); final HashSet<Integer> existingSubIds = new HashSet<>();
try (Cursor cursor = db.query(DatabaseHelper.PARTICIPANTS_TABLE, try (Cursor cursor = db.query(DatabaseHelper.PARTICIPANTS_TABLE,
ParticipantsQuery.PROJECTION, ParticipantsQuery.PROJECTION,
@@ -346,7 +346,7 @@ public class ParticipantRefresh {
final List<SubscriptionInfo> subInfoRecords = final List<SubscriptionInfo> subInfoRecords =
PhoneUtils.getDefault().getActiveSubscriptionInfoList(); PhoneUtils.getDefault().getActiveSubscriptionInfoList();
final ArrayMap<Integer, SubscriptionInfo> activeSubscriptionIdToRecordMap = final ArrayMap<Integer, SubscriptionInfo> activeSubscriptionIdToRecordMap =
new ArrayMap<Integer, SubscriptionInfo>(); new ArrayMap<>();
db.beginTransaction(); db.beginTransaction();
final Set<Integer> existingSubIds = getExistingSubIds(); final Set<Integer> existingSubIds = getExistingSubIds();
@@ -603,7 +603,7 @@ public class ParticipantRefresh {
*/ */
private static List<String> getInactiveSelfParticipantIds() { private static List<String> getInactiveSelfParticipantIds() {
final DatabaseWrapper db = DataModel.get().getDatabase(); final DatabaseWrapper db = DataModel.get().getDatabase();
final List<String> inactiveSelf = new ArrayList<String>(); final List<String> inactiveSelf = new ArrayList<>();
final String selection = ParticipantColumns.SIM_SLOT_ID + "=? AND " + final String selection = ParticipantColumns.SIM_SLOT_ID + "=? AND " +
SELF_PARTICIPANTS_CLAUSE; SELF_PARTICIPANTS_CLAUSE;
@@ -628,7 +628,7 @@ public class ParticipantRefresh {
*/ */
private static List<String> getConversationsWithSelfParticipantIds(final List<String> selfIds) { private static List<String> getConversationsWithSelfParticipantIds(final List<String> selfIds) {
final DatabaseWrapper db = DataModel.get().getDatabase(); final DatabaseWrapper db = DataModel.get().getDatabase();
final List<String> conversationIds = new ArrayList<String>(); final List<String> conversationIds = new ArrayList<>();
Cursor cursor = null; Cursor cursor = null;
try { try {
@@ -365,12 +365,10 @@ public class SyncManager {
public static class ThreadInfoCache { public static class ThreadInfoCache {
// Cache of thread->conversationId map // Cache of thread->conversationId map
private final LongSparseArray<String> mThreadToConversationId = private final LongSparseArray<String> mThreadToConversationId = new LongSparseArray<>();
new LongSparseArray<String>();
// Cache of thread->recipients map // Cache of thread->recipients map
private final LongSparseArray<List<String>> mThreadToRecipients = private final LongSparseArray<List<String>> mThreadToRecipients = new LongSparseArray<>();
new LongSparseArray<List<String>>();
// Remember the conversation ids that need to be archived // Remember the conversation ids that need to be archived
private final HashSet<String> mArchivedConversations = new HashSet<>(); private final HashSet<String> mArchivedConversations = new HashSet<>();
@@ -47,7 +47,7 @@ public abstract class Action implements Parcelable {
protected final Bundle actionParameters; protected final Bundle actionParameters;
// This does not get written to the parcel // This does not get written to the parcel
private final List<Action> mBackgroundActions = new LinkedList<Action>(); private final List<Action> mBackgroundActions = new LinkedList<>();
/** /**
* Process the action locally - runs on action service thread. * Process the action locally - runs on action service thread.
@@ -413,8 +413,7 @@ public class ActionMonitor {
* Map of action monitors indexed by actionKey * Map of action monitors indexed by actionKey
*/ */
@VisibleForTesting @VisibleForTesting
static final SimpleArrayMap<String, ActionMonitor> sActionMonitors = static final SimpleArrayMap<String, ActionMonitor> sActionMonitors = new SimpleArrayMap<>();
new SimpleArrayMap<String, ActionMonitor>();
/** /**
* Insert new monitor into map * Insert new monitor into map
@@ -188,7 +188,7 @@ public class DeleteConversationAction extends Action implements Parcelable {
} }
public static final Parcelable.Creator<DeleteConversationAction> CREATOR public static final Parcelable.Creator<DeleteConversationAction> CREATOR
= new Parcelable.Creator<DeleteConversationAction>() { = new Parcelable.Creator<>() {
@Override @Override
public DeleteConversationAction createFromParcel(final Parcel in) { public DeleteConversationAction createFromParcel(final Parcel in) {
return new DeleteConversationAction(in); return new DeleteConversationAction(in);
@@ -119,7 +119,7 @@ public class DeleteMessageAction extends Action implements Parcelable {
} }
public static final Parcelable.Creator<DeleteMessageAction> CREATOR public static final Parcelable.Creator<DeleteMessageAction> CREATOR
= new Parcelable.Creator<DeleteMessageAction>() { = new Parcelable.Creator<>() {
@Override @Override
public DeleteMessageAction createFromParcel(final Parcel in) { public DeleteMessageAction createFromParcel(final Parcel in) {
return new DeleteMessageAction(in); return new DeleteMessageAction(in);
@@ -327,8 +327,7 @@ public class DownloadMmsAction extends Action implements Parcelable {
super(in); super(in);
} }
public static final Parcelable.Creator<DownloadMmsAction> CREATOR public static final Parcelable.Creator<DownloadMmsAction> CREATOR = new Parcelable.Creator<>() {
= new Parcelable.Creator<DownloadMmsAction>() {
@Override @Override
public DownloadMmsAction createFromParcel(final Parcel in) { public DownloadMmsAction createFromParcel(final Parcel in) {
return new DownloadMmsAction(in); return new DownloadMmsAction(in);
@@ -97,7 +97,7 @@ public class FixupMessageStatusOnStartupAction extends Action implements Parcela
} }
public static final Parcelable.Creator<FixupMessageStatusOnStartupAction> CREATOR public static final Parcelable.Creator<FixupMessageStatusOnStartupAction> CREATOR
= new Parcelable.Creator<FixupMessageStatusOnStartupAction>() { = new Parcelable.Creator<>() {
@Override @Override
public FixupMessageStatusOnStartupAction createFromParcel(final Parcel in) { public FixupMessageStatusOnStartupAction createFromParcel(final Parcel in) {
return new FixupMessageStatusOnStartupAction(in); return new FixupMessageStatusOnStartupAction(in);
@@ -157,7 +157,7 @@ public class GetOrCreateConversationAction extends Action implements Parcelable
} }
public static final Parcelable.Creator<GetOrCreateConversationAction> CREATOR public static final Parcelable.Creator<GetOrCreateConversationAction> CREATOR
= new Parcelable.Creator<GetOrCreateConversationAction>() { = new Parcelable.Creator<>() {
@Override @Override
public GetOrCreateConversationAction createFromParcel(final Parcel in) { public GetOrCreateConversationAction createFromParcel(final Parcel in) {
return new GetOrCreateConversationAction(in); return new GetOrCreateConversationAction(in);
@@ -463,7 +463,7 @@ public class InsertNewMessageAction extends Action implements Parcelable {
} }
public static final Parcelable.Creator<InsertNewMessageAction> CREATOR public static final Parcelable.Creator<InsertNewMessageAction> CREATOR
= new Parcelable.Creator<InsertNewMessageAction>() { = new Parcelable.Creator<>() {
@Override @Override
public InsertNewMessageAction createFromParcel(final Parcel in) { public InsertNewMessageAction createFromParcel(final Parcel in) {
return new InsertNewMessageAction(in); return new InsertNewMessageAction(in);
@@ -96,8 +96,7 @@ public class MarkAsReadAction extends Action implements Parcelable {
super(in); super(in);
} }
public static final Parcelable.Creator<MarkAsReadAction> CREATOR public static final Parcelable.Creator<MarkAsReadAction> CREATOR = new Parcelable.Creator<>() {
= new Parcelable.Creator<MarkAsReadAction>() {
@Override @Override
public MarkAsReadAction createFromParcel(final Parcel in) { public MarkAsReadAction createFromParcel(final Parcel in) {
return new MarkAsReadAction(in); return new MarkAsReadAction(in);
@@ -109,8 +109,7 @@ public class MarkAsSeenAction extends Action implements Parcelable {
super(in); super(in);
} }
public static final Parcelable.Creator<MarkAsSeenAction> CREATOR public static final Parcelable.Creator<MarkAsSeenAction> CREATOR = new Parcelable.Creator<>() {
= new Parcelable.Creator<MarkAsSeenAction>() {
@Override @Override
public MarkAsSeenAction createFromParcel(final Parcel in) { public MarkAsSeenAction createFromParcel(final Parcel in) {
return new MarkAsSeenAction(in); return new MarkAsSeenAction(in);
@@ -106,7 +106,7 @@ public class ProcessDeliveryReportAction extends Action implements Parcelable {
} }
public static final Parcelable.Creator<ProcessDeliveryReportAction> CREATOR public static final Parcelable.Creator<ProcessDeliveryReportAction> CREATOR
= new Parcelable.Creator<ProcessDeliveryReportAction>() { = new Parcelable.Creator<>() {
@Override @Override
public ProcessDeliveryReportAction createFromParcel(final Parcel in) { public ProcessDeliveryReportAction createFromParcel(final Parcel in) {
return new ProcessDeliveryReportAction(in); return new ProcessDeliveryReportAction(in);
@@ -565,7 +565,7 @@ public class ProcessDownloadedMmsAction extends Action {
} }
public static final Parcelable.Creator<ProcessDownloadedMmsAction> CREATOR public static final Parcelable.Creator<ProcessDownloadedMmsAction> CREATOR
= new Parcelable.Creator<ProcessDownloadedMmsAction>() { = new Parcelable.Creator<>() {
@Override @Override
public ProcessDownloadedMmsAction createFromParcel(final Parcel in) { public ProcessDownloadedMmsAction createFromParcel(final Parcel in) {
return new ProcessDownloadedMmsAction(in); return new ProcessDownloadedMmsAction(in);
@@ -457,7 +457,7 @@ public class ProcessPendingMessagesAction extends Action implements Parcelable {
} }
public static final Parcelable.Creator<ProcessPendingMessagesAction> CREATOR public static final Parcelable.Creator<ProcessPendingMessagesAction> CREATOR
= new Parcelable.Creator<ProcessPendingMessagesAction>() { = new Parcelable.Creator<>() {
@Override @Override
public ProcessPendingMessagesAction createFromParcel(final Parcel in) { public ProcessPendingMessagesAction createFromParcel(final Parcel in) {
return new ProcessPendingMessagesAction(in); return new ProcessPendingMessagesAction(in);
@@ -296,7 +296,7 @@ public class ProcessSentMessageAction extends Action {
} }
public static final Parcelable.Creator<ProcessSentMessageAction> CREATOR public static final Parcelable.Creator<ProcessSentMessageAction> CREATOR
= new Parcelable.Creator<ProcessSentMessageAction>() { = new Parcelable.Creator<>() {
@Override @Override
public ProcessSentMessageAction createFromParcel(final Parcel in) { public ProcessSentMessageAction createFromParcel(final Parcel in) {
return new ProcessSentMessageAction(in); return new ProcessSentMessageAction(in);
@@ -150,7 +150,7 @@ public class ReadDraftDataAction extends Action implements Parcelable {
} }
public static final Parcelable.Creator<ReadDraftDataAction> CREATOR public static final Parcelable.Creator<ReadDraftDataAction> CREATOR
= new Parcelable.Creator<ReadDraftDataAction>() { = new Parcelable.Creator<>() {
@Override @Override
public ReadDraftDataAction createFromParcel(final Parcel in) { public ReadDraftDataAction createFromParcel(final Parcel in) {
return new ReadDraftDataAction(in); return new ReadDraftDataAction(in);
@@ -181,7 +181,7 @@ public class ReceiveMmsMessageAction extends Action implements Parcelable {
} }
public static final Parcelable.Creator<ReceiveMmsMessageAction> CREATOR public static final Parcelable.Creator<ReceiveMmsMessageAction> CREATOR
= new Parcelable.Creator<ReceiveMmsMessageAction>() { = new Parcelable.Creator<>() {
@Override @Override
public ReceiveMmsMessageAction createFromParcel(final Parcel in) { public ReceiveMmsMessageAction createFromParcel(final Parcel in) {
return new ReceiveMmsMessageAction(in); return new ReceiveMmsMessageAction(in);
@@ -184,7 +184,7 @@ public class ReceiveSmsMessageAction extends Action implements Parcelable {
} }
public static final Parcelable.Creator<ReceiveSmsMessageAction> CREATOR public static final Parcelable.Creator<ReceiveSmsMessageAction> CREATOR
= new Parcelable.Creator<ReceiveSmsMessageAction>() { = new Parcelable.Creator<>() {
@Override @Override
public ReceiveSmsMessageAction createFromParcel(final Parcel in) { public ReceiveSmsMessageAction createFromParcel(final Parcel in) {
return new ReceiveSmsMessageAction(in); return new ReceiveSmsMessageAction(in);
@@ -115,7 +115,7 @@ public class RedownloadMmsAction extends Action implements Parcelable {
} }
public static final Parcelable.Creator<RedownloadMmsAction> CREATOR public static final Parcelable.Creator<RedownloadMmsAction> CREATOR
= new Parcelable.Creator<RedownloadMmsAction>() { = new Parcelable.Creator<>() {
@Override @Override
public RedownloadMmsAction createFromParcel(final Parcel in) { public RedownloadMmsAction createFromParcel(final Parcel in) {
return new RedownloadMmsAction(in); return new RedownloadMmsAction(in);
@@ -115,7 +115,7 @@ public class ResendMessageAction extends Action implements Parcelable {
} }
public static final Parcelable.Creator<ResendMessageAction> CREATOR public static final Parcelable.Creator<ResendMessageAction> CREATOR
= new Parcelable.Creator<ResendMessageAction>() { = new Parcelable.Creator<>() {
@Override @Override
public ResendMessageAction createFromParcel(final Parcel in) { public ResendMessageAction createFromParcel(final Parcel in) {
return new ResendMessageAction(in); return new ResendMessageAction(in);
@@ -435,8 +435,7 @@ public class SendMessageAction extends Action implements Parcelable {
super(in); super(in);
} }
public static final Parcelable.Creator<SendMessageAction> CREATOR public static final Parcelable.Creator<SendMessageAction> CREATOR = new Parcelable.Creator<>() {
= new Parcelable.Creator<SendMessageAction>() {
@Override @Override
public SendMessageAction createFromParcel(final Parcel in) { public SendMessageAction createFromParcel(final Parcel in) {
return new SendMessageAction(in); return new SendMessageAction(in);
@@ -73,7 +73,7 @@ class SyncMessageBatch {
mMmsToAdd = mmsToAdd; mMmsToAdd = mmsToAdd;
mMessagesToDelete = messagesToDelete; mMessagesToDelete = messagesToDelete;
mCache = cache; mCache = cache;
mConversationsToUpdate = new HashSet<String>(); mConversationsToUpdate = new HashSet<>();
} }
void updateLocalDatabase() { void updateLocalDatabase() {
@@ -221,12 +221,11 @@ public class SyncMessagesAction extends Action implements Parcelable {
cache.clear(); cache.clear();
// Sms messages to store // Sms messages to store
final ArrayList<SmsMessage> smsToAdd = new ArrayList<SmsMessage>(); final ArrayList<SmsMessage> smsToAdd = new ArrayList<>();
// Mms messages to store // Mms messages to store
final LongSparseArray<MmsMessage> mmsToAdd = new LongSparseArray<MmsMessage>(); final LongSparseArray<MmsMessage> mmsToAdd = new LongSparseArray<>();
// List of local SMS/MMS to remove // List of local SMS/MMS to remove
final ArrayList<LocalDatabaseMessage> messagesToDelete = final ArrayList<LocalDatabaseMessage> messagesToDelete = new ArrayList<>();
new ArrayList<LocalDatabaseMessage>();
long lastTimestampMillis = SYNC_FAILED; long lastTimestampMillis = SYNC_FAILED;
if (syncManager.isSyncing(upperBoundTimeMillis)) { if (syncManager.isSyncing(upperBoundTimeMillis)) {
@@ -242,7 +241,7 @@ public class SyncMessagesAction extends Action implements Parcelable {
// If comparison succeeds bundle up the changes for processing in ActionService // If comparison succeeds bundle up the changes for processing in ActionService
if (lastTimestampMillis > SYNC_FAILED) { if (lastTimestampMillis > SYNC_FAILED) {
final ArrayList<MmsMessage> mmsToAddList = new ArrayList<MmsMessage>(); final ArrayList<MmsMessage> mmsToAddList = new ArrayList<>();
for (int i = 0; i < mmsToAdd.size(); i++) { for (int i = 0; i < mmsToAdd.size(); i++) {
final MmsMessage mms = mmsToAdd.valueAt(i); final MmsMessage mms = mmsToAdd.valueAt(i);
mmsToAddList.add(mms); mmsToAddList.add(mms);
@@ -610,7 +609,7 @@ public class SyncMessagesAction extends Action implements Parcelable {
} }
public static final Parcelable.Creator<SyncMessagesAction> CREATOR public static final Parcelable.Creator<SyncMessagesAction> CREATOR
= new Parcelable.Creator<SyncMessagesAction>() { = new Parcelable.Creator<>() {
@Override @Override
public SyncMessagesAction createFromParcel(final Parcel in) { public SyncMessagesAction createFromParcel(final Parcel in) {
return new SyncMessagesAction(in); return new SyncMessagesAction(in);
@@ -77,7 +77,7 @@ public class UpdateConversationArchiveStatusAction extends Action {
} }
public static final Parcelable.Creator<UpdateConversationArchiveStatusAction> CREATOR public static final Parcelable.Creator<UpdateConversationArchiveStatusAction> CREATOR
= new Parcelable.Creator<UpdateConversationArchiveStatusAction>() { = new Parcelable.Creator<>() {
@Override @Override
public UpdateConversationArchiveStatusAction createFromParcel(final Parcel in) { public UpdateConversationArchiveStatusAction createFromParcel(final Parcel in) {
return new UpdateConversationArchiveStatusAction(in); return new UpdateConversationArchiveStatusAction(in);
@@ -132,7 +132,7 @@ public class UpdateDestinationBlockedAction extends Action {
} }
public static final Parcelable.Creator<UpdateDestinationBlockedAction> CREATOR public static final Parcelable.Creator<UpdateDestinationBlockedAction> CREATOR
= new Parcelable.Creator<UpdateDestinationBlockedAction>() { = new Parcelable.Creator<>() {
@Override @Override
public UpdateDestinationBlockedAction createFromParcel(final Parcel in) { public UpdateDestinationBlockedAction createFromParcel(final Parcel in) {
return new UpdateDestinationBlockedAction(in); return new UpdateDestinationBlockedAction(in);
@@ -47,7 +47,7 @@ public class UpdateMessageNotificationAction extends Action {
} }
public static final Parcelable.Creator<UpdateMessageNotificationAction> CREATOR public static final Parcelable.Creator<UpdateMessageNotificationAction> CREATOR
= new Parcelable.Creator<UpdateMessageNotificationAction>() { = new Parcelable.Creator<>() {
@Override @Override
public UpdateMessageNotificationAction createFromParcel(final Parcel in) { public UpdateMessageNotificationAction createFromParcel(final Parcel in) {
return new UpdateMessageNotificationAction(in); return new UpdateMessageNotificationAction(in);
@@ -87,7 +87,7 @@ public class UpdateMessagePartSizeAction extends Action implements Parcelable {
} }
public static final Parcelable.Creator<UpdateMessagePartSizeAction> CREATOR public static final Parcelable.Creator<UpdateMessagePartSizeAction> CREATOR
= new Parcelable.Creator<UpdateMessagePartSizeAction>() { = new Parcelable.Creator<>() {
@Override @Override
public UpdateMessagePartSizeAction createFromParcel(final Parcel in) { public UpdateMessagePartSizeAction createFromParcel(final Parcel in) {
return new UpdateMessagePartSizeAction(in); return new UpdateMessagePartSizeAction(in);
@@ -88,7 +88,7 @@ public class WriteDraftMessageAction extends Action implements Parcelable {
} }
public static final Parcelable.Creator<WriteDraftMessageAction> CREATOR public static final Parcelable.Creator<WriteDraftMessageAction> CREATOR
= new Parcelable.Creator<WriteDraftMessageAction>() { = new Parcelable.Creator<>() {
@Override @Override
public WriteDraftMessageAction createFromParcel(final Parcel in) { public WriteDraftMessageAction createFromParcel(final Parcel in) {
return new WriteDraftMessageAction(in); return new WriteDraftMessageAction(in);
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -33,7 +34,7 @@ public abstract class BindingBase<T extends BindableData> {
* Creates a new exclusively owned binding for the owner object. * Creates a new exclusively owned binding for the owner object.
*/ */
public static <T extends BindableData> Binding<T> createBinding(final Object owner) { public static <T extends BindableData> Binding<T> createBinding(final Object owner) {
return new Binding<T>(owner); return new Binding<>(owner);
} }
/** /**
@@ -43,7 +44,7 @@ public abstract class BindingBase<T extends BindableData> {
*/ */
public static <T extends BindableData> ImmutableBindingRef<T> createBindingReference( public static <T extends BindableData> ImmutableBindingRef<T> createBindingReference(
final BindingBase<T> srcBinding) { final BindingBase<T> srcBinding) {
return new ImmutableBindingRef<T>(srcBinding); return new ImmutableBindingRef<>(srcBinding);
} }
/** /**
@@ -52,7 +53,7 @@ public abstract class BindingBase<T extends BindableData> {
*/ */
public static <T extends BindableData> DetachableBinding<T> createDetachableBinding( public static <T extends BindableData> DetachableBinding<T> createDetachableBinding(
final Object owner) { final Object owner) {
return new DetachableBinding<T>(owner); return new DetachableBinding<>(owner);
} }
public abstract T getData(); public abstract T getData();
@@ -72,7 +72,7 @@ public class ConversationData extends BindableData {
* for each message. * for each message.
*/ */
public List<Integer> getPositions(final String conversationId, final List<Long> ids) { public List<Integer> getPositions(final String conversationId, final List<Long> ids) {
final ArrayList<Integer> result = new ArrayList<Integer>(); final ArrayList<Integer> result = new ArrayList<>();
if (ids.isEmpty()) { if (ids.isEmpty()) {
return result; return result;
@@ -84,7 +84,7 @@ public class ConversationData extends BindableData {
new String [] { conversationId })); new String [] { conversationId }));
if (c != null) { if (c != null) {
try { try {
final Set<Long> idsSet = new HashSet<Long>(ids); final Set<Long> idsSet = new HashSet<>(ids);
if (c.moveToLast()) { if (c.moveToLast()) {
do { do {
final long messageId = c.getLong(0); final long messageId = c.getLong(0);
@@ -81,7 +81,7 @@ public class ConversationListData extends BindableData
private static final int INDEX_BLOCKED_PARTICIPANTS_NORMALIZED_DESTINATION = 1; private static final int INDEX_BLOCKED_PARTICIPANTS_NORMALIZED_DESTINATION = 1;
// all blocked participants // all blocked participants
private final HashSet<String> mBlockedParticipants = new HashSet<String>(); private final HashSet<String> mBlockedParticipants = new HashSet<>();
@NonNull @NonNull
@Override @Override
@@ -489,7 +489,7 @@ public class ConversationListItemData {
return participants.get(0).getDisplayName(true); return participants.get(0).getDisplayName(true);
} }
final ArrayList<String> participantNames = new ArrayList<String>(); final ArrayList<String> participantNames = new ArrayList<>();
for (final ParticipantData participant : participants) { for (final ParticipantData participant : participants) {
// Prefer first name over full name for group conversation // Prefer first name over full name for group conversation
participantNames.add(participant.getDisplayName(false)); participantNames.add(participant.getDisplayName(false));
@@ -163,7 +163,7 @@ public class ConversationMessageData {
// statics to avoid unnecessary object allocation // statics to avoid unnecessary object allocation
private static final StringBuilder sUnquoteStringBuilder = new StringBuilder(); private static final StringBuilder sUnquoteStringBuilder = new StringBuilder();
private static final ArrayList<String> sUnquoteResults = new ArrayList<String>(); private static final ArrayList<String> sUnquoteResults = new ArrayList<>();
// this lock is used to guard access to the above statics // this lock is used to guard access to the above statics
private static final Object sUnquoteLock = new Object(); private static final Object sUnquoteLock = new Object();
@@ -281,7 +281,7 @@ public class ConversationMessageData {
final String rawTexts, final String rawTexts,
final int partsCount, final int partsCount,
final String messageId) { final String messageId) {
final List<MessagePartData> parts = new LinkedList<MessagePartData>(); final List<MessagePartData> parts = new LinkedList<>();
if (partsCount == 1) { if (partsCount == 1) {
parts.add(makePartData( parts.add(makePartData(
rawIds, rawIds,
@@ -42,7 +42,7 @@ public class ConversationParticipantsData implements Iterable<ParticipantData> {
private int mParticipantCountExcludingSelf = 0; private int mParticipantCountExcludingSelf = 0;
public ConversationParticipantsData() { public ConversationParticipantsData() {
mConversationParticipantsMap = new SimpleArrayMap<String, ParticipantData>(); mConversationParticipantsMap = new SimpleArrayMap<>();
} }
public void bind(final Cursor cursor) { public void bind(final Cursor cursor) {
@@ -66,7 +66,7 @@ public class ConversationParticipantsData implements Iterable<ParticipantData> {
ArrayList<ParticipantData> getParticipantListExcludingSelf() { ArrayList<ParticipantData> getParticipantListExcludingSelf() {
final ArrayList<ParticipantData> retList = final ArrayList<ParticipantData> retList =
new ArrayList<ParticipantData>(mConversationParticipantsMap.size()); new ArrayList<>(mConversationParticipantsMap.size());
for (int i = 0; i < mConversationParticipantsMap.size(); i++) { for (int i = 0; i < mConversationParticipantsMap.size(); i++) {
final ParticipantData participant = mConversationParticipantsMap.valueAt(i); final ParticipantData participant = mConversationParticipantsMap.valueAt(i);
if (!participant.isSelf()) { if (!participant.isSelf()) {
@@ -103,7 +103,7 @@ public class ConversationParticipantsData implements Iterable<ParticipantData> {
@NonNull @NonNull
@Override @Override
public Iterator<ParticipantData> iterator() { public Iterator<ParticipantData> iterator() {
return new Iterator<ParticipantData>() { return new Iterator<>() {
private int mCurrentIndex = -1; private int mCurrentIndex = -1;
@Override @Override
@@ -117,9 +117,9 @@ public class DraftMessageData extends BindableData implements ReadDraftDataActio
public DraftMessageData(final String conversationId) { public DraftMessageData(final String conversationId) {
mConversationId = conversationId; mConversationId = conversationId;
mAttachments = new ArrayList<MessagePartData>(); mAttachments = new ArrayList<>();
mReadOnlyAttachments = Collections.unmodifiableList(mAttachments); mReadOnlyAttachments = Collections.unmodifiableList(mAttachments);
mPendingAttachments = new ArrayList<PendingAttachmentData>(); mPendingAttachments = new ArrayList<>();
mReadOnlyPendingAttachments = Collections.unmodifiableList(mPendingAttachments); mReadOnlyPendingAttachments = Collections.unmodifiableList(mPendingAttachments);
mListeners = new DraftMessageDataEventDispatcher(); mListeners = new DraftMessageDataEventDispatcher();
mMessageTextStats = new MessageTextStats(); mMessageTextStats = new MessageTextStats();
@@ -773,7 +773,7 @@ public class DraftMessageData extends BindableData implements ReadDraftDataActio
mBindingId = binding.getBindingId(); mBindingId = binding.getBindingId();
// Obtain an immutable copy of the attachment list so we can operate on it in the // Obtain an immutable copy of the attachment list so we can operate on it in the
// background thread. // background thread.
mAttachmentsCopy = new ArrayList<MessagePartData>(mAttachments); mAttachmentsCopy = new ArrayList<>(mAttachments);
mCheckDraftForSendTask = this; mCheckDraftForSendTask = this;
} }
@@ -202,7 +202,7 @@ public class MessageData implements Parcelable {
* Create an "empty" message * Create an "empty" message
*/ */
public MessageData() { public MessageData() {
mParts = new ArrayList<MessagePartData>(); mParts = new ArrayList<>();
} }
public static String[] getProjection() { public static String[] getProjection() {
@@ -846,7 +846,7 @@ public class MessageData implements Parcelable {
mRetryStartTimestamp = in.readLong(); mRetryStartTimestamp = in.readLong();
// Read parts // Read parts
mParts = new ArrayList<MessagePartData>(); mParts = new ArrayList<>();
final int partCount = in.readInt(); final int partCount = in.readInt();
for (int i = 0; i < partCount; i++) { for (int i = 0; i < partCount; i++) {
mParts.add((MessagePartData) in.readParcelable(MessagePartData.class.getClassLoader())); mParts.add((MessagePartData) in.readParcelable(MessagePartData.class.getClassLoader()));
@@ -889,7 +889,7 @@ public class MessageData implements Parcelable {
} }
public static final Parcelable.Creator<MessageData> CREATOR public static final Parcelable.Creator<MessageData> CREATOR
= new Parcelable.Creator<MessageData>() { = new Parcelable.Creator<>() {
@Override @Override
public MessageData createFromParcel(final Parcel in) { public MessageData createFromParcel(final Parcel in) {
return new MessageData(in); return new MessageData(in);
@@ -413,7 +413,7 @@ public class MessagePartData implements Parcelable {
} }
public static final Parcelable.Creator<MessagePartData> CREATOR public static final Parcelable.Creator<MessagePartData> CREATOR
= new Parcelable.Creator<MessagePartData>() { = new Parcelable.Creator<>() {
@Override @Override
public MessagePartData createFromParcel(final Parcel in) { public MessagePartData createFromParcel(final Parcel in) {
return new MessagePartData(in); return new MessagePartData(in);
@@ -45,8 +45,7 @@ import com.android.messaging.util.TextUtil;
*/ */
public class ParticipantData implements Parcelable { public class ParticipantData implements Parcelable {
private static final ArrayMap<Integer, String> sSubIdtoParticipantIdCache = private static final ArrayMap<Integer, String> sSubIdtoParticipantIdCache = new ArrayMap<>();
new ArrayMap<Integer, String>();
// We always use -1 as default/invalid sub id although system may give us anything negative // We always use -1 as default/invalid sub id although system may give us anything negative
public static final int DEFAULT_SELF_SUB_ID = MmsManager.DEFAULT_SUB_ID; public static final int DEFAULT_SELF_SUB_ID = MmsManager.DEFAULT_SUB_ID;
@@ -583,8 +582,7 @@ public class ParticipantData implements Parcelable {
dest.writeString(mSubscriptionName); dest.writeString(mSubscriptionName);
} }
public static final Parcelable.Creator<ParticipantData> CREATOR public static final Parcelable.Creator<ParticipantData> CREATOR = new Parcelable.Creator<>() {
= new Parcelable.Creator<ParticipantData>() {
@Override @Override
public ParticipantData createFromParcel(final Parcel in) { public ParticipantData createFromParcel(final Parcel in) {
return new ParticipantData(in); return new ParticipantData(in);
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -162,7 +163,7 @@ public class PendingAttachmentData extends MessagePartData {
} }
public static final Parcelable.Creator<PendingAttachmentData> CREATOR public static final Parcelable.Creator<PendingAttachmentData> CREATOR
= new Parcelable.Creator<PendingAttachmentData>() { = new Parcelable.Creator<>() {
@Override @Override
public PendingAttachmentData createFromParcel(final Parcel in) { public PendingAttachmentData createFromParcel(final Parcel in) {
return new PendingAttachmentData(in); return new PendingAttachmentData(in);
@@ -37,7 +37,7 @@ public class SelfParticipantsData {
private final ArrayMap<String, ParticipantData> mSelfParticipantMap; private final ArrayMap<String, ParticipantData> mSelfParticipantMap;
public SelfParticipantsData() { public SelfParticipantsData() {
mSelfParticipantMap = new ArrayMap<String, ParticipantData>(); mSelfParticipantMap = new ArrayMap<>();
} }
public void bind(final Cursor cursor) { public void bind(final Cursor cursor) {
@@ -55,7 +55,7 @@ public class SelfParticipantsData {
* @param activeOnly if set, returns active self entries only (i.e. those with SIMs plugged in). * @param activeOnly if set, returns active self entries only (i.e. those with SIMs plugged in).
*/ */
public List<ParticipantData> getSelfParticipants(final boolean activeOnly) { public List<ParticipantData> getSelfParticipants(final boolean activeOnly) {
List<ParticipantData> list = new ArrayList<ParticipantData>(); List<ParticipantData> list = new ArrayList<>();
for (final ParticipantData self : mSelfParticipantMap.values()) { for (final ParticipantData self : mSelfParticipantMap.values()) {
if (!activeOnly || self.isActiveSubscription()) { if (!activeOnly || self.isActiveSubscription()) {
list.add(self); list.add(self);
@@ -196,7 +196,7 @@ public class SettingsData extends BindableData implements
public List<SettingsItem> getSettingsItems() { public List<SettingsItem> getSettingsItems() {
final List<ParticipantData> selfs = mSelfParticipantsData.getSelfParticipants(true); final List<ParticipantData> selfs = mSelfParticipantsData.getSelfParticipants(true);
final List<SettingsItem> settingsItems = new ArrayList<SettingsItem>(); final List<SettingsItem> settingsItems = new ArrayList<>();
// First goes the general settings, followed by per-subscription settings. // First goes the general settings, followed by per-subscription settings.
settingsItems.add(SettingsItem.createGeneralSettingsItem(mContext)); settingsItems.add(SettingsItem.createGeneralSettingsItem(mContext));
// For per-subscription settings, show the actual SIM name with phone number if the // For per-subscription settings, show the actual SIM name with phone number if the
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -86,7 +87,7 @@ public class SubscriptionListData {
private final Context mContext; private final Context mContext;
public SubscriptionListData(final Context context) { public SubscriptionListData(final Context context) {
mEntriesExcludingDefault = new ArrayList<SubscriptionListEntry>(); mEntriesExcludingDefault = new ArrayList<>();
mContext = context; mContext = context;
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -31,7 +32,7 @@ class AsyncMediaRequestWrapper<T extends RefCountedMediaResource> extends Bindab
public static <T extends RefCountedMediaResource> AsyncMediaRequestWrapper<T> public static <T extends RefCountedMediaResource> AsyncMediaRequestWrapper<T>
createWith(final MediaRequest<T> wrappedRequest, createWith(final MediaRequest<T> wrappedRequest,
final MediaResourceLoadListener<T> listener) { final MediaResourceLoadListener<T> listener) {
return new AsyncMediaRequestWrapper<T>(listener, wrappedRequest); return new AsyncMediaRequestWrapper<>(listener, wrappedRequest);
} }
private final MediaRequest<T> mWrappedRequest; private final MediaRequest<T> mWrappedRequest;
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -44,7 +45,7 @@ public class AvatarGroupRequestDescriptor extends CompositeImageRequestDescripto
final int desiredWidth, final int desiredHeight) { final int desiredWidth, final int desiredHeight) {
final List<String> participantUriStrings = AvatarUriUtil.getGroupParticipantUris(uri); final List<String> participantUriStrings = AvatarUriUtil.getGroupParticipantUris(uri);
final List<AvatarRequestDescriptor> avatarDescriptors = final List<AvatarRequestDescriptor> avatarDescriptors =
new ArrayList<AvatarRequestDescriptor>(participantUriStrings.size()); new ArrayList<>(participantUriStrings.size());
for (final String uriString : participantUriStrings) { for (final String uriString : participantUriStrings) {
final AvatarRequestDescriptor descriptor = new AvatarRequestDescriptor( final AvatarRequestDescriptor descriptor = new AvatarRequestDescriptor(
Uri.parse(uriString), desiredWidth, desiredHeight); Uri.parse(uriString), desiredWidth, desiredHeight);
@@ -55,7 +56,7 @@ public class AvatarGroupRequestDescriptor extends CompositeImageRequestDescripto
@Override @Override
public CompositeImageRequest<?> buildBatchImageRequest(final Context context) { public CompositeImageRequest<?> buildBatchImageRequest(final Context context) {
return new CompositeImageRequest<AvatarGroupRequestDescriptor>(context, this); return new CompositeImageRequest<>(context, this);
} }
@Override @Override
@@ -59,13 +59,13 @@ public class CustomVCardEntryConstructor implements VCardInterpreter {
/** /**
* Represents current stack of VCardEntry. Used to support nested vCard (vCard 2.1). * Represents current stack of VCardEntry. Used to support nested vCard (vCard 2.1).
*/ */
private final List<CustomVCardEntry> mEntryStack = new ArrayList<CustomVCardEntry>(); private final List<CustomVCardEntry> mEntryStack = new ArrayList<>();
private CustomVCardEntry mCurrentEntry; private CustomVCardEntry mCurrentEntry;
private final int mVCardType; private final int mVCardType;
private final Account mAccount; private final Account mAccount;
private final List<EntryHandler> mEntryHandlers = new ArrayList<EntryHandler>(); private final List<EntryHandler> mEntryHandlers = new ArrayList<>();
public CustomVCardEntryConstructor() { public CustomVCardEntryConstructor() {
this(VCardConfig.VCARD_TYPE_V21_GENERIC, null); this(VCardConfig.VCARD_TYPE_V21_GENERIC, null);
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -33,7 +34,7 @@ public abstract class MediaCacheManager implements MemoryCache {
protected final SparseArray<MediaCache<?>> mCaches; protected final SparseArray<MediaCache<?>> mCaches;
public MediaCacheManager() { public MediaCacheManager() {
mCaches = new SparseArray<MediaCache<?>>(); mCaches = new SparseArray<>();
MemoryCacheManager.get().registerMemoryCache(this); MemoryCacheManager.get().registerMemoryCache(this);
} }
@@ -233,8 +233,7 @@ public class MediaResourceManager {
} }
// We don't use SafeAsyncTask here since it enforces the shared thread pool executor // We don't use SafeAsyncTask here since it enforces the shared thread pool executor
// whereas we want a dedicated thread pool executor. // whereas we want a dedicated thread pool executor.
AsyncTask<Void, Void, MediaLoadingResult<T>> mediaLoadingTask = AsyncTask<Void, Void, MediaLoadingResult<T>> mediaLoadingTask = new AsyncTask<>() {
new AsyncTask<Void, Void, MediaLoadingResult<T>>() {
private Exception mException; private Exception mException;
@Override @Override
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -118,7 +119,7 @@ public class PoolableImageCache extends MediaCache<ImageResource> {
private final SparseArray<LinkedList<ImageResource>> mImageListSparseArray; private final SparseArray<LinkedList<ImageResource>> mImageListSparseArray;
public ReusableImageResourcePool() { public ReusableImageResourcePool() {
mImageListSparseArray = new SparseArray<LinkedList<ImageResource>>(); mImageListSparseArray = new SparseArray<>();
} }
/** /**
@@ -232,7 +233,7 @@ public class PoolableImageCache extends MediaCache<ImageResource> {
Assert.isTrue(poolKey != INVALID_POOL_KEY); Assert.isTrue(poolKey != INVALID_POOL_KEY);
LinkedList<ImageResource> imageList = mImageListSparseArray.get(poolKey); LinkedList<ImageResource> imageList = mImageListSparseArray.get(poolKey);
if (imageList == null) { if (imageList == null) {
imageList = new LinkedList<ImageResource>(); imageList = new LinkedList<>();
mImageListSparseArray.put(poolKey, imageList); mImageListSparseArray.put(poolKey, imageList);
} }
imageList.addLast(imageResource); imageList.addLast(imageResource);
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -48,7 +49,7 @@ public abstract class RefCountedMediaResource {
// to find out where each ref change happens. // to find out where each ref change happens.
private static final boolean DEBUG = false; private static final boolean DEBUG = false;
private static final String TAG = "bugle_media_ref_history"; private static final String TAG = "bugle_media_ref_history";
private final ArrayList<String> mRefHistory = new ArrayList<String>(); private final ArrayList<String> mRefHistory = new ArrayList<>();
// A lock that guards access to shared members in this class (and all its subclasses). // A lock that guards access to shared members in this class (and all its subclasses).
private final ReentrantLock mLock = new ReentrantLock(); private final ReentrantLock mLock = new ReentrantLock();
@@ -83,9 +83,9 @@ public class UriImageRequestDescriptor extends ImageRequestDescriptor {
@Override @Override
public MediaRequest<ImageResource> buildSyncMediaRequest(final Context context) { public MediaRequest<ImageResource> buildSyncMediaRequest(final Context context) {
if (uri == null || UriUtil.isLocalUri(uri)) { if (uri == null || UriUtil.isLocalUri(uri)) {
return new UriImageRequest<UriImageRequestDescriptor>(context, this); return new UriImageRequest<>(context, this);
} else { } else {
return new NetworkUriImageRequest<UriImageRequestDescriptor>(context, this); return new NetworkUriImageRequest<>(context, this);
} }
} }
} }
@@ -71,7 +71,7 @@ public class VCardRequest implements MediaRequest<VCardResource> {
VCardRequest(final Context context, final VCardRequestDescriptor descriptor) { VCardRequest(final Context context, final VCardRequestDescriptor descriptor) {
mDescriptor = descriptor; mDescriptor = descriptor;
mContext = context; mContext = context;
mLoadedVCards = new ArrayList<VCardResourceEntry>(); mLoadedVCards = new ArrayList<>();
} }
@Override @Override
@@ -163,7 +163,7 @@ public class VCardResourceEntry {
final VCardEntry vcard) { final VCardEntry vcard) {
final Resources resources = Factory.get().getApplicationContext().getResources(); final Resources resources = Factory.get().getApplicationContext().getResources();
final List<VCardResourceEntry.VCardResourceEntryDestinationItem> retList = final List<VCardResourceEntry.VCardResourceEntryDestinationItem> retList =
new ArrayList<VCardResourceEntry.VCardResourceEntryDestinationItem>(); new ArrayList<>();
if (vcard.getPhoneList() != null) { if (vcard.getPhoneList() != null) {
for (final PhoneData phone : vcard.getPhoneList()) { for (final PhoneData phone : vcard.getPhoneList()) {
final Intent intent = new Intent(Intent.ACTION_DIAL); final Intent intent = new Intent(Intent.ACTION_DIAL);
@@ -264,7 +264,7 @@ public class VCardResourceEntry {
if (vcard.getNotes() != null) { if (vcard.getNotes() != null) {
for (final NoteData note : vcard.getNotes()) { for (final NoteData note : vcard.getNotes()) {
final ArrayMap<String, String> curChildMap = new ArrayMap<String, String>(); final ArrayMap<String, String> curChildMap = new ArrayMap<>();
if (TextUtils.isGraphic(note.getNote())){ if (TextUtils.isGraphic(note.getNote())){
retList.add(new VCardResourceEntryDestinationItem(note.getNote(), retList.add(new VCardResourceEntryDestinationItem(note.getNote(),
resources.getString(R.string.vcard_detail_notes_label), null)); resources.getString(R.string.vcard_detail_notes_label), null));
@@ -1,6 +1,7 @@
/* /*
* Copyright (C) 2007 Esmertec AG. * Copyright (C) 2007 Esmertec AG.
* Copyright (C) 2007 The Android Open Source Project * Copyright (C) 2007 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -402,8 +403,8 @@ public class CharacterSets {
static { static {
// Create the HashMaps. // Create the HashMaps.
MIBENUM_TO_NAME_MAP = new SparseArray<String>(); MIBENUM_TO_NAME_MAP = new SparseArray<>();
NAME_TO_MIBENUM_MAP = new SimpleArrayMap<String, Integer>(); NAME_TO_MIBENUM_MAP = new SimpleArrayMap<>();
assert (MIBENUM_NUMBERS.length == MIME_NAMES.length); assert (MIBENUM_NUMBERS.length == MIME_NAMES.length);
final int count = MIBENUM_NUMBERS.length - 1; final int count = MIBENUM_NUMBERS.length - 1;
for (int i = 0; i <= count; i++) { for (int i = 0; i <= count; i++) {
@@ -245,7 +245,7 @@ public class EncodedStringValue implements Cloneable {
public static EncodedStringValue[] extract(String src) { public static EncodedStringValue[] extract(String src) {
String[] values = src.split(";"); String[] values = src.split(";");
ArrayList<EncodedStringValue> list = new ArrayList<EncodedStringValue>(); ArrayList<EncodedStringValue> list = new ArrayList<>();
for (int i = 0; i < values.length; i++) { for (int i = 0; i < values.length; i++) {
if (values[i].length() > 0) { if (values[i].length() > 0) {
list.add(new EncodedStringValue(values[i])); list.add(new EncodedStringValue(values[i]));
@@ -1,6 +1,7 @@
/* /*
* Copyright (C) 2007 Esmertec AG. * Copyright (C) 2007 Esmertec AG.
* Copyright (C) 2007 The Android Open Source Project * Copyright (C) 2007 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -26,7 +27,7 @@ public class PduBody {
* Constructor. * Constructor.
*/ */
public PduBody() { public PduBody() {
mParts = new Vector<PduPart>(); mParts = new Vector<>();
} }
/** /**
@@ -1,6 +1,7 @@
/* /*
* Copyright (C) 2007-2008 Esmertec AG. * Copyright (C) 2007-2008 Esmertec AG.
* Copyright (C) 2007-2008 The Android Open Source Project * Copyright (C) 2007-2008 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -120,7 +121,7 @@ public class PduComposer {
private static SimpleArrayMap<String, Integer> mContentTypeMap = null; private static SimpleArrayMap<String, Integer> mContentTypeMap = null;
static { static {
mContentTypeMap = new SimpleArrayMap<String, Integer>(); mContentTypeMap = new SimpleArrayMap<>();
int i; int i;
for (i = 0; i < PduContentTypes.contentTypes.length; i++) { for (i = 0; i < PduContentTypes.contentTypes.length; i++) {
@@ -1,6 +1,7 @@
/* /*
* Copyright (C) 2007 Esmertec AG. * Copyright (C) 2007 Esmertec AG.
* Copyright (C) 2007 The Android Open Source Project * Copyright (C) 2007 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -346,7 +347,7 @@ public class PduHeaders {
* Constructor of PduHeaders. * Constructor of PduHeaders.
*/ */
public PduHeaders() { public PduHeaders() {
mHeaderMap = new SparseArray<Object>(); mHeaderMap = new SparseArray<>();
} }
/** /**
@@ -652,7 +653,7 @@ public class PduHeaders {
throw new RuntimeException("Invalid header field!"); throw new RuntimeException("Invalid header field!");
} }
ArrayList<EncodedStringValue> list = new ArrayList<EncodedStringValue>(); ArrayList<EncodedStringValue> list = new ArrayList<>();
for (int i = 0; i < value.length; i++) { for (int i = 0; i < value.length; i++) {
list.add(value[i]); list.add(value[i]);
} }
@@ -684,7 +685,7 @@ public class PduHeaders {
ArrayList<EncodedStringValue> list = ArrayList<EncodedStringValue> list =
(ArrayList<EncodedStringValue>) mHeaderMap.get(field); (ArrayList<EncodedStringValue>) mHeaderMap.get(field);
if (null == list) { if (null == list) {
list = new ArrayList<EncodedStringValue>(); list = new ArrayList<>();
} }
list.add(value); list.add(value);
mHeaderMap.put(field, list); mHeaderMap.put(field, list);
@@ -1,6 +1,7 @@
/* /*
* Copyright (C) 2007-2008 Esmertec AG. * Copyright (C) 2007-2008 Esmertec AG.
* Copyright (C) 2007-2008 The Android Open Source Project * Copyright (C) 2007-2008 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -811,7 +812,7 @@ public class PduParser {
} }
case PduHeaders.CONTENT_TYPE: { case PduHeaders.CONTENT_TYPE: {
SparseArray<Object> map = new SparseArray<Object>(); SparseArray<Object> map = new SparseArray<>();
byte[] contentType = byte[] contentType =
parseContentType(pduDataStream, map); parseContentType(pduDataStream, map);
@@ -882,7 +883,7 @@ public class PduParser {
} }
/* parse part's content-type */ /* parse part's content-type */
SparseArray<Object> map = new SparseArray<Object>(); SparseArray<Object> map = new SparseArray<>();
byte[] contentType = parseContentType(pduDataStream, map); byte[] contentType = parseContentType(pduDataStream, map);
if (null != contentType) { if (null != contentType) {
part.setContentType(contentType); part.setContentType(contentType);
@@ -1,6 +1,7 @@
/* /*
* Copyright (C) 2007-2008 Esmertec AG. * Copyright (C) 2007-2008 Esmertec AG.
* Copyright (C) 2007-2008 The Android Open Source Project * Copyright (C) 2007-2008 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -123,7 +124,7 @@ public class PduPart {
* Empty Constructor. * Empty Constructor.
*/ */
public PduPart() { public PduPart() {
mPartHeader = new SparseArray<Object>(); mPartHeader = new SparseArray<>();
} }
/** /**
@@ -213,7 +213,7 @@ public class PduPersister {
private static final SparseArray<String> LONG_COLUMN_NAME_MAP; private static final SparseArray<String> LONG_COLUMN_NAME_MAP;
static { static {
MESSAGE_BOX_MAP = new SimpleArrayMap<Uri, Integer>(); MESSAGE_BOX_MAP = new SimpleArrayMap<>();
MESSAGE_BOX_MAP.put(Mms.Inbox.CONTENT_URI, Mms.MESSAGE_BOX_INBOX); MESSAGE_BOX_MAP.put(Mms.Inbox.CONTENT_URI, Mms.MESSAGE_BOX_INBOX);
MESSAGE_BOX_MAP.put(Mms.Sent.CONTENT_URI, Mms.MESSAGE_BOX_SENT); MESSAGE_BOX_MAP.put(Mms.Sent.CONTENT_URI, Mms.MESSAGE_BOX_SENT);
MESSAGE_BOX_MAP.put(Mms.Draft.CONTENT_URI, Mms.MESSAGE_BOX_DRAFTS); MESSAGE_BOX_MAP.put(Mms.Draft.CONTENT_URI, Mms.MESSAGE_BOX_DRAFTS);
@@ -223,7 +223,7 @@ public class PduPersister {
CHARSET_COLUMN_INDEX_MAP.put(PduHeaders.SUBJECT, PDU_COLUMN_SUBJECT_CHARSET); CHARSET_COLUMN_INDEX_MAP.put(PduHeaders.SUBJECT, PDU_COLUMN_SUBJECT_CHARSET);
CHARSET_COLUMN_INDEX_MAP.put(PduHeaders.RETRIEVE_TEXT, PDU_COLUMN_RETRIEVE_TEXT_CHARSET); CHARSET_COLUMN_INDEX_MAP.put(PduHeaders.RETRIEVE_TEXT, PDU_COLUMN_RETRIEVE_TEXT_CHARSET);
CHARSET_COLUMN_NAME_MAP = new SparseArray<String>(); CHARSET_COLUMN_NAME_MAP = new SparseArray<>();
CHARSET_COLUMN_NAME_MAP.put(PduHeaders.SUBJECT, Mms.SUBJECT_CHARSET); CHARSET_COLUMN_NAME_MAP.put(PduHeaders.SUBJECT, Mms.SUBJECT_CHARSET);
CHARSET_COLUMN_NAME_MAP.put(PduHeaders.RETRIEVE_TEXT, Mms.RETRIEVE_TEXT_CHARSET); CHARSET_COLUMN_NAME_MAP.put(PduHeaders.RETRIEVE_TEXT, Mms.RETRIEVE_TEXT_CHARSET);
@@ -232,7 +232,7 @@ public class PduPersister {
ENCODED_STRING_COLUMN_INDEX_MAP.put(PduHeaders.RETRIEVE_TEXT, PDU_COLUMN_RETRIEVE_TEXT); ENCODED_STRING_COLUMN_INDEX_MAP.put(PduHeaders.RETRIEVE_TEXT, PDU_COLUMN_RETRIEVE_TEXT);
ENCODED_STRING_COLUMN_INDEX_MAP.put(PduHeaders.SUBJECT, PDU_COLUMN_SUBJECT); ENCODED_STRING_COLUMN_INDEX_MAP.put(PduHeaders.SUBJECT, PDU_COLUMN_SUBJECT);
ENCODED_STRING_COLUMN_NAME_MAP = new SparseArray<String>(); ENCODED_STRING_COLUMN_NAME_MAP = new SparseArray<>();
ENCODED_STRING_COLUMN_NAME_MAP.put(PduHeaders.RETRIEVE_TEXT, Mms.RETRIEVE_TEXT); ENCODED_STRING_COLUMN_NAME_MAP.put(PduHeaders.RETRIEVE_TEXT, Mms.RETRIEVE_TEXT);
ENCODED_STRING_COLUMN_NAME_MAP.put(PduHeaders.SUBJECT, Mms.SUBJECT); ENCODED_STRING_COLUMN_NAME_MAP.put(PduHeaders.SUBJECT, Mms.SUBJECT);
@@ -245,7 +245,7 @@ public class PduPersister {
TEXT_STRING_COLUMN_INDEX_MAP.put(PduHeaders.RESPONSE_TEXT, PDU_COLUMN_RESPONSE_TEXT); TEXT_STRING_COLUMN_INDEX_MAP.put(PduHeaders.RESPONSE_TEXT, PDU_COLUMN_RESPONSE_TEXT);
TEXT_STRING_COLUMN_INDEX_MAP.put(PduHeaders.TRANSACTION_ID, PDU_COLUMN_TRANSACTION_ID); TEXT_STRING_COLUMN_INDEX_MAP.put(PduHeaders.TRANSACTION_ID, PDU_COLUMN_TRANSACTION_ID);
TEXT_STRING_COLUMN_NAME_MAP = new SparseArray<String>(); TEXT_STRING_COLUMN_NAME_MAP = new SparseArray<>();
TEXT_STRING_COLUMN_NAME_MAP.put(PduHeaders.CONTENT_LOCATION, Mms.CONTENT_LOCATION); TEXT_STRING_COLUMN_NAME_MAP.put(PduHeaders.CONTENT_LOCATION, Mms.CONTENT_LOCATION);
TEXT_STRING_COLUMN_NAME_MAP.put(PduHeaders.CONTENT_TYPE, Mms.CONTENT_TYPE); TEXT_STRING_COLUMN_NAME_MAP.put(PduHeaders.CONTENT_TYPE, Mms.CONTENT_TYPE);
TEXT_STRING_COLUMN_NAME_MAP.put(PduHeaders.MESSAGE_CLASS, Mms.MESSAGE_CLASS); TEXT_STRING_COLUMN_NAME_MAP.put(PduHeaders.MESSAGE_CLASS, Mms.MESSAGE_CLASS);
@@ -266,7 +266,7 @@ public class PduPersister {
OCTET_COLUMN_INDEX_MAP.put(PduHeaders.RETRIEVE_STATUS, PDU_COLUMN_RETRIEVE_STATUS); OCTET_COLUMN_INDEX_MAP.put(PduHeaders.RETRIEVE_STATUS, PDU_COLUMN_RETRIEVE_STATUS);
OCTET_COLUMN_INDEX_MAP.put(PduHeaders.STATUS, PDU_COLUMN_STATUS); OCTET_COLUMN_INDEX_MAP.put(PduHeaders.STATUS, PDU_COLUMN_STATUS);
OCTET_COLUMN_NAME_MAP = new SparseArray<String>(); OCTET_COLUMN_NAME_MAP = new SparseArray<>();
OCTET_COLUMN_NAME_MAP.put(PduHeaders.CONTENT_CLASS, Mms.CONTENT_CLASS); OCTET_COLUMN_NAME_MAP.put(PduHeaders.CONTENT_CLASS, Mms.CONTENT_CLASS);
OCTET_COLUMN_NAME_MAP.put(PduHeaders.DELIVERY_REPORT, Mms.DELIVERY_REPORT); OCTET_COLUMN_NAME_MAP.put(PduHeaders.DELIVERY_REPORT, Mms.DELIVERY_REPORT);
OCTET_COLUMN_NAME_MAP.put(PduHeaders.MESSAGE_TYPE, Mms.MESSAGE_TYPE); OCTET_COLUMN_NAME_MAP.put(PduHeaders.MESSAGE_TYPE, Mms.MESSAGE_TYPE);
@@ -285,7 +285,7 @@ public class PduPersister {
LONG_COLUMN_INDEX_MAP.put(PduHeaders.EXPIRY, PDU_COLUMN_EXPIRY); LONG_COLUMN_INDEX_MAP.put(PduHeaders.EXPIRY, PDU_COLUMN_EXPIRY);
LONG_COLUMN_INDEX_MAP.put(PduHeaders.MESSAGE_SIZE, PDU_COLUMN_MESSAGE_SIZE); LONG_COLUMN_INDEX_MAP.put(PduHeaders.MESSAGE_SIZE, PDU_COLUMN_MESSAGE_SIZE);
LONG_COLUMN_NAME_MAP = new SparseArray<String>(); LONG_COLUMN_NAME_MAP = new SparseArray<>();
LONG_COLUMN_NAME_MAP.put(PduHeaders.DATE, Mms.DATE); LONG_COLUMN_NAME_MAP.put(PduHeaders.DATE, Mms.DATE);
LONG_COLUMN_NAME_MAP.put(PduHeaders.DELIVERY_TIME, Mms.DELIVERY_TIME); LONG_COLUMN_NAME_MAP.put(PduHeaders.DELIVERY_TIME, Mms.DELIVERY_TIME);
LONG_COLUMN_NAME_MAP.put(PduHeaders.EXPIRY, Mms.EXPIRY); LONG_COLUMN_NAME_MAP.put(PduHeaders.EXPIRY, Mms.EXPIRY);
@@ -1135,7 +1135,7 @@ public class PduPersister {
} }
final PduHeaders headers = sendReq.getPduHeaders(); final PduHeaders headers = sendReq.getPduHeaders();
final HashSet<String> recipients = new HashSet<String>(); final HashSet<String> recipients = new HashSet<>();
for (final int addrType : ADDRESS_FIELDS) { for (final int addrType : ADDRESS_FIELDS) {
EncodedStringValue[] array = null; EncodedStringValue[] array = null;
if (addrType == PduHeaders.FROM) { if (addrType == PduHeaders.FROM) {
@@ -1233,8 +1233,8 @@ public class PduPersister {
PDU_CACHE_INSTANCE.setUpdating(uri, true); PDU_CACHE_INSTANCE.setUpdating(uri, true);
} }
final ArrayList<PduPart> toBeCreated = new ArrayList<PduPart>(); final ArrayList<PduPart> toBeCreated = new ArrayList<>();
final ArrayMap<Uri, PduPart> toBeUpdated = new ArrayMap<Uri, PduPart>(); final ArrayMap<Uri, PduPart> toBeUpdated = new ArrayMap<>();
final int partsNum = body.getPartsNum(); final int partsNum = body.getPartsNum();
final StringBuilder filter = new StringBuilder().append('('); final StringBuilder filter = new StringBuilder().append('(');
@@ -1376,7 +1376,7 @@ public class PduPersister {
} }
final SparseArray<EncodedStringValue[]> addressMap = final SparseArray<EncodedStringValue[]> addressMap =
new SparseArray<EncodedStringValue[]>(ADDRESS_FIELDS.length); new SparseArray<>(ADDRESS_FIELDS.length);
// Save address information. // Save address information.
for (final int addrType : ADDRESS_FIELDS) { for (final int addrType : ADDRESS_FIELDS) {
EncodedStringValue[] array = null; EncodedStringValue[] array = null;
@@ -1392,7 +1392,7 @@ public class PduPersister {
addressMap.put(addrType, array); addressMap.put(addrType, array);
} }
final HashSet<String> recipients = new HashSet<String>(); final HashSet<String> recipients = new HashSet<>();
final int msgType = pdu.getMessageType(); final int msgType = pdu.getMessageType();
// Here we only allocate thread ID for M-Notification.ind, // Here we only allocate thread ID for M-Notification.ind,
// M-Retrieve.conf and M-Send.req. // M-Retrieve.conf and M-Send.req.
@@ -1553,7 +1553,7 @@ public class PduPersister {
final SparseArray<EncodedStringValue[]> addressMap, final String selfNumber) { final SparseArray<EncodedStringValue[]> addressMap, final String selfNumber) {
final EncodedStringValue[] arrayTo = addressMap.get(PduHeaders.TO); final EncodedStringValue[] arrayTo = addressMap.get(PduHeaders.TO);
final EncodedStringValue[] arrayCc = addressMap.get(PduHeaders.CC); final EncodedStringValue[] arrayCc = addressMap.get(PduHeaders.CC);
final ArrayList<String> numbers = new ArrayList<String>(); final ArrayList<String> numbers = new ArrayList<>();
if (arrayTo != null) { if (arrayTo != null) {
for (final EncodedStringValue v : arrayTo) { for (final EncodedStringValue v : arrayTo) {
if (v != null) { if (v != null) {
@@ -1,6 +1,7 @@
/* /*
* Copyright (C) 2008 Esmertec AG. * Copyright (C) 2008 Esmertec AG.
* Copyright (C) 2008 The Android Open Source Project * Copyright (C) 2008 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -29,7 +30,7 @@ public abstract class AbstractCache<K, V> {
private final SimpleArrayMap<K, CacheEntry<V>> mCacheMap; private final SimpleArrayMap<K, CacheEntry<V>> mCacheMap;
protected AbstractCache() { protected AbstractCache() {
mCacheMap = new SimpleArrayMap<K, CacheEntry<V>>(); mCacheMap = new SimpleArrayMap<>();
} }
public boolean put(K key, V value) { public boolean put(K key, V value) {
@@ -47,7 +48,7 @@ public abstract class AbstractCache<K, V> {
} }
if (key != null) { if (key != null) {
CacheEntry<V> cacheEntry = new CacheEntry<V>(); CacheEntry<V> cacheEntry = new CacheEntry<>();
cacheEntry.value = value; cacheEntry.value = value;
mCacheMap.put(key, cacheEntry); mCacheMap.put(key, cacheEntry);
@@ -65,7 +65,7 @@ public final class PduCache extends AbstractCache<Uri, PduCacheEntry> {
URI_MATCHER.addURI("mms-sms", "conversations", MMS_CONVERSATION); URI_MATCHER.addURI("mms-sms", "conversations", MMS_CONVERSATION);
URI_MATCHER.addURI("mms-sms", "conversations/#", MMS_CONVERSATION_ID); URI_MATCHER.addURI("mms-sms", "conversations/#", MMS_CONVERSATION_ID);
MATCH_TO_MSGBOX_ID_MAP = new SparseArray<Integer>(); MATCH_TO_MSGBOX_ID_MAP = new SparseArray<>();
MATCH_TO_MSGBOX_ID_MAP.put(MMS_INBOX, Mms.MESSAGE_BOX_INBOX); MATCH_TO_MSGBOX_ID_MAP.put(MMS_INBOX, Mms.MESSAGE_BOX_INBOX);
MATCH_TO_MSGBOX_ID_MAP.put(MMS_SENT, Mms.MESSAGE_BOX_SENT); MATCH_TO_MSGBOX_ID_MAP.put(MMS_SENT, Mms.MESSAGE_BOX_SENT);
MATCH_TO_MSGBOX_ID_MAP.put(MMS_DRAFTS, Mms.MESSAGE_BOX_DRAFTS); MATCH_TO_MSGBOX_ID_MAP.put(MMS_DRAFTS, Mms.MESSAGE_BOX_DRAFTS);
@@ -77,9 +77,9 @@ public final class PduCache extends AbstractCache<Uri, PduCacheEntry> {
private final HashSet<Uri> mUpdating; private final HashSet<Uri> mUpdating;
private PduCache() { private PduCache() {
mMessageBoxes = new SparseArray<HashSet<Uri>>(); mMessageBoxes = new SparseArray<>();
mThreads = new SimpleArrayMap<Long, HashSet<Uri>>(); mThreads = new SimpleArrayMap<>();
mUpdating = new HashSet<Uri>(); mUpdating = new HashSet<>();
} }
public static synchronized PduCache getInstance() { public static synchronized PduCache getInstance() {
@@ -97,14 +97,14 @@ public final class PduCache extends AbstractCache<Uri, PduCacheEntry> {
int msgBoxId = entry.getMessageBox(); int msgBoxId = entry.getMessageBox();
HashSet<Uri> msgBox = mMessageBoxes.get(msgBoxId); HashSet<Uri> msgBox = mMessageBoxes.get(msgBoxId);
if (msgBox == null) { if (msgBox == null) {
msgBox = new HashSet<Uri>(); msgBox = new HashSet<>();
mMessageBoxes.put(msgBoxId, msgBox); mMessageBoxes.put(msgBoxId, msgBox);
} }
long threadId = entry.getThreadId(); long threadId = entry.getThreadId();
HashSet<Uri> thread = mThreads.get(threadId); HashSet<Uri> thread = mThreads.get(threadId);
if (thread == null) { if (thread == null) {
thread = new HashSet<Uri>(); thread = new HashSet<>();
mThreads.put(threadId, thread); mThreads.put(threadId, thread);
} }
@@ -218,8 +218,7 @@ public class DatabaseMessages {
mBody = in.readString(); mBody = in.readString();
} }
public static final Parcelable.Creator<SmsMessage> CREATOR public static final Parcelable.Creator<SmsMessage> CREATOR = new Parcelable.Creator<>() {
= new Parcelable.Creator<SmsMessage>() {
@Override @Override
public SmsMessage createFromParcel(final Parcel in) { public SmsMessage createFromParcel(final Parcel in) {
return new SmsMessage(in); return new SmsMessage(in);
@@ -488,15 +487,14 @@ public class DatabaseMessages {
mRetrieveStatus = in.readInt(); mRetrieveStatus = in.readInt();
final int nParts = in.readInt(); final int nParts = in.readInt();
mParts = new ArrayList<MmsPart>(); mParts = new ArrayList<>();
mPartsProcessed = false; mPartsProcessed = false;
for (int i = 0; i < nParts; i++) { for (int i = 0; i < nParts; i++) {
mParts.add((MmsPart) in.readParcelable(getClass().getClassLoader())); mParts.add((MmsPart) in.readParcelable(getClass().getClassLoader()));
} }
} }
public static final Parcelable.Creator<MmsMessage> CREATOR public static final Parcelable.Creator<MmsMessage> CREATOR = new Parcelable.Creator<>() {
= new Parcelable.Creator<MmsMessage>() {
@Override @Override
public MmsMessage createFromParcel(final Parcel in) { public MmsMessage createFromParcel(final Parcel in) {
return new MmsMessage(in); return new MmsMessage(in);
@@ -822,8 +820,7 @@ public class DatabaseMessages {
mSize = in.readLong(); mSize = in.readLong();
} }
public static final Parcelable.Creator<MmsPart> CREATOR public static final Parcelable.Creator<MmsPart> CREATOR = new Parcelable.Creator<>() {
= new Parcelable.Creator<MmsPart>() {
@Override @Override
public MmsPart createFromParcel(final Parcel in) { public MmsPart createFromParcel(final Parcel in) {
return new MmsPart(in); return new MmsPart(in);
@@ -905,7 +902,7 @@ public class DatabaseMessages {
} }
public static final Parcelable.Creator<LocalDatabaseMessage> CREATOR public static final Parcelable.Creator<LocalDatabaseMessage> CREATOR
= new Parcelable.Creator<LocalDatabaseMessage>() { = new Parcelable.Creator<>() {
@Override @Override
public LocalDatabaseMessage createFromParcel(final Parcel in) { public LocalDatabaseMessage createFromParcel(final Parcel in) {
return new LocalDatabaseMessage(in); return new LocalDatabaseMessage(in);
@@ -163,7 +163,7 @@ public class MmsSmsUtils {
* messages. * messages.
*/ */
public static long getOrCreateThreadId(final Context context, final String recipient) { public static long getOrCreateThreadId(final Context context, final String recipient) {
final Set<String> recipients = new HashSet<String>(); final Set<String> recipients = new HashSet<>();
recipients.add(recipient); recipients.add(recipient);
return getOrCreateThreadId(context, recipients); return getOrCreateThreadId(context, recipients);
+3 -3
View File
@@ -763,7 +763,7 @@ public class MmsUtils {
Uri.parse("content://mms-sms/canonical-address"); Uri.parse("content://mms-sms/canonical-address");
private static List<String> getAddresses(final Context context, final String spaceSepIds) { private static List<String> getAddresses(final Context context, final String spaceSepIds) {
final List<String> numbers = new ArrayList<String>(); final List<String> numbers = new ArrayList<>();
final String[] ids = spaceSepIds.split(" "); final String[] ids = spaceSepIds.split(" ");
for (final String id : ids) { for (final String id : ids) {
long longId; long longId;
@@ -813,7 +813,7 @@ public class MmsUtils {
// Get telephony SMS thread ID // Get telephony SMS thread ID
public static long getOrCreateSmsThreadId(final Context context, final String dest) { public static long getOrCreateSmsThreadId(final Context context, final String dest) {
// use destinations to determine threadId // use destinations to determine threadId
final Set<String> recipients = new HashSet<String>(); final Set<String> recipients = new HashSet<>();
recipients.add(dest); recipients.add(dest);
try { try {
return MmsSmsUtils.Threads.getOrCreateThreadId(context, recipients); return MmsSmsUtils.Threads.getOrCreateThreadId(context, recipients);
@@ -829,7 +829,7 @@ public class MmsUtils {
return -1; return -1;
} }
// use destinations to determine threadId // use destinations to determine threadId
final Set<String> recipients = new HashSet<String>(dests); final Set<String> recipients = new HashSet<>(dests);
try { try {
return MmsSmsUtils.Threads.getOrCreateThreadId(context, recipients); return MmsSmsUtils.Threads.getOrCreateThreadId(context, recipients);
} catch (final IllegalArgumentException e) { } catch (final IllegalArgumentException e) {
+3 -3
View File
@@ -62,7 +62,7 @@ public class SmsSender {
* A map for pending sms messages. The key is the random request UUID. * A map for pending sms messages. The key is the random request UUID.
*/ */
private static final ConcurrentHashMap<Uri, SendResult> sPendingMessageMap = private static final ConcurrentHashMap<Uri, SendResult> sPendingMessageMap =
new ConcurrentHashMap<Uri, SendResult>(); new ConcurrentHashMap<>();
private static final Random RANDOM = new Random(); private static final Random RANDOM = new Random();
@@ -256,8 +256,8 @@ public class SmsSender {
Assert.notNull(context); Assert.notNull(context);
final SmsManager smsManager = PhoneUtils.get(subId).getSmsManager(); final SmsManager smsManager = PhoneUtils.get(subId).getSmsManager();
final int messageCount = messages.size(); final int messageCount = messages.size();
final ArrayList<PendingIntent> deliveryIntents = new ArrayList<PendingIntent>(messageCount); final ArrayList<PendingIntent> deliveryIntents = new ArrayList<>(messageCount);
final ArrayList<PendingIntent> sentIntents = new ArrayList<PendingIntent>(messageCount); final ArrayList<PendingIntent> sentIntents = new ArrayList<>(messageCount);
for (int i = 0; i < messageCount; i++) { for (int i = 0; i < messageCount; i++) {
// Make pending intents different for each message part // Make pending intents different for each message part
final int partId = (messageCount <= 1 ? 0 : i + 1); final int partId = (messageCount <= 1 ? 0 : i + 1);
@@ -417,7 +417,7 @@ public class AsyncImageView extends ImageView implements MediaResourceLoadListen
private final HashSet<AsyncImageView> mAttachedViews; private final HashSet<AsyncImageView> mAttachedViews;
public AsyncImageViewDelayLoader() { public AsyncImageViewDelayLoader() {
mAttachedViews = new HashSet<AsyncImageView>(); mAttachedViews = new HashSet<>();
} }
private void registerView(final AsyncImageView view) { private void registerView(final AsyncImageView view) {
@@ -119,7 +119,7 @@ public class ClassZeroActivity extends Activity {
requestWindowFeature(Window.FEATURE_NO_TITLE); requestWindowFeature(Window.FEATURE_NO_TITLE);
if (mMessageQueue == null) { if (mMessageQueue == null) {
mMessageQueue = new ArrayList<ContentValues>(); mMessageQueue = new ArrayList<>();
} }
if (!queueMsgFromIntent(getIntent())) { if (!queueMsgFromIntent(getIntent())) {
return; return;
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -103,7 +104,7 @@ public class LineWrapLayout extends ViewGroup {
int currLineHeight = 0; int currLineHeight = 0;
// Do a dry-run first to get the line heights. // Do a dry-run first to get the line heights.
final ArrayList<Integer> lineHeights = new ArrayList<Integer>(); final ArrayList<Integer> lineHeights = new ArrayList<>();
for (int i = 0; i < childCount; i++) { for (int i = 0; i < childCount; i++) {
View currChild = getChildAt(i); View currChild = getChildAt(i);
if (currChild.getVisibility() == GONE) { if (currChild.getVisibility() == GONE) {
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -158,13 +159,13 @@ public class MultiAttachmentLayout extends FrameLayout {
public MultiAttachmentLayout(final Context context, final AttributeSet attrs) { public MultiAttachmentLayout(final Context context, final AttributeSet attrs) {
super(context, attrs); super(context, attrs);
mPreviewViews = new ArrayList<ViewWrapper>(); mPreviewViews = new ArrayList<>();
} }
public void bindAttachments(final Iterable<MessagePartData> attachments, public void bindAttachments(final Iterable<MessagePartData> attachments,
final Rect transitionRect, final int count) { final Rect transitionRect, final int count) {
final ArrayList<ViewWrapper> previousViews = mPreviewViews; final ArrayList<ViewWrapper> previousViews = mPreviewViews;
mPreviewViews = new ArrayList<ViewWrapper>(); mPreviewViews = new ArrayList<>();
removeView(mPlusTextView); removeView(mPlusTextView);
mPlusTextView = null; mPlusTextView = null;
+2 -3
View File
@@ -118,8 +118,7 @@ public class SnackBar {
} }
public static class Builder { public static class Builder {
private static final List<SnackBarInteraction> NO_INTERACTIONS = private static final List<SnackBarInteraction> NO_INTERACTIONS = new ArrayList<>();
new ArrayList<SnackBarInteraction>();
private final Context mContext; private final Context mContext;
private final SnackBarManager mSnackBarManager; private final SnackBarManager mSnackBarManager;
@@ -213,7 +212,7 @@ public class SnackBar {
mPlacement = builder.mPlacement; mPlacement = builder.mPlacement;
mParentView = builder.mParentView; mParentView = builder.mParentView;
if (builder.mInteractions == null) { if (builder.mInteractions == null) {
mInteractions = new ArrayList<SnackBarInteraction>(); mInteractions = new ArrayList<>();
} else { } else {
mInteractions = builder.mInteractions; mInteractions = builder.mInteractions;
} }
@@ -122,7 +122,7 @@ public class SettingsActivity extends BugleActionBarActivity {
*/ */
private class SettingsListAdapter extends ArrayAdapter<SettingsItem> { private class SettingsListAdapter extends ArrayAdapter<SettingsItem> {
public SettingsListAdapter(final Context context) { public SettingsListAdapter(final Context context) {
super(context, R.layout.settings_item_view, new ArrayList<SettingsItem>()); super(context, R.layout.settings_item_view, new ArrayList<>());
} }
public void setSettingsItems(final List<SettingsItem> newList) { public void setSettingsItems(final List<SettingsItem> newList) {
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -157,12 +158,12 @@ public class AttachmentGridView extends GridView implements
} }
} }
public static final Parcelable.Creator<SavedState> CREATOR = public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator<>() {
new Parcelable.Creator<SavedState>() {
@Override @Override
public SavedState createFromParcel(final Parcel in) { public SavedState createFromParcel(final Parcel in) {
return new SavedState(in); return new SavedState(in);
} }
@Override @Override
public SavedState[] newArray(final int size) { public SavedState[] newArray(final int size) {
return new SavedState[size]; return new SavedState[size];
@@ -310,7 +310,7 @@ public final class ContactRecipientAdapter extends BaseRecipientAdapter {
final RecipientMatchCallback callback) { final RecipientMatchCallback callback) {
final int addressesSize = Math.min( final int addressesSize = Math.min(
RecipientAlternatesAdapter.MAX_LOOKUPS, inAddresses.size()); RecipientAlternatesAdapter.MAX_LOOKUPS, inAddresses.size());
final HashSet<String> addresses = new HashSet<String>(); final HashSet<String> addresses = new HashSet<>();
for (int i = 0; i < addressesSize; i++) { for (int i = 0; i < addressesSize; i++) {
final Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(inAddresses.get(i).toLowerCase()); final Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(inAddresses.get(i).toLowerCase());
addresses.add(tokens.length > 0 ? tokens[0].getAddress() : inAddresses.get(i)); addresses.add(tokens.length > 0 ? tokens[0].getAddress() : inAddresses.get(i));
@@ -259,8 +259,7 @@ public class ContactRecipientAutoCompleteView extends RecipientEditTextView {
public ArrayList<ParticipantData> getRecipientParticipantDataForConversationCreation() { public ArrayList<ParticipantData> getRecipientParticipantDataForConversationCreation() {
final DrawableRecipientChip[] recips = getText() final DrawableRecipientChip[] recips = getText()
.getSpans(0, getText().length(), DrawableRecipientChip.class); .getSpans(0, getText().length(), DrawableRecipientChip.class);
final ArrayList<ParticipantData> contacts = final ArrayList<ParticipantData> contacts = new ArrayList<>(recips.length);
new ArrayList<ParticipantData>(recips.length);
for (final DrawableRecipientChip recipient : recips) { for (final DrawableRecipientChip recipient : recips) {
final RecipientEntry entry = recipient.getEntry(); final RecipientEntry entry = recipient.getEntry();
if (entry != null && entry.isValid() && entry.getDestination() != null && if (entry != null && entry.isValid() && entry.getDestination() != null &&
@@ -277,7 +276,7 @@ public class ContactRecipientAutoCompleteView extends RecipientEditTextView {
* consumer with determining quickly whether a contact is currently selected. * consumer with determining quickly whether a contact is currently selected.
*/ */
public Set<String> getSelectedDestinations() { public Set<String> getSelectedDestinations() {
Set<String> set = new HashSet<String>(); Set<String> set = new HashSet<>();
final DrawableRecipientChip[] recips = getText() final DrawableRecipientChip[] recips = getText()
.getSpans(0, getText().length(), DrawableRecipientChip.class); .getSpans(0, getText().length(), DrawableRecipientChip.class);
@@ -67,7 +67,7 @@ public class ContactRecipientPhotoManager implements PhotoManager {
new AvatarRequestDescriptor(avatarUri, mIconSize, mIconSize); new AvatarRequestDescriptor(avatarUri, mIconSize, mIconSize);
final BindableMediaRequest<ImageResource> req = descriptor.buildAsyncMediaRequest( final BindableMediaRequest<ImageResource> req = descriptor.buildAsyncMediaRequest(
mContext, mContext,
new MediaResourceLoadListener<ImageResource>() { new MediaResourceLoadListener<>() {
@Override @Override
public void onMediaResourceLoaded(final MediaRequest<ImageResource> request, public void onMediaResourceLoaded(final MediaRequest<ImageResource> request,
final ImageResource resource, final boolean isCached) { final ImageResource resource, final boolean isCached) {
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -111,7 +112,7 @@ public class ContactSectionIndexer implements SectionIndexer {
} }
this.mSections = sections; this.mSections = sections;
mSectionStartingPositions = new ArrayList<Integer>(counts.length); mSectionStartingPositions = new ArrayList<>(counts.length);
int position = 0; int position = 0;
for (int i = 0; i < counts.length; i++) { for (int i = 0; i < counts.length; i++) {
if (TextUtils.isEmpty(mSections[i])) { if (TextUtils.isEmpty(mSections[i])) {
@@ -131,8 +132,8 @@ public class ContactSectionIndexer implements SectionIndexer {
// The result is stored into two arrays, one for the section header (i.e. the first // The result is stored into two arrays, one for the section header (i.e. the first
// character), and one for the starting position, which is guaranteed to be sorted in // character), and one for the starting position, which is guaranteed to be sorted in
// ascending order. // ascending order.
final ArrayList<String> sections = new ArrayList<String>(); final ArrayList<String> sections = new ArrayList<>();
mSectionStartingPositions = new ArrayList<Integer>(); mSectionStartingPositions = new ArrayList<>();
if (cursor != null) { if (cursor != null) {
cursor.moveToPosition(-1); cursor.moveToPosition(-1);
int currentPosition = 0; int currentPosition = 0;
@@ -655,7 +655,7 @@ public class ComposeMessageView extends LinearLayout
mBinding.getData().hasAttachments(); mBinding.getData().hasAttachments();
final List<MessagePartData> attachments = final List<MessagePartData> attachments =
new ArrayList<MessagePartData>(draftMessageData.getReadOnlyAttachments()); new ArrayList<>(draftMessageData.getReadOnlyAttachments());
if (draftMessageData.getIsMms()) { // MMS case if (draftMessageData.getIsMms()) { // MMS case
if (draftMessageData.hasAttachments()) { if (draftMessageData.hasAttachments()) {
if (hasAttachmentsChanged) { if (hasAttachmentsChanged) {
@@ -276,7 +276,7 @@ public class ConversationActivityUiState implements Parcelable, Cloneable {
} }
public static final Parcelable.Creator<ConversationActivityUiState> CREATOR public static final Parcelable.Creator<ConversationActivityUiState> CREATOR
= new Parcelable.Creator<ConversationActivityUiState>() { = new Parcelable.Creator<>() {
@Override @Override
public ConversationActivityUiState createFromParcel(final Parcel in) { public ConversationActivityUiState createFromParcel(final Parcel in) {
return new ConversationActivityUiState(in); return new ConversationActivityUiState(in);
@@ -508,7 +508,7 @@ public class ConversationFragment extends Fragment implements ConversationDataLi
mRecyclerView.setHasFixedSize(true); mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(manager); mRecyclerView.setLayoutManager(manager);
mRecyclerView.setItemAnimator(new DefaultItemAnimator() { mRecyclerView.setItemAnimator(new DefaultItemAnimator() {
private final List<ViewHolder> mAddAnimations = new ArrayList<ViewHolder>(); private final List<ViewHolder> mAddAnimations = new ArrayList<>();
private PopupTransitionAnimation mPopupTransitionAnimation; private PopupTransitionAnimation mPopupTransitionAnimation;
@Override @Override

Some files were not shown because too many files have changed in this diff Show More