Bug 1386906 - Add Pocket keys to build system. r=chmanchester

MozReview-Commit-ID: 8fjcSkn1P7P

--HG--
extra : rebase_source : bb7d2a561517decdf3b05badaced27ea9e7e2000
This commit is contained in:
Chenxia Liu 2017-08-09 12:11:10 -07:00
parent 8a07e63ea4
commit 9c27584fe8
12 changed files with 62 additions and 1 deletions

View File

@ -337,4 +337,11 @@ public class AppConstants {
//#else
false;
//#endif
public static final String MOZ_POCKET_API_KEY =
//#ifdef MOZ_ANDROID_POCKET
"@MOZ_POCKET_API_KEY@";
//#else
null;
//#endif
}

View File

@ -50,6 +50,7 @@ def _defines():
'MOZ_ANDROID_PWA',
'MOZ_LEANPLUM_SDK_KEY',
'MOZ_LEANPLUM_SDK_CLIENTID',
'MOZ_ANDROID_POCKET',
'MOZ_ANDROID_SEARCH_ACTIVITY',
'MOZ_CRASHREPORTER',
'MOZ_DEBUG',
@ -112,6 +113,9 @@ def _defines():
DEFINES['MOZ_LEANPLUM_SDK_KEY'] = CONFIG['MOZ_LEANPLUM_SDK_KEY']
DEFINES['MOZ_LEANPLUM_SDK_CLIENTID'] = CONFIG['MOZ_LEANPLUM_SDK_CLIENTID']
if CONFIG['MOZ_ANDROID_POCKET']:
DEFINES['MOZ_POCKET_API_KEY'] = CONFIG['MOZ_POCKET_API_KEY']
DEFINES['MOZ_BUILDID'] = open(os.path.join(buildconfig.topobjdir, 'buildid.h')).readline().split()[2]
# Set the appropriate version code if not set by MOZ_APP_ANDROID_VERSION_CODE.

View File

@ -11,6 +11,7 @@ import android.content.SharedPreferences;
import android.net.Uri;
import android.util.Log;
import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.Locales;
import org.mozilla.gecko.util.FileUtils;
import org.mozilla.gecko.util.ProxySelector;
@ -29,6 +30,14 @@ import java.util.concurrent.TimeUnit;
* {@link #loadInBackground()} returns a JSON string of Pocket stories.
*
* NB: Using AsyncTaskLoader rather than AsyncTask so that loader is tied Activity lifecycle.
*
* Access to Pocket Stories is controlled by a private Pocket API token.
* Add the following to your mozconfig to compile with the Pocket Stories:
*
* export MOZ_ANDROID_POCKET=1
* ac_add_options --with-pocket-api-keyfile=$topsrcdir/mobile/android/base/pocket-api-sandbox.token
*
* and include the Pocket API token in the token file.
*/
public class PocketStoriesLoader extends AsyncTaskLoader<String> {
@ -42,7 +51,7 @@ public class PocketStoriesLoader extends AsyncTaskLoader<String> {
// Pocket API params and defaults
private static final String GLOBAL_ENDPOINT = "https://getpocket.com/v3/firefox/global-recs";
private static final String PARAM_APIKEY = "consumer_key";
private static final String APIKEY = "KEY_PLACEHOLDER"; // Bug 1386906: Add Pocket keys to builders.
private static final String APIKEY = AppConstants.MOZ_POCKET_API_KEY;
private static final String PARAM_COUNT = "count";
private static final int DEFAULT_COUNT = 20;
private static final String PARAM_LOCALE = "locale_lang";
@ -82,6 +91,10 @@ public class PocketStoriesLoader extends AsyncTaskLoader<String> {
@Override
public String loadInBackground() {
if (APIKEY == null) {
Log.e(LOGTAG, "Missing Pocket API key! See class comment about how to set up a mozconfig.");
return null;
}
return makeAPIRequestWithKey(APIKEY);
}

View File

@ -16,6 +16,9 @@ with Files('*Manifest*'):
with Files('adjust-sdk-sandbox.token'):
BUG_COMPONENT = ('Firefox for Android', 'Build Config & IDE Support')
with Files('pocket-api-sandbox.token'):
BUG_COMPONENT = ('Firefox for Android', 'Build Config & IDE Support')
with Files('android-services.mozbuild'):
BUG_COMPONENT = ('Android Background Services', 'Android Sync')

View File

@ -0,0 +1 @@
123456789

View File

@ -33,6 +33,7 @@ ac_add_options --without-mozilla-api-keyfile
ac_add_options --without-google-api-keyfile
ac_add_options --without-adjust-sdk-keyfile
ac_add_options --without-leanplum-sdk-keyfile
ac_add_options --without-pocket-api-keyfile
# Similarly explicitly disable install tracking for l10n, we'll inherit from en-US
export MOZ_INSTALL_TRACKING=

View File

@ -33,6 +33,7 @@ ac_add_options --without-mozilla-api-keyfile
ac_add_options --without-google-api-keyfile
ac_add_options --without-adjust-sdk-keyfile
ac_add_options --without-leanplum-sdk-keyfile
ac_add_options --without-pocket-api-keyfile
# Similarly explicitly disable install tracking for l10n, we'll inherit from en-US
export MOZ_INSTALL_TRACKING=

View File

@ -15,5 +15,6 @@ STRIP_FLAGS="--strip-debug"
export MOZILLA_OFFICIAL=1
export MOZ_TELEMETRY_REPORTING=1
export MOZ_ANDROID_MMA=1
export MOZ_ANDROID_POCKET=1
. "$topsrcdir/mobile/android/config/mozconfigs/common.override"

View File

@ -15,5 +15,6 @@ STRIP_FLAGS="--strip-debug"
export MOZILLA_OFFICIAL=1
export MOZ_TELEMETRY_REPORTING=1
export MOZ_ANDROID_MMA=1
export MOZ_ANDROID_POCKET=1
. "$topsrcdir/mobile/android/config/mozconfigs/common.override"

View File

@ -78,6 +78,19 @@ else
ac_add_options --with-leanplum-sdk-keyfile="$topsrcdir/mobile/android/base/leanplum-sdk-sandbox.token"
fi
# MOZ_ANDROID_POCKET depends on --with-pocket-api-keyfile, and will
# fail if MOZ_ANDROID_POCKET is specified but a keyfile is not. We set a default
# dummy key for non-channel builds, because Pocket is not a critical component.
if test "$MOZ_UPDATE_CHANNEL" = "release" ; then
ac_add_options --with-pocket-api-keyfile=/builds/pocket-api-release.token
elif test "$MOZ_UPDATE_CHANNEL" = "beta" ; then
ac_add_options --with-pocket-api-keyfile=/builds/pocket-api-beta.token
elif test "$MOZ_UPDATE_CHANNEL" = "nightly" ; then
ac_add_options --with-pocket-api-keyfile=/builds/pocket-api-nightly.token
else
ac_add_options --with-pocket-api-keyfile="$topsrcdir/mobile/android/base/pocket-api-sandbox.token"
fi
export SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE=/builds/crash-stats-api.token
# Package js shell.

View File

@ -44,6 +44,13 @@ option(env='MOZ_ANDROID_MMA',
set_config('MOZ_ANDROID_MMA',
depends_if('MOZ_ANDROID_MMA')(lambda _: True))
option(env='MOZ_ANDROID_POCKET',
help='Enable Pocket Stories in Activity Stream.',
default=True)
set_config('MOZ_ANDROID_POCKET',
depends_if('MOZ_ANDROID_POCKET')(lambda _: True))
project_flag('MOZ_ANDROID_DOWNLOADS_INTEGRATION',
help='Enable system download manager on Android',
default=True)
@ -159,3 +166,10 @@ def check_android_mma(android_mma,
if not leanplum_sdk_keyfile:
die('You must specify --with-leanplum-sdk-keyfile=/path/to/keyfile when'
' building with MOZ_ANDROID_MMA=1')
@depends('MOZ_ANDROID_POCKET',
'--with-pocket-api-keyfile')
def check_android_pocket(android_pocket, pocket_api_keyfile):
if android_pocket and not pocket_api_keyfile:
die('You must specify --with-pocket-api-keyfile=/path/to/keyfile when'
' building with MOZ_ANDROID_POCKET=1')

View File

@ -560,6 +560,8 @@ simple_keyfile('Adjust SDK')
id_and_secret_keyfile('Leanplum SDK')
simple_keyfile('Pocket API')
# Servo integration
# ==============================================================
option('--enable-stylo', nargs='?', choices=('build',),