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

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

Merge "Fix NPE in testWindowContextAddMismatchedWindowType" into sc-v2-dev

parents ca7eb3f9 eff3dfe4
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
import static android.window.WindowProvider.KEY_IS_WINDOW_PROVIDER_SERVICE;
import static android.window.WindowProviderService.isWindowProviderService;

import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
@@ -177,8 +177,7 @@ public final class WindowManagerImpl implements WindowManager {
                + " Please create another Window Context via"
                + " createWindowContext(getDisplay(), " + windowType + ", null)"
                + " to add window with type:" + windowType);
        if (!windowProvider.getWindowContextOptions().getBoolean(KEY_IS_WINDOW_PROVIDER_SERVICE,
                false)) {
        if (!isWindowProviderService(windowProvider.getWindowContextOptions())) {
            throw exception;
        }
        // Throw IncorrectCorrectViolation if the Window Context is allowed to provide multiple
+13 −0
Original line number Diff line number Diff line
@@ -55,6 +55,19 @@ public abstract class WindowProviderService extends Service implements WindowPro
    private WindowManager mWindowManager;
    private boolean mInitialized;

    /**
     * Returns {@code true} if the {@code windowContextOptions} declares that it is a
     * {@link WindowProviderService}.
     *
     * @hide
     */
    public static boolean isWindowProviderService(@Nullable Bundle windowContextOptions) {
        if (windowContextOptions == null) {
            return false;
        }
        return (windowContextOptions.getBoolean(KEY_IS_WINDOW_PROVIDER_SERVICE, false));
    }

    public WindowProviderService() {
        mOptions = new Bundle();
        mOptions.putBoolean(KEY_IS_WINDOW_PROVIDER_SERVICE, true);
+2 −2
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ import static android.view.WindowManagerGlobal.RELAYOUT_RES_SURFACE_CHANGED;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_INVALID;
import static android.view.displayhash.DisplayHashResultCallback.DISPLAY_HASH_ERROR_MISSING_WINDOW;
import static android.view.displayhash.DisplayHashResultCallback.DISPLAY_HASH_ERROR_NOT_VISIBLE_ON_SCREEN;
import static android.window.WindowContext.KEY_IS_WINDOW_PROVIDER_SERVICE;
import static android.window.WindowProviderService.isWindowProviderService;

import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ADD_REMOVE;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_BOOT;
@@ -1740,7 +1740,7 @@ public class WindowManagerService extends IWindowManager.Stub
                    // We allow WindowProviderService to add window other than windowContextType,
                    // but the WindowProviderService won't be associated with the window's
                    // WindowToken.
                    if (!options.getBoolean(KEY_IS_WINDOW_PROVIDER_SERVICE, false)) {
                    if (!isWindowProviderService(options)) {
                        return WindowManagerGlobal.ADD_INVALID_TYPE;
                    }
                } else {