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

Commit aec8ca1d authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6796148 from e959f094 to rvc-qpr1-release

Change-Id: If264a9ab7a9a3432ca06a80c29b1223ff6ae72f9
parents e728ad1e e959f094
Loading
Loading
Loading
Loading
+15 −10
Original line number Diff line number Diff line
@@ -1914,10 +1914,8 @@ class ContextImpl extends Context {
    @Override
    public Object getSystemService(String name) {
        if (vmIncorrectContextUseEnabled()) {
            // We may override this API from outer context.
            final boolean isUiContext = isUiContext() || isOuterUiContext();
            // Check incorrect Context usage.
            if (isUiComponent(name) && !isUiContext) {
            if (isUiComponent(name) && !isSelfOrOuterUiContext()) {
                final String errorMessage = "Tried to access visual service "
                        + SystemServiceRegistry.getSystemServiceClassName(name)
                        + " from a non-visual Context:" + getOuterContext();
@@ -1934,15 +1932,17 @@ class ContextImpl extends Context {
        return SystemServiceRegistry.getSystemService(this, name);
    }

    private boolean isOuterUiContext() {
        return getOuterContext() != null && getOuterContext().isUiContext();
    }

    @Override
    public String getSystemServiceName(Class<?> serviceClass) {
        return SystemServiceRegistry.getSystemServiceName(serviceClass);
    }

    // TODO(b/149463653): check if we still need this method after migrating IMS to WindowContext.
    private boolean isSelfOrOuterUiContext() {
        // We may override outer context's isUiContext
        return isUiContext() || getOuterContext() != null && getOuterContext().isUiContext();
    }

    /** @hide */
    @Override
    public boolean isUiContext() {
@@ -2389,7 +2389,6 @@ class ContextImpl extends Context {
        context.setResources(createResources(mToken, mPackageInfo, mSplitName, displayId,
                overrideConfiguration, getDisplayAdjustments(displayId).getCompatibilityInfo(),
                mResources.getLoaders()));
        context.mIsUiContext = isUiContext() || isOuterUiContext();
        return context;
    }

@@ -2409,6 +2408,11 @@ class ContextImpl extends Context {
                mResources.getLoaders()));
        context.mDisplay = display;
        context.mIsAssociatedWithDisplay = true;
        // Note that even if a display context is derived from an UI context, it should not be
        // treated as UI context because it does not handle configuration changes from the server
        // side. If the context does need to handle configuration changes, please use
        // Context#createWindowContext(int, Bundle).
        context.mIsUiContext = false;
        return context;
    }

@@ -2494,7 +2498,7 @@ class ContextImpl extends Context {

    @Override
    public Display getDisplay() {
        if (!mIsSystemOrSystemUiContext && !mIsAssociatedWithDisplay) {
        if (!mIsSystemOrSystemUiContext && !mIsAssociatedWithDisplay && !isSelfOrOuterUiContext()) {
            throw new UnsupportedOperationException("Tried to obtain display from a Context not "
                    + "associated with one. Only visual Contexts (such as Activity or one created "
                    + "with Context#createWindowContext) or ones created with "
@@ -2770,6 +2774,7 @@ class ContextImpl extends Context {
            mDisplay = container.mDisplay;
            mIsAssociatedWithDisplay = container.mIsAssociatedWithDisplay;
            mIsSystemOrSystemUiContext = container.mIsSystemOrSystemUiContext;
            mIsUiContext = container.isSelfOrOuterUiContext();
        } else {
            mBasePackageName = packageInfo.mPackageName;
            ApplicationInfo ainfo = packageInfo.getApplicationInfo();
+11 −1
Original line number Diff line number Diff line
@@ -176,6 +176,13 @@ public class TaskInfo {
     */
    public boolean isResizeable;

    /**
     * Screen orientation set by {@link #baseActivity} via
     * {@link Activity#setRequestedOrientation(int)}.
     * @hide
     */
    public @ActivityInfo.ScreenOrientation int requestedOrientation;

    TaskInfo() {
        // Do nothing
    }
@@ -247,6 +254,7 @@ public class TaskInfo {
                ? ActivityInfo.CREATOR.createFromParcel(source)
                : null;
        isResizeable = source.readBoolean();
        requestedOrientation = source.readInt();
    }

    /**
@@ -297,6 +305,7 @@ public class TaskInfo {
            topActivityInfo.writeToParcel(dest, flags);
        }
        dest.writeBoolean(isResizeable);
        dest.writeInt(requestedOrientation);
    }

    @Override
@@ -315,6 +324,7 @@ public class TaskInfo {
                + " token=" + token
                + " topActivityType=" + topActivityType
                + " pictureInPictureParams=" + pictureInPictureParams
                + " topActivityInfo=" + topActivityInfo;
                + " topActivityInfo=" + topActivityInfo
                + " requestedOrientation=" + requestedOrientation;
    }
}
+9 −5
Original line number Diff line number Diff line
@@ -1208,15 +1208,19 @@ public class InputMethodService extends AbstractInputMethodService {
        mWindow.getWindow().getAttributes().setFitInsetsIgnoringVisibility(true);

        // IME layout should always be inset by navigation bar, no matter its current visibility,
        // unless automotive requests it, since automotive may hide the navigation bar.
        // unless automotive requests it. Automotive devices may request the navigation bar to be
        // hidden when the IME shows up (controlled via config_automotiveHideNavBarForKeyboard)
        // in order to maximize the visible screen real estate. When this happens, the IME window
        // should animate from the bottom of the screen to reduce the jank that happens from the
        // lack of synchronization between the bottom system window and the IME window.
        if (mIsAutomotive && mAutomotiveHideNavBarForKeyboard) {
            mWindow.getWindow().setDecorFitsSystemWindows(false);
        }
        mWindow.getWindow().getDecorView().setOnApplyWindowInsetsListener(
                (v, insets) -> v.onApplyWindowInsets(
                        new WindowInsets.Builder(insets).setInsets(
                                navigationBars(),
                                mIsAutomotive && mAutomotiveHideNavBarForKeyboard
                                        ? android.graphics.Insets.NONE
                                        : insets.getInsetsIgnoringVisibility(navigationBars())
                                )
                                insets.getInsetsIgnoringVisibility(navigationBars()))
                                .build()));

        // For ColorView in DecorView to work, FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS needs to be set
+11 −0
Original line number Diff line number Diff line
@@ -113,6 +113,14 @@ public abstract class FileSystemProvider extends DocumentsProvider {
        // Default is no-op
    }

    /**
     * Callback indicating that the given document has been deleted or moved. This gives
     * the provider a hook to revoke the uri permissions.
     */
    protected void onDocIdDeleted(String docId) {
        // Default is no-op
    }

    @Override
    public boolean onCreate() {
        throw new UnsupportedOperationException(
@@ -283,6 +291,7 @@ public abstract class FileSystemProvider extends DocumentsProvider {

        final String afterDocId = getDocIdForFile(after);
        onDocIdChanged(docId);
        onDocIdDeleted(docId);
        onDocIdChanged(afterDocId);

        final File afterVisibleFile = getFileForDocId(afterDocId, true);
@@ -312,6 +321,7 @@ public abstract class FileSystemProvider extends DocumentsProvider {

        final String docId = getDocIdForFile(after);
        onDocIdChanged(sourceDocumentId);
        onDocIdDeleted(sourceDocumentId);
        onDocIdChanged(docId);
        moveInMediaStore(visibleFileBefore, getFileForDocId(docId, true));

@@ -343,6 +353,7 @@ public abstract class FileSystemProvider extends DocumentsProvider {
        }

        onDocIdChanged(docId);
        onDocIdDeleted(docId);
        removeFromMediaStore(visibleFile);
    }

+29 −9
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.content;
import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY;
import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;

import static com.google.common.truth.Truth.assertThat;

@@ -188,19 +189,38 @@ public class ContextTest {

        assertFalse(wrapper.isUiContext());

        wrapper = new ContextWrapper(new TestUiContext());
        wrapper = new ContextWrapper(getUiContext());

        assertTrue(wrapper.isUiContext());
    }

    private static class TestUiContext extends ContextWrapper {
        TestUiContext() {
            super(null /* base */);
    @Test
    public void testIsUiContext_UiContextDerivedContext() {
        final Context uiContext = getUiContext();
        Context context = uiContext.createAttributionContext(null /* attributionTag */);

        assertTrue(context.isUiContext());

        context = uiContext.createConfigurationContext(new Configuration());

        assertTrue(context.isUiContext());
    }

        @Override
        public boolean isUiContext() {
            return true;
    @Test
    public void testIsUiContext_UiContextDerivedDisplayContext() {
        final Context uiContext = getUiContext();
        final Display secondaryDisplay =
                getSecondaryDisplay(uiContext.getSystemService(DisplayManager.class));
        final Context context = uiContext.createDisplayContext(secondaryDisplay);

        assertFalse(context.isUiContext());
    }

    private Context getUiContext() {
        final Context appContext = ApplicationProvider.getApplicationContext();
        final DisplayManager displayManager = appContext.getSystemService(DisplayManager.class);
        final Display display = displayManager.getDisplay(DEFAULT_DISPLAY);
        return appContext.createDisplayContext(display)
                .createWindowContext(TYPE_APPLICATION_OVERLAY, null /* options */);
    }
}
Loading