You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[google_sign_in] Use an activity for credential requests (#9497)
`getCredentialManager` is documented to require an activity context, not an application context; this fixes it to use the activity context since in some configurations using the application context will throw an error.
Fixesflutter/flutter#171122
## Pre-Review Checklist
[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
Copy file name to clipboardExpand all lines: packages/google_sign_in/google_sign_in_android/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java
+12-1Lines changed: 12 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -219,6 +219,17 @@ public void getCredential(
219
219
return;
220
220
}
221
221
222
+
// getCredentialAsync requires an acitivity context, not an application context, per
223
+
// the API docs.
224
+
Activityactivity = getActivity();
225
+
if (activity == null) {
226
+
ResultUtilsKt.completeWithGetCredentialFailure(
227
+
callback,
228
+
newGetCredentialFailure(
229
+
GetCredentialFailureType.NO_ACTIVITY, "No activity available", null));
Copy file name to clipboardExpand all lines: packages/google_sign_in/google_sign_in_android/android/src/main/kotlin/io/flutter/plugins/googlesignin/Messages.kt
+11-6Lines changed: 11 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -48,18 +48,23 @@ enum class GetCredentialFailureType(val raw: Int) {
48
48
UNEXPECTED_CREDENTIAL_TYPE(0),
49
49
/** Indicates that a server client ID was not provided. */
50
50
MISSING_SERVER_CLIENT_ID(1),
51
+
/**
52
+
* Indicates that the user needs to be prompted for authorization, but there is no current
53
+
* activity to prompt in.
54
+
*/
55
+
NO_ACTIVITY(2),
51
56
/** The request was internally interrupted. */
52
-
INTERRUPTED(2),
57
+
INTERRUPTED(3),
53
58
/** The request was canceled by the user. */
54
-
CANCELED(3),
59
+
CANCELED(4),
55
60
/** No matching credential was found. */
56
-
NO_CREDENTIAL(4),
61
+
NO_CREDENTIAL(5),
57
62
/** The provider was not properly configured. */
58
-
PROVIDER_CONFIGURATION_ISSUE(5),
63
+
PROVIDER_CONFIGURATION_ISSUE(6),
59
64
/** The credential manager is not supported on this device. */
Copy file name to clipboardExpand all lines: packages/google_sign_in/google_sign_in_android/android/src/test/java/io/flutter/plugins/googlesignin/GoogleSignInTest.java
+52-12Lines changed: 52 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -191,6 +191,7 @@ public void getCredential_returnsAuthenticationInfo() {
0 commit comments