mirror of
https://github.com/YTVanced/VancedMicroG
synced 2024-11-24 04:05:13 +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.NetworkInfo;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -247,6 +248,8 @@ public class LoginActivity extends AssistantActivity {
|
||||||
accountManager.setUserData(account, "oauthAccessToken", "1");
|
accountManager.setUserData(account, "oauthAccessToken", "1");
|
||||||
accountManager.setUserData(account, "firstName", response.firstName);
|
accountManager.setUserData(account, "firstName", response.firstName);
|
||||||
accountManager.setUserData(account, "lastName", response.lastName);
|
accountManager.setUserData(account, "lastName", response.lastName);
|
||||||
|
if (!TextUtils.isEmpty(response.accountId))
|
||||||
|
accountManager.setUserData(account, "GoogleUserId", response.accountId);
|
||||||
|
|
||||||
retrieveGmsToken(account);
|
retrieveGmsToken(account);
|
||||||
setResult(RESULT_OK);
|
setResult(RESULT_OK);
|
||||||
|
@ -282,7 +285,9 @@ public class LoginActivity extends AssistantActivity {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(AuthResponse response) {
|
public void onResponse(AuthResponse response) {
|
||||||
authManager.storeResponse(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);
|
checkin(true);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ public class PeopleManager {
|
||||||
return BitmapFactory.decodeFile(avaterFile.getPath());
|
return BitmapFactory.decodeFile(avaterFile.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadUserInfo(Context context, Account account) {
|
public static String loadUserInfo(Context context, Account account) {
|
||||||
try {
|
try {
|
||||||
URLConnection conn = new URL(USERINFO_URL).openConnection();
|
URLConnection conn = new URL(USERINFO_URL).openConnection();
|
||||||
conn.addRequestProperty("Authorization", "Bearer " + getUserInfoAuthKey(context, account));
|
conn.addRequestProperty("Authorization", "Bearer " + getUserInfoAuthKey(context, account));
|
||||||
|
@ -104,8 +104,10 @@ public class PeopleManager {
|
||||||
DatabaseHelper databaseHelper = new DatabaseHelper(context);
|
DatabaseHelper databaseHelper = new DatabaseHelper(context);
|
||||||
databaseHelper.putOwner(contentValues);
|
databaseHelper.putOwner(contentValues);
|
||||||
databaseHelper.close();
|
databaseHelper.close();
|
||||||
|
return contentValues.getAsString("gaia_id");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.w(TAG, e);
|
Log.w(TAG, e);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue