Backed out changeset a3d80ef3d9b9 (bug 1568674) for Android build bustage on MmaStubImp.java:20. CLOSED TREE

This commit is contained in:
Csoregi Natalia 2019-08-13 16:51:36 +03:00
Родитель dc6efa0aee
Коммит c2bc86bafd
7 изменённых файлов: 62 добавлений и 25 удалений

Просмотреть файл

@ -15,7 +15,6 @@ import android.support.annotation.NonNull;
import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.BrowserApp;
import org.mozilla.gecko.Experiments;
import org.mozilla.gecko.GeckoSharedPrefs;
import org.mozilla.gecko.MmaConstants;
import org.mozilla.gecko.PrefsHelper;
import org.mozilla.gecko.R;
@ -110,7 +109,6 @@ public class MmaDelegate {
}
mmaHelper.setDeviceId(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.
mmaHelper.init(activity, attributes);

Просмотреть файл

@ -32,8 +32,6 @@ public interface MmaInterface {
void stop();
void setToken(String token);
@CheckResult boolean handleGcmMessage(Context context, String from, Bundle bundle);
void setDeviceId(@NonNull String deviceId);

Просмотреть файл

@ -160,11 +160,6 @@ public class MmaLeanplumImp implements MmaInterface {
Leanplum.setDeviceId(deviceId);
}
@Override
public void setToken(@NonNull String token) {
Leanplum.setToken(token);
}
@Override
public PanelConfig getPanelConfig(@NonNull Context context, PanelConfig.TYPE type, final boolean useLocalValues) {
if (useLocalValues) {

Просмотреть файл

@ -104,7 +104,6 @@ public class Leanplum {
private static RegisterDeviceFinishedCallback registerDeviceFinishedHandler;
private static LeanplumDeviceIdMode deviceIdMode = LeanplumDeviceIdMode.MD5_MAC_ADDRESS;
private static String customDeviceId;
private static String customToken;
private static String defaultChannelId;
private static boolean userSpecifiedDeviceId;
private static boolean initializedMessageTemplates = false;
@ -174,10 +173,6 @@ public class Leanplum {
Constants.hashFilesToDetermineModifications = enabled;
}
public static void setToken(String token) {
customToken = token;
}
/**
* Optional. Whether to enable file uploading in development mode.
*
@ -639,7 +634,11 @@ public class Leanplum {
*/
private static void checkAndStartNotificationsModules() {
if (Util.hasPlayServices()) {
LeanplumPushService.onStart();
try {
Class.forName(LEANPLUM_PUSH_SERVICE).getDeclaredMethod("onStart")
.invoke(null);
} catch (Throwable ignored) {
}
} else {
Log.i("No valid Google Play Services APK found.");
}
@ -697,8 +696,6 @@ public class Leanplum {
params.put(Constants.Params.DEVICE_SYSTEM_VERSION, Util.getSystemVersion());
if (!TextUtils.isEmpty(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_OFFSET_SECONDS, Integer.toString(timezoneOffsetSeconds));
@ -851,8 +848,10 @@ public class Leanplum {
}
try {
LeanplumNotificationChannel.configureChannels(context, notificationGroups,
notificationChannels, defaultNotificationChannel);
Class.forName(LEANPLUM_NOTIFICATION_CHANNEL)
.getDeclaredMethod("configureChannels", Context.class, JSONArray.class,
JSONArray.class, String.class).invoke(new Object(), context,
notificationGroups, notificationChannels, defaultNotificationChannel);
} catch (Throwable ignored) {
}
}
@ -881,6 +880,8 @@ public class Leanplum {
parseVariantDebugInfo(response);
// Allow bidirectional realtime variable updates.
if (Constants.isDevelopmentModeEnabled) {
final Context currentContext = (
LeanplumActivityHelper.currentActivity != context &&
LeanplumActivityHelper.currentActivity != null) ?
@ -939,7 +940,7 @@ public class Leanplum {
// Check for updates.
final String latestVersion = response.optString(Constants.Keys.LATEST_VERSION, null);
if (isRegistered && latestVersion != null && Constants.isDevelopmentModeEnabled) {
if (isRegistered && latestVersion != null) {
Log.i("An update to Leanplum Android SDK, " + latestVersion +
", is available. Go to leanplum.com to download it.");
}
@ -968,6 +969,7 @@ public class Leanplum {
if (isRegistered) {
LeanplumInternal.onHasStartedAndRegisteredAsDeveloper();
}
}
LeanplumInternal.moveToForeground();
startHeartbeat();
} catch (Throwable t) {

Просмотреть файл

@ -89,8 +89,14 @@ abstract class LeanplumCloudMessagingProvider {
return;
}
LeanplumCloudMessagingProvider.registrationId = registrationId;
// Check if received push notification token is different from stored one and send new one to
// server.
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(registrationId);
sendRegistrationIdToBackend(LeanplumCloudMessagingProvider.registrationId);
}
}
/**

Просмотреть файл

@ -631,7 +631,7 @@ class LeanplumNotificationChannel {
* @param notificationChannels Notification channels.
* @param defaultNotificationChannel Default channel details.
*/
public static void configureChannels(Context context, JSONArray notificationGroups,
static void configureChannels(Context context, JSONArray notificationGroups,
JSONArray notificationChannels, String defaultNotificationChannel) {
// Configure notification channels and groups
configureNotificationGroups(

Просмотреть файл

@ -109,7 +109,13 @@ public class LeanplumPushService {
* multiple sender IDs, use {@link LeanplumPushService#setGcmSenderIds}.
*/
public static void setGcmSenderId(String senderId) {
LeanplumGcmProvider.setSenderId(senderId);
try {
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);
}
}
/**
@ -738,7 +744,39 @@ public class LeanplumPushService {
* Call this when Leanplum starts. This method will call by reflection from AndroidSDKCore.
*/
static void onStart() {
LeanplumPushServiceGcm.onStart();
Class leanplumGcmPushServiceClass = null;
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) {
}
}
}
/**