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

Commit 8df631cd authored by Marvin W.'s avatar Marvin W. 🐿️
Browse files

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...
parent 9624bb71
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -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();
                    }
+3 −1
Original line number Diff line number Diff line
@@ -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;
        }
    }