diff --git a/play-services-core/src/main/java/org/microg/gms/auth/AskPermissionActivity.java b/play-services-core/src/main/java/org/microg/gms/auth/AskPermissionActivity.java
index d7701784a4..ee665636ef 100644
--- a/play-services-core/src/main/java/org/microg/gms/auth/AskPermissionActivity.java
+++ b/play-services-core/src/main/java/org/microg/gms/auth/AskPermissionActivity.java
@@ -92,7 +92,7 @@ private IntentData(Intent intent) {
try {
consentData = ConsentData.ADAPTER.decode(intent.getByteArrayExtra(EXTRA_CONSENT_DATA));
} catch (Exception e) {
- // Ignore
+ Log.w(TAG, "ConsentData decode failed", e);
}
}
}
@@ -169,24 +169,34 @@ public void onAllow() {
findViewById(R.id.progress_bar).setVisibility(VISIBLE);
findViewById(R.id.no_progress_bar).setVisibility(GONE);
new Thread(() -> {
+ Bundle result = null;
try {
AuthResponse response = authManager.requestAuthWithBackgroundResolution(data.fromAccountManager);
- Bundle result = new Bundle();
+ result = new Bundle();
result.putString(KEY_AUTHTOKEN, response.auth);
result.putString(KEY_ACCOUNT_NAME, data.accountName);
result.putString(KEY_ACCOUNT_TYPE, data.accountType);
result.putString(KEY_ANDROID_PACKAGE_NAME, data.packageName);
result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, true);
- setAccountAuthenticatorResult(result);
} catch (IOException e) {
Log.w(TAG, e);
}
- finish();
+ final Bundle finalResult = result;
+ runOnUiThread(() -> {
+ Intent resultIntent = new Intent();
+ if (finalResult != null) {
+ setAccountAuthenticatorResult(finalResult);
+ resultIntent.putExtras(finalResult);
+ }
+ setResult(RESULT_OK, resultIntent);
+ finish();
+ });
}).start();
}
public void onDeny() {
authManager.setPermitted(false);
+ setResult(RESULT_CANCELED);
finish();
}
@@ -204,12 +214,9 @@ private boolean isOAuth() {
}
private String getScopeLabel(String scope) {
- if (data.consentData != null) {
- for (ConsentData.ScopeDetails scopeDetails : data.consentData.scopes) {
- if (scope.equals(scopeDetails.id)) {
- return scopeDetails.title;
- }
- }
+ ConsentData.ScopeDetails matched = findScopeDetails(scope);
+ if (matched != null && matched.title != null) {
+ return matched.title;
}
String labelResourceId = "permission_scope_";
String escapedScope = scope.replace("/", "_").replace("-", "_");
@@ -226,16 +233,31 @@ private String getScopeLabel(String scope) {
}
private String getScopeDescription(String scope) {
- if (data.consentData != null) {
- for (ConsentData.ScopeDetails scopeDetails : data.consentData.scopes) {
- if (scope.equals(scopeDetails.id)) {
- return scopeDetails.description;
- }
- }
+ ConsentData.ScopeDetails matched = findScopeDetails(scope);
+ return matched != null ? matched.description : null;
+ }
+
+ private ConsentData.ScopeDetails findScopeDetails(String scope) {
+ if (data.consentData == null || scope == null) return null;
+ String aliasFull = canonicalOidcScope(scope);
+ for (ConsentData.ScopeDetails sd : data.consentData.scopes) {
+ if (scope.equals(sd.id)) return sd;
+ if (aliasFull != null && aliasFull.equals(sd.id)) return sd;
}
return null;
}
+ private static String canonicalOidcScope(String scope) {
+ switch (scope) {
+ case "email":
+ return "https://www.googleapis.com/auth/userinfo.email";
+ case "profile":
+ return "https://www.googleapis.com/auth/userinfo.profile";
+ default:
+ return null;
+ }
+ }
+
private String getServiceLabel(String service) {
int labelResource = getResources().getIdentifier("permission_service_" + service + "_label", "string", getPackageName());
if (labelResource != 0) {
diff --git a/play-services-core/src/main/res/layout/ask_permission.xml b/play-services-core/src/main/res/layout/ask_permission.xml
index 7795e13fc9..1de3d4c7dc 100644
--- a/play-services-core/src/main/res/layout/ask_permission.xml
+++ b/play-services-core/src/main/res/layout/ask_permission.xml
@@ -24,7 +24,7 @@
android:gravity="center_horizontal"
android:paddingTop="10dp"
android:text="@string/account_manager_title"
- android:textColor="?attr/colorPrimary"
+ android:textColor="?android:attr/textColorPrimary"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
@@ -88,7 +88,7 @@
android:padding="15dp"
android:gravity="center_horizontal"
android:textSize="18sp"
- android:textColor="?attr/colorAccent"
+ android:textColor="?android:attr/textColorPrimary"
android:text="@string/ask_scope_permission_title"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
@@ -102,7 +102,7 @@
-
\ No newline at end of file
+
diff --git a/play-services-core/src/main/res/layout/ask_permission_list_entry.xml b/play-services-core/src/main/res/layout/ask_permission_list_entry.xml
index dbc58106a3..bea07ff666 100644
--- a/play-services-core/src/main/res/layout/ask_permission_list_entry.xml
+++ b/play-services-core/src/main/res/layout/ask_permission_list_entry.xml
@@ -34,15 +34,17 @@
-
\ No newline at end of file
+