0
0
Fork 0
mirror of https://github.com/YTVanced/VancedMicroG synced 2024-11-24 04:05:13 +00:00

Remove direct references of account type "com.google"

This commit is contained in:
mar-v-in 2015-03-12 16:49:25 +01:00
parent a6edceebec
commit 0ded14dee1
7 changed files with 27 additions and 10 deletions

View file

@ -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;
}

View file

@ -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)

View file

@ -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);

View file

@ -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);

View file

@ -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));
}

View file

@ -22,6 +22,8 @@ import android.app.IntentService;
import android.content.Intent;
import android.util.Log;
import com.google.android.gms.R;
import org.microg.gms.people.PeopleManager;
public class CheckinService extends IntentService {
@ -38,7 +40,8 @@ public class CheckinService extends IntentService {
if (info != null) {
Log.d(TAG, "Checked in as " + Long.toHexString(info.androidId));
}
for (Account account : AccountManager.get(this).getAccountsByType("com.google")) {
String accountType = getString(R.string.google_account_type);
for (Account account : AccountManager.get(this).getAccountsByType(accountType)) {
PeopleManager.loadUserInfo(this, account);
}
} catch (Exception e) {

View file

@ -24,6 +24,7 @@ import android.os.Parcel;
import android.os.RemoteException;
import android.util.Log;
import com.google.android.gms.R;
import com.google.android.gms.common.data.DataHolder;
import com.google.android.gms.common.internal.ICancelToken;
import com.google.android.gms.people.internal.IPeopleCallbacks;
@ -42,7 +43,8 @@ public class PeopleServiceImpl extends IPeopleService.Stub {
Log.d(TAG, "loadOwners: " + var2 + ", " + var3 + ", " + accountName + ", " + var5 + ", " + sortOrder);
AccountManager accountManager = AccountManager.get(context);
Bundle result = new Bundle();
for (Account account : accountManager.getAccountsByType("com.google")) {
String accountType = context.getString(R.string.google_account_type);
for (Account account : accountManager.getAccountsByType(accountType)) {
if (accountName == null || account.name.equals(accountName)) {
result.putParcelable(account.name, null);
}