repo_id
stringclasses
1 value
file_path
stringlengths
117
174
content
stringlengths
8
42.4k
__index_level_0__
int64
0
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/services/internal/caching/FileCacheResult.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.services.internal.caching; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.adobe.marketing.mobile.services.caching.CacheExpiry; import com.adobe.marketing.mobile.services.caching.CacheResult; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.util.Map; /** Represents a result returned by {@link FileCacheService} */ class FileCacheResult implements CacheResult { private final File fileContent; private final CacheExpiry cacheExpiry; private final Map<String, String> metadata; static final String METADATA_KEY_EXPIRY_IN_MILLIS = "expiryInMillis"; static final String METADATA_KEY_PATH_TO_FILE = "pathToFile"; public FileCacheResult( @NonNull final File data, @NonNull final CacheExpiry cacheExpiry, @Nullable final Map<String, String> metadata) { this.fileContent = data; this.cacheExpiry = cacheExpiry; this.metadata = metadata; } @Override public InputStream getData() { try { return new FileInputStream(fileContent); } catch (Exception e) { return null; } } @NonNull @Override public CacheExpiry getExpiry() { return cacheExpiry; } @Nullable @Override public Map<String, String> getMetadata() { return metadata; } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/services/internal/caching/FileCacheService.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.services.internal.caching; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.adobe.marketing.mobile.services.Log; import com.adobe.marketing.mobile.services.ServiceConstants; import com.adobe.marketing.mobile.services.caching.CacheEntry; import com.adobe.marketing.mobile.services.caching.CacheExpiry; import com.adobe.marketing.mobile.services.caching.CacheResult; import com.adobe.marketing.mobile.services.caching.CacheService; import java.io.File; import java.util.Date; import java.util.Map; /** A {@code CacheService} that uses file storage as the cache store. */ public class FileCacheService implements CacheService { private static final String TAG = "FileCacheService"; static final String ROOT_CACHE_DIR_NAME = "aepsdkcache"; private final CacheFileManager cacheFileManager; public FileCacheService() { this.cacheFileManager = new CacheFileManager(ROOT_CACHE_DIR_NAME); } /** * Creates or updates the key-value pair in the cache. Stores the content and its metadata as * separate files internally in the cache directory supplied by {@code * DeviceInforming#getApplicationCacheDir} * * @param cacheName name of the bucket where the cache entry is to be created * @param key key for the cache entry * @param value the value that is to be associated with {@code key} * @return true if the value for the key was created or updated; false otherwise. */ @Override public boolean set( @NonNull final String cacheName, @NonNull final String key, @NonNull final CacheEntry value) { // Create the bucket if necessary final File cacheBucket = cacheFileManager.createCache(cacheName); if (cacheBucket == null) { Log.debug( ServiceConstants.LOG_TAG, TAG, "Could not set value for key: [%s] in cache: [%s]." + "Cache creation failed."); return false; } return cacheFileManager.createCacheFile(cacheName, key, value); } /** * Retrieves the value associated with the key being queried. Note that the {@code CacheResult} * returned may have additional metadata internally used by the {@code FileCacheService}. * * @param cacheName name of the bucket where the entry is to be fetched from * @param key key for the cache entry * @return the {@code FileCacheResult} associated with the key if present; null otherwise. */ @Nullable @Override public CacheResult get(@NonNull final String cacheName, @NonNull final String key) { final File cacheFile = cacheFileManager.getCacheFile(cacheName, key); if (cacheFile == null) return null; final Map<String, String> cacheMetadata = cacheFileManager.getCacheMetadata(cacheName, key); // We lost the metadata/metadata is corrupt, but have an entry - so there must have been an // error. // Remove the cache entry as well and return null. if (cacheMetadata == null) { Log.debug( ServiceConstants.LOG_TAG, TAG, "Could not find metadata for key: [%s] in cache: [%s]."); remove(cacheName, key); return null; } final String expiryFromMetadata = cacheMetadata.get(FileCacheResult.METADATA_KEY_EXPIRY_IN_MILLIS); final CacheExpiry expiry = getExpiryFromEpoch(expiryFromMetadata); if (expiry.isExpired()) { // If the cache entry has expired by the time it was fetched, remove it // and return null. Log.debug( ServiceConstants.LOG_TAG, TAG, "Cache entry for key: [%s] in cache: [%s] has expired."); remove(cacheName, key); return null; } return new FileCacheResult(cacheFile, expiry, cacheMetadata); } /** * Removes the key and entry associated with it from {@code cacheName}. * * @param cacheName name of the bucket where the entry is to be fetched from * @param key the key for the cache entry that is to be removed * @return true if the removal was successful; false otherwise. */ @Override public boolean remove(@NonNull final String cacheName, @NonNull final String key) { return cacheFileManager.deleteCacheFile(cacheName, key); } /** * Translates the epochString provided into a {@code CacheExpiry} * * @param epochString the epoch to use for populating {@code CacheExpiry.expiry} * @return a valid CacheExpiry at epoch provided by {@code epochString} if valid; an expired * CacheExpiry otherwise. */ private CacheExpiry getExpiryFromEpoch(final String epochString) { try { return (epochString == null) ? CacheExpiry.never() : CacheExpiry.at(new Date(Long.parseLong(epochString))); } catch (final NumberFormatException e) { Log.debug( ServiceConstants.LOG_TAG, TAG, "Failed to parse expiry from stored metadata. Marking as expired"); return CacheExpiry.at(new Date(0)); } } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/services/caching/CacheResult.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.services.caching; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import java.io.InputStream; import java.util.Map; /** Represents an item that is retrieved from cache using {@code CacheService} */ public interface CacheResult { /** * Gets the content of the item that is retrieved from the cache. * * @return the content of the item that was cached */ @Nullable InputStream getData(); /** * Gets the expiry of the item that is retrieved from the cache. * * @return expiry of the item that was cached */ @NonNull CacheExpiry getExpiry(); /** * Gets the metadata of the item that is retrieved from the cache. Note that this metadata may * also contain additional keys used internally by {@code CacheService} to facilitate caching. * * @return metadata of the item provided when it was cached. */ @Nullable Map<String, String> getMetadata(); }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/services/caching/CacheService.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.services.caching; import androidx.annotation.NonNull; import androidx.annotation.Nullable; /** Represents a component that facilitates caching. */ public interface CacheService { /** * Creates or updates the key-value pair in the cache. * * @param cacheName name of the cache where the cache entry is to be created * @param key key for the item to be cached * @param value the value that is to be associated with {@code key} */ boolean set( @NonNull final String cacheName, @NonNull final String key, @NonNull final CacheEntry value); /** * Retrieves the item associated with the key from the cache. * * @param cacheName name of the cache where the key should be queried from * @param key key for the cache entry * @return a valid cache entry for the key if one exists; null otherwise. */ @Nullable CacheResult get(@NonNull final String cacheName, @NonNull final String key); /** * Removes the item associated with the key from the cache. * * @param cacheName name of the cache where the item is to be removed from * @param key the key for the item that is to be removed * @return true if the item has been removed; false otherwise. */ boolean remove(@NonNull final String cacheName, @NonNull final String key); }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/services/caching/CacheExpiry.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.services.caching; import java.util.Date; /** Represents the expiry of a cached item. */ public class CacheExpiry { /** The date beyond which the cache item is deemed expired and invalid. */ private final Date expiration; private CacheExpiry(final Date expiration) { this.expiration = expiration; } public final Date getExpiration() { return expiration; } /** * Creates a {@code CacheExpiry} with {@code CacheExpiry.expiration} after {@code * durationInMillis} from now. * * @param durationInMillis the milliseconds after current time that the {@code expiration} * should be set to * @return {@code CacheExpiry} with {@code expiration} after {@code durationInMillis} from now. */ public static CacheExpiry after(final long durationInMillis) { return new CacheExpiry(new Date(System.currentTimeMillis() + durationInMillis)); } /** * Creates a {@code CacheExpiry} with {@code expiration} at the date provided. * * @param date that that the {@code CacheExpiry.expiration} should be set to * @return {@code CacheExpiry} with {@code expiration} at the date provided. */ public static CacheExpiry at(final Date date) { return new CacheExpiry(date); } /** * Creates a {@code CacheExpiry} with no {@code expiration} date. * * @return {@code CacheExpiry} with no {@code expiration}. */ public static CacheExpiry never() { return new CacheExpiry(null); } /** * Evaluates whether the {@code CacheExpiry.expiration} has elapsed. * * @return true if the {@code CacheExpiry.expiration} is before current time. */ public boolean isExpired() { return expiration != null && System.currentTimeMillis() >= expiration.getTime(); } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/services/caching/CacheEntry.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.services.caching; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import java.io.InputStream; import java.util.HashMap; import java.util.Map; /** Represents an item that can be cached using {@link CacheService} */ public class CacheEntry { /** The input stream which provides the data to be cached */ private final InputStream data; /** The expiration for this item */ private final CacheExpiry expiry; /** The metadata associated with this cache entry */ private final Map<String, String> metadata; public CacheEntry( @NonNull final InputStream data, @NonNull final CacheExpiry expiry, @Nullable final Map<String, String> metadata) { this.data = data; this.expiry = expiry; this.metadata = metadata == null ? new HashMap<>() : new HashMap<>(metadata); } @NonNull public InputStream getData() { return data; } @NonNull public CacheExpiry getExpiry() { return expiry; } @Nullable public Map<String, String> getMetadata() { return metadata; } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/services/uri/UriOpening.kt
/* Copyright 2023 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.services.uri /** * Represents a component capable of opening URIs. */ interface UriOpening { /** * Opens the given [uri] after consulting the [URIHandler] if one is set. * @param uri the URI to open * @return true if the URI was opened successfully, false otherwise. */ fun openUri(uri: String): Boolean /** * Sets the [URIHandler] to be used for fetching destination intents when opening URIs. */ fun setUriHandler(handler: URIHandler) }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/services/uri/UriService.kt
/* Copyright 2023 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.services.uri import android.app.Activity import android.content.Intent import android.net.Uri import com.adobe.marketing.mobile.services.Log import com.adobe.marketing.mobile.services.ServiceConstants import com.adobe.marketing.mobile.services.ServiceProvider /** * Represents a component capable of opening URIs. */ internal class UriService : UriOpening { internal companion object { private const val LOG_TAG = "UriService" } private var uriHandler: URIHandler? = null override fun openUri(uri: String): Boolean { if (uri.isBlank()) { Log.debug(ServiceConstants.LOG_TAG, LOG_TAG, "Cannot open URI. URI is empty.") return false } val currentActivity: Activity = ServiceProvider.getInstance().appContextService.currentActivity ?: kotlin.run { Log.debug(ServiceConstants.LOG_TAG, LOG_TAG, "Cannot open URI: $uri. No current activity found.") return false } val configuredDestination: Intent? = uriHandler?.getURIDestination(uri) return try { val intent = configuredDestination ?: Intent(Intent.ACTION_VIEW).apply { data = Uri.parse(uri) } currentActivity.startActivity(intent) true } catch (e: Exception) { Log.debug(ServiceConstants.LOG_TAG, LOG_TAG, "Failed to open URI: $uri. ${e.message}") false } } override fun setUriHandler(handler: URIHandler) { uriHandler = handler } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/services/uri/URIHandler.kt
/* Copyright 2023 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.services.uri import android.content.Intent /** Interface for handling fetching destination intents for URI's */ interface URIHandler { /** * Returns a destination of the given URI. * * @param uri the URI to open * @return an [Intent] for the given URI, or null if no destination is found. */ fun getURIDestination(uri: String): Intent? }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/lifecycle/src/main/java/com/adobe/marketing/mobile/Lifecycle.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile; import com.adobe.marketing.mobile.lifecycle.LifecycleExtension; public class Lifecycle { private static final String EXTENSION_VERSION = "3.0.1"; public static final Class<? extends Extension> EXTENSION = LifecycleExtension.class; private Lifecycle() {} /** * Returns the version of the {@link Lifecycle} extension * * @return The version as {@code String} */ public static String extensionVersion() { return EXTENSION_VERSION; } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/lifecycle/src/main/java/com/adobe/marketing/mobile/lifecycle/XDMLanguage.java
/* Copyright 2023 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.lifecycle; import androidx.annotation.NonNull; import com.adobe.marketing.mobile.util.StringUtils; import java.util.HashMap; import java.util.Map; import java.util.regex.Pattern; class XDMLanguage { private final String languageRegex = "^(((([A-Za-z]{2,3}(-([A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-([A-Za-z]{4}))?(-([A-Za-z]{2}|[0-9]{3}))?(-([A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-([0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(x(-[A-Za-z0-9]{1,8})+))?)|(x(-[A-Za-z0-9]{1,8})+)|((en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)|(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang)))$"; private final Pattern languagePattern = Pattern.compile(languageRegex); private final String language; XDMLanguage(final String language) { if (StringUtils.isNullOrEmpty(language) || !isValidLanguageTag(language)) { throw new IllegalArgumentException("Language tag failed validation"); } this.language = language; } String getLanguage() { return this.language; } Map<String, Object> serializeToXdm() { Map<String, Object> map = new HashMap<String, Object>(); map.put("language", this.language); return map; } /** * Validate the language tag is formatted per the XDM Environment Schema required pattern. * * @param tag the language tag to validate * @return true if the language tag matches the pattern. */ private boolean isValidLanguageTag(@NonNull final String tag) { return languagePattern.matcher(tag).matches(); } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/lifecycle/src/main/java/com/adobe/marketing/mobile/lifecycle/LifecycleV2Extension.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.lifecycle; import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; import com.adobe.marketing.mobile.Event; import com.adobe.marketing.mobile.EventSource; import com.adobe.marketing.mobile.EventType; import com.adobe.marketing.mobile.ExtensionApi; import com.adobe.marketing.mobile.services.DeviceInforming; import com.adobe.marketing.mobile.services.Log; import com.adobe.marketing.mobile.services.NamedCollection; import com.adobe.marketing.mobile.util.DataReader; import com.adobe.marketing.mobile.util.StringUtils; import java.util.HashMap; import java.util.Map; /** * LifecycleV2Extension class * * <p>The responsibility of LifecycleV2Extension is to compute the application launch/close XDM * metrics, usually consumed by the Edge Network and related extensions */ class LifecycleV2Extension { private static final String SELF_LOG_TAG = "LifecycleV2Extension"; private final LifecycleV2DataStoreCache dataStoreCache; private final LifecycleV2StateManager stateManager; private final LifecycleV2MetricsBuilder xdmMetricsBuilder; private final NamedCollection dataStore; private final DeviceInforming deviceInfoService; private final long BACKDATE_TIMESTAMP_OFFSET_MILLIS = 1000; // backdate timestamps by 1 second private final ExtensionApi extensionApi; /** * Constructor for the LifecycleV2Extension. * * @param dataStore {@code NamedCollection} instance * @param deviceInfoService {@code DeviceInforming} instance * @param extensionApi {@code ExtensionApi} instance */ LifecycleV2Extension( final NamedCollection dataStore, final DeviceInforming deviceInfoService, final ExtensionApi extensionApi) { this(dataStore, deviceInfoService, null, extensionApi); } /** * This constructor is intended for testing purposes. * * @param dataStore {@code NamedCollection} instance * @param deviceInfoService {@code DeviceInforming} instance * @param metricsBuilder XDM LifecycleMetricsBuilder instance. If null, a new instance will be * created */ @VisibleForTesting LifecycleV2Extension( final NamedCollection dataStore, final DeviceInforming deviceInfoService, final LifecycleV2MetricsBuilder metricsBuilder, final ExtensionApi extensionApi) { this.dataStore = dataStore; this.deviceInfoService = deviceInfoService; this.extensionApi = extensionApi; stateManager = new LifecycleV2StateManager(); dataStoreCache = new LifecycleV2DataStoreCache(dataStore); xdmMetricsBuilder = metricsBuilder != null ? metricsBuilder : new LifecycleV2MetricsBuilder(deviceInfoService); } /** * Handles the start use-case as application launch XDM event. If a previous abnormal close was * detected, an application close event will be dispatched first. * * @param event event containing lifecycle start data * @param isInstall boolean indicating whether this is an application install scenario */ void start(final Event event, final boolean isInstall) { stateManager.updateState( LifecycleV2StateManager.State.START, updated -> { if (!updated) { return; } // detect a possible crash/incorrect start/pause implementation if (!isInstall && isCloseUnknown( dataStoreCache.getAppStartTimestampMillis(), dataStoreCache.getAppPauseTimestampMillis())) { // in case of an unknown close situation, use the last known app close event // timestamp // if no close timestamp was persisted, backdate this event to start // timestamp - 1 second Map<String, Object> appCloseXDMData = xdmMetricsBuilder.buildAppCloseXDMData( dataStoreCache.getAppStartTimestampMillis(), dataStoreCache.getCloseTimestampMillis(), event.getTimestamp() - BACKDATE_TIMESTAMP_OFFSET_MILLIS, true); // Dispatch application close event with xdm data dispatchApplicationClose(appCloseXDMData, event); } final long startTimestamp = event.getTimestamp(); dataStoreCache.setAppStartTimestamp(startTimestamp); Map<String, Object> appLaunchXDMData = xdmMetricsBuilder.buildAppLaunchXDMData( startTimestamp, isInstall, isUpgrade()); Map<String, String> freeFormData = DataReader.optStringMap( event.getEventData(), LifecycleConstants.EventDataKeys.Lifecycle .ADDITIONAL_CONTEXT_DATA, null); // Dispatch application launch event with xdm data dispatchApplicationLaunch(appLaunchXDMData, freeFormData, event); // persist App version to track App upgrades persistAppVersion(); }); } /** * Handles the pause use-case as application close XDM event. * * @param event event containing lifecycle pause timestamp */ void pause(final Event event) { stateManager.updateState( LifecycleV2StateManager.State.PAUSE, updated -> { if (!updated) { return; } final long pauseTimestamp = event.getTimestamp(); dataStoreCache.setAppPauseTimestamp(pauseTimestamp); Map<String, Object> appCloseXDMData = xdmMetricsBuilder.buildAppCloseXDMData( dataStoreCache.getAppStartTimestampMillis(), pauseTimestamp, pauseTimestamp, false); // Dispatch application close event with xdm data dispatchApplicationClose(appCloseXDMData, event); }); } /** * Updates the last known event timestamp in cache and if needed in persistence * * @param event to be processed; should not be null */ void updateLastKnownTimestamp(final Event event) { dataStoreCache.setLastKnownTimestamp(event.getTimestamp()); } /** * This helper method identifies if the previous session ended due to an incorrect * implementation or possible app crash. * * @param previousAppStart start timestamp from previous session (milliseconds) * @param previousAppPause pause timestamp from previous session (milliseconds) * @return the status of the previous app close, true if this is considered an unknown close * event */ private boolean isCloseUnknown(final long previousAppStart, final long previousAppPause) { return previousAppStart <= 0 || previousAppStart > previousAppPause; } /** * Check if the application has been upgraded * * @return boolean whether the app has been upgraded */ private boolean isUpgrade() { String previousAppVersion = ""; if (dataStore != null) { previousAppVersion = dataStore.getString(LifecycleV2Constants.DataStoreKeys.LAST_APP_VERSION, ""); } return (deviceInfoService != null && !StringUtils.isNullOrEmpty(previousAppVersion) && !previousAppVersion.equalsIgnoreCase( LifecycleUtil.getV2AppVersion(deviceInfoService))); } /** Persist the application version into datastore */ private void persistAppVersion() { // Persist app version for xdm workflow if (dataStore != null && deviceInfoService != null) { dataStore.setString( LifecycleV2Constants.DataStoreKeys.LAST_APP_VERSION, LifecycleUtil.getV2AppVersion(deviceInfoService)); } } /** * Dispatches a lifecycle application launch event onto the EventHub containing the session info * as xdm event data * * @param appLaunchXDMData the current session start xdm data * @param freeFormData additional free-form context data * @param parentEvent the event that triggered the application launch event */ private void dispatchApplicationLaunch( final Map<String, Object> appLaunchXDMData, final Map<String, String> freeFormData, @NonNull final Event parentEvent) { if (appLaunchXDMData == null || appLaunchXDMData.isEmpty()) { Log.trace( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Not dispatching application launch event as xdm data was null"); return; } Map<String, Object> launchEventData = new HashMap<>(); launchEventData.put(LifecycleV2Constants.EventDataKeys.XDM, appLaunchXDMData); if (freeFormData != null && !freeFormData.isEmpty()) { launchEventData.put(LifecycleV2Constants.EventDataKeys.DATA, freeFormData); } Event lifecycleLaunchEvent = new Event.Builder( LifecycleV2Constants.EventName.APPLICATION_LAUNCH_EVENT, EventType.LIFECYCLE, EventSource.APPLICATION_LAUNCH) .setEventData(launchEventData) .chainToParentEvent(parentEvent) .build(); extensionApi.dispatch(lifecycleLaunchEvent); } /** * Dispatches a lifecycle application close event onto the EventHub containing the session info * as xdm event data * * @param appCloseXDMData the current session close xdm data * @param parentEvent the event that triggered the application close event */ private void dispatchApplicationClose( final Map<String, Object> appCloseXDMData, @NonNull final Event parentEvent) { if (appCloseXDMData == null || appCloseXDMData.isEmpty()) { Log.trace( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Not dispatching application close event as xdm data was null"); return; } Map<String, Object> closeEventData = new HashMap<>(); closeEventData.put(LifecycleV2Constants.EventDataKeys.XDM, appCloseXDMData); Event lifecycleCloseEvent = new Event.Builder( LifecycleV2Constants.EventName.APPLICATION_CLOSE_EVENT, EventType.LIFECYCLE, EventSource.APPLICATION_CLOSE) .setEventData(closeEventData) .chainToParentEvent(parentEvent) .build(); extensionApi.dispatch(lifecycleCloseEvent); } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/lifecycle/src/main/java/com/adobe/marketing/mobile/lifecycle/XDMLifecycleDeviceTypeEnum.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.lifecycle; /** * XDM Device type enum definition. Supported values by the Android SDK are: * * <ul> * <li>mobile * <li>tablet * </ul> * * Other possible values, not supported at this time: * * <ul> * <li>desktop * <li>ereader * <li>gaming * <li>television * <li>settop * <li>mediaplayer * <li>computers * <li>tv screens * </ul> */ @SuppressWarnings("unused") enum XDMLifecycleDeviceTypeEnum { MOBILE("mobile"), // Mobile TABLET("tablet"); // Tablet // todo: watch to be added once included in the xdm enum private final String value; XDMLifecycleDeviceTypeEnum(final String enumValue) { this.value = enumValue; } @Override public String toString() { return value; } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/lifecycle/src/main/java/com/adobe/marketing/mobile/lifecycle/LifecycleTimerState.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.lifecycle; import com.adobe.marketing.mobile.AdobeCallback; import com.adobe.marketing.mobile.services.Log; import java.util.Timer; import java.util.TimerTask; /** * Encapsulates a {@link Timer} object and provides API to start/cancel the timer or check whether * the timer is running. */ class LifecycleTimerState { private static final String SELF_LOG_TAG = "LifecycleTimerState"; private boolean isTimerRunning; private long timeout; private TimerTask timerTask; private Timer timer; private AdobeCallback<Boolean> callback; private final String debugName; private final Object timerMutex; /** * Constructor * * @param debugName a {@link String} used as log tag */ LifecycleTimerState(final String debugName) { this.timeout = 0; this.isTimerRunning = false; this.debugName = debugName; this.timerMutex = new Object(); } /** * Checks if the timer is still running. * * @return a {@code boolean} indicates whether there is a timer and it is still running */ boolean isTimerRunning() { synchronized (timerMutex) { return timerTask != null && isTimerRunning; } } /** * Starts the timer with the given {@code long} timeout value, and call the {@code * AdobeCallback<Boolean>} if the timer was not canceled before timeout. * * @param timeout {@code long} timeout value for the timer * @param callback the {@code AdobeCallback<Boolean>} to be invoked once times out */ void startTimer(final long timeout, final AdobeCallback<Boolean> callback) { synchronized (timerMutex) { if (timerTask != null) { Log.debug(LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Timer has already started."); return; } this.timeout = timeout; this.isTimerRunning = true; this.callback = callback; try { timerTask = new TimerTask() { @Override public void run() { LifecycleTimerState.this.isTimerRunning = false; if (LifecycleTimerState.this.callback != null) { LifecycleTimerState.this.callback.call(true); } } }; timer = new Timer(this.debugName); timer.schedule(timerTask, timeout); Log.trace( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "%s timer scheduled having timeout %s ms", this.debugName, this.timeout); } catch (Exception e) { Log.warning( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Error creating %s timer, failed with error: (%s)", this.debugName, e); } } } /** Cancels the timer and sets the state back to normal. */ void cancel() { synchronized (timerMutex) { if (timer != null) { try { timer.cancel(); Log.trace( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "%s timer was canceled", this.debugName); } catch (Exception e) { Log.warning( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Error cancelling %s timer, failed with error: (%s)", this.debugName, e); } timerTask = null; } // set is running to false regardless of whether the timer is null or not this.isTimerRunning = false; } } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/lifecycle/src/main/java/com/adobe/marketing/mobile/lifecycle/LifecycleV1Extension.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.lifecycle; import com.adobe.marketing.mobile.Event; import com.adobe.marketing.mobile.EventSource; import com.adobe.marketing.mobile.EventType; import com.adobe.marketing.mobile.ExtensionApi; import com.adobe.marketing.mobile.SharedStateResolution; import com.adobe.marketing.mobile.SharedStateResult; import com.adobe.marketing.mobile.SharedStateStatus; import com.adobe.marketing.mobile.services.DeviceInforming; import com.adobe.marketing.mobile.services.NamedCollection; import com.adobe.marketing.mobile.util.DataReader; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; class LifecycleV1Extension { private static final String SELF_LOG_TAG = "LifecycleV1Extension"; private final NamedCollection dataStore; private final ExtensionApi extensionApi; private final LifecycleState lifecycleState; /** * Constructor for the LifecycleV2Extension. * * @param dataStore {@code NamedCollection} instance * @param deviceInfoService {@code DeviceInforming} instance * @param extensionApi {@code ExtensionApi} instance */ LifecycleV1Extension( final NamedCollection dataStore, final DeviceInforming deviceInfoService, final ExtensionApi extensionApi) { this.dataStore = dataStore; this.extensionApi = extensionApi; lifecycleState = new LifecycleState(dataStore, deviceInfoService); } /** * Start the lifecycle session for standard and XDM workflows * * @param startEvent current lifecycle event to be processed * @param configurationSharedState configuration shared state data for this event */ void start( final Event startEvent, final Map<String, Object> configurationSharedState, final boolean isInstall) { final long startTimestampInSeconds = startEvent.getTimestampInSeconds(); Map<String, Object> eventData = startEvent.getEventData(); Map<String, String> additionalContextData = DataReader.optStringMap( eventData, LifecycleConstants.EventDataKeys.Lifecycle.ADDITIONAL_CONTEXT_DATA, null); LifecycleSession.SessionInfo previousSessionInfo = lifecycleState.start( startTimestampInSeconds, additionalContextData, getAdvertisingIdentifier(startEvent), getSessionTimeoutLength(configurationSharedState), isInstall); if (previousSessionInfo == null) { // Analytics extension needs adjusted start date to calculate timeSinceLaunch param. if (dataStore != null) { final long adjustedStartTimeInSeconds = dataStore.getLong(LifecycleConstants.DataStoreKeys.START_DATE, 0L); updateLifecycleSharedState( startEvent, adjustedStartTimeInSeconds, lifecycleState.getContextData()); return; } } updateLifecycleSharedState( startEvent, startTimestampInSeconds, lifecycleState.getContextData()); if (previousSessionInfo != null) { dispatchSessionStart( startTimestampInSeconds, previousSessionInfo.getStartTimestampInSeconds(), previousSessionInfo.getPauseTimestampInSeconds(), startEvent); } } /** * Pause the lifecycle session for standard lifecycle workflow * * @param pauseEvent current lifecycle event to be processed */ void pause(final Event pauseEvent) { lifecycleState.pause(pauseEvent); } /** * Updates the lifecycle shared state with current context data and default data when extension * is registered */ void onRegistered() { updateLifecycleSharedState(null, 0, lifecycleState.computeBootData()); } /** * Gets advertising identifier. * * @param event Event containing advertising identifier data * @return the advertising identifier */ private String getAdvertisingIdentifier(final Event event) { SharedStateResult identitySharedState = extensionApi.getSharedState( LifecycleConstants.EventDataKeys.Identity.MODULE_NAME, event, false, SharedStateResolution.ANY); if (identitySharedState != null && identitySharedState.getStatus() == SharedStateStatus.SET) { return DataReader.optString( identitySharedState.getValue(), LifecycleConstants.EventDataKeys.Identity.ADVERTISING_IDENTIFIER, null); } return null; } /** * Reads the session timeout from the configuration shared state, if not found returns the * default session timeout * * @param configurationSharedState current configuration shared state * @return session timeout */ private long getSessionTimeoutLength(final Map<String, Object> configurationSharedState) { return DataReader.optLong( configurationSharedState, LifecycleConstants.EventDataKeys.Configuration.LIFECYCLE_CONFIG_SESSION_TIMEOUT, LifecycleConstants.DEFAULT_LIFECYCLE_TIMEOUT); } /** * Updates lifecycle shared state versioned at {@code event} with {@code contextData} * * @param event the event to version the shared state at * @param startTimestampInSeconds The current session start timestamp in seconds * @param contextData {@code Map<String, String>} context data to be updated */ private void updateLifecycleSharedState( final Event event, final long startTimestampInSeconds, final Map<String, String> contextData) { Map<String, Object> lifecycleSharedState = new HashMap<>(); lifecycleSharedState.put( LifecycleConstants.EventDataKeys.Lifecycle.MAX_SESSION_LENGTH, LifecycleConstants.MAX_SESSION_LENGTH_SECONDS); lifecycleSharedState.put( LifecycleConstants.EventDataKeys.Lifecycle.LIFECYCLE_CONTEXT_DATA, contextData); // Convert these timestamps to milliseconds. lifecycleSharedState.put( LifecycleConstants.EventDataKeys.Lifecycle.SESSION_START_TIMESTAMP, TimeUnit.SECONDS.toMillis(startTimestampInSeconds)); extensionApi.createSharedState(lifecycleSharedState, event); } /** * Dispatches a Lifecycle response content event with appropriate event data * * @param startTimestampInSeconds session start time * @param previousStartTimeInSeconds start time of previous session * @param previousPauseTimeInSeconds pause time of previous session * @param parentEvent the lifecycle event that triggered start */ private void dispatchSessionStart( final long startTimestampInSeconds, final long previousStartTimeInSeconds, final long previousPauseTimeInSeconds, final Event parentEvent) { // Dispatch a new event with session related data Map<String, Object> eventDataMap = new HashMap<>(); eventDataMap.put( LifecycleConstants.EventDataKeys.Lifecycle.LIFECYCLE_CONTEXT_DATA, lifecycleState.getContextData()); eventDataMap.put( LifecycleConstants.EventDataKeys.Lifecycle.SESSION_EVENT, LifecycleConstants.EventDataKeys.Lifecycle.LIFECYCLE_START); eventDataMap.put( LifecycleConstants.EventDataKeys.Lifecycle.MAX_SESSION_LENGTH, LifecycleConstants.MAX_SESSION_LENGTH_SECONDS); // Convert these timestamps to milliseconds. eventDataMap.put( LifecycleConstants.EventDataKeys.Lifecycle.SESSION_START_TIMESTAMP, TimeUnit.SECONDS.toMillis(startTimestampInSeconds)); eventDataMap.put( LifecycleConstants.EventDataKeys.Lifecycle.PREVIOUS_SESSION_START_TIMESTAMP, TimeUnit.SECONDS.toMillis(previousStartTimeInSeconds)); eventDataMap.put( LifecycleConstants.EventDataKeys.Lifecycle.PREVIOUS_SESSION_PAUSE_TIMESTAMP, TimeUnit.SECONDS.toMillis(previousPauseTimeInSeconds)); final Event startEvent = new Event.Builder( LifecycleConstants.EventName.LIFECYCLE_START_EVENT, EventType.LIFECYCLE, EventSource.RESPONSE_CONTENT) .setEventData(eventDataMap) .chainToParentEvent(parentEvent) .build(); extensionApi.dispatch(startEvent); } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/lifecycle/src/main/java/com/adobe/marketing/mobile/lifecycle/LifecycleUtil.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.lifecycle; import com.adobe.marketing.mobile.services.DeviceInforming; import com.adobe.marketing.mobile.util.StringUtils; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.TimeZone; final class LifecycleUtil { private static final String DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; private LifecycleUtil() {} /** * Formats a {@code Date} to an ISO 8601 date-time string in UTC as defined in <a * href="https://tools.ietf.org/html/rfc3339#section-5.6">RFC 3339, section 5.6</a> For example, * 2017-09-26T15:52:25Z * * @param timestamp a timestamp * @return {@code timestamp} formatted to a string in the format of 'yyyy-MM-dd'T'HH:mm:ss'Z'', * or an empty string if {@code timestamp} is null */ static String dateTimeISO8601String(final Date timestamp) { return dateToISO8601String(timestamp, DATE_TIME_FORMAT); } /** * Formats a {@code Date} with the provided {@code timestampFormat} * * @param timestamp a timestamp * @param timestampFormat the format in which to format the date or the default {@link * #DATE_TIME_FORMAT} if this parameter is null or empty * @return {@code timestamp} formatted to a string */ private static String dateToISO8601String(final Date timestamp, final String timestampFormat) { if (timestamp == null) { return ""; } final String timePattern = StringUtils.isNullOrEmpty(timestampFormat) ? DATE_TIME_FORMAT : timestampFormat; final Locale posixLocale = new Locale(Locale.US.getLanguage(), Locale.US.getCountry(), "POSIX"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(timePattern, posixLocale); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); return simpleDateFormat.format(timestamp); } /** * Formats the locale value by replacing '_' with '-'. Uses {@link Locale#toString()} to * retrieve the language tag. * * <p>Note. the use of {@code Locale#toString()} does not return a value formatted to BCP 47. * For example, script codes are appended to the locale as "-#scriptCode", as in "zh-HK-#Hant", * where BCP 47 requires the format as "zh-Hant-HK". * * @see #formatLocaleXDM(Locale) * @param locale active locale value * @return string representation of the locale */ static String formatLocale(final Locale locale) { return locale == null ? null : locale.toString().replace('_', '-'); } /** * Format the locale to the string format used in XDM. Returns {@link Locale#toLanguageTag()}. * * @param locale active Locale value * @return String representation of the locale */ static String formatLocaleXDM(final Locale locale) { if (locale == null) { return null; } return locale.toLanguageTag(); } /** * Returns the application version in the format of "appVersion (versionCode)". Example: 2.3 * (10) * * @param deviceInfoService DeviceInfoService instance * @return application version */ static String getV2AppVersion(final DeviceInforming deviceInfoService) { if (deviceInfoService == null) { return null; } final String applicationVersion = deviceInfoService.getApplicationVersion(); final String applicationVersionCode = deviceInfoService.getApplicationVersionCode(); return String.format( "%s%s", !StringUtils.isNullOrEmpty(applicationVersion) ? String.format("%s", applicationVersion) : "", !StringUtils.isNullOrEmpty(applicationVersionCode) ? String.format(" (%s)", applicationVersionCode) : ""); } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/lifecycle/src/main/java/com/adobe/marketing/mobile/lifecycle/LifecycleConstants.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.lifecycle; import java.util.concurrent.*; class LifecycleConstants { /** General constants */ static final String DATA_STORE_NAME = "AdobeMobile_Lifecycle"; static final long MAX_SESSION_LENGTH_SECONDS = TimeUnit.DAYS.toSeconds(7); static final long WRONG_EPOCH_MAX_LENGTH_SECONDS = TimeUnit.DAYS.toSeconds(365 * 30); // 30 years static final int DEFAULT_LIFECYCLE_TIMEOUT = 300; static final String LOG_TAG = "Lifecycle"; static final String FRIENDLY_NAME = "Lifecycle"; static final class EventName { static final String LIFECYCLE_START_EVENT = "LifecycleStart"; private EventName() {} } static class ContextDataValues { static final String UPGRADE_EVENT = "UpgradeEvent"; static final String CRASH_EVENT = "CrashEvent"; static final String LAUNCH_EVENT = "LaunchEvent"; static final String INSTALL_EVENT = "InstallEvent"; static final String DAILY_ENG_USER_EVENT = "DailyEngUserEvent"; static final String MONTHLY_ENG_USER_EVENT = "MonthlyEngUserEvent"; private ContextDataValues() {} } /** Module Data Store keys */ static class DataStoreKeys { static final String LIFECYCLE_DATA = "LifecycleData"; static final String START_DATE = "SessionStart"; static final String INSTALL_DATE = "InstallDate"; static final String UPGRADE_DATE = "UpgradeDate"; static final String LAST_USED_DATE = "LastDateUsed"; static final String LAUNCHES_AFTER_UPGRADE = "LaunchesAfterUpgrade"; static final String LAUNCHES = "Launches"; static final String LAST_VERSION = "LastVersion"; static final String PAUSE_DATE = "PauseDate"; static final String SUCCESSFUL_CLOSE = "SuccessfulClose"; static final String OS_VERSION = "OsVersion"; static final String APP_ID = "AppId"; private DataStoreKeys() {} } private LifecycleConstants() {} static final class EventDataKeys { static final String STATE_OWNER = "stateowner"; private EventDataKeys() {} static final class Configuration { static final String MODULE_NAME = "com.adobe.module.configuration"; static final String LIFECYCLE_CONFIG_SESSION_TIMEOUT = "lifecycle.sessionTimeout"; private Configuration() {} } static final class Lifecycle { static final String MODULE_NAME = "com.adobe.module.lifecycle"; static final String ADDITIONAL_CONTEXT_DATA = "additionalcontextdata"; static final String APP_ID = "appid"; static final String CARRIER_NAME = "carriername"; static final String CRASH_EVENT = "crashevent"; static final String PREVIOUS_OS_VERSION = "previousosversion"; static final String PREVIOUS_APP_ID = "previousappid"; static final String DAILY_ENGAGED_EVENT = "dailyenguserevent"; static final String DAY_OF_WEEK = "dayofweek"; static final String DAYS_SINCE_FIRST_LAUNCH = "dayssincefirstuse"; static final String DAYS_SINCE_LAST_LAUNCH = "dayssincelastuse"; static final String DAYS_SINCE_LAST_UPGRADE = "dayssincelastupgrade"; static final String DEVICE_NAME = "devicename"; static final String DEVICE_RESOLUTION = "resolution"; static final String HOUR_OF_DAY = "hourofday"; static final String IGNORED_SESSION_LENGTH = "ignoredsessionlength"; static final String INSTALL_DATE = "installdate"; static final String INSTALL_EVENT = "installevent"; static final String LAUNCH_EVENT = "launchevent"; static final String LAUNCHES = "launches"; static final String LAUNCHES_SINCE_UPGRADE = "launchessinceupgrade"; static final String LIFECYCLE_ACTION_KEY = "action"; static final String LIFECYCLE_CONTEXT_DATA = "lifecyclecontextdata"; static final String LIFECYCLE_PAUSE = "pause"; static final String LIFECYCLE_START = "start"; static final String LOCALE = "locale"; static final String MAX_SESSION_LENGTH = "maxsessionlength"; static final String MONTHLY_ENGAGED_EVENT = "monthlyenguserevent"; static final String OPERATING_SYSTEM = "osversion"; static final String PREVIOUS_SESSION_LENGTH = "prevsessionlength"; static final String PREVIOUS_SESSION_PAUSE_TIMESTAMP = "previoussessionpausetimestampmillis"; static final String PREVIOUS_SESSION_START_TIMESTAMP = "previoussessionstarttimestampmillis"; static final String RUN_MODE = "runmode"; static final String SESSION_EVENT = "sessionevent"; static final String SESSION_START_TIMESTAMP = "starttimestampmillis"; static final String SYSTEM_LOCALE = "systemlocale"; static final String UPGRADE_EVENT = "upgradeevent"; private Lifecycle() {} } static final class Identity { static final String MODULE_NAME = "com.adobe.module.identity"; static final String ADVERTISING_IDENTIFIER = "advertisingidentifier"; private Identity() {} } } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/lifecycle/src/main/java/com/adobe/marketing/mobile/lifecycle/XDMLifecycleDevice.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.lifecycle; import java.util.HashMap; import java.util.Map; /** * Class {@code Device} representing a subset of the XDM Device data type fields. An identified * device, application or device browser instance that is trackable across sessions. */ @SuppressWarnings("unused") class XDMLifecycleDevice { private String manufacturer; private String modelNumber; private String model; private int screenHeight; private int screenWidth; private XDMLifecycleDeviceTypeEnum type; XDMLifecycleDevice() {} Map<String, Object> serializeToXdm() { Map<String, Object> map = new HashMap<String, Object>(); if (this.manufacturer != null) { map.put("manufacturer", this.manufacturer); } if (this.model != null) { map.put("model", this.model); } if (this.modelNumber != null) { map.put("modelNumber", this.modelNumber); } if (this.screenHeight > 0) { map.put("screenHeight", this.screenHeight); } if (this.screenWidth > 0) { map.put("screenWidth", this.screenWidth); } if (this.type != null) { map.put("type", this.type.toString()); } return map; } /** * Returns the Manufacturer property The name of the organization who owns the design and * creation of the device, for example, 'Apple' is the manufacturer of the iPhone. * * @return {@link String} value or null if the property is not set */ String getManufacturer() { return this.manufacturer; } /** * Sets the Manufacturer property The name of the organization who owns the design and creation * of the device, for example, 'Apple' is the manufacturer of the iPhone. * * @param newValue the new Manufacturer value */ void setManufacturer(final String newValue) { this.manufacturer = newValue; } /** * Returns the Model number property The unique model number designation assigned by the * manufacturer for this device. Model numbers are not versions, but unique identifiers that * identify a particular model configuration. While the model for a particular phone might be * 'iPhone 6S' the model number would be 'A1633', or 'A1634' based on configuration at the time * of sale. * * @return {@link String} value or null if the property is not set */ String getModelNumber() { return this.modelNumber; } /** * Sets the Model number property The unique model number designation assigned by the * manufacturer for this device. Model numbers are not versions, but unique identifiers that * identify a particular model configuration. While the model for a particular phone might be * 'iPhone 6S' the model number would be 'A1633', or 'A1634' based on configuration at the time * of sale. * * @param newValue the new Model number value */ void setModelNumber(final String newValue) { this.modelNumber = newValue; } /** * Returns the Model property The name of the model for the device. This is the common, * human-readable, or marketing name for the device. For example, the 'iPhone 6S' is a * particular model of mobile phone. * * @return {@link String} value or null if the property is not set */ String getModel() { return this.model; } /** * Sets the Model property The name of the model for the device. This is the common, * human-readable, or marketing name for the device. For example, the 'iPhone 6S' is a * particular model of mobile phone. * * @param newValue the new Model value */ void setModel(final String newValue) { this.model = newValue; } /** * Returns the Screen height property The number of vertical pixels of the device's active * display in the default orientation. * * @return int value */ int getScreenHeight() { return this.screenHeight; } /** * Sets the Screen height property The number of vertical pixels of the device's active display * in the default orientation. * * @param newValue the new Screen height value */ void setScreenHeight(final int newValue) { this.screenHeight = newValue; } /** * Returns the Screen width property The number of horizontal pixels of the device's active * display in the default orientation. * * @return int value */ int getScreenWidth() { return this.screenWidth; } /** * Sets the Screen width property The number of horizontal pixels of the device's active display * in the default orientation. * * @param newValue the new Screen width value */ void setScreenWidth(final int newValue) { this.screenWidth = newValue; } /** * Returns the Type property Type of device being tracked. * * @return {@link XDMLifecycleDeviceTypeEnum} value or null if the property is not set */ XDMLifecycleDeviceTypeEnum getType() { return this.type; } /** * Sets the Type property Type of device being tracked. * * @param newValue the new Type value */ void setType(final XDMLifecycleDeviceTypeEnum newValue) { this.type = newValue; } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/lifecycle/src/main/java/com/adobe/marketing/mobile/lifecycle/LifecycleV2MetricsBuilder.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.lifecycle; import com.adobe.marketing.mobile.services.DeviceInforming; import com.adobe.marketing.mobile.services.Log; import java.util.Date; import java.util.Map; import java.util.concurrent.TimeUnit; /** * XDMLifecycleMetricsBuilder collects metrics in XDM format, to be sent as two XDM events for * mobile application launch and application close. Refer to the Mobile App Lifecycle Details mixin, * which includes: * * <ul> * <li>XDM Environment datatype * <li>XMD Device datatype * <li>XDM Application datatype * </ul> */ class LifecycleV2MetricsBuilder { private static final String SELF_LOG_TAG = "LifecycleV2MetricsBuilder"; private final DeviceInforming deviceInfoService; private XDMLifecycleDevice xdmDeviceInfo; private XDMLifecycleEnvironment xdmEnvironmentInfo; /** * Constructor for the Lifecycle metrics builder in XDM format * * @param deviceInfoService {@link DeviceInforming} instance to be used for collecting the * metrics */ LifecycleV2MetricsBuilder(final DeviceInforming deviceInfoService) { this.deviceInfoService = deviceInfoService; if (deviceInfoService == null) { Log.debug( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "%s (Device Info Services), while creating XDMLifecycleMetricsBuilder.", Log.UNEXPECTED_NULL_VALUE); } } /** * Builds the data required for the XDM Application Launch event, including {@link * XDMLifecycleApplication}, {@link XDMLifecycleEnvironment} and {@link XDMLifecycleDevice} * info. * * @param launchTimestampMillis the app launch timestamp (milliseconds) * @param isInstall indicates if this is an app install * @param isUpgrade indicates if this is an app upgrade * @return serialized data in {@link Map} format */ Map<String, Object> buildAppLaunchXDMData( final long launchTimestampMillis, final boolean isInstall, final boolean isUpgrade) { XDMLifecycleMobileDetails appLaunchXDMData = new XDMLifecycleMobileDetails(); appLaunchXDMData.setApplication(computeAppLaunchData(isInstall, isUpgrade)); appLaunchXDMData.setDevice(computeDeviceData()); appLaunchXDMData.setEnvironment(computeEnvironmentData()); appLaunchXDMData.setEventType(LifecycleV2Constants.XDMEventType.APP_LAUNCH); appLaunchXDMData.setTimestamp(new Date(launchTimestampMillis)); return appLaunchXDMData.serializeToXdm(); } /** * Builds the data required for the XDM Application Close event, including {@link * XDMLifecycleApplication}. * * @param launchTimestampMillis the app launch timestamp (milliseconds) * @param closeTimestampMillis the app close timestamp (milliseconds) * @param fallbackCloseEventTimestampMillis the timestamp to be used as xdm.timestamp for the * Close event when {@code closeTimestampMillis} is invalid or 0 * @param isCloseUnknown indicates if this is a regular or abnormal close event * @return serialized data in {@link Map} format */ Map<String, Object> buildAppCloseXDMData( final long launchTimestampMillis, final long closeTimestampMillis, final long fallbackCloseEventTimestampMillis, final boolean isCloseUnknown) { XDMLifecycleMobileDetails appCloseXDMData = new XDMLifecycleMobileDetails(); appCloseXDMData.setApplication( computeAppCloseData(launchTimestampMillis, closeTimestampMillis, isCloseUnknown)); appCloseXDMData.setEventType(LifecycleV2Constants.XDMEventType.APP_CLOSE); long unwrappedCloseTimestamp = closeTimestampMillis > 0 ? closeTimestampMillis : fallbackCloseEventTimestampMillis; appCloseXDMData.setTimestamp(new Date(unwrappedCloseTimestamp)); return appCloseXDMData.serializeToXdm(); } /** * Computes general application information as well as details related to the type of launch * (install, upgrade, regular launch) * * @param isInstall indicates if this is an app install * @param isUpgrade indicates if this is an app upgrade * @return this {@link XDMLifecycleApplication} with the launch information */ private XDMLifecycleApplication computeAppLaunchData( final boolean isInstall, final boolean isUpgrade) { XDMLifecycleApplication xdmApplicationInfoLaunch = new XDMLifecycleApplication(); xdmApplicationInfoLaunch.setIsLaunch(true); if (isInstall) { xdmApplicationInfoLaunch.setIsInstall(true); } else if (isUpgrade) { xdmApplicationInfoLaunch.setIsUpgrade(true); } if (deviceInfoService == null) { Log.debug( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Unable to add XDM Application data for app launch due to DeviceInfoService" + " being not initialized."); return xdmApplicationInfoLaunch; } xdmApplicationInfoLaunch.setName(deviceInfoService.getApplicationName()); xdmApplicationInfoLaunch.setId(deviceInfoService.getApplicationPackageName()); xdmApplicationInfoLaunch.setVersion(LifecycleUtil.getV2AppVersion(deviceInfoService)); xdmApplicationInfoLaunch.setLanguage( LifecycleUtil.formatLocaleXDM(deviceInfoService.getActiveLocale())); return xdmApplicationInfoLaunch; } /** * Computes metrics related to the type of close event. The session length is computed based on * the launch and close timestamp values. The {@code closeTimestampMillis} corresponds to the * pause event timestamp in normal scenarios or to the last known close event in case of an * abnormal application close. * * @param launchTimestampMillis the app launch timestamp (milliseconds) * @param closeTimestampMillis the app close timestamp (milliseconds) * @param isCloseUnknown indicates if this is a regular or abnormal close event * @return this {@link XDMLifecycleApplication} */ private XDMLifecycleApplication computeAppCloseData( final long launchTimestampMillis, final long closeTimestampMillis, final boolean isCloseUnknown) { XDMLifecycleApplication xdmApplicationInfoClose = new XDMLifecycleApplication(); xdmApplicationInfoClose.setIsClose(true); xdmApplicationInfoClose.setCloseType( isCloseUnknown ? XDMLifecycleCloseTypeEnum.UNKNOWN : XDMLifecycleCloseTypeEnum.CLOSE); // Session Length is defined in seconds xdmApplicationInfoClose.setSessionLength( computeSessionLengthSeconds(launchTimestampMillis, closeTimestampMillis)); return xdmApplicationInfoClose; } /** * Returns information related to the running environment. This data is computed once, when it * is first used, then returned from cache. * * @return {@link XDMLifecycleEnvironment} */ private XDMLifecycleEnvironment computeEnvironmentData() { if (xdmEnvironmentInfo != null) { return xdmEnvironmentInfo; } if (deviceInfoService == null) { Log.debug( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Unable to add XDM Environment data due to DeviceInfoService being not" + " initialized."); return null; } xdmEnvironmentInfo = new XDMLifecycleEnvironment(); xdmEnvironmentInfo.setCarrier(deviceInfoService.getMobileCarrierName()); xdmEnvironmentInfo.setType( LifecycleV2DataConverter.toEnvironmentTypeEnum(deviceInfoService.getRunMode())); xdmEnvironmentInfo.setOperatingSystem(deviceInfoService.getOperatingSystemName()); xdmEnvironmentInfo.setOperatingSystemVersion(deviceInfoService.getOperatingSystemVersion()); xdmEnvironmentInfo.setLanguage( LifecycleUtil.formatLocaleXDM(deviceInfoService.getSystemLocale())); return xdmEnvironmentInfo; } /** * Returns information related to the running environment. This data is computed once, when it * is first used, then returned from cache. * * @return {@link XDMLifecycleDevice} */ private XDMLifecycleDevice computeDeviceData() { if (xdmDeviceInfo != null) { return xdmDeviceInfo; } if (deviceInfoService == null) { Log.debug( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Unable to add XDM Device data due to DeviceInfoService being not" + " initialized."); return null; } xdmDeviceInfo = new XDMLifecycleDevice(); DeviceInforming.DisplayInformation displayInfo = deviceInfoService.getDisplayInformation(); if (displayInfo != null) { // absolute width/height of the device xdmDeviceInfo.setScreenWidth(displayInfo.getWidthPixels()); xdmDeviceInfo.setScreenHeight(displayInfo.getHeightPixels()); } xdmDeviceInfo.setType( LifecycleV2DataConverter.toDeviceTypeEnum(deviceInfoService.getDeviceType())); xdmDeviceInfo.setModel(deviceInfoService.getDeviceName()); xdmDeviceInfo.setModelNumber(deviceInfoService.getDeviceBuildId()); xdmDeviceInfo.setManufacturer(deviceInfoService.getDeviceManufacturer()); return xdmDeviceInfo; } /** * Computes the session length based on the previous app session launch and close timestamp. The * returned session length is in seconds. If the session length is larger than can be * represented by an Integer, then 0 is returned. * * @param launchTimestampMillis last known app launch timestamp (milliseconds) * @param closeTimestampMillis last known app close timestamp (milliseconds) * @return the session length (seconds) or 0 if the session length could not be computed */ private int computeSessionLengthSeconds( final long launchTimestampMillis, final long closeTimestampMillis) { long sessionLength = 0; if (launchTimestampMillis > 0 && closeTimestampMillis > 0 && closeTimestampMillis > launchTimestampMillis) { sessionLength = closeTimestampMillis - launchTimestampMillis; } long sessionLengthSeconds = TimeUnit.MILLISECONDS.toSeconds(sessionLength); return sessionLengthSeconds <= Integer.MAX_VALUE ? (int) sessionLengthSeconds : 0; } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/lifecycle/src/main/java/com/adobe/marketing/mobile/lifecycle/LifecycleState.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.lifecycle; import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; import com.adobe.marketing.mobile.Event; import com.adobe.marketing.mobile.services.DeviceInforming; import com.adobe.marketing.mobile.services.Log; import com.adobe.marketing.mobile.services.NamedCollection; import com.adobe.marketing.mobile.util.StringUtils; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; // Manages the business logic of the Lifecycle extension class LifecycleState { private static final String SELF_LOG_TAG = "LifecycleState"; private final NamedCollection namedCollection; private final DeviceInforming deviceInfoService; private final LifecycleSession lifecycleSession; private final Map<String, String> lifecycleContextData = new HashMap<>(); private final Map<String, String> previousSessionLifecycleContextData = new HashMap<>(); LifecycleState(final NamedCollection namedCollection, final DeviceInforming deviceInfoService) { this.namedCollection = namedCollection; this.deviceInfoService = deviceInfoService; lifecycleSession = new LifecycleSession(namedCollection); } Map<String, String> computeBootData() { Map<String, String> contextData = new HashMap<>(); Map<String, String> currentContextData = getContextData(); if (currentContextData != null) { contextData.putAll(currentContextData); } Map<String, String> defaultData = new LifecycleMetricsBuilder( deviceInfoService, namedCollection, TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis())) .addCoreData() .addGenericData() .build(); contextData.putAll(defaultData); return contextData; } /** * Starts a new lifecycle session at the given date with the provided data * * @param startTimestampInSeconds start time for the event * @param additionalContextData additional context data for this start event * @param advertisingIdentifier The advertising identifier provided by the identity extension * @param sessionTimeoutInSeconds The session timeout for this start event, * @param isInstall Indicates whether this is an application install scenario * @return Instance of {@code LifecycleSession.SessionInfo} having the previous session info if * it exists otherwise null */ LifecycleSession.SessionInfo start( final long startTimestampInSeconds, final Map<String, String> additionalContextData, final String advertisingIdentifier, final long sessionTimeoutInSeconds, final boolean isInstall) { String previousOsVersion = ""; String previousAppId = ""; if (namedCollection != null) { previousOsVersion = namedCollection.getString(LifecycleConstants.DataStoreKeys.OS_VERSION, ""); previousAppId = namedCollection.getString(LifecycleConstants.DataStoreKeys.APP_ID, ""); } LifecycleMetricsBuilder metricsBuilder = new LifecycleMetricsBuilder( deviceInfoService, namedCollection, startTimestampInSeconds); Map<String, String> defaultData = metricsBuilder.addCoreData().addGenericData().build(); if (!isInstall) { checkForApplicationUpgrade( defaultData.get(LifecycleConstants.EventDataKeys.Lifecycle.APP_ID)); } LifecycleSession.SessionInfo previousSessionInfo = lifecycleSession.start( startTimestampInSeconds, sessionTimeoutInSeconds, defaultData); if (previousSessionInfo == null) { return null; } lifecycleContextData.clear(); Map<String, String> lifecycleData = new HashMap<>(); // determine config type (install, upgrade, or launch) if (isInstall) { // install hit metricsBuilder.addInstallData().addGenericData().addCoreData(); lifecycleData.putAll(metricsBuilder.build()); } else { // upgrade and launch hits metricsBuilder .addLaunchData() .addUpgradeData(isUpgrade()) .addCrashData(previousSessionInfo.isCrash()) .addGenericData() .addCoreData(); lifecycleData.putAll(metricsBuilder.build()); Map<String, String> sessionContextData = lifecycleSession.getSessionData( startTimestampInSeconds, sessionTimeoutInSeconds, previousSessionInfo); lifecycleData.putAll(sessionContextData); if (!StringUtils.isNullOrEmpty(previousOsVersion)) { lifecycleData.put( LifecycleConstants.EventDataKeys.Lifecycle.PREVIOUS_OS_VERSION, previousOsVersion); } if (!StringUtils.isNullOrEmpty(previousAppId)) { lifecycleData.put( LifecycleConstants.EventDataKeys.Lifecycle.PREVIOUS_APP_ID, previousAppId); } } if (additionalContextData != null) { lifecycleData.putAll(additionalContextData); } if (!StringUtils.isNullOrEmpty(advertisingIdentifier)) { lifecycleData.put( LifecycleConstants.EventDataKeys.Identity.ADVERTISING_IDENTIFIER, advertisingIdentifier); } // Update lifecycle context data and persist lifecycle info into local storage lifecycleContextData.putAll(lifecycleData); persistLifecycleContextData(startTimestampInSeconds); return previousSessionInfo; } /** * Pause the current lifecycle session * * @param event event containing lifecycle pause timestamp */ void pause(final Event event) { lifecycleSession.pause(event.getTimestampInSeconds()); } /** * Updates the application identifier in the local lifecycle context data in case of upgrade * * @param applicationIdentifier the application identifier */ void checkForApplicationUpgrade(final String applicationIdentifier) { // early out if this isn't an upgrade or if it is an install if (!isUpgrade()) { return; } // get a map of lifecycle data in shared preferences or memory final Map<String, String> lifecycleData = getContextData(); // no data to update if (lifecycleData == null || lifecycleData.isEmpty()) { return; } // update the version in our map lifecycleData.put(LifecycleConstants.EventDataKeys.Lifecycle.APP_ID, applicationIdentifier); if (lifecycleContextData.isEmpty()) { // update the previous session's map previousSessionLifecycleContextData.put( LifecycleConstants.EventDataKeys.Lifecycle.APP_ID, applicationIdentifier); // update data in local storage if (namedCollection != null) { namedCollection.setMap( LifecycleConstants.DataStoreKeys.LIFECYCLE_DATA, lifecycleData); } } else { // if we have the map in memory, update it lifecycleContextData.putAll(lifecycleData); } } /** * Gets lifecycle context data. If lifecycleContextData has elements, it returns a copy of the * existing key-value pairs Otherwise, if previousSessionLifecycleContextData has elements, it * returns a copy of the key-value pairs Otherwise it reads context data from persistence and * returns the keys * * @return {@code Map<String, String>} lifecycle context data */ Map<String, String> getContextData() { // if we already have lifecycle data, return it if (!lifecycleContextData.isEmpty()) { return lifecycleContextData; } if (!previousSessionLifecycleContextData.isEmpty()) { return previousSessionLifecycleContextData; } previousSessionLifecycleContextData.putAll(getPersistedContextData()); return previousSessionLifecycleContextData; } /** * Used for testing only Update lifecycle context data. Equivalent to calling * putAll(contextData) on existing lifecycle data * * @param contextData {@code Map<String, String>} context data to be updated */ @VisibleForTesting void updateContextData(@NonNull final Map<String, String> contextData) { lifecycleContextData.putAll(contextData); } /** * Used for testing only Update previous session lifecycle context data. Equivalent to calling * putAll(contextData) on prev lifecycle data * * @param contextData {@code Map<String, String>} context data to be updated */ @VisibleForTesting void updatePreviousSessionLifecycleContextData(@NonNull final Map<String, String> contextData) { previousSessionLifecycleContextData.putAll(contextData); } /** * Gets persisted lifecycle context data from local storage. * * @return {@code Map<String, String>} persisted lifecycle context data */ Map<String, String> getPersistedContextData() { // if we didn't have any lifecycle data, pull what was persisted last if (namedCollection == null) { Log.warning( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Failed to read lifecycle data from persistence %s (DataStore)", Log.UNEXPECTED_NULL_VALUE); return new HashMap<>(); } Map<String, String> lifecycleData = namedCollection.getMap(LifecycleConstants.DataStoreKeys.LIFECYCLE_DATA); return lifecycleData != null ? lifecycleData : new HashMap<>(); } /** * Check if the application has been upgraded * * @return true if the current app version does not equal the app version stored in the data * store */ private boolean isUpgrade() { String previousAppVersion = ""; if (namedCollection != null) { previousAppVersion = namedCollection.getString(LifecycleConstants.DataStoreKeys.LAST_VERSION, ""); } return (deviceInfoService != null && !StringUtils.isNullOrEmpty(previousAppVersion) && !previousAppVersion.equalsIgnoreCase(deviceInfoService.getApplicationVersion())); } /** * Persist lifecycle context data. * * @param startTimestamp current event timestamp to be stored as last used date */ private void persistLifecycleContextData(final long startTimestamp) { if (namedCollection == null) { Log.debug( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Failed to update lifecycle data, %s (DataStore)", Log.UNEXPECTED_NULL_VALUE); return; } namedCollection.setMap( LifecycleConstants.DataStoreKeys.LIFECYCLE_DATA, lifecycleContextData); namedCollection.setLong(LifecycleConstants.DataStoreKeys.LAST_USED_DATE, startTimestamp); if (deviceInfoService != null) { namedCollection.setString( LifecycleConstants.DataStoreKeys.LAST_VERSION, deviceInfoService.getApplicationVersion()); } } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/lifecycle/src/main/java/com/adobe/marketing/mobile/lifecycle/LifecycleV2DataConverter.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.lifecycle; import com.adobe.marketing.mobile.services.DeviceInforming; import com.adobe.marketing.mobile.util.StringUtils; /** Helper class that converts standard data types to XDM data types for Lifecycle metrics */ class LifecycleV2DataConverter { /** * Converts {@link DeviceInforming.DeviceType} value to {@link XDMLifecycleDeviceTypeEnum}. If * new values are added to the {@link XDMLifecycleDeviceTypeEnum} this helper needs to be * updated as well. * * @param deviceType the type of the device returned by the {@link DeviceInforming} * @return the device type enum value, null if the provided {@code deviceType} is null or the * default {@link XDMLifecycleDeviceTypeEnum#MOBILE} if the value is unknown */ static XDMLifecycleDeviceTypeEnum toDeviceTypeEnum( final DeviceInforming.DeviceType deviceType) { if (deviceType == null) { return null; } // todo: watch to be added once included in the xdm enum if (deviceType == DeviceInforming.DeviceType.TABLET) { return XDMLifecycleDeviceTypeEnum.TABLET; } return XDMLifecycleDeviceTypeEnum.MOBILE; // if unknown, default is Mobile } /** * Converts {@link DeviceInforming#getRunMode()} String to {@link * XDMLifecycleEnvironmentTypeEnum}. It currently only supports the {@link * XDMLifecycleEnvironmentTypeEnum#APPLICATION} type and requires updates once the * SystemInfoService is updated to support multiple values. * * @param runMode the device run mode * @return the environment type enum value, or null if unknown */ static XDMLifecycleEnvironmentTypeEnum toEnvironmentTypeEnum(final String runMode) { if (StringUtils.isNullOrEmpty(runMode) || !"application".equalsIgnoreCase(runMode)) { return null; } return XDMLifecycleEnvironmentTypeEnum.APPLICATION; } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/lifecycle/src/main/java/com/adobe/marketing/mobile/lifecycle/LifecycleV2DataStoreCache.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.lifecycle; import com.adobe.marketing.mobile.services.Log; import com.adobe.marketing.mobile.services.NamedCollection; import java.util.concurrent.TimeUnit; /** * Lifecycle DataStore Cache layer for persisting the timestamp values required for Lifecycle * session computation in XDM, including close timestamp to be used for app close time * approximation, start and pause timestamps. This class is not thread safe, so it should be used in * a thread safe setup. */ class LifecycleV2DataStoreCache { private static final String SELF_LOG_TAG = "LifecycleV2DataStoreCache"; private final NamedCollection dataStore; private final long closeTimestampMillis; // close timestamp at initialization time (persisted in the // previous session) // used to keep track of the last persisted value to optimize the commits to persistence private long lastClosePersistedValue; /** * Initializes the class and loads the app close timestamp from persistence * * @param dataStore the {@code NamedCollection} used to read/write last known timestamp */ LifecycleV2DataStoreCache(final NamedCollection dataStore) { this.dataStore = dataStore; if (this.dataStore == null) { Log.warning( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "%s DataStore was provided, the functionality is limited", Log.UNEXPECTED_EMPTY_VALUE); closeTimestampMillis = 0L; return; } // DataStore is set, migrate any old timestamps migrateTimestampsSecToMillis(); final long tempTs = this.dataStore.getLong( LifecycleV2Constants.DataStoreKeys.APP_CLOSE_TIMESTAMP_MILLIS, 0L); this.closeTimestampMillis = tempTs > 0 ? tempTs + LifecycleV2Constants.CACHE_TIMEOUT_MILLIS : tempTs; } /** * The last known close timestamp value to be updated in cache and, if needed, in persistence as * well. The write will execute after {@link LifecycleV2Constants#CACHE_TIMEOUT_MILLIS} since * last update. * * @param timestampMillis current timestamp (milliseconds) */ void setLastKnownTimestamp(final long timestampMillis) { if (dataStore != null && timestampMillis - lastClosePersistedValue >= LifecycleV2Constants.CACHE_TIMEOUT_MILLIS) { dataStore.setLong( LifecycleV2Constants.DataStoreKeys.APP_CLOSE_TIMESTAMP_MILLIS, timestampMillis); lastClosePersistedValue = timestampMillis; } } /** * Returns the approximated app close timestamp in milliseconds. This value is loaded from * persistence when {@link LifecycleV2DataStoreCache} is initialized and it includes the {@link * LifecycleV2Constants#CACHE_TIMEOUT_MILLIS} for the eventuality when the application was * closed before the last commit was executed. * * @return the last known close timestamp value or 0 if not found, for example on first launch */ long getCloseTimestampMillis() { return closeTimestampMillis; } /** * Updates the last app start timestamp in persistence. * * @param timestampMillis start timestamp (milliseconds) */ void setAppStartTimestamp(final long timestampMillis) { if (dataStore != null) { dataStore.setLong( LifecycleV2Constants.DataStoreKeys.APP_START_TIMESTAMP_MILLIS, timestampMillis); } } /** * Reads the last app start timestamp from persistence and returns the value. * * @return app start timestamp (milliseconds) or 0 if not found */ long getAppStartTimestampMillis() { return dataStore != null ? dataStore.getLong( LifecycleV2Constants.DataStoreKeys.APP_START_TIMESTAMP_MILLIS, 0L) : 0L; } /** * Updates the last app pause timestamp in persistence. * * @param timestampMillis pause timestamp (milliseconds) */ void setAppPauseTimestamp(final long timestampMillis) { if (dataStore != null) { dataStore.setLong( LifecycleV2Constants.DataStoreKeys.APP_PAUSE_TIMESTAMP_MILLIS, timestampMillis); } } /** * Reads the last pause timestamp from persistence and returns the value. * * @return app pause timestamp (milliseconds) or 0 if not found */ long getAppPauseTimestampMillis() { return dataStore != null ? dataStore.getLong( LifecycleV2Constants.DataStoreKeys.APP_PAUSE_TIMESTAMP_MILLIS, 0L) : 0L; } /** * Migrates any timestamps stored in seconds to timestamps stored in milliseconds. Removes * timestamps in seconds from persistent storage. */ private void migrateTimestampsSecToMillis() { migrateDataStoreKey( LifecycleV2Constants.DataStoreKeys.APP_START_TIMESTAMP_SEC, LifecycleV2Constants.DataStoreKeys.APP_START_TIMESTAMP_MILLIS); migrateDataStoreKey( LifecycleV2Constants.DataStoreKeys.APP_PAUSE_TIMESTAMP_SEC, LifecycleV2Constants.DataStoreKeys.APP_PAUSE_TIMESTAMP_MILLIS); migrateDataStoreKey( LifecycleV2Constants.DataStoreKeys.APP_CLOSE_TIMESTAMP_SEC, LifecycleV2Constants.DataStoreKeys.APP_CLOSE_TIMESTAMP_MILLIS); } /** * Migrate a single data store key holding a timestamp in seconds to a new key holding the same * timestamp in milliseconds. After migration, {@code keyMilliseconds} is added to the data * store while {@code keySeconds} is removed. * * @param keySeconds the data store key name holding a timestamp in seconds * @param keyMilliseconds the data store key name to add holding a timestamp in milliseconds. */ private void migrateDataStoreKey(final String keySeconds, final String keyMilliseconds) { if (dataStore == null) { return; } if (dataStore.contains(keySeconds)) { long value = dataStore.getLong(keySeconds, 0L); if (value > 0) { dataStore.setLong(keyMilliseconds, TimeUnit.SECONDS.toMillis(value)); Log.trace( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Migrated persisted '%s' to '%s'.", keySeconds, keyMilliseconds); } dataStore.remove(keySeconds); } } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/lifecycle/src/main/java/com/adobe/marketing/mobile/lifecycle/XDMLifecycleCloseTypeEnum.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.lifecycle; @SuppressWarnings("unused") enum XDMLifecycleCloseTypeEnum { CLOSE("close"), // Close UNKNOWN("unknown"); // Unknown private final String value; XDMLifecycleCloseTypeEnum(final String enumValue) { this.value = enumValue; } @Override public String toString() { return value; } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/lifecycle/src/main/java/com/adobe/marketing/mobile/lifecycle/XDMLifecycleApplication.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.lifecycle; import com.adobe.marketing.mobile.services.Log; import java.util.HashMap; import java.util.Map; /** Class {@code Application} */ @SuppressWarnings("unused") class XDMLifecycleApplication { private final String LOG_SOURCE = "XDMLifecycleApplication"; private XDMLifecycleCloseTypeEnum closeType; private String id; private boolean isClose; private boolean isInstall; private boolean isLaunch; private boolean isUpgrade; private XDMLanguage language; private String name; private int sessionLength; private String version; XDMLifecycleApplication() {} Map<String, Object> serializeToXdm() { Map<String, Object> map = new HashMap<String, Object>(); if (this.id != null) { map.put("id", this.id); } if (this.name != null) { map.put("name", this.name); } if (this.version != null) { map.put("version", this.version); } if (this.isClose) { map.put("isClose", this.isClose); } if (this.isInstall) { map.put("isInstall", this.isInstall); } if (this.isLaunch) { map.put("isLaunch", this.isLaunch); } if (this.isUpgrade) { map.put("isUpgrade", this.isUpgrade); } if (this.closeType != null) { map.put("closeType", this.closeType.toString()); } if (this.sessionLength > 0) { map.put("sessionLength", this.sessionLength); } if (this.language != null) { map.put("_dc", this.language.serializeToXdm()); } return map; } /** * Returns the CloseType property The type of the close event. A value of 'close' indicates the * application signaled the close event. A value of 'unknown' indicates the application was * launched without previously signaling it closed. * * @return {@link XDMLifecycleCloseTypeEnum} value or null if the property is not set */ XDMLifecycleCloseTypeEnum getCloseType() { return this.closeType; } /** * Sets the CloseType property The type of the close event. A value of 'close' indicates the * application signaled the close event. A value of 'unknown' indicates the application was * launched without previously signaling it closed. * * @param newValue the new CloseType value */ void setCloseType(final XDMLifecycleCloseTypeEnum newValue) { this.closeType = newValue; } /** * Returns the Application identifier property Identifier of the application. * * @return {@link String} value or null if the property is not set */ String getId() { return this.id; } /** * Sets the Application identifier property Identifier of the application. * * @param newValue the new Application identifier value */ void setId(final String newValue) { this.id = newValue; } /** * Returns the Is Close property Indicates whether or not this is an application close event. * * @return boolean value */ boolean getIsClose() { return this.isClose; } /** * Sets the Is Close property Indicates whether or not this is an application close event. * * @param newValue the new Is Close value */ void setIsClose(final boolean newValue) { this.isClose = newValue; } /** * Returns the Is Install property Indicates whether or not this is an application install * event. * * @return boolean value */ boolean getIsInstall() { return this.isInstall; } /** * Sets the Is Install property Indicates whether or not this is an application install event. * * @param newValue the new Is Install value */ void setIsInstall(final boolean newValue) { this.isInstall = newValue; } /** * Returns the Is Launch property Indicates whether or not this is an application launch event. * * @return boolean value */ boolean getIsLaunch() { return this.isLaunch; } /** * Sets the Is Launch property Indicates whether or not this is an application launch event. * * @param newValue the new Is Launch value */ void setIsLaunch(final boolean newValue) { this.isLaunch = newValue; } /** * Returns the Is Upgrade property Indicates whether or not this is an application upgrade * event. * * @return boolean value */ boolean getIsUpgrade() { return this.isUpgrade; } /** * Sets the Is Upgrade property Indicates whether or not this is an application upgrade event. * * @param newValue the new Is Upgrade value */ void setIsUpgrade(final boolean newValue) { this.isUpgrade = newValue; } /** * Returns the Language property The language of the environment to represent the user's * linguistic, geographical, or cultural preferences for data presentation. * * @return {@link String} value or null if the property is not set */ String getLanguage() { return this.language != null ? this.language.getLanguage() : null; } /** * Sets the Language property The language of the environment to represent the user's * linguistic, geographical, or cultural preferences for data presentation (according to IETF * RFC 3066). * * @param newValue the new Language value */ void setLanguage(final String newValue) { try { this.language = new XDMLanguage(newValue); } catch (IllegalArgumentException ex) { Log.warning( LifecycleConstants.LOG_TAG, LOG_SOURCE, "Language tag '%s' failed validation and will be dropped. Values for XDM" + " field 'application._dc.language' must conform to BCP 47.", newValue); } } /** * Returns the Name property Name of the application. * * @return {@link String} value or null if the property is not set */ String getName() { return this.name; } /** * Sets the Name property Name of the application. * * @param newValue the new Name value */ void setName(final String newValue) { this.name = newValue; } /** * Returns the Session Length property Reports the number of seconds that a previous application * session lasted based on how long the application was open and in the foreground. Session * length is a positive value with no max bound (no max session length) * * @return int value */ int getSessionLength() { return this.sessionLength; } /** * Sets the Session Length property Reports the number of seconds that a previous application * session lasted based on how long the application was open and in the foreground. Session * length is a positive value with no max bound (no max session length) * * @param newValue the new Session Length value */ void setSessionLength(final int newValue) { this.sessionLength = newValue; } /** * Returns the Version property Version of the application. * * @return {@link String} value or null if the property is not set */ String getVersion() { return this.version; } /** * Sets the Version property Version of the application. * * @param newValue the new Version value */ void setVersion(final String newValue) { this.version = newValue; } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/lifecycle/src/main/java/com/adobe/marketing/mobile/lifecycle/XDMLifecycleMobileDetails.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.lifecycle; import java.util.HashMap; import java.util.Map; /** This class is intended to be used by the {@link LifecycleV2Extension}. */ @SuppressWarnings("unused") class XDMLifecycleMobileDetails { private XDMLifecycleApplication application; private XDMLifecycleDevice device; private XDMLifecycleEnvironment environment; private String eventType; private java.util.Date timestamp; XDMLifecycleMobileDetails() {} Map<String, Object> serializeToXdm() { Map<String, Object> map = new HashMap<String, Object>(); if (this.application != null) { final Map<String, Object> applicationData = this.application.serializeToXdm(); if (applicationData != null && !applicationData.isEmpty()) { map.put("application", applicationData); } } if (this.device != null) { final Map<String, Object> deviceData = this.device.serializeToXdm(); if (deviceData != null && !deviceData.isEmpty()) { map.put("device", deviceData); } } if (this.environment != null) { final Map<String, Object> environmentData = this.environment.serializeToXdm(); if (environmentData != null && !environmentData.isEmpty()) { map.put("environment", environmentData); } } if (this.eventType != null) { map.put("eventType", this.eventType); } if (this.timestamp != null) { map.put("timestamp", LifecycleUtil.dateTimeISO8601String(this.timestamp)); } return map; } /** * Returns the Application property * * @return {@link XDMLifecycleApplication} value or null if the property is not set */ XDMLifecycleApplication getApplication() { return this.application; } /** * Sets the Application property * * @param newValue the new Application value */ void setApplication(final XDMLifecycleApplication newValue) { this.application = newValue; } /** * Returns the Device property An identified device, application or device browser instance that * is trackable across sessions, normally by cookies. * * @return {@link XDMLifecycleDevice} value or null if the property is not set */ XDMLifecycleDevice getDevice() { return this.device; } /** * Sets the Device property An identified device, application or device browser instance that is * trackable across sessions, normally by cookies. * * @param newValue the new Device value */ void setDevice(final XDMLifecycleDevice newValue) { this.device = newValue; } /** * Returns the Environment property Information about the surrounding situation the event * observation occurred in, specifically detailing transitory information such as the network or * software versions. * * @return {@link XDMLifecycleEnvironment} value or null if the property is not set */ XDMLifecycleEnvironment getEnvironment() { return this.environment; } /** * Sets the Environment property Information about the surrounding situation the event * observation occurred in, specifically detailing transitory information such as the network or * software versions. * * @param newValue the new Environment value */ void setEnvironment(final XDMLifecycleEnvironment newValue) { this.environment = newValue; } /** * Returns the Event Type property The primary event type for this time-series record. * * @return {@link String} value or null if the property is not set */ String getEventType() { return this.eventType; } /** * Sets the Event Type property The primary event type for this time-series record. * * @param newValue the new Event Type value */ void setEventType(final String newValue) { this.eventType = newValue; } /** * Returns the Timestamp property The time when an event or observation occurred. * * @return {@link java.util.Date} value or null if the property is not set */ java.util.Date getTimestamp() { return this.timestamp; } /** * Sets the Timestamp property The time when an event or observation occurred. * * @param newValue the new Timestamp value */ void setTimestamp(final java.util.Date newValue) { this.timestamp = newValue; } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/lifecycle/src/main/java/com/adobe/marketing/mobile/lifecycle/XDMLifecycleEnvironment.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.lifecycle; import com.adobe.marketing.mobile.services.Log; import java.util.HashMap; import java.util.Map; /** * Class {@code Environment} representing a subset of the XDM Environment data type fields. * Information about the surrounding situation the event observation occurred in, specifically * detailing transitory information such as the network or software versions. */ @SuppressWarnings("unused") class XDMLifecycleEnvironment { private final String LOG_SOURCE = "XDMLifecycleEnvironment"; private String carrier; private XDMLanguage language; private String operatingSystem; private String operatingSystemVersion; private XDMLifecycleEnvironmentTypeEnum type; XDMLifecycleEnvironment() {} Map<String, Object> serializeToXdm() { Map<String, Object> map = new HashMap<String, Object>(); if (this.carrier != null) { map.put("carrier", this.carrier); } if (this.language != null) { map.put("_dc", this.language.serializeToXdm()); } if (this.operatingSystem != null) { map.put("operatingSystem", this.operatingSystem); } if (this.operatingSystemVersion != null) { map.put("operatingSystemVersion", this.operatingSystemVersion); } if (this.type != null) { map.put("type", this.type.toString()); } return map; } /** * Returns the Mobile network carrier property A mobile network carrier or MNO, also known as a * wireless service provider, wireless carrier, cellular company, or mobile network carrier, is * a provider of services wireless communications that owns or controls all the elements * necessary to sell and deliver services to an end user. * * @return {@link String} value or null if the property is not set */ String getCarrier() { return this.carrier; } /** * Sets the Mobile network carrier property A mobile network carrier or MNO, also known as a * wireless service provider, wireless carrier, cellular company, or mobile network carrier, is * a provider of services wireless communications that owns or controls all the elements * necessary to sell and deliver services to an end user. * * @param newValue the new Mobile network carrier value */ void setCarrier(final String newValue) { this.carrier = newValue; } /** * Returns the Language property The language of the environment to represent the user's * linguistic, geographical, or cultural preferences for data presentation. * * @return {@link String} value or null if the property is not set */ String getLanguage() { return this.language != null ? this.language.getLanguage() : null; } /** * Sets the Language property The language of the environment to represent the user's * linguistic, geographical, or cultural preferences for data presentation (according to IETF * RFC 3066). * * @param newValue the new Language value */ void setLanguage(final String newValue) { try { this.language = new XDMLanguage(newValue); } catch (IllegalArgumentException ex) { Log.warning( LifecycleConstants.LOG_TAG, LOG_SOURCE, "Language tag '%s' failed validation and will be dropped. Values for XDM" + " field 'environment._dc.language' must conform to BCP 47.", newValue); } } /** * Returns the Operating system property The name of the operating system used when the * observation was made. The attribute should not contain any version information such as * '10.5.3', but instead contain 'edition' designations such as 'Ultimate' or 'Professional'. * * @return {@link String} value or null if the property is not set */ String getOperatingSystem() { return this.operatingSystem; } /** * Sets the Operating system property The name of the operating system used when the observation * was made. The attribute should not contain any version information such as '10.5.3', but * instead contain 'edition' designations such as 'Ultimate' or 'Professional'. * * @param newValue the new Operating system value */ void setOperatingSystem(final String newValue) { this.operatingSystem = newValue; } /** * Returns the Operating system version property The full version identifier for the operating * system used when the observation was made. Versions are generally numerically composed but * may be in a vendor defined format. * * @return {@link String} value or null if the property is not set */ String getOperatingSystemVersion() { return this.operatingSystemVersion; } /** * Sets the Operating system version property The full version identifier for the operating * system used when the observation was made. Versions are generally numerically composed but * may be in a vendor defined format. * * @param newValue the new Operating system version value */ void setOperatingSystemVersion(final String newValue) { this.operatingSystemVersion = newValue; } /** * Returns the Type property The type of the application environment. * * @return {@link XDMLifecycleEnvironmentTypeEnum} value or null if the property is not set */ XDMLifecycleEnvironmentTypeEnum getType() { return this.type; } /** * Sets the Type property The type of the application environment. * * @param newValue the new Type value */ void setType(final XDMLifecycleEnvironmentTypeEnum newValue) { this.type = newValue; } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/lifecycle/src/main/java/com/adobe/marketing/mobile/lifecycle/LifecycleSession.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.lifecycle; import com.adobe.marketing.mobile.lifecycle.LifecycleConstants.DataStoreKeys; import com.adobe.marketing.mobile.services.Log; import com.adobe.marketing.mobile.services.NamedCollection; import java.util.HashMap; import java.util.Map; /** * Class for managing lifecycle sessions for standard, non-XDM scenarios. Persists start, pause, and * end timestamps for lifecycle sessions. Also generates session context data for Analytics * reporting */ class LifecycleSession { private static final String SELF_LOG_TAG = "LifecycleSession"; private final NamedCollection dataStore; private boolean lifecycleHasRun; LifecycleSession(final NamedCollection dataStore) { this.dataStore = dataStore; } /** * Start a new lifecycle session. Returns a SessionInfo object containing the previous session's * data if it is a new session Returns null if the previous session is resumed, or if lifecycle * has already run * * @param startTimestampInSeconds long session start time (in seconds) * @param sessionTimeoutInSeconds int session timeout (in seconds) * @param coreData core data generated from LifecycleMetricsBuilder * @return SessionInfo object containing previous session's data */ SessionInfo start( final long startTimestampInSeconds, final long sessionTimeoutInSeconds, final Map<String, String> coreData) { if (lifecycleHasRun) { return null; } if (dataStore == null) { Log.debug( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Failed to start session, %s (persisted data)", Log.UNEXPECTED_NULL_VALUE); return null; } lifecycleHasRun = true; final long previousSessionStartTimeInSeconds = dataStore.getLong(DataStoreKeys.START_DATE, 0L); final long previousSessionPauseTimeInSeconds = dataStore.getLong(DataStoreKeys.PAUSE_DATE, 0L); final boolean previousSessionCrashed = !dataStore.getBoolean(DataStoreKeys.SUCCESSFUL_CLOSE, true); // if we have a pause date, check to see if pausedTime is less than the session timeout // threshold if (previousSessionPauseTimeInSeconds > 0) { final long pausedTimeInSecond = startTimestampInSeconds - previousSessionPauseTimeInSeconds; if (pausedTimeInSecond < sessionTimeoutInSeconds && previousSessionStartTimeInSeconds > 0) { // handle sessions that did not time out by removing paused time from session // do this by adding the paused time the session start time dataStore.setLong( DataStoreKeys.START_DATE, previousSessionStartTimeInSeconds + pausedTimeInSecond); // clear lifecycle flags dataStore.setBoolean(DataStoreKeys.SUCCESSFUL_CLOSE, false); dataStore.remove(DataStoreKeys.PAUSE_DATE); return null; } } dataStore.setLong(DataStoreKeys.START_DATE, startTimestampInSeconds); dataStore.remove(DataStoreKeys.PAUSE_DATE); dataStore.setBoolean(DataStoreKeys.SUCCESSFUL_CLOSE, false); final int launches = dataStore.getInt(DataStoreKeys.LAUNCHES, 0) + 1; dataStore.setInt(DataStoreKeys.LAUNCHES, launches); dataStore.setString( DataStoreKeys.OS_VERSION, coreData.get(LifecycleConstants.EventDataKeys.Lifecycle.OPERATING_SYSTEM)); dataStore.setString( DataStoreKeys.APP_ID, coreData.get(LifecycleConstants.EventDataKeys.Lifecycle.APP_ID)); Log.trace(LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "New lifecycle session started"); return new SessionInfo( previousSessionStartTimeInSeconds, previousSessionPauseTimeInSeconds, previousSessionCrashed); } /** * Pause current lifecycle session * * @param pauseTimestampInSeconds pause timestamp (in seconds) */ void pause(final long pauseTimestampInSeconds) { if (dataStore == null) { Log.debug( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Failed to pause session, %s (persisted data)", Log.UNEXPECTED_NULL_VALUE); return; } dataStore.setBoolean(DataStoreKeys.SUCCESSFUL_CLOSE, true); dataStore.setLong(DataStoreKeys.PAUSE_DATE, pauseTimestampInSeconds); Log.trace(LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Lifecycle session paused"); // reset lifecycle flag lifecycleHasRun = false; } /** * Gets session length data (used for Analytics reporting) * * @param startTimestampInSeconds session start timestamp (in seconds) * @param sessionTimeoutInSeconds session timeout (in seconds) * @param previousSessionInfo SessionInfo object containing previous session's data * @return {@code Map<String, String>} session length context data */ Map<String, String> getSessionData( final long startTimestampInSeconds, final long sessionTimeoutInSeconds, final LifecycleSession.SessionInfo previousSessionInfo) { Map<String, String> sessionContextData = new HashMap<>(); if (dataStore == null) { Log.debug( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "%s (data store), Failed to get session length data", Log.UNEXPECTED_NULL_VALUE); return sessionContextData; } if (previousSessionInfo == null) { Log.debug( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "%s (previous session info), Failed to get session length data", Log.UNEXPECTED_NULL_VALUE); return sessionContextData; } final long timeSincePauseInSeconds = startTimestampInSeconds - previousSessionInfo.getPauseTimestampInSeconds(); final long lastSessionTimeSeconds = previousSessionInfo.getPauseTimestampInSeconds() - previousSessionInfo.getStartTimestampInSeconds(); // if we have not exceeded our timeout, bail if (timeSincePauseInSeconds < sessionTimeoutInSeconds) { return sessionContextData; } // verify our session time is valid if (lastSessionTimeSeconds > 0 && lastSessionTimeSeconds < LifecycleConstants.MAX_SESSION_LENGTH_SECONDS) { sessionContextData.put( LifecycleConstants.EventDataKeys.Lifecycle.PREVIOUS_SESSION_LENGTH, Long.toString(lastSessionTimeSeconds)); } else { // data is out of bounds, still record it in context data but put it in a different key sessionContextData.put( LifecycleConstants.EventDataKeys.Lifecycle.IGNORED_SESSION_LENGTH, Long.toString(lastSessionTimeSeconds)); } return sessionContextData; } /** Container for lifecycle session information */ static class SessionInfo { private final long startTimestampInSeconds; private final long pauseTimestampInSeconds; private final boolean isCrash; SessionInfo( final long startTimestampInSeconds, final long pauseTimestampInSeconds, final boolean isCrash) { this.startTimestampInSeconds = startTimestampInSeconds; this.pauseTimestampInSeconds = pauseTimestampInSeconds; this.isCrash = isCrash; } long getStartTimestampInSeconds() { return startTimestampInSeconds; } long getPauseTimestampInSeconds() { return pauseTimestampInSeconds; } boolean isCrash() { return isCrash; } } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/lifecycle/src/main/java/com/adobe/marketing/mobile/lifecycle/LifecycleMetricsBuilder.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.lifecycle; import com.adobe.marketing.mobile.services.DeviceInforming; import com.adobe.marketing.mobile.services.Log; import com.adobe.marketing.mobile.services.NamedCollection; import com.adobe.marketing.mobile.util.StringUtils; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.TimeUnit; /** * LifecycleMetricsBuilder * * <p>The responsibility of LifecycleMetrics Builder is to build a map that contains the various * pieces of lifecycle data. This builder has the ability to add all install, launch, and upgrade * data to this map and return it when build method is called. */ final class LifecycleMetricsBuilder { private static final String SELF_LOG_TAG = "LifecycleMetricsBuilder"; private final DateFormat sdfDate = new SimpleDateFormat("M/d/yyyy", Locale.US); private final Map<String, String> lifecycleData; private final DeviceInforming deviceInfoService; private final NamedCollection lifecycleDataStore; private final long timestampInSeconds; LifecycleMetricsBuilder( final DeviceInforming deviceInfoService, final NamedCollection dataStore, final long timestampInSeconds) { this.lifecycleData = new HashMap<>(); this.deviceInfoService = deviceInfoService; this.lifecycleDataStore = dataStore; this.timestampInSeconds = timestampInSeconds; if (dataStore == null) { Log.debug( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "%s (Data Store), while creating LifecycleExtension Metrics Builder.", Log.UNEXPECTED_NULL_VALUE); } if (deviceInfoService == null) { Log.debug( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "%s (Device Info Services), while creating LifecycleExtension Metrics Builder", Log.UNEXPECTED_NULL_VALUE); } } /** * Returns the context data map that was built * * @return the context data map that was built */ Map<String, String> build() { return lifecycleData; } /** * Adds all install data key value pairs to the lifecycle data map and updates the install date * in persistence * * @return the builder itself */ LifecycleMetricsBuilder addInstallData() { Log.trace( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Adding install data to lifecycle data map"); lifecycleData.put( LifecycleConstants.EventDataKeys.Lifecycle.DAILY_ENGAGED_EVENT, LifecycleConstants.ContextDataValues.DAILY_ENG_USER_EVENT); lifecycleData.put( LifecycleConstants.EventDataKeys.Lifecycle.MONTHLY_ENGAGED_EVENT, LifecycleConstants.ContextDataValues.MONTHLY_ENG_USER_EVENT); lifecycleData.put( LifecycleConstants.EventDataKeys.Lifecycle.INSTALL_EVENT, LifecycleConstants.ContextDataValues.INSTALL_EVENT); lifecycleData.put( LifecycleConstants.EventDataKeys.Lifecycle.INSTALL_DATE, stringFromTimestamp(timestampInSeconds)); return this; } /** * Adds all launch data key value pairs to the lifecycle data map * * @return the builder itself */ LifecycleMetricsBuilder addLaunchData() { Log.trace( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Adding launch data to the lifecycle data map"); if (lifecycleDataStore == null) { return this; } long lastLaunchDate = lifecycleDataStore.getLong(LifecycleConstants.DataStoreKeys.LAST_USED_DATE, 0); long firstLaunchDate = lifecycleDataStore.getLong(LifecycleConstants.DataStoreKeys.INSTALL_DATE, 0); Calendar calendarCurrentTimestamp = calendarFromTimestampInSeconds(timestampInSeconds); Calendar calendarPersistedTimestamp = calendarFromTimestampInSeconds(lastLaunchDate); int daysSinceLastUse = calculateDaysBetween(lastLaunchDate, timestampInSeconds); int daysSinceFirstUse = calculateDaysBetween(firstLaunchDate, timestampInSeconds); if (calendarCurrentTimestamp.get(Calendar.MONTH) != calendarPersistedTimestamp.get(Calendar.MONTH) || calendarCurrentTimestamp.get(Calendar.YEAR) != calendarPersistedTimestamp.get(Calendar.YEAR)) { lifecycleData.put( LifecycleConstants.EventDataKeys.Lifecycle.DAILY_ENGAGED_EVENT, LifecycleConstants.ContextDataValues.DAILY_ENG_USER_EVENT); lifecycleData.put( LifecycleConstants.EventDataKeys.Lifecycle.MONTHLY_ENGAGED_EVENT, LifecycleConstants.ContextDataValues.MONTHLY_ENG_USER_EVENT); } else if (calendarCurrentTimestamp.get(Calendar.DAY_OF_MONTH) != calendarPersistedTimestamp.get(Calendar.DAY_OF_MONTH)) { lifecycleData.put( LifecycleConstants.EventDataKeys.Lifecycle.DAILY_ENGAGED_EVENT, LifecycleConstants.ContextDataValues.DAILY_ENG_USER_EVENT); } if (daysSinceLastUse >= 0) { lifecycleData.put( LifecycleConstants.EventDataKeys.Lifecycle.DAYS_SINCE_LAST_LAUNCH, Integer.toString(daysSinceLastUse)); } if (daysSinceFirstUse >= 0) { lifecycleData.put( LifecycleConstants.EventDataKeys.Lifecycle.DAYS_SINCE_FIRST_LAUNCH, Integer.toString(daysSinceFirstUse)); } return this; } /** * Adds all generic data key value pairs to the lifecycle data map (e.g. day of week, hour of * day, no of launches) * * @return the builder itself */ LifecycleMetricsBuilder addGenericData() { Log.trace( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Adding generic data to the lifecycle data map"); if (lifecycleDataStore != null) { int launches = lifecycleDataStore.getInt(LifecycleConstants.DataStoreKeys.LAUNCHES, -1); if (launches != -1) { lifecycleData.put( LifecycleConstants.EventDataKeys.Lifecycle.LAUNCHES, Integer.toString(launches)); } } Calendar calendarCurrentTimestamp = calendarFromTimestampInSeconds(timestampInSeconds); // first day of week is Sunday, days will have indexes [1-7] lifecycleData.put( LifecycleConstants.EventDataKeys.Lifecycle.DAY_OF_WEEK, Integer.toString(calendarCurrentTimestamp.get(Calendar.DAY_OF_WEEK))); lifecycleData.put( LifecycleConstants.EventDataKeys.Lifecycle.HOUR_OF_DAY, Integer.toString(calendarCurrentTimestamp.get(Calendar.HOUR_OF_DAY))); lifecycleData.put( LifecycleConstants.EventDataKeys.Lifecycle.LAUNCH_EVENT, LifecycleConstants.ContextDataValues.LAUNCH_EVENT); return this; } /** * Adds all upgrade data key value pairs to the lifecycle data map if upgrade parameter is true * * @param upgrade boolean specifying if this was an upgrade or not * @return the builder itself */ LifecycleMetricsBuilder addUpgradeData(final boolean upgrade) { Log.trace( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Adding upgrade data to lifecycle data map"); if (upgrade) { lifecycleData.put( LifecycleConstants.EventDataKeys.Lifecycle.UPGRADE_EVENT, LifecycleConstants.ContextDataValues.UPGRADE_EVENT); } if (lifecycleDataStore == null) { return this; } long upgradeDate = lifecycleDataStore.getLong(LifecycleConstants.DataStoreKeys.UPGRADE_DATE, 0L); if (upgrade) { lifecycleDataStore.setLong( LifecycleConstants.DataStoreKeys.UPGRADE_DATE, timestampInSeconds); lifecycleDataStore.setInt(LifecycleConstants.DataStoreKeys.LAUNCHES_AFTER_UPGRADE, 0); } else if (upgradeDate > 0) { int daysSinceUpgrade = calculateDaysBetween(upgradeDate, timestampInSeconds); int launchesAfterUpgrade = lifecycleDataStore.getInt( LifecycleConstants.DataStoreKeys.LAUNCHES_AFTER_UPGRADE, 0) + 1; lifecycleDataStore.setInt( LifecycleConstants.DataStoreKeys.LAUNCHES_AFTER_UPGRADE, launchesAfterUpgrade); lifecycleData.put( LifecycleConstants.EventDataKeys.Lifecycle.LAUNCHES_SINCE_UPGRADE, Integer.toString(launchesAfterUpgrade)); if (daysSinceUpgrade >= 0) { lifecycleData.put( LifecycleConstants.EventDataKeys.Lifecycle.DAYS_SINCE_LAST_UPGRADE, Integer.toString(daysSinceUpgrade)); } } return this; } /** * Adds crash info to the lifecycle data map if previousSessionCrash is true * * @param previousSessionCrash specifies if there was a crash in the previous session * @return the builder itself */ LifecycleMetricsBuilder addCrashData(final boolean previousSessionCrash) { Log.trace( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Adding crash data to lifecycle data map"); if (previousSessionCrash) { lifecycleData.put( LifecycleConstants.EventDataKeys.Lifecycle.CRASH_EVENT, LifecycleConstants.ContextDataValues.CRASH_EVENT); } return this; } /** * Adds all core data key value pairs to the lifecycle data map. If some of the values are null, * the corresponding keys will not be added in the lifecycle data map. * * @return the builder itself */ LifecycleMetricsBuilder addCoreData() { Log.trace( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Adding core data to lifecycle data map"); if (deviceInfoService == null) { return this; } final String deviceName = deviceInfoService.getDeviceName(); if (!StringUtils.isNullOrEmpty(deviceName)) { lifecycleData.put(LifecycleConstants.EventDataKeys.Lifecycle.DEVICE_NAME, deviceName); } final String carrierName = deviceInfoService.getMobileCarrierName(); if (!StringUtils.isNullOrEmpty(carrierName)) { lifecycleData.put(LifecycleConstants.EventDataKeys.Lifecycle.CARRIER_NAME, carrierName); } final String appId = getApplicationIdentifier(); if (!StringUtils.isNullOrEmpty(appId)) { lifecycleData.put(LifecycleConstants.EventDataKeys.Lifecycle.APP_ID, appId); } final String operatingSystem = deviceInfoService.getOperatingSystemName() + " " + deviceInfoService.getOperatingSystemVersion(); if (!StringUtils.isNullOrEmpty(operatingSystem)) { lifecycleData.put( LifecycleConstants.EventDataKeys.Lifecycle.OPERATING_SYSTEM, operatingSystem); } final String resolution = getResolution(); if (!StringUtils.isNullOrEmpty(resolution)) { lifecycleData.put( LifecycleConstants.EventDataKeys.Lifecycle.DEVICE_RESOLUTION, resolution); } final String locale = LifecycleUtil.formatLocale(deviceInfoService.getActiveLocale()); if (!StringUtils.isNullOrEmpty(locale)) { lifecycleData.put(LifecycleConstants.EventDataKeys.Lifecycle.LOCALE, locale); } final String systemLocale = LifecycleUtil.formatLocale(deviceInfoService.getSystemLocale()); if (!StringUtils.isNullOrEmpty(systemLocale)) { lifecycleData.put( LifecycleConstants.EventDataKeys.Lifecycle.SYSTEM_LOCALE, systemLocale); } final String runMode = deviceInfoService.getRunMode(); if (!StringUtils.isNullOrEmpty(runMode)) { lifecycleData.put(LifecycleConstants.EventDataKeys.Lifecycle.RUN_MODE, runMode); } return this; } /** * Calculates the number of days between two times provided * * @param startTimestampInSeconds the starting date * @param endTimestampInSeconds the end date * @return the resulted number of days */ private int calculateDaysBetween( final long startTimestampInSeconds, final long endTimestampInSeconds) { if (startTimestampInSeconds < LifecycleConstants.WRONG_EPOCH_MAX_LENGTH_SECONDS || endTimestampInSeconds < LifecycleConstants.WRONG_EPOCH_MAX_LENGTH_SECONDS) { Log.debug( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Invalid timestamp - startTimestampInSeconds (%d), endTimestampInSeconds (%d)", startTimestampInSeconds, endTimestampInSeconds); return -1; } Calendar calendarStartDate = calendarFromTimestampInSeconds(startTimestampInSeconds); Calendar calendarEndDate = calendarFromTimestampInSeconds(endTimestampInSeconds); int yearsDifference = calendarEndDate.get(Calendar.YEAR) - calendarStartDate.get(Calendar.YEAR); int daysDifference = calendarEndDate.get(Calendar.DAY_OF_YEAR) - calendarStartDate.get(Calendar.DAY_OF_YEAR); int startYear = calendarStartDate.get(Calendar.YEAR); int endYear = calendarEndDate.get(Calendar.YEAR); if (yearsDifference == 0) { return daysDifference; } else { int daysInYearsDifference = 0; final int leapYearDays = 366; final int otherYearDays = 365; GregorianCalendar gregorianCalendar = new GregorianCalendar(); for (int year = startYear; year < endYear; year++) { if (gregorianCalendar.isLeapYear(year)) { daysInYearsDifference += leapYearDays; } else { daysInYearsDifference += otherYearDays; } } return daysDifference + daysInYearsDifference; } } private Calendar calendarFromTimestampInSeconds(final long timestampInSeconds) { Calendar calendarStartDate = Calendar.getInstance(); calendarStartDate.setTimeInMillis(TimeUnit.SECONDS.toMillis(timestampInSeconds)); return calendarStartDate; } private String stringFromTimestamp(final long timestampInSeconds) { synchronized (sdfDate) { return sdfDate.format(TimeUnit.SECONDS.toMillis(timestampInSeconds)); } } /** * Generates the Application ID string from Application name, version and version code * * @return string representation of the Application ID */ private String getApplicationIdentifier() { if (deviceInfoService == null) { return null; } final String applicationName = deviceInfoService.getApplicationName(); final String applicationVersion = deviceInfoService.getApplicationVersion(); final String applicationVersionCode = deviceInfoService.getApplicationVersionCode(); return String.format( "%s%s%s", applicationName, !StringUtils.isNullOrEmpty(applicationVersion) ? String.format(" %s", applicationVersion) : "", !StringUtils.isNullOrEmpty(applicationVersionCode) ? String.format(" (%s)", applicationVersionCode) : ""); } /** * Generates the resolution string from DisplayInformationInterface * * @return string representation of the resolution */ private String getResolution() { if (deviceInfoService == null) { return null; } DeviceInforming.DisplayInformation displayInfo = deviceInfoService.getDisplayInformation(); if (displayInfo == null) { Log.debug( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Failed to get resolution %s for DisplayInformation", Log.UNEXPECTED_NULL_VALUE); return null; } return String.format( Locale.US, "%dx%d", displayInfo.getWidthPixels(), displayInfo.getHeightPixels()); } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/lifecycle/src/main/java/com/adobe/marketing/mobile/lifecycle/LifecycleV2StateManager.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.lifecycle; import com.adobe.marketing.mobile.AdobeCallback; import com.adobe.marketing.mobile.services.Log; /** * Manager for current app session state updates for the XDM scenario based on the start/pause * Lifecycle events. For standard, non-XDM scenarios, see {@link LifecycleSession}. */ class LifecycleV2StateManager { private static final String SELF_LOG_TAG = "LifecycleV2StateManager"; // timer used for waiting for pause-start consecutive updates, which can be encountered while // tracking // the app lifecycle background/foreground changes. private final LifecycleTimerState updateTimer; // protects concurrent access to updateTimer and state related params private final Object stateUpdatesMutex = new Object(); private State currentState; private AdobeCallback<Boolean> cancelableCallback; enum State { START("start"), PAUSE("pause"); private final String value; State(final String value) { this.value = value; } } LifecycleV2StateManager() { this.updateTimer = new LifecycleTimerState("ADBLifecycleStateManager"); } /** * Updates {@code currentState} if needed and returns the status of the update operation through * the provided callback. * * <p>Expected scenarios: If this is the first start update in the session, the state gets * updated immediately. If this is a start -> pause update, a timer of {@link * LifecycleV2Constants#STATE_UPDATE_TIMEOUT_MILLIS} will start to wait for any other immediate * updates (start/pause) that would indicate the session is not over yet. If an update is * received before the timer expired: * * <ul> * <li>start - would cancel the timer and ignore the update (session continues) * <li>pause - would reset the timer as the session should end based on the last pause update * </ul> * * If no other update is received the pause update is marked as completed. * * <p>Consecutive start updates are being ignored as the session continues. * * @param newState (required) the new state that needs to be updated * @param callback (required) completion callback to be invoked with the status of the update * once the operation is complete */ void updateState(final State newState, final AdobeCallback<Boolean> callback) { if (callback == null || newState == null) { return; } synchronized (stateUpdatesMutex) { if (updateTimer.isTimerRunning()) { if (State.START.equals(newState)) { Log.trace( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Consecutive pause-start state update detected, ignoring."); cancelTimer(); callback.call(false); } else if (State.PAUSE.equals(newState)) { Log.trace( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "New pause state update received while waiting, restarting the count."); restartTimer(newState, callback); } return; } if (this.currentState == newState) { Log.trace( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Consecutive %s state update received, ignoring.", currentState); callback.call(false); return; } if (State.PAUSE.equals(newState)) { Log.trace( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "New pause state update received, waiting for %s (ms) before updating.", LifecycleV2Constants.STATE_UPDATE_TIMEOUT_MILLIS); startTimer(newState, callback); } else { Log.trace( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "New start state update received."); currentState = newState; callback.call(true); } } } /** * Starts the {@code updateTimer} with the new state. * * @param newState (required) the new state that needs to be updated * @param callback (required) completion callback to be invoked with the status of the update * once the operation is complete */ private void startTimer(final State newState, final AdobeCallback<Boolean> callback) { cancelableCallback = callback; updateTimer.startTimer( LifecycleV2Constants.STATE_UPDATE_TIMEOUT_MILLIS, complete -> { // no other event interrupted this timer, proceed with processing the new state synchronized (stateUpdatesMutex) { currentState = newState; updateTimer.cancel(); callback.call(true); cancelableCallback = null; } }); } /** * Cancels and restarts the {@code updateTimer} with the new state. * * @param newState (required) the new state that needs to be updated * @param callback (required) completion callback to be invoked with the status of the update * once the operation is complete */ private void restartTimer(final State newState, final AdobeCallback<Boolean> callback) { cancelTimer(); startTimer(newState, callback); } /** * Cancels the running {@code updateTimer} and calls the cancelable callback with false if * needed. */ private void cancelTimer() { if (cancelableCallback != null) { cancelableCallback.call(false); cancelableCallback = null; } updateTimer.cancel(); } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/lifecycle/src/main/java/com/adobe/marketing/mobile/lifecycle/LifecycleExtension.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.lifecycle; import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; import com.adobe.marketing.mobile.Event; import com.adobe.marketing.mobile.EventSource; import com.adobe.marketing.mobile.EventType; import com.adobe.marketing.mobile.Extension; import com.adobe.marketing.mobile.ExtensionApi; import com.adobe.marketing.mobile.Lifecycle; import com.adobe.marketing.mobile.SharedStateResolution; import com.adobe.marketing.mobile.SharedStateResult; import com.adobe.marketing.mobile.SharedStateStatus; import com.adobe.marketing.mobile.services.DeviceInforming; import com.adobe.marketing.mobile.services.Log; import com.adobe.marketing.mobile.services.NamedCollection; import com.adobe.marketing.mobile.services.ServiceProvider; import com.adobe.marketing.mobile.util.DataReader; import java.util.Map; /** * LifecycleExtension class * * <p>The responsibility of LifecycleExtension is to handle the calculation and population of a base * set of data within the SDK. This data will consist of information about the lifecycle of the app * involving launches, installs and upgrades. * * <p>This extension handles two main scenarios: * * <ul> * <li>Computing standard lifecycle sessions, usually consumed by the Analytics extension * <li>Computing the application launch/close XDM metrics, usually consumed by the Edge Network * and related extensions * </ul> */ public class LifecycleExtension extends Extension { private static final String SELF_LOG_TAG = "LifecycleExtension"; private final NamedCollection lifecycleDataStore; private final LifecycleV1Extension lifecycleV1; private final LifecycleV2Extension lifecycleV2; /** * Constructor for the LifecycleExtension, must be called by inheritors. It is called by the * Mobile SDK when registering the extension and it initializes the extension and registers * event listeners. * * @param extensionApi {@code ExtensionApi} instance */ protected LifecycleExtension(final ExtensionApi extensionApi) { this( extensionApi, ServiceProvider.getInstance() .getDataStoreService() .getNamedCollection(LifecycleConstants.DATA_STORE_NAME), ServiceProvider.getInstance().getDeviceInfoService()); } /** * This constructor is intended for testing purposes. * * @param extensionApi {@code ExtensionApi} instance * @param namedCollection {@code NamedCollection} instance * @param deviceInfoService {@code DeviceInforming} instance */ @VisibleForTesting protected LifecycleExtension( final ExtensionApi extensionApi, final NamedCollection namedCollection, final DeviceInforming deviceInfoService) { this( extensionApi, namedCollection, new LifecycleV1Extension(namedCollection, deviceInfoService, extensionApi), new LifecycleV2Extension(namedCollection, deviceInfoService, extensionApi)); } /** * This constructor is intended for testing purposes. * * @param extensionApi {@code ExtensionApi} instance * @param namedCollection {@code NamedCollection} instance * @param lifecycleV1Extension {@code LifecycleV1Extension} instance * @param lifecycleV2Extension {@code LifecycleV2Extension} instance */ @VisibleForTesting protected LifecycleExtension( final ExtensionApi extensionApi, final NamedCollection namedCollection, final LifecycleV1Extension lifecycleV1Extension, final LifecycleV2Extension lifecycleV2Extension) { super(extensionApi); lifecycleDataStore = namedCollection; lifecycleV1 = lifecycleV1Extension; lifecycleV2 = lifecycleV2Extension; } @NonNull @Override protected String getName() { return LifecycleConstants.EventDataKeys.Lifecycle.MODULE_NAME; } @Override protected String getVersion() { return Lifecycle.extensionVersion(); } @Override protected String getFriendlyName() { return LifecycleConstants.FRIENDLY_NAME; } @Override protected void onRegistered() { getApi().registerEventListener( EventType.GENERIC_LIFECYCLE, EventSource.REQUEST_CONTENT, this::handleLifecycleRequestEvent); getApi().registerEventListener( EventType.WILDCARD, EventSource.WILDCARD, this::updateLastKnownTimestamp); lifecycleV1.onRegistered(); } @Override public boolean readyForEvent(final Event event) { if (event.getType().equalsIgnoreCase(EventType.GENERIC_LIFECYCLE) && event.getSource().equalsIgnoreCase(EventSource.REQUEST_CONTENT)) { SharedStateResult configurationSharedState = getApi().getSharedState( LifecycleConstants.EventDataKeys.Configuration.MODULE_NAME, event, false, SharedStateResolution.ANY); return configurationSharedState != null && configurationSharedState.getStatus() == SharedStateStatus.SET; } return true; } /** * Processes an event of type generic lifecycle and source request content * * @param event lifecycle request content {@code Event} */ void handleLifecycleRequestEvent(final Event event) { SharedStateResult configurationSharedState = getApi().getSharedState( LifecycleConstants.EventDataKeys.Configuration.MODULE_NAME, event, false, SharedStateResolution.ANY); if (configurationSharedState == null || configurationSharedState.getStatus() == SharedStateStatus.PENDING) { Log.trace( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Waiting for configuration to process lifecycle request event"); return; } Map<String, Object> eventData = event.getEventData(); if (eventData == null) { Log.trace( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Failed to process lifecycle event '%s for event data'", Log.UNEXPECTED_NULL_VALUE); return; } String lifecycleAction = DataReader.optString( eventData, LifecycleConstants.EventDataKeys.Lifecycle.LIFECYCLE_ACTION_KEY, ""); if (LifecycleConstants.EventDataKeys.Lifecycle.LIFECYCLE_START.equals(lifecycleAction)) { Log.debug(LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Starting lifecycle"); startApplicationLifecycle(event, configurationSharedState.getValue()); } else if (LifecycleConstants.EventDataKeys.Lifecycle.LIFECYCLE_PAUSE.equals( lifecycleAction)) { Log.debug(LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Pausing lifecycle"); pauseApplicationLifecycle(event); } else { Log.warning( LifecycleConstants.LOG_TAG, SELF_LOG_TAG, "Invalid action for lifecycle request event"); } } /** * Updates the last known event timestamp in cache and if needed in persistence * * @param event to be processed; should not be null */ void updateLastKnownTimestamp(final Event event) { lifecycleV2.updateLastKnownTimestamp(event); } /** * Start the lifecycle session for standard and XDM workflows * * @param event current lifecycle request event with start action * @param configurationSharedState configuration shared state data for this event */ private void startApplicationLifecycle( final Event event, final Map<String, Object> configurationSharedState) { boolean isInstall = isInstall(); lifecycleV1.start(event, configurationSharedState, isInstall); lifecycleV2.start(event, isInstall); if (isInstall) { persistInstallDate(event); } } /** * Pause the lifecycle session for standard and XDM workflows * * @param event current lifecycle request event with pause action */ private void pauseApplicationLifecycle(final Event event) { lifecycleV1.pause(event); lifecycleV2.pause(event); } /** * Check if install has been processed * * @return true if there is no install date stored in the data store */ private boolean isInstall() { return (lifecycleDataStore != null && !lifecycleDataStore.contains(LifecycleConstants.DataStoreKeys.INSTALL_DATE)); } /** * Persist Application install date. * * @param event lifecycle start event. */ private void persistInstallDate(final Event event) { if (lifecycleDataStore == null) { return; } final long startTimestampInSeconds = event.getTimestampInSeconds(); lifecycleDataStore.setLong( LifecycleConstants.DataStoreKeys.INSTALL_DATE, startTimestampInSeconds); } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/lifecycle/src/main/java/com/adobe/marketing/mobile/lifecycle/XDMLifecycleEnvironmentTypeEnum.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.lifecycle; /** * XDM Environment type enum definition. Supported values by the Android SDK are: * * <ul> * <li>application * </ul> * * Other possible values, not supported at this time: * * <ul> * <li>browser * <li>iot * <li>external * <li>widget * </ul> */ @SuppressWarnings("unused") enum XDMLifecycleEnvironmentTypeEnum { APPLICATION("application"); // Application private final String value; XDMLifecycleEnvironmentTypeEnum(final String enumValue) { this.value = enumValue; } @Override public String toString() { return value; } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/lifecycle/src/main/java/com/adobe/marketing/mobile/lifecycle/LifecycleV2Constants.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.lifecycle; class LifecycleV2Constants { static final int CACHE_TIMEOUT_MILLIS = 2000; static final int STATE_UPDATE_TIMEOUT_MILLIS = 500; static final class XDMEventType { static final String APP_LAUNCH = "application.launch"; static final String APP_CLOSE = "application.close"; private XDMEventType() {} } static final class EventName { static final String APPLICATION_LAUNCH_EVENT = "Application Launch (Foreground)"; static final String APPLICATION_CLOSE_EVENT = "Application Close (Background)"; private EventName() {} } static final class EventDataKeys { static final String XDM = "xdm"; static final String DATA = "data"; private EventDataKeys() {} } /** Module Data Store keys */ static class DataStoreKeys { static final String LAST_APP_VERSION = "v2LastAppVersion"; static final String APP_START_TIMESTAMP_MILLIS = "v2AppStartTimestampMillis"; static final String APP_PAUSE_TIMESTAMP_MILLIS = "v2AppPauseTimestampMillis"; static final String APP_CLOSE_TIMESTAMP_MILLIS = "v2AppCloseTimestampMillis"; // Deprecated, use timestamps in milliseconds. Kept here for migration workflows. static final String APP_START_TIMESTAMP_SEC = "v2AppStartTimestamp"; static final String APP_PAUSE_TIMESTAMP_SEC = "v2AppPauseTimestamp"; static final String APP_CLOSE_TIMESTAMP_SEC = "v2AppCloseTimestamp"; private DataStoreKeys() {} } private LifecycleV2Constants() {} }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/KonductorConfig.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/NetworkResponseHandler.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/EdgeHitProcessor.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/RequestBuilder.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/EdgeExtension.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/EdgeJson.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/EdgeRequest.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/EdgeEventHandle.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/Utils.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/EdgeSharedStateCallback.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/EdgeState.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/EventUtils.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/ImplementationDetails.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/RetryResult.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/CompletionCallbacksManager.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/EdgeCallback.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/EdgeDataEntity.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/RequestMetadata.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/EdgeNetworkService.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/EdgeHit.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/ExperienceEvent.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/EdgeConsentUpdate.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/EdgeConstants.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/StateMetadata.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/EdgeEndpoint.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/StoreResponsePayload.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/QueryOptions.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/EdgeStateCallback.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/ConsentStatus.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/Edge.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/EdgeProperties.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/StoreResponsePayloadManager.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/xdm/Property.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/xdm/Schema.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/xdm/Formatters.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edge_3_0_0/edge/src/main/java/com/adobe/marketing/mobile/edge/SDKConfig.kt
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edgeIdentity_3_0_0/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/IdentityStorageManager.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edgeIdentity_3_0_0/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/SharedStateCallback.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edgeIdentity_3_0_0/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/IdentityConstants.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edgeIdentity_3_0_0/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/URLUtils.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edgeIdentity_3_0_0/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/Utils.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edgeIdentity_3_0_0/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/Identity.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edgeIdentity_3_0_0/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/EventUtils.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edgeIdentity_3_0_0/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/IdentityItem.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edgeIdentity_3_0_0/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/AuthenticatedState.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edgeIdentity_3_0_0/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/IdentityState.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edgeIdentity_3_0_0/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/IdentityExtension.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edgeIdentity_3_0_0/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/IdentityProperties.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edgeIdentity_3_0_0/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/IdentityMap.java
AEP Edge
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/edgeIdentity_3_0_0/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/ECID.java
AEP Edge
0