android: Improve workflow on devices with root

During initial scan of application, detect if root access is available
and track it.  If user later selects "Click here for ways to fix this".
display a new dialogue that offers to push the layer directly.

If pushing fails, fall back to production dialogue.

Also add a new persistent setting to enable automatic layer pushing.
This commit is contained in:
Cody Northrop
2017-08-07 14:41:36 -06:00
committed by Baldur Karlsson
parent 6c40e4e651
commit fb8eef23d0
8 changed files with 149 additions and 11 deletions
+97 -9
View File
@@ -423,8 +423,8 @@ void CaptureDialog::vulkanLayerWarn_mouseClick()
void CaptureDialog::CheckAndroidSetup(QString &filename)
{
ui->androidWarn->setVisible(false);
ui->androidScan->setVisible(true);
ui->androidWarn->setVisible(false);
LambdaThread *scan = new LambdaThread([this, filename]() {
@@ -466,6 +466,7 @@ void CaptureDialog::androidWarn_mouseClick()
bool missingPermissions = bool(m_AndroidFlags & AndroidFlags::MissingPermissions);
bool missingLibrary = bool(m_AndroidFlags & AndroidFlags::MissingLibrary);
bool rootAccess = bool(m_AndroidFlags & AndroidFlags::RootAccess);
if(missingPermissions)
{
@@ -481,21 +482,107 @@ void CaptureDialog::androidWarn_mouseClick()
msg +=
tr("<b>Missing library</b><br>"
"The RenderDoc library must be present in the "
"installed application.<br><br>"
"To fix this, you should repackage the APK following guidelines on the "
"<a href='http://github.com/baldurk/renderdoc/wiki/Android-Support'>"
"RenderDoc Wiki</a><br><br>");
"installed application.<br><br>");
}
if(missingPermissions)
{
// Don't prompt for patching if anything other than library is missing
// Don't prompt for patching if permissions are wrong - we can't fix that
RDDialog::critical(this, caption, msg);
return;
}
else
// Track whether we tried to push layer directly, to influence text
bool triedPush = false;
// Track whether to continue with push suggestion dialogue, in case user clicked Cancel
bool suggestPatch = true;
if(rootAccess)
{
// Check whether user has requested automatic pushing
bool autoPushConfig = m_Ctx.Config().Android_AutoPushLayerToApp;
// Separately, track whether the persistent checkBox is selected
bool autoPushCheckBox = autoPushConfig;
QMessageBox::StandardButton prompt = QMessageBox::No;
// Only display initial prompt if user has not chosen to push automatically
if(!autoPushConfig)
{
QString rootmsg = msg;
rootmsg +=
tr("Your device appears to have <b>root access</b>. If you are only targeting Vulkan, "
"RenderDoc can try to push the layer directly to your application.<br><br>"
"Would you like RenderDoc to push the layer?<br>");
QString checkMsg(lit("Automatically push the layer on rooted devices"));
QCheckBox *cb = new QCheckBox(checkMsg, this);
cb->setChecked(autoPushCheckBox);
prompt = RDDialog::questionChecked(this, caption, rootmsg, cb, autoPushCheckBox,
RDDialog::YesNoCancel);
}
if(autoPushConfig || prompt == QMessageBox::Yes)
{
bool pushSucceeded = false;
triedPush = true;
// Only update the autoPush setting if Yes was clicked
if(autoPushCheckBox != m_Ctx.Config().Android_AutoPushLayerToApp)
{
m_Ctx.Config().Android_AutoPushLayerToApp = autoPushCheckBox;
m_Ctx.Config().Save();
}
// Call into layer push routine, then continue
LambdaThread *push = new LambdaThread([this, exe, &pushSucceeded]() {
QByteArray hostnameBytes = m_Ctx.Replay().CurrentRemote()->Hostname.toUtf8();
if(RENDERDOC_PushLayerToAndroidApp(hostnameBytes.data(), exe.toUtf8().data()))
{
// Sucess!
pushSucceeded = true;
RDDialog::information(
this, tr("Push succeeded!"),
tr("The push attempt succeeded and %1 now contains the RenderDoc layer").arg(exe));
}
});
push->start();
if(push->isRunning())
{
ShowProgressDialog(this, tr("Pushing layer to %1, please wait...").arg(exe),
[push]() { return !push->isRunning(); });
}
push->deleteLater();
if(pushSucceeded)
{
// We should be good from here, no futher prompts
suggestPatch = false;
ui->androidWarn->setVisible(false);
}
}
else if(prompt == QMessageBox::Cancel)
{
// Cancel skips any other fix prompts
suggestPatch = false;
}
}
if(suggestPatch)
{
if(triedPush)
msg.insert(0, tr("The push attempt failed, so other methods must be used to fix the missing "
"layer.<br><br>"));
msg +=
tr("If you are only targeting Vulkan, RenderDoc can try to add the layer for you, "
tr("To fix this, you should repackage the APK following guidelines on the "
"<a href='http://github.com/baldurk/renderdoc/wiki/Android-Support'>"
"RenderDoc Wiki</a><br><br>"
"If you are only targeting Vulkan, RenderDoc can try to <b>add the layer for you</b>, "
"which requires pulling the APK, patching it, uninstalling the original, and "
"installing the modified version with a debug key. "
"This works for many debuggable applications, but not all, especially those that "
@@ -506,7 +593,8 @@ void CaptureDialog::androidWarn_mouseClick()
"</a> to get them.<br><br>"
"Would you like RenderDoc to try patching your APK?");
QMessageBox::StandardButton prompt = RDDialog::question(this, caption, msg);
QMessageBox::StandardButton prompt =
RDDialog::question(this, caption, msg, RDDialog::YesNoCancel);
if(prompt == QMessageBox::Yes)
{