Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions capture_service/device_mgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,30 @@ absl::Status AndroidDevice::CheckAbi()
return absl::OkStatus();
}

absl::Status AndroidDevice::CheckScreenOn()
{
absl::StatusOr<std::string> grep_output =
Adb().RunAndGetResult("shell dumpsys input_method | grep mInteractive=true");
if (!grep_output.ok() || grep_output->empty())
{
return absl::FailedPreconditionError(
"Device screen is off. Please ensure the screen is on before retrying");
}
return absl::OkStatus();
}

absl::Status AndroidDevice::CheckDeviceUnlocked()
{
absl::StatusOr<std::string> grep_output =
Adb().RunAndGetResult("shell dumpsys trust | grep deviceLocked=0");
if (!grep_output.ok() || grep_output->empty())
{
return absl::FailedPreconditionError(
"Device is locked. Please ensure the device is unlocked before retrying");
}
return absl::OkStatus();
}

absl::Status AndroidDevice::RequestRootAccess()
{
RETURN_IF_ERROR(Adb().Run("root"));
Expand Down Expand Up @@ -1109,6 +1133,9 @@ absl::Status DeviceManager::RunReplayApk(const GfxrReplaySettings& settings) con
return validated_settings.status();
}

RETURN_IF_ERROR(m_device->CheckScreenOn());
RETURN_IF_ERROR(m_device->CheckDeviceUnlocked());

LOG(INFO) << "RunReplayApk(): Attempt to pin GPU clock frequency";
bool trouble_pinning_clock = false;
auto ret = adb.Run("shell setprop compositor.high_priority 0");
Expand Down
6 changes: 6 additions & 0 deletions capture_service/device_mgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ class AndroidDevice
// Uses run-as with app permissions to delete file_name from the app's own storage
absl::Status CleanupFileWithPermissions(std::string_view package, std::string_view file_name);

// Check if the device's screen is on
absl::Status CheckScreenOn();

// Check if the device is unlocked
absl::Status CheckDeviceUnlocked();

private:
explicit AndroidDevice(const std::string& serial);

Expand Down
Loading