mirror of
https://github.com/YTVanced/VancedMicroG
synced 2024-11-27 21:53:00 +00:00
Fix account id retrieval for registered G+ accounts
The bug can cause Chrome/Chromium to cause an endless loop (=> high CPU usage, reduced battery time). Please remove and re-add your account...
This commit is contained in:
parent
9624bb7185
commit
8df631cd95
2 changed files with 9 additions and 2 deletions
|
@ -26,6 +26,7 @@ import android.net.ConnectivityManager;
|
|||
import android.net.NetworkInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
|
@ -247,6 +248,8 @@ public class LoginActivity extends AssistantActivity {
|
|||
accountManager.setUserData(account, "oauthAccessToken", "1");
|
||||
accountManager.setUserData(account, "firstName", response.firstName);
|
||||
accountManager.setUserData(account, "lastName", response.lastName);
|
||||
if (!TextUtils.isEmpty(response.accountId))
|
||||
accountManager.setUserData(account, "GoogleUserId", response.accountId);
|
||||
|
||||
retrieveGmsToken(account);
|
||||
setResult(RESULT_OK);
|
||||
|
@ -282,7 +285,9 @@ public class LoginActivity extends AssistantActivity {
|
|||
@Override
|
||||
public void onResponse(AuthResponse response) {
|
||||
authManager.storeResponse(response);
|
||||
PeopleManager.loadUserInfo(LoginActivity.this, account);
|
||||
String accountId = PeopleManager.loadUserInfo(LoginActivity.this, account);
|
||||
if (!TextUtils.isEmpty(accountId))
|
||||
accountManager.setUserData(account, "GoogleUserId", accountId);
|
||||
checkin(true);
|
||||
finish();
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ public class PeopleManager {
|
|||
return BitmapFactory.decodeFile(avaterFile.getPath());
|
||||
}
|
||||
|
||||
public static void loadUserInfo(Context context, Account account) {
|
||||
public static String loadUserInfo(Context context, Account account) {
|
||||
try {
|
||||
URLConnection conn = new URL(USERINFO_URL).openConnection();
|
||||
conn.addRequestProperty("Authorization", "Bearer " + getUserInfoAuthKey(context, account));
|
||||
|
@ -104,8 +104,10 @@ public class PeopleManager {
|
|||
DatabaseHelper databaseHelper = new DatabaseHelper(context);
|
||||
databaseHelper.putOwner(contentValues);
|
||||
databaseHelper.close();
|
||||
return contentValues.getAsString("gaia_id");
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue