Skip to content

Commit

Permalink
Merge pull request #8 from adobe/dev-2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
praveek authored Jan 27, 2023
2 parents 4fce173 + 27d3530 commit 85c2006
Show file tree
Hide file tree
Showing 65 changed files with 137 additions and 82 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ jobs:
command: make unit-test-coverage

- store_test_results:
path: code/android-media-library/build/test-results/testPhoneDebugUnitTest
path: code/media/build/test-results/testPhoneDebugUnitTest

- run:
name: Upload unit test coverage
command: |
bash ./codecov -v -X s3 -c -D "./code/android-media-library/build/reports/coverage/test/phone/debug" -F unit-tests
bash ./codecov -v -X s3 -c -D "./code/media/build/reports/coverage/test/phone/debug" -F unit-tests
functional-test:
executor:
Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:
- run:
name: Upload coverage report
command: |
bash ./codecov -v -X s3 -c -D "./code/android-media-library/build/reports/coverage/androidTest/phone/debug" -F functional-tests
bash ./codecov -v -X s3 -c -D "./code/media/build/reports/coverage/androidTest/phone/debug" -F functional-tests
workflows:
version: 2
Expand Down
2 changes: 1 addition & 1 deletion docs/Media.md → Documentation/APIReference.md
Original file line number Diff line number Diff line change
Expand Up @@ -720,4 +720,4 @@ tracker.updateQoEObject(qoeObject);

## Media Constants

Refer [MediaConstants.java](../code/android-media-library/src/phone/java/com/adobe/marketing/mobile/MediaConstants.java) to see the constants exposed by Media extension.
Refer [MediaConstants.java](../code/media/src/phone/java/com/adobe/marketing/mobile/MediaConstants.java) to see the constants exposed by Media extension.
4 changes: 4 additions & 0 deletions Documentation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Media extension documentation

## Contents
- [API reference](APIReference.md)
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
EXTENSION-LIBRARY-FOLDER-NAME = android-media-library
EXTENSION-LIBRARY-FOLDER-NAME = media
TEST-APP-FOLDER-NAME = testapp

BUILD-ASSEMBLE-LOCATION = ./ci/assemble
Expand Down
8 changes: 5 additions & 3 deletions code/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ org.gradle.jvmargs=-Xmx2048m
android.injected.testOnly=false
org.gradle.configureondemand=false

moduleProjectName=android-media-library
moduleProjectName=media
moduleName=media
moduleAARName=android-media-library-phone-release.aar
moduleAARName=media-phone-release.aar
moduleVersion=3.0.0

mavenRepoName=AdobeMobileMediaSdk
mavenRepoDescription=Android Analytics Extension for Audio and Video.
mavenUploadDryRunFlag=false
mavenCoreVersion=2.0.0
android.useAndroidX=true
android.useAndroidX=true

android.disableAutomaticComponentCreation=true
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
governing permissions and limitations under the License.
*/

package com.adobe.marketing.mobile.media;
package com.adobe.marketing.mobile.media.internal;

import static org.junit.Assert.*;

import android.content.Context;
import androidx.test.core.app.ApplicationProvider;
import com.adobe.marketing.mobile.services.MockAppContextService;
import com.adobe.marketing.mobile.services.ServiceProviderExtension;
import java.io.File;
import java.io.IOException;
import java.util.*;
import org.junit.Test;

Expand Down Expand Up @@ -273,4 +275,26 @@ public void test_deleteAllHits_multipleSessionsPresent() {
assertTrue(hits.isEmpty());
}
}

@Test
public void test_deleteDeprecatedDatabaseFile() throws IOException {
// Setup
Context context = ApplicationProvider.getApplicationContext();
final String DEPRECATED_2X_DB_FILE_NAME = "ADBMobileMedia.sqlite";
File oldDB = new File(context.getCacheDir(), DEPRECATED_2X_DB_FILE_NAME);
oldDB.createNewFile();

File newDB = context.getDatabasePath(MEDIA_DATABASE);
newDB.delete();

// Before upgrade
assertTrue(oldDB.exists());
assertFalse(newDB.exists());

MediaDBService dbService = new MediaDBServiceImpl();

// After upgrade
assertFalse(oldDB.exists());
assertTrue(newDB.exists());
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
governing permissions and limitations under the License.
*/

package com.adobe.marketing.mobile.media;
package com.adobe.marketing.mobile.media.internal;

class MediaCollectionConstants {

private MediaCollectionConstants() {}

static final String MEDIA_LIBRARY_VERSION =
"android-media-" + com.adobe.marketing.mobile.Media.extensionVersion();

static final class EventType {
private EventType() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
governing permissions and limitations under the License.
*/

package com.adobe.marketing.mobile.media;
package com.adobe.marketing.mobile.media.internal;

import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
governing permissions and limitations under the License.
*/

package com.adobe.marketing.mobile.media;
package com.adobe.marketing.mobile.media.internal;

import com.adobe.marketing.mobile.services.Log;
import com.adobe.marketing.mobile.util.DataReader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
governing permissions and limitations under the License.
*/

package com.adobe.marketing.mobile.media;
package com.adobe.marketing.mobile.media.internal;

import androidx.annotation.VisibleForTesting;
import com.adobe.marketing.mobile.Event;
Expand Down Expand Up @@ -270,6 +270,12 @@ String getError(final Map<String, Object> context) {
return info != null && StateInfo.fromObjectMap(info) != null;
};

IMediaRuleCallback isValidErrorInfo =
(rule, context) -> {
String errorId = getError(context);
return errorId != null && !errorId.isEmpty();
};

IMediaRuleCallback isDifferentAdBreakInfo =
(rule, context) -> {
if (!mediaContext.isInAdBreak()) {
Expand Down Expand Up @@ -753,7 +759,9 @@ void setUpMediaRules() {

// MediaRule::trackError
MediaRule error = new MediaRule(MediaRuleName.Error.ordinal(), "API::trackError");
error.addPredicate(isInMedia, true, ErrorMessage.ErrNotInMedia).addAction(cmdError);
error.addPredicate(isInMedia, true, ErrorMessage.ErrNotInMedia)
.addPredicate(isValidErrorInfo, true, ErrorMessage.ErrInvalidErrorId)
.addAction(cmdError);

ruleEngine.addRule(error);

Expand Down Expand Up @@ -1233,6 +1241,9 @@ class ErrorMessage {
"Media tracker is not tracking the State passed into 'API:trackEvent(StateEnd)'.";
static final String ErrTrackedStatesLimitReached =
"Media tracker is already tracking maximum allowed states (10) per session.";
static final String ErrInvalidErrorId =
"ErrorId passed into 'API:trackError' is invalid. Please pass valid non-empty non-null"
+ " string for ErrorId.";
}

class PrerollQueuedRule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
governing permissions and limitations under the License.
*/

package com.adobe.marketing.mobile.media;
package com.adobe.marketing.mobile.media.internal;

import com.adobe.marketing.mobile.services.Log;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
governing permissions and limitations under the License.
*/

package com.adobe.marketing.mobile.media;
package com.adobe.marketing.mobile.media.internal;

import java.util.List;
import java.util.Set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
governing permissions and limitations under the License.
*/

package com.adobe.marketing.mobile.media;
package com.adobe.marketing.mobile.media.internal;

import com.adobe.marketing.mobile.services.Log;
import com.adobe.marketing.mobile.util.DataReader;
import com.adobe.marketing.mobile.util.JSONUtils;
import com.adobe.marketing.mobile.util.SQLiteUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
Expand All @@ -25,6 +26,9 @@

class MediaDBServiceImpl implements MediaDBService {
private static final String LOG_TAG = "MediaDBService";
private static final String MEDIA_DB_FILE_NAME = MediaInternalConstants.Media.SHARED_STATE_NAME;
private static final String DEPRECATED_2X_DB_FILE_NAME = "ADBMobileMedia.sqlite";

private MediaDatabase database;

private static final String KEY_EVENT_TYPE = "eventtype";
Expand All @@ -36,7 +40,16 @@ class MediaDBServiceImpl implements MediaDBService {

MediaDBServiceImpl() {
try {
database = new MediaDatabase();
// Delete deprecated 2X database from cache directory.
if (SQLiteUtils.deleteDBFromCacheDir(DEPRECATED_2X_DB_FILE_NAME)) {
Log.debug(
MediaInternalConstants.EXTENSION_LOG_TAG,
LOG_TAG,
"Media 2.x database file (%s) deleted.",
DEPRECATED_2X_DB_FILE_NAME);
}

database = new MediaDatabase(MEDIA_DB_FILE_NAME);
} catch (Exception ex) {
Log.trace(
MediaInternalConstants.EXTENSION_LOG_TAG,
Expand All @@ -47,7 +60,7 @@ class MediaDBServiceImpl implements MediaDBService {
}
}

String serializeHit(final MediaHit mediaHit) {
private String serializeHit(final MediaHit mediaHit) {
if (mediaHit == null) {
return null;
}
Expand All @@ -62,7 +75,7 @@ String serializeHit(final MediaHit mediaHit) {
return new JSONObject(mediaHitMap).toString();
}

MediaHit deserializeHit(final String mediaHitStr) {
private MediaHit deserializeHit(final String mediaHitStr) {
try {
Map<String, Object> mediaHitMap = JSONUtils.toMap(new JSONObject(mediaHitStr));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
governing permissions and limitations under the License.
*/

package com.adobe.marketing.mobile.media;
package com.adobe.marketing.mobile.media.internal;

import android.content.ContentValues;
import android.content.Context;
Expand All @@ -28,7 +28,6 @@

class MediaDatabase {
private static final String LOG_TAG = "MediaDatabase";
private static final String MEDIA_DB_FILE_NAME = MediaInternalConstants.Media.SHARED_STATE_NAME;
private static final String MEDIA_TABLE_NAME = "MEDIAHITS";

private static final String TB_KEY_ID = "id";
Expand All @@ -38,13 +37,13 @@ class MediaDatabase {
private final String dbPath;
private final Object dbMutex;

MediaDatabase() {
MediaDatabase(final String dbName) {
Context context =
ServiceProvider.getInstance().getAppContextService().getApplicationContext();
if (context == null) {
throw new IllegalStateException("Context is null");
}
File database = context.getDatabasePath(MEDIA_DB_FILE_NAME);
File database = context.getDatabasePath(dbName);
dbPath = database.getPath();
dbMutex = new Object();
createTableIfNotExist();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
governing permissions and limitations under the License.
*/

package com.adobe.marketing.mobile.media;
package com.adobe.marketing.mobile.media.internal;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
governing permissions and limitations under the License.
*/

package com.adobe.marketing.mobile.media;
package com.adobe.marketing.mobile.media.internal;

import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
governing permissions and limitations under the License.
*/

package com.adobe.marketing.mobile.media;
package com.adobe.marketing.mobile.media.internal;

interface MediaHitProcessor {
String startSession();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
governing permissions and limitations under the License.
*/

package com.adobe.marketing.mobile.media;
package com.adobe.marketing.mobile.media.internal;

final class MediaInternalConstants {
static final String EXTENSION_LOG_TAG = "Media";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
governing permissions and limitations under the License.
*/

package com.adobe.marketing.mobile.media;
package com.adobe.marketing.mobile.media.internal;

import com.adobe.marketing.mobile.Media;
import com.adobe.marketing.mobile.services.Log;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
governing permissions and limitations under the License.
*/

package com.adobe.marketing.mobile.media;
package com.adobe.marketing.mobile.media.internal;

import com.adobe.marketing.mobile.MobilePrivacyStatus;
import com.adobe.marketing.mobile.services.HttpMethod;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
governing permissions and limitations under the License.
*/

package com.adobe.marketing.mobile.media;
package com.adobe.marketing.mobile.media.internal;

import com.adobe.marketing.mobile.MobilePrivacyStatus;
import com.adobe.marketing.mobile.services.Log;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
governing permissions and limitations under the License.
*/

package com.adobe.marketing.mobile.media;
package com.adobe.marketing.mobile.media.internal;

import com.adobe.marketing.mobile.Media;
import com.adobe.marketing.mobile.MobilePrivacyStatus;
import com.adobe.marketing.mobile.VisitorID;
import com.adobe.marketing.mobile.services.DeviceInforming;
Expand Down Expand Up @@ -155,7 +154,8 @@ static Map<String, Object> mediaHitToEventData(
}

params.put(
MediaCollectionConstants.Session.MEDIA_VERSION.key, Media.extensionVersion());
MediaCollectionConstants.Session.MEDIA_VERSION.key,
MediaCollectionConstants.MEDIA_LIBRARY_VERSION);

// Remove sessionID from params
params.remove(MediaInternalConstants.EventDataKeys.Tracker.SESSION_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
governing permissions and limitations under the License.
*/

package com.adobe.marketing.mobile.media;
package com.adobe.marketing.mobile.media.internal;

import com.adobe.marketing.mobile.services.Log;
import java.util.HashMap;
Expand Down
Loading

0 comments on commit 85c2006

Please # to comment.