For #25311 - Set tokens used when communicating with Pocket

releases_v102.0.0
Mugurell 7 months ago committed by mergify[bot]
parent 98e3b8bf52
commit 2343b7534c
  1. 1
      .gitignore
  2. 15
      app/build.gradle
  3. 6
      app/src/main/java/org/mozilla/fenix/components/Core.kt
  4. 10
      app/src/main/java/org/mozilla/fenix/utils/Settings.kt
  5. 5
      app/src/main/res/values/preference_keys.xml
  6. 1
      taskcluster/fenix_taskgraph/transforms/build.py

1
.gitignore vendored

@ -85,6 +85,7 @@ gen-external-apklibs
.mls_token
.nimbus
.wallpaper_url
.pocket_consumer_key
# Python Byte-compiled / optimized / DLL files
__pycache__/

@ -389,6 +389,21 @@ android.applicationVariants.all { variant ->
buildConfigField 'String', 'WALLPAPER_URL', '""'
println("--")
}
// -------------------------------------------------------------------------------------------------
// BuildConfig: Set the Pocket consumer key from a local file if it exists
// -------------------------------------------------------------------------------------------------
print("Pocket consumer key: ")
try {
def token = new File("${rootDir}/.pocket_consumer_key").text.trim()
buildConfigField 'String', 'POCKET_CONSUMER_KEY', '"' + token + '"'
println "(Added from .pocket_consumer_key file)"
} catch (FileNotFoundException ignored) {
buildConfigField 'String', 'POCKET_CONSUMER_KEY', '""'
println("--")
}
}
// Generate Kotlin code for the Fenix Glean metrics.

@ -365,8 +365,10 @@ class Core(
PocketStoriesConfig(
client,
Frequency(4, TimeUnit.HOURS),
// These need to be updated. See https://mozilla-hub.atlassian.net/browse/FNXV2-20329.
Profile(UUID.randomUUID(), "fenix")
Profile(
profileId = UUID.fromString(context.settings().pocketSponsoredStoriesProfileId),
appId = BuildConfig.POCKET_CONSUMER_KEY
)
)
}
val pocketStoriesService by lazyMonitored { PocketStoriesService(context, pocketStoriesConfig) }

@ -53,6 +53,7 @@ import org.mozilla.fenix.settings.sitepermissions.AUTOPLAY_BLOCK_ALL
import org.mozilla.fenix.settings.sitepermissions.AUTOPLAY_BLOCK_AUDIBLE
import org.mozilla.fenix.wallpapers.WallpaperManager
import java.security.InvalidParameterException
import java.util.UUID
private const val AUTOPLAY_USER_SETTING = "AUTOPLAY_USER_SETTING"
@ -1274,6 +1275,15 @@ class Settings(private val appContext: Context) : PreferencesHolder {
default = { homescreenSections[HomeScreenSection.POCKET] == true },
)
/**
* Get the profile id to use in the sponsored stories communications with the Pocket endpoint.
*/
val pocketSponsoredStoriesProfileId by stringPreference(
appContext.getPreferenceKey(R.string.pref_key_pocket_sponsored_stories_profile),
default = UUID.randomUUID().toString(),
persistDefaultIfNotExists = true
)
/**
* Indicates if the Contile functionality should be visible.
*/

@ -279,6 +279,10 @@
<string name="pref_key_open_next_tab_desktop_mode" translatable="false">pref_key_open_next_tab_desktop_mode</string>
<!-- Pocket -->
<string name="pref_key_pocket_homescreen_recommendations" translatable="false">pref_key_pocket_homescreen_recommendations</string>
<string name="pref_key_pocket_sponsored_stories_profile" translatable="false">pref_key_pocket_sponsored_stories_profile</string>
<!-- Secret Info Setting Keys -->
<string name="pref_key_secret_debug_info" translatable="false">pref_key_secret_debug_info</string>
@ -287,6 +291,5 @@
<string name="pref_key_nimbus_experiments" translatable="false">pref_key_nimbus_experiments</string>
<string name="pref_key_nimbus_use_preview" translatable="false">pref_key_nimbus_use_preview</string>
<string name="pref_key_history_metadata_feature" translatable="false">pref_key_history_metadata_feature</string>
<string name="pref_key_pocket_homescreen_recommendations" translatable="false">pref_key_pocket_homescreen_recommendations</string>
<string name="pref_key_show_unified_search" translatable="false">pref_key_show_unified_search</string>
</resources>

@ -55,6 +55,7 @@ def add_shippable_secrets(config, tasks):
("mls", ".mls_token"),
("nimbus_url", ".nimbus"),
("wallpaper_url", ".wallpaper_url"),
("pocket_consumer_key", ".pocket_consumer_key"),
)
]
)

Loading…
Cancel
Save