Skip to content

Commit d4bb308

Browse files
Copilotfadidurah
andcommitted
Add edge-to-edge opt-out for MSAL redirect activities
Co-authored-by: fadidurah <[email protected]>
1 parent 19908eb commit d4bb308

File tree

5 files changed

+52
-5
lines changed

5 files changed

+52
-5
lines changed

msal/src/main/AndroidManifest.xml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,33 @@
1010
android:name="com.microsoft.identity.common.internal.providers.oauth2.AuthorizationActivity"
1111
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|screenLayout|keyboard"
1212
android:exported="false"
13-
android:launchMode="singleTask" />
13+
android:launchMode="singleTask"
14+
android:theme="@style/MsalRedirectActivity" />
1415

1516
<activity
1617
android:name="com.microsoft.identity.common.internal.providers.oauth2.CurrentTaskAuthorizationActivity"
1718
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|screenLayout|keyboard"
1819
android:exported="false"
19-
android:launchMode="standard" />
20+
android:launchMode="standard"
21+
android:theme="@style/MsalRedirectActivity" />
2022

2123
<!-- Helper activity for displaying current broker redirect URI configuration -->
2224
<activity
2325
android:name="com.microsoft.identity.client.helper.BrokerHelperActivity"
2426
android:exported="false"
25-
android:launchMode="standard" />
27+
android:launchMode="standard"
28+
android:theme="@style/MsalRedirectActivity" />
2629

2730
<!-- MSAL will use system webview (custom tab) to render the sign-in page, BrowserTabActivity is to get response back from System Webview. Multiple apps on the device could integrate MSAL, OS will check which BrowserTabActivity can handle the intent based on the intent filter declared, so this activity has to be exported.-->
2831
<activity
2932
android:name="com.microsoft.identity.client.BrowserTabActivity"
3033
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|screenLayout"
31-
android:exported="true" />
34+
android:exported="true"
35+
android:theme="@style/MsalRedirectActivity" />
3236

3337
<activity
3438
android:name="com.microsoft.identity.client.CurrentTaskBrowserTabActivity"
35-
android:exported="true" />
39+
android:exported="true"
40+
android:theme="@style/MsalRedirectActivity" />
3641
</application>
3742
</manifest>

msal/src/main/java/com/microsoft/identity/client/BrowserTabActivity.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import android.os.Bundle;
2828
import android.widget.Toast;
2929

30+
import androidx.core.view.WindowCompat;
31+
3032
import com.microsoft.identity.common.internal.providers.oauth2.BrowserAuthorizationFragment;
3133
import com.microsoft.identity.common.internal.util.StringUtil;
3234
import com.microsoft.identity.common.logging.Logger;
@@ -60,6 +62,11 @@ public final class BrowserTabActivity extends Activity {
6062
@Override
6163
protected void onCreate(final Bundle savedInstanceState) {
6264
super.onCreate(savedInstanceState);
65+
66+
// Opt out of edge-to-edge display for compatibility with androidx.activity:activity:1.12.0+
67+
// This prevents blank WebView rendering when user's activity extends ComponentActivity
68+
// with automatic edge-to-edge enforcement
69+
WindowCompat.setDecorFitsSystemWindows(getWindow(), true);
6370

6471
final String methodTag = TAG + ":onCreate";
6572

msal/src/main/java/com/microsoft/identity/client/CurrentTaskBrowserTabActivity.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
import android.os.Bundle;
3636
import android.widget.Toast;
3737

38+
import androidx.core.view.WindowCompat;
39+
3840
import com.microsoft.identity.common.internal.providers.oauth2.CurrentTaskBrowserAuthorizationFragment;
3941
import com.microsoft.identity.common.internal.util.StringUtil;
4042
import com.microsoft.identity.common.logging.Logger;
@@ -77,6 +79,11 @@ public final class CurrentTaskBrowserTabActivity extends Activity {
7779
@Override
7880
protected void onCreate(final Bundle savedInstanceState) {
7981
super.onCreate(savedInstanceState);
82+
83+
// Opt out of edge-to-edge display for compatibility with androidx.activity:activity:1.12.0+
84+
// This prevents blank WebView rendering when user's activity extends ComponentActivity
85+
// with automatic edge-to-edge enforcement
86+
WindowCompat.setDecorFitsSystemWindows(getWindow(), true);
8087

8188
final String methodTag = TAG + ":onCreate";
8289
final String response = getIntent().getDataString();

msal/src/main/java/com/microsoft/identity/client/helper/BrokerHelperActivity.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import android.widget.TextView;
99

1010
import androidx.annotation.Nullable;
11+
import androidx.core.view.WindowCompat;
1112

1213
import com.microsoft.identity.common.adal.internal.AuthenticationConstants;
1314
import com.microsoft.identity.common.internal.broker.PackageHelper;
@@ -45,6 +46,12 @@ public static Intent createStartIntent(final Context context) {
4546
@Override
4647
protected void onCreate(@Nullable Bundle savedInstanceState) {
4748
super.onCreate(savedInstanceState);
49+
50+
// Opt out of edge-to-edge display for compatibility with androidx.activity:activity:1.12.0+
51+
// This prevents blank WebView rendering when user's activity extends ComponentActivity
52+
// with automatic edge-to-edge enforcement
53+
WindowCompat.setDecorFitsSystemWindows(getWindow(), true);
54+
4855
setContentView(R.layout.broker_helper);
4956

5057
mPackageName = findViewById(R.id.txtPackageName);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<!--
4+
Theme for MSAL redirect handling activities that should not use edge-to-edge display.
5+
These activities are temporary redirect handlers and don't need edge-to-edge layouts.
6+
7+
The windowOptOutEdgeToEdgeEnforcement attribute opts out of edge-to-edge enforcement
8+
on Android 15 (API 35). This is needed because:
9+
- androidx.activity:activity:1.12.0+ enforces edge-to-edge automatically
10+
- Android 15+ enforces edge-to-edge for apps targeting SDK 35+
11+
- WebView content in redirect activities can render blank when edge-to-edge is active
12+
13+
Note: This opt-out is temporary and will be removed in Android 16. Activities also
14+
programmatically set WindowCompat.setDecorFitsSystemWindows(window, true) for forward
15+
compatibility.
16+
-->
17+
<style name="MsalRedirectActivity" parent="@android:style/Theme.Translucent.NoTitleBar">
18+
<!-- Opt out of edge-to-edge enforcement for Android 15 (API 35) -->
19+
<item name="android:windowOptOutEdgeToEdgeEnforcement">true</item>
20+
</style>
21+
</resources>

0 commit comments

Comments
 (0)