Skip to content

Commit 08dfc81

Browse files
committed
feat(manifest): fixing pr comments
1 parent 331f977 commit 08dfc81

File tree

6 files changed

+39
-31
lines changed

6 files changed

+39
-31
lines changed

AndroidSDK/src/com/leanplum/LeanplumCloudMessagingProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private static void sendRegistrationIdToBackend(String registrationId) {
6666
public abstract boolean isInitialized();
6767

6868
/**
69-
* Whether app manifest is setup correctly. This will be checked only in DEBUG builds.
69+
* Whether app manifest is setup correctly.
7070
*
7171
* @return True if manifest is setup, false otherwise.
7272
*/

AndroidSDK/src/com/leanplum/LeanplumFcmProvider.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,30 @@ public boolean isManifestSetup() {
5353
if (context == null) {
5454
return false;
5555
}
56-
// Firebase can only be setup through gradle, so we don't have to check manually
57-
// whether manifest is properly setup. We will only check our own services.
56+
5857
try {
58+
boolean hasPushReceiver = LeanplumManifestHelper.checkComponent(LeanplumManifestHelper.ApplicationComponent.RECEIVER,
59+
LeanplumManifestHelper.LP_PUSH_RECEIVER, false, null,
60+
Collections.singletonList(LeanplumManifestHelper.LP_PUSH_FCM_LISTENER_SERVICE), context.getPackageName());
61+
5962
boolean hasPushFirebaseMessagingService = LeanplumManifestHelper.checkComponent(
6063
LeanplumManifestHelper.ApplicationComponent.SERVICE,
61-
LeanplumManifestHelper.PUSH_FIREBASE_MESSAGING_SERVICE, false, null,
62-
Collections.singletonList(LeanplumManifestHelper.MESSAGING_EVENT), context.getPackageName());
64+
LeanplumManifestHelper.LP_PUSH_FCM_MESSAGING_SERVICE, false, null,
65+
Collections.singletonList(LeanplumManifestHelper.FCM_MESSAGING_EVENT), context.getPackageName());
6366

6467
boolean hasPushFirebaseListenerService = LeanplumManifestHelper.checkComponent(
6568
LeanplumManifestHelper.ApplicationComponent.SERVICE,
66-
LeanplumManifestHelper.PUSH_FCM_LISTENER_SERVICE, false, null,
67-
Collections.singletonList(LeanplumManifestHelper.INSTANCE_ID_EVENT), context.getPackageName());
69+
LeanplumManifestHelper.LP_PUSH_FCM_LISTENER_SERVICE, false, null,
70+
Collections.singletonList(LeanplumManifestHelper.FCM_INSTANCE_ID_EVENT), context.getPackageName());
6871

6972
boolean hasRegistrationService = LeanplumManifestHelper.checkComponent(
7073
LeanplumManifestHelper.ApplicationComponent.SERVICE,
7174
LeanplumPushRegistrationService.class.getName(), false, null, null, context.getPackageName());
7275

73-
if (hasPushFirebaseMessagingService && hasPushFirebaseListenerService && hasRegistrationService) {
76+
boolean hasServices = hasPushFirebaseMessagingService && hasPushFirebaseListenerService &&
77+
hasRegistrationService;
78+
79+
if (hasPushReceiver && hasServices) {
7480
Log.i("Firebase Messaging is setup correctly.");
7581
return true;
7682
}

AndroidSDK/src/com/leanplum/LeanplumGcmProvider.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,31 +120,31 @@ public boolean isManifestSetup() {
120120
return false;
121121
}
122122
try {
123-
boolean hasPermissions = LeanplumManifestHelper.checkPermission(LeanplumManifestHelper.RECEIVE_PERMISSION, false, true)
123+
boolean hasPermissions = LeanplumManifestHelper.checkPermission(LeanplumManifestHelper.GCM_RECEIVE_PERMISSION, false, true)
124124
&& (LeanplumManifestHelper.checkPermission(context.getPackageName() + ".gcm.permission.C2D_MESSAGE", true, false)
125125
|| LeanplumManifestHelper.checkPermission(context.getPackageName() + ".permission.C2D_MESSAGE", true, true));
126126

127127
boolean hasGcmReceiver = LeanplumManifestHelper.checkComponent(
128128
LeanplumManifestHelper.ApplicationComponent.RECEIVER, LeanplumManifestHelper.GCM_RECEIVER,
129-
true, LeanplumManifestHelper.SEND_PERMISSION, Arrays.asList(LeanplumManifestHelper.RECEIVE_ACTION,
130-
LeanplumManifestHelper.REGISTRATION_ACTION), context.getPackageName());
129+
true, LeanplumManifestHelper.GCM_SEND_PERMISSION, Arrays.asList(LeanplumManifestHelper.GCM_RECEIVE_ACTION,
130+
LeanplumManifestHelper.GCM_REGISTRATION_ACTION), context.getPackageName());
131131
boolean hasPushReceiver = LeanplumManifestHelper.checkComponent(LeanplumManifestHelper.ApplicationComponent.RECEIVER,
132-
LeanplumPushReceiver.class.getName(), false, null,
133-
Collections.singletonList(LeanplumManifestHelper.PUSH_LISTENER_SERVICE_FILTER), context.getPackageName());
132+
LeanplumManifestHelper.LP_PUSH_RECEIVER, false, null,
133+
Collections.singletonList(LeanplumManifestHelper.LP_PUSH_LISTENER_SERVICE), context.getPackageName());
134134

135135
boolean hasReceivers = hasGcmReceiver && hasPushReceiver;
136136

137137
boolean hasPushListenerService = LeanplumManifestHelper.checkComponent(
138138
LeanplumManifestHelper.ApplicationComponent.SERVICE,
139-
LeanplumPushListenerService.class.getName(), false, null,
140-
Collections.singletonList(LeanplumManifestHelper.RECEIVE_ACTION), context.getPackageName());
139+
LeanplumManifestHelper.LP_PUSH_LISTENER_SERVICE, false, null,
140+
Collections.singletonList(LeanplumManifestHelper.GCM_RECEIVE_ACTION), context.getPackageName());
141141
boolean hasInstanceIdService = LeanplumManifestHelper.checkComponent(
142142
LeanplumManifestHelper.ApplicationComponent.SERVICE,
143-
LeanplumPushInstanceIDService.class.getName(), false, null,
144-
Collections.singletonList(LeanplumManifestHelper.INSTANCE_ID_ACTION), context.getPackageName());
143+
LeanplumManifestHelper.LP_PUSH_INSTANCE_ID_SERVICE, false, null,
144+
Collections.singletonList(LeanplumManifestHelper.GCM_INSTANCE_ID_ACTION), context.getPackageName());
145145
boolean hasRegistrationService = LeanplumManifestHelper.checkComponent(
146146
LeanplumManifestHelper.ApplicationComponent.SERVICE,
147-
LeanplumPushRegistrationService.class.getName(), false, null, null, context.getPackageName());
147+
LeanplumManifestHelper.LP_PUSH_REGISTRATION_SERVICE, false, null, null, context.getPackageName());
148148

149149
boolean hasServices = hasPushListenerService && hasInstanceIdService && hasRegistrationService;
150150

AndroidSDK/src/com/leanplum/LeanplumManualProvider.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
* @author Anna Orlova
3030
*/
3131
public class LeanplumManualProvider extends LeanplumCloudMessagingProvider {
32-
3332
LeanplumManualProvider(Context context, String registrationId) {
3433
onRegistrationIdReceived(context, registrationId);
3534
}

AndroidSDK/src/com/leanplum/LeanplumPushService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,13 +664,13 @@ static void onStart() {
664664
private static void initPushService() {
665665
if (isFirebaseEnabled()) {
666666
if (!enableFcmServices()) {
667-
Log.i("Failed to initialize FCM services.");
667+
Log.w("Failed to initialize FCM services.");
668668
return;
669669
}
670670
provider = new LeanplumFcmProvider();
671671
} else {
672672
if (!enableGcmServices()) {
673-
Log.i("Failed to initialize GCM services.");
673+
Log.w("Failed to initialize GCM services.");
674674
return;
675675
}
676676
provider = new LeanplumGcmProvider();

AndroidSDK/src/com/leanplum/internal/LeanplumManifestHelper.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,24 @@
4242
*/
4343
public class LeanplumManifestHelper {
4444
// Google Cloud Messaging
45-
public static final String SEND_PERMISSION = "com.google.android.c2dm.permission.SEND";
46-
public static final String RECEIVE_PERMISSION = "com.google.android.c2dm.permission.RECEIVE";
47-
public static final String RECEIVE_ACTION = "com.google.android.c2dm.intent.RECEIVE";
48-
public static final String REGISTRATION_ACTION = "com.google.android.c2dm.intent.REGISTRATION";
49-
public static final String INSTANCE_ID_ACTION = "com.google.android.gms.iid.InstanceID";
45+
public static final String GCM_SEND_PERMISSION = "com.google.android.c2dm.permission.SEND";
46+
public static final String GCM_RECEIVE_PERMISSION = "com.google.android.c2dm.permission.RECEIVE";
47+
public static final String GCM_RECEIVE_ACTION = "com.google.android.c2dm.intent.RECEIVE";
48+
public static final String GCM_REGISTRATION_ACTION = "com.google.android.c2dm.intent.REGISTRATION";
49+
public static final String GCM_INSTANCE_ID_ACTION = "com.google.android.gms.iid.InstanceID";
5050
public static final String GCM_RECEIVER = "com.google.android.gms.gcm.GcmReceiver";
5151

5252
// Firebase
53-
public static final String INSTANCE_ID_EVENT = "com.google.firebase.INSTANCE_ID_EVENT";
54-
public static final String MESSAGING_EVENT = "com.google.firebase.MESSAGING_EVENT";
53+
public static final String FCM_INSTANCE_ID_EVENT = "com.google.firebase.INSTANCE_ID_EVENT";
54+
public static final String FCM_MESSAGING_EVENT = "com.google.firebase.MESSAGING_EVENT";
5555

5656
// Leanplum
57-
public static final String PUSH_LISTENER_SERVICE_FILTER = "com.leanplum.LeanplumPushListenerService";
58-
public static final String PUSH_FCM_LISTENER_SERVICE = "com.leanplum.LeanplumPushFcmListenerService";
59-
public static final String PUSH_FIREBASE_MESSAGING_SERVICE = "com.leanplum.LeanplumPushFirebaseMessagingService";
57+
public static final String LP_PUSH_INSTANCE_ID_SERVICE = "com.leanplum.LeanplumPushInstanceIDService";
58+
public static final String LP_PUSH_LISTENER_SERVICE = "com.leanplum.LeanplumPushListenerService";
59+
public static final String LP_PUSH_FCM_LISTENER_SERVICE = "com.leanplum.LeanplumPushFcmListenerService";
60+
public static final String LP_PUSH_FCM_MESSAGING_SERVICE = "com.leanplum.LeanplumPushFirebaseMessagingService";
61+
public static final String LP_PUSH_REGISTRATION_SERVICE = "com.leanplum.LeanplumPushRegistrationService";
62+
public static final String LP_PUSH_RECEIVER = "com.leanplum.LeanplumPushReceiver";
6063

6164
/**
6265
* Gets Class for name.

0 commit comments

Comments
 (0)