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

Commit ea325634 authored by Andrii Kulian's avatar Andrii Kulian
Browse files

Add bundle options to Context#createWindowContext API

Add Bundle parameter to createWindowContext method to allow
passing window-related options.

Bug: 128338354
Test: Build, auto test
Change-Id: I19cf9335068ecf94c9d94a99be0e8f1021f78e34
parent 9652ad95
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -9984,7 +9984,7 @@ package android.content {
    method public abstract android.content.Context createDisplayContext(@NonNull android.view.Display);
    method public abstract android.content.Context createDisplayContext(@NonNull android.view.Display);
    method @NonNull public android.content.Context createFeatureContext(@Nullable String);
    method @NonNull public android.content.Context createFeatureContext(@Nullable String);
    method public abstract android.content.Context createPackageContext(String, int) throws android.content.pm.PackageManager.NameNotFoundException;
    method public abstract android.content.Context createPackageContext(String, int) throws android.content.pm.PackageManager.NameNotFoundException;
    method @NonNull public android.content.Context createWindowContext(int);
    method @NonNull public android.content.Context createWindowContext(int, @Nullable android.os.Bundle);
    method public abstract String[] databaseList();
    method public abstract String[] databaseList();
    method public abstract boolean deleteDatabase(String);
    method public abstract boolean deleteDatabase(String);
    method public abstract boolean deleteFile(String);
    method public abstract boolean deleteFile(String);
+2 −2
Original line number Original line Diff line number Diff line
@@ -2364,13 +2364,13 @@ class ContextImpl extends Context {
    }
    }


    @Override
    @Override
    public @NonNull WindowContext createWindowContext(int type) {
    public @NonNull WindowContext createWindowContext(int type, Bundle options) {
        if (getDisplay() == null) {
        if (getDisplay() == null) {
            throw new UnsupportedOperationException("WindowContext can only be created from "
            throw new UnsupportedOperationException("WindowContext can only be created from "
                    + "other visual contexts, such as Activity or one created with "
                    + "other visual contexts, such as Activity or one created with "
                    + "Context#createDisplayContext(Display)");
                    + "Context#createDisplayContext(Display)");
        }
        }
        return new WindowContext(this, null /* token */, type);
        return new WindowContext(this, null /* token */, type, options);
    }
    }


    ContextImpl createBaseWindowContext(IBinder token) {
    ContextImpl createBaseWindowContext(IBinder token) {
+2 −2
Original line number Original line Diff line number Diff line
@@ -53,7 +53,7 @@ public class WindowContext extends ContextWrapper {
     * @param type Window type to be used with this context.
     * @param type Window type to be used with this context.
     * @hide
     * @hide
     */
     */
    public WindowContext(Context base, IBinder token, int type) {
    public WindowContext(Context base, IBinder token, int type, Bundle options) {
        super(null /* base */);
        super(null /* base */);


        mWms = WindowManagerGlobal.getWindowManagerService();
        mWms = WindowManagerGlobal.getWindowManagerService();
@@ -76,7 +76,7 @@ public class WindowContext extends ContextWrapper {
            return;
            return;
        }
        }
        try {
        try {
            mWms.addWindowContextToken(mToken, type, mDisplayId, getPackageName());
            mWms.addWindowTokenWithOptions(mToken, type, mDisplayId, options, getPackageName());
            // TODO(window-context): remove token with a DeathObserver
            // TODO(window-context): remove token with a DeathObserver
        }  catch (RemoteException e) {
        }  catch (RemoteException e) {
            mOwnsToken = false;
            mOwnsToken = false;
+3 −2
Original line number Original line Diff line number Diff line
@@ -5767,7 +5767,7 @@ public abstract class Context {
     * final DisplayManager dm = anyContext.getSystemService(DisplayManager.class);
     * final DisplayManager dm = anyContext.getSystemService(DisplayManager.class);
     * final Display primaryDisplay = dm.getDisplay(DEFAULT_DISPLAY);
     * final Display primaryDisplay = dm.getDisplay(DEFAULT_DISPLAY);
     * final Context windowContext = anyContext.createDisplayContext(primaryDisplay)
     * final Context windowContext = anyContext.createDisplayContext(primaryDisplay)
     *         .createWindowContext(TYPE_APPLICATION_OVERLAY);
     *         .createWindowContext(TYPE_APPLICATION_OVERLAY, null);
     * final View overlayView = Inflater.from(windowContext).inflate(someLayoutXml, null);
     * final View overlayView = Inflater.from(windowContext).inflate(someLayoutXml, null);
     *
     *
     * // WindowManager.LayoutParams initialization
     * // WindowManager.LayoutParams initialization
@@ -5787,6 +5787,7 @@ public abstract class Context {
     * </p>
     * </p>
     *
     *
     * @param type Window type in {@link WindowManager.LayoutParams}
     * @param type Window type in {@link WindowManager.LayoutParams}
     * @param options Bundle used to pass window-related options.
     * @return A {@link Context} that can be used to create windows.
     * @return A {@link Context} that can be used to create windows.
     * @throws UnsupportedOperationException if this is called on a non-UI context, such as
     * @throws UnsupportedOperationException if this is called on a non-UI context, such as
     *         {@link android.app.Application Application} or {@link android.app.Service Service}.
     *         {@link android.app.Application Application} or {@link android.app.Service Service}.
@@ -5798,7 +5799,7 @@ public abstract class Context {
     * @see #WALLPAPER_SERVICE
     * @see #WALLPAPER_SERVICE
     * @throws IllegalArgumentException if token is invalid
     * @throws IllegalArgumentException if token is invalid
     */
     */
    public @NonNull Context createWindowContext(int type)  {
    public @NonNull Context createWindowContext(int type, @Nullable Bundle options)  {
        throw new RuntimeException("Not implemented. Must override in a subclass.");
        throw new RuntimeException("Not implemented. Must override in a subclass.");
    }
    }


+2 −2
Original line number Original line Diff line number Diff line
@@ -978,8 +978,8 @@ public class ContextWrapper extends Context {


    @Override
    @Override
    @NonNull
    @NonNull
    public Context createWindowContext(int type) {
    public Context createWindowContext(int type, @Nullable Bundle options) {
        return mBase.createWindowContext(type);
        return mBase.createWindowContext(type, options);
    }
    }


    @Override
    @Override
Loading