Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopt changes in Core 2.0 #76

Merged
merged 6 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions code/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,23 @@ dependencies {
implementation 'androidx.navigation:navigation-ui-ktx:2.3.3'

implementation project(':edgeidentity')
implementation 'com.adobe.marketing.mobile:core:1+'
implementation 'com.adobe.marketing.mobile:identity:1+'
implementation 'com.adobe.marketing.mobile:edgeconsent:1.+'

// TODO: Uncomment next line when core 2.0 artifacts are published to maven
// implementation "com.adobe.marketing.mobile:core:${rootProject.mavenCoreVersion}"
implementation 'com.github.adobe.aepsdk-core-android:core:dev-v2.0.0-SNAPSHOT'

implementation ('com.adobe.marketing.mobile:identity:1+') {
transitive = false
}
implementation('com.adobe.marketing.mobile:edgeconsent:1.+') {
transitive = false
}
implementation('com.adobe.marketing.mobile:edge:1.3.2-SNAPSHOT') {
prudrabhat marked this conversation as resolved.
Show resolved Hide resolved
exclude group: 'com.adobe.marketing.mobile', module:'edgeidentity'
transitive = false
}
implementation ('com.adobe.marketing.mobile:assurance:1+') {
transitive = false
}
implementation 'com.adobe.marketing.mobile:assurance:1+'

/* Ad ID implementation (pt. 1/5)
implementation("com.google.android.gms:play-services-ads-lite:20.6.0")
Expand Down
6 changes: 5 additions & 1 deletion code/edgeidentity/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,11 @@ task platformFunctionalTestJacocoReport(type: JacocoReport, dependsOn: "createPh
dependencies {

// Adobe Mobile SDK Core
implementation "com.adobe.marketing.mobile:core:${rootProject.mavenCoreVersion}"

// TODO: Uncomment next line when core 2.0 artifacts are published to maven
// implementation "com.adobe.marketing.mobile:core:${rootProject.mavenCoreVersion}"
implementation 'com.github.adobe.aepsdk-core-android:core:dev-v2.0.0-SNAPSHOT'
implementation 'androidx.annotation:annotation:1.3.0'

testImplementation "androidx.test.ext:junit:${rootProject.ext.junitVersion}"
testImplementation "org.mockito:mockito-core:${rootProject.ext.mockitoCoreVersion}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public enum AuthenticatedState {
*/
LOGGED_OUT("loggedOut");

private String name;
private final String name;

private AuthenticatedState(final String name) {
AuthenticatedState(final String name) {
this.name = name;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import com.adobe.marketing.mobile.LoggingMode;
import com.adobe.marketing.mobile.MobileCore;
import com.adobe.marketing.mobile.util.StringUtils;
import java.util.Locale;
import java.util.Objects;
import java.util.UUID;
Expand Down Expand Up @@ -41,7 +42,7 @@ final class ECID {
* @param ecidString a valid (38-digit UUID) ECID string representation, if null or empty a new ECID will be generated
*/
ECID(final String ecidString) {
if (Utils.isNullOrEmpty(ecidString)) {
if (StringUtils.isNullOrEmpty(ecidString)) {
MobileCore.log(
LoggingMode.DEBUG,
IdentityConstants.LOG_TAG,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@

package com.adobe.marketing.mobile.edge.identity;

import static com.adobe.marketing.mobile.edge.identity.IdentityConstants.LOG_TAG;

import com.adobe.marketing.mobile.Event;
import com.adobe.marketing.mobile.LoggingMode;
import com.adobe.marketing.mobile.MobileCore;
import com.adobe.marketing.mobile.util.DataReader;
import com.adobe.marketing.mobile.util.StringUtils;
import java.util.Map;

/**
Expand Down Expand Up @@ -97,24 +95,10 @@ static boolean isRequestContentEvent(final Event event) {
* @return true if urlVariables key is present in the event data and has a value of true
*/
static boolean isGetUrlVariablesRequestEvent(final Event event) {
if (event == null || event.getEventData() == null) {
return false;
}
boolean getUrlVariablesFlag = false;

try {
Object urlVariablesFlagObject = event.getEventData().get(IdentityConstants.EventDataKeys.URL_VARIABLES);
getUrlVariablesFlag = urlVariablesFlagObject != null && (boolean) urlVariablesFlagObject;
} catch (ClassCastException e) {
MobileCore.log(
LoggingMode.WARNING,
LOG_TAG,
"EventUtils - Failed to read urlvariables value, expected boolean: " + e.getLocalizedMessage()
);
return false;
}

return getUrlVariablesFlag;
return (
event != null &&
DataReader.optBoolean(event.getEventData(), IdentityConstants.EventDataKeys.URL_VARIABLES, false)
);
}

/**
Expand All @@ -139,18 +123,15 @@ static boolean isRequestResetEvent(final Event event) {
* @return {@code boolean} indicating if it is the shared state update for the provided {@code stateOwnerName}
*/
static boolean isSharedStateUpdateFor(final String stateOwnerName, final Event event) {
if (Utils.isNullOrEmpty(stateOwnerName) || event == null) {
return false;
}

String stateOwner;

try {
stateOwner = (String) event.getEventData().get(IdentityConstants.EventDataKeys.STATE_OWNER);
} catch (ClassCastException e) {
if (StringUtils.isNullOrEmpty(stateOwnerName) || event == null) {
return false;
}

final String stateOwner = DataReader.optString(
event.getEventData(),
IdentityConstants.EventDataKeys.STATE_OWNER,
""
);
return stateOwnerName.equals(stateOwner);
}

Expand All @@ -169,23 +150,9 @@ static boolean isSharedStateUpdateFor(final String stateOwnerName, final Event e
*/
static String getAdId(final Event event) {
final Map<String, Object> data = event.getEventData();
String adID;

try {
adID = (String) data.get(IdentityConstants.EventDataKeys.ADVERTISING_IDENTIFIER);
} catch (ClassCastException e) {
MobileCore.log(
LoggingMode.DEBUG,
LOG_TAG,
"EventUtils - Failed to extract ad ID from event, expected String: " + e.getLocalizedMessage()
);
return "";
}
final String adID = DataReader.optString(data, IdentityConstants.EventDataKeys.ADVERTISING_IDENTIFIER, "");

if (adID == null || IdentityConstants.Default.ZERO_ADVERTISING_ID.equals(adID)) {
return "";
}
return adID;
return (adID == null || IdentityConstants.Default.ZERO_ADVERTISING_ID.equals(adID) ? "" : adID);
prudrabhat marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand All @@ -195,23 +162,12 @@ static String getAdId(final Event event) {
* @return the ECID or null if not found or unable to parse the payload
*/
static ECID getECID(final Map<String, Object> identityDirectSharedState) {
ECID legacyEcid = null;

try {
final String legacyEcidString = (String) identityDirectSharedState.get(
IdentityConstants.SharedState.IdentityDirect.ECID
);
legacyEcid = legacyEcidString == null ? null : new ECID(legacyEcidString);
} catch (ClassCastException e) {
MobileCore.log(
LoggingMode.DEBUG,
LOG_TAG,
"EventUtils - Failed to extract ECID from Identity direct shared state, expected String: " +
e.getLocalizedMessage()
);
}

return legacyEcid;
final String legacyEcidString = DataReader.optString(
identityDirectSharedState,
IdentityConstants.SharedState.IdentityDirect.ECID,
null
);
return (legacyEcidString == null ? null : new ECID(legacyEcidString));
}

/**
Expand All @@ -221,26 +177,10 @@ static ECID getECID(final Map<String, Object> identityDirectSharedState) {
* @return the Experience Cloud Org Id or null if not found or unable to parse the payload
*/
static String getOrgId(final Map<String, Object> configurationSharedState) {
String orgId = null;

if (configurationSharedState == null) {
return orgId;
}

try {
orgId =
(String) configurationSharedState.get(
IdentityConstants.SharedState.Configuration.EXPERIENCE_CLOUD_ORGID
);
} catch (ClassCastException e) {
MobileCore.log(
LoggingMode.DEBUG,
LOG_TAG,
"EventUtils - Failed to extract Experience ORG ID from Configuration shared state, expected String: " +
e.getLocalizedMessage()
);
}

return orgId;
return DataReader.optString(
configurationSharedState,
IdentityConstants.SharedState.Configuration.EXPERIENCE_CLOUD_ORGID,
null
);
}
}
Loading