| 283 | }; |
| 284 | |
| 285 | AndroidVersionCheckResult CheckAndroidServerVersion(const rdcstr &deviceID, ABI abi) |
| 286 | { |
| 287 | // assume all servers are updated at the same rate. Only check first ABI's version |
| 288 | rdcstr packageName = GetRenderDocPackageForABI(abi); |
| 289 | RDCLOG("Checking installed version of %s on %s", packageName.c_str(), deviceID.c_str()); |
| 290 | |
| 291 | rdcstr dump = adbExecCommand(deviceID, "shell pm dump " + packageName).strStdout; |
| 292 | if(dump.empty()) |
| 293 | { |
| 294 | RDCWARN("Unable to pm dump %s", packageName.c_str()); |
| 295 | return AndroidVersionCheckResult::NotInstalled; |
| 296 | } |
| 297 | |
| 298 | rdcstr versionCode = GetFirstMatchingLine(dump, "versionCode=").trimmed(); |
| 299 | rdcstr versionName = GetFirstMatchingLine(dump, "versionName=").trimmed(); |
| 300 | |
| 301 | // versionCode is not alone in this line, isolate it |
| 302 | if(versionCode != "") |
| 303 | { |
| 304 | int32_t spaceOffset = versionCode.find(' '); |
| 305 | if(spaceOffset >= 0) |
| 306 | versionCode.erase(spaceOffset, ~0U); |
| 307 | |
| 308 | versionCode.erase(0, strlen("versionCode=")); |
| 309 | } |
| 310 | else |
| 311 | { |
| 312 | RDCWARN("Unable to determine versionCode for: %s", packageName.c_str()); |
| 313 | } |
| 314 | |
| 315 | if(versionName != "") |
| 316 | { |
| 317 | versionName.erase(0, strlen("versionName=")); |
| 318 | } |
| 319 | else |
| 320 | { |
| 321 | RDCWARN("Unable to determine versionName for: %s", packageName.c_str()); |
| 322 | } |
| 323 | |
| 324 | if(versionCode.empty() && versionName.empty()) |
| 325 | return AndroidVersionCheckResult::NotInstalled; |
| 326 | |
| 327 | // Compare the server's versionCode and versionName with the host's for compatibility |
| 328 | rdcstr hostVersionCode = |
| 329 | rdcstr(STRINGIZE(RENDERDOC_VERSION_MAJOR)) + rdcstr(STRINGIZE(RENDERDOC_VERSION_MINOR)); |
| 330 | rdcstr hostVersionName = GitVersionHash; |
| 331 | |
| 332 | // False positives will hurt us, so check for explicit matches |
| 333 | if((hostVersionCode == versionCode) && (hostVersionName == versionName)) |
| 334 | { |
| 335 | RDCLOG("Installed server version (%s:%s) is compatible", versionCode.c_str(), |
| 336 | versionName.c_str()); |
| 337 | return AndroidVersionCheckResult::Correct; |
| 338 | } |
| 339 | |
| 340 | RDCWARN("RenderDoc server versionCode:versionName (%s:%s) is incompatible with host (%s:%s)", |
| 341 | versionCode.c_str(), versionName.c_str(), hostVersionCode.c_str(), hostVersionName.c_str()); |
| 342 |
no test coverage detected