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

Commit 7869b006 authored by Arpit Singh's avatar Arpit Singh Committed by Android (Google) Code Review
Browse files

Merge "Add density to display viewports" into main

parents ccfcb379 2707747e
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -81,6 +81,9 @@ public final class DisplayViewport {

    public @ViewportType int type;

    // The logical display density which is the basis for density-independent pixels.
    public int densityDpi;

    public void copyFrom(DisplayViewport viewport) {
        valid = viewport.valid;
        isActive = viewport.isActive;
@@ -93,6 +96,7 @@ public final class DisplayViewport {
        uniqueId = viewport.uniqueId;
        physicalPort = viewport.physicalPort;
        type = viewport.type;
        densityDpi = viewport.densityDpi;
    }

    /**
@@ -125,7 +129,8 @@ public final class DisplayViewport {
              && deviceHeight == other.deviceHeight
              && TextUtils.equals(uniqueId, other.uniqueId)
              && Objects.equals(physicalPort, other.physicalPort)
              && type == other.type;
              && type == other.type
              && densityDpi == other.densityDpi;
    }

    @Override
@@ -145,6 +150,7 @@ public final class DisplayViewport {
            result += prime * result + physicalPort.hashCode();
        }
        result += prime * result + type;
        result += prime * result + densityDpi;
        return result;
    }

@@ -158,6 +164,7 @@ public final class DisplayViewport {
                + ", uniqueId='" + uniqueId + "'"
                + ", physicalPort=" + physicalPort
                + ", orientation=" + orientation
                + ", densityDpi=" + densityDpi
                + ", logicalFrame=" + logicalFrame
                + ", physicalFrame=" + physicalFrame
                + ", deviceWidth=" + deviceWidth
+6 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ static struct {
    jfieldID uniqueId;
    jfieldID physicalPort;
    jfieldID type;
    jfieldID densityDpi;
} gDisplayViewportClassInfo;

static struct {
@@ -82,6 +83,8 @@ status_t android_hardware_display_DisplayViewport_toNative(JNIEnv* env, jobject
    viewport->type = static_cast<ViewportType>(env->GetIntField(viewportObj,
                gDisplayViewportClassInfo.type));

    viewport->densityDpi = env->GetIntField(viewportObj, gDisplayViewportClassInfo.densityDpi);

    jobject logicalFrameObj =
            env->GetObjectField(viewportObj, gDisplayViewportClassInfo.logicalFrame);
    viewport->logicalLeft = env->GetIntField(logicalFrameObj, gRectClassInfo.left);
@@ -135,6 +138,9 @@ int register_android_hardware_display_DisplayViewport(JNIEnv* env) {
    gDisplayViewportClassInfo.type = GetFieldIDOrDie(env,
            gDisplayViewportClassInfo.clazz, "type", "I");

    gDisplayViewportClassInfo.densityDpi =
            GetFieldIDOrDie(env, gDisplayViewportClassInfo.clazz, "densityDpi", "I");

    clazz = FindClassOrDie(env, "android/graphics/Rect");
    gRectClassInfo.left = GetFieldIDOrDie(env, clazz, "left", "I");
    gRectClassInfo.top = GetFieldIDOrDie(env, clazz, "top", "I");
+1 −0
Original line number Diff line number Diff line
@@ -3510,6 +3510,7 @@ public final class DisplayManagerService extends SystemService {
        viewport.valid = true;
        viewport.displayId = displayId;
        viewport.isActive = Display.isActiveState(info.state);
        viewport.densityDpi = info.densityDpi;
    }

    private void updateViewportPowerStateLocked(LogicalDisplay display) {