Search in sources :

Example 1 with PhoneScreenInteractionEventBuilder

use of com.zendrive.sdk.testing.mockdrive.PhoneScreenInteractionEventBuilder in project zendrive-sdk-android-sample by zendrive.

the class MockDriveLayoutHandler method simulateCustomMockDrive.

/**
 * To create a completely new MockDrive from scratch use the MockDrive.Builder API.
 */
private MockZendriveOperationResult simulateCustomMockDrive(Context context) {
    long driveStartTimestamp = 1543870794382L;
    long driveEndTimestamp = 1543871176352L;
    ArrayList<LocationPointWithTimestamp> waypoints = new ArrayList<>();
    LocationPoint startLocationPoint = new LocationPoint(27.4293013, -82.5636051);
    LocationPoint endLocationPoint = new LocationPoint(27.4265938, -82.5306409);
    LocationPoint hardTurnStartLocation = new LocationPoint(27.429106, -82.530999);
    LocationPoint hardTurnEndLocation = new LocationPoint(27.428820, -82.530591);
    LocationPoint collisionLocation = new LocationPoint(27.427161, -82.530617);
    LocationPoint aggressiveAccelerationLocation = new LocationPoint(27.429283, -82.546828);
    LocationPoint hardBrakeLocation = new LocationPoint(27.429312, -82.548994);
    LocationPoint phoneHandlingStartLocation = new LocationPoint(27.427824, -82.530598);
    LocationPoint phoneHandlingEndLocation = new LocationPoint(27.426933, -82.530628);
    LocationPoint speedingStartLocationPoint = new LocationPoint(27.429316, -82.559140);
    LocationPoint speedingEndLocationPoint = new LocationPoint(27.429290, -82.557029);
    LocationPoint phoneScreenInteractionStartLocation = new LocationPoint(27.429330, -82.562356);
    LocationPoint phoneScreenInteractionEndLocation = new LocationPoint(27.429259, -82.560129);
    LocationPoint stopSignViolationLocationPoint = new LocationPoint(27.429191, -82.540527);
    waypoints.add(new LocationPointWithTimestamp(startLocationPoint, driveStartTimestamp));
    waypoints.add(new LocationPointWithTimestamp(phoneScreenInteractionStartLocation, 1543870802367L));
    waypoints.add(new LocationPointWithTimestamp(phoneScreenInteractionEndLocation, 1543870815396L));
    waypoints.add(new LocationPointWithTimestamp(speedingStartLocationPoint, 1543870828368L));
    waypoints.add(new LocationPointWithTimestamp(speedingEndLocationPoint, 1543870846391L));
    waypoints.add(new LocationPointWithTimestamp(hardBrakeLocation, 1543871082354L));
    waypoints.add(new LocationPointWithTimestamp(aggressiveAccelerationLocation, 1543871124370L));
    waypoints.add(new LocationPointWithTimestamp(stopSignViolationLocationPoint, 1543871128383L));
    waypoints.add(new LocationPointWithTimestamp(hardTurnStartLocation, 1543871132397L));
    waypoints.add(new LocationPointWithTimestamp(hardTurnEndLocation, 1543871142367L));
    waypoints.add(new LocationPointWithTimestamp(phoneHandlingStartLocation, 1543871149359L));
    waypoints.add(new LocationPointWithTimestamp(phoneHandlingEndLocation, 1543871159381L));
    waypoints.add(new LocationPointWithTimestamp(collisionLocation, 1543871167418L));
    waypoints.add(new LocationPointWithTimestamp(endLocationPoint, driveEndTimestamp));
    MockEventBuilder aggressiveAccelerationEventBuilder = new AggressiveAccelerationEventBuilder(1543871082354L).setLocation(aggressiveAccelerationLocation).setSeverity(ZendriveEventSeverity.HIGH);
    MockEventBuilder collisionEventBuilder = new CollisionEventBuilder(1543871082354L, driveStartTimestamp, "accidentId", ZendriveAccidentConfidence.HIGH, 70, ZendriveVehicleType.CAR, ZendriveCollisionSeverity.HIGH).setLocation(collisionLocation);
    MockEventBuilder hardBrakeEventBuilder = new HardBrakeEventBuilder(1543871082354L).setLocation(hardBrakeLocation).setSeverity(ZendriveEventSeverity.LOW);
    MockEventBuilder speedingEventBuilder = new SpeedingEventBuilder(1543871124370L, 1543871132397L).setSpeedingInfo(35, 40, 25).setLocation(speedingStartLocationPoint, speedingEndLocationPoint).setSeverity(ZendriveEventSeverity.NOT_AVAILABLE);
    MockEventBuilder phoneScreenInteractionEventBuilder = new PhoneScreenInteractionEventBuilder(1543871124370L, 1543871132397L).setLocation(phoneScreenInteractionStartLocation, phoneScreenInteractionEndLocation).setSeverity(ZendriveEventSeverity.NOT_AVAILABLE);
    MockEventBuilder phoneHandlingEventBuilder = new PhoneHandlingEventBuilder(1543871124370L, 1543871132397L).setLocation(phoneHandlingStartLocation, phoneHandlingEndLocation).setSeverity(ZendriveEventSeverity.NOT_AVAILABLE);
    MockEventBuilder hardTurnEventBuilder = new HardTurnEventBuilder(1543871124370L, 1543871132397L, ZendriveTurnDirection.RIGHT).setLocation(hardTurnStartLocation, hardTurnEndLocation).setSeverity(ZendriveEventSeverity.NOT_AVAILABLE);
    MockEventBuilder stopSignViolationEventBuilder = new StopSignViolationEventBuilder(1543871128383L).setLocation(stopSignViolationLocationPoint).setSeverity(ZendriveEventSeverity.NOT_AVAILABLE);
    ZendriveEventRatings eventRatings = new ZendriveEventRatings();
    eventRatings.aggressiveAccelerationRating = ZendriveStarRating.FOUR;
    eventRatings.hardBrakeRating = ZendriveStarRating.THREE;
    eventRatings.speedingRating = ZendriveStarRating.TWO;
    eventRatings.hardTurnRating = ZendriveStarRating.FOUR;
    eventRatings.phoneHandlingRating = ZendriveStarRating.FOUR;
    MockDrive.Builder builder = MockDrive.Builder.newAutoDrive(driveStartTimestamp, driveEndTimestamp).setWayPoints(waypoints).setAverageSpeed(20).setMaxSpeed(40).setDistanceMeters(100).setDriveType(ZendriveDriveType.DRIVE).setPhonePosition(PhonePosition.UNKNOWN).setUserMode(ZendriveUserMode.DRIVER).setEventRatings(eventRatings).setScore(54).addEventBuilder(aggressiveAccelerationEventBuilder).addEventBuilder(collisionEventBuilder).addEventBuilder(hardBrakeEventBuilder).addEventBuilder(speedingEventBuilder).addEventBuilder(phoneScreenInteractionEventBuilder).addEventBuilder(phoneHandlingEventBuilder).addEventBuilder(hardTurnEventBuilder).addEventBuilder(stopSignViolationEventBuilder);
    MockDrive customMockDrive = builder.build();
    return customMockDrive.simulate(context, 10);
}
Also used : HardTurnEventBuilder(com.zendrive.sdk.testing.mockdrive.HardTurnEventBuilder) ArrayList(java.util.ArrayList) LocationPoint(com.zendrive.sdk.LocationPoint) CollisionEventBuilder(com.zendrive.sdk.testing.mockdrive.CollisionEventBuilder) MockDrive(com.zendrive.sdk.testing.mockdrive.MockDrive) HardBrakeEventBuilder(com.zendrive.sdk.testing.mockdrive.HardBrakeEventBuilder) AggressiveAccelerationEventBuilder(com.zendrive.sdk.testing.mockdrive.AggressiveAccelerationEventBuilder) PhoneHandlingEventBuilder(com.zendrive.sdk.testing.mockdrive.PhoneHandlingEventBuilder) LocationPointWithTimestamp(com.zendrive.sdk.LocationPointWithTimestamp) PhoneScreenInteractionEventBuilder(com.zendrive.sdk.testing.mockdrive.PhoneScreenInteractionEventBuilder) ZendriveEventRatings(com.zendrive.sdk.ZendriveEventRatings) MockEventBuilder(com.zendrive.sdk.testing.mockdrive.MockEventBuilder) SpeedingEventBuilder(com.zendrive.sdk.testing.mockdrive.SpeedingEventBuilder) StopSignViolationEventBuilder(com.zendrive.sdk.testing.mockdrive.StopSignViolationEventBuilder)

Aggregations

LocationPoint (com.zendrive.sdk.LocationPoint)1 LocationPointWithTimestamp (com.zendrive.sdk.LocationPointWithTimestamp)1 ZendriveEventRatings (com.zendrive.sdk.ZendriveEventRatings)1 AggressiveAccelerationEventBuilder (com.zendrive.sdk.testing.mockdrive.AggressiveAccelerationEventBuilder)1 CollisionEventBuilder (com.zendrive.sdk.testing.mockdrive.CollisionEventBuilder)1 HardBrakeEventBuilder (com.zendrive.sdk.testing.mockdrive.HardBrakeEventBuilder)1 HardTurnEventBuilder (com.zendrive.sdk.testing.mockdrive.HardTurnEventBuilder)1 MockDrive (com.zendrive.sdk.testing.mockdrive.MockDrive)1 MockEventBuilder (com.zendrive.sdk.testing.mockdrive.MockEventBuilder)1 PhoneHandlingEventBuilder (com.zendrive.sdk.testing.mockdrive.PhoneHandlingEventBuilder)1 PhoneScreenInteractionEventBuilder (com.zendrive.sdk.testing.mockdrive.PhoneScreenInteractionEventBuilder)1 SpeedingEventBuilder (com.zendrive.sdk.testing.mockdrive.SpeedingEventBuilder)1 StopSignViolationEventBuilder (com.zendrive.sdk.testing.mockdrive.StopSignViolationEventBuilder)1 ArrayList (java.util.ArrayList)1