Skip to content

Commit

Permalink
Auth: Make sure we throw the IOException as before, so we don't run i…
Browse files Browse the repository at this point in the history
…nto null referenes later
  • Loading branch information
mar-v-in authored and fynngodau committed Sep 25, 2024
1 parent 79099a2 commit ea108d7
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
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;
Expand Down Expand Up @@ -254,20 +255,23 @@ private boolean isSystemApp() {
}
}

@NonNull
public AuthResponse requestAuthWithBackgroundResolution(boolean legacy) throws IOException {
try {
return requestAuth(legacy);
} catch (NotOkayException e) {
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);
}
Expand All @@ -277,20 +281,23 @@ public AuthResponse requestAuthWithBackgroundResolution(boolean legacy) throws I
}
}

@NonNull
public AuthResponse requestAuthWithForegroundResolution(boolean legacy) throws IOException {
try {
return requestAuth(legacy);
} catch (NotOkayException e) {
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);
}
Expand All @@ -300,6 +307,7 @@ public AuthResponse requestAuthWithForegroundResolution(boolean legacy) throws I
}
}

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

0 comments on commit ea108d7

Please sign in to comment.