createMap() {
}
static final class ContextDataKeys {
- static final String INSTALL_EVENT_KEY = "a.InstallEvent";
- static final String LAUNCH_EVENT_KEY = "a.LaunchEvent";
- static final String CRASH_EVENT_KEY = "a.CrashEvent";
- static final String UPGRADE_EVENT_KEY = "a.UpgradeEvent";
- static final String DAILY_ENGAGED_EVENT_KEY = "a.DailyEngUserEvent";
+ static final String INSTALL_EVENT_KEY = "a.InstallEvent";
+ static final String LAUNCH_EVENT_KEY = "a.LaunchEvent";
+ static final String CRASH_EVENT_KEY = "a.CrashEvent";
+ static final String UPGRADE_EVENT_KEY = "a.UpgradeEvent";
+ static final String DAILY_ENGAGED_EVENT_KEY = "a.DailyEngUserEvent";
static final String MONTHLY_ENGAGED_EVENT_KEY = "a.MonthlyEngUserEvent";
- static final String INSTALL_DATE = "a.InstallDate";
- static final String LAUNCHES = "a.Launches";
- static final String PREVIOUS_SESSION_LENGTH = "a.PrevSessionLength";
- static final String DAYS_SINCE_FIRST_LAUNCH = "a.DaysSinceFirstUse";
- static final String DAYS_SINCE_LAST_LAUNCH = "a.DaysSinceLastUse";
- static final String HOUR_OF_DAY = "a.HourOfDay";
- static final String DAY_OF_WEEK = "a.DayOfWeek";
- static final String OPERATING_SYSTEM = "a.OSVersion";
- static final String APPLICATION_IDENTIFIER = "a.AppID";
- static final String DAYS_SINCE_LAST_UPGRADE = "a.DaysSinceLastUpgrade";
- static final String LAUNCHES_SINCE_UPGRADE = "a.LaunchesSinceUpgrade";
- static final String ADVERTISING_IDENTIFIER = "a.adid";
- static final String DEVICE_NAME = "a.DeviceName";
- static final String DEVICE_RESOLUTION = "a.Resolution";
- static final String CARRIER_NAME = "a.CarrierName";
- static final String LOCALE = "a.locale";
- static final String RUN_MODE = "a.RunMode";
- static final String IGNORED_SESSION_LENGTH = "a.ignoredSessionLength";
+ static final String INSTALL_DATE = "a.InstallDate";
+ static final String LAUNCHES = "a.Launches";
+ static final String PREVIOUS_SESSION_LENGTH = "a.PrevSessionLength";
+ static final String DAYS_SINCE_FIRST_LAUNCH = "a.DaysSinceFirstUse";
+ static final String DAYS_SINCE_LAST_LAUNCH = "a.DaysSinceLastUse";
+ static final String HOUR_OF_DAY = "a.HourOfDay";
+ static final String DAY_OF_WEEK = "a.DayOfWeek";
+ static final String OPERATING_SYSTEM = "a.OSVersion";
+ static final String APPLICATION_IDENTIFIER = "a.AppID";
+ static final String DAYS_SINCE_LAST_UPGRADE = "a.DaysSinceLastUpgrade";
+ static final String LAUNCHES_SINCE_UPGRADE = "a.LaunchesSinceUpgrade";
+ static final String ADVERTISING_IDENTIFIER = "a.adid";
+ static final String DEVICE_NAME = "a.DeviceName";
+ static final String DEVICE_RESOLUTION = "a.Resolution";
+ static final String CARRIER_NAME = "a.CarrierName";
+ static final String LOCALE = "a.locale";
+ static final String RUN_MODE = "a.RunMode";
+ static final String IGNORED_SESSION_LENGTH = "a.ignoredSessionLength";
private ContextDataKeys() {}
}
@@ -106,12 +109,11 @@ static class TargetResponse {
private TargetResponse() {}
}
-
static final String DATA_STORE_KEY = "ADOBEMOBILE_TARGET";
static class DataStoreKeys {
- static final String TNT_ID = "TNT_ID";
- static final String THIRD_PARTY_ID = "THIRD_PARTY_ID";
+ static final String TNT_ID = "TNT_ID";
+ static final String THIRD_PARTY_ID = "THIRD_PARTY_ID";
static final String SESSION_ID = "SESSION_ID";
static final String SESSION_TIMESTAMP = "SESSION_TIMESTAMP";
static final String EDGE_HOST = "EDGE_HOST";
@@ -148,7 +150,7 @@ static final class EventDataKeys {
static final String IS_LOCATION_DISPLAYED = "islocationdisplayed";
static final String IS_LOCATION_CLICKED = "islocationclicked";
static final String THIRD_PARTY_ID = "thirdpartyid";
- static final String TNT_ID = "tntid";
+ static final String TNT_ID = "tntid";
static final String SESSION_ID = "sessionid";
static final String RESET_EXPERIENCE = "resetexperience";
static final String CLEAR_PREFETCH_CACHE = "clearcache";
@@ -167,9 +169,9 @@ static final class EventDataKeys {
static final String EXPERIENCE_CLOUD = "experienceCloud";
static final String PROPERTY = "property";
static final String ENVIRONMENT_ID = "environmentId";
- static final String TRACK_INTERNAL = "trackinternal";
- static final String TRACK_ACTION = "action";
- static final String CONTEXT_DATA = "contextdata";
+ static final String TRACK_INTERNAL = "trackinternal";
+ static final String TRACK_ACTION = "action";
+ static final String CONTEXT_DATA = "contextdata";
static final class Order {
static final String ID = "id";
@@ -190,8 +192,8 @@ private EventDataKeys() {}
}
static final class Configuration {
- static final String EXTENSION_NAME = "com.adobe.module.configuration";
- static final String GLOBAL_CONFIG_PRIVACY = "global.privacy";
+ static final String EXTENSION_NAME = "com.adobe.module.configuration";
+ static final String GLOBAL_CONFIG_PRIVACY = "global.privacy";
static final String TARGET_CLIENT_CODE = "target.clientCode";
static final String TARGET_PREVIEW_ENABLED = "target.previewEnabled";
static final String TARGET_NETWORK_TIMEOUT = "target.timeout";
@@ -220,30 +222,30 @@ private Identity() {}
static final class Lifecycle {
static final String EXTENSION_NAME = "com.adobe.module.lifecycle";
- static final String APP_ID = "appid";
- static final String CARRIER_NAME = "carriername";
- static final String CRASH_EVENT = "crashevent";
- static final String DAILY_ENGAGED_EVENT = "dailyenguserevent";
- static final String DAY_OF_WEEK = "dayofweek";
+ static final String APP_ID = "appid";
+ static final String CARRIER_NAME = "carriername";
+ static final String CRASH_EVENT = "crashevent";
+ 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_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_CONTEXT_DATA = "lifecyclecontextdata";
- static final String LOCALE = "locale";
- static final String MONTHLY_ENGAGED_EVENT = "monthlyenguserevent";
- static final String OPERATING_SYSTEM = "osversion";
+ 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_CONTEXT_DATA = "lifecyclecontextdata";
+ static final String LOCALE = "locale";
+ static final String MONTHLY_ENGAGED_EVENT = "monthlyenguserevent";
+ static final String OPERATING_SYSTEM = "osversion";
static final String PREVIOUS_SESSION_LENGTH = "prevsessionlength";
- static final String RUN_MODE = "runmode";
- static final String UPGRADE_EVENT = "upgradeevent";
+ static final String RUN_MODE = "runmode";
+ static final String UPGRADE_EVENT = "upgradeevent";
private Lifecycle() {}
}
@@ -260,14 +262,15 @@ private EventHub() {}
static class PreviewKeys {
// Target preview Constants
- static final String PREVIEW_PARAMETERS = "at_preview_params";
- static final String PREVIEW_TOKEN = "at_preview_token";
- static final String PREVIEW_ENDPOINT = "at_preview_endpoint";
- static final String DEFAULT_TARGET_PREVIEW_ENDPOINT = "hal.testandtarget.omniture.com";
- static final String DEEPLINK = "deeplink";
+ static final String PREVIEW_PARAMETERS = "at_preview_params";
+ static final String PREVIEW_TOKEN = "at_preview_token";
+ static final String PREVIEW_ENDPOINT = "at_preview_endpoint";
+ static final String DEFAULT_TARGET_PREVIEW_ENDPOINT = "hal.testandtarget.omniture.com";
+ static final String DEEPLINK = "deeplink";
static final String DEEPLINK_SCHEME = "adbinapp";
static final String DEEPLINK_SCHEME_PATH_CANCEL = "cancel";
static final String DEEPLINK_SCHEME_PATH_CONFIRM = "confirm";
+
private PreviewKeys() {}
}
-}
\ No newline at end of file
+}
diff --git a/code/target/src/main/java/com/adobe/marketing/mobile/target/TargetErrors.java b/code/target/src/main/java/com/adobe/marketing/mobile/target/TargetErrors.java
index f7dfd04..dd0063d 100644
--- a/code/target/src/main/java/com/adobe/marketing/mobile/target/TargetErrors.java
+++ b/code/target/src/main/java/com/adobe/marketing/mobile/target/TargetErrors.java
@@ -1,56 +1,67 @@
/*
- 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.
- */
+ 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.target;
final class TargetErrors {
- static final String NO_CLIENT_CODE = "Missing client code";
- static final String NOT_OPTED_IN = "Privacy status is not opted in";
- static final String NO_PREFETCH_REQUESTS = "Empty or null prefetch requests list";
- static final String NO_CONNECTION = "Unable to open connection";
- static final String NULL_RESPONSE_JSON = "Null response Json";
- static final String ERROR_RESPONSE = "Errors returned in Target response: ";
- static final String NOTIFICATION_ERROR_TAG = "Notification";
- static final String NO_PREFETCH_MBOXES = "No prefetch mbox content in Target response";
- static final String MBOX_NAME_NULL_OR_EMPTY = "MboxName is either null or empty";
- static final String MBOX_NAMES_NULL_OR_EMPTY = "MboxNames List is either null or empty";
- static final String NO_TARGET_REQUESTS = "No valid Target Request found.";
- static final String PARAMS_SERIALIZATION_FAILED = "TargetParameters serialization failed";
- static final String NETWORK_SERVICE_UNAVAILABLE = "Unable to send target request, Network service is not available";
- static final String REQUEST_BUILDER_INIT_FAILED = "Couldn't initialize the target request builder for this request";
- static final String REQUEST_BUILDER_INIT_FAILED_NOTIFICATIONS =
- "Couldn't initialize the target request builder to extract the notifications";
- static final String REQUEST_GENERATION_FAILED = "Failed to generate the Target request payload";
- static final String UNEXPECTED_VISITORIDS_LIST = "The serialized visitorIdsList received as parameter is not a list %s";
- static final String NO_CACHED_MBOX_FOUND = "No cached mbox found for %s";
- static final String TOKEN_LIST_EMPTY_OR_NULL = "Tokens list is null or empty in the view notification object";
- static final String DISPLAY_NOTIFICATION_SEND_FAILED = "Unable to send display notification: %s";
- static final String DISPLAY_NOTIFICATION_CREATE_FAILED = "Failed to create display notification Json(%s)";
- static final String DISPLAY_NOTIFICATION_TOKEN_EMPTY =
- "Unable to create display notification as token is null or empty";
- static final String DISPLAY_NOTIFICATION_NOT_SENT = "No display notifications are available to send";
- static final String DISPLAY_NOTIFICATION_NULL_FOR_MBOX = "No display notifications are available to send for mbox %s";
- static final String CLICK_NOTIFICATION_SEND_FAILED = "Unable to send click notification: ";
- static final String CLICK_NOTIFICATION_NOT_SENT = "No click notifications are available to send";
- static final String NO_CLICK_METRICS = "No click metrics set on mbox: %s";
- static final String NO_CLICK_METRIC_FOUND = "No click metric found on mbox: %s";
- static final String CLICK_NOTIFICATION_CREATE_FAILED = "Failed to create click notification Json(%s)";
- static final String NO_PREFETCH_IN_PREVIEW = "Target prefetch can't be used while in preview mode";
- static final String TARGET_NOT_ENABLED_FOR_PREVIEW = "Target is not enabled, cannot enter in preview mode: %s";
- static final String TARGET_PREVIEW_DISABLED =
- "Target Preview is disabled, please change the configuration and try again";
- static final String TARGET_THIRD_PARTY_ID_NOT_PERSISTED = "Failed to persist thirdPartyId, %s";
- static final String TARGET_TNT_ID_NOT_PERSISTED = "Failed to persist tntID, %s";
- static final String TARGET_SESSION_ID_NOT_PERSISTED = "Failed to persist session id, %s";
+ static final String NO_CLIENT_CODE = "Missing client code";
+ static final String NOT_OPTED_IN = "Privacy status is not opted in";
+ static final String NO_PREFETCH_REQUESTS = "Empty or null prefetch requests list";
+ static final String NO_CONNECTION = "Unable to open connection";
+ static final String NULL_RESPONSE_JSON = "Null response Json";
+ static final String ERROR_RESPONSE = "Errors returned in Target response: ";
+ static final String NOTIFICATION_ERROR_TAG = "Notification";
+ static final String NO_PREFETCH_MBOXES = "No prefetch mbox content in Target response";
+ static final String MBOX_NAME_NULL_OR_EMPTY = "MboxName is either null or empty";
+ static final String MBOX_NAMES_NULL_OR_EMPTY = "MboxNames List is either null or empty";
+ static final String NO_TARGET_REQUESTS = "No valid Target Request found.";
+ static final String PARAMS_SERIALIZATION_FAILED = "TargetParameters serialization failed";
+ static final String NETWORK_SERVICE_UNAVAILABLE =
+ "Unable to send target request, Network service is not available";
+ static final String REQUEST_BUILDER_INIT_FAILED =
+ "Couldn't initialize the target request builder for this request";
+ static final String REQUEST_BUILDER_INIT_FAILED_NOTIFICATIONS =
+ "Couldn't initialize the target request builder to extract the notifications";
+ static final String REQUEST_GENERATION_FAILED = "Failed to generate the Target request payload";
+ static final String UNEXPECTED_VISITORIDS_LIST =
+ "The serialized visitorIdsList received as parameter is not a list %s";
+ static final String NO_CACHED_MBOX_FOUND = "No cached mbox found for %s";
+ static final String TOKEN_LIST_EMPTY_OR_NULL =
+ "Tokens list is null or empty in the view notification object";
+ static final String DISPLAY_NOTIFICATION_SEND_FAILED =
+ "Unable to send display notification: %s";
+ static final String DISPLAY_NOTIFICATION_CREATE_FAILED =
+ "Failed to create display notification Json(%s)";
+ static final String DISPLAY_NOTIFICATION_TOKEN_EMPTY =
+ "Unable to create display notification as token is null or empty";
+ static final String DISPLAY_NOTIFICATION_NOT_SENT =
+ "No display notifications are available to send";
+ static final String DISPLAY_NOTIFICATION_NULL_FOR_MBOX =
+ "No display notifications are available to send for mbox %s";
+ static final String CLICK_NOTIFICATION_SEND_FAILED = "Unable to send click notification: ";
+ static final String CLICK_NOTIFICATION_NOT_SENT =
+ "No click notifications are available to send";
+ static final String NO_CLICK_METRICS = "No click metrics set on mbox: %s";
+ static final String NO_CLICK_METRIC_FOUND = "No click metric found on mbox: %s";
+ static final String CLICK_NOTIFICATION_CREATE_FAILED =
+ "Failed to create click notification Json(%s)";
+ static final String NO_PREFETCH_IN_PREVIEW =
+ "Target prefetch can't be used while in preview mode";
+ static final String TARGET_NOT_ENABLED_FOR_PREVIEW =
+ "Target is not enabled, cannot enter in preview mode: %s";
+ static final String TARGET_PREVIEW_DISABLED =
+ "Target Preview is disabled, please change the configuration and try again";
+ static final String TARGET_THIRD_PARTY_ID_NOT_PERSISTED = "Failed to persist thirdPartyId, %s";
+ static final String TARGET_TNT_ID_NOT_PERSISTED = "Failed to persist tntID, %s";
+ static final String TARGET_SESSION_ID_NOT_PERSISTED = "Failed to persist session id, %s";
- private TargetErrors() {}
+ private TargetErrors() {}
}
diff --git a/code/target/src/main/java/com/adobe/marketing/mobile/target/TargetExtension.java b/code/target/src/main/java/com/adobe/marketing/mobile/target/TargetExtension.java
index 1108f61..190433b 100644
--- a/code/target/src/main/java/com/adobe/marketing/mobile/target/TargetExtension.java
+++ b/code/target/src/main/java/com/adobe/marketing/mobile/target/TargetExtension.java
@@ -1,20 +1,19 @@
/*
- 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.
- */
+ 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.target;
+import android.content.Context;
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;
@@ -35,14 +34,11 @@
import com.adobe.marketing.mobile.services.Networking;
import com.adobe.marketing.mobile.services.ServiceProvider;
import com.adobe.marketing.mobile.services.ui.UIService;
+import com.adobe.marketing.mobile.services.uri.UriOpening;
import com.adobe.marketing.mobile.util.DataReader;
import com.adobe.marketing.mobile.util.DataReaderException;
import com.adobe.marketing.mobile.util.JSONUtils;
import com.adobe.marketing.mobile.util.StringUtils;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
import java.net.HttpURLConnection;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
@@ -52,45 +48,54 @@
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.json.JSONException;
+import org.json.JSONObject;
/**
- * Adobe Target is the Adobe Marketing Cloud solution that provides everything you need to tailor and personalize your customers
- * experience on mobile application.
- *
- * It helps you to deliver targeted content within your mobile Application.
- * The extension will provide a way to react to public facing Target APIs to make target request and get responses through asynchronous callbacks.
- * Returns an instance of the Target extension. Adds all the Listeners to the provided EventHub.
- * The Target extension listens for the following {@link Event}s:
+ * Adobe Target is the Adobe Marketing Cloud solution that provides everything you need to tailor
+ * and personalize your customers experience on mobile application.
+ *
+ *
It helps you to deliver targeted content within your mobile Application. The extension will
+ * provide a way to react to public facing Target APIs to make target request and get responses
+ * through asynchronous callbacks. Returns an instance of the Target extension. Adds all the
+ * Listeners to the provided EventHub. The Target extension listens for the following {@link
+ * Event}s:
+ *
*
- * - {@link EventType#TARGET} - {@link EventSource#REQUEST_CONTENT}
- * - {@code EventType#TARGET} - {@link EventSource#REQUEST_RESET}
- * - {@code EventType#TARGET} - {@link EventSource#REQUEST_IDENTITY}
- * - {@code EventType#GENERIC_DATA} - {@link EventSource#OS}
- * - {@link EventType#CONFIGURATION} - {@link EventSource#RESPONSE_CONTENT}
+ * - {@link EventType#TARGET} - {@link EventSource#REQUEST_CONTENT}
+ *
- {@code EventType#TARGET} - {@link EventSource#REQUEST_RESET}
+ *
- {@code EventType#TARGET} - {@link EventSource#REQUEST_IDENTITY}
+ *
- {@code EventType#GENERIC_DATA} - {@link EventSource#OS}
+ *
- {@link EventType#CONFIGURATION} - {@link EventSource#RESPONSE_CONTENT}
*
- *
- * The Target extension dispatches the following {@code Event}s:
+ *
+ *
The Target extension dispatches the following {@code Event}s:
+ *
*
- * - {@code EventType#TARGET} - {@code EventSource#RESPONSE_CONTENT}
- * - {@code EventType#TARGET} - {@code EventSource#RESPONSE_IDENTITY}
- * - {@code EventType#TARGET} - {@code EventSource#RESPONSE_IDENTITY}
+ * - {@code EventType#TARGET} - {@code EventSource#RESPONSE_CONTENT}
+ *
- {@code EventType#TARGET} - {@code EventSource#RESPONSE_IDENTITY}
+ *
- {@code EventType#TARGET} - {@code EventSource#RESPONSE_IDENTITY}
*
- *
- * The Target extension has dependencies on the following {@link ServiceProvider} services:
+ *
+ *
The Target extension has dependencies on the following {@link ServiceProvider} services:
+ *
*
- * - {@link DataStoring}
- * - {@link Networking}
+ * - {@link DataStoring}
+ *
- {@link Networking}
*
*
* @see ServiceProvider
*/
public class TargetExtension extends Extension {
private static final String CLASS_NAME = "TargetExtension";
- private static final String TARGET_EVENT_DISPATCH_MESSAGE = "Dispatching - Target response content event";
+ private static final String TARGET_EVENT_DISPATCH_MESSAGE =
+ "Dispatching - Target response content event";
private final DeviceInforming deviceInfoService;
private final Networking networkService;
private final UIService uiService;
+ private final UriOpening uriService;
+ private final Context context;
private final TargetState targetState;
private final TargetResponseParser targetResponseParser;
@@ -99,44 +104,49 @@ public class TargetExtension extends Extension {
/**
* Constructor for {@code TargetExtension}.
- *
- * It is invoked during the extension registration to retrieve the extension's details such as name and version.
+ *
+ *
It is invoked during the extension registration to retrieve the extension's details such
+ * as name and version.
*
* @param extensionApi {@link ExtensionApi} instance.
*/
protected TargetExtension(final ExtensionApi extensionApi) {
- super(extensionApi);
-
- deviceInfoService = ServiceProvider.getInstance().getDeviceInfoService();
- NamedCollection dataStore = ServiceProvider.getInstance().getDataStoreService().getNamedCollection(TargetConstants.DATA_STORE_KEY);
- networkService = ServiceProvider.getInstance().getNetworkService();
- uiService = ServiceProvider.getInstance().getUIService();
-
- targetState = new TargetState(dataStore);
- targetResponseParser = new TargetResponseParser();
- targetPreviewManager = new TargetPreviewManager(networkService, uiService);
- targetRequestBuilder = getRequestBuilder();
+ this(extensionApi, null, null, null, null);
}
/**
* Constructor for {@code TargetExtension}.
- *
- * Used only for Testing purposes.
+ *
+ *
Used only for Testing purposes.
*
* @param extensionApi {@link ExtensionApi} instance.
*/
@VisibleForTesting
- protected TargetExtension(final ExtensionApi extensionApi, final DeviceInforming deviceInfoService, final Networking networkService,
- final UIService uiService, final TargetState targetState, final TargetPreviewManager targetPreviewManager,
- final TargetRequestBuilder requestBuilder, final TargetResponseParser responseParser) {
+ protected TargetExtension(
+ final ExtensionApi extensionApi,
+ final TargetState targetState,
+ final TargetPreviewManager targetPreviewManager,
+ final TargetRequestBuilder requestBuilder,
+ final TargetResponseParser responseParser) {
super(extensionApi);
- this.deviceInfoService = deviceInfoService;
- this.networkService = networkService;
- this.uiService = uiService;
- this.targetState = targetState;
- this.targetPreviewManager = targetPreviewManager;
- this.targetRequestBuilder = requestBuilder;
- this.targetResponseParser = responseParser;
+ deviceInfoService = ServiceProvider.getInstance().getDeviceInfoService();
+ NamedCollection dataStore =
+ ServiceProvider.getInstance()
+ .getDataStoreService()
+ .getNamedCollection(TargetConstants.DATA_STORE_KEY);
+ networkService = ServiceProvider.getInstance().getNetworkService();
+ uiService = ServiceProvider.getInstance().getUIService();
+ uriService = ServiceProvider.getInstance().getUriService();
+ context = ServiceProvider.getInstance().getAppContextService().getApplicationContext();
+
+ this.targetState = targetState != null ? targetState : new TargetState(dataStore);
+ this.targetPreviewManager =
+ targetPreviewManager != null
+ ? targetPreviewManager
+ : new TargetPreviewManager(networkService, uiService, uriService, context);
+ this.targetRequestBuilder = requestBuilder != null ? requestBuilder : getRequestBuilder();
+ this.targetResponseParser =
+ responseParser != null ? responseParser : new TargetResponseParser();
}
/**
@@ -144,8 +154,7 @@ protected TargetExtension(final ExtensionApi extensionApi, final DeviceInforming
*
* @return {@link String} containing the unique name for this extension.
*/
- @NonNull
- @Override
+ @NonNull @Override
protected String getName() {
return TargetConstants.EXTENSION_NAME;
}
@@ -156,7 +165,9 @@ protected String getName() {
* @return {@link String} containing the friendly name for this extension.
*/
@Override
- protected String getFriendlyName() { return TargetConstants.FRIENDLY_NAME; }
+ protected String getFriendlyName() {
+ return TargetConstants.FRIENDLY_NAME;
+ }
/**
* Retrieve the extension version.
@@ -176,17 +187,33 @@ public boolean readyForEvent(@NonNull final Event event) {
@Override
protected void onRegistered() {
- getApi().registerEventListener(EventType.TARGET, EventSource.REQUEST_CONTENT, this::handleTargetRequestContentEvent);
- getApi().registerEventListener(EventType.TARGET, EventSource.REQUEST_RESET, this::handleTargetRequestResetEvent);
- getApi().registerEventListener(EventType.TARGET, EventSource.REQUEST_IDENTITY, this::handleTargetRequestIdentityEvent);
- getApi().registerEventListener(EventType.GENERIC_DATA, EventSource.OS, this::handleGenericDataOSEvent);
- getApi().registerEventListener(EventType.CONFIGURATION, EventSource.RESPONSE_CONTENT, this::handleConfigurationResponseContentEvent);
+ getApi().registerEventListener(
+ EventType.TARGET,
+ EventSource.REQUEST_CONTENT,
+ this::handleTargetRequestContentEvent);
+ getApi().registerEventListener(
+ EventType.TARGET,
+ EventSource.REQUEST_RESET,
+ this::handleTargetRequestResetEvent);
+ getApi().registerEventListener(
+ EventType.TARGET,
+ EventSource.REQUEST_IDENTITY,
+ this::handleTargetRequestIdentityEvent);
+ getApi().registerEventListener(
+ EventType.GENERIC_DATA, EventSource.OS, this::handleGenericDataOSEvent);
+ getApi().registerEventListener(
+ EventType.CONFIGURATION,
+ EventSource.RESPONSE_CONTENT,
+ this::handleConfigurationResponseContentEvent);
}
void handleTargetRequestContentEvent(@NonNull final Event event) {
if (TargetUtils.isNullOrEmpty(event.getEventData())) {
- Log.warning(TargetConstants.LOG_TAG, CLASS_NAME,
- "handleTargetRequestContentEvent - Failed to process Target request content event, event data is null/ empty.");
+ Log.warning(
+ TargetConstants.LOG_TAG,
+ CLASS_NAME,
+ "handleTargetRequestContentEvent - Failed to process Target request content"
+ + " event, event data is null/ empty.");
return;
}
@@ -200,15 +227,25 @@ void handleTargetRequestContentEvent(@NonNull final Event event) {
if (eventData.containsKey(TargetConstants.EventDataKeys.PREFETCH)) {
final List