According the spec PulseCounterConfig.Builder.setSourceConfig must throw IAE only if sourceConfig is not null and sourceConfig's direction is not set to GPIOPinConfig.DIR_INPUT_ONLY or GPIOPinConfig.DIR_BOTH_INIT_INPUT.
Now null reference isn't taken in account so it throws NPE.
Now null reference isn't taken in account so it throws NPE.