Skip to content

Commit

Permalink
Auth: Return error for services known to not be supported in hasCapab…
Browse files Browse the repository at this point in the history
…ilities
  • Loading branch information
mar-v-in authored and YT-Advanced committed May 5, 2024
1 parent 316ba06 commit ea48d3e
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,14 @@ public Bundle requestGoogleAccountsAccess(String packageName) throws RemoteExcep

@Override
public int hasCapabilities(HasCapabilitiesRequest request) throws RemoteException {
Log.w(TAG, "Not implemented: hasCapabilities(" + request.account + ", " + Arrays.toString(request.capabilities) + ")");
PackageUtils.assertGooglePackagePermission(context, GooglePackagePermission.ACCOUNT);
List<String> services = Arrays.asList(AccountManager.get(context).getUserData(request.account, "services").split(","));
for (String capability : request.capabilities) {
if (capability.startsWith("service_") && !services.contains(capability.substring(8)) || !services.contains(capability)) {
return 6;
}
}
Log.w(TAG, "Not fully implemented: hasCapabilities(" + request.account + ", " + Arrays.toString(request.capabilities) + ")");
return 1;
}

Expand Down

0 comments on commit ea48d3e

Please sign in to comment.