Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Ability to disable amazon's DRM #2849

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ android {
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
buildConfigField "boolean", "ENABLE_AMAZON_DRM", getExtOrDefault("enableAmazonDrm")
}

buildTypes {
Expand Down
1 change: 1 addition & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ RNIap_ndkversion=23.1.7779620
RNIap_playServicesVersion=18.1.0
RNIap_amazonSdkVersion=3.0.4
RNIap_playBillingSdkVersion=7.0.0
RNIap_enableAmazonDrm=true

android.useAndroidX=true
android.enableJetifier=true
68 changes: 37 additions & 31 deletions android/src/amazon/java/com/dooboolab/rniap/RNIapAmazonModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,40 +57,46 @@ class RNIapAmazonModule(

@ReactMethod
fun verifyLicense(promise: Promise) {
try {
LicensingService.verifyLicense(reactApplicationContext) { licenseResponse ->
when (
val status: LicenseResponse.RequestStatus =
licenseResponse.requestStatus
) {
LicenseResponse.RequestStatus.LICENSED -> {
Log.d(TAG, "LicenseResponse status: $status")
promise.resolve("LICENSED")
}
LicenseResponse.RequestStatus.NOT_LICENSED -> {
Log.d(TAG, "LicenseResponse status: $status")
promise.resolve("NOT_LICENSED")
}
LicenseResponse.RequestStatus.EXPIRED -> {
Log.d(TAG, "LicenseResponse status: $status")
promise.resolve("EXPIRED")
}
LicenseResponse.RequestStatus.ERROR_VERIFICATION -> {
Log.d(TAG, "LicenseResponse status: $status")
promise.resolve("ERROR_VERIFICATION")
}
LicenseResponse.RequestStatus.ERROR_INVALID_LICENSING_KEYS -> {
Log.d(TAG, "LicenseResponse status: $status")
promise.resolve("ERROR_INVALID_LICENSING_KEYS")
}
LicenseResponse.RequestStatus.UNKNOWN_ERROR -> {
Log.d(TAG, "LicenseResponse status: $status")
promise.resolve("UNKNOWN_ERROR")
if (BuildConfig.ENABLE_AMAZON_DRM) {
Log.d(TAG, "Amazon's DRM is enabled")
try {
LicensingService.verifyLicense(reactApplicationContext) { licenseResponse ->
when (
val status: LicenseResponse.RequestStatus =
licenseResponse.requestStatus
) {
LicenseResponse.RequestStatus.LICENSED -> {
Log.d(TAG, "LicenseResponse status: $status")
promise.resolve("LICENSED")
}
LicenseResponse.RequestStatus.NOT_LICENSED -> {
Log.d(TAG, "LicenseResponse status: $status")
promise.resolve("NOT_LICENSED")
}
LicenseResponse.RequestStatus.EXPIRED -> {
Log.d(TAG, "LicenseResponse status: $status")
promise.resolve("EXPIRED")
}
LicenseResponse.RequestStatus.ERROR_VERIFICATION -> {
Log.d(TAG, "LicenseResponse status: $status")
promise.resolve("ERROR_VERIFICATION")
}
LicenseResponse.RequestStatus.ERROR_INVALID_LICENSING_KEYS -> {
Log.d(TAG, "LicenseResponse status: $status")
promise.resolve("ERROR_INVALID_LICENSING_KEYS")
}
LicenseResponse.RequestStatus.UNKNOWN_ERROR -> {
Log.d(TAG, "LicenseResponse status: $status")
promise.resolve("UNKNOWN_ERROR")
}
}
}
} catch (exception: Exception) {
promise.reject("Error while attempting to check for License", exception)
}
} catch (exception: Exception) {
promise.reject("Error while attempting to check for License", exception)
} else {
Log.d(TAG, "Amazon's DRM is disabled")
promise.resolve("NOT_LICENSED")
}
}

Expand Down
6 changes: 4 additions & 2 deletions plugin/__tests__/fixtures/buildGradleFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ android {
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 34
versionName "1.16.2"
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()`;
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
buildConfigField "boolean", "ENABLE_AMAZON_DRM", getExtOrDefault("enableAmazonDrm")`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make this look more like a boolean? Something like isAmazonDrmEnabled would be great.


const appBuildGradleWithPlayStoreIAP = `
apply plugin: "com.android.application"
Expand All @@ -43,7 +44,8 @@ missingDimensionStrategy "store", "play"
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 34
versionName "1.16.2"
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()`;
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
buildConfigField "boolean", "ENABLE_AMAZON_DRM", getExtOrDefault("enableAmazonDrm")`;

const appBuildGradleWithAmazonStoreIAP = `
apply plugin: "com.android.application"
Expand Down
Loading