Skip to content

Commit ca07ec7

Browse files
committed
Update IAP plugin to version 5.3.0+300
1 parent e8abb1e commit ca07ec7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+720
-1986
lines changed

flutter-hms-iap/.docs/homeScreen.jpg

-623 KB
Binary file not shown.

flutter-hms-iap/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1+
## 5.3.0+300
2+
3+
* [Breaking Change] Added null-safety support.
4+
* Updated Huawei IAP SDK version to 5.3.0.300
5+
* isSupportAppTouch parameter is added to isEnvReady API for AppTouch.
6+
* Added carrierId and country to IsEnvReadyResult for obtaining the carrier ID and the country of the currently signed-in ID.
7+
* Added a class of constants, named SignAlgorithmConstants, which contains the algorithm that you pass for calling a certain IapClient API.
8+
* Added signatureAlgorithm to ConsumeOwnedPurchaseReq, OwnedPurchasesReq and PurchaseIntentReq classes to specify signature algorithm to sign the result data.
9+
* Added signatureAlgorithm to ConsumeOwnedPurchaseResult, OwnedPurchasesResult and PurchaseResultInfo to verify the signature algorithm.
10+
111
## 5.0.2+301
12+
213
* Updated HMSLogger.
314

415
## 5.0.2+300

flutter-hms-iap/README.md

Lines changed: 20 additions & 1449 deletions
Large diffs are not rendered by default.

flutter-hms-iap/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ android {
4040
}
4141

4242
dependencies {
43-
implementation 'com.huawei.hms:iap:5.0.2.300'
43+
implementation 'com.huawei.hms:iap:5.3.0.300'
4444
implementation 'com.google.code.gson:gson:2.8.5'
4545
}
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
org.gradle.jvmargs=-Xmx1536M
2-
android.enableR8=true
32
android.useAndroidX=true
43
android.enableJetifier=true
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

flutter-hms-iap/android/gradlew

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ esac
8282

8383
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
8484

85+
8586
# Determine the Java command to use to start the JVM.
8687
if [ -n "$JAVA_HOME" ] ; then
8788
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@@ -129,6 +130,7 @@ fi
129130
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
130131
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
131132
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133+
132134
JAVACMD=`cygpath --unix "$JAVACMD"`
133135

134136
# We build the pattern for arguments to be converted via cygpath

flutter-hms-iap/android/gradlew.bat

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
4040

4141
set JAVA_EXE=java.exe
4242
%JAVA_EXE% -version >NUL 2>&1
43-
if "%ERRORLEVEL%" == "0" goto init
43+
if "%ERRORLEVEL%" == "0" goto execute
4444

4545
echo.
4646
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -54,7 +54,7 @@ goto fail
5454
set JAVA_HOME=%JAVA_HOME:"=%
5555
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
5656

57-
if exist "%JAVA_EXE%" goto init
57+
if exist "%JAVA_EXE%" goto execute
5858

5959
echo.
6060
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -64,28 +64,14 @@ echo location of your Java installation.
6464

6565
goto fail
6666

67-
:init
68-
@rem Get command-line arguments, handling Windows variants
69-
70-
if not "%OS%" == "Windows_NT" goto win9xME_args
71-
72-
:win9xME_args
73-
@rem Slurp the command line arguments.
74-
set CMD_LINE_ARGS=
75-
set _SKIP=2
76-
77-
:win9xME_args_slurp
78-
if "x%~1" == "x" goto execute
79-
80-
set CMD_LINE_ARGS=%*
81-
8267
:execute
8368
@rem Setup the command line
8469

8570
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
8671

72+
8773
@rem Execute Gradle
88-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
74+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
8975

9076
:end
9177
@rem End local scope for the variables with windows NT shell

flutter-hms-iap/android/src/main/java/com/huawei/hms/flutter/iap/MethodCallHandlerImpl.java

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,21 @@ public class MethodCallHandlerImpl implements MethodCallHandler, ActivityResultL
7272
hmsLogger = HMSLogger.getInstance(mActivity.getApplicationContext());
7373
}
7474

75-
private void isEnvReady(@NonNull final Result result) {
75+
private void isEnvReady(@NonNull final MethodCall call, @NonNull final Result result) {
7676
final String isEnvReadyMethodName = "isEnvReady";
77+
final Boolean isSupportAppTouch = call.argument("isSupportAppTouch") == null
78+
? null
79+
: ValueGetter.getBoolean("isSupportAppTouch", call);
7780
hmsLogger.startMethodExecutionTimer(isEnvReadyMethodName);
78-
mIapClient.isEnvReady()
79-
.addOnSuccessListener(new DefaultSuccessListener<>(result, mGson, hmsLogger, isEnvReadyMethodName))
80-
.addOnFailureListener(new IsEnvReadyFailureListener(this, result, REQUEST_IS_ENVIRONMENT_READY, hmsLogger));
81+
if(isSupportAppTouch == null) {
82+
mIapClient.isEnvReady()
83+
.addOnSuccessListener(new DefaultSuccessListener<>(result, mGson, hmsLogger, isEnvReadyMethodName))
84+
.addOnFailureListener(new IsEnvReadyFailureListener(this, result, REQUEST_IS_ENVIRONMENT_READY, hmsLogger));
85+
} else{
86+
mIapClient.isEnvReady(isSupportAppTouch)
87+
.addOnSuccessListener(new DefaultSuccessListener<>(result, mGson, hmsLogger, isEnvReadyMethodName))
88+
.addOnFailureListener(new IsEnvReadyFailureListener(this, result, REQUEST_IS_ENVIRONMENT_READY, hmsLogger));
89+
}
8190
}
8291

8392
private void isSandboxActivated(@NonNull final Result result) {
@@ -119,13 +128,17 @@ private void createPurchaseIntent(@NonNull final MethodCall call, @NonNull final
119128
final String reservedInfor = call.argument("reservedInfor") == null
120129
? null
121130
: ValueGetter.getString("reservedInfor", call);
131+
final String signatureAlgorithm = call.argument("signatureAlgorithm") == null
132+
? null
133+
: ValueGetter.getString("signatureAlgorithm", call);
122134

123135
//Constructing request
124136
final PurchaseIntentReq request = new PurchaseIntentReq();
125137
request.setProductId(productId);
126138
request.setPriceType(priceType);
127139
request.setDeveloperPayload(developerPayload);
128140
request.setReservedInfor(reservedInfor);
141+
request.setSignatureAlgorithm(signatureAlgorithm);
129142

130143
//Create purchase intent from IAP service
131144
final String createPurchaseIntentMethodName = "createPurchaseIntent";
@@ -144,11 +157,15 @@ private void consumeOwnedPurchase(@NonNull final MethodCall call, @NonNull final
144157
final String developerChallenge = call.argument("developerChallenge") == null
145158
? null
146159
: ValueGetter.getString("developerChallenge", call);
160+
final String signatureAlgorithm = call.argument("signatureAlgorithm") == null
161+
? null
162+
: ValueGetter.getString("signatureAlgorithm", call);
147163

148164
//Constructing request
149165
final ConsumeOwnedPurchaseReq request = new ConsumeOwnedPurchaseReq();
150166
request.setDeveloperChallenge(developerChallenge);
151167
request.setPurchaseToken(purchaseToken);
168+
request.setSignatureAlgorithm(signatureAlgorithm);
152169

153170
// Call service from IAP service
154171
final String consumeOwnedPurchaseMethodName = "consumeOwnedPurchase";
@@ -164,6 +181,9 @@ private void consumeOwnedPurchase(@NonNull final MethodCall call, @NonNull final
164181
private void obtainOwnedPurchaseRecord(@NonNull final MethodCall call, @NonNull final Result result) {
165182
//Arguments
166183
final int priceType = ValueGetter.getInt("priceType", call);
184+
final String signatureAlgorithm = call.argument("signatureAlgorithm") == null
185+
? null
186+
: ValueGetter.getString("signatureAlgorithm", call);
167187
final String continuationToken = call.argument("continuationToken") == null
168188
? null
169189
: ValueGetter.getString("continuationToken", call);
@@ -172,6 +192,7 @@ private void obtainOwnedPurchaseRecord(@NonNull final MethodCall call, @NonNull
172192
final OwnedPurchasesReq request = new OwnedPurchasesReq();
173193
request.setContinuationToken(continuationToken);
174194
request.setPriceType(priceType);
195+
request.setSignatureAlgorithm(signatureAlgorithm);
175196

176197
//Obtain record from IAP service
177198
final String obtainOwnedPurchaseRecordMethodName = "obtainOwnedPurchaseRecord";
@@ -190,11 +211,15 @@ private void obtainOwnedPurchases(@NonNull final MethodCall call, @NonNull final
190211
final String continuationToken = call.argument("continuationToken") == null
191212
? null
192213
: ValueGetter.getString("continuationToken", call);
214+
final String signatureAlgorithm = call.argument("signatureAlgorithm") == null
215+
? null
216+
: ValueGetter.getString("signatureAlgorithm", call);
193217

194218
//Constructing request
195219
final OwnedPurchasesReq request = new OwnedPurchasesReq();
196220
request.setContinuationToken(continuationToken);
197221
request.setPriceType(priceType);
222+
request.setSignatureAlgorithm(signatureAlgorithm);
198223

199224
//Obtain owned purchase from IAP service
200225
final String obtainOwnedPurchasesMethodName = "obtainOwnedPurchases";
@@ -231,7 +256,7 @@ private void startIapActivity(@NonNull final MethodCall call, final Result resul
231256
public void onMethodCall(@NonNull final MethodCall call, @NonNull final Result result) {
232257
switch (call.method) {
233258
case "isEnvReady":
234-
isEnvReady(result);
259+
isEnvReady(call, result);
235260
break;
236261
case "isSandboxActivated":
237262
isSandboxActivated(result);

flutter-hms-iap/android/src/main/java/com/huawei/hms/flutter/iap/logger/HMSLogger.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public final class HMSLogger {
4040

4141
private static final String PLATFORM = "Flutter";
4242

43-
private static final String VERSION = "5.0.2.301";
43+
private static final String VERSION = "5.3.0.300";
4444

4545
private static final String SERVICE = "Cross-Platform";
4646

flutter-hms-iap/android/src/main/java/com/huawei/hms/flutter/iap/utils/JSONUtils.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public static JSONObject getJSONFromPurchaseResultInfo(final PurchaseResultInfo
5050
jsonObject.put("errMsg", obj.getErrMsg());
5151
jsonObject.put("inAppPurchaseData", obj.getInAppPurchaseData());
5252
jsonObject.put("inAppDataSignature", obj.getInAppDataSignature());
53+
jsonObject.put("signatureAlgorithm", obj.getSignatureAlgorithm());
5354
} catch (final JSONException e) {
5455
Log.e(TAG, e.toString());
5556
}

flutter-hms-iap/android/src/main/java/com/huawei/hms/flutter/iap/utils/ValueGetter.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,13 @@ public static String getString(final String key, final MethodCall call) {
4141
throw new IllegalArgumentException();
4242
}
4343
}
44+
45+
public static Boolean getBoolean(final String key, final MethodCall call){
46+
final Object value = call.argument(key);
47+
if (value instanceof Boolean) {
48+
return (Boolean) value;
49+
} else {
50+
throw new IllegalArgumentException();
51+
}
52+
}
4453
}
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
org.gradle.jvmargs=-Xmx1536M
2-
android.enableR8=true
32
android.useAndroidX=true
43
android.enableJetifier=true
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)