Merge "Handle null safety source id list in broadcast receiver."
This commit is contained in:
committed by
Android (Google) Code Review
commit
a1bb6057b4
@@ -33,8 +33,9 @@ public class SafetySourceBroadcastReceiver extends BroadcastReceiver {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImmutableList<String> sourceIds =
|
String[] sourceIdsExtra = intent.getStringArrayExtra(EXTRA_REFRESH_SAFETY_SOURCE_IDS);
|
||||||
ImmutableList.copyOf(intent.getStringArrayExtra(EXTRA_REFRESH_SAFETY_SOURCE_IDS));
|
if (sourceIdsExtra != null && sourceIdsExtra.length > 0) {
|
||||||
|
ImmutableList<String> sourceIds = ImmutableList.copyOf(sourceIdsExtra);
|
||||||
|
|
||||||
if (sourceIds.contains(LockScreenSafetySource.SAFETY_SOURCE_ID)) {
|
if (sourceIds.contains(LockScreenSafetySource.SAFETY_SOURCE_ID)) {
|
||||||
LockScreenSafetySource.sendSafetyData(context);
|
LockScreenSafetySource.sendSafetyData(context);
|
||||||
@@ -45,3 +46,4 @@ public class SafetySourceBroadcastReceiver extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@@ -79,6 +79,16 @@ public class SafetySourceBroadcastReceiverTest {
|
|||||||
verify(mSafetyCenterManagerWrapper, never()).sendSafetyCenterUpdate(any(), any());
|
verify(mSafetyCenterManagerWrapper, never()).sendSafetyCenterUpdate(any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void sendSafetyData_whenSafetyCenterIsEnabled_withNullSourceIds_sendsNoData() {
|
||||||
|
when(mSafetyCenterStatusHolder.isEnabled(mApplicationContext)).thenReturn(true);
|
||||||
|
Intent intent = new Intent();
|
||||||
|
|
||||||
|
new SafetySourceBroadcastReceiver().onReceive(mApplicationContext, intent);
|
||||||
|
|
||||||
|
verify(mSafetyCenterManagerWrapper, never()).sendSafetyCenterUpdate(any(), any());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sendSafetyData_whenSafetyCenterIsEnabled_withNoSourceIds_sendsNoData() {
|
public void sendSafetyData_whenSafetyCenterIsEnabled_withNoSourceIds_sendsNoData() {
|
||||||
when(mSafetyCenterStatusHolder.isEnabled(mApplicationContext)).thenReturn(true);
|
when(mSafetyCenterStatusHolder.isEnabled(mApplicationContext)).thenReturn(true);
|
||||||
|
Reference in New Issue
Block a user