IllegalAccessException: Tried to access visual service WindowManager from a non-visual Context
The Pixel 2 logs the following error when trying to connect via Bluetooth. There's no crash and the toast is shown despite the error.
2021-05-06 14:27:52.650 8451-8451/org.briarproject.briar.android.debug E/ContextImpl: Tried to access visual service WindowManager from a non-visual Context:org.briarproject.briar.android.BriarApplicationImpl@61e162e Visual services, such as WindowManager, WallpaperService or LayoutInflater should be accessed from Activity or other visual Context. Use an Activity or a Context created with Context#createWindowContext(int, Bundle), which are adjusted to the configuration and visual bounds of an area on screen.
java.lang.IllegalAccessException: Tried to access visual service WindowManager from a non-visual Context:org.briarproject.briar.android.BriarApplicationImpl@61e162e
at android.app.ContextImpl.getSystemService(ContextImpl.java:1916)
at android.content.ContextWrapper.getSystemService(ContextWrapper.java:803)
at android.content.Context.getSystemService(Context.java:3705)
at android.widget.ToastPresenter.<init>(ToastPresenter.java:81)
at android.widget.Toast$TN.<init>(Toast.java:615)
at android.widget.Toast.<init>(Toast.java:167)
at android.widget.Toast.makeText(Toast.java:492)
at android.widget.Toast.makeText(Toast.java:480)
at android.widget.Toast.makeText(Toast.java:519)
at org.briarproject.briar.android.conversation.BluetoothConnecter.lambda$showToast$3(BluetoothConnecter.java:255)
at org.briarproject.briar.android.conversation.BluetoothConnecter.lambda$showToast$3$BluetoothConnecter(Unknown Source:0)
at org.briarproject.briar.android.conversation.-$$Lambda$BluetoothConnecter$jmWLO-6UfeDYoCXxklJACu5-eRY.run(Unknown Source:4)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)