[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [Git][tpo/applications/tor-browser][tor-browser-128.3.0esr-14.0-1] fixup! [android] Use NimbusDisabled



Title: GitLab

morgan pushed to branch tor-browser-128.3.0esr-14.0-1 at The Tor Project / Applications / Tor Browser

Commits:

  • 183d35fc
    by clairehurst at 2024-10-03T14:55:59-06:00
    fixup! [android] Use NimbusDisabled
    

3 changed files:

Changes:

  • mobile/android/android-components/components/service/nimbus/src/main/java/mozilla/components/service/nimbus/messaging/NimbusMessagingController.kt
    ... ... @@ -101,36 +101,36 @@ open class NimbusMessagingController(
    101 101
          * creates a URI string for the message action.
    
    102 102
          */
    
    103 103
         @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
    
    104
    -    fun processMessageActionToUri(message: Message): Uri {
    
    104
    +    open fun processMessageActionToUri(message: Message): Uri {
    
    105 105
             val (uuid, action) = messagingStorage.generateUuidAndFormatMessage(message)
    
    106 106
             sendClickedMessageTelemetry(message.id, uuid)
    
    107 107
     
    
    108 108
             return convertActionIntoDeepLinkSchemeUri(action)
    
    109 109
         }
    
    110 110
     
    
    111
    -    private fun sendDismissedMessageTelemetry(messageId: String) {
    
    111
    +    open fun sendDismissedMessageTelemetry(messageId: String) {
    
    112 112
             GleanMessaging.messageDismissed.record(GleanMessaging.MessageDismissedExtra(messageId))
    
    113 113
         }
    
    114 114
     
    
    115
    -    private fun sendShownMessageTelemetry(messageId: String) {
    
    115
    +    open fun sendShownMessageTelemetry(messageId: String) {
    
    116 116
             GleanMessaging.messageShown.record(GleanMessaging.MessageShownExtra(messageId))
    
    117 117
         }
    
    118 118
     
    
    119
    -    private fun sendExpiredMessageTelemetry(messageId: String) {
    
    119
    +    open fun sendExpiredMessageTelemetry(messageId: String) {
    
    120 120
             GleanMessaging.messageExpired.record(GleanMessaging.MessageExpiredExtra(messageId))
    
    121 121
         }
    
    122 122
     
    
    123
    -    private fun sendClickedMessageTelemetry(messageId: String, uuid: String?) {
    
    123
    +    open fun sendClickedMessageTelemetry(messageId: String, uuid: String?) {
    
    124 124
             GleanMessaging.messageClicked.record(
    
    125 125
                 GleanMessaging.MessageClickedExtra(messageKey = messageId, actionUuid = uuid),
    
    126 126
             )
    
    127 127
         }
    
    128 128
     
    
    129
    -    private fun sendMicrosurveyCompletedTelemetry(messageId: String, answer: String?) {
    
    129
    +    open fun sendMicrosurveyCompletedTelemetry(messageId: String, answer: String?) {
    
    130 130
             MicroSurvey.response.record(MicroSurvey.ResponseExtra(surveyId = messageId, userSelection = answer))
    
    131 131
         }
    
    132 132
     
    
    133
    -    private fun convertActionIntoDeepLinkSchemeUri(action: String): Uri =
    
    133
    +    open fun convertActionIntoDeepLinkSchemeUri(action: String): Uri =
    
    134 134
             if (action.startsWith("://")) {
    
    135 135
                 "$deepLinkScheme$action".toUri()
    
    136 136
             } else {
    

  • mobile/android/android-components/components/service/nimbus/src/main/java/mozilla/components/service/nimbus/messaging/NimbusMessagingStorage.kt
    ... ... @@ -33,7 +33,7 @@ const val MESSAGING_FEATURE_ID = "messaging"
    33 33
     /**
    
    34 34
      * Provides messages from [messagingFeature] and combine with the metadata store on [metadataStorage].
    
    35 35
      */
    
    36
    -class NimbusMessagingStorage(
    
    36
    +open class NimbusMessagingStorage(
    
    37 37
         private val context: Context,
    
    38 38
         private val metadataStorage: MessageMetadataStorage,
    
    39 39
         private val onMalformedMessage: (String) -> Unit = {
    

  • mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/NimbusComponents.kt
    ... ... @@ -5,15 +5,21 @@
    5 5
     package org.mozilla.fenix.components
    
    6 6
     
    
    7 7
     import android.content.Context
    
    8
    +import android.content.Intent
    
    9
    +import android.net.Uri
    
    8 10
     import mozilla.components.service.nimbus.NimbusApi
    
    9 11
     import mozilla.components.service.nimbus.NimbusDisabled
    
    10 12
     import mozilla.components.service.nimbus.messaging.FxNimbusMessaging
    
    11 13
     import mozilla.components.service.nimbus.messaging.Message
    
    14
    +import mozilla.components.service.nimbus.messaging.Message.Metadata
    
    15
    +import mozilla.components.service.nimbus.messaging.MessageData
    
    12 16
     import mozilla.components.service.nimbus.messaging.MessageMetadataStorage
    
    17
    +import mozilla.components.service.nimbus.messaging.MessageSurfaceId
    
    13 18
     import mozilla.components.service.nimbus.messaging.NimbusMessagingController
    
    14 19
     import mozilla.components.service.nimbus.messaging.NimbusMessagingControllerInterface
    
    15 20
     import mozilla.components.service.nimbus.messaging.NimbusMessagingStorage
    
    16 21
     import mozilla.components.service.nimbus.messaging.OnDiskMessageMetadataStorage
    
    22
    +import mozilla.components.service.nimbus.messaging.StyleData
    
    17 23
     import org.mozilla.experiments.nimbus.NimbusEventStore
    
    18 24
     import org.mozilla.experiments.nimbus.NimbusMessagingHelperInterface
    
    19 25
     import org.mozilla.experiments.nimbus.NullNimbus
    
    ... ... @@ -91,7 +97,7 @@ class NimbusComponents(private val context: Context) {
    91 97
          * from the Nimbus Messaging component.
    
    92 98
          */
    
    93 99
         val messaging: NimbusMessagingControllerInterface by lazyMonitored {
    
    94
    -        NimbusMessagingController(
    
    100
    +        NullNimbusMessagingController(
    
    95 101
                 messagingStorage = messagingStorage,
    
    96 102
                 deepLinkScheme = BuildConfig.DEEP_LINK_SCHEME,
    
    97 103
             )
    
    ... ... @@ -127,3 +133,110 @@ class NullMessageMetadataStorage(): MessageMetadataStorage {
    127 133
             // noop
    
    128 134
         }
    
    129 135
     }
    
    136
    +
    
    137
    +class NullNimbusMessagingController(
    
    138
    +    messagingStorage: NimbusMessagingStorage,
    
    139
    +    deepLinkScheme: String,
    
    140
    +) : NimbusMessagingController(messagingStorage, deepLinkScheme) {
    
    141
    +
    
    142
    +    private val nullMessage: Message = Message(
    
    143
    +        id = "",
    
    144
    +        data = MessageData(),
    
    145
    +        action = "",
    
    146
    +        style = StyleData(),
    
    147
    +        triggerIfAll = listOf(),
    
    148
    +        excludeIfAny = listOf(),
    
    149
    +        metadata = Metadata(""),
    
    150
    +    )
    
    151
    +
    
    152
    +    override suspend fun onMessageDisplayed(displayedMessage: Message, bootIdentifier: String?): Message {
    
    153
    +        return nullMessage
    
    154
    +    }
    
    155
    +
    
    156
    +    /**
    
    157
    +     * Called when a message has been dismissed by the user.
    
    158
    +     *
    
    159
    +     * Records a messageDismissed event, and records that the message
    
    160
    +     * has been dismissed.
    
    161
    +     */
    
    162
    +    override suspend fun onMessageDismissed(message: Message) {
    
    163
    +        return
    
    164
    +    }
    
    165
    +
    
    166
    +    /**
    
    167
    +     * Called when a microsurvey attached to a message has been completed by the user.
    
    168
    +     *
    
    169
    +     * @param message The message containing the microsurvey that was completed.
    
    170
    +     * @param answer The user's response to the microsurvey question.
    
    171
    +     */
    
    172
    +    override suspend fun onMicrosurveyCompleted(message: Message, answer: String) {
    
    173
    +        return
    
    174
    +    }
    
    175
    +
    
    176
    +    /**
    
    177
    +     * Called once the user has clicked on a message.
    
    178
    +     *
    
    179
    +     * This records that the message has been clicked on, but does not record a
    
    180
    +     * glean event. That should be done via [processMessageActionToUri].
    
    181
    +     */
    
    182
    +    override suspend fun onMessageClicked(message: Message) {
    
    183
    +        return
    
    184
    +    }
    
    185
    +
    
    186
    +    /**
    
    187
    +     * Create and return the relevant [Intent] for the given [Message].
    
    188
    +     *
    
    189
    +     * @param message the [Message] to create the [Intent] for.
    
    190
    +     * @return an [Intent] using the processed [Message].
    
    191
    +     */
    
    192
    +    override fun getIntentForMessage(message: Message) = Intent()
    
    193
    +
    
    194
    +    /**
    
    195
    +     * Will attempt to get the [Message] for the given [id].
    
    196
    +     *
    
    197
    +     * @param id the [Message.id] of the [Message] to try to match.
    
    198
    +     * @return the [Message] with a matching [id], or null if no [Message] has a matching [id].
    
    199
    +     */
    
    200
    +    override suspend fun getMessage(id: String): Message? {
    
    201
    +        return nullMessage
    
    202
    +    }
    
    203
    +
    
    204
    +    /**
    
    205
    +     * The [message] action needs to be examined for string substitutions
    
    206
    +     * and any `uuid` needs to be recorded in the Glean event.
    
    207
    +     *
    
    208
    +     * We call this `process` as it has a side effect of logging a Glean event while it
    
    209
    +     * creates a URI string for the message action.
    
    210
    +     */
    
    211
    +    override fun processMessageActionToUri(message: Message): Uri {
    
    212
    +        return Uri.EMPTY
    
    213
    +    }
    
    214
    +
    
    215
    +    override fun sendDismissedMessageTelemetry(messageId: String) {
    
    216
    +        return
    
    217
    +    }
    
    218
    +
    
    219
    +    override fun sendShownMessageTelemetry(messageId: String) {
    
    220
    +        return
    
    221
    +    }
    
    222
    +
    
    223
    +    override fun sendExpiredMessageTelemetry(messageId: String) {
    
    224
    +        return
    
    225
    +    }
    
    226
    +
    
    227
    +    override fun sendClickedMessageTelemetry(messageId: String, uuid: String?) {
    
    228
    +        return
    
    229
    +    }
    
    230
    +
    
    231
    +    override fun sendMicrosurveyCompletedTelemetry(messageId: String, answer: String?) {
    
    232
    +        return
    
    233
    +    }
    
    234
    +
    
    235
    +    override fun convertActionIntoDeepLinkSchemeUri(action: String): Uri = Uri.EMPTY
    
    236
    +
    
    237
    +    override suspend fun getMessages(): List<Message> = listOf()
    
    238
    +
    
    239
    +    override suspend fun getNextMessage(surfaceId: MessageSurfaceId) = nullMessage
    
    240
    +
    
    241
    +    override fun getNextMessage(surfaceId: MessageSurfaceId, messages: List<Message>) = nullMessage
    
    242
    +}

  • _______________________________________________
    tor-commits mailing list
    tor-commits@xxxxxxxxxxxxxxxxxxxx
    https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits