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

Commit ea108d7e authored by Marvin W.'s avatar Marvin W. 🐿️ Committed by Fynn Godau
Browse files

Auth: Make sure we throw the IOException as before, so we don't run into null referenes later

parent 79099a24
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ import android.content.pm.PackageManager;
import android.net.Uri;
import android.util.Log;

import androidx.annotation.NonNull;
import org.microg.gms.accountaction.ErrorResolverKt;
import org.microg.gms.accountaction.Resolution;
import org.microg.gms.common.NotOkayException;
@@ -254,6 +255,7 @@ public class AuthManager {
        }
    }

    @NonNull
    public AuthResponse requestAuthWithBackgroundResolution(boolean legacy) throws IOException {
        try {
            return requestAuth(legacy);
@@ -261,13 +263,15 @@ public class AuthManager {
            if (e.getMessage() != null) {
                Resolution errorResolution = ErrorResolverKt.resolveAuthErrorMessage(context, e.getMessage());
                if (errorResolution != null) {
                    return ErrorResolverKt.initiateFromBackgroundBlocking(
                    AuthResponse response = ErrorResolverKt.initiateFromBackgroundBlocking(
                            errorResolution,
                            context,
                            getAccount(),
                            // infinite loop is prevented
                            () -> requestAuth(legacy)
                    );
                    if (response == null) throw new IOException(e);
                    return response;
                } else {
                    throw new IOException(e);
                }
@@ -277,6 +281,7 @@ public class AuthManager {
        }
    }

    @NonNull
    public AuthResponse requestAuthWithForegroundResolution(boolean legacy) throws IOException {
        try {
            return requestAuth(legacy);
@@ -284,13 +289,15 @@ public class AuthManager {
            if (e.getMessage() != null) {
                Resolution errorResolution = ErrorResolverKt.resolveAuthErrorMessage(context, e.getMessage());
                if (errorResolution != null) {
                    return ErrorResolverKt.initiateFromForegroundBlocking(
                    AuthResponse response = ErrorResolverKt.initiateFromForegroundBlocking(
                            errorResolution,
                            context,
                            getAccount(),
                            // infinite loop is prevented
                            () -> requestAuth(legacy)
                    );
                    if (response == null) throw new IOException(e);
                    return response;
                } else {
                    throw new IOException(e);
                }
@@ -300,6 +307,7 @@ public class AuthManager {
        }
    }

    @NonNull
    public AuthResponse requestAuth(boolean legacy) throws IOException {
        if (service.equals(AuthConstants.SCOPE_GET_ACCOUNT_ID)) {
            AuthResponse response = new AuthResponse();