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

Commit d3e4c5ba authored by Yuxin Hu's avatar Yuxin Hu
Browse files

Add a new GpuService API to query persist.graphics.egl

To solve b/408439360 and b/409589250, we need to query
persist.graphics.egl in GraphicsEnvironment.java. This change
adds the GpuService API to read persist.graphics.egl value
through aidl. This way we don't need to alter the sepolicy
to expose read access of graphics_config_writable_prop to
general apps, and we can control when the persist.graphics.egl
is accessed by adding UID permission.

Flag: com.android.graphics.graphicsenv.flags.query_persist_graphics_egl
Bug: b/408439360
Bug: b/409589250
Test: make, flash to shiba, check there is no avc:  denied  { read } for  name="u:object_r:graphics_config_writable_prop
Change-Id: Ic12c6a3ca515728740f6e9c70bb3834d67d3231e
parent 91ae097a
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -746,6 +746,18 @@ void GraphicsEnv::nativeToggleAngleAsSystemDriver(bool enabled) {
    gpuService->toggleAngleAsSystemDriver(enabled);
}

std::string GraphicsEnv::nativeGetPersistGraphicsEgl() {
    if (!graphicsenv_flags::query_persist_graphics_egl()) {
        return "";
    }
    const sp<IGpuService> gpuService = getGpuService();
    if (!gpuService) {
        ALOGE("No GPU service");
        return "";
    }
    return gpuService->getPersistGraphicsEgl();
}

bool GraphicsEnv::shouldUseSystemAngle() {
    return mShouldUseSystemAngle;
}
+18 −0
Original line number Diff line number Diff line
@@ -108,6 +108,18 @@ public:
                           IBinder::FLAG_ONEWAY);
    }

    std::string getPersistGraphicsEgl() override {
        Parcel data, reply;
        data.writeInterfaceToken(IGpuService::getInterfaceDescriptor());

        status_t error = remote()->transact(BnGpuService::GET_PERSIST_GRAPHICS_EGL, data, &reply);
        std::string persistGraphicsEgl;
        if (error == OK) {
            error = reply.readUtf8FromUtf16(&persistGraphicsEgl);
        }
        return persistGraphicsEgl;
    }

    std::string getUpdatableDriverPath() override {
        Parcel data, reply;
        data.writeInterfaceToken(IGpuService::getInterfaceDescriptor());
@@ -286,6 +298,12 @@ status_t BnGpuService::onTransact(uint32_t code, const Parcel& data, Parcel* rep
            toggleAngleAsSystemDriver(enableAngleAsSystemDriver);
            return OK;
        }
        case GET_PERSIST_GRAPHICS_EGL: {
            CHECK_INTERFACE(IGpuService, data, reply);

            std::string persistGraphicsEgl = getPersistGraphicsEgl();
            return reply->writeUtf8AsUtf16(persistGraphicsEgl);
        }
        case GET_FEATURE_CONFIG_OVERRIDES: {
            CHECK_INTERFACE(IGpuService, data, reply);

+7 −0
Original line number Diff line number Diff line
@@ -7,3 +7,10 @@ flag {
  description: "This flag controls the ANGLE Feature Overrides in GraphicsEnv."
  bug: "372694741"
}

flag {
  name: "query_persist_graphics_egl"
  namespace: "gpu"
  description: "This flag controls the ability to query persist.graphics.egl through GpuService"
  bug: "408439360"
}
+2 −0
Original line number Diff line number Diff line
@@ -126,6 +126,8 @@ public:
                                  std::vector<const char*>& disabled);
    // Set the persist.graphics.egl system property value.
    void nativeToggleAngleAsSystemDriver(bool enabled);
    // Get the persist.graphics.egl system property value.
    std::string nativeGetPersistGraphicsEgl();
    bool shouldUseSystemAngle();
    bool shouldUseNativeDriver();

+4 −0
Original line number Diff line number Diff line
@@ -57,6 +57,9 @@ public:
    // sets ANGLE as system GLES driver if enabled==true by setting persist.graphics.egl to true.
    virtual void toggleAngleAsSystemDriver(bool enabled) = 0;

    // gets persist.graphics.egl value
    virtual std::string getPersistGraphicsEgl() = 0;

    // Get the list of features to override.
    virtual FeatureOverrides getFeatureOverrides() = 0;
};
@@ -72,6 +75,7 @@ public:
        SET_TARGET_STATS_ARRAY,
        ADD_VULKAN_ENGINE_NAME,
        GET_FEATURE_CONFIG_OVERRIDES,
        GET_PERSIST_GRAPHICS_EGL,
        // Always append new enum to the end.
    };

Loading