Respond with null data when no screen lock.

Safety Center expects a response to the broadcast in this case.
The Settings app should respond with explicitely no data to Safety
Center rather than not respond.

Bug: 295845686
Test: atest LockScreenSafetySourceTest
Change-Id: Ibaa134b1f93304731f37444ab222b3dc628bae02
This commit is contained in:
Elliot Sisteron
2023-08-14 14:08:48 +00:00
parent 322ad6a698
commit cea9ff385a
2 changed files with 9 additions and 3 deletions

View File

@@ -63,6 +63,12 @@ public final class LockScreenSafetySource {
}
if (!screenLockPreferenceDetailsUtils.isAvailable()) {
SafetyCenterManagerWrapper.get().setSafetySourceData(
context,
SAFETY_SOURCE_ID,
/* safetySourceData= */ null,
safetyEvent
);
return;
}

View File

@@ -102,15 +102,15 @@ public class LockScreenSafetySourceTest {
}
@Test
public void setSafetySourceData_whenScreenLockIsDisabled_doesNotSetData() {
public void setSafetySourceData_whenScreenLockIsDisabled_setsNullData() {
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
when(mScreenLockPreferenceDetailsUtils.isAvailable()).thenReturn(false);
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
verify(mSafetyCenterManagerWrapper, never()).setSafetySourceData(
any(), any(), any(), any());
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), eq(null), any());
}
@Test