0
0
Fork 0
mirror of https://github.com/YTVanced/VancedMicroG synced 2024-12-05 01:07:27 +00:00

Return empty list of accounts when receiving weird requests

This is an attempt to fix #1052
This commit is contained in:
Marvin W 2020-12-01 18:27:43 +01:00
parent f7190091af
commit c0324710f3
No known key found for this signature in database
GPG key ID: 072E9235DB996F2A
2 changed files with 12 additions and 7 deletions

View file

@ -35,6 +35,7 @@ import org.microg.gms.common.PackageUtils;
import java.util.Arrays; import java.util.Arrays;
import static org.microg.gms.auth.AuthConstants.DEFAULT_ACCOUNT_TYPE;
import static org.microg.gms.auth.AuthConstants.PROVIDER_EXTRA_ACCOUNTS; import static org.microg.gms.auth.AuthConstants.PROVIDER_EXTRA_ACCOUNTS;
import static org.microg.gms.auth.AuthConstants.PROVIDER_EXTRA_CLEAR_PASSWORD; import static org.microg.gms.auth.AuthConstants.PROVIDER_EXTRA_CLEAR_PASSWORD;
import static org.microg.gms.auth.AuthConstants.PROVIDER_METHOD_CLEAR_PASSWORD; import static org.microg.gms.auth.AuthConstants.PROVIDER_METHOD_CLEAR_PASSWORD;
@ -65,15 +66,20 @@ public class AccountContentProvider extends ContentProvider {
if (getContext().checkCallingPermission(Manifest.permission.GET_ACCOUNTS) != PackageManager.PERMISSION_GRANTED) if (getContext().checkCallingPermission(Manifest.permission.GET_ACCOUNTS) != PackageManager.PERMISSION_GRANTED)
throw new SecurityException("Access denied, missing GET_ACCOUNTS or EXTENDED_ACCESS permission"); throw new SecurityException("Access denied, missing GET_ACCOUNTS or EXTENDED_ACCESS permission");
} }
if (PROVIDER_METHOD_GET_ACCOUNTS.equals(method) && AuthConstants.DEFAULT_ACCOUNT_TYPE.equals(arg)) { if (PROVIDER_METHOD_GET_ACCOUNTS.equals(method)) {
Bundle result = new Bundle(); Bundle result = new Bundle();
AccountManager am = AccountManager.get(getContext());
Account[] accounts = null; Account[] accounts = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { if (arg != null && (arg.equals(DEFAULT_ACCOUNT_TYPE) || arg.startsWith(DEFAULT_ACCOUNT_TYPE + "."))) {
accounts = am.getAccountsByTypeForPackage(arg, packageName); AccountManager am = AccountManager.get(getContext());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
accounts = am.getAccountsByTypeForPackage(arg, packageName);
}
if (accounts == null || accounts.length == 0) {
accounts = am.getAccountsByType(arg);
}
} }
if (accounts == null || accounts.length == 0) { if (accounts == null) {
accounts = am.getAccountsByType(arg); accounts = new Account[0];
} }
result.putParcelableArray(PROVIDER_EXTRA_ACCOUNTS, accounts); result.putParcelableArray(PROVIDER_EXTRA_ACCOUNTS, accounts);
return result; return result;

View file

@ -18,7 +18,6 @@ package org.microg.gms.wallet;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.os.Parcel; import android.os.Parcel;
import android.os.RemoteException; import android.os.RemoteException;
import android.util.Log; import android.util.Log;