Skip to content

Commit

Permalink
feat(SDK-4447) Deletes methods and fields for non firebase push provi…
Browse files Browse the repository at this point in the history
…ders

- removes all hms, amazon, baidu constants
  • Loading branch information
CTLalit committed Feb 27, 2025
1 parent a922f6d commit 78fc73a
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 125 deletions.
4 changes: 1 addition & 3 deletions clevertap-core/consumer-rules.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# For CleverTap SDK's
-keep class com.clevertap.android.sdk.pushnotification.fcm.FcmPushProvider{*;}
-keep class com.clevertap.android.hms.HmsPushProvider{*;}
-keep class com.google.firebase.messaging.FirebaseMessagingService{*;}
-keep class com.clevertap.android.sdk.pushnotification.CTNotificationIntentService{*;}
-keep class com.google.android.exoplayer2.ExoPlayer{*;}
Expand All @@ -15,6 +14,5 @@
public static final ** CREATOR;
}
-dontwarn com.clevertap.android.sdk.**
-dontwarn com.baidu.**
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,
SourceFile,LineNumberTable,*Annotation*,EnclosingMethod
SourceFile,LineNumberTable,*Annotation*,EnclosingMetod
Original file line number Diff line number Diff line change
Expand Up @@ -2359,20 +2359,6 @@ public CTProductConfigController productConfig() {
return coreState.getCtProductConfigController(context);
}

/**
* Sends the Baidu registration ID to CleverTap.
*
* @param regId The Baidu registration ID
* @param register Boolean indicating whether to register
* or not for receiving push messages from CleverTap.
* Set this to true to receive push messages from CleverTap,
* and false to not receive any messages from CleverTap.
*/
@SuppressWarnings("unused")
public void pushBaiduRegistrationId(String regId, boolean register) {
coreState.getPushProviders().handleToken(regId, PushType.BPS, register);
}

/**
* Push Charged event, which describes a purchase made.
*
Expand Down Expand Up @@ -2518,20 +2504,6 @@ public Future<?> pushGeofenceEnteredEvent(JSONObject geofenceProperties) {
.raiseEventForGeofences(Constants.GEOFENCE_ENTERED_EVENT_NAME, geofenceProperties);
}

/**
* Sends the Huawei registration ID to CleverTap.
*
* @param regId The Huawei registration ID
* @param register Boolean indicating whether to register
* or not for receiving push messages from CleverTap.
* Set this to true to receive push messages from CleverTap,
* and false to not receive any messages from CleverTap.
*/
@SuppressWarnings("unused")
public void pushHuaweiRegistrationId(String regId, boolean register) {
coreState.getPushProviders().handleToken(regId, PushType.HPS, register);
}

/**
* Pushes the Notification Clicked event for App Inbox to CleverTap.
*
Expand Down Expand Up @@ -3091,20 +3063,6 @@ private void manifestAsyncValidation() {
});
}

/**
* Sends the ADM registration ID to CleverTap.
*
* @param token The ADM registration ID
* @param register Boolean indicating whether to register
* or not for receiving push messages from CleverTap.
* Set this to true to receive push messages from CleverTap,
* and false to not receive any messages from CleverTap.
*/
@SuppressWarnings("unused")
private void pushAmazonRegistrationId(String token, boolean register) {
coreState.getPushProviders().handleToken(token, PushType.ADM, register);
}

static void onActivityCreated(Activity activity) {
onActivityCreated(activity, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,4 @@ public interface CTPushProvider {
* Requests the push registration token.
*/
void requestToken();

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,38 @@

public interface PushConstants {

@StringDef({FCM_DELIVERY_TYPE, HMS_DELIVERY_TYPE, BAIDU_DELIVERY_TYPE, ADM_DELIVERY_TYPE})
@StringDef({FCM_DELIVERY_TYPE})
@Retention(RetentionPolicy.SOURCE)
@interface DeliveryType {

}

@StringDef({CT_FIREBASE_PROVIDER_CLASS, CT_BAIDU_PROVIDER_CLASS,
CT_HUAWEI_PROVIDER_CLASS, CT_ADM_PROVIDER_CLASS})
@StringDef({CT_FIREBASE_PROVIDER_CLASS})
@Retention(RetentionPolicy.SOURCE)
@interface CTPushProviderClass {

}

@StringDef({FIREBASE_SDK_CLASS, BAIDU_SDK_CLASS, HUAWEI_SDK_CLASS, ADM_SDK_CLASS})
@StringDef({FIREBASE_SDK_CLASS})
@Retention(RetentionPolicy.SOURCE)
@interface PushMessagingClass {

}

@StringDef({FCM_PROPERTY_REG_ID, HPS_PROPERTY_REG_ID, BPS_PROPERTY_REG_ID,
ADM_PROPERTY_REG_ID})
@StringDef({FCM_PROPERTY_REG_ID})
@Retention(RetentionPolicy.SOURCE)
@interface RegKeyType {

}

@IntDef({ANDROID_PLATFORM, AMAZON_PLATFORM})
@IntDef({ANDROID_PLATFORM})
@Retention(RetentionPolicy.SOURCE)
@interface Platform {

}

enum PushType {
FCM(FCM_DELIVERY_TYPE, FCM_PROPERTY_REG_ID, CT_FIREBASE_PROVIDER_CLASS, FIREBASE_SDK_CLASS),
HPS(HMS_DELIVERY_TYPE, HPS_PROPERTY_REG_ID, CT_HUAWEI_PROVIDER_CLASS, HUAWEI_SDK_CLASS),
BPS(BAIDU_DELIVERY_TYPE, BPS_PROPERTY_REG_ID, CT_BAIDU_PROVIDER_CLASS, BAIDU_SDK_CLASS),
ADM(ADM_DELIVERY_TYPE, ADM_PROPERTY_REG_ID, CT_ADM_PROVIDER_CLASS, ADM_SDK_CLASS);
FCM(FCM_DELIVERY_TYPE, FCM_PROPERTY_REG_ID, CT_FIREBASE_PROVIDER_CLASS, FIREBASE_SDK_CLASS);

private final String ctProviderClassName;

Expand All @@ -54,8 +49,12 @@ enum PushType {

private final String type;

PushType(@DeliveryType String type, @RegKeyType String prefKey, @CTPushProviderClass String className,
@PushMessagingClass String messagingSDKClassName) {
PushType(
@DeliveryType String type,
@RegKeyType String prefKey,
@CTPushProviderClass String className,
@PushMessagingClass String messagingSDKClassName
) {
this.type = type;
this.tokenPrefKey = prefKey;
this.ctProviderClassName = className;
Expand Down Expand Up @@ -94,29 +93,11 @@ String toString() {
@NonNull
String FCM_DELIVERY_TYPE = "fcm";
@NonNull
String BAIDU_DELIVERY_TYPE = "bps";
@NonNull
String HMS_DELIVERY_TYPE = "hps";
@NonNull
String ADM_DELIVERY_TYPE = "adm";
String CT_FIREBASE_PROVIDER_CLASS = "com.clevertap.android.sdk.pushnotification.fcm.FcmPushProvider";
String CT_BAIDU_PROVIDER_CLASS = "com.clevertap.android.bps.BaiduPushProvider";
String CT_HUAWEI_PROVIDER_CLASS = "com.clevertap.android.hms.HmsPushProvider";
String CT_ADM_PROVIDER_CLASS = "com.clevertap.android.adm.AmazonPushProvider";
String FIREBASE_SDK_CLASS = "com.google.firebase.messaging.FirebaseMessagingService";
String BAIDU_SDK_CLASS = "com.baidu.android.pushservice.PushMessageReceiver";
String HUAWEI_SDK_CLASS = "com.huawei.hms.push.HmsMessageService";
String ADM_SDK_CLASS = "com.amazon.device.messaging.ADM";
String FCM_PROPERTY_REG_ID = "fcm_token";
String BPS_PROPERTY_REG_ID = "bps_token";
String HPS_PROPERTY_REG_ID = "hps_token";
String ADM_PROPERTY_REG_ID = "adm_token";
/**
* Android platform type. Only GCM transport will be allowed.
*/
int ANDROID_PLATFORM = 1;
/**
* Amazon platform type. Only ADM transport will be allowed.
*/
int AMAZON_PLATFORM = 2;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static com.clevertap.android.sdk.pushnotification.PushConstants.LOG_TAG;
import static com.clevertap.android.sdk.pushnotification.PushConstants.PushType.FCM;
import static com.clevertap.android.sdk.pushnotification.PushConstants.PushType.HPS;
import static com.clevertap.android.sdk.pushnotification.PushNotificationUtil.getAccountIdFromNotificationBundle;

import android.content.Context;
Expand Down Expand Up @@ -50,8 +49,11 @@ public boolean onActionButtonClick(final Context context, final Bundle extras, f
}

@Override
public synchronized boolean onMessageReceived(final Context applicationContext, final Bundle message,
final String pushType) {
public synchronized boolean onMessageReceived(
final Context applicationContext,
final Bundle message,
final String pushType
) {
message.putLong(Constants.OMR_INVOKE_TIME_IN_MILLIS,System.currentTimeMillis());
CleverTapAPI cleverTapAPI = CleverTapAPI
.getGlobalInstance(applicationContext, getAccountIdFromNotificationBundle(message));
Expand Down Expand Up @@ -86,8 +88,6 @@ public synchronized boolean onMessageReceived(final Context applicationContext,
public boolean onNewToken(final Context applicationContext, final String token, final String pushType) {
if (pushType.equals(FCM.getType())) {
CleverTapAPI.tokenRefresh(applicationContext, token, FCM);
} else if (pushType.equals(HPS.getType())) {
CleverTapAPI.tokenRefresh(applicationContext, token, HPS);
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import com.clevertap.android.sdk.Logger;
import com.clevertap.android.sdk.ManifestInfo;
import com.clevertap.android.sdk.StorageHelper;
import com.clevertap.android.sdk.Utils;
import com.clevertap.android.sdk.db.BaseDatabaseManager;
import com.clevertap.android.sdk.db.DBAdapter;
import com.clevertap.android.sdk.interfaces.AudibleNotification;
Expand All @@ -59,10 +58,6 @@
import org.json.JSONException;
import org.json.JSONObject;

/**
* Single point of contact to load & support all types of Notification messaging services viz. FCM, HMS etc.
*/

@RestrictTo(Scope.LIBRARY_GROUP)
public class PushProviders implements CTPushProviderListener {

Expand Down Expand Up @@ -256,15 +251,6 @@ public void doTokenRefresh(String token, PushType pushType) {
case FCM:
handleToken(token, PushType.FCM, true);
break;
case HPS:
handleToken(token, PushType.HPS, true);
break;
case BPS:
handleToken(token, PushType.BPS, true);
break;
case ADM:
handleToken(token, PushType.ADM, true);
break;
}
}

Expand Down Expand Up @@ -754,24 +740,12 @@ private boolean isValid(CTPushProvider provider) {
"Provider: %s version %s does not match the SDK version %s. Make sure all CleverTap dependencies are the same version.");
return false;
}
switch (provider.getPushType()) {
case FCM:
case HPS:
case BPS:
if (provider.getPlatform() != PushConstants.ANDROID_PLATFORM) {
config.log(PushConstants.LOG_TAG, "Invalid Provider: " + provider.getClass() +
" delivery is only available for Android platforms." + provider.getPushType());
return false;
}
break;
case ADM:
if (provider.getPlatform() != PushConstants.AMAZON_PLATFORM) {
config.log(PushConstants.LOG_TAG, "Invalid Provider: " +
provider.getClass() +
" ADM delivery is only available for Amazon platforms." + provider.getPushType());
return false;
}
break;
if (provider.getPushType() == PushType.FCM) {
if (provider.getPlatform() != PushConstants.ANDROID_PLATFORM) {
config.log(PushConstants.LOG_TAG, "Invalid Provider: " + provider.getClass() +
" delivery is only available for Android platforms." + provider.getPushType());
return false;
}
}

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,6 @@ private static void checkReceiversServices(final Context context, PushProviders
} catch (Exception e) {
Logger.v("Receiver/Service issue : " + e.toString());

} catch (Error error) {
Logger.v("FATAL : " + error.getMessage());
}
}else if(pushType == PushType.HPS){
try {
// use class name string directly here to avoid class not found issues on class import
validateServiceInManifest((Application) context.getApplicationContext(),
"com.clevertap.android.hms.CTHmsMessageService");
} catch (Exception e) {
Logger.v("Receiver/Service issue : " + e.toString());

} catch (Error error) {
Logger.v("FATAL : " + error.getMessage());
}
Expand Down

0 comments on commit 78fc73a

Please sign in to comment.