Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0ded14de authored by Marvin W.'s avatar Marvin W. 🐿️
Browse files

Remove direct references of account type "com.google"

parent a6edceeb
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import android.content.pm.PackageManager;
import android.preference.PreferenceManager;
import android.util.Log;

import com.google.android.gms.R;

import org.microg.gms.common.PackageUtils;

import java.io.IOException;
@@ -43,6 +45,7 @@ public class AuthManager {
    private AccountManager accountManager;
    private Account account;
    private String packageSignature;
    private String accountType;

    public AuthManager(Context context, String accountName, String packageName, String service) {
        this.context = context;
@@ -51,6 +54,12 @@ public class AuthManager {
        this.service = service;
    }

    public String getAccountType() {
        if (accountType == null)
            accountType = context.getString(R.string.google_account_type);
        return accountType;
    }

    public AccountManager getAccountManager() {
        if (accountManager == null)
            accountManager = AccountManager.get(context);
@@ -59,7 +68,7 @@ public class AuthManager {

    public Account getAccount() {
        if (account == null)
            account = new Account(accountName, "com.google");
            account = new Account(accountName, getAccountType());
        return account;
    }

+1 −3
Original line number Diff line number Diff line
@@ -38,8 +38,6 @@ import static org.microg.gms.auth.AskPermissionActivity.EXTRA_CONSENT_DATA;
public class AuthManagerServiceImpl extends IAuthManagerService.Stub {
    private static final String TAG = "GmsAuthManagerSvc";

    public static final String GOOGLE_ACCOUNT_TYPE = "com.google";

    public static final String KEY_AUTHORITY = "authority";
    public static final String KEY_CALLBACK_INTENT = "callback_intent";
    public static final String KEY_CALLER_UID = "callerUid";
@@ -83,7 +81,7 @@ public class AuthManagerServiceImpl extends IAuthManagerService.Stub {
                Intent i = new Intent(context, AskPermissionActivity.class);
                i.putExtras(extras);
                i.putExtra(KEY_ANDROID_PACKAGE_NAME, packageName);
                i.putExtra(KEY_ACCOUNT_TYPE, GOOGLE_ACCOUNT_TYPE);
                i.putExtra(KEY_ACCOUNT_TYPE, authManager.getAccountType());
                i.putExtra(KEY_ACCOUNT_NAME, accountName);
                i.putExtra(KEY_AUTHTOKEN, scope);
                if (res.consentDataBase64 != null)
+4 −2
Original line number Diff line number Diff line
@@ -62,10 +62,12 @@ public class LoginActivity extends AssistantActivity {
    private static final String COOKIE_OAUTH_TOKEN = "oauth_token";

    private WebView webView;
    private String accountType;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        accountType = getString(R.string.google_account_type);
        webView = createWebView(this);
        webView.addJavascriptInterface(new JsBridge(), "mm");
        ((ViewGroup) findViewById(R.id.auth_root)).addView(webView);
@@ -79,7 +81,7 @@ public class LoginActivity extends AssistantActivity {
        if (getIntent().hasExtra(EXTRA_TOKEN)) {
            if (getIntent().hasExtra(EXTRA_EMAIL)) {
                AccountManager accountManager = AccountManager.get(LoginActivity.this);
                Account account = new Account(getIntent().getStringExtra(EXTRA_EMAIL), "com.google");
                Account account = new Account(getIntent().getStringExtra(EXTRA_EMAIL), accountType);
                accountManager.addAccountExplicitly(account, getIntent().getStringExtra(EXTRA_TOKEN), null);
                retrieveGmsToken(account);
            } else {
@@ -168,7 +170,7 @@ public class LoginActivity extends AssistantActivity {
                    @Override
                    public void onResponse(AuthResponse response) {
                        AccountManager accountManager = AccountManager.get(LoginActivity.this);
                        Account account = new Account(response.email, "com.google");
                        Account account = new Account(response.email, accountType);
                        if (accountManager.addAccountExplicitly(account, response.token, null)) {
                            accountManager.setAuthToken(account, "SID", response.Sid);
                            accountManager.setAuthToken(account, "LSID", response.LSid);
+1 −1
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ class AccountAuthenticator extends AbstractAccountAuthenticator {

    @Override
    public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType, String[] requiredFeatures, Bundle options) throws NetworkErrorException {
        if (accountType.equals(accountType)) {
        if (accountType.equals(this.accountType)) {
            final Intent i = new Intent(context, LoginActivity.class);
            i.putExtras(options);
            i.putExtra(LoginActivity.EXTRA_TMPL, LoginActivity.TMPL_NEW_ACCOUNT);
+4 −1
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import android.accounts.AccountManager;
import android.content.ContentResolver;
import android.content.Context;

import com.google.android.gms.R;

import org.microg.gms.auth.AuthManager;
import org.microg.gms.common.Constants;
import org.microg.gms.common.DeviceConfiguration;
@@ -42,7 +44,8 @@ public class CheckinManager {
            return null;
        List<CheckinClient.Account> accounts = new ArrayList<>();
        AccountManager accountManager = AccountManager.get(context);
        for (Account account : accountManager.getAccountsByType("com.google")) {
        String accountType = context.getString(R.string.google_account_type);
        for (Account account : accountManager.getAccountsByType(accountType)) {
            String token = new AuthManager(context, account.name, Constants.GMS_PACKAGE_NAME, "ac2dm").getAuthToken();
            accounts.add(new CheckinClient.Account(account.name, token));
        }
Loading