mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-24 02:40:52 +00:00
Handle failed APK installation and patching
If "adb install" command is used with "-g" flag, we may get java.lang.SecurityException on some devices because granting runtime permissions at installation time is only allowed for system apps (however we can enable it in the device's Developer options menu). Also, pulling APK from /data/app/ may be restricted. We can workaround by copying the APK to a directory which we can access then try to pull the APK from there.
This commit is contained in:
committed by
Baldur Karlsson
parent
691c115946
commit
6c39b58d0b
@@ -451,10 +451,22 @@ bool PullAPK(const string &deviceID, const string &pkgPath, const string &apk)
|
||||
elapsed += 1000;
|
||||
}
|
||||
|
||||
RDCERR("Failed to pull APK");
|
||||
RDCLOG("Failed to pull APK");
|
||||
return false;
|
||||
}
|
||||
|
||||
void CopyAPK(const string &deviceID, const string &pkgPath, const string ©Path)
|
||||
{
|
||||
RDCLOG("Copying APK to %s", copyPath.c_str());
|
||||
adbExecCommand(deviceID, "shell cp " + pkgPath + " " + copyPath);
|
||||
}
|
||||
|
||||
void RemoveAPK(const string &deviceID, const string &path)
|
||||
{
|
||||
RDCLOG("Removing APK from %s", path.c_str());
|
||||
adbExecCommand(deviceID, "shell rm -f " + path);
|
||||
}
|
||||
|
||||
bool HasRootAccess(const std::string &deviceID)
|
||||
{
|
||||
RDCLOG("Checking for root access on %s", deviceID.c_str());
|
||||
@@ -572,7 +584,17 @@ extern "C" RENDERDOC_API AndroidFlags RENDERDOC_CC RENDERDOC_MakeDebuggablePacka
|
||||
|
||||
// Try the following steps, bailing if anything fails
|
||||
if(!Android::PullAPK(deviceID, pkgPath, origAPK))
|
||||
return AndroidFlags::ManifestPatchFailure;
|
||||
{
|
||||
// Copy the APK to public storage, then try to pull again
|
||||
std::string copyPath = "/sdcard/" + package + ".copy.apk";
|
||||
Android::CopyAPK(deviceID, pkgPath, copyPath);
|
||||
bool success = Android::PullAPK(deviceID, copyPath, origAPK);
|
||||
Android::RemoveAPK(deviceID, copyPath);
|
||||
if(!success)
|
||||
{
|
||||
return AndroidFlags::ManifestPatchFailure;
|
||||
}
|
||||
}
|
||||
|
||||
progress(0.4f);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user