Android: Fix passing binary data through pipe on Windows

Passing binary data through a pipe may break as soon it hits
a control sequence. Encode binary data before piping and
decode it on the device before writing to file.

Fixes: QTCREATORBUG-21547
Change-Id: Iddef5582631575fdd2091c3795d2468be10b8c74
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Christian Stenger
2018-11-21 15:23:08 +01:00
committed by Eike Ziller
parent ca7c534e58
commit 069ac16e19

View File

@@ -278,7 +278,8 @@ bool AndroidRunnerWorker::uploadFile(const QString &from, const QString &to, con
if (!f.open(QIODevice::ReadOnly))
return false;
runAdb({"shell", "run-as", m_packageName, "rm", to});
auto res = runAdb({"shell", "run-as", m_packageName, QString("sh -c 'cat > %1'").arg(to)}, 60, f.readAll());
const QByteArray data = f.readAll();
const bool res = runAdb({"shell", "run-as", m_packageName, QString("sh -c 'base64 -d > %1'").arg(to)}, 60, data.toBase64());
if (!res)
return false;
return runAdb({"shell", "run-as", m_packageName, "chmod", flags, to});