Skip to content

Commit

Permalink
Updates function and variable naming
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantComm committed Dec 6, 2024
1 parent 100f667 commit d15af14
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 38 deletions.
2 changes: 1 addition & 1 deletion capture_service/android_application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ absl::Status VulkanApplication::Cleanup()
return absl::OkStatus();
}

void AndroidApplication::setGfxrEnabled(bool enable)
void AndroidApplication::SetGfxrEnabled(bool enable)
{
kGfxrEnabled = enable;
}
Expand Down
9 changes: 5 additions & 4 deletions capture_service/android_application.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ class AndroidApplication
bool IsDebuggable() const { return m_is_debuggable; }
bool IsStarted() const { return m_started; }
virtual bool IsRunning() const;
void setGfxrEnabled(bool enable);
void setArchitecture(const std::string &architecture) { m_device_architecture = architecture; };
void setFrames(const std::string &frames) { m_gfxr_capture_frames = frames; };
void setGfxrCaptureFileDirectory(const std::string &capture_file_directory)
void SetGfxrEnabled(bool enable);
void SetArchitecture(const std::string &architecture) { m_device_architecture = architecture; };
void SetFrames(const std::string &frames) { m_gfxr_capture_frames = frames; };
void SetGfxrCaptureFileDirectory(const std::string &capture_file_directory)
{
m_gfxr_capture_file_directory = capture_file_directory;
};
Expand All @@ -70,6 +70,7 @@ class AndroidApplication
ApplicationType m_type;
std::string m_main_activity;
std::string m_command_args;
// Available architectures are arm64-v8, armeabi-v7a, x86, and x86_64.
std::string m_device_architecture;
std::string m_gfxr_capture_file_directory;
std::string m_gfxr_capture_frames;
Expand Down
44 changes: 22 additions & 22 deletions capture_service/device_mgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ absl::Status AndroidDevice::SetupDevice()
RETURN_IF_ERROR(Adb().Run("shell setenforce 0"));
RETURN_IF_ERROR(Adb().Run("shell getenforce"));

if (!kGfxrEnabled)
if (!m_gfxr_enabled)
{
RETURN_IF_ERROR(
Adb().Run(absl::StrFormat("push %s %s",
Expand Down Expand Up @@ -216,7 +216,7 @@ absl::Status AndroidDevice::CleanupDevice()
RETURN_IF_ERROR(Adb().Run("shell setenforce 0"));
}

if (kGfxrEnabled)
if (m_gfxr_enabled)
{
RETURN_IF_ERROR(
Adb().Run(absl::StrFormat("shell rm %s/%s", kTargetPath, kVkGfxrLayerLibName), true));
Expand Down Expand Up @@ -248,66 +248,66 @@ absl::Status AndroidDevice::SetupApp(const std::string &package,
{
if (type == ApplicationType::VULKAN_APK)
{
app = std::make_unique<VulkanApplication>(*this, package, command_args);
m_app = std::make_unique<VulkanApplication>(*this, package, command_args);
}

else if (type == ApplicationType::OPENXR_APK)
{
app = std::make_unique<OpenXRApplication>(*this, package, command_args);
m_app = std::make_unique<OpenXRApplication>(*this, package, command_args);
}
if (app == nullptr)
if (m_app == nullptr)
{
return absl::InternalError("Failed allocate memory for AndroidApplication");
}
if (kGfxrEnabled)
if (m_gfxr_enabled)
{
app->setArchitecture(device_architecture);
app->setGfxrCaptureFileDirectory(gfxr_capture_directory);
app->setFrames(gfxr_capture_frames);
app->setGfxrEnabled(true);
m_app->SetArchitecture(device_architecture);
m_app->SetGfxrCaptureFileDirectory(gfxr_capture_directory);
m_app->SetFrames(gfxr_capture_frames);
m_app->SetGfxrEnabled(true);
}
else
{
app->setGfxrEnabled(false);
m_app->SetGfxrEnabled(false);
}
return app->Setup();
return m_app->Setup();
}

absl::Status AndroidDevice::SetupApp(const std::string &command,
const std::string &command_args,
const ApplicationType type)
{
assert(type == ApplicationType::VULKAN_CLI);
app = std::make_unique<VulkanCliApplication>(*this, command, command_args);
m_app = std::make_unique<VulkanCliApplication>(*this, command, command_args);

if (app == nullptr)
if (m_app == nullptr)
{
return absl::InternalError("Failed allocate memory for VulkanCliApplication");
}

return app->Setup();
return m_app->Setup();
}

absl::Status AndroidDevice::CleanupAPP()
{
app = nullptr;
m_app = nullptr;
return absl::OkStatus();
}

absl::Status AndroidDevice::StartApp()
{
if (app)
if (m_app)
{
return app->Start();
return m_app->Start();
}
return absl::OkStatus();
}

absl::Status AndroidDevice::StopApp()
{
if (app)
if (m_app)
{
return app->Stop();
return m_app->Stop();
}
return absl::OkStatus();
}
Expand Down Expand Up @@ -433,9 +433,9 @@ absl::Status AndroidDevice::RetrieveTrace(const std::string &trace_path,
return Adb().Run(absl::StrFormat("shell rm %s", trace_path));
}

void AndroidDevice::enableGfxr(bool enableGfxr)
void AndroidDevice::EnableGfxr(bool enable_gfxr)
{
kGfxrEnabled = enableGfxr;
m_gfxr_enabled = enable_gfxr;
}

} // namespace Dive
10 changes: 5 additions & 5 deletions capture_service/device_mgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class AndroidDevice
absl::Status Init();
absl::Status SetupDevice();
absl::Status CleanupDevice();
void enableGfxr(bool enableGfxr);
void EnableGfxr(bool enable_gfxr);

enum class PackageListOptions
{
Expand Down Expand Up @@ -95,18 +95,18 @@ class AndroidDevice
const AdbSession &Adb() const { return m_adb; }
AdbSession &Adb() { return m_adb; }

AndroidApplication *GetCurrentApplication() { return app.get(); }
AndroidApplication *GetCurrentApplication() { return m_app.get(); }
absl::Status RetrieveTrace(const std::string &trace_file_path,
const std::string &save_path,
const bool isGfxrCapture);
const bool is_gfxr_capture);

private:
const std::string m_serial;
DeviceInfo m_dev_info;
AdbSession m_adb;
DeviceState m_original_state;
std::unique_ptr<AndroidApplication> app;
bool kGfxrEnabled;
std::unique_ptr<AndroidApplication> m_app;
bool m_gfxr_enabled;
};

class DeviceManager
Expand Down
12 changes: 6 additions & 6 deletions capture_service/dive_client_cli.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ ABSL_FLAG(
std::string,
device_architecture,
"x86",
"specify the device architecture to capture with gfxr. If not specified, the default is x86.");
"specify the device architecture to capture with gfxr (arm64-v8, armeabi-v7a, x86, or x86_64). If not specified, the default is x86.");
ABSL_FLAG(std::string,
gfxr_capture_file_dir,
"gfxr_capture",
Expand Down Expand Up @@ -213,7 +213,7 @@ bool run_package(Dive::DeviceManager& mgr,
const std::string& device_architecture,
const std::string& gfxr_capture_directory,
const std::string& gfxr_capture_frames,
bool isGfxrCapture)
bool is_gfxr_capture)
{
std::string serial = absl::GetFlag(FLAGS_device);

Expand All @@ -230,7 +230,7 @@ bool run_package(Dive::DeviceManager& mgr,
return false;
}
auto dev = *dev_ret;
dev->enableGfxr(isGfxrCapture);
dev->EnableGfxr(is_gfxr_capture);
auto ret = dev->SetupDevice();
if (!ret.ok())
{
Expand Down Expand Up @@ -353,7 +353,7 @@ bool run_and_capture(Dive::DeviceManager& mgr,
const std::string& device_architecture,
const std::string& gfxr_capture_directory,
const std::string& gfxr_capture_frames,
const bool isGfxrCapture)
const bool is_gfxr_capture)
{

std::string target_str = absl::GetFlag(FLAGS_target);
Expand All @@ -365,12 +365,12 @@ bool run_and_capture(Dive::DeviceManager& mgr,
device_architecture,
gfxr_capture_directory,
gfxr_capture_frames,
isGfxrCapture);
is_gfxr_capture);
int time_to_wait_in_seconds = absl::GetFlag(FLAGS_trigger_capture_after);
std::cout << "wait for " << time_to_wait_in_seconds << " seconds" << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(time_to_wait_in_seconds));

if (isGfxrCapture)
if (is_gfxr_capture)
{
retrieve_gfxr_capture(mgr, gfxr_capture_directory);
}
Expand Down

0 comments on commit d15af14

Please sign in to comment.