ProcessPendingMessagesAction works based on subscriptions

PorcessPendingMessagesAction queues one message for sending/downloading
associated with a subscription triggering current action at a time. And
the ConnectivityUtil also works based on subscriptions so that pending
messages can be processed regardless of other phones' state in multi-sim
case.

It includes cleanup code as well.

Test: Manual

Change-Id: Id6b4f4a0aa6a3291e7a4d8a5d3f0fbb9db3c5b86
Signed-off-by: Taesu Lee <taesu82.lee@samsung.com>
This commit is contained in:
Taesu Lee
2020-02-28 18:16:54 +09:00
parent 4e84ad49bb
commit 4e99cc0a02
21 changed files with 274 additions and 464 deletions
@@ -22,10 +22,12 @@ import android.database.Cursor;
import android.graphics.Color;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.appcompat.mms.MmsManager;
import android.telephony.SubscriptionInfo;
import android.text.TextUtils;
import androidx.appcompat.mms.MmsManager;
import androidx.collection.ArrayMap;
import com.android.ex.chips.RecipientEntry;
import com.android.messaging.Factory;
import com.android.messaging.R;
@@ -41,6 +43,10 @@ import com.android.messaging.util.TextUtil;
* A class that encapsulates all of the data for a specific participant in a conversation.
*/
public class ParticipantData implements Parcelable {
private static final ArrayMap<Integer, String> sSubIdtoParticipantIdCache =
new ArrayMap<Integer, String>();
// 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;
@@ -282,6 +288,34 @@ public class ParticipantData implements Parcelable {
return pd;
}
public static String getParticipantId(final DatabaseWrapper db, final int subId) {
String id;
synchronized (sSubIdtoParticipantIdCache) {
id = sSubIdtoParticipantIdCache.get(subId);
}
if (id != null) {
return id;
}
try (final Cursor cursor =
db.query(DatabaseHelper.PARTICIPANTS_TABLE,
new String[] {ParticipantColumns._ID},
ParticipantColumns.SUB_ID + " =?",
new String[] {Integer.toString(subId)}, null, null, null)) {
if (cursor.moveToFirst()) {
// We found an existing participant in the database
id = cursor.getString(0);
synchronized (sSubIdtoParticipantIdCache) {
// Add it to the cache for next time
sSubIdtoParticipantIdCache.put(subId, id);
}
}
}
return id;
}
private void maybeSetupUnknownSender() {
if (isUnknownSender()) {
// Because your locale may change, we setup the display string for the unknown sender