Skip to content

Commit

Permalink
Ask user to grant INTERNET permission to app if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
elviscapiaq committed Jan 10, 2025
1 parent cdf84f0 commit b5c307e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions capture_service/dive_client_cli.cc
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,22 @@ bool list_package(Dive::DeviceManager& mgr, const std::string& device_serial)
return true;
}

std::string GetCommandOutput(const std::string& command)
{
std::string output;
std::array<char, 128> buffer;
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(command.c_str(), "r"), pclose);
if (!pipe)
{
throw std::runtime_error("popen() failed!");
}
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr)
{
output += buffer.data();
}
return output;
}

bool run_package(Dive::DeviceManager& mgr,
const std::string& app_type,
const std::string& package,
Expand Down Expand Up @@ -241,6 +257,16 @@ bool run_package(Dive::DeviceManager& mgr,
return false;
}

std::string command_query = absl::
StrFormat("adb shell dumpsys package %s | grep \"android.permission.INTERNET: granted=true\"",
package);
if (GetCommandOutput(command_query).empty())
{
std::cout << "Error: android.permission.INTERNET has to be granted in AndroidManifest file!"
<< std::endl;
return false;
}

if (app_type == "openxr")
{
ret = dev->SetupApp(package,
Expand Down

0 comments on commit b5c307e

Please sign in to comment.