|
|
@@ -71,7 +71,6 @@ public class SharedViewModel extends ViewModel {
|
|
|
user.setUid(authAccount.getUnionId());
|
|
|
user.setUname(authAccount.getDisplayName());
|
|
|
user.setPicture(authAccount.getAvatarUriString());
|
|
|
-// LogUtil.i(task, "User Info "+user);
|
|
|
updateUserData(user);
|
|
|
}
|
|
|
});
|
|
|
@@ -89,11 +88,16 @@ public class SharedViewModel extends ViewModel {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 使用华为账号登录前,需要调用此方法获取AccountAuthService实例
|
|
|
+ */
|
|
|
public AccountAuthService getAccountAuthServiceForSignIn() {
|
|
|
+ // 调用AccountAuthParamsHelper.setIdToken方法请求授权。
|
|
|
AccountAuthParams mAuthParam = new AccountAuthParamsHelper(AccountAuthParams.DEFAULT_AUTH_REQUEST_PARAM)
|
|
|
.setIdToken()
|
|
|
.setAccessToken()
|
|
|
.createParams();
|
|
|
+ // 调用AccountAuthManager.getService方法初始化AccountAuthService对象。
|
|
|
mAuthManager = AccountAuthManager.getService(CourseLearningDemoApplication.getContext(), mAuthParam);
|
|
|
return mAuthManager;
|
|
|
}
|
|
|
@@ -118,6 +122,9 @@ public class SharedViewModel extends ViewModel {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 取消华为账号授权
|
|
|
+ */
|
|
|
public void cancelAuthorization(){
|
|
|
mAuthManager.cancelAuthorization().addOnCompleteListener(new OnCompleteListener<Void>() {
|
|
|
@Override
|