Specify exported status and PendingIntent mutability.

Also reduce shake sampling frequency, add coarse location permission.
Random things for targetSdk 32.
This commit is contained in:
Nicholas Tinsley
2022-09-20 10:13:58 -04:00
committed by Cody Henthorne
parent 2566d6f61f
commit b9f4dc3fe9
38 changed files with 126 additions and 63 deletions

View File

@@ -15,6 +15,7 @@ import androidx.core.app.NotificationCompat
import androidx.core.app.RemoteInput
import androidx.core.content.LocusIdCompat
import androidx.core.graphics.drawable.IconCompat
import org.signal.core.util.PendingIntentFlags.mutable
import org.thoughtcrime.securesms.R
import org.thoughtcrime.securesms.conversation.ConversationIntents
import org.thoughtcrime.securesms.database.GroupDatabase
@@ -341,7 +342,7 @@ sealed class NotificationBuilder(protected val context: Context) {
context,
0,
ConversationIntents.createBubbleIntent(context, conversation.recipient.id, conversation.thread.threadId),
0
mutable()
)
val bubbleMetadata = NotificationCompat.BubbleMetadata.Builder(intent, AvatarUtil.getIconCompatForShortcut(context, conversation.recipient))

View File

@@ -136,7 +136,7 @@ data class NotificationConversation(
return try {
TaskStackBuilder.create(context)
.addNextIntentWithParentStack(intent)
.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT)
.getPendingIntent(0, PendingIntentFlags.updateCurrent())
} catch (e: NullPointerException) {
Log.w(NotificationFactory.TAG, "Vivo device quirk sometimes throws NPE", e)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)

View File

@@ -15,6 +15,7 @@ import android.os.TransactionTooLargeException
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.content.ContextCompat
import org.signal.core.util.PendingIntentFlags
import org.signal.core.util.concurrent.SignalExecutors
import org.signal.core.util.logging.Log
import org.thoughtcrime.securesms.MainActivity
@@ -239,7 +240,7 @@ object NotificationFactory {
setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN)
setChannelId(NotificationChannels.getMessagesChannel(context))
setContentTitle(context.getString(R.string.app_name))
setContentIntent(PendingIntent.getActivity(context, 0, MainActivity.clearTop(context), 0))
setContentIntent(PendingIntent.getActivity(context, 0, MainActivity.clearTop(context), PendingIntentFlags.mutable()))
setGroupSummary(true)
setSubText(context.getString(R.string.MessageNotifier_d_new_messages_in_d_conversations, state.messageCount, state.threadCount))
setContentInfo(state.messageCount.toString())
@@ -320,7 +321,7 @@ object NotificationFactory {
setContentTitle(context.getString(R.string.MessageNotifier_message_delivery_failed))
setContentText(context.getString(R.string.MessageNotifier_failed_to_deliver_message))
setTicker(context.getString(R.string.MessageNotifier_error_delivering_message))
setContentIntent(PendingIntent.getActivity(context, 0, intent, 0))
setContentIntent(PendingIntent.getActivity(context, 0, intent, PendingIntentFlags.mutable()))
setAutoCancel(true)
setAlarms(recipient)
setChannelId(NotificationChannels.FAILURES)
@@ -349,7 +350,7 @@ object NotificationFactory {
setLargeIcon(BitmapFactory.decodeResource(context.resources, R.drawable.ic_info_outline))
setContentTitle(context.getString(R.string.MessageNotifier_message_delivery_paused))
setContentText(context.getString(R.string.MessageNotifier_verify_to_continue_messaging_on_signal))
setContentIntent(PendingIntent.getActivity(context, 0, intent, 0))
setContentIntent(PendingIntent.getActivity(context, 0, intent, PendingIntentFlags.mutable()))
setOnlyAlertOnce(true)
setAutoCancel(true)
setAlarms(recipient)

View File

@@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.notifications.v2
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import org.signal.core.util.PendingIntentFlags
import org.thoughtcrime.securesms.notifications.DeleteNotificationReceiver
import org.thoughtcrime.securesms.notifications.MarkReadReceiver
import org.thoughtcrime.securesms.notifications.NotificationIds
@@ -67,7 +68,7 @@ data class NotificationState(val conversations: List<NotificationConversation>,
.putParcelableArrayListExtra(DeleteNotificationReceiver.EXTRA_THREADS, ArrayList(threads))
.makeUniqueToPreventMerging()
return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
return PendingIntent.getBroadcast(context, 0, intent, PendingIntentFlags.updateCurrent())
}
fun getMarkAsReadIntent(context: Context): PendingIntent? {
@@ -76,7 +77,7 @@ data class NotificationState(val conversations: List<NotificationConversation>,
.putExtra(MarkReadReceiver.NOTIFICATION_ID_EXTRA, NotificationIds.MESSAGE_SUMMARY)
.makeUniqueToPreventMerging()
return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
return PendingIntent.getBroadcast(context, 0, intent, PendingIntentFlags.updateCurrent())
}
fun getThreadsWithMostRecentNotificationFromSelf(): Set<ConversationId> {