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

Commit 853c0f31 authored by Charles Chen's avatar Charles Chen
Browse files

Release Context#isUiContext(Context)

The purpose of this API is to verify whether a context is an
UI context or not. We can also leverage the jetpack WindowManager
to all kinds of UI contexts v.s. Activities only currently by
release this API.

Bug: 170275820
Test: atest ContextIsUiContextTest
Change-Id: I334b63e555331e46d0a94ec9f721bd675f1ab331
parent 857df8d6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -10158,6 +10158,7 @@ package android.content {
    method public abstract void grantUriPermission(String, android.net.Uri, int);
    method public abstract boolean isDeviceProtectedStorage();
    method public boolean isRestricted();
    method public static boolean isUiContext(@NonNull android.content.Context);
    method public abstract boolean moveDatabaseFrom(android.content.Context, String);
    method public abstract boolean moveSharedPreferencesFrom(android.content.Context, String);
    method @NonNull public final android.content.res.TypedArray obtainStyledAttributes(@NonNull @StyleableRes int[]);
+15 −0
Original line number Diff line number Diff line
@@ -6285,4 +6285,19 @@ public abstract class Context {
    public boolean isUiContext() {
        throw new RuntimeException("Not implemented. Must override in a subclass.");
    }

    /**
     * Returns {@code true} if the context is a UI context which can access UI components such as
     * {@link WindowManager}, {@link android.view.LayoutInflater LayoutInflater} or
     * {@link android.app.WallpaperManager WallpaperManager}.
     * <p>
     * Examples of UI contexts are
     * an {@link android.app.Activity Activity}, a context created from
     * {@link #createWindowContext(int, Bundle)} or
     * {@link android.inputmethodservice.InputMethodService InputMethodService}
     * </p>
     */
    public static boolean isUiContext(@NonNull Context context) {
        return context.isUiContext();
    }
}