Skip to content

Commit

Permalink
Update browser selector (#2250)
Browse files Browse the repository at this point in the history
With the changes introduced in
AzureAD/microsoft-authentication-library-common-for-android#2564,
I broke the MSAL test app, we need to update the signature for Browser
selector.
  • Loading branch information
p3dr0rv authored Jan 24, 2025
1 parent c1eafb7 commit 5c0ff4e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import com.microsoft.identity.client.exception.MsalException;
import com.microsoft.identity.client.exception.MsalServiceException;
import com.microsoft.identity.client.exception.MsalUiRequiredException;
import com.microsoft.identity.common.internal.ui.browser.AndroidBrowserSelector;
import com.microsoft.identity.common.java.browser.Browser;
import com.microsoft.identity.common.java.exception.BaseException;
import com.microsoft.identity.common.java.ui.PreferredAuthMethod;
import com.microsoft.identity.common.java.util.StringUtil;
Expand Down Expand Up @@ -68,7 +70,14 @@ public void onError(MsalException exception) {
});
}

public abstract String getDefaultBrowser();
public String getDefaultBrowser() {
final Browser browser =
new AndroidBrowserSelector(getApp().getConfiguration().getAppContext()).selectBrowser(
getApp().getConfiguration().getBrowserSafeList(),
getApp().getConfiguration().getPreferredBrowser()
);
return browser == null ? "Unknown" : browser.getPackageName();
}

public abstract String getMode();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@
import com.microsoft.identity.client.PoPAuthenticationScheme;
import com.microsoft.identity.client.PublicClientApplication;
import com.microsoft.identity.client.claims.ClaimsRequest;
import com.microsoft.identity.client.exception.MsalClientException;
import com.microsoft.identity.client.exception.MsalException;
import com.microsoft.identity.common.internal.ui.browser.BrowserSelector;
import com.microsoft.identity.common.java.exception.ClientException;

import java.util.List;

Expand All @@ -62,17 +59,6 @@ public IPublicClientApplication getApp() {
return mApp;
}

@Override
public String getDefaultBrowser() {
try {
return BrowserSelector.select(mApp.getConfiguration().getAppContext(),
mApp.getConfiguration().getBrowserSafeList(),
mApp.getConfiguration().getPreferredBrowser()).getPackageName();
} catch (ClientException e) {
return "Unknown";
}
}

@Override
public void loadAccounts(@NonNull final INotifyOperationResultCallback<List<IAccount>> callback) {
mApp.getAccounts(new IPublicClientApplication.LoadAccountsCallback() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@
import com.microsoft.identity.client.PoPAuthenticationScheme;
import com.microsoft.identity.client.PublicClientApplication;
import com.microsoft.identity.client.claims.ClaimsRequest;
import com.microsoft.identity.client.exception.MsalClientException;
import com.microsoft.identity.client.exception.MsalException;
import com.microsoft.identity.common.internal.ui.browser.BrowserSelector;
import com.microsoft.identity.common.java.exception.ClientException;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -65,17 +62,6 @@ public IPublicClientApplication getApp() {
return mApp;
}

@Override
public String getDefaultBrowser() {
try {
return BrowserSelector.select(mApp.getConfiguration().getAppContext(),
mApp.getConfiguration().getBrowserSafeList(),
mApp.getConfiguration().getPreferredBrowser()).getPackageName();
} catch (ClientException e) {
return "Unknown";
}
}

@Override
public void loadAccounts(final @NonNull INotifyOperationResultCallback<List<IAccount>> callback) {
mApp.getCurrentAccountAsync(new ISingleAccountPublicClientApplication.CurrentAccountCallback() {
Expand Down

0 comments on commit 5c0ff4e

Please sign in to comment.