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

Commit 4268b167 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update topology-graph population for new format" into main

parents 7579eb82 5847c5af
Loading
Loading
Loading
Loading
+8 −18
Original line number Diff line number Diff line
@@ -87,14 +87,11 @@ status_t android_hardware_display_DisplayTopologyAdjacentDisplay_toNative(

status_t android_hardware_display_DisplayTopologyGraphNode_toNative(
        JNIEnv* env, jobject nodeObj,
        std::unordered_map<ui::LogicalDisplayId, std::vector<DisplayTopologyAdjacentDisplay>>&
                graph,
        std::unordered_map<ui::LogicalDisplayId, int>& displaysDensity,
        std::unordered_map<ui::LogicalDisplayId, FloatRect>& displayBoundsDp) {
        std::unordered_map<ui::LogicalDisplayId, DisplayTopologyGraph::Properties>& topologyGraph) {
    ui::LogicalDisplayId displayId = ui::LogicalDisplayId{
            env->GetIntField(nodeObj, gDisplayTopologyGraphNodeClassInfo.displayId)};

    displaysDensity[displayId] =
    topologyGraph[displayId].density =
            env->GetIntField(nodeObj, gDisplayTopologyGraphNodeClassInfo.density);

    ScopedLocalRef<jobject> displayBounds(env,
@@ -102,7 +99,8 @@ status_t android_hardware_display_DisplayTopologyGraphNode_toNative(
                                                              gDisplayTopologyGraphNodeClassInfo
                                                                      .boundsInGlobalDp));
    android_hardware_display_DisplayTopologyDisplayBounds_toNative(env, displayBounds.get(),
                                                                   &displayBoundsDp[displayId]);
                                                                   &topologyGraph[displayId]
                                                                            .boundsInGlobalDp);

    jobjectArray adjacentDisplaysArray = static_cast<jobjectArray>(
            env->GetObjectField(nodeObj, gDisplayTopologyGraphNodeClassInfo.adjacentDisplays));
@@ -121,7 +119,7 @@ status_t android_hardware_display_DisplayTopologyGraphNode_toNative(
                                                                             adjacentDisplayObj
                                                                                     .get(),
                                                                             &adjacentDisplay);
            graph[displayId].push_back(adjacentDisplay);
            topologyGraph[displayId].adjacentDisplays.push_back(adjacentDisplay);
        }
    }
    return OK;
@@ -129,10 +127,7 @@ status_t android_hardware_display_DisplayTopologyGraphNode_toNative(

base::Result<const DisplayTopologyGraph> android_hardware_display_DisplayTopologyGraph_toNative(
        JNIEnv* env, jobject topologyObj) {
    std::unordered_map<ui::LogicalDisplayId, std::vector<DisplayTopologyAdjacentDisplay>>
            topologyGraph;
    std::unordered_map<ui::LogicalDisplayId, int> displaysDensity;
    std::unordered_map<ui::LogicalDisplayId, FloatRect> absoluteDisplayBoundsDp;
    std::unordered_map<ui::LogicalDisplayId, DisplayTopologyGraph::Properties> topologyGraph;
    ui::LogicalDisplayId primaryDisplayId = ui::LogicalDisplayId{
            env->GetIntField(topologyObj, gDisplayTopologyGraphClassInfo.primaryDisplayId)};

@@ -148,15 +143,10 @@ base::Result<const DisplayTopologyGraph> android_hardware_display_DisplayTopolog
            }

            android_hardware_display_DisplayTopologyGraphNode_toNative(env, nodeObj.get(),
                                                                       /*byRef*/ topologyGraph,
                                                                       /*byRef*/ displaysDensity,
                                                                       /*byRef*/
                                                                       absoluteDisplayBoundsDp);
                                                                       /*byRef*/ topologyGraph);
        }
    }
    return DisplayTopologyGraph::create(primaryDisplayId, std::move(topologyGraph),
                                        std::move(displaysDensity),
                                        std::move(absoluteDisplayBoundsDp));
    return DisplayTopologyGraph::create(primaryDisplayId, std::move(topologyGraph));
}

// ----------------------------------------------------------------------------