Skip to content

Commit

Permalink
Add null check and logs for around device active use case.
Browse files Browse the repository at this point in the history
In a small subset of devices, we are seeing the device active use case
not being defined. This CL adds a layer of validation to ensure its
definition before use.

BUG=chromium:1405615

(cherry picked from commit ac62487)

Change-Id: I0f9becc25cea976aaef0a34681947e1527d6b3e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4144369
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Hirthanan Subenderan <hirthanan@google.com>
Cr-Original-Commit-Position: refs/heads/main@{#1090443}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4148927
Auto-Submit: Hirthanan Subenderan <hirthanan@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/branch-heads/5481@{#188}
Cr-Branched-From: 130f3e4-refs/heads/main@{#1084008}
  • Loading branch information
Hirthanan Subenderan authored and Chromium LUCI CQ committed Jan 9, 2023
1 parent 134c052 commit a1784d7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ DeviceActiveUseCase::DeviceActiveUseCase(
statistics_provider_(
chromeos::system::StatisticsProvider::GetInstance()) {
DCHECK(psm_delegate_);
DCHECK(local_state_);
}

DeviceActiveUseCase::~DeviceActiveUseCase() = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,17 @@ void DeviceActivityClient::OnGetLastPingDatesStatusFetched(
GetUseCasePtr(psm_rlwe::RlweUseCase::CROS_FRESNEL_FIRST_ACTIVE);
break;
default:
VLOG(1) << "PSM use case is not supported yet.";
LOG(ERROR) << "PSM use case is not supported yet.";
continue;
}

// Crashes may occur due to device_active_use_case_ptr not being defined
// at this point.
if (device_active_use_case_ptr == nullptr) {
LOG(ERROR) << "Device active use case is not defined.";
return;
}

if (!device_active_use_case_ptr->IsLastKnownPingTimestampSet()) {
RecordPreservedFileState(
DeviceActivityClient::PreservedFileState::kReadOkLocalStateEmpty);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ DeviceActivityController::DeviceActivityController(
DeviceActivityClient::DeviceActivityMethod::
kDeviceActivityControllerConstructor);

DCHECK(local_state);
DCHECK(!g_ash_device_activity_controller);
g_ash_device_activity_controller = this;

Expand Down

0 comments on commit a1784d7

Please sign in to comment.