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

Commit f2001b43 authored by Ahaan Ugale's avatar Ahaan Ugale
Browse files

Fix deadlock in showing Toast for sensitive content

Toast#show calls into NotificationManagerService which then acquires a
lock there.

WMS is at a lower layer of the system and shouldn't be calling into a
higher level system with a lock held. This cl fixes the layering
inversion.

Bug: 323580163
Test: atest CtsSensitiveContentProtectionTestCases:android.sensitivecontentprotection.cts.ViewSensitiveContentTest --iterations
Change-Id: I4e829183b7f29ad2ad3231f4ea91937b8d9e2c6b
parent a7136d36
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -10163,10 +10163,12 @@ public class WindowManagerService extends IWindowManager.Stub
        // TODO(b/323580163): Check if already shown and update shown state.
        if (mSensitiveContentPackages.shouldBlockScreenCaptureForApp(w.getOwningPackage(),
                w.getOwningUid(), w.getWindowToken())) {
            mH.post(() -> {
                Toast.makeText(mContext, Looper.getMainLooper(),
                                mContext.getString(R.string.screen_not_shared_sensitive_content),
                                Toast.LENGTH_SHORT)
                        .show();
            });
        }
    }
}