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

Update firebase version and null check on HtppLoader header #700

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions src/nme/net/HttpLoader.hx
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ class HttpLoader
public function getHeaders() : Array<String>
{
var headerMap = http.responseHeaders;
if (headerMap == null) {
onError("Header returns null");
return [""];
}
return [ for(h in headerMap.keys()) h + ": " + headerMap.get(h) ];
}

Expand Down
35 changes: 31 additions & 4 deletions templates/android/PROJ-gradle/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ android {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}

::if KEY_STORE::
signingConfigs {
release {
Expand Down Expand Up @@ -93,7 +98,8 @@ dependencies {
})
// Support is in 'androidx.core' now
::if ANDROID_BILLING::
api 'com.android.billingclient:billing:2.1.0'
// api 'com.android.billingclient:billing:2.1.0'
api "com.android.billingclient:billing:4.0.0"
::end::
testImplementation 'junit:junit:4.12'

Expand All @@ -103,15 +109,36 @@ dependencies {

::if NME_FIREBASE::
// Add the dependency for the Performance Monitoring library
implementation 'com.google.firebase:firebase-analytics:17.2.2'
implementation platform('com.google.firebase:firebase-bom')
implementation 'com.google.firebase:firebase-analytics'

::if NME_FIREBASE_PERFORMANCE::
implementation 'com.google.firebase:firebase-perf:19.0.7'
implementation 'com.google.firebase:firebase-perf'
::end::

::if NME_FIREBASE_CRASHLYTICS::
implementation 'com.google.firebase:firebase-crashlytics-ndk:17.1.0'
implementation 'com.google.firebase:firebase-crashlytics-ndk'
::end::

implementation 'com.google.android.gms:play-services-ads:20.2.0'
//implementation 'com.google.firebase:firebase-inappmessaging'
//implementation 'com.google.firebase:firebase-inappmessaging-display'
//implementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.firebase:firebase-iid'
// implementation 'com.google.firebase:firebase-messaging:17.3.4'
// implementation 'com.google.firebase:firebase-core:16.0.4'
//implementation 'com.google.firebase:firebase-config'
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-analytics'
//implementation 'com.google.firebase:firebase-config:18.0.0'
//implementation 'com.google.firebase:firebase-iid:19.0.1'
// implementation 'com.google.firebase:firebase-messaging:20.0.1'
// implementation 'com.android.support:support-annotations:28.0.0'
// implementation 'com.google.firebase:firebase-core:17.0.0'
//implementation 'com.google.firebase:firebase-crash:16.2.1'
//implementation 'com.google.firebase:firebase-analytics:17.0.0'
implementation 'com.google.code.gson:gson:2.8.7'
implementation "androidx.work:work-runtime:2.5.0"
::end::

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@

</application>

<uses-sdk android:minSdkVersion="::ANDROID_MIN_API_LEVEL::"
android:targetSdkVersion="::ANDROID_TARGET_API_LEVEL::" />

<!--<uses-sdk android:minSdkVersion="::ANDROID_MIN_API_LEVEL::"
android:targetSdkVersion="::ANDROID_TARGET_API_LEVEL::" />-->
::foreach appPermission:: <uses-permission android:name="::permission::" android:required="::required::" />
::end::
<uses-permission android:name="android.permission.WAKE_LOCK" />
Expand Down
8 changes: 4 additions & 4 deletions templates/android/PROJ-gradle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ buildscript {
google()
}
dependencies {
classpath "com.android.tools.build:gradle:3.4.0"
classpath "com.android.tools.build:gradle:3.6.4"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

::if NME_FIREBASE::
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.gms:google-services:4.3.8'
::if NME_FIREBASE_PERFORMANCE::
// Add the dependency for the Performance Monitoring plugin
classpath 'com.google.firebase:perf-plugin:1.3.1' // Performance Monitoring plugin
classpath 'com.google.firebase:perf-plugin:1.4.0' // Performance Monitoring plugin
::end::

::if NME_FIREBASE_CRASHLYTICS::
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.0'
::end::
::end::
}
Expand Down
1 change: 1 addition & 0 deletions templates/android/PROJ-gradle/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.useAndroidX=true
23 changes: 15 additions & 8 deletions templates/android/java/org/haxe/nme/BillingManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@

import android.text.TextUtils;
import android.util.Base64;
import com.android.billingclient.util.BillingHelper;
// import com.android.billingclient.util.BillingHelper;
import android.util.Log;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.KeyFactory;
Expand Down Expand Up @@ -355,7 +356,7 @@ private void handlePurchase(Purchase purchase, JSONArray outList) throws JSONE
boolean valid = verifyValidSignature(purchase.getOriginalJson(), purchase.getSignature());

JSONObject obj= new JSONObject();
obj.put("sku", purchase.getSku() );
obj.put("sku", purchase.getSkus().get(0) );
obj.put("valid", valid );
obj.put("purchaseToken", purchase.getPurchaseToken() );
obj.put("orderId", purchase.getOrderId() );
Expand Down Expand Up @@ -457,7 +458,8 @@ public static boolean verifyPurchaseInsecure(String base64PublicKey, String sign

if (TextUtils.isEmpty(signedData) || TextUtils.isEmpty(base64PublicKey)
|| TextUtils.isEmpty(signature)) {
BillingHelper.logWarn(TAG, "Purchase verification failed: missing data.");
// BillingHelper.logWarn(TAG, "Purchase verification failed: missing data.");
Log.w(TAG,"Purchase verification failed: missing data.");
return false;
}

Expand All @@ -482,7 +484,8 @@ public static PublicKey generatePublicKey(String encodedPublicKey) throws IOExce
throw new RuntimeException(e);
} catch (InvalidKeySpecException e) {
String msg = "Invalid key specification: " + e;
BillingHelper.logWarn(TAG, msg);
// BillingHelper.logWarn(TAG, msg);
Log.w(TAG, msg);
throw new IOException(msg);
}
}
Expand All @@ -501,25 +504,29 @@ public static boolean verify(PublicKey publicKey, String signedData, String sign
try {
signatureBytes = Base64.decode(signature, Base64.DEFAULT);
} catch (IllegalArgumentException e) {
BillingHelper.logWarn(TAG, "Base64 decoding failed.");
// BillingHelper.logWarn(TAG, "Base64 decoding failed.");
Log.w(TAG, "Base64 decoding failed.");
return false;
}
try {
Signature signatureAlgorithm = Signature.getInstance(SIGNATURE_ALGORITHM);
signatureAlgorithm.initVerify(publicKey);
signatureAlgorithm.update(signedData.getBytes());
if (!signatureAlgorithm.verify(signatureBytes)) {
BillingHelper.logWarn(TAG, "Signature verification failed.");
// BillingHelper.logWarn(TAG, "Signature verification failed.");
Log.w(TAG,"Signature verification failed.");
return false;
}
return true;
} catch (NoSuchAlgorithmException e) {
// "RSA" is guaranteed to be available.
throw new RuntimeException(e);
} catch (InvalidKeyException e) {
BillingHelper.logWarn(TAG, "Invalid key specification.");
// BillingHelper.logWarn(TAG, "Invalid key specification.");
Log.w(TAG,"Invalid key specification");
} catch (SignatureException e) {
BillingHelper.logWarn(TAG, "Signature exception.");
// BillingHelper.logWarn(TAG, "Signature exception.");
Log.w(TAG, "Signature exception");
}
return false;
}
Expand Down