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

Commit 1a364965 authored by Charles Chen's avatar Charles Chen Committed by Android (Google) Code Review
Browse files

Merge "Annotating context in framework base"

parents 48c732b0 65911744
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.annotation.RequiresPermission;
import android.annotation.StyleRes;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.annotation.UiContext;
import android.app.VoiceInteractor.Request;
import android.app.admin.DevicePolicyManager;
import android.app.assist.AssistContent;
@@ -726,6 +727,7 @@ import java.util.function.Consumer;
 * upload, independent of whether the original activity is paused, stopped,
 * or finished.
 */
@UiContext
public class Activity extends ContextThemeWrapper
        implements LayoutInflater.Factory2,
        Window.Callback, KeyEvent.Callback,
+10 −5
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.StringRes;
import android.annotation.StyleRes;
import android.annotation.UiContext;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.ComponentName;
import android.content.Context;
@@ -101,6 +102,7 @@ public class Dialog implements DialogInterface, Window.Callback,
    private final WindowManager mWindowManager;

    @UnsupportedAppUsage
    @UiContext
    final Context mContext;
    @UnsupportedAppUsage
    final Window mWindow;
@@ -158,7 +160,7 @@ public class Dialog implements DialogInterface, Window.Callback,
     * @param context the context in which the dialog should run
     * @see android.R.styleable#Theme_dialogTheme
     */
    public Dialog(@NonNull Context context) {
    public Dialog(@UiContext @NonNull Context context) {
        this(context, 0, true);
    }

@@ -177,11 +179,12 @@ public class Dialog implements DialogInterface, Window.Callback,
     * @param themeResId a style resource describing the theme to use for the
     *              window, or {@code 0} to use the default dialog theme
     */
    public Dialog(@NonNull Context context, @StyleRes int themeResId) {
    public Dialog(@UiContext @NonNull Context context, @StyleRes int themeResId) {
        this(context, themeResId, true);
    }

    Dialog(@NonNull Context context, @StyleRes int themeResId, boolean createContextThemeWrapper) {
    Dialog(@UiContext @NonNull Context context, @StyleRes int themeResId,
            boolean createContextThemeWrapper) {
        if (createContextThemeWrapper) {
            if (themeResId == Resources.ID_NULL) {
                final TypedValue outValue = new TypedValue();
@@ -222,7 +225,7 @@ public class Dialog implements DialogInterface, Window.Callback,
        mCancelMessage = cancelCallback;
    }

    protected Dialog(@NonNull Context context, boolean cancelable,
    protected Dialog(@UiContext @NonNull Context context, boolean cancelable,
            @Nullable OnCancelListener cancelListener) {
        this(context);
        mCancelable = cancelable;
@@ -234,7 +237,9 @@ public class Dialog implements DialogInterface, Window.Callback,
     * 
     * @return Context The Context used by the Dialog.
     */
    public final @NonNull Context getContext() {
    @UiContext
    @NonNull
    public final Context getContext() {
        return mContext;
    }

+3 −2
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.annotation.UiContext;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.ComponentName;
import android.content.ContentResolver;
@@ -213,7 +214,6 @@ public class WallpaperManager {
    private static final Object sSync = new Object[0];
    @UnsupportedAppUsage
    private static Globals sGlobals;

    private final Context mContext;
    private final boolean mWcgEnabled;
    private final ColorManagementProxy mCmProxy;
@@ -539,7 +539,8 @@ public class WallpaperManager {
        }
    }

    /*package*/ WallpaperManager(IWallpaperManager service, Context context, Handler handler) {
    /*package*/ WallpaperManager(IWallpaperManager service, @UiContext Context context,
            Handler handler) {
        mContext = context;
        if (service != null) {
            initGlobals(service, context.getMainLooper());
+2 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.view.WindowManagerGlobal.ADD_TOO_MANY_TOKENS;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UiContext;
import android.content.Context;
import android.content.ContextWrapper;
import android.os.Bundle;
@@ -42,6 +43,7 @@ import java.lang.ref.Reference;
 * @see Context#createWindowContext(int, Bundle)
 * @hide
 */
@UiContext
public class WindowContext extends ContextWrapper {
    private final WindowManagerImpl mWindowManager;
    private final IWindowManager mWms;
+9 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.annotation.CallbackExecutor;
import android.annotation.CheckResult;
import android.annotation.ColorInt;
import android.annotation.ColorRes;
import android.annotation.DisplayContext;
import android.annotation.DrawableRes;
import android.annotation.IntDef;
import android.annotation.NonNull;
@@ -33,6 +34,7 @@ import android.annotation.StyleableRes;
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.annotation.UiContext;
import android.annotation.UserIdInt;
import android.app.ActivityManager;
import android.app.IApplicationThread;
@@ -3750,6 +3752,7 @@ public abstract class Context {
     * @see #getSystemService(String)
     * @see android.view.WindowManager
     */
    @UiContext
    public static final String WINDOW_SERVICE = "window";

    /**
@@ -3760,6 +3763,7 @@ public abstract class Context {
     * @see #getSystemService(String)
     * @see android.view.LayoutInflater
     */
    @UiContext
    public static final String LAYOUT_INFLATER_SERVICE = "layout_inflater";

    /**
@@ -3932,6 +3936,7 @@ public abstract class Context {
     *
     * @see #getSystemService(String)
     */
    @UiContext
    public static final String WALLPAPER_SERVICE = "wallpaper";

    /**
@@ -5789,6 +5794,7 @@ public abstract class Context {
     *
     * @return A {@link Context} for the display.
     */
    @DisplayContext
    public abstract Context createDisplayContext(@NonNull Display display);

    /**
@@ -5853,7 +5859,9 @@ public abstract class Context {
     * the current number of window contexts without adding any view by
     * {@link WindowManager#addView} <b>exceeds five</b>.
     */
    public @NonNull Context createWindowContext(@WindowType int type, @Nullable Bundle options)  {
    @UiContext
    @NonNull
    public Context createWindowContext(@WindowType int type, @Nullable Bundle options)  {
        throw new RuntimeException("Not implemented. Must override in a subclass.");
    }

Loading