99#include " driver_detection_manager.h"
1010#include " driver_detector.h"
1111#include " linglong/common/global/initialize.h"
12- #include " linglong/utils/cmd.h"
1312#include " linglong/utils/error/error.h"
1413#include " linglong/utils/gettext.h"
1514#include " tl/expected.hpp"
@@ -86,41 +85,6 @@ linglong::utils::error::Result<DriverDetectionConfigManager> setupConfigManager(
8685 return configManager;
8786}
8887
89- linglong::utils::error::Result<void >
90- installDriverPackage (const std::vector<GraphicsDriverInfo> &drivers)
91- {
92- LINGLONG_TRACE (" installDriverPackage" )
93-
94- try {
95- for (const auto &driverInfo : drivers) {
96- LogD (" Processing driver: Identify={}, Version={}, Package={}, Installed={}" ,
97- driverInfo.identify ,
98- driverInfo.version ,
99- driverInfo.packageName ,
100- driverInfo.isInstalled );
101-
102- if (driverInfo.isInstalled ) {
103- LogD (" Driver package is already installed: {}" , driverInfo.packageName );
104- continue ;
105- }
106-
107- // Execute ll-cli install command to install the package
108- auto ret = linglong::utils::Cmd (" ll-cli" ).exec ({ " install" , driverInfo.packageName });
109- if (!ret) {
110- return LINGLONG_ERR (" Installation command failed: " + ret.error ().message ());
111- }
112-
113- LogD (" Driver package installation command executed successfully: {}" , *ret);
114- }
115-
116- return LINGLONG_OK;
117- } catch (const std::exception &e) {
118- return LINGLONG_ERR (" Failed to install driver package: " + std::string (e.what ()));
119- }
120-
121- return LINGLONG_OK;
122- }
123-
12488} // namespace
12589
12690int main (int argc, char *argv[])
@@ -191,7 +155,7 @@ int main(int argc, char *argv[])
191155 DriverDetectionManager detectionManager;
192156
193157 // Run driver detection and handling for all available drivers
194- auto result = detectionManager.detectAllDrivers ();
158+ auto result = detectionManager.detectAvailableDrivers ();
195159
196160 if (!result) {
197161 LogF (" Driver detection failed: {}" , result.error ().message ());
@@ -201,8 +165,8 @@ int main(int argc, char *argv[])
201165
202166 const auto &detectionResult = *result;
203167
204- if (! detectionResult.hasAvailableDrivers () ) {
205- std::cout << " No available graphics drivers detected or already installed " << std::endl ;
168+ if (detectionResult.size () == 0 ) {
169+ LogD ( " No graphics drivers detected that require installation or upgrade " ) ;
206170 return 0 ;
207171 }
208172
@@ -211,22 +175,21 @@ int main(int argc, char *argv[])
211175 " will be performed."
212176 << std::endl;
213177 std::cout << " Detected drivers:" << std::endl;
214- for (const auto &driverInfo : detectionResult. detectedDrivers ) {
178+ for (const auto &info : detectionResult) {
215179 std::cout << " ----------------------------------------" << std::endl;
216- std::cout << " Identify: " << driverInfo.identify << std::endl;
217- std::cout << " Version: " << driverInfo.version << std::endl;
218- std::cout << " Package: " << driverInfo.packageName << std::endl;
219- std::cout << " Installed: " << (driverInfo.isInstalled ? " Yes" : " No" ) << std::endl;
180+ std::cout << " Identify: " << info.identify << std::endl;
181+ std::cout << " Version: " << info.packageVersion << std::endl;
182+ std::cout << " Package: " << info.packageName << std::endl;
220183 std::cout << " ----------------------------------------" << std::endl;
221184 }
222185 return 0 ;
223186 }
224187
225- LogD (" Detected {} graphics driver(s)" , detectionResult.detectedDrivers . size ());
188+ LogD (" Detected {} graphics driver(s)" , detectionResult.size ());
226189
227190 if (options.installOnly ) {
228191 std::cout << " Install-only: installing detected drivers without notifications" << std::endl;
229- auto installResult = installDriverPackage (detectionResult. detectedDrivers );
192+ auto installResult = detectionManager. installDriverPackage (detectionResult);
230193 if (!installResult) {
231194 LogW (" Failed to install driver package {}: {}" ,
232195 options.packageName ,
@@ -270,7 +233,7 @@ int main(int argc, char *argv[])
270233 if (response.action == kActionInstallNow && response.success ) {
271234 LogD (" User chose to install graphics driver" );
272235
273- auto installResult = installDriverPackage (detectionResult. detectedDrivers );
236+ auto installResult = detectionManager. installDriverPackage (detectionResult);
274237 if (!installResult) {
275238 LogW (" Failed to install driver package: {}" , installResult.error ().message ());
276239 return 1 ;
0 commit comments