mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-18 15:55:36 +00:00
Bug 1568674 Leanplum startup problem in Fennec 68.0 r=VladBaicu
Enabled bidirectional realtime variable updates for production mode. Differential Revision: https://phabricator.services.mozilla.com/D41231 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
f3d824c187
commit
3045c46408
@ -15,6 +15,7 @@ import android.support.annotation.NonNull;
|
|||||||
import org.mozilla.gecko.AppConstants;
|
import org.mozilla.gecko.AppConstants;
|
||||||
import org.mozilla.gecko.BrowserApp;
|
import org.mozilla.gecko.BrowserApp;
|
||||||
import org.mozilla.gecko.Experiments;
|
import org.mozilla.gecko.Experiments;
|
||||||
|
import org.mozilla.gecko.GeckoSharedPrefs;
|
||||||
import org.mozilla.gecko.MmaConstants;
|
import org.mozilla.gecko.MmaConstants;
|
||||||
import org.mozilla.gecko.PrefsHelper;
|
import org.mozilla.gecko.PrefsHelper;
|
||||||
import org.mozilla.gecko.R;
|
import org.mozilla.gecko.R;
|
||||||
@ -109,6 +110,7 @@ public class MmaDelegate {
|
|||||||
}
|
}
|
||||||
mmaHelper.setDeviceId(deviceId);
|
mmaHelper.setDeviceId(deviceId);
|
||||||
PrefsHelper.setPref(GeckoPreferences.PREFS_MMA_DEVICE_ID, deviceId);
|
PrefsHelper.setPref(GeckoPreferences.PREFS_MMA_DEVICE_ID, deviceId);
|
||||||
|
mmaHelper.setToken(GeckoSharedPrefs.forApp(applicationContext).getString("gcm_token", ""));
|
||||||
// above two config setup required to be invoked before mmaHelper.init.
|
// above two config setup required to be invoked before mmaHelper.init.
|
||||||
mmaHelper.init(activity, attributes);
|
mmaHelper.init(activity, attributes);
|
||||||
|
|
||||||
|
@ -32,6 +32,8 @@ public interface MmaInterface {
|
|||||||
|
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
|
void setToken(String token);
|
||||||
|
|
||||||
@CheckResult boolean handleGcmMessage(Context context, String from, Bundle bundle);
|
@CheckResult boolean handleGcmMessage(Context context, String from, Bundle bundle);
|
||||||
|
|
||||||
void setDeviceId(@NonNull String deviceId);
|
void setDeviceId(@NonNull String deviceId);
|
||||||
|
@ -160,6 +160,11 @@ public class MmaLeanplumImp implements MmaInterface {
|
|||||||
Leanplum.setDeviceId(deviceId);
|
Leanplum.setDeviceId(deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setToken(@NonNull String token) {
|
||||||
|
Leanplum.setToken(token);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PanelConfig getPanelConfig(@NonNull Context context, PanelConfig.TYPE type, final boolean useLocalValues) {
|
public PanelConfig getPanelConfig(@NonNull Context context, PanelConfig.TYPE type, final boolean useLocalValues) {
|
||||||
if (useLocalValues) {
|
if (useLocalValues) {
|
||||||
|
@ -48,6 +48,11 @@ public class MmaStubImp implements MmaInterface {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setToken(String token) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handleGcmMessage(Context context, String from, Bundle bundle) {
|
public boolean handleGcmMessage(Context context, String from, Bundle bundle) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -104,6 +104,7 @@ public class Leanplum {
|
|||||||
private static RegisterDeviceFinishedCallback registerDeviceFinishedHandler;
|
private static RegisterDeviceFinishedCallback registerDeviceFinishedHandler;
|
||||||
private static LeanplumDeviceIdMode deviceIdMode = LeanplumDeviceIdMode.MD5_MAC_ADDRESS;
|
private static LeanplumDeviceIdMode deviceIdMode = LeanplumDeviceIdMode.MD5_MAC_ADDRESS;
|
||||||
private static String customDeviceId;
|
private static String customDeviceId;
|
||||||
|
private static String customToken;
|
||||||
private static String defaultChannelId;
|
private static String defaultChannelId;
|
||||||
private static boolean userSpecifiedDeviceId;
|
private static boolean userSpecifiedDeviceId;
|
||||||
private static boolean initializedMessageTemplates = false;
|
private static boolean initializedMessageTemplates = false;
|
||||||
@ -173,6 +174,10 @@ public class Leanplum {
|
|||||||
Constants.hashFilesToDetermineModifications = enabled;
|
Constants.hashFilesToDetermineModifications = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setToken(String token) {
|
||||||
|
customToken = token;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional. Whether to enable file uploading in development mode.
|
* Optional. Whether to enable file uploading in development mode.
|
||||||
*
|
*
|
||||||
@ -634,11 +639,7 @@ public class Leanplum {
|
|||||||
*/
|
*/
|
||||||
private static void checkAndStartNotificationsModules() {
|
private static void checkAndStartNotificationsModules() {
|
||||||
if (Util.hasPlayServices()) {
|
if (Util.hasPlayServices()) {
|
||||||
try {
|
LeanplumPushService.onStart();
|
||||||
Class.forName(LEANPLUM_PUSH_SERVICE).getDeclaredMethod("onStart")
|
|
||||||
.invoke(null);
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Log.i("No valid Google Play Services APK found.");
|
Log.i("No valid Google Play Services APK found.");
|
||||||
}
|
}
|
||||||
@ -696,6 +697,8 @@ public class Leanplum {
|
|||||||
params.put(Constants.Params.DEVICE_SYSTEM_VERSION, Util.getSystemVersion());
|
params.put(Constants.Params.DEVICE_SYSTEM_VERSION, Util.getSystemVersion());
|
||||||
if (!TextUtils.isEmpty(registrationId)) {
|
if (!TextUtils.isEmpty(registrationId)) {
|
||||||
params.put(Constants.Params.DEVICE_PUSH_TOKEN, registrationId);
|
params.put(Constants.Params.DEVICE_PUSH_TOKEN, registrationId);
|
||||||
|
} else if (!TextUtils.isEmpty(customToken)) {
|
||||||
|
params.put(Constants.Params.DEVICE_PUSH_TOKEN, customToken);
|
||||||
}
|
}
|
||||||
params.put(Constants.Keys.TIMEZONE, localTimeZone.getID());
|
params.put(Constants.Keys.TIMEZONE, localTimeZone.getID());
|
||||||
params.put(Constants.Keys.TIMEZONE_OFFSET_SECONDS, Integer.toString(timezoneOffsetSeconds));
|
params.put(Constants.Keys.TIMEZONE_OFFSET_SECONDS, Integer.toString(timezoneOffsetSeconds));
|
||||||
@ -848,10 +851,8 @@ public class Leanplum {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class.forName(LEANPLUM_NOTIFICATION_CHANNEL)
|
LeanplumNotificationChannel.configureChannels(context, notificationGroups,
|
||||||
.getDeclaredMethod("configureChannels", Context.class, JSONArray.class,
|
notificationChannels, defaultNotificationChannel);
|
||||||
JSONArray.class, String.class).invoke(new Object(), context,
|
|
||||||
notificationGroups, notificationChannels, defaultNotificationChannel);
|
|
||||||
} catch (Throwable ignored) {
|
} catch (Throwable ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -880,8 +881,6 @@ public class Leanplum {
|
|||||||
parseVariantDebugInfo(response);
|
parseVariantDebugInfo(response);
|
||||||
|
|
||||||
// Allow bidirectional realtime variable updates.
|
// Allow bidirectional realtime variable updates.
|
||||||
if (Constants.isDevelopmentModeEnabled) {
|
|
||||||
|
|
||||||
final Context currentContext = (
|
final Context currentContext = (
|
||||||
LeanplumActivityHelper.currentActivity != context &&
|
LeanplumActivityHelper.currentActivity != context &&
|
||||||
LeanplumActivityHelper.currentActivity != null) ?
|
LeanplumActivityHelper.currentActivity != null) ?
|
||||||
@ -940,7 +939,7 @@ public class Leanplum {
|
|||||||
|
|
||||||
// Check for updates.
|
// Check for updates.
|
||||||
final String latestVersion = response.optString(Constants.Keys.LATEST_VERSION, null);
|
final String latestVersion = response.optString(Constants.Keys.LATEST_VERSION, null);
|
||||||
if (isRegistered && latestVersion != null) {
|
if (isRegistered && latestVersion != null && Constants.isDevelopmentModeEnabled) {
|
||||||
Log.i("An update to Leanplum Android SDK, " + latestVersion +
|
Log.i("An update to Leanplum Android SDK, " + latestVersion +
|
||||||
", is available. Go to leanplum.com to download it.");
|
", is available. Go to leanplum.com to download it.");
|
||||||
}
|
}
|
||||||
@ -969,7 +968,6 @@ public class Leanplum {
|
|||||||
if (isRegistered) {
|
if (isRegistered) {
|
||||||
LeanplumInternal.onHasStartedAndRegisteredAsDeveloper();
|
LeanplumInternal.onHasStartedAndRegisteredAsDeveloper();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
LeanplumInternal.moveToForeground();
|
LeanplumInternal.moveToForeground();
|
||||||
startHeartbeat();
|
startHeartbeat();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
@ -89,14 +89,8 @@ abstract class LeanplumCloudMessagingProvider {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LeanplumCloudMessagingProvider.registrationId = registrationId;
|
LeanplumCloudMessagingProvider.registrationId = registrationId;
|
||||||
// Check if received push notification token is different from stored one and send new one to
|
storePreferences(context.getApplicationContext());
|
||||||
// server.
|
sendRegistrationIdToBackend(registrationId);
|
||||||
if (!LeanplumCloudMessagingProvider.registrationId.equals(SharedPreferencesUtil.getString(
|
|
||||||
context, Constants.Defaults.LEANPLUM_PUSH, Constants.Defaults.PROPERTY_REGISTRATION_ID))) {
|
|
||||||
Log.i("Device registered for push notifications with registration token", registrationId);
|
|
||||||
storePreferences(context.getApplicationContext());
|
|
||||||
sendRegistrationIdToBackend(LeanplumCloudMessagingProvider.registrationId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -631,7 +631,7 @@ class LeanplumNotificationChannel {
|
|||||||
* @param notificationChannels Notification channels.
|
* @param notificationChannels Notification channels.
|
||||||
* @param defaultNotificationChannel Default channel details.
|
* @param defaultNotificationChannel Default channel details.
|
||||||
*/
|
*/
|
||||||
static void configureChannels(Context context, JSONArray notificationGroups,
|
public static void configureChannels(Context context, JSONArray notificationGroups,
|
||||||
JSONArray notificationChannels, String defaultNotificationChannel) {
|
JSONArray notificationChannels, String defaultNotificationChannel) {
|
||||||
// Configure notification channels and groups
|
// Configure notification channels and groups
|
||||||
configureNotificationGroups(
|
configureNotificationGroups(
|
||||||
|
@ -109,13 +109,7 @@ public class LeanplumPushService {
|
|||||||
* multiple sender IDs, use {@link LeanplumPushService#setGcmSenderIds}.
|
* multiple sender IDs, use {@link LeanplumPushService#setGcmSenderIds}.
|
||||||
*/
|
*/
|
||||||
public static void setGcmSenderId(String senderId) {
|
public static void setGcmSenderId(String senderId) {
|
||||||
try {
|
LeanplumGcmProvider.setSenderId(senderId);
|
||||||
Class.forName(COM_LEANPLUM_GCM_PROVIDER).getDeclaredMethod("setSenderId",
|
|
||||||
String.class).invoke(new Object(), senderId);
|
|
||||||
} catch (Throwable throwable) {
|
|
||||||
Log.e("Couldn't invoke a LeanplumGcmProvider.setGcmSenderId method, please be " +
|
|
||||||
"sure you include LeanplumGCM module.", throwable);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -744,39 +738,7 @@ public class LeanplumPushService {
|
|||||||
* Call this when Leanplum starts. This method will call by reflection from AndroidSDKCore.
|
* Call this when Leanplum starts. This method will call by reflection from AndroidSDKCore.
|
||||||
*/
|
*/
|
||||||
static void onStart() {
|
static void onStart() {
|
||||||
Class leanplumGcmPushServiceClass = null;
|
LeanplumPushServiceGcm.onStart();
|
||||||
Class leanplumFcmPushServiceClass = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
leanplumGcmPushServiceClass = Class.forName(LEANPLUM_PUSH_SERVICE_GCM);
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
leanplumFcmPushServiceClass = Class.forName(LEANPLUM_PUSH_SERVICE_FCM);
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
}
|
|
||||||
|
|
||||||
if (leanplumGcmPushServiceClass != null && leanplumFcmPushServiceClass != null) {
|
|
||||||
Log.e("Leanplum does not support leanplum-gcm and leanplum-fcm library at the " +
|
|
||||||
"same time. To support Leanplum GCM and Location services modify your build.gradle by " +
|
|
||||||
"including only implementation 'com.leanplum:leanplum:+' " +
|
|
||||||
"To support only GCM services, use implementation 'com.leanplum:leanplum-gcm:+' " +
|
|
||||||
"For FCM services include implementation 'com.leanplum:leanplum-fcm:+'" +
|
|
||||||
" If you wish to use Leanplum FCM and Location services you also need to include " +
|
|
||||||
"implementation 'com.leanplum:leanplum-location:+'.");
|
|
||||||
|
|
||||||
} else if (leanplumGcmPushServiceClass != null) {
|
|
||||||
try {
|
|
||||||
leanplumGcmPushServiceClass.getDeclaredMethod("onStart").invoke(null);
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
}
|
|
||||||
} else if (leanplumFcmPushServiceClass != null) {
|
|
||||||
try {
|
|
||||||
leanplumFcmPushServiceClass.getDeclaredMethod("onStart").invoke(null);
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user