Skip to content

Commit bca228f

Browse files
rpdomeCopilot
andcommitted
Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent a6d2373 commit bca228f

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

testapps/testapp/src/main/java/com/microsoft/identity/client/testapp/SilentAuthReceiver.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,21 @@ public class SilentAuthReceiver extends BroadcastReceiver {
6262

6363
@Override
6464
public void onReceive(final Context context, final Intent intent) {
65+
if (!ACTION_SILENT_AUTH.equals(intent.getAction())) {
66+
Log.w(TAG, "Ignoring broadcast with unexpected action: " + intent.getAction());
67+
return;
68+
}
69+
6570
Log.w(TAG, "=== SilentAuthReceiver triggered (PROCESS_STATE_RECEIVER) ===");
6671

6772
final String scopes = intent.getStringExtra("scopes");
6873
final String scopeString = (scopes != null) ? scopes : "https://graph.microsoft.com/.default";
6974

7075
Log.w(TAG, "Scopes: " + scopeString);
7176

72-
// Use goAsync() to extend the receiver's lifecycle beyond the 10s limit
77+
// Use goAsync() so work can continue after onReceive() returns.
78+
// The broadcast still has a finite system time budget, so
79+
// PendingResult.finish() must be called promptly.
7380
final PendingResult pendingResult = goAsync();
7481

7582
// Create PCA with default config (uses broker)
@@ -143,6 +150,10 @@ public void onError(MsalException exception) {
143150
pendingResult.finish();
144151
}
145152
});
153+
} else {
154+
Log.e(TAG, "Unexpected app type: " + app.getClass().getName()
155+
+ " — neither single nor multiple account mode.");
156+
pendingResult.finish();
146157
}
147158
}
148159

@@ -158,7 +169,7 @@ private void doSilentAuth(
158169
final AcquireTokenSilentParameters parameters = new AcquireTokenSilentParameters.Builder()
159170
.forAccount(account)
160171
.fromAuthority(account.getAuthority())
161-
.withScopes(Arrays.asList(scopeString.toLowerCase().split(" ")))
172+
.withScopes(Arrays.asList(scopeString.trim().split("\\s+")))
162173
.forceRefresh(true) // Force network call to eSTS (no cache)
163174
.withCallback(new AuthenticationCallback() {
164175
@Override

0 commit comments

Comments
 (0)