use of com.android.internal.telephony.nitz.NitzSignalInputFilterPredicateFactory.TrivalentPredicate in project android_frameworks_opt_telephony by LineageOS.
the class NitzSignalInputFilterPredicateFactoryTest method testTrivalentPredicate_rateLimitCheck_offsetDifference.
@Test
public void testTrivalentPredicate_rateLimitCheck_offsetDifference() {
Scenario scenario = UNIQUE_US_ZONE_SCENARIO1;
int nitzSpacingThreshold = mFakeDeviceState.getNitzUpdateSpacingMillis();
NitzData baseNitzData = scenario.createNitzData();
TrivalentPredicate triPredicate = createRateLimitCheck(mFakeDeviceState);
long baseElapsedRealtimeMillis = mFakeDeviceState.elapsedRealtime();
TimestampedValue<NitzData> baseSignal = new TimestampedValue<>(baseElapsedRealtimeMillis, baseNitzData);
// Create a new NitzSignal that should be filtered.
int elapsedTimeIncrement = nitzSpacingThreshold - 1;
TimestampedValue<NitzData> intermediateNitzSignal = createIncrementedNitzSignal(baseSignal, elapsedTimeIncrement);
NitzData intermediateNitzData = intermediateNitzSignal.getValue();
assertFalse(triPredicate.mustProcessNitzSignal(baseSignal, intermediateNitzSignal));
// Two signals spaced apart so that the second would be filtered, but they contain different
// offset information so should be detected as "different" and processed.
{
// Modifying the local offset should be enough to recognize the NitzData as different.
NitzData differentOffsetNitzData = NitzData.createForTests(intermediateNitzData.getLocalOffsetMillis() + 1, intermediateNitzData.getDstAdjustmentMillis(), intermediateNitzData.getCurrentTimeInMillis(), intermediateNitzData.getEmulatorHostTimeZone());
TimestampedValue<NitzData> differentOffsetSignal = new TimestampedValue<>(baseSignal.getReferenceTimeMillis() + elapsedTimeIncrement, differentOffsetNitzData);
assertTrue(triPredicate.mustProcessNitzSignal(baseSignal, differentOffsetSignal));
}
}
use of com.android.internal.telephony.nitz.NitzSignalInputFilterPredicateFactory.TrivalentPredicate in project android_frameworks_opt_telephony by LineageOS.
the class NitzSignalInputFilterPredicateFactoryTest method testTrivalentPredicate_rateLimitCheck_elapsedRealtime.
@Test
public void testTrivalentPredicate_rateLimitCheck_elapsedRealtime() {
Scenario scenario = UNIQUE_US_ZONE_SCENARIO1;
int nitzSpacingThreshold = mFakeDeviceState.getNitzUpdateSpacingMillis();
NitzData baseNitzData = scenario.createNitzData();
TrivalentPredicate triPredicate = createRateLimitCheck(mFakeDeviceState);
long baseElapsedRealtimeMillis = mFakeDeviceState.elapsedRealtime();
TimestampedValue<NitzData> baseSignal = new TimestampedValue<>(baseElapsedRealtimeMillis, baseNitzData);
// Two identical signals: no spacing so the new signal should not be processed.
{
assertFalse(triPredicate.mustProcessNitzSignal(baseSignal, baseSignal));
}
// Two signals not spaced apart enough: the new signal should not processed.
{
int elapsedTimeIncrement = nitzSpacingThreshold - 1;
TimestampedValue<NitzData> newSignal = createIncrementedNitzSignal(baseSignal, elapsedTimeIncrement);
assertFalse(triPredicate.mustProcessNitzSignal(baseSignal, newSignal));
}
// Two signals spaced apart: the new signal should be processed.
{
int elapsedTimeIncrement = nitzSpacingThreshold + 1;
TimestampedValue<NitzData> newSignal = createIncrementedNitzSignal(baseSignal, elapsedTimeIncrement);
assertTrue(triPredicate.mustProcessNitzSignal(baseSignal, newSignal));
}
}
use of com.android.internal.telephony.nitz.NitzSignalInputFilterPredicateFactory.TrivalentPredicate in project android_frameworks_opt_telephony by LineageOS.
the class NitzSignalInputFilterPredicateFactoryTest method testTrivalentPredicate_bogusElapsedRealtimeCheck.
@Test
public void testTrivalentPredicate_bogusElapsedRealtimeCheck() {
Scenario scenario = UNIQUE_US_ZONE_SCENARIO1;
long elapsedRealtimeClock = mFakeDeviceState.elapsedRealtime();
TimestampedValue<NitzData> nitzSignal = scenario.createNitzSignal(elapsedRealtimeClock);
TrivalentPredicate triPredicate = createBogusElapsedRealtimeCheck(mContext, mFakeDeviceState);
assertNull(triPredicate.mustProcessNitzSignal(null, nitzSignal));
// Any signal that claims to be from the future must be rejected.
TimestampedValue<NitzData> bogusNitzSignal = new TimestampedValue<>(elapsedRealtimeClock + 1, nitzSignal.getValue());
assertFalse(triPredicate.mustProcessNitzSignal(null, bogusNitzSignal));
}
use of com.android.internal.telephony.nitz.NitzSignalInputFilterPredicateFactory.TrivalentPredicate in project android_frameworks_opt_telephony by LineageOS.
the class NitzSignalInputFilterPredicateFactoryTest method testNitzSignalInputFilterPredicateImpl_nullIsIgnored.
@Test
public void testNitzSignalInputFilterPredicateImpl_nullIsIgnored() {
Scenario scenario = UNIQUE_US_ZONE_SCENARIO1;
TimestampedValue<NitzData> nitzSignal = scenario.createNitzSignal(mFakeDeviceState.elapsedRealtime());
TrivalentPredicate nullPredicate = (x, y) -> null;
TrivalentPredicate[] triPredicates = { nullPredicate };
NitzSignalInputFilterPredicateImpl impl = new NitzSignalInputFilterPredicateImpl(triPredicates);
assertTrue(impl.mustProcessNitzSignal(null, nitzSignal));
}
use of com.android.internal.telephony.nitz.NitzSignalInputFilterPredicateFactory.TrivalentPredicate in project android_frameworks_opt_telephony by LineageOS.
the class NitzSignalInputFilterPredicateFactoryTest method testTrivalentPredicate_noOldSignalCheck.
@Test
public void testTrivalentPredicate_noOldSignalCheck() {
Scenario scenario = UNIQUE_US_ZONE_SCENARIO1;
TimestampedValue<NitzData> nitzSignal = scenario.createNitzSignal(mFakeDeviceState.elapsedRealtime());
TrivalentPredicate triPredicate = NitzSignalInputFilterPredicateFactory.createNoOldSignalCheck();
assertTrue(triPredicate.mustProcessNitzSignal(null, nitzSignal));
assertNull(triPredicate.mustProcessNitzSignal(nitzSignal, nitzSignal));
}
Aggregations