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

Commit 9a3368f5 authored by Marco Loaiza's avatar Marco Loaiza Committed by Android (Google) Code Review
Browse files

Merge "Handle device context with invalid deviceId"

parents 001ac6ff 08224ce1
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -3062,7 +3062,14 @@ class ContextImpl extends Context {

    @Override
    public boolean isDeviceContext() {
        return mIsExplicitDeviceId || isAssociatedWithDisplay();
        if (mIsExplicitDeviceId) {
            if (mDeviceId == VirtualDeviceManager.DEVICE_ID_DEFAULT) {
                return true;
            }
            VirtualDeviceManager vdm = getSystemService(VirtualDeviceManager.class);
            return vdm.isValidVirtualDeviceId(mDeviceId);
        }
        return isAssociatedWithDisplay();
    }

    @Override
+4 −2
Original line number Diff line number Diff line
@@ -7378,10 +7378,12 @@ public abstract class Context {
    /**
     * Indicates whether the value of {@link Context#getDeviceId()} can be relied upon for
     * this instance. It will return {@code true} for Contexts created by
     * {@link Context#createDeviceContext(int)}, as well as for UI and Display Contexts.
     * {@link Context#createDeviceContext(int)} which reference a valid device ID, as well as for
     * UI and Display Contexts.
     * <p>
     * Contexts created with {@link Context#createDeviceContext(int)} will have an explicit
     * device association, which will never change. UI Contexts and Display Contexts are
     * device association, which will never change, even if the underlying device is closed or is
     * removed. UI Contexts and Display Contexts are
     * already associated with a display, so if the device association is not explicitly
     * given, {@link Context#getDeviceId()} will return the ID of the device associated with
     * the associated display. The system can assign an arbitrary device id value for Contexts not