From 01e7e2518ff3d73efccb8fdeb98ab18625380f2c Mon Sep 17 00:00:00 2001 From: rlatapy-luna Date: Thu, 13 Dec 2018 14:36:08 +0100 Subject: [PATCH 1/2] Add release public method Allow deallocate resources and unbind services --- .../com/amazonaws/mobileconnectors/cognitoauth/Auth.java | 7 +++++++ .../mobileconnectors/cognitoauth/AuthClient.java | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/aws-android-sdk-cognitoauth/src/main/java/com/amazonaws/mobileconnectors/cognitoauth/Auth.java b/aws-android-sdk-cognitoauth/src/main/java/com/amazonaws/mobileconnectors/cognitoauth/Auth.java index 1f805192f8..ed0d8fa80c 100644 --- a/aws-android-sdk-cognitoauth/src/main/java/com/amazonaws/mobileconnectors/cognitoauth/Auth.java +++ b/aws-android-sdk-cognitoauth/src/main/java/com/amazonaws/mobileconnectors/cognitoauth/Auth.java @@ -655,4 +655,11 @@ public Auth setUsername(final String username) { this.user.setUsername(username); return this; } + + /** + * Release resources used by {@link Auth} + */ + public void release() { + this.user.unbindServiceConnection(); + } } diff --git a/aws-android-sdk-cognitoauth/src/main/java/com/amazonaws/mobileconnectors/cognitoauth/AuthClient.java b/aws-android-sdk-cognitoauth/src/main/java/com/amazonaws/mobileconnectors/cognitoauth/AuthClient.java index 0e222883a4..d9d2586b2a 100644 --- a/aws-android-sdk-cognitoauth/src/main/java/com/amazonaws/mobileconnectors/cognitoauth/AuthClient.java +++ b/aws-android-sdk-cognitoauth/src/main/java/com/amazonaws/mobileconnectors/cognitoauth/AuthClient.java @@ -221,6 +221,15 @@ public void getTokens(final Uri uri) { getTokens(uri, userHandler); } + + /** + * Unbind {@link AuthClient#mCustomTabsServiceConnection} + */ + public void unbindServiceConnection() { + if(mCustomTabsServiceConnection != null) + context.unbindService(mCustomTabsServiceConnection); + } + /** * Internal method to exchange code for tokens. *

From 1591728fbae28694a304ac7a49d517ab08a9d901 Mon Sep 17 00:00:00 2001 From: rlatapy-luna Date: Thu, 13 Dec 2018 14:37:10 +0100 Subject: [PATCH 2/2] Fix duplicate client creation Lead to double binding to service --- .../java/com/amazonaws/mobileconnectors/cognitoauth/Auth.java | 1 - 1 file changed, 1 deletion(-) diff --git a/aws-android-sdk-cognitoauth/src/main/java/com/amazonaws/mobileconnectors/cognitoauth/Auth.java b/aws-android-sdk-cognitoauth/src/main/java/com/amazonaws/mobileconnectors/cognitoauth/Auth.java index ed0d8fa80c..334352b9c7 100644 --- a/aws-android-sdk-cognitoauth/src/main/java/com/amazonaws/mobileconnectors/cognitoauth/Auth.java +++ b/aws-android-sdk-cognitoauth/src/main/java/com/amazonaws/mobileconnectors/cognitoauth/Auth.java @@ -159,7 +159,6 @@ private Auth(final Context context, this.signOutRedirectUri = signOutRedirectUri; this.scopes = scopes; this.user = new AuthClient(context, this); - this.user = new AuthClient(context, this); this.user.setUserHandler(userHandler); this.userPoolId = userPoolId; this.advancedSecurityDataCollectionFlag = advancedSecurityDataCollectionFlag;