Skip to content

Commit

Permalink
Add sperate retry for permission checks
Browse files Browse the repository at this point in the history
Change-Id: Ibbce02fa14a003f80a2de10ebe5e4e756168c2d5
  • Loading branch information
tjr-arm authored and baldurk committed Jan 10, 2024
1 parent 7a22f95 commit d8a0b1c
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions renderdoc/android/android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,23 +525,14 @@ RDResult InstallRenderDocServer(const rdcstr &deviceID)

RDCLOG("Installed package '%s', checking for success...", apk.c_str());

bool retryNeeded;
AndroidVersionCheckResult versionCheck = CheckAndroidServerVersion(deviceID, abi);
retryNeeded = (versionCheck != AndroidVersionCheckResult::Correct);

if(!retryNeeded)
{
AndroidInstallPermissionCheckResult permissionsCheck =
CheckAndroidServerInstallPermissions(deviceID, GetRenderDocPackageForABI(abi), apiVersion);
retryNeeded = (permissionsCheck != AndroidInstallPermissionCheckResult::Correct);
}

if(retryNeeded)
if(versionCheck != AndroidVersionCheckResult::Correct)
{
RDCLOG("Failed to install APK. stdout: %s, stderr: %s",
adbInstall.strStdout.trimmed().c_str(), adbInstall.strStderror.trimmed().c_str());
RDCLOG("Retrying...");
InstallAPK(deviceID, apk, apiVersion);
adbExecCommand(deviceID, "install -r \"" + apk + "\"");

versionCheck = CheckAndroidServerVersion(deviceID, abi);

Expand Down Expand Up @@ -570,13 +561,26 @@ RDResult InstallRenderDocServer(const rdcstr &deviceID)
// verify the install properly.
result = ResultCode::AndroidAPKVerifyFailed;
}
}

// Only verify permissions if we are otherwise happy with the installation
if(result != ResultCode::AndroidAPKVerifyFailed)
{
AndroidInstallPermissionCheckResult permissionsCheck =
CheckAndroidServerInstallPermissions(deviceID, GetRenderDocPackageForABI(abi), apiVersion);
if(permissionsCheck != AndroidInstallPermissionCheckResult::Correct)
{
RDCWARN("Failed to verify APK installation permissions after retry.");
result = ResultCode::AndroidAPKVerifyFailed;
RDCWARN("Failed to verify APK installation permissions. Retrying...");
// Some devices will only grant permissions with a second installation attempt
InstallAPK(deviceID, apk, apiVersion);
// Check permission and version again - version was correct last time so should ok here
if((CheckAndroidServerVersion(deviceID, abi) != AndroidVersionCheckResult::Correct) ||
(CheckAndroidServerInstallPermissions(deviceID, GetRenderDocPackageForABI(abi), apiVersion) !=
AndroidInstallPermissionCheckResult::Correct))
{
RDCWARN("Failed to verify APK installation");
result = ResultCode::AndroidAPKVerifyFailed;
}
}
}
}
Expand Down

0 comments on commit d8a0b1c

Please sign in to comment.