diff --git a/Account Kit/README.md b/Account Kit/README.md
index 3223ddd..406f92c 100644
--- a/Account Kit/README.md
+++ b/Account Kit/README.md
@@ -1,21 +1,27 @@
# Accountkit-Android-sample
+English | [䏿–‡](https://github.com/HMS-Core/huawei-account-demo/blob/master/Account-Client-Java-Demo/Account_Demo_AndroidStudio/README_ZH.md)
+
## Table of Contents
* [Introduction](#introduction)
- * [Getting Started](#getting-started)
* [Supported Environments](#supported-environments)
+ * [Getting Started](#getting-started)
* [Result](#result)
* [License](#license)
## Introduction
- Android sample code encapsulates APIs of the HUAWEI Account Kit server. It provides sample program for your reference or usage.
- The following describes of Android sample code.
-
- hmssample: Sample code packages. This package contains code that implements Sign, SignInCode and SignOut.
- logger: This packages contains code that implements logger View.
+Android sample code encapsulates APIs of the HUAWEI Account Kit server. It provides sample program for your reference or usage.
+The following describes of Android sample code.
+
+hmssample: Sample code packages. This package contains code that implements Sign, SignInCode, SilentSignIn, SignOut and CancelAuthorization.
+logger: This packages contains code that implements logger View.
+
+
+## Supported Environments
+Android SDK Version >= 23 and JDK version >= 1.8 is recommended.
## Getting Started
@@ -30,16 +36,17 @@
(2) Change the value of applicationid in the app-level build.gradle file of the sample project to the package name of your app.
6. Run the sample on your Android device or emulator.
-
-## Supported Environments
- Android SDK Version >= 23 and JDK version >= 1.8 is recommended.
-## Result
- This demo provides demonstration for following scenarios:
- 1. ID-Token Mode Sign In. Sign in and Id-Token verification are both included.
- 2. Authorization Code Mode Sign In.
- 3. Sign out.
+## Result
+This demo provides demonstration for following scenarios:
+1. ID-Token Mode Sign In.
+2. Authorization Code Mode Sign In.
+3. Silent Sign In.
+4. Sign out.
+5. Cancel Authorization.
+

-## License
- Account-kit Android sample is licensed under the [Apache License, version 2.0](http://www.apache.org/licenses/LICENSE-2.0).
+
+## License
+Account-kit Android sample is licensed under the [Apache License, version 2.0](http://www.apache.org/licenses/LICENSE-2.0).
diff --git a/Account Kit/README_ZH.md b/Account Kit/README_ZH.md
new file mode 100644
index 0000000..feb3a58
--- /dev/null
+++ b/Account Kit/README_ZH.md
@@ -0,0 +1,42 @@
+# »ªÎªÕʺŷþÎñ¿Í»§¶ËJavaʾÀý´úÂë
+
+ÖÐÎÄ | [English](https://github.com/HMS-Core/huawei-account-demo/blob/master/Account-Client-Java-Demo/Account_Demo_AndroidStudio/README.md)
+
+## Ŀ¼
+* [¼ò½é](#¼ò½é)
+* [»·¾³ÒªÇó](#»·¾³ÒªÇó)
+* [¿ª·¢×¼±¸](#¿ª·¢×¼±¸)
+* [ÔËÐнá¹û](#ÔËÐнá¹û)
+* [ÊÚȨÐí¿É](#ÊÚȨÐí¿É)
+
+## ¼ò½é
+AndroidʾÀý´úÂë¶Ô»ªÎªÕʺŷþÎñ£¨HUAWEI Account Kit£©µÄ¿Í»§¶Ë½Ó¿Ú½øÐзâ×°£¬°üº¬·á¸»µÄʾÀý³ÌÐò£¬·½±ãÄú²Î¿¼»òÖ±½ÓʹÓá£ÏêÇéÈçÏ£º
+
+hmssample£ºÊ¾Àý´úÂë°ü£¬¿ÉʵÏֵǼ¡¢ÊÚȨµÇ¼¡¢¾²Ä¬µÇ¼¡¢Í˳öÕʺźÍÕʺÅÈ¡ÏûÊÚȨ¹¦ÄÜ¡£
+logger£º¿ÉʵÏÖÈÕÖ¾¼Ç¼¡£
+
+## »·¾³ÒªÇó
+ÍÆ¼öʹÓÃAndroid SDK 23¼°ÒÔÉϰ汾¡¢JDK 1.8¼°ÒÔÉϰ汾¡£
+
+## ¿ª·¢×¼±¸
+1. ¼ì²éAndroid Studio¿ª·¢»·¾³ÊÇ·ñ¾ÍÐ÷¡£ÔÚAndroid StudioÖдò¿ª¡°build.gradle¡±ÎļþËùÔÚµÄʾÀý´úÂ빤³ÌĿ¼£¬²¢ÔÚÄúÒѰ²×°×îÐÂ°æ»ªÎªÒÆ¶¯·þÎñ£¨HMS Core£©µÄÉ豸»òÄ£ÄâÆ÷ÉÏÔËÐвâÊÔÓ¦Óá£
+2. ×¢²á[»ªÎªÕʺÅ](https://developer.huawei.com/consumer/cn/)¡£
+3. ´´½¨Ó¦Óò¢ÔÚAppGallery ConnectÖÐÅäÖÃÏà¹ØÐÅÏ¢¡£¾ßÌåÇë²Î¿¼[¿ª·¢×¼±¸](https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/config-agc-0000001050196065)¡£
+4. ¹¹½¨´ËʾÀýdemoǰ£¬ÇëÏȽ«demoµ¼ÈëAndroid Studio£¨3.0¼°ÒÔÉϰ汾£©¡£
+5. ÅäÖÃʾÀý´úÂ룺
+ £¨1£©ÔÚAppGallery ConnectÏÂÔØÄúÓ¦Óõġ°agconnect-services.json¡±Îļþ£¬½«¸ÃÎļþ¿½±´µ½Ó¦Óü¶¸ùĿ¼Ï¡£
+ £¨2£©ÐÞ¸ÄʾÀý¹¤³ÌÖÐÓ¦Óü¶¡°build.gradle¡±ÎļþÖеġ°applicationid¡±ÎªÄú×Ô¼ºµÄÓ¦ÓðüÃû¡£
+6. ÔÚAndroidÉ豸»òÄ£ÄâÆ÷ÉÏÔËÐÐÄúµÄÓ¦Óá£
+
+## ÔËÐнá¹û
+±¾Ê¾Àý´úÂëÌṩÁËÒÔÏÂʹÓó¡¾°£º
+1. ID TokenģʽµÇ¼¡£
+2. Authorization CodeģʽµÇ¼¡£
+3. ¾²Ä¬µÇ¼¡£
+4. Í˳öÕʺš£
+5. ÕʺÅÈ¡ÏûÊÚȨ¡£
+
+
+
+## ÊÚȨÐí¿É
+»ªÎªÕʺŷþÎñAndroidʾÀý´úÂë¾¹ý[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0)ÊÚȨÐí¿É¡£
\ No newline at end of file
diff --git a/Account Kit/Third Party Open Source Software Notice.docx b/Account Kit/Third Party Open Source Software Notice.docx
deleted file mode 100644
index 172a7bd..0000000
Binary files a/Account Kit/Third Party Open Source Software Notice.docx and /dev/null differ
diff --git a/Account Kit/Third Party Open Source Software Notice.pdf b/Account Kit/Third Party Open Source Software Notice.pdf
new file mode 100644
index 0000000..8b7ffc7
Binary files /dev/null and b/Account Kit/Third Party Open Source Software Notice.pdf differ
diff --git a/Account Kit/images/account_sample_result.jpg b/Account Kit/images/account_sample_result.jpg
index 7172e4b..1aefb3a 100644
Binary files a/Account Kit/images/account_sample_result.jpg and b/Account Kit/images/account_sample_result.jpg differ
diff --git a/Account Kit/java/.gitignore b/Account Kit/java/.gitignore
index 39fb081..a9dbb41 100644
--- a/Account Kit/java/.gitignore
+++ b/Account Kit/java/.gitignore
@@ -3,6 +3,7 @@
/local.properties
/.idea/workspace.xml
/.idea/libraries
+.idea
.DS_Store
/build
/captures
diff --git a/Account Kit/java/README.md b/Account Kit/java/README.md
index a8d6183..406f92c 100644
--- a/Account Kit/java/README.md
+++ b/Account Kit/java/README.md
@@ -1,21 +1,27 @@
# Accountkit-Android-sample
+English | [䏿–‡](https://github.com/HMS-Core/huawei-account-demo/blob/master/Account-Client-Java-Demo/Account_Demo_AndroidStudio/README_ZH.md)
+
## Table of Contents
* [Introduction](#introduction)
- * [Getting Started](#getting-started)
* [Supported Environments](#supported-environments)
+ * [Getting Started](#getting-started)
* [Result](#result)
* [License](#license)
## Introduction
- Android sample code encapsulates APIs of the HUAWEI Account Kit server. It provides sample program for your reference or usage.
- The following describes of Android sample code.
+Android sample code encapsulates APIs of the HUAWEI Account Kit server. It provides sample program for your reference or usage.
+The following describes of Android sample code.
- hmssample: Sample code packages. This package contains code that implements Sign, SignInCode and SignOut.
- logger: This packages contains code that implements logger View.
+hmssample: Sample code packages. This package contains code that implements Sign, SignInCode, SilentSignIn, SignOut and CancelAuthorization.
+logger: This packages contains code that implements logger View.
+
+
+## Supported Environments
+Android SDK Version >= 23 and JDK version >= 1.8 is recommended.
## Getting Started
@@ -30,16 +36,17 @@
(2) Change the value of applicationid in the app-level build.gradle file of the sample project to the package name of your app.
6. Run the sample on your Android device or emulator.
-
-## Supported Environments
- Android SDK Version >= 23 and JDK version >= 1.8 is recommended.
-## Result
- This demo provides demonstration for following scenarios:
- 1. ID-Token Mode Sign In. Sign in and Id-Token verification are both included.
- 2. Authorization Code Mode Sign In.
- 3. Sign out.
-
-
-## License
- Account-kit Android sample is licensed under the [Apache License, version 2.0](http://www.apache.org/licenses/LICENSE-2.0).
+## Result
+This demo provides demonstration for following scenarios:
+1. ID-Token Mode Sign In.
+2. Authorization Code Mode Sign In.
+3. Silent Sign In.
+4. Sign out.
+5. Cancel Authorization.
+
+
+
+
+## License
+Account-kit Android sample is licensed under the [Apache License, version 2.0](http://www.apache.org/licenses/LICENSE-2.0).
diff --git a/Account Kit/java/README_ZH.md b/Account Kit/java/README_ZH.md
new file mode 100644
index 0000000..feb3a58
--- /dev/null
+++ b/Account Kit/java/README_ZH.md
@@ -0,0 +1,42 @@
+# »ªÎªÕʺŷþÎñ¿Í»§¶ËJavaʾÀý´úÂë
+
+ÖÐÎÄ | [English](https://github.com/HMS-Core/huawei-account-demo/blob/master/Account-Client-Java-Demo/Account_Demo_AndroidStudio/README.md)
+
+## Ŀ¼
+* [¼ò½é](#¼ò½é)
+* [»·¾³ÒªÇó](#»·¾³ÒªÇó)
+* [¿ª·¢×¼±¸](#¿ª·¢×¼±¸)
+* [ÔËÐнá¹û](#ÔËÐнá¹û)
+* [ÊÚȨÐí¿É](#ÊÚȨÐí¿É)
+
+## ¼ò½é
+AndroidʾÀý´úÂë¶Ô»ªÎªÕʺŷþÎñ£¨HUAWEI Account Kit£©µÄ¿Í»§¶Ë½Ó¿Ú½øÐзâ×°£¬°üº¬·á¸»µÄʾÀý³ÌÐò£¬·½±ãÄú²Î¿¼»òÖ±½ÓʹÓá£ÏêÇéÈçÏ£º
+
+hmssample£ºÊ¾Àý´úÂë°ü£¬¿ÉʵÏֵǼ¡¢ÊÚȨµÇ¼¡¢¾²Ä¬µÇ¼¡¢Í˳öÕʺźÍÕʺÅÈ¡ÏûÊÚȨ¹¦ÄÜ¡£
+logger£º¿ÉʵÏÖÈÕÖ¾¼Ç¼¡£
+
+## »·¾³ÒªÇó
+ÍÆ¼öʹÓÃAndroid SDK 23¼°ÒÔÉϰ汾¡¢JDK 1.8¼°ÒÔÉϰ汾¡£
+
+## ¿ª·¢×¼±¸
+1. ¼ì²éAndroid Studio¿ª·¢»·¾³ÊÇ·ñ¾ÍÐ÷¡£ÔÚAndroid StudioÖдò¿ª¡°build.gradle¡±ÎļþËùÔÚµÄʾÀý´úÂ빤³ÌĿ¼£¬²¢ÔÚÄúÒѰ²×°×îÐÂ°æ»ªÎªÒÆ¶¯·þÎñ£¨HMS Core£©µÄÉ豸»òÄ£ÄâÆ÷ÉÏÔËÐвâÊÔÓ¦Óá£
+2. ×¢²á[»ªÎªÕʺÅ](https://developer.huawei.com/consumer/cn/)¡£
+3. ´´½¨Ó¦Óò¢ÔÚAppGallery ConnectÖÐÅäÖÃÏà¹ØÐÅÏ¢¡£¾ßÌåÇë²Î¿¼[¿ª·¢×¼±¸](https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/config-agc-0000001050196065)¡£
+4. ¹¹½¨´ËʾÀýdemoǰ£¬ÇëÏȽ«demoµ¼ÈëAndroid Studio£¨3.0¼°ÒÔÉϰ汾£©¡£
+5. ÅäÖÃʾÀý´úÂ룺
+ £¨1£©ÔÚAppGallery ConnectÏÂÔØÄúÓ¦Óõġ°agconnect-services.json¡±Îļþ£¬½«¸ÃÎļþ¿½±´µ½Ó¦Óü¶¸ùĿ¼Ï¡£
+ £¨2£©ÐÞ¸ÄʾÀý¹¤³ÌÖÐÓ¦Óü¶¡°build.gradle¡±ÎļþÖеġ°applicationid¡±ÎªÄú×Ô¼ºµÄÓ¦ÓðüÃû¡£
+6. ÔÚAndroidÉ豸»òÄ£ÄâÆ÷ÉÏÔËÐÐÄúµÄÓ¦Óá£
+
+## ÔËÐнá¹û
+±¾Ê¾Àý´úÂëÌṩÁËÒÔÏÂʹÓó¡¾°£º
+1. ID TokenģʽµÇ¼¡£
+2. Authorization CodeģʽµÇ¼¡£
+3. ¾²Ä¬µÇ¼¡£
+4. Í˳öÕʺš£
+5. ÕʺÅÈ¡ÏûÊÚȨ¡£
+
+
+
+## ÊÚȨÐí¿É
+»ªÎªÕʺŷþÎñAndroidʾÀý´úÂë¾¹ý[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0)ÊÚȨÐí¿É¡£
\ No newline at end of file
diff --git a/Account Kit/java/app/Third Party Open Source Software Notice.docx b/Account Kit/java/app/Third Party Open Source Software Notice.docx
deleted file mode 100644
index c0def5a..0000000
Binary files a/Account Kit/java/app/Third Party Open Source Software Notice.docx and /dev/null differ
diff --git a/Account Kit/java/app/Third Party Open Source Software Notice.pdf b/Account Kit/java/app/Third Party Open Source Software Notice.pdf
new file mode 100644
index 0000000..8b7ffc7
Binary files /dev/null and b/Account Kit/java/app/Third Party Open Source Software Notice.pdf differ
diff --git a/Account Kit/java/app/app.iml b/Account Kit/java/app/app.iml
index 1851702..f51c452 100644
--- a/Account Kit/java/app/app.iml
+++ b/Account Kit/java/app/app.iml
@@ -4,8 +4,6 @@
-
-
@@ -19,8 +17,8 @@
-
-
+
+
@@ -34,15 +32,15 @@
-
-
-
+
+
+
-
-
+
+
@@ -51,13 +49,6 @@
-
-
-
-
-
-
-
@@ -65,6 +56,13 @@
+
+
+
+
+
+
+
@@ -72,13 +70,6 @@
-
-
-
-
-
-
-
@@ -86,40 +77,69 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Account Kit/java/app/build.gradle b/Account Kit/java/app/build.gradle
index 069b76f..feb28ac 100644
--- a/Account Kit/java/app/build.gradle
+++ b/Account Kit/java/app/build.gradle
@@ -24,10 +24,11 @@ android {
}
}
- compileSdkVersion 28
+ compileSdkVersion 29
+ buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.huawei.codelab.hwid"
- minSdkVersion 17
+ minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
@@ -48,11 +49,9 @@ dependencies {
ext.ESPRESSO_VERSION = '2.2.2'
implementation fileTree(include: ['*.jar',], dir: 'libs')
- implementation 'com.android.support:support-compat:28.0.0'
- implementation 'com.google.code.gson:gson:2.8.5'
- implementation 'com.huawei.hms:hwid:5.0.3.301'
- implementation "com.squareup.okhttp3:okhttp:3.14.2"
- implementation 'com.squareup.okio:okio:1.14.1'
+ implementation 'androidx.appcompat:appcompat:1.2.0'
+ implementation "com.google.code.gson:gson:2.8.5"
+ implementation 'com.huawei.hms:hwid:5.2.0.300'
}
repositories { flatDir { dirs '../aars' } }
diff --git a/Account Kit/java/app/src/main/AndroidManifest.xml b/Account Kit/java/app/src/main/AndroidManifest.xml
index 33ca520..f8fb9bd 100644
--- a/Account Kit/java/app/src/main/AndroidManifest.xml
+++ b/Account Kit/java/app/src/main/AndroidManifest.xml
@@ -3,8 +3,6 @@
package="com.huawei.hmssample">
-
-
@@ -13,13 +11,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Account Kit/java/app/src/main/assets/hmssdksample.jpg b/Account Kit/java/app/src/main/assets/hmssdksample.jpg
deleted file mode 100644
index bb1e543..0000000
Binary files a/Account Kit/java/app/src/main/assets/hmssdksample.jpg and /dev/null differ
diff --git a/Account Kit/java/app/src/main/java/com/huawei/hmssample/HuaweiIdActivity.java b/Account Kit/java/app/src/main/java/com/huawei/hmssample/AccountActivity.java
similarity index 52%
rename from Account Kit/java/app/src/main/java/com/huawei/hmssample/HuaweiIdActivity.java
rename to Account Kit/java/app/src/main/java/com/huawei/hmssample/AccountActivity.java
index 47ce042..7ffcf10 100644
--- a/Account Kit/java/app/src/main/java/com/huawei/hmssample/HuaweiIdActivity.java
+++ b/Account Kit/java/app/src/main/java/com/huawei/hmssample/AccountActivity.java
@@ -17,7 +17,9 @@
import android.app.FragmentTransaction;
import android.content.Intent;
+import android.os.Build;
import android.os.Bundle;
+import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
@@ -25,33 +27,34 @@
import com.huawei.hmf.tasks.OnSuccessListener;
import com.huawei.hmf.tasks.Task;
import com.huawei.hms.common.ApiException;
-import com.huawei.hms.support.hwid.HuaweiIdAuthManager;
-import com.huawei.hms.support.hwid.request.HuaweiIdAuthParams;
-import com.huawei.hms.support.hwid.request.HuaweiIdAuthParamsHelper;
-import com.huawei.hms.support.hwid.result.AuthHuaweiId;
-import com.huawei.hms.support.hwid.service.HuaweiIdAuthService;
+import com.huawei.hms.support.account.AccountAuthManager;
+import com.huawei.hms.support.account.request.AccountAuthParams;
+import com.huawei.hms.support.account.request.AccountAuthParamsHelper;
+import com.huawei.hms.support.account.result.AuthAccount;
+import com.huawei.hms.support.account.service.AccountAuthService;
import com.huawei.logger.Log;
import com.huawei.logger.LoggerActivity;
/**
- * Codelab
- * Demonstration of HuaweiId
+ * Codelab
+ * Demonstration of HuaweiId
*/
-public class HuaweiIdActivity extends LoggerActivity implements OnClickListener {
+public class AccountActivity extends LoggerActivity implements OnClickListener {
//Log tag
public static final String TAG = "HuaweiIdActivity";
- private HuaweiIdAuthService mAuthManager;
- private HuaweiIdAuthParams mAuthParam;
+ private AccountAuthService mAuthManager;
+ private AccountAuthParams mAuthParam;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_huaweiid);
- findViewById(R.id.hwid_signin).setOnClickListener(this);
- findViewById(R.id.hwid_signout).setOnClickListener(this);
- findViewById(R.id.hwid_signInCode).setOnClickListener(this);
-
+ setContentView(R.layout.activity_account);
+ findViewById(R.id.account_signin).setOnClickListener(this);
+ findViewById(R.id.account_signout).setOnClickListener(this);
+ findViewById(R.id.account_signInCode).setOnClickListener(this);
+ findViewById(R.id.account_silent_signin).setOnClickListener(this);
+ findViewById(R.id.cancel_authorization).setOnClickListener(this);
//sample log Please ignore
addLogFragment();
}
@@ -76,20 +79,20 @@ protected void onDestroy() {
* Pull up the authorization interface by getSignInIntent
*/
private void signIn() {
- mAuthParam = new HuaweiIdAuthParamsHelper(HuaweiIdAuthParams.DEFAULT_AUTH_REQUEST_PARAM)
+ mAuthParam = new AccountAuthParamsHelper(AccountAuthParams.DEFAULT_AUTH_REQUEST_PARAM)
.setIdToken()
.setAccessToken()
.createParams();
- mAuthManager = HuaweiIdAuthManager.getService(HuaweiIdActivity.this, mAuthParam);
+ mAuthManager = AccountAuthManager.getService(AccountActivity.this, mAuthParam);
startActivityForResult(mAuthManager.getSignInIntent(), Constant.REQUEST_SIGN_IN_LOGIN);
}
private void signInCode() {
- mAuthParam = new HuaweiIdAuthParamsHelper(HuaweiIdAuthParams.DEFAULT_AUTH_REQUEST_PARAM)
+ mAuthParam = new AccountAuthParamsHelper(AccountAuthParams.DEFAULT_AUTH_REQUEST_PARAM)
.setProfile()
.setAuthorizationCode()
.createParams();
- mAuthManager = HuaweiIdAuthManager.getService(HuaweiIdActivity.this, mAuthParam);
+ mAuthManager = AccountAuthManager.getService(AccountActivity.this, mAuthParam);
startActivityForResult(mAuthManager.getSignInIntent(), Constant.REQUEST_SIGN_IN_LOGIN_CODE);
}
@@ -98,32 +101,29 @@ private void signInCode() {
* sign Out by signOut
*/
private void signOut() {
- if (null != mAuthManager) {
- Task signOutTask = mAuthManager.signOut();
- signOutTask.addOnSuccessListener(new OnSuccessListener() {
- @Override
- public void onSuccess(Void aVoid) {
- Log.i(TAG, "signOut Success");
- }
- }).addOnFailureListener(new OnFailureListener() {
- @Override
- public void onFailure(Exception e) {
- Log.i(TAG, "signOut fail");
- }
- });
- }
+ Task signOutTask = mAuthManager.signOut();
+ signOutTask.addOnSuccessListener(new OnSuccessListener() {
+ @Override
+ public void onSuccess(Void aVoid) {
+ Log.i(TAG, "signOut Success");
+ }
+ }).addOnFailureListener(new OnFailureListener() {
+ @Override
+ public void onFailure(Exception e) {
+ Log.i(TAG, "signOut fail");
+ }
+ });
}
-
/**
* Codelab Code
* Silent SignIn by silentSignIn
*/
private void silentSignIn() {
- Task task = mAuthManager.silentSignIn();
- task.addOnSuccessListener(new OnSuccessListener() {
+ Task task = mAuthManager.silentSignIn();
+ task.addOnSuccessListener(new OnSuccessListener() {
@Override
- public void onSuccess(AuthHuaweiId authHuaweiId) {
+ public void onSuccess(AuthAccount authAccount) {
Log.i(TAG, "silentSignIn success");
}
});
@@ -142,47 +142,74 @@ public void onFailure(Exception e) {
@Override
public void onClick(View v) {
switch (v.getId()) {
- case R.id.hwid_signin:
+ case R.id.account_signin:
signIn();
break;
- case R.id.hwid_signout:
+ case R.id.account_signout:
signOut();
break;
- case R.id.hwid_signInCode:
+ case R.id.account_signInCode:
signInCode();
break;
+ case R.id.account_silent_signin:
+ silentSignIn();
+ break;
+ case R.id.cancel_authorization:
+ cancelAuthorization();
+ break;
default:
break;
}
}
+ private void cancelAuthorization() {
+ mAuthParam = new AccountAuthParamsHelper(AccountAuthParams.DEFAULT_AUTH_REQUEST_PARAM)
+ .setProfile()
+ .setAuthorizationCode()
+ .createParams();
+ mAuthManager = AccountAuthManager.getService(AccountActivity.this, mAuthParam);
+ Task task = mAuthManager.cancelAuthorization();
+ task.addOnSuccessListener(new OnSuccessListener() {
+ @Override
+ public void onSuccess(Void aVoid) {
+ Log.i(TAG, "cancelAuthorization success");
+ }
+ });
+ task.addOnFailureListener(new OnFailureListener() {
+ @Override
+ public void onFailure(Exception e) {
+ Log.i(TAG, "cancelAuthorization failure:" + e.getClass().getSimpleName());
+ }
+ });
+ }
+
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == Constant.REQUEST_SIGN_IN_LOGIN) {
//login success
//get user message by parseAuthResultFromIntent
- Task authHuaweiIdTask = HuaweiIdAuthManager.parseAuthResultFromIntent(data);
- if (authHuaweiIdTask.isSuccessful()) {
- AuthHuaweiId huaweiAccount = authHuaweiIdTask.getResult();
- Log.i(TAG, huaweiAccount.getDisplayName() + " signIn success ");
- Log.i(TAG,"AccessToken: " + huaweiAccount.getAccessToken());
+ Task authAccountTask = AccountAuthManager.parseAuthResultFromIntent(data);
+ if (authAccountTask.isSuccessful()) {
+ AuthAccount authAccount = authAccountTask.getResult();
+ Log.i(TAG, authAccount.getDisplayName() + " signIn success ");
+ Log.i(TAG, "AccessToken: " + authAccount.getAccessToken());
} else {
- Log.i(TAG, "signIn failed: " + ((ApiException) authHuaweiIdTask.getException()).getStatusCode());
+ Log.i(TAG, "signIn failed: " + ((ApiException) authAccountTask.getException()).getStatusCode());
}
}
if (requestCode == Constant.REQUEST_SIGN_IN_LOGIN_CODE) {
//login success
- Task authHuaweiIdTask = HuaweiIdAuthManager.parseAuthResultFromIntent(data);
- if (authHuaweiIdTask.isSuccessful()) {
- AuthHuaweiId huaweiAccount = authHuaweiIdTask.getResult();
+ Task authAccountTask = AccountAuthManager.parseAuthResultFromIntent(data);
+ if (authAccountTask.isSuccessful()) {
+ AuthAccount authAccount = authAccountTask.getResult();
Log.i(TAG, "signIn get code success.");
- Log.i(TAG,"ServerAuthCode: " + huaweiAccount.getAuthorizationCode());
+ Log.i(TAG, "ServerAuthCode: " + authAccount.getAuthorizationCode());
/**** english doc:For security reasons, the operation of changing the code to an AT must be performed on your server. The code is only an example and cannot be run. ****/
/**********************************************************************************************/
} else {
- Log.i(TAG, "signIn get code failed: " + ((ApiException) authHuaweiIdTask.getException()).getStatusCode());
+ Log.i(TAG, "signIn get code failed: " + ((ApiException) authAccountTask.getException()).getStatusCode());
}
}
}
diff --git a/Account Kit/java/app/src/main/java/com/huawei/hmssample/Constant.java b/Account Kit/java/app/src/main/java/com/huawei/hmssample/Constant.java
index 934a7a1..df17931 100644
--- a/Account Kit/java/app/src/main/java/com/huawei/hmssample/Constant.java
+++ b/Account Kit/java/app/src/main/java/com/huawei/hmssample/Constant.java
@@ -24,9 +24,4 @@ public class Constant {
public static final int REQUEST_SIGN_IN_LOGIN = 1002;
//login by code
public static final int REQUEST_SIGN_IN_LOGIN_CODE = 1003;
-
- /**
- * your app’s client ID,please replace it of yours
- */
- public static final String CLIENT_ID = "your app's client ID";
}
diff --git a/Account Kit/java/app/src/main/java/com/huawei/logger/LogView.java b/Account Kit/java/app/src/main/java/com/huawei/logger/LogView.java
index 8acbcd4..1cf7afd 100644
--- a/Account Kit/java/app/src/main/java/com/huawei/logger/LogView.java
+++ b/Account Kit/java/app/src/main/java/com/huawei/logger/LogView.java
@@ -18,6 +18,7 @@
import java.text.SimpleDateFormat;
import java.util.Date;
+import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
@@ -25,6 +26,7 @@
import com.huawei.logger.Log.LogNode;
+@SuppressLint("AppCompatCustomView")
public class LogView extends TextView implements LogNode {
private LogNode mNext;
diff --git a/Account Kit/kotlin/app/src/main/res/layout/activity_huaweiid.xml b/Account Kit/java/app/src/main/res/layout/activity_account.xml
similarity index 58%
rename from Account Kit/kotlin/app/src/main/res/layout/activity_huaweiid.xml
rename to Account Kit/java/app/src/main/res/layout/activity_account.xml
index a7c413c..fd54f0b 100644
--- a/Account Kit/kotlin/app/src/main/res/layout/activity_huaweiid.xml
+++ b/Account Kit/java/app/src/main/res/layout/activity_account.xml
@@ -10,29 +10,39 @@
android:paddingLeft="@dimen/activity_title_margin"
android:paddingTop="@dimen/activity_title_margin"
android:paddingRight="@dimen/activity_title_margin"
- tools:context="com.huawei.hmssample.HuaweiIdActivity">
+ tools:context="com.huawei.hmssample.AccountActivity">
+ android:text="@string/sign_in" />
+ android:text="@string/revokeAccess" />
+ android:text="@string/silent_sign_in" />
+
+
+
+
hmssample
- HuaweiId
- HuaweiPay
- HuaweiPUSH
- HuaweiSns
- HuaweiLocation
- HuaweiOpendevice
- HuaweiPpskit
- HuaweiGame
- Huawei Account Kit Demo
- Huawei Account Usage Process
- ID-Token Mode Signln
- SignOut
- AuthorizationCode Mode Signln
+ Account Kit Demo
+ Account Usage Process
+ ID-Token Mode Signln
+ SignOut
+ AuthorizationCode Mode Signln
+ Silent SignIn
+ Cancel Authorization
diff --git a/Account Kit/java/build.gradle b/Account Kit/java/build.gradle
index f596cad..d42d8db 100644
--- a/Account Kit/java/build.gradle
+++ b/Account Kit/java/build.gradle
@@ -8,9 +8,9 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.3.2'
+ classpath 'com.android.tools.build:gradle:3.4.0'
// Codelab Configuration - agc plugin
- classpath 'com.huawei.agconnect:agcp:1.2.0.300'
+ classpath 'com.huawei.agconnect:agcp:1.4.2.300'
}
}
diff --git a/Account Kit/java/gradle/wrapper/gradle-wrapper.properties b/Account Kit/java/gradle/wrapper/gradle-wrapper.properties
index a14b340..4a27d5b 100644
--- a/Account Kit/java/gradle/wrapper/gradle-wrapper.properties
+++ b/Account Kit/java/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
diff --git a/Account Kit/kotlin/.gitignore b/Account Kit/kotlin/.gitignore
index 39fb081..0f6ca2d 100644
--- a/Account Kit/kotlin/.gitignore
+++ b/Account Kit/kotlin/.gitignore
@@ -7,3 +7,4 @@
/build
/captures
.externalNativeBuild
+.idea
diff --git a/Account Kit/kotlin/README.md b/Account Kit/kotlin/README.md
index 6582684..66f314d 100644
--- a/Account Kit/kotlin/README.md
+++ b/Account Kit/kotlin/README.md
@@ -1,43 +1,41 @@
-## Accountkit-Android-sample
+# Accountkit-Android-sample
+English | [䏿–‡](https://github.com/HMS-Core/huawei-account-demo/blob/master/Account-Client-Kotlin-Demo/README_ZH.md)
## Table of Contents
* [Introduction](#introduction)
* [Installation](#installation)
- * [Configuration ](#configuration )
* [Supported Environments](#supported-environments)
- * [Sample Code](# Sample Code)
+ * [Sample Code](#sample-code)
* [License](#license)
## Introduction
- Android sample code encapsulates APIs of the HUAWEI Account Kit server. It provides sample program for your reference or usage.
- The following describes of Android sample code.
+Android sample code encapsulates APIs of the HUAWEI Account Kit server. It provides sample program for your reference or usage.
+The following describes of Android sample code.
- hmssample: Sample code packages. This package contains code that implements Sign, SignInCode and SignOut.
- logger: This packages contains code that implements logger View.
+hmssample: Sample code packages. This package contains code that implements Sign, SignInCode, SilentSignIn, SignOut and CancelAuthorization.
+logger: This packages contains code that implements logger View.
## Installation
- To use functions provided by examples, please make sure Huawei Mobile Service 4.0 has been installed on your cellphone.
+To use functions provided by examples, please make sure Huawei Mobile Service 4.0 has been installed on your cellphone.
+
+
## Supported Environments
- Android SDK Version >= 23 and JDK version >= 1.8 is recommended.
+Android SDK Version >= 23 and JDK version >= 1.8 is recommended.
-## Configurations
- The following describes parameters in Contant.java
- CLIENT_ID: App ID, which can be obtained from AppGallery Connect website, please replace it with your app's client ID.
- CERT_URL: Request CERT_URL to get public key's URL from jwks_uri, then get public key.
- ID_TOKEN_ISSUE: The value that ISS string of ID Token should be equal to.
## Sample Code
- This demo provides demonstration for following scenarios:
- 1. ID-Token Mode Sign In. Sign in and Id-Token verification are both included.
- 2. Authorization Code Mode Sign In.
- 3. Sign out.
+This demo provides demonstration for following scenarios:
+1. ID-Token Mode Sign In.
+2. Authorization Code Mode Sign In.
+3. Silent Sign In.
+4. Sign out.
+5. Cancel Authorization.
- The business logic of ID-Token Mode Sign In and Authorization Code Mode Sign In are implemented in HuaweiIdActivity.java while Id-Token verification are implemented in IDTokenParse.java.
-
+The business logic of ID-Token Mode Sign In and Authorization Code Mode Sign In are implemented in AccountActivity.kt.
## License
- Account-kit Android sample is licensed under the [Apache License, version 2.0](http://www.apache.org/licenses/LICENSE-2.0).
+Account-kit Android sample is licensed under the [Apache License, version 2.0](http://www.apache.org/licenses/LICENSE-2.0).
diff --git a/Account Kit/kotlin/README_ZH.md b/Account Kit/kotlin/README_ZH.md
new file mode 100644
index 0000000..da25583
--- /dev/null
+++ b/Account Kit/kotlin/README_ZH.md
@@ -0,0 +1,34 @@
+# »ªÎªÕʺŷþÎñ¿Í»§¶ËKotlinʾÀý´úÂë
+
+ÖÐÎÄ | [English](https://github.com/HMS-Core/huawei-account-demo/blob/master/Account-Client-Kotlin-Demo/README.md)
+
+## Ŀ¼
+* [¼ò½é](#¼ò½é)
+* [°²×°](#°²×°)
+* [»·¾³ÒªÇó](#»·¾³ÒªÇó)
+* [ʾÀý´úÂë](#ʾÀý´úÂë)
+* [ÊÚȨÐí¿É](#ÊÚȨÐí¿É)
+
+## ¼ò½é
+AndroidʾÀý´úÂë¶Ô»ªÎªÕʺŷþÎñ£¨HUAWEI Account Kit£©µÄ¿Í»§¶Ë½Ó¿Ú½øÐзâ×°£¬°üº¬·á¸»µÄʾÀý³ÌÐò£¬·½±ãÄú²Î¿¼»òÖ±½ÓʹÓá£ÏêÇéÈçÏ£º
+hmssample£ºÊ¾Àý´úÂë°ü£¬¿ÉʵÏֵǼ¡¢ÊÚȨµÇ¼¡¢¾²Ä¬µÇ¼¡¢Í˳öÕʺźÍÕʺÅÈ¡ÏûÊÚȨ¹¦ÄÜ¡£
+logger£º¿ÉʵÏÖÈÕÖ¾¼Ç¼¡£
+
+## °²×°
+ÈçÐèʹÓñ¾Ê¾Àý´úÂëÖеĸ÷ÖÖ¹¦ÄÜ£¬ÇëÈ·±£ÄúµÄÉ豸ÉÏÒѰ²×°»ªÎªÒƶ¯·þÎñ£¨HMS Core£©4.0¡£
+
+## »·¾³ÒªÇó
+ÍÆ¼öʹÓÃAndroid SDK 23¼°ÒÔÉϰ汾¡¢JDK 1.8¼°ÒÔÉϰ汾¡£
+
+## ʾÀý´úÂë
+±¾Ê¾Àý´úÂëÌṩÁËÒÔÏÂʹÓó¡¾°£º
+1. ID TokenģʽµÇ¼¡£
+2. Authorization CodeģʽµÇ¼¡£
+3. ¾²Ä¬µÇ¼¡£
+4. Í˳öÕʺš£
+5. ÕʺÅÈ¡ÏûÊÚȨ¡£
+
+¾ßÌåÒµÎñÂß¼£ºÔÚAccountActivity.ktÖÐʵÏÖID TokenģʽµÇ¼ºÍAuthorization CodeµÇ¼¡£
+
+## ÊÚȨÐí¿É
+»ªÎªÕʺŷþÎñAndroidʾÀý´úÂë¾¹ý[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0)ÊÚȨÐí¿É¡£
\ No newline at end of file
diff --git a/Account Kit/kotlin/app/Third Party Open Source Software Notice.docx b/Account Kit/kotlin/app/Third Party Open Source Software Notice.docx
deleted file mode 100644
index 7be1280..0000000
Binary files a/Account Kit/kotlin/app/Third Party Open Source Software Notice.docx and /dev/null differ
diff --git a/Account Kit/kotlin/app/Third Party Open Source Software Notice.pdf b/Account Kit/kotlin/app/Third Party Open Source Software Notice.pdf
new file mode 100644
index 0000000..8b7ffc7
Binary files /dev/null and b/Account Kit/kotlin/app/Third Party Open Source Software Notice.pdf differ
diff --git a/Account Kit/kotlin/app/build.gradle b/Account Kit/kotlin/app/build.gradle
index 7567555..21bf645 100644
--- a/Account Kit/kotlin/app/build.gradle
+++ b/Account Kit/kotlin/app/build.gradle
@@ -26,10 +26,11 @@ android {
}
}
- compileSdkVersion 28
+ compileSdkVersion 29
+ buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.huawei.codelab.hwid"
- minSdkVersion 17
+ minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
@@ -50,11 +51,9 @@ dependencies {
ext.ESPRESSO_VERSION = '2.2.2'
implementation fileTree(include: ['*.jar',], dir: 'libs')
- implementation 'com.android.support:support-compat:28.0.0'
- implementation 'com.google.code.gson:gson:2.8.5'
- implementation 'com.huawei.hms:hwid:5.0.3.301'
- implementation "com.squareup.okhttp3:okhttp:3.14.2"
- implementation 'com.squareup.okio:okio:1.14.1'
+ implementation 'androidx.appcompat:appcompat:1.2.0'
+ implementation "com.google.code.gson:gson:2.8.5"
+ implementation 'com.huawei.hms:hwid:5.2.0.300'
}
repositories { flatDir { dirs '../aars' } }
diff --git a/Account Kit/kotlin/app/src/androidTest/java/com/huawei/hmssample/ExampleInstrumentedTest.kt b/Account Kit/kotlin/app/src/androidTest/java/com/huawei/hmssample/ExampleInstrumentedTest.kt
deleted file mode 100644
index 482b89b..0000000
--- a/Account Kit/kotlin/app/src/androidTest/java/com/huawei/hmssample/ExampleInstrumentedTest.kt
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.huawei.hmssample
-
-import androidx.test.platform.app.InstrumentationRegistry
-import androidx.test.ext.junit.runners.AndroidJUnit4
-
-import org.junit.Test
-import org.junit.runner.RunWith
-
-import org.junit.Assert.*
-
-/**
- * Instrumented test, which will execute on an Android device.
- *
- * See [testing documentation](http://d.android.com/tools/testing).
- */
-@RunWith(AndroidJUnit4::class)
-class ExampleInstrumentedTest {
- @Test
- fun useAppContext() {
- // Context of the app under test.
- val appContext = InstrumentationRegistry.getInstrumentation().targetContext
- assertEquals("com.huawei.hmssample", appContext.packageName)
- }
-}
diff --git a/Account Kit/kotlin/app/src/main/AndroidManifest.xml b/Account Kit/kotlin/app/src/main/AndroidManifest.xml
index d18c91a..f8fb9bd 100644
--- a/Account Kit/kotlin/app/src/main/AndroidManifest.xml
+++ b/Account Kit/kotlin/app/src/main/AndroidManifest.xml
@@ -3,8 +3,6 @@
package="com.huawei.hmssample">
-
-
@@ -13,13 +11,6 @@
-
-
-
-
-
-
-
diff --git a/Account Kit/kotlin/app/src/main/java/com/huawei/hmssample/AccountActivity.kt b/Account Kit/kotlin/app/src/main/java/com/huawei/hmssample/AccountActivity.kt
new file mode 100644
index 0000000..714a308
--- /dev/null
+++ b/Account Kit/kotlin/app/src/main/java/com/huawei/hmssample/AccountActivity.kt
@@ -0,0 +1,174 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+ *
+ * Licensed 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 CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.huawei.hmssample
+
+import android.content.Intent
+import android.os.Bundle
+import android.view.View
+import com.huawei.hms.common.ApiException
+import com.huawei.hms.support.account.AccountAuthManager
+import com.huawei.hms.support.account.request.AccountAuthParams
+import com.huawei.hms.support.account.request.AccountAuthParamsHelper
+import com.huawei.hms.support.account.service.AccountAuthService
+import com.huawei.logger.Log
+import com.huawei.logger.LoggerActivity
+import kotlinx.android.synthetic.main.activity_account.*
+
+class AccountActivity : LoggerActivity() {
+ //Log tag
+ val TAG = "HuaweiIdActivity"
+ private var mAuthManager: AccountAuthService? = null
+ private var mAuthParam: AccountAuthParams? = null
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_account)
+ account_signin.setOnClickListener(mOnClickListener)
+ account_signout.setOnClickListener(mOnClickListener)
+ account_signInCode.setOnClickListener(mOnClickListener)
+ account_silent_signin.setOnClickListener(mOnClickListener)
+ cancel_authorization.setOnClickListener(mOnClickListener)
+ //sample log Please ignore
+ addLogFragment()
+ }
+
+
+ override fun onStart() {
+ super.onStart()
+ }
+
+ override fun onStop() {
+ super.onStop()
+ }
+
+ override fun onDestroy() {
+ super.onDestroy()
+ }
+
+ /**
+ * Codelab Code
+ * Pull up the authorization interface by getSignInIntent
+ */
+ private fun signIn() {
+ mAuthParam = AccountAuthParamsHelper(AccountAuthParams.DEFAULT_AUTH_REQUEST_PARAM)
+ .setIdToken()
+ .setAccessToken()
+ .createParams()
+ mAuthManager = AccountAuthManager.getService(this@AccountActivity, mAuthParam)
+ startActivityForResult(mAuthManager?.signInIntent, Constant.REQUEST_SIGN_IN_LOGIN)
+ }
+
+ private fun signInCode() {
+ mAuthParam = AccountAuthParamsHelper(AccountAuthParams.DEFAULT_AUTH_REQUEST_PARAM)
+ .setProfile()
+ .setAuthorizationCode()
+ .createParams()
+ mAuthManager = AccountAuthManager.getService(this@AccountActivity, mAuthParam)
+ startActivityForResult(mAuthManager?.signInIntent, Constant.REQUEST_SIGN_IN_LOGIN_CODE)
+ }
+
+ /**
+ * Codelab Code
+ * sign Out by signOut
+ */
+ private fun signOut() {
+ val signOutTask = mAuthManager?.signOut()
+ signOutTask?.addOnSuccessListener {
+ Log.i(TAG, "signOut Success")
+ }?.addOnFailureListener {
+ Log.i(TAG, "signOut fail")
+ }
+ }
+
+ /**
+ * Codelab Code
+ * Silent SignIn by silentSignIn
+ */
+ private fun silentSignIn() {
+ val task = mAuthManager?.silentSignIn()
+ task?.addOnSuccessListener { Log.i(TAG, "silentSignIn success") }
+ task?.addOnFailureListener { e ->
+ //if Failed use getSignInIntent
+ if (e is ApiException) {
+ val apiException = e
+ signIn()
+ }
+ }
+ }
+
+ private val mOnClickListener: View.OnClickListener = object : View.OnClickListener {
+ override fun onClick(v: View?) {
+ when (v?.id) {
+ R.id.account_signin -> signIn()
+ R.id.account_signout -> signOut()
+ R.id.account_signInCode -> signInCode()
+ R.id.account_silent_signin -> silentSignIn()
+ R.id.cancel_authorization -> cancelAuthorization()
+ }
+ }
+ }
+
+ private fun cancelAuthorization() {
+ mAuthParam = AccountAuthParamsHelper(AccountAuthParams.DEFAULT_AUTH_REQUEST_PARAM)
+ .setProfile()
+ .setAuthorizationCode()
+ .createParams()
+ mAuthManager = AccountAuthManager.getService(this@AccountActivity, mAuthParam)
+ val task = mAuthManager?.cancelAuthorization()
+ task?.addOnSuccessListener { Log.i(TAG, "cancelAuthorization success") }
+ task?.addOnFailureListener { e -> Log.i(TAG, "cancelAuthorization failure:" + e.javaClass.simpleName) }
+ }
+
+
+ override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
+ super.onActivityResult(requestCode, resultCode, data)
+ if (requestCode == Constant.REQUEST_SIGN_IN_LOGIN) {
+ //login success
+ //get user message by parseAuthResultFromIntent
+ val authAccountTask = AccountAuthManager.parseAuthResultFromIntent(data)
+ if (authAccountTask.isSuccessful) {
+ val authAccount = authAccountTask.result
+ Log.i(TAG, authAccount.getDisplayName() + " signIn success ")
+ Log.i(TAG, "AccessToken: " + authAccount.getAccessToken())
+ } else {
+ Log.i(TAG, "signIn failed: " + (authAccountTask.exception as ApiException).statusCode)
+ }
+ }
+ if (requestCode == Constant.REQUEST_SIGN_IN_LOGIN_CODE) {
+ //login success
+ val authAccountTask = AccountAuthManager.parseAuthResultFromIntent(data)
+ if (authAccountTask.isSuccessful) {
+ val authAccount = authAccountTask.result
+ Log.i(TAG, "signIn get code success.")
+ Log.i(TAG, "ServerAuthCode: " + authAccount.authorizationCode)
+ /**** english doc:For security reasons, the operation of changing the code to an AT must be performed on your server. The code is only an example and cannot be run. */
+ /** */
+ } else {
+ Log.i(TAG, "signIn get code failed: " + (authAccountTask.exception as ApiException).statusCode)
+ }
+ }
+ }
+
+ /**
+ * sample log Please ignore
+ */
+ private fun addLogFragment() {
+ val transaction = fragmentManager.beginTransaction()
+ val fragment = LogFragment()
+ transaction.replace(R.id.framelog, fragment)
+ transaction.commit()
+ }
+}
\ No newline at end of file
diff --git a/Account Kit/kotlin/app/src/main/java/com/huawei/hmssample/Constant.kt b/Account Kit/kotlin/app/src/main/java/com/huawei/hmssample/Constant.kt
index 223922b..a09cfca 100644
--- a/Account Kit/kotlin/app/src/main/java/com/huawei/hmssample/Constant.kt
+++ b/Account Kit/kotlin/app/src/main/java/com/huawei/hmssample/Constant.kt
@@ -1,23 +1,34 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+ *
+ * Licensed 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 CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.huawei.hmssample
-
object Constant {
- const val IS_LOG = 1
+ val IS_LOG = 1
//login
- const val REQUEST_SIGN_IN_LOGIN = 1002
+ val REQUEST_SIGN_IN_LOGIN = 1002
//login by code
- const val REQUEST_SIGN_IN_LOGIN_CODE = 1003
- /**
- * your app’s client ID,please replace it of yours
- */
- const val CLIENT_ID = "101090009"
+ val REQUEST_SIGN_IN_LOGIN_CODE = 1003
+
/**
* JWK JSON Web Key endpoint, developer can get the JWK of the last two days from this endpoint
* See more about JWK in http://self-issued.info/docs/draft-ietf-jose-json-web-key.html
*/
- const val CERT_URL = "https://oauth-login.cloud.huawei.com/oauth2/v3/certs"
+ val CERT_URL = "https://oauth-login.cloud.huawei.com/oauth2/v3/certs"
/**
* Id Token issue
*/
- const val ID_TOKEN_ISSUE = "https://accounts.huawei.com"
+ val ID_TOKEN_ISSUE = "https://accounts.huawei.com"
}
\ No newline at end of file
diff --git a/Account Kit/kotlin/app/src/main/java/com/huawei/hmssample/HuaweiIdActivity.kt b/Account Kit/kotlin/app/src/main/java/com/huawei/hmssample/HuaweiIdActivity.kt
deleted file mode 100644
index 9586c78..0000000
--- a/Account Kit/kotlin/app/src/main/java/com/huawei/hmssample/HuaweiIdActivity.kt
+++ /dev/null
@@ -1,147 +0,0 @@
-package com.huawei.hmssample
-
-import android.content.Intent
-import android.os.Bundle
-import android.view.View
-import com.huawei.hms.common.ApiException
-import com.huawei.hms.support.hwid.HuaweiIdAuthManager
-import com.huawei.hms.support.hwid.request.HuaweiIdAuthParams
-import com.huawei.hms.support.hwid.request.HuaweiIdAuthParamsHelper
-import com.huawei.hms.support.hwid.service.HuaweiIdAuthService
-import com.huawei.logger.Log
-import com.huawei.logger.LoggerActivity
-import kotlinx.android.synthetic.main.activity_huaweiid.*
-
-/**
- * Codelab
- * Demonstration of HuaweiId
- */
-class HuaweiIdActivity : LoggerActivity() {
-
- //Log tag
- val TAG = "HuaweiIdActivity"
- private var mAuthManager: HuaweiIdAuthService? = null
- private var mAuthParam: HuaweiIdAuthParams? = null
-
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- setContentView(R.layout.activity_huaweiid)
- initListener()
- //sample log Please ignore
- addLogFragment()
- }
-
- private fun initListener() {
- hwid_signin.setOnClickListener(mOnClickListener)
- hwid_signout.setOnClickListener(mOnClickListener)
- hwid_signInCode.setOnClickListener(mOnClickListener)
- }
-
- private val mOnClickListener: View.OnClickListener = View.OnClickListener {
- when (it.id) {
- R.id.hwid_signin -> {
- signIn()
- }
- R.id.hwid_signout -> {
- signOut()
- }
- R.id.hwid_signInCode -> {
- signInCode()
- }
- }
- }
-
- /**
- * Codelab Code
- * Pull up the authorization interface by getSignInIntent
- */
- private fun signIn() {
- mAuthParam = HuaweiIdAuthParamsHelper(HuaweiIdAuthParams.DEFAULT_AUTH_REQUEST_PARAM)
- .setIdToken()
- .setAccessToken()
- .createParams()
- mAuthManager = HuaweiIdAuthManager.getService(this@HuaweiIdActivity, mAuthParam)
- startActivityForResult(mAuthManager?.signInIntent, Constant.REQUEST_SIGN_IN_LOGIN)
- }
-
- private fun signInCode() {
- mAuthParam = HuaweiIdAuthParamsHelper(HuaweiIdAuthParams.DEFAULT_AUTH_REQUEST_PARAM)
- .setProfile()
- .setAuthorizationCode()
- .createParams()
- mAuthManager = HuaweiIdAuthManager.getService(this@HuaweiIdActivity, mAuthParam)
- startActivityForResult(mAuthManager?.signInIntent, Constant.REQUEST_SIGN_IN_LOGIN_CODE)
- }
-
- /**
- * Codelab Code
- * sign Out by signOut
- */
- private fun signOut() {
- val signOutTask = mAuthManager?.signOut()
- signOutTask?.let {
- it.addOnSuccessListener {
- Log.i(TAG, "signOut Success")
- }.addOnFailureListener {
- Log.i(TAG, "signOut fail")
- }
- }
- }
-
- /**
- * Codelab Code
- * Silent SignIn by silentSignIn
- */
- private fun silentSignIn() {
- val task = mAuthManager?.silentSignIn()
- task?.let {
- it.addOnSuccessListener { Log.i(TAG, "silentSignIn success") }
- it.addOnFailureListener { e ->
- //if Failed use getSignInIntent
- if (e is ApiException) {
- val apiException = e
- signIn()
- }
- }
- }
- }
-
-
- override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
- super.onActivityResult(requestCode, resultCode, data)
- when(requestCode) {
- Constant.REQUEST_SIGN_IN_LOGIN -> {
- val authHuaweiIdTask = HuaweiIdAuthManager.parseAuthResultFromIntent(data)
- if (authHuaweiIdTask.isSuccessful) {
- val huaweiAccount = authHuaweiIdTask.result
- Log.i(TAG, huaweiAccount.displayName + " signIn success ")
- Log.i(TAG, "AccessToken: " + huaweiAccount.accessToken)
- } else {
- Log.i(TAG, "signIn failed: " + (authHuaweiIdTask.exception as ApiException).statusCode)
- }
- }
- Constant.REQUEST_SIGN_IN_LOGIN_CODE ->{
- //login success
- val authHuaweiIdTask = HuaweiIdAuthManager.parseAuthResultFromIntent(data)
- if (authHuaweiIdTask.isSuccessful) {
- val huaweiAccount = authHuaweiIdTask.result
- Log.i(TAG, "signIn get code success.")
- Log.i(TAG, "ServerAuthCode: " + huaweiAccount.authorizationCode)
- /**** english doc:For security reasons, the operation of changing the code to an AT must be performed on your server. The code is only an example and cannot be run. */
- } else {
- Log.i(TAG, "signIn get code failed: " + (authHuaweiIdTask.exception as ApiException).statusCode)
- }
- }
- }
- }
-
- /**
- * sample log Please ignore
- */
- private fun addLogFragment() {
- val transaction = fragmentManager.beginTransaction()
- val fragment = LogFragment()
- transaction.replace(R.id.framelog, fragment)
- transaction.commit()
- }
-}
\ No newline at end of file
diff --git a/Account Kit/kotlin/app/src/main/java/com/huawei/hmssample/IDTokenParser.kt b/Account Kit/kotlin/app/src/main/java/com/huawei/hmssample/IDTokenParser.kt
deleted file mode 100644
index 4f05f41..0000000
--- a/Account Kit/kotlin/app/src/main/java/com/huawei/hmssample/IDTokenParser.kt
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
- *
- * Licensed 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 CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.huawei.hmssample
-
-import android.util.Base64
-import com.auth0.jwk.InvalidPublicKeyException
-import com.auth0.jwk.Jwk
-import com.auth0.jwt.JWT
-import com.auth0.jwt.algorithms.Algorithm
-import com.auth0.jwt.exceptions.JWTDecodeException
-import com.auth0.jwt.exceptions.JWTVerificationException
-import com.auth0.jwt.exceptions.TokenExpiredException
-import com.huawei.hmssample.common.ICallBack
-import com.huawei.logger.Log.i
-import okhttp3.Call
-import okhttp3.Callback
-import okhttp3.OkHttpClient
-import okhttp3.Request
-import okhttp3.Response
-import org.json.JSONArray
-import org.json.JSONException
-import org.json.JSONObject
-import java.io.IOException
-import java.nio.charset.Charset
-import java.security.interfaces.RSAPublicKey
-
-/**
- * Function Description
- * This is a demo for verify Id Token issued by HuaWei OAuth Server
- * The demo just show how to verify Id Token in your local server
- * The open source software depended by this demo may have vulnerabilities,
- * please refer to the open source software release website and update to
- * the latest version or replace it with other open source software.
- * Local validation is much more efficiently than by access the tokeninfo endpoint
- * You'd better learn more about the JWT and JWK for understanding this demo
- * See more about JWT in https://jwt.io/
- * See more about JWK in http://self-issued.info/docs/draft-ietf-jose-json-web-key.html
- */
-class IDTokenParser {
-
- companion object {
- private const val MAX_PUBLIC_KEY_SIZE = 4
- private val TAG = IDTokenParser::class.java.simpleName
- private val DEFAULT_CHARSET =
- Charset.forName("UTF-8")
- }
-
- private var mJsonArray: JSONArray? = null
- private var mRSAPublicKey: RSAPublicKey? = null
-
- /**
- * catch the public key in this map
- */
- private val keyId2PublicKey: MutableMap = HashMap()
-
- /**
- * Verify Id Token
- *
- * @param idToken Your IdToken
- * @param callBack Asyn CallBack
- * @throws InvalidPublicKeyException throw when InvalidPublicKeyException happened
- */
- @Throws(InvalidPublicKeyException::class, JWTDecodeException::class)
- fun verify(idToken: String?, callBack: ICallBack) {
- val decoder = JWT.decode(idToken)
- getRSAPublicKeyByKidAsyn(decoder.keyId, object : ICallBack {
- override fun onSuccess() {
- try {
- val algorithm = Algorithm.RSA256(mRSAPublicKey, null)
- val verifier = JWT.require(algorithm).build()
- val payload = String(Base64.decode(decoder.payload,
- Base64.URL_SAFE
- ), DEFAULT_CHARSET)
- val jsonObject = JSONObject(payload)
- // Verify the value of iss
- if (decoder.issuer != Constant.ID_TOKEN_ISSUE) {
- callBack.onFailed()
- return
- }
- // Verify your app’s client ID.
- if (decoder.audience.size > 0 && decoder.audience[0] != Constant.CLIENT_ID) {
- callBack.onFailed()
- return
- }
- // verify signature
- verifier.verify(decoder)
- jsonObject.put("alg", decoder.algorithm)
- jsonObject.put("typ", decoder.type)
- jsonObject.put("kid", decoder.keyId)
- callBack.onSuccess(jsonObject.toString())
- } catch (e: JWTDecodeException) {
- callBack.onFailed()
- } catch (e: JSONException) {
- callBack.onFailed()
- } catch (e: TokenExpiredException) {
- callBack.onFailed() // jwt token is expire
- } catch (e: JWTVerificationException) {
- callBack.onFailed() // VERIFY SIGNATURE failed
- } catch (e: Exception) {
- callBack.onFailed()
- } catch (e: Error) {
- callBack.onFailed()
- }
- }
-
- override fun onSuccess(result: String?) {}
- override fun onFailed() {
- callBack.onFailed()
- }
- })
- }
-
- /**
- * get the RSAPublicKey by kid
- * Please cache the RSAPublicKey
- * In the demo we cache it in a map
- *
- * @param keyId Input keyId
- * @param callBack asyn callback
- * @throws InvalidPublicKeyException throw when InvalidPublicKeyException happened
- */
- @Throws(InvalidPublicKeyException::class)
- private fun getRSAPublicKeyByKidAsyn(keyId: String, callBack: ICallBack) {
- getJwks(object : ICallBack {
- override fun onSuccess() {
- if (keyId2PublicKey[keyId] != null) {
- mRSAPublicKey = keyId2PublicKey[keyId]
- callBack.onSuccess()
- return
- }
- if (mJsonArray == null) {
- mRSAPublicKey = null
- return
- }
-
- if (keyId2PublicKey.size > MAX_PUBLIC_KEY_SIZE) {
- keyId2PublicKey.clear()
- }
- try {
- for (i in 0 until mJsonArray!!.length()) {
- val kid = mJsonArray!!.getJSONObject(i).getString("kid")
- keyId2PublicKey[kid] =
- getRsaPublicKeyByJwk(mJsonArray!!.getJSONObject(i))
- }
- mRSAPublicKey = keyId2PublicKey[keyId]
- callBack.onSuccess()
- } catch (e: Exception) {
- mRSAPublicKey = null
- i(TAG, "getRSAPublicKeyByKid failed: " + e.message)
- }
- }
-
- override fun onSuccess(result: String?) {}
- override fun onFailed() {
- mRSAPublicKey = null
- }
- })
- }
-
- /**
- * get jwks from the https://oauth-login.cloud.huawei.com/oauth2/v3/certs endpoint
- * because the jwk update each day, please cache the jwk,here is the example of jwks
- * See more about JWK in http://self-issued.info/docs/draft-ietf-jose-json-web-key.html
- * {
- * "keys":[
- * {
- * "kty":"RSA",
- * "e":"AQAB",
- * "use":"sig",
- * "kid":"670c64e7443941582167f405e0a62a08c6db5becb090f397a45aa572fa000553",
- * "alg":"RS256",
- * "n":"AK4C-h_gWpziPmzo6PEBuwxHHD2F9x_LgiE5zl73fVmzBTo3KzRu8nXURQA-uV857r_qEhfsJQyy0Nr_wIkfAU86JsFHcGwzLlJucN12EHXOFY6nLti9tSWUAWaa2HAZuJytyc-DyguLR_nH5IKmGhmcgI26zUG07UPUB2Xnsn-T-K1npnaNI7K7xlbGQy5UUPFjQPBRiV2R_-iGf5KIqCwebXe24wzhbWMnmfb0lilAZyYO7PiQ8UgJJTuZOMbCD7P0dUJwxitHo81OyoVJUGQZpLBZqHVSsRpC0UZuxMEMBPza4R55yZS3gAKkE1xILabCUV-CJ6Gp4c4J1tiFNcc"
- * },
- * {
- * "kty":"RSA",
- * "e":"AQAB",
- * "use":"sig",
- * "kid":"1226cda6b82e6aa140ffe2f32515f1929c3048b2cdba267935fb71963fd3e57a",
- * "alg":"RS256",
- * "n":"AMNDMIxlySrGqeV7V3s865ZwzBD0hXVq8ys0H_ZQGMbfWss0WuwHrmIRdq8OQrYoN_o2KZKtUPBsJpJMAZ26JeGqf3dsU_wFEEjNOfrDdyIs86K6gKfQFLewUNycmzMhlqDFlCujAAF33RYn-Xg7UXG3pO_2PdcD1zIrxtawQZ-TQTMgH5mgX_lWO1YfYSuB91xEvUZII1ZYDjLcbkzjZCbvfU4tT2_PV8-gU0UaHI-pcyreUwB1EhleDZUW8MiaIVSr6UIYfHflxBQRrwCcFy-q_u-OeYBS683djmbF-FKZVKlipKim6hGpqIb-PC8pHO_WmM01sNvvMAkF1D5bg0M"
- * }
- * ]
- * }
- */
- private fun getJwks(iCallBack: ICallBack) {
- val okHttpClient = OkHttpClient()
- val request = Request.Builder().url(Constant.CERT_URL).build()
- val call = okHttpClient.newCall(request)
- call.enqueue(object : Callback {
- override fun onFailure(call: Call, e: IOException) {
- i(TAG, "Get ID Token failed.")
- iCallBack.onFailed()
- }
-
- override fun onResponse(call: Call, response: Response) {
- if (!response.isSuccessful) return
- try {
- val res = response.body?.string() ?: ""
- val jsonObject = JSONObject(res)
- mJsonArray = jsonObject.getJSONArray("keys")
- iCallBack.onSuccess()
- } catch (e: NullPointerException) {
- i(TAG, "parse JsonArray failed.${e.message}")
- iCallBack.onFailed()
- } catch (e: JSONException) {
- i(TAG, "parse JsonArray failed.${e.message}")
- iCallBack.onFailed()
- } catch (e: IOException) {
- i(TAG, "parse JsonArray failed.${e.message}")
- iCallBack.onFailed()
- } catch (e: Exception) {
- i(TAG, "parse JsonArray failed.${e.message}")
- iCallBack.onFailed()
- }
- }
- })
- }
-
- /**
- * get RsaPublicKey from a JWK
- * @param jwkObject received JSONObject
- * @return RsaPublicKey from a JWK
- * @throws InvalidPublicKeyException
- */
- @Throws(InvalidPublicKeyException::class, JSONException::class)
- private fun getRsaPublicKeyByJwk(jwkObject: JSONObject): RSAPublicKey {
-
- val additionalAttributes: MutableMap = HashMap()
- additionalAttributes["n"] = jwkObject.getString("n")
- additionalAttributes["e"] = jwkObject.getString("e")
- val operations: List = ArrayList()
- val jwk = Jwk(
- jwkObject.getString("kid"),
- jwkObject.getString("kty"),
- jwkObject.getString("alg"),
- jwkObject.getString("use"),
- operations,
- null,
- null,
- null,
- additionalAttributes
- )
- return jwk.publicKey as RSAPublicKey
- }
-}
\ No newline at end of file
diff --git a/Account Kit/kotlin/app/src/main/java/com/huawei/hmssample/LogFragment.kt b/Account Kit/kotlin/app/src/main/java/com/huawei/hmssample/LogFragment.kt
index d573ccd..48f21e3 100644
--- a/Account Kit/kotlin/app/src/main/java/com/huawei/hmssample/LogFragment.kt
+++ b/Account Kit/kotlin/app/src/main/java/com/huawei/hmssample/LogFragment.kt
@@ -1,3 +1,18 @@
+/*
+Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+ Licensed 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 CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
package com.huawei.hmssample
import android.annotation.SuppressLint
diff --git a/Account Kit/kotlin/app/src/main/java/com/huawei/hmssample/common/ICallBack.kt b/Account Kit/kotlin/app/src/main/java/com/huawei/hmssample/common/ICallBack.kt
deleted file mode 100644
index 283a27d..0000000
--- a/Account Kit/kotlin/app/src/main/java/com/huawei/hmssample/common/ICallBack.kt
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
- *
- * Licensed 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 CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.huawei.hmssample.common
-
-/**
- * Call back
- */
-interface ICallBack {
- fun onSuccess()
- fun onSuccess(result: String?)
- fun onFailed()
-}
\ No newline at end of file
diff --git a/Account Kit/kotlin/app/src/main/java/com/huawei/logger/LogCatWrapper.kt b/Account Kit/kotlin/app/src/main/java/com/huawei/logger/LogCatWrapper.kt
index e5b7d5f..2e119c1 100644
--- a/Account Kit/kotlin/app/src/main/java/com/huawei/logger/LogCatWrapper.kt
+++ b/Account Kit/kotlin/app/src/main/java/com/huawei/logger/LogCatWrapper.kt
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+ *
+ * Licensed 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 CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.huawei.logger
/**
diff --git a/Account Kit/kotlin/app/src/main/java/com/huawei/logger/LogNode.kt b/Account Kit/kotlin/app/src/main/java/com/huawei/logger/LogNode.kt
deleted file mode 100644
index ea696c8..0000000
--- a/Account Kit/kotlin/app/src/main/java/com/huawei/logger/LogNode.kt
+++ /dev/null
@@ -1,5 +0,0 @@
-package com.huawei.logger
-
-interface LogNode {
- fun println(priority: Int, tag: String?, msg: String?, tr: Throwable?)
-}
\ No newline at end of file
diff --git a/Account Kit/kotlin/app/src/main/java/com/huawei/logger/LogView.kt b/Account Kit/kotlin/app/src/main/java/com/huawei/logger/LogView.kt
index 7b69ae4..71806dc 100644
--- a/Account Kit/kotlin/app/src/main/java/com/huawei/logger/LogView.kt
+++ b/Account Kit/kotlin/app/src/main/java/com/huawei/logger/LogView.kt
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+ *
+ * Licensed 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 CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.huawei.logger
import android.app.Activity
diff --git a/Account Kit/kotlin/app/src/main/java/com/huawei/logger/LoggerActivity.kt b/Account Kit/kotlin/app/src/main/java/com/huawei/logger/LoggerActivity.kt
index 699c63f..cde52f7 100644
--- a/Account Kit/kotlin/app/src/main/java/com/huawei/logger/LoggerActivity.kt
+++ b/Account Kit/kotlin/app/src/main/java/com/huawei/logger/LoggerActivity.kt
@@ -1,19 +1,34 @@
+/*
+Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
+
+ Licensed 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 CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
package com.huawei.logger
import android.app.Activity
import com.huawei.hmssample.LogFragment
import com.huawei.hmssample.R
-open class LoggerActivity :Activity() {
+open class LoggerActivity : Activity() {
override fun onStart() {
- // TODO Auto-generated method stub
super.onStart()
initializeLogging()
}
private fun initializeLogging() {
- val logFragment = fragmentManager.findFragmentById(R.id.framelog) as LogFragment
+ val logFragment = fragmentManager.findFragmentById(R.id.framelog) as LogFragment
+
val logcat = LogCatWrapper()
logcat.setNext(logFragment.getLogView()!!)
Log.setLogNode(logcat)
diff --git a/Account Kit/kotlin/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/Account Kit/kotlin/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
deleted file mode 100644
index 2b068d1..0000000
--- a/Account Kit/kotlin/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Account Kit/kotlin/app/src/main/res/drawable/ic_launcher_background.xml b/Account Kit/kotlin/app/src/main/res/drawable/ic_launcher_background.xml
deleted file mode 100644
index 07d5da9..0000000
--- a/Account Kit/kotlin/app/src/main/res/drawable/ic_launcher_background.xml
+++ /dev/null
@@ -1,170 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Account Kit/kotlin/app/src/main/res/layout/activity_account.xml b/Account Kit/kotlin/app/src/main/res/layout/activity_account.xml
new file mode 100644
index 0000000..fd54f0b
--- /dev/null
+++ b/Account Kit/kotlin/app/src/main/res/layout/activity_account.xml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Account Kit/kotlin/app/src/main/res/values/strings.xml b/Account Kit/kotlin/app/src/main/res/values/strings.xml
index 3987054..6cc4947 100644
--- a/Account Kit/kotlin/app/src/main/res/values/strings.xml
+++ b/Account Kit/kotlin/app/src/main/res/values/strings.xml
@@ -2,18 +2,12 @@
hmssample
- HuaweiId
- HuaweiPay
- HuaweiPUSH
- HuaweiSns
- HuaweiLocation
- HuaweiOpendevice
- HuaweiPpskit
- HuaweiGame
- Huawei Account Kit Demo
- Huawei Account Usage Process
- ID-Token Mode Signln
- SignOut
- AuthorizationCode Mode Signln
+ Account Kit Demo
+ Account Usage Process
+ ID-Token Mode Signln
+ SignOut
+ AuthorizationCode Mode Signln
+ Silent SignIn
+ Cancel Authorization
diff --git a/Account Kit/kotlin/app/src/test/java/com/huawei/hmssample/ExampleUnitTest.kt b/Account Kit/kotlin/app/src/test/java/com/huawei/hmssample/ExampleUnitTest.kt
deleted file mode 100644
index 417dcbc..0000000
--- a/Account Kit/kotlin/app/src/test/java/com/huawei/hmssample/ExampleUnitTest.kt
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.huawei.hmssample
-
-import org.junit.Test
-
-import org.junit.Assert.*
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * See [testing documentation](http://d.android.com/tools/testing).
- */
-class ExampleUnitTest {
- @Test
- fun addition_isCorrect() {
- assertEquals(4, 2 + 2)
- }
-}
diff --git a/Account Kit/kotlin/build.gradle b/Account Kit/kotlin/build.gradle
index e4603dc..ce8dfc8 100644
--- a/Account Kit/kotlin/build.gradle
+++ b/Account Kit/kotlin/build.gradle
@@ -4,14 +4,14 @@ buildscript {
ext.kotlin_version = '1.3.31'
repositories {
// Codelab Configuration - HMS SDK
- maven { url 'http://developer.huawei.com/repo/' }
+ maven { url 'https://developer.huawei.com/repo/' }
google()
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.3.2'
+ classpath 'com.android.tools.build:gradle:3.4.0'
// Codelab Configuration - agc plugin
- classpath 'com.huawei.agconnect:agcp:1.2.0.300'
+ classpath 'com.huawei.agconnect:agcp:1.4.2.300'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
@@ -19,7 +19,7 @@ buildscript {
allprojects {
repositories {
// Codelab Configuration - HMS SDK
- maven { url 'http://developer.huawei.com/repo/' }
+ maven { url 'https://developer.huawei.com/repo/' }
google()
jcenter()
}
diff --git a/Account Kit/kotlin/gradle/wrapper/gradle-wrapper.properties b/Account Kit/kotlin/gradle/wrapper/gradle-wrapper.properties
index a14b340..4a27d5b 100644
--- a/Account Kit/kotlin/gradle/wrapper/gradle-wrapper.properties
+++ b/Account Kit/kotlin/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
diff --git a/Map Kit/app/build.gradle b/Map Kit/app/build.gradle
index bb9db79..5a12d1e 100644
--- a/Map Kit/app/build.gradle
+++ b/Map Kit/app/build.gradle
@@ -37,5 +37,5 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.aar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
- implementation 'com.huawei.hms:maps:5.0.3.301'
+ implementation 'com.huawei.hms:maps:5.0.5.301'
}
diff --git a/Map Kit/build.gradle b/Map Kit/build.gradle
index d17a9e1..a52ec71 100644
--- a/Map Kit/build.gradle
+++ b/Map Kit/build.gradle
@@ -8,7 +8,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
- classpath 'com.huawei.agconnect:agcp:1.4.1.300'
+ classpath 'com.huawei.agconnect:agcp:1.4.2.300'
}
}
diff --git a/Push Kit/README.md b/Push Kit/README.md
index b4f274c..6f76bfb 100644
--- a/Push Kit/README.md
+++ b/Push Kit/README.md
@@ -8,7 +8,7 @@
* [Installation](#installation)
* [Configuration ](#configuration)
* [Supported Environments](#supported-environments)
- * [Hardware Requirements](#Hardware-Requirements)
+ * [Hardware Requirements](#Hardware-Requirement)
* [License and Terms](#license-and-terms)
diff --git a/Site Kit/app/build.gradle b/Site Kit/app/build.gradle
index 779fb00..3752e61 100644
--- a/Site Kit/app/build.gradle
+++ b/Site Kit/app/build.gradle
@@ -41,5 +41,5 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
- implementation 'com.huawei.hms:site:5.0.3.301'
+ implementation 'com.huawei.hms:site:5.0.5.301'
}
diff --git a/Site Kit/build.gradle b/Site Kit/build.gradle
index 0f1b34d..d41aef7 100644
--- a/Site Kit/build.gradle
+++ b/Site Kit/build.gradle
@@ -8,7 +8,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
- classpath 'com.huawei.agconnect:agcp:1.4.1.300'
+ classpath 'com.huawei.agconnect:agcp:1.4.2.300'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}