Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added gradle/verification-keyring.gpg
Empty file.
16 changes: 16 additions & 0 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13047,6 +13047,22 @@
<sha512 value="12c2b82ed8c1fc6794fe17f5f2f31ed3ded4d8353d24c4480b2f1415b6c10f6969a70ca9e758e14d94028ee46af1f6f294a17046edcfd8b0ea9f223e2733164d" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.gradle.toolchains" name="foojay-resolver" version="1.0.0">
<artifact name="foojay-resolver-1.0.0.jar">
<sha512 value="b88512eaf3aeda8862ba52b7b1a7cc5d3b232eb09f02bb288521910f018c8ede7acfe56fbceb167ad01a3a4f0092c07f675b5ae7d7906284e04f14414fb643f9" origin="Generated by Gradle"/>
</artifact>
<artifact name="foojay-resolver-1.0.0.module">
<sha512 value="1e40f52c1d48034b6a76cb72065b7c4c033bf04e45c2bed3f81d759a2b207ae7ebc1b4b33688285e91b5a9b5d486da3509ad753227415ea0ea0969bac3260186" origin="Generated by Gradle"/>
</artifact>
<artifact name="foojay-resolver-1.0.0-sources.jar">
<sha512 value="e4a3c4bd2649ccd1502cf45af4aaeeea15891dbc0c0696d9cc30b385a8fdd97ca9d36382ff399820a8ef17a3d2af447c2d4b89aec05ded01574985c4a644638f" origin="Calculated by agent"/>
</artifact>
</component>
<component group="org.gradle.toolchains.foojay-resolver-convention" name="org.gradle.toolchains.foojay-resolver-convention.gradle.plugin" version="1.0.0">
<artifact name="org.gradle.toolchains.foojay-resolver-convention.gradle.plugin-1.0.0.pom">
<sha512 value="57b924377d3c62fe9b5758c662f0d51c96bb2790b47551225958888d47abd2b04d1741c8b2d845001b3c5e1442f19c47864de11dbfa89f45bfa961521e696e20" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.hamcrest" name="hamcrest" version="2.2">
<artifact name="hamcrest-2.2-javadoc.jar">
<sha512 value="2f67a85dcb669ff712a5cda3a41e8bb4cbe20295940601e03e7f20b6f62e7506d95b621d515b96c244446b2839e2b78be4f0646939b45716f078bda27bac5002" origin="Generated by Gradle"/>
Expand Down
3 changes: 3 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ pluginManagement {
gradlePluginPortal()
}
}
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
Expand Down
46 changes: 39 additions & 7 deletions src/com/android/messaging/datamodel/BugleNotifications.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public static void update(final String conversationId, final int coverage) {
LogUtil.v(TAG, "Update: conversationId = " + conversationId
+ " coverage = " + coverage);
}
Assert.isNotMainThread();
Assert.isNotMainThread();

if (!PhoneUtils.getDefault().isDefaultSmsApp()) {
LogUtil.d(TAG, "Skipping notification: not the default SMS app");
Expand All @@ -157,10 +157,42 @@ public static void update(final String conversationId, final int coverage) {
private static void createMessageNotification(final String conversationId) {
final MessageNotificationState state = MessageNotificationState.getNotificationState();
final boolean softSound = DataModel.get().isNewMessageObservable(conversationId);

if (state == null) {
if (softSound && !TextUtils.isEmpty(conversationId)) {
final Uri ringtoneUri = getNotificationRingtoneUriForConversationId(conversationId);
playObservableConversationNotificationSound(ringtoneUri);

boolean isBlocked = false;

// 1. Access the database to check the participant's blocked status
final DatabaseWrapper db = DataModel.get().getDatabase();

// 2. Query the participant table for this specific conversation ID
final String query = "SELECT " + DatabaseHelper.ParticipantColumns.BLOCKED +
" FROM " + DatabaseHelper.PARTICIPANTS_TABLE +
" INNER JOIN " + DatabaseHelper.CONVERSATION_PARTICIPANTS_TABLE +
" ON " + DatabaseHelper.PARTICIPANTS_TABLE + "." + DatabaseHelper.ParticipantColumns._ID +
" = " + DatabaseHelper.CONVERSATION_PARTICIPANTS_TABLE + "." + DatabaseHelper.ConversationParticipantsColumns.PARTICIPANT_ID +
" WHERE " + DatabaseHelper.CONVERSATION_PARTICIPANTS_TABLE + "." + DatabaseHelper.ConversationParticipantsColumns.CONVERSATION_ID + " = ?";

try (android.database.Cursor cursor = db.rawQuery(query, new String[] { conversationId })) {
if (cursor != null) {
while (cursor.moveToNext()) {
// If any participant in this conversation has BLOCKED = 1, flag it
if (cursor.getInt(0) == 1) {
isBlocked = true;
break;
}
}
}
}

// 3. The Gatekeeper: Only play the sound if the conversation is NOT blocked
if (!isBlocked) {
final Uri ringtoneUri = getNotificationRingtoneUriForConversationId(conversationId);
playObservableConversationNotificationSound(ringtoneUri);
} else {
LogUtil.v(TAG, "Suppressed audio for blocked observable conversation.");
}
}
return;
}
Expand Down Expand Up @@ -232,7 +264,7 @@ private static Uri getNotificationRingtoneUriForConversationId(final String conv
* @param conversationId The conversation id (optional)
*/
private static String buildNotificationTag(final String name,
final String conversationId) {
final String conversationId) {
final Context context = Factory.get().getApplicationContext();
if (conversationId != null) {
return context.getPackageName() + name + ":" + conversationId;
Expand Down Expand Up @@ -489,7 +521,7 @@ private static void playObservableConversationNotificationSound(final Uri ringto
final boolean silenced =
audioManager.getRingerMode() != AudioManager.RINGER_MODE_NORMAL;
if (silenced) {
return;
return;
}

final NotificationPlayer player = new NotificationPlayer(LogUtil.BUGLE_TAG);
Expand Down Expand Up @@ -522,12 +554,12 @@ public static void markMessagesAsRead(final String conversationId, final boolean
}

public static void notifyEmergencySmsFailed(final String emergencyNumber,
final String conversationId) {
final String conversationId) {
final Context context = Factory.get().getApplicationContext();

final CharSequence line1 = MessageNotificationState.applyWarningTextColor(context,
context.getString(R.string.notification_emergency_send_failure_line1,
emergencyNumber));
emergencyNumber));
final String line2 = context.getString(R.string.notification_emergency_send_failure_line2,
emergencyNumber);
final PendingIntent destinationIntent = UIIntents.get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ public static void processMessageDownloaded(final int resultCode, final Bundle e

// This is called for fast failing downloading (due to airplane mode or mobile data )
public static void processMessageDownloadFastFailed(final String messageId,
final Uri notificationUri, final String conversationId, final String participantId,
final String contentLocation, final int subId, final String subPhoneNumber,
final int statusIfFailed, final boolean autoDownload, final String transactionId,
final int resultCode) {
final Uri notificationUri, final String conversationId, final String participantId,
final String contentLocation, final int subId, final String subPhoneNumber,
final int statusIfFailed, final boolean autoDownload, final String transactionId,
final int resultCode) {
Assert.notNull(messageId);
Assert.notNull(notificationUri);
Assert.notNull(conversationId);
Expand All @@ -163,8 +163,8 @@ public static void processMessageDownloadFastFailed(final String messageId,
}

public static void processDownloadActionFailure(final String messageId, final int status,
final int rawStatus, final String conversationId, final String participantId,
final int statusIfFailed, final int subId, final String transactionId) {
final int rawStatus, final String conversationId, final String participantId,
final int statusIfFailed, final int subId, final String transactionId) {
Assert.notNull(messageId);
Assert.notNull(conversationId);
Assert.notNull(participantId);
Expand All @@ -184,7 +184,7 @@ public static void processDownloadActionFailure(final String messageId, final in
}

public static void sendDeferredRespStatus(final String messageId, final String transactionId,
final String contentLocation, final int subId) {
final String contentLocation, final int subId) {
final ProcessDownloadedMmsAction action = new ProcessDownloadedMmsAction();
final Bundle params = action.actionParameters;
params.putString(KEY_MESSAGE_ID, messageId);
Expand Down Expand Up @@ -473,7 +473,8 @@ private MessageData processResult(final int status, final int rawStatus, final U

// TODO: Also write these values to the telephony provider
mms.mRead = messageInFocusedConversation;
mms.mSeen = messageInObservableConversation;
// Align with standard SMS: seen = read || messageInObservableConversation || blocked
mms.mSeen = mms.mRead || messageInObservableConversation || blockedSender;

// Translate to our format
message = MmsUtils.createMmsMessage(mms, conversationId, senderParticipantId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,9 @@ public static final String getNotificationQuerySql() {
+ MessageData.BUGLE_STATUS_INCOMING_COMPLETE + ", "
+ MessageData.BUGLE_STATUS_INCOMING_YET_TO_MANUAL_DOWNLOAD + ")"
+ " AND "
+ DatabaseHelper.MessageColumns.SEEN + " = 0)"
+ DatabaseHelper.MessageColumns.SEEN + " = 0"
+ " AND "
+ DatabaseHelper.PARTICIPANTS_TABLE + "." + ParticipantColumns.BLOCKED + " = 0)"
+ ")"
+ NOTIFICATION_QUERY_SQL_GROUP_BY;
}
Expand Down
17 changes: 16 additions & 1 deletion src/com/android/messaging/receiver/SmsReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,23 @@ public void onReceive(final Context context, final Intent intent) {
(Telephony.Sms.Intents.SMS_RECEIVED_ACTION.equals(action) ||
// TODO: update this with the actual constant from Telephony
"android.provider.Telephony.MMS_DOWNLOADED".equals(action))) {
postNewMessageSecondaryUserNotification();
boolean isSenderBlocked = false;
final android.telephony.SmsMessage[] messages = getMessagesFromIntent(intent);
if (messages != null && messages.length > 0) {
final String senderAddress = messages[0].getOriginatingAddress();
if (senderAddress != null) {
final com.android.messaging.datamodel.DatabaseWrapper db = com.android.messaging.datamodel.DataModel.get().getDatabase();
isSenderBlocked = com.android.messaging.datamodel.BugleDatabaseOperations.isBlockedDestination(db, senderAddress);

}
}
if (isSenderBlocked) {
postNewMessageSecondaryUserNotification();
}else{
LogUtil.v(TAG,"SmsReceviver:Suppressed secondary user notification for blocked sender");
}
}

}
}

Expand Down
Loading