Skip to content

Commit 12991fe

Browse files
committed
Ask user to grant INTERNET permission to app if needed
1 parent ddf30f0 commit 12991fe

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

capture_service/dive_client_cli.cc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,22 @@ bool list_package(Dive::DeviceManager& mgr, const std::string& device_serial)
216216
return true;
217217
}
218218

219+
std::string GetCommandOutput(const std::string& command)
220+
{
221+
std::string output;
222+
std::array<char, 128> buffer;
223+
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(command.c_str(), "r"), pclose);
224+
if (!pipe)
225+
{
226+
throw std::runtime_error("popen() failed!");
227+
}
228+
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr)
229+
{
230+
output += buffer.data();
231+
}
232+
return output;
233+
}
234+
219235
bool run_package(Dive::DeviceManager& mgr,
220236
const std::string& app_type,
221237
const std::string& package,
@@ -249,6 +265,16 @@ bool run_package(Dive::DeviceManager& mgr,
249265
return false;
250266
}
251267

268+
std::string command_query = absl::
269+
StrFormat("adb shell dumpsys package %s | grep \"android.permission.INTERNET: granted=true\"",
270+
package);
271+
if (GetCommandOutput(command_query).empty())
272+
{
273+
std::cout << "Error: android.permission.INTERNET has to be granted in AndroidManifest file!"
274+
<< std::endl;
275+
return false;
276+
}
277+
252278
if (app_type == "openxr")
253279
{
254280
ret = dev->SetupApp(package,

0 commit comments

Comments
 (0)