Skip to content

Commit

Permalink
Merge pull request #455 from CleverTap/develop
Browse files Browse the repository at this point in the history
Release Clevertap-Android-SDK v5.2.0 , Clevertap-Xiaomi-SDK v1.5.3 and Clevertap-Huawei-SDK v1.3.3 SDK-3115
  • Loading branch information
piyush-kukadiya authored Aug 10, 2023
2 parents 11d1746 + 12dce2a commit bc86c70
Show file tree
Hide file tree
Showing 54 changed files with 1,956 additions and 100 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## CHANGE LOG.

### August 10, 2023

* [CleverTap Android SDK v5.2.0](docs/CTCORECHANGELOG.md)
* [CleverTap Xiaomi Push SDK v1.5.3](docs/CTXIAOMIPUSHCHANGELOG.md)
* [CleverTap Huawei Push SDK v1.3.3](docs/CTHUAWEIPUSHCHANGELOG.md)

### June 28, 2023

* [CleverTap Android SDK v5.1.0](docs/CTCORECHANGELOG.md)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ We publish the SDK to `mavenCentral` as an `AAR` file. Just declare it as depend

```groovy
dependencies {
implementation "com.clevertap.android:clevertap-android-sdk:5.1.0"
implementation "com.clevertap.android:clevertap-android-sdk:5.2.0"
}
```

Alternatively, you can download and add the AAR file included in this repo in your Module libs directory and tell gradle to install it like this:

```groovy
dependencies {
implementation (name: "clevertap-android-sdk-5.1.0", ext: 'aar')
implementation (name: "clevertap-android-sdk-5.2.0", ext: 'aar')
}
```

Expand All @@ -46,7 +46,7 @@ Add the Firebase Messaging library and Android Support Library v4 as dependencie

```groovy
dependencies {
implementation "com.clevertap.android:clevertap-android-sdk:5.1.0"
implementation "com.clevertap.android:clevertap-android-sdk:5.2.0"
implementation "androidx.core:core:1.9.0"
implementation "com.google.firebase:firebase-messaging:23.0.6"
implementation "com.google.android.gms:play-services-ads:19.4.0" // Required only if you enable Google ADID collection in the SDK (turned off by default).
Expand Down
1 change: 1 addition & 0 deletions clevertap-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ dependencies {
// Unit testing dependencies
testImplementation project(':test_shared')
testImplementation Libs.firebase_messaging
testImplementation "io.mockk:mockk:1.13.5"

androidTestImplementation "androidx.work:work-testing:2.7.1"
androidTestImplementation "androidx.test:runner:1.5.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.net.Uri;
import android.os.Bundle;
import android.os.RemoteException;

import com.android.installreferrer.api.InstallReferrerClient;
import com.android.installreferrer.api.InstallReferrerStateListener;
import com.android.installreferrer.api.ReferrerDetails;
Expand All @@ -13,6 +14,7 @@
import com.clevertap.android.sdk.pushnotification.PushProviders;
import com.clevertap.android.sdk.task.CTExecutorFactory;
import com.clevertap.android.sdk.task.Task;

import java.util.concurrent.Callable;

class ActivityLifeCycleManager {
Expand Down Expand Up @@ -85,6 +87,7 @@ public Void call() throws Exception {
public void activityResumed(Activity activity) {
config.getLogger().verbose(config.getAccountId(), "App in foreground");
sessionManager.checkTimeoutSession();

//Anything in this If block will run once per App Launch.
if (!coreMetaData.isAppLaunchPushed()) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import android.location.Location;
import android.net.Uri;
import android.os.Bundle;

import androidx.annotation.NonNull;

import com.clevertap.android.sdk.displayunits.model.CleverTapDisplayUnit;
import com.clevertap.android.sdk.events.BaseEventQueueManager;
import com.clevertap.android.sdk.inapp.CTInAppNotification;
Expand All @@ -25,15 +27,17 @@
import com.clevertap.android.sdk.validation.ValidationResultFactory;
import com.clevertap.android.sdk.validation.ValidationResultStack;
import com.clevertap.android.sdk.validation.Validator;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class AnalyticsManager extends BaseAnalyticsManager {

Expand Down Expand Up @@ -102,8 +106,7 @@ public void addMultiValuesForKey(final String key, final ArrayList<String> value
task.execute("addMultiValuesForKey", new Callable<Void>() {
@Override
public Void call() {
final String command = (localDataStore.getProfileValueForKey(key) != null)
? Constants.COMMAND_ADD : Constants.COMMAND_SET;
final String command = Constants.COMMAND_ADD;
_handleMultiValues(values, key, command);
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ public void dismissInAppNotification() {
Logger.d("CleverTap Instance is null.");
} else {
//Dismisses current IAM and proceeds to call promptForPushPermission()
inAppBaseFullFragment.didDismiss(null);
if (inAppBaseFullFragment != null) {
inAppBaseFullFragment.didDismiss(null);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.clevertap.android.sdk;

import android.content.Context;

import com.clevertap.android.sdk.cryption.CryptHandler;
import com.clevertap.android.sdk.cryption.CryptUtils;
import com.clevertap.android.sdk.db.DBManager;
import com.clevertap.android.sdk.events.EventMediator;
import com.clevertap.android.sdk.events.EventQueueManager;
Expand All @@ -18,6 +21,7 @@
import com.clevertap.android.sdk.variables.CTVariables;
import com.clevertap.android.sdk.variables.Parser;
import com.clevertap.android.sdk.variables.VarCache;

import java.util.concurrent.Callable;

class CleverTapFactory {
Expand All @@ -43,10 +47,21 @@ static CoreState getCoreState(Context context, CleverTapInstanceConfig cleverTap
CleverTapInstanceConfig config = new CleverTapInstanceConfig(cleverTapInstanceConfig);
coreState.setConfig(config);

DBManager baseDatabaseManager = new DBManager(config, ctLockManager);
coreState.setDatabaseManager(baseDatabaseManager);

CryptHandler cryptHandler = new CryptHandler(config.getEncryptionLevel(), CryptHandler.EncryptionAlgorithm.AES, config.getAccountId());
coreState.setCryptHandler(cryptHandler);
Task<Void> task = CTExecutorFactory.executors(config).postAsyncSafelyTask();
task.execute("migratingEncryptionLevel", () -> {
CryptUtils.migrateEncryptionLevel(context, config, cryptHandler, baseDatabaseManager.loadDBAdapter(context));
return null;
});

EventMediator eventMediator = new EventMediator(context, config, coreMetaData);
coreState.setEventMediator(eventMediator);

LocalDataStore localDataStore = new LocalDataStore(context, config);
LocalDataStore localDataStore = new LocalDataStore(context, config, cryptHandler);
coreState.setLocalDataStore(localDataStore);

DeviceInfo deviceInfo = new DeviceInfo(context, config, cleverTapID, coreMetaData);
Expand All @@ -60,9 +75,6 @@ static CoreState getCoreState(Context context, CleverTapInstanceConfig cleverTap
SessionManager sessionManager = new SessionManager(config, coreMetaData, validator, localDataStore);
coreState.setSessionManager(sessionManager);

DBManager baseDatabaseManager = new DBManager(config, ctLockManager);
coreState.setDatabaseManager(baseDatabaseManager);

ControllerManager controllerManager = new ControllerManager(context, config,
ctLockManager, callbackManager, deviceInfo, baseDatabaseManager);
coreState.setControllerManager(controllerManager);
Expand Down Expand Up @@ -95,7 +107,7 @@ public Void call() throws Exception {
eventMediator,
sessionManager, callbackManager,
mainLooperHandler, deviceInfo, validationResultStack,
networkManager, coreMetaData, ctLockManager, localDataStore, controllerManager);
networkManager, coreMetaData, ctLockManager, localDataStore, controllerManager, cryptHandler);
coreState.setBaseEventQueueManager(baseEventQueueManager);

AnalyticsManager analyticsManager = new AnalyticsManager(context, config, baseEventQueueManager, validator,
Expand Down Expand Up @@ -137,7 +149,7 @@ public Void call() throws Exception {
LoginController loginController = new LoginController(context, config, deviceInfo,
validationResultStack, baseEventQueueManager, analyticsManager,
coreMetaData, controllerManager, sessionManager,
localDataStore, callbackManager, baseDatabaseManager, ctLockManager);
localDataStore, callbackManager, baseDatabaseManager, ctLockManager, cryptHandler);
coreState.setLoginController(loginController);

VarCache varCache = new VarCache(config,context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;

import com.clevertap.android.sdk.Constants.IdentityType;
import com.clevertap.android.sdk.cryption.CryptHandler;
import com.clevertap.android.sdk.login.LoginConstants;

import org.json.JSONObject;

import java.util.ArrayList;
import java.util.Arrays;
import org.json.JSONObject;

public class CleverTapInstanceConfig implements Parcelable {

Expand Down Expand Up @@ -72,6 +77,8 @@ public CleverTapInstanceConfig[] newArray(int size) {
private boolean sslPinning;

private boolean useGoogleAdId;
private int encryptionLevel;


@SuppressWarnings("unused")
public static CleverTapInstanceConfig createInstance(Context context, @NonNull String accountId,
Expand Down Expand Up @@ -116,9 +123,11 @@ public static CleverTapInstanceConfig createInstance(Context context, @NonNull S
this.beta = config.beta;
this.allowedPushTypes = config.allowedPushTypes;
this.identityKeys = config.identityKeys;
this.encryptionLevel = config.encryptionLevel;
}

private CleverTapInstanceConfig(Context context, String accountId, String accountToken, String accountRegion,
private
CleverTapInstanceConfig(Context context, String accountId, String accountToken, String accountRegion,
boolean isDefault) {
this.accountId = accountId;
this.accountToken = accountToken;
Expand All @@ -143,9 +152,12 @@ private CleverTapInstanceConfig(Context context, String accountId, String accoun
* For default instance, use manifest meta, otherwise use from setter field
*/
if (isDefaultInstance) {
this.encryptionLevel = manifest.getEncryptionLevel();
identityKeys = manifest.getProfileKeys();
log(LoginConstants.LOG_TAG_ON_USER_LOGIN, "Setting Profile Keys from Manifest: " + Arrays
.toString(identityKeys));
} else {
this.encryptionLevel = 0;
}
}

Expand Down Expand Up @@ -209,6 +221,9 @@ private CleverTapInstanceConfig(String jsonString) throws Throwable {
if (configJsonObject.has(Constants.KEY_IDENTITY_TYPES)) {
this.identityKeys = (String[]) toArray(configJsonObject.getJSONArray(Constants.KEY_IDENTITY_TYPES));
}
if(configJsonObject.has(Constants.KEY_ENCRYPTION_LEVEL)){
this.encryptionLevel = configJsonObject.getInt(Constants.KEY_ENCRYPTION_LEVEL);
}
} catch (Throwable t) {
Logger.v("Error constructing CleverTapInstanceConfig from JSON: " + jsonString + ": ", t.getCause());
throw (t);
Expand Down Expand Up @@ -236,6 +251,7 @@ private CleverTapInstanceConfig(Parcel in) {
allowedPushTypes = new ArrayList<>();
in.readList(allowedPushTypes, String.class.getClassLoader());
identityKeys = in.createStringArray();
encryptionLevel = in.readInt();
}

@Override
Expand Down Expand Up @@ -366,6 +382,7 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeByte((byte) (beta ? 0x01 : 0x00));
dest.writeList(allowedPushTypes);
dest.writeStringArray(identityKeys);
dest.writeInt(encryptionLevel);
}

public boolean getEnableCustomCleverTapId() {
Expand Down Expand Up @@ -415,6 +432,12 @@ boolean isUseGoogleAdId() {
void setCreatedPostAppLaunch() {
this.createdPostAppLaunch = true;
}
public void setEncryptionLevel(CryptHandler.EncryptionLevel encryptionLevel) {
this.encryptionLevel = encryptionLevel.intValue();
}
public int getEncryptionLevel() {
return encryptionLevel;
}

String toJSONString() {
JSONObject configJsonObject = new JSONObject();
Expand All @@ -436,6 +459,7 @@ String toJSONString() {
configJsonObject.put(Constants.KEY_PACKAGE_NAME, getPackageName());
configJsonObject.put(Constants.KEY_BETA, isBeta());
configJsonObject.put(Constants.KEY_ALLOWED_PUSH_TYPES, toJsonArray(allowedPushTypes));
configJsonObject.put(Constants.KEY_ENCRYPTION_LEVEL , getEncryptionLevel());
return configJsonObject.toString();
} catch (Throwable e) {
Logger.v("Unable to convert config to JSON : ", e.getCause());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.StringDef;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Arrays;
Expand Down Expand Up @@ -41,6 +42,7 @@ public interface Constants {
String LABEL_INTENT_SERVICE = "CLEVERTAP_INTENT_SERVICE";
String LABEL_XIAOMI_APP_KEY = "CLEVERTAP_XIAOMI_APP_KEY";
String LABEL_XIAOMI_APP_ID = "CLEVERTAP_XIAOMI_APP_ID";
String LABEL_ENCRYPTION_LEVEL = "CLEVERTAP_ENCRYPTION_LEVEL";
String LABEL_DEFAULT_CHANNEL_ID = "CLEVERTAP_DEFAULT_CHANNEL_ID";
String FCM_FALLBACK_NOTIFICATION_CHANNEL_ID = "fcm_fallback_notification_channel";
String FCM_FALLBACK_NOTIFICATION_CHANNEL_NAME = "Misc";
Expand Down Expand Up @@ -184,6 +186,8 @@ public interface Constants {
String KEY_BG = "bg";
String KEY_TITLE = "title";
String KEY_TEXT = "text";
String KEY_KEY = "key";
String KEY_VALUE = "value";
String KEY_COLOR = "color";
String KEY_MESSAGE = "message";
String KEY_HIDE_CLOSE = "close";
Expand All @@ -200,6 +204,8 @@ public interface Constants {
String KEY_PACKAGE_NAME = "packageName";
String KEY_ALLOWED_PUSH_TYPES = "allowedPushTypes";
String KEY_IDENTITY_TYPES = "identityTypes";
String KEY_ENCRYPTION_LEVEL = "encryptionLevel";
String KEY_ENCRYPTION_FLAG_STATUS = "encryptionFlagStatus";
String WZRK_PUSH_ID = "wzrk_pid";
String WZRK_PUSH_SILENT = "wzrk_pn_s";
String EXTRAS_FROM = "extras_from";
Expand Down Expand Up @@ -258,10 +264,20 @@ public interface Constants {
String KEY_HAS_URL = "hasUrl";
String KEY_HAS_LINKS = "hasLinks";
String KEY_LINKS = "links";
String KEY_ENCRYPTION_MIGRATION = "encryptionmigration";
String KEY_ENCRYPTION_CGK = "cgk";
String KEY_ENCRYPTION_NAME = "Name";
String KEY_ENCRYPTION_IDENTITY = "Identity";
String KEY_ENCRYPTION_PHONE = "Phone";
String KEY_ENCRYPTION_EMAIL = "Email";
String TEST_IDENTIFIER = "0_0";
String FEATURE_DISPLAY_UNIT = "DisplayUnit : ";
String FEATURE_FLAG_UNIT = "Feature Flag : ";
String LOG_TAG_PRODUCT_CONFIG = "Product Config : ";

String CRYPTION_SALT = "W1ZRCl3>";
String CRYPTION_IV = "__CL3>3Rt#P__1V_";

int FETCH_TYPE_PC = 0;
int FETCH_TYPE_FF = 1;
int FETCH_TYPE_VARIABLES = 4;
Expand Down Expand Up @@ -292,6 +308,11 @@ public interface Constants {
int INVALID_MULTI_VALUE_KEY = 23;
int RESTRICTED_MULTI_VALUE_KEY = 24;
int INVALID_INCREMENT_DECREMENT_VALUE = 25;
int ENCRYPTION_FLAG_FAIL = 0b00;
int ENCRYPTION_FLAG_CGK_SUCCESS = 0b01;
int ENCRYPTION_FLAG_DB_SUCCESS = 0b10;
int ENCRYPTION_FLAG_ALL_SUCCESS = 0b11;

String CLEVERTAP_IDENTIFIER = "CLEVERTAP_IDENTIFIER";
String SEPARATOR_COMMA = ",";
String EMPTY_STRING = "";
Expand All @@ -301,6 +322,10 @@ public interface Constants {
// valid profile identifier keys
HashSet<String> LEGACY_IDENTITY_KEYS = new HashSet<>(Arrays.asList(TYPE_IDENTITY, TYPE_EMAIL));
HashSet<String> ALL_IDENTITY_KEYS = new HashSet<>(Arrays.asList(TYPE_IDENTITY, TYPE_EMAIL, TYPE_PHONE));
HashSet<String> MEDIUM_CRYPT_KEYS = new HashSet<>(Arrays.asList(KEY_ENCRYPTION_CGK, KEY_ENCRYPTION_MIGRATION, KEY_ENCRYPTION_EMAIL, KEY_ENCRYPTION_PHONE, KEY_ENCRYPTION_IDENTITY, KEY_ENCRYPTION_NAME));
HashSet<String> NONE_CRYPT_KEYS = new HashSet<>(Arrays.asList(KEY_ENCRYPTION_MIGRATION));
HashSet<String> piiDBKeys = new HashSet<>(Arrays.asList(KEY_ENCRYPTION_NAME, KEY_ENCRYPTION_EMAIL, KEY_ENCRYPTION_IDENTITY, KEY_ENCRYPTION_PHONE));


int MAX_DELAY_FREQUENCY = 1000 * 60 * 10;

Expand Down
Loading

0 comments on commit bc86c70

Please sign in to comment.